How do I use CallStack?
niteria at gmail.com
Mon Dec 7 10:45:25 UTC 2015
If you're debugging GHC, I've recently added pprSTrace :: (?location ::
CallStack) => SDoc -> a -> a in Outputable. It's been a great help for me
in understanding where the calls were coming from. You can just use it
without importing anything extra, and when you want more context you just
add (?location :: CallStack) => to the function you're debugging, plus
necessary imports (GHC.Stack) and extensions (ImplicitParams). I think it
improved my workflow by an order of magnitude.
2015-12-07 6:39 GMT+00:00 Eric Seidel <eric at seidel.io>:
> Hi Richard,
> Sorry for all of the confusion, it seems the docs do indeed need some
> On Sun, Dec 6, 2015, at 20:56, Richard Eisenberg wrote:
> > That looks like exactly what I want. Thanks.
> > There remain two mysteries:
> > - I thought that CallStacks were a new feature that would come with GHC
> > 8.0. Yet it seems the datatype is present in base-4.8.x. Even though the
> > docs even say (wrongly, evidently) that it's in base since 4.9.
> They were originally merged into 7.11, but were backported to the
> official 7.10.2 release due to popular demand. It appears the @since
> annotation wasn't updated correspondingly.
> > - That function seems missing in HEAD. Or maybe it moved. A little
> > searching says it *did* move, to GHC.Exception.
> In HEAD we are now using CallStacks for error and undefined, which was
> not the case for the 7.10.2 release. This means the type needs to be
> defined much earlier in base, before we even have enough functionality
> to write a sensible formatter. showCallStack currently lives in
> GHC.Exception because that's where it's used, but that's not a good
> reason... I'll take another look at moving it back to GHC.Stack.
> > Well, my problem is solved. But I think the documentation needs a pass
> > here. And is there a reason not to have a Show instance?
> I usually only use compiler-derived Show instances so that Read
> automatically works, as well as some nice formatting libraries like
> http://hackage.haskell.org/package/pretty-show for debugging. For
> pretty-printing like showCallStack I prefer a standalone function or a
> separate type-class.
> If the name "showCallStack" suggests the compiler-derived output, we
> could change it to something like "prettyCallStack" or
> "formatCallStack", I don't have a strong opinion there.
> Thanks for the comments!
> ghc-devs mailing list
> ghc-devs at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs