This file contains 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
type Validator<T> = (val: any) => T | Error; | |
type ValidatorExtract<V> = V extends Validator<infer T> ? T : never; | |
type ValidatorMap = { [key: string]: Validator<any> }; | |
const err = (ty: string) => new Error('validate failed: ' + ty); | |
const nullV: Validator<null> = (val: any) => | |
val === null ? val : err('null'); | |
const undefinedV: Validator<undefined> = (val: any) => | |
typeof val === 'undefined' ? val : err('undefined'); |
This file contains 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
data Tm = Var Int | Ann Tm Tm | Abs Tm | App Tm Tm | Pi Tm Tm | Fix Tm | Uni | |
data Clos = Clos Tm Env | |
data Dm = DVar Int | DAbs Clos | DNeutral Int [Dm] | DPi Dm Clos | DFix Clos | DUni | |
type Env = [Dm] | |
capp :: Clos -> Dm -> Dm | |
capp (Clos b e) t = eval (t : e) b | |
vapp :: Dm -> Dm -> Dm | |
vapp a b = |
This file contains 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
module Self where | |
-- core language | |
type Ix = Int | |
data Core | |
= Var Ix | |
| Abs Core | |
| App Core Core | |
| Pi Core Core |
This file contains 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
-- universe polymorphism | |
module UnivPoly where | |
-- core language | |
type Ix = Int | |
data Term | |
= Var Ix | |
| Abs Term | |
| App Term Term |
This file contains 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
{-# OPTIONS --type-in-type #-} | |
open import Agda.Builtin.Unit | |
open import Agda.Builtin.Sigma | |
open import Data.Product | |
data Ty : Set where | |
U : Ty | |
Pi : (A : Set) -> (A -> Ty) -> Ty | |
PiInd : Ty -> Ty |
This file contains 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
{-# OPTIONS --type-in-type #-} | |
open import Agda.Builtin.Unit | |
open import Agda.Builtin.Sigma | |
open import Data.Product | |
data Ind : Set where | |
U : Ind | |
Pi : (A : Set) -> (A -> Ind) -> Ind |
This file contains 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
{-# OPTIONS --type-in-type #-} | |
open import Agda.Builtin.Unit | |
open import Agda.Builtin.Sigma | |
open import Data.Product | |
record Ty : Set where | |
instance constructor U | |
data Ctx : Set where |
This file contains 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
{-# OPTIONS --type-in-type #-} | |
open import Agda.Builtin.Unit | |
open import Agda.Builtin.Sigma | |
open import Data.Product | |
data Ty : Set where | |
U : Ty | |
Pi : (A : Set) -> (A -> Ty) -> Ty |
This file contains 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
{-# OPTIONS --type-in-type #-} | |
open import Agda.Builtin.Unit | |
open import Agda.Builtin.Sigma | |
open import Data.Product | |
data Ix : Set where | |
U : Ix | |
Pi : (A : Set) -> (A -> Ix) -> Ix |
This file contains 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
{-# OPTIONS --type-in-type #-} | |
open import Agda.Builtin.Unit | |
open import Agda.Builtin.Sigma | |
open import Agda.Builtin.Equality | |
open import Data.Product | |
data Ind (I : Set) : Set where | |
U : I -> Ind I | |
Pi : (A : Set) -> (A -> Ind I) -> Ind I |
OlderNewer