Movatterモバイル変換


[0]ホーム

URL:


{-# LANGUAGE Trustworthy #-}{-# LANGUAGE NoImplicitPrelude           , ExistentialQuantification           , MagicHash           , RecordWildCards           , PatternSynonyms  #-}{-# LANGUAGE TypeInType #-}{-# OPTIONS_HADDOCK not-home #-}------------------------------------------------------------------------------- |-- Module      :  GHC.Exception-- Copyright   :  (c) The University of Glasgow, 1998-2002-- License     :  see libraries/base/LICENSE---- Maintainer  :  cvs-ghc@haskell.org-- Stability   :  internal-- Portability :  non-portable (GHC extensions)---- Exceptions and exception-handling functions.-------------------------------------------------------------------------------moduleGHC.Exception(moduleGHC.Exception.Type,throw,ErrorCall(..,ErrorCall),errorCallException,errorCallWithCallStackException-- re-export CallStack and SrcLoc from GHC.Types,CallStack,fromCallSiteList,getCallStack,prettyCallStack,prettyCallStackLines,showCCSStack,SrcLoc(..),prettySrcLoc)whereimportGHC.BaseimportGHC.ShowimportGHC.Stack.TypesimportGHC.OldListimportGHC.PrimimportGHC.IO.Unsafeimport{-# SOURCE#-}GHC.Stack.CCSimportGHC.Exception.Type-- | Throw an exception.  Exceptions may be thrown from purely-- functional code, but may only be caught within the 'IO' monad.throw::forall(r::RuntimeRep).forall(a::TYPEr).foralle.Exceptione=>e->athrow :: e -> athrowee=SomeException -> aforall b a. b -> araise#(e -> SomeExceptionforall e. Exception e => e -> SomeExceptiontoExceptionee)-- | This is thrown when the user calls 'error'. The first @String@ is the-- argument given to 'error', second @String@ is the location.dataErrorCall=ErrorCallWithLocationStringStringderiving(Eq-- ^ @since 4.7.0.0,Ord-- ^ @since 4.7.0.0)patternErrorCall::String->ErrorCallpattern$bErrorCall :: String -> ErrorCall$mErrorCall :: forall r. ErrorCall -> (String -> r) -> (Void# -> r) -> rErrorCallerr<-ErrorCallWithLocationerr_whereErrorCallStringerr=String -> String -> ErrorCallErrorCallWithLocationStringerrString""{-# COMPLETEErrorCall#-}-- | @since 4.0.0.0instanceExceptionErrorCall-- | @since 4.0.0.0instanceShowErrorCallwhereshowsPrec :: Int -> ErrorCall -> ShowSshowsPrecInt_(ErrorCallWithLocationStringerrString"")=String -> ShowSshowStringStringerrshowsPrecInt_(ErrorCallWithLocationStringerrStringloc)=String -> ShowSshowStringStringerrShowS -> ShowS -> ShowSforall b c a. (b -> c) -> (a -> b) -> a -> c.Char -> ShowSshowCharChar'\n'ShowS -> ShowS -> ShowSforall b c a. (b -> c) -> (a -> b) -> a -> c.String -> ShowSshowStringStringlocerrorCallException::String->SomeExceptionerrorCallException :: String -> SomeExceptionerrorCallExceptionStrings=ErrorCall -> SomeExceptionforall e. Exception e => e -> SomeExceptiontoException(String -> ErrorCallErrorCallStrings)errorCallWithCallStackException::String->CallStack->SomeExceptionerrorCallWithCallStackException :: String -> CallStack -> SomeExceptionerrorCallWithCallStackExceptionStringsCallStackstk=IO SomeException -> SomeExceptionforall a. IO a -> aunsafeDupablePerformIO(IO SomeException -> SomeException)-> IO SomeException -> SomeExceptionforall a b. (a -> b) -> a -> b$do[String]ccsStack<-IO [String]currentCallStackletimplicitParamCallStack :: [String]implicitParamCallStack=CallStack -> [String]prettyCallStackLinesCallStackstkccsCallStack :: [String]ccsCallStack=[String] -> [String]showCCSStack[String]ccsStackstack :: Stringstack=String -> [String] -> Stringforall a. [a] -> [[a]] -> [a]intercalateString"\n"([String] -> String) -> [String] -> Stringforall a b. (a -> b) -> a -> b$[String]implicitParamCallStack[String] -> [String] -> [String]forall a. [a] -> [a] -> [a]++[String]ccsCallStackSomeException -> IO SomeExceptionforall (m :: * -> *) a. Monad m => a -> m areturn(SomeException -> IO SomeException)-> SomeException -> IO SomeExceptionforall a b. (a -> b) -> a -> b$ErrorCall -> SomeExceptionforall e. Exception e => e -> SomeExceptiontoException(String -> String -> ErrorCallErrorCallWithLocationStringsStringstack)showCCSStack::[String]->[String]showCCSStack :: [String] -> [String]showCCSStack[]=[]showCCSStack[String]stk=String"CallStack (from -prof):"String -> [String] -> [String]forall a. a -> [a] -> [a]:ShowS -> [String] -> [String]forall a b. (a -> b) -> [a] -> [b]map(String"  "String -> ShowSforall a. [a] -> [a] -> [a]++)([String] -> [String]forall a. [a] -> [a]reverse[String]stk)-- prettySrcLoc and prettyCallStack are defined here to avoid hs-boot-- files. See Note [Definition of CallStack]-- | Pretty print a 'SrcLoc'.---- @since 4.9.0.0prettySrcLoc::SrcLoc->StringprettySrcLoc :: SrcLoc -> StringprettySrcLocSrcLoc{IntStringsrcLocEndCol :: SrcLoc -> IntsrcLocEndLine :: SrcLoc -> IntsrcLocStartCol :: SrcLoc -> IntsrcLocStartLine :: SrcLoc -> IntsrcLocFile :: SrcLoc -> StringsrcLocModule :: SrcLoc -> StringsrcLocPackage :: SrcLoc -> StringsrcLocEndCol :: IntsrcLocEndLine :: IntsrcLocStartCol :: IntsrcLocStartLine :: IntsrcLocFile :: StringsrcLocModule :: StringsrcLocPackage :: String..}=(String -> ShowS) -> String -> [String] -> Stringforall a b. (a -> b -> b) -> b -> [a] -> bfoldrString -> ShowSforall a. [a] -> [a] -> [a](++)String""[StringsrcLocFile,String":",Int -> Stringforall a. Show a => a -> StringshowIntsrcLocStartLine,String":",Int -> Stringforall a. Show a => a -> StringshowIntsrcLocStartCol,String" in ",StringsrcLocPackage,String":",StringsrcLocModule]-- | Pretty print a 'CallStack'.---- @since 4.9.0.0prettyCallStack::CallStack->StringprettyCallStack :: CallStack -> StringprettyCallStack=String -> [String] -> Stringforall a. [a] -> [[a]] -> [a]intercalateString"\n"([String] -> String)-> (CallStack -> [String]) -> CallStack -> Stringforall b c a. (b -> c) -> (a -> b) -> a -> c.CallStack -> [String]prettyCallStackLinesprettyCallStackLines::CallStack->[String]prettyCallStackLines :: CallStack -> [String]prettyCallStackLinesCallStackcs=caseCallStack -> [(String, SrcLoc)]getCallStackCallStackcsof[]->[][(String, SrcLoc)]stk->String"CallStack (from HasCallStack):"String -> [String] -> [String]forall a. a -> [a] -> [a]:((String, SrcLoc) -> String) -> [(String, SrcLoc)] -> [String]forall a b. (a -> b) -> [a] -> [b]map((String"  "String -> ShowSforall a. [a] -> [a] -> [a]++)ShowS -> ((String, SrcLoc) -> String) -> (String, SrcLoc) -> Stringforall b c a. (b -> c) -> (a -> b) -> a -> c.(String, SrcLoc) -> StringprettyCallSite)[(String, SrcLoc)]stkwhereprettyCallSite :: (String, SrcLoc) -> StringprettyCallSite(Stringf,SrcLocloc)=StringfString -> ShowSforall a. [a] -> [a] -> [a]++String", called at "String -> ShowSforall a. [a] -> [a] -> [a]++SrcLoc -> StringprettySrcLocSrcLocloc

[8]ページ先頭

©2009-2025 Movatter.jp