Specification of newtype deriving

Simon Peyton-Jones simonpj at microsoft.com
Mon Apr 3 07:15:58 EDT 2006

| By the way, the description in the GHC User's Guide
| 	newtype T v1...vn = T' (S t1...tk vk+1...vn) deriving (c1...cm)
| is too restrictive in requiring that S must be a type constructor of
| the same arity as T, forbidding things like
| 	newtype Wrap m a = Wrap (m a) deriving (Monad, Eq)
| It should be
| 	newtype T v1...vn = T' (t vk+1...vn) deriving (c1...cm)
| with vk+1...vn not free in the type expression t.  It should also
| mention that T may not be recursive, unless all the classes are
| those derivable by the existing mechanism.  (There is some
| awkwardness in the overlap between the two mechanisms.)

Good point.   It turned out that the HEAD already implemented this, but
because I hadn't thought of this case, I'd missed a test in the eta-ok
test.  So there was a lurking bug.

I've fixed the documentation as you suggest too.

Thanks for pointing this out


More information about the Haskell-prime mailing list