mapstateF :: (a -> b -> (a, [c])) -> a -> F b c
mapstateF stf s0
mapstateFcreates abstract fudgets with internal state. A state transition function determines its behaviour.
stf :: a -> b -> (a, [c])
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 :: a
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.