nutcracker.toolkit
Type members
Classlikes
A Toolkit whose representation of a program (Toolkit.Prg) is a free monad over some algebra (FreeToolkit.Lang).
A Toolkit whose representation of a program (Toolkit.Prg) is a free monad over some algebra (FreeToolkit.Lang).
FreeToolkit is typically created by composing multiple Modules.
Module bridges three levels of abstraction:
Module bridges three levels of abstraction:
- API. Client code is written against an (MTL-style) API. What API a module provides is module-specific. For example, PropagationModule provides the nutcracker.Propagation API.
- Instruction set. Low-level instructions which are able to express all of the API operations. We define program as the free monad over (a superset of) the instruction set. We consider a variation of free monads, util.FreeK, where the instructions can talk about (the type of) programs in which they are embedded. In the simplest case, there is a one-to-one mapping between the API operations and instructions. There are cases, however, when an API operation has to be split into multiple instructions.
- Interpreter. Interprets (free) programs in terms of state transitions.
- Companion:
- object
Extends Toolkit with a notion of observable (RefToolkit.Val) and writable (RefToolkit.Var) cells, (potentially) residing inside RefToolkit.State.
Extends Toolkit with a notion of observable (RefToolkit.Val) and writable (RefToolkit.Var) cells, (potentially) residing inside RefToolkit.State.
When StashToolkit.State is not a persistent data structure, it might still provide a way to remember the current state (as if push on the stack) and return to it later (as if pop off the stack). StashToolkit is a Toolkit that supports such operations on Toolkit.State.
When StashToolkit.State is not a persistent data structure, it might still provide a way to remember the current state (as if push on the stack) and return to it later (as if pop off the stack). StashToolkit is a Toolkit that supports such operations on Toolkit.State.
Provides implementations of multiple APIs. The specific APIs provided by a Toolkit are defined in subclasses, such as PropagationToolkit, BranchingToolkit, RelToolkit, etc.
Provides implementations of multiple APIs. The specific APIs provided by a Toolkit are defined in subclasses, such as PropagationToolkit, BranchingToolkit, RelToolkit, etc.
The unifying feature across all provided APIs is that programs written against those APIs can be represented by a type Toolkit.Prg, which is at least a monad. Such programs can be interpreted (Toolkit.interpret) as state transitions on Toolkit.State.