Hoogle Search
Within LTS Haskell 24.31 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
enumFromThenTo :: Enum a => a -> a -> a -> [a]incipit-base Incipit.Base Used in Haskell's translation of [n,n'..m] with [n,n'..m] = enumFromThenTo n n' m, a possible implementation being enumFromThenTo n n' m = worker (f x) (c x) n m, x = fromEnum n' - fromEnum n, c x = bool (>=) ((x 0)
f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + 1) (pred y) | otherwise = y
andworker s c v m | c v m = v : worker s c (s v) m | otherwise = []
Examples
enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
enumFromTo :: Enum a => a -> a -> [a]incipit-base Incipit.Base Used in Haskell's translation of [n..m] with [n..m] = enumFromTo n m, a possible implementation being
enumFromTo n m | n <= m = n : enumFromTo (succ n) m | otherwise = []
Examples
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumerateFromTo :: Enum a => a -> a -> Source amachines Data.Machine.Source Enumerate from a value to a final value, inclusive, via succ Examples:
>>> run $ enumerateFromTo 1 3 [1,2,3]
enumerate :: forall (m :: Type -> Type) a . (Monad m, Bounded a, Enumerable a) => Stream m astreamly-core Streamly.Data.Stream enumerate = enumerateFrom minBound
Enumerate a Bounded type from its minBound to maxBoundenumerateFrom :: forall (m :: Type -> Type) . (Enumerable a, Monad m) => a -> Stream m astreamly-core Streamly.Data.Stream enumerateFrom from generates a stream starting with the element from, enumerating up to maxBound when the type is Bounded or generating an infinite stream when the type is not Bounded.
>>> Stream.toList $ Stream.take 4 $ Stream.enumerateFrom (0 :: Int) [0,1,2,3]
For Fractional types, enumeration is numerically stable. However, no overflow or underflow checks are performed.>>> Stream.toList $ Stream.take 4 $ Stream.enumerateFrom 1.1 [1.1,2.1,3.1,4.1]
enumerateFromThen :: forall (m :: Type -> Type) . (Enumerable a, Monad m) => a -> a -> Stream m astreamly-core Streamly.Data.Stream enumerateFromThen from then generates a stream whose first element is from, the second element is then and the successive elements are in increments of then - from. 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.enumerateFromThen 0 2 [0,2,4,6]
>>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromThen 0 (-2) [0,-2,-4,-6]
-
streamly-core Streamly.Data.Stream enumerateFromThenTo from then to generates a finite stream whose first element is from, the second element is then and the successive elements are in increments of then - from up to to. Enumeration can occur downwards or upwards depending on whether then comes before or after from.
>>> Stream.toList $ Stream.enumerateFromThenTo 0 2 6 [0,2,4,6]
>>> Stream.toList $ Stream.enumerateFromThenTo 0 (-2) (-6) [0,-2,-4,-6]
enumerateFromTo :: forall (m :: Type -> Type) . (Enumerable a, Monad m) => a -> a -> Stream m astreamly-core Streamly.Data.Stream Generate a finite stream starting with the element from, enumerating the type up to the value to. If to is smaller than from then an empty stream is returned.
>>> Stream.toList $ Stream.enumerateFromTo 0 4 [0,1,2,3,4]
For Fractional types, the last element is equal to the specified to value after rounding to the nearest integral value.>>> Stream.toList $ Stream.enumerateFromTo 1.1 4 [1.1,2.1,3.1,4.1]
>>> Stream.toList $ Stream.enumerateFromTo 1.1 4.6 [1.1,2.1,3.1,4.1,5.1]
enumerateTo :: forall (m :: Type -> Type) a . (Monad m, Bounded a, Enumerable a) => a -> Stream m astreamly-core Streamly.Data.Stream >>> enumerateTo = Stream.enumerateFromTo minBound
Enumerate a Bounded type from its minBound to specified value.enumerateFrom :: forall (m :: Type -> Type) . (Enumerable a, Monad m) => Unfold m a astreamly-core Streamly.Data.Unfold Unfolds from generating a stream starting with the element from, enumerating up to maxBound when the type is Bounded or generating an infinite stream when the type is not Bounded.
>>> Stream.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFrom (0 :: Int) [0,1,2,3]
For Fractional types, enumeration is numerically stable. However, no overflow or underflow checks are performed.>>> Stream.toList $ Stream.take 4 $ Stream.unfold Unfold.enumerateFrom 1.1 [1.1,2.1,3.1,4.1]
Pre-release