machines-0.6.2: Networked stream transducers

Safe HaskellNone
LanguageHaskell2010

Data.Machine.Runner

Synopsis

Documentation

foldrT :: Monad m => (o -> b -> b) -> b -> MachineT m k o -> m b Source #

Right fold over a stream. This will be lazy if the underlying monad is.

runT = foldrT (:) []

foldlT :: Monad m => (b -> o -> b) -> b -> MachineT m k o -> m b Source #

Strict left fold over a stream.

foldMapT :: (Monad m, Monoid r) => (o -> r) -> MachineT m k o -> m r Source #

Strict fold over a stream. Items are accumulated on the right:

... ((f o1 <> f o2) <> f o3) ...

Where this is expensive, use the dual monoid instead.

foldT :: (Monad m, Monoid o) => MachineT m k o -> m o Source #

Strict fold over a monoid stream. Items are accumulated on the right:

... ((o1 <> o2) <> o3) ...

Where this is expensive, use the dual monoid instead.

foldT = foldMapT id

runT1 :: Monad m => MachineT m k o -> m (Maybe o) Source #

Run a machine with no input until it yields for the first time, then stop it. This is intended primarily for use with accumulating machines, such as the ones produced by fold or fold1

runT1 m = getFirst $ foldMapT (First . Just) (m ~> taking 1)

runT :: Monad m => MachineT m k b -> m [b] Source #

Stop feeding input into model and extract an answer

runT_ :: Monad m => MachineT m k b -> m () Source #

Stop feeding input into model, taking only the effects.