-- | Left fold of accumulating function onto a list.
-- Runs until the accumulating function has consumed
-- the list, then returns the accumulator. Generalizes
-- 'Data.List.mapAccumL'.
envelop :: (b -> [a] -> (b, [a])) -> b -> [a] -> b
envelop _ a [] = a
envelop :: (b -> [a] -> (b, [a])) -> b -> [a] -> b
envelop _ a [] = a
envelop _ a [] = a