Opened 3 years ago

Closed 3 years ago

#9194 closed bug (duplicate)

Remove magic parsing of (~)

Reported by: goldfire Owned by:
Priority: normal Milestone:
Component: Compiler (Parser) Version: 7.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #10059, #10056 Differential Rev(s):
Wiki Page:

Description

It seems that (~) has magical parsing:

Prelude> :i (~)

<interactive>:1:2: parse error on input ‘~’
Prelude> :k (~)
(~) :: k -> k -> Constraint
Prelude> :i (+)   -- for comparison
class Num a where
  (+) :: a -> a -> a
  ...
  	-- Defined in ‘GHC.Num’
infixl 6 +

Now that type operators do not need to start with a colon, this magic seems unnecessary. The (~) syntax does not need to be wired-in, unless I'm missing something. (The definition of (~) needs to be wired in -- it's just the syntax that doesn't need to be.)

Change History (5)

comment:1 Changed 3 years ago by goldfire

I suppose this means that it should be exported from Prelude and be hidable, available for user definitions, etc.

comment:2 Changed 3 years ago by simonpj

Yes, I suspect that (~) pre-dated -XTypeOperators.

Good idea: I'd be happy if someone did this.

Simon

comment:3 in reply to:  2 Changed 3 years ago by goldfire

Replying to simonpj:

Yes, I suspect that (~) pre-dated -XTypeOperators.

And, crucially, allowing type operators to skip the opening colon.

Your comment does make me think that this change would then require users to specify TypeOperators whenever they use (~). This would be a breaking change that would likely affect a lot of code, and perhaps for little gain. We could just special-case (~) not to require TypeOperators, but is that any better than the status quo?

comment:4 Changed 3 years ago by thomie

Component: CompilerCompiler (Parser)

comment:5 Changed 3 years ago by goldfire

Resolution: duplicate
Status: newclosed

I'm closing this in favor of #10056, which is essentially the same issue and has better comments on the ticket.

Note: See TracTickets for help on using tickets.