9.3.2 Type Reification

Type reification is used to create instances of haxe.macro.Expr.ComplexType in a convenient way. It is identified by a macro : Type, where Type can be any valid type path expression. This is similar to explicit type hints in normal code, e.g. for variables in the form of var x:Type.

Each constructor of ComplexType has a distinct syntax:

  • TPath: macro : pack.Type
  • TFunction: macro : Arg1 -> Arg2 -> Return
  • TAnonymous: macro : { field: Type }
  • TParent: macro : (Type)
  • TExtend: macro : {> Type, field: Type }
  • TOptional: macro : ?Type

Take the Haxe Survey!