
#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 goldfire): I like this general idea. But I want to find a way to the bottom of the slope, where '''all''' partial functions in base get call stack information. This plan alleviates your problem (3) quite nicely. * For problem (1): it seems quite easy to write a core-to-core pass that scrubs away the call stacks. This core pass would be enabled by `-O` but could be countermanded with `-fno-scrub-call-stacks` (in case there is an error only in optimized code, say). base would be compiled with `-fno- scrub-call-stacks`. This approach doesn't fix the performance of library functions, though. So we could instead have base export two versions of the functions, one with call stacks and one without. How do we relate the two? Via `RULES`: {{{#!hs foldr1 :: (?callstack :: CallStack) => ... faster_foldr1 :: ... {-# RULES "foldr1 call stack scrub" foldr1 = faster_foldr1 #-} }}} Without optimizations, we get the call stack. With optimizations, we don't. Huzzah. It's easy to imagine someone wanting to disable only these call-stack- ish RULES but keep others. Perhaps we should consider tagging RULES somehow to allow activating or deactivating RULES in groups. But that's a proposal for another day, and I don't think we absolutely need that here. * For problem (2): Your suggestions are good. We could also do a cheap trick like this: {{{#!hs type PartialFunction = (?callstack :: CallStack) head :: PartialFunction => [a] -> a }}} Yes, this needs `ConstraintKinds`, but I sorta like it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11035#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler