fmt
This commit is contained in:
parent
0ec66864fb
commit
6bbb1f0996
1 changed files with 28 additions and 23 deletions
|
@ -90,16 +90,17 @@ and synth_pattern
|
||||||
: HopixTypes.typing_environment -> HopixAST.pattern Position.located
|
: HopixTypes.typing_environment -> HopixAST.pattern Position.located
|
||||||
-> HopixTypes.aty * HopixTypes.typing_environment
|
-> HopixTypes.aty * HopixTypes.typing_environment
|
||||||
=
|
=
|
||||||
fun env Position.{ value = p; position = pos } -> match p with
|
fun env Position.{ value = p; position = pos } ->
|
||||||
| PWildcard -> failwith "PWildcard"
|
match p with
|
||||||
| PLiteral l-> failwith "Pliteral"
|
| PWildcard -> failwith "synth_pattern | PWildcard"
|
||||||
| PVariable pv -> failwith "PVariable"
|
| PLiteral l -> failwith "synth_pattern | Pliteral"
|
||||||
| PTypeAnnotation(p,ty) -> failwith "PTypeAnnot"
|
| PVariable pv -> failwith "synth_pattern | PVariable"
|
||||||
| PTuple(plist) -> failwith "PTuple"
|
| PTypeAnnotation (p, ty) -> failwith "synth_pattern | PTypeAnnot"
|
||||||
| POr(plist) -> failwith "POr"
|
| PTuple plist -> failwith "synth_pattern | PTuple"
|
||||||
| PAnd (plist) -> failwith "PAnd"
|
| POr plist -> failwith "synth_pattern | POr"
|
||||||
| PTaggedValue(cons,tlist,plist) -> failwith "PTagged"
|
| PAnd plist -> failwith "synth_pattern | PAnd"
|
||||||
| PRecord(plist,tlist) -> failwith "PRecord"
|
| PTaggedValue (cons, tlist, plist) -> failwith "synth_pattern | PTagged"
|
||||||
|
| PRecord (plist, tlist) -> failwith "synth_pattern | PRecord"
|
||||||
|
|
||||||
and synth_variable
|
and synth_variable
|
||||||
: HopixTypes.typing_environment -> identifier Position.located
|
: HopixTypes.typing_environment -> identifier Position.located
|
||||||
|
@ -214,10 +215,10 @@ and synth_fun
|
||||||
: HopixTypes.typing_environment -> pattern Position.located
|
: HopixTypes.typing_environment -> pattern Position.located
|
||||||
-> expression Position.located -> HopixTypes.aty
|
-> expression Position.located -> HopixTypes.aty
|
||||||
=
|
=
|
||||||
fun tenv pat expr ->
|
fun tenv pat expr ->
|
||||||
let pat_type, tenv = synth_pattern tenv pat in
|
let pat_type, tenv = synth_pattern tenv pat in
|
||||||
let expr_type = synth_expression tenv expr in
|
let expr_type = synth_expression tenv expr in
|
||||||
ATyArrow(pat_type,expr_type)
|
ATyArrow (pat_type, expr_type)
|
||||||
|
|
||||||
and synth_tannot
|
and synth_tannot
|
||||||
: HopixTypes.typing_environment -> expression Position.located -> ty Position.located
|
: HopixTypes.typing_environment -> expression Position.located -> ty Position.located
|
||||||
|
@ -233,15 +234,18 @@ and synth_field
|
||||||
: HopixTypes.typing_environment -> expression Position.located
|
: HopixTypes.typing_environment -> expression Position.located
|
||||||
-> label Position.located -> ty Position.located list option -> HopixTypes.aty
|
-> label Position.located -> ty Position.located list option -> HopixTypes.aty
|
||||||
=
|
=
|
||||||
fun tenv expr lbl tlist -> failwith "synth_field" (*let expr_type = synth_expression tenv expr in
|
fun tenv expr lbl tlist ->
|
||||||
match expr_type with
|
(* TODO *)
|
||||||
|
failwith "synth_field"
|
||||||
|
(*let expr_type = synth_expression tenv expr in
|
||||||
|
match expr_type with
|
||||||
| ATyCon(cons,atlist) ->
|
| ATyCon(cons,atlist) ->
|
||||||
(
|
(
|
||||||
(* Impossible car n'est pas dans le mli*)
|
(* Impossible car n'est pas dans le mli*)
|
||||||
let lbllist = HopixTypes.lookup_information_of_type_constructor lbl.position cons tenv in
|
let lbllist = HopixTypes.lookup_information_of_type_constructor lbl.position cons tenv in
|
||||||
match lbllist with
|
match lbllist with
|
||||||
| Record r ->
|
| Record r ->
|
||||||
if List.mem lbl.value r
|
if List.mem lbl.value r
|
||||||
then
|
then
|
||||||
let label_scheme =
|
let label_scheme =
|
||||||
try HopixTypes.lookup_type_scheme_of_label label_pos label_val tenv with
|
try HopixTypes.lookup_type_scheme_of_label label_pos label_val tenv with
|
||||||
|
@ -251,17 +255,18 @@ and synth_field
|
||||||
try HopixTypes.instantiate_type_scheme label_scheme atlist with
|
try HopixTypes.instantiate_type_scheme label_scheme atlist with
|
||||||
| HopixTypes.InvalidInstantiation { expected; given } ->
|
| HopixTypes.InvalidInstantiation { expected; given } ->
|
||||||
invalid_instantiation (Position.position expr) expected given
|
invalid_instantiation (Position.position expr) expected given
|
||||||
else
|
else
|
||||||
failwith "Erreur de label"
|
failwith "Erreur de label"
|
||||||
)
|
)
|
||||||
| _ -> failwith "Ceci n'est pas un label"
|
| _ -> failwith "Ceci n'est pas un label"
|
||||||
*)
|
*)
|
||||||
|
|
||||||
and synth_tuple
|
and synth_tuple
|
||||||
: HopixTypes.typing_environment -> expression Position.located list -> HopixTypes.aty
|
: HopixTypes.typing_environment -> expression Position.located list -> HopixTypes.aty
|
||||||
=
|
=
|
||||||
fun tenv elist -> let list_type = List.map(
|
fun tenv elist ->
|
||||||
fun x -> synth_expression tenv x
|
let list_type = List.map (fun x -> synth_expression tenv x) elist in
|
||||||
) elist in HopixTypes.ATyTuple(list_type)
|
HopixTypes.ATyTuple list_type
|
||||||
|
|
||||||
and synth_sequence
|
and synth_sequence
|
||||||
: HopixTypes.typing_environment -> expression Position.located list -> HopixTypes.aty
|
: HopixTypes.typing_environment -> expression Position.located list -> HopixTypes.aty
|
||||||
|
|
Reference in a new issue