#4370: Bring back monad comprehensions
---------------------------------+------------------------------------------
    Reporter:  simonpj           |        Owner:  nsch        
        Type:  feature request   |       Status:  new         
    Priority:  normal            |    Milestone:  7.2.1       
   Component:  Compiler          |      Version:  6.12.3      
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------

Comment(by nsch):

 Replying to [comment:14 simonpj]:
 > I'm afraid that the `PostTcTable` in `MDoExpr` is misleading. As you'll
 see, it's the ''only'' use of `PostTcTable` and it shouldn't really be
 there.

 I'll get ridd of it. I didn't like it anyway. :)

 > Here you mean "`guard` is looked up '''only''' for monad
 comprehensions", I assume?

 Yes.

 > In other cases, the `guard` field stays as bottom?

 Yes.

 > Actually, on reflection, consider this.
 > {{{
 >   do notation:     do { e ; Q }  -->   e >> do { Q }
 >   monad comp:      [ e | g; Q ]  -->   guard g >> [ e | Q ]
 > }}}
 > Which suggests that you can typecheck the `ExprStmt` of a monad
 comprhension
 > in the above way, and then attach a `SyntaxExpr` of ( (>>) . guard ) to
 the `ExprStmt`.
 > Then you'd only need the one field.  The `(>>)` and `guard` would be
 looked up
 > (they are rebindable) but the compose operation `(.)` is the real built-
 in one,
 > not rebindable.  This would be much neater than having two fields, one
 of which
 > is usually bottom.

 I actually tried that, but I cannot typecheck that `((>>) . guard)`
 function in the typechecker using `tcSyntaxOp` since it results in some
 GHC panic error message on runtime. It's a bit difficult to reproduce
 right now since it requires quite a few changes - but if you think the
 exact error message would be helpful I can get it.

 However, I'm not sure if this is the right way to typecheck this
 expression, but using `tcMonoExpr` is obvisouly wrong and I didn't see any
 other usefull functions.

 > Do you think you could write the documentation first?

 I'll work on that. Thanks for the examples.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4370#comment:15>
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