Logo Mibo

Mibo.Adaptive

Mibo.Adaptive is the incremental-computation library under the Adaptive architecture: a pull-based derived state graph that tracks dependencies automatically and recomputes only what changed. In SPU terms it is the machinery behind the P: the state is cval/cmap inputs, and projections are aval graphs computed from them. It ships as its own NuGet package, depends only on the .NET base class library, and can be used without the rest of Mibo.

The main target is the tight-loop profile: many values change between reads, and reads must be cheap and allocation-free. The intended shape is a derived state graph forced once per step of your main loop.

open Mibo.Adaptive

let width = CVal.create 10.0
let height = CVal.create 20.0

let areaOf (w: float) (h: float) = w * h

// Computed values track dependencies automatically
let area = width |> AVal.map2 areaOf height

AVal.getValue area   // 200.0
width.Set(15.0)
AVal.getValue area   // 300.0

Design

Write as many times as you want between reads: the writes cost nothing until you read. Read as many times as you want after that: reads cost nothing until the next write.

When to use FSharp.Data.Adaptive instead

FSharp.Data.Adaptive is the mature choice for general incremental computing: it has the full API surface, IndexList, history, and Fable/JS support, and it wins on very wide dependency graphs and large mapA collections where the coarse scan loses.

Rule of thumb: general incremental computing → FSharp.Data.Adaptive. Tight loops with cheap reads → Mibo.Adaptive.

Layout of this section

The Mibo integration on top of the library (AdaptiveProgram, hosts, the intent queue) is documented under Adaptive; it lives in Mibo.Core, which references this package.

val width: obj
val height: obj
val areaOf: w: float -> h: float -> float
val w: float
Multiple items
val float: value: 'T -> float (requires member op_Explicit)

--------------------
type float = System.Double

--------------------
type float<'Measure> = float
val h: float
val area: obj

Type something to start searching.