Agenda¶

Introduction to "unison the programming language"
Introduction of the domain problem
Introduction to "unison the not programming language"
Introduction to "unison the programming language"

The basis¶
We will work on a single file names
scratch.uOn the side of
scratch.uwe will startucm(Unison Codebase Manager) in a terminal.Each time we save
scratch.u,ucmwill take the change and run & print each statement after a>
Hello World¶
-- scratch.u
msg = "Hello World"
> msg
msgis a constant- the usage of
>is kind of a print - the
ucmkind of a repl
First function¶
-- scratch.u
Add1 x = x + 1
> Add1 32
- Unison is an "haskell like" language
- functions are defined in the most direct way
- Calling a function does not requires parenthisis
Second function¶
-- scratch.u
Add1 x = x + 1
Times2 x = x * 2
Add1Times2 x = Times2 (Add1 x)
> Add1Times2 5
- Still no parenthisis to define the arguments
- Parenthisis are only use to show priority (
Times2 (Add1 x)is not the same asTimes2 Add1 x)
Turing completeness¶
-- scratch.u
fibb x = if x < 1 then 1 else ((fibb (x - 1)) + (fibb (x - 2)))
> fibb 6
- There is an
if-then-elseprimitive... - Loops are made with recursion
Types¶
-- scratch.u
structural type LinkList t = Nil | Cons t (LinkList t)
ll = Cons 2 (Cons 1 (Cons 0 Nil))
> ll
- Unison is a very strongly typed language
- The above code is the "classical" example of a linked list 3 Indeed, it uses generics types
For the geeks of the geeks¶
Unison is a purely functional strongly typed programming language
Unison is greedy (aka, not lazy)
Unison uses "algebraic effects" to handle side effects
Unison runtime is Chez Scheme (or soon will be)
For the rest of the presentation...¶
-- scratch.u
Add1 x = x + 1
Times2 x = x * 2
Add1Times2 x = Times2 (Add1 x)
> Add1Times2 5
- We need to focus on the essential
- We are going to use dull mathematical functions
Introduction of the domain problem¶

Q&A question...¶
- Hey kids, when you program, what do you do with important data?
You put that data in a database!
- Hey kids, when you program, what is your most important data?
Your source code
- Hey kids, why your source code is not in a database?
Because we still code in a "pre-database era" fashion
But Git is a code database¶
Not really, Git has not idea of your source code
Git tracks files, nothing else
The source code is still in files
Saying your source code is in a database because it is versionned in Git is like saying your json blobs are in a database because they are stored as
VARCHARin mysql.Git a absolutly amazing (best software ever written?)
unison is a programming language..
That puts your source code in a database
The rest we do not care
unison the not programming language

unison the Genious Idea

Content-addressable storage¶
is a way to store information so it can be retrieved based on its content, not its name or location.
-- wikipedia
Content-addressable storage¶
We have a table that store "things". The primary key of the table is the "hash" of the "things".
| Id | Text |
|---|---|
ff5b5776505060eec58fff6f462a8fe9 |
"didier" |
da8dee114a147c07ef0527ac3a6e1d58 |
"maxime" |
3258460251858f7db401b0b70af6b925 |
"ivo" |
201b00ab3b5fba10c15a4e5b8695c478 |
"mohit" |
4794571aa96694574177576ba90ef3bb |
"faiz" |
Important¶
- it is impossible to find two values with the same hash
- the only way to know the id, is to know the value
- Make things "immutable"
Content-addressable storage is used in multiple "good" software¶
git (git commit are content addressable)
bitcoins
public key infrastructure, public keys are associated with their hash
bit torrent
nix
How does unison uses Content-addressable storage ?
Unison only stores the "abstract syntax tree" (not the text of the source code)
Unison hashes the "abstract syntax tree" as primary key
Functions are named by their hashes
Visible function names are only "labels"
How does unison uses Content-addressable storage ?
| Source Table | |
|---|---|
| Hash | Source |
t7g50rohbm |
x -> x + 1 |
qkrj8bbq2m |
x -> t7g50rohbm (t7g50rohbm X) |
| Labels | |
|---|---|
| Label | Hash |
t7g50rohbm |
Add1 |
qkrj8bbq2m |
Add2 |
How does unison uses Content-addressable storage ?
- We can consider the "hash" of a function as its cannonical name
For Java programmers, it could look like something such as¶
List.of(
"function",
List.of(
"arguments", List.of("argument_1")),
List.of("body", List.of("#65ba56", "argument_1", "1"))).hashCode()
Terminology | Merkle tree¶
Merkle tree is a tree in which every "leaf" node is labelled with the cryptographic hash of a data block
-- wikipedia

Advantages of this approach¶
- Functions are immutable; it is impossible to rename a function
- It is impossible to "break" a function; all functions are built-in the functions
- Compiler needs to compile each function exactly once
- Tooling can be amazing!
unison the merkel tree

Inside the database?¶
We can look inside unison's database by connecting to the sqlite3 database located at $HOME/.unison/v2/unison.sqlite3
Conclusion¶

About unison¶
Unison is at the very top of "cool new things about programming language"
Unfortunatly, it is hard to start small while using unison
It would be cool if other programming environment could use a similar approach (java?, javascript?)
About Content-addressable storage¶
We should always use content-addressable storage when possible
content-addressable storage is not harder to use and simplify implementation of ass kicking features
Other cool technology we could look at¶
duckdb, the sqlite for data science
FoundationDB, the database with the least errors
Datomic, the database with the coolest feature
Nix, the software that maximaze the value of $love^2 + hate^2$
Typst, finally a something that takes over $\LaTex2e$
Clojure... made simple easy


