How do I use CallStack?

Richard Eisenberg eir at cis.upenn.edu
Mon Dec 7 04:56:09 UTC 2015


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.

- That function seems missing in HEAD. Or maybe it moved. A little searching says it *did* move, to GHC.Exception.

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?

Thanks!
Richard

On Dec 6, 2015, at 11:48 PM, Levent Erkok <erkokl at gmail.com> wrote:

> There's a function for that: https://hackage.haskell.org/package/base-4.8.1.0/docs/GHC-Stack.html#v:showCallStack
> 
> 
> 
> On Sun, Dec 6, 2015 at 8:43 PM, Richard Eisenberg <eir at cis.upenn.edu> wrote:
> Hi devs,
> 
> I wish to use the new CallStack feature to track call sites of a function. I want my function to print out where it was called from. I do not want to call `error`. How do I do this?
> 
> I looked in the release notes. They describe the CallStack feature at an overview, and the docs suggest that it has a Show instance. But the notes don't say where to import CallStack from. I found it in GHC.Stack, but I'm unsure this is the right place to take it from. The GHC release notes also refer me to the ghc-prim release notes. These (which I assume are ghc-prim/changelog.md) don't discuss CallStack. In any case, when I try to `show ?callstack`, I learn that CallStack is not an instance of Show, or I somehow haven't imported the instance.
> 
> Help?
> 
> Thanks!
> Richard
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20151206/18be58b4/attachment.html>


More information about the ghc-devs mailing list