on master help sign in
Add MonadTrans and MonadThrow instances

They are not yet required by anything, but since I wrote them, committing them.

commitb7c094e5e329053b67f8a17eaba0ea7186f5e4cc authorHarendra Kumar <harendra.kumar@gmail.com> dateThu 14 Nov 2019, 05:12 (7 years ago) parent3becd54
1 file changed+7
src/Streamly/Internal/Data/Stream/StreamD/Type.hs+7
src/Streamly/Internal/Data/Stream/StreamD/Type.hs+7
@@ -67,6 +67,7 @@ where
6767
6868import Control.Applicative (liftA2)
6969import Control.Monad (ap, when)
70+import Control.Monad.Catch (MonadThrow, throwM)
7071import Control.Monad.Trans (lift, MonadTrans)
7172import Data.Functor.Identity (Identity(..))
7273import GHC.Base (build)
@@ -247,6 +248,12 @@ instance Monad m => Monad (Stream m) where
247248 {-# INLINE (>>=) #-}
248249 (>>=) = flip concatMap
249250
251+instance MonadTrans Stream where
252+ lift = yieldM
253+
254+instance (MonadThrow m) => MonadThrow (Stream m) where
255+ throwM = lift . throwM
256+
250257-- XXX Use of SPEC constructor in folds causes 2x performance degradation in
251258-- one shot operations, but helps immensely in operations composed of multiple
252259-- combinators or the same combinator many times. There seems to be an