Skip to content

Instantly share code, notes, and snippets.

@scott-fleischman
scott-fleischman / VecList.agda
Created June 18, 2016 00:24
Extensional equivalence of Lists and Vectors
module VecList where
open import Agda.Builtin.Equality
open import Agda.Builtin.Nat
data List (A : Set) : Set where
[] : List A
_:>_ : A → List A → List A
data Vec (A : Set) : Nat → Set where
@scott-fleischman
scott-fleischman / GreekAccents.agda
Last active June 16, 2016 20:09
Encoding rules of Greek Accents from book by D. A. Carson
{-# OPTIONS --exact-split #-}
-- adapted from Greek Accents by D.A.Carson
module GreekAccents where
data Consonant : Set where
β γ δ ζ θ κ ƛ μ ν ξ π ρ ῥ σ τ φ χ ψ [ : Consonant
data SingleVowel : Set where
α ε η ι ο υ ω : SingleVowel
@scott-fleischman
scott-fleischman / Reify.agda
Last active June 10, 2016 06:30
What if we reify plus and other things normally expressed as functions?
module Reify where
open import Agda.Builtin.Equality
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
module Function where
{-# OPTIONS --type-in-type #-}
-- Taken from http://www.cs.nott.ac.uk/~psztxa/g53cfr/l20.html/l20.html
module _ where
open import Agda.Builtin.Unit
open import Agda.Builtin.Equality
data ⊥ : Set where
@scott-fleischman
scott-fleischman / Curry.agda
Last active May 16, 2016 20:27
Abstract currying in Agda
module Curry where
module And where
data And : Set → Set → Set where
and : (X Y : Set) → X → Y → And X Y
curry
: (X Y Z : Set)
→ (And X Y → Z)
@scott-fleischman
scott-fleischman / Todo.purs
Last active April 27, 2016 16:27
PureScript Todo app
module App.Todo where
import Prelude (const, (+), class Show, class Eq, eq, show, map, ($))
import Data.Array (snoc, filter)
import Pux.CSS (textDecoration, lineThrough, noneTextDecoration, style, TextDecoration, color, rgb)
import Pux.Html (Html, div, input, button, text, ul, li, p, a)
import Pux.Html.Attributes (type_, value, key)
import Pux.Html.Events (onChange, onClick)
data Action
module Set1
open MCPrelude
let fiveRands =
let s0 = mkSeed 1I
let (r1, s1) = rand s0
let (r2, s2) = rand s1
let (r3, s3) = rand s2
let (r4, s4) = rand s3
{-# LANGUAGE MonadComprehensions #-}
{-# LANGUAGE RebindableSyntax #-}
module Set1 where
import MCPrelude
type Gen a = Seed -> (a, Seed)
fiveRands :: [Integer]
@scott-fleischman
scott-fleischman / proof sketch.agda
Last active April 14, 2016 06:53
Applicative List composition law proof sketch
proof
cmp
→ {A : Set la} {B : Set lb} {C : Set lc}
→ (B → C)
→ (A → B)
→ (A → C)
cmp g f x = g (f x)
pure a = a ∷ []