Movatterモバイル変換


[0]ホーム

URL:


{-# LANGUAGE Trustworthy #-}{-# LANGUAGE NoImplicitPrelude, MagicHash, ImplicitParams #-}{-# LANGUAGE RankNTypes, PolyKinds, DataKinds #-}{-# OPTIONS_HADDOCK not-home #-}------------------------------------------------------------------------------- |-- 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.-------------------------------------------------------------------------------moduleGHC.Err(absentErr,error,errorWithoutStackTrace,undefined)whereimportGHC.Types(Char,RuntimeRep)importGHC.Stack.TypesimportGHC.PrimimportGHC.Integer()-- Make sure Integer and Natural are compiled firstimportGHC.Natural()-- because GHC depends on it in a wired-in way-- so the build system doesn't see the dependency.-- See Note [Depend on GHC.Integer] and-- Note [Depend on GHC.Natural] in GHC.Base.import{-# SOURCE#-}GHC.Exception(errorCallWithCallStackException,errorCallException)-- | 'error' stops execution and displays an error message.error::forall(r::RuntimeRep).forall(a::TYPEr).HasCallStack=>[Char]->aerror :: [Char] -> aerror[Char]s=SomeException -> aforall b a. b -> araise#([Char] -> CallStack -> SomeExceptionerrorCallWithCallStackException[Char]s?callStack::CallStackCallStack?callStack)-- Bleh, we should be using 'GHC.Stack.callStack' instead of-- '?callStack' here, but 'GHC.Stack.callStack' depends on-- 'GHC.Stack.popCallStack', which is partial and depends on-- 'error'.. Do as I say, not as I do.-- | A variant of 'error' that does not produce a stack trace.---- @since 4.9.0.0errorWithoutStackTrace::forall(r::RuntimeRep).forall(a::TYPEr).[Char]->aerrorWithoutStackTrace :: [Char] -> aerrorWithoutStackTrace[Char]s=SomeException -> aforall b a. b -> araise#([Char] -> SomeExceptionerrorCallException[Char]s)-- Note [Errors in base]-- ~~~~~~~~~~~~~~~~~~~~~-- As of base-4.9.0.0, `error` produces a stack trace alongside the-- error message using the HasCallStack machinery. This provides-- a partial stack trace, containing the call-site of each function-- with a HasCallStack constraint.---- In base, however, the only functions that have such constraints are-- error and undefined, so the stack traces from partial functions in-- base will never contain a call-site in user code. Instead we'll-- usually just get the actual call to error. Base functions already-- have a good habit of providing detailed error messages, including the-- name of the offending partial function, so the partial stack-trace-- does not provide any extra information, just noise. Thus, we export-- the callstack-aware error, but within base we use the-- errorWithoutStackTrace variant for more hygienic error messages.-- | 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::forall(r::RuntimeRep).forall(a::TYPEr).HasCallStack=>aundefined :: aundefined=[Char] -> aforall a. (?callStack::CallStack) => [Char] -> aerror[Char]"Prelude.undefined"-- | Used for compiler-generated error message;-- encoding saves bytes of string junk.absentErr::aabsentErr :: aabsentErr=[Char] -> aforall a. [Char] -> aerrorWithoutStackTrace[Char]"Oops! The program has entered an `absent' argument!\n"

[8]ページ先頭

©2009-2025 Movatter.jp