1
0
Fork 0

nested app

This commit is contained in:
Mylloon 2024-04-30 13:39:28 +02:00
parent dc1efb51e2
commit fb7fc53863
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 13 additions and 5 deletions

View file

@ -58,12 +58,13 @@ let typeof t =
(* Nested *) (* Nested *)
nested_infer env env' ty_fn nested_infer env env' ty_fn
| None -> None, env) | None -> None, env)
(* | (Some (Type.Var _ as ty1), _), _ -> | (Some (Type.Var _ as ty1), _), _ ->
(* On this case we may have a function represented as a variable *) (* On this case we may have a function represented as a variable *)
(* TODO: Nested application *)
let ty2 = Type.Arrow (ty1, ty1) in let ty2 = Type.Arrow (ty1, ty1) in
(match Unification.unify ty1 ty2 with (match Unification.unify ty1 ty2 with
| Some env' -> Some ty2, env' | Some env' -> Some ty2, env'
| _ -> None, env) *) | _ -> None, env)
| _ -> None, env) | _ -> None, env)
in in
fst (infer TypeSubstitution.empty t) fst (infer TypeSubstitution.empty t)

View file

@ -62,6 +62,13 @@ let tests_typeof =
( Fun (x, Proj (First, Proj (Second, Var x))) ( Fun (x, Proj (First, Proj (Second, Var x)))
, Pair (Pair (IntConst 1, IntConst 2), IntConst 3) )) , Pair (Pair (IntConst 1, IntConst 2), IntConst 3) ))
, Some Type.Int ) , Some Type.Int )
(* ; (* x -> y -> (x -> y -> z) -> z *)
( "fun x -> fun y -> fun z -> z x y"
, Term.(Fun (x, Fun (y, Fun (z, App (Var z, App (Var x, Var y))))))
, Some
Type.(
Arrow (Var x, Arrow (Var y, Arrow (Arrow (Var x, Arrow (Var y, Var z)), Var z))))
) *)
] ]
;; ;;