X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FIOBase.lhs;h=c25c69ed0c2483e6cc9f0880ac18272d44237add;hb=1172e0e4b9640aa96095e31bcdc854cc55b54e34;hp=84a2d84405816c3ed7751b819b7f1b1cce90c493;hpb=7e85a637700a5b134ac9381e811c0fc1da8cad8f;p=haskell-directory.git diff --git a/GHC/IOBase.lhs b/GHC/IOBase.lhs index 84a2d84..c25c69e 100644 --- a/GHC/IOBase.lhs +++ b/GHC/IOBase.lhs @@ -743,13 +743,18 @@ throwIO err = IO $ raiseIO# err ioException :: IOException -> IO a ioException err = IO $ raiseIO# (IOException err) +-- | Raise an 'IOError' in the 'IO' monad. ioError :: IOError -> IO a ioError = ioException -- --------------------------------------------------------------------------- -- IOError type --- | The Haskell 98 type for exceptions in the @IO@ monad. +-- | The Haskell 98 type for exceptions in the 'IO' monad. +-- Any I\/O operation may raise an 'IOError' instead of returning a result. +-- For a more general type of exception, including also those that arise +-- in pure code, see 'Control.Exception.Exception'. +-- -- In Haskell 98, this is an opaque type. type IOError = IOException @@ -771,6 +776,7 @@ instance Eq IOException where (IOError h1 e1 loc1 str1 fn1) == (IOError h2 e2 loc2 str2 fn2) = e1==e2 && str1==str2 && h1==h2 && loc1==loc2 && fn1==fn2 +-- | An abstract type that contains a value for each variant of 'IOError'. data IOErrorType -- Haskell 98: = AlreadyExists @@ -826,6 +832,14 @@ instance Show IOErrorType where UnsupportedOperation -> "unsupported operation" DynIOError{} -> "unknown IO error" +-- | Construct an 'IOError' value with a string describing the error. +-- The 'fail' method of the 'IO' instance of the 'Monad' class raises a +-- 'userError', thus: +-- +-- > instance Monad IO where +-- > ... +-- > fail s = ioError (userError s) +-- userError :: String -> IOError userError str = IOError Nothing UserError "" str Nothing