This directory demonstrates the most basic usage of Haxe→Elixir compilation, focusing on creating simple Elixir modules using the @:module syntax.
- Understand
@:moduleannotation for clean syntax - Learn pipe operator (
|>) usage in Haxe - Master public and private function patterns
- See the compilation output compared to hand-written Elixir
Demonstrates: Core @:module syntax, basic functions
Compiles to: BasicModule.ex
Demonstrates: Pipe operators, functional composition
Compiles to: MathHelper.ex
Demonstrates: Public/private functions, @:private annotation
Compiles to: UserUtil.ex
cd examples/01-simple-modules
haxe compile-all.hxml# Basic module
haxe BasicModule.hxml
# Math helper with pipes
haxe MathHelper.hxml
# User utilities with private functions
haxe UserUtil.hxmlEach example includes:
.hxsource file (Haxe).hxmlcompilation configexpected/directory with hand-written Elixir equivalentoutput/directory with compiled result
# Compare compiled vs expected
diff output/BasicModule.ex expected/BasicModule.exEliminates the need to write public static on every function:
@:module
class BasicModule {
// Automatically becomes "def hello() do"
function hello(): String {
return "world";
}
}Native Elixir-style functional composition:
function calculate(x: Float): Float {
return x
|> multiplyByTwo()
|> addTen()
|> Math.round();
}Use @:private for defp generation:
@:private
function validateInput(data: String): Bool {
return data != null && data.length > 0;
}After mastering simple modules, continue to:
- 02-mix-project - Integration with Mix build system
- 03-phoenix-app - Minimal Phoenix web app authored in Haxe
- todo-app - Full Phoenix LiveView + Ecto reference app
Compilation errors?
- Ensure Haxe 4.3.7+ is installed
- Check that
reflaxe_runtimeflag is set in .hxml files - Verify src/ directory is in classpath
Output doesn't match expected?
- This is normal as compiler output may include additional metadata
- Focus on the core function definitions and module structure