Skip to content

Instantly share code, notes, and snippets.

View TOTBWF's full-sized avatar

Reed Mullanix TOTBWF

View GitHub Profile
@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
--
@TOTBWF
TOTBWF / IOHCC.hs
Last active July 21, 2021 00:41
My submission for the International Obfuscated Haskell Code Competetion
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ImpredicativeTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module IOHCC where
import Unsafe.Coerce
u = unsafeCoerce
@TOTBWF
TOTBWF / Categories.hs
Last active April 21, 2021 06:06
A Tenative Category Heirarchy
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
@TOTBWF
TOTBWF / DayOne.agda
Created December 20, 2020 01:53
A formally verified implementation of Day One of the 2020 Advent of Code
module DayOne where
-- Lets build this up from scratch, for didactic purposes.
-- If we were doing this "for real" we ought to use agda-stdlib.
--------------------------------------------------------------------------------
-- Basic Definitions
--------------------------------------------------------------------------------
-- First, natural numbers and lists. Nothing too exciting here.
@TOTBWF
TOTBWF / Fixpoint.agda
Last active April 28, 2025 05:14
Agda proof of the Knaster-Tarski Fixpoint Theorem
-- A proof of the Knaster-Tarski Fixpoint Theorem
-- See https://en.wikipedia.org/wiki/Knaster%E2%80%93Tarski_theorem
module Fixpoint where
open import Level
open import Data.Product
open import Relation.Binary
open import Relation.Binary.Morphism
@TOTBWF
TOTBWF / Regex.agda
Created December 2, 2020 16:25
Brzozowski Derivatives in Agda
-- Regexes via Brzozowski derivatives
{-# OPTIONS --without-K --safe #-}
module Regex where
open import Function
open import Data.Char
open import Data.Char.Properties renaming (_≟_ to _≟ᶜ_)
open import Data.String using (toList)
open import Data.Bool
@TOTBWF
TOTBWF / HigherCategories.agda
Created August 23, 2020 07:11
Some stuff from "Higher Operads, Higher Categories"
{-# OPTIONS --without-K --safe #-}
-- Some stuff from "Higher Operads, Higher Categories"
-- https://arxiv.org/abs/math/0305049
module MultiCategory where
open import Level
open import Data.Product using (Σ; _×_; _,_; proj₁; proj₂; uncurry)
open import Categories.Category
open import Categories.Bicategory
@TOTBWF
TOTBWF / TypeFamilyDrama.hs
Created August 21, 2020 01:32
A weird case where destructuring a tuple causes type errors
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilyDependencies #-}
module Lib where
import Data.Functor.Const
type family NonInjective env a = result | result -> env where
NonInjective env (a -> r) = [env] -> NonInjective env r
NonInjective env a = [env]
@TOTBWF
TOTBWF / Pullback.hs
Created May 14, 2020 01:08
Pullbacks in (dependent) haskell
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoStarIsType #-}
{-# LANGUAGE GADTs #-}
module Pullbacks where
@TOTBWF
TOTBWF / HProfunctor.hs
Created September 23, 2019 22:25
Higher Profunctors
type (~>) f g = forall x. f x -> g x
class HProfunctor (p :: (* -> *) -> (* -> *) -> * -> *) where
hdimap :: (f ~> g) -> (h ~> i) -> p g h ~> p f i
instance HProfunctor Ran where
hdimap fg hi r = Ran $ \k -> hi $ runRan r (fg . k)
instance HProfunctor Lan where
hdimap fg hi (Lan gbx h) = Lan (gbx . fg) (hi h)