Renderingen-US

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
378378100%

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 {
    const list<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    const 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]
    const tf32[] seed ← empty
    const tf32[2, 3] a ← seed.from_flat(flat_a, [2, 3])
    const tf32[3, 4] b ← seed.from_flat(flat_b, [3, 4])
    const tf32[2, 4] product ← a.matmul(b)
    const f32 mean ← product.mean()
    print mean
}
faber convert --to la — canonical Faber
incipit {
    fixum lista<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    fixum 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]
    fixum tf32[] seed ← vacua
    fixum tf32[2, 3] a ← seed.strue(flat_a, [2, 3])
    fixum tf32[3, 4] b ← seed.strue(flat_b, [3, 4])
    fixum tf32[2, 4] product ← a.matmul(b)
    fixum 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[] seed ← เซตว่าง
    คงที่ tf32[2, 3] a ← seed.สร้างจากข้อมูลแบน(flat_a, [2, 3])
    คงที่ tf32[3, 4] b ← seed.สร้างจากข้อมูลแบน(flat_b, [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[] seed ← 空集
    常量 tf32[2, 3] a ← seed.由扁平构造(flat_a, [2, 3])
    常量 tf32[3, 4] b ← seed.由扁平构造(flat_b, [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[] seed ← 空集
    定值 tf32[2, 3] a ← seed.由扁平建構(flat_a, [2, 3])
    定值 tf32[3, 4] b ← seed.由扁平建構(flat_b, [3, 4])
    定值 tf32[2, 4] product ← a.矩陣乘法(b)
    定值 f32 mean ← product.平均值()
    註記 mean
}
faber convert --to vi — Vietnamese
bắt_đầu {
    hằng danh_sách<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    hằng 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]
    hằng tf32[] seed ← tập_rỗng
    hằng tf32[2, 3] a ← seed.dựng_từ_phẳng(flat_a, [2, 3])
    hằng tf32[3, 4] b ← seed.dựng_từ_phẳng(flat_b, [3, 4])
    hằng tf32[2, 4] product ← a.nhân_ma_trận(b)
    hằng 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[] seed ← فارغ
    ثابت tf32[2, 3] a ← seed.ابن_من_مسطح(flat_a, [2, 3])
    ثابت tf32[3, 4] b ← seed.ابن_من_مسطح(flat_b, [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[] seed ← खाली
    स्थिर tf32[2, 3] a ← seed.समतल_से_बनाओ(flat_a, [2, 3])
    स्थिर tf32[3, 4] b ← seed.समतल_से_बनाओ(flat_b, [3, 4])
    स्थिर tf32[2, 4] product ← a.आव्यूह_गुणन(b)
    स्थिर f32 mean ← product.माध्य()
    दिखाओ mean
}

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

incipit {
    fixum lista<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    fixum 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]
    fixum tf32[] seed ← vacua
    fixum tf32[2, 3] a ← seed.strue(flat_a, [2, 3])
    fixum tf32[3, 4] b ← seed.strue(flat_b, [3, 4])
    fixum tf32[2, 4] product ← a.matmul(b)
    fixum 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 {
    var int total ← 0
    for from numeri const n {
        total ← total + n
    }
    return total
}

main {
    const 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 fixum n {
        total ← total + n
    }
    redde total
}

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

---

All targets · Measured support per term