Amortia is a pure functional programming language designed to compile to the BEAM VM. It combines Haskell and Lisp syntax with the battle-tested concurrency and fault-tolerance of Erlang's virtual machine.
Current Status: Parser & AST Visualizer The compiler pipeline is under active development. Right now, you can parse Amortia code, generate AST in JSON format, and explore it with an interactive hot-reloading visualizer.
|
Amortia |
→ |
AST |
→ |
Erlang |
→ 🚧 |
Core |
→ |
BEAM |
Note
Amortia requires GHC (Glasgow Haskell Compiler) >= 9.0 and Make
git clone https://github.com/yourusername/amortia.git
cd amortia
make release
sudo make install # optionalCreate a file example.amor:
defn last :: [a] -> a {
"Returns the last element of a list.
Raises badarg error if the list is empty."
[] -> error badarg
[x] -> x
[_|xs] -> last xs
}# Compile to erlang
amortia example.amor
# Watch mode with hot reloading
amortia watch example.amor
# Visualize once
amortia visualize example.amor
# Export AST to JSON
amortia json example.amor output.jsondefn length :: [a] -> Int {
"Calculate the length of a list"
[] -> 0
[_|xs] -> 1 + length xs
}| Pattern | Description |
|---|---|
x |
Variable binding |
_ |
Wildcard |
[] |
Empty list |
[x|xs] |
Head and tail |
42 |
Literal match |
Hindley-Milner style with parametric polymorphism:
defn map :: (a -> b) -> [a] -> [b] {
"Apply a function to each element of a list"
f [] -> []
f [x|xs] -> [f x | map f xs]
}Tip
Use watch mode for the best development experience with instant feedback!
The interactive visualizer provides:
- Side-by-side source code and AST tree view
- Syntax highlighting
- Hot reloading - changes reflect instantly
- Collapsible tree nodes
- JSON export toggle
amortia --watch mycode.amormake # Development build
make release # Optimized build
make clean # Clean artifactsamortia/
├── Parser.hs # Megaparsec-based parser
├── Codegen.hs # Erlang code generation
├── Main.hs # CLI tool & visualizer
├── visualizer.html # Interactive AST viewer
└── Makefile # Build configuration
Phase 1: Parser & Tooling ✓
- ✅ Complete parser
- ✅ AST generation and JSON export
- ✅ Interactive visualizer with hot-reloading
Phase 2: Compiler (In Progress)
- ⏳ Type checker and inference
- ⏳ Erlang code generation
- ⏳ Standard library
Phase 3: BEAM Integration (Planned)
- 📋 Core Erlang emission
- 📋 Direct BEAM bytecode generation
- 📋 Interop with Erlang/Elixir
MIT License - see LICENSE file for details