Agda-2.3.2: A dependently typed functional programming language and proof assistant

Safe Haskell | None

Agda.Compiler.Epic.Erasure

Description

Some arguments to functions (types in particular) will not be used in the body. Wouldn't it be useful if these wasn't passed around at all? Fear not, we here perform some analysis and try to remove as many of these occurences as possible.

We employ the worker/wrapper transform, so if f x1 .. xn = e and we notice that some is not needed we create: f' xj .. xk = e [xi := unit] and f x1 .. xn = f' xj .. xk. i.e we erase them in f' and replace by unit, and the original f function calls the new f'. The idea is that f should be inlined and then peace on earth.

Synopsis

- isIrr :: Relevance -> Bool
- isRel :: Relevance -> Bool
- (||-) :: Relevance -> Relevance -> Relevance
- (&&-) :: Relevance -> Relevance -> Relevance
- data ErasureState = ErasureState {
  - relevancies :: Map Var [Relevance]
  - funs :: Map Var Fun
  }
- type Erasure = StateT ErasureState
- erasure :: [Fun] -> Compile TCM [Fun]
- removeUnused :: Map Var [Relevance] -> Expr -> Expr
- initiate :: Fun -> Erasure (Compile TCM) ()
- initialRels :: Type -> Relevance -> [Relevance]
- ignoreForced :: Relevance -> Bool
- relevant :: (Functor m, Monad m) => Var -> Expr -> Erasure m Relevance
- step :: Integer -> Erasure (Compile TCM) (Map Var [Relevance])
- diff :: (Ord k, Eq a) => Map k a -> Map k a -> [(k, (a, a))]

# Documentation

isIrr :: Relevance -> Bool

isRel :: Relevance -> Bool

(||-) :: Relevance -> Relevance -> Relevance

Relevance or

(&&-) :: Relevance -> Relevance -> Relevance

Relevance and

data ErasureState

Constructors

ErasureState |

Fields

relevancies :: Map Var [Relevance]
funs :: Map Var Fun

type Erasure = StateT ErasureState

erasure :: [Fun] -> Compile TCM [Fun]

Try to find as many unused variables as possible

removeUnused :: Map Var [Relevance] -> Expr -> Expr

initiate :: Fun -> Erasure (Compile TCM) ()

Initiate a function's relevancies

initialRels :: Type -> Relevance -> [Relevance]

ignoreForced :: Relevance -> Bool

relevant :: (Functor m, Monad m) => Var -> Expr -> Erasure m Relevance

Calculate if a variable is relevant in an expression

step :: Integer -> Erasure (Compile TCM) (Map Var [Relevance])

Try to find a fixpoint for all the functions relevance.

diff :: (Ord k, Eq a) => Map k a -> Map k a -> [(k, (a, a))]