{"action":"created","issue":{"url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/506","repository_url":"https://api.github.com/repos/fsharp/fslang-suggestions","labels_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/506/labels{/name}","comments_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/506/comments","events_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/506/events","html_url":"https://github.com/fsharp/fslang-suggestions/issues/506","id":187006680,"number":506,"title":"Allow _.Property or (.Property) shorthand accessor functions","user":{"login":"wastaz","id":6367407,"avatar_url":"https://avatars3.githubusercontent.com/u/6367407?v=4","gravatar_id":"","url":"https://api.github.com/users/wastaz","html_url":"https://github.com/wastaz","followers_url":"https://api.github.com/users/wastaz/followers","following_url":"https://api.github.com/users/wastaz/following{/other_user}","gists_url":"https://api.github.com/users/wastaz/gists{/gist_id}","starred_url":"https://api.github.com/users/wastaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wastaz/subscriptions","organizations_url":"https://api.github.com/users/wastaz/orgs","repos_url":"https://api.github.com/users/wastaz/repos","events_url":"https://api.github.com/users/wastaz/events{/privacy}","received_events_url":"https://api.github.com/users/wastaz/received_events","type":"User","site_admin":false},"labels":[{"id":752357665,"url":"https://api.github.com/repos/fsharp/fslang-suggestions/labels/area:%20syntax","name":"area: syntax","color":"fef2c0","default":false},{"id":465113757,"url":"https://api.github.com/repos/fsharp/fslang-suggestions/labels/old%20votes:300+","name":"old votes:300+","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":245,"created_at":"2016-11-03T09:09:43Z","updated_at":"2018-03-02T06:08:44Z","closed_at":null,"author_association":"NONE","body":"\r\nThis is a feature that I would love to steal from Elm :)\r\nIn Elm, if I define a record as such\r\n\r\n`type Foo = {\r\n   bar : int\r\n   baz : int\r\n}`\r\n\r\nI then automatically get functions such as .bar and .baz that I can use as getters for this record. So instead of writing code like this\r\n\r\n`foo |> fun f -> f.bar |> (+) 5`\r\n\r\nI can write code like this\r\n\r\n`foo |> .bar |> (+) 5`\r\n\r\nWhile this may seem useless in this small example, it does make things a lot nicer in larger chains, for example if I have a list that I want to map over\r\n\r\n`fooList |> List.map .bar |> List.max`\r\n\r\nNote: While this works in Elm it wont work in F# since `List.map.bar` and `List.map .bar` is the same so in the F# version I guess this would have to either be `List.map (.bar)` or a different character than `.` should be used. For example `List.map #bar` or `List.map :bar` or something similar?\r\n\r\nI feel that I am often writing these type of small functions and while it works, this type of construct would be a nice-to-have.\r\n\r\nBasically what I would suggest is that `.bar` would be a special syntax that expands into `fun a -> a.bar` maybe by generating some type of generic function like this\r\n\r\n`let inline bar a = (^T : (member bar : 'b) a)`\r\n\r\n## Pros and Cons \r\n\r\nThe advantages of making this adjustment to F# are\r\n* less unnecessary visual noise for a pretty common use case\r\n* improves on the experience when piping values\r\n* should not interfere with any existing code (at least I think)\r\n\r\nThe disadvantages of making this adjustment to F# are\r\n* introduces a special case in parsing code which might be hard to fit into the compiler in a nice way (Not sure about this, someone who knows more about this \r\n* may be seen as \"magic\" and be harder to understand?\r\n* two ways of doing the same thing\r\n\r\n## Affadavit (must be submitted)\r\n\r\nPlease tick this by placing a cross in the box:\r\n* [X] This is not a question (e.g. like one you might ask on [stackoverflow](http://stackoverflow.com)) and I have searched stackoverflow for discussions of this issue\r\n* [X] I have [searched both open and closed suggestions on this site](http://github.com/fsharp/fslang-suggestions/issues) and believe this is not a duplicate\r\n* [X] This is not something which has obviously \"already been decided\" in previous versions of F#.  If you're questioning a fundamental design decision that has obviously already been taken (e.g. \"Make F# untyped\") then please don't submit it.\r\n\r\nPlease tick all that apply:\r\n* [X] This is not a breaking change to the F# language design\r\n* [X] I would be willing to help implement and/or test this\r\n* [ ] I or my company would be willing to help crowdfund F# Software Foundation members to work on this\r\n"},"comment":{"url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/comments/369831017","html_url":"https://github.com/fsharp/fslang-suggestions/issues/506#issuecomment-369831017","issue_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/506","id":369831017,"user":{"login":"jwosty","id":4031185,"avatar_url":"https://avatars3.githubusercontent.com/u/4031185?v=4","gravatar_id":"","url":"https://api.github.com/users/jwosty","html_url":"https://github.com/jwosty","followers_url":"https://api.github.com/users/jwosty/followers","following_url":"https://api.github.com/users/jwosty/following{/other_user}","gists_url":"https://api.github.com/users/jwosty/gists{/gist_id}","starred_url":"https://api.github.com/users/jwosty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwosty/subscriptions","organizations_url":"https://api.github.com/users/jwosty/orgs","repos_url":"https://api.github.com/users/jwosty/repos","events_url":"https://api.github.com/users/jwosty/events{/privacy}","received_events_url":"https://api.github.com/users/jwosty/received_events","type":"User","site_admin":false},"created_at":"2018-03-02T06:08:44Z","updated_at":"2018-03-02T06:08:44Z","author_association":"CONTRIBUTOR","body":"Just gonna throw another syntax out there:\r\n\r\n    xs |> List.map ->Prop\r\n\r\nNot sure how this would work with changing (`->Prop1.Prop2`? ew.), but maybe an interesting avenue to explore."}}
{"actor":{"display_login":"jwosty"}}