X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FErr.lhs;h=946ca36af6b3979d6ca5841ff2114a1339dd562d;hb=7c0b04fd273621130062418bb764809c79488dd2;hp=fb34ab569b12d9096def1f7b619fdd3fb0fba052;hpb=05e43a9bd25232efced01ce45d00b3b3ba12af51;p=haskell-directory.git diff --git a/GHC/Err.lhs b/GHC/Err.lhs index fb34ab5..946ca36 100644 --- a/GHC/Err.lhs +++ b/GHC/Err.lhs @@ -1,20 +1,25 @@ -% ----------------------------------------------------------------------------- -% $Id: Err.lhs,v 1.4 2002/04/11 12:03:43 simonpj Exp $ -% -% (c) The University of Glasgow, 1994-2000 -% - -\section[GHC.Err]{Module @GHC.Err@} - -The GHC.Err module defines the code for the wired-in error functions, -which have a special type in the compiler (with "open tyvars"). - -We cannot define these functions in a module where they might be used -(e.g., GHC.Base), because the magical wired-in type will get confused -with what the typechecker figures out. - \begin{code} -{-# OPTIONS -fno-implicit-prelude #-} +{-# OPTIONS_GHC -fno-implicit-prelude #-} +----------------------------------------------------------------------------- +-- | +-- Module : GHC.Err +-- Copyright : (c) The University of Glasgow, 1994-2002 +-- License : see libraries/base/LICENSE +-- +-- Maintainer : cvs-ghc@haskell.org +-- Stability : internal +-- Portability : non-portable (GHC extensions) +-- +-- The "GHC.Err" module defines the code for the wired-in error functions, +-- which have a special type in the compiler (with \"open tyvars\"). +-- +-- We cannot define these functions in a module where they might be used +-- (e.g., "GHC.Base"), because the magical wired-in type will get confused +-- with what the typechecker figures out. +-- +----------------------------------------------------------------------------- + +-- #hide module GHC.Err ( irrefutPatError @@ -25,8 +30,9 @@ module GHC.Err , recConError , runtimeError -- :: Addr# -> a -- Addr# points to UTF8 encoded C string - , absentErr, parError -- :: a - , seqError -- :: a + , absentErr -- :: a + , divZeroError -- :: a + , overflowError -- :: a , error -- :: String -> a , assertError -- :: String -> Bool -> a -> a @@ -34,9 +40,11 @@ module GHC.Err , undefined -- :: a ) where +#ifndef __HADDOCK__ import GHC.Base import GHC.List ( span ) import GHC.Exception +#endif \end{code} %********************************************************* @@ -46,12 +54,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 @@ -68,11 +77,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} @@ -123,3 +130,18 @@ untangle coded message } not_bar c = c /= '|' \end{code} + +Divide by zero and arithmetic overflow. +We put them here because they are needed relatively early +in the libraries before the Exception type has been defined yet. + +\begin{code} +{-# NOINLINE divZeroError #-} +divZeroError :: a +divZeroError = throw (ArithException DivideByZero) + +{-# NOINLINE overflowError #-} +overflowError :: a +overflowError = throw (ArithException Overflow) +\end{code} +