| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
System.FS.Sim.Stream
Description
Finite and infinite streams of s.Maybe a
Synopsis
- data Stream a = UnsafeStream {}
- data InternalInfo
- runStream :: Stream a -> (Maybe a, Stream a)
- runStreamN :: Int -> Stream a -> ([Maybe a], Stream a)
- runStreamIndefinitely :: Stream a -> [Maybe a]
- always :: a -> Stream a
- empty :: Stream a
- repeating :: [Maybe a] -> Stream a
- unsafeMkInfinite :: [Maybe a] -> Stream a
- unsafeMkFinite :: [Maybe a] -> Stream a
- filter :: (Maybe a -> Bool) -> Stream a -> Stream a
- null :: Stream a -> Bool
- isFinite :: Stream a -> Bool
- isInfinite :: Stream a -> Bool
- genFinite :: Gen (Maybe a) -> Gen (Stream a)
- genFiniteN :: Int -> Gen (Maybe a) -> Gen (Stream a)
- genInfinite :: Gen (Maybe a) -> Gen (Stream a)
- genMaybe :: Int -> Int -> Gen a -> Gen (Maybe a)
- shrinkStream :: Stream a -> [Stream a]
- liftShrinkStream :: (Maybe a -> [Maybe a]) -> Stream a -> [Stream a]
Streams
A stream of s that can be infinite.Maybe a
Constructors
| UnsafeStream | UNSAFE: when constructing, modifying, or accessing the internals of a
INVARIANT: if the stream is marked as |
Fields
| |
data InternalInfo Source #
Running
runStreamN :: Int -> Stream a -> ([Maybe a], Stream a) Source #
\( O(n) \): like runStream, but advancing the stream n times.
If n<=0, then the stream is advanced 0 times.
runStreamIndefinitely :: Stream a -> [Maybe a] Source #
\( O(\infty) \): like runStream, but advancing the stream indefinitely.
For infinite streams, this produces an infinite list. For finite streams, this produces a finite list.
Construction
unsafeMkInfinite :: [Maybe a] -> Stream a Source #
UNSAFE: Make a Stream that is marked as infinite. It is the user's
responsibility to only pass in infinite lists. See UnsafeStream for more
information.
unsafeMkFinite :: [Maybe a] -> Stream a Source #
UNSAFE: Make a Stream that is marked as finite. It is the user's
responsibility to only pass in finite lists. See UnsafeStream for more
information.
Modify
Query
isInfinite :: Stream a -> Bool Source #
Check that the stream is infinite
Generation and shrinking
Generate a finite Stream of length n.
shrinkStream :: Stream a -> [Stream a] Source #
Shrink a stream like it is an InfiniteList.
Infinite streams are shrunk differently than lists that are finite, which is to ensure that we shrink infinite lists towards finite lists.
- Infinite streams are shrunk by taking finite prefixes of the argument stream. Note that there are an infinite number of finite prefixes, so even though the *shrink list* is infinite, the individual *list elements* are finite.
- Finite streams are shrunk like lists are shrunk normally, preserving finiteness.
liftShrinkStream :: (Maybe a -> [Maybe a]) -> Stream a -> [Stream a] Source #
Like shrinkStream, but with a custom shrinker for elements of the stream.