Skip to content

Instantly share code, notes, and snippets.

View TOTBWF's full-sized avatar

Reed Mullanix TOTBWF

View GitHub Profile
@TOTBWF
TOTBWF / day-1.c
Last active December 2, 2022 00:01
Advent of Code 2022 Day 1 with excessive SIMD
#include <fcntl.h>
#include <immintrin.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
uint32_t parse_4_digits(const __m128i input) {
const __m128i char_0 = _mm_set1_epi8('0');
// Normalize the '0' char to actually be 0x00.
@TOTBWF
TOTBWF / 1Lab.Reflection.Duh.agda
Created October 4, 2022 22:42
A simple Agda tactic that just uses the first valid thing in scope.
module 1Lab.Reflection.Duh where
open import 1Lab.Reflection
open import 1Lab.Prelude
open import Data.List
open import Data.Nat
private
try-all : Term → Nat → Telescope → TC Term
try-all goal _ [] = typeError $ strErr "Couldn't find anything!" ∷ []
@TOTBWF
TOTBWF / MicroTT.ml
Last active July 5, 2025 22:58
A simple single-file elaborator for MLTT
(** Core Types *)
module Syntax =
struct
type t =
| Local of int
| Hole of string
| Let of string * t * t
| Lam of string * t
| Ap of t * t
| Pair of t * t
@TOTBWF
TOTBWF / NbE.hs
Created June 4, 2022 17:52
NbE.hs
module NbE where
data Term
= Var Int
-- ^ DeBruijin Indicies (count outwards)
| Lam Term
| App Term Term
| Pair Term Term
| Fst Term
| Snd Term
{-# LANGUAGE TypeApplications #-}
module TwitterProblem where
import Data.SBV
--------------------------------------------------------------------------------
-- Complex Numbers, constructed from Algebraic Reals
data AlgComplex a = AlgComplex { real :: a, imaginary :: a}
@TOTBWF
TOTBWF / CartesianNbE.agda
Last active February 5, 2022 23:24
NbE for Cartesian Categories
{-# OPTIONS --without-K --safe #-}
open import Categories.Category.Core
open import Categories.Category.Cartesian
module Categories.Tactic.Cartesian.Solver {o ℓ e} {𝒞 : Category o ℓ e} (cartesian : Cartesian 𝒞) where
open import Level
open import Categories.Category.BinaryProducts
@TOTBWF
TOTBWF / Operads.agda
Created January 23, 2022 01:34
Colored Operads via Syntactic Categories
{-# OPTIONS --without-K --safe #-}
module Operads where
open import Level
open import Categories.Category.Core
open import Categories.Functor.Core
open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; cong₂; sym)
import Relation.Binary.PropositionalEquality as Eq
{-# OPTIONS --without-K --safe #-}
module InitialAlgebra where
open import Level hiding (zero) renaming (suc to ℓ-suc)
open import Relation.Binary.PropositionalEquality.Core
open import Data.Nat.Base using (ℕ; zero; suc; _+_)
open import Data.List.Base using (List; []; _∷_)
@TOTBWF
TOTBWF / Static.agda
Created December 1, 2021 07:50
Compile Time File Embedding in Agda
{-# OPTIONS --allow-exec #-}
-- Embed a file as a string inside of an agda program.
-- To use this, make sure to add '/bin/cat' to '~/.agda/executables'
module Static where
open import Function
open import Data.Unit
@TOTBWF
TOTBWF / ObfuscatedSKI.hs
Last active February 23, 2023 06:29
A Lambda Expression to SKI Combinator compiler, written entirely using SKI combinators.
This file has been truncated, but you can view the full file.
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE TemplateHaskell #-}
module ObfuscatedSKI where
import Unsafe.Coerce (unsafeCoerce)
--------------------------------------------------------------------------------
-- A Lambda to SKI Combinator Compiler, written entirely using SKI Combinators
--