[GHC] #7828: RebindableSyntax and Arrow

GHC ghc-devs at haskell.org
Fri May 30 09:49:46 UTC 2014


#7828: RebindableSyntax and Arrow
----------------------------------------------+----------------------------
        Reporter:  AlessandroVermeulen        |            Owner:
            Type:  bug                        |  jstolarek
        Priority:  normal                     |           Status:  new
       Component:  Compiler (Type checker)    |        Milestone:  7.10.1
      Resolution:                             |          Version:  7.6.2
Operating System:  Unknown/Multiple           |         Keywords:
 Type of failure:  GHC rejects valid program  |     Architecture:
       Test Case:                             |  Unknown/Multiple
        Blocking:                             |       Difficulty:  Unknown
                                              |       Blocked By:
                                              |  Related Tickets:
----------------------------------------------+----------------------------

Comment (by jstolarek):

 > I think the idea would be that each construct becomes decorated with the
 overloaded operations necessary to desugar it.

 Technically this is simple but I feel the resulting design will be
 inelegant. We use `StmtLR` datatype to represent both the monadic and
 arrow do-notation. This means that desugaring `BindStmt` inside a monadic
 `do` requires calls to `>>=` and `fail`
 ([https://github.com/ghc/ghc/blob/master/compiler/deSugar/DsExpr.lhs#L765
 here]), whereas desugaring the same `BindStmt` inside the arrow `do`
 requires a call to `first`, two different calls to `>>>` and two different
 calls to `arr`
 ([https://github.com/ghc/ghc/blob/master/compiler/deSugar/DsArrows.lhs#L838
 here]). Adding five extra fields to `BindStmt` feels like a lot of
 unnecessary noise. Perhaps creating helper datatypes to store these extra
 identifiers would be better? But then every (or almost every) constructor
 of `StmtLR` would require such extra datatype. I don't yet see a clean
 solution. Augmenting `HsCmd` with this extra information seems relatively
 simple, with `HsCmdCase` being the only tricky case. (It reuses a call to
 `(|||)` in every branch of a case
 ([https://github.com/ghc/ghc/blob/master/compiler/deSugar/DsArrows.lhs#L555
 here]), which means we need to generate a whole list of new identifiers.)

 What do you think about the design I describe above? Is it acceptable?

 Janek

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7828#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list