module Data.Csv.Parser.Megaparsec
( ConversionError (..)
, decode
, decodeWith
, decodeByName
, decodeByNameWith)
where
import Data.Csv hiding
( decode
, decodeWith
, decodeByName
, decodeByNameWith )
import Data.Vector (Vector)
import Text.Megaparsec
import qualified Data.ByteString.Lazy as BL
import Data.Csv.Parser.Megaparsec.Internals
( ConversionError (..)
, csv
, csvWithHeader
, decodeWithC)
decode :: FromRecord a
=> HasHeader
-> FilePath
-> BL.ByteString
-> Either (ParseErrorBundle BL.ByteString ConversionError) (Vector a)
decode :: forall a.
FromRecord a =>
HasHeader
-> FilePath
-> ByteString
-> Either (ParseErrorBundle ByteString ConversionError) (Vector a)
decode = DecodeOptions
-> HasHeader
-> FilePath
-> ByteString
-> Either (ParseErrorBundle ByteString ConversionError) (Vector a)
forall a.
FromRecord a =>
DecodeOptions
-> HasHeader
-> FilePath
-> ByteString
-> Either (ParseErrorBundle ByteString ConversionError) (Vector a)
decodeWith DecodeOptions
defaultDecodeOptions
{-# INLINE decode #-}
decodeWith :: FromRecord a
=> DecodeOptions
-> HasHeader
-> FilePath
-> BL.ByteString
-> Either (ParseErrorBundle BL.ByteString ConversionError) (Vector a)
decodeWith :: forall a.
FromRecord a =>
DecodeOptions
-> HasHeader
-> FilePath
-> ByteString
-> Either (ParseErrorBundle ByteString ConversionError) (Vector a)
decodeWith = (DecodeOptions -> Parser (Vector a))
-> DecodeOptions
-> HasHeader
-> FilePath
-> ByteString
-> Either (ParseErrorBundle ByteString ConversionError) (Vector a)
forall a.
(DecodeOptions -> Parser a)
-> DecodeOptions
-> HasHeader
-> FilePath
-> ByteString
-> Either (ParseErrorBundle ByteString ConversionError) a
decodeWithC DecodeOptions -> Parser (Vector a)
forall a. FromRecord a => DecodeOptions -> Parser (Vector a)
csv
{-# INLINE decodeWith #-}
decodeByName :: FromNamedRecord a
=> FilePath
-> BL.ByteString
-> Either (ParseErrorBundle BL.ByteString ConversionError) (Header, Vector a)
decodeByName :: forall a.
FromNamedRecord a =>
FilePath
-> ByteString
-> Either
(ParseErrorBundle ByteString ConversionError) (Header, Vector a)
decodeByName = DecodeOptions
-> FilePath
-> ByteString
-> Either
(ParseErrorBundle ByteString ConversionError) (Header, Vector a)
forall a.
FromNamedRecord a =>
DecodeOptions
-> FilePath
-> ByteString
-> Either
(ParseErrorBundle ByteString ConversionError) (Header, Vector a)
decodeByNameWith DecodeOptions
defaultDecodeOptions
{-# INLINE decodeByName #-}
decodeByNameWith :: FromNamedRecord a
=> DecodeOptions
-> FilePath
-> BL.ByteString
-> Either (ParseErrorBundle BL.ByteString ConversionError) (Header, Vector a)
decodeByNameWith :: forall a.
FromNamedRecord a =>
DecodeOptions
-> FilePath
-> ByteString
-> Either
(ParseErrorBundle ByteString ConversionError) (Header, Vector a)
decodeByNameWith DecodeOptions
opts = Parsec ConversionError ByteString (Header, Vector a)
-> FilePath
-> ByteString
-> Either
(ParseErrorBundle ByteString ConversionError) (Header, Vector a)
forall e s a.
Parsec e s a -> FilePath -> s -> Either (ParseErrorBundle s e) a
parse (DecodeOptions
-> Parsec ConversionError ByteString (Header, Vector a)
forall a.
FromNamedRecord a =>
DecodeOptions -> Parser (Header, Vector a)
csvWithHeader DecodeOptions
opts)
{-# INLINE decodeByNameWith #-}