1
0
Fork 0
This repository has been archived on 2024-05-03. You can view files and clone it, but cannot push or open issues or pull requests.
unification-pfa/lib/inference.ml
Mylloon 83b2039262
* Add dummy implementation
* Add Identifier.t
* WIP: typeof? (idk what Im doing)
2024-03-14 22:24:38 +01:00

19 lines
645 B
OCaml

let rec typeof = function
| Term.Var _ ->
(* Une variable n'a pas de type *)
None
| Term.IntConst _ -> Some Type.Int
| Term.Binop (t1, _, t2) ->
(* Les 2 types de l'opération sont égaux *)
(match typeof t1, typeof t2 with
| Some (_ as ty1), Some (_ as ty2) -> if ty1 = ty2 then Some ty1 else None
| _ -> None)
| Term.Pair (t1, t2) ->
(* On forme le produit *)
(match typeof t1, typeof t2 with
| Some ty1, Some ty2 -> Some (Type.Product (ty1, ty2))
| _ -> None)
| Term.Proj (_proj, _t) -> failwith "TODO"
| Term.Fun (_, _) -> failwith "TODO"
| Term.App (_t1, _t2) -> failwith "TODO"
;;