@@ -16,7 +16,6 @@ module Data.Codec.Argonaut.Sum
16
16
import Prelude
17
17
18
18
import Control.Alt ((<|>))
19
- import Control.Monad.Error.Class (throwError )
20
19
import Data.Argonaut.Core (Json )
21
20
import Data.Argonaut.Core (Json , fromString ) as J
22
21
import Data.Array (catMaybes )
@@ -290,7 +289,7 @@ checkTag tagKey obj expectedTag = do
290
289
) ∷ _ Json
291
290
tag ← CA .decode CA .string val ∷ _ String
292
291
unless (tag == expectedTag)
293
- $ throwError
292
+ $ Left
294
293
$ TypeMismatch (" Expecting tag `" <> expectedTag <> " `, got `" <> tag <> " `" )
295
294
296
295
parseNoFields ∷ Encoding → Json → String → Either JsonDecodeError Unit
@@ -303,7 +302,7 @@ parseNoFields encoding json expectedTag =
303
302
) ∷ _ Json
304
303
fields ← CA .decode CA .jarray val ∷ _ (Array Json )
305
304
when (fields /= [] )
306
- $ throwError
305
+ $ Left
307
306
$ TypeMismatch " Expecting an empty array"
308
307
309
308
EncodeTagValue { tagKey, valuesKey, omitEmptyArguments } → do
@@ -316,13 +315,13 @@ parseNoFields encoding json expectedTag =
316
315
) ∷ _ Json
317
316
fields ← CA .decode CA .jarray val ∷ _ (Array Json )
318
317
when (fields /= [] )
319
- $ throwError
318
+ $ Left
320
319
$ TypeMismatch " Expecting an empty array"
321
320
322
321
EncodeUntagged {} → do
323
322
fields ← CA .decode CA .jarray json ∷ _ (Array Json )
324
323
when (fields /= [] )
325
- $ throwError
324
+ $ Left
326
325
$ TypeMismatch " Expecting an empty array"
327
326
328
327
parseSingleField ∷ Encoding → Json → String → Either JsonDecodeError Json
@@ -338,7 +337,7 @@ parseSingleField encoding json expectedTag = case encoding of
338
337
fields ← CA .decode CA .jarray val
339
338
case fields of
340
339
[ head ] → pure head
341
- _ → throwError $ TypeMismatch " Expecting exactly one element"
340
+ _ → Left $ TypeMismatch " Expecting exactly one element"
342
341
343
342
EncodeTagValue { tagKey, valuesKey, unwrapSingleArguments } → do
344
343
obj ← CA .decode jobject json
@@ -353,7 +352,7 @@ parseSingleField encoding json expectedTag = case encoding of
353
352
fields ← CA .decode CA .jarray val
354
353
case fields of
355
354
[ head ] → pure head
356
- _ → throwError $ TypeMismatch " Expecting exactly one element"
355
+ _ → Left $ TypeMismatch " Expecting exactly one element"
357
356
358
357
EncodeUntagged { unwrapSingleArguments } → do
359
358
if unwrapSingleArguments then
@@ -362,7 +361,7 @@ parseSingleField encoding json expectedTag = case encoding of
362
361
fields ← CA .decode CA .jarray json
363
362
case fields of
364
363
[ head ] → pure head
365
- _ → throwError $ TypeMismatch " Expecting exactly one element"
364
+ _ → Left $ TypeMismatch " Expecting exactly one element"
366
365
367
366
parseManyFields ∷ Encoding → Json → String → Either JsonDecodeError (Array Json )
368
367
parseManyFields encoding json expectedTag =
0 commit comments