Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

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.

reader locale
faber convert --to en — English reader surface
fn divide(int a, int b) → int ∪ none {
    if b ≡ 0 then return null
    return a / b
}
faber convert --to la — canonical Faber
functio divide(numerus a, numerus b) → numerus ∪ nihil {
    si b ≡ 0 ergo redde nulla
    redde a / b
}
faber convert --to th-TH — Thai
ฟังก์ชัน divide(จํานวน a, จํานวน b) → จํานวน ∪ ไม่มี {
    ถ้า b ≡ 0 ดังนั้น คืน ขาดหาย
    คืน a / b
}
faber convert --to zh-Hans — Simplified Chinese
函数 divide(整数 a, 整数 b) → 整数 ∪ 无 {
    如果 b ≡ 0 则 返回 缺失
    返回 a / b
}
faber convert --to zh-Hant — Traditional Chinese
函式 divide(整數 a, 整數 b) → 整數 ∪ 無 {
    若 b ≡ 0 則 傳回 缺失
    傳回 a / b
}
faber convert --to vi — Vietnamese
hàm divide(số a, số b) → số ∪ hư_không {
    nếu b ≡ 0 do_đó trả vắng
    trả a / b
}
faber convert --to ar — Arabic
دالة divide(عدد a, عدد b) → عدد ∪ لاشيء {
    إذا b ≡ 0 إذن أعد غائب
    أعد a / b
}
faber convert --to hi — Hindi
फलन divide(संख्या a, संख्या b) → संख्या ∪ कुछनहीं {
    यदि b ≡ 0 अतः लौटाओ अभाव
    लौटाओ a / b
}

int 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:

reader locale
faber convert --to en — English reader surface
main {
    let list<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    let tensor<f32, [2, 3]> matrix ← valores ↦ tensor<f32, [2, 3]>
    let f32 medium ← matrix.mean()
    print medium
}
faber convert --to la — canonical Faber
incipit {
    sit lista<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    sit tensor<f32, [2, 3]> matrix ← valores ↦ tensor<f32, [2, 3]>
    sit f32 medium ← matrix.media()
    nota medium
}
faber convert --to th-TH — Thai
เริ่ม {
    กำหนด รายการ<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    กำหนด เทนเซอร์<f32, [2, 3]> matrix ← valores ↦ เทนเซอร์<f32, [2, 3]>
    กำหนด f32 medium ← matrix.ค่าเฉลี่ย()
    บันทึก medium
}
faber convert --to zh-Hans — Simplified Chinese
入口 {
    设 列表<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    设 张量<f32, [2, 3]> matrix ← valores ↦ 张量<f32, [2, 3]>
    设 f32 medium ← matrix.均值()
    显示 medium
}
faber convert --to zh-Hant — Traditional Chinese
入口 {
    設為 列表<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    設為 張量<f32, [2, 3]> matrix ← valores ↦ 張量<f32, [2, 3]>
    設為 f32 medium ← matrix.平均值()
    註記 medium
}
faber convert --to vi — Vietnamese
bắt_đầu {
    đặt danh_sách<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    đặt ten_xo<f32, [2, 3]> matrix ← valores ↦ ten_xo<f32, [2, 3]>
    đặt f32 medium ← matrix.trung_bình()
    ghi_chú medium
}
faber convert --to ar — Arabic
بداية {
    ليكن قائمة<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    ليكن موتر<f32, [2, 3]> matrix ← valores ↦ موتر<f32, [2, 3]>
    ليكن f32 medium ← matrix.المتوسط()
    اعرض medium
}
faber convert --to hi — Hindi
आरंभ {
    बैठा सूची<f32> valores ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    बैठा टेंसर<f32, [2, 3]> matrix ← valores ↦ टेंसर<f32, [2, 3]>
    बैठा f32 medium ← matrix.माध्य()
    दिखाओ medium
}

main is the entry point. let binds a fixed name. ← is the bind glyph — assignment reads right-to-left into the name. print prints.

By topic#

PageWhat it covers
Entry pointsmain, async entry, CLI arguments and annotations
Bindingslet vs mut, type holes, union holes
Types and widthsNumbers and their widths, lists, tables, tensors, vectors, and the sugar for each
GenericsGeneric functions, generic containers, class
Loopsfor over values, keys, and ranges; while
Control flowif / elif / else, switch, match over unions
Errors and catchingThe ⇥ error channel, throw, and catch on many block forms
Conversions↦ conversion, recovery with ⊥, conversion vs casting
ImportsStandard library, local files, aliasing, and public re-exports
Reader localesThe same program in eight human languages, side by side
Testingdescribe, test, assert, tags, running tests
CommandsThe 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.

KeywordMeansShown on
mainProgram entry pointEntry points
async_mainAsync program entry pointEntry points
fnDeclare a functionGenerics
returnReturn a valueControl flow
letBind a fixed nameBindings
mutBind a writable nameBindings
classDeclare a record typeGenerics
typeName an alias for a typeTypes and widths
ifIfControl flow
elifElse-ifControl flow
elseElseControl flow
switchSelect over a valueControl flow
matchMatch over a unionControl flow
caseA case armControl flow
forIterateLoops
whileWhileLoops
throwSend a value down the error channelErrors and catching
catchCatch from the error channelErrors and catching
importImport a module or itemImports
testDeclare a testTesting

Glyphs#

GlyphReads 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.