Skip to content
Snippets Groups Projects

Representation-polymorphic HasField (fixes #22156)

Closed Adam Gundry requested to merge wip/amg/T22156 into master
1 unresolved thread

This generalises the HasField class to support representation polymorphism, so that instead of

type HasField :: forall {k} . k -> Type -> Type -> Constraint

we have

type HasField :: forall {k} {r_rep} {a_rep} . k -> TYPE r_rep -> TYPE a_rep -> Constraint

This change was approved by the CLC here: https://github.com/haskell/core-libraries-committee/issues/194#issuecomment-1800412006

The required code changes were surprisingly small. However, a small wrinkle is that this change makes GHC.Records no longer inferred as Safe due to the new import of TYPE from GHC.Exts. As far as I know TYPE is not currently exported from a Trustworthy module, so I've resorted to marking GHC.Records as Trustworthy. I don't know if there is a better solution here. EDIT: this happened anyway with the ghc-internal split, and I don't think it is particularly specific to GHC.Records anyway.

Edited by Adam Gundry

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 1 {-# LANGUAGE AllowAmbiguousTypes #-}
2 {-# LANGUAGE ExplicitForAll #-}
2 3 {-# LANGUAGE FunctionalDependencies #-}
3 4 {-# LANGUAGE PolyKinds #-}
5 {-# LANGUAGE StandaloneKindSignatures #-}
6 {-# LANGUAGE Trustworthy #-}
  • As you say, surprisingly easy. Do comment the Trustworthy business though!

  • Simon Peyton Jones approved this merge request

    approved this merge request

  • Adam Gundry added 1 commit

    added 1 commit

    • c04fcaba - Mark GHC.Records as Trustworthy

    Compare with previous version

  • Adam Gundry added 34 commits

    added 34 commits

    Compare with previous version

  • Adam Gundry added 25 commits

    added 25 commits

    Compare with previous version

  • Adam Gundry added 77 commits

    added 77 commits

    Compare with previous version

  • Author Developer

    I've rebased this now that !11400 (closed) has landed (which, it turns out, needed to mark GHC.Records as Trustworthy anyway). Hopefully it should now be good to merge?

  • Adam Gundry changed the description

    changed the description

  • The code looks good to me. I approve with the following asterisks:

    • In hasfieldrun03.hs, f1 and f2, g1 and g2 give identical results. I'd change something so that it's not completely trivial (e.g. make f2 return f1 + 1).

    • There's a merge conflict and ghc-9.10 already had an rc1 released, so I'm afraid you have to adapt the updates to changelogs to ghc-9.12.

  • Krzysztof Gogolewski approved this merge request

    approved this merge request

  • Adam Gundry added 468 commits

    added 468 commits

    Compare with previous version

  • Adam Gundry added 1 commit

    added 1 commit

    Compare with previous version

  • I will attempt to batch this MR (!12647 (closed))...

  • closed

  • Please register or sign in to reply
    Loading