[GHC] #14911: Offer a way to augment call stacks

GHC ghc-devs at haskell.org
Mon Mar 12 07:35:28 UTC 2018


#14911: Offer a way to augment call stacks
-------------------------------------+-------------------------------------
           Reporter:  dfeuer         |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Core           |           Version:  8.4.1
  Libraries                          |
           Keywords:  CallStacks     |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Sometimes, I may want to capture some information that can be reported
 when an error occurs. Suppose I have

 {{{#!hs
 f x y = g x (h y)

 g :: HasCallStack => ...
 g x y = ..... (error "whoopsy") ....
 }}}

 I may want `f` to record information about `y` that will be reported if
 `g` throws an exception. As far as I can tell, the only currently
 supported way to do this is horrible and limited:

 {{{#!hs
 f x y = unsafeDupablePerformIO $
   catch (evaluate (g x (h y))) $ \e -> ....
 }}}

 I'd much rather have a function like

 {{{#!hs
 addMessage :: HasCallStack
            => String
            -> (HasCallStack => a)
            -> a
 }}}

 This would stick a string into the current call stack "frame" and call the
 argument. I imagine this can be implemented directly with the underlying
 implicit parameter, likely with a slight change to the `CallStack`
 representation.

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


More information about the ghc-tickets mailing list