Skip to content

Commit 900278e

Browse files
committed
Refactor infix operator
1 parent 3018283 commit 900278e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tools/src/prettier_printer.ml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module CodePrinter = struct
111111
let id x = x
112112

113113
(** add a write event to the context *)
114-
let ( !- ) str ctx =
114+
let write str ctx =
115115
{
116116
ctx with
117117
events = Write str :: ctx.events;
@@ -135,16 +135,16 @@ module CodePrinter = struct
135135
}
136136
|> updateMode true
137137

138-
let sepSpace ctx = !-" " ctx
139-
let sepComma ctx = !-", " ctx
140-
let sepSemi ctx = !-"; " ctx
141-
let sepOpenT ctx = !-"(" ctx
142-
let sepCloseT ctx = !-")" ctx
143-
let sepOpenR ctx = !-"{" ctx
144-
let sepCloseR ctx = !-"}" ctx
145-
let sepOpenL ctx = !-"[" ctx
146-
let sepCloseL ctx = !-"]" ctx
147-
let sepEq ctx = !-" = " ctx
138+
let sepSpace ctx = write " " ctx
139+
let sepComma ctx = write ", " ctx
140+
let sepSemi ctx = write "; " ctx
141+
let sepOpenT ctx = write "(" ctx
142+
let sepCloseT ctx = write ")" ctx
143+
let sepOpenR ctx = write "{" ctx
144+
let sepCloseR ctx = write "}" ctx
145+
let sepOpenL ctx = write "[" ctx
146+
let sepCloseL ctx = write "]" ctx
147+
let sepEq ctx = write " = " ctx
148148
let wrapInParentheses f = sepOpenT +> f +> sepCloseT
149149
let indent ctx =
150150
let nextIdent = ctx.current_indent + ctx.indent_size in
@@ -198,14 +198,14 @@ module CodePrinter = struct
198198
| Application (name, argument) -> genApplication name argument
199199
| Record record -> genRecord record
200200
| Ident ident -> genIdent ident
201-
| String str -> !-(Format.sprintf "\"%s\"" str)
201+
| String str -> write (Format.sprintf "\"%s\"" str)
202202
| Tuple ts -> genTuple ts
203203
| List xs -> genList xs
204204

205205
and genApplication (name : string) (argument : oak) : appendEvents =
206-
let short = !-name +> sepOpenT +> genOak argument +> sepCloseT in
206+
let short = write name +> sepOpenT +> genOak argument +> sepCloseT in
207207
let long =
208-
!-name +> sepOpenT
208+
write name +> sepOpenT
209209
+> (match argument with
210210
| List _ | Record _ -> genOak argument
211211
| _ -> indentAndNln (genOak argument) +> sepNln)
@@ -234,17 +234,17 @@ module CodePrinter = struct
234234
let long = col genNamedField sepNln oaks in
235235
expressionFitsOnRestOfLine short long
236236

237-
and genIdent (ident : string) : appendEvents = !-ident
237+
and genIdent (ident : string) : appendEvents = write ident
238238

239239
and genNamedField (field : namedField) : appendEvents =
240240
let genValue =
241241
match field.value with
242242
| Tuple _ -> sepOpenT +> genOak field.value +> sepCloseT
243243
| _ -> genOak field.value
244244
in
245-
let short = !-(field.name) +> sepEq +> genValue in
245+
let short = write (field.name) +> sepEq +> genValue in
246246
let long =
247-
!-(field.name) +> sepEq
247+
write (field.name) +> sepEq
248248
+>
249249
match field.value with
250250
| List _ | Record _ -> genOak field.value

0 commit comments

Comments
 (0)