attoparsec-parsec

An Attoparsec compatibility layer for Parsec

Latest on Hackage:0.1.3

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

MIT licensed and maintained by Simon Hengel
# An Attoparsec compatibility layer for Parsec

`attoparsec-parsec` allows you to write parsers that can be compiled against
both [Attoparsec](http://hackage.haskell.org/package/attoparsec) and
[Parsec](http://hackage.haskell.org/package/parsec).

Example:

~~~ {.haskell}
{-# LANGUAGE CPP #-}
import Prelude hiding (takeWhile)
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.IO as Text

#ifdef USE_ATTOPARSEC
import Data.Attoparsec.Text
#else
import Data.Attoparsec.Text.Parsec
#endif

main :: IO ()
main = Text.interact (either error id . parseOnly removeDashes)

removeDashes :: Parser Text
removeDashes = Text.concat `fmap` sepBy text dash
where
text = takeWhile (/= '-')
dash = takeWhile1 (== '-')
~~~
Depends on:
Used by 1 package:
comments powered byDisqus