[GHC] #7828: RebindableSyntax and Arrow
GHC
ghc-devs at haskell.org
Thu May 29 13:27:43 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 have spent some time on this today and I have some questions. As I
understand Simon's comment the idea is to handle the arrow do-notation
similarly to the monadic do-notation. Looking at the handling of monadic
bind I see that indeed each `BindStmt` stores a unique call to `>>=` and
`fail`. These are
[https://github.com/ghc/ghc/blob/master/compiler/rename/RnExpr.lhs#L681
generated in the renamer] and then
[https://github.com/ghc/ghc/blob/master/compiler/deSugar/DsExpr.lhs#L775
converted to explicit lambda by the desugarer]. For arrow operations -
`arr`, `(>>>)`, `first` and possibly `loop`, `(|||)` and `app` -
[https://github.com/ghc/ghc/blob/master/compiler/rename/RnExpr.lhs#L416
renamer creates a shared table of names].
[https://github.com/ghc/ghc/blob/master/compiler/deSugar/DsArrows.lhs#L69
Desugarer creates a command environment] that contains identifiers that
are shared by all desugared expressions. This basicaly rephrases what
Simon wrote. Now I have reached a point where I'm not sure what to do. For
monads calls to bind are introduced only (?) when we encounter `BindStmt`.
For arrows it is not that simple. For example calls to `>>>` are
introduced when we desugar `BodyStmt`, `BindStmt` and `RecStmt` but also
by
[https://github.com/ghc/ghc/blob/master/compiler/deSugar/DsArrows.lhs#L94
`do_compose`], which does not correspond to any particular source
construct but is called in many places of arrow notation desugarer.
Another place where we introduce `>>>` is
[https://github.com/ghc/ghc/blob/master/compiler/deSugar/DsArrows.lhs#L1038
desugaring of CmdLStmt]. I might be wrong, but it seems to me that adding
`SyntaxExpr` to `HsCmd` constructors won't help us here. We need a way of
generating fresh calls to desugared arrow operations out of thin air.
I also don't understand why is arrow notation
[https://github.com/ghc/ghc/blob/master/compiler/rename/RnExpr.lhs#L803
considered not rebindable]? The comment suggests that this is because
!DsArrows performs a separate desugaring of arrow notation. Am I right to
think that after this change is implemented arrow notation will be marked
as rebindable?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7828#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list