Renderingen-US

Types and widths

Types come before names. textus nomen, never nomen: textus.

Everyday types#

reader locale
faber format --locale en — English reader surface
fn nihil_agit()  void {
    print "done"
}

main {
    const string nomen  "Marcus"
    const int aetas  30
    const bool ready  true
    const list<int> empty  vacua
    const int  null missing  null
    print nomen, aetas, ready, empty, missing
    nihil_agit()
}
faber format --locale la — canonical Faber
functio nihil_agit()  vacuum {
    nota "done"
}

incipit {
    fixum textus nomen  "Marcus"
    fixum numerus aetas  30
    fixum bivalens ready  verum
    fixum lista<numerus> empty  vacua
    fixum numerus  nihil missing  nihil
    nota nomen, aetas, ready, empty, missing
    nihil_agit()
}
faber format --locale th-TH — Thai
ฟังก์ชัน nihil_agit()  เปล่า {
    บันทึก "done"
}

เริ่ม {
    คงที่ ข้อความ nomen  "Marcus"
    คงที่ จำนวน aetas  30
    คงที่ ตรรกะ ready  จริง
    คงที่ รายการ<จำนวน> empty  เซตว่าง
    คงที่ จำนวน  ว่าง missing  ว่าง
    บันทึก nomen, aetas, ready, empty, missing
    nihil_agit()
}
faber format --locale zh-Hans — Simplified Chinese
函数 nihil_agit()  无值 {
    显示 "done"
}

入口 {
    常量 文本 nomen  "Marcus"
    常量 整数 aetas  30
    常量 布尔 ready  
    常量 列表<整数> empty  空集
    常量 整数   missing  
    显示 nomen, aetas, ready, empty, missing
    nihil_agit()
}
faber format --locale zh-Hant — Traditional Chinese
函式 nihil_agit()  空值 {
    註記 "done"
}

入口 {
    定值 文字 nomen  "Marcus"
    定值 整數 aetas  30
    定值 布林 ready  
    定值 列表<整數> empty  空集
    定值 整數   missing  
    註記 nomen, aetas, ready, empty, missing
    nihil_agit()
}
faber format --locale vi — Vietnamese
hàm nihil_agit()  trống {
    ghi_chú "done"
}

bắt_đầu {
    hằng văn_bản nomen  "Marcus"
    hằng số aetas  30
    hằng logic ready  đúng
    hằng danh_sách<số> empty  tập_rỗng
    hằng số  rỗng missing  rỗng
    ghi_chú nomen, aetas, ready, empty, missing
    nihil_agit()
}
faber format --locale ar — Arabic
دالة nihil_agit()  فراغ {
    اعرض "done"
}

بداية {
    ثابت نص nomen  "Marcus"
    ثابت عدد aetas  30
    ثابت منطقي ready  صواب
    ثابت قائمة<عدد> empty  فارغ
    ثابت عدد  لاشيء missing  لاشيء
    اعرض nomen, aetas, ready, empty, missing
    nihil_agit()
}
faber format --locale hi — Hindi
फलन nihil_agit()  रिक्त {
    दिखाओ "done"
}

आरंभ {
    स्थिर पाठ nomen  "Marcus"
    स्थिर संख्या aetas  30
    स्थिर तार्किक ready  सत्य
    स्थिर सूची<संख्या> empty  खाली
    स्थिर संख्या  शून्य missing  शून्य
    दिखाओ nomen, aetas, ready, empty, missing
    nihil_agit()
}
TypeIs
stringtext
inta number, default width
booltrue / false — true / false
voidthe return type of a function that yields no value
nullabsence — the other half of an optional

Do not confuse void with vacua. void is a type, used as a return annotation. vacua is a value: the empty collection, which is why it seeds lists and tensors above. Binding vacua to something that is not a collection is a compile error.

Numeric widths#

int is the general number. When the width matters, name it directly — these are the same family, spelled precisely.

