Simon Peyton Jones
simonpj at microsoft.com
Thu Jan 28 15:40:38 UTC 2016
OK. Let's make sure the wiki page and documentation reflects this.
| -----Original Message-----
| From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Eric
| Sent: 27 January 2016 18:16
| To: ghc-devs at haskell.org
| Subject: Re: CallStack naming
| On Thu, Jan 21, 2016, at 04:07, Simon Peyton Jones wrote:
| > | It’d probably need a built-in function
| > |
| > | setCallStack :: CallStack -> (AppendsCallStack => a) -> a
| > Correct. This is easy to write in Core but not in Haskell.
| Ugh, I just realized that we can't write setCallStack (with implicit
| parameters) in Haskell either. Well, we can, but it adds an entry to
| the stack.. Why? Let's look at the implementation
| setCallStack :: CallStack -> (HasCallStack => a) -> a
| setCallStack stk do_this =
| let ?callStack = stk in do_this
| Rebinding ?callStack works just fine, but the occurrence of do_this
| causes GHC to push an entry onto the stack, which is less than ideal.
| What does this look like in practice? If we evaluate
| setCallStack foo (error "die")
| the resulting stack will be
| The rebinding trick works for withFrozenCallStack precisely because we
| freeze the CallStack, so the push from do_this is ignored.
| So, long story short, I'm not convinced of the utility of setCallStack.
| I think perhaps we should not provide it, and just do the rebinding
| trick inside withFrozenCallStack (which was the only use-case for
| setCallStack to begin with).
| ghc-devs mailing list
| ghc-devs at haskell.org
More information about the ghc-devs