1open Base
2
3type t = int
4
5let of_int = Fn.id
6let to_int = Fn.id
7let of_string = Int.of_string
8let to_string = Int.to_string
9
10let render t =
11 let value = to_int t in
12 let scaled = Int.min 5 (Int.max 0 value) in
13 let yellow = "\027[33m" in
14 let reset = "\027[0m" in
15 let block =
16 match scaled with
17 | 0 -> " "
18 | 1 -> "░"
19 | 2 -> "▒"
20 | 3 -> "▓"
21 | 4 -> "█"
22 | 5 -> "█"
23 | _ -> assert false
24 in
25 yellow ^ block ^ reset