@@ -569,6 +569,7 @@ ideslaveProcess fn (Apropos a) = do process fn (Apropos a)
569 iPrintResult ""
569 iPrintResult ""
570ideslaveProcess fn (WhoCalls n) = process fn (WhoCalls n)
570ideslaveProcess fn (WhoCalls n) = process fn (WhoCalls n)
571ideslaveProcess fn (CallsWho n) = process fn (CallsWho n)
571ideslaveProcess fn (CallsWho n) = process fn (CallsWho n)
572+ideslaveProcess fn (PrintDef n) = process fn (PrintDef n)
572ideslaveProcess fn _ = iPrintError "command not recognized or not supported"
573ideslaveProcess fn _ = iPrintError "command not recognized or not supported"
@@ -1172,6 +1173,27 @@ process fn (MakeDoc s) =
1172 else return . Left $ "Illegal name: " ++ head bad
1173 else return . Left $ "Illegal name: " ++ head bad
1173 case result of Right _ -> iputStrLn "IdrisDoc generated"
1174 case result of Right _ -> iputStrLn "IdrisDoc generated"
1174 Left err -> iPrintError err
1175 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)
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))
1195+ in ppTm lhs <+> text "=" <+> ppTm rhs
1196+ ppMissing _ = empty
1177showTotal :: Totality -> IState -> String
1199showTotal :: Totality -> IState -> String