Type aliases
type Name = ExistingType gives another spelling to the same type. An alias is transparent, so it adds vocabulary without creating a new nominal identity or a conversion boundary.
An alias may take type parameters and may name any complete type expression, including tuples, functions, optionals, and instantiated user types.
type Pair = (int, int)
type Maybe<T> = Optional<T>
fn show(pair: Pair) -> string { "${pair.0},${pair.1}" }
fn main() {
let value: Maybe<Pair> = some((3, 4))
println(show(value.unwrap()))
}
Examples use the moon toolchain version shown beside each result.
Output & diagnostics
Expected: 3,4
Ctrl/⌘+Enter runs the current lesson.