summaryrefslogtreecommitdiff
path: root/src/marker.ml
blob: 19b1be0d6f6abc5bd25470bda0e8258809ebe170 (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
27
28
29
30
31
32
33
34
35
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