Skip to content

Instantly share code, notes, and snippets.

View gallais's full-sized avatar

G. Allais gallais

View GitHub Profile
@gallais
gallais / AllHList.hs
Last active September 12, 2017 17:16
Have fun with All and HList
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_GHC -Wall #-}
module AllHList where
@gallais
gallais / NbeIsASemantics.agda
Last active July 28, 2017 14:23
Nbe Is A Semantics
module NbeIsASemantics where
open import Data.Unit
open import Data.Empty
open import Data.Product
open import Agda.Builtin.List
data Ty : Set where
α : Ty
_⇒_ : Ty → Ty → Ty
open import Data.String
record Print (A : Set) : Set where
field
print : A → String
open Print {{…}} public
mutual
data α : Set where
@gallais
gallais / iotan.v
Created July 23, 2017 18:53
Generalising the statement
Require Import PeanoNat.
Require Import List.
Import ListNotations.
Fixpoint iota (n : nat) : list nat :=
match n with
| 0 => []
| S k => iota k ++ [k]
end.
@gallais
gallais / feq_dec.v
Created July 23, 2017 14:24
Writing a decision procedure for equality on fins
Inductive fin : nat -> Set :=
| F1 : forall {n : nat}, fin (S n)
| FS : forall {n : nat}, fin n -> fin (S n).
Definition C {m : nat} (x : fin (S m)) :=
{ x' | x = FS x' } + { x = F1 }.
Definition case {m : nat} (x : fin (S m)) : C x :=
match x in fin (S n) return { x' | x = FS x' } + { x = F1 } with
| F1 => inright eq_refl
@gallais
gallais / FiniteMap.agda
Last active July 13, 2017 13:37
IntMap
module poc.FiniteMap where
open import Function
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
record _↔_ (A B : Set) : Set where
field push : A → B
pull : B → A
module Accessibility where
data Acc {A : Set} (R : A → A → Set) (a : A) : Set where
step : (∀ b → R b a → Acc R b) → Acc R a
□^ : ∀ {A : Set} (R : A → A → Set) → (A → Set) → (A → Set)
□^ R P a = ∀ b → R b a → P b
[_] : {A : Set} → (A → Set) → Set
[ P ] = ∀ {a} → P a
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ConstraintKinds #-}
import Data.Constraint
import Data.Function
@gallais
gallais / Zippy.agda
Created June 8, 2017 14:21
Structural equality for inductive types
module Zippy where
data Desc : Set₁ where
`σ : (A : Set) (d : A → Desc) → Desc
`r : Desc → Desc
`q : Desc
open import Size
open import Data.Unit
open import Data.Product
@gallais
gallais / Printf.idr
Created May 30, 2017 13:03
towards a working example
module Printf
import Lightyear.Char
import Lightyear.Core
import Lightyear.Combinators
import Lightyear.Strings
%access public export
%default total