I need to verify the type for the lambda expression: $\lambda f.\lambda x.f (f x)$My method gives me: $(a\rightarrow c)\rightarrow b\rightarrow c$Im trying to define it in Haskell (on Hugs) like this: h= \f x -> f (f x)When i call the :type comamnd it gives me:(a -> a) -> a -> aIs mi function correctly defined in Haskell?, or my method gives me a wrong result?
Verify the type of a lambda expression
lambda calculus;type theory
Haskell is right.I do not know whether your Haskell syntax is correct, though it looks plausible to me, but the Haskell typing is the right one.Since $f$ is applied to the result of $f(x)$, $f$ must be of type $a\rightarrow a$,$a$ being the type of $x$.