Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
- data ProcessA a b c
- class Occasional' a where
- class Occasional' a => Occasional a where
- data Event a
- condEvent :: Bool -> Event a -> Event a
- filterEvent :: Arrow ar => (a -> Bool) -> ar (Event a) (Event a)
- filterJust :: Arrow ar => ar (Event (Maybe a)) (Event a)
- filterLeft :: Arrow ar => ar (Event (Either a b)) (Event a)
- filterRight :: Arrow ar => ar (Event (Either a b)) (Event b)
- splitEvent :: Arrow ar => ar (Event (Either a b)) (Event a, Event b)
- evMap :: Arrow a => (b -> c) -> a (Event b) (Event c)
- newtype PlanT i o m a = PlanT {}
- type Plan i o a = forall m. Monad m => PlanT i o m a
- await :: Plan i o i
- yield :: o -> Plan i o ()
- stop :: Plan i o a
- catchP :: Monad m => PlanT i o m a -> PlanT i o m a -> PlanT i o m a
- stopped :: (ArrowApply a, Occasional c) => ProcessA a b c
- muted :: (ArrowApply a, Occasional' b, Occasional c) => ProcessA a b c
- constructT :: (Monad m, ArrowApply a) => (forall b. m b -> a () b) -> PlanT i o m r -> ProcessA a (Event i) (Event o)
- repeatedlyT :: (Monad m, ArrowApply a) => (forall b. m b -> a () b) -> PlanT i o m r -> ProcessA a (Event i) (Event o)
- construct :: ArrowApply a => PlanT i o Identity r -> ProcessA a (Event i) (Event o)
- repeatedly :: ArrowApply a => PlanT i o Identity r -> ProcessA a (Event i) (Event o)
- run :: ArrowApply a => ProcessA a (Event b) (Event c) -> a [b] [c]
- runOn :: (ArrowApply a, Monoid r, Foldable f) => (c -> r) -> ProcessA a (Event b) (Event c) -> a (f b) r
- run_ :: ArrowApply a => ProcessA a (Event b) (Event c) -> a [b] ()
- data ExecInfo fa = ExecInfo {
- yields :: fa
- hasConsumed :: Bool
- hasStopped :: Bool
- stepRun :: ArrowApply a => ProcessA a (Event b) (Event c) -> a b (ExecInfo [c], ProcessA a (Event b) (Event c))
- stepYield :: ArrowApply a => ProcessA a (Event b) (Event c) -> a b (ExecInfo (Maybe c), ProcessA a (Event b) (Event c))
- switch :: ArrowApply a => ProcessA a b (c, Event t) -> (t -> ProcessA a b c) -> ProcessA a b c
- dSwitch :: ArrowApply a => ProcessA a b (c, Event t) -> (t -> ProcessA a b c) -> ProcessA a b c
- rSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, Event (ProcessA a b c)) c
- drSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, Event (ProcessA a b c)) c
- kSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, c) (Event t) -> (ProcessA a b c -> t -> ProcessA a b c) -> ProcessA a b c
- dkSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, c) (Event t) -> (ProcessA a b c -> t -> ProcessA a b c) -> ProcessA a b c
- gSwitch :: ArrowApply a => ProcessA a b (p, r) -> ProcessA a p q -> ProcessA a (q, r) (c, Event t) -> (ProcessA a p q -> t -> ProcessA a b c) -> ProcessA a b c
- dgSwitch :: ArrowApply a => ProcessA a b (p, r) -> ProcessA a p q -> ProcessA a (q, r) (c, Event t) -> (ProcessA a p q -> t -> ProcessA a b c) -> ProcessA a b c
- pSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a ext c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c)
- pSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a b c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c)
- dpSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a ext c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c)
- dpSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a b c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c)
- rpSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, Event (col (ProcessA a ext c) -> col (ProcessA a ext c))) (col c)
- rpSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, Event (col (ProcessA a b c) -> col (ProcessA a b c))) (col c)
- drpSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, Event (col (ProcessA a ext c) -> col (ProcessA a ext c))) (col c)
- drpSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, Event (col (ProcessA a b c) -> col (ProcessA a b c))) (col c)
- par :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a b (col c)
- parB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a b (col c)
- fit :: (ArrowApply a, ArrowApply a') => (forall p q. a p q -> a' p q) -> ProcessA a b c -> ProcessA a' b c
- fitW :: (ArrowApply a, ArrowApply a', Functor w) => (forall p. w p -> p) -> (forall p q. a p q -> a' (w p) q) -> ProcessA a b c -> ProcessA a' (w b) c
- unsafeExhaust :: (ArrowApply a, Foldable f) => a b (f c) -> ProcessA a b (Event c)
Stream transducer type
The stream transducer arrow.
To construct ProcessA
instances, use Plan
,
arr
, functions declared in Utils
,
or arrow combinations of them.
See an introduction at Control.Arrow.Machine documentation.
ArrowApply a => ArrowChoice (ProcessA a) Source # | |
ArrowApply a => Arrow (ProcessA a) Source # | |
ArrowApply a => ArrowLoop (ProcessA a) Source # | |
ArrowApply a => Profunctor (ProcessA a) Source # | |
ArrowApply a => Category * (ProcessA a) Source # | |
ArrowApply a => Functor (ProcessA a i) Source # | |
ArrowApply a => Applicative (ProcessA a i) Source # | |
Event type and utility
class Occasional' a where Source #
Signals that can be absent(NoEvent
) or end.
For composite structure, collapse
can be defined as monoid sum of all member occasionals.
Occasional' (Event a) Source # | |
(Occasional' a, Occasional' b) => Occasional' (a, b) Source # | |
class Occasional' a => Occasional a where Source #
Occasional signals with creation methods.
Occasional (Event a) Source # | |
(Occasional a, Occasional b) => Occasional (a, b) Source # | |
Discrete events on a time line. Created and consumed by various transducers.
evMap :: Arrow a => (b -> c) -> a (Event b) (Event c) Source #
Alias of "arr . fmap"
While "ProcessA a (Event b) (Event c)" means a transducer from b to c, function b->c can be lifted into a transducer by fhis function.
But in most cases you needn't call this function in proc-do notations,
because arr
s are completed automatically while desugaring.
For example,
proc x -> returnA -< f <$> x
is equivalent to
evMap f
Coroutine monad
Procedural coroutine monad that can await or yield values.
Coroutines can be encoded to machines by constructT
or so on and
then put into ProcessA
compositions.
newtype PlanT i o m a Source #
MonadReader r m => MonadReader r (PlanT i o m) Source # | |
MonadState s m => MonadState s (PlanT i o m) Source # | |
MonadWriter w m => MonadWriter w (PlanT i o m) Source # | |
MonadTrans (PlanT i o) Source # | |
Monad (PlanT i o m) Source # | |
Functor (PlanT i o m) Source # | |
Applicative (PlanT i o m) Source # | |
Alternative m => Alternative (PlanT i o m) Source # | |
(Monad m, Alternative m) => MonadPlus (PlanT i o m) Source # | |
stopped :: (ArrowApply a, Occasional c) => ProcessA a b c Source #
muted :: (ArrowApply a, Occasional' b, Occasional c) => ProcessA a b c Source #
Constructing machines from plans
constructT :: (Monad m, ArrowApply a) => (forall b. m b -> a () b) -> PlanT i o m r -> ProcessA a (Event i) (Event o) Source #
repeatedlyT :: (Monad m, ArrowApply a) => (forall b. m b -> a () b) -> PlanT i o m r -> ProcessA a (Event i) (Event o) Source #
repeatedly :: ArrowApply a => PlanT i o Identity r -> ProcessA a (Event i) (Event o) Source #
Running machines (at once)
runOn :: (ArrowApply a, Monoid r, Foldable f) => (c -> r) -> ProcessA a (Event b) (Event c) -> a (f b) r Source #
Run a machine with results concatenated in terms of a monoid.
run_ :: ArrowApply a => ProcessA a (Event b) (Event c) -> a [b] () Source #
Run a machine discarding all results.
Running machines (step-by-step)
Represents return values and informations of step executions.
ExecInfo | |
|
stepRun :: ArrowApply a => ProcessA a (Event b) (Event c) -> a b (ExecInfo [c], ProcessA a (Event b) (Event c)) Source #
Execute until an input consumed and the machine suspends.
stepYield :: ArrowApply a => ProcessA a (Event b) (Event c) -> a b (ExecInfo (Maybe c), ProcessA a (Event b) (Event c)) Source #
Execute until an output produced.
Primitive machines - switches
Switches inspired by Yampa library.
Signature is almost same, but collection requirement is not only Functor
,
but Traversable
. This is because of side effects.
switch :: ArrowApply a => ProcessA a b (c, Event t) -> (t -> ProcessA a b c) -> ProcessA a b c Source #
dSwitch :: ArrowApply a => ProcessA a b (c, Event t) -> (t -> ProcessA a b c) -> ProcessA a b c Source #
kSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, c) (Event t) -> (ProcessA a b c -> t -> ProcessA a b c) -> ProcessA a b c Source #
dkSwitch :: ArrowApply a => ProcessA a b c -> ProcessA a (b, c) (Event t) -> (ProcessA a b c -> t -> ProcessA a b c) -> ProcessA a b c Source #
gSwitch :: ArrowApply a => ProcessA a b (p, r) -> ProcessA a p q -> ProcessA a (q, r) (c, Event t) -> (ProcessA a p q -> t -> ProcessA a b c) -> ProcessA a b c Source #
dgSwitch :: ArrowApply a => ProcessA a b (p, r) -> ProcessA a p q -> ProcessA a (q, r) (c, Event t) -> (ProcessA a p q -> t -> ProcessA a b c) -> ProcessA a b c Source #
pSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a ext c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c) Source #
pSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a b c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c) Source #
dpSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a ext c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c) Source #
dpSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, col c) (Event mng) -> (col (ProcessA a b c) -> mng -> ProcessA a b (col c)) -> ProcessA a b (col c) Source #
rpSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, Event (col (ProcessA a ext c) -> col (ProcessA a ext c))) (col c) Source #
rpSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, Event (col (ProcessA a b c) -> col (ProcessA a b c))) (col c) Source #
drpSwitch :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a (b, Event (col (ProcessA a ext c) -> col (ProcessA a ext c))) (col c) Source #
drpSwitchB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a (b, Event (col (ProcessA a b c) -> col (ProcessA a b c))) (col c) Source #
par :: (ArrowApply a, Traversable col) => (forall sf. b -> col sf -> col (ext, sf)) -> col (ProcessA a ext c) -> ProcessA a b (col c) Source #
parB :: (ArrowApply a, Traversable col) => col (ProcessA a b c) -> ProcessA a b (col c) Source #
Primitive machines - other safe primitives
fit :: (ArrowApply a, ArrowApply a') => (forall p q. a p q -> a' p q) -> ProcessA a b c -> ProcessA a' b c Source #
Natural transformation
fitW :: (ArrowApply a, ArrowApply a', Functor w) => (forall p. w p -> p) -> (forall p q. a p q -> a' (w p) q) -> ProcessA a b c -> ProcessA a' (w b) c Source #
Experimental: more general fit.
Should w be a comonad?
Primitive machines - unsafe
unsafeExhaust :: (ArrowApply a, Foldable f) => a b (f c) -> ProcessA a b (Event c) Source #
Repeatedly call p
.
How many times p
is called is indefinite.
So p
must satisfy the equation below;
p &&& (p >>> arr null) === p &&& arr (const True)
where
null = getAll . foldMap (_ -> All False)