@@ -75,8 +75,8 @@ renderModules showHierarchy ms = do
75 mapM_ (renderModule showHierarchy) ms
75 mapM_ (renderModule showHierarchy) ms
77renderModule :: Bool -> P.Module -> Docs
77renderModule :: Bool -> P.Module -> Docs
78−renderModule showHierarchy (P.Module moduleName ds exps) =
78+renderModule showHierarchy mdl@(P.Module moduleName _ exps) =
79− let exported = filter (isExported exps) ds
79+ let ds = P.exportedDeclarations mdl
80 hasTypes = any isTypeDeclaration ds
80 hasTypes = any isTypeDeclaration ds
81 hasTypeclasses = any isTypeClassDeclaration ds
81 hasTypeclasses = any isTypeClassDeclaration ds
82 hasTypeclassInstances = any isTypeInstanceDeclaration ds
82 hasTypeclassInstances = any isTypeInstanceDeclaration ds
@@ -87,7 +87,7 @@ renderModule showHierarchy (P.Module moduleName ds exps) =
87 when hasTypes $ do
87 when hasTypes $ do
88 headerLevel 3 "Types"
88 headerLevel 3 "Types"
90− renderTopLevel exps (filter isTypeDeclaration exported)
90+ renderTopLevel exps (filter isTypeDeclaration ds)
92 when hasTypeclasses $ do
92 when hasTypeclasses $ do
93 headerLevel 3 "Type Classes"
93 headerLevel 3 "Type Classes"
@@ -95,7 +95,7 @@ renderModule showHierarchy (P.Module moduleName ds exps) =
95 when showHierarchy $ do
95 when showHierarchy $ do
96 renderTypeclassImage moduleName
96 renderTypeclassImage moduleName
98− renderTopLevel exps (filter isTypeClassDeclaration exported)
98+ renderTopLevel exps (filter isTypeClassDeclaration ds)
100 when hasTypeclassInstances $ do
100 when hasTypeclassInstances $ do
101 headerLevel 3 "Type Class Instances"
101 headerLevel 3 "Type Class Instances"
@@ -105,34 +105,9 @@ renderModule showHierarchy (P.Module moduleName ds exps) =
105 when hasValues $ do
105 when hasValues $ do
106 headerLevel 3 "Values"
106 headerLevel 3 "Values"
108− renderTopLevel exps (filter isValueDeclaration exported)
108+ renderTopLevel exps (filter isValueDeclaration ds)
111−isExported :: Maybe [P.DeclarationRef] -> P.Declaration -> Bool
112−isExported Nothing _ = True
113−isExported _ P.TypeInstanceDeclaration{} = True
114−isExported exps (P.PositionedDeclaration _ d) = isExported exps d
115−isExported (Just exps) decl = any (matches decl) exps
117− matches (P.TypeDeclaration ident _) (P.ValueRef ident') = ident == ident'
118− matches (P.ExternDeclaration _ ident _ _) (P.ValueRef ident') = ident == ident'
119− matches (P.DataDeclaration _ ident _ _) (P.TypeRef ident' _) = ident == ident'
120− matches (P.ExternDataDeclaration ident _) (P.TypeRef ident' _) = ident == ident'
121− matches (P.TypeSynonymDeclaration ident _ _) (P.TypeRef ident' _) = ident == ident'
122− matches (P.TypeClassDeclaration ident _ _ _) (P.TypeClassRef ident') = ident == ident'
123− matches (P.PositionedDeclaration _ d) r = d `matches` r
124− matches d (P.PositionedDeclarationRef _ r) = d `matches` r
127−isDctorExported :: P.ProperName -> Maybe [P.DeclarationRef] -> P.ProperName -> Bool
128−isDctorExported _ Nothing _ = True
129−isDctorExported ident (Just exps) ctor = test `any` exps
131− test (P.PositionedDeclarationRef _ d) = test d
132− test (P.TypeRef ident' Nothing) = ident == ident'
133− test (P.TypeRef ident' (Just ctors)) = ident == ident' && ctor `elem` ctors
136renderTopLevel :: Maybe [P.DeclarationRef] -> [P.Declaration] -> Docs
111renderTopLevel :: Maybe [P.DeclarationRef] -> [P.Declaration] -> Docs
137renderTopLevel exps decls = forM_ (sortBy (compare `on` getName) decls) $ \decl -> do
112renderTopLevel exps decls = forM_ (sortBy (compare `on` getName) decls) $ \decl -> do
138 renderDeclaration 4 exps decl
113 renderDeclaration 4 exps decl
@@ -152,7 +127,7 @@ renderDeclaration n exps (P.DataDeclaration dtype name args ctors) = do
153 typeApp = foldl P.TypeApp (P.TypeConstructor (P.Qualified Nothing name)) (map toTypeVar args)
128 typeApp = foldl P.TypeApp (P.TypeConstructor (P.Qualified Nothing name)) (map toTypeVar args)
154 typeName = prettyPrintType' typeApp
129 typeName = prettyPrintType' typeApp
155− exported = filter (isDctorExported name exps . fst) ctors
130+ exported = filter (P.isDctorExported name exps . fst) ctors
156 atIndent n $ show dtype ++ " " ++ typeName ++ (if null exported then "" else " where")
131 atIndent n $ show dtype ++ " " ++ typeName ++ (if null exported then "" else " where")
157 forM_ exported $ \(ctor, tys) ->
132 forM_ exported $ \(ctor, tys) ->
158 let ctorTy = foldr P.function typeApp tys
133 let ctorTy = foldr P.function typeApp tys