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

GHC ghc-devs at haskell.org
Thu Oct 29 18:29:13 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 nomeata):

 How about we stay on top of the slipperly slope for a while, and let
 people experiment with their call-stack enabled custom Preludes first for
 a while?

 In fact, what I do not like about
 {{{
 ghci> minimumBy compare []
 *** Exception: Prelude.foldr1: empty list
 CallStack:
   error, called at libraries/base/GHC/List.hs:999:3 in
 base-4.8.2.0:GHC.List
 }}}
 is that it leaks implementation details. This is great in your own code,
 but a polished library should _not_ leak a call stack about its details;
 it should either print plain exception or the call stack that finishes at
 the library’s API. At least for “expected exceptions” like `"empty list"`.

 So I would say what we have to do here is to prevent this call to error
 from adding a call stack. For that, uses of `error` in library functions¹
 should explicitly use `let ?foo::CallStack = emptyCallStack in error
 "..."` to prevent the constraint solver from adding an implementation-
 leaky call-stack here (if that even works, maybe what I want to achieve
 here requires modifications to the solver).

 ¹ Of course, precisely those that do not propagate the `?_::CallStack`
 constraint to the caller. If we decide to do that, then everything is
 fine.

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


More information about the ghc-tickets mailing list