Skip to content

Instantly share code, notes, and snippets.

View CAIMEOX's full-sized avatar
💭
🎲

CAIMEO CAIMEOX

💭
🎲
View GitHub Profile
@hirrolot
hirrolot / CoC.ml
Last active August 30, 2025 01:15
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@Trebor-Huang
Trebor-Huang / freeCCC.agda
Last active August 12, 2025 08:46
Defines STLC as the free CCC over the base type in Agda directly with HITs. Proves canonicity directly by induction.
{-# OPTIONS --cubical --no-import-sorts --postfix-projections -W ignore #-}
module freeCCC where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Unit using (Unit; isPropUnit; isSetUnit)
open import Cubical.Data.Bool using (Bool; true; false; if_then_else_; isSetBool)
open import Cubical.Data.Sum using (_⊎_; inr; inl)
open import Cubical.Data.Sigma using (Σ; _×_; ΣPathP)
@dogles
dogles / markovjr_tech_notes.md
Last active May 21, 2025 20:43
Markov Jr. Technical Notes

Introduction

Markov Jr. is an open source C# application that creates procedural content primarily via applying Markov rewrite rules to a 2D or 3D grid. A rewrite rule has an input and output pattern, which essentially specifies what pattern to look for in the existing grid, and what to replace it with.

For example, given a 2D grid, this would replace any white dot with a white cross:

***/*W*/*** :: *W*/WWW/*W*

The left hand side is the rule input, and the right hand side is the output. The / character is used to delimit rows, and space is used to delimit Z-layers (in 3D grids). The input rule above translates to the 2D pattern:

@mb64
mb64 / hm_with_kinds.ml
Created February 13, 2022 00:16
Hindley-Milner type checking with higher-kinded types, in OCaml
type name = string
module AST = struct
type ty =
| TFun of ty * ty
| TNamed of string
| TApp of ty * ty
type exp =
| Annot of exp * ty
@yangzhixuan
yangzhixuan / FastApp.hs
Last active February 14, 2025 13:09
Efficient Free Applicatives/Monads from Okasaki's Functional Data Structures, with an application to fast substitution-based lambda normalising
{-# LANGUAGE GADTs, RankNTypes, TypeOperators, ScopedTypeVariables, KindSignatures #-}
module FastApp where
import Prelude hiding (head, tail)
import Control.Applicative
-- Chris Okasaki invented many cool and efficient functional data structures
-- in his book Purely Functional Data Structures.
-- Among them, one is catenable lists supporting amortised O(1)-time |(++)|,
@nyuichi
nyuichi / 90-min-scc.scm
Created July 31, 2011 10:36
The 90 Minute Scheme to C Compiler
#!/usr/local/Gambit-C/bin/gsi
; Copyright (C) 2004 by Marc Feeley, All Rights Reserved.
; This is the "90 minute Scheme to C compiler" presented at the
; Montreal Scheme/Lisp User Group on October 20, 2004.
; Usage with Gambit-C 4.0:
;
; % ./90-min-scc.scm test.scm