Allow non-operator infix pattern synonyms
authorMatthew Pickering <matthewtpickering@gmail.com>
Thu, 8 Oct 2015 01:36:38 +0000 (20:36 -0500)
committerAustin Seipp <austin@well-typed.com>
Thu, 8 Oct 2015 01:37:08 +0000 (20:37 -0500)
For example

```
pattern head `Cons` tail = head : tail
```

Reviewed By: goldfire, austin

Differential Revision: https://phabricator.haskell.org/D1295

GHC Trac Issues: #10747

compiler/parser/Parser.y
testsuite/tests/patsyn/should_compile/T10747.hs [new file with mode: 0644]
testsuite/tests/patsyn/should_compile/all.T

index 7e7f579..7079a94 100644 (file)
@@ -1148,7 +1148,7 @@ pattern_synonym_decl :: { LHsDecl RdrName }
 
 pattern_synonym_lhs :: { (Located RdrName, HsPatSynDetails (Located RdrName)) }
         : con vars0 { ($1, PrefixPatSyn $2) }
-        | varid consym varid { ($2, InfixPatSyn $1 $3) }
+        | varid conop varid { ($2, InfixPatSyn $1 $3) }
 
 vars0 :: { [Located RdrName] }
         : {- empty -}                 { [] }
diff --git a/testsuite/tests/patsyn/should_compile/T10747.hs b/testsuite/tests/patsyn/should_compile/T10747.hs
new file mode 100644 (file)
index 0000000..b02d8d0
--- /dev/null
@@ -0,0 +1,5 @@
+{-# LANGUAGE PatternSynonyms #-}
+
+module T10747 where
+
+pattern head `Cons` tail = head : tail
index b0776ac..5e86a99 100644 (file)
@@ -24,3 +24,4 @@ test('T9889', normal, compile, [''])
 test('T9867', normal, compile, [''])
 test('T9975a', normal, compile_fail, [''])
 test('T9975b', normal, compile, [''])
+test('T10747', normal, compile, [''])