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
type t =
| Index of int
| Id of int
| Description of string
| Label of string
[@@deriving eq, ord, show]
let to_yojson = function
| Index x -> `List [`String "index"; `Int x]
| Id x -> `List [`String "id"; `Int x]
| Description x -> `List [`String "description"; `String x]
| Label x -> `List [`String "label"; `String x]
let of_yojson = function
| `List [`String "index"; `Int x] -> Ok (Index x)
| `List [`String "id"; `Int x] -> Ok (Id x)
| `List [`String "description"; `String x] -> Ok (Description x)
| `List [`String "label"; `String x] -> Ok (Label x)
| _ -> Error "Slot.t"
let default = Index 0
let to_string = function
| Index i -> ("slot index", string_of_int i)
| Id i -> ("slot ID", string_of_int i)
| Description s -> ("slot description", s)
| Label s -> ("token label", s)