explicitly quantified classes in functions

Hal Daume III hdaume@ISI.EDU
Thu, 4 Apr 2002 13:17:33 -0800 (PST)


> I believe that ghc translates the signature above to
> 
> foo :: forall q . Foo q => Double -> q
> 
> (I don't understand why GHC does this... it seems to have more potential
> for confusion)

I thought post 5.03 didn't do this?  Isn't this the point of "Putting type
annotations to use"?  Or am I missing something?

> This should more clearly show that foo is required to take a Double and
> give, in return, anything in class Foo that is requested, which it
> certainly does not (it always returns a Double).  

Right.

> > > class Foo p where
> > > instance Foo Double where
> > > data T = forall q . Foo q => T q
> > > foo :: Double -> T
> > > foo p = T p
> > 
> > which is very similar, except that the explicit universal quantification
> > is happening in in the datatype and not the function type.
> 
> Actually, this is not really universal quantification, it is existential
> quantification.  If you actually wrote a datatype that did universal

I meant existential.  Sorry