[Haskell-cafe] Re: Newbie question

Derek Elkins derek.a.elkins at gmail.com
Mon Jan 21 15:55:51 EST 2008


On Mon, 2008-01-21 at 22:36 +0100, Peter Verswyvelen wrote:
> Hey, I knew about the forall (I use that to represent OO style
> collections, very handy), but not about the exists. Thanks. But GHC
> 6.8.2 (with -fglasgow-exts) does not seem to accept this "exists"
> keyword? 

That's because it isn't GHC syntax, Stefan was just using for
demonstration purposes.  (However, I think HBC does accept free
existentials.)  GHC does support local existentials (with two different
syntaxes) and that's what you are probably using to make your "OO style
collections".  When you write:
data Foo = forall a.Foo (Num a => a)
this is an -existential-.
The type of (the data constructor) Foo is:
Foo :: forall a.(Num a => a) -> Foo
The rules of logic give:
Foo :: (exists a.Num a => a) -> Foo
note the change in scoping and compare this to local universal
quantification:
data Foo = Foo (forall a.Num a => a)
Foo :: (forall a.Num a => a) -> Foo



More information about the Haskell-Cafe mailing list