
15 May
2018
15 May
'18
5:31 p.m.
On Tue, May 15, 2018 at 7:08 AM, Vanessa McHale
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. D