stateMonadSP :: s -> SPms i o s ans -> (ans -> SP i o) -> SP i o type SPms i o s ans = Ms (SP i o) s ans putSPms :: o -> SPms i o s () putsSPms :: [o] -> SPms i o s () getSPms :: SPms i o s i nullSPms :: SPms i o s () unitSPms :: ?? bindSPms :: ?? thenSPms :: ?? loadSPms :: SPms i o s s storeSPms :: s -> SPms i o s ()
A monadic stream processor of type SPms inp outp state ans
is a
stream processor that inputs messages of type inp
,
output messages of type outp
(like a stream processor of type SP inp outp
),
has an internal state of type state
and produces a final result of type ans
.
unitSPms
and bindSPms
are the unit and bind operations of the
monad. unitSPms x
is a stream processor that immediately returns
the result x
, without performing any I/O operations.
The operations putSPms
, getSPms
and nullSPms
correspond
to the ordinary stream processor operations putSP
, getSP
and nullSP
respectively.
The operations loadSPms
and storeSPms
allows you to access
and change the internal state.
stateMonadSP
allows a monadic stream processor with state to be
used in any context where an ordinary stream procesor is required.
stateMonadPS state0 spms sp
first runs spms
with state0
as the initial state and then continues as sp
. The final state
and result from spms
is thrown away.
Monadic stream processors without state: SPm.
Monadic fudget kernels: Ks, putKs, getKs, ...