Remove unused imports
[ghc-base.git] / GHC / Err.lhs
1 \begin{code}
2 {-# OPTIONS_GHC -XNoImplicitPrelude #-}
3 {-# OPTIONS_HADDOCK hide #-}
4 -----------------------------------------------------------------------------
5 -- |
6 -- Module      :  GHC.Err
7 -- Copyright   :  (c) The University of Glasgow, 1994-2002
8 -- License     :  see libraries/base/LICENSE
9 -- 
10 -- Maintainer  :  cvs-ghc@haskell.org
11 -- Stability   :  internal
12 -- Portability :  non-portable (GHC extensions)
13 --
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\").
16 -- 
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.
20 -- 
21 -----------------------------------------------------------------------------
22
23 -- #hide
24 module GHC.Err
25        (
26          absentErr                 -- :: a
27        , divZeroError              -- :: a
28        , overflowError             -- :: a
29
30        , error                     -- :: String -> a
31
32        , undefined                 -- :: a
33        ) where
34
35 #ifndef __HADDOCK__
36 import GHC.Base
37 import GHC.IOBase
38 import GHC.List ()
39 import GHC.Exception
40 #endif
41 \end{code}
42
43 %*********************************************************
44 %*                                                      *
45 \subsection{Error-ish functions}
46 %*                                                      *
47 %*********************************************************
48
49 \begin{code}
50 -- | 'error' stops execution and displays an error message.
51 error :: String -> a
52 error s = throw (ErrorCall s)
53
54 -- | A special case of 'error'.
55 -- It is expected that compilers will recognize this and insert error
56 -- messages which are more appropriate to the context in which 'undefined'
57 -- appears. 
58
59 undefined :: a
60 undefined =  error "Prelude.undefined"
61 \end{code}
62
63 %*********************************************************
64 %*                                                       *
65 \subsection{Compiler generated errors + local utils}
66 %*                                                       *
67 %*********************************************************
68
69 Used for compiler-generated error message;
70 encoding saves bytes of string junk.
71
72 \begin{code}
73 absentErr :: a
74
75 absentErr = error "Oops! The program has entered an `absent' argument!\n"
76 \end{code}
77
78 Divide by zero and arithmetic overflow.
79 We put them here because they are needed relatively early
80 in the libraries before the Exception type has been defined yet.
81
82 \begin{code}
83 {-# NOINLINE divZeroError #-}
84 divZeroError :: a
85 divZeroError = throw DivideByZero
86
87 {-# NOINLINE overflowError #-}
88 overflowError :: a
89 overflowError = throw Overflow
90 \end{code}
91