How do I use CallStack?
Eric Seidel
eric at seidel.io
Mon Dec 7 06:39:11 UTC 2015
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 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!
Eric
More information about the ghc-devs
mailing list