Cheat sheet
Short examples of how Faber is actually written. Every snippet on these pages compiles — they are checked against the compiler on each build, not typed from memory.
This is not the corpus. The corpus is the exhaustive reference: one page per keyword, every construct registered and measured. The cheat sheet is the opposite shape — a handful of pages, each showing the two or three ways people really write something.
The feel of the language#
Three signals do most of the work. Types come before names, behaviour words are Latin, and structure is carried by glyphs rather than punctuation soup.
faber format --locale en — English reader surfacefn divide(int a, int b) → int ∪ null {
if b ≡ 0 then return null
return a / b
}faber format --locale la — canonical Faberfunctio divide(numerus a, numerus b) → numerus ∪ nihil {
si b ≡ 0 ergo redde nihil
redde a / b
}faber format --locale th-TH — Thaiฟังก์ชัน divide(จำนวน a, จำนวน b) → จำนวน ∪ ว่าง {
ถ้า b ≡ 0 ดังนั้น คืน ว่าง
คืน a / b
}faber format --locale zh-Hans — Simplified Chinese函数 divide(整数 a, 整数 b) → 整数 ∪ 空 {
如果 b ≡ 0 则 返回 空
返回 a / b
}faber format --locale zh-Hant — Traditional Chinese函式 divide(整數 a, 整數 b) → 整數 ∪ 空 {
若 b ≡ 0 則 傳回 空
傳回 a / b
}faber format --locale vi — Vietnamesehàm divide(số a, số b) → số ∪ rỗng {
nếu b ≡ 0 do_đó trả rỗng
trả a / b
}faber format --locale ar — Arabicدالة divide(عدد a, عدد b) → عدد ∪ لاشيء {
إذا b ≡ 0 إذن أعد لاشيء
أعد a / b
}faber format --locale hi — Hindiफलन divide(संख्या a, संख्या b) → संख्या ∪ शून्य {
यदि b ≡ 0 अतः लौटाओ शून्य
लौटाओ a / b
}numerus a — type first, then the name. → introduces the return type. ∪
joins types into a union, so this returns a number or nothing. ≡ is
equality. return returns.
A whole program, doing real work:
faber format --locale en — English reader surfacemain {
const list<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
const tensor<f32, []> seed ← vacua
const tensor<f32, [2, 3]> matrix ← seed.strue(valores, [2, 3])
const f32 medium ← matrix.media()
print medium
}faber format --locale la — canonical Faberincipit {
fixum lista<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
fixum tensor<f32, []> seed ← vacua
fixum tensor<f32, [2, 3]> matrix ← seed.strue(valores, [2, 3])
fixum f32 medium ← matrix.media()
nota medium
}faber format --locale th-TH — Thaiเริ่ม {
คงที่ รายการ<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
คงที่ เทนเซอร์<f32, []> seed ← เซตว่าง
คงที่ เทนเซอร์<f32, [2, 3]> matrix ← seed.strue(valores, [2, 3])
คงที่ f32 medium ← matrix.media()
บันทึก medium
}faber format --locale zh-Hans — Simplified Chinese入口 {
常量 列表<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
常量 张量<f32, []> seed ← 空集
常量 张量<f32, [2, 3]> matrix ← seed.strue(valores, [2, 3])
常量 f32 medium ← matrix.media()
显示 medium
}faber format --locale zh-Hant — Traditional Chinese入口 {
定值 列表<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
定值 張量<f32, []> seed ← 空集
定值 張量<f32, [2, 3]> matrix ← seed.strue(valores, [2, 3])
定值 f32 medium ← matrix.media()
註記 medium
}faber format --locale vi — Vietnamesebắt_đầu {
hằng danh_sách<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
hằng ten_xo<f32, []> seed ← tập_rỗng
hằng ten_xo<f32, [2, 3]> matrix ← seed.strue(valores, [2, 3])
hằng f32 medium ← matrix.media()
ghi_chú medium
}faber format --locale ar — Arabicبداية {
ثابت قائمة<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
ثابت موتر<f32, []> seed ← فارغ
ثابت موتر<f32, [2, 3]> matrix ← seed.strue(valores, [2, 3])
ثابت f32 medium ← matrix.media()
اعرض medium
}faber format --locale hi — Hindiआरंभ {
स्थिर सूची<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
स्थिर टेंसर<f32, []> seed ← खाली
स्थिर टेंसर<f32, [2, 3]> matrix ← seed.strue(valores, [2, 3])
स्थिर f32 medium ← matrix.media()
दिखाओ medium
}main is the entry point. const binds a constant. ← is the bind glyph —
assignment reads right-to-left into the name. print prints.
By topic#
| Page | What it covers |
|---|---|
| Entry points | main, async entry, CLI arguments and annotations |
| Bindings | const vs var, type holes, union holes |
| Types and widths | Numbers and their widths, lists, tables, tensors, vectors, and the sugar for each |
| Generics | Generic functions, generic containers, class |
| Loops | for over values, keys, and ranges; while |
| Control flow | if / elif / else, switch, match over unions |
| Errors and catching | The ⇥ error channel, iace, and catch on many block forms |
| Conversions | ↦ conversion, recovery with ⇥, conversion vs casting |
| Imports | Standard library, local files, aliasing, publica vs privata |
| Reader locales | The same program in eight human languages, side by side |
| Testing | probandum, proba, adfirma, tags, running tests |
| Commands | The daily faber CLI loop |
Keywords you will meet first#
The twenty that carry most Faber source. Each links to the page that shows it in use; the corpus has the exhaustive entry for every one.
| Keyword | Means | Shown on |
|---|---|---|
main | Program entry point | Entry points |
incipiet | Async program entry point | Entry points |
fn | Declare a function | Generics |
return | Return a value | Control flow |
const | Bind a constant | Bindings |
var | Bind a mutable variable | Bindings |
class | Declare a record type | Generics |
typus | Name an alias for a type | Types and widths |
if | If | Control flow |
elif | Else-if | Control flow |
else | Else | Control flow |
switch | Select over a value | Control flow |
match | Match over a union | Control flow |
case | A case arm | Control flow |
for | Iterate | Loops |
while | While | Loops |
iace | Send a value down the error channel | Errors and catching |
catch | Catch from the error channel | Errors and catching |
import | Import a module or item | Imports |
proba | Declare a test | Testing |
Glyphs#
| Glyph | Reads as |
|---|---|
← | bind — put the value on the right into the name on the left |
→ | returns this type |
⇥ | …and may fail with this error type |
≡ | equals |
∪ | union of types |
↦ | convert to this type |
∴ | closure joint |
‥ | range, as in 0‥10 |
Full discussion: Glyphs and Latin.