Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Typed Lambda Calculus

I want to find the type of the lambda expression \x y -> x y y. I proceed as follows.

  1. We go in the reverse order of operations and "unpack" the expression. Assume the whole expression has type A. Then let y have type x1 and \x y -> x y have type B. Then A = B -> x1
  2. We already know the type of y, and let \x y -> x be of the type C. Then B = C -> x1.
  3. The type of \x y -> x is obviously x1->x2->x1. This is given to us in the previous exercise and makes sense because this expression takes in two arguments and returns the first.

Putting it all together we have that:

A = B -> x1 = C -> x1 -> x1 = (x1 -> x2 -> x1) -> x1 -> x1

The correct answer is somehow:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

(x1 -> x1 -> x2) -> x1 -> x2 

What am I doing wrong?

>Solution :

Here I just write stuff’s types under it and go from there:

foo = \x   y ->   x   y    y
foo    x   y =    x   y    y 
       a   b                 :  c
                  a   b    b :  c
                  a   b :  b -> c
                  a : b -> b -> c
foo : a -> b -> c
    ~ (b -> b -> c) -> b -> c
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading