weeder-2.4.1: Detect dead code
Safe HaskellSafe-Inferred
LanguageHaskell2010

Weeder

Synopsis

Analysis

data Analysis Source #

All information maintained by analyseHieFile.

Constructors

Analysis 

Fields

  • dependencyGraph :: Graph Declaration

    A graph between declarations, capturing dependencies.

  • declarationSites :: Map Declaration (Set RealSrcSpan)

    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.

  • implicitRoots :: Set Declaration

    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.

  • exports :: Map Module (Set Declaration)

    All exports for a given module.

  • modulePaths :: Map Module FilePath

    A map from modules to the file path to the .hs file defining them.

Instances

Instances details
Generic Analysis Source # 
Instance details

Defined in Weeder

Associated Types

type Rep Analysis :: Type -> Type #

Methods

from :: Analysis -> Rep Analysis x #

to :: Rep Analysis x -> Analysis #

type Rep Analysis Source # 
Instance details

Defined in Weeder

analyseHieFile :: MonadState Analysis m => HieFile -> m () Source #

Incrementally update Analysis with information in a HieFile.

emptyAnalysis :: Analysis Source #

The empty analysis - the result of analysing zero .hie files.

allDeclarations :: Analysis -> Set Declaration Source #

The set of all known declarations, including usages.

Reachability

data Root Source #

A root for reachability analysis.

Constructors

DeclarationRoot Declaration

A given declaration is a root.

ModuleRoot Module

All exported declarations in a module are roots.

Instances

Instances details
Eq Root Source # 
Instance details

Defined in Weeder

Methods

(==) :: Root -> Root -> Bool #

(/=) :: Root -> Root -> Bool #

Ord Root Source # 
Instance details

Defined in Weeder

Methods

compare :: Root -> Root -> Ordering #

(<) :: Root -> Root -> Bool #

(<=) :: Root -> Root -> Bool #

(>) :: Root -> Root -> Bool #

(>=) :: Root -> Root -> Bool #

max :: Root -> Root -> Root #

min :: Root -> Root -> Root #

reachable :: Analysis -> Set Root -> Set Declaration Source #

Determine the set of all declaration reachable from a set of roots.

Declarations

data Declaration Source #

Constructors

Declaration 

Fields