Skip to content

Commit 1a6a3b2

Browse files
committed
change README
1 parent a5828f8 commit 1a6a3b2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ codecSample = sum "Sample"
169169

170170
The special case of a constructor with zero arguments like `Foo`, we just use `unit` instead of a tuple.
171171

172+
#### Custom encodings
173+
172174
If you need control of the actual encoding being used, there's also [`sumWith`](https://pursuit.purescript.org/packages/purescript-codec-argonaut/docs/Data.Codec.Sum.Sum#v:sumWith). It takes an extra argument of type [`Encoding`](https://pursuit.purescript.org/packages/purescript-codec-argonaut/docs/Data.Codec.Sum#v:Encoding)
173175

174176
Generally two types of encodings are supported:
@@ -180,6 +182,7 @@ Generally two types of encodings are supported:
180182

181183
There are also a couple of extra options that can be specified. E.g. for custom field names instead of `"tag"` and `"value"`.
182184

185+
#### Sum types with only nullary constructors
183186

184187
If you have a sum type that only consists of nullary constructors and it has a [`Generic`](https://pursuit.purescript.org/packages/purescript-generics-rep/docs/Data.Generic.Rep#t:Generic) instance defined, [`nullarySum`](https://pursuit.purescript.org/packages/purescript-codec-argonaut/docs/Data.Codec.Argonaut.Generic#v:nullarySum) provided by [`Data.Codec.Argonaut.Generic`](https://pursuit.purescript.org/packages/purescript-codec-argonaut/docs/Data.Codec.Argonaut.Generic) can generate a codec that will encode the constructors as string values matching the constructor names in the JSON.
185188

0 commit comments

Comments
 (0)