Gabriella439 / Haskell-Errors-Library

Type-safe error handling
BSD 3-Clause "New" or "Revised" License
64 stars 22 forks source link

failWithM polymorphic in the returning monad #43

Open BartAdv opened 8 years ago

BartAdv commented 8 years ago

I've stumbled upon an issue which is best described by my stackoverflow question:

http://stackoverflow.com/questions/37515246/using-failwith-with-servant-and-custom-monad-stack

One of the answers suggested rolling own helper:

(!??) :: MonadError e m => m (Maybe a) -> e -> m a
act !?? err = act >>= maybe (throwError err) return

I'm not that proficient in transformers stacks, and I bet the aim of this library is to help people like me, so what would be the chances of including thing like that? Would it supersede the existing !? or would it have to be separate helper?

Gabriella439 commented 8 years ago

Some time ago I chose not to generalize things to MonadError, but I might change my mind now