reader locale
faber format --locale en — English reader surface
main {
    const int<i32> signed  -7
    const int<u8> byte  255
    const f64 wide  1.5
    print signed, byte, wide
}
faber format --locale la — canonical Faber
incipit {
    fixum numerus<i32> signed  -7
    fixum numerus<u8> byte  255
    fixum f64 wide  1.5
    nota signed, byte, wide
}
faber format --locale th-TH — Thai
เริ่ม {
    คงที่ จำนวน<i32> signed  -7
    คงที่ จำนวน<u8> byte  255
    คงที่ f64 wide  1.5
    บันทึก signed, byte, wide
}
faber format --locale zh-Hans — Simplified Chinese
入口 {
    常量 整数<i32> signed  -7
    常量 整数<u8> byte  255
    常量 f64 wide  1.5
    显示 signed, byte, wide
}
faber format --locale zh-Hant — Traditional Chinese
入口 {
    定值 整數<i32> signed  -7
    定值 整數<u8> byte  255
    定值 f64 wide  1.5
    註記 signed, byte, wide
}
faber format --locale vi — Vietnamese
bắt_đầu {
    hằng số<i32> signed  -7
    hằng số<u8> byte  255
    hằng f64 wide  1.5
    ghi_chú signed, byte, wide
}
faber format --locale ar — Arabic
بداية {
    ثابت عدد<i32> signed  -7
    ثابت عدد<u8> byte  255
    ثابت f64 wide  1.5
    اعرض signed, byte, wide
}
faber format --locale hi — Hindi
आरंभ {
    स्थिर संख्या<i32> signed  -7
    स्थिर संख्या<u8> byte  255
    स्थिर f64 wide  1.5
    दिखाओ signed, byte, wide
}
FamilyWidths
Signedi8 i16 i32 i64
Unsignedu8 u16 u32 u64
Floatingf16 f32 f64

Lists and tables#

reader locale
faber format --locale en — English reader surface
main {
    const list<int> numeri  [1, 2, 3]
    const map<string, int> aetates  { "Marcus": 30, "Julia": 28 }
    print numeri[0]
    print aetates["Marcus"]
    print numeri.longitudo()
}
faber format --locale la — canonical Faber
incipit {
    fixum lista<numerus> numeri  [1, 2, 3]
    fixum tabula<textus, numerus> aetates  { "Marcus": 30, "Julia": 28 }
    nota numeri[0]
    nota aetates["Marcus"]
    nota numeri.longitudo()
}
faber format --locale th-TH — Thai
เริ่ม {
    คงที่ รายการ<จำนวน> numeri  [1, 2, 3]
    คงที่ ตาราง<ข้อความ, จำนวน> aetates  { "Marcus": 30, "Julia": 28 }
    บันทึก numeri[0]
    บันทึก aetates["Marcus"]
    บันทึก numeri.longitudo()
}
faber format --locale zh-Hans — Simplified Chinese
入口 {
    常量 列表<整数> numeri  [1, 2, 3]
    常量 映射<文本, 整数> aetates  { "Marcus": 30, "Julia": 28 }
    显示 numeri[0]
    显示 aetates["Marcus"]
    显示 numeri.longitudo()
}
faber format --locale zh-Hant — Traditional Chinese
入口 {
    定值 列表<整數> numeri  [1, 2, 3]
    定值 表格<文字, 整數> aetates  { "Marcus": 30, "Julia": 28 }
    註記 numeri[0]
    註記 aetates["Marcus"]
    註記 numeri.longitudo()
}
faber format --locale vi — Vietnamese
bắt_đầu {
    hằng danh_sách<số> numeri  [1, 2, 3]
    hằng bảng<văn_bản, số> aetates  { "Marcus": 30, "Julia": 28 }
    ghi_chú numeri[0]
    ghi_chú aetates["Marcus"]
    ghi_chú numeri.longitudo()
}
faber format --locale ar — Arabic
بداية {
    ثابت قائمة<عدد> numeri  [1, 2, 3]
    ثابت جدول<نص, عدد> aetates  { "Marcus": 30, "Julia": 28 }
    اعرض numeri[0]
    اعرض aetates["Marcus"]
    اعرض numeri.longitudo()
}
faber format --locale hi — Hindi
आरंभ {
    स्थिर सूची<संख्या> numeri  [1, 2, 3]
    स्थिर तालिका<पाठ, संख्या> aetates  { "Marcus": 30, "Julia": 28 }
    दिखाओ numeri[0]
    दिखाओ aetates["Marcus"]
    दिखाओ numeri.longitudo()
}

