[GHC] #11686: implicit call stacks should provide a way to get the calling function's name
GHC
ghc-devs at haskell.org
Mon Mar 7 23:18:42 UTC 2016
#11686: implicit call stacks should provide a way to get the calling function's
name
-------------------------------------+-------------------------------------
Reporter: elaforge | Owner:
Type: feature | Status: new
request |
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
With implicit call stacks we can get the calling SrcPos and the called
function's name, but not the caller function's name. E.g.:
{{{#!hs
{-# LANGUAGE ImplicitParams, ConstraintKinds #-}
import qualified GHC.Stack as Stack
caller :: IO ()
caller = callee 10
where
callee :: (?stack :: Stack.CallStack) => Int -> IO ()
callee _n = mapM_ print (Stack.getCallStack ?stack)
}}}
Gives
{{{
("?stack",SrcLoc {srcLocPackage = "main", srcLocModule = "Main",
srcLocFile = "T.hs", srcLocStartLine = 9, srcLocStartCol = 36,
srcLocEndLine = 9, srcLocEndCol = 42})
("callee",SrcLoc {srcLocPackage = "main", srcLocModule = "Main",
srcLocFile = "T.hs", srcLocStartLine = 6, srcLocStartCol = 23,
srcLocEndLine = 6, srcLocEndCol = 29})
}}}
It would be nice to get the name "caller" as well. It's too bad
getCallStack returns pairs instead of an abstract type like Frame.
Perhaps a separate Stack.getFrames could do that while getCallStack
continues to return pairs for compatibility.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11686>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list