Stellar doesn’t manipulate objects, functions or types, it manipulates APIs. To do so, Stellar provides 4 operators:
sequence,(&>): The sequencing of two APIschoose,(+): The choice of two APIsproduct,(*): The product of two APIsparallel,(//): The parallel product of two APIs
Sequencing API calls
Real systems do more than talk to one database, they talk to multiple databases, sometime microservices, and nowadays even autonomous agents.
Stellar models a program that calls out to several APIs in sequence as a single API:
complex : APP =&> (JSONRPC &> SQL &> HTTP)
The &> operator composes APIs in sequence, ensuring that each API call
happens in the given order, and carries along the data obtained from a previous
API call.
This specific example statis that the API-transformer translates from the App’s
API into a sequence of calls starting with a JSONRPC call, followed by an
SQL query, and ending with an HTTP call to another server.
Crucially, when implementing this API-transfomer, the result of the JSONRPC
call will be available for the SQL query, and the result of the SQL query will
be available for make the HTTP call.
Chosing what APIs to call out of multiple APIs
Calling multiple APIs in parallel, only one result matters
Calling multiple APIs in parallel, using all results
Mapping across operators
Each operator has an accompanying function to map its left and right API while maintaining the operator:
inSequence,~&>~:a =&> a' -> b =&> b' -> a &> b =&> a' &> b'map across the sequence productalternatively,~+~:a =&> a' -> b =&> b' -> a + b =&> a' + b'map across the choice of APIconcurrently,~*~:a =&> a' -> b =&> b' -> a * b =&> a' * b'map across the product of APIinParallel,~//~:a =&> a' -> b =&> b' -> a // b =&> a' // b'map across the parallel product of API
Like before, those operators have a name so you know how to pronounce the symbol for it.