\begin{code}{-# OPTIONS_GHC -XNoImplicitPrelude #-}{-# OPTIONS_HADDOCK hide #-}------------------------------------------------------------------------------- |-- 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.-- ------------------------------------------------------------------------------- #hidemoduleGHC.Err(absentErr-- :: a,divZeroError-- :: a,overflowError-- :: a,error-- :: String -> a,undefined-- :: a)where#ifndef __HADDOCK__importGHC.TypesimportGHC.Exception#endif\end{code}%*********************************************************%**\subsection{Error-ishfunctions}%**%*********************************************************\begin{code}-- | 'error' stops execution and displays an error message.error::[Char]->aerrors=throw(ErrorCalls)-- | 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'-- appears. undefined::aundefined=error"Prelude.undefined"\end{code}%*********************************************************%**\subsection{Compilergeneratederrors+localutils}%**%*********************************************************Usedforcompiler-generatederrormessage;encodingsavesbytesofstringjunk.\begin{code}absentErr::aabsentErr=error"Oops! The program has entered an `absent' argument!\n"\end{code}Dividebyzeroandarithmeticoverflow.WeputthemherebecausetheyareneededrelativelyearlyinthelibrariesbeforetheExceptiontypehasbeendefinedyet.\begin{code}{-# NOINLINE divZeroError #-}divZeroError::adivZeroError=throwDivideByZero{-# NOINLINE overflowError #-}overflowError::aoverflowError=throwOverflow\end{code}