Skip to content

Instantly share code, notes, and snippets.

View copumpkin's full-sized avatar
💭
Mostly unresponsive these days

Daniel Peebles copumpkin

💭
Mostly unresponsive these days
View GitHub Profile
@copumpkin
copumpkin / Collatz.agda
Last active December 23, 2015 14:09
Here's Collatz, as promised. Hole left as exercise for the reader.
module Collatz where
open import Coinduction
open import Data.Nat hiding (_+_; _*_)
open import Data.Fin hiding (_+_; fromℕ; toℕ)
open import Data.Bin hiding (suc)
open import Data.Maybe
open import Data.Product
open import Data.List as List
open import Data.Colist
@copumpkin
copumpkin / Mutable.hs
Last active December 23, 2015 14:09
Mutable buffered Iteratee-like things. Goal is to let me reuse the input "chunks" but to prevent users from hanging onto them and seeing data they shouldn't see. Does it work? You can leak the MVector reference in an existential but then you can't do anything with it, right?
{-# LANGUAGE RankNTypes, BangPatterns #-}
module Mutable where
import Control.Monad
import Control.Monad.ST
import Data.STRef
import Data.Vector.Mutable (MVector)
import qualified Data.Vector.Mutable as MV
-- A read-only view into an MVector or similar
@copumpkin
copumpkin / Lawvere.agda
Last active October 26, 2017 22:53
Lawvere's theorem
module Lawvere where
open import Function.Equality hiding (cong)
open import Function.Surjection
open import Data.Product
open import Relation.Binary.PropositionalEquality
lawvere : {A B : Set} (f : A ↠ (A → B)) (g : B → B) → ∃ λ x → x ≡ g x
lawvere {A} {B} f g = h a , subst (λ r → h a ≡ g r) (cong (λ f → f a) (from-to refl)) refl
where
@copumpkin
copumpkin / Polymorphic.agda
Last active December 22, 2015 10:28
A strongly typed polymorphic lambda calculus
module Polymorphic where
import Level
open Level using (Level; _⊔_)
open import Function
open import Data.Product hiding (map)
open import Data.List hiding (all)
data Index {A : Set} : List A → A → Set where
zero : ∀ {τ Γ} → Index (τ ∷ Γ) τ
@copumpkin
copumpkin / Topology.agda
Last active May 20, 2020 08:00
Topology?
module Topology where
import Level
open import Function
open import Data.Empty
open import Data.Unit
open import Data.Nat hiding (_⊔_)
open import Data.Fin
open import Data.Product
open import Relation.Nullary
@copumpkin
copumpkin / Semidecidable.agda
Last active August 6, 2018 16:21
Semidecidability!
module Semidecidable where
open import Coinduction
open import Function
open import Data.Empty
open import Relation.Nullary
open import Relation.Binary hiding (Rel)
import Relation.Binary.PropositionalEquality as PropEq
open import Category.Monad
@copumpkin
copumpkin / gist:4759099
Last active December 12, 2015 10:29
zipWith/foldr challenge!
-- This is the type we're working with.
data List a = List (forall r. (a -> r -> r) -> r -> r)
-- Implement this signature. It should not be inefficient, so if you're planning
-- on writing something like tail (notoriously inefficient using foldr) on our
-- List type, think again! It should be possible to write with the same time
-- complexity as the original. And of course, converting to/from a conventional
-- list is cheating :)
zipWith :: (a -> b -> c) -> List a -> List b -> List c
@copumpkin
copumpkin / Weird.agda
Last active March 14, 2023 09:32
Work in progress on seemingly impossible Agda, à la Escardó with a Luke Palmer flavor
module Weird where
open import Coinduction
open import Function
open import Data.Empty
open import Data.Product
open import Data.Conat
open import Relation.Nullary
open import Relation.Nullary.Negation
open import Relation.Unary as U
@copumpkin
copumpkin / Telescope.agda
Last active August 22, 2021 04:12
Telescopes?
module Telescope where
open import Function
open import Data.Unit
open import Data.Product
open import Data.Nat
open import Data.Vec
infixr 6 _∷_
@copumpkin
copumpkin / Grothendieck.agda
Last active February 25, 2023 07:16
Grothendieck group
module Grothendieck where
open import Level using (_⊔_)
open import Function
open import Algebra
open import Algebra.Structures
open import Data.Product
import Relation.Binary.EqReasoning as EqReasoning