mirror of
https://github.com/byteverse/colonnade.git
synced 2024-09-11 06:45:41 +03:00
switch to using EitherWrap
This commit is contained in:
parent
5f9e4f6416
commit
4a2091acef
@ -2,6 +2,7 @@
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
module Colonnade.Decoding where
|
||||
|
||||
import Colonnade.Internal (EitherWrap(..))
|
||||
import Colonnade.Types
|
||||
import Data.Functor.Contravariant
|
||||
import Data.Vector (Vector)
|
||||
@ -27,17 +28,17 @@ uncheckedRun :: forall content a.
|
||||
Vector content
|
||||
-> Decoding Indexed content a
|
||||
-> Either (DecodingErrors Indexed content) a
|
||||
uncheckedRun v = go
|
||||
uncheckedRun v = getEitherWrap . go
|
||||
where
|
||||
go :: forall b.
|
||||
Decoding Indexed content b
|
||||
-> Either (DecodingErrors Indexed content) b
|
||||
go (DecodingPure b) = Right b
|
||||
-> EitherWrap (DecodingErrors Indexed content) b
|
||||
go (DecodingPure b) = EitherWrap (Right b)
|
||||
go (DecodingAp (Indexed ix) decode apNext) =
|
||||
let rnext = go apNext
|
||||
content = Vector.unsafeIndex v ix
|
||||
rcurrent = mapLeft (DecodingErrors . Vector.singleton . DecodingError content (Indexed ix)) (decode content)
|
||||
in eitherMonoidAp rnext rcurrent
|
||||
in rnext <*> (EitherWrap rcurrent)
|
||||
|
||||
-- | Maps over a 'Decoding' that expects headers, converting these
|
||||
-- expected headers into the indices of the columns that they
|
||||
|
Loading…
Reference in New Issue
Block a user