pub enum Prim {
Show 103 variants
Add,
Sub,
Mul,
Div,
Rem,
Neg,
Abs,
Sqrt,
Sin,
Cos,
Trunc,
ToFloat,
Eq,
Ne,
Lt,
Le,
Gt,
Ge,
And,
Or,
Not,
ToStr,
StrTrim,
StrToInt,
StrLen,
StrSlice,
StrSplit,
StrJoin,
StrContains,
StrStartsWith,
StrEndsWith,
StrUpper,
StrLower,
StrReplace,
StrIndexOf,
StrRepeat,
StrChars,
StrIsEmpty,
ListLen,
ListIsEmpty,
ListGet,
ListSlice,
ListReverse,
ListTake,
ListDrop,
ListContains,
ListIndexOf,
ListFold,
ListAll,
ListAny,
ListFlatMap,
ListZip,
ListAppend,
MapKeys,
MapMerge,
JsonParse,
JsonRender,
TimeFormat,
TimeParse,
Digest,
DigestKeyed,
DigestEq,
HexEncode,
HexDecode,
Base64Encode,
Base64Decode,
UuidParse,
UuidVersion,
HttpFetch,
MapList,
FilterList,
ConcatLists,
SortBy,
MapGet,
MapInsert,
MapRemove,
MapValues,
MapContains,
MapLen,
OptionIsSome,
OptionUnwrapOr,
HtmlEl,
HtmlText,
HtmlAttr,
HtmlOn,
HtmlKey,
NewUuid,
Now,
SecretEnv,
Raise,
Try,
Parallel,
InternalOf,
Reveal,
MergeClients,
Presence,
StreamFilterMap,
Fold,
Durable,
SignalMap,
SignalMap2,
PerSession,
Decide,
}Expand description
A primitive operation. Everything the standard library provides in Phase 1.
Variants§
Add
Sub
Mul
Div
Rem
Neg
Abs
abs, sqrt and Int → Float, which are the three the numeric tower needs before any
of SICP §1.1.7 will run (docs/32 §32.1). Abs is resolved from its operand the way the
arithmetic operators are; the other two are monomorphic.
Sqrt
Sin
Cos
Trunc
ToFloat
Eq
Ne
Lt
Le
Gt
Ge
And
Or
Not
ToStr
StrTrim
StrToInt
StrLen
StrSlice
StrSplit
StrJoin
StrContains
StrStartsWith
StrEndsWith
StrUpper
StrLower
StrReplace
StrIndexOf
StrRepeat
StrChars
StrIsEmpty
ListLen
ListIsEmpty
ListGet
ListSlice
ListReverse
ListTake
ListDrop
ListContains
ListIndexOf
ListFold
ListAll
ListAny
ListFlatMap
ListZip
ListAppend
MapKeys
MapMerge
JsonParse
JsonRender
TimeFormat
TimeParse
Digest
DigestKeyed
A message authentication code: the one primitive whose input is a secret[Str] and whose
output is a Str. Charged cap.sign rather than left free, so a view cannot mint one —
docs/adr/0014 is the record of the decision and §3.5 is what it is measured against.
DigestEq
Constant-time equality, for the caller comparing a digest against one that arrived.
HexEncode
HexDecode
Base64Encode
Base64Decode
UuidParse
Validates and normalises: two spellings of one identifier must not be two map keys.
UuidVersion
HttpFetch
MapList
FilterList
ConcatLists
SortBy
MapGet
MapInsert
MapRemove
MapValues
MapContains
MapLen
OptionIsSome
OptionUnwrapOr
HtmlEl
HtmlText
HtmlAttr
HtmlOn
HtmlKey
NewUuid
Mints a fresh id. Nondeterministic, so §3.7 forbids it inside a fold; the client mints entity ids instead, which is “the small tell that browsers here are replicas, not terminals”.
Now
Reads the wall clock. The other half of §3.7’s rule: “time is data on the envelope”.
SecretEnv
Reads a secret from the process environment, yielding a secret[Str] (§3.5).
Raise
raise e — fail with a value.
The atom it performs is raises(T), which depends on the type of its argument, so the
checker attaches it where that type is known rather than Prim::effects declaring it.
This is the first primitive whose row is not a constant, and it is why that table’s doc
says “the atoms this primitive performs itself”.
Try
try: block — run a thunk, and turn a raise of the named type into an Err.
Two arguments: the thunk, and the name of the error type this handler catches. The name is
what stops a handler from catching a failure it cannot type — a caller’s function may raise
something this try never heard of, and that has to keep travelling.
Parallel
parallel: block — run the scope’s children, then its tail with their results bound.
The arguments are the children’s thunks followed by the continuation, so a child cannot
outlive the scope: there is no handle, and the only thing that can read a child’s result is
the one lambda the scope built. That is docs/38
§38.4’s “spawn/await as effect operations, the scope as their handler” with the handler as
the only form — the operations are not separately reachable.
The children are independent by construction (none of them can name another) and no child may perform an effect another child could observe, so the scope’s answer does not depend on the order they ran in. A backend may therefore run them together; running them in the order they are written is a correct implementation of that, and is what the tree-walker does.
InternalOf
Wraps a value as internal[T]: storable, never Sendable.
Reveal
Unwraps one. Performs cap.internal, so only the authority chokepoint can do it.
MergeClients
Presence
presence() — who is connected now, as a signal that is not a function of the log.
D6’s last row. It performs cap.presence rather than an atom of its own, which is F16
(docs/14) taken literally: “presence signals
leak who-is-online; gate behind a capability like any other view”. The capability is also
what places it — no tier below the server discharges a cap.* — so a fold cannot read the
roster and a view reaches it across a declared edge.
StreamFilterMap
Fold
Durable
SignalMap
SignalMap2
PerSession
§3.8’s per-session view: todos.map(filter_by(session.user)). First-class because “the
fanout cost becomes a first-class engineering concern”.
Decide
The authority chokepoint: the sole consumer of ingress, holding the accumulator so that first-writer-wins and ownership can be decided (§3.7, F2).
Implementations§
Source§impl Prim
impl Prim
pub fn name(self) -> &'static str
Sourcepub fn effects(self) -> Vec<Effect>
pub fn effects(self) -> Vec<Effect>
The atoms this primitive performs itself.
The polymorphic half of a primitive’s row — map_list’s e, which is whatever its function
argument does — lives in the scheme in crate::prelude, because a row variable is not a
constant. A test holds the two in agreement.