Re: How do I use CallStack?

2015-12-07 Thread Richard Eisenberg
And sorry if my tone on those emails was a bit snarky. It was late... though snarkiness at any hour is unwelcome. :) I understand the concerns about the Show instance, though I have no opinion about the name of the pretty-printer. My only request is that the pretty-print function is easily

Re: How do I use CallStack?

2015-12-07 Thread Eric Seidel
On Mon, Dec 7, 2015, at 06:15, Richard Eisenberg wrote: > And sorry if my tone on those emails was a bit snarky. It was late... > though snarkiness at any hour is unwelcome. :) > > I understand the concerns about the Show instance, though I have no > opinion about the name of the

Re: How do I use CallStack?

2015-12-07 Thread Ben Gamari
Eric Seidel writes: > Hi Richard, > > Sorry for all of the confusion, it seems the docs do indeed need some > love! > > 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

Re: How do I use CallStack?

2015-12-07 Thread Bartosz Nitka
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

Re: How do I use CallStack?

2015-12-07 Thread Niklas Hambüchen
On 07/12/15 11:59, Ben Gamari wrote: >> 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. > > I have also struggled with these sorts of naming decisions. The >

Re: How do I use CallStack?

2015-12-07 Thread Eric Seidel
> > As quite a separate point from above, I may have found a bug: I put a > > (?callstack :: CallStack) constraint on TcEvidence.mkTcTransCo and then > > put the same constraint on TcCanonical.rewriteEqEvidence. GHC complained > > about a redundant constraint on rewriteEqEvidence, and indeed its

Re: How do I use CallStack?

2015-12-07 Thread Richard Eisenberg
On Dec 7, 2015, at 2:23 PM, Eric Seidel wrote: > After staring at your bug confusedly for a few minutes, wondering why I > couldn't simplify it, I realized that the actual warning I was getting > was in *mkTcTransCo*, not rewriteEqEvidence. mkTcTransCo does not in > fact use a

Re: How do I use CallStack?

2015-12-07 Thread Eric Seidel
Oh I forgot to mention that I was testing on my local branch which fixes precisely this kind of bug when the CallStack is used inside a let-binder, which is what happens in rewriteEqEvidence. So it looks like my patch takes care of this issue. Thanks for the report! Sent from my iPhone > On

Re: How do I use CallStack?

2015-12-06 Thread Levent Erkok
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 wrote: > Hi devs, > > I wish to use the new CallStack feature to track call sites of a function. > I want my

Re: How do I use CallStack?

2015-12-06 Thread Reid Barton
On Sun, Dec 6, 2015 at 11:56 PM, 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

Re: How do I use CallStack?

2015-12-06 Thread Richard Eisenberg
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

Re: How do I use CallStack?

2015-12-06 Thread Evan Laforge
Also, a call stack frame is just a (name, srcloc) pair, so you can format it yourself. I use: show_stack :: CallStack -> String show_stack = maybe "" show_frame . Seq.last . Stack.getCallStack where show_frame (name, srcloc) = SrcLoc.srcLocFile srcloc ++ ":" ++ show

How do I use CallStack?

2015-12-06 Thread Richard Eisenberg
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

Re: How do I use CallStack?

2015-12-06 Thread Eric Seidel
Hi Richard, Sorry for all of the confusion, it seems the docs do indeed need some love! 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