[GHC] #11035: Add implicit call-stacks to partial functions in base

GHC ghc-devs at haskell.org
Thu Oct 29 22:08:32 UTC 2015


#11035: Add implicit call-stacks to partial functions in base
-------------------------------------+-------------------------------------
        Reporter:  gridaphobe        |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.2
      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):

 > it should either print plain exception or the call stack that finishes
 at the library’s API

 I would say that `minimumBy`s call stack does "finish at the library's
 api;" the root is in GHC.List, which is part of base. Perhaps you mean
 that a function `f` should only print call stacks whose root is `f`.
 That's an interesting point, and does seem reasonable for production code,
 but it sounds very non-trivial to implement.

 You can think of the CallStack solver as rewriting your code as follows.
 Whenever it sees a CallStack constraint, eg from a call to `error`

 {{{
 f x = error
 }}}

 it inserts a new implicit binder that adds the current call-site

 {{{
 f x = let ?callStack = <this-call-site> `pushCallStack` ?callStack
       in error
 }}}

 The `?callStack` on the rhs will either be discharged by the CallStack in
 `f`s context (if `f` requested one) or by the empty CallStack.

 So we can't just write `let ?callStack = emptyCallStack in error` because
 that's effectively what GHC is already doing for us. Instead we would need
 multiple versions of the callstack-aware functions, as Richard suggested.

 In general, I think Richard's suggestion of a call-stack scrubbing pass
 for optimized code should satisfy your concern as well. If I compile
 packages from hackage with optimizations (the default I think), then I
 won't see the implementation details. If I don't, I'll see the details,
 but I can at least submit a more informative bug report!

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11035#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list