[Haskell-cafe] Re: Existencial quantification and polymorphic
datatypes (actually, components...)
ChrisK
haskell at list.mightyreason.com
Tue Jan 20 13:10:42 EST 2009
> Great, thanks! I'm enlightened :)
And no one had to hit you with a stick first!
>
> But how is this:
>
> data SomeNum = forall a. SN a
>
> different from:
>
> data SomeNum = SN (forall a. a)
>
> ?
At a glance they look the same to me — but only the first is accepted by ghc.
There is also the GADT syntax:
> data SomeNum where SomeNum :: forall a. (Typeable a, Num a) => a -> SomeNum
which is accepted by ghc with the LANGUAGE GADTs extension.
The GADT is more than simple syntactic sugar, it allows for easier use this kind
of existential type.
--
Chris
More information about the Haskell-Cafe
mailing list