Fix for let rec, currently not implemented
This commit is contained in:
@ -251,7 +251,16 @@ let rec evaluate_type_polimorphic program (env: env) level =
|
||||
let* var_ty = evaluate_type_polimorphic xval env (level + 1) in
|
||||
let generalized_ty = generalize level var_ty in
|
||||
evaluate_type_polimorphic rest (VariableMap.add x generalized_ty env) level
|
||||
| LetFun (_f, _xs, _typef, _fbody, _rest) -> failwith "Not Implemented"
|
||||
| LetFun (f, xs, _typef, fbody, rest) ->
|
||||
let* _ = Error (`RecusrionsNotImplemented "Let Rec is not implemented.") in
|
||||
let tmp_type_f = VariableTypeP (ref (Unbound (new_global_id (), level))) in
|
||||
let new_env = VariableMap.add f tmp_type_f env in
|
||||
let param_type = VariableTypeP (ref (Unbound (new_global_id (), level))) in
|
||||
let fn_env = VariableMap.add xs param_type new_env in
|
||||
let* body_type = evaluate_type_polimorphic fbody fn_env level in
|
||||
let* _ = unify tmp_type_f body_type in
|
||||
evaluate_type_polimorphic rest (VariableMap.add f tmp_type_f env) level
|
||||
|
||||
|
||||
(* -------------------------------------------------------------------------- *)
|
||||
|
||||
@ -419,3 +428,10 @@ let typecheck_polymorphic (program: t_exp)
|
||||
in
|
||||
let generalized_ty = generalize (-1) type_program in
|
||||
Ok (generalized_ty)
|
||||
|
||||
let typecheck_polymorphic_unbound (program: t_exp)
|
||||
: (type_f, [> typechecking_error]) result =
|
||||
global_type_id := 0;
|
||||
let* type_program = evaluate_type_polimorphic program VariableMap.empty 0 in
|
||||
let generalized_ty = generalize (-1) type_program in
|
||||
Ok (generalized_ty)
|
||||
|
||||
Reference in New Issue
Block a user