@@ -87,7 +87,6 @@ import qualified System.IO as IO
88import Streamly.Core
88import Streamly.Core
89import Streamly.Streams
89import Streamly.Streams
91------------------------------------------------------------------------------
90------------------------------------------------------------------------------
92-- Construction
91-- Construction
93------------------------------------------------------------------------------
92------------------------------------------------------------------------------
@@ -334,14 +333,9 @@ head m =
334 in (runStream (toStream m)) Nothing stop yield
333 in (runStream (toStream m)) Nothing stop yield
336-- | Extract the last element of the stream, if any.
335-- | Extract the last element of the stream, if any.
337last :: (Streaming t, Monad m) => t m a -> m (Maybe a)
337last :: (Streaming t, Monad m) => t m a -> m (Maybe a)
338−last m = go (toStream m)
338+last = foldl (\_ y -> Just y) Nothing id
341− let stop = return Nothing
342− yield a Nothing = return (Just a)
343− yield _ (Just x) = go x
344− in (runStream m1) Nothing stop yield
346-- | Determine whether an element is present in the stream.
340-- | Determine whether an element is present in the stream.
347elem :: (Streaming t, Monad m, Eq a) => a -> t m a -> m Bool
341elem :: (Streaming t, Monad m, Eq a) => a -> t m a -> m Bool