Package parser-comb: Stream parser combinators

Information

nameparser-comb
version1.78
descriptionStream parser combinators
authorJoe Leslie-Hurd <joe@gilith.com>
licenseMIT
requiresbool
option
pair
parser-stream
showData.Bool
Data.List
Data.Option
Data.Pair
Parser
Parser.Stream

Files

Defined Type Operator

Defined Constants

Theorems

isParser parseAll.pa

isParser parseNone.pn

parseAll = mkParser parseAll.pa

parseNone = mkParser parseNone.pn

destParser parseNone = parseNone.pn

p. isParser (destParser p)

inverse parseAll (λa. a :: [])

strongInverse parseAll (λa. a :: [])

s. parse parseNone s = none

a. mkParser (destParser a) = a

p. parse p eof = none

p. parse p error = none

pb pc. isParser (parsePair.pbc pb pc)

f p. isParser (partialMap.pf f p)

f. parseOption f = partialMap f parseAll

a s. parseNone.pn a s = none

r. isParser r destParser (mkParser r) = r

a s. parseAll.pa a s = some (a, s)

pb pc. parsePair pb pc = mkParser (parsePair.pbc pb pc)

pb pc. destParser (parsePair pb pc) = parsePair.pbc pb pc

f p. partialMap f p = mkParser (partialMap.pf f p)

f p. destParser (partialMap f p) = partialMap.pf f p

parse parseAll = case none none (λa s. some (a, s))

p. parseSome p = parseOption (λa. if p a then some a else none)

f p. map f p = partialMap (λb. some (f b)) p

x s. parse parseAll (cons x s) = some (x, s)

f g p. mapToken f g p = mkParser (mapToken.pf f g p)

p a s. parse p (cons a s) = destParser p a s

p.
    parse (parseSome p) =
    case none none (λa s. if p a then some (a, s) else none)

f.
    parse (parseOption f) =
    case none none (λa s. case f a of none none | some b some (b, s))

p a s. destParser (parseSome p) a s = if p a then some (a, s) else none

f a s.
    destParser (parseOption f) a s =
    case f a of none none | some b some (b, s)

f e. (b. f (e b) = some b) inverse (parseOption f) (λb. e b :: [])

p a s b s'. destParser p a s = some (b, s') isSuffix s' s

p e. inverse p e x s. parse p (append (e x) s) = some (x, s)

p s.
    parse p s = none
    b s'. parse p s = some (b, s') isProperSuffix s' s

f p g e.
    inverse p e (b. f (g b) = b) inverse (map f p) (λc. e (g c))

p.
    isParser p
    x xs. case p x xs of none | some (y, xs') isSuffix xs' xs

f p g e.
    inverse p e (b. f (g b) = some b)
    inverse (partialMap f p) (λc. e (g c))

p a s.
    destParser p a s = none
    b s'. destParser p a s = some (b, s') isSuffix s' s

p a s.
    isParser p p a s = none b s'. p a s = some (b, s') isSuffix s' s

f p s.
    parse (map f p) s =
    case parse p s of none none | some (b, s') some (f b, s')

p e.
    strongInverse p e
    inverse p e s x s'. parse p s = some (x, s') s = append (e x) s'

pb pc eb ec.
    inverse pb eb inverse pc ec
    inverse (parsePair pb pc) (λ(b, c). eb b @ ec c)

pb pc eb ec.
    strongInverse pb eb strongInverse pc ec
    strongInverse (parsePair pb pc) (λ(b, c). eb b @ ec c)

f p a s.
    destParser (map f p) a s =
    case destParser p a s of none none | some (b, s') some (f b, s')

f p s.
    parse (partialMap f p) s =
    case parse p s of
      none none
    | some (b, s') case f b of none none | some c some (c, s')

f p a s.
    partialMap.pf f p a s =
    case destParser p a s of
      none none
    | some (b, s') case f b of none none | some c some (c, s')

f g p b s.
    mapToken.pf f g p b s =
    case destParser p (g b) (map g s) of
      none none
    | some (c, s') some (c, map f s')

f e.
    (b. f (e b) = some b)
    (a1 a2 b. f a1 = some b f a2 = some b a1 = a2)
    strongInverse (parseOption f) (λb. e b :: [])

f p g e.
    strongInverse p e (b. f (g b) = b)
    (b1 b2 c. f b1 = c f b2 = c b1 = b2)
    strongInverse (map f p) (λc. e (g c))

pb pc s.
    parse (parsePair pb pc) s =
    case parse pb s of
      none none
    | some (b, s')
        case parse pc s' of
          none none
        | some (c, s'') some ((b, c), s'')

f p g e.
    strongInverse p e (b. f (g b) = some b)
    (b1 b2 c. f b1 = some c f b2 = some c b1 = b2)
    strongInverse (partialMap f p) (λc. e (g c))

pb pc a s.
    parsePair.pbc pb pc a s =
    case destParser pb a s of
      none none
    | some (b, s')
        case parse pc s' of
          none none
        | some (c, s'') some ((b, c), s'')

Input Type Operators

Input Constants

Assumptions

¬

¬

t. t t

x. isSuffix x x

p. p

(¬) = λp. p

() = λp. p ((select) p)

t. (x. t) t

t. (λx. t x) = t

() = λp. p = λx.

a'. ¬(none = some a')

t. ¬¬t t

t. ( t) t

t. t

t. t t

t. t t

t. t

t. t t

t. t

t. t t

t. t

t. t

s. append [] s = s

t. ( t) ¬t

t. t ¬t

() = λp q. p q p

t. (t ) (t )

t1 t2. (if then t1 else t2) = t2

t1 t2. (if then t1 else t2) = t1

b f. case b f none = b

p x. p x p ((select) p)

xy. x y. xy = (x, y)

x y. x = y y = x

t1 t2. t1 t2 t2 t1

x y. isProperSuffix x y isSuffix x y

x. x = none a. x = some a

() = λp q. (λf. f p q) = λf. f

e b f. case e b f eof = b

e b f. case e b f error = e

() = λp. q. (x. p x q) q

a a'. some a = some a' a = a'

b f a. case b f (some a) = f a

f g. (x. f x = g x) f = g

() = λp q. r. (p r) (q r) r

s s'. isSuffix s s' s = s' isProperSuffix s s'

f. fn. x y. fn (x, y) = f x y

h t s. append (h :: t) s = cons h (append t s)

t1 t2 t3. (t1 t2) t3 t1 t2 t3

x y z. append (x @ y) z = append x (append y z)

x y z. isSuffix x y isSuffix y z isSuffix x z

p. (x. y. p x y) y. x. p x (y x)

s a s'. isProperSuffix s (cons a s') s = s' isProperSuffix s s'

x. x = error x = eof a0 a1. x = cons a0 a1

e b f a s. case e b f (cons a s) = f a s

p q. (x. p x q x) (x. p x) x. q x

x y a b. (x, y) = (a, b) x = a y = b

a0 a1 a0' a1'. cons a0 a1 = cons a0' a1' a0 = a0' a1 = a1'

f0 f1 f2.
    fn.
      fn error = f0 fn eof = f1
      a0 a1. fn (cons a0 a1) = f2 a0 a1 (fn a1)