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