This is a drafty draft.
Fides is an interaction language. It posits that interaction is the fundamental unit of reality, with communication and computation emerging merely as special cases. Its primary inspiration is the pi-calculus, inheriting concepts of concurrency, message-passing, non-determinism, ephemeral code, mobility, and the primacy of names.
- Interaction-Universality: Fides is designed to faithfully represent all possible games, whether cooperative, competitive, or concurrent.
- The Fidesphere (Trust Model): The language runtime is the only required Trusted Third Party. The language itself is reified into a launch primitive. It acts as a digital notary, launching quoted process code and providing certificates of exactly what code got launched. If the runtime is trusted, it can be used to bootstrap other trusted third parties, allowing arbitrary cooperation, programmatically, amongst parties that do not trust each other a priori.
- Timelessness: There is no global clock. Causality is established solely through communication events (happens-before relationships).
One important and convenient syntactic category in Fides is polars.
- Neutral (Invariant): Can flow in either direction. (e.g., Data constructors like
Record). - Expression (Covariant): A Source. It produces values (e.g., Reading from a channel).
- Extractor (Contravariant): A Sink. It consumes values (e.g., Writing to a channel).
- Illegal (Bivariant): A theoretical state where constraints conflict; syntactically unconstructible.
- Polars (Open Ends): The primary connectors. A Polar is a "half-connection" waiting to be closed or extended.
- Bipolars (Transducers): Single-Input, Single-Output processors. They act as pipes, filters, or functions.
- Apolars (Processes): The unit of execution. Fully connected circuits that run concurrently in the Fidesphere.
Forward(Polar_A, Polar_B): The fundamental "Cut" operation. Fuses a Source (A) and a Sink (B) into an Apolar process.Apply(Bipolar, Polar): Constructs a new Polar by connecting a Polar with a Bipolar in the forward direction.Deply(Bipolar, Polar): Constructs a new Polar by connecting a Polar with a Bipolar in the reverse direction, meaning that the Bipolar is inverted before getting connected.Backward(Polar_A, Polar_B): Creates a Bipolar that internally pipes data between A and B, exposing their outer ends to the context.
-
Com(Location): -
As Expression: Receive (Source).
-
As Extractor: Send (Sink).
-
Send(Data_Expr, Address_Expr): An Apolar for dynamic addressing. SendsDatatoAddress(a reified channel reference). -
Pick: -
As Expression: A generic race primitive. Selects the first value arriving from multiple sources.
-
As Extractor: A demultiplexer. Non-deterministically routes one value to one of the connected sinks.
-
Spread: An Extractor that broadcasts a single received value to multiple recipients. -
Replicate(Apolar): Persists a process, spawning copies indefinitely (often replaced by recursive embedding for stateful logic). -
Concurrent(Apolar...): Runs multiple processes in parallel.
-
Record: Named product types. -
Constructors:
Record,ExtendRecord. -
Spatial:
Bundle(LocRef_A, LocRef_B)constructs a record by pulling values from locations A and B. Conversely, acts as a Sink that pushes record fields into those locations. -
Bag: Unordered multisets. -
Constructors:
Bag,ExtendBag. -
Spatial:
Collect(Location, Size)waits for exactlySizeitems to arrive atLocation, then bundles them. Or does the dual.
Cell(Name, Value): An independent Apolar process holding a single value.CompareAndSwap(CellRef, Old, New): An atomic expression returning the current value.Match(Extractor_A, Extractor_B): An Extractor that routes incoming data to A or B based on type matching (Structural Typing).Hold: An expression that holds a value until a "go" signal is received.Signal: A Bipolar that triggers a unit signal output upon receiving any input.
There is a strict bijection between Values and Data Types.
- Fundamental Types:
- Behaviors: Compiled, executable code. Functions are simply Bipolar Behaviors (reusable transducers).
- Quotes: Reified code / Abstract Syntax Trees
- Names: Syntactic entities representing identity/capability
- Addresses: Reified channel references (values that can be passed)
- Signed Values: Produced/Verified via
Sign(Name, Polar)
Fides has sound and complete metaprogramming.
- Construction (Quote): Code is built as a Quote. It is type-safe by construction.
Escape:
- Transformation:
Children: Returns a Bag of sub-quotes (AST children).Update: Maps a Bipolar over children to transform the AST.Rename: Dynamically applies a statically specified renaming to a Behavior, Quote or Record.Zip/Args: Tools for manipulating collections of syntactic entities.
- Reification (Run):
Wrap: Wraps a value into a quote.Eval: Reduces a quoted expression to a value.Compile: Converts a quote to a behavior.Embed: Inserts a Behavior value into the current context. Inherits capabilities.Launch: Spawns a Quote as an independent process.
Catchable: Wraps a process so it can be halted and serialized back into a Quote (capturing dynamic state).Pausable/Mortal/Contingent: Primitives to control process liveness based on signals or boolean cells.
Launch(Quote): Returns a cryptographically signed Certificate.- The Proof: The Certificate contains the launched code (after
PublicNewreduction). It proves exactly what logic is running. - Bootstrapping:
PublicNewcreates fresh names that are effectively "published" in the Certificate, allowing other parties to discover and connect to the new process ("Service Discovery").
- Static Resolution: Access rights are tied to Names in the syntactic scope.
- Capability-Closed: To be
Launch-ed, a Quote must not have unbound top-level escapes, or have unresolved capability requirements. - Private vs. Public:
Newcreates invisible internal wiring;PublicNewcreates visible external interfaces.
Fides does not have an official concrete syntax. Examples are written in simplified pseudo-notation.
We start with the "Hello World" of interaction: connecting a Producer to a Consumer.
A simple process that generates a "Greeting" record and sends it through a channel
Forward(
// SOURCE (Expression):
// Construct a Record literal { msg = "Hello", id = 123 }.
Record(
msg -> "Hello",
id -> 123,
),
// SINK (Extractor):
// Consumes the value by writing it to channel at name c.
Com(ChanRef(c)),
)
In Fides, records can be built "spatially" by pulling from different locations at the same time. This is useful for gathering dependencies.
Forward(
// SOURCE: The Bundle
// Waits until it can read one value from name1 AND one from name2.
// Creates a record: { name1 = val_from_A, name2 = val_from_B }
Bundle(ChanRef(name1), ChanRef(name2)),
// SINK: The Writer
// Writes the resulting record to output_chan.
Com(ChanRef(output_chan)),
)