@@ -125,9 +125,6 @@ module Streamly.Internal.Data.Unfold
126 , concatMapM
126 , concatMapM
127 , outerProduct
127 , outerProduct
132 -- * Exceptions
129 -- * Exceptions
133 , gbracket_
130 , gbracket_
@@ -159,7 +156,7 @@ import Streamly.Internal.Data.IOFinalizer
159 (newIOFinalizer, runIOFinalizer, clearingIOFinalizer)
156 (newIOFinalizer, runIOFinalizer, clearingIOFinalizer)
160import Streamly.Internal.Data.Stream.StreamD.Type (Stream(..), Step(..))
157import Streamly.Internal.Data.Stream.StreamD.Type (Stream(..), Step(..))
161import Streamly.Internal.Data.Time.Clock (Clock(Monotonic), getTime)
158import Streamly.Internal.Data.Time.Clock (Clock(Monotonic), getTime)
162−import Streamly.Internal.Data.Unfold.Types (Unfold(..), lmap, map)
159+import Streamly.Internal.Data.Unfold.Types (Unfold(..), lmap, map, const)
163import System.Mem (performMajorGC)
160import System.Mem (performMajorGC)
165import qualified Prelude
162import qualified Prelude
@@ -429,13 +426,6 @@ singleton f = singletonM $ return . f
429identity :: Monad m => Unfold m a a
426identity :: Monad m => Unfold m a a
430identity = singletonM return
427identity = singletonM return
432−const :: Monad m => m b -> Unfold m a b
433−const m = Unfold step inject
435− inject _ = return ()
436− step () = m >>= \r -> return $ Yield r ()
439-- | Convert a list of pure values to a 'Stream'
429-- | Convert a list of pure values to a 'Stream'
440{-# INLINE_LATE fromList #-}
430{-# INLINE_LATE fromList #-}
441fromList :: Monad m => Unfold m [a] a
431fromList :: Monad m => Unfold m [a] a
@@ -952,6 +942,8 @@ concat (Unfold step1 inject1) (Unfold step2 inject2) = Unfold step inject
952data OuterProductState s1 s2 sy x y =
942data OuterProductState s1 s2 sy x y =
953 OuterProductOuter s1 y | OuterProductInner s1 sy s2 x
943 OuterProductOuter s1 y | OuterProductInner s1 sy s2 x
945+-- XXX this can be written in terms of "cross".
955-- | Create an outer product (vector product or cartesian product) of the
947-- | Create an outer product (vector product or cartesian product) of the
956-- output streams of two unfolds.
948-- output streams of two unfolds.
@@ -981,34 +973,6 @@ outerProduct (Unfold step1 inject1) (Unfold step2 inject2) = Unfold step inject
981 Skip s -> Skip (OuterProductInner ost sy s x)
973 Skip s -> Skip (OuterProductInner ost sy s x)
982 Stop -> Skip (OuterProductOuter ost sy)
974 Stop -> Skip (OuterProductOuter ost sy)
984−-- Special cases of outer product
985−-- | Outer product with a function application.
989−{-# INLINE_NORMAL ap #-}
991− Unfold m a (b -> c) -> Unfold m d b -> Unfold m (a, d) c
992−ap (Unfold _step1 _inject1) (Unfold _step2 _inject2) = undefined
994−-- | Outer product discarding the first element.
998−{-# INLINE_NORMAL apDiscardFst #-}
999−apDiscardFst :: -- Monad m =>
1000− Unfold m a b -> Unfold m c d -> Unfold m (a, c) d
1001−apDiscardFst (Unfold _step1 _inject1) (Unfold _step2 _inject2) = undefined
1003−-- | Outer product discarding the second element.
1007−{-# INLINE_NORMAL apDiscardSnd #-}
1008−apDiscardSnd :: -- Monad m =>
1009− Unfold m a b -> Unfold m c d -> Unfold m (a, c) b
1010−apDiscardSnd (Unfold _step1 _inject1) (Unfold _step2 _inject2) = undefined
1012-- XXX This can be used to implement a Monad instance for "Unfold m ()".
976-- XXX This can be used to implement a Monad instance for "Unfold m ()".
1014data ConcatMapState s1 s2 = ConcatMapOuter s1 | ConcatMapInner s1 s2
978data ConcatMapState s1 s2 = ConcatMapOuter s1 | ConcatMapInner s1 s2