You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+29-10
Original file line number
Diff line number
Diff line change
@@ -15,20 +15,39 @@ The Unison language
15
15
Overview
16
16
--------
17
17
18
-
[Unison](https://unisonweb.org) is a modern, statically-typed purely functional language with the ability to describe entire distributed systems using a single program. Here's an example of a distributed map-reduce implementation:
18
+
[Unison](https://unison-lang.org) is a statically-typed functional language with type inference, an effect system, and advanced tooling. It is based around [a big idea of content-addressed code](https://www.unison-lang.org/learn/the-big-idea/), in which function are identified by a hash of their implementation rather than by name, and code is stored as its AST in a database. This provides a number of benefits:
19
+
20
+
* No builds. Unison has perfect incremental compilation, with a shared compilation cache that is part of the codebase format. Despite the strong static typing, you are almost never waiting for code to compile.
21
+
* Instant, non-breaking renaming of definitions.
22
+
* Perfect caching of tests, only rerunning determinstic tests if dependencies changed.
23
+
* Semantically-aware version control, avoiding spurious merge conflicts from things like order of imports, whitespace or code formatting differences, and so on.
24
+
25
+
Unison can be used like any other general-purpose language, or you can use it in conjunction with [Unison Cloud](https://unison.cloud) for building distributed systems.
26
+
27
+
Here is some sample code:
28
+
19
29
20
30
```Haskell
21
-
-- comments start with `--`
22
-
mapReduce loc fn ifEmpty reduce data= match split data with
23
-
Empty-> ifEmpty
24
-
One a -> fn a
25
-
Two left right ->
26
-
fl = forkAt loc '(mapReduce loc fn ifEmpty reduce !left)
27
-
fr = forkAt loc '(mapReduce loc fn ifEmpty reduce !right)
28
-
reduce (await fl) (await fr)
31
+
-- A comment!
32
+
-- Function signatures appear before the definition
33
+
factorial :Nat->Nat
34
+
factorial n =product (range 0 (n +1))
35
+
36
+
-- Signatures can left off; they will be inferred
37
+
List.map f as =
38
+
go acc rem= match rem with
39
+
[]-> acc
40
+
a +: as -> go (acc :+ f a) as
41
+
go [] as
42
+
43
+
>List.map (x -> x *10) (range 010)
44
+
= [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]
45
+
46
+
>List.map factorial [1,2,3,4]
47
+
= [1, 2, 6, 24]
29
48
```
30
49
31
-
This function can be either simulated locally (possibly with faults injected for testing purposes), or run atop a distributed pool of compute. See [this article](https://www.unison-lang.org/articles/distributed-datasets/) for more in-depth coverage of how to build distributed computing libraries like this.
50
+
Functions arguments are separated by spaces instead of parens and commas. Loops are written using recursion (above the helper function `go` defines a loop). The language supports pattern matching via `match <expr> with <cases>`, which works for lists and also user-defined data types.
0 commit comments