[Haskell-cafe] An interesting monad: "Prompt"

Ryan Ingram ryani.spam at gmail.com
Sun Nov 25 12:59:59 EST 2007


Also, I didn't realize this at first, but in order to use any of the
MonadTrans instances, like having StateT s (Prompt p) automatically be a
MonadPrompt, you sadly also need "-fallow-overlapping-instances".

This is because MonadTrans monads looks a lot like Prompt.

arbitrary MonadTrans monad:
  t (m :: * -> *) (a :: *)
Prompt:
  Prompt (p :: * -> *) (a :: *)

Since you can substitute "Prompt" for t and rename m to p, they look like
they match the some of the same types to the compiler.  However, since
Prompt won't ever be declared as an instance of MonadTrans, the overlap is
safe.

The alternative is to declare all the instances you need manually:

instance MonadPrompt p (StateT s (Prompt p)) where prompt = lift . prompt
-- etc.

  -- ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071125/7e0ec3c7/attachment.htm


More information about the Haskell-Cafe mailing list