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.Error

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

Contents
  1. Simulate Errors monad
  2. Streams
  3. Generating partial reads/writes
  4. Blob
  5. Generating corruption for hPutSome
  6. Error streams for HasFS
Synopsis
  • Packagefs-sim-0.5.0.1
  • Exports21
  • LanguageHaskell2010
  • LicenceApache-2.0
  • SourceError.hs

Simulate Errors monad

Streams

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

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

Generating corruption for hPutSome

Error streams for HasFS

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