|
|
|
|
|
by dragonwriter
2732 days ago
|
|
> His point is that Maybe a should be composed of all the values of a, plus one more value, nil No, that's a simple union type. There are very good reasons for Maybe to be different than unions (Maybe can nest meaningfully, simple unions can't.) Maybe Maybe a is valid, and often useful, type. Of course, if you have a function of type a -> b and find out you need a more general Maybe a -> b, instead of a breaking change, you just write a wrapper function that produces the correct result for Nothing and delegates to the existing function for Some(a) and you're done without breaking existing clients. (Now, I suppose, if you're u had something like Scala implicits available, having an implicit a -> Maybe a conversion might sometimes be useful, though it does make code less clear.) |
|