lloyAlloy on GitHub
trait
Docs

trait

Updated
trait Name
    function m(self): T
end

A behavior contract: method signatures, with a body as a default. impl Trait for Name implements it and <T: Trait> bounds a generic; <T: A & B> asks for both. The trait itself takes no type parameters.

An impl of an operator trait writes the metamethod: Add (add, __add), Sub, Mul, Div, Eq (eq, __eq), Lt and Le (__lt, __le), Display (to_string, __tostring), Call (call, __call), Len, Concat, and Drop (drop, which delete runs as Destroy). A bound names a shape the std exports, Display, Debug, Clone, Eq, PartialEq, Ord, Add, Sub, Mul, Div, Serialize; a file's own trait of the same name wins. alloy doc Traits lists them.

Emits a type with the method signatures.

The word is also free as a name. trait declares only before a name on the same line, so local trait = 1 and t.trait read the Luau way.