Prim

Enum Prim 

Source
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 IntFloat, 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

Source

pub fn name(self) -> &'static str

Source

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.

Trait Implementations§

Source§

impl Clone for Prim

Source§

fn clone(&self) -> Prim

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Prim

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Prim

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Prim

Source§

fn cmp(&self, other: &Prim) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Prim

Source§

fn eq(&self, other: &Prim) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Prim

Source§

fn partial_cmp(&self, other: &Prim) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Prim

Source§

impl Eq for Prim

Source§

impl StructuralPartialEq for Prim

Auto Trait Implementations§

§

impl Freeze for Prim

§

impl RefUnwindSafe for Prim

§

impl Send for Prim

§

impl Sync for Prim

§

impl Unpin for Prim

§

impl UnwindSafe for Prim

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.