Add prettyName

This is to display names in a user friendly way, especially case and
with block names
This commit is contained in:
Edwin Brady 2020-03-18 19:33:19 +00:00
parent fbff80545d
commit 59b66d6134
36 changed files with 81 additions and 63 deletions

View File

@ -475,8 +475,9 @@ export
HasNames Name where
full gam (Resolved i)
= do Just gdef <- lookupCtxtExact (Resolved i) gam
| Nothing => do coreLift $ putStrLn $ "Missing name! " ++ show i
pure (Resolved i)
-- May occasionally happen when working with metadata.
-- It's harmless, so just silently return the resolved name.
| Nothing => pure (Resolved i)
pure (fullname gdef)
full gam n = pure n
@ -1061,6 +1062,23 @@ toResolvedNames t
= do defs <- get Ctxt
resolved (gamma defs) t
-- Make the name look nicer for user display
export
prettyName : {auto c : Ref Ctxt Defs} ->
Name -> Core String
prettyName (Nested i n)
= do i' <- toFullNames (Resolved i)
pure (show !(prettyName i') ++ "," ++
show !(prettyName n))
prettyName (CaseBlock outer idx)
= do outer' <- toFullNames (Resolved outer)
pure ("case block in " ++ !(prettyName outer'))
prettyName (WithBlock outer idx)
= do outer' <- toFullNames (Resolved outer)
pure ("with block in " ++ !(prettyName outer'))
prettyName (NS ns n) = prettyName n
prettyName n = pure (show n)
export
setFlag : {auto c : Ref Ctxt Defs} ->
FC -> Name -> DefFlag -> Core ()

View File

@ -68,16 +68,16 @@ perror (BadDataConType fc n fam)
perror (NotCovering fc n IsCovering)
= pure $ "Internal error (Coverage of " ++ show n ++ ")"
perror (NotCovering fc n (MissingCases cs))
= pure $ show n ++ " is not covering. Missing cases:\n\t" ++
= pure $ !(prettyName n) ++ " is not covering. Missing cases:\n\t" ++
showSep "\n\t" !(traverse (pshow []) cs)
perror (NotCovering fc n (NonCoveringCall ns))
= pure $ show n ++ " is not covering:\n\t" ++
= pure $ !(prettyName n) ++ " is not covering:\n\t" ++
"Calls non covering function"
++ case ns of
[fn] => " " ++ show fn
_ => "s: " ++ showSep ", " (map show ns)
perror (NotTotal fc n r)
= pure $ show n ++ " is not total"
= pure $ !(prettyName n) ++ " is not total"
perror (LinearUsed fc count n)
= pure $ "There are " ++ show count ++ " uses of linear name " ++ sugarName n
perror (LinearMisuse fc n Rig0 ctx)
@ -196,16 +196,16 @@ perror (RewriteNoChange _ env rule ty)
perror (NotRewriteRule fc env rule)
= pure $ !(pshow env rule) ++ " is not a rewrite rule type"
perror (CaseCompile _ n DifferingArgNumbers)
= pure $ "Patterns for " ++ show !(toFullNames n) ++ " have differing numbers of arguments"
= pure $ "Patterns for " ++ !(prettyName n) ++ " have differing numbers of arguments"
perror (CaseCompile _ n DifferingTypes)
= pure $ "Patterns for " ++ show !(toFullNames n) ++ " require matching on different types"
= pure $ "Patterns for " ++ !(prettyName n) ++ " require matching on different types"
perror (CaseCompile _ n UnknownType)
= pure $ "Can't infer type to match in " ++ show !(toFullNames n)
= pure $ "Can't infer type to match in " ++ !(prettyName n)
perror (CaseCompile fc n (NotFullyApplied cn))
= pure $ "Constructor " ++ show !(toFullNames cn) ++ " is not fully applied"
perror (CaseCompile fc n (MatchErased (_ ** (env, tm))))
= pure $ "Attempt to match on erased argument " ++ !(pshow env tm) ++
" in " ++ show !(toFullNames n)
" in " ++ !(prettyName n)
perror (BadDotPattern _ env reason x y)
= pure $ "Can't match on " ++ !(pshow env x) ++
" (" ++ show reason ++ ")"
@ -234,16 +234,16 @@ perror ForceNeeded = pure "Internal error when resolving implicit laziness"
perror (InternalError str) = pure $ "INTERNAL ERROR: " ++ str
perror (InType fc n err)
= pure $ "While processing type of " ++ sugarName !(getFullName n) ++
= pure $ "While processing type of " ++ !(prettyName n) ++
" at " ++ show fc ++ ":\n" ++ !(perror err)
perror (InCon fc n err)
= pure $ "While processing constructor " ++ sugarName !(getFullName n) ++
= pure $ "While processing constructor " ++ !(prettyName n) ++
" at " ++ show fc ++ ":\n" ++ !(perror err)
perror (InLHS fc n err)
= pure $ "While processing left hand side of " ++ sugarName !(getFullName n) ++
= pure $ "While processing left hand side of " ++ !(prettyName n) ++
" at " ++ show fc ++ ":\n" ++ !(perror err)
perror (InRHS fc n err)
= pure $ "While processing right hand side of " ++ sugarName !(getFullName n) ++
= pure $ "While processing right hand side of " ++ !(prettyName n) ++
" at " ++ show fc ++ ":\n" ++ !(perror err)
export

View File

@ -137,7 +137,7 @@ mutual
= toPTerm p (IVar loc n)
toPTerm p (IVar fc n)
= do ns <- fullNamespace
pure (sugarApp (PRef fc (if ns then n else dropNS n)))
pure (sugarApp (PRef fc (if ns then n else UN !(prettyName n))))
toPTerm p (IPi fc rig Implicit n arg ret)
= do imp <- showImplicits
if imp

View File

@ -15,7 +15,7 @@ Main> Main.strangeId':
strangeId' _
Main> Bye for now!
1/1: Building TypeCase2 (TypeCase2.idr)
TypeCase2.idr:5:14--5:17:While processing left hand side of Main.strangeId at TypeCase2.idr:5:1--6:1:
TypeCase2.idr:5:14--5:17:While processing left hand side of strangeId at TypeCase2.idr:5:1--6:1:
Can't match on Nat (Erased argument)
TypeCase2.idr:9:5--9:9:While processing left hand side of Main.foo at TypeCase2.idr:9:1--10:1:
TypeCase2.idr:9:5--9:9:While processing left hand side of foo at TypeCase2.idr:9:1--10:1:
Can't match on Nat (Erased argument)

View File

@ -1,7 +1,7 @@
1/1: Building Ambig1 (Ambig1.idr)
Main> Bye for now!
1/1: Building Ambig2 (Ambig2.idr)
Ambig2.idr:22:21--22:28:While processing right hand side of Main.keepUnique at Ambig2.idr:22:1--24:1:
Ambig2.idr:22:21--22:28:While processing right hand side of keepUnique at Ambig2.idr:22:1--24:1:
Ambiguous elaboration. Possible correct results:
Main.Set.toList ?arg
Main.Vect.toList ?arg

View File

@ -1,8 +1,8 @@
1/1: Building Dots1 (Dots1.idr)
1/1: Building Dots2 (Dots2.idr)
Dots2.idr:2:7--2:9:While processing left hand side of Main.foo at Dots2.idr:2:1--4:1:
Dots2.idr:2:7--2:9:While processing left hand side of foo at Dots2.idr:2:1--4:1:
Can't match on ?x [no locals in scope] (Non linear pattern variable)
1/1: Building Dots3 (Dots3.idr)
Dots3.idr:5:29--5:30:While processing left hand side of Main.addBaz at Dots3.idr:5:1--6:1:
Dots3.idr:5:29--5:30:While processing left hand side of addBaz at Dots3.idr:5:1--6:1:
Pattern variable z unifies with:
?y [no locals in scope]

View File

@ -1,5 +1,5 @@
1/1: Building Rewrite (Rewrite.idr)
Rewrite.idr:15:25--17:1:While processing right hand side of Main.wrongCommutes at Rewrite.idr:15:1--17:1:
Rewrite.idr:15:25--17:1:While processing right hand side of wrongCommutes at Rewrite.idr:15:1--17:1:
Rewriting by m + k = k + m did not change type S k + m = m + S k
Rewrite.idr:19:26--20:1:While processing right hand side of Main.wrongCommutes2 at Rewrite.idr:19:1--20:1:
Rewrite.idr:19:26--20:1:While processing right hand side of wrongCommutes2 at Rewrite.idr:19:1--20:1:
Nat is not a rewrite rule type

View File

@ -1,18 +1,18 @@
1/1: Building Eta (Eta.idr)
Eta.idr:14:10--15:1:While processing right hand side of Main.etaBad at Eta.idr:14:1--15:1:
Eta.idr:14:10--15:1:While processing right hand side of etaBad at Eta.idr:14:1--15:1:
When unifying ?x = ?x and MkTest = \x => (\y => (MkTest ?_ ?_))
Mismatch between:
Integer
and
Nat
1/1: Building Eta2 (Eta2.idr)
Eta2.idr:2:8--4:1:While processing right hand side of Main.test at Eta2.idr:2:1--4:1:
Eta2.idr:2:8--4:1:While processing right hand side of test at Eta2.idr:2:1--4:1:
When unifying ?x = ?x and S = \x => (S ?_)
Mismatch between:
Nat
and
a
Eta2.idr:5:44--6:1:While processing right hand side of Main.test2 at Eta2.idr:5:1--6:1:
Eta2.idr:5:44--6:1:While processing right hand side of test2 at Eta2.idr:5:1--6:1:
When unifying ?x = ?x and S = \x => (S ?_)
Mismatch between:
Nat

View File

@ -1,6 +1,6 @@
1/1: Building CaseInf (CaseInf.idr)
CaseInf.idr:7:24--9:1:While processing right hand side of Main.test3bad at CaseInf.idr:6:1--9:1:
While processing right hand side of Main.case block in 1160(179) at CaseInf.idr:7:14--9:1:
CaseInf.idr:7:24--9:1:While processing right hand side of test3bad at CaseInf.idr:6:1--9:1:
While processing right hand side of case block in test3bad at CaseInf.idr:7:14--9:1:
When unifying Integer and Nat
Mismatch between:
Integer

View File

@ -1,3 +1,3 @@
1/1: Building Fin (Fin.idr)
Fin.idr:33:7--35:1:While processing right hand side of Main.bar at Fin.idr:33:1--35:1:
Fin.idr:33:7--35:1:While processing right hand side of bar at Fin.idr:33:1--35:1:
Can't find an implementation for IsJust (integerToFin 8 (S (assert_total (integerToNat (prim__sub_Integer 5 (fromInteger 1))))))

View File

@ -1,7 +1,7 @@
1/1: Building Erase (Erase.idr)
Erase.idr:5:5--5:11:While processing left hand side of Main.bad at Erase.idr:5:1--6:1:
Erase.idr:5:5--5:11:While processing left hand side of bad at Erase.idr:5:1--6:1:
Can't match on False (Erased argument)
Erase.idr:19:18--19:22:While processing left hand side of Main.minusBad at Erase.idr:19:1--20:1:
Erase.idr:19:18--19:22:While processing left hand side of minusBad at Erase.idr:19:1--20:1:
Can't match on LeZ (Erased argument)
Main> \m => minus (S (S m)) m prf
Main> Bye for now!

View File

@ -1,3 +1,3 @@
1/1: Building arity (arity.idr)
arity.idr:5:16--5:22:While processing right hand side of Main.foo at arity.idr:4:1--7:1:
arity.idr:5:16--5:22:While processing right hand side of foo at arity.idr:4:1--7:1:
Constructor Main.MkN is not fully applied

View File

@ -1,3 +1,3 @@
1/1: Building erased (erased.idr)
erased.idr:7:17--7:21:While processing left hand side of Main.nameOf at erased.idr:7:1--8:1:
erased.idr:7:17--7:21:While processing left hand side of nameOf at erased.idr:7:1--8:1:
Can't match on Bool (Erased argument)

View File

@ -1,5 +1,5 @@
1/1: Building unboundimps (unboundimps.idr)
unboundimps.idr:18:11--18:14:While processing type of Main.len' at unboundimps.idr:18:1--19:1:
unboundimps.idr:18:11--18:14:While processing type of len' at unboundimps.idr:18:1--19:1:
Undefined name xs
unboundimps.idr:19:16--19:18:While processing type of Main.append' at unboundimps.idr:19:1--21:1:
unboundimps.idr:19:16--19:18:While processing type of append' at unboundimps.idr:19:1--21:1:
Undefined name n

View File

@ -1,5 +1,5 @@
1/1: Building lets (lets.idr)
lets.idr:22:39--23:14:While processing right hand side of Main.dolet2 at lets.idr:21:1--26:1:
lets.idr:22:39--23:14:While processing right hand side of dolet2 at lets.idr:21:1--26:1:
When unifying Maybe Int and Maybe String
Mismatch between:
Int

View File

@ -1,5 +1,5 @@
1/1: Building Cover (Cover.idr)
Cover.idr:14:1--14:8:While processing left hand side of Main.badBar at Cover.idr:14:1--15:1:
Cover.idr:14:1--14:8:While processing left hand side of badBar at Cover.idr:14:1--15:1:
Can't match on Z as it has a polymorphic type
Main> Main.foo:
foo (Z, S _)

View File

@ -1,5 +1,5 @@
1/1: Building Cover (Cover.idr)
Cover.idr:12:1--12:5:While processing left hand side of Main.bad at Cover.idr:12:1--13:1:
Cover.idr:12:1--12:5:While processing left hand side of bad at Cover.idr:12:1--13:1:
Can't match on Just (fromInteger 0) as it has a polymorphic type
Main> Main.okay:
okay (S _) IsNat

View File

@ -1,5 +1,5 @@
1/1: Building Error (Error.idr)
Error.idr:6:19--7:1:While processing right hand side of Main.wrong at Error.idr:6:1--7:1:
Error.idr:6:19--7:1:While processing right hand side of wrong at Error.idr:6:1--7:1:
When unifying a and Vect ?k a
Mismatch between:
a

View File

@ -1,3 +1,3 @@
1/1: Building Error (Error.idr)
Error.idr:6:12--6:14:While processing right hand side of Main.wrong at Error.idr:6:1--7:1:
Error.idr:6:12--6:14:While processing right hand side of wrong at Error.idr:6:1--7:1:
Undefined name x

View File

@ -1,5 +1,5 @@
1/1: Building Error (Error.idr)
Error.idr:12:18--13:1:While processing right hand side of Main.wrong at Error.idr:12:1--13:1:
Error.idr:12:18--13:1:While processing right hand side of wrong at Error.idr:12:1--13:1:
Sorry, I can't find any elaboration which works. All errors:
If Main.length: When unifying Nat and Vect ?n ?a
Mismatch between:

View File

@ -1,12 +1,12 @@
1/1: Building Error1 (Error1.idr)
Error1.idr:8:9--9:1:While processing right hand side of Main.wrong at Error1.idr:8:1--9:1:
Error1.idr:8:9--9:1:While processing right hand side of wrong at Error1.idr:8:1--9:1:
Can't find an implementation for Show (Vect (S (S (S (S Z)))) Integer)
1/1: Building Error2 (Error2.idr)
Error2.idr:13:38--15:1:While processing right hand side of Main.show at Error2.idr:13:3--15:1:
Error2.idr:13:38--15:1:While processing right hand side of show at Error2.idr:13:3--15:1:
Multiple solutions found in search. Possible correct results:
Show implementation at Error2.idr:11:1--15:1
Show implementation at Error2.idr:7:1--11:1
Error2.idr:16:9--17:1:While processing right hand side of Main.wrong at Error2.idr:16:1--17:1:
Error2.idr:16:9--17:1:While processing right hand side of wrong at Error2.idr:16:1--17:1:
Multiple solutions found in search. Possible correct results:
Show implementation at Error2.idr:11:1--15:1
Show implementation at Error2.idr:7:1--11:1

View File

@ -1,5 +1,5 @@
1/1: Building IfErr (IfErr.idr)
IfErr.idr:4:11--6:1:While processing right hand side of Main.foo at IfErr.idr:4:1--6:1:
IfErr.idr:4:11--6:1:While processing right hand side of foo at IfErr.idr:4:1--6:1:
Can't find an implementation for Eq a
IfErr.idr:7:11--8:1:While processing right hand side of Main.bar at IfErr.idr:7:1--8:1:
IfErr.idr:7:11--8:1:While processing right hand side of bar at IfErr.idr:7:1--8:1:
Can't find an implementation for Eq Wibble

View File

@ -1,5 +1,5 @@
1/1: Building IfErr (IfErr.idr)
IfErr.idr:15:10--17:1:While processing right hand side of Main.test at IfErr.idr:15:1--17:1:
IfErr.idr:15:10--17:1:While processing right hand side of test at IfErr.idr:15:1--17:1:
Can't find an implementation for Eq Foo
IfErr.idr:23:9--25:1:While processing right hand side of Main.test2 at IfErr.idr:23:1--25:1:
IfErr.idr:23:9--25:1:While processing right hand side of test2 at IfErr.idr:23:1--25:1:
Can't find an implementation for Show Foo

View File

@ -1,5 +1,5 @@
1/1: Building CongErr (CongErr.idr)
CongErr.idr:4:11--5:1:While processing right hand side of Main.fsprf at CongErr.idr:4:1--5:1:
CongErr.idr:4:11--5:1:While processing right hand side of fsprf at CongErr.idr:4:1--5:1:
Can't solve constraint between:
?_ x
and

View File

@ -1,3 +1,3 @@
1/1: Building Loop (Loop.idr)
Loop.idr:2:11--3:1:While processing right hand side of Main.example at Loop.idr:2:1--3:1:
Loop.idr:2:11--3:1:While processing right hand side of example at Loop.idr:2:1--3:1:
Main.example is already defined

View File

@ -1,7 +1,7 @@
1/3: Building Nat (Nat.idr)
2/3: Building Mult (Mult.idr)
3/3: Building Test (Test.idr)
Test.idr:5:9--5:13:While processing type of Test.thing at Test.idr:5:1--6:1:
Test.idr:5:9--5:13:While processing type of thing at Test.idr:5:1--6:1:
Name Nat.Nat is inaccessible since Nat is not explicitly imported
Test.idr:6:1--8:1:No type declaration for Test.thing
Test> Bye for now!

View File

@ -1,3 +1,3 @@
1/1: Building Deps (Deps.idr)
Deps.idr:18:13--19:3:While processing right hand side of Main.badcard at Deps.idr:18:3--19:3:
Deps.idr:18:13--19:3:While processing right hand side of badcard at Deps.idr:18:3--19:3:
k is not accessible in this context

View File

@ -1,3 +1,3 @@
1/1: Building TypeInt (TypeInt.idr)
TypeInt.idr:14:25--14:50:While processing constructor Main.MkRecord at TypeInt.idr:14:3--15:1:
TypeInt.idr:14:25--14:50:While processing constructor MkRecord at TypeInt.idr:14:3--15:1:
Can't find an implementation for Interface ?s

View File

@ -1,11 +1,11 @@
1/1: Building gnu (gnu.idr)
gnu.idr:47:27--49:1:While processing right hand side of Main.TestSurprise1 at gnu.idr:47:1--49:1:
gnu.idr:47:27--49:1:While processing right hand side of TestSurprise1 at gnu.idr:47:1--49:1:
Multiple solutions found in search. Possible correct results:
gnu1
gnu2
gnu.idr:50:21--52:1:While processing right hand side of Main.TestSurprise2 at gnu.idr:50:1--52:1:
gnu.idr:50:21--52:1:While processing right hand side of TestSurprise2 at gnu.idr:50:1--52:1:
Multiple solutions found in search. Possible correct results:
f ()
g ()
gnu.idr:53:19--54:1:While processing right hand side of Main.TestSurprise3 at gnu.idr:53:1--54:1:
gnu.idr:53:19--54:1:While processing right hand side of TestSurprise3 at gnu.idr:53:1--54:1:
Can't find an implementation for Gnu

View File

@ -1,5 +1,5 @@
1/1: Building ZFun (ZFun.idr)
ZFun.idr:13:7--15:1:While processing right hand side of Main.bar at ZFun.idr:13:1--15:1:
ZFun.idr:13:7--15:1:While processing right hand side of bar at ZFun.idr:13:1--15:1:
Main.test is not accessible in this context
Main> [tc] Main> S (S (S (S (S (S (S (S (S (S Z)))))))))
[tc] Main> Bye for now!

View File

@ -1,3 +1,3 @@
1/1: Building LCase (LCase.idr)
LCase.idr:7:11--10:13:While processing right hand side of Main.foo at LCase.idr:6:1--12:1:
LCase.idr:7:11--10:13:While processing right hand side of foo at LCase.idr:6:1--12:1:
There are 0 uses of linear name y

View File

@ -1,4 +1,4 @@
1/1: Building param (param.idr)
1/1: Building parambad (parambad.idr)
parambad.idr:7:7--8:1:While processing right hand side of Main.U at parambad.idr:7:3--8:1:
parambad.idr:7:7--8:1:While processing right hand side of U at parambad.idr:7:3--8:1:
Name Main.X.foo is private

View File

@ -1,10 +1,10 @@
1/1: Building Holes (Holes.idr)
Holes.idr:4:64--4:85:While processing type of Main.Vect_ext at Holes.idr:4:1--7:1:
Holes.idr:4:64--4:85:While processing type of Vect_ext at Holes.idr:4:1--7:1:
Name Builtin.~=~ is inaccessible since Builtin is not explicitly imported
Holes.idr:7:26--8:1:While processing type of Main.Weird at Holes.idr:7:1--8:1:
Holes.idr:7:26--8:1:While processing type of Weird at Holes.idr:7:1--8:1:
Name Builtin.~=~ is inaccessible since Builtin is not explicitly imported
Holes.idr:8:1--10:1:No type declaration for Main.Weird
Holes.idr:10:5--10:10:While processing type of Main.f at Holes.idr:10:1--11:1:
Holes.idr:10:5--10:10:While processing type of f at Holes.idr:10:1--11:1:
Name Prelude.Bool is inaccessible since Prelude is not explicitly imported
Holes.idr:11:1--12:1:No type declaration for Main.f
Main> (interactive):1:4--1:8:Undefined name help

View File

@ -1,5 +1,5 @@
1/1: Building iftype (iftype.idr)
iftype.idr:15:15--16:1:While processing right hand side of Main.isInListBad at iftype.idr:15:1--16:1:
iftype.idr:15:15--16:1:While processing right hand side of isInListBad at iftype.idr:15:1--16:1:
Can't solve constraint between:
if c then "Foo" else "Bar"
and

View File

@ -1,5 +1,5 @@
1/1: Building Main (Main.idr)
Main.idr:27:37--27:72:While processing right hand side of Main.dpairWithExtraInfoBad at Main.idr:27:1--28:1:
Main.idr:27:37--27:72:While processing right hand side of dpairWithExtraInfoBad at Main.idr:27:1--28:1:
When unifying [MN (fromInteger 0), MN (fromInteger 0)] and [MN (fromInteger 0)]
Mismatch between:
[MN (fromInteger 0)]

View File

@ -2,7 +2,7 @@
1/1: Building DescribeList (DescribeList.idr)
1/1: Building DescribeList2 (DescribeList2.idr)
1/1: Building DLFail (DLFail.idr)
DLFail.idr:3:20--3:29:While processing left hand side of Main.describe_list_end at DLFail.idr:3:1--4:1:
DLFail.idr:3:20--3:29:While processing left hand side of describe_list_end at DLFail.idr:3:1--4:1:
Can't match on ?xs ++ [?x] (Not a constructor application or primitive)
1/1: Building IsSuffix (IsSuffix.idr)
1/1: Building MergeSort (MergeSort.idr)