@@ -99,17 +99,17 @@ taggedSum name printTag parseTag f g = Codec.codec decodeCase encodeCase
99
99
-- ------------------------------------------------------------------------------
100
100
101
101
data Encoding
102
- = EncodeCtorAsTag
102
+ = EncodeNested
103
103
{ unwrapSingleArguments ∷ Boolean }
104
- | EncodeTagValue
104
+ | EncodeTagged
105
105
{ tagKey ∷ String
106
106
, valuesKey ∷ String
107
107
, omitEmptyArguments ∷ Boolean
108
108
, unwrapSingleArguments ∷ Boolean
109
109
}
110
110
111
111
defaultEncoding ∷ Encoding
112
- defaultEncoding = EncodeTagValue
112
+ defaultEncoding = EncodeTagged
113
113
{ tagKey: " tag"
114
114
, valuesKey: " values"
115
115
, unwrapSingleArguments: false
@@ -293,7 +293,7 @@ checkTag tagKey obj expectedTag = do
293
293
parseNoFields ∷ Encoding → Json → String → Either JsonDecodeError Unit
294
294
parseNoFields encoding json expectedTag =
295
295
case encoding of
296
- EncodeCtorAsTag {} → do
296
+ EncodeNested {} → do
297
297
obj ← CA .decode jobject json
298
298
val ←
299
299
( Obj .lookup expectedTag obj # note (TypeMismatch (" Expecting a property `" <> expectedTag <> " `" ))
@@ -303,7 +303,7 @@ parseNoFields encoding json expectedTag =
303
303
$ Left
304
304
$ TypeMismatch " Expecting an empty array"
305
305
306
- EncodeTagValue { tagKey, valuesKey, omitEmptyArguments } → do
306
+ EncodeTagged { tagKey, valuesKey, omitEmptyArguments } → do
307
307
obj ← CA .decode jobject json
308
308
checkTag tagKey obj expectedTag
309
309
when (not omitEmptyArguments) do
@@ -318,7 +318,7 @@ parseNoFields encoding json expectedTag =
318
318
319
319
parseSingleField ∷ Encoding → Json → String → Either JsonDecodeError Json
320
320
parseSingleField encoding json expectedTag = case encoding of
321
- EncodeCtorAsTag { unwrapSingleArguments } → do
321
+ EncodeNested { unwrapSingleArguments } → do
322
322
obj ← CA .decode jobject json
323
323
val ←
324
324
( Obj .lookup expectedTag obj # note (TypeMismatch (" Expecting a property `" <> expectedTag <> " `" ))
@@ -331,7 +331,7 @@ parseSingleField encoding json expectedTag = case encoding of
331
331
[ head ] → pure head
332
332
_ → Left $ TypeMismatch " Expecting exactly one element"
333
333
334
- EncodeTagValue { tagKey, valuesKey, unwrapSingleArguments } → do
334
+ EncodeTagged { tagKey, valuesKey, unwrapSingleArguments } → do
335
335
obj ← CA .decode jobject json
336
336
checkTag tagKey obj expectedTag
337
337
val ←
@@ -349,14 +349,14 @@ parseSingleField encoding json expectedTag = case encoding of
349
349
parseManyFields ∷ Encoding → Json → String → Either JsonDecodeError (Array Json )
350
350
parseManyFields encoding json expectedTag =
351
351
case encoding of
352
- EncodeCtorAsTag {} → do
352
+ EncodeNested {} → do
353
353
obj ← CA .decode jobject json
354
354
val ←
355
355
( Obj .lookup expectedTag obj # note (TypeMismatch (" Expecting a property `" <> expectedTag <> " `" ))
356
356
) ∷ _ Json
357
357
CA .decode CA .jarray val
358
358
359
- EncodeTagValue { tagKey, valuesKey } → do
359
+ EncodeTagged { tagKey, valuesKey } → do
360
360
obj ← CA .decode jobject json
361
361
checkTag tagKey obj expectedTag
362
362
val ←
@@ -368,7 +368,7 @@ parseManyFields encoding json expectedTag =
368
368
encodeSumCase ∷ Encoding → String → Array Json → Json
369
369
encodeSumCase encoding tag jsons =
370
370
case encoding of
371
- EncodeCtorAsTag { unwrapSingleArguments } →
371
+ EncodeNested { unwrapSingleArguments } →
372
372
let
373
373
val = case jsons of
374
374
[] → CA .encode CA .jarray []
@@ -379,7 +379,7 @@ encodeSumCase encoding tag jsons =
379
379
[ tag /\ val
380
380
]
381
381
382
- EncodeTagValue { tagKey, valuesKey, unwrapSingleArguments, omitEmptyArguments } →
382
+ EncodeTagged { tagKey, valuesKey, unwrapSingleArguments, omitEmptyArguments } →
383
383
let
384
384
tagEntry =
385
385
Just (tagKey /\ CA .encode CA .string tag) ∷ Maybe (String /\ Json )
0 commit comments