-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Encode and decode CSV files -- -- Please see README.md @package siphon @version 0.6 module Siphon.Types newtype Escaped c Escaped :: c -> Escaped c [getEscaped] :: Escaped c -> c data Siphon c Siphon :: !(c -> Escaped c) -> !(Vector (Escaped c) -> c) -> (c -> IResult c (Vector c)) -> (c -> Bool) -> Siphon c [siphonEscape] :: Siphon c -> !(c -> Escaped c) [siphonIntercalate] :: Siphon c -> !(Vector (Escaped c) -> c) [siphonParseRow] :: Siphon c -> c -> IResult c (Vector c) [siphonNull] :: Siphon c -> c -> Bool data DecolonnadeCellError f content DecolonnadeCellError :: !content -> !(Indexed f content) -> !String -> DecolonnadeCellError f content [decodingCellErrorContent] :: DecolonnadeCellError f content -> !content [decodingCellErrorHeader] :: DecolonnadeCellError f content -> !(Indexed f content) [decodingCellErrorMessage] :: DecolonnadeCellError f content -> !String data Indexed f a Indexed :: !Int -> !(f a) -> Indexed f a [indexedIndex] :: Indexed f a -> !Int [indexedHeading] :: Indexed f a -> !(f a) newtype DecolonnadeCellErrors f content DecolonnadeCellErrors :: Vector (DecolonnadeCellError f content) -> DecolonnadeCellErrors f content [getDecolonnadeCellErrors] :: DecolonnadeCellErrors f content -> Vector (DecolonnadeCellError f content) data DecolonnadeRowError f content DecolonnadeRowError :: !Int -> !(RowError f content) -> DecolonnadeRowError f content [decodingRowErrorRow] :: DecolonnadeRowError f content -> !Int [decodingRowErrorError] :: DecolonnadeRowError f content -> !(RowError f content) data RowError f content -- | Error occurred parsing the document into cells RowErrorParse :: !String -> RowError f content -- | Error decoding the content RowErrorDecode :: !(DecolonnadeCellErrors f content) -> RowError f content -- | Wrong number of cells in the row RowErrorSize :: !Int -> !Int -> RowError f content RowErrorHeading :: !(HeadingErrors content) -> RowError f content RowErrorMinSize :: !Int -> !Int -> RowError f content -- | Error decoding unicode content RowErrorMalformed :: !String -> RowError f content data HeadingErrors content HeadingErrors :: Vector content -> Vector (content, Int) -> HeadingErrors content -- | headers that were missing [headingErrorsMissing] :: HeadingErrors content -> Vector content -- | headers that occurred more than once [headingErrorsDuplicate] :: HeadingErrors content -> Vector (content, Int) -- | This just actually a specialization of the free applicative. Check out -- Control.Applicative.Free in the free library to -- learn more about this. The meanings of the fields are documented -- slightly more in the source code. Unfortunately, haddock does not play -- nicely with GADTs. data Decolonnade f content a [DecolonnadePure] :: !a -> Decolonnade f content a [DecolonnadeAp] :: !(f content) -> !(content -> Either String a) -> !(Decolonnade f content (a -> b)) -> Decolonnade f content b instance (GHC.Classes.Eq (f content), GHC.Classes.Eq content) => GHC.Classes.Eq (Siphon.Types.DecolonnadeRowError f content) instance (GHC.Read.Read (f content), GHC.Read.Read content) => GHC.Read.Read (Siphon.Types.DecolonnadeRowError f content) instance (GHC.Show.Show (f content), GHC.Show.Show content) => GHC.Show.Show (Siphon.Types.DecolonnadeRowError f content) instance (GHC.Classes.Eq (f content), GHC.Classes.Eq content) => GHC.Classes.Eq (Siphon.Types.RowError f content) instance (GHC.Read.Read (f content), GHC.Read.Read content) => GHC.Read.Read (Siphon.Types.RowError f content) instance (GHC.Show.Show (f content), GHC.Show.Show content) => GHC.Show.Show (Siphon.Types.RowError f content) instance GHC.Classes.Eq content => GHC.Classes.Eq (Siphon.Types.HeadingErrors content) instance GHC.Read.Read content => GHC.Read.Read (Siphon.Types.HeadingErrors content) instance GHC.Show.Show content => GHC.Show.Show (Siphon.Types.HeadingErrors content) instance (GHC.Classes.Eq (f content), GHC.Classes.Eq content) => GHC.Classes.Eq (Siphon.Types.DecolonnadeCellErrors f content) instance (GHC.Read.Read (f content), GHC.Read.Read content) => GHC.Read.Read (Siphon.Types.DecolonnadeCellErrors f content) instance (GHC.Show.Show (f content), GHC.Show.Show content) => GHC.Show.Show (Siphon.Types.DecolonnadeCellErrors f content) instance GHC.Base.Monoid (Siphon.Types.DecolonnadeCellErrors f content) instance (GHC.Classes.Eq (f content), GHC.Classes.Eq content) => GHC.Classes.Eq (Siphon.Types.DecolonnadeCellError f content) instance (GHC.Read.Read (f content), GHC.Read.Read content) => GHC.Read.Read (Siphon.Types.DecolonnadeCellError f content) instance (GHC.Show.Show (f content), GHC.Show.Show content) => GHC.Show.Show (Siphon.Types.DecolonnadeCellError f content) instance GHC.Read.Read (f a) => GHC.Read.Read (Siphon.Types.Indexed f a) instance GHC.Show.Show (f a) => GHC.Show.Show (Siphon.Types.Indexed f a) instance GHC.Base.Functor f => GHC.Base.Functor (Siphon.Types.Indexed f) instance GHC.Classes.Ord (f a) => GHC.Classes.Ord (Siphon.Types.Indexed f a) instance GHC.Classes.Eq (f a) => GHC.Classes.Eq (Siphon.Types.Indexed f a) instance (GHC.Show.Show content, Data.Typeable.Internal.Typeable content) => GHC.Exception.Exception (Siphon.Types.HeadingErrors content) instance GHC.Base.Monoid (Siphon.Types.HeadingErrors content) instance GHC.Base.Functor (Siphon.Types.Decolonnade f content) instance GHC.Base.Applicative (Siphon.Types.Decolonnade f content) module Siphon.Text siphon :: Siphon Text encodeRow :: Vector (Escaped Text) -> Text escape :: Text -> Escaped Text escapeAlways :: Text -> Escaped Text module Siphon.Internal.Text text :: Siphon Text encodeRow :: Vector (Escaped Text) -> Text escape :: Text -> Escaped Text -- | This implementation is definitely suboptimal. A better option (which -- would waste a little space but would be much faster) would be to build -- the new text by writing to a buffer directly. escapeAlways :: Text -> Escaped Text -- | Specialized version of sepBy1' which is faster due to not -- accepting an arbitrary separator. sepByDelim1' :: Parser a -> Char -> Parser [a] -- | Specialized version of sepBy1' which is faster due to not -- accepting an arbitrary separator. sepByEndOfLine1' :: Parser a -> Parser [a] -- | Parse a record, not including the terminating line separator. The -- terminating line separate is not included as the last record in a CSV -- file is allowed to not have a terminating line separator. You most -- likely want to use the endOfLine parser in combination with -- this parser. row :: Char -> Parser (Vector Text) rowNoNewline :: Char -> Parser (Vector Text) -- | Parse a field. The field may be in either the escaped or non-escaped -- format. The return value is unescaped. field :: Char -> Parser Text escapedField :: Parser Text escapedFieldInner :: Builder -> Parser Builder unescapedField :: Char -> Parser Text dquote :: Parser Char unescape :: Parser Text -- | A strict version of <$> for monads. (<$!>) :: Monad m => (a -> b) -> m a -> m b infixl 4 <$!> -- | A version of liftM2 that is strict in the result of its first -- action. liftM2' :: (Monad m) => (a -> b -> c) -> m a -> m b -> m c -- | Match either a single newline character '\n', or a carriage -- return followed by a newline character "\r\n", or a single -- carriage return '\r'. endOfLine :: Parser () textDoubleQuote :: Text doubleQuote :: Char newline :: Char cr :: Char comma :: Char -- | A CSV parser. The parser defined here is RFC 4180 compliant, with the -- following extensions: -- -- -- -- The functions in this module can be used to implement e.g. a resumable -- parser that is fed input incrementally. module Siphon.Internal byteStringChar8 :: Siphon ByteString encodeRow :: Vector (Escaped ByteString) -> ByteString escape :: ByteString -> Escaped ByteString -- | This implementation is definitely suboptimal. A better option (which -- would waste a little space but would be much faster) would be to build -- the new bytestring by writing to a buffer directly. escapeAlways :: ByteString -> Escaped ByteString -- | Specialized version of sepBy1' which is faster due to not -- accepting an arbitrary separator. sepByDelim1' :: Parser a -> Word8 -> Parser [a] -- | Specialized version of sepBy1' which is faster due to not -- accepting an arbitrary separator. sepByEndOfLine1' :: Parser a -> Parser [a] -- | Parse a record, not including the terminating line separator. The -- terminating line separate is not included as the last record in a CSV -- file is allowed to not have a terminating line separator. You most -- likely want to use the endOfLine parser in combination with -- this parser. row :: Word8 -> Parser (Vector ByteString) rowNoNewline :: Word8 -> Parser (Vector ByteString) removeBlankLines :: [Vector ByteString] -> [Vector ByteString] -- | Parse a field. The field may be in either the escaped or non-escaped -- format. The return value is unescaped. field :: Word8 -> Parser ByteString escapedField :: Parser ByteString unescapedField :: Word8 -> Parser ByteString dquote :: Parser Char -- | This could be improved. We could avoid the builder and just write to a -- buffer directly. unescape :: Parser ByteString -- | A strict version of <$> for monads. (<$!>) :: Monad m => (a -> b) -> m a -> m b infixl 4 <$!> -- | Is this an empty record (i.e. a blank line)? blankLine :: Vector ByteString -> Bool -- | A version of liftM2 that is strict in the result of its first -- action. liftM2' :: (Monad m) => (a -> b -> c) -> m a -> m b -> m c -- | Match either a single newline character '\n', or a carriage -- return followed by a newline character "\r\n", or a single -- carriage return '\r'. endOfLine :: Parser () doubleQuote :: Word8 newline :: Word8 cr :: Word8 comma :: Word8 module Siphon.Encoding row :: Siphon c -> Colonnade f a c -> a -> c header :: Siphon c -> Colonnade Headed a c -> c pipe :: Monad m => Siphon c -> Colonnade f a c -> Pipe a c m x headedPipe :: Monad m => Siphon c -> Colonnade Headed a c -> Pipe a c m x module Siphon.Decoding mkParseError :: Int -> [String] -> String -> DecolonnadeRowError f content -- | This is seldom useful but is included for completeness. headlessPipe :: Monad m => Siphon c -> Decolonnade Headless c a -> Pipe c a m (DecolonnadeRowError Headless c) indexedPipe :: Monad m => Siphon c -> Decolonnade (Indexed Headless) c a -> Pipe c a m (DecolonnadeRowError Headless c) headedPipe :: (Monad m, Eq c) => Siphon c -> Decolonnade Headed c a -> Pipe c a m (DecolonnadeRowError Headed c) consumeGeneral :: Monad m => Int -> Siphon c -> (Int -> [String] -> String -> e) -> Consumer' c m (Either e (Vector c, Maybe c)) pipeGeneral :: Monad m => Int -> Siphon c -> (Int -> [String] -> String -> e) -> (Int -> Vector c -> Either e a) -> Maybe c -> Pipe c a m e -- | This is a convenience function for working with pipes-text. -- It will convert a UTF-8 decoding error into a -- DecolonnadeRowError, so the pipes can be properly chained -- together. convertDecodeError :: String -> Either (Producer ByteString m ()) () -> Maybe (DecolonnadeRowError f c) headed :: content -> (content -> Either String a) -> Decolonnade Headed content a headless :: (content -> Either String a) -> Decolonnade Headless content a indexed :: Int -> (content -> Either String a) -> Decolonnade (Indexed Headless) content a instance GHC.Base.Functor (Siphon.Decoding.EitherWrap a) instance GHC.Base.Monoid a => GHC.Base.Applicative (Siphon.Decoding.EitherWrap a) module Siphon.Content byteStringChar8 :: Siphon ByteString text :: Siphon Text module Siphon.ByteString.Char8 module Siphon