@@ -64,23 +64,23 @@ binderTy (PVTy t) = t
6464
6565mutual
6666 instance Show SpecialName where
67− show (WhereN i n1 n2) = "(WhereN " ++ show i ++ " " ++
68− show n1 ++ " " ++ show n2 ++ ")"
69− show (WithN i n) = "(WithN " ++ show i ++ " " ++ show n ++ ")"
70− show (InstanceN i ss) = "(InstanceN " ++ show i ++ " " ++ show ss ++ ")"
71− show (ParentN n s) = "(ParentN " ++ show n ++ " " ++ show s ++ ")"
72− show (MethodN n) = "(MethodN " ++ show n ++ ")"
73− show (CaseN n) = "(CaseN " ++ show n ++ ")"
74− show (ElimN n) = "(ElimN " ++ show n ++ ")"
75− show (InstanceCtorN n) = "(InstanceCtorN " ++ show n ++ ")"
76− show (MetaN parent meta) = "(MetaN " ++ show parent ++ " " ++ show meta ++ ")"
67+ showPrec d (WhereN i n1 n2) = showCon d "WhereN" $ showArg i ++
68+ showArg n1 ++ showArg n2
69+ showPrec d (WithN i n) = showCon d "WithN" $ showArg i ++ showArg n
70+ showPrec d (InstanceN i ss) = showCon d "InstanceN" $ showArg i ++ showArg ss
71+ showPrec d (ParentN n s) = showCon d "ParentN" $ showArg n ++ showArg s
72+ showPrec d (MethodN n) = showCon d "MethodN" $ showArg n
73+ showPrec d (CaseN n) = showCon d "CaseN" $ showArg n
74+ showPrec d (ElimN n) = showCon d "ElimN" $ showArg n
75+ showPrec d (InstanceCtorN n) = showCon d "InstanceCtorN" $ showArg n
76+ showPrec d (MetaN parent meta) = showCon d "MetaN" $ showArg parent ++ showArg meta
7777
7878 instance Show TTName where
79− show (UN str) = "(UN " ++ show str ++ ")"
80− show (NS n ns) = "(NS " ++ show n ++ " " ++ show ns ++ ")"
81− show (MN i str) = "(MN " ++ show i ++ " " ++ show str ++ ")"
82− show (SN sn) = "(SN " ++ assert_total (show sn) ++ ")"
83− show NErased = "NErased"
79+ showPrec d (UN str) = showCon d "UN" $ showArg str
80+ showPrec d (NS n ns) = showCon d "NS" $ showArg n ++ showArg ns
81+ showPrec d (MN i str) = showCon d "MN" $ showArg i ++ showArg str
82+ showPrec d (SN sn) = showCon d "SN" $ assert_total (showArg sn)
83+ showPrec d NErased = "NErased"
8484
8585mutual
8686 instance Eq TTName where
@@ -104,28 +104,44 @@ mutual
104104 _ == _ = False
105105
106106instance Show TTUExp where
107− show (UVar i) = "(UVar " ++ show i ++ ")"
108− show (UVal i) = "(UVal " ++ show i ++ ")"
107+ showPrec d (UVar i) = showCon d "UVar" $ showArg i
108+ showPrec d (UVal i) = showCon d "UVal" $ showArg i
109109
110110instance Eq TTUExp where
111111 (UVar i) == (UVar j) = i == j
112112 (UVal i) == (UVal j) = i == j
113113 x == y = False
114114
115+instance Show NativeTy where
116+ show IT8 = "IT8"
117+ show IT16 = "IT16"
118+ show IT32 = "IT32"
119+ show IT64 = "IT64"
120+
121+instance Show IntTy where
122+ showPrec d (ITFixed t) = showCon d "ITFixed" $ showArg t
123+ showPrec d ITNative = "ITNative"
124+ showPrec d ITBig = "ITBig"
125+ showPrec d ITChar = "ITChar"
126+
127+instance Show ArithTy where
128+ showPrec d (ATInt t) = showCon d "ATInt" $ showArg t
129+ showPrec d ATFloat = "ATFloat"
130+
115131instance Show Const where
116− show (I i) = "(I " ++ show i ++ ")"
117− show (BI n) = "(BI " ++ show n ++ ")"
118− show (Fl f) = "(Fl " ++ show f ++ ")"
119− show (Ch c) = "(Ch " ++ show c ++ ")"
120− show (Str str) = "(Str " ++ show str ++ ")"
121− show (B8 b) = "(B8 ...)"
122− show (B16 b) = "(B16 ...)"
123− show (B32 b) = "(B32 ...)"
124− show (B64 b) = "(B64 ...)"
125− show (AType x) = "(AType ...)"
126− show StrType = "StrType"
127− show VoidType = "VoidType"
128− show Forgot = "Forgot"
132+ showPrec d (I i) = showCon d "I" $ showArg i
133+ showPrec d (BI n) = showCon d "BI" $ showArg n
134+ showPrec d (Fl f) = showCon d "Fl" $ showArg f
135+ showPrec d (Ch c) = showCon d "Ch" $ showArg c
136+ showPrec d (Str str) = showCon d "Str" $ showArg str
137+ showPrec d (B8 b) = showCon d "B8" $ showArg b
138+ showPrec d (B16 b) = showCon d "B16" $ showArg b
139+ showPrec d (B32 b) = showCon d "B32" $ showArg b
140+ showPrec d (B64 b) = showCon d "B64" $ showArg b
141+ showPrec d (AType x) = showCon d "AType" $ showArg x
142+ showPrec d StrType = "StrType"
143+ showPrec d VoidType = "VoidType"
144+ showPrec d Forgot = "Forgot"
129145
130146instance Eq NativeTy where
131147 IT8 == IT8 = True
@@ -164,10 +180,10 @@ instance Eq Const where
164180
165181
166182instance Show NameType where
167− show Bound = "Bound"
168− show Ref = "Ref"
169− show (DCon t ar) = "(DCon " ++ show t ++ " " ++ show ar ++ ")"
170− show (TCon t ar) = "(TCon " ++ show t ++ " " ++ show ar ++ ")"
183+ showPrec d Bound = "Bound"
184+ showPrec d Ref = "Ref"
185+ showPrec d (DCon t ar) = showCon d "DCon" $ showArg t ++ showArg ar
186+ showPrec d (TCon t ar) = showCon d "TCon" $ showArg t ++ showArg ar
171187
172188instance Eq NameType where
173189 Bound == Bound = True
@@ -177,15 +193,15 @@ instance Eq NameType where
177193 x == y = False
178194
179195instance (Show a) => Show (Binder a) where
180− show (Lam t) = "(Lam " ++ show t ++ ")"
181− show (Pi t _) = "(Pi " ++ show t ++ ")"
182− show (Let t1 t2) = "(Let " ++ show t1 ++ " " ++ show t2 ++ ")"
183− show (NLet t1 t2) = "(NLet " ++ show t1 ++ " " ++ show t2 ++ ")"
184− show (Hole t) = "(Hole " ++ show t ++ ")"
185− show (GHole t) = "(GHole " ++ show t ++ ")"
186− show (Guess t1 t2) = "(Guess " ++ show t1 ++ " " ++ show t2 ++ ")"
187− show (PVar t) = "(PVar " ++ show t ++ ")"
188− show (PVTy t) = "(PVTy " ++ show t ++ ")"
196+ showPrec d (Lam t) = showCon d "Lam" $ showArg t
197+ showPrec d (Pi t1 t2) = showCon d "Pi" $ showArg t1 ++ showArg t2
198+ showPrec d (Let t1 t2) = showCon d "Let" $ showArg t1 ++ showArg t2
199+ showPrec d (NLet t1 t2) = showCon d "NLet" $ showArg t1 ++ showArg t2
200+ showPrec d (Hole t) = showCon d "Hole" $ showArg t
201+ showPrec d (GHole t) = showCon d "GHole" $ showArg t
202+ showPrec d (Guess t1 t2) = showCon d "Guess" $ showArg t1 ++ showArg t2
203+ showPrec d (PVar t) = showCon d "PVar" $ showArg t
204+ showPrec d (PVTy t) = showCon d "PVTy" $ showArg t
189205
190206instance (Eq a) => Eq (Binder a) where
191207 (Lam t) == (Lam t') = t == t'
@@ -200,17 +216,17 @@ instance (Eq a) => Eq (Binder a) where
200216 x == y = False
201217
202218instance Show TT where
203− show = my_show
204− where %assert_total my_show : TT -> String
205− my_show (P nt n t) = "(P " ++ show nt ++ " " ++ show n ++ " " ++ show t ++ ")"
206− my_show (V i) = "(V " ++ show i ++ ")"
207− my_show (Bind n b t) = "(Bind " ++ show n ++ " " ++ show b ++ " " ++ show t ++ ")"
208− my_show (App t1 t2) = "(App " ++ show t1 ++ " " ++ show t2 ++ ")"
209− my_show (TConst c) = "(TConst " ++ show c ++ ")"
210− my_show (Proj tm i) = "(Proj " ++ show tm ++ " " ++ show i ++ ")"
211− my_show Erased = "Erased"
212− my_show Impossible = "Impossible"
213− my_show (TType u) = "(TType " ++ show u ++ ")"
219+ showPrec = my_show
220+ where %assert_total my_show : Prec -> TT -> String
221+ my_show d (P nt n t) = showCon d "P" $ showArg nt ++ showArg n ++ showArg t
222+ my_show d (V i) = showCon d "V" $ showArg i
223+ my_show d (Bind n b t) = showCon d "Bind" $ showArg n ++ showArg b ++ showArg t
224+ my_show d (App t1 t2) = showCon d "App" $ showArg t1 ++ showArg t2
225+ my_show d (TConst c) = showCon d "TConst" $ showArg c
226+ my_show d (Proj tm i) = showCon d "Proj" $ showArg tm ++ showArg i
227+ my_show d Erased = "Erased"
228+ my_show d Impossible = "Impossible"
229+ my_show d (TType u) = showCon d "TType" $ showArg u
214230
215231instance Eq TT where
216232 a == b = equalp a b
@@ -251,53 +267,53 @@ forget tm = fe [] tm
251267 fe env Impossible = Nothing
252268
253269instance Show Raw where
254− show r = my_show r
255− where %assert_total my_show : Raw -> String
256− my_show (Var n) = "(Var " ++ show n ++ ")"
257− my_show (RBind n b tm) = "(RBind " ++ show n ++ " " ++ show b ++ " " ++ my_show tm ++ ")"
258− my_show (RApp tm tm') = "(RApp " ++ my_show tm ++ " " ++ my_show tm' ++ ")"
259− my_show RType = "RType"
260− my_show (RForce tm) = "(RForce " ++ my_show tm ++ ")"
261− my_show (RConstant c) = "(RConstant " ++ show c ++ ")"
270+ showPrec = my_show
271+ where %assert_total my_show : Prec -> Raw -> String
272+ my_show d (Var n) = showCon d "Var" $ showArg n
273+ my_show d (RBind n b tm) = showCon d "RBind" $ showArg n ++ showArg b ++ " " ++ my_show App tm
274+ my_show d (RApp tm tm') = showCon d "RApp" $ " " ++ my_show App tm ++ " " ++ my_show App tm'
275+ my_show d RType = "RType"
276+ my_show d (RForce tm) = showCon d "RForce" $ " " ++ my_show App tm
277+ my_show d (RConstant c) = showCon d "RConstant" $ showArg c
262278
263279instance Show SourceLocation where
264− show (FileLoc filename line col) = "FileLoc \"" ++ filename ++ "\" " ++ show line ++ " " ++ show col
280+ showPrec d (FileLoc filename line col) = showCon d "FileLoc" $ showArg filename ++ showArg line ++ showArg col
265281
266282instance Show Err where
267− show (Msg x) = "Msg \"" ++ x ++ "\""
268− show (InternalMsg x) = "InternalMsg \"" ++ x ++ "\""
269− show (CantUnify x tm tm' err xs y) = "CantUnify " ++ show x ++
270− " ( " ++ show tm ++ ") (" ++ show tm' ++ ") (" ++ show err ++ ") " ++
271− show xs ++ " " ++ show y
272− show (InfiniteUnify n tm xs) = "InfiniteUnify " ++ show n ++ show tm ++ show xs
273− show (CantConvert tm tm' xs) = "CantConvert " ++ show tm ++ show tm' ++ show xs
274− show (CantSolveGoal tm ctxt) = "CantSolveGoal " ++ show tm ++ " " ++ show ctxt
275− show (UnifyScope n n' tm xs) = "UnifyScope " ++ show n ++ " " ++ show n' ++ " " ++ show tm ++ " " ++ show xs
276− show (CantInferType x) = "CantInferType " ++ show x
277− show (NonFunctionType tm tm') = "NonFunctionType " ++ show tm ++ show tm'
278− show (NotEquality tm tm') = "NotEquality " ++ show tm ++ " " ++ show tm'
279− show (TooManyArguments n) = "TooManyArguments " ++ show n
280− show (CantIntroduce tm) = "CantIntroduce " ++ show tm
281− show (NoSuchVariable n) = "NoSuchVariable " ++ show n
282− show (WithFnType tm) = "WithFnType " ++ show tm
283− show (CantMatch tm) = "CantMatch " ++ show tm
284− show (NoTypeDecl n) = "NoTypeDecl " ++ show n
285− show (NotInjective tm tm' x) = "NotInjective " ++ show tm ++ " " ++ show tm'
286− show (CantResolve tm) = "CantResolve " ++ show tm
287− show (InvalidTCArg n tm) = "InvalidTCName " ++ show n ++ " (" ++ show tm ++ ")"
288− show (CantResolveAlts xs) = "CantResolveAlts " ++ show xs
289− show (IncompleteTerm tm) = "IncompleteTerm " ++ show tm
290− show (NoEliminator s tm) = "NoEliminator " ++ show s ++ " " ++ show tm
291− show UniverseError = "UniverseError"
292− show ProgramLineComment = "ProgramLineComment"
293− show (Inaccessible n) = "Inaccessible " ++ show n
294− show (UnknownImplicit n f) = "UnknownImplicit " ++ show n ++ " " ++ show f
295− show (NonCollapsiblePostulate n) = "NonCollapsiblePostulate " ++ show n
296− show (AlreadyDefined n) = "AlreadyDefined " ++ show n
297− show (ProofSearchFail err) = "ProofSearchFail " ++ show err
298− show (NoRewriting tm) = "NoRewriting " ++ show tm
299− show (ProviderError x) = "ProviderError \"" ++ show x ++ "\""
300− show (LoadingFailed x err) = "LoadingFailed " ++ show x ++ " (" ++ show err ++ ")"
283+ showPrec d (Msg x) = showCon d "Msg" $ showArg x
284+ showPrec d (InternalMsg x) = showCon d "InternalMsg" $ showArg x
285+ showPrec d (CantUnify x tm tm' err xs y) = showCon d "CantUnify" $ showArg x ++
286+ showArg tm ++ showArg tm' ++ showArg err ++
287+ showArg xs ++ showArg y
288+ showPrec d (InfiniteUnify n tm xs) = showCon d "InfiniteUnify" $ showArg n ++ showArg tm ++ showArg xs
289+ showPrec d (CantConvert tm tm' xs) = showCon d "CantConvert" $ showArg tm ++ showArg tm' ++ showArg xs
290+ showPrec d (CantSolveGoal tm ctxt) = showCon d "CantSolveGoal" $ showArg tm ++ showArg ctxt
291+ showPrec d (UnifyScope n n' tm xs) = showCon d "UnifyScope" $ showArg n ++ showArg n' ++ showArg tm ++ showArg xs
292+ showPrec d (CantInferType x) = showCon d "CantInferType" $ showArg x
293+ showPrec d (NonFunctionType tm tm') = showCon d "NonFunctionType" $ showArg tm ++ showArg tm'
294+ showPrec d (NotEquality tm tm') = showCon d "NotEquality" $ showArg tm ++ showArg tm'
295+ showPrec d (TooManyArguments n) = showCon d "TooManyArguments" $ showArg n
296+ showPrec d (CantIntroduce tm) = showCon d "CantIntroduce" $ showArg tm
297+ showPrec d (NoSuchVariable n) = showCon d "NoSuchVariable" $ showArg n
298+ showPrec d (WithFnType tm) = showCon d "WithFnType" $ showArg tm
299+ showPrec d (CantMatch tm) = showCon d "CantMatch" $ showArg tm
300+ showPrec d (NoTypeDecl n) = showCon d "NoTypeDecl" $ showArg n
301+ showPrec d (NotInjective tm tm' x) = showCon d "NotInjective" $ showArg tm ++ showArg tm'
302+ showPrec d (CantResolve tm) = showCon d "CantResolve" $ showArg tm
303+ showPrec d (InvalidTCArg n tm) = showCon d "InvalidTCName" $ showArg n ++ showArg tm
304+ showPrec d (CantResolveAlts xs) = showCon d "CantResolveAlts" $ showArg xs
305+ showPrec d (IncompleteTerm tm) = showCon d "IncompleteTerm" $ showArg tm
306+ showPrec d (NoEliminator s tm) = showCon d "NoEliminator" $ showArg s ++ showArg tm
307+ showPrec d UniverseError = "UniverseError"
308+ showPrec d ProgramLineComment = "ProgramLineComment"
309+ showPrec d (Inaccessible n) = showCon d "Inaccessible" $ showArg n
310+ showPrec d (UnknownImplicit n f) = showCon d "UnknownImplicit" $ showArg n ++ showArg f
311+ showPrec d (NonCollapsiblePostulate n) = showCon d "NonCollapsiblePostulate" $ showArg n
312+ showPrec d (AlreadyDefined n) = showCon d "AlreadyDefined" $ showArg n
313+ showPrec d (ProofSearchFail err) = showCon d "ProofSearchFail" $ showArg err
314+ showPrec d (NoRewriting tm) = showCon d "NoRewriting" $ showArg tm
315+ showPrec d (ProviderError x) = showCon d "ProviderError" $ showArg x
316+ showPrec d (LoadingFailed x err) = showCon d "LoadingFailed" $ showArg x ++ showArg err
301317
302318-------------------------
303319-- Idiom brackets for Raw