lista<T> holds many of one type. A map maps keys to values — the { "key": value } form above is inline JSON ascribed to a map type, not a separate map literal, which is why it uses : where Faber's typed construction uses =. Both take type holes and unions as their parameters:

reader locale
faber format --locale en — English reader surface
main {
    const list<string  int> mixed  [1, "two", 3]
    const list<int> inferred  [1, 2, 3]
    print mixed, inferred
}
faber format --locale la — canonical Faber
incipit {
    fixum lista<textus  numerus> mixed  [1, "two", 3]
    fixum lista<numerus> inferred  [1, 2, 3]
    nota mixed, inferred
}
faber format --locale th-TH — Thai
เริ่ม {
    คงที่ รายการ<ข้อความ  จำนวน> mixed  [1, "two", 3]
    คงที่ รายการ<จำนวน> inferred  [1, 2, 3]
    บันทึก mixed, inferred
}
faber format --locale zh-Hans — Simplified Chinese
入口 {
    常量 列表<文本  整数> mixed  [1, "two", 3]
    常量 列表<整数> inferred  [1, 2, 3]
    显示 mixed, inferred
}
faber format --locale zh-Hant — Traditional Chinese
入口 {
    定值 列表<文字  整數> mixed  [1, "two", 3]
    定值 列表<整數> inferred  [1, 2, 3]
    註記 mixed, inferred
}
faber format --locale vi — Vietnamese
bắt_đầu {
    hằng danh_sách<văn_bản  số> mixed  [1, "two", 3]
    hằng danh_sách<số> inferred  [1, 2, 3]
    ghi_chú mixed, inferred
}
faber format --locale ar — Arabic
بداية {
    ثابت قائمة<نص  عدد> mixed  [1, "two", 3]
    ثابت قائمة<عدد> inferred  [1, 2, 3]
    اعرض mixed, inferred
}
faber format --locale hi — Hindi
आरंभ {
    स्थिर सूची<पाठ  संख्या> mixed  [1, "two", 3]
    स्थिर सूची<संख्या> inferred  [1, 2, 3]
    दिखाओ mixed, inferred
}

Tensors#

A tensor carries an element type and a shape. vacua seeds an empty one; strue builds a shaped tensor from flat values.

reader locale
faber format --locale en — English reader surface
main {
    const list<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    const tensor<f32, []> seed  vacua
    const tensor<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    print m.media()
}
faber format --locale la — canonical Faber
incipit {
    fixum lista<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    fixum tensor<f32, []> seed  vacua
    fixum tensor<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    nota m.media()
}
faber format --locale th-TH — Thai
เริ่ม {
    คงที่ รายการ<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    คงที่ เทนเซอร์<f32, []> seed  เซตว่าง
    คงที่ เทนเซอร์<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    บันทึก m.media()
}
faber format --locale zh-Hans — Simplified Chinese
入口 {
    常量 列表<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    常量 张量<f32, []> seed  空集
    常量 张量<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    显示 m.media()
}
faber format --locale zh-Hant — Traditional Chinese
入口 {
    定值 列表<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    定值 張量<f32, []> seed  空集
    定值 張量<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    註記 m.media()
}
faber format --locale vi — Vietnamese
bắt_đầu {
    hằng danh_sách<f32> flat  [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]> m  seed.strue(flat, [2, 3])
    ghi_chú m.media()
}
faber format --locale ar — Arabic
بداية {
    ثابت قائمة<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    ثابت موتر<f32, []> seed  فارغ
    ثابت موتر<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    اعرض m.media()
}
faber format --locale hi — Hindi
आरंभ {
    स्थिर सूची<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    स्थिर टेंसर<f32, []> seed  खाली
    स्थिर टेंसर<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    दिखाओ m.media()
}

Shape sugar#

tf32[2, 3] is sugar for tensor<f32, [2, 3]> — same type, shorter to read in a signature.

reader locale
faber format --locale en — English reader surface
fn medium(tensor<f32, [2, 3]> m)  f32 {
    return m.media()
}

