2 % (c) The AQUA Project, Glasgow University, 1994-1996
5 \section[GHCerr]{Module @GHCerr@}
7 The GHCerr module defines the code for the wired-in error functions,
8 which have a special type in the compiler (with "open tyvars").
10 We cannot define these functions in a module where they might be used
11 (e.g., GHCbase), because the magical wired-in type will get confused
12 with what the typechecker figures out.
15 {-# OPTIONS -fno-implicit-prelude #-}
20 import PrelList ( span )
23 ---------------------------------------------------------------
24 -- HACK: Magic unfoldings not implemented for unboxed lists
25 -- Need to define a "build" to avoid undefined symbol
26 -- in this module to avoid .hi proliferation.
28 build = error "GHCbase.build"
29 augment = error "GHCbase.augment"
30 --{-# GENERATE_SPECS build a #-}
31 --build :: ((a -> [a] -> [a]) -> [a] -> [a]) -> [a]
36 Used for compiler-generated error message;
37 encoding saves bytes of string junk.
40 absentErr, parError :: a
42 absentErr = error "Oops! The program has entered an `absent' argument!\n"
43 parError = error "Oops! Entered GHCerr.parError (a GHC bug -- please report it!)\n"
48 , noDefaultMethodError
49 , noExplicitMethodError
50 , nonExhaustiveGuardsError
53 , recUpdError :: String -> a
55 noDefaultMethodError s = error ("noDefaultMethodError:"++s)
56 noExplicitMethodError s = error ("No default method for class operation "++s)
57 irrefutPatError s = error (untangle s "Irrefutable pattern failed for pattern")
58 nonExhaustiveGuardsError s = error (untangle s "Non-exhaustive guards in")
59 patError s = error (untangle s "Non-exhaustive patterns in")
60 recConError s = error (untangle s "Missing field in record construction:")
61 recUpdError s = error (untangle s "Record to doesn't contain field(s) to be updated")
65 (untangle coded message) expects "coded" to be of the form
71 location message details
74 untangle coded message
82 = case (span not_bar coded) of { (location, rest) ->
84 ('|':details) -> (location, ' ' : details)
90 -- This local variant of "error" calls PatErrorHdrHook instead of ErrorHdrHook,
91 -- but the former does exactly the same as the latter, so I nuked it.
93 -- patError__ = error__ (\ x -> _ccall_ PatErrorHdrHook x)