blob: c459dcacf5cbe6230afc3a625b81b21d0e38403d (
plain)
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
|
type 'a t = UTF8.Buffer.buffer -> unit
type 'a obs = UTF8.Buffer.buffer -> unit
let str s buffer =
UTF8.Buffer.add_string buffer s
let num n buffer =
if DataType.Num.is_integer n then
DataType.Num.to_int n
|> string_of_int
|> UTF8.from_utf8string
|> UTF8.Buffer.add_string buffer
else
let f = DataType.Num.to_float n
and to_b = UTF8.Format.formatter_of_buffer buffer in
ignore @@ UTF8.Format.fprintf to_b "%.2f" f;
Format.pp_print_flush to_b ()
let date n buffer =
let y, m, d = DataType.Date.date_from_julian_day n in
UTF8.Printf.bprintf buffer "%d/%d/%d" y m d
let bool b buffer =
UTF8.Printf.bprintf buffer "%B" b
let observe elem buffer = elem buffer
|