CallStack naming

Simon Peyton Jones simonpj at microsoft.com
Thu Jan 21 12:07:48 UTC 2016


|  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.  We also need something similar for Typeable, when we get a type-indexed version of TypeRep

	withTypeable :: TypeRep a -> (Typeable a => r) => r


Additionally, for ICallStack (bikeshed: I don’t like "AppendsCallStack") we would need to ensure that the new local instance over-rode all others, like for implicit parameters; see Note [Shadowing of Implicit Parameters] in TcInteract.

This part isn't necessary for Typeable because all witnesses are the same.


Bother.

Well, in the short term, let's 
 * implement it with the constraint synonym
 * bikeshed about names
 * write down the user-visible API, ensuring that it makes
   no mention of implicit parameters (provide setCallStack)

Then we can implement the API differently later if we so desire.

The main disadvantage is that the abstraction is leaky.  We can't *prevent* users from seeing and using the implicit parameter.

Does that sound like a plan.  Might you do it Eric?  The urgency is just to get 8.0 out with an API that we like

Simon

|  -----Original Message-----
|  From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of
|  Joachim Breitner
|  Sent: 21 January 2016 09:19
|  To: ghc-devs at haskell.org
|  Subject: Re: CallStack naming
|  
|  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.de|  https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fwww.jo
|  achim-
|  breitner.de%2f&data=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7cdece5
|  7f942bc42b0dd2308d32243eff4%7c72f988bf86f141af91ab2d7cd011db47%7c1&sda
|  ta=67ZZO9n8VFDeRV7DCzaI46uxdf%2bPMC4Plx5XY8tMcUc%3d
|    Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0xF0FBF51F
|    Debian Developer: nomeata at debian.org



More information about the ghc-devs mailing list