Changes between Version 1 and Version 2 of ApplicativeDo
 Timestamp:
 Oct 11, 2013 9:51:03 AM (19 months ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

ApplicativeDo
v1 v2 20 20 2. Applicative syntax can be a bit obscure and hard to write. 21 21 Donotaiton is more natural, so we would like to be able to write 22 Applicative composition in donotation where possible. Do notation 23 can't be desugared into Applicative in general, but a certain 24 subset of it can be. 22 Applicative composition in donotation where possible. For example: 23 {{{ 24 (\x y z > x*y + y*z + z*x) <$> expr1 <*> expr2 <*> expr3 25 }}} 26 vs. 27 {{{ 28 do x < expr1; y < expr2; z < expr3; return $ x*y + y*z + z*x 29 }}} 30 31 3. Donotation can't be desugared into Applicative in general, but a certain 32 subset of it can be. For Applicatives that aren't also Monads, we would still like to 33 be able to use the donotation, albeit with some restrictions, 34 and have an Applicative constraint inferred rather than Monad. 25 35 26 36 Clearly we need Applicative to be a superclass of Monad for this to 27 37 work, hence this can only happen after the AMP changes have landed. 38 39 Since in general Applicative composition might behave differently from monadic bind, any automatic desugaring to Applicative operations would be an optin extension: 40 41 {{{ 42 {# LANGUAGE ApplicativeDo #} 43 }}} 28 44 29 45 == Stage 1 … … 60 76 {{{ 61 77 do 78 .. stmts1 .. 62 79 x < A 63 80 y < B 64 81 z < E[y] 65 .. more..82 .. stmts2 .. 66 83 }}} 67 84 … … 70 87 {{{ 71 88 do 89 .. stmts1 .. 72 90 (x,y) < (,) <$> A <*> B 73 91 z < E[y] 74 .. more..92 .. stmts2 .. 75 93 }}} 76 94