A Haskell-like purely functional language for the JVM
Documentation · Compiler API reference · Examples · Discord
Warning
Elara is currently a work in progress, expect a lot of breaking changes and unfinished features!
import Elara.Prim
type Option a = None | Some a
def map : (a -> b) -> Option a -> Option b
let map f opt =
match opt with
None -> None
Some x -> Some (f x)
def main : IO ()
let main = println (map (\x -> x * 2) (Some 3))
-- Prints: Some 6Elara was made to try and achieve two things. If you like the sound of these, Elara could be for you:
- A Haskell-like language on the JVM platform with high quality interoperability (todo)
- A modern Elm and Rust-like developer experience
In general, Elara also has some pretty cool features:
- Haskell- and F#-style, on the JVM. Algebraic data types, pattern matching and inferred Hindley-Milner polymorphism, compiled to JVM bytecode.
- High Quality Rust- and Elm-Style Error Messages:
- Modern Compiler Architecture: A query-based compiler with constraint-based Hindley-Milner inference.
Comparison with other languages
| Elara | Haskell | Frege | Eta | Scala 3 | Elm | Gleam | |
|---|---|---|---|---|---|---|---|
| Runs on the JVM | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ |
| Effects tracked in types | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
| Full type inference | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| Type classes / traits | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | |
| Actively maintained | ✅ | ✅ | ❌ | ✅ | ✅ | ||
| Production-ready | ❌ | ✅ | ✅ | ✅ | ✅ |
✅ yes ·
1. Get Elara
# prebuilt statically-linked binary for x86-64 Linux, see the Releases page for others
curl -fsSL https://github.com/ElaraLang/elara/releases/download/dev-build/elara-x86_64-linux -o elara
chmod +x elaraor build from source with Nix: nix develop, then just run hello.elr builds and runs it in one command.
You'll also need a JDK if using the JVM backend.
For detailed build instructions see the documentation
2. Write a program
-- hello.elr
import Prelude
import Elara.Prim
def main : IO ()
let main = println "Hello, World!"3. Run it
./elara run hello.elr # run in the interpreter
./elara run hello.elr --target jvm # compile to JVM bytecode and run on the JVMMore runnable programs are in examples/, demonstrating features like pattern matching, higher-order functions, polymorphism, a JSON parser, and more.
Elara is still in early stages. So far, we have a full working pipeline (parse → rename → typecheck → Core → JVM / Interpreter), a small standard library, and a golden-tested set of examples and error messages. See the changelog for what's changed recently.
Contributions are always very welcome! Start with CONTRIBUTING.md and the development setup, then look for issues labelled good first issue. If you have questions, ask on Discord.
Elara owes its existence to numerous open-source projects, particularly to Grace for its use as a reference implementation for type checking.
Elara is released under the MIT License.