{-# LINE 1 "GHC/ExecutionStack/Internal.hsc" #-}
{-# LANGUAGE MultiWayIf #-}
module GHC.ExecutionStack.Internal (
Location (..)
, SrcLoc (..)
, StackTrace
, stackFrames
, stackDepth
, collectStackTrace
, showStackFrames
, invalidateDebugCache
) where
import Control.Monad (join)
import Data.Word
import Foreign.C.Types
import Foreign.C.String (peekCString, CString)
import Foreign.Ptr (Ptr, nullPtr, castPtr, plusPtr, FunPtr)
import Foreign.ForeignPtr
import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Storable (Storable(..))
import System.IO.Unsafe (unsafePerformIO, unsafeInterleaveIO)
data SrcLoc = SrcLoc { SrcLoc -> String
sourceFile :: String
, SrcLoc -> Int
sourceLine :: Int
, SrcLoc -> Int
sourceColumn :: Int
}
data Location = Location { Location -> String
objectName :: String
, Location -> String
functionName :: String
, Location -> Maybe SrcLoc
srcLoc :: Maybe SrcLoc
}
data Chunk = Chunk { Chunk -> Word
chunkFrames :: !Word
, Chunk -> Ptr Chunk
chunkNext :: !(Ptr Chunk)
, Chunk -> Ptr Addr
chunkFirstFrame :: !(Ptr Addr)
}
newtype StackTrace = StackTrace (ForeignPtr StackTrace)
type Addr = Ptr ()
withSession :: (ForeignPtr Session -> IO a) -> IO (Maybe a)
withSession :: (ForeignPtr Session -> IO a) -> IO (Maybe a)
withSession action :: ForeignPtr Session -> IO a
action = do
Ptr Session
ptr <- IO (Ptr Session)
libdw_pool_take
if | Ptr Session
forall a. Ptr a
nullPtr Ptr Session -> Ptr Session -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr Session
ptr -> Maybe a -> IO (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe a
forall a. Maybe a
Nothing
| Bool
otherwise -> do
ForeignPtr Session
fptr <- FinalizerPtr Session -> Ptr Session -> IO (ForeignPtr Session)
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FinalizerPtr Session
libdw_pool_release Ptr Session
ptr
a
ret <- ForeignPtr Session -> IO a
action ForeignPtr Session
fptr
Maybe a -> IO (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe a -> IO (Maybe a)) -> Maybe a -> IO (Maybe a)
forall a b. (a -> b) -> a -> b
$ a -> Maybe a
forall a. a -> Maybe a
Just a
ret
stackDepth :: StackTrace -> Int
stackDepth :: StackTrace -> Int
stackDepth (StackTrace fptr :: ForeignPtr StackTrace
fptr) =
IO Int -> Int
forall a. IO a -> a
unsafePerformIO (IO Int -> Int) -> IO Int -> Int
forall a b. (a -> b) -> a -> b
$ ForeignPtr StackTrace -> (Ptr StackTrace -> IO Int) -> IO Int
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr StackTrace
fptr ((Ptr StackTrace -> IO Int) -> IO Int)
-> (Ptr StackTrace -> IO Int) -> IO Int
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr StackTrace
ptr ->
Word -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word -> Int) -> (Word -> Word) -> Word -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> Word
asWord (Word -> Int) -> IO Word -> IO Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((\hsc_ptr :: Ptr StackTrace
hsc_ptr -> Ptr StackTrace -> Int -> IO Word
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr StackTrace
hsc_ptr 0)) Ptr StackTrace
ptr
{-# LINE 84 "GHC/ExecutionStack/Internal.hsc" #-}
where
asWord :: Word -> Word
asWord = Word -> Word
forall a. a -> a
id :: Word -> Word
peekChunk :: Ptr Chunk -> IO Chunk
peekChunk :: Ptr Chunk -> IO Chunk
peekChunk ptr :: Ptr Chunk
ptr =
Word -> Ptr Chunk -> Ptr Addr -> Chunk
Chunk (Word -> Ptr Chunk -> Ptr Addr -> Chunk)
-> IO Word -> IO (Ptr Chunk -> Ptr Addr -> Chunk)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((\hsc_ptr :: Ptr Chunk
hsc_ptr -> Ptr Chunk -> Int -> IO Word
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr Chunk
hsc_ptr 0)) Ptr Chunk
ptr
{-# LINE 90 "GHC/ExecutionStack/Internal.hsc" #-}
IO (Ptr Chunk -> Ptr Addr -> Chunk)
-> IO (Ptr Chunk) -> IO (Ptr Addr -> Chunk)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((\hsc_ptr :: Ptr Chunk
hsc_ptr -> Ptr Chunk -> Int -> IO (Ptr Chunk)
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr Chunk
hsc_ptr 8)) Ptr Chunk
ptr
{-# LINE 91 "GHC/ExecutionStack/Internal.hsc" #-}
IO (Ptr Addr -> Chunk) -> IO (Ptr Addr) -> IO Chunk
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ptr Addr -> IO (Ptr Addr)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr Any -> Ptr Addr
forall a b. Ptr a -> Ptr b
castPtr (Ptr Any -> Ptr Addr) -> Ptr Any -> Ptr Addr
forall a b. (a -> b) -> a -> b
$ ((\hsc_ptr :: Ptr Chunk
hsc_ptr -> Ptr Chunk
hsc_ptr Ptr Chunk -> Int -> Ptr Any
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16)) Ptr Chunk
ptr)
{-# LINE 92 "GHC/ExecutionStack/Internal.hsc" #-}
chunksList :: StackTrace -> IO [Chunk]
chunksList :: StackTrace -> IO [Chunk]
chunksList (StackTrace fptr :: ForeignPtr StackTrace
fptr) = ForeignPtr StackTrace
-> (Ptr StackTrace -> IO [Chunk]) -> IO [Chunk]
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr StackTrace
fptr ((Ptr StackTrace -> IO [Chunk]) -> IO [Chunk])
-> (Ptr StackTrace -> IO [Chunk]) -> IO [Chunk]
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr StackTrace
ptr ->
[Chunk] -> Ptr Chunk -> IO [Chunk]
go [] (Ptr Chunk -> IO [Chunk]) -> IO (Ptr Chunk) -> IO [Chunk]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ((\hsc_ptr :: Ptr StackTrace
hsc_ptr -> Ptr StackTrace -> Int -> IO (Ptr Chunk)
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr StackTrace
hsc_ptr 8)) Ptr StackTrace
ptr
{-# LINE 98 "GHC/ExecutionStack/Internal.hsc" #-}
where
go :: [Chunk] -> Ptr Chunk -> IO [Chunk]
go accum :: [Chunk]
accum ptr :: Ptr Chunk
ptr
| Ptr Chunk
ptr Ptr Chunk -> Ptr Chunk -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr Chunk
forall a. Ptr a
nullPtr = [Chunk] -> IO [Chunk]
forall (m :: * -> *) a. Monad m => a -> m a
return [Chunk]
accum
| Bool
otherwise = do
Chunk
chunk <- Ptr Chunk -> IO Chunk
peekChunk Ptr Chunk
ptr
[Chunk] -> Ptr Chunk -> IO [Chunk]
go (Chunk
chunk Chunk -> [Chunk] -> [Chunk]
forall a. a -> [a] -> [a]
: [Chunk]
accum) (Chunk -> Ptr Chunk
chunkNext Chunk
chunk)
peekLocation :: Ptr Location -> IO Location
peekLocation :: Ptr Location -> IO Location
peekLocation ptr :: Ptr Location
ptr = do
let peekCStringPtr :: CString -> IO String
peekCStringPtr :: CString -> IO String
peekCStringPtr p :: CString
p
| CString
p CString -> CString -> Bool
forall a. Eq a => a -> a -> Bool
/= CString
forall a. Ptr a
nullPtr = CString -> IO String
peekCString (CString -> IO String) -> CString -> IO String
forall a b. (a -> b) -> a -> b
$ CString -> CString
forall a b. Ptr a -> Ptr b
castPtr CString
p
| Bool
otherwise = String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return ""
String
objFile <- CString -> IO String
peekCStringPtr (CString -> IO String) -> IO CString -> IO String
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ((\hsc_ptr :: Ptr Location
hsc_ptr -> Ptr Location -> Int -> IO CString
forall a b. Storable a => Ptr b -> Int -> IO a
peekByteOff Ptr Location
hsc_ptr 0)) Ptr Location
ptr
{-# LINE 113 "GHC/ExecutionStack/Internal.hsc" #-}
function <- peekCStringPtr =<< ((\hsc_ptr -> peekByteOff hsc_ptr 8)) ptr
{-# LINE 114 "GHC/ExecutionStack/Internal.hsc" #-}
srcFile <- peekCStringPtr =<< ((\hsc_ptr -> peekByteOff hsc_ptr 16)) ptr
{-# LINE 115 "GHC/ExecutionStack/Internal.hsc" #-}
lineNo <- ((\hsc_ptr -> peekByteOff hsc_ptr 24)) ptr :: IO Word32
{-# LINE 116 "GHC/ExecutionStack/Internal.hsc" #-}
colNo <- ((\hsc_ptr -> peekByteOff hsc_ptr 28)) ptr :: IO Word32
{-# LINE 117 "GHC/ExecutionStack/Internal.hsc" #-}
let _srcLoc
| null srcFile = Nothing
| otherwise = Just $ SrcLoc { sourceFile = srcFile
, sourceLine = fromIntegral lineNo
, sourceColumn = fromIntegral colNo
}
Location -> IO Location
forall (m :: * -> *) a. Monad m => a -> m a
return Location :: String -> String -> Maybe SrcLoc -> Location
Location { objectName :: String
objectName = String
objFile
, functionName :: String
functionName = String
function
, srcLoc :: Maybe SrcLoc
srcLoc = Maybe SrcLoc
_srcLoc
}
locationSize :: Int
locationSize :: Int
locationSize = (32)
{-# LINE 131 "GHC/ExecutionStack/Internal.hsc" #-}
stackFrames :: StackTrace -> Maybe [Location]
stackFrames :: StackTrace -> Maybe [Location]
stackFrames st :: StackTrace
st@(StackTrace fptr :: ForeignPtr StackTrace
fptr) = IO (Maybe [Location]) -> Maybe [Location]
forall a. IO a -> a
unsafePerformIO (IO (Maybe [Location]) -> Maybe [Location])
-> IO (Maybe [Location]) -> Maybe [Location]
forall a b. (a -> b) -> a -> b
$ (ForeignPtr Session -> IO [Location]) -> IO (Maybe [Location])
forall a. (ForeignPtr Session -> IO a) -> IO (Maybe a)
withSession ((ForeignPtr Session -> IO [Location]) -> IO (Maybe [Location]))
-> (ForeignPtr Session -> IO [Location]) -> IO (Maybe [Location])
forall a b. (a -> b) -> a -> b
$ \sess :: ForeignPtr Session
sess -> do
[Chunk]
chunks <- StackTrace -> IO [Chunk]
chunksList StackTrace
st
ForeignPtr Session -> [Chunk] -> IO [Location]
go ForeignPtr Session
sess ([Chunk] -> [Chunk]
forall a. [a] -> [a]
reverse [Chunk]
chunks)
where
go :: ForeignPtr Session -> [Chunk] -> IO [Location]
go :: ForeignPtr Session -> [Chunk] -> IO [Location]
go _ [] = [Location] -> IO [Location]
forall (m :: * -> *) a. Monad m => a -> m a
return []
go sess :: ForeignPtr Session
sess (chunk :: Chunk
chunk : chunks :: [Chunk]
chunks) = do
[Location]
this <- ForeignPtr Session -> Chunk -> IO [Location]
iterChunk ForeignPtr Session
sess Chunk
chunk
[Location]
rest <- IO [Location] -> IO [Location]
forall a. IO a -> IO a
unsafeInterleaveIO (ForeignPtr Session -> [Chunk] -> IO [Location]
go ForeignPtr Session
sess [Chunk]
chunks)
[Location] -> IO [Location]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Location]
this [Location] -> [Location] -> [Location]
forall a. [a] -> [a] -> [a]
++ [Location]
rest)
iterChunk :: ForeignPtr Session -> Chunk -> IO [Location]
iterChunk :: ForeignPtr Session -> Chunk -> IO [Location]
iterChunk sess :: ForeignPtr Session
sess chunk :: Chunk
chunk = Word -> Ptr Addr -> IO [Location]
iterFrames (Chunk -> Word
chunkFrames Chunk
chunk) (Chunk -> Ptr Addr
chunkFirstFrame Chunk
chunk)
where
iterFrames :: Word -> Ptr Addr -> IO [Location]
iterFrames :: Word -> Ptr Addr -> IO [Location]
iterFrames 0 _ = [Location] -> IO [Location]
forall (m :: * -> *) a. Monad m => a -> m a
return []
iterFrames n :: Word
n frame :: Ptr Addr
frame = do
Addr
pc <- Ptr Addr -> IO Addr
forall a. Storable a => Ptr a -> IO a
peek Ptr Addr
frame :: IO Addr
Maybe Location
mframe <- Addr -> IO (Maybe Location)
lookupFrame Addr
pc
[Location]
rest <- IO [Location] -> IO [Location]
forall a. IO a -> IO a
unsafeInterleaveIO (Word -> Ptr Addr -> IO [Location]
iterFrames (Word
nWord -> Word -> Word
forall a. Num a => a -> a -> a
-1) Ptr Addr
forall a. Ptr a
frame')
[Location] -> IO [Location]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Location] -> IO [Location]) -> [Location] -> IO [Location]
forall a b. (a -> b) -> a -> b
$ [Location]
-> (Location -> [Location]) -> Maybe Location -> [Location]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [Location]
rest (Location -> [Location] -> [Location]
forall a. a -> [a] -> [a]
:[Location]
rest) Maybe Location
mframe
where
frame' :: Ptr b
frame' = Ptr Addr
frame Ptr Addr -> Int -> Ptr b
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Addr -> Int
forall a. Storable a => a -> Int
sizeOf (Addr
forall a. HasCallStack => a
undefined :: Addr)
lookupFrame :: Addr -> IO (Maybe Location)
lookupFrame :: Addr -> IO (Maybe Location)
lookupFrame pc :: Addr
pc = ForeignPtr StackTrace
-> (Ptr StackTrace -> IO (Maybe Location)) -> IO (Maybe Location)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr StackTrace
fptr ((Ptr StackTrace -> IO (Maybe Location)) -> IO (Maybe Location))
-> (Ptr StackTrace -> IO (Maybe Location)) -> IO (Maybe Location)
forall a b. (a -> b) -> a -> b
$ IO (Maybe Location) -> Ptr StackTrace -> IO (Maybe Location)
forall a b. a -> b -> a
const (IO (Maybe Location) -> Ptr StackTrace -> IO (Maybe Location))
-> IO (Maybe Location) -> Ptr StackTrace -> IO (Maybe Location)
forall a b. (a -> b) -> a -> b
$ do
Int -> (Ptr Location -> IO (Maybe Location)) -> IO (Maybe Location)
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
locationSize ((Ptr Location -> IO (Maybe Location)) -> IO (Maybe Location))
-> (Ptr Location -> IO (Maybe Location)) -> IO (Maybe Location)
forall a b. (a -> b) -> a -> b
$ \buf :: Ptr Location
buf -> do
CInt
ret <- ForeignPtr Session -> (Ptr Session -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Session
sess ((Ptr Session -> IO CInt) -> IO CInt)
-> (Ptr Session -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \sessPtr :: Ptr Session
sessPtr -> Ptr Session -> Ptr Location -> Addr -> IO CInt
libdw_lookup_location Ptr Session
sessPtr Ptr Location
buf Addr
pc
case CInt
ret of
0 -> Location -> Maybe Location
forall a. a -> Maybe a
Just (Location -> Maybe Location) -> IO Location -> IO (Maybe Location)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Location -> IO Location
peekLocation Ptr Location
buf
_ -> Maybe Location -> IO (Maybe Location)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Location
forall a. Maybe a
Nothing
data Session
foreign import ccall unsafe "libdwPoolTake"
libdw_pool_take :: IO (Ptr Session)
foreign import ccall unsafe "&libdwPoolRelease"
libdw_pool_release :: FunPtr (Ptr Session -> IO ())
foreign import ccall unsafe "libdwPoolClear"
libdw_pool_clear :: IO ()
foreign import ccall unsafe "libdwLookupLocation"
libdw_lookup_location :: Ptr Session -> Ptr Location -> Addr -> IO CInt
foreign import ccall unsafe "libdwGetBacktrace"
libdw_get_backtrace :: Ptr Session -> IO (Ptr StackTrace)
foreign import ccall unsafe "&backtraceFree"
backtrace_free :: FunPtr (Ptr StackTrace -> IO ())
collectStackTrace :: IO (Maybe StackTrace)
collectStackTrace :: IO (Maybe StackTrace)
collectStackTrace = (Maybe (Maybe StackTrace) -> Maybe StackTrace)
-> IO (Maybe (Maybe StackTrace)) -> IO (Maybe StackTrace)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Maybe (Maybe StackTrace) -> Maybe StackTrace
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (IO (Maybe (Maybe StackTrace)) -> IO (Maybe StackTrace))
-> IO (Maybe (Maybe StackTrace)) -> IO (Maybe StackTrace)
forall a b. (a -> b) -> a -> b
$ (ForeignPtr Session -> IO (Maybe StackTrace))
-> IO (Maybe (Maybe StackTrace))
forall a. (ForeignPtr Session -> IO a) -> IO (Maybe a)
withSession ((ForeignPtr Session -> IO (Maybe StackTrace))
-> IO (Maybe (Maybe StackTrace)))
-> (ForeignPtr Session -> IO (Maybe StackTrace))
-> IO (Maybe (Maybe StackTrace))
forall a b. (a -> b) -> a -> b
$ \sess :: ForeignPtr Session
sess -> do
Ptr StackTrace
st <- ForeignPtr Session
-> (Ptr Session -> IO (Ptr StackTrace)) -> IO (Ptr StackTrace)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Session
sess Ptr Session -> IO (Ptr StackTrace)
libdw_get_backtrace
if | Ptr StackTrace
st Ptr StackTrace -> Ptr StackTrace -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr StackTrace
forall a. Ptr a
nullPtr -> Maybe StackTrace -> IO (Maybe StackTrace)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe StackTrace
forall a. Maybe a
Nothing
| Bool
otherwise -> StackTrace -> Maybe StackTrace
forall a. a -> Maybe a
Just (StackTrace -> Maybe StackTrace)
-> (ForeignPtr StackTrace -> StackTrace)
-> ForeignPtr StackTrace
-> Maybe StackTrace
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ForeignPtr StackTrace -> StackTrace
StackTrace (ForeignPtr StackTrace -> Maybe StackTrace)
-> IO (ForeignPtr StackTrace) -> IO (Maybe StackTrace)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FinalizerPtr StackTrace
-> Ptr StackTrace -> IO (ForeignPtr StackTrace)
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FinalizerPtr StackTrace
backtrace_free Ptr StackTrace
st
invalidateDebugCache :: IO ()
invalidateDebugCache :: IO ()
invalidateDebugCache = IO ()
libdw_pool_clear
showStackFrames :: [Location] -> ShowS
showStackFrames :: [Location] -> ShowS
showStackFrames frames :: [Location]
frames =
String -> ShowS
showString "Stack trace:\n"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ShowS -> ShowS -> ShowS) -> ShowS -> [ShowS] -> ShowS
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) ShowS
forall a. a -> a
id ((Location -> ShowS) -> [Location] -> [ShowS]
forall a b. (a -> b) -> [a] -> [b]
map Location -> ShowS
showFrame [Location]
frames)
where
showFrame :: Location -> ShowS
showFrame loc :: Location
loc =
String -> ShowS
showString " " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Location -> ShowS
showLocation Location
loc ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar '\n'
showLocation :: Location -> ShowS
showLocation :: Location -> ShowS
showLocation loc :: Location
loc =
String -> ShowS
showString (Location -> String
functionName Location
loc)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS -> (SrcLoc -> ShowS) -> Maybe SrcLoc -> ShowS
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ShowS
forall a. a -> a
id SrcLoc -> ShowS
showSrcLoc (Location -> Maybe SrcLoc
srcLoc Location
loc)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString " in "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString (Location -> String
objectName Location
loc)
where
showSrcLoc :: SrcLoc -> ShowS
showSrcLoc :: SrcLoc -> ShowS
showSrcLoc sloc :: SrcLoc
sloc =
String -> ShowS
showString " ("
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString (SrcLoc -> String
sourceFile SrcLoc
sloc)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString ":"
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShowS
forall a. Show a => a -> ShowS
shows (SrcLoc -> Int
sourceLine SrcLoc
sloc)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString "."
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> ShowS
forall a. Show a => a -> ShowS
shows (SrcLoc -> Int
sourceColumn SrcLoc
sloc)
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString ")"