clash-lib-1.4.6: Clash: a functional hardware description language - As a library
Copyright(C) 2020 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Core.PartialEval

Description

The main API of the partial evaluator. This exposes the main functions needed to call the evaluator, and the type of evaluators. A concrete implementation of an evaluator is required to use this module: this can be imported from the library for the compiler front-end, e.g. Clash.GHC.PartialEval in clash-ghc.

Synopsis

Documentation

data Evaluator Source #

An evaluator for Clash core. This consists of two functions: one to evaluate a term to weak-head normal form (WHNF) and another to recursively evaluate sub-terms to obtain beta-normal eta-long form (NF).

Constructors

Evaluator 

whnf Source #

Arguments

:: Evaluator

The evaluator implementation to use.

-> GlobalEnv

The initial global environment.

-> Bool

Whether evaluation should keep lifted data constructors. See NOTE [Lifted Constructors] in Clash.Core.PartialEval.NormalForm.

-> Id

The id of the term under evaluation.

-> Term

The term under evaluation.

-> IO (Term, GlobalEnv)

The term evalated to WHNF, and the final global environment.

Evaluate a term to WHNF, converting the result back to a Term. The global environment at the end of evaluation is also returned, callers should preserve any parts of the global environment needed for later calls.

nf Source #

Arguments

:: Evaluator

The evaluator implementation to use.

-> GlobalEnv

The initial global environment.

-> Bool

Whether evaluation should keep lifted data constructors. See NOTE [Lifted Constructors] in Clash.Core.PartialEval.NormalForm.

-> Id

The id of the term under evaluation.

-> Term

The term under evaluation.

-> IO (Term, GlobalEnv)

The term evalated to NF, and the final global environment.

Evaluate a term to NF, converting the result back to a Term. See whnf for more details.

mkGlobalEnv Source #

Arguments

:: BindingMap

Global bindings available to the evaluator.

-> TyConMap

The type constructors known by Clash.

-> InScopeSet

The set of variables in scope during evaluation.

-> Supply

The supply of fresh names for variables.

-> Word

The initial supply of fuel.

-> IntMap Value

The initial IO heap.

-> Int

The address of the next heap element.

-> GlobalEnv