@@ -81,7 +81,7 @@ import Control.Concurrent.MVar
81import Network
81import Network
82import Control.Concurrent
82import Control.Concurrent
83import Data.Maybe
83import Data.Maybe
84−import Data.List
84+import Data.List hiding (group)
85import Data.Char
85import Data.Char
86import Data.Version
86import Data.Version
87import Data.Word (Word)
87import Data.Word (Word)
@@ -477,6 +477,16 @@ runIdeSlaveCommand h id orig fn modes (IdeSlave.TermShowImplicits bnd tm) =
477 ideSlaveForceTermImplicits h id bnd True tm
477 ideSlaveForceTermImplicits h id bnd True tm
478runIdeSlaveCommand h id orig fn modes (IdeSlave.TermNoImplicits bnd tm) =
478runIdeSlaveCommand h id orig fn modes (IdeSlave.TermNoImplicits bnd tm) =
479 ideSlaveForceTermImplicits h id bnd False tm
479 ideSlaveForceTermImplicits h id bnd False tm
480+runIdeSlaveCommand h id orig fn mods (IdeSlave.PrintDef name) =
481+ case splitName name of
482+ Left err -> iPrintError err
483+ Right n -> process "(ideslave)" (PrintDef n)
484+ where splitName :: String -> Either String Name
485+ splitName s = case reverse $ splitOn "." s of
486+ [] -> Left ("Didn't understand name '" ++ s ++ "'")
487+ [n] -> Right $ sUN n
488+ (n:ns) -> Right $ sNS (sUN n) ns
481-- | Show a term for IDESlave with the specified implicitness
491-- | Show a term for IDESlave with the specified implicitness
482ideSlaveForceTermImplicits :: Handle -> Integer -> [(Name, Bool)] -> Bool -> Term -> Idris ()
492ideSlaveForceTermImplicits :: Handle -> Integer -> [(Name, Bool)] -> Bool -> Term -> Idris ()
@@ -1172,26 +1182,42 @@ process fn (MakeDoc s) =
1172 Left err -> iPrintError err
1182 Left err -> iPrintError err
1173process fn (PrintDef n) =
1183process fn (PrintDef n) =
1174 do ist <- getIState
1184 do ist <- getIState
1175 let patdefs = idris_patdefs ist
1186 let patdefs = idris_patdefs ist
1187+ tyinfo = idris_datatypes ist
1176− result = map (ppDef ist) (lookupCtxtName n patdefs)
1188+ result = map (ppDef ist) (lookupCtxtName n patdefs) ++
1189+ map (ppTy ist) (lookupCtxtName n tyinfo) ++
1190+ map (ppCon ist) (filter (flip isDConName ctxt) (lookupNames n ctxt))
1177 case result of
1191 case result of
1178 [] -> iPrintError "Not found"
1192 [] -> iPrintError "Not found"
1179 outs -> iRenderResult . vsep $ outs
1193 outs -> iRenderResult . vsep $ outs
1180 where ppDef :: IState -> (Name, ([([Name], Term, Term)], [PTerm])) -> Doc OutputAnnotation
1194 where ppDef :: IState -> (Name, ([([Name], Term, Term)], [PTerm])) -> Doc OutputAnnotation
1181 ppDef ist (n, (clauses, missing)) =
1195 ppDef ist (n, (clauses, missing)) =
1182 prettyName True True [] n <+> colon <+>
1196 prettyName True True [] n <+> colon <+>
1183− pprintPTerm (ppOptionIst ist) [] [] [] (delabTy ist n) <$>
1197+ align (pprintDelabTy ist n) <$>
1184 indent 2 (ppClauses ist clauses <> ppMissing missing)
1198 indent 2 (ppClauses ist clauses <> ppMissing missing)
1185 ppClauses ist [] = text "No clauses."
1199 ppClauses ist [] = text "No clauses."
1186 ppClauses ist cs = vsep (map pp cs)
1200 ppClauses ist cs = vsep (map pp cs)
1187 where pp (vars, lhs, rhs) =
1201 where pp (vars, lhs, rhs) =
1202+ let ppTm t = annotate (AnnTerm (zip vars (repeat False)) t) .
1188− let ppTm = pprintPTerm (ppOptionIst ist)
1203+ pprintPTerm (ppOptionIst ist)
1189− (zip vars (repeat False))
1204+ (zip vars (repeat False))
1190− [] [] .
1205+ [] [] .
1191− delab ist
1206+ delab ist $
1192− in ppTm lhs <+> text "=" <+> ppTm rhs
1208+ in group $ ppTm lhs <+> text "=" <$> (group . align . hang 2 $ ppTm rhs)
1193 ppMissing _ = empty
1209 ppMissing _ = empty
1211+ ppTy :: IState -> (Name, TypeInfo) -> Doc OutputAnnotation
1212+ ppTy ist (n, TI constructors isCodata _ _ _)
1213+ = kwd key <+> prettyName True True [] n <+> colon <+>
1214+ align (pprintDelabTy ist n) <+> kwd "where" <$>
1215+ indent 2 (vsep (map (ppCon ist) constructors))
1217+ key | isCodata = "codata"
1218+ | otherwise = "data"
1219+ kwd = annotate AnnKeyword . text
1220+ ppCon ist n = prettyName True False [] n <+> colon <+> align (pprintDelabTy ist n)
1196showTotal :: Totality -> IState -> String
1222showTotal :: Totality -> IState -> String
1197showTotal t@(Partial (Other ns)) i
1223showTotal t@(Partial (Other ns)) i