Modulevector-stream-0.1.0.1Haskell2010
Data.Stream.Monadic
Monadic stream combinators.
Contents
Synopsis
- data Box
- value liftBox
- data Stream
- data Step
- data SPEC
- value length
- value null
- value empty
- value singleton
- value cons
- value snoc
- value replicate
- value replicateM
- value generate
- value generateM
- value ++
- value head
- value last
- value !!
- value !?
- value slice
- value init
- value tail
- value take
- value drop
- value map
- value mapM
- value mapM_
- value trans
- value unbox
- value concatMap
- value flatten
- value indexed
- value indexedR
- value zipWithM_
- value zipWithM
- value zipWith3M
- value zipWith4M
- value zipWith5M
- value zipWith6M
- value zipWith
- value zipWith3
- value zipWith4
- value zipWith5
- value zipWith6
- value zip
- value zip3
- value zip4
- value zip5
- value zip6
- value eqBy
- value cmpBy
- value filter
- value filterM
- value uniq
- value mapMaybe
- value mapMaybeM
- value catMaybes
- value takeWhile
- value takeWhileM
- value dropWhile
- value dropWhileM
- value elem
- value notElem
- value find
- value findM
- value findIndex
- value findIndexM
- value foldl
- value foldlM
- value foldl1
- value foldl1M
- value foldM
- value fold1M
- value foldl'
- value foldlM'
- value foldl1'
- value foldl1M'
- value foldM'
- value fold1M'
- value foldr
- value foldrM
- value foldr1
- value foldr1M
- value and
- value or
- value concatMapM
- value unfoldr
- value unfoldrM
- value unfoldrN
- value unfoldrNM
- value unfoldrExactN
- value unfoldrExactNM
- value iterateN
- value iterateNM
- value prescanl
- value prescanlM
- value prescanl'
- value prescanlM'
- value postscanl
- value postscanlM
- value postscanl'
- value postscanlM'
- value scanl
- value scanlM
- value scanl'
- value scanlM'
- value scanl1
- value scanl1M
- value scanl1'
- value scanl1M'
- value enumFromStepN
- value enumFromTo
- value enumFromThenTo
- value toList
- value fromList
- value fromListN
- Packagevector-stream-0.1.0.1
- Exports117
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceMonadic.hs
Box monad
Stream
Result 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.Internal.Types
in ghc-internal 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