-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get Type of a microstate? #273
Comments
microstate.constructor.Type |
I will test it but I believe there were some weird edge cases. Should we make |
Actually, we probably need to return the type that let light = create(TrafficLight, 'green');
light.constructor.Type //=> class GreenLight {}'
typeOf(light) //=> TrafficLight |
How do we do that? |
I'm not exactly sure how aside from making union types first-class citizens. |
Upon reflection, I think we need to have ways to access them all. We can start storing the import { typeOf } from 'microstates';
let five = create(Maybe(Number), 5);
typeOf(five) //=> Maybe<Number>
five.constructor.Type //=> Just<Number>
let anulled = five.set(null);
typeOf(anulled) //=> Maybe<Number>
annulled.constructor.Type //=> Nothing |
Worth noting that subatomic microstate rely on storing the original Type https://github.com/microstates/lab/blob/master/src/meta.js#L40-L42 So when / if this makes it into master, there will be a |
We don't have a way to get the Type of a Microstate. This makes it difficult when I want to be able to serialize a Microstate where the microstate went through a few transitions. Especially when the microstate might have gone a type change via
set
. We havemetaOf
,valueOf
but nottypeOf
.The text was updated successfully, but these errors were encountered: