OverloadedRecordFields magic constraint solving for HasField
AbandonedPublic

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

Details

Summary

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

Repository
rGHC Glasgow Haskell Compiler
Branch
wip/hasfield
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 7785
Build 9554: GHC Patch Validation (amd64/Linux)
Build 9553: arc lint + arc unit
adamgundry retitled this revision from to OverloadedRecordFields magic constraint solving for HasField.Dec 22 2015, 11:54 AM
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
compiler/typecheck/TcInteract.hs
2241

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

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
  • Merge remote-tracking branch 'origin/master' into wip/hasfield
bgamari requested changes to this revision.May 11 2016, 6:36 AM

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.