Safe Haskell  None 

Language  Haskell2010 
This module defines various Coroutine
types that operate on
Sink
and Source
values. The simplest of the bunch
are Consumer
and Producer
types, which respectively operate on a single source or sink. A Transducer
has access
both to a Source
to read from and a Sink
to write
into. Finally, a Splitter
reads from a single source and writes all of the input, without any modifications, into
two sinks of the same type.
 newtype Performer m r = Performer {
 perform :: m r
 type OpenConsumer m a d x r = (AncestorFunctor a d, Monoid x) => Source m a x > Coroutine d m r
 newtype Consumer m x r = Consumer {
 consume :: forall a d. OpenConsumer m a d x r
 type OpenProducer m a d x r = (AncestorFunctor a d, Monoid x) => Sink m a x > Coroutine d m r
 newtype Producer m x r = Producer {
 produce :: forall a d. OpenProducer m a d x r
 type OpenTransducer m a1 a2 d x y r = (AncestorFunctor a1 d, AncestorFunctor a2 d, Monoid x, Monoid y) => Source m a1 x > Sink m a2 y > Coroutine d m r
 newtype Transducer m x y = Transducer {
 transduce :: forall a1 a2 d. OpenTransducer m a1 a2 d x y ()
 type OpenSplitter m a1 a2 a3 d x r = (AncestorFunctor a1 d, AncestorFunctor a2 d, AncestorFunctor a3 d, Monoid x) => Source m a1 x > Sink m a2 x > Sink m a3 x > Coroutine d m r
 newtype Splitter m x = Splitter {
 split :: forall a1 a2 a3 d. OpenSplitter m a1 a2 a3 d x ()
 data Boundary y
 data Markup y x
 type Parser m x b = Transducer m x [Markup b x]
 class PipeableComponentPair m w c1 c2 c3  c1 c2 > c3, c1 c3 > c2, c2 c3 > c2, c1 > m w, c2 > m w, c3 > m where
 class Branching c m x r  c > m x where
 isolateConsumer :: forall m x r. (Monad m, Monoid x) => (forall d. Functor d => Source m d x > Coroutine d m r) > Consumer m x r
 isolateProducer :: forall m x r. (Monad m, Monoid x) => (forall d. Functor d => Sink m d x > Coroutine d m r) > Producer m x r
 isolateTransducer :: forall m x y. (Monad m, Monoid x) => (forall d. Functor d => Source m d x > Sink m d y > Coroutine d m ()) > Transducer m x y
 isolateSplitter :: forall m x b. (Monad m, Monoid x) => (forall d. Functor d => Source m d x > Sink m d x > Sink m d x > Coroutine d m ()) > Splitter m x
 oneToOneTransducer :: (Monad m, FactorialMonoid x, Monoid y) => (x > y) > Transducer m x y
 statelessTransducer :: Monad m => (x > y) > Transducer m [x] y
 statelessChunkTransducer :: Monad m => (x > y) > Transducer m x y
 statefulTransducer :: (Monad m, MonoidNull y) => (state > x > (state, y)) > state > Transducer m [x] y
 statelessSplitter :: Monad m => (x > Bool) > Splitter m [x]
 statefulSplitter :: Monad m => (state > x > (state, Bool)) > state > Splitter m [x]
Component types
newtype Performer m r Source #
A coroutine that has no inputs nor outputs  and therefore may not suspend at all, which means it's not really a coroutine.
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x r) (Consumer m x ()) (Performer m r) Source #  
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x r) (Performer m r) Source #  
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x ()) (Performer m ()) Source #  
(AnyListOrUnit x, AnyListOrUnit y) => CompatibleSignature (Performer m r) (PerformerType r) m x y Source #  
type OpenConsumer m a d x r = (AncestorFunctor a d, Monoid x) => Source m a x > Coroutine d m r Source #
newtype Consumer m x r Source #
A coroutine that consumes values from a Source
.
Consumer  

(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x r) (Consumer m x ()) (Performer m r) Source #  
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x r) (Performer m r) Source #  
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x ()) (Performer m ()) Source #  
(Monad m, Monoid x, Monoid y) => PipeableComponentPair m y (Transducer m x y) (Consumer m y r) (Consumer m x r) Source #  
Monad m => Branching (Consumer m x r) m x r Source #  
AnyListOrUnit y => CompatibleSignature (Consumer m x r) (ConsumerType r) m [x] y Source #  
type OpenProducer m a d x r = (AncestorFunctor a d, Monoid x) => Sink m a x > Coroutine d m r Source #
newtype Producer m x r Source #
A coroutine that produces values and puts them into a Sink
.
Producer  

(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x r) (Consumer m x ()) (Performer m r) Source #  
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x r) (Performer m r) Source #  
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x ()) (Performer m ()) Source #  
(Monad m, Monoid x, Monoid y) => PipeableComponentPair m x (Producer m x r) (Transducer m x y) (Producer m y r) Source #  
AnyListOrUnit y => CompatibleSignature (Producer m x r) (ProducerType r) m y [x] Source #  
type OpenTransducer m a1 a2 d x y r = (AncestorFunctor a1 d, AncestorFunctor a2 d, Monoid x, Monoid y) => Source m a1 x > Sink m a2 y > Coroutine d m r Source #
newtype Transducer m x y Source #
The Transducer
type represents coroutines that transform a data stream. Execution of transduce
must continue
consuming the given Source
and feeding the Sink
as
long as there is any data in the source.
Transducer  

