haskell / mtl

The Monad Transformer Library
http://www.haskell.org/haskellwiki/Monad_Transformers
Other
362 stars 63 forks source link

There is no relation between MonadFail and MonadError #59

Closed safinaskar closed 5 years ago

safinaskar commented 5 years ago

Currently there is no relation between MonadFail and MonadError. And this is bad.

What is the right way to report errors if you know that they are strings and you want to be able to catch them in pure code? Currently we have such options: Either String, MonadFail and MonadError. Either String is not very general, so we have MonadFail and MonadError. Unfortunately, they are incompatible in both ways! What to do? Well, I propose creating instance instance (MonadError String a) => MonadFail a

chessai commented 5 years ago

I'm not a fan of such overlapping instances.

I'm also not sure there should be something considered "the right way" to report errors.

I'm against this.

chessai commented 5 years ago

In GHC 8.8.1, fail will be rebindable to allow any IsString. So this idea becomes even worse IMO.

See https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0038-fail-rebindable-with-overloaded-strings.rst

chessai commented 5 years ago

Closing. If anyone thinks this would be useful, feel free to re-open/ping to re-open.