File: Export.hs

package info (click to toggle)
hlint 2.1.10-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 588 kB
  • sloc: haskell: 4,475; lisp: 86; makefile: 5
file content (26 lines) | stat: -rw-r--r-- 981 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{-
    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 _ (Module _ (Just o@(ModuleHead a name warning exports)) _ _ _)
    | Nothing <- exports =
        let o2 = ModuleHead a name warning $ Just $ ExportSpecList a [EModuleContents a name]
        in [(ignore "Use module export list" o o2 []){ideaNote = [Note "an explicit list is usually better"]}]
    | Just (ExportSpecList _ xs) <- exports, EModuleContents a name `elem_` xs =
        let o2 = ModuleHead a name warning $ Just $ ExportSpecList a $ EVar a ellipses : delete_ (EModuleContents a name) xs
        in [ignore "Use explicit module export list" o o2 []]
exportHint _ _ = []