-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Detect dead code
--   
--   Find declarations.
@package weeder
@version 2.2.0

module Weeder

-- | All information maintained by <a>analyseHieFile</a>.
data Analysis
Analysis :: Graph Declaration -> Map Declaration (Set RealSrcSpan) -> Set Declaration -> Map Module (Set Declaration) -> Map Module FilePath -> Analysis

-- | A graph between declarations, capturing dependencies.
[dependencyGraph] :: Analysis -> Graph Declaration

-- | A partial mapping between declarations and their definition site. This
--   Map is partial as we don't always know where a Declaration was defined
--   (e.g., it may come from a package without source code). We capture a
--   set of spans, because a declaration may be defined in multiple
--   locations, e.g., a type signature for a function separate from its
--   definition.
[declarationSites] :: Analysis -> Map Declaration (Set RealSrcSpan)

-- | The Set of all Declarations that are always reachable. This is used to
--   capture knowledge not yet modelled in weeder, such as instance
--   declarations depending on top-level functions.
[implicitRoots] :: Analysis -> Set Declaration

-- | All exports for a given module.
[exports] :: Analysis -> Map Module (Set Declaration)

-- | A map from modules to the file path to the .hs file defining them.
[modulePaths] :: Analysis -> Map Module FilePath

-- | Incrementally update <a>Analysis</a> with information in a
--   <a>HieFile</a>.
analyseHieFile :: MonadState Analysis m => HieFile -> m ()

-- | The empty analysis - the result of analysing zero <tt>.hie</tt> files.
emptyAnalysis :: Analysis

-- | The set of all known declarations, including usages.
allDeclarations :: Analysis -> Set Declaration

-- | A root for reachability analysis.
data Root

-- | A given declaration is a root.
DeclarationRoot :: Declaration -> Root

-- | All exported declarations in a module are roots.
ModuleRoot :: Module -> Root

-- | Determine the set of all declaration reachable from a set of roots.
reachable :: Analysis -> Set Root -> Set Declaration
data Declaration
Declaration :: Module -> OccName -> Declaration

-- | The module this declaration occurs in.
[declModule] :: Declaration -> Module

-- | The symbol name of a declaration.
[declOccName] :: Declaration -> OccName
instance GHC.Classes.Ord Weeder.Declaration
instance GHC.Classes.Eq Weeder.Declaration
instance GHC.Generics.Generic Weeder.Analysis
instance GHC.Classes.Ord Weeder.Root
instance GHC.Classes.Eq Weeder.Root
instance GHC.Show.Show Weeder.Declaration

module Weeder.Config

-- | Configuration for Weeder analysis.
data Config
Config :: Set String -> Bool -> Config

-- | Any declarations matching these regular expressions will be added to
--   the root set.
[rootPatterns] :: Config -> Set String

-- | If True, consider all declarations in a type class as part of the root
--   set. Weeder is currently unable to identify whether or not a type
--   class instance is used - enabling this option can prevent false
--   positives.
[typeClassRoots] :: Config -> Bool

-- | A Dhall expression decoder for <a>Config</a>.
--   
--   This parses Dhall expressions of the type <tt>{ roots : List Text,
--   type-class-roots : Bool }</tt>.
config :: Decoder Config


-- | This module provides an entry point to the Weeder executable.
module Weeder.Main

-- | Parse command line arguments and into a <a>Config</a> and run
--   <a>mainWithConfig</a>.
main :: IO ()

-- | Run Weeder in the current working directory with a given
--   <a>Config</a>.
--   
--   This will recursively find all files with the given extension in the
--   given directories, perform analysis, and report all unused definitions
--   according to the <a>Config</a>.
mainWithConfig :: String -> [FilePath] -> Bool -> Config -> IO ()
