Copyright | © 2015 Patryk Zadarnowski <pat@jantar.org> |
---|---|
License | BSD3 |
Maintainer | pat@jantar.org |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
This module provides a definition of a simple processor with a unit request type and an unspecified acknowledgement type, together with a number of common combinators for their definitions.
- module Control.Quiver
- type SQ a b f r = forall b'. P () a b b' f r
- type SP a b f e = SQ a b f (SPResult e)
- type SPResult e = Maybe (Maybe e)
- pattern SPComplete :: Maybe (Maybe t)
- pattern SPFailed :: t -> Maybe (Maybe t)
- pattern SPIncomplete :: Maybe t
- spfetch :: Functor f => SQ a b f (Maybe a)
- spemit :: b -> SP a b f e
- (>:>) :: b -> SP a b f e -> SP a b f e
- (>>!) :: Monad f => SP a b f e -> (e -> SP a b f e') -> SP a b f e'
- sppure :: (a -> b) -> SP a b f e
- spid :: SP a a f e
- spconcat :: SP [a] a f e
- spfold :: Monoid a => SQ a x f a
- spfold' :: Monoid a => SQ a x f a
- spfoldl :: (b -> a -> b) -> b -> SQ a x f b
- spfoldl' :: (b -> a -> b) -> b -> SQ a x f b
- spfoldr :: (a -> b -> b) -> b -> SQ a x f b
- spfoldr' :: (a -> b -> b) -> b -> SQ a x f b
Documentation
module Control.Quiver
type SQ a b f r = forall b'. P () a b b' f r Source
A simple processor step with a unit request type and an unspecified response type:
type SP a b f e = SQ a b f (SPResult e) Source
A simple processor with a unit request type, an unspecified response type and a result type tailored towards reporting the terminating condition of an intermediate component in a composed “processor stack”.
pattern SPComplete :: Maybe (Maybe t) Source
Simple processor result value indicating successful processing of the entire input stream.
pattern SPFailed :: t -> Maybe (Maybe t) Source
Simple processor result value indicating unsuccessful processing of the input stream.
pattern SPIncomplete :: Maybe t Source
Simple processor result value indicating premature termination of the consumer.
spfetch :: Functor f => SQ a b f (Maybe a) Source
spfetch
represents a singleton simple stream processor that
sends the request value x
upstream and delivers the
next input value received, or Nothing
if the upstream
processor has been depleted.
spemit :: b -> SP a b f e Source
spemit y
represents a singleton stream processor that
produces a single output value y
, delivering either
SPComplete
if y
was consumed by the downstream processor,
or SPIncomplete
otherwise.
(>:>) :: b -> SP a b f e -> SP a b f e infixr 5 Source
y >:> p
represents a singleton stream processor that
produces a single output value y
and continues with
the processor p
, deliverying SPIncomplete
if y
could
not be consumed by the downstream processor.
(>>!) :: Monad f => SP a b f e -> (e -> SP a b f e') -> SP a b f e' infixl 1 Source
p >>! k
is equivalent to p
, with any failures in p
supplied to the continuation processor k
. Note that
k
is not executed if p
completes successfully with
SPComplete
or is interrupted by the downstream processor,
deliverying SPIncomplete
.
sppure :: (a -> b) -> SP a b f e Source
sppure f
produces an infinite consumer/producer that
uses a pure function f
to convert every input value into
an output; equivalent to qpure id f (const ())
.
spfold :: Monoid a => SQ a x f a Source
A processor that delivers the entire input of the stream folded
into a single value using mappend
.
spfold' :: Monoid a => SQ a x f a Source
A processor that delivers the entire input of the stream folded
into a single value using strict application of mappend
.
spfoldl :: (b -> a -> b) -> b -> SQ a x f b Source
A processor that delivers the entire input of the stream folded into a single value using the supplied left-associative function and initial value.
spfoldl' :: (b -> a -> b) -> b -> SQ a x f b Source
A processor that delivers the entire input of the stream folded into a single value using strict application of the supplied left-associative function and initial value.