@@ -569,6 +569,7 @@ ideslaveProcess fn (Apropos a) = do process fn (Apropos a)
569569 iPrintResult ""
570570ideslaveProcess fn (WhoCalls n) = process fn (WhoCalls n)
571571ideslaveProcess fn (CallsWho n) = process fn (CallsWho n)
572+ideslaveProcess fn (PrintDef n) = process fn (PrintDef n)
572573ideslaveProcess fn _ = iPrintError "command not recognized or not supported"
573574
574575
@@ -1172,6 +1173,27 @@ process fn (MakeDoc s) =
11721173 else return . Left $ "Illegal name: " ++ head bad
11731174 case result of Right _ -> iputStrLn "IdrisDoc generated"
11741175 Left err -> iPrintError err
1176+process fn (PrintDef n) =
1177+ do ist <- getIState
1178+ let patdefs = idris_patdefs ist
1179+ result = map (ppDef ist) (lookupCtxtName n patdefs)
1180+ case result of
1181+ [] -> iPrintError "Not found"
1182+ outs -> iRenderResult . vsep $ outs
1183+ where ppDef :: IState -> (Name, ([([Name], Term, Term)], [PTerm])) -> Doc OutputAnnotation
1184+ ppDef ist (n, (clauses, missing)) =
1185+ prettyName True True [] n <+> colon <+>
1186+ pprintPTerm (ppOptionIst ist) [] [] [] (delabTy ist n) <$>
1187+ indent 2 (ppClauses ist clauses <> ppMissing missing)
1188+ ppClauses ist [] = text "No clauses."
1189+ ppClauses ist cs = vsep (map pp cs)
1190+ where pp (vars, lhs, rhs) =
1191+ let ppTm = pprintPTerm (ppOptionIst ist)
1192+ (zip vars (repeat False))
1193+ [] [] .
1194+ delab ist
1195+ in ppTm lhs <+> text "=" <+> ppTm rhs
1196+ ppMissing _ = empty
11751197
11761198
11771199showTotal :: Totality -> IState -> String