HORIZON HASKELLDocslts/ghc-9.14.x99ffbb82026-10-19Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 99ffbb8 · 2026-10-19

Modulefs-sim-0.5.0.1Haskell2010

System.FS.Sim.Stream

Finite and infinite streams of Maybe as.

Contents
  1. Streams
  2. Running
  3. Construction
  4. Modify
  5. Query
  6. Generation and shrinking
Synopsis
  • Packagefs-sim-0.5.0.1
  • Exports20
  • LanguageHaskell2010
  • LicenceApache-2.0
  • SourceStream.hs

Streams

datadata Stream a

A stream of Maybe as that can be infinite.

Constructors

  • UnsafeStream

    UNSAFE: when constructing, modifying, or accessing the internals of a Stream, it is the responsibility of the user to preserve the following invariant:

    INVARIANT: if the stream is marked as Infinite, then the internal list should be infinite. If the stream is marked as Finite, then the internal list should finite.

    • If the internal list is infinite but marked as Finite, then shrink or show on the corresponding stream will diverge.

    • If the internal list is finite but marked as Infinite, then shrink on the corresponding stream will degrade to an infinite list of empty streams.

Instances2Functor, Show
  • Functor StreamDefined in fs-sim-0.5.0.1 · System.FS.Sim.Stream
  • Show a => Show (Stream a)Defined in fs-sim-0.5.0.1 · System.FS.Sim.Stream

    Fully shows a Stream if it is finite, or prints a placeholder string if it is infinite.

Running

Construction

Modify

Query

valuenull :: Stream a -> Bool

Check that the stream is empty.

In general, a stream is only empty if the stream is equivalent to empty.

A finite/infinite stream consisting of only Nothings is not considered to be empty. In particular, null (always Nothing) /= True.

Generation and shrinking

valueshrinkStream :: Stream a -> [Stream a]

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.