on master help sign in
Show argument names in :doc
7faf4e8David Raymond Christiansen
src/Idris/AbsSyntax.hs+1−1
@@ -567,7 +567,7 @@ ihPrintFunTypes h bnd n overloads = do imp <- impShow
567 RawOutput -> consoleDisplayAnnotated h output
567 RawOutput -> consoleDisplayAnnotated h output
568 IdeSlave n -> ideSlaveReturnAnnotated n h output
568 IdeSlave n -> ideSlaveReturnAnnotated n h output
569 where fullName n = prettyName True bnd n
569 where fullName n = prettyName True bnd n
570− ppOverload imp n tm = fullName n <+> colon <+> align (pprintPTerm imp bnd tm)
570+ ppOverload imp n tm = fullName n <+> colon <+> align (pprintPTerm imp bnd [] tm)
571
571
572ihRenderResult :: Handle -> Doc OutputAnnotation -> Idris ()
572ihRenderResult :: Handle -> Doc OutputAnnotation -> Idris ()
573ihRenderResult h d = do ist <- getIState
573ihRenderResult h d = do ist <- getIState
src/Idris/AbsSyntaxTree.hs+4−3
@@ -1085,14 +1085,15 @@ consoleDecorate ist (AnnTextFmt fmt) = Idris.Colours.colourise (colour fmt)
1085prettyImp :: Bool -- ^^ whether to show implicits
1085prettyImp :: Bool -- ^^ whether to show implicits
1086 -> PTerm -- ^^ the term to pretty-print
1086 -> PTerm -- ^^ the term to pretty-print
1087 -> Doc OutputAnnotation
1087 -> Doc OutputAnnotation
1088−prettyImp impl = pprintPTerm impl []
1088+prettyImp impl = pprintPTerm impl [] []
1089
1089
1090-- | Pretty-print a high-level Idris term in some bindings context
1090-- | Pretty-print a high-level Idris term in some bindings context
1091pprintPTerm :: Bool -- ^^ whether to show implicits
1091pprintPTerm :: Bool -- ^^ whether to show implicits
1092 -> [(Name, Bool)] -- ^^ the currently-bound names and whether they are implicit
1092 -> [(Name, Bool)] -- ^^ the currently-bound names and whether they are implicit
1093+ -> [Name] -- ^^ names to always show in pi, even if not used
1093 -> PTerm -- ^^ the term to pretty-print
1094 -> PTerm -- ^^ the term to pretty-print
1094 -> Doc OutputAnnotation
1095 -> Doc OutputAnnotation
1095−pprintPTerm impl bnd = prettySe 10 bnd
1096+pprintPTerm impl bnd docArgs = prettySe 10 bnd
1096 where
1097 where
1097 prettySe :: Int -> [(Name, Bool)] -> PTerm -> Doc OutputAnnotation
1098 prettySe :: Int -> [(Name, Bool)] -> PTerm -> Doc OutputAnnotation
1098 prettySe p bnd (PQuote r) =
1099 prettySe p bnd (PQuote r) =
@@ -1112,7 +1113,7 @@ pprintPTerm impl bnd = prettySe 10 bnd
1112 prettySe 10 bnd v <+> kwd "in" </>
1113 prettySe 10 bnd v <+> kwd "in" </>
1113 prettySe 10 ((n, False):bnd) sc
1114 prettySe 10 ((n, False):bnd) sc
1114 prettySe p bnd (PPi (Exp l s _) n ty sc)
1115 prettySe p bnd (PPi (Exp l s _) n ty sc)
1115− | n `elem` allNamesIn sc || impl =
1116+ | n `elem` allNamesIn sc || impl || n `elem` docArgs =
1116 let open = if Lazy `elem` l then text "|" <> lparen else lparen in
1117 let open = if Lazy `elem` l then text "|" <> lparen else lparen in
1117 bracket p 2 . group $
1118 bracket p 2 . group $
1118 enclose open rparen (group . align $ bindingOf n False <+> colon <+> prettySe 10 bnd ty) <+>
1119 enclose open rparen (group . align $ bindingOf n False <+> colon <+> prettySe 10 bnd ty) <+>
src/Idris/Delaborate.hs+1−1
@@ -138,7 +138,7 @@ pprintTerm :: IState -> PTerm -> Doc OutputAnnotation
138pprintTerm ist = pprintTerm' ist []
138pprintTerm ist = pprintTerm' ist []
139
139
140pprintTerm' :: IState -> [(Name, Bool)] -> PTerm -> Doc OutputAnnotation
140pprintTerm' :: IState -> [(Name, Bool)] -> PTerm -> Doc OutputAnnotation
141−pprintTerm' ist = pprintPTerm (opt_showimp (idris_options ist))
141+pprintTerm' ist bnd tm = pprintPTerm (opt_showimp (idris_options ist)) bnd [] tm
142
142
143pshow :: IState -> Err -> String
143pshow :: IState -> Err -> String
144pshow ist err = displayDecorated (consoleDecorate ist) .
144pshow ist err = displayDecorated (consoleDecorate ist) .
src/Idris/Docs.hs+5−4
@@ -33,7 +33,8 @@ showDoc d | nullDocstring d = empty
33
33
34pprintFD :: Bool -> FunDoc -> Doc OutputAnnotation
34pprintFD :: Bool -> FunDoc -> Doc OutputAnnotation
35pprintFD imp (FD n doc args ty f)
35pprintFD imp (FD n doc args ty f)
36− = nest 4 (prettyName imp [] n <+> colon <+> prettyImp imp ty <$> renderDocstring doc <$>
36+ = nest 4 (prettyName imp [] n <+> colon <+> pprintPTerm imp [] (map (\(n,_,_,_) -> n) args) ty <$>
37+ renderDocstring doc <$>
37 maybe empty (\f -> text (show f) <> line) f <>
38 maybe empty (\f -> text (show f) <> line) f <>
38 let argshow = showArgs args [] in
39 let argshow = showArgs args [] in
39 if not (null argshow)
40 if not (null argshow)
@@ -42,20 +43,20 @@ pprintFD imp (FD n doc args ty f)
42
43
43 where showArgs ((n, ty, Exp {}, d):args) bnd
44 where showArgs ((n, ty, Exp {}, d):args) bnd
44 = bindingOf n False <+> colon <+>
45 = bindingOf n False <+> colon <+>
45− pprintPTerm imp bnd ty <>
46+ pprintPTerm imp bnd [] ty <>
46 showDoc (maybe emptyDocstring id d) <> line
47 showDoc (maybe emptyDocstring id d) <> line
47 :
48 :
48 showArgs args ((n, False):bnd)
49 showArgs args ((n, False):bnd)
49 showArgs ((n, ty, Constraint {}, d):args) bnd
50 showArgs ((n, ty, Constraint {}, d):args) bnd
50 = text "Class constraint" <+>
51 = text "Class constraint" <+>
51− pprintPTerm imp bnd ty <> showDoc (maybe emptyDocstring id d) <> line
52+ pprintPTerm imp bnd [] ty <> showDoc (maybe emptyDocstring id d) <> line
52 :
53 :
53 showArgs args ((n, True):bnd)
54 showArgs args ((n, True):bnd)
54 showArgs ((n, ty, Imp {}, d):args) bnd
55 showArgs ((n, ty, Imp {}, d):args) bnd
55 | Just d' <- d
56 | Just d' <- d
56 = text "(implicit)" <+>
57 = text "(implicit)" <+>
57 bindingOf n True <+> colon <+>
58 bindingOf n True <+> colon <+>
58− pprintPTerm imp bnd ty <>
59+ pprintPTerm imp bnd [] ty <>
59 showDoc d' <> line
60 showDoc d' <> line
60 :
61 :
61 showArgs args ((n, True):bnd)
62 showArgs args ((n, True):bnd)
src/Idris/Prover.hs+5−5
@@ -104,7 +104,7 @@ dumpState ist ps@(PS nm (h:hs) _ _ tm _ _ _ _ _ _ problems i _ _ ctxy _ _ _ _) =
104 where
104 where
105 showImplicits = opt_showimp (idris_options ist)
105 showImplicits = opt_showimp (idris_options ist)
106
106
107− tPretty bnd t = pprintPTerm showImplicits bnd $ delab ist t
107+ tPretty bnd t = pprintPTerm showImplicits bnd [] $ delab ist t
108
108
109 assumptionNames :: Env -> [Name]
109 assumptionNames :: Env -> [Name]
110 assumptionNames = map fst
110 assumptionNames = map fst
@@ -236,8 +236,8 @@ ploop fn d prompt prf e h
236 TType _ ->
236 TType _ ->
237 ihPrintTermWithType h (prettyImp imp PType) type1Doc
237 ihPrintTermWithType h (prettyImp imp PType) type1Doc
238 _ -> let bnd = map (\x -> (fst x, False)) env in
238 _ -> let bnd = map (\x -> (fst x, False)) env in
239− ihPrintTermWithType h (pprintPTerm imp bnd (delab ist tm))
239+ ihPrintTermWithType h (pprintPTerm imp bnd [] (delab ist tm))
240− (pprintPTerm imp bnd (delab ist ty))
240+ (pprintPTerm imp bnd [] (delab ist ty))
241 putIState ist
241 putIState ist
242 return (False, e, False, prf))
242 return (False, e, False, prf))
243 (\err -> do putIState ist { tt_ctxt = ctxt } ; ierror err)
243 (\err -> do putIState ist { tt_ctxt = ctxt } ; ierror err)
@@ -254,8 +254,8 @@ ploop fn d prompt prf e h
254 let tm' = force (normaliseAll ctxt' env tm)
254 let tm' = force (normaliseAll ctxt' env tm)
255 ty' = force (normaliseAll ctxt' env ty)
255 ty' = force (normaliseAll ctxt' env ty)
256 imp = opt_showimp (idris_options ist')
256 imp = opt_showimp (idris_options ist')
257− tmDoc = pprintPTerm imp bnd (delab ist' tm')
257+ tmDoc = pprintPTerm imp bnd [] (delab ist' tm')
258− tyDoc = pprintPTerm imp bnd (delab ist' ty')
258+ tyDoc = pprintPTerm imp bnd [] (delab ist' ty')
259 ihPrintTermWithType (idris_outh ist') tmDoc tyDoc
259 ihPrintTermWithType (idris_outh ist') tmDoc tyDoc
260 putIState ist
260 putIState ist
261 return (False, e, False, prf))
261 return (False, e, False, prf))
src/Idris/REPL.hs+1−1
@@ -518,7 +518,7 @@ process h fn (Check (PRef _ n))
518 annotate (AnnName n Nothing Nothing) (text $ show n) <+> colon <+>
518 annotate (AnnName n Nothing Nothing) (text $ show n) <+> colon <+>
519 align (tPretty bnd ist g)
519 align (tPretty bnd ist g)
520
520
521− tPretty bnd ist t = pprintPTerm (opt_showimp (idris_options ist)) bnd t
521+ tPretty bnd ist t = pprintPTerm (opt_showimp (idris_options ist)) bnd [] t
522
522
523
523
524process h fn (Check t)
524process h fn (Check t)