2 {-# OPTIONS_GHC -XNoImplicitPrelude #-}
3 {-# OPTIONS_HADDOCK hide #-}
4 -----------------------------------------------------------------------------
7 -- Copyright : (c) The University of Glasgow, 1994-2002
8 -- License : see libraries/base/LICENSE
10 -- Maintainer : cvs-ghc@haskell.org
11 -- Stability : internal
12 -- Portability : non-portable (GHC extensions)
14 -- The "GHC.Err" module defines the code for the wired-in error functions,
15 -- which have a special type in the compiler (with \"open tyvars\").
17 -- We cannot define these functions in a module where they might be used
18 -- (e.g., "GHC.Base"), because the magical wired-in type will get confused
19 -- with what the typechecker figures out.
21 -----------------------------------------------------------------------------
27 , divZeroError -- :: a
28 , overflowError -- :: a
30 , error -- :: String -> a
41 %*********************************************************
43 \subsection{Error-ish functions}
45 %*********************************************************
48 -- | 'error' stops execution and displays an error message.
50 error s = throw (ErrorCall s)
52 -- | A special case of 'error'.
53 -- It is expected that compilers will recognize this and insert error
54 -- messages which are more appropriate to the context in which 'undefined'
58 undefined = error "Prelude.undefined"
61 %*********************************************************
63 \subsection{Compiler generated errors + local utils}
65 %*********************************************************
67 Used for compiler-generated error message;
68 encoding saves bytes of string junk.
73 absentErr = error "Oops! The program has entered an `absent' argument!\n"
76 Divide by zero and arithmetic overflow.
77 We put them here because they are needed relatively early
78 in the libraries before the Exception type has been defined yet.
81 {-# NOINLINE divZeroError #-}
83 divZeroError = throw DivideByZero
85 {-# NOINLINE overflowError #-}
87 overflowError = throw Overflow