-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Megaparsec parser of CSV files that plays nicely with Cassava
--   
--   Megaparsec parser of CSV files that plays nicely with Cassava.
@package cassava-megaparsec
@version 2.1.1

module Data.Csv.Parser.Megaparsec.Internals

-- | Custom error component for CSV parsing. It allows typed reporting of
--   conversion errors.
newtype ConversionError
ConversionError :: String -> ConversionError

-- | Parser type that uses “custom error component” ConversionError.
type Parser = Parsec ConversionError ByteString

-- | Parse a CSV file that does not include a header.
csv :: FromRecord a => DecodeOptions -> Parser (Vector a)

-- | Parse a CSV file that includes a header.
csvWithHeader :: FromNamedRecord a => DecodeOptions -> Parser (Header, Vector a)

-- | Decode CSV data using the provided parser, skipping a leading header
--   if necessary.
decodeWithC :: (DecodeOptions -> Parser a) -> DecodeOptions -> HasHeader -> FilePath -> ByteString -> Either (ParseErrorBundle ByteString ConversionError) a

-- | Convert a Record to a NamedRecord by attaching column
--   names. The Header and Record must be of the same length.
toNamedRecord :: Header -> Record -> NamedRecord

-- | Parse a header, including the terminating line separator.
header :: Word8 -> Parser Header

-- | Parse a header name. Header names have the same format as regular
--   fields.
name :: Word8 -> Parser Name

-- | 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.
record :: Word8 -> (Record -> Parser a) -> Parser a

-- | Parse a field. The field may be in either the escaped or non-escaped
--   format. The returned value is unescaped.
field :: Word8 -> Parser Field

-- | Parse an escaped field.
escapedField :: Parser ByteString

-- | Parse an unescaped field.
unescapedField :: Word8 -> Parser ByteString
instance GHC.Internal.Data.Data.Data Data.Csv.Parser.Megaparsec.Internals.ConversionError
instance GHC.Classes.Eq Data.Csv.Parser.Megaparsec.Internals.ConversionError
instance GHC.Classes.Ord Data.Csv.Parser.Megaparsec.Internals.ConversionError
instance GHC.Internal.Read.Read Data.Csv.Parser.Megaparsec.Internals.ConversionError
instance GHC.Internal.Show.Show Data.Csv.Parser.Megaparsec.Internals.ConversionError
instance Text.Megaparsec.Error.ShowErrorComponent Data.Csv.Parser.Megaparsec.Internals.ConversionError

-- | A CSV parser. The parser here is RFC 4180 compliant, with the
--   following extensions:
--   
--   
--   
- Non-escaped fields may contain any characters except
--   double-quotes, commas (or generally delimiter characters), carriage
--   returns, and newlines.
--   
- Escaped fields may contain any characters, but double-quotes need
--   to be escaped.
--   
--   
--   The parser provides better error messages than the parser that comes
--   with Cassava library, while being compatible with the rest of the
--   library.
module Data.Csv.Parser.Megaparsec

-- | Custom error component for CSV parsing. It allows typed reporting of
--   conversion errors.
newtype ConversionError
ConversionError :: String -> ConversionError

-- | Deserialize CSV records form a lazy ByteString. If this fails
--   due to incomplete or invalid input, Left is returned.
--   Equivalent to decodeWith defaultDecodeOptions.
decode :: FromRecord a => HasHeader -> FilePath -> ByteString -> Either (ParseErrorBundle ByteString ConversionError) (Vector a)

-- | Like decode, but lets you customize how the CSV data is parsed.
decodeWith :: FromRecord a => DecodeOptions -> HasHeader -> FilePath -> ByteString -> Either (ParseErrorBundle ByteString ConversionError) (Vector a)

-- | Deserialize CSV records from a lazy ByteString. If this fails
--   due to incomplete or invalid input, Left is returned. The data
--   is assumed to be preceded by a header. Equivalent to
--   decodeByNameWith defaultDecodeOptions.
decodeByName :: FromNamedRecord a => FilePath -> ByteString -> Either (ParseErrorBundle ByteString ConversionError) (Header, Vector a)

-- | Like decodeByName, but lets you customize how the CSV data is
--   parsed.
decodeByNameWith :: FromNamedRecord a => DecodeOptions -> FilePath -> ByteString -> Either (ParseErrorBundle ByteString ConversionError) (Header, Vector a)
