X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FErr.lhs;h=85453aa11d6e8c923357ff2c9a8e9d91cada4a21;hb=d9a0d6f44a930da4ae49678908e37793d693467c;hp=e7abb0cc17175e793e9f6e009b7ff2b0965de41b;hpb=b706340c451952adf230b5b8daecad8a1f34d714;p=ghc-base.git diff --git a/GHC/Err.lhs b/GHC/Err.lhs index e7abb0c..85453aa 100644 --- a/GHC/Err.lhs +++ b/GHC/Err.lhs @@ -1,5 +1,5 @@ \begin{code} -{-# OPTIONS -fno-implicit-prelude #-} +{-# OPTIONS_GHC -fno-implicit-prelude #-} ----------------------------------------------------------------------------- -- | -- Module : GHC.Err @@ -19,6 +19,7 @@ -- ----------------------------------------------------------------------------- +-- #hide module GHC.Err ( irrefutPatError @@ -29,8 +30,8 @@ module GHC.Err , recConError , runtimeError -- :: Addr# -> a -- Addr# points to UTF8 encoded C string - , absentErr, parError -- :: a - , seqError -- :: a + , absentErr -- :: a + , divZeroError -- :: a , error -- :: String -> a , assertError -- :: String -> Bool -> a -> a @@ -38,9 +39,11 @@ module GHC.Err , undefined -- :: a ) where +#ifndef __HADDOCK__ import GHC.Base import GHC.List ( span ) import GHC.Exception +#endif \end{code} %********************************************************* @@ -50,12 +53,13 @@ import GHC.Exception %********************************************************* \begin{code} --- error stops execution and displays an error message +-- | 'error' stops execution and displays an error message. error :: String -> a error s = throw (ErrorCall s) +-- | A special case of 'error'. -- It is expected that compilers will recognize this and insert error --- messages which are more appropriate to the context in which undefined +-- messages which are more appropriate to the context in which 'undefined' -- appears. undefined :: a @@ -72,11 +76,9 @@ Used for compiler-generated error message; encoding saves bytes of string junk. \begin{code} -absentErr, parError, seqError :: a +absentErr :: a absentErr = error "Oops! The program has entered an `absent' argument!\n" -parError = error "Oops! Entered GHCerr.parError (a GHC bug -- please report it!)\n" -seqError = error "Oops! Entered seqError (a GHC bug -- please report it!)\n" \end{code} \begin{code} @@ -127,3 +129,13 @@ untangle coded message } not_bar c = c /= '|' \end{code} + +Divide by zero. We put it here because it is needed relatively early +in the libraries before the Exception type has been defined yet. + +\begin{code} +{-# NOINLINE divZeroError #-} +divZeroError :: a +divZeroError = throw (ArithException DivideByZero) +\end{code} +