Changes between Version 4 and Version 5 of MonadComprehensions


Ignore:
Timestamp:
May 12, 2011 10:09:05 AM (4 years ago)
Author:
nsch
Comment:

translation for grouping & first implementation details

Legend:

Unmodified
Added
Removed
Modified
  • MonadComprehensions

    v4 v5  
    5656=== Examples ===
    5757
    58 Some translation examples (using the do notation):
     58Some translation examples using the do notation to avoid things like pattern matching failures are:
    5959
    6060{{{
    6161[ x+y | x <- Just 1, y <- Just 2 ]
    6262
    63 =>
    64 
     63-- translates to:
    6564do x <- Just 1
    6665   y <- Just 2
     
    7372[ x | x <- [1..], then take 10 ]
    7473
    75 =>
    76 
     74-- translates to:
    7775take 10 (do
    7876  x <- [1..]
     
    8482{{{
    8583[ (x :: [Int]) | x <- [1,2,1,2], then group by x ] :: [[Int]]
     84
     85-- translates to:
     86do x <- mgroupWith (\x -> x) [1,2,1,2]
     87   return x
    8688}}}
    8789
     
    9294      | y <- [4,5,6] ]
    9395
    94 =>
    95 
     96-- translates to:
    9697do (x,y) <- mzip [1,2,3] [4,5,6]
    9798   return (x+y)
    9899}}}
    99100
     101Note that the actual implementation is **not** using the *do*-Notation
     102
    100103== Implementation details ==
     104
     105Monad comprehensions had to change the `StmtLR` data type in the `hsSyn/HsExpr.lhs` file in order to be able to lookup and store all functions required to desugare monad comprehensions correctly (e.g. `return`, `(>>=)`, `guard` etc). Renaming is done in `rename/RnExpr.lhs` and typechecking in `typecheck/TcMatches.lhs`. The main desugaring is done in `deSugar/DsListComp.lhs`. If you want to start hacking on monad comprehensions I'd look at those files first.
     106
     107Some things you might want to be aware of:
     108
     109[todo]