diff --git a/flap/src/hopix/hopixTypechecker.ml b/flap/src/hopix/hopixTypechecker.ml index 663e942..1fa1029 100644 --- a/flap/src/hopix/hopixTypechecker.ml +++ b/flap/src/hopix/hopixTypechecker.ml @@ -92,15 +92,66 @@ and synth_pattern = fun env Position.{ value = p; position = pos } -> match p with - | PWildcard -> failwith "synth_pattern | PWildcard" - | PLiteral l -> failwith "synth_pattern | Pliteral" - | PVariable pv -> failwith "synth_pattern | PVariable" - | PTypeAnnotation (p, ty) -> failwith "synth_pattern | PTypeAnnot" - | PTuple plist -> failwith "synth_pattern | PTuple" - | POr plist -> failwith "synth_pattern | POr" - | PAnd plist -> failwith "synth_pattern | PAnd" - | PTaggedValue (cons, tlist, plist) -> failwith "synth_pattern | PTagged" - | PRecord (plist, tlist) -> failwith "synth_pattern | PRecord" + | PWildcard -> pattern_wildcard pos + | PLiteral l -> pattern_literal env l + | PVariable _ -> pattern_variable pos + | PTypeAnnotation (p, ty) -> pattern_tannot env p ty + | PTuple plist -> pattern_tuple env plist + | POr plist -> pattern_or env plist + | PAnd plist -> pattern_and env plist + | PTaggedValue (cons, tlist, plist) -> pattern_tagval env cons tlist plist + | PRecord (plist, tlist) -> pattern_record env plist tlist + +and pattern_wildcard : Position.t -> HopixTypes.aty * HopixTypes.typing_environment = + fun pos -> HopixTypes.type_error pos "No types found." + +and pattern_literal + : HopixTypes.typing_environment -> HopixAST.literal Position.located + -> HopixTypes.aty * HopixTypes.typing_environment + = + fun tenv l -> failwith "synth_pattern | Pliteral" + +and pattern_variable : Position.t -> HopixTypes.aty * HopixTypes.typing_environment = + fun pos -> HopixTypes.type_error pos "No types found." + +and pattern_tannot + : HopixTypes.typing_environment -> HopixAST.pattern Position.located + -> HopixAST.ty Position.located -> HopixTypes.aty * HopixTypes.typing_environment + = + fun tenv p ty -> failwith "synth_pattern | PTypeAnnot" + +and pattern_tuple + : HopixTypes.typing_environment -> HopixAST.pattern Position.located list + -> HopixTypes.aty * HopixTypes.typing_environment + = + fun tenv plist -> failwith "synth_pattern | PTuple" + +and pattern_or + : HopixTypes.typing_environment -> HopixAST.pattern Position.located list + -> HopixTypes.aty * HopixTypes.typing_environment + = + fun tenv plist -> failwith "synth_pattern | POr" + +and pattern_and + : HopixTypes.typing_environment -> HopixAST.pattern Position.located list + -> HopixTypes.aty * HopixTypes.typing_environment + = + fun tenv plist -> failwith "synth_pattern | PAnd" + +and pattern_tagval + : HopixTypes.typing_environment -> HopixAST.constructor Position.located + -> HopixAST.ty Position.located list option -> HopixAST.pattern Position.located list + -> HopixTypes.aty * HopixTypes.typing_environment + = + fun tenv cons tlist plist -> failwith "synth_pattern | PTagged" + +and pattern_record + : HopixTypes.typing_environment + -> (HopixAST.label Position.located * HopixAST.pattern Position.located) list + -> HopixAST.ty Position.located list option + -> HopixTypes.aty * HopixTypes.typing_environment + = + fun tenv plist tlist -> failwith "synth_pattern | PRecord" and synth_variable : HopixTypes.typing_environment -> identifier Position.located