Deprecated

attoparsec-enumerator

Pass input from an enumerator to an Attoparsec parser. https://john-millikin.com/software/attoparsec-enumerator/

Latest on Hackage:0.3.4

See all snapshots attoparsec-enumerator appears in

MIT licensed and maintained by John Millikin

Module documentation for 0.3.3

This version can be pinned in stack with:[email protected]:c60d94c87182293413052f9645063e40fd6f0361ab22d66daf4e8bc209f5d69d,1635
  • Data
    • Data.Attoparsec
      • Data.Attoparsec.Enumerator

This library allows an Attoparsec parser to receive input incrementally from an enumerator. This could be used for parsing large files, or implementing binary network protocols.

(-# LANGUAGE OverloadedStrings #-)

import Control.Applicative
import Data.Attoparsec
import Data.Attoparsec.Enumerator
import Data.Enumerator
import Data.Enumerator.Binary (enumHandle)
import Data.Enumerator.List
import System.IO

parser = string "foo" <|> string "bar"

main = do
    xy <- run_ (enumHandle 1 stdin $$ do
        x <- iterParser parser
        y <- iterParser parser
        return (x, y))
    print xy