Skip to content

Make HasCallStack include the caller

See also: #24709

Summary

If I do putStrLn $ prettyCallStack pretty I get something like

CallStack (from HasCallStack):
  dtraceIO, called at SourceFileModule.hs:34:5 in my-package:SourceFileModule

So I get the location of caller, but I don't get the name of the caller. If caller has HasCallStack, then I get its name but also where it's called from:

CallStack (from HasCallStack):
  dtraceIO, called at SourceFileModule.hs:34:5 in my-package:SourceFileModule
  caller, called at OtherModule.hs:34:5 in my-package:OtherModule

but it's not always desirable to add HasCallStack to caller (e.g. it may be recursive). However, the caller name is static.

Could we have the name of the caller be included in the CallStacks, so we could get

CallStack (from HasCallStack):
  dtraceIO, called at SourceFileModule.hs:34:5 in my-package:SourceFileModule
  caller

or as some may suggest that current CallStack is off by one, and instead we should have

CallStack (from HasCallStack at dtraceIO):
  caller at SourceFileModule.hs:34:5 in my-package:SourceFileModule
Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information