Understanding Product and Sum in Category Theory

摘要: Product type guarantees that if you have a function of type Y -> X1 and a function of type Y -> X2, you must have a unique function of type Y -> X1 x X2 satisfying the property. Sum type guarantees that if you have a unique function of type X1 -> Y and a function of type X2 -> Y, you must have a function of type X1 ∐ X2 -> Y satisfying the property.阅读全文
posted @ 2017-12-04 07:32 Todd Wei 阅读(25) 评论(0) 编辑

Converting Recursive Traversal to Iterator

摘要: Introduces a general pattern named Lazy Iterator for converting recursive traversal to iterator. It can be used to simulate generator (the "yield" keyword) in languages like Python.阅读全文
posted @ 2017-11-13 12:31 Todd Wei 阅读(126) 评论(0) 编辑

Monad Explained in One Picture

摘要: The point of Monad is composability. In the green category, T -> Monad and U -> Monad阅读全文
posted @ 2017-05-05 13:00 Todd Wei 阅读(400) 评论(0) 编辑

Stateful Future Transformation

摘要: A general function to transform the future of an initial state to the future of its final state.阅读全文
posted @ 2017-03-13 03:11 Todd Wei 阅读(267) 评论(0) 编辑

Function Composition vs Object Composition

摘要: Functions are born in a harmonious ecosystem. Whenever you write a function, you automatically enjoy compose, functors, monads, monad transformers...阅读全文
posted @ 2017-02-06 14:55 Todd Wei 阅读(331) 评论(0) 编辑

Distributed MVCC Based Cross-row Transaction

摘要: The algorithm for supporting distributed MVCC based multi-row transactions on top of a distributed key-value database with single-row transaction support.阅读全文
posted @ 2016-11-28 15:30 Todd Wei 阅读(246) 评论(0) 编辑

A Beginner's Guide to Paxos

摘要: The code ideas of Paxos protocol: 1) Optimistic concurrency control (variant 2). Hold a "preemptible lock" first, try updating, restart on denial; 2) Quorum as a logical unit of acceptor for choose operation. A value is chosen iff it's accepted by a quorum, which implies from the proposer's perspective the choose operation is atomic, it's all or nothing, it's either accepted by a quorum or it isn't.阅读全文
posted @ 2016-07-07 14:33 Todd Wei 阅读(617) 评论(1) 编辑

Functional Programming without Lambda - Part 2 Lifting, Functor, Monad

摘要: fmap :: (T -> R) -> Functor<T> -> Functor<R> lifts a function of type T -> R into a function of type Functor<T> -> Functor<R>; flatMap :: (T -> Monad<R>) -> Monad<T> -> Monad<R> lifts a function of type T -> Monad<R> into a function of type Monad<T> -> Monad<R>.阅读全文
posted @ 2015-05-30 12:47 Todd Wei 阅读(1359) 评论(0) 编辑

Functional Programming without Lambda - Part 1 Functional Composition

摘要: Functional programming doesn't necessarily depend on Lambda, it's more about the unique way of composing a bunch a small functions into a larger one.阅读全文
posted @ 2015-05-25 13:35 Todd Wei 阅读(1451) 评论(0) 编辑

异常处理原则

摘要: 本文介绍了自己总结的Java异常处理的原理和原则,包括:1.Exception和Error的区别;2.声明异常和未声明异常的区别;3.什么情况下应抛出未声明异常;4.如何捕获和处理其他方法抛出的异常;5.自定义异常应继承Exception还是RuntimeException。阅读全文
posted @ 2014-11-02 09:46 Todd Wei 阅读(6571) 评论(11) 编辑

公告

统计

  • 随笔 - 63
  • 文章 - 43
  • 评论 - 1163