Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions FSharpActivePatterns/bin/REPL.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,35 @@ let run_repl dump_parsetree input_file =
| None -> stdin
| Some n -> open_in n
in
let rec run_repl_helper run =
let rec run_repl_helper run env state =
let open Format in
match run ic with
| Fail -> fprintf err_formatter "Error occured\n"
| Empty ->
fprintf std_formatter "\n";
print_flush ();
run_repl_helper run
run_repl_helper run env state
| End -> ()
| Result ast ->
let result = infer ast in
let result = infer ast env state in
(match result with
| Error err ->
| new_state, Error err ->
fprintf err_formatter "Type checking failed: %a\n" pp_error err;
print_flush ()
| Ok t ->
print_flush ();
run_repl_helper run env new_state
| new_state, Ok (env, types) ->
(match dump_parsetree with
| true -> print_construction std_formatter ast
| false ->
fprintf std_formatter "- : ";
pp_typ std_formatter t);
print_flush ());
run_repl_helper run
List.iter
(fun t ->
fprintf std_formatter "- : ";
pp_typ std_formatter t)
types;
print_flush ());
run_repl_helper run env new_state)
in
run_repl_helper run_single
run_repl_helper run_single TypeEnvironment.empty 0
;;

type opts =
Expand Down
Loading
Loading