Revert "Generate Typeable info at definition sites"
[ghc.git] / libraries / base / GHC / Stack / Types.hs
1 {-# LANGUAGE NoImplicitPrelude #-}
2
3 -----------------------------------------------------------------------------
4 -- |
5 -- Module : GHC.Stack.Types
6 -- Copyright : (c) The University of Glasgow 2015
7 -- License : see libraries/ghc-prim/LICENSE
8 --
9 -- Maintainer : cvs-ghc@haskell.org
10 -- Stability : internal
11 -- Portability : non-portable (GHC Extensions)
12 --
13 -- type definitions for call-stacks via implicit parameters.
14 -- Use GHC.Exts from the base package instead of importing this
15 -- module directly.
16 --
17 -----------------------------------------------------------------------------
18
19 module GHC.Stack.Types (
20 -- * Implicit parameter call stacks
21 SrcLoc(..), CallStack(..),
22 ) where
23
24 import GHC.Types
25
26 -- Make implicit dependency known to build system
27 import GHC.Tuple ()
28 import GHC.Integer ()
29
30 ----------------------------------------------------------------------
31 -- Explicit call-stacks built via ImplicitParams
32 ----------------------------------------------------------------------
33
34 -- | @CallStack@s are an alternate method of obtaining the call stack at a given
35 -- point in the program.
36 --
37 -- When an implicit-parameter of type @CallStack@ occurs in a program, GHC will
38 -- solve it with the current location. If another @CallStack@ implicit-parameter
39 -- is in-scope (e.g. as a function argument), the new location will be appended
40 -- to the one in-scope, creating an explicit call-stack. For example,
41 --
42 -- @
43 -- myerror :: (?loc :: CallStack) => String -> a
44 -- myerror msg = error (msg ++ "\n" ++ showCallStack ?loc)
45 -- @
46 -- ghci> myerror "die"
47 -- *** Exception: die
48 -- CallStack:
49 -- ?loc, called at MyError.hs:7:51 in main:MyError
50 -- myerror, called at <interactive>:2:1 in interactive:Ghci1
51 --
52 -- @CallStack@s do not interact with the RTS and do not require compilation with
53 -- @-prof@. On the other hand, as they are built up explicitly using
54 -- implicit-parameters, they will generally not contain as much information as
55 -- the simulated call-stacks maintained by the RTS.
56 --
57 -- A @CallStack@ is a @[(String, SrcLoc)]@. The @String@ is the name of
58 -- function that was called, the 'SrcLoc' is the call-site. The list is
59 -- ordered with the most recently called function at the head.
60 --
61 -- @since 4.8.2.0
62 data CallStack = CallStack { getCallStack :: [([Char], SrcLoc)] }
63 -- See Note [Overview of implicit CallStacks]
64
65 -- | A single location in the source code.
66 --
67 -- @since 4.8.2.0
68 data SrcLoc = SrcLoc
69 { srcLocPackage :: [Char]
70 , srcLocModule :: [Char]
71 , srcLocFile :: [Char]
72 , srcLocStartLine :: Int
73 , srcLocStartCol :: Int
74 , srcLocEndLine :: Int
75 , srcLocEndCol :: Int
76 }