on master help sign in
Remove improper instances from Fold as discussed in #449
619b574adithyaov
src/Streamly/Internal/Data/Fold/Types.hs+1−10
@@ -80,15 +80,12 @@ simplify :: Fold2 m c a b -> c -> Fold m a b
80simplify (Fold2 step inject extract) c = Fold step (inject c) extract
80simplify (Fold2 step inject extract) c = Fold step (inject c) extract
81
81
82-- | Maps a function on the output of the fold (the type @b@).
82-- | Maps a function on the output of the fold (the type @b@).
83−instance Applicative m => Functor (Fold m a) where
83+instance Functor m => Functor (Fold m a) where
84 {-# INLINE fmap #-}
84 {-# INLINE fmap #-}
85 fmap f (Fold step start done) = Fold step start done'
85 fmap f (Fold step start done) = Fold step start done'
86 where
86 where
87 done' x = fmap f $! done x
87 done' x = fmap f $! done x
88
88
89− {-# INLINE (<$) #-}
90− (<$) b = \_ -> pure b
91−
92-- | The fold resulting from '<*>' distributes its input to both the argument
89-- | The fold resulting from '<*>' distributes its input to both the argument
93-- folds and combines their output using the supplied function.
90-- folds and combines their output using the supplied function.
94instance Applicative m => Applicative (Fold m a) where
91instance Applicative m => Applicative (Fold m a) where
@@ -102,12 +99,6 @@ instance Applicative m => Applicative (Fold m a) where
102 done (Tuple' xL xR) = doneL xL <*> doneR xR
99 done (Tuple' xL xR) = doneL xL <*> doneR xR
103 in Fold step begin done
100 in Fold step begin done
104
101
105− {-# INLINE (<*) #-}
106− (<*) m = \_ -> m
107−
108− {-# INLINE (*>) #-}
109− _ *> m = m
110−
111-- | Combines the outputs of the folds (the type @b@) using their 'Semigroup'
102-- | Combines the outputs of the folds (the type @b@) using their 'Semigroup'
112-- instances.
103-- instances.
113instance (Semigroup b, Monad m) => Semigroup (Fold m a b) where
104instance (Semigroup b, Monad m) => Semigroup (Fold m a b) where