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 -> ...) anEitherValue
I propose we do something similar here via nullable
nullable :: forall a. b -> (a -> b) -> Nullable a -> b
Is your change request related to a problem? Please describe.
When writing FFI, I must always convert a
Nullable ainto aMaybe ato determine whether it isnullor not and then to unwrap the surrounding "box". While I can determine whether something isnullvianull == aValueThatMightBeNull, this only works if theahas anEqinstance. And once I know something isnull, I can only unwrap theNullableviaunsafeCoerce. I'd like to do both in the same function.Describe the solution you'd like
MaybeandEitherboth define an eliminator function (i.e. CPS pattern matching) that accounts for this:I propose we do something similar here via
nullable