Safe Haskell | None |
---|---|
Language | Haskell2010 |
User-facing API to work with STG programs.
- initialState :: Var -> Program -> StgState
- evalStep :: StgState -> StgState
- evalUntil :: RunForSteps -> HaltIf -> PerformGc -> StgState -> StgState
- evalsUntil :: RunForSteps -> HaltIf -> PerformGc -> StgState -> NonEmpty StgState
- terminated :: StgState -> Bool
- newtype HaltIf = HaltIf (StgState -> Bool)
- data RunForSteps
- garbageCollect :: GarbageCollectionAlgorithm -> StgState -> StgState
- newtype PerformGc = PerformGc (StgState -> Maybe GarbageCollectionAlgorithm)
- data GarbageCollectionAlgorithm
- triStateTracing :: GarbageCollectionAlgorithm
- twoSpaceCopying :: GarbageCollectionAlgorithm
Documentation
Evaluation
:: 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
:: 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.
evalsUntil
≈unfoldr
evalUntil
terminated :: StgState -> Bool Source
Check whether a state is terminal.
data RunForSteps Source
Predicate to decide whether the machine should halt.
RunIndefinitely | Do not terminate based on the number of steps |
RunForMaxSteps Integer |
Garbage collection
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.