[Haskell-cafe] Re: Newbie question

Wolfgang Jeltsch g9ks157k at acme.softbase.org
Mon Jan 21 18:35:11 EST 2008


Am Montag, 21. Januar 2008 21:55 schrieb Derek Elkins:
> 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

I think you have a typo here.  The type of the data constructor should be 
this:

    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

Best wishes,
Wolfgang


More information about the Haskell-Cafe mailing list