Skip to main content
Elara is currently a work in progress and is not yet ready for production use. Join the Discord server for updates and discussions.

What is Elara?

Elara is a purely functional programming language that targets the JVM. It combines the elegance of Haskell’s syntax with F#-inspired features, bringing powerful functional programming concepts to the Java ecosystem.

Key features

  • Pure functional programming - All functions are pure by default, with effects tracked in the type system via an IO monad
  • Hindley-Milner type system - Complete type inference means you rarely need to write type annotations
  • JVM target - Compiles to Java bytecode for seamless interoperability with the Java ecosystem
  • Pattern matching - Powerful pattern matching on algebraic data types
  • Higher-order functions - First-class functions with lambda expressions
  • Algebraic data types - Define custom types with sum and product types

Code example

Here’s a taste of Elara’s syntax:
import Prelude
import Elara.Prim
import String

type Shape =
    Circle Int
    | Rectangle Int Int
    | Square Int

def area : Shape -> Int
let area shape =
    match shape with
        Circle r -> 3 * r * r
        Rectangle w h -> w * h
        Square s -> s * s

let main =
    let c = Circle 5
    println ("Area: " ++ toString (area c))

Get started

Installation

Install Elara and set up your development environment

Quickstart

Write and run your first Elara program in minutes

Language guide

Learn Elara’s syntax, type system, and core concepts

Examples

Explore real-world code examples and patterns

How the compiler works

The Elara compiler transforms your code through multiple passes:
1

Lexing

Source code is converted into tokens, with layout rules transformed into braces and semicolons
2

Parsing

Tokens are parsed into a Frontend AST that mirrors the language syntax
3

Desugaring

Syntactic sugar is removed, converting multi-argument lambdas into nested single-argument lambdas
4

Renaming

Names are resolved to fully qualified names and local variables receive unique identifiers
5

Shunting

Operator precedence and associativity are applied
6

Type checking

Types are inferred and checked using the Hindley-Milner algorithm
7

Core transformation

The typed AST is converted to a Core language (similar to GHC’s Core)
8

Optimization

Multiple optimization passes are performed on the Core representation
9

JVM emission

The optimized Core is compiled to JVM bytecode and written to class files

Community

Elara is an open-source project under active development. We welcome contributions and feedback!
  • Join our Discord server for discussions and support
  • Check out the GitHub repository to contribute
  • Follow development updates and design decisions in the community

License

Elara is released under the MIT License.

Build docs developers (and LLMs) love