nicer constructors for ASTs
This commit is contained in:
parent
3d9b730803
commit
302de6266e
3 changed files with 98 additions and 83 deletions
|
@ -152,20 +152,48 @@ mutual
|
|||
%name Scoped body
|
||||
%name ScopedBody body
|
||||
|
||||
||| scope which ignores all its binders
|
||||
public export %inline
|
||||
SN : {s : Nat} -> f n -> Scoped s f n
|
||||
SN = S (replicate s "_") . N
|
||||
|
||||
||| scope which uses its binders
|
||||
public export %inline
|
||||
SY : Vect s BaseName -> f (s + n) -> Scoped s f n
|
||||
SY ns = S ns . Y
|
||||
|
||||
||| more convenient Pi
|
||||
public export %inline
|
||||
Pi_ : (qty : q) -> (x : BaseName) ->
|
||||
(arg : Term q d n) -> (res : Term q d (S n)) -> Term q d n
|
||||
Pi_ {qty, x, arg, res} = Pi {qty, arg, res = S [x] $ Y res}
|
||||
|
||||
||| non dependent function type
|
||||
public export %inline
|
||||
Arr : (qty : q) -> (arg, res : Term q d n) -> Term q d n
|
||||
Arr {qty, arg, res} = Pi {qty, arg, res = S ["_"] $ N res}
|
||||
Arr {qty, arg, res} = Pi {qty, arg, res = SN res}
|
||||
|
||||
||| non dependent equality type
|
||||
||| more convenient Sig
|
||||
public export %inline
|
||||
Eq0 : (ty, l, r : Term q d n) -> Term q d n
|
||||
Eq0 {ty, l, r} = Eq {ty = S ["_"] $ N ty, l, r}
|
||||
Sig_ : (x : BaseName) -> (fst : Term q d n) ->
|
||||
(snd : Term q d (S n)) -> Term q d n
|
||||
Sig_ {x, fst, snd} = Sig {fst, snd = S [x] $ Y snd}
|
||||
|
||||
||| non dependent pair type
|
||||
public export %inline
|
||||
And : (fst, snd : Term q d n) -> Term q d n
|
||||
And {fst, snd} = Sig {fst, snd = S ["_"] $ N snd}
|
||||
And {fst, snd} = Sig {fst, snd = SN snd}
|
||||
|
||||
||| more convenient Eq
|
||||
public export %inline
|
||||
Eq_ : (i : BaseName) -> (ty : Term q (S d) n) ->
|
||||
(l, r : Term q d n) -> Term q d n
|
||||
Eq_ {i, ty, l, r} = Eq {ty = S [i] $ Y ty, l, r}
|
||||
|
||||
||| non dependent equality type
|
||||
public export %inline
|
||||
Eq0 : (ty, l, r : Term q d n) -> Term q d n
|
||||
Eq0 {ty, l, r} = Eq {ty = SN ty, l, r}
|
||||
|
||||
||| same as `F` but as a term
|
||||
public export %inline
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue