| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Circuit.Parser.Csv.Lexer
Description
Fast imperative CSV tokenizer over strict ByteString.
Complementary to the combinator path in Circuit.Parser.Csv: a single
unsafeIndex pass emitting zero-copy slices. Commas are implied between
adjacent field tokens; CRowEnd marks record boundaries. CQuoted
payloads keep their doubled-quote escapes intact.
Synopsis
- data CsvToken
- runCsvLexerBS :: ByteString -> Either (Int, String) [CsvToken]
Tokens
A flat CSV token. Payloads are zero-copy slices of the input.
Constructors
| CField ByteString | |
| CQuoted ByteString | |
| CRowEnd |
Running
runCsvLexerBS :: ByteString -> Either (Int, String) [CsvToken] Source #
Tokenize a strict ByteString as CSV.
On failure, returns the byte offset and a message.
>>>runCsvLexerBS (C.pack "a,b\r\n\"x\"\"y\",z")Right [CField "a",CField "b",CRowEnd,CQuoted "x\"\"y",CField "z"]
>>>runCsvLexerBS (C.pack "a,\"b")Left (4,"unterminated quoted field")
>>>runCsvLexerBS (C.pack "ab\"cd")Left (2,"unexpected quote in plain field")