You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to take a maybe and unwrap it by running a thunk when it's a nothing. from-just works with a plain value instead of a thunk, while from-just! doesn't let me override the nothing behavior. I can work around this easily but it seems like something that should be built in.
An #:on-nothing keyword argument to from-just! would let me do this while remaining backward compatible and not adding a third from-just function.
The text was updated successfully, but these errors were encountered:
I don’t really like this very much, but the point you raise is reasonable. I don’t want to change from-just!, though, since the whole point of it having that ! at the end is to make it scary. I don’t want to add a safe case to from-just! because I think it would dilute the evilness.
In Haskell, this obviously isn’t a problem because Haskell is lazy. (Interestingly, this is one of the areas where we probably take laziness for granted in Haskell and forget how useful it is when debating strictness vs laziness.) However, Racket is strict, so sometimes from-just isn’t right.
Perhaps we could add support to from-just for this instead of from-just!? Unfortunately, case-lambda and case-> do not support keyword arguments, but it would be possible to construct an API that semantically has this contract:
I'd like to take a
maybe
and unwrap it by running a thunk when it's anothing
.from-just
works with a plain value instead of a thunk, whilefrom-just!
doesn't let me override thenothing
behavior. I can work around this easily but it seems like something that should be built in.An
#:on-nothing
keyword argument tofrom-just!
would let me do this while remaining backward compatible and not adding a thirdfrom-just
function.The text was updated successfully, but these errors were encountered: