Skip to content

Instantly share code, notes, and snippets.

@scott-fleischman
scott-fleischman / AgdaFromNothing.agda
Created January 11, 2017 20:26
Agda from Nothing: Order in the Types - Run through
module AgdaFromNothing where
data Bool : Set where
true : Bool
false : Bool
not : Bool -> Bool
not true = false
not false = true
module _ where
-- from McBride (2014) How to Keep Your Neighbours in Order
data 𝟘 : Set where
record 𝟙 : Set where
constructor <>
record Σ (A : Set) (B : A → Set) : Set where
constructor _,_
@scott-fleischman
scott-fleischman / Greek Scans.md
Last active November 23, 2016 19:01
Ancient Greek Scans
@scott-fleischman
scott-fleischman / AppApp.agda
Last active October 6, 2016 06:40
Experiments with applicative traversals
module _ where
open import Agda.Builtin.List
infixl 6 _++_
_++_ : {A : Set} → (xs ys : List A) → List A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ xs ++ ys
infixr 6 _+_
@scott-fleischman
scott-fleischman / RecordEta.agda
Created September 26, 2016 19:05
Agda record eta equality
module RecordEta where
open import Agda.Builtin.Equality
module Eta where
record Pair (A B : Set) : Set where
constructor pair
field
fst : A
snd : B
@scott-fleischman
scott-fleischman / EqualityFunction.agda
Created July 21, 2016 23:00
Ways to introduce equality of functions
module _ where
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
id1 : (f : Bool → Bool) → f ≡ f
id1 f = refl
f : Bool → Bool
f true = false
@scott-fleischman
scott-fleischman / ToFromNeg.agda
Created July 21, 2016 20:43
To/from with negation
module _ where
open import Agda.Builtin.Equality
data ⊥ : Set where
⊥-elim : {A : Set} → ⊥ → A
⊥-elim ()
data A : Set where
a1 a2 a3 : A
@scott-fleischman
scott-fleischman / NotEqualProofs.agda
Created July 21, 2016 20:10
Simple proofs involving negation
module _ where
data A : Set where
a1 a2 a3 : A
open import Agda.Builtin.Equality
data ⊥ : Set where
gen-neq : a1 ≡ a2 → ⊥
gen-neq ()
@scott-fleischman
scott-fleischman / Neighbor.agda
Created June 29, 2016 17:09
BST with explicit proof from "Keeping your neighbours in order"
{-# OPTIONS --exact-split #-}
module Neighbor where
data 𝟘 : Set where
open import Agda.Builtin.Unit renaming (⊤ to 𝟙)
infixr 5 _×_ _,_
record Sg (A : Set) (B : A → Set) : Set where
constructor _,_
@scott-fleischman
scott-fleischman / List.agda
Created June 29, 2016 15:13
Lists with min and max length
module List where
open import Agda.Builtin.List
open import Agda.Builtin.Nat
data ListLength (A : Set) : Nat → Set where
[] : ListLength A zero
_∷_ : (x : A) → {n : Nat} → (xs : ListLength A n) → ListLength A (suc n)
data Fin : Nat → Set where