unison README

The project's README from github.com/unisonweb/unison. As one markdown file: README.md.

The Unison language

CI Status Pre-Release Status

Alt

Overview

Unison 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, 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:

Unison can be used like any other general-purpose language, or you can use it in conjunction with Unison Cloud for building distributed systems.

Here is some sample code:

-- A comment!
-- Function signatures appear before the definition
factorial : Nat -> Nat
factorial n = product (range 1 (n + 1))

-- Signatures can be left off; they will be inferred
List.map f as =
  go acc rem = match rem with
    [] -> acc
    a +: as -> go (acc :+ f a) as
  go [] as

> List.map (x -> x * 10) (range 0 10)
= [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]

> List.map factorial [1,2,3,4]
= [1, 2, 6, 24]

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.

Other resources:

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. (Hint: brew update && brew install stack)

$ git clone https://github.com/unisonweb/unison.git
$ cd unison
$ stack --version # we'll want to know this version if you run into trouble
$ stack build --fast --test && stack exec unison

To run the Unison Local UI while building from source, you can use the /dev-ui-install.sh script. It will download the latest release of unison-local-ui and put it in the expected location for the unison executable created by stack build. When you start unison, you'll see a url where Unison Local UI is running.

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

Language Server Protocol (LSP)

View Language Server setup instructions here.

AI Agent Server (MCP)

View AI Agent Server setup instructions here.

Codebase Server

When ucm starts it starts a Codebase web server that is used by the Unison Local UI. It selects a random port and a unique token that must be used when starting the UI to correctly connect to the server.

The port, host and token can all be configured by providing environment variables when starting ucm: UCM_PORT, UCM_HOST, and UCM_TOKEN.

Configuration

See the documentation for configuration here

unison (unisonweb/unison)

Searching Database…

6.8K ·GitHub
这是什么?Unison 是一种静态类型的函数式编程语言,具有类型推断、副作用系统和先进的工具链,其核心思想是内容寻址代码:函数由其实现的哈希值标识,而不是靠名字。
Unison 是一门完整的编程语言,还是添加到现有项目中的东西?它是一门完整的通用编程语言,拥有自己的编译器、运行时(ucm)和代码库格式,而不是一个库。代码以 AST 形式存储在数据库中,并通过内容哈希而不是名字或文件路径来引用。
构建它之前需要先安装 Stack 吗?需要,Stack 是 Unison 依赖的构建工具;在 macOS 上可以用 Homebrew 安装。
我也要像其他语言那样忍受漫长的编译时间吗?不用——Unison 拥有完美的增量编译,共享的编译缓存直接内置在代码库格式中,因此你几乎从不需要等代码编译,重命名定义也是瞬时完成且不会造成破坏。
Unison Cloud 是用来做什么的?它让你可以把像普通程序一样编写的 Unison 代码直接作为分布式系统运行,无需切换语言或工具。
为什么内容寻址的代码能避免合并冲突?因为定义由其实现的哈希标识,而不是文本或格式,Unison 的版本控制具有语义感知能力,会忽略导入顺序或空白差异等通常引发虚假冲突的因素。
Codebase 网页服务器是如何工作的?ucm 启动时会在随机端口上启动一个带有唯一 token 的网页服务器,Unison Local UI 使用它来连接;端口、主机和 token 可以分别通过 UCMPORT、UCMHOST 和 UCMTOKEN 环境变量覆盖。
当我修改代码时,测试会怎样?Unison 会完美地缓存测试结果,只有当依赖真正发生变化时才重新运行确定性的测试,从而省去多余的测试运行。
What are similar projects?morloc, rust-analyzer, epiq, elixir, otp, Benzi, nvim-lspconfig, Nim
Creator
unisonweb
Size
148 MB
Stars
6.8K
Age
11y
Commits · 90 Days