@@ -35,14 +35,14 @@ renderPackage name vers mods =
35-- Render a single Module.
35-- Render a single Module.
37renderModule :: P.Module -> RenderedModule
37renderModule :: P.Module -> RenderedModule
38−renderModule m@(P.Module coms moduleName _ exps) =
38+renderModule m@(P.Module coms moduleName _ _) =
39 RenderedModule (show moduleName) comments declarations
39 RenderedModule (show moduleName) comments declarations
41 comments = renderComments coms
41 comments = renderComments coms
42 declarations = groupChildren declarationsWithChildren
42 declarations = groupChildren declarationsWithChildren
43 declarationsWithChildren = mapMaybe go (P.exportedDeclarations m)
43 declarationsWithChildren = mapMaybe go (P.exportedDeclarations m)
44 go decl = getDeclarationTitle decl
44 go decl = getDeclarationTitle decl
45− >>= renderDeclaration exps decl
45+ >>= renderDeclaration decl
47-- | An intermediate stage which we go through during rendering.
47-- | An intermediate stage which we go through during rendering.
@@ -95,39 +95,38 @@ getDeclarationTitle _ = Nothing
95basicDeclaration :: String -> RenderedCode -> Maybe IntermediateDeclaration
95basicDeclaration :: String -> RenderedCode -> Maybe IntermediateDeclaration
96basicDeclaration title code = Just (Right (RenderedDeclaration title Nothing code Nothing []))
96basicDeclaration title code = Just (Right (RenderedDeclaration title Nothing code Nothing []))
98−renderDeclaration :: Maybe [P.DeclarationRef] -> P.Declaration -> String -> Maybe IntermediateDeclaration
98+renderDeclaration :: P.Declaration -> String -> Maybe IntermediateDeclaration
99−renderDeclaration _ (P.TypeDeclaration ident' ty) title =
99+renderDeclaration (P.TypeDeclaration ident' ty) title =
100 basicDeclaration title code
100 basicDeclaration title code
102 code = ident (show ident')
102 code = ident (show ident')
103 <> sp <> syntax "::" <> sp
103 <> sp <> syntax "::" <> sp
104 <> renderType ty
104 <> renderType ty
105−renderDeclaration _ (P.ExternDeclaration _ ident' _ ty) title =
105+renderDeclaration (P.ExternDeclaration _ ident' _ ty) title =
106 basicDeclaration title code
106 basicDeclaration title code
108 code = ident (show ident')
108 code = ident (show ident')
109 <> sp <> syntax "::" <> sp
109 <> sp <> syntax "::" <> sp
110 <> renderType ty
110 <> renderType ty
111−renderDeclaration exps (P.DataDeclaration dtype name args ctors) title =
111+renderDeclaration (P.DataDeclaration dtype name args ctors) title =
112 Just (Right (RenderedDeclaration title Nothing code Nothing children))
112 Just (Right (RenderedDeclaration title Nothing code Nothing children))
114 typeApp = foldl P.TypeApp (P.TypeConstructor (P.Qualified Nothing name)) (map toTypeVar args)
114 typeApp = foldl P.TypeApp (P.TypeConstructor (P.Qualified Nothing name)) (map toTypeVar args)
115− exported = filter (P.isDctorExported name exps . fst) ctors
116 code = keyword (show dtype) <> sp <> renderType typeApp
115 code = keyword (show dtype) <> sp <> renderType typeApp
117− children = map renderCtor exported
116+ children = map renderCtor ctors
118 -- TODO: Comments for data constructors?
117 -- TODO: Comments for data constructors?
119 renderCtor (ctor', tys) =
118 renderCtor (ctor', tys) =
120 let typeApp' = foldl P.TypeApp (P.TypeConstructor (P.Qualified Nothing ctor')) tys
119 let typeApp' = foldl P.TypeApp (P.TypeConstructor (P.Qualified Nothing ctor')) tys
121 childCode = renderType typeApp'
120 childCode = renderType typeApp'
122 in RenderedChildDeclaration (show ctor') Nothing childCode Nothing ChildDataConstructor
121 in RenderedChildDeclaration (show ctor') Nothing childCode Nothing ChildDataConstructor
123−renderDeclaration _ (P.ExternDataDeclaration name kind') title =
122+renderDeclaration (P.ExternDataDeclaration name kind') title =
124 basicDeclaration title code
123 basicDeclaration title code
126 code = keywordData <> sp
125 code = keywordData <> sp
127 <> renderType (P.TypeConstructor (P.Qualified Nothing name))
126 <> renderType (P.TypeConstructor (P.Qualified Nothing name))
128 <> sp <> syntax "::" <> sp
127 <> sp <> syntax "::" <> sp
129 <> renderKind kind'
128 <> renderKind kind'
130−renderDeclaration _ (P.TypeSynonymDeclaration name args ty) title =
129+renderDeclaration (P.TypeSynonymDeclaration name args ty) title =
131 basicDeclaration title code
130 basicDeclaration title code
133 typeApp = foldl P.TypeApp (P.TypeConstructor (P.Qualified Nothing name)) (map toTypeVar args)
132 typeApp = foldl P.TypeApp (P.TypeConstructor (P.Qualified Nothing name)) (map toTypeVar args)
@@ -137,7 +136,7 @@ renderDeclaration _ (P.TypeSynonymDeclaration name args ty) title =
137 , syntax "="
136 , syntax "="
138 , renderType ty
137 , renderType ty
140−renderDeclaration _ (P.TypeClassDeclaration name args implies ds) title = do
139+renderDeclaration (P.TypeClassDeclaration name args implies ds) title = do
141 Just (Right (RenderedDeclaration title Nothing code Nothing children))
140 Just (Right (RenderedDeclaration title Nothing code Nothing children))
143 code = mintersperse sp $
142 code = mintersperse sp $
@@ -172,7 +171,7 @@ renderDeclaration _ (P.TypeClassDeclaration name args implies ds) title = do
173 in RenderedChildDeclaration (show ident') Nothing childCode Nothing ChildTypeClassMember
172 in RenderedChildDeclaration (show ident') Nothing childCode Nothing ChildTypeClassMember
174 renderClassMember _ = error "Invalid argument to renderClassMember."
173 renderClassMember _ = error "Invalid argument to renderClassMember."
175−renderDeclaration _ (P.TypeInstanceDeclaration name constraints className tys _) title = do
174+renderDeclaration (P.TypeInstanceDeclaration name constraints className tys _) title = do
176 Just (Left (classNameString : typeNameStrings, childDecl))
175 Just (Left (classNameString : typeNameStrings, childDecl))
178 classNameString = unQual className
177 classNameString = unQual className
@@ -204,15 +203,15 @@ renderDeclaration _ (P.TypeInstanceDeclaration name constraints className tys _)
204 in renderType supApp
203 in renderType supApp
206 classApp = foldl P.TypeApp (P.TypeConstructor className) tys
205 classApp = foldl P.TypeApp (P.TypeConstructor className) tys
207−renderDeclaration exps (P.PositionedDeclaration srcSpan com d') title =
206+renderDeclaration (P.PositionedDeclaration srcSpan com d') title =
208− fmap (addComments . addSourceSpan) (renderDeclaration exps d' title)
207+ fmap (addComments . addSourceSpan) (renderDeclaration d' title)
210 addComments (Left (t, d)) = Left (t, d { rcdComments = renderComments com })
209 addComments (Left (t, d)) = Left (t, d { rcdComments = renderComments com })
211 addComments (Right d) = Right (d { rdComments = renderComments com })
210 addComments (Right d) = Right (d { rdComments = renderComments com })
213 addSourceSpan (Left (t, d)) = Left (t, d { rcdSourceSpan = Just srcSpan })
212 addSourceSpan (Left (t, d)) = Left (t, d { rcdSourceSpan = Just srcSpan })
214 addSourceSpan (Right d) = Right (d { rdSourceSpan = Just srcSpan })
213 addSourceSpan (Right d) = Right (d { rdSourceSpan = Just srcSpan })
215−renderDeclaration _ _ _ = Nothing
214+renderDeclaration _ _ = Nothing
217renderComments :: [P.Comment] -> Maybe String
216renderComments :: [P.Comment] -> Maybe String
218renderComments cs = do
217renderComments cs = do