stateMonadSP, SPms, et al


stateMonadSP :: a -> SPms b c a d -> (d -> SP b c) -> SP b c
type SPms a b c d = Ms (SP a b) c d
putSPms :: a -> SPms b a c ()
putsSPms :: [a] -> SPms b a c ()
getSPms :: SPms a b c a
nullSPms :: SPms a b c ()
unitSPms :: a -> SPms b c d a
bindSPms :: SPms a b c d -> (d -> SPms a b c e) -> SPms a b c e
thenSPms :: SPms a b c () -> SPms a b c d -> SPms a b c d
loadSPms :: SPms a b c c
storeSPms :: a -> SPms b c a ()


These combinators implement a stream processor monad with state.

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.


Incomplete documentation.

See Also

Continuation style stream processor operations: SP, putSP, getSP, nullSP.

Monadic stream processors without state: SPm.

Monadic fudget kernels: Ks, putKs, getKs, ...