| 50 |
Format.fprintf ppf "but its infered type is: %a@\n" |
Format.fprintf ppf "but its infered type is: %a@\n" |
| 51 |
print_norm s; |
print_norm s; |
| 52 |
Format.fprintf ppf "which is not a subtype, as shown by the value %a@\n" |
Format.fprintf ppf "which is not a subtype, as shown by the value %a@\n" |
| 53 |
Types.Print.print_sample (Types.Sample.get (Types.diff s t)); |
Types.Sample.print (Types.Sample.get (Types.diff s t)); |
| 54 |
Format.fprintf ppf "%s@\n" msg |
Format.fprintf ppf "%s@\n" msg |
| 55 |
| Typer.NonExhaustive t -> |
| Typer.NonExhaustive t -> |
| 56 |
Format.fprintf ppf "This pattern matching is not exhaustive@\n"; |
Format.fprintf ppf "This pattern matching is not exhaustive@\n"; |
| 57 |
Format.fprintf ppf "Residual type: %a@\n" |
Format.fprintf ppf "Residual type: %a@\n" |
| 58 |
print_norm t; |
print_norm t; |
| 59 |
Format.fprintf ppf "Sample value: %a@\n" |
Format.fprintf ppf "Sample value: %a@\n" |
| 60 |
Types.Print.print_sample (Types.Sample.get t) |
Types.Sample.print (Types.Sample.get t) |
| 61 |
| Typer.UnboundId x -> |
| Typer.UnboundId x -> |
| 62 |
Format.fprintf ppf "Unbound identifier %s@\n" x |
Format.fprintf ppf "Unbound identifier %s@\n" x |
| 63 |
| exn -> |
| exn -> |
| 93 |
let insert_type_bindings = |
let insert_type_bindings = |
| 94 |
List.iter (fun (x,t) -> |
List.iter (fun (x,t) -> |
| 95 |
typing_env := Typer.Env.add x t !typing_env; |
typing_env := Typer.Env.add x t !typing_env; |
| 96 |
Format.fprintf ppf "|- %s : %a@\n" x print_norm t) |
Format.fprintf ppf "|- %s : %a@\n@." x print_norm t) |
| 97 |
|
|
| 98 |
let type_decl decl = |
let type_decl decl = |
| 99 |
insert_type_bindings (Typer.type_let_decl !typing_env decl) |
insert_type_bindings (Typer.type_let_decl !typing_env decl) |
| 103 |
List.iter |
List.iter |
| 104 |
(fun (x,v) -> |
(fun (x,v) -> |
| 105 |
Eval.enter_global x v; |
Eval.enter_global x v; |
| 106 |
Format.fprintf ppf "=> %s : @[%a@]@\n" x Value.print v |
Format.fprintf ppf "=> %s : @[%a@]@\n@." x Value.print v |
| 107 |
) bindings |
) bindings |
| 108 |
|
|
| 109 |
let phrase ph = |
let phrase ph = |
| 111 |
| Ast.EvalStatement e -> |
| Ast.EvalStatement e -> |
| 112 |
let (fv,e) = Typer.expr e in |
let (fv,e) = Typer.expr e in |
| 113 |
let t = Typer.type_check !typing_env e Types.any true in |
let t = Typer.type_check !typing_env e Types.any true in |
| 114 |
Format.fprintf ppf "|- %a@\n" print_norm t; |
Format.fprintf ppf "|- %a@\n@." print_norm t; |
| 115 |
let v = Eval.eval !eval_env e in |
let v = Eval.eval !eval_env e in |
| 116 |
Format.fprintf ppf "=> @[%a@]@\n" Value.print v |
Format.fprintf ppf "=> @[%a@]@\n@." Value.print v |
| 117 |
| Ast.LetDecl (p,{descr=Ast.Abstraction _}) -> () |
| Ast.LetDecl (p,{descr=Ast.Abstraction _}) -> () |
| 118 |
| Ast.LetDecl (p,e) -> |
| Ast.LetDecl (p,e) -> |
| 119 |
let decl = Typer.let_decl p e in |
let decl = Typer.let_decl p e in |