#4430: Better support for resolving infix expressions in template haskell
---------------------------------+------------------------------------------
    Reporter:  reinerp           |        Owner:  reinerp     
        Type:  feature request   |       Status:  new         
    Priority:  normal            |    Milestone:              
   Component:  Template Haskell  |      Version:  6.12.3      
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------

Comment(by simonpj):

 Good point.  I've thought about this a bit.  I suggest we use the
 {{{
 data Exp = ...
   | UnresolvedInfixE
        Exp    -- Left
        Exp    -- Operator
        Exp    -- Right
   | Parens Exp
   ...
 }}}
 Reasoning
  * It's simple, direct, and understandable.
  * It is what GHC itself already does
  * It is easy on the chap ''constructing'' the code.  A parser is only
 going to see one infix operator at a time, so building that list of
 operands (the alternative approach) would be awkward.
  * `UnresolvedInfixE` doesn't need to support sections, because `InfixE`
 can do the job.  If you write
 {{{
  InfixE
    Nothing
    op1
    (UnresolvedInfixE e1 op2 e2)
 }}}
 then there should be an error if the fixity of `op1` and `op2` don't
 relate correctly.  To avoid this check, use `Parens`, or `InfixE` for the
 inner constructor.  (Of course the docs should state this.)

 I think that leads to a simple, understandable design.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4430#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to