
So, how do we take it forward from here? Is it possible to have HasCallStack automatically for functions in IO and/or above a certain cost
#13360: Add a flag to enable inferring HasCallStack constraints -------------------------------------+------------------------------------- Reporter: gridaphobe | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by gridaphobe): Replying to [comment:30 bgamari]: threshold?
I think we'll need to define the criterion here a bit more precisely. In
particular, it's not clear that doing this in a completely type-driven way makes sense. For instance, what about a function in `MaybeT IO`? Yeah, and it gets even worse when you think about things like `MonadIO`, `MonadBaseControl`, etc.
Using a size-threshold sounds plausible but feels a bit ad-hoc.
I agree. I'm pretty reluctant to tie a user-facing feature like `HasCallStack` to GHC's size heuristics, that would make it quite difficult for users to reason about which functions will get an automatic constraint. And worse, there doesn't seem to be any reason to expect a size heuristic to produce a proper **chain** of callstack-aware functions.
However, this does raise a question: What prevents you from just using cost center stacks?
Well, cost-center stacks require the entire world to have been compiled with `-prof`, which can be pretty time-consuming. In contrast, `HasCallStack` could be enabled on a per-module basis while maintaining interoperability with non-`HasCallStack` code. I feel like this could be a useful debugging tool, though it is somewhat limited in scope, i.e. in the limit it clearly devolves to a manual version of the `-prof` way. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13360#comment:34 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler