File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ module Streaming.Internal (
8686import Control.Applicative
8787import Control.Concurrent (threadDelay )
8888import Control.Monad
89+ import Control.Monad.Catch (MonadThrow (.. ), MonadCatch (.. ))
8990import Control.Monad.Error.Class
9091import Control.Monad.Fail as Fail
9192import Control.Monad.Morph
@@ -381,6 +382,19 @@ instance (Functor f, MonadState s m) => MonadState s (Stream f m) where
381382 {-# INLINE state #-}
382383#endif
383384
385+ instance (Functor f , MonadThrow m ) => MonadThrow (Stream f m ) where
386+ throwM = lift . throwM
387+ {-# INLINE throwM #-}
388+
389+ instance (Functor f , MonadCatch m ) => MonadCatch (Stream f m ) where
390+ catch str f = loop str
391+ where
392+ loop x = case x of
393+ Return r -> Return r
394+ Effect m -> Effect $ fmap loop m `catch` (return . f)
395+ Step g -> Step (fmap loop g)
396+ {-# INLINABLE catch #-}
397+
384398instance (Functor f , MonadError e m ) => MonadError e (Stream f m ) where
385399 throwError = lift . throwError
386400 {-# INLINE throwError #-}
You can’t perform that action at this time.
0 commit comments