You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type GenericEnumOptions = { constructorTagTransform :: String -> String }
7
+
```
8
+
9
+
#### `defaultGenericEnumOptions`
10
+
11
+
```purescript
12
+
defaultGenericEnumOptions :: GenericEnumOptions
13
+
```
14
+
15
+
#### `genericDecodeEnum`
16
+
17
+
```purescript
18
+
genericDecodeEnum :: forall a rep. Generic a rep => GenericDecodeEnum rep => GenericEnumOptions -> Foreign -> F a
19
+
```
20
+
21
+
A generic function to be used with "Enums", or sum types with only no-argument constructors. This is used for decoding from strings to one of the constructors, combined with the `constructorTagTransform` property of `SumEncoding`.
22
+
23
+
#### `genericEncodeEnum`
24
+
25
+
```purescript
26
+
genericEncodeEnum :: forall a rep. Generic a rep => GenericEncodeEnum rep => GenericEnumOptions -> a -> Foreign
27
+
```
28
+
29
+
A generic function to be used with "Enums", or sum types with only no-argument constructors. This is used for encoding to strings from one of the constructors, combined with the `constructorTagTransform` property of `SumEncoding`.
decodeEnum :: GenericEnumOptions -> Foreign -> F a
44
+
```
45
+
46
+
A type class for type representations that can be used for decoding to an Enum. Only the sum and no-argument constructor instances are valid, while others provide a `Fail` constraint to fail in compilation.
(GenericDecodeEnum a, GenericDecodeEnum b) => GenericDecodeEnum (Sum a b)
60
+
(IsSymbol name) => GenericDecodeEnum (Constructor name NoArguments)
61
+
(Fail "genericEncode/DecodeEnum cannot be used on types that are not sums of constructors with no arguments.") => GenericDecodeEnum (Constructor name (Argument a))
62
+
(Fail "genericEncode/DecodeEnum cannot be used on types that are not sums of constructors with no arguments.") => GenericDecodeEnum (Constructor name (Product a b))
63
+
(Fail "genericEncode/DecodeEnum cannot be used on types that are not sums of constructors with no arguments.") => GenericDecodeEnum (Constructor name (Rec a))
64
+
```
65
+
66
+
#### `GenericEncodeEnum`
67
+
68
+
```purescript
69
+
class GenericEncodeEnum a where
70
+
encodeEnum :: GenericEnumOptions -> a -> Foreign
71
+
```
72
+
73
+
A type class for type representations that can be used for encoding from an Enum. Only the sum and no-argument constructor instances are valid, while others provide a `Fail` constraint to fail in compilation.
74
+
75
+
##### Instances
76
+
```purescript
77
+
(GenericEncodeEnum a, GenericEncodeEnum b) => GenericEncodeEnum (Sum a b)
78
+
(IsSymbol name) => GenericEncodeEnum (Constructor name NoArguments)
79
+
(Fail "genericEncode/DecodeEnum cannot be used on types that are not sums of constructors with no arguments.") => GenericEncodeEnum (Constructor name (Argument a))
80
+
(Fail "genericEncode/DecodeEnum cannot be used on types that are not sums of constructors with no arguments.") => GenericEncodeEnum (Constructor name (Product a b))
81
+
(Fail "genericEncode/DecodeEnum cannot be used on types that are not sums of constructors with no arguments.") => GenericEncodeEnum (Constructor name (Rec a))
0 commit comments