don't print empty contexts in errors

This commit is contained in:
rhiannon morris 2023-03-26 16:10:39 +02:00
parent 84e1cc78cc
commit 46e13c8ca2
3 changed files with 16 additions and 3 deletions

View file

@ -218,7 +218,7 @@ unzip3 (tel :< (x, y, z)) =
export
public export
lengthPrf : Telescope _ from to -> (len ** len + from = to)
lengthPrf [<] = (0 ** Refl)
lengthPrf (tel :< _) =
@ -234,6 +234,11 @@ public export %inline
length : Telescope {} -> Nat
length = fst . lengthPrf
public export
null : Telescope _ from to -> Bool
null [<] = True
null _ = False
export
foldl : {0 acc : Nat -> Type} ->

View file

@ -71,6 +71,10 @@ namespace TyContext
empty =
MkTyContext {dctx = new, dnames = [<], tctx = [<], tnames = [<], qtys = [<]}
public export %inline
null : TyContext q d n -> Bool
null ctx = null ctx.dnames && null ctx.tnames
export %inline
extendTyN : Telescope (\n => (q, BaseName, Term q d n)) from to ->
TyContext q d from -> TyContext q d to
@ -158,6 +162,10 @@ namespace EqContext
dassign = [<], dnames = [<], tctx = [<], tnames = [<], qtys = [<]
}
public export %inline
null : EqContext q n -> Bool
null ctx = null ctx.dnames && null ctx.tnames
export %inline
extendTyN : Telescope (\n => (q, BaseName, Term q 0 n)) from to ->
EqContext q from -> EqContext q to

View file

@ -300,12 +300,12 @@ parameters {auto _ : (Eq q, IsQty q, PrettyHL q)} (unicode : Bool)
where
inTContext : TyContext q d n -> Doc HL -> Doc HL
inTContext ctx doc =
if showContext then
if showContext && not (null ctx) then
vsep [sep ["in context", prettyTyContext unicode ctx], doc]
else doc
inEContext : EqContext q n -> Doc HL -> Doc HL
inEContext ctx doc =
if showContext then
if showContext && not (null ctx) then
vsep [sep ["in context", prettyEqContext unicode ctx], doc]
else doc