f, g :: [Int] -> Int
f xs = execState (go xs) 0
where
go [] = pure ()
go (x:xs) = do
modify (+ x)
go xs
g = flip execState 0 . traverse_ \x -> modify (+ x)
h :: [Int] -> IO Int
h xs = flip execStateT 0 do
for_ xs \x -> do
liftIO (print x)
modify (+ x)