expressi icon indicating copy to clipboard operation
expressi copied to clipboard

Infer a type of captured free variable in function body

Open coord-e opened this issue 5 years ago • 2 comments

  1. Implement Value::free_variables
  2. Remove check_captures and replace its uses with that above
  3. Use Value::free_variables in TypeInfer::transform_with_env and rollback new_env changes to env

coord-e avatar Mar 11 '19 16:03 coord-e

test code:

let zero = (f, x) -> x;
let succ = n -> (f, x) -> f(n(f, x));
let plus = (m, n) -> m(succ, n);  // !
let toint = f -> f(x -> x + 1, 0);
let four = plus(succ(zero), succ(succ(succ(zero))));
toint(four)  // 4

coord-e avatar Mar 11 '19 16:03 coord-e

  1. doesn't work!

coord-e avatar Mar 12 '19 07:03 coord-e