1
0
Fork 0
This commit is contained in:
Mylloon 2024-04-14 03:49:59 +02:00
parent b809467cff
commit b2be96a0f5
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -35,14 +35,21 @@ let typeof t =
| None, _ -> Some (Type.Arrow (Type.Var id, ty_body)), env') | None, _ -> Some (Type.Arrow (Type.Var id, ty_body)), env')
| _ -> None, env) | _ -> None, env)
| Term.App (t1, t2) -> | Term.App (t1, t2) ->
(* TODO: When a variable is a function *) (* Infer the type of t1 and t2 *)
(match infer env t1, infer env t2 with (match infer env t1, infer env t2 with
| (Some (Type.Arrow (ty_param, ty_fn)), _), (Some ty_args, _) -> | (Some (Type.Arrow (ty_param, ty_fn)), _), (Some ty_args, _) ->
(* Check if the function type matches the arguments *) (* Check if the argument type matches the parameter type *)
(match Unification.unify ty_param ty_args with (match Unification.unify ty_param ty_args with
| Some _ -> Some ty_fn, env | Some _ -> Some ty_fn, env
| None -> None, env) | None -> None, env)
| _, _ -> None, env) | (Some _ (* (Type.Var _ as ty1) *), _), _ ->
(* On this case we may have a function represented as the variable *)
(* let ty2 = Type.Arrow (ty1, ty1) in
(match Unification.unify ty1 ty2 with
| Some env' -> Some ty2, env'
| _ -> None, env) *)
None, env
| _ -> None, env)
in in
fst (infer TypeSubstitution.empty t) fst (infer TypeSubstitution.empty t)
;; ;;