Haskell

October 18, 2016 ยท View on GitHub

Sparcl - Small Parser Combinator Library for Standard ML (MLton, Poly/ML), Haskell and Perl


Haskell

data Result r = Done r ByteString | Partial | Fail

newtype Parser r = Parser { runParser :: ByteString -> Result r }

Three versions for Standard ML

sparcl-string.sml and sparcl-substring.sml

datatype 'r Result = Done of 'r * substring | Partial | Fail type 'r Parser = substring -> 'r Result

sparcl-string.sml : string -> string Parser sparcl-substring.sml : string -> substring Parser

By the way, Haskell ByteString is substring.

sparcl-reader.sml

datatype ('r, 'cs) Result = Done of 'r * 'cs | Partial | Fail type ('r, 'cs) Parser = (char, 'cs) StringCvt.reader -> 'cs -> ('r, 'cs) Result

Example

For example see p* files.

Combinators Library for standard scanners

If you are looking for Combinators Library for standard scanners, see Scancom (https://github.com/kni/scancom)