@@ -59,7 +59,7 @@ isExported (Just exps) decl = any (matches decl) exps
5959 matches _ _ = False
6060
6161exportedDeclarations :: Module -> [Declaration]
62−exportedDeclarations (Module _ decls exps) = filter (isExported exps) decls
62+exportedDeclarations (Module _ decls exps) = filter (isExported exps) (flattenDecls decls)
6363
6464-- |
6565-- Test if a data constructor for a given type is exported, given a module's export list.
@@ -80,7 +80,7 @@ exportedDctors :: Module -> ProperName -> [ProperName]
8080exportedDctors (Module _ decls exps) ident =
8181 filter (isDctorExported ident exps) dctors
8282 where
83− dctors = concatMap getDctors decls
83+ dctors = concatMap getDctors (flattenDecls decls)
8484 getDctors (DataDeclaration _ _ _ ctors) = map fst ctors
8585 getDctors (PositionedDeclaration _ d) = getDctors d
8686 getDctors _ = []
@@ -267,6 +267,14 @@ isTypeClassDeclaration TypeInstanceDeclaration{} = True
267267isTypeClassDeclaration (PositionedDeclaration _ d) = isTypeClassDeclaration d
268268isTypeClassDeclaration _ = False
269269
270+-- |
271+-- Recursively flatten data binding groups in the list of declarations
272+flattenDecls :: [Declaration] -> [Declaration]
273+flattenDecls = concatMap flattenOne
274+ where flattenOne :: Declaration -> [Declaration]
275+ flattenOne (DataBindingGroupDeclaration decls) = concatMap flattenOne decls
276+ flattenOne d = [d]
277+
270278-- |
271279-- A guard is just a boolean-valued expression that appears alongside a set of binders
272280--