Skip to content

Instantly share code, notes, and snippets.

View tiye's full-sized avatar
💭
Make Cirru great again!

题叶 tiye

💭
Make Cirru great again!
View GitHub Profile

Haskell Monoid(幺半群)的介绍

为什么程序员应该关心 Monoids?因为 Monoids 是一种在编程中反复出现的常见模式。当模式出现时,我们可以将它们抽象化并利用我们过去所做的工作。这使我们能够在经过验证的稳定代码之上快速开发解决方案。

将"可交换性"添加到 Monoid(Commutative Monoid),你就有了可以并行执行的东西。随着摩尔定律的终结,并行计算是我们提高处理速度的唯一希望。

以下是我在学习 Monoids 后学到的。它未必完整,但希望能够对于向人们介绍 Monoids 有所帮助。

Monoid 谱系

@tiye
tiye / defonce.clj
Created July 25, 2016 04:19 — forked from cemerick/defonce.clj
`defonce` for ClojureScript
(ns whatever.cljs
(:require [cljs.compiler :refer (munge)])
(:refer-clojure :exclude (munge defonce)))
(defmacro defonce
[vname expr]
(let [ns (-> &env :ns :name name munge)
mname (munge (str vname))]
`(when-not (.hasOwnProperty ~(symbol "js" ns) ~mname)
(def ~vname ~expr))))
@tiye
tiye / W.lhs.md
Created September 1, 2015 01:31 — forked from paf31/W.lhs
Algorithm W

Principal type-schemes for functional programs

Luis Damas and Robin Milner, POPL '82

module W where

import Data.List
import Data.Maybe
import Data.Function