
27 Oct
2006
27 Oct
'06
2:02 p.m.
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