main {
    const list<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    const tensor<f32, []> seed  vacua
    const tensor<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    print medium(m)
}
faber format --locale la — canonical Faber
functio medium(tensor<f32, [2, 3]> m)  f32 {
    redde m.media()
}

incipit {
    fixum lista<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    fixum tensor<f32, []> seed  vacua
    fixum tensor<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    nota medium(m)
}
faber format --locale th-TH — Thai
ฟังก์ชัน medium(เทนเซอร์<f32, [2, 3]> m)  f32 {
    คืน m.media()
}

เริ่ม {
    คงที่ รายการ<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    คงที่ เทนเซอร์<f32, []> seed  เซตว่าง
    คงที่ เทนเซอร์<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    บันทึก medium(m)
}
faber format --locale zh-Hans — Simplified Chinese
函数 medium(张量<f32, [2, 3]> m)  f32 {
    返回 m.media()
}

入口 {
    常量 列表<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    常量 张量<f32, []> seed  空集
    常量 张量<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    显示 medium(m)
}
faber format --locale zh-Hant — Traditional Chinese
函式 medium(張量<f32, [2, 3]> m)  f32 {
    傳回 m.media()
}

入口 {
    定值 列表<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    定值 張量<f32, []> seed  空集
    定值 張量<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    註記 medium(m)
}
faber format --locale vi — Vietnamese
hàm medium(ten_xo<f32, [2, 3]> m)  f32 {
    trả m.media()
}

bắt_đầu {
    hằng danh_sách<f32> flat  [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]> m  seed.strue(flat, [2, 3])
    ghi_chú medium(m)
}
faber format --locale ar — Arabic
دالة medium(موتر<f32, [2, 3]> m)  f32 {
    أعد m.media()
}

بداية {
    ثابت قائمة<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    ثابت موتر<f32, []> seed  فارغ
    ثابت موتر<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    اعرض medium(m)
}
faber format --locale hi — Hindi
फलन medium(टेंसर<f32, [2, 3]> m)  f32 {
    लौटाओ m.media()
}

