[Haskell-cafe] Inverting a Monad

ajb at spamcop.net ajb at spamcop.net
Wed Feb 6 18:20:13 EST 2008

G'day all.

On Feb 6, 2008 12:45 PM, Felipe Lessa <felipe.lessa at gmail.com> wrote:

>> I guess your parser is a monad transformer, so *maybe* the solution  
>>  is to require MonadError from the inner monad.

Quoting Bas van Dijk <v.dijk.bas at gmail.com>:

> Indeed my parser 'P t m a' is a monad transformer. I will try out
> requiring 'm' to have a 'MonadError' constraint and see how far I come
> with that.

I've occasionally found this useful:

class (Monad m) => MonadNegate m where
     mtrue :: m ()
     mfalse :: m ()
     mnot :: m a -> m ()

     mtrue = return ()
     mfalse = fail "False"

Andrew Bromage

More information about the Haskell-Cafe mailing list