arg; } Enumerated types Enumerated types are an important feature of the language; they can have type parameters and be recursive. They provide basic support for algebraic data types, allowing the inclusion of product types, in a fashion similar to Haskell and ML. A switch expression can apply pattern matching to an enum value, allowing for elegant solutions to complex programming problems: enum Color { red; green; blue; rgb(r:Int, g:Int, b:Int); } class Colors { static function toInt(c:Color):Int { return switch (c) { case red: 0xFF0000; case green: 0x00FF00; case blue: 0x0000FF; case rgb(r, g, b): (r << 16) | (g << 8) | b; } } static function validCalls() { var redint = toInt(Color.red); var rgbint = toInt(Color.rgb(100, 100, 100)); } } Examples of parametric enum types are the Haxe standard library types Option and Either: enum Option<T> { Some(v:T); None; } enum Either<L, R> { Left(v:L); Right(v:R); } Haxe also supports generalized algebraic data types (GADTs). Anonymous types Anonymous types are defined by denoting their structure explicitly, using a syntax that follows the mathematical record-based representation of a type. They can be used to implement structural typing for function arguments (see below), and can be given an alias with the keyword typedef: typedef AliasForAnon = { a:Int, b:String, c:Float->Void }; Function types Functions are first-class values in Haxe. Their type is denoted by using arrows between argument types, and between the argument type(s) and return type, as common in many functional languages. However, unlike in prominent examples like Haskell or the ML language family, not all functions are unary functions (functions with one argument only), and in Haxe, functions can't be partially applied per default. Thus, the following type signatures have different semantics than in the aforementioned languages. The type F1 is a function that takes a String as arguments and returns a value of type Float. Types F1 andF2 denote the same type, except that F2 uses labelled parameter, which is useful for completion and documentation purposes. Types F4 and F5 denote the same type. Both are binary functions that return a binary function of type F3. For F5 the syntax to declare a function type within a function type is used. typedef F1 = String -> Float; typedef F2 = (text:String) -> Float; typedef F3 = (score:Int, text:String) -> Float; typedef F4 = (score:Int, text:String) -> F3; typedef F5 = (score:Int, text:String) -> ((score:Int, text:String) ->