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