ddc-core-simpl-0.4.3.1: Disciplined Disciple Compiler code transformations.

DDC.Core.Analysis.Usage

Contents

Description

Annotate let bindings with how their bound variables are used.

Synopsis

# Usage map

data Used Source #

Tracks how a bound variable is used.

Constructors

 UsedFunction Bound variable is used as the function in an application. UsedDestruct Bound variable is destructed by a case-expression. UsedInCast Bound variable is used inside a weakclo cast. UsedOcc Bound variable has an occurrence that is not one of the above. UsedInLambda Used Usage is inside a Lambda abstraction (either type or value) UsedInAlt Used Usage is inside a case alternative.

Instances

 Source # Methods(==) :: Used -> Used -> Bool #(/=) :: Used -> Used -> Bool # Source # MethodsshowsPrec :: Int -> Used -> ShowS #show :: Used -> String #showList :: [Used] -> ShowS #

data UsedMap n Source #

Map of bound name to how the variable is used.

Constructors

 UsedMap (Map n [Used])

Instances

 Show n => Show (UsedMap n) Source # MethodsshowsPrec :: Int -> UsedMap n -> ShowS #show :: UsedMap n -> String #showList :: [UsedMap n] -> ShowS #

# Usage analysis

usageModule :: Ord n => Module a n -> Module (UsedMap n, a) n Source #

Annotate all binding occurrences of variables in an expression with how they are used.

usageX :: Ord n => Exp a n -> Exp (UsedMap n, a) n Source #

Annotate all binding occurrences of variables in an expression with how they are used.