Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,842
    • Issues 4,842
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Merge requests
  • !3257

Open
Created May 09, 2020 by Adam Gundry@adamgundryDeveloper
  • Report abuse
Report abuse

WIP: Change HasField to support updates

  • Overview 96
  • Commits 10
  • Pipelines 16
  • Changes 50

This implements GHC proposal 158 (see #16232). That is, it changes GHC.Records.HasField from

class HasField x r a | x r -> a where
  getField :: r -> a

to:

class HasField x r a | x r -> a where
  hasField :: r -> (a -> r, a)

The essence of the implementation is described in Note [Record updaters] and the updated Note [HasField instances]. It follows the approach suggested by @simonpj in #16232, namely generating an updater function alongside the selector function. The Name of this function is stored in DataCon, hence the changes to FieldLabel. I have not changed mkRecSelBind to derive the selector binding from the updater, although in principle this is possible.

The commits are conceptually distinct steps but not individually buildable; I've kept them separate for ease of review/rebasing but I will squash them before merge.

Still to do: update the user docs. Now with user docs!

Edited Apr 07, 2021 by Adam Gundry
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: wip/amg/hasfield-2020