diff options
Diffstat (limited to 'src/initial_check.ml')
| -rw-r--r-- | src/initial_check.ml | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/initial_check.ml b/src/initial_check.ml index 812bfaad..9516f53e 100644 --- a/src/initial_check.ml +++ b/src/initial_check.ml @@ -430,17 +430,26 @@ let to_ast_lit (Parse_ast.L_aux(lit,l)) : lit = | Parse_ast.L_bin(b) -> L_bin(b) | Parse_ast.L_real r -> L_real r | Parse_ast.L_string(s) -> L_string(s)) - ,l) - + ,l) + +let rec to_ast_typ_pat (Parse_ast.ATyp_aux (typ_aux, l)) = + match typ_aux with + | Parse_ast.ATyp_wild -> TP_wild + | Parse_ast.ATyp_var kid -> TP_var (to_ast_var kid) + | Parse_ast.ATyp_app (f, typs) -> + TP_app (to_ast_id f, List.map to_ast_typ_pat typs) + | _ -> typ_error l "Unexpected type in type pattern" None None None + let rec to_ast_pat (k_env : kind Envmap.t) (def_ord : order) (Parse_ast.P_aux(pat,l) : Parse_ast.pat) : unit pat = P_aux( (match pat with | Parse_ast.P_lit(lit) -> P_lit(to_ast_lit lit) | Parse_ast.P_wild -> P_wild - | Parse_ast.P_as(pat,id) -> P_as(to_ast_pat k_env def_ord pat,to_ast_id id) + | Parse_ast.P_var (pat, Parse_ast.ATyp_aux (Parse_ast.ATyp_id id, _)) -> + P_as (to_ast_pat k_env def_ord pat, to_ast_id id) | Parse_ast.P_typ(typ,pat) -> P_typ(to_ast_typ k_env def_ord typ,to_ast_pat k_env def_ord pat) | Parse_ast.P_id(id) -> P_id(to_ast_id id) - | Parse_ast.P_var (pat,kid) -> P_var (to_ast_pat k_env def_ord pat, TP_var (to_ast_var kid)) + | Parse_ast.P_var (pat, typ) -> P_var (to_ast_pat k_env def_ord pat, to_ast_typ_pat typ) | Parse_ast.P_app(id,pats) -> if pats = [] then P_id (to_ast_id id) |
