File tree Expand file tree Collapse file tree
src/Control/Monad/Logic/Sequence Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -219,9 +219,23 @@ single a = return (a :< mzero)
219219
220220instance Monad m => Functor (SeqT m ) where
221221 {-# INLINEABLE fmap #-}
222- fmap f (SeqT q) = SeqT $ fmap (liftM (fmap f)) q
223- {-# INLINABLE (<$) #-}
224- x <$ SeqT q = SeqT $ fmap (liftM (x <$ )) q
222+ fmap = fmapSeqT
223+
224+ fmapSeqT :: Monad m => (a -> b ) -> SeqT m a -> SeqT m b
225+ fmapSeqT f s = unstream (fmap_s f (stream s))
226+ {-# INLINEABLE [3] fmapSeqT #-}
227+
228+ fmap_s :: Monad m => (a -> b ) -> StreamM m a -> StreamM m b
229+ fmap_s f (StreamM next_a a0) = StreamM next a0
230+ where
231+ {-# INLINE next #-}
232+ next a = do
233+ x <- next_a a
234+ case x of
235+ Done -> return Done
236+ Skip s -> return (Skip s)
237+ Yield y ys -> return (Yield (f y) ys)
238+ {-# INLINEABLE [1] fmap_s #-}
225239
226240instance Monad m => Applicative (SeqT m ) where
227241 {-# INLINE pure #-}
You can’t perform that action at this time.
0 commit comments