comment "--" ;
comment "{-" "-}" ;
-layout "where", "let", "split", "mutual" ;
+layout "where", "let", "split", "mutual", "with" ;
layout stop "in" ;
-- Do not use layout toplevel as it makes pExp fail!
Let. Exp ::= "let" "{" [Decl] "}" "in" Exp ;
Lam. Exp ::= "\\" [PTele] "->" Exp ;
Path. Exp ::= "<" [AIdent] ">" Exp ;
+Split. Exp ::= "split@" Exp "with" "{" [Branch] "}" ;
Fun. Exp1 ::= Exp2 "->" Exp1 ;
Pi. Exp1 ::= [PTele] "->" Exp1 ;
Sigma. Exp1 ::= [PTele] "*" Exp1 ;
e <- resolveExp t0
es <- mapM resolveExp ts
return $ foldr1 CTT.Pair (e:es)
+ Split t brs -> do
+ t' <- resolveExp t
+ brs' <- mapM resolveBranch brs
+ loc <- getLoc (case brs of
+ OBranch (AIdent (l,_)) _ _:_ -> l
+ PBranch (AIdent (l,_)) _ _ _:_ -> l
+ _ -> (0,0))
+ return $ CTT.Split "" loc t' brs' -- Do we ever use the name?
Let decls e -> do
(rdecls,names) <- resolveDecls decls
mkWheres rdecls <$> local (insertIdents names) (resolveExp e)
;; define several class of keywords
(setq ctt-keywords '("hdata" "data" "import" "mutual" "let" "in" "split"
- "module" "where" "U") )
+ "with" "module" "where" "U") )
(setq ctt-special '("undefined" "primitive"))
;; create regex strings
data N0 =
-efq (A : U) : N0 -> A = split{}
+efq (A : U) : N0 -> A = split {}
neg (A : U) : U = A -> N0
data Unit = tt
-propUnit : prop Unit = rem
- where rem1 : (x:Unit) -> Id Unit x tt = split tt -> refl Unit tt
- rem (x:Unit) : (y:Unit) -> Id Unit x y = split tt -> rem1 x
+propUnit : prop Unit = split
+ tt -> split@((x:Unit) -> Id Unit tt x) with
+ tt -> <i> tt
setUnit : set Unit = propSet Unit propUnit
data or (A B : U) = inl (a : A)
| inr (b : B)
-propOr (A B : U) (hA : prop A) (hB : prop B) (h : A -> neg B) : prop (or A B) = rem
- where
- rem : (a b : or A B) -> Id (or A B) a b = split
- inl a' -> rem1
- where
- rem1 : (b : or A B) -> Id (or A B) (inl a') b = split
+propOr (A B : U) (hA : prop A) (hB : prop B) (h : A -> neg B) : prop (or A B) = split
+ inl a' -> split@((b : or A B) -> Id (or A B) (inl a') b) with
inl b' -> <i> inl (hA a' b' @ i)
inr b' -> efq (Id (or A B) (inl a') (inr b')) (h a' b')
- inr a' -> rem1
- where
- rem1 : (b : or A B) -> Id (or A B) (inr a') b = split
+ inr a' -> split@((b : or A B) -> Id (or A B) (inr a') b) with
inl b' -> efq (Id (or A B) (inr a') (inl b')) (h b' a')
inr b' -> <i> inr (hB a' b' @ i)