@@ -75,8 +75,8 @@ renderModules showHierarchy ms = do
7575 mapM_ (renderModule showHierarchy) ms
7676
7777renderModule :: Bool -> P.Module -> Docs
78−renderModule showHierarchy (P.Module moduleName ds exps) =
79− let exported = filter (isExported exps) ds
78+renderModule showHierarchy mdl@(P.Module moduleName _ exps) =
79+ let ds = P.exportedDeclarations mdl
8080 hasTypes = any isTypeDeclaration ds
8181 hasTypeclasses = any isTypeClassDeclaration ds
8282 hasTypeclassInstances = any isTypeInstanceDeclaration ds
@@ -87,7 +87,7 @@ renderModule showHierarchy (P.Module moduleName ds exps) =
8787 when hasTypes $ do
8888 headerLevel 3 "Types"
8989 spacer
90− renderTopLevel exps (filter isTypeDeclaration exported)
90+ renderTopLevel exps (filter isTypeDeclaration ds)
9191 spacer
9292 when hasTypeclasses $ do
9393 headerLevel 3 "Type Classes"
@@ -95,7 +95,7 @@ renderModule showHierarchy (P.Module moduleName ds exps) =
9595 when showHierarchy $ do
9696 renderTypeclassImage moduleName
9797 spacer
98− renderTopLevel exps (filter isTypeClassDeclaration exported)
98+ renderTopLevel exps (filter isTypeClassDeclaration ds)
9999 spacer
100100 when hasTypeclassInstances $ do
101101 headerLevel 3 "Type Class Instances"
@@ -105,34 +105,9 @@ renderModule showHierarchy (P.Module moduleName ds exps) =
105105 when hasValues $ do
106106 headerLevel 3 "Values"
107107 spacer
108− renderTopLevel exps (filter isValueDeclaration exported)
108+ renderTopLevel exps (filter isValueDeclaration ds)
109109 spacer
110110
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
116− where
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
125− matches _ _ = False
126−
127−isDctorExported :: P.ProperName -> Maybe [P.DeclarationRef] -> P.ProperName -> Bool
128−isDctorExported _ Nothing _ = True
129−isDctorExported ident (Just exps) ctor = test `any` exps
130− where
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
134− test _ = False
135−
136111renderTopLevel :: Maybe [P.DeclarationRef] -> [P.Declaration] -> Docs
137112renderTopLevel exps decls = forM_ (sortBy (compare `on` getName) decls) $ \decl -> do
138113 renderDeclaration 4 exps decl
@@ -152,7 +127,7 @@ renderDeclaration n exps (P.DataDeclaration dtype name args ctors) = do
152127 let
153128 typeApp = foldl P.TypeApp (P.TypeConstructor (P.Qualified Nothing name)) (map toTypeVar args)
154129 typeName = prettyPrintType' typeApp
155− exported = filter (isDctorExported name exps . fst) ctors
130+ exported = filter (P.isDctorExported name exps . fst) ctors
156131 atIndent n $ show dtype ++ " " ++ typeName ++ (if null exported then "" else " where")
157132 forM_ exported $ \(ctor, tys) ->
158133 let ctorTy = foldr P.function typeApp tys