[Haskell-cafe] Existentially-quantified constructors, Eq and Show

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Sun Dec 11 14:41:43 EST 2005


John Meacham wrote:
> PS. many, including me, feel 'forall' is a misnomer there and should be
> the keyword 'exists' instead. so just read 'foralls' that come _before_
> the type name as 'exists' in your head and it will make more sense.

I disagree. When you write

     forall a. D (P a) (Q a)

it means that there's a variant of D for all types a. It's as though you had

       D (P Bool) (Q Bool)
     | D (P String) (Q String)
     | ...

Writing exists instead would mean that there's only one version of D for 
some a, and you don't know what that a is; in that case you could only 
safely apply D to arguments of type (forall b. P b) and (forall b. Q b).

I think the problem is not with the use of forall, but with the use of the 
term "existential type". The fact that existential quantification shows up 
in discussions of this language extension is a red herring. Even Haskell 98 
has existential types in this sense, since (forall a. ([a] -> Int)) and 
((exists a. [a]) -> Int) are isomorphic.

-- Ben


More information about the Haskell-Cafe mailing list