flatparse: High-performance parsing from strict bytestrings

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

Flatparse is a high-performance parsing library, focusing on programming languages and human-readable data formats. See the README for more information: https://github.com/AndrasKovacs/flatparse.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.0.1, 0.1.0.2, 0.1.1.1, 0.1.1.2, 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.3.0.0, 0.3.0.1, 0.3.0.2, 0.3.0.3, 0.3.1.0, 0.3.2.0, 0.3.3.0, 0.3.4.0, 0.3.5.0, 0.3.5.1, 0.4.0.0, 0.4.0.1, 0.4.0.2, 0.4.1.0, 0.5.0.0, 0.5.0.1, 0.5.0.2, 0.5.1.0, 0.5.1.1, 0.5.2.0
Change log None available
Dependencies base (>=4.7 && <5), bytestring, containers, template-haskell [details]
License MIT
Copyright 2021 András Kovács
Author András Kovács
Maintainer puttamalac@gmail.com
Category Parsing
Home page https://github.com/AndrasKovacs/flatparse#readme
Bug tracker https://github.com/AndrasKovacs/flatparse/issues
Source repo head: git clone https://github.com/AndrasKovacs/flatparse
Uploaded by AndrasKovacs at 2021-03-15T21:17:11Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for flatparse-0.1.0.1

[back to package description]

flatparse

CI

flatparse is a high-performance parsing library, focusing on programming languages and human-readable data formats. The "flat" in the name refers to the ByteString parsing input, which has pinned contiguous data, and also to the library internals, which avoids indirections and heap allocations whenever possible.

Features and non-features

flatparse comes in two flavors: FlatParse.Basic and FlatParse.Stateful. Both support a custom error type and a custom reader environment.

The reason for baking a reader into the parsers, is that if we need it, it's convenient, and if we don't, then GHC very reliably optimizes unused environments away. In contrast, GHC optimizes much less reliably if we try to wrap the existing Reader from transformers around our parsers.

Tutorial

Informative tutorials are work in progress. See src/FlatParse/Examples for a lexer/parser example with acceptably good error messages.

Some benchmarks

Execution times below. See source code in bench. Compiled with GHC 8.8.4 -O2 -fllvm.

benchmark runtime
s-exp/fpbasic 3.365 ms
s-exp/fpstateful 3.421 ms
s-exp/attoparsec 42.84 ms
s-exp/megaparsec 57.54 ms
s-exp/parsec 179.7 ms
long keyword/fpbasic 216.4 μs
long keyword/fpstateful 299.0 μs
long keyword/attoparsec 5.297 ms
long keyword/megaparsec 3.646 ms
long keyword/parsec 49.18 ms
numeral csv/fpbasic 743.5 μs
numeral csv/fpstateful 848.5 μs
numeral csv/attoparsec 20.64 ms
numeral csv/megaparsec 10.12 ms
numeral csv/parsec 78.52 ms

Object file sizes for each module containing the s-exp, long keyword and numeral csv benchmarks.

library object file size (bytes)
fpbasic 26456
fpstateful 30008
attoparsec 83288
megaparsec 188696
parsec 75880