Skip to main content

Param serialization

Everywhere Stan enforces the SerializableParam constraint on a value (atomFamily, selectorFamily), it means that the value will be used as a cache key. The process of computing cache keys must be idempotent (the same value should always produce the same key) and stable (reordering properties should not affect the result). As a result, not all values are acceptable.

Stan currently limits valid parameters to JSON-like values:

type Json =
| string
| number
| boolean
| null
| { [property: string]: Json }
| Json[];

This is illustrated in the following examples:

family(1); // Valid

family([1, 2, 3]); // Valid

family(function foo() {
return 'bar';
}); // Invalid

family(Promise.resolve(1)); // Invalid

See also