AK
Size: a a a
AK
ST
AK
ST
AK
import Json.Decode exposing (map3)
ST
AK
AK
AK
ST
AK
AK
AK
ST
AK
ST
AK
AK
trickyDecoder : Decoder DecodedTypeWithErrorsAccumulated
trickyDecoder =
Decode.field "lotsOfFields" Decode.value
|> Decode.andThen
((\a ->
let
left : Result String { lefty : List DecodedType, decodingErrors : List String }
left =
Decode.decodeValue (typeDecoder "left") a
right : Result String { sails : List DecodedType, decodingErrors : List String }
right =
Decode.decodeValue (typeDecoder "right") a
errors : List String
errors =
Result.map2 (\a b -> List.concat [ a.decodingErrors, b.decodingErrors ]) left right |> Result.withDefault []
emptyListToMaybe : List a -> Maybe (List a)
emptyListToMaybe list =
if List.isEmpty list then
Nothing
else
Just list
—lot's of code that actually forms the VALID payload
decodedType =
"DecodedTypeHardcoreListOfSomething"
—
in
{ type_ = decodedType, decodingErrors = errors, encodedValue = a }
)
— some more functions
» Decode.succeed
)
AK
AK