RE: monad transformer library

You do know that in GHC (though not Hugs) you can say newtype Foo = 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 | | hello, | | Iavor Diatchki wrote: | >> Use of type synonyms, like | >> | >> type Reader r = 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 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? | | bye | iavor | | _______________________________________________ | Libraries mailing list | Libraries@haskell.org | http://www.haskell.org/mailman/listinfo/libraries

On Fri, Jun 06, 2003 at 09:14:18AM +0100, Simon Peyton-Jones wrote:
You do know that in GHC (though not Hugs) you can say
newtype Foo = 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.
I recall that you came across a glitch with the specification of this feature -- is that all sorted out now?
Mind you, it's probably no help to you because we must support Hugs and nhc here
Precisely, though Nhc is already ruled out by the multi-parameter type classes and functional dependencies used in both old and new versions of the monad libraries.

On Fri, Jun 06, 2003 at 10:19:40AM +0100, Ross Paterson wrote:
On Fri, Jun 06, 2003 at 09:14:18AM +0100, Simon Peyton-Jones wrote:
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.
I recall that you came across a glitch with the specification of this feature -- is that all sorted out now?
There is of course the obvious glitch that "the instance for the representation type" is _not_ used as is when deriving Read or Show. An understandable special case, but still a bit ugly. Lauri Alanko la@iki.fi

hello, sorry for the slow reply, i've been travelling for the last few days and now i am finally adjusting to europian time :-)
You do know that in GHC (though not Hugs) you can say
newtype Foo = MkFoo Baz deriving( Monad, MyClass, This, That )
i remember experimenting with this using one of the earlier implementations, and something didn't work when i was trying to derive multiparameter classes with functional dependencies (GHC crashed). i will give it another go using GHC 6.0 to make sure that it works. as for the library i think that we should perhaps stick with the type synonims for the time being until at least hugs supports the deriving extension. bye iavor
participants (4)
-
Iavor Diatchki
-
Lauri Alanko
-
Ross Paterson
-
Simon Peyton-Jones