@@ -57,6 +57,7 @@ module Streamly.Internal.Prelude
5757 , unfoldr
5858 , unfoldrM
5959 , unfold
60+ , unfold0
6061 , iterate
6162 , iterateM
6263 , fromIndices
@@ -536,6 +537,7 @@ import Data.Kind (Type)
536537#endif
537538import Data.Heap (Entry(..))
538539import Data.Maybe (isJust, fromJust, isNothing)
540+import Data.Void (Void)
539541import Foreign.Storable (Storable)
540542import Prelude
541543 hiding (filter, drop, dropWhile, take, takeWhile, zipWith, foldr,
@@ -706,6 +708,13 @@ unfoldrMZipSerial = Serial.unfoldrM
706708unfold :: (IsStream t, Monad m) => Unfold m a b -> a -> t m b
707709unfold unf x = fromStreamD $ D.unfold unf x
708710
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+
709718------------------------------------------------------------------------------
710719-- Specialized Generation
711720------------------------------------------------------------------------------