scc-0.8.3.1: Streaming component combinators
Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.SCC.Types

Description

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.

Synopsis

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.

Constructors

Performer 

Fields

Instances

Instances details
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x r) (Consumer m x ()) (Performer m r) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> Producer m x () -> Consumer m x () -> Performer m () Source #

(AnyListOrUnit x, AnyListOrUnit y) => CompatibleSignature (Performer m r) (PerformerType r) m x y Source # 
Instance details

Defined in Control.Concurrent.SCC.Configurable

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.

Constructors

Consumer 

Fields

Instances

Instances details
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x r) (Consumer m x ()) (Performer m r) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> Transducer m x y -> Consumer m y r -> Consumer m x r Source #

Monad m => Branching (Consumer m x r) m x r Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

combineBranches :: (forall (d :: Type -> Type). PairBinder m -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x r) -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x r) -> forall (a :: Type -> Type). OpenConsumer m a d x r) -> PairBinder m -> Consumer m x r -> Consumer m x r -> Consumer m x r Source #

AnyListOrUnit y => CompatibleSignature (Consumer m x r) (ConsumerType r) m [x] y Source # 
Instance details

Defined in Control.Concurrent.SCC.Configurable

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.

Constructors

Producer 

Fields

Instances

Instances details
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x r) (Consumer m x ()) (Performer m r) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Configurable

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.

Constructors

Transducer 

Fields

Instances

Instances details
(Monad m, Monoid x, Monoid y, Monoid z) => PipeableComponentPair m y (Transducer m x y) (Transducer m y z) (Transducer m x z) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> Transducer m x y -> Consumer m y r -> Consumer m x r Source #

Monad m => Branching (Transducer m x y) m x () Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

combineBranches :: (forall (d :: Type -> Type). PairBinder m -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x ()) -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x ()) -> forall (a :: Type -> Type). OpenConsumer m a d x ()) -> PairBinder m -> Transducer m x y -> Transducer m x y -> Transducer m x y Source #

CompatibleSignature (Transducer m x y) TransducerType m [x] [y] Source # 
Instance details

Defined in Control.Concurrent.SCC.Configurable

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 #

newtype Splitter m x 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.

Constructors

Splitter 

Fields

Instances

Instances details
Monad m => Branching (Splitter m x) m x () Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

combineBranches :: (forall (d :: Type -> Type). PairBinder m -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x ()) -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x ()) -> forall (a :: Type -> Type). OpenConsumer m a d x ()) -> PairBinder m -> Splitter m x -> Splitter m x -> Splitter m x Source #

data Boundary y Source #

A Boundary value is produced to mark either a Start and End of a region of data, or an arbitrary Point in data. A Point is semantically equivalent to a Start immediately followed by End.

Constructors

Start y 
End y 
Point y 

Instances

Instances details
Functor Boundary Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

fmap :: (a -> b) -> Boundary a -> Boundary b #

(<$) :: a -> Boundary b -> Boundary a #

Eq y => Eq (Boundary y) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

(==) :: Boundary y -> Boundary y -> Bool #

(/=) :: Boundary y -> Boundary y -> Bool #

Show y => Show (Boundary y) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

showsPrec :: Int -> Boundary y -> ShowS #

show :: Boundary y -> String #

showList :: [Boundary y] -> ShowS #

data Markup y x Source #

Type of values in a markup-up stream. The Content constructor wraps the actual data.

Constructors

Content x 
Markup (Boundary y) 

Instances

Instances details
Functor (Markup y) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

fmap :: (a -> b) -> Markup y a -> Markup y b #

(<$) :: a -> Markup y b -> Markup y a #

(Monoid x, Monoid y, Coercible x y) => Coercible [Markup b x] y Source # 
Instance details

Defined in Control.Concurrent.SCC.Coercions

Methods

coerce :: forall (m :: Type -> Type). Monad m => Transducer m [Markup b x] y Source #

adaptConsumer :: forall (m :: Type -> Type) r. (Monad m, Monoid [Markup b x], Monoid y) => Consumer m y r -> Consumer m [Markup b x] r Source #

adaptProducer :: forall (m :: Type -> Type) r. (Monad m, Monoid [Markup b x], Monoid y) => Producer m [Markup b x] r -> Producer m y r Source #

Coercible [x] [y] => Coercible [Markup b x] [y] Source # 
Instance details

Defined in Control.Concurrent.SCC.Coercions

Methods

coerce :: forall (m :: Type -> Type). Monad m => Transducer m [Markup b x] [y] Source #

adaptConsumer :: forall (m :: Type -> Type) r. (Monad m, Monoid [Markup b x], Monoid [y]) => Consumer m [y] r -> Consumer m [Markup b x] r Source #

adaptProducer :: forall (m :: Type -> Type) r. (Monad m, Monoid [Markup b x], Monoid [y]) => Producer m [Markup b x] r -> Producer m [y] r Source #

(Eq x, Eq y) => Eq (Markup y x) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

(==) :: Markup y x -> Markup y x -> Bool #

(/=) :: Markup y x -> Markup y x -> Bool #

(Show x, Show y) => Show (Markup y x) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

showsPrec :: Int -> Markup y x -> ShowS #

show :: Markup y x -> String #

showList :: [Markup y x] -> ShowS #

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.

Methods

compose :: PairBinder m -> c1 -> c2 -> c3 Source #

Instances

Instances details
(Monad m, Monoid x) => PipeableComponentPair m x (Producer m x r) (Consumer m x ()) (Performer m r) Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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 # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

compose :: PairBinder m -> 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.

Methods

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.

Instances

Instances details
Monad m => Branching (Splitter m x) m x () Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

combineBranches :: (forall (d :: Type -> Type). PairBinder m -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x ()) -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x ()) -> forall (a :: Type -> Type). OpenConsumer m a d x ()) -> PairBinder m -> Splitter m x -> Splitter m x -> Splitter m x Source #

Monad m => Branching (Transducer m x y) m x () Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

combineBranches :: (forall (d :: Type -> Type). PairBinder m -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x ()) -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x ()) -> forall (a :: Type -> Type). OpenConsumer m a d x ()) -> PairBinder m -> Transducer m x y -> Transducer m x y -> Transducer m x y Source #

Monad m => Branching (Consumer m x r) m x r Source # 
Instance details

Defined in Control.Concurrent.SCC.Types

Methods

combineBranches :: (forall (d :: Type -> Type). PairBinder m -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x r) -> (forall (a :: Type -> Type) (d' :: Type -> Type). AncestorFunctor d d' => OpenConsumer m a d' x r) -> forall (a :: Type -> Type). OpenConsumer m a d x r) -> PairBinder m -> Consumer m x r -> Consumer m x r -> Consumer m x r Source #

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 state-transition 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 state-converting function that also assigns a Boolean value to each input item and lifts it into a Splitter.