A compiler for the Elm language written in ANSI C99.
The compiler is intended to be used either as a standalone compiler and virtual machine for executing Elm code, or embedded as a static or dynamic library in a larger program.
The compiler is currently targeting Elm 0.19, but is not yet feature complete.
The following core language features have been implemented so far:
- Single line comments
- Multiline comments
- Boolean literals
- Int and Float literals
- String and Char literals
- Multiline string literals
- Expressions
- Indentation sensitive parsing
- Infix operators
- Lists
- Tuples
- Records
- If-then-else conditionals
- Case-of conditionals
- Pattern matching
- Function declarations
- Anonymous functions
- Structural typing (function arguments)
- Function application
- Higher-order functions
- Arithmethic operators with type inference
- Let expressions
- Modules
- Qualified imports
- Type annotations
- Type aliases
- Custom types
- Ports
- Effect managers
The kernel contains native implementations of some core functions used by
packages in the elm
namespace (e.g. elm/core
and friends). These packages
typically contain native code written in Javascript. The elmc compiler instead
provides versions of these functions written in C or Assembler.
When compiling Elm code the compiler will generate an Intermediate Representation (IR) of the source code. This IR is then analysed and optimized before being passed to the code generator step. The following optimizations are currently implemented:
After the optimization step the IR is transformed to executable machine code by the JIT compiler.