attoparsec Documentation

repository·master·Indexed 19 days ago

https://github.com/haskell/attoparsec

A high-performance Haskell parser combinator library optimized for parsing network protocols and complex text or binary formats. It utilizes a continuation-based approach for efficient input handling and is designed for high-speed parsing of byte arrays.

Tokens
380
Snippets
1
Records
3
Agent score
18%

What's inside attoparsec

  1. Compare Attoparsec with Parsec for performance and error handling

    master

    When choosing between Attoparsec and Parsec, consider your specific requirements for speed, error reporting, and input handling:

    Performance

    Attoparsec is optimized for high-speed parsing of byte arrays (e.g., network protocols). In benchmarks parsing HTTP GET requests, Attoparsec achieved approximately 56% of the speed of a hand-rolled C parser, significantly outperforming standard Parsec 3 implementations.

    Error Messages

    • Parsec 3: Provides much more user-friendly and descriptive error messages.
    • Attoparsec: Prioritizes performance and is specialized for byte arrays; it does not prioritize friendly error messages.

    Input Handling and Memory

    • Parsec 3: Requires all input to be available upfront, either as a single large chunk or via lazy I/O (which incurs a performance penalty).
    • Attoparsec: Uses a continuation-based approach. If there is insufficient data to return a complete result, it returns a continuation that allows you to provide more data. This eliminates the need for lazy I/O or manual buffering and allows for a pure API that is agnostic of the input source.