Skip to main content
Early alpha · see what's newVapour

A typed language that transpiles to R

Vapour makes R developers more confident in their programs: types, static checks and a cleaner syntax, compiled to plain R you can ship anywhere.

curl -fsSL https://vapour.run/install.sh | sh

Requires R. Prebuilt binaries for Linux, macOS, and Windows are also available, see installation.

user.vp
1type user: object {
2 age: int,
3 name: char
4}
5
6func create(name: char): user {
7 return user(name = name)
8}
9
10let john: user = create("John")
11
12# error: left expects int, right returns char
13john$age = "thirty-six"
Why Vapour?

R, with guard rails

Separating the code you write from the code that runs means Vapour can check it first.

Types

Types aren't just for compilers, they help you too. Stop getting caught out by unexpected NULLs.

let x: char = "hello, world"
# error: wrong type
x = NULL
Learn more →

Robustness

Catch flagrant problems as you type, before they reach your users, or even your unit tests.

func foo(x: int): int {
return x + 1
}
# warning: y not found
print(y)
Learn more →

Syntax

Keep the whole R ecosystem, but let the syntax evolve faster than the language underneath, like ECMAScript for JavaScript.

let x: int = 1
# increment in place
x += 41
Learn more →
Transpilation

Write Vapour, ship R

Every Vapour file compiles down to plain R. No runtime, no dependency: your users only ever see R.

user.vp
1type user: object {
2 age: int,
3 name: char
4}
5
6func create(name: char): user {
7 return user(name = name)
8}
9
10@generic
11func (p: any) set_age(age: int, ...: any): any
12
13@default
14func (p: any) set_age(age: int, ...: any): null {
15 stop("not implemented")
16}
17
18func (p: user) set_age(age: int, ...: any): user {
19 p$age = age
20 return p
21}
22
23let john: user = create("John") |>
24 set_age(36)
user.R
1create <- function(name) {
2 return(structure(
3 list(
4 name = name
5 ),
6 class = c("user", "list")
7 ))
8}
9
10set_age <- function(p, age, ...) {
11 UseMethod("set_age")
12}
13
14set_age.default <- function(p, age, ...) {
15 stop("not implemented")
16}
17
18set_age.user <- function(p, age, ...) {
19 p$age <- age
20 return(p)
21}
22
23john <- create("John") |>
24 set_age(36)
Get going

Up and running in minutes

  1. 1

    Install

    Prebuilt binaries for Linux, macOS and Windows, or install with Go.

    Install Vapour →
  2. 2

    Set up your editor

    Syntax highlighting and LSP diagnostics for VS Code, Positron, Vim and Neovim.

    Editor setup →
  3. 3

    Write your first program

    Learn the syntax, the type system, and how to build packages with Vapour.

    Get started →
Roadmap

What's next

Vapour is in early alpha. Here's where it's heading.

  1. 01

    R type inference

    Infer types from base R so type checking can be executed.

  2. 02

    Autocompletion LSP

    The LSP currently only provides diagnostics, it should also provide autocompletion (and maybe more).

  3. 03

    Vapour type inference

    Infer types in Vapour to reduce verbosity a tad.

  4. 04

    Package development tools

    Vapour could provide functionality similar to that of devtools.

  5. 05

    Improve transpiler

    The transpiler currently outputs valid but extremely ugly R code.

  6. 06

    Formatter

    Include a formatter.

  7. 07

    Extensions

    Allow extending Vapour, e.g.: with @decorators.