on master help sign in
Add unfold0
6cc0e92Shlok Datye
src/Streamly/Internal/Prelude.hs+9
@@ -57,6 +57,7 @@ module Streamly.Internal.Prelude
57 , unfoldr
57 , unfoldr
58 , unfoldrM
58 , unfoldrM
59 , unfold
59 , unfold
60+ , unfold0
60 , iterate
61 , iterate
61 , iterateM
62 , iterateM
62 , fromIndices
63 , fromIndices
@@ -536,6 +537,7 @@ import Data.Kind (Type)
536#endif
537#endif
537import Data.Heap (Entry(..))
538import Data.Heap (Entry(..))
538import Data.Maybe (isJust, fromJust, isNothing)
539import Data.Maybe (isJust, fromJust, isNothing)
540+import Data.Void (Void)
539import Foreign.Storable (Storable)
541import Foreign.Storable (Storable)
540import Prelude
542import Prelude
541 hiding (filter, drop, dropWhile, take, takeWhile, zipWith, foldr,
543 hiding (filter, drop, dropWhile, take, takeWhile, zipWith, foldr,
@@ -706,6 +708,13 @@ unfoldrMZipSerial = Serial.unfoldrM
706unfold :: (IsStream t, Monad m) => Unfold m a b -> a -> t m b
708unfold :: (IsStream t, Monad m) => Unfold m a b -> a -> t m b
707unfold unf x = fromStreamD $ D.unfold unf x
709unfold unf x = fromStreamD $ D.unfold unf x
708
710
711+-- | Convert an 'Unfold' with a closed input end into a stream.
712+--
713+-- /Internal/
714+{-# INLINE unfold0 #-}
715+unfold0 :: (IsStream t, Monad m) => Unfold m Void b -> t m b
716+unfold0 unf = unfold unf (error "unfold0: unexpected void evaluation")
717+
709------------------------------------------------------------------------------
718------------------------------------------------------------------------------
710-- Specialized Generation
719-- Specialized Generation
711------------------------------------------------------------------------------
720------------------------------------------------------------------------------