@@ -29,6 +29,7 @@ data Docs = FunDoc FunDoc
29 [FunDoc] -- method docs
29 [FunDoc] -- method docs
30 [(Name, Maybe Docstring)] -- parameters and their docstrings
30 [(Name, Maybe Docstring)] -- parameters and their docstrings
31 [PTerm] -- instances
31 [PTerm] -- instances
32+ [PTerm] -- superclasses
32 deriving Show
33 deriving Show
34showDoc d | nullDocstring d = empty
35showDoc d | nullDocstring d = empty
@@ -77,7 +78,7 @@ pprintDocs ist (DataDoc t args)
77 if null args then text "No constructors."
78 if null args then text "No constructors."
78 else nest 4 (text "Constructors:" <> line <>
79 else nest 4 (text "Constructors:" <> line <>
79 vsep (map (pprintFD ist) args))
80 vsep (map (pprintFD ist) args))
80−pprintDocs ist (ClassDoc n doc meths params instances)
81+pprintDocs ist (ClassDoc n doc meths params instances superclasses)
81 = nest 4 (text "Type class" <+> prettyName (ppopt_impl ppo) [] n <>
82 = nest 4 (text "Type class" <+> prettyName (ppopt_impl ppo) [] n <>
82 if nullDocstring doc then empty else line <> renderDocstring doc)
83 if nullDocstring doc then empty else line <> renderDocstring doc)
83 <> line <$>
84 <> line <$>
@@ -90,9 +91,13 @@ pprintDocs ist (ClassDoc n doc meths params instances)
90 vsep (if null instances' then [text "<no instances>"]
91 vsep (if null instances' then [text "<no instances>"]
91 else map dumpInstance instances'))
92 else map dumpInstance instances'))
93− if null subclasses then empty
94+ (if null subclasses then empty
94− else line <$> nest 4 (text "Subclasses:" <$>
95+ else line <$> nest 4 (text "Subclasses:" <$>
95− vsep (map (dumpInstance . prettifySubclasses) subclasses))
96+ vsep (map (dumpInstance . prettifySubclasses) subclasses)))
98+ (if null superclasses then empty
99+ else line <$> nest 4 (text "Default superclass instances:" <$>
100+ vsep (map dumpInstance superclasses)))
97 params' = zip pNames (repeat False)
102 params' = zip pNames (repeat False)
@@ -119,11 +124,11 @@ pprintDocs ist (ClassDoc n doc meths params instances)
119 updateRef nm (PRef fc _) = PRef fc nm
124 updateRef nm (PRef fc _) = PRef fc nm
120 updateRef _ pt = pt
125 updateRef _ pt = pt
122− hasConstraint (PPi (Constraint _ _) _ _ _) = True
127+ isSubclass (PPi (Constraint _ _) _ (PApp _ _ args) (PApp _ (PRef _ nm) args')) = nm == n && map getTm args == map getTm args'
123− hasConstraint (PPi _ _ _ pt) = hasConstraint pt
128+ isSubclass (PPi _ _ _ pt) = isSubclass pt
124− hasConstraint _ = False
129+ isSubclass _ = False
126− (subclasses, instances') = partition hasConstraint instances
131+ (subclasses, instances') = partition isSubclass instances
128 prettyParameters = if any (isJust . snd) params
133 prettyParameters = if any (isJust . snd) params
129 then vsep (map (\(nm,md) -> prettyName False params' nm <+> maybe empty showDoc md) params)
134 then vsep (map (\(nm,md) -> prettyName False params' nm <+> maybe empty showDoc md) params)
@@ -152,8 +157,12 @@ docClass n ci
152 docstr = maybe emptyDocstring fst docStrings
157 docstr = maybe emptyDocstring fst docStrings
153 params = map (\pn -> (pn, docStrings >>= (lookup pn . snd))) (class_params ci)
158 params = map (\pn -> (pn, docStrings >>= (lookup pn . snd))) (class_params ci)
154 instances = map (delabTy i) (class_instances ci)
159 instances = map (delabTy i) (class_instances ci)
160+ superclasses = catMaybes $ map getDInst (class_default_superclasses ci)
155− mdocs <- mapM (docFun .fst) (class_methods ci)
161+ mdocs <- mapM (docFun . fst) (class_methods ci)
156− return $ ClassDoc n docstr mdocs params instances
162+ return $ ClassDoc n docstr mdocs params instances superclasses
164+ getDInst (PInstance _ _ _ _ _ t _ _) = Just t
165+ getDInst _ = Nothing
158docFun :: Name -> Idris FunDoc
167docFun :: Name -> Idris FunDoc
@@ -192,6 +201,3 @@ pprintConstDocs ist c str = text "Primitive" <+> text (if constIsType c then "ty
192 t (Str _) = PConstant StrType
201 t (Str _) = PConstant StrType
193 t (Ch c) = PConstant $ AType (ATInt ITChar)
202 t (Ch c) = PConstant $ AType (ATInt ITChar)
194 t _ = PType
203 t _ = PType