HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulevector-stream-0.1.0.1Haskell2010

Data.Stream.Monadic

Monadic stream combinators.

  • 4 types
  • 113 values

Box monad

2 declarations
datadata Box a
#

Box monad

Constructors

Instances3Monad, Functor, Applicative
  • Monad BoxDefined in vector-stream-0.1.0.1 · Data.Stream.Monadic
  • Functor BoxDefined in vector-stream-0.1.0.1 · Data.Stream.Monadic
  • Applicative BoxDefined in vector-stream-0.1.0.1 · Data.Stream.Monadic

Stream

3 declarations
datadata Step s a where
#

Result of taking a single step in a stream

Constructors

Instances1Functor
  • Functor (Step s)Defined in vector-stream-0.1.0.1 · Data.Stream.Monadic
datadata SPEC
#

SPEC is used by GHC in the SpecConstr pass in order to inform the compiler when to be particularly aggressive. In particular, it tells GHC to specialize regardless of size or the number of specializations. However, not all loops fall into this category.

Libraries can specify this by using SPEC data type to inform which loops should be aggressively specialized. For example, instead of

loop x where loop arg = ...

write

loop SPEC x where loop !_ arg = ...

There is no semantic difference between SPEC and SPEC2, we just need a type with two constructors lest it is optimised away before SpecConstr.

This type is reexported from GHC.Exts since GHC 9.0 and base-4.15. For compatibility with earlier releases import it from GHC.Types in ghc-prim package.

Length

Construction

Accessing elements

Substreams

valueslice
  1. :: Monad m
  2. => Int

    starting index

  3. -> Int

    length

  4. -> Stream m a
  5. -> Stream m a
#

Extract a substream of the given length starting at the given position.

Mapping

valuemapM_ :: Monad m => (a -> m b) -> Stream m a -> m ()
#

Execute a monadic action for each element of the Stream

Zipping

Comparisons

Filtering

Searching

Folding

valuefoldlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a
#

Left fold with a monadic operator

valuefoldl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> m a
#

Left fold with a strict accumulator

valuefoldlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> m a
#

Left fold with a strict accumulator and a monadic operator

valuefoldl1' :: Monad m => (a -> a -> a) -> Stream m a -> m a
#

Left fold over a non-empty Stream with a strict accumulator

valuefoldrM :: Monad m => (a -> b -> m b) -> b -> Stream m a -> m b
#

Right fold with a monadic operator

valuefoldr1 :: Monad m => (a -> a -> a) -> Stream m a -> m a
#

Right fold over a non-empty stream

Specialised folds

Unfolding

valueiterateN :: Monad m => Int -> (a -> a) -> a -> Stream m a
#

O(n) Apply function \max(n - 1, 0) times to an initial value, producing a stream of \max(n, 0) values.

valueiterateNM :: Monad m => Int -> (a -> m a) -> a -> Stream m a
#

O(n) Apply monadic function \max(n - 1, 0) times to an initial value, producing a stream of \max(n, 0) values.

Scans

valueprescanlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a
#

Prefix scan with strict accumulator and a monadic operator

valuescanlM :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a
#

Haskell-style scan with a monadic operator

valuescanl' :: Monad m => (a -> b -> a) -> a -> Stream m b -> Stream m a
#

Haskell-style scan with strict accumulator

valuescanlM' :: Monad m => (a -> b -> m a) -> a -> Stream m b -> Stream m a
#

Haskell-style scan with strict accumulator and a monadic operator

valuescanl1M' :: Monad m => (a -> a -> m a) -> Stream m a -> Stream m a
#

Initial-value free scan over a Stream with a strict accumulator and a monadic operator

Enumerations

Conversions