On Fri, Jun 5, 2009 at 6:38 PM, wren ng thornton<w...@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:

http://community.haskell.org/~aslatter/code/parsec/with_class/

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.

Antoine
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to