-
Notifications
You must be signed in to change notification settings - Fork 4
/
formatters.sml
executable file
·25 lines (20 loc) · 997 Bytes
/
formatters.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
val string_formatter = fn s => s
val int_formatter = Int.toString
val bool_formatter = Bool.toString
fun a_list_formatter element_formatter list =
case list of
[] => "[]"
| elements => "[" ^ (String.concatWith ", " (List.map element_formatter elements)) ^ "]"
fun a_option_formatter value_formatter option =
case option of
NONE => "NONE"
| SOME value => "SOME " ^ value_formatter(value)
val string_list_formatter = a_list_formatter string_formatter
val int_list_formatter = a_list_formatter int_formatter
val bool_list_formatter = a_list_formatter bool_formatter
val string_list_option_formatter = a_option_formatter string_list_formatter
val int_list_option_formatter = a_option_formatter int_list_formatter
val bool_list_option_formatter = a_option_formatter bool_list_formatter
val string_option_formatter = a_option_formatter string_formatter
val int_option_formatter = a_option_formatter int_formatter
val bool_option_formatter = a_option_formatter bool_formatter