A New Functional Programming Language

Loreal is building a hardware-aware functional language.

Loreal is a programming language project by Pasindu Pramodya, a system engineer focused on deterministic memory management, compile-time reference counting, and a dedicated loop construct that exposes reuse opportunities instead of hiding them inside recursion.

Read the research paper

Resource management via hardware-aware loop specialization

The paper argues that a dedicated loop construct gives the compiler stronger lifetime information than general recursion, enabling compile-time reference counting, deterministic drops, and Functional But In-Place mutation when uniqueness is preserved.

Open paper

Explain the language

What Loreal is trying to prove

Loreal is a functional language design that tries to bridge semantic clarity and hardware efficiency without using tracing GC or pushing ownership annotations onto the programmer. The compiler pipeline is designed around exact last-use analysis, explicit drops, and reuse opportunities that emerge from loop boundaries.

Why this functional language matters

  • Perceus-style reference counting replaces non-deterministic collection with precise compile-time drops.
  • next acts as a hard kill-point, making current-iteration bindings dead before the back edge.
  • Reuse analysis can turn drop-to-alloc pairs into conditional in-place mutation for uniquely owned values.

Interactive playground

Examples now, execution soon

The playground section shows the syntax direction and loop-oriented model. The run path is intentionally disabled until the compiler and browser integration exist.

Loop-specialized filter

                      def filter_loop(list, p) do
  loop (list, []) (curr, acc) ->
    match curr do
      Nil -> break(reverse(acc))
      Cons(x, xs) ->
        if p(x) do
          next(xs, Cons(x, acc))
        else
          next(xs, acc)
        end
    end
  end
end
                    

Minimal loop shape

                      loop (init_val) (var) -> {
  if (condition) {
    next(updated_val)
  } else {
    break(result)
  }
}
                    

Key features

Minimal surface, compiler-heavy design

Explicit loop kill-points

Loreal introduces a dedicated loop construct where `next` becomes a structural boundary for liveness and reuse analysis.

Perceus-style RC pipeline

The design follows compile-time reference counting with precise drop insertion instead of runtime tracing GC pauses.

FBIP mutation path

Pure-looking transformations can reuse memory in place when uniqueness holds, targeting O(1) overhead per iteration.

Compiler-first architecture

ANF, MIR CFG construction, liveness passes, and LLVM lowering are central to the language design from the start.

Development roadmap

From language paper to usable toolchain

1

Stabilize parser, AST, and core syntax for the `loop` construct.

2

Finish MIR CFG generation and liveness analysis around `next` boundaries.

3

Implement RC insertion and greedy reuse detection for drop-to-alloc patterns.

4

Lower reuse tokens into LLVM conditional reuse blocks.

5

Ship the first public docs and a runnable browser playground.