I’m currently having Haskell for university. Given the following haskell code:
true::t -> t1 -> t
true = (\x y -> x)
false::t -> t1 -> t1
false = (\x y -> y)
-- Implication
(==>) = (\x y -> x y true)
The task is to determine the type of the function (==>).
GHCi says it is (==>) :: (t1 -> (t2 -> t3 -> t2) -> t) -> t1 -> t.
I can see that the evaluation order is the following (as the type stays the same):
(==>) = (\x y -> (x y) true)
So the function true ist argument to (x y).
Can anyone explain why the result type t is bound to the result of the first argument and in which way GHCi determines the type of (==>)?
First, to give a better overview,
Let’s call the result of the implication
r, then we have, in\x y -> x y true :: r, thatso
x :: y -> True t f -> r, and thuswhich, expanding
Trueagain, is