CSV

CSV :: # (opaque)

RFC 4180-style CSV parsing and typed record decoding.

Quoted fields, escaped double quotes, CRLF record separators, and simple LF separators are supported. The first row is treated as data rather than as headings.

is_eq : _

Compare two decoded CSV values structurally.

parse_str : Parser(CSVRecord, a), Str -> Try(List(a), [ParsingFailure(Str), SyntaxError(Str), ParsingIncomplete(CSVRecord)])

Parse CSV text and decode every record with the supplied record parser.

parse_csv : Parser(CSVRecord, a), CSV -> Try(List(a), [ParsingFailure(Str), ParsingIncomplete(CSVRecord)])

Decode every record in an already parsed CSV value.

parse_csv_record : Parser(CSVRecord, a), CSVRecord -> Try(a, [ParsingFailure(Str), ParsingIncomplete(CSVRecord)])

Decode one CSVRecord with the supplied record parser.

Parsing succeeds only when the record parser consumes every field.

record : a -> Parser(CSVRecord, a)

Start a record parser with a curried constructor for the desired value.

record(|first_name| |last_name| |age| User({ first_name, last_name, age }))
.field(string)
.field(string)
.field(u64)
field : Parser(Utf8, a) -> Parser(CSVRecord, a)

Consume the next field of a CSVRecord using a UTF-8 field parser.

string : Parser(CSVField, Str)

Parse one CSV field as a valid UTF-8 string.

u64 : Parser(CSVField, U64)

Parse one CSV field as an unsigned 64-bit integer.

f64 : Parser(CSVField, F64)

Parse one CSV field as a 64-bit floating-point number.

parse_str_to_csv : Str -> Try(CSV, [ParsingFailure(Str), ParsingIncomplete(Utf8)])

Parse CSV text into raw records and UTF-8 fields.

file : Parser(Utf8, CSV)

Parse a complete RFC 4180-style CSV file into raw records and fields.

CSVRecord : List(CSVField)

One CSV row represented as a list of raw UTF-8 fields.

CSVField : Utf8

One raw UTF-8 field from a CSV row.