I have to convert a Haskell type signature into a term. The type signature is :
f :: (a -> b -> c) -> (d -> b) -> (d -> a) -> d -> c
The correct resulting term is :
f g h j x = g (j x) (h x)
and here lies my problem as I understand it g
is a function which returns a function which returns c
and c
is function which returns a function d
which returns b
and b
is a function which returns itself which then returns itself again which then returns c
.
Correct me if i am wrong.
What I don't get is why is g
taking (j x)
as first argument and (h x)
as second argument. Shouldn't it be the other way around? Haskell is right associative and h
is the secound parameter given to the function f
and not j
.
c
is function" - why? Parentheses matter:a -> b -> c
is a complete signature. It's a function that takesa
and returns another function that takesb
and returnsc
. Then(d -> b)
is the second argument tof
. – ForceBru