[Haskell-cafe] HasCallStack - runtime costs?

Johannes Waldmann johannes.waldmann at htwk-leipzig.de
Mon Mar 7 17:21:30 UTC 2016


Eric wrote earlier:

> If you import a function with a HasCallStack constraint
> there's no way to disable the overhead ...

> For non-recursive functions like head and tail,
> the overhead is probably not large enough to be noticeable.

Now I'm confused: should this mean that head and tail
are "functions with a HasCallStack constraint"?
If I ask ghci for their type, it just says head :: [a] -> a
and that's also what's in the source
https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/libraries/base-4.9.0.0/src/GHC-List.html#head
but the Callstack explanation in the user manual
does show a different version of head
https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/users_guide/glasgow_exts.html#hascallstack

I am not particularly concerned about head and tail here
but generally about how to find out whether my code
is taking a performance penalty.

I think the documentation (user manual Section 9.31)
is rather brief about the semantics. It speaks about
solving "HasCallStack" constraints - but they could also
be propagated? There is secondary documentation like
https://ghc.haskell.org/trac/ghc/wiki/ExplicitCallStack
but it does not tell what is actually implemented,
or I don't see it.

- J.W.



More information about the Haskell-Cafe mailing list