Skip to content

Instantly share code, notes, and snippets.

@brendanzab
brendanzab / open-interperters.ml
Last active December 31, 2024 14:41
Open interpreters using polymorphic variants and extensible variants.
(** This is a demonstration of implementing interpreters in an extensible way
that offers a partial solution to the expression problem. The idea is that
the language can be extended with more features after the fact, without
altering previous definitions. It also has the benefit of grouping the
related extensions to the syntax and semantic domains together with the
relevant evaluation rules in a per-feature way.
This approach used is similar to the one described by Matthias Blume in
{{:https://www.microsoft.com/en-us/research/video/records-sums-cases-and-exceptions-row-polymorphism-at-work/}
Records, sums, cases, and exceptions: Row-polymorphism at work}.
@AndrasKovacs
AndrasKovacs / TwoStageRegion.md
Last active June 1, 2026 04:09
Lightweight region memory management in a two-stage language
@tttardigrado
tttardigrado / pll.hs
Last active November 24, 2024 08:42
P'' implementation in under 30 lines of Haskell
data P = R | L | Seq P P | Loop P
data Tape = Tape [Int] Int [Int]
empty :: Tape
empty = Tape (repeat 0) 0 (repeat 0)
left :: Tape -> Tape
left (Tape (l:ls) v rs) = Tape ls l (v:rs)
@brendanzab
brendanzab / set.pol
Last active October 16, 2025 11:31
Set interface as a codata type in Polarity (see: https://polarity-lang.github.io)
data Bool { T, F }
data Nat { Z, S(n: Nat) }
def (n1: Nat).eq(n2: Nat): Bool {
Z => n2.match {
Z => T,
S(_) => F,
},
S(n1) => n2.match {