r/purescript • • Apr 16 '18

Rethinking MonadError

https://lukajcb.github.io/blog/functional/2018/04/15/rethinking-monaderror.html
5 Upvotes

5 comments sorted by

View all comments

Show parent comment

2

u/natefaubion Apr 16 '18

I also think this class is interesting because it's similar in spirit to the Parallel class in PureScript.

I think I can answer my own question, in that the idea is to basically have a representation that mirrors ExceptT, where the unexceptional type just reflects the error in an Either. So in the case of Bifunctor Aff, you could have newtype UAff a = UAff (forall void. Aff void a). And changing the error type amount to rethrowing the Either in the exceptional type.

1

u/LukaJCB Apr 16 '18

Yeah, in the Scala version of this blog post I went into exactly that. :) Essentially you can wrap any MonadError inside a newtype Unexceptional f a = f a and provide only a smart constructor endeavor :: forall m e a. MonadError m e => m a -> Unexceptional m a and thus get a working instance for MonadBlunder.