Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 39 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<div align="center">

<img src="src/typr_carre.png" alt="TypR logo" width="250">

# TypR

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

[![Downloads](https://img.shields.io/crates/d/typr)](https://crates.io/crates/typr)
[![Latest release](https://img.shields.io/github/v/release/we-data-ch/typr)](https://github.com/we-data-ch/typr/releases/latest)
[![CI](https://github.com/we-data-ch/typr/actions/workflows/ci.yml/badge.svg)](https://github.com/we-data-ch/typr/actions)
[![Docker Pulls](https://img.shields.io/docker/pulls/fabricehategekimana/typr)](https://hub.docker.com/r/fabricehategekimana/typr)
[![Open VSX](https://img.shields.io/open-vsx/v/wedata-ch.typr-language)](https://open-vsx.org/extension/wedata-ch/typr-language)
[![License](https://img.shields.io/github/license/we-data-ch/typr)](LICENSE)

[Documentation](https://we-data-ch.github.io/typr.github.io/) ·
[Playground](https://we-data-ch.github.io/typr-playground.github.io/) ·
[Blog](https://we-data-ch.github.io/typr.github.io/blog)
Expand All @@ -13,26 +22,41 @@ interfaces, compiled to idiomatic, readable R.

---

TypR is not a new runtime. It is a static verification and desugaring layer that
compiles entirely to conventional R before execution — every generated `R/*.R`
file stays readable and runs on a stock R installation. It targets the step
beyond exploratory scripting: package production, maintenance, and code that has
to survive in production.
**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.**

<table>
<tr>
<td><strong>R today</strong></td>
<td><strong>TypR</strong></td>
</tr>
<tr>
<td>

```r
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)
}
```

```typr
type Shape <- .Circle(num) | .Square(num);
</td>
<td>

let area <- fn(s: Shape): num {
match s {
.Circle(r) => 3.14159 * r * r,
.Square(side) => side * side,
}
```r
let normalize <- fn(x: [num], na.rm: bool = false): [num] {
if (na.rm) { x <- x[!is.na(x)] };
(x - mean(x)) / sd(x)
};

# UFCS, pipes and plain calls are all equivalent
(3.0) |> .Circle() |> area() |> print();
```

</td>
</tr>
</table>

## Install

| Channel | Command |
Expand Down
Binary file added src/typr_carre.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading