From ed2a97502cb825877562c05881da4fb2e8eecad6 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 8 Aug 2021 16:55:37 +0530 Subject: refactor --- src/marker.ml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/marker.ml (limited to 'src/marker.ml') 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 @@ +module type Marker = sig + type t + val of_string : string -> t + val pp : out_channel -> t -> unit +end + +module Marker = struct + type t = Point + | Pixel + | Circle + | TriangleDown + | TriangleUp + | TriangleLeft + | TriangleRight + | Custom of string + + exception Invalid_marker_length + let of_string s = + if String.length s <> 1 + then raise Invalid_marker_length + else Custom(s) + + let pp channel n = + (match n with + | Point -> "." + | Pixel -> "," + | Circle -> "o" + | TriangleDown -> "v" + | TriangleUp -> "^" + | TriangleLeft -> ">" + | TriangleRight -> "<" + | Custom(s) -> s) + |> Printf.fprintf channel "%s" + +end + -- cgit v1.2.3