colonnade-0.5: 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) -> Decolonnade f c1 a -> Decolonnade f c2 a Source #

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

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

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

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

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

uncheckedRunWithRow :: Int -> Decolonnade (Indexed f) content a -> Vector content -> Either (DecolonnadeRowError f content) a Source #

This function uses unsafeIndex to access elements of the Vector.

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

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

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

headedToIndexed Source #

Arguments

:: Eq content 
=> Vector content

Headers in the source document

-> Decolonnade Headed content a

Decolonnade that contains expected headers

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

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

prettyError :: (c -> String) -> DecolonnadeRowError 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 #