[Haskell-cafe] Re: Type System (Was: Currying and Partial
Evaluation)
Felipe Lessa
felipe.lessa at gmail.com
Wed Jan 9 05:01:28 EST 2008
On Jan 9, 2008 12:39 AM, Achim Schneider <barsoap at web.de> wrote:
> Yes, exactly that wire which isn't obscured by the boiler plate has
> kindled my interest.
The name of a type variable doesn't really matter. GHC tries to
preserve the names you give, otherwise it creates their own. For
example,
Prelude> :t \a b c d e f g -> (a,b,c,d,e,f,g)
\a b c d e f g -> (a,b,c,d,e,f,g) :: t
-> t1
-> t2
-> t3
-> t4
-> t5
-> t6
-> (t, t1, t2, t3, t4, t5, t6)
Welll, so why 'b'? Well, GHC didn't choose 'b' at all =)
Prelude> :t let y f = f (y f) in y
let y f = f (y f) in y :: (t -> t) -> t
but
Prelude> :t let y f = f $ y f in y
let y f = f $ y f in y :: (b -> b) -> b
because
Prelude> :t ($)
($) :: (a -> b) -> a -> b
In another exemple,
Prelude> :t \a b c d e f g -> (id a,b,c,d,e,f,g)
\a b c d e f g -> (id a,b,c,d,e,f,g) :: a -> t -> t1 -> t2 -> t3 -> t4
-> t5 -> (a, t, t1, t2, t3, t4, t5)
Prelude> :t \a b c d e f g -> (a,b,c,d,id e,f,g)
\a b c d e f g -> (a,b,c,d,id e,f,g) :: t -> t1 -> t2 -> t3 -> a -> t4
-> t5 -> (t, t1, t2, t3, a, t4, t5)
Prelude> :t \a b c d e f g -> (a,b,id c,d,id e,f,g)
\a b c d e f g -> (a,b,id c,d,id e,f,g) :: t -> t1 -> a -> t2 -> a1 ->
t3 -> t4 -> (t, t1, a, t2, a1, t3, t4)
--
Felipe.
More information about the Haskell-Cafe
mailing list