mirror of
https://github.com/byteverse/colonnade.git
synced 2024-09-11 06:45:41 +03:00
add column indexing function
This commit is contained in:
parent
5325778502
commit
3240edd8ec
@ -23,9 +23,12 @@ headless f = DecodingAp Headless f (DecodingPure id)
|
||||
headed :: content -> (content -> Either String a) -> Decoding Headed content a
|
||||
headed h f = DecodingAp (Headed h) f (DecodingPure id)
|
||||
|
||||
-- | Maps over a 'Decoding' that expects headers, converting these
|
||||
-- expected headers into the indices of the columns that they
|
||||
-- correspond to.
|
||||
headedToIndexed :: forall content a. Eq content
|
||||
=> Vector content
|
||||
-> Decoding Headed content a
|
||||
=> Vector content -- ^ Headers in the source document
|
||||
-> Decoding Headed content a -- ^ Decoding that contains expected headers
|
||||
-> Either (HeadingError content) (Decoding Indexed content a)
|
||||
headedToIndexed v = go
|
||||
where
|
||||
|
@ -14,6 +14,8 @@ module Colonnade.Types
|
||||
import Data.Vector (Vector)
|
||||
import Data.Functor.Contravariant (Contravariant(..))
|
||||
import Data.Functor.Contravariant.Divisible (Divisible(..))
|
||||
import Control.Exception (Exception)
|
||||
import Data.Typeable (Typeable)
|
||||
import qualified Data.Vector as Vector
|
||||
|
||||
-- | Isomorphic to 'Identity'
|
||||
@ -33,6 +35,8 @@ data HeadingError content = HeadingError
|
||||
, headingErrorDuplicate :: Vector (content,Int) -- ^ headers that occurred more than once
|
||||
} deriving (Show,Read)
|
||||
|
||||
instance (Show content, Typeable content) => Exception (HeadingError content)
|
||||
|
||||
instance Monoid (HeadingError content) where
|
||||
mempty = HeadingError Vector.empty Vector.empty
|
||||
mappend (HeadingError a1 b1) (HeadingError a2 b2) = HeadingError
|
||||
|
Loading…
Reference in New Issue
Block a user