Opened 2 years ago

Closed 22 months ago

#10747 closed bug (fixed)

Infix pattern synonyms fail to parse (regression)

Reported by: heisenbug Owned by: mpickering
Priority: high Milestone: 7.10.3
Component: Compiler (Parser) Version: 7.10.1
Keywords: PatternSynonyms Cc: cactus, mpickering
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: patsyn/should_compile/T10747
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D1295
Wiki Page:

Description (last modified by rwbarton)

{-# LANGUAGE PatternSynonyms #-}
pattern head `Cons` tail = head : tail

In v7.10 I get:

[1 of 1] Compiling Main             ( pat.hs, interpreted )

pat.hs:2:14: parse error on input ?`?

In v7.8 I get:

[1 of 1] Compiling Main             ( ph.hs, interpreted )
Ok, modules loaded: Main.
*Main> :set -XPatternSynonyms
*Main> let h `Cons` t = "ht"
*Main> h
'h'
*Main> t
"t"

Change History (12)

comment:1 Changed 2 years ago by rwbarton

Are you sure about the version numbers? I see it working in 7.8, but failing in 7.10 and HEAD.

comment:2 in reply to:  1 Changed 2 years ago by heisenbug

Replying to rwbarton:

Are you sure about the version numbers? I see it working in 7.8, but failing in 7.10 and HEAD.

Ooops, no. Actually I was using a (self built) ghci-7.9.20141103 for the test. Sorry for the wrong interpolation :-(

Last edited 2 years ago by heisenbug (previous) (diff)

comment:3 Changed 2 years ago by rwbarton

Description: modified (diff)
Priority: normalhigh
Version: 7.117.10.1

comment:4 Changed 23 months ago by thomie

Cc: cactus mpickering added
Component: CompilerCompiler (Parser)
Keywords: PatternSynonyms added
Milestone: 7.10.3

comment:5 Changed 23 months ago by heisenbug

(please disregard, this is a value-level pattern synonym)

Maybe I have to enable TypeOperators too?

<checking...>

No, same error message.

error: parse error on input ?`?
Failed, modules loaded: none.
Last edited 23 months ago by heisenbug (previous) (diff)

comment:6 Changed 23 months ago by mpickering

I'm yet to look at this in detail but I suspect that this was never meant to work. I assumed that infix pattern synonyms definitions were meant to be like infix data constructor definitions.

comment:7 in reply to:  6 Changed 23 months ago by heisenbug

Replying to mpickering:

I'm yet to look at this in detail but I suspect that this was never meant to work. I assumed that infix pattern synonyms definitions were meant to be like infix data constructor definitions.

Then it should work:

$ ghci
GHCi, version 7.11.20150928: http://www.haskell.org/ghc/  :? for help
Prelude> data List a = Nil | a `Cons` List a deriving Show
Prelude> 4 `Cons` Nil
4 `Cons` Nil

This has been working for ages!

comment:8 Changed 23 months ago by mpickering

Owner: set to mpickering

Ok! I will add it to my queue.

comment:9 Changed 23 months ago by mpickering

Differential Rev(s): Phab:D1295

comment:10 Changed 23 months ago by Austin Seipp <austin@…>

In 69a6e425/ghc:

Allow non-operator infix pattern synonyms

For example

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

Reviewed By: goldfire, austin

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

GHC Trac Issues: #10747

comment:11 Changed 22 months ago by thomie

Status: newmerge
Test Case: patsyn/should_compile/T10747

One line fix, should be easy to merge.

comment:12 Changed 22 months ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.