9bd71327d93a54c6f87b19bb480e52eb3a3f5499
[ghc.git] / libraries / base / GHC / Err.hs
1 {-# LANGUAGE Trustworthy #-}
2 {-# LANGUAGE NoImplicitPrelude, MagicHash #-}
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 module GHC.Err( absentErr, error, undefined ) where
25 import GHC.CString ()
26 import GHC.Types
27 import GHC.Prim
28 import GHC.Integer () -- Make sure Integer is compiled first
29 -- because GHC depends on it in a wired-in way
30 -- so the build system doesn't see the dependency
31 import {-# SOURCE #-} GHC.Exception( errorCallException )
32
33 -- | 'error' stops execution and displays an error message.
34 error :: [Char] -> a
35 error s = raise# (errorCallException s)
36
37 -- | A special case of 'error'.
38 -- It is expected that compilers will recognize this and insert error
39 -- messages which are more appropriate to the context in which 'undefined'
40 -- appears.
41 undefined :: a
42 undefined = error "Prelude.undefined"
43
44 -- | Used for compiler-generated error message;
45 -- encoding saves bytes of string junk.
46 absentErr :: a
47 absentErr = error "Oops! The program has entered an `absent' argument!\n"