[Haskell-cafe] Re: Editors for Haskell

Simon Marlow simonmarhaskell at gmail.com
Fri Jun 2 07:18:56 EDT 2006


Malcolm Wallace wrote:
> "Brian Hulley" <brianh at metamilk.com> wrote:
> 
> 
>>Thanks for pointing this out. Although there is still a problem with
>>the  fact that var, qvar, qcon etc is in the context free syntax
>>instead of the  lexical syntax so you could write:
>>
>>        2 `    plus      ` 4
>>        (    Prelude.+
>>               {- a comment -} ) 5 6
> 
> 
> You appear to be right.  However, I don't think I have ever seen a piece
> of code that actually used the first form.  People seem to naturally
> place the backticks right next to the variable name.  Should we consider
> the fact that whitespace and comments are permitted between backticks to
> be a bug in the Report?  It certainly feels like it should be a lexical
> issue.

I tend in the other direction: I'd rather see as much as possible pushed 
into the context-free syntax.  The only reason that qualified 
identifiers are in the lexical syntax currently is because of the clash 
with the '.' operator.

I'm not sure I can concisely explain why I think it is better to use the 
context-free syntax than the lexical syntax, but I'll try.  I believe 
the lexical syntax should adhere, as far as possible, to the following rule:

   juxtaposition of lexemes of different classes should not affect
   the lexical interpretation.

in other words, whitespace between different lexemes is irrelevant.  I 
know this rule is violated in many places in the Haskell lexical syntax, 
but at least for me it serves as a guideline for what is tasteful.  For 
example, it rules out `x` as a lexeme, because ` ought to be a reserved 
symbol, and then `x` would be a justaposition of 3 lexemes.  This also 
explains to me why I think many of GHC's syntactic extensions are ugly 
(42#, (#..#), $x, [d|..|], etc.).  However, it's really hard to extend 
the lexical syntax and stick to this rule, especially if you want to add 
brackets.  So you should consider this a rant, nothing more.

Cheers,
	Simon


More information about the Haskell-Cafe mailing list