Changes between Version 4 and Version 5 of FixityResolution


Ignore:
Timestamp:
Jul 8, 2009 9:59:22 AM (6 years ago)
Author:
simonmar@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FixityResolution

    v4 v5  
    1 '''Ticket:''' #30 
     1= Proposal: <name> = 
     2 
     3|| Type    || change || 
     4|| Status  || discussion ||  
     5|| Owner   || [mailto:[email protected] Simon Marlow] || 
     6|| Section || Syntax Reference || 
     7|| Dependencies || || 
     8|| Related      || NegativeSyntax || 
     9 
     10== Compiler support == 
     11 
     12|| GHC   || full (no flag) || 
     13|| nhc98 || full (no flag) || 
     14|| Hugs  || full (no flag) || 
     15|| UHC   || full (no flag) || 
     16|| JHC   || full (no flag) || 
     17|| LHC   || full (no flag) || 
     18 
     19== Summary == 
     20 
     21== Description == 
     22 
     23 
    224 
    325This is a proposal that doesn't affect anything except the presentation of the report, because all Haskell implementations currently do it this way anyway.  There are some legal Haskell programs, according to the report, that aren't accepted by current implementations (see below).  I propose we make the language specification match the implementations. 
    426 
    5 == The Problem == 
     27=== The Problem === 
    628 
    729The Haskell 98 context-free syntax includes fixity resolution as part of the grammar, with a fixed number of fixities ([1..9]), essentially using macro expansion to define the grammar.  Apart from being really ugly, and not corresponding to any known implementation (long ago GHC used a yacc parser formulated like this, but not any more), this gives rise to some constructions that are very hard to parse correctly.  For example, the expression: 
     
    2547As far as I know, no Haskell compiler gets this right.  
    2648 
    27 == The Solution == 
     49=== The Solution === 
    2850 
    2951These constructions rely on the parser being aware of operator fixities during parsing, which is an unreasonable restriction - it's often easier to follow imports after parsing a file, rather than during it. 
     
    3456 
    3557Sample code for resolving fixities is here: [attachment:resolve.hs].  I believe this implements Haskell 98 fixity resolution, without prefix negation (prefix negation could be added, but we might not need to; see NegativeSyntax).  The core of the parser is 12 lines of code, with a few lines of datatype declarations and pretty-printing.  Note that there is no upper limit on precedence levels, but there is a lower limit of zero.  This code could serve as the basis for specifying fixity resolution in the Haskell' report. 
     58 
     59== References == 
     60 
     61 * '''Ticket:''' #30 
     62 * [attachment:resolve.hs] 
     63 
     64== Report Delta == 
     65