Skip to content

Instantly share code, notes, and snippets.

View prescod's full-sized avatar

Paul Prescod prescod

View GitHub Profile
@prescod
prescod / todo.roc
Created February 17, 2026 00:55
Todo list app in Roc
app [main!] {
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.20.0/X73hGh05nNTkDHU06FHC0YfFaQB1pimX7gncRcao5mU.tar.br",
weaver: "https://github.com/smores56/weaver/releases/download/0.6.0/4GmRnyE7EFjzv6dDpebJoWWwXV285OMt4ntHIc6qvmY.tar.br",
json: "https://github.com/lukewilliamboswell/roc-json/releases/download/0.13.0/RqendgZw5e1RsQa3kFhgtnMP8efWoqGRsAvubx4-zus.tar.br",
}
import cli.Arg exposing [Arg]
import cli.Stdout
import cli.File
import cli.Utc
@prescod
prescod / mandelbrot_color.bml
Created February 16, 2026 23:42
Color SVG Mandelbrot in BechML
use Core.*;
scale : int := 1000;
xMin : int := Int.sub 0 2500;
xMax : int := 1000;
yMin : int := Int.sub 0 1750;
yMax : int := 1750;
size : int := 256;
cellPx : int := 4;
@prescod
prescod / mandelbrot.bml
Created February 16, 2026 22:49
Mandelbrot Runner in BechML
use Core.*;
scale : int := 1000;
xMin : int := Int.sub 0 2500;
xMax : int := 1000;
yMin : int := Int.sub 0 1750;
yMax : int := 1750;
width : int := 80;
@prescod
prescod / bechml-runner.mjs
Created February 16, 2026 22:20
BechML Runner JS
#!/usr/bin/env node
// BechML runner using WASM module from bechml.github.io
// Requires: Node.js, bechml.wasm and core/ in same directory as this script
// Usage: node bechml-runner.mjs <source.bml>
// Optional: BECHML_WASM_DIR env var overrides location of bechml.wasm and core/
import { readFileSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import { WASI } from 'wasi';

BechML Reference Manual

A quick-reference guide for AI systems learning BechML - a friendly, higher-kinded, modular, functional scripting language.


Overview

BechML is a statically-typed functional programming language with:

  • Higher-kinded types
@prescod
prescod / gist:4a94435bd455b4e60c8831344a6fc5fe
Created February 16, 2026 18:12
Unison toy adventure game
-- Text Adventure Game in Unison
-- A simple dungeon adventure
-- Room identifiers
unique type RoomId = Entrance | DarkHallway | TreasureRoom
-- Command types
unique type Command = North | South | East | West | Look | Help | Quit | Take | Inventory | Unknown
-- Game state
@prescod
prescod / gist:446259a7bfa22e6f72cef5b857e5ecad
Created February 16, 2026 17:38
Snowfakery output for Git Data Model
Blob(id=1, object_id=b729333c959a35b355d0d1374622fdf7a2df773d, type=blob, filename=young.xls, content=Read value moment network peace summer war land. Difficult conference woman poor practice.
Teacher his theory. Film study run staff. Plan voice large about go rather wrong., size=6637)
Blob(id=2, object_id=63d44a371b25ab3234251bf220a5e0fb4976fff6, type=blob, filename=dream.js, content=Develop them car knowledge. Wear interesting something entire.
Start different affect agree pick race building power. In foot white behind hard., size=6605)
Blob(id=3, object_id=20ca5694a1122682123355aa11353694a88285b1, type=blob, filename=develop.tiff, content=Plan travel open seek watch question region. Go project take ground pretty.
Miss cause detail perhaps. Hard plan car laugh bed improve the. Marriage remain discover charge cell kid., size=29753)
Blob(id=4, object_id=c8dd610308d1511cfc81926ac4f71d7e87d43f4c, type=blob, filename=very.ods, content=Size technology on stage force well. Coach people various through safe.
Leader
@prescod
prescod / gist:6ad5b680cb7b9e8b29aa81170d390d31
Created February 16, 2026 17:15
Snowfakery Recipe for Git Data Model
# Snowfakery recipe for Git's core data model
# Generates: Objects (commits, trees, blobs, tags), References, Index entries, and Reflogs
# ============================================
# OBJECTS
# ============================================
# Blob - stores file contents
- object: Blob
count: 20
@prescod
prescod / massive_shuffles.py
Created April 7, 2024 17:55
Massive shuffles
from snowfakery.utils.randomized_range import random_range
countries = ["Canada", "Mexico", "United States", "Japan", "China"] * 1_000_000
def shuffle_sequence(sequence):
indexes = random_range(0, len(sequence))
for index in indexes:
yield sequence[index]
@prescod
prescod / gist:b2ec0f6ee88d0b87662d6cf591a1d40a
Created June 3, 2023 03:58
Pandoc auto-markup attempt
<p>Plug-in coding conventions</p>
<p>To ensure custom plug-ins work well with the core toolkit code and
remain compatible with future releases, the DITA Open Toolkit project
recommends that plug-ins use modern development practices and common
coding patterns.</p>
<p>Best practices</p>
<p>Adhering to certain development practices will properly isolate your
code from that of DITA Open Toolkit. This will make it easier to you to
upgrade to new versions of DITA-OT when they are released.</p>
<ul>