आरंभ {
    स्थिर सूची<f32> flat  [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
    स्थिर टेंसर<f32, []> seed  खाली
    स्थिर टेंसर<f32, [2, 3]> m  seed.strue(flat, [2, 3])
    दिखाओ medium(m)
}

Vectors#

vector<T, N> is a fixed-width vector, with vf32[N] as its sugar. Build one by converting a literal — the conversion is what fixes the width.

reader locale
faber format --locale en — English reader surface
main {
    const vector<f32, 4> v  [1.0, 2.0, 3.0, 4.0] ↦ vector<f32, 4>
    print v
}
faber format --locale la — canonical Faber
incipit {
    fixum vector<f32, 4> v  [1.0, 2.0, 3.0, 4.0] ↦ vector<f32, 4>
    nota v
}
faber format --locale th-TH — Thai
เริ่ม {
    คงที่ เวกเตอร์<f32, 4> v  [1.0, 2.0, 3.0, 4.0] ↦ เวกเตอร์<f32, 4>
    บันทึก v
}
faber format --locale zh-Hans — Simplified Chinese
入口 {
    常量 向量<f32, 4> v  [1.0, 2.0, 3.0, 4.0] ↦ 向量<f32, 4>
    显示 v
}
faber format --locale zh-Hant — Traditional Chinese
入口 {
    定值 向量<f32, 4> v  [1.0, 2.0, 3.0, 4.0] ↦ 向量<f32, 4>
    註記 v
}
faber format --locale vi — Vietnamese
bắt_đầu {
    hằng vectơ<f32, 4> v  [1.0, 2.0, 3.0, 4.0] ↦ vectơ<f32, 4>
    ghi_chú v
}
faber format --locale ar — Arabic
بداية {
    ثابت متجه<f32, 4> v  [1.0, 2.0, 3.0, 4.0] ↦ متجه<f32, 4>
    اعرض v
}
faber format --locale hi — Hindi
आरंभ {
    स्थिर सदिश<f32, 4> v  [1.0, 2.0, 3.0, 4.0] ↦ सदिश<f32, 4>
    दिखाओ v
}

Naming a type#

typus gives a type another name.

reader locale
faber format --locale en — English reader surface
type Nomen = string

type Puncta = list<int>

main {
    const string n  "Marcus"
    const list<int> p  [1, 2, 3]
    print n, p
}
faber format --locale la — canonical Faber
typus Nomen = textus

typus Puncta = lista<numerus>

incipit {
    fixum textus n  "Marcus"
    fixum lista<numerus> p  [1, 2, 3]
    nota n, p
}
faber format --locale th-TH — Thai
ชนิดนามแฝง Nomen = ข้อความ

ชนิดนามแฝง Puncta = รายการ<จำนวน>

เริ่ม {
    คงที่ ข้อความ n  "Marcus"
    คงที่ รายการ<จำนวน> p  [1, 2, 3]
    บันทึก n, p
}
faber format --locale zh-Hans — Simplified Chinese
类型 Nomen = 文本

类型 Puncta = 列表<整数>

入口 {
    常量 文本 n  "Marcus"
    常量 列表<整数> p  [1, 2, 3]
    显示 n, p
}
faber format --locale zh-Hant — Traditional Chinese
型別 Nomen = 文字

型別 Puncta = 列表<整數>

入口 {
    定值 文字 n  "Marcus"
    定值 列表<整數> p  [1, 2, 3]
    註記 n, p
}
faber format --locale vi — Vietnamese
kiểu_tên Nomen = văn_bản

kiểu_tên Puncta = danh_sách<số>

bắt_đầu {
    hằng văn_bản n  "Marcus"
    hằng danh_sách<số> p  [1, 2, 3]
    ghi_chú n, p
}
faber format --locale ar — Arabic
نمط Nomen = نص

نمط Puncta = قائمة<عدد>

بداية {
    ثابت نص n  "Marcus"
    ثابت قائمة<عدد> p  [1, 2, 3]
    اعرض n, p
}
faber format --locale hi — Hindi
प्रकार Nomen = पाठ

प्रकार Puncta = सूची<संख्या>

आरंभ {
    स्थिर पाठ n  "Marcus"
    स्थिर सूची<संख्या> p  [1, 2, 3]
    दिखाओ n, p
}

Records#

class declares a record. Fields are type-first, like everything else.

reader locale
faber format --locale en — English reader surface
class Persona {
    string nomen
    int aetas
}

main {
    const Persona p  Persona {nomen = "Marcus", aetas = 30}
    print p.nomen, p.aetas
}
faber format --locale la — canonical Faber
genus Persona {
    textus nomen
    numerus aetas
}

incipit {
    fixum Persona p  Persona {nomen = "Marcus", aetas = 30}
    nota p.nomen, p.aetas
}
faber format --locale th-TH — Thai
ชนิด Persona {
    ข้อความ nomen
    จำนวน aetas
}

เริ่ม {
    คงที่ Persona p  Persona {nomen = "Marcus", aetas = 30}
    บันทึก p.nomen, p.aetas
}
faber format --locale zh-Hans — Simplified Chinese
 Persona {
    文本 nomen
    整数 aetas
}

入口 {
    常量 Persona p  Persona {nomen = "Marcus", aetas = 30}
    显示 p.nomen, p.aetas
}
faber format --locale zh-Hant — Traditional Chinese
類型 Persona {
    文字 nomen
    整數 aetas
}

入口 {
    定值 Persona p  Persona {nomen = "Marcus", aetas = 30}
    註記 p.nomen, p.aetas
}
faber format --locale vi — Vietnamese
kiểu Persona {
    văn_bản nomen
    số aetas
}

bắt_đầu {
    hằng Persona p  Persona {nomen = "Marcus", aetas = 30}
    ghi_chú p.nomen, p.aetas
}
faber format --locale ar — Arabic
صنف Persona {
    نص nomen
    عدد aetas
}

بداية {
    ثابت Persona p  Persona {nomen = "Marcus", aetas = 30}
    اعرض p.nomen, p.aetas
}
faber format --locale hi — Hindi
वर्ग Persona {
    पाठ nomen
    संख्या aetas
}

आरंभ {
    स्थिर Persona p  Persona {nomen = "Marcus", aetas = 30}
    दिखाओ p.nomen, p.aetas
}

Related: Bindings · Conversions · Types and values