pretty printing errors
This commit is contained in:
parent
54ba4e237f
commit
32f38238ef
14 changed files with 424 additions and 217 deletions
|
@ -1,8 +1,10 @@
|
|||
module Quox.Syntax.Dim
|
||||
|
||||
import Quox.Name
|
||||
import Quox.Syntax.Var
|
||||
import Quox.Syntax.Subst
|
||||
import Quox.Pretty
|
||||
import Quox.Context
|
||||
|
||||
import Decidable.Equality
|
||||
import Control.Function
|
||||
|
@ -31,29 +33,26 @@ data Dim : Nat -> Type where
|
|||
B : Var d -> Dim d
|
||||
%name Dim.Dim p, q
|
||||
|
||||
private %inline
|
||||
drepr : Dim n -> Either DimConst (Var n)
|
||||
drepr (K k) = Left k
|
||||
drepr (B x) = Right x
|
||||
|
||||
export Eq (Dim n) where (==) = (==) `on` drepr
|
||||
export Ord (Dim n) where compare = compare `on` drepr
|
||||
|
||||
export
|
||||
Show (Dim n) where
|
||||
show (K k) = showCon App "K" $ show k
|
||||
show (B i) = showCon App "B" $ show i
|
||||
%runElab deriveIndexed "Dim" [Eq, Ord, Show]
|
||||
|
||||
export
|
||||
PrettyHL DimConst where
|
||||
prettyM Zero = hl Dim <$> ifUnicode "𝟬" "0"
|
||||
prettyM One = hl Dim <$> ifUnicode "𝟭" "1"
|
||||
prettyM = pure . hl Dim . ends "0" "1"
|
||||
|
||||
export
|
||||
PrettyHL (Dim n) where
|
||||
prettyM (K e) = prettyM e
|
||||
prettyM (B i) = prettyVar DVar DVarErr (!ask).dnames i
|
||||
|
||||
export
|
||||
prettyDim : (dnames : NContext d) -> Dim d -> Doc HL
|
||||
prettyDim dnames p =
|
||||
let env = MakePrettyEnv {
|
||||
dnames = toSnocList' dnames, tnames = [<],
|
||||
unicode = True, prec = Outer
|
||||
} in
|
||||
runReader env $ prettyM p
|
||||
|
||||
|
||||
||| `endsOr l r x e` returns:
|
||||
||| - `l` if `p` is `K Zero`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue