Hoogle Search
Within LTS Haskell 24.32 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
streamly-core Streamly.Internal.Data.Unfold Enumerate from given starting Enum value from with stride of 1 till maxBound Internal
-
streamly-core Streamly.Internal.Data.Unfold Can be used to enumerate unbounded integrals. This does not check for overflow or underflow for bounded integrals. Internal
enumerateFromStepNum :: forall (m :: Type -> Type) a . (Monad m, Num a) => Unfold m (a, a) astreamly-core Streamly.Internal.Data.Unfold Unfolds (from, stride) generating an infinite stream starting from from and incrementing every time by stride. For Bounded types, after the value overflows it keeps enumerating in a cycle:
>>> Stream.toList $ Stream.take 10 $ Stream.unfold Unfold.enumerateFromStepNum (255::Word8,1) [255,0,1,2,3,4,5,6,7,8]
The implementation is numerically stable for floating point values. Note enumerateFromStepIntegral is faster for integrals. InternalenumerateFromThen :: forall (m :: Type -> Type) . (Enumerable a, Monad m) => Unfold m (a, a) astreamly-core Streamly.Internal.Data.Unfold Unfolds (from, then) generating a stream whose first element is from and the successive elements are in increments of then. Enumeration can occur downwards or upwards depending on whether then comes before or after from. For Bounded types the stream ends when maxBound is reached, for unbounded types it keeps enumerating infinitely.
>>> Stream.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFromThen (0, 2) [0,2,4,6]
>>> Stream.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFromThen (0,(-2)) [0,-2,-4,-6]
Pre-release-
streamly-core Streamly.Internal.Data.Unfold No documentation available.
-
streamly-core Streamly.Internal.Data.Unfold No documentation available.
-
streamly-core Streamly.Internal.Data.Unfold No documentation available.
enumerateFromThenNum :: forall (m :: Type -> Type) a . (Monad m, Num a) => Unfold m (a, a) astreamly-core Streamly.Internal.Data.Unfold Same as 'enumerateFromStepNum (from, next)' using a stride of next - from:
>>> enumerateFromThenNum = lmap ((from, next) -> (from, next - from)) Unfold.enumerateFromStepNum
Example: @ >>> Stream.toList $ Stream.take 10 $ Stream.unfold enumerateFromThenNum (255::Word8,0) [255,0,1,2,3,4,5,6,7,8]The implementation is numerically stable for floating point values. Note that enumerateFromThenIntegral is faster for integrals. Note that in the strange world of floating point numbers, using
enumerateFromThenNum (from, from + 1) is almost exactly the same as enumerateFromStepNum (from, 1) but not precisely the same. Because (from + 1) - from is not exactly 1, it may lose some precision, the loss may also be aggregated in each step, if you want that precision then use enumerateFromStepNum instead. Internal-
streamly-core Streamly.Internal.Data.Unfold Enumerate from given starting Enum value from and next Enum value next with stride of (fromEnum next - fromEnum from) till maxBound. Internal
enumerateFromThenTo :: forall (m :: Type -> Type) . (Enumerable a, Monad m) => Unfold m (a, a, a) astreamly-core Streamly.Internal.Data.Unfold Unfolds (from, then, to) generating a finite stream whose first element is from and the successive elements are in increments of then up to to. Enumeration can occur downwards or upwards depending on whether then comes before or after from.
>>> Stream.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, 2, 6) [0,2,4,6]
>>> Stream.toList $ Stream.unfold Unfold.enumerateFromThenTo (0, (-2), (-6)) [0,-2,-4,-6]
Pre-release