Existentials
Jon Fairbairn
Jon.Fairbairn@cl.cam.ac.uk
Thu, 17 Apr 2003 10:47:55 +0100
On 2003-04-17 at 09:02BST "Simon Peyton-Jones" wrote:
> Many of you have grown to love existential data types, which we current
> write like this:
>
> data T = forall a. Foo a (a -> Int)
>
> Mark and I chose 'forall' rather than 'exists' to save grabbing another
> keyword from the programmer. And indeed, the type of the constructor
> Foo is
> Foo :: forall a. a -> (a->Int) -> T
>
> But every single time I explain this to someone, I find I have to make
> excuses for using the term 'forall'. I say "it really means 'exists',
> but we didn't want to lose another keyword".
>
> I have gradually concluded that our decision was a mistake.
I strongly agree. Suppose at some point we wanted to
allow something like
data T = exists t. Foo t (t -> Int) (forall x . x -> x)
the present notation would be /really/ confusing, especially
since any real example would be more complex than the above.
> Allow 'exists'
Yes.
> Deprecate 'forall' (for defining existentials, that is)
> Eventually allow only 'exists'
Is there really a need for an overlap? If, at the next
release you were to emit a special error message, rather
than a "deprecated" warning, wouldn't that prompt people to
make the change more swiftly? I suppose this would only be
acceptable if an automatic translation were provided.
Jón
--
Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk