on master help sign in
Make Fold.head terminating.
08dd169Pranay Sashank
src/Streamly/Internal/Data/Fold.hs+1−1
@@ -773,7 +773,7 @@ index = genericIndex
773-- @since 0.7.0
773-- @since 0.7.0
774{-# INLINABLE head #-}
774{-# INLINABLE head #-}
775head :: Monad m => Fold m a (Maybe a)
775head :: Monad m => Fold m a (Maybe a)
776−head = _Fold1 const
776+head = mkFold_ (const (Done . Just)) (Partial Nothing)
777
777
778-- | Returns the first element that satisfies the given predicate.
778-- | Returns the first element that satisfies the given predicate.
779--
779--