monad transformer library (was: Re: list monad transformer)

Ross Paterson ross@soi.city.ac.uk
Wed, 4 Jun 2003 10:38:56 +0100


A few comments on your recent commit of a proposed new monad structure
(fptools/libraries/base/Control.Monad.X.*):

I never liked the old "diagonal" structure, but a lot of people use
these modules, and they'll notice the change of interface.

In the old scheme, Control.Monad.Fix was portable, and now it isn't.
(This will ripple through to my favourite module, Control.Arrow.)
I'd prefer that the MonadFix instances for the new monad transformers
be defined in the transformer modules, so they could import a portable
Fix as before.

You defined the classes in Trans, the types in Types and the instances
in the *T modules, which makes them orphan instances, I believe (cf GHC
User's Guide 4.9.8).  Why not just get rid of Types and move the type
definitions into the relevant *T modules?

Use of type synonyms, like

	type Reader r = R.ReaderT r Identity

is more economical, but will lead to more complex error messages.

Resumptions may be generalized to

	newtype ResumeT f m a   = Re { unRe :: m (Res f m a) }
	data Res f m a          = Value a | Delay (f (ResumeT f m a))

where f is a functor.