{"action":"created","issue":{"url":"https://api.github.com/repos/kcsongor/generic-lens/issues/52","repository_url":"https://api.github.com/repos/kcsongor/generic-lens","labels_url":"https://api.github.com/repos/kcsongor/generic-lens/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/kcsongor/generic-lens/issues/52/comments","events_url":"https://api.github.com/repos/kcsongor/generic-lens/issues/52/events","html_url":"https://github.com/kcsongor/generic-lens/issues/52","id":329041882,"node_id":"MDU6SXNzdWUzMjkwNDE4ODI=","number":52,"title":"First-class record construction.","user":{"login":"lortabac","id":1907333,"node_id":"MDQ6VXNlcjE5MDczMzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1907333?v=4","gravatar_id":"","url":"https://api.github.com/users/lortabac","html_url":"https://github.com/lortabac","followers_url":"https://api.github.com/users/lortabac/followers","following_url":"https://api.github.com/users/lortabac/following{/other_user}","gists_url":"https://api.github.com/users/lortabac/gists{/gist_id}","starred_url":"https://api.github.com/users/lortabac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lortabac/subscriptions","organizations_url":"https://api.github.com/users/lortabac/orgs","repos_url":"https://api.github.com/users/lortabac/repos","events_url":"https://api.github.com/users/lortabac/events{/privacy}","received_events_url":"https://api.github.com/users/lortabac/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-04T12:51:19Z","updated_at":"2018-06-05T15:40:45Z","closed_at":null,"author_association":"NONE","body":"One of the things that often annoy me in Haskell is that record construction is not a first-class element. For example, imagine this simple record construction:\r\n\r\n`john = Person { name = \"John\", age = 42 }`\r\n\r\nThere are two problems with this definition:\r\n\r\n- `{ name = \"John\", age = 42 }` cannot be assigned to a variable nor reused anywhere else.\r\n\r\n- It cannot be composed with other record constructors to get the union of all the fields. If you use lenses, you can compose record updates (through setters) but not record construction AFAIK.\r\n\r\nGiven the record/hlist isomorphism it should not be too hard to implement a first-class record \"builder\". Internally it can be expressed as an hlist (with convenient user-facing types and operators to set and compose fields) and record construction would consist of reordering the elements of the list and converting to the record representation.\r\n\r\nThis feature would allow for a form of composition that goes beyond the subtype/supertype relation. I have often needed it, but I have always thought this was impossible to achieve in Haskell. Now I realized it might be doable, and `generic-lens` already has the necessary infrastructure. What do you think of the idea?"},"comment":{"url":"https://api.github.com/repos/kcsongor/generic-lens/issues/comments/394758140","html_url":"https://github.com/kcsongor/generic-lens/issues/52#issuecomment-394758140","issue_url":"https://api.github.com/repos/kcsongor/generic-lens/issues/52","id":394758140,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDc1ODE0MA==","user":{"login":"lortabac","id":1907333,"node_id":"MDQ6VXNlcjE5MDczMzM=","avatar_url":"https://avatars3.githubusercontent.com/u/1907333?v=4","gravatar_id":"","url":"https://api.github.com/users/lortabac","html_url":"https://github.com/lortabac","followers_url":"https://api.github.com/users/lortabac/followers","following_url":"https://api.github.com/users/lortabac/following{/other_user}","gists_url":"https://api.github.com/users/lortabac/gists{/gist_id}","starred_url":"https://api.github.com/users/lortabac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lortabac/subscriptions","organizations_url":"https://api.github.com/users/lortabac/orgs","repos_url":"https://api.github.com/users/lortabac/repos","events_url":"https://api.github.com/users/lortabac/events{/privacy}","received_events_url":"https://api.github.com/users/lortabac/received_events","type":"User","site_admin":false},"created_at":"2018-06-05T15:40:45Z","updated_at":"2018-06-05T15:40:45Z","author_association":"NONE","body":"Maybe my `field` function should be renamed to something less ambiguous :)\r\n\r\nThe open/close idea is cool. I thought this kind of polymorphic update was already possible, but a quick test in GHCI showed me that it is not the case.\r\n\r\nWhat I like about this HList isomorphism is that it can give you the flexibility of extensible records, without the inconvenience of needing a whole new \"language\" and ecosystem. I'm pretty sure there is still a lot to be explored in this sense."}}
{"actor":{"display_login":"lortabac"}}