Skip to content

Instantly share code, notes, and snippets.

@gregorycollins
Created December 12, 2010 21:43
Show Gist options
  • Save gregorycollins/738362 to your computer and use it in GitHub Desktop.
Save gregorycollins/738362 to your computer and use it in GitHub Desktop.
catchError' :: Monad m =>
Iteratee a m b
-> (SomeException -> Iteratee a m b)
-> Iteratee a m b
catchError' iter h = do
step <- lift $ runIteratee iter
go step
where
go step =
case step of
(Error e) -> h e
(Yield x r) -> yield x r
(Continue k) -> do
mbX <- head
maybe (k EOF)
(\x -> do
step' <- lift $ runIteratee $ k (Chunks [x])
go step')
mbX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment