From 52eabc26972d203f2d29553018402c2a987da1fa Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 5 Dec 2023 04:29:42 +0100 Subject: [PATCH] synth_for --- flap/src/hopix/hopixTypechecker.ml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/flap/src/hopix/hopixTypechecker.ml b/flap/src/hopix/hopixTypechecker.ml index 594ace2..0046e84 100644 --- a/flap/src/hopix/hopixTypechecker.ml +++ b/flap/src/hopix/hopixTypechecker.ml @@ -242,7 +242,20 @@ and synth_for -> expression Position.located -> expression Position.located -> expression Position.located -> HopixTypes.aty = - fun tenv id estart eend expr -> failwith "Students! This is your job! (synth_for)" + fun tenv id estart eend expr -> + let estart_ty = synth_expression tenv estart in + check_equal_types estart.position ~expected:estart_ty ~given:HopixTypes.hint; + let eend_ty = synth_expression tenv eend in + check_equal_types eend.position ~expected:eend_ty ~given:HopixTypes.hint; + let tenv' = + HopixTypes.bind_value + id.value + (HopixTypes.monomorphic_type_scheme HopixTypes.hint) + tenv + in + let e_ty = synth_expression tenv' expr in + check_equal_types expr.position ~expected:e_ty ~given:HopixTypes.hunit; + HopixTypes.hunit and check_expression : HopixTypes.typing_environment -> HopixAST.expression Position.located