
Packages
Shiny applications
Data pipelines
APIs
curl -fsSL https://we-data-ch.github.io/typr.github.io/install/install.sh | shOne command, no admin rights, checksum verified. Other ways to install
TypR compiles to ordinary R and runs on its ecosystem as-is — the same packages, the same Shiny apps, the same tools you already use.


main.ty
typr build
main.RZero lock-in. The generated main.R is plain, idiomatic R — no TypR runtime, no added dependency. Stop using TypR any time, and the code you shipped keeps running exactly as it did.
R projects start as scripts. The ones that turn into packages, Shiny applications or data pipelines end up maintained for years — and by then, the shape of the data is what everyone needs to know. Define it once, and use it throughout your system.
type Order <- list {
id: int,
total: num
};
type Customer <- list {
id: int,
name: char,
orders: [Order]
};
typed functions
typed reactives
typed responsesMistakes that R reports late, or never. Each one below is rejected by the compiler before the code runs.
set_alpha <- function(alpha) {
stopifnot(
is.numeric(alpha),
length(alpha) == 1,
alpha >= 0,
alpha <= 1
)
alpha
}
set_alpha(1.5)
# Four lines of checks, and they only
# fire when this call finally runs.let set_alpha <- fn(
alpha: num & (>= 0.0) & (<= 1.0)
): num {
alpha
};
set_alpha(1.5);The range lives in the signature. A literal that breaks it is rejected at compile time; a value only known at run time gets one check, at the call.
× Type error: No signature of function 'set_alpha' matches this call.
╭─[contracts.ty:7:2]
6 │
7 │ set_alpha(1.5);
· ────┬────
· ╰── Called with 1 argument(s): (1.5)
╰────
help: 'set_alpha' exists but none of its signature(s) accepts these
arguments:
((<= 1) & (>= 0) & num) -> numHere is that discipline applied to the R code you already write.
summarise_sales <- function(sales, region) {
# What is `sales`? A list? A data.frame?
# What comes back? A number? A vector?
# Only the body knows, and only at run time.
sum(sales$amount[sales$region == region])
}type Sale <- list { region: char, amount: num };
let summarise_sales <- fn(
sales: [Sale],
region: char
): num {
(sales) |> filter(\(s) s$region == region)
|> map(\(s) s$amount)
|> sum()
};A function signature becomes part of the documentation and the contract of your package.
The typr command provides the tools needed to build, explore and maintain TypR projects.

Start building your next R package, application or data system with TypR. One command installs it.
curl -fsSL https://we-data-ch.github.io/typr.github.io/install/install.sh | shOne command, no admin rights, checksum verified. Other ways to install