Skip to content

Instantly share code, notes, and snippets.

View juanbono's full-sized avatar
:shipit:

Juan Bono juanbono

:shipit:
View GitHub Profile
-- The "Boolean" language from Types and Programming Languages, 3.5
-- Terms of the boolean language
data Term : Set where
true false : Term
if_then_else_ : Term → Term → Term → Term
-- A small-step semantics. Each constructor is a single reduction rule.
data _⟶_ : Term → Term → Set where
e-IfTrue : ∀ {t₂ t₃} → if true then t₂ else t₃ ⟶ t₂
@juanbono
juanbono / Lang.mkdown
Created May 11, 2016 03:10 — forked from mamcx/Lang.mkdown
Lista de recursos sobre crear lenguajes de programacion
@juanbono
juanbono / fix-audio.sh
Created June 27, 2016 17:53 — forked from david-christiansen/fix-audio.sh
How to fix the audio on the current crop of OPLSS videos
#!/bin/bash
for i in *.mp4; do
if [ ! -a "${i%.mp4}-fixed.mp4" ]; then
ffmpeg -i "$i" -vcodec copy -ac 1 "${i%.mp4}-fixed.mp4"
fi
done
@juanbono
juanbono / abt.hs
Created July 4, 2016 10:34 — forked from pchiusano/abt.hs
Simple abstract binding trees implementation in Haskell
-- A port of: http://semantic-domain.blogspot.com/2015/03/abstract-binding-trees.html
{-# LANGUAGE DeriveFunctor #-}
module ABT where
import qualified Data.Foldable as Foldable
import Data.Foldable (Foldable)
import Data.Set (Set)
import qualified Data.Set as Set
module Expr
import Data.Vect
import Data.Fin
data Expr : Nat -> Type where
Var : Fin n -> Expr n
Lam : Expr (S n) -> Expr n
App : Expr n -> Expr n -> Expr n
data Closure : Type where
@juanbono
juanbono / hm_scott.lhs
Created July 4, 2016 10:42 — forked from stelleg/hm_scott.lhs
Hindley Milner + Scott Encoding Musings
Sometimes it would be nice if a type system could automatically "do it's best"
to restrict what a value will be. For example, the type `Bool` is the compiler
saying the value will either be `True` or `False`, but it doesn't know which.
What we want is the compiler to be able to be precise when possible, so instead
of always saying `Bool` (or "I don't know"), it could say `True`, `False`, or
`Bool`. This gist shows how Hindley Milner already has this capability that can
be exercised by using Church or Scott encodings of simple data types.
> {-# LANGUAGE RankNTypes #-}
> import qualified Data.Maybe as M
@juanbono
juanbono / Classical.agda
Created July 10, 2016 18:52 — forked from laMudri/Classical.agda
Double negation embedding
module Classical where
open import Function using (_∘_; case_of_; id; _$_)
open import Data.Product using (_×_; _,_)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Unit using (⊤; tt)
open import Data.Bool
using (Bool; true; false; not; if_then_else_)
renaming (_∨_ to _b∨_; _∧_ to _b∧_)
@juanbono
juanbono / UntypedLambda.agda
Created July 10, 2016 19:02 — forked from gallais/UntypedLambda.agda
Interpreting the untyped lambda calculus in Agda
{-# OPTIONS --copatterns #-}
module UntypedLambda where
open import Size
open import Function
mutual
data Delay (A : Set) (i : Size) : Set where
@juanbono
juanbono / abt
Created July 12, 2016 15:00 — forked from neel-krishnaswami/abt
Abstract binding trees implementation
(* -*- mode: ocaml; -*- *)
module type FUNCTOR = sig
type 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
end
type 'a monoid = {unit : 'a ; join : 'a -> 'a -> 'a}
type var = string