add Definitions module
This commit is contained in:
parent
413c454898
commit
44778825c2
5 changed files with 57 additions and 14 deletions
|
@ -15,7 +15,7 @@ import Control.Monad.Identity
|
||||||
infixl 5 :<
|
infixl 5 :<
|
||||||
||| a sequence of bindings under an existing context. each successive element
|
||| a sequence of bindings under an existing context. each successive element
|
||||||
||| has one more bound variable, which correspond to all previous elements
|
||| has one more bound variable, which correspond to all previous elements
|
||||||
||| as well as the global context.
|
||| as well as the surrounding context.
|
||||||
public export
|
public export
|
||||||
data Telescope : (tm : Nat -> Type) -> (from, to : Nat) -> Type where
|
data Telescope : (tm : Nat -> Type) -> (from, to : Nat) -> Type where
|
||||||
Lin : Telescope tm from from
|
Lin : Telescope tm from from
|
||||||
|
@ -26,7 +26,7 @@ public export
|
||||||
Telescope' : (a : Type) -> (from, to : Nat) -> Type
|
Telescope' : (a : Type) -> (from, to : Nat) -> Type
|
||||||
Telescope' a = Telescope (\_ => a)
|
Telescope' a = Telescope (\_ => a)
|
||||||
|
|
||||||
||| a global context is actually just a telescope over no existing bindings
|
||| a top level context is actually just a telescope over no existing bindings
|
||||||
public export
|
public export
|
||||||
Context : (tm : Nat -> Type) -> (len : Nat) -> Type
|
Context : (tm : Nat -> Type) -> (len : Nat) -> Type
|
||||||
Context tm len = Telescope tm 0 len
|
Context tm len = Telescope tm 0 len
|
||||||
|
|
52
lib/Quox/Definition.idr
Normal file
52
lib/Quox/Definition.idr
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
module Quox.Definition
|
||||||
|
|
||||||
|
import public Quox.Syntax
|
||||||
|
import public Data.SortedMap
|
||||||
|
import public Control.Monad.State
|
||||||
|
|
||||||
|
|
||||||
|
public export
|
||||||
|
record AnyTerm where
|
||||||
|
constructor T
|
||||||
|
def : forall d, n. Term d n
|
||||||
|
|
||||||
|
public export
|
||||||
|
record Definition where
|
||||||
|
constructor MkDef'
|
||||||
|
qty : Qty
|
||||||
|
0 qtyGlobal : IsGlobal qty
|
||||||
|
type : AnyTerm
|
||||||
|
term : Maybe AnyTerm
|
||||||
|
|
||||||
|
public export %inline
|
||||||
|
MkDef : (qty : Qty) -> (0 qtyGlobal : IsGlobal qty) =>
|
||||||
|
(type, term : forall d, n. Term d n) -> Definition
|
||||||
|
MkDef {qty, type, term} =
|
||||||
|
MkDef' {qty, qtyGlobal = %search, type = T type, term = Just (T term)}
|
||||||
|
|
||||||
|
public export %inline
|
||||||
|
MkAbstract : (qty : Qty) -> (0 qtyGlobal : IsGlobal qty) =>
|
||||||
|
(type : forall d, n. Term d n) -> Definition
|
||||||
|
MkAbstract {qty, type} =
|
||||||
|
MkDef' {qty, qtyGlobal = %search, type = T type, term = Nothing}
|
||||||
|
|
||||||
|
|
||||||
|
public export %inline
|
||||||
|
(.type0) : Definition -> Term 0 0
|
||||||
|
g.type0 = g.type.def
|
||||||
|
|
||||||
|
public export %inline
|
||||||
|
(.term0) : Definition -> Maybe (Term 0 0)
|
||||||
|
g.term0 = map (\t => t.def) g.term
|
||||||
|
|
||||||
|
public export %inline
|
||||||
|
(.qtyP) : Definition -> Subset Qty IsGlobal
|
||||||
|
g.qtyP = Element g.qty g.qtyGlobal
|
||||||
|
|
||||||
|
public export %inline
|
||||||
|
isZero : Definition -> Bool
|
||||||
|
isZero g = g.qty == Zero
|
||||||
|
|
||||||
|
public export
|
||||||
|
Definitions : Type
|
||||||
|
Definitions = SortedMap Name Definition
|
|
@ -1,6 +1,7 @@
|
||||||
module Quox.Equal
|
module Quox.Equal
|
||||||
|
|
||||||
import public Quox.Syntax
|
import public Quox.Syntax
|
||||||
|
import public Quox.Definition
|
||||||
import Control.Monad.Either
|
import Control.Monad.Either
|
||||||
import Generics.Derive
|
import Generics.Derive
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ module Quox.Typing
|
||||||
import public Quox.Syntax
|
import public Quox.Syntax
|
||||||
import public Quox.Context
|
import public Quox.Context
|
||||||
import public Quox.Equal
|
import public Quox.Equal
|
||||||
|
import public Quox.Definition
|
||||||
|
|
||||||
import Data.Nat
|
import Data.Nat
|
||||||
import public Data.SortedMap
|
import public Data.SortedMap
|
||||||
|
@ -31,18 +32,6 @@ QOutput : Nat -> Type
|
||||||
QOutput = QContext
|
QOutput = QContext
|
||||||
|
|
||||||
|
|
||||||
public export
|
|
||||||
record Global where
|
|
||||||
constructor MkGlobal
|
|
||||||
qty : Qty
|
|
||||||
0 qtyGlobal : IsGlobal qty
|
|
||||||
type, term : forall d, n. Term d n
|
|
||||||
|
|
||||||
public export
|
|
||||||
Globals : Type
|
|
||||||
Globals = SortedMap Name Global
|
|
||||||
|
|
||||||
|
|
||||||
public export
|
public export
|
||||||
record TyContext (d, n : Nat) where
|
record TyContext (d, n : Nat) where
|
||||||
constructor MkTyContext
|
constructor MkTyContext
|
||||||
|
|
|
@ -26,6 +26,7 @@ modules =
|
||||||
Quox.Syntax.Term.Subst,
|
Quox.Syntax.Term.Subst,
|
||||||
Quox.Syntax.Universe,
|
Quox.Syntax.Universe,
|
||||||
Quox.Syntax.Var,
|
Quox.Syntax.Var,
|
||||||
|
Quox.Definition,
|
||||||
Quox.Token,
|
Quox.Token,
|
||||||
Quox.Lexer,
|
Quox.Lexer,
|
||||||
Quox.Parser,
|
Quox.Parser,
|
||||||
|
|
Loading…
Reference in a new issue