fmt
This commit is contained in:
parent
8b3a34ba2d
commit
1f1e58f84f
1 changed files with 52 additions and 50 deletions
|
@ -214,7 +214,6 @@ and pattern_tagval
|
|||
-> HopixTypes.aty * HopixTypes.typing_environment
|
||||
=
|
||||
fun tenv cons tlist plist ->
|
||||
|
||||
let cons_scheme =
|
||||
try HopixTypes.lookup_type_scheme_of_constructor cons.position cons.value tenv with
|
||||
| HopixTypes.Unbound (pos, Constructor (KId c)) ->
|
||||
|
@ -233,8 +232,7 @@ and pattern_tagval
|
|||
invalid_instantiation cons.position expected given
|
||||
in
|
||||
let p_args, tenv = synth_list_pattern tenv plist in
|
||||
(
|
||||
let expected_args, result =
|
||||
( (let expected_args, result =
|
||||
HopixTypes.destruct_function_type_maximally cons.position tcons
|
||||
in
|
||||
(try
|
||||
|
@ -249,8 +247,8 @@ and pattern_tagval
|
|||
cons.position
|
||||
~expected:result
|
||||
~given:(HopixTypes.ATyArrow (result, result)));
|
||||
result
|
||||
),tenv
|
||||
result)
|
||||
, tenv )
|
||||
|
||||
and synth_list_pattern tenv = function
|
||||
| [] -> [], tenv
|
||||
|
@ -268,10 +266,12 @@ and pattern_record
|
|||
fun tenv plist tlist ->
|
||||
let label = fst (List.hd plist) in
|
||||
let type_cons, _, labels =
|
||||
let LId label_name = label.value in
|
||||
let (LId label_name) = label.value in
|
||||
try HopixTypes.lookup_type_constructor_of_label label.position label.value tenv with
|
||||
| HopixTypes.Unbound (pos, Label (LId i)) ->
|
||||
HopixTypes.type_error pos (Printf.sprintf "There is no type definition for label `%s'." label_name )
|
||||
HopixTypes.type_error
|
||||
pos
|
||||
(Printf.sprintf "There is no type definition for label `%s'." label_name)
|
||||
in
|
||||
let tlist' =
|
||||
match tlist with
|
||||
|
@ -279,8 +279,8 @@ and pattern_record
|
|||
| None -> HopixTypes.type_error label.position "No types found."
|
||||
in
|
||||
let tenv =
|
||||
List.fold_left (
|
||||
fun tenv (Position.{ position = label_pos; value = label_val }, pat) ->
|
||||
List.fold_left
|
||||
(fun tenv (Position.{ position = label_pos; value = label_val }, pat) ->
|
||||
let label_scheme =
|
||||
try HopixTypes.lookup_type_scheme_of_label label_pos label_val tenv with
|
||||
| HopixTypes.Unbound (pos, Label (LId i)) ->
|
||||
|
@ -291,15 +291,17 @@ and pattern_record
|
|||
| HopixTypes.InvalidInstantiation { expected; given } ->
|
||||
invalid_instantiation (Position.position pat) expected given
|
||||
in
|
||||
let _,expected = HopixTypes.destruct_function_type label_pos instance_type_scheme in
|
||||
let (given,tenv) = synth_pattern tenv pat in
|
||||
check_equal_types label_pos ~expected ~given; tenv
|
||||
) tenv plist;
|
||||
let _, expected =
|
||||
HopixTypes.destruct_function_type label_pos instance_type_scheme
|
||||
in
|
||||
let given, tenv = synth_pattern tenv pat in
|
||||
check_equal_types label_pos ~expected ~given;
|
||||
tenv)
|
||||
tenv
|
||||
plist
|
||||
in
|
||||
ATyCon (type_cons, tlist'), tenv
|
||||
|
||||
|
||||
|
||||
and synth_variable
|
||||
: HopixTypes.typing_environment -> identifier Position.located
|
||||
-> ty Position.located list option -> HopixTypes.aty
|
||||
|
|
Reference in a new issue