Foreign/C/Error.hs

    {-# LANGUAGE CPP, PackageImports #-}
    #if __GLASGOW_HASKELL__ >= 701
    {-# LANGUAGE Safe #-}
    #endif

    -- | The module "Foreign.C.Error" facilitates C-specific error
    -- handling of @errno@.
    module Foreign.C.Error (

      -- * Haskell representations of @errno@ values

      Errno(..),            -- instance: Eq

      -- ** 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.
      eOK, e2BIG, eACCES, eADDRINUSE, eADDRNOTAVAIL, eADV, eAFNOSUPPORT, eAGAIN,
      eALREADY, eBADF, eBADMSG, eBADRPC, eBUSY, eCHILD, eCOMM, eCONNABORTED,
      eCONNREFUSED, eCONNRESET, eDEADLK, eDESTADDRREQ, eDIRTY, eDOM, eDQUOT,
      eEXIST, eFAULT, eFBIG, eFTYPE, eHOSTDOWN, eHOSTUNREACH, eIDRM, eILSEQ,
      eINPROGRESS, eINTR, eINVAL, eIO, eISCONN, eISDIR, eLOOP, eMFILE, eMLINK,
      eMSGSIZE, eMULTIHOP, eNAMETOOLONG, eNETDOWN, eNETRESET, eNETUNREACH,
      eNFILE, eNOBUFS, eNODATA, eNODEV, eNOENT, eNOEXEC, eNOLCK, eNOLINK,
      eNOMEM, eNOMSG, eNONET, eNOPROTOOPT, eNOSPC, eNOSR, eNOSTR, eNOSYS,
      eNOTBLK, eNOTCONN, eNOTDIR, eNOTEMPTY, eNOTSOCK, eNOTTY, eNXIO,
      eOPNOTSUPP, ePERM, ePFNOSUPPORT, ePIPE, ePROCLIM, ePROCUNAVAIL,
      ePROGMISMATCH, ePROGUNAVAIL, ePROTO, ePROTONOSUPPORT, ePROTOTYPE,
      eRANGE, eREMCHG, eREMOTE, eROFS, eRPCMISMATCH, eRREMOTE, eSHUTDOWN,
      eSOCKTNOSUPPORT, eSPIPE, eSRCH, eSRMNT, eSTALE, eTIME, eTIMEDOUT,
      eTOOMANYREFS, eTXTBSY, eUSERS, eWOULDBLOCK, eXDEV,

      -- ** 'Errno' functions
                            -- :: Errno
      isValidErrno,         -- :: Errno -> Bool

      -- access to the current thread's "errno" value
      --
      getErrno,             -- :: IO Errno
      resetErrno,           -- :: IO ()

      -- conversion of an "errno" value into IO error
      --
      errnoToIOError,       -- :: String       -- location
                            -- -> Errno        -- errno
                            -- -> Maybe Handle -- handle
                            -- -> Maybe String -- filename
                            -- -> IOError

      -- throw current "errno" value
      --
      throwErrno,           -- ::                String               -> IO a

      -- ** Guards for IO operations that may fail

      throwErrnoIf,         -- :: (a -> Bool) -> String -> IO a       -> IO a
      throwErrnoIf_,        -- :: (a -> Bool) -> String -> IO a       -> IO ()
      throwErrnoIfRetry,    -- :: (a -> Bool) -> String -> IO a       -> IO a
      throwErrnoIfRetry_,   -- :: (a -> Bool) -> String -> IO a       -> IO ()
      throwErrnoIfMinus1,   -- :: Num a
                            -- =>                String -> IO a       -> IO a
      throwErrnoIfMinus1_,  -- :: Num a
                            -- =>                String -> IO a       -> IO ()
      throwErrnoIfMinus1Retry,
                            -- :: Num a
                            -- =>                String -> IO a       -> IO a
      throwErrnoIfMinus1Retry_,
                            -- :: Num a
                            -- =>                String -> IO a       -> IO ()
      throwErrnoIfNull,     -- ::                String -> IO (Ptr a) -> IO (Ptr a)
      throwErrnoIfNullRetry,-- ::                String -> IO (Ptr a) -> IO (Ptr a)

      throwErrnoIfRetryMayBlock,
      throwErrnoIfRetryMayBlock_,
      throwErrnoIfMinus1RetryMayBlock,
      throwErrnoIfMinus1RetryMayBlock_,
      throwErrnoIfNullRetryMayBlock,

      throwErrnoPath,
      throwErrnoPathIf,
      throwErrnoPathIf_,
      throwErrnoPathIfNull,
      throwErrnoPathIfMinus1,
      throwErrnoPathIfMinus1_,

      ) where

    import "base" Foreign.C.Error