Skip to content

Instantly share code, notes, and snippets.

@Guest0x0
Guest0x0 / HAMT.ml
Created August 7, 2023 17:30
Hash Array Mapped Trie implementation & benchmark in OCaml
(* HAMT v.s. AVL benchmark.
test for their usage as string map.
usage:
> ocamlopt HAMT.ml -o <executable-name>
> <executable-name> (avl|hamt) (random|ordered) <key-length>
time data of the form:
<tree-size> <add-time> <find-time>
@Guest0x0
Guest0x0 / minimal-MLTT.ml
Last active April 21, 2024 16:59
minimal MLTT implementation step-by-step
(* 这是我(预期,亦或是已经)在 ∞-type càfe summer school 上做的 talk,
"从零教你手把手实现一个 MLTT 类型检查器"
的内容稿。本 talk 计划以现场边讲解边手写代码的方式实现,
所以虽然这份内容稿会尽量尝试还原 talk 的思路和逻辑,
它的内容可能会与实际的 talk 有出入,建议有条件的人直接去听 talk 本身 *)
(* 本次 talk 将会使用 OCaml 来实现一个 MLTT 类型检查器。
你可能不会写 OCaml,但这没有关系。本次 talk 只会使用以下的功能:
@Guest0x0
Guest0x0 / minimal-PM.ml
Last active July 7, 2023 02:19
a minimal pattern matching compiler demo
(* a minimal pattern-matching compiler *)
(* use integer as variable for easy generation *)
type var = int
type typename = string
type constructor = string
type typ =
@Guest0x0
Guest0x0 / ANF-with-joint-point.ml
Created November 18, 2022 12:46
ANF transformation with joint point optimization for branching, using explicit CPS
module Src = struct
type expr =
| Int of int
| Var of string
| Op of string * expr * expr
| Let of string * expr * expr
| If of expr * expr * expr
end
@Guest0x0
Guest0x0 / ANF-with-joint-point.ml
Created November 18, 2022 12:42
ANF transformation with joint point for branching, using higher order reference cell
module Src = struct
type expr =
| Int of int
| Var of string
| Op of string * expr * expr
| Let of string * expr * expr
| If of expr * expr * expr
end