{"action":"created","issue":{"url":"https://api.github.com/repos/purescript/purescript/issues/888","labels_url":"https://api.github.com/repos/purescript/purescript/issues/888/labels{/name}","comments_url":"https://api.github.com/repos/purescript/purescript/issues/888/comments","events_url":"https://api.github.com/repos/purescript/purescript/issues/888/events","html_url":"https://github.com/purescript/purescript/issues/888","id":58160430,"number":888,"title":"`where` clause on guarded clause","user":{"login":"pseudonom","id":5056117,"avatar_url":"https://avatars.githubusercontent.com/u/5056117?v=3","gravatar_id":"","url":"https://api.github.com/users/pseudonom","html_url":"https://github.com/pseudonom","followers_url":"https://api.github.com/users/pseudonom/followers","following_url":"https://api.github.com/users/pseudonom/following{/other_user}","gists_url":"https://api.github.com/users/pseudonom/gists{/gist_id}","starred_url":"https://api.github.com/users/pseudonom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pseudonom/subscriptions","organizations_url":"https://api.github.com/users/pseudonom/orgs","repos_url":"https://api.github.com/users/pseudonom/repos","events_url":"https://api.github.com/users/pseudonom/events{/privacy}","received_events_url":"https://api.github.com/users/pseudonom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-19T02:29:46Z","updated_at":"2015-02-19T18:07:41Z","closed_at":null,"body":"In Purescript,\r\n```purescript\r\nfoo | a = 1 where a = true\r\n```\r\nthrows `Unknown value 'a'` on compilation.\r\n\r\n(Haskell allows this.)"},"comment":{"url":"https://api.github.com/repos/purescript/purescript/issues/comments/75103947","html_url":"https://github.com/purescript/purescript/issues/888#issuecomment-75103947","issue_url":"https://api.github.com/repos/purescript/purescript/issues/888","id":75103947,"user":{"login":"pseudonom","id":5056117,"avatar_url":"https://avatars.githubusercontent.com/u/5056117?v=3","gravatar_id":"","url":"https://api.github.com/users/pseudonom","html_url":"https://github.com/pseudonom","followers_url":"https://api.github.com/users/pseudonom/followers","following_url":"https://api.github.com/users/pseudonom/following{/other_user}","gists_url":"https://api.github.com/users/pseudonom/gists{/gist_id}","starred_url":"https://api.github.com/users/pseudonom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pseudonom/subscriptions","organizations_url":"https://api.github.com/users/pseudonom/orgs","repos_url":"https://api.github.com/users/pseudonom/repos","events_url":"https://api.github.com/users/pseudonom/events{/privacy}","received_events_url":"https://api.github.com/users/pseudonom/received_events","type":"User","site_admin":false},"created_at":"2015-02-19T18:07:41Z","updated_at":"2015-02-19T18:07:41Z","body":"> Can you provide any samples of this being used to specify a function more elegantly than would otherwise be possible?\r\n\r\nIt's not the only way to write the function, but I initially tried guarded `where`s with a smart constructor:\r\n\r\n```purescript\r\nmkFoo :: Bar -> Either Error Foo\r\nmkFoo a | test1 a = Left Err1 where test1 = ...\r\nmkFoo a | test2 a = Left Err2 where test2 = ...\r\nmkFoo a | test3 a = Left Err3 where test3 = ...\r\nmkFoo a | otherwise = Right (Foo a)\r\n```\r\n(Effectively, a multi-way conditional.)\r\n\r\nIt's not obvious to me that there's a better way to write that."}}