This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {- | |
| This file demonstrates a technique for making working with de Bruijn-indexed | |
| terms easier that I learnt from the paper /The Linearity Monad/ by Jennifer | |
| Paykin and Steve Zdancewic. After defining well-typed terms `Γ ⊢ τ` using de Bruijn | |
| indices, we define an auxiliary function `lam` that takes in the variable term explicitly: | |
| > lam : {V : Type} {Γ : Cxt V} {τ σ : Ty V} | |
| > → (({Δ : Cxt V} → {{IsExt Δ (Γ , τ)}} → Δ ⊢ τ) | |
| > → (Γ , τ) ⊢ σ) | |
| > → Γ ⊢ τ ⇒ σ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \documentclass{article} | |
| \input{numbering.tex} | |
| \begin{document} | |
| \section{Introduction} | |
| \begin{element} | |
| Hello |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open import Agda.Builtin.Sigma | |
| open import Agda.Builtin.Equality | |
| postulate | |
| funext : ∀ {a b} {A : Set a} {B : A → Set b} → {f g : (x : A) → B x} | |
| → ((x : A) → f x ≡ g x) → f ≡ g | |
| uip : ∀ {a} {A : Set a} {x y : A} → {p q : x ≡ y} → p ≡ q |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \documentclass{article} | |
| \usepackage{amsmath} | |
| %include polycode.fmt | |
| \newenvironment{autohscode}% | |
| {\relax\ifmmode\expandafter\pmboxed\else\expandafter\plainhscode\fi}% | |
| {\relax\ifmmode\expandafter\endpmboxed\else\expandafter\endplainhscode\fi} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE ImpredicativeTypes #-} | |
| {-# LANGUAGE GADTs #-} | |
| data Free f a where | |
| V :: a -> Free f a | |
| O :: f (Free f a) -> Free f a | |
| fold :: Functor f => (a -> c) -> (f c -> c) -> Free f a -> c | |
| fold k alg (V a) = k a | |
| fold k alg (O o) = alg (fmap (fold k alg) o) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE DataKinds, ImpredicativeTypes #-} | |
| -- Clocked guarded corecursion in the style of Atkey and McBride | |
| -- https://bentnib.org/productive.pdf | |
| -------- Library code ----------- | |
| data Clock | |
| newtype Later (k :: Clock) (a :: *) = L a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Control.Monad (foldM) | |
| import Prelude hiding (sum) | |
| import Control.Monad.Random (MonadRandom(getRandom)) | |
| type Pos = Int | |
| data TArray = E | N TArray -- Left subtree | |
| Int -- Data payload (not position!) | |
| Int -- Priority | |
| Int -- Size of the tree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % ---------------------------------------------------------------------- | |
| % Some useful commands when doing highlighting of Agda code in LaTeX. | |
| % ---------------------------------------------------------------------- | |
| \ProvidesPackage{agda} | |
| \RequirePackage{ifxetex, ifluatex, xifthen, xcolor, polytable, etoolbox, | |
| calc, environ, xparse, xkeyval, amsmath} | |
| % https://tex.stackexchange.com/questions/47576/combining-ifxetex-and-ifluatex-with-the-logical-or-operation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (require "reflection.rkt") | |
| ; unit : x -> [x] | |
| (define unit (lambda (x) (cons x '()))) | |
| ; bind : [x] -> (x -> [y]) -> [y] | |
| (define bind (lambda (m f) (apply append (map f m)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE KindSignatures, GADTs, TypeOperators, TypeFamilies, UndecidableInstances #-} | |
| {-# LANGUAGE FlexibleContexts, MultiParamTypeClasses, FlexibleInstances #-} | |
| {-# LANGUAGE ConstraintKinds, DeriveFunctor #-} | |
| import Prelude hiding (Functor) | |
| import qualified Prelude (Functor) | |
| -- This file explores doing category theory in Haskell by implementing | |
| -- Ralf Hinze et al.'s adjoint folds [1]: | |
| -- |
NewerOlder