[GHC] #13360: Add a flag to enable inferring HasCallStack constraints

GHC ghc-devs at haskell.org
Fri Nov 10 10:30:16 UTC 2017


#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 saurabhnanda):

 **Question** -- if `error` is not there in the source code, does GHC
 optimise away `HasCallStack` completely? I'm seeing the same perf numbers
 for the two functions given below (the call to `throw` has been commented
 out):

 {{{
 factorialCS :: (HasCallStack) => Integer -> Integer
 factorialCS 1 = 1
 -- factorialCS 3 = throw $ CustomException "Error from CS version"
 callStack
 factorialCS n = n * factorialCS (n - 1)

 factorial :: Integer -> Integer
 factorial 1 = 1
 -- factorial 3 = throw $ CustomException "Error from non-CS version"
 emptyCallStack
 factorial n = n * factorial (n - 1)
 }}}

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


More information about the ghc-tickets mailing list