Skip to content
Branch: master
Go to file
Code

Latest commit

etaoins committed b9ef897 Jul 11, 2020
Local vars can only refer to vars within the same module. Exports, on
the other hand, are a combination of {module, local}.

This re-arrangement means we don't need to assign module IDs until after
type inference. This means our REPL can lower and infer modules
anonymously without registering the module in our compiler context. It
also removes some complexity in type inference and makes some data
structures smaller.

One downside is now `eval_hir` needs to know which module an expression
is in to look up the correct global variable.

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Arret

License Build status

Overview

Arret is pure functional, strongly typed language with Lisp-like syntax. It aims to combine the expressiveness of Lisp with guarantees provided by functional programming. The language design documentation has a high-level summary of the language's design choices.

The Arret compiler and parts of its standard library are written in Rust. The mechanism for calling Rust code from Arret is referred to as the Rust Function Interface or RFI. Documentation for the arret_runtime crate describes the core concepts of the RFI.

Installation

Docker REPL Image

There is a public Docker image at etaoins/arret:repl that runs the Arret REPL. Whenever cargo run repl appears in the documentation this command can be used instead:

> docker run -ti etaoins/arret:repl

It can also evaluate single file programs:

> cat hello-world.arret
(import [stdlib base])
(defn main! ()
  (println! "Hello, world!"))

> docker run -i etaoins/arret:repl eval - < hello-world.arret
Hello, world!

Build Requirements

  1. A Unix-like host running on ARM64, x86-64 or x86-32. These are the platforms supporting lazy compilation with LLVM's ORC JIT.
  2. LLVM 9 or 10
  3. Rust

Building with rustup and Cargo

> curl https://sh.rustup.rs -sSf | sh
> cd ~/path/to/repo/root
> cargo run repl

Usage

REPL

The REPL provides an interactive environment for exploring Arret. It's supported as a first class environment in Arret; the REPL is just as powerful as the compiler.

> cargo run repl
arret> (length '(1 2 3 4 5))
=> 5
arret> (defn identity #{T} ([x T]) -> T x)
defined
arret> /type identity
=> (All #{T} T -> T)
arret> (identity "Hello, world!")
=> "Hello, world!"
arret> /type (identity [one two three])
=> (Vector 'one 'two 'three)
arret> /quit

Compiler

Compiled programs have a (main!) function as their entry point:

(import [stdlib base])

(defn main! ()
  (println! "Hello, world!"))

These can be compiled to a static binary by running Arret with the path name:

> cargo run compile hello-world.arret
> ./hello-world
"Hello, world!"

Editors

A basic Visual Studio Code extension is bundled in editors/code. This uses the Language Server from the lsp-server crate.

# Install `arret-lsp-server`
cargo install --path lsp-server

# Install the Visual Studio code extension
cd editors/code
yarn
yarn vscode:install

Examples

The Arret language is still rapidly evolving. This makes it impractical to provide accurate documentation of the language and standard library. However, the test programs in run-pass give examples of working Arret code.

About

Pure functional Lisp implemented in Rust

Resources

License

Releases

No releases published

Languages

You can’t perform that action at this time.