We examine the of function we've seen on a few types and discover it's the Pointed interface. Instead of doing constructor way of Task: const useTask= (x) => new Task((rej, res) => res(x)) We can just say: Task.of("something"); //Task(&quo…
A pointed functor is a functor with an of method class IO { // The value we take for IO is always a function! static of (x) { return new IO(() => x) } constructor (fn) { this.$value = fn; } map (fn) { return new IO(compose(fn, this.$value)) } } What'…
What is applicative functor: the ability to apply functors to each other. For example we have tow functors: Container(2), Container(3) // We can't do this because the numbers are bottled up. add(Container.of(), Container.of()); // NaN We cannot just…
Monads allow you to nest computations. They are a pointed functor that adds mjoin and chain functions to combine other functors. Brian shows a number of code examples of different monads in action. functions: "mjoin", "chain" mjoin: va…
参考文档1 参考文档2 函数式编程术语 高阶函数 Higher-Order Functions 以函数为参数的函数 返回一个函数的函数 函数的元 Arity 比如,一个带有两个参数的函数被称为二元函数 惰性求值 Lazy evaluation 是一种按需求值机制,它会延迟对表达式的求值,直到其需要为止 // 设置一个随机数,需要时,才会计算,每次计算都是一个不同的值 const rand = function*() { while (1 < 2) { yield Math.random() }…
Before we introduce what is Monad, first let's recap what is a pointed functor: A pointed functor is a Functor with .of() method Why pointed Functor is imporant? here OK, now, let's continue to see some code: const mmo = Maybe.of(Maybe.of('nunchucks'…
经过了一段时间的学习,我们了解了一系列泛函数据类型.我们知道,在所有编程语言中,数据类型是支持软件编程的基础.同样,泛函数据类型Foldable,Monoid,Functor,Applicative,Traversable,Monad也是我们将来进入实际泛函编程的必需.在前面对这些数据类型的探讨中我们发现: 1.Monoid的主要用途是在进行折叠(Foldable)算法时对可折叠结构内元素进行函数施用(function application). 2.Functor可以对任何高阶数据类型F[_]…
原文:http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/ Situation You want to develop a RESTful web API for developers that is secure to use, but doesn’t require the complexity of OAuth and takes a simple “pass the cr…
Source: http://ho.ax/posts/2012/02/debugging-the-mac-os-x-kernel-with-vmware-and-gdb/ Source: http://ho.ax/posts/2012/02/vmware-hardware-debugging/ Edit 13 July 2013: I've made a couple of updates to this post to clarify a couple of things and resolv…
reading the "The Typeclassopedia" by Brent Yorgey in Monad.Reader#13 ,and found that "the Functor hierachy" is interdependent of "the Category hierachy" as the Figure.1 shown. And according to the author, ArrowApply == Monad,…