Skip to content

Commit c1b69b9

Browse files
committed
Implement Fold.fromPure and Fold.fromEffect directly
1 parent 6a47782 commit c1b69b9

File tree

1 file changed

+2
-2
lines changed
  • core/src/Streamly/Internal/Data/Fold

1 file changed

+2
-2
lines changed

core/src/Streamly/Internal/Data/Fold/Type.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ instance Functor m => Functor (Fold m a) where
954954
--
955955
{-# INLINE fromPure #-}
956956
fromPure :: Applicative m => b -> Fold m a b
957-
fromPure = fromScanl . Scanl.const
957+
fromPure b = Fold undefined (pure $ Done b) pure pure
958958

959959
-- | Make a fold that yields the result of the supplied effectful action
960960
-- without consuming any further input.
@@ -963,7 +963,7 @@ fromPure = fromScanl . Scanl.const
963963
--
964964
{-# INLINE fromEffect #-}
965965
fromEffect :: Applicative m => m b -> Fold m a b
966-
fromEffect = fromScanl . Scanl.constM
966+
fromEffect b = Fold undefined (Done <$> b) pure pure
967967

968968
{-# ANN type SeqFoldState Fuse #-}
969969
data SeqFoldState sl f sr = SeqFoldL !sl | SeqFoldR !f !sr

0 commit comments

Comments
 (0)