foldlT still seems to leak some space, and strictly applying o to f b seems to solve this (e.g. f b $! o). I can submit a PR if desired.
foldlT :: Monad m => (b -> o -> b) -> b -> M.MachineT m k o -> m b
foldlT f = go
where
go !b m = do
step <- M.runMachineT m
case step of
M.Stop -> return b
M.Yield o m' -> go (f b $! o) m'
M.Await _ _ m' -> go b m'
foldlT
still seems to leak some space, and strictly applyingo
tof b
seems to solve this (e.g.f b $! o
). I can submit a PR if desired.