The trap of Bash trap

摘要: When executing a pipe, each command of the pipe is in a separate process from the Bash process. The variable modified by the function is lost. The exit code of the function is also lost, because the exit code of a pipe is the exit code of the last command of the pipe. 阅读全文
posted @ 2019-06-16 00:34 Todd Wei 阅读(1008) 评论(1) 推荐(0) 编辑

Visualizing the Git data model

摘要: This tool is used to generate the object graph of a Git repository. The primary purpose is to help Git learners better understand the Git data model through visualization. 阅读全文
posted @ 2018-05-21 10:24 Todd Wei 阅读(1000) 评论(0) 推荐(0) 编辑

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 阅读(933) 评论(0) 推荐(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 阅读(1746) 评论(0) 推荐(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 阅读(831) 评论(0) 推荐(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 阅读(681) 评论(0) 推荐(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 阅读(1113) 评论(0) 推荐(1) 编辑

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 阅读(802) 评论(0) 推荐(0) 编辑

A Beginner's Guide to Paxos

摘要: The core 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 阅读(1160) 评论(1) 推荐(0) 编辑

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 阅读(2218) 评论(0) 推荐(0) 编辑