Version 2 (modified by simonpj@…, 8 years ago) (diff)


Infix Type Constructors

Brief Explanation

GHC allows type constructors to be infix operators (conops, beginning with :, but not including : itself).

Changes to the syntax may depend on whether CompositionAsDot is adopted, but roughly speaking we add

 qtycon   -> qconid  | ( qconsym )
 qtyconop -> qconsym | ` qconid `

And type gets an extra production:

 type    -> btype qtyconop type

(modulo FixityResolution). Also, there are obvious changes to the grammar for type, data, and newtype declarations.



Add infix type constructors


  • This is a straightforward generalisation, doesn't break any existing code, and improves the consistency of the syntax.



  • Note that classes can be infix too; this is useful.
  • Need to have a way to set the fixity of a type constructor T differently than the data constructor T (or not?).
  • Need to allow infix notation in contexts
    f :: (a :>: b) => bla blah
  • Watch out for code like this (
     infixr 5 `Foo`
     infixr 6 `Bar`
     data a `Foo` b = a `FOO` a `Bar` b
     data a `Bar` b = a `BAR` b