[Haskell-cafe] Monad transformer responsibilities
aslatter at gmail.com
Fri Jun 5 21:45:04 EDT 2009
On Fri, Jun 5, 2009 at 6:38 PM, wren ng thornton<wren at freegeek.org> wrote:
> 4) Define a newtype of MyMonadT Parsec and declare instances of MyMonad and
> Parsec for it.
> Yes, I know Parsec is (an alias for) a data type, not a type class. But for
> the general problem, using newtype wrappers is often the best solution when
> it's possible. This is one of the reasons why it's good to define type
> classes for specialty monads rather than hard-wiring the types of functions
> to use the one concrete instance. (For instance, this is one of the things
> that rocks about the LogicT library; you can add a StateT on top of a
> MonadLogic and it all works great.)
> For the actual case of Parsec, you could try defining a GenParser class and
> giving it all the combinators as methods, but that's a good deal of work and
> may not scale to your task.
If you need a head start:
I'm not too happy with what turned out to be the class methods. But
I'd need to retire certain parts of the Parsec API to clean it up.
More information about the Haskell-Cafe