Newbie proposal: operator backquoting

Dusty dusty-aquarius at narod.ru
Thu Jun 21 01:14:55 EDT 2007


    Hello, dear list members!
  I'm just a Haskell newbie, but I want to make some proposal to Haskell'.
  There are some tickets in tracking system, that inspired by conflict between binary operators and other use of the same lexeme. At least I found 3 of that: "get rid of unary '-' operator" (http://hackage.haskell.org/trac/haskell-prime/ticket/50), "Eliminate . as an operator" (http://hackage.haskell.org/trac/haskell-prime/ticket/20) and "Replace the array indexing operator, '!'" (http://hackage.haskell.org/trac/haskell-prime/ticket/96).
  IMHO, all specified problems may be made less embarrassing - if not completly solved - if Haskell' have some way to solve lexical ambiguity in concrete position. As for those problems have similar lexical construct (binary operator) on one side - and different construct on other side: so this solution must take place over binary operators.
  I propose to use the same construct, that always used to convert function application to binary operator: backquoting. Any lexeme, bounded by backquotes, will be treated by grammar as binary operator; and no special grammatic case can be applied. So:
('-'1)    is operator section, \x -> x-1,              while  (-1)    is negative number
('-'y)    is operator section, \x -> x-y,              while  (-y)    is unary function application, negate y
foo '-'1  has two arguments, (-) and 1,                while  foo -1  has one argument, -1
F'.'g     is composition of function and constructor,  while  F.g     is qualified function name
('!'x)    is operator section,                         while  !x      is bang pattern (or strictness annotation).
  I think, this proposal does not require neither big changes in Haskell grammar, nor it ruins any existing code.

  Alexander Dakhov.


More information about the Haskell-prime mailing list