clash-lib-1.4.1: Clash: a functional hardware description language - As a library
Copyright(C) 2020 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <christiaan.baaij@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Core.Evaluator.Types

Description

Types for the Partial Evaluator

Synopsis

Documentation

whnf :: Evaluator -> TyConMap -> Bool -> Machine -> Machine Source #

Evaluate to WHNF given an existing Heap and Stack

data Evaluator Source #

An evaluator is a collection of basic building blocks which are used to define partial evaluation. In this implementation, it consists of two types of function:

  • steps, which applies the reduction realtion to the current term
  • unwindings, which pop the stack and evaluate the stack frame

Variants of these functions also exist for evalauting primitive operations. This is because there may be multiple frontends to the compiler which can reuse a common step and unwind, but have different primitives.

Constructors

Evaluator 

unwindStack :: Machine -> Maybe Machine Source #

Completely unwind the stack to get back the complete term

type Step = Machine -> TyConMap -> Maybe Machine Source #

A single step in the partial evaluator. The result is the new heap and stack, and the next expression to be reduced.

data Machine Source #

A machine represents the current state of the abstract machine used to evaluate terms. A machine has a term under evaluation, a stack, and three heaps:

  • a primitive heap to store IO values from primitives (like ByteArrays)
  • a global heap to store top-level bindings in scope
  • a local heap to store local bindings in scope

Machines also include a unique supply and InScopeSet. These are needed when new heap bindings are created, and are just an implementation detail.

Instances

Instances details
Show Machine Source # 
Instance details

Defined in Clash.Core.Evaluator.Types

data Value Source #

Constructors

Lambda Id Term

Functions

TyLambda TyVar Term

Type abstractions

DC DataCon [Either Term Type]

Data constructors

Lit Literal

Literals

PrimVal PrimInfo [Type] [Value]

Clash's number types are represented by their "fromInteger#" primitive function. So some primitives are values.

Suspend Term

Used by lazy primitives

TickValue TickInfo Value

Preserve ticks from Terms in Values

CastValue Value Type Type

Preserve casts from Terms in Values

Instances

Instances details
Show Value Source # 
Instance details

Defined in Clash.Core.Evaluator.Types

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

forcePrims :: Machine -> Bool Source #

Are we in a context where special primitives must be forced.

See [Note: forcing special primitives]