[GHC] #16232: Add setField to HasField
GHC
ghc-devs at haskell.org
Fri Jan 25 14:28:49 UTC 2019
#16232: Add setField to HasField
-------------------------------------+-------------------------------------
Reporter: adamgundry | Owner: adamgundry
Type: feature request | Status: new
Priority: normal | Milestone: 8.10.1
Component: Compiler (Type | Version: 8.7
checker) |
Resolution: | Keywords: ORF
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by adamgundry):
* owner: (none) => adamgundry
Comment:
> I suggest taking the direct path, and generate an update function for
each field.
Sorry, to be clear, do you mean the approach of generating renamed syntax
at definition sites?
> Its more work than Matthew says because we may need to evaluate the
argument (for strict constructors) or unbox it (if the argument is
UNPACKed).
Exactly, perhaps my example didn't do a good job of conveying the awkward
points here. Let me see if I understand correctly what generating Core
directly needs to do in the general case:
* When we pattern match in Core, we match on the *worker* (binding its
existential tyvars, theta and the arguments as given by `dataConInstSig`).
* We can use `dataConBoxer` to build let-bindings for the arguments to the
wrapper out of the bound variables from matching on the worker.
* We need to construct an application of the *wrapper* to appropriate
boxed arguments, replacing the one that corresponds to the field being
updated with the new value. I don't understand very clearly how to do
this. In particular, I'm not sure how to figure out the order in which to
instantiate type variables and dictionaries in the wrapper's type.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16232#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list