foldlM :: MonadPlus m => (a -> b -> m a) -> a -> m b -> m a
foldlM step start fetch =
  loop start
  where
    loop !state =
      mplus
        (do
          !element <- fetch
          loop =<< step state element)
        (return state)
foldlM :: MonadPlus m => (a -> b -> m a) -> a -> m b -> m a
foldlM step start fetch =
  loop start
  where
    loop !state =
      mplus
        (do
          !element <- fetch
          loop =<< step state element)
        (return state)
foldlM step start fetch =
  loop start
  where
    loop !state =
      mplus
        (do
          !element <- fetch
          loop =<< step state element)
        (return state)