(Monad m, Monoid x, Monoid y, Monoid z) => PipeableComponentPair m y (Transducer m x y) (Transducer m y z) (Transducer m x z) Source #  
(Monad m, Monoid x, Monoid y) => PipeableComponentPair m x (Producer m x r) (Transducer m x y) (Producer m y r) Source #  
(Monad m, Monoid x, Monoid y) => PipeableComponentPair m y (Transducer m x y) (Consumer m y r) (Consumer m x r) Source #  
Monad m => Branching (Transducer m x y) m x () Source #  
CompatibleSignature (Transducer m x y) TransducerType m [x] [y] Source #  
type OpenSplitter m a1 a2 a3 d x r = (AncestorFunctor a1 d, AncestorFunctor a2 d, AncestorFunctor a3 d, Monoid x) => Source m a1 x > Sink m a2 x > Sink m a3 x > Coroutine d m r Source #
The Splitter
type represents coroutines that distribute the input stream acording to some criteria. A splitter
should distribute only the original input data, and feed it into the sinks in the same order it has been read from
the source. Furthermore, the input source should be entirely consumed and fed into the two sinks.
A splitter can be used in two ways: as a predicate to determine which portions of its input stream satisfy a certain
property, or as a chunker to divide the input stream into chunks. In the former case, the predicate is considered
true for exactly those parts of the input that are written to its true sink. In the latter case, a chunk is a
contiguous section of the input stream that is written exclusively to one sink, either true or false. A mempty
value written to either of the two sinks can also terminate the chunk written to the other sink.
Splitter  

Type of values in a markupup stream. The Content
constructor wraps the actual data.
type Parser m x b = Transducer m x [Markup b x] Source #
A parser is a transducer that marks up its input.
class PipeableComponentPair m w c1 c2 c3  c1 c2 > c3, c1 c3 > c2, c2 c3 > c2, c1 > m w, c2 > m w, c3 > m where Source #
Class PipeableComponentPair
applies to any two components that can be combined into a third component with the
following properties:
 The input of the result, if any, becomes the input of the first component.
 The output produced by the first child component is consumed by the second child component.
 The result output, if any, is the output of the second component.
compose :: PairBinder m > c1 > c2 > c3 Source #
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x r) (Consumer m x ()) (Performer m r) Source #  
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x r) (Performer m r) Source #  
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x ()) (Consumer m x ()) (Performer m ()) Source #  
(Monad m, Monoid x, Monoid y, Monoid z) => PipeableComponentPair m y (Transducer m x y) (Transducer m y z) (Transducer m x z) Source #  
(Monad m, Monoid x, Monoid y) => PipeableComponentPair m x (Producer m x r) (Transducer m x y) (Producer m y r) Source #  
(Monad m, Monoid x, Monoid y) => PipeableComponentPair m y (Transducer m x y) (Consumer m y r) (Consumer m x r) Source #  
class Branching c m x r  c > m x where Source #
Branching
is a type class representing all types that can act as consumers, namely Consumer
,
Transducer
, and Splitter
.
combineBranches :: (forall d. PairBinder m > (forall a d'. AncestorFunctor d d' => OpenConsumer m a d' x r) > (forall a d'. AncestorFunctor d d' => OpenConsumer m a d' x r) > forall a. OpenConsumer m a d x r) > PairBinder m > c > c > c Source #
combineBranches
is used to combine two values of Branch
class into one, using the given Consumer
binary
combinator.
Component constructors
isolateConsumer :: forall m x r. (Monad m, Monoid x) => (forall d. Functor d => Source m d x > Coroutine d m r) > Consumer m x r Source #
Creates a proper Consumer
from a function that is, but can't be proven to be, an OpenConsumer
.
isolateProducer :: forall m x r. (Monad m, Monoid x) => (forall d. Functor d => Sink m d x > Coroutine d m r) > Producer m x r Source #
Creates a proper Producer
from a function that is, but can't be proven to be, an OpenProducer
.
isolateTransducer :: forall m x y. (Monad m, Monoid x) => (forall d. Functor d => Source m d x > Sink m d y > Coroutine d m ()) > Transducer m x y Source #
Creates a proper Transducer
from a function that is, but can't be proven to be, an OpenTransducer
.
isolateSplitter :: forall m x b. (Monad m, Monoid x) => (forall d. Functor d => Source m d x > Sink m d x > Sink m d x > Coroutine d m ()) > Splitter m x Source #
Creates a proper Splitter
from a function that is, but can't be proven to be, an OpenSplitter
.
oneToOneTransducer :: (Monad m, FactorialMonoid x, Monoid y) => (x > y) > Transducer m x y Source #
Function oneToOneTransducer
takes a function that maps one input value to one output value each, and lifts it
into a Transducer
.
statelessTransducer :: Monad m => (x > y) > Transducer m [x] y Source #
Function statelessTransducer
takes a function that maps one input value into a list of output values, and
lifts it into a Transducer
.
statelessChunkTransducer :: Monad m => (x > y) > Transducer m x y Source #
Function statelessTransducer
takes a function that maps one input value into a list of output values, and
lifts it into a Transducer
.
statefulTransducer :: (Monad m, MonoidNull y) => (state > x > (state, y)) > state > Transducer m [x] y Source #
Function statefulTransducer
constructs a Transducer
from a statetransition function and the initial
state. The transition function may produce arbitrary output at any transition step.
statelessSplitter :: Monad m => (x > Bool) > Splitter m [x] Source #
Function statelessSplitter
takes a function that assigns a Boolean value to each input item and lifts it into
a Splitter
.
statefulSplitter :: Monad m => (state > x > (state, Bool)) > state > Splitter m [x] Source #
Function statefulSplitter
takes a stateconverting function that also assigns a Boolean value to each input
item and lifts it into a Splitter
.