Skip to main content

Quick Start

This guide walks you through type-checking your first R file with Infr.

1. Create an Infr file

Rename any existing .R file to .infr, or create a new one:

hello.infr
const greet <- function(name: character, excited: logical = FALSE) -> character {
if (excited) {
paste0("Hello, ", name, "!")
} else {
paste("Hello", name)
}
}

const msg: character <- greet("Alice", excited = TRUE)

2. Type-check

infr check hello.infr

If there are no errors, Infr exits silently. Try introducing a type error:

greet(42)
# Error [infr]: Type mismatch in argument `name` of `greet()`.
# Expected: character
# Got: numeric

3. Transpile to R

infr build hello.infr

This emits a clean hello.R file with all type annotations and const/let keywords stripped:

hello.R
greet <- function(name, excited = FALSE) {
if (excited) {
paste0("Hello, ", name, "!")
} else {
paste("Hello", name)
}
}

msg <- greet("Alice", excited = TRUE)

4. Initialize a project

For multi-file projects, create an infr.toml configuration:

infr init

This generates a default infr.toml:

infr.toml
[project]
name = "my-analysis"

[check]
strictness = "relaxed"

[output]
dir = "R/"
preserve_comments = true

5. Batch transpile

infr build src/ -o R/

6. Watch mode

infr watch src/

Re-checks files on every save.

What's next?