monad transformer library

Simon Peyton-Jones
Fri, 6 Jun 2003 09:14:18 +0100

You do know that in GHC (though not Hugs) you can say

	newtype Foo =3D MkFoo Baz deriving( Monad, MyClass, This, That )

That is, deriving works for arbitrary classes for newtypes, just using
the instance
for the representation type.  This greatly alleviates the pain you refer
to.  It's documented in the GHC user manual.

Mind you, it's probably no help to you because we must support Hugs and
nhc here


| -----Original Message-----
| From: []
On Behalf Of Iavor Diatchki
| Sent: 04 June 2003 21:16
| To: Iavor Diatchki
| Cc: Ross Paterson;
| Subject: Re: monad transformer library
| hello,
| Iavor Diatchki wrote:
| >> Use of type synonyms, like
| >>
| >>     type Reader r =3D R.ReaderT r Identity
| >>
| >> is more economical, but will lead to more complex error messages.
| >
| > this is a good point and i will change that, unless anyone objects?
| i am having 2nd thoughts about that.  using newtypes will require an
| alwful lot of "fake" instances making the libarary about 2 times
| i tried to make a few errors and the error messages did not seem much
| worse with the "type" -- what happens is that "missing instances" are
| reported for the Identity monad, rather than the "Reader" monad.
| this seems reasonable as methods usually just search for the first
| that implements a given "feature", until they hit the "base case".
| newtype changes the base case from Identity to Reader, which in some
| case i think is perhaps more confusing.  any thoughts?
| bye
| iavor
| _______________________________________________
| Libraries mailing list