Getting started
1. Why this language
TypR is a powerfull datascience/software engeneering tool and a typed version of the R language that introduces an optional static type system, while preserving the flexibility and expressiveness that make R a powerful tool for data analysis and statistics.
Its main goals are:
- Reduce runtime errors through early detection (at writing or compilation time).
- Improve readability and maintainability of medium- to large-scale R projects.
- Facilitate teamwork by making function contracts and data structures explicit.
- Prepare R code for production use, without giving up the existing ecosystem.
TypR aims to strike a balance: more rigor when needed, without sacrificing productivity.
2. What TypR is not
Not a R's replacement
R is a powerful tool for research, exploration, experimentation and visual production for data analysis and statistics. TypR is there to handle another set of activity going from package production/maintenance to live application scalability in production.
Not low level R
Even though, in the future types will help building faster code, their goal is more about data modeling and safety.
Target audience
This language is primarily intended for:
- Data scientists and statisticians who use R and want more reliable analyses.
- Developers working on complex or mission-critical R projects.
- Data teams in organizations seeking to standardize and secure their codebases.
- Researchers and educators who want to introduce sound software engineering practices into their work.
It is especially well suited for projects that go beyond simple exploratory scripts.
3. Prerequisites
To use TypR, it is recommended to:
- Have a basic knowledge of the R language (syntax, functions, data frames).
- Understand fundamental programming concepts (functions, variables, modules).
Experience in data science or statistics is a plus, but not strictly required.
4. Installation
TypR is installed as a complement to R.
General steps:
1. Install a recent version of R.
You can install R (and RStudio) in this link.
2. Install the TypR compiler/interpreter
You can install TypR in 3 different ways:
With the release page
If you have Windows or Linux (not yet available for Mac OS) you can download it with the release page.
Via DockerHub:
If you have docker you can install TypR with your terminal:
docker pull fabricehategekimana/typr:latest
You can then run it in this way:
docker run -it --rm -v $(pwd):/workspace fabricehategekimana/typr:latest
With Cargo (Rust)
If you already have Rust in your system, you can download it with Cargo from Rust:
cargo install TypR
3. Verify the installation
To verify your installation, you can use this command:
> typr --version
typr [actual version]
Once installed, TypR can be used:
- from the command line,
- within a compatible IDE,
5. First program
Here is a simple first example in TypR:
print("Hello world")
Here is another example doing the same thing but with type expressions
let hello: char <- "Hello world";
let my_print <- fn(msg: char): Empty {
print(msg)
};
my_print(hello)
Core concepts
Primitive types
TypR introduces explicit types for basic values:
- integer (int)
- numbers (num)
- booleans (bool)
- characters (char)
These types allow the compiler to check code consistency.
Functions
Typed functions
fn(a: int, b: int): int {
a + b
}
Functions can declare:
- the type of their parameters,
- the type of their return value.
This makes developer intent explicit and prevents many classes of errors.
Untyped functions
function(a, b) {
a + b
}
To keep a flexible way to interop with raw R code.
Data structures
Vectors
c(1, 2, 3, 4)
Lists
list(name = "Anna", age = 56)
or
:{name: "Anna", age: 56}
Going further
To deepen your use of TypR, you can:
- Explore advanced types
- Learn about integration with the existing R ecosystem (packages, scripts, notebooks).
TypR is designed to evolve alongside its users and their needs.