Skip to content

Instantly share code, notes, and snippets.

View BekaValentine's full-sized avatar

Rebecca Valentine BekaValentine

View GitHub Profile
module Scratch where
postulate
Inf : ∀ {a} (A : Set a) → Set a
delay : ∀ {a} {A : Set a} → A → Inf A
force : ∀ {a} {A : Set a} → Inf A → A
{-# BUILTIN INFINITY Inf #-}
{-# BUILTIN SHARP delay #-}
{-# BUILTIN FLAT force #-}
@BekaValentine
BekaValentine / DelCont.txt
Created February 11, 2016 13:33
a first attempt at a type theory of delimited continuations
The main judgment of this system is the hypothetical judgment
Γ ; K ; S ⊢ M : A true
where @Γ@ is a standard type context, @K@ is a set of in-scope reset points
for the delimited continuations, and @S@ is an optional in-scope shift
indicating what the most recent shift term needs for it's hole type. @K@ and
@S@ are defined as
K ::= e | K, k : A resets B
@BekaValentine
BekaValentine / DelCont.hs
Created February 15, 2016 22:46
A way to interpret delimited continuations in an EDSL
import Control.Monad.Trans.Cont hiding (shift,reset)
import Control.Monad.Trans.Reader
import Control.Monad.Trans.State
:
: D
:
A true
---------- true-proves
D proves A
D proves A
---------- :-Intro
an expression with no metavars we'll call closed, and an expression w/
metavars is open
a substitution S is a for a set of metavars G is a total map from G (or any
superset of G) to closed expressions
given an open expression M with metavars in G (where G might have more than
just the ones in M), and a substitution S for G, [S]M is a closed expression
provability is a concept that applies to closed expressions, ie a closed
module LE where
-- These are the core types used in LE projects
data Entity end
data Background (e : Entity) end
data Nonexistant (e : Entity) end
newtype ChurchNat = ChurchNat { foldNat :: forall r. r -> (r -> r) -> r }
zero :: ChurchNat
zero = ChurchNat (\z _ -> z)
suc :: ChurchNat -> ChurchNat
suc n = ChurchNat (\z s -> s (foldNat n z s))
fromInt :: Int -> ChurchNat
fromInt 0 = zero
data Tm : Nat -> Set where
var : forall {n} -> Fin n -> Tm n
lam : forall {n} -> Tm (suc n) -> Tm n
app : forall {n} -> Tm n -> Tm n -> Tm n
module Scratch where
infixr 60 _*_
infixr 50 _=>_
data Ty : Set where
Zero One : Ty
_*_ _=>_ : Ty → Ty → Ty
infixl 40 _,_
module Scratch where
data Nat : Set where
zero : Nat
suc : Nat → Nat
data Fin : Nat → Set where
fzero : ∀ {n} → Fin (suc n)