typr-core 0.5.11

Core type checking and transpilation logic for TypR - a typed superset of R
Documentation

TypR

A typed superset of R — static type checking, modules, sum types and interfaces, compiled to idiomatic, readable R.

Downloads Latest release CI Docker Pulls Open VSX License

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.

normalize <- function(x, na.rm = FALSE) {
  stopifnot(is.numeric(x), length(x) > 0)
  if (na.rm) x <- x[!is.na(x)]
  (x - mean(x)) / sd(x)
}
let normalize <- fn(x: [num], na.rm: bool = false): [num] {
    if (na.rm) { x <- x[!is.na(x)] };
    (x - mean(x)) / sd(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

typr new my_package     # scaffold a project
typr check              # type-check without emitting
typr build              # transpile to R/
typr run                # build and run
typr test               # run testthat suites
typr document           # generate .Rd documentation
typr pkgdown            # build a documentation website
typr repl               # interactive session
typr lsp                # language server (used by the editor extensions)
typr mcp                # MCP server (exposes the compiler to AI agents)

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:

{
  "mcpServers": {
    "typr": {
      "command": "typr",
      "args": ["mcp"]
    }
  }
}

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