|
1 | | -type t = |
2 | | - [ `Constructor |
3 | | - | `Labels |
4 | | - | `Modules |
5 | | - | `Modules_type |
6 | | - | `Types |
7 | | - | `Values |
8 | | - | `Variants |
9 | | - | `Keywords ] |
| 1 | +module In = struct |
| 2 | + type t = |
| 3 | + [ `Constructor |
| 4 | + | `Labels |
| 5 | + | `Modules |
| 6 | + | `Modules_type |
| 7 | + | `Types |
| 8 | + | `Values |
| 9 | + | `Variants |
| 10 | + | `Keywords ] |
| 11 | + [@@deriving enumerate, equal] |
10 | 12 |
|
11 | | -let to_string = function |
12 | | - | `Constructor -> "constructor" |
13 | | - | `Keywords -> "keywords" |
14 | | - | `Labels -> "label" |
15 | | - | `Modules -> "module" |
16 | | - | `Modules_type -> "module-type" |
17 | | - | `Types -> "type" |
18 | | - | `Values -> "value" |
19 | | - | `Variants -> "variant" |
| 13 | + let to_string = function |
| 14 | + | `Constructor -> "constructor" |
| 15 | + | `Keywords -> "keywords" |
| 16 | + | `Labels -> "label" |
| 17 | + | `Modules -> "module" |
| 18 | + | `Modules_type -> "module-type" |
| 19 | + | `Types -> "type" |
| 20 | + | `Values -> "value" |
| 21 | + | `Variants -> "variant" |
20 | 22 |
|
21 | | -let of_string_opt = function |
22 | | - | "t" | "type" | "types" -> Some `Types |
23 | | - | "v" | "val" | "value" | "values" -> Some `Values |
24 | | - | "variant" | "variants" | "var" -> Some `Variants |
25 | | - | "c" | "constr" | "constructor" -> Some `Constructor |
26 | | - | "l" | "label" | "labels" -> Some `Labels |
27 | | - | "m" | "mod" | "module" -> Some `Modules |
28 | | - | "mt" | "modtype" | "module-type" -> Some `Modules_type |
29 | | - | "k" | "kw" | "keyword" | "keywords" -> Some `Keywords |
30 | | - | _ -> None |
| 23 | + let of_string_opt = function |
| 24 | + | "t" | "type" | "types" -> Some `Types |
| 25 | + | "v" | "val" | "value" | "values" -> Some `Values |
| 26 | + | "variant" | "variants" | "var" -> Some `Variants |
| 27 | + | "c" | "constr" | "constructor" -> Some `Constructor |
| 28 | + | "l" | "label" | "labels" -> Some `Labels |
| 29 | + | "m" | "mod" | "module" -> Some `Modules |
| 30 | + | "mt" | "modtype" | "module-type" -> Some `Modules_type |
| 31 | + | "k" | "kw" | "keyword" | "keywords" -> Some `Keywords |
| 32 | + | _ -> None |
| 33 | +end |
| 34 | + |
| 35 | +module Out = struct |
| 36 | + (* CR-someday: This module is necessary because ppx_string_conv doesn't currently |
| 37 | + (v0.17.0) support polymorphic variants. *) |
| 38 | + module For_deriving = struct |
| 39 | + type t = |
| 40 | + | Value [@rename "Value"] |
| 41 | + | Constructor [@rename "Constructor"] |
| 42 | + | Variant [@rename "Variant"] |
| 43 | + | Label [@rename "Label"] |
| 44 | + | Module [@rename "Module"] |
| 45 | + | Modtype [@rename "Signature"] |
| 46 | + | Type [@rename "Type"] |
| 47 | + | MethodCall [@rename "#"] |
| 48 | + | Keyword [@rename "Keyword"] |
| 49 | + [@@deriving string] |
| 50 | + |
| 51 | + let to_poly = function |
| 52 | + | Value -> `Value |
| 53 | + | Constructor -> `Constructor |
| 54 | + | Variant -> `Variant |
| 55 | + | Label -> `Label |
| 56 | + | Module -> `Module |
| 57 | + | Modtype -> `Modtype |
| 58 | + | Type -> `Type |
| 59 | + | MethodCall -> `MethodCall |
| 60 | + | Keyword -> `Keyword |
| 61 | + |
| 62 | + let of_poly = function |
| 63 | + | `Value -> Value |
| 64 | + | `Constructor -> Constructor |
| 65 | + | `Variant -> Variant |
| 66 | + | `Label -> Label |
| 67 | + | `Module -> Module |
| 68 | + | `Modtype -> Modtype |
| 69 | + | `Type -> Type |
| 70 | + | `MethodCall -> MethodCall |
| 71 | + | `Keyword -> Keyword |
| 72 | + end |
| 73 | + |
| 74 | + type t = |
| 75 | + [ `Value |
| 76 | + | `Constructor |
| 77 | + | `Variant |
| 78 | + | `Label |
| 79 | + | `Module |
| 80 | + | `Modtype |
| 81 | + | `Type |
| 82 | + | `MethodCall |
| 83 | + | `Keyword ] |
| 84 | + [@@deriving enumerate, equal] |
| 85 | + |
| 86 | + let to_string x = For_deriving.of_poly x |> For_deriving.to_string |
| 87 | + let of_string s = For_deriving.of_string s |> For_deriving.to_poly |
| 88 | +end |
0 commit comments