Modulevector-stream-0.1.0.1Haskell2010
Data.Stream.Monadic
Monadic stream combinators.
- 4 types
- 113 values
- Packagevector-stream-0.1.0.1
- Exports117
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceMonadic.hs
Box monad
2 declarationsStream
3 declarationsResult of taking a single step in a stream
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
Length of a Stream
Check if a Stream is empty
Construction
Empty Stream
Singleton Stream
Prepend an element
Append an element
Replicate a value to a given length
Yield a Stream of values obtained by performing the monadic action the given number of times
Generate a stream from its indices
Concatenate two Streams
Accessing elements
First element of the Stream or error if empty
Last element of the Stream or error if empty
Element at the given position
Element at the given position or Nothing if out of bounds
Substreams
Extract a substream of the given length starting at the given position.
All but the last element
All but the first element
The first n elements
All but the first n elements
Mapping
Map a function over a Stream
Map a monadic function over a Stream
Execute a monadic action for each element of the Stream
Transform a Stream to use a different monad
Zipping
Pair each element in a Stream with its index
Pair each element in a Stream with its index, starting from the right and counting down
Zip two Streams with the given monadic function
Comparisons
Check if two Streams are equal
Lexicographically compare two Streams
Filtering
Drop elements which do not satisfy the predicate
Drop elements which do not satisfy the monadic predicate
Drop repeated adjacent elements.
Apply monadic function to each element and drop all Nothings
Longest prefix of elements that satisfy the predicate
Longest prefix of elements that satisfy the monadic predicate
Drop the longest prefix of elements that satisfy the predicate
Drop the longest prefix of elements that satisfy the monadic predicate
Searching
Check whether the Stream contains an element
Inverse of elem
Folding
Left fold
Left fold with a monadic operator
Left fold over a non-empty Stream
Left fold over a non-empty Stream with a monadic operator
Same as foldlM
Same as foldl1M
Left fold with a strict accumulator
Left fold with a strict accumulator and a monadic operator
Left fold over a non-empty Stream with a strict accumulator
Left fold over a non-empty Stream with a strict accumulator and a monadic operator
Same as foldlM'
Same as foldl1M'
Right fold
Right fold with a monadic operator
Right fold over a non-empty stream
Right fold over a non-empty stream with a monadic operator
Specialised folds
Unfolding
Unfold
Unfold with a monadic function
Unfold at most n elements with a monadic function.
Unfold exactly n elements
Unfold exactly n elements with a monadic function.
O(n) Apply function \max(n - 1, 0) times to an initial value,
producing a stream of \max(n, 0) values.
O(n) Apply monadic function \max(n - 1, 0) times to an initial value,
producing a stream of \max(n, 0) values.
Scans
Prefix scan
Prefix scan with a monadic operator
Prefix scan with strict accumulator
Prefix scan with strict accumulator and a monadic operator
Suffix scan
Suffix scan with a monadic operator
Suffix scan with strict accumulator
Suffix scan with strict acccumulator and a monadic operator
Haskell-style scan
Haskell-style scan with a monadic operator
Haskell-style scan with strict accumulator
Haskell-style scan with strict accumulator and a monadic operator
Initial-value free scan over a Stream
Initial-value free scan over a Stream with a monadic operator
Initial-value free scan over a Stream with a strict accumulator
Initial-value free scan over a Stream with a strict accumulator and a monadic operator
Enumerations
Yield a Stream of the given length containing the values x, x+y,
x+y+y etc.
Enumerate values
WARNING: This operation can be very inefficient. If at all possible, use enumFromStepN instead.
Enumerate values with a given step.
WARNING: This operation is very inefficient. If at all possible, use enumFromStepN instead.
Conversions
Convert a Stream to a list
Convert a list to a Stream
Convert the first n elements of a list to a Bundle