withState package:bluefin

>>> runPureEff $ withState 10 $ \st -> do
n <- get st
pure (s -> (2 * n, s))
(20,10)
runPureEff $ withStateSource $ \source -> do
n <- newState source 5
total <- newState source 0

withJump $ \done -> forever $ do
n' <- get n
modify total (+ n')
when (n' == 0) $ jumpTo done
modify n (subtract 1)

get total
15