50 lines
1.1 KiB
Idris
50 lines
1.1 KiB
Idris
module Quox.Definition
|
|
|
|
import public Quox.Syntax
|
|
import public Data.SortedMap
|
|
import public Control.Monad.State
|
|
|
|
|
|
public export
|
|
record AnyTerm where
|
|
constructor T
|
|
get : forall d, n. Term d n
|
|
|
|
public export
|
|
record Definition where
|
|
constructor MkDef'
|
|
qty : Qty
|
|
type : AnyTerm
|
|
term : Maybe AnyTerm
|
|
{auto 0 qtyGlobal : IsGlobal qty}
|
|
|
|
public export %inline
|
|
mkDef : (qty : Qty) -> (0 _ : IsGlobal qty) =>
|
|
(type, term : forall d, n. Term d n) -> Definition
|
|
mkDef qty type term = MkDef' {qty, type = T type, term = Just (T term)}
|
|
|
|
public export %inline
|
|
mkAbstract : (qty : Qty) -> (0 _ : IsGlobal qty) =>
|
|
(type : forall d, n. Term d n) -> Definition
|
|
mkAbstract qty type = MkDef' {qty, type = T type, term = Nothing}
|
|
|
|
|
|
public export %inline
|
|
(.type0) : Definition -> Term 0 0
|
|
g.type0 = g.type.get
|
|
|
|
public export %inline
|
|
(.term0) : Definition -> Maybe (Term 0 0)
|
|
g.term0 = map (\t => t.get) 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
|