stgi-1.0.1: Educational implementation of the STG (Spineless Tagless G-machine)

Safe HaskellNone
LanguageHaskell2010

Stg.Machine

Contents

Description

User-facing API to work with STG programs.

Synopsis

Documentation

initialState Source

Arguments

:: Var

Main

-> Program 
-> StgState 

Create a suitable initial state for an STG.

Evaluation

evalStep :: StgState -> StgState Source

Perform a single STG machine evaluation step.

evalUntil Source

Arguments

:: RunForSteps

Maximum number of steps allowed

-> HaltIf

Halting decision function

-> PerformGc

Condition under which to perform GC

-> StgState

Initial state

-> StgState

Final state

Evaluate the STG until a predicate holds, aborting if the maximum number of steps are exceeded.

last (evalsUntil ...) ≡ evalUntil

evalsUntil Source

Arguments

:: RunForSteps

Maximum number of steps allowed

-> HaltIf

Halting decision function

-> PerformGc

Condition under which to perform GC

-> StgState

Initial state

-> NonEmpty StgState

Initial state plus intermediate states

Evaluate the STG, and record all intermediate states.

  • Stop when a predicate holds.
  • Stop if the maximum number of steps are exceeded.
  • Perform GC on every step.
evalsUntilunfoldr evalUntil

terminated :: StgState -> Bool Source

Check whether a state is terminal.

newtype HaltIf Source

Predicate to decide whether the machine should halt.

Constructors

HaltIf (StgState -> Bool) 

data RunForSteps Source

Predicate to decide whether the machine should halt.

Constructors

RunIndefinitely

Do not terminate based on the number of steps

RunForMaxSteps Integer 

Garbage collection

newtype PerformGc Source

Decide whether garbage collection should be attempted, and with which algorithm.

triStateTracing :: GarbageCollectionAlgorithm Source

Remove all unused addresses, without moving the others.

twoSpaceCopying :: GarbageCollectionAlgorithm Source

Remove all unused addresses by moving them to a safe location.