
On Wednesday 20 October 2010 16:04:41, Patrick LeBoutillier wrote:
Prelude> :t flip flip :: (a -> b -> c) -> b -> a -> c Prelude> :t id id :: a -> a Prelude> :t flip id flip id :: b -> (b -> c) -> c
How does one get the type of "flip id" by applying "flip" to "id"?
flip :: (a -> b -> c) -> b -> a -> c id :: t -> t So for flip id, we must unify (t -> t) with (a -> b -> c), which is, fully parenthesized, (a -> (b -> c)). So t = a, as that's what appears left of the outermost (->). Also, t = (b -> c), as that's what appears right of the outermost (->). a = t = b -> c, so in flip id, id appears at the type (b -> c) -> (b -> c) and flip is used at the type ((b -> c) -> (b -> c)) -> b -> (b -> c) -> c The first is eaten by flip, leaving flip id :: b -> (b -> c) -> c
Thanks,
Patrick
HTH, Daniel