colonnade-0.4.6: Generic types and functions for columnar encoding and decoding

Safe HaskellNone
LanguageHaskell2010

Colonnade.Decoding

Synopsis

Documentation

contramapContent :: forall c1 c2 f a. Contravariant f => (c2 -> c1) -> Decoding f c1 a -> Decoding f c2 a Source #

Converts the content type of a Decoding. The Contravariant f constraint means that f can be Headless but not Headed.

headless :: (content -> Either String a) -> Decoding Headless content a Source #

headed :: content -> (content -> Either String a) -> Decoding Headed content a Source #

indexed :: Int -> (content -> Either String a) -> Decoding (Indexed Headless) content a Source #

maxIndex :: forall f c a. Decoding (Indexed f) c a -> Int Source #

uncheckedRunWithRow :: Int -> Decoding (Indexed f) content a -> Vector content -> Either (DecodingRowError f content) a Source #

This function uses unsafeIndex to access elements of the Vector.

uncheckedRun :: forall content a f. Decoding (Indexed f) content a -> Vector content -> Either (DecodingCellErrors f content) a Source #

This function does not check to make sure that the indicies in the Decoding are in the Vector.

length :: forall f c a. Decoding f c a -> Int Source #

headedToIndexed Source #

Arguments

:: Eq content 
=> Vector content

Headers in the source document

-> Decoding Headed content a

Decoding that contains expected headers

-> Either (HeadingErrors content) (Decoding (Indexed Headed) content a) 

Maps over a Decoding that expects headers, converting these expected headers into the indices of the columns that they correspond to.

prettyError :: (c -> String) -> DecodingRowError f c -> String Source #

This adds one to the index because text editors consider line number to be one-based, not zero-based.

prettyRowError :: (content -> String) -> RowError f content -> (String, [String]) Source #