-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkindkey.ml
51 lines (46 loc) · 1.15 KB
/
kindkey.ml
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
type extracted =
[ `Class
| `ClassType
| `ClassField
| `Constr
| `Exception
| `Field
| `Method
| `ModType
| `Module
| `Type
| `Value
| `Package
]
type search = extracted
type all = search
let to_string = function
| `Class -> "class"
| `ClassType -> "class type"
| `ClassField -> "class val"
| `Constr -> "constr"
| `Exception -> "exception"
| `Field -> "field"
| `Method -> "method"
| `ModType -> "module type"
| `Module -> "module"
| `Type -> "type"
| `Value -> "val"
| `Package -> "package"
let of_string s =
(* CR jfuruse: parsing of kind is very ugly *)
let s = <:s<\s+/ /g>> s in
match s with
| "class" -> Some `Class
| "class val" -> Some `ClassField
| "class type" -> Some `ClassType
| "constr" -> Some `Constr
| "exception" -> Some `Exception
| "field" -> Some `Field
| "method" -> Some `Method
| "module type" -> Some `ModType
| "module" -> Some `Module
| "type" -> Some `Type
| "val" -> Some `Value
| "package" -> Some `Package
| _ -> None