Skip to content

Commit e9f8608

Browse files
committed
Remove untagged
1 parent 94f51b3 commit e9f8608

File tree

2 files changed

+0
-92
lines changed

2 files changed

+0
-92
lines changed

src/Data/Codec/Argonaut/Sum.purs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ data Encoding
107107
, omitEmptyArguments Boolean
108108
, unwrapSingleArguments Boolean
109109
}
110-
| EncodeUntagged
111-
{ unwrapSingleArguments Boolean }
112110

113111
defaultEncoding Encoding
114112
defaultEncoding = EncodeTagValue
@@ -318,12 +316,6 @@ parseNoFields encoding json expectedTag =
318316
$ Left
319317
$ TypeMismatch "Expecting an empty array"
320318

321-
EncodeUntagged {} → do
322-
fields ← CA.decode CA.jarray json _ (Array Json)
323-
when (fields /= [])
324-
$ Left
325-
$ TypeMismatch "Expecting an empty array"
326-
327319
parseSingleField Encoding Json String Either JsonDecodeError Json
328320
parseSingleField encoding json expectedTag = case encoding of
329321
EncodeCtorAsTag { unwrapSingleArguments } → do
@@ -354,15 +346,6 @@ parseSingleField encoding json expectedTag = case encoding of
354346
[ head ] → pure head
355347
_ → Left $ TypeMismatch "Expecting exactly one element"
356348

357-
EncodeUntagged { unwrapSingleArguments } → do
358-
if unwrapSingleArguments then
359-
pure json
360-
else do
361-
fields ← CA.decode CA.jarray json
362-
case fields of
363-
[ head ] → pure head
364-
_ → Left $ TypeMismatch "Expecting exactly one element"
365-
366349
parseManyFields Encoding Json String Either JsonDecodeError (Array Json)
367350
parseManyFields encoding json expectedTag =
368351
case encoding of
@@ -382,9 +365,6 @@ parseManyFields encoding json expectedTag =
382365
) _ Json
383366
CA.decode CA.jarray val
384367

385-
EncodeUntagged {} →
386-
CA.decode CA.jarray json
387-
388368
encodeSumCase Encoding String Array Json Json
389369
encodeSumCase encoding tag jsons =
390370
case encoding of
@@ -411,9 +391,3 @@ encodeSumCase encoding tag jsons =
411391
in
412392
encode jobject $ Obj.fromFoldable $ catMaybes
413393
[ tagEntry, valEntry ]
414-
415-
EncodeUntagged { unwrapSingleArguments } →
416-
case jsons of
417-
[]CA.encode CA.jarray []
418-
[ json ] | unwrapSingleArguments → json
419-
manyJsons → CA.encode CA.jarray manyJsons

test/Test/Sum.purs

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -313,71 +313,5 @@ main = do
313313
, "}"
314314
]
315315

316-
log " - EncodeUntagged"
317-
do
318-
log " - default"
319-
do
320-
let
321-
opts = EncodeUntagged
322-
{ unwrapSingleArguments: false
323-
}
324-
check
325-
(codecSample opts)
326-
Foo
327-
$ Str.joinWith "\n"
328-
[ "[]"
329-
]
330-
331-
check
332-
(codecSample opts)
333-
(Bar 42)
334-
$ Str.joinWith "\n"
335-
[ "["
336-
, " 42"
337-
, "]"
338-
]
339-
340-
check
341-
(codecSample opts)
342-
(Baz true "hello" 42)
343-
$ Str.joinWith "\n"
344-
[ "["
345-
, " true,"
346-
, " \"hello\","
347-
, " 42"
348-
, "]"
349-
]
350-
351-
log " - Option: Unwrap single arguments"
352-
do
353-
let
354-
opts = EncodeUntagged
355-
{ unwrapSingleArguments: true
356-
}
357-
check
358-
(codecSample opts)
359-
Foo
360-
$ Str.joinWith "\n"
361-
[ "[]"
362-
]
363-
364-
check
365-
(codecSample opts)
366-
(Bar 42)
367-
$ Str.joinWith "\n"
368-
[ "42"
369-
]
370-
371-
check
372-
(codecSample opts)
373-
(Baz true "hello" 42)
374-
$ Str.joinWith "\n"
375-
[ "["
376-
, " true,"
377-
, " \"hello\","
378-
, " 42"
379-
, "]"
380-
]
381-
382316
quickCheck (propCodec genMySum (codecSample defaultEncoding))
383317

0 commit comments

Comments
 (0)