-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathx.ml
41 lines (32 loc) · 800 Bytes
/
x.ml
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
let p = Printf.printf
let x = "X"
let string_formatter oc x = output_string oc x
let int = 1
let int_formatter oc x = Printf.fprintf oc "%d" x
let float = 2.0
let float_formatter oc x = Printf.fprintf oc "%g" x
let story = "STORY"
let told = "TOLD"
let started = "STARTED"
let () =
p [%fmt "$story"]
let () =
p [%fmt "${1, %d}"]
let () =
p [%fmt {|${x, string_formatter}|}]
let () =
p [%fmt "${int, int_formatter} looks different than ${float, float_formatter}!"]
let () = p [%fmt
{xxx|This is a $story
That is still being ${told, %s}
But before we get ${"started", string_formatter}
We're all gonna get $$old|xxx}
]
let f () () =
Printf.ksprintf print_endline
let () =
f () () [%fmt "$x"]
let g () ~fmt =
Printf.ksprintf print_endline fmt
let () =
g () ~fmt:[%fmt "$story"]