Skip to content

Commit c4f40d7

Browse files
committed
lint: redundant match
Signed-off-by: Gleb Nasretdinov <gleb.nasretdinov@proton.me>
1 parent 0de1b06 commit c4f40d7

1 file changed

Lines changed: 54 additions & 54 deletions

File tree

FSharpActivePatterns/lib/REPLUtils.ml

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ let input_upto_sep sep ic =
2929
| Some line ->
3030
let line = String.trim line in
3131
let len = String.length line in
32-
(match String.ends_with ~suffix:sep line with
33-
| true ->
34-
Buffer.add_substring b line 0 (len - sep_len);
35-
Buffer.add_string b "\n";
36-
Input (Buffer.contents b)
37-
| false ->
38-
Buffer.add_string b line;
39-
Buffer.add_string b "\n";
40-
fill_buffer b)
32+
if String.ends_with ~suffix:sep line
33+
then (
34+
Buffer.add_substring b line 0 (len - sep_len);
35+
Buffer.add_string b "\n";
36+
Input (Buffer.contents b))
37+
else (
38+
Buffer.add_string b line;
39+
Buffer.add_string b "\n";
40+
fill_buffer b)
4141
in
4242
let buffer = Buffer.create 1024 in
4343
fill_buffer buffer
@@ -57,14 +57,14 @@ let input_with_indents ic =
5757
|| is_empty
5858
|| String.starts_with ~prefix:"and" (String.trim line)
5959
in
60-
(match is_continue with
61-
| true ->
62-
Buffer.add_string b (line ^ "\n");
63-
fill_buffer b
64-
| false ->
65-
seek_in ic start_pos;
66-
Buffer.add_string b "\n";
67-
Input (Buffer.contents b))
60+
if is_continue
61+
then (
62+
Buffer.add_string b (line ^ "\n");
63+
fill_buffer b)
64+
else (
65+
seek_in ic start_pos;
66+
Buffer.add_string b "\n";
67+
Input (Buffer.contents b))
6868
in
6969
let buffer = Buffer.create 1024 in
7070
let first_line = take_line () in
@@ -115,43 +115,43 @@ let run_repl dump_parsetree input_file input_string =
115115
run_repl_helper run type_env value_env state values_acc
116116
| End -> type_env, value_env, values_acc
117117
| Result (Ok ast) ->
118-
(match dump_parsetree with
119-
| true ->
120-
print_construction std_formatter ast;
121-
run_repl_helper run type_env value_env state values_acc
122-
| false ->
123-
let result = run_interpreter type_env value_env state ast in
124-
(match result with
125-
| new_state, Error err ->
126-
fprintf err_formatter "Error occured: %a\n" pp_global_error err;
127-
print_flush ();
128-
run_repl_helper run type_env value_env new_state values_acc
129-
| new_state, Ok (new_type_env, new_value_env, evaled_names) ->
130-
(match ic with
131-
| None ->
132-
Base.Map.iteri
133-
~f:(fun ~key ~data ->
134-
let t, v = data in
135-
fprintf
136-
std_formatter
137-
"val %s : %a = %a\n"
138-
key
139-
pp_typ
140-
t
141-
ValueEnv.pp_value
142-
v)
143-
evaled_names;
144-
print_flush ();
145-
run_repl_helper run new_type_env new_value_env new_state values_acc
146-
| Some _ ->
147-
let overwrite map1 map2 =
148-
Base.Map.fold
149-
~init:map1
150-
~f:(fun ~key ~data map1 -> Base.Map.set map1 ~key ~data)
151-
map2
152-
in
153-
let values_acc = overwrite values_acc evaled_names in
154-
run_repl_helper run new_type_env new_value_env new_state values_acc)))
118+
if dump_parsetree
119+
then (
120+
print_construction std_formatter ast;
121+
run_repl_helper run type_env value_env state values_acc)
122+
else (
123+
let result = run_interpreter type_env value_env state ast in
124+
match result with
125+
| new_state, Error err ->
126+
fprintf err_formatter "Error occured: %a\n" pp_global_error err;
127+
print_flush ();
128+
run_repl_helper run type_env value_env new_state values_acc
129+
| new_state, Ok (new_type_env, new_value_env, evaled_names) ->
130+
(match ic with
131+
| None ->
132+
Base.Map.iteri
133+
~f:(fun ~key ~data ->
134+
let t, v = data in
135+
fprintf
136+
std_formatter
137+
"val %s : %a = %a\n"
138+
key
139+
pp_typ
140+
t
141+
ValueEnv.pp_value
142+
v)
143+
evaled_names;
144+
print_flush ();
145+
run_repl_helper run new_type_env new_value_env new_state values_acc
146+
| Some _ ->
147+
let overwrite map1 map2 =
148+
Base.Map.fold
149+
~init:map1
150+
~f:(fun ~key ~data map1 -> Base.Map.set map1 ~key ~data)
151+
map2
152+
in
153+
let values_acc = overwrite values_acc evaled_names in
154+
run_repl_helper run new_type_env new_value_env new_state values_acc))
155155
in
156156
let type_env = TypeEnv.default in
157157
let value_env = ValueEnv.default in

0 commit comments

Comments
 (0)