I know some people consider fail
to be a mistake, and I can see why. (It seems like MonadPlus was made to replace it). But as long as it is there, it seems like it would make sense for partial functions to use fail
and pure
instead of Just
and Nothing
. As this would allow you to do everything you can currently do and more, so something like safeHead
could give you the traditional Just
/Nothing
or instead you could return [x]
/[]
.
From what I have read about MonadPlus
it seems like it would be better than using fail
. But I don't know enough about it to say for sure, and it also would probably involve pulling into Prelude, which might be a good idea, but would be a larger change than just using fail
.
So I guess my question is why partial functions don't use fail
OR MonadPlus
, both seem better than using a concrete type.