case-identity

Simon Peyton-Jones simonpj@microsoft.com
Tue, 29 Jul 2003 08:54:36 +0100


Ahem.  What I should have said is that the list of alternatives always
covers all cases that can occur. For example in

data Foo =3D Red | Green | Blue

...case x of=20
	Red -> True
	other -> ...(case x of=20
			 Green -> ...
			 Blue -> ... ) ...

The inner case is considered exhaustive because Red can't occur.  Any
Red alternative in the inner case will be considered dead, and removed.

Simon

| -----Original Message-----
| From: glasgow-haskell-users-admin@haskell.org
[mailto:glasgow-haskell-users-admin@haskell.org]
| On Behalf Of David Sabel
| Sent: 28 July 2003 21:43
| To: glasgow-haskell-users@haskell.org
| Subject: Re: case-identity
|=20
| > In Core, the list of alternatives is always exhaustive.
|=20
| Ok, thanks.
| So I assume the "dead alternative elimination" is no longer done in
| the simplifier?
|=20
| (
| The dead alternative elimination is defined as:
|=20
|  case x of            =3D=3D=3D>     case x of
|    P1 -> E1                      P1 -> E1
|    ...                           ...
|    ci a1 ... an -> Ei            Pn -> En
|    ...                           [without ci a1 ... an -> Ei]
|    Pn -> En
|=20
| if x is not of constructor c_i
| )
|=20
| David
|=20
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users@haskell.org
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users