Skip to content

Instantly share code, notes, and snippets.

@CoderPuppy
CoderPuppy / Komi20250302.agda
Last active March 3, 2025 23:13
Proof inspired by a discussion with Komi in the Programming Language Development Discord
module Komi20250302 where
data _≡_ {A : Set} (base : A) : A → Set where
refl : base ≡ base
sym : {A : Set} {x y : A} → x ≡ y → y ≡ x
sym refl = refl
trans : {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z
trans refl p = p
@CoderPuppy
CoderPuppy / mine.lua
Created February 6, 2025 05:33
[CC] Shaft Miner
local FUEL_TARGET = 1024
local FILLER_TARGET = 128
local ignore_blocks = {
['minecraft:stone'] = true;
['minecraft:cobblestone'] = true;
-- ['minecraft:andesite'] = true;
-- ['minecraft:diorite'] = true;
-- ['minecraft:granite'] = true;
-- ['minecraft:dirt'] = true;
['minecraft:deepslate'] = true;
@CoderPuppy
CoderPuppy / sway-config
Created December 7, 2024 16:16
Sway issue 2024-12-07: Lost all input devices
set $HOME /home/cpup
set $GUIX $HOME/.guix-profile
output eDP-1 {
mode 2880x1800@60Hz
scale 1.5
pos 1920 0
}
output "Hewlett Packard HP LP2475w CNC0510PV3" {
@CoderPuppy
CoderPuppy / PHOAS.agda
Created July 11, 2023 11:17
Variant of Parametric Higher-Order Abstract Syntax where each binder binds a type.
{-# OPTIONS --overlapping-instances --instance-search-depth=10 #-}
module PHOAS where
open import Agda.Primitive
record Weakening1 {ℓ₁} {ℓ₂} (V : Set ℓ₁) (V' : Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where
field weaken : V → V'
record Weakening {ℓ₁} {ℓ₂} (V : Set ℓ₁) (V' : Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where
field weaken : V → V'
@CoderPuppy
CoderPuppy / Berardi.agda
Created July 21, 2022 01:15
Berardi's paradox in Agda
{-# OPTIONS --without-K #-}
module Berardi where
-- proof irrelevance from impredicativity and excluded middle
-- adapted from https://www.cs.princeton.edu/courses/archive/fall07/cos595/stdlib/html/Coq.Logic.Berardi.html
open import Agda.Primitive
{-# NO_UNIVERSE_CHECK #-}
@CoderPuppy
CoderPuppy / CoquandPaulin.agda
Created July 20, 2022 02:46
Formalization of paradox from Coquand and Paulin '88 in Agda
{-# OPTIONS --without-K #-}
module CoquandPaulin where
-- contradiction from non-strictly-positive type and impredicative sigma
-- possibly also "strong elimination", whatever that is
-- and impredicative identity
-- adapted from https://vilhelms.github.io/posts/why-must-inductive-types-be-strictly-positive/
-- originally from Inductively Defined Types by Thierry Coquand and Christine Paulin
@CoderPuppy
CoderPuppy / Hurkens.agda
Created July 18, 2022 16:03
Hurkens' paradox in Agda using Impredicativity
module Hurkens where
-- derived from https://github.com/agda/agda/blob/5d30d8e7a25dfced02edefd82699f1f7b6f79316/test/Succeed/Hurkens.agda
-- adapted to use impredicativity instead of --type-in-type
data ⊥ : Set where
{-# NO_UNIVERSE_CHECK #-}
record Impred₁ (A : Set₂) (B : A → Set₁) : Set₁ where
field at : (a : A) → B a
@CoderPuppy
CoderPuppy / Hemem.hs
Created April 18, 2021 02:14
Writing Hindley-Milner from memory for the first time
{-# OPTIONS_GHC -Wno-tabs #-}
{-# LANGUAGE ImportQualifiedPost, LambdaCase, BlockArguments #-}
module Hemem where
-- roughly Hindley-Milner type inference
-- my first implementation
-- in 1½ hours with no reference
-- just things I pulled from memory (of reading articles about HM)
-- missing an occurs check
@CoderPuppy
CoderPuppy / inv-test.lua
Last active February 5, 2021 04:17
ComputerCraft Inventory System
local I = dofile 'cc/mining/inventory.lua'
xpcall(function()
dofile 'cc/mining/inventory-ui.lua' (I)
end, function(err)
if err == 'Terminated' then return end
sleep(3)
term.setTextColor(colors.red)
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1, 1)
@CoderPuppy
CoderPuppy / tunneler.lua
Last active January 31, 2021 18:03
ComputerCraft Tunneler
local fill_i
local fill_left = 0
local function place_fill(f)
if fill_left <= 0 then
local is = {}
for i = 1, 16 do
local d = turtle.getItemDetail(i)
if d then
is[d.name] = is[d.name] or i
end