{"action":"opened","issue":{"url":"https://api.github.com/repos/bvssvni/path_semantics/issues/98","repository_url":"https://api.github.com/repos/bvssvni/path_semantics","labels_url":"https://api.github.com/repos/bvssvni/path_semantics/issues/98/labels{/name}","comments_url":"https://api.github.com/repos/bvssvni/path_semantics/issues/98/comments","events_url":"https://api.github.com/repos/bvssvni/path_semantics/issues/98/events","html_url":"https://github.com/bvssvni/path_semantics/issues/98","id":168697302,"number":98,"title":"Closures and currying","user":{"login":"bvssvni","id":1743862,"avatar_url":"https://avatars.githubusercontent.com/u/1743862?v=3","gravatar_id":"","url":"https://api.github.com/users/bvssvni","html_url":"https://github.com/bvssvni","followers_url":"https://api.github.com/users/bvssvni/followers","following_url":"https://api.github.com/users/bvssvni/following{/other_user}","gists_url":"https://api.github.com/users/bvssvni/gists{/gist_id}","starred_url":"https://api.github.com/users/bvssvni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bvssvni/subscriptions","organizations_url":"https://api.github.com/users/bvssvni/orgs","repos_url":"https://api.github.com/users/bvssvni/repos","events_url":"https://api.github.com/users/bvssvni/events{/privacy}","received_events_url":"https://api.github.com/users/bvssvni/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bvssvni/path_semantics/labels/discussion","name":"discussion","color":"bfe5bf"},{"url":"https://api.github.com/repos/bvssvni/path_semantics/labels/draft","name":"draft","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-01T17:21:16Z","updated_at":"2016-08-01T17:21:16Z","closed_at":null,"body":"Using Prolog/Dyon inspired notation for multiple statements:\r\n\r\n- `:=` binds a closure to variable\r\n- `\\` begins a closure\r\n- `,` separates function statements\r\n- `.` terminates list of function statements\r\n\r\n```\r\na := \\(real, real) -> bool, \\ : (X, Y) X < Y.\r\nb := \\(real, real) -> bool, \\ : (X, Y) X + eps <= Y.\r\na = b\r\n```\r\n\r\nThe last statement `a = b` means `a` and `b` are semantically equivalent. All identical paths taken from either one results in same truth values. Notice that `eps = 1 / inf` is the smallest real number that is larger than zero.\r\n\r\nThis is equivalent to:\r\n\r\n```\r\na(real, real) -> bool,\r\n: (X, Y) -> X < Y.\r\nb(real, real) -> bool,\r\n: (X, Y) -> X + eps <= Y.\r\na = b\r\n```\r\n\r\nAlternative notion for mutable variables: Use `===` for semantic equivalence, `==` for literal equivalence.\r\n\r\n### Currying\r\n\r\nUsing `\\` has the advantage that you can explicitly tell when to use function currying in a path:\r\n\r\n```\r\n// Person becomes owner of purchased item.\r\nowns(item, person) -> bool.\r\nbuy(item, person) -> person,\r\n: (X, \\owns(X) false) -> \\owns(X) true.\r\n```\r\n\r\nThis is a bit easier to read, because you know that not all arguments are included. One can interpret it as an anonymous closure `\\(person) -> bool`. All paths take a single argument, so you only need to look up the type of the last argument to check it.\r\n\r\nA nice mathematical property with such closures is that all paths, that depends only on previous arguments, are compatible with full currying (see https://github.com/bvssvni/path_semantics/issues/78 for partial currying)."}}
{"actor":{"display_login":"bvssvni"}}