HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulefs-sim-0.5.0.1Haskell2010

System.FS.Sim.Error

HasFS instance wrapping SimFS that generates errors, suitable for testing error handling.

  • 7 types
  • 14 values
  • Packagefs-sim-0.5.0.1
  • Exports21
  • LanguageHaskell2010
  • LicenceApache-2.0
  • SourceError.hs

Simulate Errors monad

4 declarations

Streams

3 declarations

An ErrorStream is a possibly infinite Stream of (Maybe) FsErrorTypes.

Nothing indicates that there is no error.

Each time the ErrorStream is used (see runErrorStream), the first element (Nothing in case the list is empty) is taken from the list and an ErrorStream with the remainder of the list is returned. The first element represents whether an error should be returned or not.

An FsError consists of a number of fields: fsErrorType, a fsErrorPath, etc. Only the first fields is interesting. Therefore, we only generate the FsErrorType. The FsErrorType will be used to construct the actual FsError.

Generating partial reads/writes

4 declarations
newtypenewtype Partial
#

A Partial p, where p > 0, is a number representing how many fewer bytes should be read or written than requested.

Constructors

Instances2Show, Arbitrary

Given a requested number of bytes to read/write, compute a partial number of bytes to read/write.

We subtract p from the number of requested bytes. If that would result in 0 requested bytes or less, we request 1 byte. If the number of requested bytes was already 0, we can't simulate a partial read so we return 0 again.

Blob

3 declarations

Generating corruption for hPutSome

2 declarations

Error streams for HasFS

5 declarations
datadata Errors
#

Error streams for the methods of the HasFS type class.

An ErrorStream is provided for each method of the HasFS type class. This ErrorStream will be used to generate potential errors that will be thrown by the corresponding method.

For hPutSome, an ErrorStreamWithCorruption is provided to simulate corruption.

An Errors is used in conjunction with SimErrorFS, which is a layer on top of SimFS that simulates methods throwing FsErrors.

Instances2Show, Arbitrary
valuegenErrors
  1. :: Bool

    True -> generate partial writes

  2. -> Bool

    True -> generate SubstituteWithJunk corruptions

  3. -> Gen Errors
#

Generator for Errors that allows some things to be disabled.

This is needed by the VolatileDB state machine tests, which try to predict what should happen based on the Errors, which is too complex sometimes.