-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
type: enhancementA new feature or addition.A new feature or addition.
Description
Is your change request related to a problem? Please describe.
When writing FFI, I must always convert a Nullable a into a Maybe a to determine whether it is null or not and then to unwrap the surrounding "box". While I can determine whether something is null via null == aValueThatMightBeNull, this only works if the a has an Eq instance. And once I know something is null, I can only unwrap the Nullable via unsafeCoerce. I'd like to do both in the same function.
Describe the solution you'd like
Maybe and Either both define an eliminator function (i.e. CPS pattern matching) that accounts for this:
maybe nothingValue (\valueWrappedInJust -> ...) aMaybeValue
either (\valueWrappedInLeft -> ...) (\valueWrappedInRight -> ...) anEitherValueI propose we do something similar here via nullable
nullable :: forall a. b -> (a -> b) -> Nullable a -> bgaryb
Metadata
Metadata
Assignees
Labels
type: enhancementA new feature or addition.A new feature or addition.