Proposal: Deprecate ExistentialQuantification

Niklas Broberg niklas.broberg at gmail.com
Sun Jun 28 07:17:20 EDT 2009


> I agree. But ;-) since it's obvious not possible to get rid of the classic
> syntax completely, I see no harm in having it support existentials and GADTs
> as well. In an ideal word, in which there wasn't a single Haskell program
> written yet, I'd indeed like to throw the classic syntax out altogether.

Ah, but there's the thing. The classic syntax *doesn't* support
existentials and GADTs, if by classic you mean Haskell 98. You need a
separate syntactic extension, and the one we have is ad-hoc and
unintuitive (the whole universal vs existential quantification thing
is awkward), not to mention ugly. There's simply no sense to a
declaration reading e.g.

> data Foo = forall a . (Show a) => Foo a

The entities on the right-hand side of that declaration come in the
wrong order, intuitively. What you really want or mean when you use
the classic syntax with existential quantification is

> data Foo = Foo (exists a . (Show a) => a)

Having that would make a lot more sense, and would fit well together
with the intuition of the classic syntax. If we wanted to keep support
for existential quantification together with the classic style, that
should IMNSHO be the way to do it. But for various reasons (like not
wanting to steal another keyword) we don't do it that way. Instead we
have a syntax that is meant to be understood as "constructor Foo has
the type forall a . (Show a) => a". But that's exactly what we would
express with the GADT-style syntax! :-)

Cheers,

/Niklas


More information about the Glasgow-haskell-users mailing list