monad transformer library

Simon Peyton-Jones simonpj@microsoft.com
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

S

| -----Original Message-----
| From: libraries-admin@haskell.org [mailto:libraries-admin@haskell.org]
On Behalf Of Iavor Diatchki
| Sent: 04 June 2003 21:16
| To: Iavor Diatchki
| Cc: Ross Paterson; libraries@haskell.org
| Subject: Re: monad transformer library
|=20
| hello,
|=20
| 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?
|=20
| i am having 2nd thoughts about that.  using newtypes will require an
| alwful lot of "fake" instances making the libarary about 2 times
bigger.
| 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
layer
| that implements a given "feature", until they hit the "base case".
using
| newtype changes the base case from Identity to Reader, which in some
| case i think is perhaps more confusing.  any thoughts?
|=20
| bye
| iavor
|=20
| _______________________________________________
| Libraries mailing list
| Libraries@haskell.org
| http://www.haskell.org/mailman/listinfo/libraries