TypR
A typed superset of R — static type checking, modules, sum types and interfaces, compiled to idiomatic, readable R.
Documentation · Playground · Blog
Just add types. TypR is a typed superset of R that compiles to readable, stock R. No runtime, no new dependencies — just static verification that catches wrong argument types, undocumented returns, and silent coercions before your code ever runs.
{
if (na.rm) x <- x
(x - ) /
}
let normalize <- : {
if (na.rm) { x <- x };
(x - ) /
};
Install
| Channel | Command |
|---|---|
| Cargo | cargo install typr |
| Binaries | latest release — Linux, macOS, Windows (x86_64 + aarch64) |
| Docker | docker run --rm -it fabricehategekimana/typr:latest |
| RStudio / Positron | typr.runner_*.tar.gz from the latest release |
| VS Code / Positron | search TypR in the Marketplace |
| Vim / Neovim | typr-vim-*.tar.gz from the latest release, or a plugin manager — see editors/vim |
All channels are published from the same tag and carry the same version number. See RELEASING.md.
Usage
MCP server
typr mcp runs an MCP server over stdio, giving AI
agents (Claude Code, Claude Desktop, etc.) direct access to the compiler — no shelling out
to typr check/typr build and parsing text output. Everything runs in-process: no
filesystem, no project directory, no .typr_cache.
Tools exposed today (see crates/typr-mcp):
| Tool | What it does |
|---|---|
check |
Type-checks TypR source, returns {ok, diagnostics[{code, message}]} with stable T0xx/S0xx codes |
build |
Same as check, plus the transpiled R code (r_code) — produced even when there are type errors |
Point a client at the typr binary with the mcp argument. After cargo install typr,
typr is on PATH, so a client config (e.g. Claude Desktop's/Claude Code's mcpServers
block) just needs:
Building from a local checkout instead of installing? Point command at
target/debug/typr (or target/release/typr) directly.
Repository layout
crates/typr-core type checking and transpilation
crates/typr-cli command-line interface
crates/typr-lsp language server
crates/typr-mcp MCP server exposing the compiler to AI agents
crates/typr-wasm WASM build powering the playground
editors/vscode VS Code / Positron extension
editors/rstudio RStudio addins (typr.runner)
editors/vim Vim / Neovim plugin
docker/ container image
cases/ reproducible bug catalog (`typr case`)
Contributing
cases/ holds a numbered, reproducible catalog of past bugs with golden
outputs — the best entry point for understanding a behaviour is usually the case
that pinned it down. cargo test --workspace runs the suite.
License
Apache-2.0