@@ -116,10 +116,12 @@ isExported (Just exps) decl = any (matches decl) exps
117isDctorExported :: P.ProperName -> Maybe [P.DeclarationRef] -> P.ProperName -> Bool
117isDctorExported :: P.ProperName -> Maybe [P.DeclarationRef] -> P.ProperName -> Bool
118isDctorExported _ Nothing _ = True
118isDctorExported _ Nothing _ = True
119−isDctorExported ident (Just exps) ctor = flip any exps $ \e -> case e of
119+isDctorExported ident (Just exps) ctor = test `any` exps
121+ test (P.PositionedDeclarationRef _ d) = test d
120− P.TypeRef ident' Nothing -> ident == ident'
122+ test (P.TypeRef ident' Nothing) = ident == ident'
121− P.TypeRef ident' (Just ctors) -> ident == ident' && ctor `elem` ctors
123+ test (P.TypeRef ident' (Just ctors)) = ident == ident' && ctor `elem` ctors
122− _ -> False
124+ test _ = False
124renderTopLevel :: Maybe [P.DeclarationRef] -> [P.Declaration] -> Docs
126renderTopLevel :: Maybe [P.DeclarationRef] -> [P.Declaration] -> Docs
125renderTopLevel exps decls = forM_ (sortBy (compare `on` getName) decls) $ \decl -> do
127renderTopLevel exps decls = forM_ (sortBy (compare `on` getName) decls) $ \decl -> do
@@ -137,9 +139,9 @@ renderDeclaration n _ (P.TypeDeclaration ident ty) =
137renderDeclaration n _ (P.ExternDeclaration _ ident _ ty) =
139renderDeclaration n _ (P.ExternDeclaration _ ident _ ty) =
138 atIndent n $ show ident ++ " :: " ++ P.prettyPrintType ty
140 atIndent n $ show ident ++ " :: " ++ P.prettyPrintType ty
139renderDeclaration n exps (P.DataDeclaration name args ctors) = do
141renderDeclaration n exps (P.DataDeclaration name args ctors) = do
140− let typeName = P.runProperName name ++ " " ++ unwords args
142+ let typeName = P.runProperName name ++ (if null args then "" else " " ++ unwords args)
141− atIndent n $ "data " ++ typeName ++ " where"
142 let exported = filter (isDctorExported name exps . fst) ctors
143 let exported = filter (isDctorExported name exps . fst) ctors
144+ atIndent n $ "data " ++ typeName ++ (if null exported then "" else " where")
143 forM_ exported $ \(ctor, tys) ->
145 forM_ exported $ \(ctor, tys) ->
144 atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ concatMap (\ty -> P.prettyPrintType ty ++ " -> ") tys ++ typeName
146 atIndent (n + 2) $ P.runProperName ctor ++ " :: " ++ concatMap (\ty -> P.prettyPrintType ty ++ " -> ") tys ++ typeName
145renderDeclaration n _ (P.ExternDataDeclaration name kind) =
147renderDeclaration n _ (P.ExternDataDeclaration name kind) =