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.

Faber

Canonical re-emission — the compiler printing the program back.

Part of the HIR lane. Every panel below is compiler output.

How to read it#

The round trip. Reader-locale spellings and formatting normalise to the canonical surface, which is how a program written in one locale can be reviewed in another.

Measured support#

CapableAnalyzableCoverage
573573100%

From the target matrix: how many corpus exempla lower to this target. Coverage is not a quality score — an emitter can lower a term and still erase a distinction.

No measured gaps in the scored sections.

Typed tensors#

Builds two shaped matrices, multiplies them, and reduces the product to a scalar. Exercises shape-bearing types and a reduction.

Faber source

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

Faber — 9 lines in, 9 out (1.0×)

incipit {
    sit lista<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    sit lista<f32> flat_b ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
    sit tf32[2, 3] a ← flat_a ↦ tf32[2, 3]
    sit tf32[3, 4] b ← flat_b ↦ tf32[3, 4]
    sit tf32[2, 4] product ← a.matmul(b)
    sit f32 mean ← product.media()
    nota mean
}

The error channel#

A function that may fail, and a caller that catches. Shows how the ⇥ channel becomes each target's own error idiom.

Faber source

reader locale
faber convert --to en — English reader surface
fn divide(int a, int b) → int ⇥ string {
    if b ≡ 0 {
        throw "division by zero"
    }
    return a / b
}

main {
    do {
        print divide(10, 2)
    }
    catch err {
        warn err
    }
}
faber convert --to la — canonical Faber
functio divide(numerus a, numerus b) → numerus ⇥ textus {
    si b ≡ 0 {
        iace "division by zero"
    }
    redde a / b
}

incipit {
    fac {
        nota divide(10, 2)
    }
    cape err {
        mone err
    }
}
faber convert --to th-TH — Thai
ฟังก์ชัน divide(จํานวน a, จํานวน b) → จํานวน ⇥ ข้อความ {
    ถ้า b ≡ 0 {
        โยน "division by zero"
    }
    คืน a / b
}

เริ่ม {
    ทำ {
        บันทึก divide(10, 2)
    }
    จับ err {
        เตือน err
    }
}
faber convert --to zh-Hans — Simplified Chinese
函数 divide(整数 a, 整数 b) → 整数 ⇥ 文本 {
    如果 b ≡ 0 {
        抛错 "division by zero"
    }
    返回 a / b
}

入口 {
    执行 {
        显示 divide(10, 2)
    }
    捕获 err {
        警告 err
    }
}
faber convert --to zh-Hant — Traditional Chinese
函式 divide(整數 a, 整數 b) → 整數 ⇥ 文字 {
    若 b ≡ 0 {
        拋出 "division by zero"
    }
    傳回 a / b
}

入口 {
    執行 {
        註記 divide(10, 2)
    }
    捕捉 err {
        警告 err
    }
}
faber convert --to vi — Vietnamese
hàm divide(số a, số b) → số ⇥ văn_bản {
    nếu b ≡ 0 {
        ném "division by zero"
    }
    trả a / b
}

bắt_đầu {
    làm {
        ghi_chú divide(10, 2)
    }
    bắt err {
        cảnh_báo err
    }
}
faber convert --to ar — Arabic
دالة divide(عدد a, عدد b) → عدد ⇥ نص {
    إذا b ≡ 0 {
        ارم "division by zero"
    }
    أعد a / b
}

بداية {
    افعل {
        اعرض divide(10, 2)
    }
    التقط err {
        نبه err
    }
}
faber convert --to hi — Hindi
फलन divide(संख्या a, संख्या b) → संख्या ⇥ पाठ {
    यदि b ≡ 0 {
        इधरफेंको "division by zero"
    }
    लौटाओ a / b
}

आरंभ {
    करो {
        दिखाओ divide(10, 2)
    }
    पकड़ो err {
        चेताओ err
    }
}

Faber — 13 lines in, 13 out (1.0×)

functio divide(numerus a, numerus b) → numerus ⇥ textus {
    si b ≡ 0 ergo iace "division by zero"
    redde a / b
}

incipit {
    fac {
        nota divide(10, 2)
    }
    cape err {
        mone err
    }
}

Collections and iteration#

A list folded to a total with for from. The plainest possible read on how loops lower.

Faber source

fn sum(list<int> numeri) → int {
    mut int total ← 0
    for from numeri let n {
        total ← total + n
    }
    return total
}

main {
    let list<int> valores ← [1, 2, 3, 4, 5]
    print sum(valores)
}

Faber — 12 lines in, 12 out (1.0×)

functio summa(lista<numerus> numeri) → numerus {
    varia numerus total ← 0
    itera ex numeri sit n {
        total ← total + n
    }
    redde total
}

incipit {
    sit lista<numerus> valores ← [1, 2, 3, 4, 5]
    nota summa(valores)
}

---

All targets · Measured support per term