on master help sign in
streamly-core: Add infixr 5 fixity for cons, consM
30c97a3pranaysashank
core/docs/Changelog.md+4
@@ -1,5 +1,9 @@
1# Changelog
1# Changelog
2
2
3+## Unreleased
4+
5+* Add fixities `infixr 5` for `cons` and `consM` functions.
6+
3## 0.2.1 (Dec 2023)
7## 0.2.1 (Dec 2023)
4
8
5* Make the serialization of the unit constructor deterministic.
9* Make the serialization of the unit constructor deterministic.
core/src/Streamly/Internal/Data/Stream/Generate.hs+2
@@ -154,6 +154,8 @@ import Streamly.Internal.Data.Stream.Type
154nil :: Applicative m => Stream m a
154nil :: Applicative m => Stream m a
155nil = Stream (\_ _ -> pure Stop) ()
155nil = Stream (\_ _ -> pure Stop) ()
156
156
157+infixr 5 `cons`
158+
157-- XXX implement in terms of consM?
159-- XXX implement in terms of consM?
158-- cons x = consM (return x)
160-- cons x = consM (return x)
159-- From an implementation perspective, StreamK.cons translates into a
161-- From an implementation perspective, StreamK.cons translates into a
core/src/Streamly/Internal/Data/Stream/Type.hs+3
@@ -212,6 +212,9 @@ pattern Stream step state <- (unShare -> UnStream step state)
212nilM :: Applicative m => m b -> Stream m a
212nilM :: Applicative m => m b -> Stream m a
213nilM m = Stream (\_ _ -> m $> Stop) ()
213nilM m = Stream (\_ _ -> m $> Stop) ()
214
214
215+
216+infixr 5 `consM`
217+
215-- | Like 'cons' but fuses an effect instead of a pure value.
218-- | Like 'cons' but fuses an effect instead of a pure value.
216{-# INLINE_NORMAL consM #-}
219{-# INLINE_NORMAL consM #-}
217consM :: Applicative m => m a -> Stream m a -> Stream m a
220consM :: Applicative m => m a -> Stream m a -> Stream m a