enumerator-0.4.3: Examples/skip.hs
module Main where
import Prelude hiding (head)
import Data.Enumerator
import Control.Monad.Trans.Class
skip :: Monad m => Enumeratee a a m b
skip (Continue k) = do
x <- head
_ <- head -- the one we're skipping
case x of
Nothing -> return $ Continue k
Just y -> do
newStep <- lift $ runIteratee $ k $ Chunks [y]
skip newStep
skip step = return step