mapstateF :: (t -> a -> (t, [b])) -> t -> F a b
mapstateF stf s0
mapstateFcreates abstract fudgets with internal state. A state transition function determines its behaviour.
stf :: t -> a -> (t, [b])
stfis applied to the message and the current state. The result from the application is a new internal state and a list of output messages.
s0 :: t
countF = mapstateF count 0 where count n _ = (n+1,[n+1])
sumF = mapstateF add 0 where add acc n = (acc+n,[acc+n])
mapstateF stf s0 = absF (concatMapAccumlSP stf s0)
Related combinators: mapAccumlSP, absF.