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