on master help sign in
Semantic colouring of identifiers in REPL
commitffb9ea92b7e6cb7c9abb10a65f0d1b9b8d36d09c authorDavid Christiansen <david@davidchristiansen.dk> dateSat 3 Aug 2013, 15:34 (13 years ago) parent77f9051
7 files changed+173−145
idris.cabal+1−1 src/Idris/AbsSyntax.hs+2−2 src/Idris/AbsSyntaxTree.hs+122−94 src/Idris/Coverage.hs+2−2 src/Idris/Delaborate.hs+10−10 src/Idris/ElabDecls.hs+25−25 src/Idris/REPL.hs+11−11
idris.cabal+1−1
@@ -278,7 +278,7 @@ Executable idris
278278 containers, process, transformers, filepath,
279279 directory, binary, bytestring, text, pretty,
280280 language-java>=0.2.2, libffi,
281− vector, vector-binary-instances
281+ vector, vector-binary-instances, ansi-terminal
282282
283283 Extensions: MultiParamTypeClasses, FunctionalDependencies,
284284 FlexibleInstances, TemplateHaskell
src/Idris/AbsSyntax.hs+2−2
@@ -1170,7 +1170,7 @@ mkPApp fc a f as = let rest = drop a as in
11701170-- FIXME: It's possible that this really has to happen after elaboration
11711171
11721172findStatics :: IState -> PTerm -> (PTerm, [Bool])
1173−findStatics ist tm = trace (showImp True tm) $
1173+findStatics ist tm = trace (showImp True False tm) $
11741174 let (ns, ss) = fs tm in
11751175 runState (pos ns ss tm) []
11761176 where fs (PPi p n t sc)
@@ -1201,7 +1201,7 @@ dumpDecls [] = ""
12011201dumpDecls (d:ds) = dumpDecl d ++ "\n" ++ dumpDecls ds
12021202
12031203dumpDecl (PFix _ f ops) = show f ++ " " ++ showSep ", " ops
1204−dumpDecl (PTy _ _ _ _ n t) = "tydecl " ++ show n ++ " : " ++ showImp True t
1204+dumpDecl (PTy _ _ _ _ n t) = "tydecl " ++ show n ++ " : " ++ showImp True False t
12051205dumpDecl (PClauses _ _ n cs) = "pat " ++ show n ++ "\t" ++ showSep "\n\t" (map (showCImp True) cs)
12061206dumpDecl (PData _ _ _ _ d) = showDImp True d
12071207dumpDecl (PParams _ ns ps) = "params {" ++ show ns ++ "\n" ++ dumpDecls ps ++ "}\n"
src/Idris/AbsSyntaxTree.hs+122−94
@@ -15,6 +15,8 @@ import Util.DynamicLinker
1515import Paths_idris
1616
1717import System.Console.Haskeline
18+import System.Console.ANSI ( Color(..), ConsoleLayer(..), SGR(..), setSGRCode,
19+ ColorIntensity(..), Underlining(..), ConsoleIntensity(..) )
1820
1921import Control.Monad.Trans.State.Strict
2022
@@ -28,7 +30,7 @@ data IOption = IOption { opt_logLevel :: Int,
2830 opt_typecase :: Bool,
2931 opt_typeintype :: Bool,
3032 opt_coverage :: Bool,
31− opt_showimp :: Bool,
33+ opt_showimp :: Bool, -- ^^ show implicits
3234 opt_errContext :: Bool,
3335 opt_repl :: Bool,
3436 opt_verbose :: Bool,
@@ -788,8 +790,22 @@ expandNS syn n = case syn_namespace syn of
788790
789791--- Pretty printing declarations and terms
790792
793+-- Set the colour of a string using POSIX escape codes
794+colourise :: Color -> ColorIntensity -> String -> String
795+colourise c i str = let sgr = [SetColor Foreground i c]
796+ in setSGRCode sgr ++ str ++ setSGRCode [Reset]
797+
798+colouriseKwd :: String -> String
799+colouriseKwd kwd = setSGRCode [SetUnderlining SingleUnderline
800+ , SetConsoleIntensity BoldIntensity
801+ , SetColor Foreground Vivid Black
802+ ] ++ kwd ++ setSGRCode [Reset]
803+
804+colouriseBound :: String -> String
805+colouriseBound = colourise Magenta Vivid
806+
791807instance Show PTerm where
792− show tm = showImp False tm
808+ show tm = showImp False False tm
793809
794810instance Pretty PTerm where
795811 pretty = prettyImp False
@@ -804,8 +820,8 @@ instance Show PData where
804820 show d = showDImp False d
805821
806822showDeclImp _ (PFix _ f ops) = show f ++ " " ++ showSep ", " ops
807−showDeclImp t (PTy _ _ _ _ n ty) = show n ++ " : " ++ showImp t ty
808−showDeclImp t (PPostulate _ _ _ _ n ty) = show n ++ " : " ++ showImp t ty
823+showDeclImp t (PTy _ _ _ _ n ty) = show n ++ " : " ++ showImp t False ty
824+showDeclImp t (PPostulate _ _ _ _ n ty) = show n ++ " : " ++ showImp t False ty
809825showDeclImp _ (PClauses _ _ n c) = showSep "\n" (map show c)
810826showDeclImp _ (PData _ _ _ _ d) = show d
811827showDeclImp _ (PParams f ns ps) = "parameters " ++ show ns ++ "\n" ++
@@ -814,24 +830,24 @@ showDeclImp _ (PParams f ns ps) = "parameters " ++ show ns ++ "\n" ++
814830
815831showCImp :: Bool -> PClause -> String
816832showCImp impl (PClause _ n l ws r w)
817− = showImp impl l ++ showWs ws ++ " = " ++ showImp impl r
833+ = showImp impl False l ++ showWs ws ++ " = " ++ showImp impl False r
818834 ++ " where " ++ show w
819835 where
820836 showWs [] = ""
821− showWs (x : xs) = " | " ++ showImp impl x ++ showWs xs
837+ showWs (x : xs) = " | " ++ showImp impl False x ++ showWs xs
822838showCImp impl (PWith _ n l ws r w)
823− = showImp impl l ++ showWs ws ++ " with " ++ showImp impl r
839+ = showImp impl False l ++ showWs ws ++ " with " ++ showImp impl False r
824840 ++ " { " ++ show w ++ " } "
825841 where
826842 showWs [] = ""
827− showWs (x : xs) = " | " ++ showImp impl x ++ showWs xs
843+ showWs (x : xs) = " | " ++ showImp impl False x ++ showWs xs
828844
829845
830846showDImp :: Bool -> PData -> String
831847showDImp impl (PDatadecl n ty cons)
832− = "data " ++ show n ++ " : " ++ showImp impl ty ++ " where\n\t"
848+ = "data " ++ show n ++ " : " ++ showImp impl False ty ++ " where\n\t"
833849 ++ showSep "\n\t| "
834− (map (\ (_, n, t, _) -> show n ++ " : " ++ showImp impl t) cons)
850+ (map (\ (_, n, t, _) -> show n ++ " : " ++ showImp impl False t) cons)
835851
836852getImps :: [PArg] -> [(Name, PTerm)]
837853getImps [] = []
@@ -851,7 +867,10 @@ getConsts (_ : xs) = getConsts xs
851867getAll :: [PArg] -> [PTerm]
852868getAll = map getTm
853869
854−prettyImp :: Bool -> PTerm -> Doc
870+-- | Pretty-print a high-level Idris term
871+prettyImp :: Bool -- ^^ whether to show implicits
872+ -> PTerm -- ^^ the term to pretty-print
873+ -> Doc
855874prettyImp impl = prettySe 10
856875 where
857876 prettySe p (PQuote r) =
@@ -1037,108 +1056,117 @@ prettyImp impl = prettySe 10
10371056 bracket outer inner doc
10381057 | inner > outer = lparen <> doc <> rparen
10391058 | otherwise = doc
1040−
1041−showImp :: Bool -> PTerm -> String
1042−showImp impl tm = se 10 tm where
1043− se p (PQuote r) = "![" ++ show r ++ "]"
1044− se p (PPatvar fc n) = if impl then show n ++ "[p]" else show n
1045− se p (PInferRef fc n) = "!" ++ show n -- ++ "[" ++ show fc ++ "]"
1046− se p (PRef fc n) = if impl then show n -- ++ "[" ++ show fc ++ "]"
1047− else showbasic n
1048− where showbasic n@(UN _) = show n
1059+
1060+-- | Show Idris term
1061+showImp :: Bool -- ^^ whether to show implicits
1062+ -> Bool -- ^^ whether to colourise
1063+ -> PTerm -- ^^ the term to show
1064+ -> String
1065+showImp impl colour tm = se 10 [] tm where
1066+ perhapsColourise :: (String -> String) -> String -> String
1067+ perhapsColourise col str = if colour then col str else str
1068+
1069+ se :: Int -> [Name] -> PTerm -> String
1070+ se p bnd (PQuote r) = "![" ++ show r ++ "]"
1071+ se p bnd (PPatvar fc n) = if impl then show n ++ "[p]" else show n
1072+ se p bnd (PInferRef fc n) = "!" ++ show n -- ++ "[" ++ show fc ++ "]"
1073+ se p bnd (PRef fc n) = if colour && n `elem` bnd then colouriseBound name else name
1074+ where name = if impl then show n else showbasic n
1075+ showbasic n@(UN _) = show n
10491076 showbasic (MN _ s) = s
10501077 showbasic (NS n s) = showSep "." (reverse s) ++ "." ++ showbasic n
1051− se p (PLam n ty sc) = bracket p 2 $ "\\ " ++ show n ++
1052− (if impl then " : " ++ se 10 ty else "") ++ " => "
1053− ++ se 10 sc
1054− se p (PLet n ty v sc) = bracket p 2 $ "let " ++ show n ++ " = " ++ se 10 v ++
1055− " in " ++ se 10 sc
1056− se p (PPi (Exp l s _) n ty sc)
1078+ se p bnd (PLam n ty sc) = bracket p 2 $ "\\ " ++ perhapsColourise colouriseBound (show n) ++
1079+ (if impl then " : " ++ se 10 bnd ty else "") ++ " => "
1080+ ++ se 10 (n:bnd) sc
1081+ se p bnd (PLet n ty v sc) = bracket p 2 $ "let " ++ perhapsColourise colouriseBound (show n) ++
1082+ " = " ++ se 10 bnd v ++
1083+ " in " ++ se 10 (n:bnd) sc
1084+ se p bnd (PPi (Exp l s _) n ty sc)
10571085 | n `elem` allNamesIn sc || impl
10581086 = bracket p 2 $
1059− (if l then "|(" else "(") ++
1060− show n ++ " : " ++ se 10 ty ++
1087+ (if l then "|(" else "(") ++
1088+ perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
10611089 ") " ++ st ++
1062− "-> " ++ se 10 sc
1063− | otherwise = bracket p 2 $ se 0 ty ++ " " ++ st ++ "-> " ++ se 10 sc
1090+ "-> " ++ se 10 (n:bnd) sc
1091+ | otherwise = bracket p 2 $ se 0 bnd ty ++ " " ++ st ++ "-> " ++ se 10 bnd sc
10641092 where st = case s of
10651093 Static -> "[static] "
10661094 _ -> ""
1067− se p (PPi (Imp l s _) n ty sc)
1068− | impl = bracket p 2 $ (if l then "|{" else "{") ++
1069− show n ++ " : " ++ se 10 ty ++
1070− "} " ++ st ++ "-> " ++ se 10 sc
1071− | otherwise = se 10 sc
1095+ se p bnd (PPi (Imp l s _) n ty sc)
1096+ | impl = bracket p 2 $ (if l then "|{" else "{") ++
1097+ perhapsColourise colouriseBound (show n) ++ " : " ++ se 10 bnd ty ++
1098+ "} " ++ st ++ "-> " ++ se 10 (n:bnd) sc
1099+ | otherwise = se 10 bnd sc
10721100 where st = case s of
10731101 Static -> "[static] "
10741102 _ -> ""
1075− se p (PPi (Constraint _ _ _) n ty sc)
1076− = bracket p 2 $ se 10 ty ++ " => " ++ se 10 sc
1077− se p (PPi (TacImp _ _ s _) n ty sc)
1078− = bracket p 2 $ "{tacimp " ++ show n ++ " : " ++ se 10 ty ++ "} -> " ++ se 10 sc
1079− se p e
1080− | Just str <- slist p e = str
1103+ se p bnd (PPi (Constraint _ _ _) n ty sc)
1104+ = bracket p 2 $ se 10 bnd ty ++ " => " ++ se 10 bnd sc
1105+ se p bnd (PPi (TacImp _ _ s _) n ty sc)
1106+ = bracket p 2 $
1107+ "{tacimp " ++ (perhapsColourise colouriseBound (show n)) ++ " : " ++ se 10 bnd ty ++ "} -> " ++
1108+ se 10 (n:bnd) sc
1109+ se p bnd e
1110+ | Just str <- slist p bnd e = str
10811111 | Just num <- snat p e = show num
1082− se p (PMatchApp _ f) = "match " ++ show f
1083− se p (PApp _ (PRef _ f) [])
1112+ se p bnd (PMatchApp _ f) = "match " ++ show f
1113+ se p bnd (PApp _ (PRef _ f) [])
10841114 | not impl = show f
1085− se p (PApp _ (PRef _ op@(UN (f:_))) args)
1115+ se p bnd (PApp _ (PRef _ op@(UN (f:_))) args)
10861116 | length (getExps args) == 2 && not impl && not (isAlpha f)
10871117 = let [l, r] = getExps args in
1088− bracket p 1 $ se 1 l ++ " " ++ show op ++ " " ++ se 0 r
1089− se p (PApp _ f as)
1118+ bracket p 1 $ se 1 bnd l ++ " " ++ show op ++ " " ++ se 0 bnd r
1119+ se p bnd (PApp _ f as)
10901120 = let args = getExps as in
1091− bracket p 1 $ se 1 f ++ if impl then concatMap sArg as
1092− else concatMap seArg args
1093− se p (PCase _ scr opts) = "case " ++ se 10 scr ++ " of " ++ showSep " | " (map sc opts)
1094− where sc (l, r) = se 10 l ++ " => " ++ se 10 r
1095− se p (PHidden tm) = "." ++ se 0 tm
1096− se p (PRefl _ t)
1121+ bracket p 1 $ se 1 bnd f ++ if impl then concatMap (sArg bnd) as
1122+ else concatMap (seArg bnd) args
1123+ se p bnd (PCase _ scr opts) = "case " ++ se 10 bnd scr ++ " of " ++ showSep " | " (map sc opts)
1124+ where sc (l, r) = se 10 bnd l ++ " => " ++ se 10 bnd r
1125+ se p bnd (PHidden tm) = "." ++ se 0 bnd tm
1126+ se p bnd (PRefl _ t)
10971127 | not impl = "refl"
1098− | otherwise = "refl {" ++ se 10 t ++ "}"
1099− se p (PResolveTC _) = "resolvetc"
1100− se p (PTrue _) = "()"
1101− se p (PFalse _) = "_|_"
1102− se p (PEq _ l r) = bracket p 2 $ se 10 l ++ " = " ++ se 10 r
1103− se p (PRewrite _ l r _) = bracket p 2 $ "rewrite " ++ se 10 l ++ " in " ++ se 10 r
1104− se p (PTyped l r) = "(" ++ se 10 l ++ " : " ++ se 10 r ++ ")"
1105− se p (PPair _ l r) = "(" ++ se 10 l ++ ", " ++ se 10 r ++ ")"
1106− se p (PDPair _ l t r) = "(" ++ se 10 l ++ " ** " ++ se 10 r ++ ")"
1107− se p (PAlternative a as) = "(|" ++ showSep " , " (map (se 10) as) ++ "|)"
1108− se p PType = "Type"
1109− se p (PConstant c) = show c
1110− se p (PProof ts) = "proof { " ++ show ts ++ "}"
1111− se p (PTactics ts) = "tactics { " ++ show ts ++ "}"
1112− se p (PMetavar n) = "?" ++ show n
1113− se p (PReturn f) = "return"
1114− se p PImpossible = "impossible"
1115− se p Placeholder = "_"
1116− se p (PDoBlock _) = "do block show not implemented"
1117− se p (PElabError s) = show s
1118− se p (PCoerced t) = se p t
1119− se p (PUnifyLog t) = "%unifyLog " ++ se p t
1120− se p (PGoal f t n sc) = "quoteGoal " ++ show n ++ " by " ++ se 10 t ++
1121− " in " ++ se 10 sc
1122−-- se p x = "Not implemented"
1123−
1124− slist' p (PApp _ (PRef _ nil) _)
1128+ | otherwise = "refl {" ++ se 10 bnd t ++ "}"
1129+ se p bnd (PResolveTC _) = "resolvetc"
1130+ se p bnd (PTrue _) = "()"
1131+ se p bnd (PFalse _) = "_|_"
1132+ se p bnd (PEq _ l r) = bracket p 2 $ se 10 bnd l ++ " = " ++ se 10 bnd r
1133+ se p bnd (PRewrite _ l r _) = bracket p 2 $ "rewrite " ++ se 10 bnd l ++ " in " ++ se 10 bnd r
1134+ se p bnd (PTyped l r) = "(" ++ se 10 bnd l ++ " : " ++ se 10 bnd r ++ ")"
1135+ se p bnd (PPair _ l r) = "(" ++ se 10 bnd l ++ ", " ++ se 10 bnd r ++ ")"
1136+ se p bnd (PDPair _ l t r) = "(" ++ se 10 bnd l ++ " ** " ++ se 10 bnd r ++ ")"
1137+ se p bnd (PAlternative a as) = "(|" ++ showSep " , " (map (se 10 bnd) as) ++ "|)"
1138+ se p bnd PType = "Type"
1139+ se p bnd (PConstant c) = show c
1140+ se p bnd (PProof ts) = "proof { " ++ show ts ++ "}"
1141+ se p bnd (PTactics ts) = "tactics { " ++ show ts ++ "}"
1142+ se p bnd (PMetavar n) = "?" ++ show n
1143+ se p bnd (PReturn f) = "return"
1144+ se p bnd PImpossible = "impossible"
1145+ se p bnd Placeholder = "_"
1146+ se p bnd (PDoBlock _) = "do block show not implemented"
1147+ se p bnd (PElabError s) = show s
1148+ se p bnd (PCoerced t) = se p bnd t
1149+ se p bnd (PUnifyLog t) = "%unifyLog " ++ se p bnd t
1150+-- se p bnd x = "Not implemented"
1151+
1152+ slist' p bnd (PApp _ (PRef _ nil) _)
11251153 | nsroot nil == UN "Nil" = Just []
1126− slist' p (PApp _ (PRef _ cons) args)
1154+ slist' p bnd (PApp _ (PRef _ cons) args)
11271155 | nsroot cons == UN "::",
11281156 (PExp {getTm=tl}):(PExp {getTm=hd}):imps <- reverse args,
11291157 all isImp imps,
1130− Just tl' <- slist' p tl
1158+ Just tl' <- slist' p bnd tl
11311159 = Just (hd:tl')
11321160 where
11331161 isImp (PImp {}) = True
11341162 isImp _ = False
1135− slist' _ _ = Nothing
1163+ slist' _ _ _ = Nothing
11361164
1137− slist p e | Just es <- slist' p e = Just $
1165+ slist p bnd e | Just es <- slist' p bnd e = Just $
11381166 case es of [] -> "[]"
1139− [x] -> "[" ++ se p x ++ "]"
1140− xs -> "[" ++ intercalate "," (map (se p) xs) ++ "]"
1141− slist _ _ = Nothing
1167+ [x] -> "[" ++ se p bnd x ++ "]"
1168+ xs -> "[" ++ intercalate "," (map (se p bnd ) xs) ++ "]"
1169+ slist _ _ _ = Nothing
11421170
11431171 -- since Prelude is always imported, S & Z are unqualified iff they're the
11441172 -- Nat ones.
@@ -1152,15 +1180,15 @@ showImp impl tm = se 10 tm where
11521180
11531181 natns = "Prelude.Nat."
11541182
1155− sArg (PImp _ _ n tm _) = siArg (n, tm)
1156− sArg (PExp _ _ tm _) = seArg tm
1157− sArg (PConstraint _ _ tm _) = scArg tm
1158− sArg (PTacImplicit _ _ n _ tm _) = stiArg (n, tm)
1183+ sArg bnd (PImp _ _ n tm _) = siArg bnd (n, tm)
1184+ sArg bnd (PExp _ _ tm _) = seArg bnd tm
1185+ sArg bnd (PConstraint _ _ tm _) = scArg bnd tm
1186+ sArg bnd (PTacImplicit _ _ n _ tm _) = stiArg bnd (n, tm)
11591187
1160− seArg arg = " " ++ se 0 arg
1161− siArg (n, val) = " {" ++ show n ++ " = " ++ se 10 val ++ "}"
1162− scArg val = " {{" ++ se 10 val ++ "}}"
1163− stiArg (n, val) = " {auto " ++ show n ++ " = " ++ se 10 val ++ "}"
1188+ seArg bnd arg = " " ++ se 0 bnd arg
1189+ siArg bnd (n, val) = " {" ++ show n ++ " = " ++ se 10 bnd val ++ "}"
1190+ scArg bnd val = " {{" ++ se 10 bnd val ++ "}}"
1191+ stiArg bnd (n, val) = " {auto " ++ show n ++ " = " ++ se 10 bnd val ++ "}"
11641192
11651193 bracket outer inner str | inner > outer = "(" ++ str ++ ")"
11661194 | otherwise = str
src/Idris/Coverage.hs+2−2
@@ -50,7 +50,7 @@ genClauses fc n xs given
5050 logLvl 5 $ show (map length argss) ++ "\n" ++ show (map length all_args)
5151 logLvl 10 $ show argss ++ "\n" ++ show all_args
5252 logLvl 10 $ "Original: \n" ++
53− showSep "\n" (map (\t -> showImp True (delab' i t True)) xs)
53+ showSep "\n" (map (\t -> showImp True False (delab' i t True)) xs)
5454 -- add an infinite supply of explicit arguments to update the possible
5555 -- cases for (the return type may be variadic, or function type, sp
5656 -- there may be more case splitting that the idris_implicits record
@@ -62,7 +62,7 @@ genClauses fc n xs given
6262 logLvl 2 $ show (length tryclauses) ++ " initially to check"
6363 let new = filter (noMatch i) (mnub i tryclauses)
6464 logLvl 1 $ show (length new) ++ " clauses to check for impossibility"
65− logLvl 5 $ "New clauses: \n" ++ showSep "\n" (map (showImp True) new)
65+ logLvl 5 $ "New clauses: \n" ++ showSep "\n" (map (showImp True False) new)
6666-- ++ " from:\n" ++ showSep "\n" (map (showImp True) tryclauses)
6767 return new
6868-- return (map (\t -> PClause n t [] PImpossible []) new)
src/Idris/Delaborate.hs+10−10
@@ -100,33 +100,33 @@ pshow i (InternalMsg s) = "INTERNAL ERROR: " ++ show s ++
100100 "Please consider reporting at " ++ bugaddr
101101pshow i (CantUnify _ x y e sc s)
102102 = let imps = opt_showimp (idris_options i) in
103− "Can't unify " ++ showImp imps (delab i x)
104− ++ " with " ++ showImp imps (delab i y) ++
105−-- " (" ++ showEnvDbg [] x ++ " and " ++ showEnvDbg [] y ++ ") " ++
103+ "Can't unify " ++ showImp imps False (delab i x)
104+ ++ " with " ++ showImp imps False (delab i y) ++
105+-- " (" ++ show x ++ " and " ++ show y ++ ") " ++
106106 case e of
107107 Msg "" -> ""
108108 _ -> "\n\nSpecifically:\n\t" ++ pshow i e ++
109109 if (opt_errContext (idris_options i)) then showSc i sc else ""
110110pshow i (CantConvert x y env)
111111 = let imps = opt_showimp (idris_options i) in
112− "Can't convert " ++ showImp imps (delab i x) ++ " with "
113− ++ showImp imps (delab i y) ++
112+ "Can't convert " ++ showImp imps False (delab i x) ++ " with "
113+ ++ showImp imps False (delab i y) ++
114114 if (opt_errContext (idris_options i)) then showSc i env else ""
115115pshow i (UnifyScope n out tm env)
116116 = let imps = opt_showimp (idris_options i) in
117117 "Can't unify " ++ show n ++ " with "
118− ++ showImp imps (delab i tm) ++ " as " ++ show out ++
118+ ++ showImp imps False (delab i tm) ++ " as " ++ show out ++
119119 " is not in scope" ++
120120 if (opt_errContext (idris_options i)) then showSc i env else ""
121121pshow i (CantInferType t)
122122 = "Can't infer type for " ++ t
123123pshow i (NonFunctionType f ty)
124124 = let imps = opt_showimp (idris_options i) in
125− showImp imps (delab i f) ++ " does not have a function type ("
126− ++ showImp imps (delab i ty) ++ ")"
125+ showImp imps False (delab i f) ++ " does not have a function type ("
126+ ++ showImp imps False (delab i ty) ++ ")"
127127pshow i (CantIntroduce ty)
128128 = let imps = opt_showimp (idris_options i) in
129− "Can't use lambda here: type is " ++ showImp imps (delab i ty)
129+ "Can't use lambda here: type is " ++ showImp imps False (delab i ty)
130130pshow i (InfiniteUnify x tm env)
131131 = "Unifying " ++ showbasic x ++ " and " ++ show (delab i tm) ++
132132 " would lead to infinite value" ++
@@ -138,7 +138,7 @@ pshow i (CantResolve c) = "Can't resolve type class " ++ show (delab i c)
138138pshow i (CantResolveAlts as) = "Can't disambiguate name: " ++ showSep ", " as
139139pshow i (NoTypeDecl n) = "No type declaration for " ++ show n
140140pshow i (NoSuchVariable n) = "No such variable " ++ show n
141−pshow i (IncompleteTerm t) = "Incomplete term " ++ showImp True (delab i t)
141+pshow i (IncompleteTerm t) = "Incomplete term " ++ showImp True False (delab i t)
142142pshow i UniverseError = "Universe inconsistency"
143143pshow i ProgramLineComment = "Program line next to comment"
144144pshow i (Inaccessible n) = show n ++ " is not an accessible pattern variable"
src/Idris/ElabDecls.hs+25−25
@@ -51,11 +51,11 @@ elabType info syn doc fc opts n ty' = {- let ty' = piBind (params info) ty_in
5151 do checkUndefined fc n
5252 ctxt <- getContext
5353 i <- getIState
54− logLvl 3 $ show n ++ " pre-type " ++ showImp True ty'
54+ logLvl 3 $ show n ++ " pre-type " ++ showImp True False ty'
5555 ty' <- addUsingConstraints syn fc ty'
5656 ty' <- implicit syn n ty'
5757 let ty = addImpl i ty'
58− logLvl 2 $ show n ++ " type " ++ showImp True ty
58+ logLvl 2 $ show n ++ " type " ++ showImp True False ty
5959 ((tyT, defer, is), log) <- tclift $ elaborate ctxt n (TType (UVal 0)) []
6060 (erun fc (build i info False n ty))
6161 ds <- checkDef fc defer
@@ -482,7 +482,7 @@ elabCon info syn tn codata (doc, n, t_in, fc)
482482 i <- getIState
483483 t_in <- implicit syn n (if codata then mkLazy t_in else t_in)
484484 let t = addImpl i t_in
485− logLvl 2 $ show fc ++ ":Constructor " ++ show n ++ " : " ++ showImp True t
485+ logLvl 2 $ show fc ++ ":Constructor " ++ show n ++ " : " ++ showImp True False t
486486 ((t', defer, is), log) <- tclift $ elaborate ctxt n (TType (UVal 0)) []
487487 (erun fc (build i info False n t))
488488 logLvl 2 $ "Rechecking " ++ show t'
@@ -589,9 +589,9 @@ elabClauses info fc opts n_in cs = let n = liftname info n_in in
589589 missing' <- filterM (checkPossible info fc True n) missing
590590 let clhs = map getLHS pdef
591591 logLvl 2 $ "Must be unreachable:\n" ++
592− showSep "\n" (map (showImp True) missing') ++
592+ showSep "\n" (map (showImp True False) missing') ++
593593 "\nAgainst: " ++
594− showSep "\n" (map (\t -> showImp True (delab ist t)) (map getLHS pdef))
594+ showSep "\n" (map (\t -> showImp True False (delab ist t)) (map getLHS pdef))
595595 -- filter out anything in missing' which is
596596 -- matched by any of clhs. This might happen since
597597 -- unification may force a variable to take a
@@ -711,7 +711,7 @@ elabVal info aspat tm_in
711711 = do ctxt <- getContext
712712 i <- getIState
713713 let tm = addImpl i tm_in
714− logLvl 10 (showImp True tm)
714+ logLvl 10 (showImp True False tm)
715715 -- try:
716716 -- * ordinary elaboration
717717 -- * elaboration as a Type
@@ -776,7 +776,7 @@ elabClause info tcgen (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
776776 _ -> []
777777 let params = getParamsInType i [] fn_is fn_ty
778778 let lhs = addImplPat i (propagateParams params (stripLinear i lhs_in))
779− logLvl 5 ("LHS: " ++ show fc ++ " " ++ showImp True lhs)
779+ logLvl 5 ("LHS: " ++ show fc ++ " " ++ showImp True False lhs)
780780 logLvl 4 ("Fixed parameters: " ++ show params ++ " from " ++ show (fn_ty, fn_is))
781781 ((lhs', dlhs, []), _) <-
782782 tclift $ elaborate ctxt (MN 0 "patLHS") infP []
@@ -806,10 +806,10 @@ elabClause info tcgen (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
806806 mapM_ (elabDecl' EAll info) wbefore
807807 -- Now build the RHS, using the type of the LHS as the goal.
808808 i <- getIState -- new implicits from where block
809− logLvl 5 (showImp True (expandParams decorate newargs defs (defs \\ decls) rhs_in))
809+ logLvl 5 (showImp True False (expandParams decorate newargs defs (defs \\ decls) rhs_in))
810810 let rhs = addImplBoundInf i (map fst newargs) (defs \\ decls)
811811 (expandParams decorate newargs defs (defs \\ decls) rhs_in)
812− logLvl 2 $ "RHS: " ++ showImp True rhs
812+ logLvl 2 $ "RHS: " ++ showImp True False rhs
813813 ctxt <- getContext -- new context with where block added
814814 logLvl 5 "STARTING CHECK"
815815 ((rhs', defer, is), _) <-
@@ -911,7 +911,7 @@ elabClause info tcgen (_, PWith fc fname lhs_in withs wval_in withblock)
911911 -- pattern bindings
912912 i <- getIState
913913 let lhs = addImplPat i lhs_in
914− logLvl 5 ("LHS: " ++ showImp True lhs)
914+ logLvl 5 ("LHS: " ++ showImp True False lhs)
915915 ((lhs', dlhs, []), _) <-
916916 tclift $ elaborate ctxt (MN 0 "patLHS") infP []
917917 (erun fc (buildTC i info True tcgen fname (infTerm lhs)))
@@ -923,7 +923,7 @@ elabClause info tcgen (_, PWith fc fname lhs_in withs wval_in withblock)
923923 logLvl 5 ("Checked " ++ show clhs)
924924 let bargs = getPBtys lhs_tm
925925 let wval = addImplBound i (map fst bargs) wval_in
926− logLvl 5 ("Checking " ++ showImp True wval)
926+ logLvl 5 ("Checking " ++ showImp True False wval)
927927 -- Elaborate wval in this context
928928 ((wval', defer, is), _) <-
929929 tclift $ elaborate ctxt (MN 0 "withRHS")
@@ -980,7 +980,7 @@ elabClause info tcgen (_, PWith fc fname lhs_in withs wval_in withblock)
980980 (map (pexp . (PRef fc) . fst) bargs_pre ++
981981 pexp wval :
982982 (map (pexp . (PRef fc) . fst) bargs_post))
983− logLvl 5 ("New RHS " ++ showImp True rhs)
983+ logLvl 5 ("New RHS " ++ showImp True False rhs)
984984 ctxt <- getContext -- New context with block added
985985 i <- getIState
986986 ((rhs', defer, is), _) <-
@@ -1009,8 +1009,8 @@ elabClause info tcgen (_, PWith fc fname lhs_in withs wval_in withblock)
10091009 mkAux wname toplhs ns ns' (PClause fc n tm_in (w:ws) rhs wheres)
10101010 = do i <- getIState
10111011 let tm = addImplPat i tm_in
1012− logLvl 2 ("Matching " ++ showImp True tm ++ " against " ++
1013− showImp True toplhs)
1012+ logLvl 2 ("Matching " ++ showImp True False tm ++ " against " ++
1013+ showImp True False toplhs)
10141014 case matchClause i toplhs tm of
10151015 Left f -> fail $ show fc ++ ":with clause does not match top level"
10161016 Right mvars ->
@@ -1020,8 +1020,8 @@ elabClause info tcgen (_, PWith fc fname lhs_in withs wval_in withblock)
10201020 mkAux wname toplhs ns ns' (PWith fc n tm_in (w:ws) wval withs)
10211021 = do i <- getIState
10221022 let tm = addImplPat i tm_in
1023− logLvl 2 ("Matching " ++ showImp True tm ++ " against " ++
1024− showImp True toplhs)
1023+ logLvl 2 ("Matching " ++ showImp True False tm ++ " against " ++
1024+ showImp True False toplhs)
10251025 withs' <- mapM (mkAuxC wname toplhs ns ns') withs
10261026 case matchClause i toplhs tm of
10271027 Left _ -> fail $ show fc ++ "with clause does not match top level"
@@ -1118,7 +1118,7 @@ elabClass info syn doc fc constraints tn ps ds
11181118 getMName (PTy _ _ _ _ n _) = nsroot n
11191119 tdecl allmeths (PTy doc syn _ o n t)
11201120 = do t' <- implicit' syn allmeths n t
1121− logLvl 5 $ "Method " ++ show n ++ " : " ++ showImp True t'
1121+ logLvl 5 $ "Method " ++ show n ++ " : " ++ showImp True False t'
11221122 return ( (n, (toExp (map fst ps) Exp t')),
11231123 (n, (doc, o, (toExp (map fst ps) Imp t'))),
11241124 (n, (syn, o, t) ) )
@@ -1152,8 +1152,8 @@ elabClass info syn doc fc constraints tn ps ds
11521152 let lhs = PApp fc (PRef fc cfn) [pconst capp]
11531153 let rhs = PResolveTC (FC "HACK" 0)
11541154 let ty = PPi constraint (MN 0 "pc") c con
1155− iLOG (showImp True ty)
1156− iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
1155+ iLOG (showImp True False ty)
1156+ iLOG (showImp True False lhs ++ " = " ++ showImp True False rhs)
11571157 i <- getIState
11581158 let conn = case con of
11591159 PRef _ n -> n
@@ -1177,9 +1177,9 @@ elabClass info syn doc fc constraints tn ps ds
11771177 let anames = map (\x -> MN x "arg") [0..]
11781178 let lhs = PApp fc (PRef fc m) (pconst capp : lhsArgs margs anames)
11791179 let rhs = PApp fc (getMeth mnames all m) (rhsArgs margs anames)
1180− iLOG (showImp True ty)
1180+ iLOG (showImp True False ty)
11811181 iLOG (show (m, ty', capp, margs))
1182− iLOG (showImp True lhs ++ " = " ++ showImp True rhs)
1182+ iLOG (showImp True False lhs ++ " = " ++ showImp True False rhs)
11831183 return [PTy doc syn fc o m ty',
11841184 PClauses fc [Inlinable] m [PClause fc m lhs [] rhs []]]
11851185
@@ -1520,8 +1520,8 @@ elabCaseBlock info d@(PClauses f o n ps)
15201520
15211521checkInferred :: FC -> PTerm -> PTerm -> Idris ()
15221522checkInferred fc inf user =
1523− do logLvl 6 $ "Checked to\n" ++ showImp True inf ++ "\n\nFROM\n\n" ++
1524− showImp True user
1523+ do logLvl 6 $ "Checked to\n" ++ showImp True False inf ++ "\n\nFROM\n\n" ++
1524+ showImp True False user
15251525 logLvl 10 $ "Checking match"
15261526 i <- getIState
15271527 tclift $ case matchClause' True i user inf of
@@ -1538,8 +1538,8 @@ checkInferred fc inf user =
15381538inferredDiff :: FC -> PTerm -> PTerm -> Idris Bool
15391539inferredDiff fc inf user =
15401540 do i <- getIState
1541− logLvl 6 $ "Checked to\n" ++ showImp True inf ++ "\n" ++
1542− showImp True user
1541+ logLvl 6 $ "Checked to\n" ++ showImp True False inf ++ "\n" ++
1542+ showImp True False user
15431543 tclift $ case matchClause' True i user inf of
15441544 Right vs -> return False
15451545 Left (x, y) -> return True
src/Idris/REPL.hs+11−11
@@ -304,8 +304,8 @@ process fn (Eval t)
304304 logLvl 3 $ "Raw: " ++ show (tm', ty')
305305 logLvl 10 $ "Debug: " ++ showEnvDbg [] tm'
306306 imp <- impShow
307− iResult (showImp imp (delab ist tm') ++ " : " ++
308− showImp imp (delab ist ty'))
307+ iResult (showImp imp True (delab ist tm') ++ " : " ++
308+ showImp imp True (delab ist ty'))
309309process fn (ExecVal t)
310310 = do ctxt <- getContext
311311 ist <- getIState
@@ -314,15 +314,15 @@ process fn (ExecVal t)
314314 let ty' = normaliseAll ctxt [] ty
315315 res <- execute tm
316316 imp <- impShow
317− iResult (showImp imp (delab ist res) ++ " : " ++
318− showImp imp (delab ist ty'))
317+ iResult (showImp imp True (delab ist res) ++ " : " ++
318+ showImp imp True (delab ist ty'))
319319process fn (Check (PRef _ n))
320320 = do ctxt <- getContext
321321 ist <- getIState
322322 imp <- impShow
323323 case lookupNames n ctxt of
324324 ts@(_:_) -> do mapM_ (\n -> iputStrLn $ show n ++ " : " ++
325− showImp imp (delabTy ist n)) ts
325+ showImp imp True (delabTy ist n)) ts
326326 iResult ""
327327 [] -> iFail $ "No such variable " ++ show n
328328process fn (Check t)
@@ -333,8 +333,8 @@ process fn (Check t)
333333 let ty' = normaliseC ctxt [] ty
334334 case tm of
335335 TType _ -> iResult ("Type : Type 1")
336− _ -> iResult (showImp imp (delab ist tm) ++ " : " ++
337− showImp imp (delab ist ty))
336+ _ -> iResult (showImp imp True (delab ist tm) ++ " : " ++
337+ showImp imp True (delab ist ty))
338338
339339process fn (DocStr n) = do i <- getIState
340340 case lookupCtxtName n (idris_docstrings i) of
@@ -364,8 +364,8 @@ process fn (Defn n) = do i <- getIState
364364 [t] -> iputStrLn (showTotal t i)
365365 _ -> return ()
366366 where printCase i (_, lhs, rhs)
367− = do iputStrLn (showImp True (delab i lhs) ++ " = " ++
368− showImp True (delab i rhs))
367+ = do iputStrLn (showImp True False (delab i lhs) ++ " = " ++
368+ showImp True False (delab i rhs))
369369process fn (TotCheck n) = do i <- getIState
370370 case lookupTotal n (tt_ctxt i) of
371371 [t] -> iResult (showTotal t i)
@@ -505,7 +505,7 @@ process fn (Missing n)
505505 case lookupCtxt n (idris_patdefs i) of
506506 [] -> return ()
507507 [(_, tms)] ->
508− iResult (showSep "\n" (map (showImp True) tms))
508+ iResult (showSep "\n" (map (showImp True False) tms))
509509 _ -> iFail $ "Ambiguous name"
510510process fn (DynamicLink l) = do i <- getIState
511511 let lib = trim l
@@ -553,7 +553,7 @@ dumpInstance n = do i <- getIState
553553 ctxt <- getContext
554554 imp <- impShow
555555 case lookupTy n ctxt of
556− ts -> mapM_ (\t -> iputStrLn $ showImp imp (delab i t)) ts
556+ ts -> mapM_ (\t -> iputStrLn $ showImp imp False (delab i t)) ts
557557
558558showTotal t@(Partial (Other ns)) i
559559 = show t ++ "\n\t" ++ showSep "\n\t" (map (showTotalN i) ns)