This short guide will have you downloading and installing Unison and running your first program. There isn't much exposition here and the focus is on getting you up and running as quickly as possible.
More in-depth guides follow this one.
Step 1: Install Unison
If you haven't already, please join the
troubleshootingchannels on Slack.
We are really hoping that if you are trying out Unison you'll come talk to us, ask questions, and report bugs! We want you to have a welcoming and positive experience when getting started! 😊
The current alpha release is for Mac OS X, 64-bit Linux, and Windows users!
Firstinstall homebrewif you haven’t already.
Then from the command line enter these commands (or better yet, paste them into your console):
brew tap unisonweb/unison brew install unison-language
This will install the Unison codebase manager executable ucm. If you’re upgrading from a previous version, just do
brew upgrade unison-language.
Note: if you get prompted for a GitHub username and password at this point, make sure you spelled unisonweb/unison correctly.
mkdir unisonlanguage curl -L https://github.com/unisonweb/unison/releases/download/release%2FM4/ucm-linux.tar.gz --output unisonlanguage/ucm.tar.gz tar -xzf unisonlanguage/ucm.tar.gz -C unisonlanguage ./unisonlanguage/ucm
mkdir unisonlanguage curl -L https://github.com/unisonweb/unison/releases/download/release%2FM4/ucm-macos.tar.gz --output unisonlanguage/ucm.tar.gz tar -xzf unisonlanguage/ucm.tar.gz -C unisonlanguage ./unisonlanguage/ucm
- Set your default terminal application to “Windows Terminal” for best results. Search for “Terminal” in Settings, or followthis how-to.
- If you’re not sure you already have it, install Git:
- via winget:
winget install --id Git.Git -e --source winget
- If you are on Windows 10 and don’t have winget, you can install itfrom the Microsoft Store,and then run the command above.
- via winget:
- DownloadUCMand extract it to a location of your choosing.
Step 2: Create your Unison codebase
ucmto initialize a Unison codebase in
$HOME/.unison.This is where Unison will store function definitions, types, namespaces, and so on. By default, the Unison Codebase Manger (abbreviated the"UCM")will begin downloading the standard library, called
base,which you'll use to write Unison code. It may take a moment!
Step 3: Create the quickstart namespace
A Unison codebase is organized by "namespaces". The root of your codebase is represented with
.and it's common to fill this top-level with namespaces representing your various projects. You can create namespaces by
cdinginto them. Use the UCM to create the
quickstartnamespace for the code in this guide.
.> cd quickstart
Next, we'll make sure the code in our quickstart project has the dependencies it needs. A project's dependencies are located in a namespace called
lib.The code for our quickstart namespace will be simple, so we only need the
baselibrary in scope. Create a copy of the
baselibrary that was downloaded to
.quickstart> fork .base lib.base
Run your first program
Back in your terminal, make a directory to work in, and create a new file there called
myTerm = List.map (x -> x * 10) [1,2,3,4,5,6] > myTerm
The first line is defining a Unison term called
myTerm.This one multiplies every element in a list by
The second, beginning with
>,is awatch expression.
ucmmonitors all the unison source files in the current directory for changes and evaluates any watch expressions:
.quickstart> I found and typechecked these definitions in ~/myUnisonCode/scratch.u. If you do an `add` or `update`, here's how your codebase would change: ⍟ These new definitions are ok to `add`: myTerm : [Nat] Now evaluating any watch expressions (lines starting with `>`)... Ctrl+C cancels. 2 | > myTerm ⧩ [10, 20, 30, 40, 50, 60]
Congratulations, you ran your first Unison program!
We want to hear from you!
If you have any trouble with the process, or have ideas about how to improve this document,come talk to us in the
"UCM" stands for "Unison Codebase Manager." It's the all-in-one tool you'll use to explore and modify a Unison codebase and run Unison programs.
In a file with the
.uextension, any line beginning with
>is a watch expression. A watch expression tells the UCM to execute the Unison expression to the right of the symbol and render the result to the console.
Watch expressions cannot execute code whose abilities are not enclosed by a handler.