
On Mon, Mar 7, 2016 at 11:46 AM, Eric Seidel
The reason we provide the name of the callee is that the standard format for a stack trace is callee+pos :)
I guess it depends how you look at it. I'm used to caller + pos, e.g. in Java: java.lang.RuntimeException: blah blah at com...Caller.caller(Caller.java:494) at ... Or python: Traceback (most recent call last): File "t.py", line 2, in caller def caller(): callee() File "t.py", line 1, in callee def callee(): 1/0 ZeroDivisionError: integer division or modulo by zero The haskell version (reversed to match python) would be like: File "Caller.hs", line 6, in callee caller = callee 10 File "Caller.hs", line 9, in ?stack callee _n = mapM_ print (Stack.getCallStack ?stack) To me this seems off by one, line 6 is in 'caller', not 'callee'.
You point about wanting the caller's name too is well-taken though. In most languages you can just look at the next item in the stack to grab the caller, but with HasCallStack there may be no next item... I doubt it would be hard to add the caller's name too, I'd be happy to look into it post-ICFP. Would you mind filing a ticket?
Done: https://ghc.haskell.org/trac/ghc/ticket/11686 In it I suggested adding a Stack.getFrames :: [Stack.Frame], Frame could then have callee and srcloc fields as per getCallStack's pairs, and add a caller field. Just a suggestion. Thanks so much!