Fixes
This commit is contained in:
@ -35,13 +35,13 @@ let rec unify type_a type_b =
|
||||
unify a1 b1
|
||||
|
||||
| VariableTypeP ({contents = Link ty_link}), ty_rest
|
||||
| ty_rest, VariableTypeP ({contents = Link ty_link})
|
||||
when ty_link = ty_rest ->
|
||||
Ok ()
|
||||
| ty_rest, VariableTypeP ({contents = Link ty_link}) ->
|
||||
unify ty_rest ty_link
|
||||
|
||||
| VariableTypeP ({contents = Unbound (a1, _)}),
|
||||
VariableTypeP ({contents = Unbound (b1, _)})
|
||||
when a1 = b1 ->
|
||||
(* should never happen *)
|
||||
Error (`WrongType "Only a single instance of a type should be available.")
|
||||
|
||||
| type_ab, VariableTypeP ({contents = Unbound (_id, _level)} as tvar)
|
||||
@ -252,7 +252,7 @@ let rec evaluate_type_polimorphic program (env: env) level =
|
||||
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) ->
|
||||
let* _ = Error (`RecusrionsNotImplemented "Let Rec is not implemented.") in
|
||||
let* _ = Error (`RecursionNotImplemented "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
|
||||
@ -421,7 +421,7 @@ let typecheck (program: t_exp) : (ftype, [> typechecking_error]) result =
|
||||
|
||||
|
||||
let typecheck_polymorphic (program: t_exp)
|
||||
: (type_f, [> typechecking_error]) result =
|
||||
: (type_f, [> polytypechecking_error]) result =
|
||||
global_type_id := 0;
|
||||
let* type_program = evaluate_type_polimorphic program VariableMap.empty 0 in
|
||||
let* _ = unifyable type_program (FunctionTypeP (IntegerTypeP, IntegerTypeP))
|
||||
@ -430,7 +430,7 @@ let typecheck_polymorphic (program: t_exp)
|
||||
Ok (generalized_ty)
|
||||
|
||||
let typecheck_polymorphic_unbound (program: t_exp)
|
||||
: (type_f, [> typechecking_error]) result =
|
||||
: (type_f, [> polytypechecking_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
|
||||
|
||||
Reference in New Issue
Block a user