How do I use CallStack?

Evan Laforge qdunkan at
Mon Dec 7 05:15:06 UTC 2015

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 "<empty-stack>" show_frame . Seq.last . Stack.getCallStack
    show_frame (name, srcloc) =
        SrcLoc.srcLocFile srcloc ++ ":" ++ show (SrcLoc.srcLocStartLine srcloc)
        ++ " [" ++ name ++ "]"

On Sun, Dec 6, 2015 at 8:56 PM, Richard Eisenberg <eir at> 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.

I've been using it since 7.10, with base 4.8.  There's also a back
port to 7.8, but it's not in the official distribution.

More information about the ghc-devs mailing list