OxL Reference

kw type

Reserved keyword

The list of words: §1.4

Syntax

ebnf
IMember     = "embed" Type | "type" Ident [ "=" Type ] | Receiver "fn" Sig [ "=>" Expr | Block ] ;
ebnf
TypeAlias   = "type" Ident [ Generics ] "=" ( [ "distinct" ] Type [ "where" Expr ] ) ;

Grammar: App. A

Defined in

Examples

oxl
type Bytes2 = [u8; 2]                     // alias, the same type
type UserId = distinct u64                // a new type, no implicit conversions
type Port   = u16 where 1..=65535         // refined type
type Name   = str where len(1..=64)
type Email  = str where matches(re".+@.+\..+")

— 3.6 Aliases, new types and refined types

oxl
type NetError = Timeout | Unavailable | Cancelled | AccessDenied | ProtocolError

— 6.5 Errors

Related diagnostics

refinement-violated, comptime-error, not-comptime, fail-type, question-context, unhandled-error, bad-label, bad-format-spec, invalid-char-literal, invalid-date, invalid-duration, invalid-escape, invalid-number, literal-overflow

See also