Skip to content
Playground(another site)

Keywords

Bynk reserves names in four tiers. The first two are lexer keywords; the third are words the lexer treats as plain identifiers; the fourth are compiler-known type names. Only the hard keywords can never be used as an identifier. A last section lists the ambient built-in functions, which reserve nothing.

A hard keyword is still allowed where a name is a label rather than a binding, so a field can carry the key a third-party payload uses (type, from, self):

  • a record field, a construction initialiser, a record or named pattern field and a variant payload field, when the keyword is followed by : ({ type: String }, Account { type: "Org" }, Account { type: t, .. }, Push(from: String)). kind stays reserved as a variant payload field.
  • a member after ., a field access or a method call, and a method declaration, when the keyword is on the same line as the . (a.type, fn Sorted.from(…), Sorted.from(xs)).

A keyword is never a parameter, a let or lambda binding or a bare reference, so field shorthand is refused: Account { type, .. } and Account { type } are bynk.parse.keyword_field_shorthand. Write type: type_ in a pattern and type: <value> in a construction.

Reserved everywhere — these 61 words can never be used as an identifier.

KeywordMeaning
BoolThe boolean base type.
BytesThe binary base type — an immutable octet sequence, erased to Uint8Array (Bytes.fromUtf8(s)).
DecimalThe exact decimal base type — an arbitrary-precision coefficient with a scale (1.20d).
DecodeErrorThe decode error type, Result[T, DecodeError] from Json.decode. Its fields are kind (Malformed, StructuralMismatch or RefinementViolation), path (e.g. $.qty) and message, all String: write "\(e.kind) at \(e.path): \(e.message)".
DurationThe time-span base type, in milliseconds (5.minutes).
EffectThe effectful-computation type, Effect[T].
ErrThe error variant of Result.
FloatThe floating-point base type.
InstantThe absolute-time base type, in epoch milliseconds (Clock.now()).
IntThe integer base type.
JsonErrorDeprecated spelling of DecodeError; it still compiles, with a warning and an auto-fix.
NoneThe empty variant of Option.
OkThe success variant of Result.
OptionThe optional-value type, Option[T].
ResultThe success-or-error type, Result[T, E].
SomeThe present variant of Option.
StringThe string base type.
ValidationErrorThe error type returned by a refined type’s .of. Its fields are field and message, both String: write "\(e.field): \(e.message)".
actorDeclare an actor — a boundary contract a handler consumes via by.
adapterDeclare an adapter — the host boundary (capability contract + binding).
agentDeclare a stateful, keyed agent inside a context.
asAlias a consumed context (consumes X as Y) or a consumed type (consumes U { T as Y }).
bindingName an adapter’s TypeScript binding module (binding "<module>").
capabilityDeclare a capability (a dependency interface) in a context, or a distinct instance of a platform resource (capability Sessions = Kv).
commonsDeclare a pure, stateless module of types and functions.
consumesDeclare a dependency on another context’s services.
contextDeclare a deployable context (services, agents, capabilities).
cronThe cron protocol on a service header (from cron).
doPerform a unit effect as a statement (do e — the binder-free let _ <- e).
elseThe alternative branch of an if, or what a block produces when a let pattern does not match (let Ok(x) = r else { … }).
ensuresDeclare a function postcondition — a pure Bool clause over the parameters and result (ensures <name>: <pred>).
enumDeclare a payloadless sum type (enum { A, B }).
expectAssert a predicate inside a test case (expect <bool-predicate>).
exportsDeclare which types a context exposes, and how.
falseThe boolean literal false.
fnDeclare a function.
fromName the protocol a service conforms to (service X from http).
givenDeclare the capabilities a handler requires.
httpThe HTTP protocol on a service header (from http).
ifA conditional expression.
impliesLogical implication (P implies Q ≡ `!P
invariantDeclare an agent invariant — a predicate that must hold of every committed state.
isTest a value against a variant pattern, yielding a Bool.
letBind a local value (let x = …, or let x <- … for an effect), or match a pattern with a fallback (let Ok(x) = r else { … }).
matchPattern-match over a sum type, Result, or Option.
opaqueDeclare an opaque type, or export a type opaquely.
propertyDeclare a generative test inside a suite (property "…" { for all … }).
protocolReserved keyword (protocols are a closed, compiler-known set).
providesProvide an implementation of a capability.
queueThe queue protocol on a service header (from queue("name")).
recordReserved keyword (records are written type X = { … }).
requiresDeclare a function precondition — a pure Bool clause over the parameters (requires <name>: <pred>).
selfThe current agent instance, inside a handler.
serviceDeclare a service (a group of handlers) in a context.
stubStub a consumed capability operation at a test seam (stub Cap.op(…) returns <v> / returns <v> after <d> / fails / never).
transitionDeclare an agent step invariant over the old/new state pair (transition <name>: …).
transparentExport a type with its structure visible (exports transparent { … }).
trueThe boolean literal true.
typeDeclare a type: alias, record, sum, opaque, or refined.
usesBring a commons into scope.
whereAttach refinement predicates to a base type.

Reserved only in the one position named below; elsewhere (a field, parameter, or other identifier) they are ordinary names.

KeywordMeaning
assetDeclare a static file the platform serves, public by construction (asset name = "path").
caseDeclare a test case inside a suite (case "…" { … }).
constDeclare a named constant — a static value of a declared type, in a context or commons (const MaxRetries: Int = 3).
embedDeclare a project file whose text is a String constant, compiled into the code and never served (embed name = "path").
eventDeclare a typed fact a context may emit (event Name = { fields }), inside a context.
messagesDeclare a message bundle for one locale (messages "<tag>" { "code" => "template" }), inside a commons.
onBegin a handler declaration (on call, on GET(…), on message, on open/on close).
suiteDeclare a test suite targeting a unit (suite <target> { case … }).

Not lexer keywords: the lexer treats these as ordinary identifiers, and they carry meaning only in the position each entry describes (inside an agent body or a migrate step, for instance). You can still use them as a field, parameter, or other name elsewhere.

WordMeaning
advanceMove the test harness’s clock forward in a case (advance Clock by 15.minutes).
byA clause word only in its positions — naming the actor a handler consumes after the return type or on a service header (… -> T by <name>: <Actor>), the actor of a call (let r <- f() by User("bob")), and the amount of advance Clock by <Duration>; an ordinary name (a parameter, a binding, a field) everywhere else.
derivesAfter a type declaration’s body, opts the type into a constraint (type Priority = enum { Low, High } derives Ord): the type is then ordered by declaration order.
dropInside a migrate step, discard a stored field’s value on purpose (drop owner).
fixtureIn a suite, declares a project file’s text as a String constant for its cases (fixture issue = "fixtures/issue.json"): test-only, read from the fixtures/ folder and never deployed.
keyThe agent’s identity field — one per agent; keys the store.
migrateAn agent’s migration step: carries a stored record from an older schema version to the current shape (migrate from 1 (old: CartV1) { … }).
parOpens a concurrent binding block (par { let a <- e1 let b <- e2 }): every effect is issued before any is awaited, and the block completes when all have settled.
privateBefore a fn, type, messages, asset, embed or const declaration in a commons or context: visible only within its own unit (and that unit’s suites), never through uses (private fn helper(…)).
removedDeclares an agent class gone (removed agent Old): its stored data is deleted at the next deploy, after a named confirmation.
replacesRenames an agent class (agent New replaces Old): the old class’s stored data and schema history move to the new one.
storeA persisted agent-state field.

Compiler-known type constructors. They are not lexer keywords — you may use them as an identifier in value position — but they are reserved in type position: a type declaration may not reuse one of these names (bynk.resolve.reserved_builtin_type).

NameMeaning
AssetA static file declared by asset name = "path"; its .url is the content-hashed URL the platform serves it at.
BoundaryRejectionWhy the router refused a request before any handler ran; the parameter of on rejected.
ConnectionA held WebSocket connection, Connection[F].
HistoryA generated call-history generator, History[Agent] (test-only).
HttpResultThe HTTP handler result type, HttpResult[T].
ListThe immutable list type, List[T].
MapThe immutable map type, Map[K, V].
QueryThe lazy storage-read type, Query[T].
QueueResultThe queue handler result type (non-generic).
RequestCookiesAn HTTP handler’s read-only view of the request’s cookies (cookies: RequestCookies).
RequestHeadersAn HTTP handler’s read-only view of the request’s headers (headers: RequestHeaders).
RequestQueryAn HTTP handler’s read-only view of the request’s query string (query: RequestQuery).
SetThe immutable set type, Set[T].
StreamThe value-over-time primitive, Stream[T].
TokenClaimsAn Oidc actor’s verified token claims, read through its binder (who.claims).

Functions the compiler provides without a declaration. They reserve nothing: a fn, parameter or local of the same name shadows the built-in.

NameMeaning
todoPlaceholder for unfinished code, todo(message: String): type-checks anywhere, faults when run, and raises the bynk.fault.todo warning so check --deny-warnings can refuse it.
unreachableMark a case that cannot happen, unreachable(message: String): type-checks anywhere and faults when evaluated, so a broken assumption is loud instead of masked by a made-up default.