Opened 6 months ago

Last modified 6 months ago

#16339 merge bug

Cannot put (.) or (!) type operators into an export list

Reported by: RyanGlScott Owned by:
Priority: normal Milestone: 8.8.1
Component: Compiler (Parser) Version: 8.7
Keywords: Cc: int-index
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case: parser/should_compile/T16339
Blocked By: Blocking:
Related Tickets: #15457, #16311 Differential Rev(s): https://gitlab.haskell.org/ghc/ghc/merge_requests/403
Wiki Page:

Description

Thanks to recent work in GHC HEAD, it is now possible to define type operators named (.) and (!):

type (f . g) x = f (g x)
type x ! f = f x

However, I was surprised to discover that it's not possible to put them in an export list! That is to say, this program doesn't parse:

{-# LANGUAGE TypeOperators #-}
module Bug (type (.), type (!)) where

type (f . g) x = f (g x)
type x ! f = f x
$ ~/Software/ghc4/inplace/bin/ghc-stage2 --interactive Bug.hs
GHCi, version 8.7.20190219: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci

Bug.hs:2:19: error: parse error on input ‘.’
  |
2 | module Bug (type (.), type (!)) where
  |                   ^

This problem appears to be specific to the (.) and (!) type operators, since any other type operator will work in its place:

{-# LANGUAGE TypeOperators #-}
module Works (type (&)) where

type (f & g) x = f (g x)

Change History (6)

comment:1 Changed 6 months ago by RyanGlScott

Summary: Cannot put (.) or (!) into an export listCannot put (.) or (!) type operators into an export list

comment:2 Changed 6 months ago by int-index

Bummer. Fix coming.

comment:3 Changed 6 months ago by int-index

Differential Rev(s): https://gitlab.haskell.org/ghc/ghc/merge_requests/403
Status: newpatch

comment:4 Changed 6 months ago by RyanGlScott

Milestone: 8.8.1
Status: patchmerge
Test Case: parser/should_compile/T16339

comment:5 Changed 6 months ago by int-index

Note that the issue is fixed by 2f4af71e73ac3b59f4faba5bf1b25774b1008898 alone, which is why I left e204431e5a5e2fd16da52b04bda2798f16c51344 as a separate commit instead of squashing them together.

Last edited 6 months ago by int-index (previous) (diff)

comment:6 Changed 6 months ago by Marge Bot <ben+marge-bot@…>

In 2f4af71e/ghc:

Dot/bang operators in export lists (Trac #16339)

The dot type operator was handled in the 'tyvarop' parser production, and the
bang type operator in 'tyapp'. However, export lists and role annotations use
'oqtycon', so these type operators could not be exported or assigned roles.

The fix is to handle them in a lower level production, 'tyconsym'.
Note: See TracTickets for help on using tickets.