OverloadedRecordFields magic constraint solving for HasField

Authored by adamgundry on Dec 22 2015, 11:54 AM.



This makes a start at implementing part 3 of the OverloadedRecordFields
trilogy (see https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/MagicClasses).
Only HasField has been done so far; updates need a bit more thought about
the design. Moreover, I've gone for the functional dependency version
as it seems simplest.

Rather than adding another special-purpose constructor to EvTerm, I made
it possible to embed arbitrary HsExprs in evidence. This should be useful
for typechecker plugins. But I can specialise it if needed.

Test Plan

some new tests added, more needed

Diff Detail

rGHC Glasgow Haskell Compiler
Lint OK
No Unit Test Coverage
Build Status
Buildable 7785
Build 9554: GHC Patch Validation (amd64/Linux)
Build 9553: arc lint + arc unit
adamgundry updated this revision to Diff 5940.Dec 22 2015, 11:54 AM
adamgundry retitled this revision from to OverloadedRecordFields magic constraint solving for HasField.
adamgundry updated this object.
adamgundry edited the test plan for this revision. (Show Details)
adamgundry added reviewers: austin, bgamari, simonpj.
adamgundry added inline comments.Dec 22 2015, 11:56 AM

Is there an easier way to do this? It seems surprisingly hard work! But perhaps that's what I get for generating non-desugared expressions as evidence?

adamgundry updated this revision to Diff 5957.Dec 23 2015, 6:26 AM
adamgundry edited edge metadata.

Fix build and test more cases

  • Resolve module import loop by adding a new boot file :-(
  • Test interaction between HasField and DuplicateRecordFields
  • Solve HasField constraints involving data families
adamgundry updated this revision to Diff 5958.Dec 23 2015, 7:23 AM
adamgundry edited edge metadata.
  • Merge remote-tracking branch 'origin/master' into wip/hasfield
bgamari requested changes to this revision.May 11 2016, 6:36 AM
bgamari edited edge metadata.

What is the status of this, @adamgundry?

This revision now requires changes to proceed.May 11 2016, 6:36 AM

In principle this is still awaiting review; I've been meaning to chase it up but have had lots of other things going on! I would particularly like feedback on:

  • whether to go ahead with the functional dependency version of HasField (see wiki page and ghc-users thread "Magic classes for Overloaded Record Fields, overlaps, FunDeps" for discussion); and
  • the approach to extending EvTerm with an arbitrary HsExpr, rather than a special case for HasField evidence (should this be a CoreExpr instead?).

In addition, I suspect this has bitrotted relative to HEAD slightly. I'll try to get it up to date and start moving again on the record update side.

adamgundry abandoned this revision.Nov 14 2016, 4:23 PM

I've put together an updated implementation of this as D2708.