@@ -103,7 +103,7 @@ module Streamly.Internal.Data.Fold
103103 -- , (!!)
104104 , genericIndex
105105 , index
106− -- , findM
106+ , findM
107107 , find
108108 , lookup
109109 , findIndex
@@ -114,7 +114,6 @@ module Streamly.Internal.Data.Fold
114114 , any
115115 , and
116116 , or
117− -- , the
118117
119118 -- * Combinators
120119 -- ** Utilities
@@ -1166,17 +1165,25 @@ head = one
11661165
11671166-- | Returns the first element that satisfies the given predicate.
11681167--
1169−-- @since 0.7.0
1170−{-# INLINE find #-}
1171−find :: Monad m => (a -> Bool) -> Fold m a (Maybe a)
1172−find predicate = foldt' step (Partial ()) (const Nothing)
1168+-- /Pre-release/
1169+{-# INLINE findM #-}
1170+findM :: Monad m => (a -> m Bool) -> Fold m a (Maybe a)
1171+findM predicate = Fold step (return $ Partial ()) (const $ return Nothing)
11731172
11741173 where
11751174
11761175 step () a =
1177− if predicate a
1178− then Done (Just a)
1179− else Partial ()
1176+ (\r ->
1177+ if r
1178+ then Done (Just a)
1179+ else Partial ()) <$> predicate a
1180+
1181+-- | Returns the first element that satisfies the given predicate.
1182+--
1183+-- @since 0.7.0
1184+{-# INLINE find #-}
1185+find :: Monad m => (a -> Bool) -> Fold m a (Maybe a)
1186+find p = findM (return . p)
11801187
11811188-- | In a stream of (key-value) pairs @(a, b)@, return the value @b@ of the
11821189-- first pair where the key equals the given value @a@.