[Haskell-cafe] state monad transformer that adds or combines state

Dennis Raddle dennis.raddle at gmail.com
Tue May 15 21:31:21 UTC 2018

On Tue, May 15, 2018 at 7:08 AM, Vanessa McHale <vanessa.mchale at iohk.io>

> You can simply use a state monad and then extract the data later when you
> don't want the extra state, viz.
> sum :: (Num a) => [a] -> asum xs = flip execState 0 $
>     mapM_ (\x -> do { s <- get ; put $ x + s }) xs
Not quite sure how this relates to my point. I need to have modify access
to the state in the deeper, original monad, as well as a temporary state
monad on top of it. And I don't want to create a single data constructor
for a single state monad that has fields for every conceivable use anywhere
in my code.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180515/b0f1bad4/attachment.html>

More information about the Haskell-Cafe mailing list