[GHC] #11035: Add implicit call-stacks to partial functions in base
GHC
ghc-devs at haskell.org
Thu Oct 29 22:17:27 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):
> 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.
What if we add a special `rootCallStack :: CallStack` which is a value
such that
{{{
x `pushCallStack` rootCallStack = rootCallStack
}}}
but
{{{
rootCallStack `pushCallStack` x = rootCallStack “:” x
}}}
as before and a call stack that consists of only a rootCallStack causes no
stack trace to be printed.
This allows the following two important patterns:
{{{
f x = let ?callStack = rootCallStack
in {... something with error or any other callStack expecting
function ...}
}}}
would prevent any CallStack information to appear in `{...}`, and
{{{
f x = let ?callStack = rootCallStack `pushCallStack` ?callStack
in {... something with error or any other callStack expecting
function ...}
}}}
which would include a CallStack in exceptions raised in `{...}`, but the
stack would end in `f`, and not expose any of the structure of the
implementation.
I’d like to have something like this for API hygiene and implementation
hiding. But note that if we had that, constant propagation (or
`rootCallStack`) and a specialization mechanism that’s very much like the
existing type class constraint specialization would allow the compiler to
specialize the implementation in the former case to one that does _not_
pass CallStacks around any more.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11035#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list