摘要: 在haskell中,我们有语法糖‘do’帮助表达monad运算。scala中我们也有相应语法糖‘for’。 for表达式会被scala compiler做一些变换,简单的例子如下: for { a foo.flatMap((a) => { bar.map((b) => { a + b }) }) 所以我们需要实现两个方法 flatMap和map。 还是用前面的state m... 阅读全文
posted @ 2015-03-12 13:21 wehu 阅读(380) 评论(0) 推荐(0) 编辑