Haskell 98 report; D Specification of Derived Instances

Simon Peyton-Jones simonpj@microsoft.com
Tue, 29 Jan 2002 01:18:29 -0800


| Just before Section D.1 there is the sentence
|=20
| When inferring the context for the derived instances, type=20
| synonyms must be expanded out first.=20
|=20
| I don't understand it. Which type synonyms need expansion?=20

Consider
	type Foo a =3D [a]
	data T a =3D MkT (Foo a) deriving( Eq )

Then we must expand the Foo synonym when inferring the
context of the derived instance decl

	instance Eq a =3D> Eq (T a) where ...

I've tried to clarify this by saying instead:
"When inferring the context for the derived instances, type synonyms
in the constructors' argument types must be expanded out first."

| Free names in the declarations d are all defined in the=20
| Prelude; the qualifier `Prelude.' is implicit here.
|=20
| Well, `Prelude' does not necessarily refer to the builtin=20
| prelude. I suppose the sentence should actually be the same=20
| as the statement at the beginning of Chapter 3 (Expressions).

Good idea. I'll do that.

| Naturally this makes clear that it is actually impossible to=20
| correctly build a tool like DrIft. There is no safe way in=20
| Haskell to refer to the builtin prelude...

I guess you could say
	import Prelude as DriftPrelude

and then use DriftPrelude.wuggle

Of course, the programmer might be using DriftPrelude, but that would
be surprising.

Simon