Your first Elara program
This guide will walk you through writing, compiling, and running your first Elara program.Make sure you have installed Elara before continuing.
Create your source file
Create a file named This simple program defines a
hello.elr with the following content:hello.elr
main function that prints “Hello, World!” to the console. The type IO () indicates that main performs an I/O operation and returns unit (nothing).Compile your program
Compile the program using the This will generate JVM bytecode in the
elara build command:build/ directory.Understanding the program
Let’s break down what’s happening in this simple program:def main : IO ()— Declares the type signature formain. It takes no arguments and performs I/O operationslet main = ...— Defines the implementation ofmainprintln— A built-in function that prints a string followed by a newline- The string
"Hello, World!"is passed toprintln
More examples
Working with numbers
- Local bindings with
let - String concatenation with
++ - Converting numbers to strings with
toString
Pattern matching with lists
- Pattern matching on lists with
match...with - Recursive functions
- The
ConsandNilconstructors for lists
Compiler commands
Debugging with dump targets
You can inspect intermediate compilation stages using the--dump flag:
lexed— Lexer output (tokens)parsed— Parser output (AST)desugared— Desugared ASTrenamed— After name resolutionshunted— After operator precedencetyped— After type checkingcore— Core IRir— JVM IRjvm— JVM bytecode info
Common patterns
IO sequencing
Use the*> operator to sequence multiple IO operations:
Importing modules
Next steps
Language guide
Learn about Elara’s type system, pattern matching, and more
Examples
Browse more complex examples and real-world patterns
Standard library
Explore the built-in functions and types
Join the community
Get help and connect with other Elara developers