{-
    Suggest using better export declarations

<TEST>
main = 1
module Foo where foo = 1 -- module Foo(module Foo) where
module Foo(foo) where foo = 1
module Foo(module Foo) where foo = 1 -- @Ignore module Foo(...) where
module Foo(module Foo, foo) where foo = 1 -- module Foo(..., foo) where
</TEST>
-}

module Hint.Export(exportHint) where

import Hint.Type


exportHint :: ModuHint
exportHint :: ModuHint
exportHint _ (Module _ (Just o :: ModuleHead S
o@(ModuleHead a :: S
a name :: ModuleName S
name warning :: Maybe (WarningText S)
warning exports :: Maybe (ExportSpecList S)
exports)) _ _ _)
    | Maybe (ExportSpecList S)
Nothing <- Maybe (ExportSpecList S)
exports =
        let o2 :: ModuleHead S
o2 = S
-> ModuleName S
-> Maybe (WarningText S)
-> Maybe (ExportSpecList S)
-> ModuleHead S
forall l.
l
-> ModuleName l
-> Maybe (WarningText l)
-> Maybe (ExportSpecList l)
-> ModuleHead l
ModuleHead S
a ModuleName S
name Maybe (WarningText S)
warning (Maybe (ExportSpecList S) -> ModuleHead S)
-> Maybe (ExportSpecList S) -> ModuleHead S
forall a b. (a -> b) -> a -> b
$ ExportSpecList S -> Maybe (ExportSpecList S)
forall a. a -> Maybe a
Just (ExportSpecList S -> Maybe (ExportSpecList S))
-> ExportSpecList S -> Maybe (ExportSpecList S)
forall a b. (a -> b) -> a -> b
$ S -> [ExportSpec S] -> ExportSpecList S
forall l. l -> [ExportSpec l] -> ExportSpecList l
ExportSpecList S
a [S -> ModuleName S -> ExportSpec S
forall l. l -> ModuleName l -> ExportSpec l
EModuleContents S
a ModuleName S
name]
        in [(String
-> ModuleHead S -> ModuleHead S -> [Refactoring SrcSpan] -> Idea
forall (ast :: * -> *) a.
(Annotated ast, Pretty a, Pretty (ast S)) =>
String -> ast S -> a -> [Refactoring SrcSpan] -> Idea
ignore "Use module export list" ModuleHead S
o ModuleHead S
o2 []){ideaNote :: [Note]
ideaNote = [String -> Note
Note "an explicit list is usually better"]}]
    | Just (ExportSpecList _ xs :: [ExportSpec S]
xs) <- Maybe (ExportSpecList S)
exports, S -> ModuleName S -> ExportSpec S
forall l. l -> ModuleName l -> ExportSpec l
EModuleContents S
a ModuleName S
name ExportSpec S -> [ExportSpec S] -> Bool
forall (f :: * -> *).
(Annotated f, Eq (f ())) =>
f S -> [f S] -> Bool
`elem_` [ExportSpec S]
xs =
        let o2 :: ModuleHead S
o2 = S
-> ModuleName S
-> Maybe (WarningText S)
-> Maybe (ExportSpecList S)
-> ModuleHead S
forall l.
l
-> ModuleName l
-> Maybe (WarningText l)
-> Maybe (ExportSpecList l)
-> ModuleHead l
ModuleHead S
a ModuleName S
name Maybe (WarningText S)
warning (Maybe (ExportSpecList S) -> ModuleHead S)
-> Maybe (ExportSpecList S) -> ModuleHead S
forall a b. (a -> b) -> a -> b
$ ExportSpecList S -> Maybe (ExportSpecList S)
forall a. a -> Maybe a
Just (ExportSpecList S -> Maybe (ExportSpecList S))
-> ExportSpecList S -> Maybe (ExportSpecList S)
forall a b. (a -> b) -> a -> b
$ S -> [ExportSpec S] -> ExportSpecList S
forall l. l -> [ExportSpec l] -> ExportSpecList l
ExportSpecList S
a ([ExportSpec S] -> ExportSpecList S)
-> [ExportSpec S] -> ExportSpecList S
forall a b. (a -> b) -> a -> b
$ S -> QName S -> ExportSpec S
forall l. l -> QName l -> ExportSpec l
EVar S
a QName S
ellipses ExportSpec S -> [ExportSpec S] -> [ExportSpec S]
forall a. a -> [a] -> [a]
: ExportSpec S -> [ExportSpec S] -> [ExportSpec S]
forall (f :: * -> *).
(Annotated f, Eq (f ())) =>
f S -> [f S] -> [f S]
delete_ (S -> ModuleName S -> ExportSpec S
forall l. l -> ModuleName l -> ExportSpec l
EModuleContents S
a ModuleName S
name) [ExportSpec S]
xs
        in [String
-> ModuleHead S -> ModuleHead S -> [Refactoring SrcSpan] -> Idea
forall (ast :: * -> *) a.
(Annotated ast, Pretty a, Pretty (ast S)) =>
String -> ast S -> a -> [Refactoring SrcSpan] -> Idea
ignore "Use explicit module export list" ModuleHead S
o ModuleHead S
o2 []]
exportHint _ _ = []