#04. Scalar types
Let's start reading the schema in smaller pieces.
#Start the demo server
telepact demo-server --port 8000#The scalar type expressions
| Type expression | Meaning |
|---|---|
boolean | true or false |
integer | whole number |
number | JSON number |
string | JSON string |
bytes | binary data |
Nullability is written with a ? suffix, like number? or string?.
#Where they show up in the demo schema
{
"fn.add": {"x": "number", "y": "number"},
"fn.getPaperTape": {"limit!": "integer"},
"fn.login": {"username": "string"},
"struct.Evaluation": {
"result": "number?",
"timestamp": "integer",
"successful": "boolean"
},
"fn.export": {},
"->": [{"Ok_": {"blob": "bytes"}}]
}#Real examples
#number
curl -s localhost:8000/api -d '[{}, {"fn.add": {"x": 1.5, "y": 2}}]'[{}, {"Ok_": {"result": 3.5}}]#integer, boolean, and nullable number?
Let's create one evaluation and then read it back:
curl -s localhost:8000/api -d '[{}, {"fn.evaluate": {"expression": {"Constant": {"value": 7}}}}]'
curl -s localhost:8000/api -d '[{}, {"fn.getPaperTape": {"limit!": 1}}]'Example response:
[
{},
{
"Ok_": {
"tape": [
{
"expression": {"Constant": {"value": 7}},
"result": 7,
"timestamp": 1744221600,
"successful": true
}
]
}
}
]#bytes
curl -s localhost:8000/api -d '[{}, {"fn.export": {}}]'Example response:
[
{
"@base64_": {
"Ok_": {
"blob": true
}
}
},
{
"Ok_": {
"blob": "gql2YXJpYWJsZXO..."
}
}
]The schema says bytes, but JSON has no raw bytes type, so Telepact coerces the wire value to Base64.
Next: 05. Collection types