Renderingen-US

type

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Declares a type alias.

Aliases: type

Syntax: type <name> = <type>

Category#

type

Examples#

radix/corpus/typus/typus.fab (canonical · keyword)#

Declares a type alias.

# =============================================================================
# type — Declares a type alias.
# =============================================================================
#
# What this teaches:
#   • Type aliases — `type` for creating shorthand names for complex types
#   • Generic aliases — aliases can wrap generic types like `list<T>` and `map<K,V>`
#
# Common mistakes:
#   • confusing type (type alias) with class (nominal type) — type creates a transparent alias, not a new type
#
# See also: class, interface, object, ∪
# =============================================================================




# Type aliases
#
# type Nomen = Typus
#
# GRAMMAR:
#   typeAliasDecl :← 'type' ident '=' typeExpr
#
# EXPECTED OUTPUT:
#   42, "Marcus", true, ["Gaius", "Lucius", "Titus"], [100, 95, 87]

# --- Primitive type aliases ---

type Signum = int
type Cognomen = string
type Viget = bool

# --- Generic type aliases ---

type Nomina = list<string>
type Puncta = list<int>
type Index = map<string, int>

# Nullable type alias (canonical T ∪ none form)
type NomenOptivum = string ∪ none

main {
    # Using primitive aliases
    const Signum signum ← 42
    const Cognomen cognomen ← "Marcus"
    const Viget viget ← true

    print signum
    print cognomen
    print viget

    # Using generic aliases
    const Nomina sodales ← ["Gaius", "Lucius", "Titus"]
    print sodales

    const Puncta puncta ← [100, 95, 87]
    print puncta
}