@@ -234,7 +234,6 @@ parseDeclaration = positioned (P.choice
234234 , parseValueDeclaration
235235 , parseExternDeclaration
236236 , parseFixityDeclaration
237− , parseImportDeclaration
238237 , parseTypeClassDeclaration
239238 , parseTypeInstanceDeclaration
240239 , parseDerivingInstanceDeclaration
@@ -258,7 +257,13 @@ parseModule = do
258257 name <- moduleName
259258 exports <- P.optionMaybe $ parens $ commaSep1 parseDeclarationRef
260259 reserved "where"
261− decls <- mark (P.many (same *> parseDeclaration))
260+ decls <- mark $ do
261+ -- TODO: extract a module header structure here, and provide a
262+ -- parseModuleHeader function. This should allow us to speed up rebuilds
263+ -- by only parsing as far as the module header. See PR #2054.
264+ imports <- P.many (same *> parseImportDeclaration)
265+ decls <- P.many (same *> parseDeclaration)
266+ return (imports ++ decls)
262267 _ <- P.eof
263268 end <- P.getPosition
264269 let ss = SourceSpan (P.sourceName start) (C.toSourcePos start) (C.toSourcePos end)