Skip to content

Instantly share code, notes, and snippets.

View gallais's full-sized avatar

G. Allais gallais

View GitHub Profile
{-# 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
@gallais
gallais / Agda.Utils.TypeLevel.hs
Created May 14, 2017 23:15
Type level functions for Agda's Utils library
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- We need undecidable instances for the definition of @Foldr@,
-- and @Domains@ and @CoDomain@ using @If@ for instance.
@gallais
gallais / swapVar.agda
Last active May 12, 2017 13:42
swapping variables
module Subst1 where
open import Term
infixl 20 _-_
_-_ : {σ : Ty} → (Γ : Con) → Var Γ σ → Con
ε - ()
(Γ , σ) - vz = Γ
(Γ , τ) - vs x = (Γ - x) , τ
@gallais
gallais / DefaultArgument.agda
Created May 9, 2017 09:24
Default named arguments
record Default {ℓ} (A : Set ℓ) (a : A) : Set ℓ where
constructor _!
field value : A
instance
default : ∀ {ℓ} {A : Set ℓ} a → Default A a
default a = record { value = a }
open import Agda.Builtin.Nat
open List
let bind (xs : 'a list) (f : 'a -> 'b list) : 'b list =
concat (map f xs)
let rec parts : 'a list -> 'a list list list = function
| [] -> [[]]
| [c] -> [[[c]]]
| c :: cs ->
bind (parts cs) (fun (p :: ps) ->
@gallais
gallais / Compiled-252.agda
Created March 3, 2017 16:08
New COMPILE pragmas in Agda
module Compiled-252 where
data U : Set where
z : U
s : U → U
{-# IMPORT Compiled.URaw #-}
{-# COMPILED_DATA U Compiled.URaw.U Compiled.URaw.Z Compiled.URaw.S #-}
@gallais
gallais / ModularParser3.hs
Last active March 1, 2017 00:43
Trying to see what Ptival's Modular Parser would look like for mutually defined types of expressions
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
module ModularParser3 where
import Data.Function
@gallais
gallais / ModularParser2.hs
Last active March 1, 2017 00:41
Trying to see what Ptival's Modular Parser would look like for mutually defined types of expressions
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}