[Haskell-cafe] upgrading mtl1 to mtl2

Ross Paterson ross at soi.city.ac.uk
Wed Feb 16 16:01:02 CET 2011


On Tue, Feb 15, 2011 at 07:46:29PM -0800, Evan Laforge wrote:
> 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?

If you're using Monad m to get Functor or Applicative instances for a
functor built from m, then I'm afraid you will need to add (Functor m)
or (Applicative m) to the constraints in most cases.

> 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?

monads-fd is deprecated is favour of mtl-2, but transformers isn't.
Now you have a choice: use the portable transformers or the functional
dependencies of mtl.  Either choice is compatible with other packages,
because both ultimately rest on transformers.

> 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"?

Good point -- I've added such a caveat.



More information about the Haskell-Cafe mailing list