on master help sign in
Show defined and automatically generated class instances in different blocks
bb25a8bPaul Koerbitz
src/Idris/Docs.hs+9−4
@@ -84,10 +84,13 @@ pprintDocs imp (ClassDoc n doc meths params instances)
84 nest 4 (text "Methods:" <$>
84 nest 4 (text "Methods:" <$>
85 vsep (map (pprintFD imp) meths))
85 vsep (map (pprintFD imp) meths))
86 <$>
86 <$>
87− nest 4 (text "Instances:" <$>
87+ nest 4 (text "Defined instances:" <$>
88− let instances' = filter (not . hasConstraint) instances
89− in vsep (if null instances' then [text "<no instances>"]
88+ vsep (if null definedInstances then [text "<no instances>"]
90− else map dumpInstance instances'))
89+ else map dumpInstance definedInstances))
90+ <>
91+ if null generatedInstances then empty
92+ else line <$> nest 4 (text "Instances generated from subclasses:" <$>
93+ vsep (map dumpInstance generatedInstances))
91 where
94 where
92 params' = zip params (repeat False)
95 params' = zip params (repeat False)
93
96
@@ -98,6 +101,8 @@ pprintDocs imp (ClassDoc n doc meths params instances)
98 hasConstraint (PPi _ _ _ pt) = hasConstraint pt
101 hasConstraint (PPi _ _ _ pt) = hasConstraint pt
99 hasConstraint _ = False
102 hasConstraint _ = False
100
103
104+ (generatedInstances, definedInstances) = partition hasConstraint instances
105+
101getDocs :: Name -> Idris Docs
106getDocs :: Name -> Idris Docs
102getDocs n
107getDocs n
103 = do i <- getIState
108 = do i <- getIState