Earlier quoted context omitted.
Very nice! I had a bit of trouble convincing myself that it has the laziness I'd want out of it, but by experimentation it seems to. Still, definitely a more complicated decomposition than that described in the article (but maybe a more interesting article!)
With one more combinator we can decompose this slightly further: stepSplit :: ([a] -> Split a) -> Split a -> Split a stepSplit f = uncurry first . bimap (++) f skip n = stepSplit (splitAt n) removeOneIfNot p = stepSplit (second (drop 1) . span p) Or in perhaps-more-familiar monadic terms: import Control.Monad (replicateM_) import Control.Monad.Trans (lift) import Control.Monad.Trans.State (StateT, evalStateT, state,…
"Whatever happened to the Popular Front, Reg?"