Add support for MonadFail in desugaring of do-notation
In ghc-8.6 and later do (a,b) <- action; return b
has type Monad m => m a
(Pattern match cannot fail)
and do (1,b) <- action; return b
has type MonadFail m => m a
(Pattern match can fail)
but action >>= \(1,b) -> return b
has type Monad m => m a
Issues:
- Without MonadFail the second and third example could be considered equivalent, with MonadFail they are not.
But even now, the second example would have been equal to
fail
if the pattern match failed, whereas the second would have been a "non-exhaustive pattern match".
Edited by Kai Prott