{"action":"created","issue":{"url":"https://api.github.com/repos/haskell/haskell-mode/issues/1313","repository_url":"https://api.github.com/repos/haskell/haskell-mode","labels_url":"https://api.github.com/repos/haskell/haskell-mode/issues/1313/labels{/name}","comments_url":"https://api.github.com/repos/haskell/haskell-mode/issues/1313/comments","events_url":"https://api.github.com/repos/haskell/haskell-mode/issues/1313/events","html_url":"https://github.com/haskell/haskell-mode/issues/1313","id":152680386,"number":1313,"title":"Pattern synonyms are highlighted as definitions","user":{"login":"taktoa","id":553443,"avatar_url":"https://avatars.githubusercontent.com/u/553443?v=3","gravatar_id":"","url":"https://api.github.com/users/taktoa","html_url":"https://github.com/taktoa","followers_url":"https://api.github.com/users/taktoa/followers","following_url":"https://api.github.com/users/taktoa/following{/other_user}","gists_url":"https://api.github.com/users/taktoa/gists{/gist_id}","starred_url":"https://api.github.com/users/taktoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taktoa/subscriptions","organizations_url":"https://api.github.com/users/taktoa/orgs","repos_url":"https://api.github.com/users/taktoa/repos","events_url":"https://api.github.com/users/taktoa/events{/privacy}","received_events_url":"https://api.github.com/users/taktoa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-03T01:17:37Z","updated_at":"2016-05-03T08:34:19Z","closed_at":null,"body":"It seems to me that every instance of the token `pattern` in the attached code sample should be highlighted with the keyword face (i.e.: the same face as `module`, `class`, `where`, etc.).\r\n\r\nThe main objection to this kind of fix is that people could want to name a function `pattern` when the extension is disabled. However, the `proc` keyword has similar problems but is currently being syntax-highlighted regardless of the presence of the relevant language pragma. I guess `proc` *is* technically in the Haskell 2010 Report so it's Official Haskell whereas -XPatternSynonyms is merely GHC Haskell, but I think that doesn't hold much water given the popularity of GHC extensions.\r\n\r\n```haskell\r\n{-# LANGUAGE GADTs           #-}\r\n{-# LANGUAGE PatternSynonyms #-}\r\n{-# LANGUAGE UnicodeSyntax   #-}\r\n{-# LANGUAGE ViewPatterns    #-}\r\n\r\n-- Pattern synonyms can be exported\r\nmodule Main (pattern A1) where\r\n\r\ndata Foo = Foo\r\ndata Bar where Bar :: (Show a) => a -> Bar\r\n\r\n-- Basic usage of unidirectional and bidirectional pattern synonyms\r\npattern A1 <- Foo\r\npattern A2 = Foo\r\n\r\n-- Patterns can have type signatures\r\n-- These type signatures have up to two contexts\r\n-- (these are called CProv and CReq for proven and required constraints resp.)\r\npattern B1 :: (Show a) => (Show a) => a -> Bar\r\npattern B1 x <- Bar x\r\npattern B2 :: (Show a) => (Show a) => a -> Bar\r\npattern B2 x =  Bar x\r\n\r\n-- If CProv is empty, it can be omitted.\r\npattern C1 :: (Show a) => a -> Bar\r\npattern C1 x <- Bar x\r\npattern C2 :: (Show a) => a -> Bar\r\npattern C2 x =  Bar x\r\n\r\n-- If CProv is not empty but CReq is, it's denoted like so:\r\npattern D1 :: (Show a) => () => a -> Bar\r\npattern D1 x <- Bar x\r\npattern D2 :: (Show a) => () => a -> Bar\r\npattern D2 x =  Bar x\r\n\r\n-- Explicitly-bidirectional pattern synonym\r\npattern Succ n <- (subtract 1 -> n) where Succ n = n + 1\r\n\r\n-- With -XUnicodeSyntax, ← can be used for a unidirectional synonym definition\r\npattern Baz ← Foo\r\n\r\n-- For comparison, a function definition:\r\nfoo :: Int -> Int\r\nfoo x = x + 5\r\n\r\nmain :: IO ()\r\nmain = return ()\r\n```"},"comment":{"url":"https://api.github.com/repos/haskell/haskell-mode/issues/comments/216468167","html_url":"https://github.com/haskell/haskell-mode/issues/1313#issuecomment-216468167","issue_url":"https://api.github.com/repos/haskell/haskell-mode/issues/1313","id":216468167,"user":{"login":"gracjan","id":917978,"avatar_url":"https://avatars.githubusercontent.com/u/917978?v=3","gravatar_id":"","url":"https://api.github.com/users/gracjan","html_url":"https://github.com/gracjan","followers_url":"https://api.github.com/users/gracjan/followers","following_url":"https://api.github.com/users/gracjan/following{/other_user}","gists_url":"https://api.github.com/users/gracjan/gists{/gist_id}","starred_url":"https://api.github.com/users/gracjan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gracjan/subscriptions","organizations_url":"https://api.github.com/users/gracjan/orgs","repos_url":"https://api.github.com/users/gracjan/repos","events_url":"https://api.github.com/users/gracjan/events{/privacy}","received_events_url":"https://api.github.com/users/gracjan/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T08:34:19Z","updated_at":"2016-05-03T08:34:19Z","body":"@taktoa: Can you create some tests that 1) use pattern in keyword position 2) use pattern in non-keyword position?\r\n\r\nMark them as failing with `:expected-result :failed` and then we will wait on somebody that will fix it."}}