Changes around mapDefault
jvoigtlaender opened this issue · comments
The result-extra
package has some recent changes that make it so that it has functions:
Result.unwrap : b -> (a -> b) -> Result e a -> b
Result.unpack : (e -> b) -> (a -> b) -> Result e a -> b
These correspond to Maybe.mapDefault
quite closely, and in the discussion there (elm-community/result-extra#10) it was argued that mapDefault
is not a good name for this kind of functionality. Moreover, the discussion came up with potential uses for a version of Maybe.mapDefault
that has a thunk for the default value. Naming is still an issue.
Here are three proposals how the functions for Maybe
could be called. Each one has pros and cons.
Maybe.unwrap : b -> (a -> b) -> Maybe a -> b
Maybe.unpack : (() -> b) -> (a -> b) -> Maybe a -> b
or
Maybe.unwrap : b -> (a -> b) -> Maybe a -> b
Maybe.unwrapLazy : (() -> b) -> (a -> b) -> Maybe a -> b
or
Maybe.unpack : b -> (a -> b) -> Maybe a -> b
Maybe.unpackLazy : (() -> b) -> (a -> b) -> Maybe a -> b
I personally vote for the first option as I really like the consistency. I strongly disagree with the third option, the second option would be okay for me too.
My vote is against the term lazy
See #25 now. Going with the first option, as voted for above.