Type operators in GHC

Brent Yorgey byorgey at seas.upenn.edu
Wed Jan 18 16:42:38 CET 2012

On Wed, Jan 18, 2012 at 02:27:21PM +0000, Simon Peyton-Jones wrote:
> Dear GHC users
> As part of beefing up the kind system, we plan to implement the "Type operators" proposal for Haskell Prime
> http://hackage.haskell.org/trac/haskell-prime/wiki/InfixTypeConstructors
> GHC has had type operators for some kind, so you can say
> 	data a :+: b = Left a | Right b
> but you can only do that for operators which start with ":".
> As part of the above wiki page you can see the proposal to broaden this to ALL operators, allowing
> 	data a + b = Left a | Right b
> Although this technically inconsistent the value page (as the wiki page discussed), I think the payoff is huge. (And "A foolish consistency is the hobgoblin of little minds", Emerson)
> This email is (a) to highlight the plan, and (b) to ask about flags.
> Our preferred approach is to *change* what -XTypeOperators does, to
> allow type operators that do not start with :.  But that will mean
> that *some* (strange) programs will stop working. The only example I
> have seen in tc192 of GHC's test suite

This is not actually that strange.  Lots of code that works with
arrows uses type variables like (~>) or similar, and to have to change
to (b `arr` c) instead of (b ~> c) would be annoying.  For example,
check out the 'netwire' package:


I'm not sure at this point which way I would lean on the issue.
Having infix type constructors that don't have to start with : is
something I would like, too.  But I just thought I would point out
that code like tc192 is not as esoteric as you seem to think.

I do agree, however, that letting things like (~>) be EITHER type
constructors OR type variables depending on what is in scope is out of
the question: it's non-compositional and makes the parser's job quite


More information about the Glasgow-haskell-users mailing list