Hi everyone,
I'm working on an open-source tool called typr that lets you write type declarations in a concise syntax (.ty files) and generates idiomatic R/S3 code from them — with static type checking before anything runs.
The idea is similar to what roxygen2 does for documentation: you write structured declarations, and the tool generates correct R code. Except here, it targets S3 class definitions, constructors, and typed function signatures.
Here's a quick example. You write this in a .ty file:
type Person = {
name: char,
age: int
};
new_person <- fn(name: char, age: int): Person {
list(name = name, age = age)
};
is_minor <- fn(p: Person): bool {
(p$age) < 18
};
And typr generates standard R/S3 code — any R user can consume the output without knowing typr exists.
I'm considering applying for an R Consortium ISC grant to package this as a proper R package (installable from r-universe), with documentation and vignettes showing real package development workflows.
I'd love your honest feedback:
- Would you find this useful in your own package development?
- What would make or break adoption for you? (editor support? CRAN compatibility? data.frame typing?)
- Any concerns or red flags you see?
The project is open source: GitHub - we-data-ch/typr: A safer complement of R, the legendary programming language for statistic and datasciences ! · GitHub
Playground: TypR Playground
Thanks for any thoughts — critical feedback is especially welcome.
Fabrice