@@ -16,7 +16,6 @@ module Data.Codec.Argonaut.Sum
1616import Prelude
1717
1818import Control.Alt ((<|>))
19- import Control.Monad.Error.Class (throwError )
2019import Data.Argonaut.Core (Json )
2120import Data.Argonaut.Core (Json , fromString ) as J
2221import Data.Array (catMaybes )
@@ -290,7 +289,7 @@ checkTag tagKey obj expectedTag = do
290289 ) ∷ _ Json
291290 tag ← CA .decode CA .string val ∷ _ String
292291 unless (tag == expectedTag)
293- $ throwError
292+ $ Left
294293 $ TypeMismatch (" Expecting tag `" <> expectedTag <> " `, got `" <> tag <> " `" )
295294
296295parseNoFields ∷ Encoding → Json → String → Either JsonDecodeError Unit
@@ -303,7 +302,7 @@ parseNoFields encoding json expectedTag =
303302 ) ∷ _ Json
304303 fields ← CA .decode CA .jarray val ∷ _ (Array Json )
305304 when (fields /= [] )
306- $ throwError
305+ $ Left
307306 $ TypeMismatch " Expecting an empty array"
308307
309308 EncodeTagValue { tagKey, valuesKey, omitEmptyArguments } → do
@@ -316,13 +315,13 @@ parseNoFields encoding json expectedTag =
316315 ) ∷ _ Json
317316 fields ← CA .decode CA .jarray val ∷ _ (Array Json )
318317 when (fields /= [] )
319- $ throwError
318+ $ Left
320319 $ TypeMismatch " Expecting an empty array"
321320
322321 EncodeUntagged {} → do
323322 fields ← CA .decode CA .jarray json ∷ _ (Array Json )
324323 when (fields /= [] )
325- $ throwError
324+ $ Left
326325 $ TypeMismatch " Expecting an empty array"
327326
328327parseSingleField ∷ Encoding → Json → String → Either JsonDecodeError Json
@@ -338,7 +337,7 @@ parseSingleField encoding json expectedTag = case encoding of
338337 fields ← CA .decode CA .jarray val
339338 case fields of
340339 [ head ] → pure head
341- _ → throwError $ TypeMismatch " Expecting exactly one element"
340+ _ → Left $ TypeMismatch " Expecting exactly one element"
342341
343342 EncodeTagValue { tagKey, valuesKey, unwrapSingleArguments } → do
344343 obj ← CA .decode jobject json
@@ -353,7 +352,7 @@ parseSingleField encoding json expectedTag = case encoding of
353352 fields ← CA .decode CA .jarray val
354353 case fields of
355354 [ head ] → pure head
356- _ → throwError $ TypeMismatch " Expecting exactly one element"
355+ _ → Left $ TypeMismatch " Expecting exactly one element"
357356
358357 EncodeUntagged { unwrapSingleArguments } → do
359358 if unwrapSingleArguments then
@@ -362,7 +361,7 @@ parseSingleField encoding json expectedTag = case encoding of
362361 fields ← CA .decode CA .jarray json
363362 case fields of
364363 [ head ] → pure head
365- _ → throwError $ TypeMismatch " Expecting exactly one element"
364+ _ → Left $ TypeMismatch " Expecting exactly one element"
366365
367366parseManyFields ∷ Encoding → Json → String → Either JsonDecodeError (Array Json )
368367parseManyFields encoding json expectedTag =
0 commit comments