[Haskell-cafe] upgrading mtl1 to mtl2

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Wed Feb 16 04:58:52 CET 2011

On 16 February 2011 14:46, Evan Laforge <qdunkan at gmail.com> wrote:
> I just got started on this because packages are starting to use mtl2.
> I had hoped it would be simple, and hopefully it is, but...
> Do I really have to add (Functor m) to the 300 or so functions with
> (Monad m) on them?  Or just not use fmap or applicative?

Use liftM instead of fmap if all of your functions are polymorphic in
the type of Monad and you don't want to bother putting in the Functor

> So I thought if it's going to be this much of a hassle I might as well
> just port to transformers, which I gather is supposed to be the future
> anyway.  But transformers is lacking the classes, and I gather they're
> in monads-tf and monads-fd.  But monads-fd says it's now deprecated
> because of the existence of mtl-2.  So what's the story?  Has
> transformers now turned around and been deprecated in favor of mtl-2?

As I understand it:

* monads-fd originally started as mtl-1 but with all the Haskell98
stuff put into a separate package called transformers (so that those
that don't need/want extensions can do so).

* mtl-2 is just a renamed monads-fd (which has since had some changes
compared to mtl-1).

* monads-tf is a Type Family version of mtl-2/monads-fd

> Should I just keep using mtl but port to mtl-2?  Or is there some
> other non-obsolete package for transformers?  This page:
> http://haskell.org/haskellwiki/Monad_Transformers
> Says that the only benefit of 'transformers' is that it's "haskell 98
> and thus more portable," but doesn't that come with the caveat that
> "only if you don't use classes and do all the lifting manually"?

Yes, but some people don't want the extensions.

There are a few other monad transformer implementations; have a look
through http://hackage.haskell.org/package/#cat:monads

Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com

More information about the Haskell-Cafe mailing list