HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulevector-stream-0.1.0.1Haskell2010

Data.Stream.Monadic

Monadic stream combinators.

Contents
  1. Box monad
  2. Stream
  3. Length
  4. Construction
  5. Accessing elements
  6. Substreams
  7. Mapping
  8. Zipping
  9. Comparisons
  10. Filtering
  11. Searching
  12. Folding
  13. Specialised folds
  14. Unfolding
  15. Scans
  16. Enumerations
  17. Conversions
Synopsis

Box monad

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

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.Internal.Types in ghc-internal package.

Length

Construction

Accessing elements

Substreams

Mapping

Zipping

Comparisons

Filtering

Searching

Folding

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

Left fold with a strict accumulator and a monadic operator

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

Enumerations

Conversions