"1.(x: A) → B" instead of "(1.x: A) → B"
also "1.A → B"
This commit is contained in:
parent
ebf6aefb1d
commit
8f0f0c1891
10 changed files with 101 additions and 110 deletions
|
@ -151,31 +151,6 @@ toVect : List a -> (n ** Vect n a)
|
|||
toVect [] = (_ ** [])
|
||||
toVect (x :: xs) = (_ ** x :: snd (toVect xs))
|
||||
|
||||
private
|
||||
0 MakeBinder : Nat -> Type
|
||||
MakeBinder n = (String, PBinderHead n -> PTerm -> PTerm)
|
||||
|
||||
private
|
||||
makePi : MakeBinder 1
|
||||
makePi = ("→", \([pi], x, s) => Pi pi x s)
|
||||
|
||||
private
|
||||
makeSig : MakeBinder 0
|
||||
makeSig = ("×", \([], x, s) => Sig x s)
|
||||
|
||||
private
|
||||
makeBinder : (m ** PBinderHead m) -> (n ** MakeBinder n) -> PTerm ->
|
||||
Grammar False PTerm
|
||||
makeBinder (m ** h) (n ** (str, f)) t =
|
||||
case decEq m n of
|
||||
Yes Refl => pure $ f h t
|
||||
No _ =>
|
||||
let q = if m == 1 then "quantity" else "quantities" in
|
||||
fatalError "'\{str}' expects \{show m} \{q}, got \{show n}"
|
||||
|
||||
private
|
||||
binderInfix : Grammar True (n ** MakeBinder n)
|
||||
binderInfix = symbols [((1 ** makePi), "→"), ((0 ** makeSig), "×")]
|
||||
|
||||
private
|
||||
lamIntro : Grammar True (BName -> PTerm -> PTerm)
|
||||
|
@ -217,7 +192,21 @@ mutual
|
|||
|
||||
private covering
|
||||
bindTerm : Grammar True PTerm
|
||||
bindTerm = join [|makeBinder binderHead binderInfix term|]
|
||||
bindTerm = pi <|> sigma
|
||||
where
|
||||
binderHead = parens {commit = False} [|MkPair bname (resC ":" *> term)|]
|
||||
|
||||
pi, sigma : Grammar True PTerm
|
||||
pi = [|makePi (qty <* res ".") domain (resC "→" *> term)|]
|
||||
where
|
||||
makePi : Three -> (BName, PTerm) -> PTerm -> PTerm
|
||||
makePi q (x, s) t = Pi q x s t
|
||||
domain = binderHead <|> [|(Nothing,) aTerm|]
|
||||
|
||||
sigma = [|makeSigma binderHead (resC "×" *> annTerm)|]
|
||||
where
|
||||
makeSigma : (BName, PTerm) -> PTerm -> PTerm
|
||||
makeSigma (x, s) t = Sig x s t
|
||||
|
||||
private covering
|
||||
annTerm : Grammar True PTerm
|
||||
|
@ -260,14 +249,6 @@ mutual
|
|||
<|> [|Tag tag|]
|
||||
<|> foldr1 Pair <$> parens (commaSep1 term)
|
||||
|
||||
private covering
|
||||
binderHead : Grammar True (n ** PBinderHead n)
|
||||
binderHead = parens {commit = False} $ do
|
||||
qs <- [|toVect qtys|]
|
||||
name <- bname
|
||||
ty <- resC ":" *> term
|
||||
pure (qs.fst ** (qs.snd, name, ty))
|
||||
|
||||
private covering
|
||||
optBinderTerm : Grammar True (BName, PTerm)
|
||||
optBinderTerm = [|MkPair optNameBinder term|]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue