@@ -87,7 +87,7 @@ module Asyncly.Streams
89import Control.Applicative (Alternative (..), liftA2)
89import Control.Applicative (Alternative (..), liftA2)
90−import Control.Monad (MonadPlus(..), ap, liftM)
90+import Control.Monad (MonadPlus(..), ap)
91import Control.Monad.Base (MonadBase (..))
91import Control.Monad.Base (MonadBase (..))
92import Control.Monad.Catch (MonadThrow)
92import Control.Monad.Catch (MonadThrow)
93import Control.Monad.Error.Class (MonadError(..))
93import Control.Monad.Error.Class (MonadError(..))
@@ -285,7 +285,11 @@ instance Monad m => Applicative (StreamT m) where
285------------------------------------------------------------------------------
285------------------------------------------------------------------------------
287instance Monad m => Functor (StreamT m) where
287instance Monad m => Functor (StreamT m) where
288− fmap = liftM
288+ fmap f (StreamT (Stream m)) = StreamT $ Stream $ \_ stp yld ->
289+ let yield a Nothing = yld (f a) Nothing
290+ yield a (Just r) = yld (f a)
291+ (Just (getStreamT (fmap f (StreamT r))))
292+ in m Nothing stp yield
290------------------------------------------------------------------------------
294------------------------------------------------------------------------------
@@ -379,7 +383,11 @@ instance Monad m => Applicative (InterleavedT m) where
379------------------------------------------------------------------------------
383------------------------------------------------------------------------------
381instance Monad m => Functor (InterleavedT m) where
385instance Monad m => Functor (InterleavedT m) where
382− fmap = liftM
386+ fmap f (InterleavedT (Stream m)) = InterleavedT $ Stream $ \_ stp yld ->
387+ let yield a Nothing = yld (f a) Nothing
389+ yld (f a) (Just (getInterleavedT (fmap f (InterleavedT r))))
390+ in m Nothing stp yield
384------------------------------------------------------------------------------
392------------------------------------------------------------------------------
@@ -489,8 +497,11 @@ instance MonadAsync m => Applicative (AsyncT m) where
489-- Functor
497-- Functor
490------------------------------------------------------------------------------
498------------------------------------------------------------------------------
492−instance MonadAsync m => Functor (AsyncT m) where
500+instance Monad m => Functor (AsyncT m) where
493− fmap = liftM
501+ fmap f (AsyncT (Stream m)) = AsyncT $ Stream $ \_ stp yld ->
502+ let yield a Nothing = yld (f a) Nothing
503+ yield a (Just r) = yld (f a) (Just (getAsyncT (fmap f (AsyncT r))))
504+ in m Nothing stp yield
495------------------------------------------------------------------------------
506------------------------------------------------------------------------------
@@ -585,8 +596,12 @@ instance MonadAsync m => Applicative (ParallelT m) where
585-- Functor
596-- Functor
586------------------------------------------------------------------------------
597------------------------------------------------------------------------------
588−instance MonadAsync m => Functor (ParallelT m) where
599+instance Monad m => Functor (ParallelT m) where
589− fmap = liftM
600+ fmap f (ParallelT (Stream m)) = ParallelT $ Stream $ \_ stp yld ->
601+ let yield a Nothing = yld (f a) Nothing
602+ yield a (Just r) = yld (f a)
603+ (Just (getParallelT (fmap f (ParallelT r))))
604+ in m Nothing stp yield
591------------------------------------------------------------------------------
606------------------------------------------------------------------------------