Changes between Version 3 and Version 4 of MonadComprehensions


Ignore:
Timestamp:
May 12, 2011 9:53:05 AM (3 years ago)
Author:
nsch
Comment:

some examples

Legend:

Unmodified
Added
Removed
Modified
  • MonadComprehensions

    v3 v4  
    22 
    33Monad comprehensions are currently in development. See ticket #4370. 
     4 
    45== Translation rules == 
    56 
     
    5354}}} 
    5455 
     56=== Examples === 
     57 
     58Some translation examples (using the do notation): 
     59 
     60{{{ 
     61[ x+y | x <- Just 1, y <- Just 2 ] 
     62 
     63=> 
     64 
     65do x <- Just 1 
     66   y <- Just 2 
     67   return (x+y) 
     68}}} 
     69 
     70Transform statements: 
     71 
     72{{{ 
     73[ x | x <- [1..], then take 10 ] 
     74 
     75=> 
     76 
     77take 10 (do 
     78  x <- [1..] 
     79  return x) 
     80}}} 
     81 
     82Grouping statements (note the change of types): 
     83 
     84{{{ 
     85[ (x :: [Int]) | x <- [1,2,1,2], then group by x ] :: [[Int]] 
     86}}} 
     87 
     88Parallel statements: 
     89 
     90{{{ 
     91[ x+y | x <- [1,2,3] 
     92      | y <- [4,5,6] ] 
     93 
     94=> 
     95 
     96do (x,y) <- mzip [1,2,3] [4,5,6] 
     97   return (x+y) 
     98}}} 
     99 
    55100== Implementation details ==