HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulebase-4.23.0.0Haskell2010

Foreign.C.Error

C-specific Marshalling support: Handling of C "errno" error codes.

Contents
  1. Haskell representations of errno values
  2. Common errno symbols
  3. Errno functions
  4. Guards for IO operations that may fail
Synopsis
  • Packagebase-4.23.0.0
  • Exports127
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceError.hs

Haskell representations of errno values

newtypenewtype Errno

Haskell representation for errno values. The implementation is deliberately exposed, to allow users to add their own definitions of Errno values.

Constructors

Instances1Eq
  • Eq ErrnoDefined in ghc-internal-10.0.0 · GHC.Internal.Foreign.C.Error

Common errno symbols

Different operating systems and/or C libraries often support different values of errno. This module defines the common values, but due to the open definition of Errno users may add definitions which are not predefined.

Errno functions

valuegetErrno :: IO Errno

Get the current value of errno in the current thread.

On GHC, the runtime will ensure that any Haskell thread will only see "its own" errno, by saving and restoring the value when Haskell threads are scheduled across OS threads.

Guards for IO operations that may fail

valuethrowErrnoIf
  1. :: (a -> Bool)

    predicate to apply to the result value of the IO operation

  2. -> String

    textual description of the location

  3. -> IO a

    the IO operation to be executed

  4. -> IO a

Throw an IOError corresponding to the current value of getErrno if the result value of the IO action meets the given predicate.