module System.IO.Error (
IOError, -- abstract
-#ifdef __GLASGOW_HASKELL__
IOErrorType, -- abstract
-#endif
catch, -- :: IO a -> (IOError -> IO a) -> IO a
try, -- :: IO a -> IO (Either IOError a)
ioError, -- :: IOError -> IO a
userError, -- :: String -> IOError
-#ifdef __GLASGOW_HASKELL__
+#ifndef __NHC__
mkIOError, -- :: IOErrorType -> String -> Maybe Handle
-- -> Maybe FilePath -> IOError
annotateIOError, -- :: IOError -> String -> Maybe FilePath
-- -> Maybe Handle -> IOError
+#endif
alreadyExistsErrorType, -- :: IOErrorType
doesNotExistErrorType,
isIllegalOperationErrorType,
isPermissionErrorType,
isUserErrorType,
-#endif /* __GLASGOW_HASKELL__ */
isAlreadyExistsError, -- :: IOError -> Bool
isDoesNotExistError,
isPermissionError,
isUserError,
-#ifdef __GLASGOW_HASKELL__
+#ifndef __NHC__
ioeGetErrorType, -- :: IOError -> IOErrorType
#endif
ioeGetErrorString, -- :: IOError -> String
) where
import Data.Either
+import Data.Maybe
#ifdef __GLASGOW_HASKELL__
import GHC.Base
-import Data.Maybe
import GHC.IOBase
import GHC.Exception
import Text.Show
#endif
#ifdef __HUGS__
-import Hugs.IO
+import Hugs.Prelude(Handle, IOException(..), IOErrorType(..))
#endif
#ifdef __NHC__
(return . Left)
#endif
-#ifdef __GLASGOW_HASKELL__
+#if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)
-- -----------------------------------------------------------------------------
-- Constructing an IOError
mkIOError t location maybe_hdl maybe_filename =
IOError{ ioe_type = t,
ioe_location = location,
- ioe_descr = "",
+ ioe_description = "",
ioe_handle = maybe_hdl,
ioe_filename = maybe_filename
}
ioeTypeToInt IllegalOperation = fromEnum EPERM
ioeTypeToInt PermissionDenied = fromEnum EACCES
#endif
+#endif /* __GLASGOW_HASKELL__ || __HUGS__ */
+#ifndef __NHC__
-- -----------------------------------------------------------------------------
-- IOErrorType
isIllegalOperation = isIllegalOperationErrorType . ioeGetErrorType
isPermissionError = isPermissionErrorType . ioeGetErrorType
isUserError = isUserErrorType . ioeGetErrorType
-#endif
+#endif /* __NHC__ */
-- -----------------------------------------------------------------------------
-- IOErrorTypes
| PermissionDenied | UserError
#endif
-#ifdef __GLASGOW_HASKELL__
alreadyExistsErrorType, doesNotExistErrorType, alreadyInUseErrorType,
fullErrorType, eofErrorType, illegalOperationErrorType,
permissionErrorType, userErrorType :: IOErrorType
illegalOperationErrorType = IllegalOperation
permissionErrorType = PermissionDenied
userErrorType = UserError
-#endif
-- -----------------------------------------------------------------------------
-- IOErrorType predicates
-#ifdef __GLASGOW_HASKELL__
isAlreadyExistsErrorType, isDoesNotExistErrorType, isAlreadyInUseErrorType,
isFullErrorType, isEOFErrorType, isIllegalOperationErrorType,
isPermissionErrorType, isUserErrorType :: IOErrorType -> Bool
-#endif
-#ifdef __GLASGOW_HASKELL__
isAlreadyExistsErrorType AlreadyExists = True
isAlreadyExistsErrorType _ = False
isUserErrorType UserError = True
isUserErrorType _ = False
-#endif
-- -----------------------------------------------------------------------------
-- Miscellaneous
-#ifdef __GLASGOW_HASKELL__
+#if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)
ioeGetErrorType :: IOError -> IOErrorType
ioeGetHandle :: IOError -> Maybe Handle
ioeGetErrorString :: IOError -> String
ioeGetHandle ioe = ioe_handle ioe
ioeGetErrorString ioe
- | isUserErrorType (ioe_type ioe) = ioe_descr ioe
+ | isUserErrorType (ioe_type ioe) = ioe_description ioe
| otherwise = show (ioe_type ioe)
ioeGetFileName ioe = ioe_filename ioe
-#endif
-- -----------------------------------------------------------------------------
-- annotating an IOError
-#ifdef __GLASGOW_HASKELL__
annotateIOError :: IOError
-> String
-> Maybe FilePath
where
Nothing `mplus` ys = ys
xs `mplus` _ = xs
-#endif
+#endif /* __GLASGOW_HASKELL__ || __HUGS__ */
#ifdef 0 /*__NHC__*/
annotateIOError (IOError msg file hdl code) msg' file' hdl' =