-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Detect dead code
--
-- Find declarations.
@package weeder
@version 2.9.0
module Weeder.Config
-- | Configuration for Weeder analysis.
type Config = ConfigType Regex
-- | Configuration that has been parsed from TOML (and can still be
-- converted back), but not yet compiled to a Config.
type ConfigParsed = ConfigType String
-- | Underlying type for Config and ConfigParsed.
data ConfigType a
Config :: [a] -> Bool -> [InstancePattern a] -> Bool -> [a] -> ConfigType a
-- | Any declarations matching these regular expressions will be added to
-- the root set.
[rootPatterns] :: ConfigType a -> [a]
-- | If True, consider all declarations in a type class as part of the root
-- set. Overrides root-instances.
[typeClassRoots] :: ConfigType a -> Bool
-- | All matching instances will be added to the root set. An absent field
-- will always match.
[rootInstances] :: ConfigType a -> [InstancePattern a]
-- | Toggle to look for and output unused types. Type family instances will
-- be marked as implicit roots.
[unusedTypes] :: ConfigType a -> Bool
-- | All matching modules will be added to the root set.
[rootModules] :: ConfigType a -> [a]
compileConfig :: ConfigParsed -> Either String Config
configToToml :: ConfigParsed -> String
decodeNoDefaults :: Decoder Config
defaultConfig :: ConfigParsed
-- | Construct via InstanceOnly, ClassOnly or ModuleOnly, and combine with
-- the Semigroup instance. The Semigroup instance ignores duplicate
-- fields, prioritising the left argument.
data InstancePattern a
modulePattern :: InstancePattern a -> Maybe a
instancePattern :: InstancePattern a -> Maybe a
classPattern :: InstancePattern a -> Maybe a
pattern InstanceOnly :: a -> InstancePattern a
pattern ClassOnly :: a -> InstancePattern a
pattern ModuleOnly :: a -> InstancePattern a
instance Data.Traversable.Traversable Weeder.Config.InstancePattern
instance Data.Foldable.Foldable Weeder.Config.InstancePattern
instance GHC.Base.Functor Weeder.Config.InstancePattern
instance GHC.Classes.Ord a => GHC.Classes.Ord (Weeder.Config.InstancePattern a)
instance GHC.Show.Show a => GHC.Show.Show (Weeder.Config.InstancePattern a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Weeder.Config.InstancePattern a)
instance Data.Traversable.Traversable Weeder.Config.ConfigType
instance Data.Foldable.Foldable Weeder.Config.ConfigType
instance GHC.Base.Functor Weeder.Config.ConfigType
instance GHC.Show.Show a => GHC.Show.Show (Weeder.Config.ConfigType a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Weeder.Config.ConfigType a)
instance TOML.Decode.DecodeTOML Weeder.Config.Config
instance TOML.Decode.DecodeTOML Weeder.Config.ConfigParsed
instance GHC.Base.Semigroup (Weeder.Config.InstancePattern a)
instance TOML.Decode.DecodeTOML (Weeder.Config.InstancePattern GHC.Base.String)
module Weeder
-- | All information maintained by analyseHieFile.
data Analysis
Analysis :: Graph Declaration -> Map Declaration (Set (Int, Int)) -> Set Root -> Map Module (Set Declaration) -> Map Module FilePath -> Map Declaration String -> Map Declaration (Set Name) -> Analysis
-- | A graph between declarations, capturing dependencies.
[dependencyGraph] :: Analysis -> Graph Declaration
-- | A partial mapping between declarations and their line numbers. 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 sites, 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 (Int, Int))
-- | Stores information on Declarations that may be automatically marked as
-- always reachable. This is used, for example, to capture knowledge not
-- yet modelled in weeder, or to mark all instances of a class as roots.
[implicitRoots] :: Analysis -> Set Root
-- | 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
-- | Used to match against the types of instances and to replace the
-- appearance of declarations in the output
[prettyPrintedType] :: Analysis -> Map Declaration String
-- | Map from declarations to the names containing evidence uses that
-- should be followed and treated as dependencies of the declaration. We
-- use this to be able to delay analysing evidence uses until later,
-- allowing us to begin the rest of the analysis before we have read all
-- hie files.
[requestedEvidence] :: Analysis -> Map Declaration (Set Name)
-- | Follow evidence uses listed under requestedEvidence back to
-- their instance bindings, and connect their corresponding declaration
-- to those bindings.
analyseEvidenceUses :: RefMap TypeIndex -> Analysis -> Analysis
-- | Incrementally update Analysis with information in a
-- HieFile.
analyseHieFile :: MonadState Analysis m => Config -> HieFile -> m ()
-- | The empty analysis - the result of analysing zero .hie files.
emptyAnalysis :: Analysis
-- | The set of all declarations that could possibly appear in the output.
outputableDeclarations :: Analysis -> Set Declaration
-- | A root for reachability analysis.
data Root
-- | A given declaration is a root.
DeclarationRoot :: Declaration -> Root
-- | We store extra information for instances in order to be able to
-- specify e.g. all instances of a class as roots.
InstanceRoot :: Declaration -> 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 Control.DeepSeq.NFData Weeder.Declaration
instance GHC.Generics.Generic Weeder.Declaration
instance GHC.Classes.Ord Weeder.Declaration
instance GHC.Classes.Eq Weeder.Declaration
instance Control.DeepSeq.NFData Weeder.Root
instance GHC.Generics.Generic Weeder.Root
instance GHC.Classes.Ord Weeder.Root
instance GHC.Classes.Eq Weeder.Root
instance Control.DeepSeq.NFData Weeder.Analysis
instance GHC.Generics.Generic Weeder.Analysis
instance GHC.Base.Semigroup Weeder.Analysis
instance GHC.Base.Monoid Weeder.Analysis
instance GHC.Show.Show Weeder.Declaration
module Weeder.Run
-- | Run Weeder on the given .hie files with the given Config.
--
-- Returns a list of Weeds that can be displayed using
-- formatWeed, and the final Analysis.
runWeeder :: Config -> [HieFile] -> ([Weed], Analysis)
data Weed
Weed :: String -> FilePath -> Int -> Int -> Declaration -> Maybe String -> Weed
[weedPackage] :: Weed -> String
[weedPath] :: Weed -> FilePath
[weedLine] :: Weed -> Int
[weedCol] :: Weed -> Int
[weedDeclaration] :: Weed -> Declaration
[weedPrettyPrintedType] :: Weed -> Maybe String
formatWeed :: Weed -> String
-- | This module provides an entry point to the Weeder executable.
module Weeder.Main
-- | Parse command line arguments and into a Config and run
-- mainWithConfig.
--
-- Exits with one of the listed Weeder exit codes on failure.
main :: IO ()
-- | Run Weeder in the current working directory with a given
-- Config.
--
-- This will recursively find all files with the given extension in the
-- given directories, perform analysis, and report all unused definitions
-- according to the Config.
--
-- Exits with one of the listed Weeder exit codes on failure.
mainWithConfig :: String -> [FilePath] -> Bool -> Config -> IO ()
-- | Find and read all .hie files in the given directories according to the
-- given parameters, exiting if any are incompatible with the current
-- version of GHC. The .hie files are returned as a lazy stream in the
-- form of a list.
--
-- Will rethrow exceptions as ExceptionInLinkedThread to the
-- calling thread.
getHieFiles :: String -> [FilePath] -> Bool -> IO [HieFile]
instance GHC.Show.Show Weeder.Main.WeederException
instance GHC.Exception.Type.Exception Weeder.Main.WeederException