[Haskell-cafe] What does the `forall` mean ?

Neil Brown nccb2 at kent.ac.uk
Thu Nov 12 05:49:54 EST 2009


Eugene Kirpichov wrote:
> 2009/11/12 Andrew Coppin <andrewcoppin at btinternet.com>:
>   
>> Even I am still not 100% sure how placing forall in different positions does
>> different things. But usually it's not something I need to worry about. :-)
>>     
>
> To me it does not look like it does different things: everywhere it
> denotes universal polymorphism. What do you mean? I might be missing
> something.
>   
I think what he means is that this:

foo :: forall a b. (a -> a) -> b -> b

uses ScopedTypeVariables, and introduces the type-name a to be available 
in the where clause of myid.  Whereas something like this:

foo2 :: (forall a. a -> a) -> b -> b

uses Rank2Types (I think?) to describe a function parameter that works 
for all types a.  So although the general concept is the same, they use 
different Haskell extensions, and one is a significant extension to the 
type system while the other (ScopedTypeVariables) is just some more 
descriptive convenience.

Thanks,

Neil.


More information about the Haskell-Cafe mailing list