CallStack naming

Joachim Breitner mail at joachim-breitner.de
Thu Jan 21 09:19:11 UTC 2016


Hi,

Am Mittwoch, den 20.01.2016, 09:24 -0800 schrieb Eric Seidel:
> The problem is that I don't know how to implement
> `withFrozenCallStack`
> (included in the wiki) as a Haskell function if CallStacks aren't
> implicit parameters under-the-hood.

breaking it further down, the problem is not with `withFrozenCallStack`
per se, but rather with any code that wants to set the current
callstack, e.g. anything of the current form

  let ?callStack = ...
  in ..

How would that look with a magic nullary constraint "AppendsCallStack"?
It’d probably need a built-in function

setCallStack :: CallStack -> (AppendsCallStack => a) -> a

with which we can likely implement `withFrozenCallStack` again:

withFrozenCallStack :: AppendsCallStack => (AppendsCallStack => a) -> a
withFrozenCallStack do_this =
  -- we pop the stack before freezing it to remove
  -- withFrozenCallStack's call-site
  let callStack = freezeCallStack (popCallStack callStack)
  in setCallStack callStack do_this

It might need a second call to popCallStack depending on the precise
semantics of `callStack :: AppendsCallStack => CallStack` (i.e. whether
that does pop one entry off itself).

Greetings,
Joachim


-- 
Joachim “nomeata” Breitner
  mail at joachim-breitner.dehttp://www.joachim-breitner.de/
  Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0xF0FBF51F
  Debian Developer: nomeata at debian.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20160121/db0bf6cb/attachment.sig>


More information about the ghc-devs mailing list