summaryrefslogtreecommitdiff
path: root/src/marker.ml
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-08-08 12:25:37 +0100
committerAkshay <[email protected]>2021-08-08 12:25:37 +0100
commited2a97502cb825877562c05881da4fb2e8eecad6 (patch)
tree32f10ad8b148aec97c0589800a2e226a19f794b2 /src/marker.ml
parent8d568855b305580591263114cc356726f393e4bf (diff)
refactor
Diffstat (limited to 'src/marker.ml')
-rw-r--r--src/marker.ml36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/marker.ml b/src/marker.ml
new file mode 100644
index 0000000..19b1be0
--- /dev/null
+++ b/src/marker.ml
@@ -0,0 +1,36 @@
1module type Marker = sig
2 type t
3 val of_string : string -> t
4 val pp : out_channel -> t -> unit
5end
6
7module Marker = struct
8 type t = Point
9 | Pixel
10 | Circle
11 | TriangleDown
12 | TriangleUp
13 | TriangleLeft
14 | TriangleRight
15 | Custom of string
16
17 exception Invalid_marker_length
18 let of_string s =
19 if String.length s <> 1
20 then raise Invalid_marker_length
21 else Custom(s)
22
23 let pp channel n =
24 (match n with
25 | Point -> "."
26 | Pixel -> ","
27 | Circle -> "o"
28 | TriangleDown -> "v"
29 | TriangleUp -> "^"
30 | TriangleLeft -> ">"
31 | TriangleRight -> "<"
32 | Custom(s) -> s)
33 |> Printf.fprintf channel "%s"
34
35end
36