The Faber language
Everything you need to read Faber is on this page. The pages beneath it go deeper on each part, but nothing here is a placeholder — if you read this far and stop, you can read a Faber program.
A whole program#
faber convert --to en — English reader surfacefn saturate(int x) → int {
if x ≺ 0 then return 0
if x ≻ 255 then return 255
return x
}
main {
let int v ← saturate(300)
print v
}faber convert --to la — canonical Faberfunctio saturate(numerus x) → numerus {
si x ≺ 0 ergo redde 0
si x ≻ 255 ergo redde 255
redde x
}
incipit {
sit numerus v ← saturate(300)
nota v
}faber convert --to th-TH — Thaiฟังก์ชัน saturate(จํานวน x) → จํานวน {
ถ้า x ≺ 0 ดังนั้น คืน 0
ถ้า x ≻ 255 ดังนั้น คืน 255
คืน x
}
เริ่ม {
กำหนด จํานวน v ← saturate(300)
บันทึก v
}faber convert --to zh-Hans — Simplified Chinese函数 saturate(整数 x) → 整数 {
如果 x ≺ 0 则 返回 0
如果 x ≻ 255 则 返回 255
返回 x
}
入口 {
设 整数 v ← saturate(300)
显示 v
}faber convert --to zh-Hant — Traditional Chinese函式 saturate(整數 x) → 整數 {
若 x ≺ 0 則 傳回 0
若 x ≻ 255 則 傳回 255
傳回 x
}
入口 {
設為 整數 v ← saturate(300)
註記 v
}faber convert --to vi — Vietnamesehàm saturate(số x) → số {
nếu x ≺ 0 do_đó trả 0
nếu x ≻ 255 do_đó trả 255
trả x
}
bắt_đầu {
đặt số v ← saturate(300)
ghi_chú v
}faber convert --to ar — Arabicدالة saturate(عدد x) → عدد {
إذا x ≺ 0 إذن أعد 0
إذا x ≻ 255 إذن أعد 255
أعد x
}
بداية {
ليكن عدد v ← saturate(300)
اعرض v
}faber convert --to hi — Hindiफलन saturate(संख्या x) → संख्या {
यदि x ≺ 0 अतः लौटाओ 0
यदि x ≻ 255 अतः लौटाओ 255
लौटाओ x
}
आरंभ {
बैठा संख्या v ← saturate(300)
दिखाओ v
}That is a complete, compilable package entry point. Reading it left to right:
| Piece | What it is |
|---|---|
fn | declares a function |
int x | the type comes before the name — always, everywhere |
→ int | the return type |
if … then | a compact single-branch conditional |
return | return |
main | the program entry point |
let | a fixed name (mut is the writable one) |
← | bind this value to that name |
print |
Type before name, always#
This is the single rule that makes the rest of the grammar small:
faber convert --to en — English reader surfacemain {
# a declaration
let int count ← 0
# another
let string name ← "Marcus"
# a generic
let list<int> scores ← [1, 2, 3]
# a nullable
let int ∪ none maybe ← null
print count, name, scores, maybe
}faber convert --to la — canonical Faberincipit {
# a declaration
sit numerus count ← 0
# another
sit textus name ← "Marcus"
# a generic
sit lista<numerus> scores ← [1, 2, 3]
# a nullable
sit numerus ∪ nihil maybe ← nulla
nota count, name, scores, maybe
}faber convert --to th-TH — Thaiเริ่ม {
# a declaration
กำหนด จํานวน count ← 0
# another
กำหนด ข้อความ name ← "Marcus"
# a generic
กำหนด รายการ<จํานวน> scores ← [1, 2, 3]
# a nullable
กำหนด จํานวน ∪ ไม่มี maybe ← ขาดหาย
บันทึก count, name, scores, maybe
}faber convert --to zh-Hans — Simplified Chinese入口 {
# a declaration
设 整数 count ← 0
# another
设 文本 name ← "Marcus"
# a generic
设 列表<整数> scores ← [1, 2, 3]
# a nullable
设 整数 ∪ 无 maybe ← 缺失
显示 count, name, scores, maybe
}faber convert --to zh-Hant — Traditional Chinese入口 {
# a declaration
設為 整數 count ← 0
# another
設為 文字 name ← "Marcus"
# a generic
設為 列表<整數> scores ← [1, 2, 3]
# a nullable
設為 整數 ∪ 無 maybe ← 缺失
註記 count, name, scores, maybe
}faber convert --to vi — Vietnamesebắt_đầu {
# a declaration
đặt số count ← 0
# another
đặt văn_bản name ← "Marcus"
# a generic
đặt danh_sách<số> scores ← [1, 2, 3]
# a nullable
đặt số ∪ hư_không maybe ← vắng
ghi_chú count, name, scores, maybe
}faber convert --to ar — Arabicبداية {
# a declaration
ليكن عدد count ← 0
# another
ليكن نص name ← "Marcus"
# a generic
ليكن قائمة<عدد> scores ← [1, 2, 3]
# a nullable
ليكن عدد ∪ لاشيء maybe ← غائب
اعرض count, name, scores, maybe
}faber convert --to hi — Hindiआरंभ {
# a declaration
बैठा संख्या count ← 0
# another
बैठा पाठ name ← "Marcus"
# a generic
बैठा सूची<संख्या> scores ← [1, 2, 3]
# a nullable
बैठा संख्या ∪ कुछनहीं maybe ← अभाव
दिखाओ count, name, scores, maybe
}There is no name: type form to learn. A declaration is a type followed by a
name, whether it is a parameter, a local, or a field. Four binding words say
how a name is bound: let is a fixed name, mut is re-pointable and writable,
ref is re-pointable and read-only, and const is a compile-time fact set with
=. Every one writes its type slot, and _ asks the compiler to infer the type.
See Types and values.
Six glyphs, and what they mean#
Faber uses a small fixed set of symbols for structure. They never localize — they are the same in every reader locale, which is what keeps a program recognizable across languages.
| Glyph | Meaning |
|---|---|
← | bind a value to a name |
→ | function return type |
∪ | union type, most often T ∪ none for nullable |
⇥ | alternate exit — the error channel |
∴ | closure joint, connecting a signature to its body |
≡ | equality |
Two more appear when you convert between types: ∷ for a compile-time
ascription and ↦ for a runtime conversion that can fail. Full table in
Glyphs and Latin.
The words you write, and the compiler's Latin#
The words in the program above — fn, if, return, let, int — are
the spellings an English reader writes; every page on this site teaches the
English reader surface. Latin is one reader locale like the rest; the pack
files are keyed by Latin spellings, so the grammar document prints its Latin
identity rendering beside the others. faber convert --to la prints any
program in Latin, and reader locales render
the same program in seven other languages. The glyphs and the type-first shape survive every
rendering untouched — and identifiers like saturate are never translated.
Where the rest lives#
| Page | What it covers |
|---|---|
| Types and values | primitives, collections, strings, nullability, conversion, bindings |
| Functions and control flow | parameters, returns, branching, loops, generics |
| Errors and testing | the ⇥ error channel, and inline describe/test/assert suites |
| Glyphs and Latin | the full glyph table, vocabulary rationale, canonical vs sugar |
| Reader locales | how one program renders in eight surfaces |
| Capabilities and frames | call dispatch and the host I/O boundary |
| Tensor computation | reductions, reduce via first, grouping, scans, edge policies, kernel, do batch, do device and do eligible |