EarleyM-0.1.0.0: Monadic Earley Parsing

Safe HaskellSafe
LanguageHaskell2010

EarleyM.Pipe

Description

Type for "pipes", having multiple writers and readers.

Each element (of type a) written to the pipe is "presented" to each reader (continuation) (of type a -> r).

Elements and readers can be adder in any order. When a new element is added, it is presented to the existing readers. When a new reader is adder, it is presented with the existing elements.

This type is used internally in the implementation of EarleyM, but it may be more widely useful.

Synopsis

Documentation

data Pipe a r Source

A "pipe" containing elements of type a, and readers of type a -> r.

empty :: Pipe a r Source

An empty pipe with no elements or readers.

write :: a -> Pipe a r -> (Pipe a r, [r]) Source

Write an element to a pipe, returning the new pipe and presentation results.

read :: (a -> r) -> Pipe a r -> (Pipe a r, [r]) Source

Attach a reader to a pipe, returning the new pipe and presentation results.

firstWrite :: a -> Pipe a r Source

Create a pipe from a single element.

firstRead :: (a -> r) -> Pipe a r Source

Create a pipe from a single reader.

elems :: Pipe a r -> [a] Source

Get the elements of a pipe.

readers :: Pipe a r -> [a -> r] Source

Get the readers of a pipe.