World's most popular travel blog for travel bloggers.

Verify the type of a lambda expression

, , No Comments
Problem Detail: 

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 -> a 

Is mi function correctly defined in Haskell?, or my method gives me a wrong result?

Asked By : Wyvern666

Answered By : babou

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$.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/22791

3200 people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback