[Haskell-cafe] Rank N type tutorial?

Greg Buchholz haskell at sleepingsquirrel.org
Fri Oct 27 14:02:51 EDT 2006


Ben Rudiak-Gould wrote:
> The way to think about it is that foralls are extra function arguments. 
> Your first example is like
> 
>   foo :: Integer -> (a::Type -> Show a -> a)
> 
> so a is chosen by the caller, not by you. The second case is like
> 
>   bar :: Integer -> (a::Type -> Show a -> a -> b) -> b
> 
> In order for the first case to work as you expect, you'd need the type
> 
>   foo :: Integer -> (a::Type, Show a, a)
> 
> which is traditionally written
> 
>   foo :: Integer -> (exists a. Show a => a)

    I thought "exists" was spelled "forall" in Haskell?

Greg Buchholz


More information about the Haskell-Cafe mailing list