Cats(1)- 从Free开始,Free cats】的更多相关文章

cats是scala的一个新的函数式编程工具库,其设计原理基本继承了scalaz:大家都是haskell typeclass的scala版实现.当然,cats在scalaz的基础上从实现细节.库组织结构和调用方式上进行了一些优化,所以对用户来说:cats的基础数据类型.数据结构在功能上与scalaz是大致相同的,可能有一些语法上的变化.与scalaz著名抽象.复杂的语法表现形式相比,cats的语法可能更形象.简单直白.在scalaz的学习过程中,我们了解到所谓函数式编程就是monadic Pro…
Training little cats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9613   Accepted: 2296 Description Facer's pet cat just gave birth to a brood of little cats. Having considered the health of those lovely cats, Facer decides to make th…
Training little cats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9299   Accepted: 2230 Description Facer's pet cat just gave birth to a brood of little cats. Having considered the health of those lovely cats, Facer decides to make th…
Training little cats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10737   Accepted: 2563 Description Facer's pet cat just gave birth to a brood of little cats. Having considered the health of those lovely cats, Facer decides to make t…
Training little cats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13488   Accepted: 3335 Description Facer's pet cat just gave birth to a brood of little cats. Having considered the health of those lovely cats, Facer decides to make t…
Training little cats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11787 Accepted: 2892 Description Facer's pet cat just gave birth to a brood of little cats. Having considered the health of those lovely cats, Facer decides to make the c…
Training little cats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11208   Accepted: 2698 Description Facer's pet cat just gave birth to a brood of little cats. Having considered the health of those lovely cats, Facer decides to make t…
Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11496   Accepted: 2815 Description Facer's pet cat just gave birth to a brood of little cats. Having considered the health of those lovely cats, Facer decides to make the cats to do some ex…
在前面的几篇关于Free编程的讨论示范中我们均使用了基础类型的运算结果.但在实际应用中因为需要考虑运算中出现异常的情况,常常会需要到更高阶复杂的运算结果类型如Option.Xor等.因为Monad无法实现组合(monad do not compose),我们如何在for-comprehension中组合这些运算呢?假如在我们上一篇讨论里的示范DSL是这样的: trait Login[+A] case class Authenticate(uid: String, pwd: String) ext…
在上一节我们讨论了通过Coproduct来实现DSL组合:用一些功能简单的基础DSL组合成符合大型多复杂功能应用的DSL.但是我们发现:cats在处理多层递归Coproduct结构时会出现编译问题.再就是Free编程是一个繁复的工作,容易出错,造成编程效率的低下.由于Free编程目前是函数式编程的主要方式(我个人认为),我们必须克服Free编程的效率问题.通过尝试,发现freeK可以作为一个很好的Free编程工具.freeK是个开源的泛函组件库,我们会在这次讨论里用freeK来完成上次讨论中以失…