Closed bobzhang closed 1 year ago
I've seen many people attempt to use unboxed and struggle with it (both understanding what it does and how to use it).
erase
doesn't seem particularly friendly... maybe any
?
I am highly in favour for not adding any primitive for that just yet, until we finally figured out how to proceed with the whole stdlib namespace cleanup discussion (Js
vs Js2
,..).
Can't we just create a doc in the interop section that shows how to export heterogenous arrays by introducing your own erase
binding in userspace? It doesn't look particularly hard, and adding an any
type or function in the core just makes it look weird from a marketing perspective.
@ryyppy this could certainly be done in user space and it is trivial. It is like option or result type, which can be done in user land, but you need a standard option type so people understand each other.
any
may be not a good name since it means type hole while it is not the case here, opaque
?
This is planned to be added into pervasives so should not be in conflict with Js/Js2
Since this is for JS interop, it kinda does make sense to put this under Js
(or Js2
) right? Easier to name and explain too. E.g. Js.opaque
vs opaque
the latter of which sounds misleadingly general
the concept is backend agnostics. It makes sense in native as well when you want to pack values of different types into a data collection
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
It seems this post creates more confusion than it solves: https://rescript-lang.org/blog/union-types-in-bucklescript
Note
@unboxed
has its own use cases, the idea is to avoid GADT for regular users unless they want to. Assuming we provide a function callederase
So people can write code like this:
This is still type safe and useful when you want to pass a heterogenous list of objects to the js user side, suggestions on the name of function and types?