A friendly programming language from the future
Go to file
2018-07-18 11:16:10 -04:00
docs partial implmentation for self-tailcalls in general letrec; eliminate tailcalls for builtins 2017-09-10 20:58:30 -04:00
editor-support/atom/language-unison support toggling comments 2018-06-16 16:31:56 -04:00
parser-typechecker Term.builtin/derived/ref smart constructors now take annotations. 2018-07-18 11:16:10 -04:00
runtime-jvm all better 2018-07-08 23:48:45 -04:00
unison-src Added some notes and example errors, generalized Term a bit to allow type annotations to contain locations. 2018-07-10 17:36:10 -04:00
yaks clean up easytest plurals 2018-06-27 18:02:48 -04:00
.gitignore split bootstrap into non-overlapping source tree 2018-06-06 14:27:41 -04:00
.travis.yml bump sbt and have travis update paulp/sbt-extras 2018-06-29 16:38:58 -04:00
config added dev notes document, updated logging defaults 2016-10-06 13:11:38 -04:00
development.markdown bump sbt version to 1.1.2, restoring incremental compilation 2018-06-25 19:13:05 -04:00
LICENSE Rename node/LICENSE to LICENSE 2015-05-06 22:09:25 -04:00
README.md started deleting and cleanup, not compiling yet 2018-05-16 18:20:27 -04:00
stack.yaml Merge pull request #205 from unisonweb/master 2018-06-25 18:39:29 -05:00

The Unison platform

Build Status

Unison is a new programming language, currently under active development. It's a modern, statically-typed purely functional language, similar to Haskell, but with a unique ability to describe entire distributed systems with a single program. Here's a simple example:

-- comments start with `--`
-- alice : Node, bob : Node

do Remote
  x = factorial 6
  Remote.transfer alice
  y = foo x -- happens on `alice` node
  Remote.transfer bob
  pure (bar x y) -- happens on `bob` node

The do Remote introduces a "remote block", where computation may proceed on multiple Unison nodes:

  • The Remote.transfer alice transfers control of the computation to the alice node.
  • The foo x call happens on the alice node.
  • At each transfer, any required definitions (such as foo and x) will be dynamically deployed to the alice node and cached for future use.
  • The Remote.transfer bob transfers control of the rest of the computation to the bob node.
  • The bar x y computation happens on the bob node. Again, any needed definitions (bar, x, and y) will be dynamically deployed to the bob node.

This dynamic transfer / deployment of arbitrary computations is possible because definitions in Unison are identified by a cryptographic hash of their content, including the hashes of all dependencies (the hash is also "nameless" as it isn't affected by naming of variables). To transfer a computation, we send it to the recipient, and the recipient checks to see if the computation references any unknown hashes. Any unknown hashes are synced to the recipient before the transfer completes and the computation proceeds.

If you'd like to learn more about the project, the talk How to write a search engine in 15 lines of code has more of an introduction to the language.

Since Unison isn't terribly useful in its current form, the rest of this README will focus on stuff that will be of interest for potential contributors, namely, how to build the code, and a brief tour of the (fairly small but action-packed) codebase. If you're just interested in the project and want to follow along with the progress, unisonweb.org is the place to go, or you can also say hello or lurk in the chat room.

Still here? All right then! Let's get to it.

A brief code tour

First, a bit of orientation. Here's the directory structure:

  • yaks/ has subprojects for various utilties not specific to Unison (the result of "yak-shaving"). Once mature, each of these might be moved to independent projects and published on Hackage.
  • parser-typechecker/ has the Unison syntax tree, parser, and typechecker. Depends on yaks/
  • runtime-jvm/ has the JVM based runtime

Building using Stack

If these instructions don't work for you or are incomplete, please file an issue.

The build uses Stack. If you don't already have it installed, follow the install instructions for your platform.

You'll also need xz on your path and also the libghc-curl-dev library someplace that stack looks for it.

Once that's all done and the stack executable is on your path, do:

$ git clone https://github.com/unisonweb/unison.git
$ cd unison
$ stack --version # make sure this returns 1.3 or later
$ stack setup
$ stack build unison-node

See development.markdown for a list of build commands you'll likely use during development.

A brief tour of the Haskell code

In the shared/ project:

  • Unison.Term and Unison.Type have the syntax trees for terms and types. In both Term and Type, the same pattern is used. Each defines a 'base functor' type, F a, which is nonrecursive, and the actual thing we use is an abstract binding tree over this base functor, an ABT F. ABT (for 'abstract binding tree') is defined in Unison.ABT. If you aren't familiar with abstract binding trees, here is a nice blog post explaining one formulation of the idea, which inspired the Unison.ABT module. A lot of operations on terms and types just delegate to generic ABT operations.
  • Unison.Parsers has the main entry point for the parser.
  • Unison.Typechecker.Context is the implementation of the typechecker, and Unison.Typechecker has the "public interface to the typechecker" and some convenience functions. There isn't a lot of code here (about 700 LOC presently), since the typechecking algorithm is pretty simple. Unlike a unification-based typechecker, where the typechecking state is an unordered bag of unification constraints and higher-rank polymorphism is usually bolted on awkwardly later, Dunfield and Krishnaswami's algorithm keeps the typechecking state as a nicely tidy ordered context, represented as a regular list manipulated in a stack-like fashion, and the algorithm handles higher-rank polymorphism very cleanly. They've also extended this work to include features like GADTs, though this new algorithm hasn't been incorporated into Unison yet.