Copyright | (C) 2014 |
---|---|
License | BSD-style (see the file etc/LICENSE.md) |
Maintainer | Dom De Re |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Conduit interface for cassava
Synopsis
- data CsvParseError
- data CsvStreamHaltParseError = HaltingCsvParseError ByteString Text
- data CsvStreamRecordParseError = CsvStreamRecordParseError Text
- fromCsv :: (FromRecord a, MonadError CsvParseError m) => DecodeOptions -> HasHeader -> ConduitT ByteString a m ()
- fromCsvLiftError :: (FromRecord a, MonadError e m) => (CsvParseError -> e) -> DecodeOptions -> HasHeader -> ConduitT ByteString a m ()
- fromNamedCsv :: (FromNamedRecord a, MonadError CsvParseError m) => DecodeOptions -> ConduitT ByteString a m ()
- fromNamedCsvLiftError :: (FromNamedRecord a, MonadError e m) => (CsvParseError -> e) -> DecodeOptions -> ConduitT ByteString a m ()
- fromCsvStreamError :: (FromRecord a, MonadError e m) => DecodeOptions -> HasHeader -> (CsvStreamHaltParseError -> e) -> ConduitT ByteString (Either CsvStreamRecordParseError a) m ()
- fromCsvStreamErrorNoThrow :: (Monad m, FromRecord a) => DecodeOptions -> HasHeader -> ConduitT ByteString (Either (Either CsvStreamHaltParseError CsvStreamRecordParseError) a) m ()
- fromNamedCsvStreamError :: (FromNamedRecord a, MonadError e m) => DecodeOptions -> (CsvStreamHaltParseError -> e) -> ConduitT ByteString (Either CsvStreamRecordParseError a) m ()
- fromNamedCsvStreamErrorNoThrow :: (Monad m, FromNamedRecord a) => DecodeOptions -> ConduitT ByteString (Either (Either CsvStreamHaltParseError CsvStreamRecordParseError) a) m ()
- toCsv :: (Monad m, ToRecord a) => EncodeOptions -> ConduitT a ByteString m ()
Types
data CsvParseError Source #
Instances
Show CsvParseError Source # | |
Defined in Data.Csv.Conduit showsPrec :: Int -> CsvParseError -> ShowS # show :: CsvParseError -> String # showList :: [CsvParseError] -> ShowS # | |
Eq CsvParseError Source # | |
Defined in Data.Csv.Conduit (==) :: CsvParseError -> CsvParseError -> Bool # (/=) :: CsvParseError -> CsvParseError -> Bool # |
data CsvStreamHaltParseError Source #
When you want to include errors in the stream, this error type represents errors that halt the stream. They do not appear inside the conduit and will instead get returned from running the conduit.
HaltingCsvParseError ByteString Text | the remaining bytestring that was read in but not parsed yet, and the stringy error msg describing the fail. |
Instances
Show CsvStreamHaltParseError Source # | |
Defined in Data.Csv.Conduit showsPrec :: Int -> CsvStreamHaltParseError -> ShowS # show :: CsvStreamHaltParseError -> String # showList :: [CsvStreamHaltParseError] -> ShowS # | |
Eq CsvStreamHaltParseError Source # | |
Defined in Data.Csv.Conduit |
data CsvStreamRecordParseError Source #
When you want to include errors in the stream, these are the errors that can be included in the stream, they are usually problems restricted to individual records, and streaming can resume from the next record you just have to decide on something sensible to do with the per record errors.
CsvStreamRecordParseError Text | The stringy error describing why this record could not be parsed. |
Instances
Show CsvStreamRecordParseError Source # | |
Defined in Data.Csv.Conduit showsPrec :: Int -> CsvStreamRecordParseError -> ShowS # show :: CsvStreamRecordParseError -> String # showList :: [CsvStreamRecordParseError] -> ShowS # | |
Eq CsvStreamRecordParseError Source # | |
Defined in Data.Csv.Conduit |
Conduits
fromCsv :: (FromRecord a, MonadError CsvParseError m) => DecodeOptions -> HasHeader -> ConduitT ByteString a m () Source #
Streams parsed records, Errors are not received in the stream but instead after the pipeline is executed,
If you want to handle errors as they come and resume, see fromCsvStreamError
fromCsvLiftError :: (FromRecord a, MonadError e m) => (CsvParseError -> e) -> DecodeOptions -> HasHeader -> ConduitT ByteString a m () Source #
Sometimes your pipeline will involve an error type other than CsvParseError
, in which case if you provide
a function to project it into your custom error type, you can use this instead of fromCsv
fromNamedCsv :: (FromNamedRecord a, MonadError CsvParseError m) => DecodeOptions -> ConduitT ByteString a m () Source #
Parses an instance of FromNamedRecord
, this conduit drops the Header
Errors are not seen in the pipeline but rather at the end after executing the pipeline, if you want to handle the errors
as they occur, try fromNamedCsvStreamError
instead.
fromNamedCsvLiftError :: (FromNamedRecord a, MonadError e m) => (CsvParseError -> e) -> DecodeOptions -> ConduitT ByteString a m () Source #
Sometimes your pipeline will involve an error type other than CsvParseError
, in which case if you provide
a function to project it into your custom error type, you can use this instead of fromCsv
fromCsvStreamError :: (FromRecord a, MonadError e m) => DecodeOptions -> HasHeader -> (CsvStreamHaltParseError -> e) -> ConduitT ByteString (Either CsvStreamRecordParseError a) m () Source #
Same as fromCsv
but allows for errors to be handled in the pipeline instead
fromCsvStreamErrorNoThrow :: (Monad m, FromRecord a) => DecodeOptions -> HasHeader -> ConduitT ByteString (Either (Either CsvStreamHaltParseError CsvStreamRecordParseError) a) m () Source #
Same as fromCsvStreamError
but allows for halting errors to be handled by the pipeline as well.
fromNamedCsvStreamError :: (FromNamedRecord a, MonadError e m) => DecodeOptions -> (CsvStreamHaltParseError -> e) -> ConduitT ByteString (Either CsvStreamRecordParseError a) m () Source #
Like fromNamedCsvStream
but allows for errors to be handled in the pipeline itself.
fromNamedCsvStreamErrorNoThrow :: (Monad m, FromNamedRecord a) => DecodeOptions -> ConduitT ByteString (Either (Either CsvStreamHaltParseError CsvStreamRecordParseError) a) m () Source #
Like fromNamedCsvStreamErrorNoThrow
but allows for errors to be handled in the pipeline itself.
toCsv :: (Monad m, ToRecord a) => EncodeOptions -> ConduitT a ByteString m () Source #
Streams from csv to text, does not create headers...