Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- sumFrom :: Monad m => Integer -> Cell m Integer Integer
- count :: Monad m => Cell m a Integer
- foldC :: (Data b, Monad m) => (a -> b -> b) -> b -> Cell m a b
- foldC' :: (Data b, Monad m) => (a -> b -> b) -> b -> Cell m a b
- keep :: (Data a, Monad m) => a -> Cell m (Maybe a) a
- keepJust :: (Monad m, Data a) => Cell m (Maybe a) (Maybe a)
- boundedFIFO :: (Data a, Monad m) => Int -> Cell m (Maybe a) (Seq a)
- edge :: Monad m => Cell m Bool Bool
- printTime :: MonadIO m => String -> m ()
- printTimeC :: MonadIO m => String -> Cell m () ()
- data BufferCommand a
- maybePush :: Maybe a -> [BufferCommand a]
- maybePop :: Maybe a -> [BufferCommand b]
- buffer :: (Monad m, Data a) => Cell m [BufferCommand a] (Maybe a)
- buffered :: (Monad m, Data a) => Cell m (Maybe a) (Maybe b) -> Cell m (Maybe a) (Maybe b)
State accumulation
sumFrom :: Monad m => Integer -> Cell m Integer Integer Source #
Sum all past inputs, starting by the given number
foldC :: (Data b, Monad m) => (a -> b -> b) -> b -> Cell m a b Source #
Accumulate all incoming data,
using the given fold function and start value.
For example, if
receives inputs foldC
f ba0
, a1
,...
it will output b
, f a0 b
, f a1 $ f a0 b
, and so on.
foldC' :: (Data b, Monad m) => (a -> b -> b) -> b -> Cell m a b Source #
Like foldC
, but does not delay the output.
boundedFIFO :: (Data a, Monad m) => Int -> Cell m (Maybe a) (Seq a) Source #
boundedFIFO n
keeps the first n
present values.
Debugging utilities
printTime :: MonadIO m => String -> m () Source #
Print the current UTC time, prepended with the first 8 characters of the given message.
Buffers
data BufferCommand a Source #
A command to send to buffer
.
buffered :: (Monad m, Data a) => Cell m (Maybe a) (Maybe b) -> Cell m (Maybe a) (Maybe b) Source #
- Whenever
value entersJust
abuffered cell
, it is added to the buffer. - Whenever
cell
emits
, the oldest value is dropped from the buffer.Just
b cell
is always fed withJust
the oldest value from the buffer, except when the buffer is empty, then it is fedNothing
.
This construction guarantees that cell
produces exactly one output for every input value.