[Haskell-cafe] Re: Polymorphic (typeclass) values in a list?

Kalman Noel kalman.noel at bluebottle.com
Sun Oct 21 07:39:12 EDT 2007


Peter Hercek wrote:
> When 'exists' is not a keyword, why 'forall' is needed at all?
> Isn't everything 'forall' qualified by default?

“forall” isn't a keyword in Haskell 98. As an extension to the language,
however, it makes certain types expressible that can not be written in H98, for
example 

    f :: (forall a. a) -> T
    
which is different from 

    g :: forall a. a -> T

although both are not particularly useful. (The only argument that f will ever
take is bottom!)

In the context of existentially quantified types, however, the forall keyword is
used probably to make the use of an extension more explicit. Without the forall
keyword, 

    data U = C a

would be an existential, while the programmer maybe really wanted the usual

    data U a = C a

Kalman

----------------------------------------------------------------------
Find out how you can get spam free email.
http://www.bluebottle.com/tag/3



More information about the Haskell-Cafe mailing list