{"action":"created","issue":{"url":"https://api.github.com/repos/robrix/Prelude/issues/55","repository_url":"https://api.github.com/repos/robrix/Prelude","labels_url":"https://api.github.com/repos/robrix/Prelude/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/robrix/Prelude/issues/55/comments","events_url":"https://api.github.com/repos/robrix/Prelude/issues/55/events","html_url":"https://github.com/robrix/Prelude/issues/55","id":179480485,"number":55,"title":"Low precedence right associative application (Haskell `$`)","user":{"login":"werediver","id":922687,"avatar_url":"https://avatars.githubusercontent.com/u/922687?v=3","gravatar_id":"","url":"https://api.github.com/users/werediver","html_url":"https://github.com/werediver","followers_url":"https://api.github.com/users/werediver/followers","following_url":"https://api.github.com/users/werediver/following{/other_user}","gists_url":"https://api.github.com/users/werediver/gists{/gist_id}","starred_url":"https://api.github.com/users/werediver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/werediver/subscriptions","organizations_url":"https://api.github.com/users/werediver/orgs","repos_url":"https://api.github.com/users/werediver/repos","events_url":"https://api.github.com/users/werediver/events{/privacy}","received_events_url":"https://api.github.com/users/werediver/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-27T12:34:36Z","updated_at":"2016-09-27T17:29:38Z","closed_at":null,"body":"## Status quo\r\nBy analogy with F# (see [F# Symbol and Operator Reference](https://docs.microsoft.com/dotnet/articles/fsharp/language-reference/symbol-and-operator-reference/index)) the backward pipe `<|` operator in this library has low precedence and **right associativity**. This kind of function application operator is of limited usefulness, because it doesn't allow consecutive application without extra parentheses.\r\n\r\nCompare:\r\n- F#, direct function application\r\n```\r\n> List.sum (List.take 2 (1 :: [2; 3])) ;;\r\nval it : int = 3\r\n``` \r\n- F#, backward pipe operator\r\n```\r\n> List.sum <| (List.take 2 <| 1 :: [2; 3]) ;;\r\nval it : int = 3\r\n```\r\n- F#, high precedence right associative backward pipe operator\r\n```\r\n> let inline (^<|) f a = f a ;;\r\n> List.sum ^<| List.take 2 ^<| 1 :: [2; 3] ;;\r\nval it : int = 3\r\n```\r\n- Haskell, direct function application:\r\n```\r\n> sum (take 2 (1 : [2, 3]))\r\n3\r\n```\r\n- Haskell, [application operator](http://hackage.haskell.org/package/base-4.9.0.0/docs/Prelude.html#v:-36-)\r\n```\r\n> sum $ take 2 $ 1 : [2, 3]\r\n3\r\n```\r\n\r\nNotice that the right associative function application operator allows to drop the maximum possible number of parentheses (_often all_).\r\n\r\n## Proposal\r\n\r\nLets introduce a low precedence right associative function application operator to allow more concise and expressive code!\r\n\r\n### How to name it?\r\nF# `^<|` intuitively connects with the left associative variant (`<|`), but originally it is a _high precedence_ operator.\r\n\r\nHaskell `$` is very concise and defines exactly the low precedence right associative function application operator, thus it seems to be the best choice."},"comment":{"url":"https://api.github.com/repos/robrix/Prelude/issues/comments/249936989","html_url":"https://github.com/robrix/Prelude/issues/55#issuecomment-249936989","issue_url":"https://api.github.com/repos/robrix/Prelude/issues/55","id":249936989,"user":{"login":"werediver","id":922687,"avatar_url":"https://avatars.githubusercontent.com/u/922687?v=3","gravatar_id":"","url":"https://api.github.com/users/werediver","html_url":"https://github.com/werediver","followers_url":"https://api.github.com/users/werediver/followers","following_url":"https://api.github.com/users/werediver/following{/other_user}","gists_url":"https://api.github.com/users/werediver/gists{/gist_id}","starred_url":"https://api.github.com/users/werediver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/werediver/subscriptions","organizations_url":"https://api.github.com/users/werediver/orgs","repos_url":"https://api.github.com/users/werediver/repos","events_url":"https://api.github.com/users/werediver/events{/privacy}","received_events_url":"https://api.github.com/users/werediver/received_events","type":"User","site_admin":false},"created_at":"2016-09-27T17:29:38Z","updated_at":"2016-09-27T17:29:38Z","body":"Actually, I'd prefer to change the declaration of `<|` to make it right associative. The only, but possibly an important, issue here is compatibility with existing code.\r\n\r\nDo you guys think this change can lead to bugs in existing code? I think it will more likely make some code incorrect, what will be easy to fix."}}
{"actor":{"display_login":"werediver"}}