type-rb

module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: MIT

README

TypeRB

[!WARNING] TypeRB is in alpha. The language, standard library, and tooling may change without notice.

TypeRB is a statically typed programming language that compiles to Go, Ruby, and TypeScript.

Install

brew install type-rb/tap/trb
trb version

Homebrew installs a prebuilt compiler on macOS or Linux. Install the target toolchain separately when you want to run generated code or manage its packages.

To build the compiler from source, use Go 1.26:

go install github.com/type-rb/type-rb/cmd/trb@latest

Playground

Open a local browser playground for experimenting with TypeRB:

trb play

It can execute, format, and transpile scratch TypeRB while switching between Go, Ruby, and TypeScript output. The server listens only on your local machine.

Tour

Learn the language through a guided, executable tour:

trb tour

The four chapters cover values and bindings, program structure, data and error modeling, and portable code across all three targets. Every lesson can be edited, run, formatted, and transpiled in the browser.

REPL

For a terminal workflow, start a typed REPL from any directory. It uses Go mode when no project configuration is present:

$ trb repl
trb:go> puts("Hello, TypeRB!")
Hello, TypeRB!
trb:go> 1 + 2
3 : Integer

Select another target for a one-off session:

trb repl --mode ruby
trb repl --mode typescript

Create a project

Create and run a Go project:

trb init --mode go --module example.com/hello hello
cd hello

Create main.trb:

def main()
	puts("Hello from TypeRB")
	return
end

Then format and run it:

trb fmt
trb run

trb run builds in a temporary directory before executing the program. Use trb build when you want to keep the generated source.

Go projects can also produce an executable:

trb build --compile
./bin/hello

Targets

  • Go for native binaries and services
  • Ruby for server and application development
  • TypeScript for server and browser applications

Every target uses the same TypeRB grammar and portable semantics. A target mode selects the backend, toolchain, and package ecosystem. Target-specific APIs require explicit imports.

Documentation

Read the documentation for the CLI, configuration, language, standard library, target guides, current status, and roadmap.

License

TypeRB is available under the MIT License.

Directories

Path Synopsis
cmd
trb command
internal
ast
Package ast defines the lossless syntax tree.
Package ast defines the lossless syntax tree.
checker
Package checker resolves names, infers local declaration types, validates assignments/returns, and records a type for every portable expression.
Package checker resolves names, infers local declaration types, validates assignments/returns, and records a type for every portable expression.
cli
compiler
Package compiler owns the public compilation pipeline.
Package compiler owns the public compilation pipeline.
declaration
Package declaration defines compiler-owned type information supplied by runtime-library providers.
Package declaration defines compiler-owned type information supplied by runtime-library providers.
formatter
Package formatter implements a deterministic, comment-preserving TypeRB printer.
Package formatter implements a deterministic, comment-preserving TypeRB printer.
ir
Package ir defines the resolved, target-independent representation consumed by every backend.
Package ir defines the resolved, target-independent representation consumed by every backend.
lexer
Package lexer provides the lossless lexical layer used by both the compiler and formatter.
Package lexer provides the lossless lexical layer used by both the compiler and formatter.
lower
Package lower converts checked syntax AST into the normalized IR.
Package lower converts checked syntax AST into the normalized IR.
packages
Package packages generates target package-manager manifests from trbconfig.jsonc.
Package packages generates target package-manager manifests from trbconfig.jsonc.
parser
Package parser implements TypeRB's handwritten recursive-descent and Pratt parsers.
Package parser implements TypeRB's handwritten recursive-descent and Pratt parsers.
playground
Package playground serves the local TypeRB playground and guided tour.
Package playground serves the local TypeRB playground and guided tour.
project
Package project owns trbconfig.jsonc discovery, validation, and persistence.
Package project owns trbconfig.jsonc discovery, validation, and persistence.
repl
Package repl implements TypeRB's project-aware interactive evaluator.
Package repl implements TypeRB's project-aware interactive evaluator.
resolver
Package resolver turns syntax imports into project or compiler-known package identities before type checking.
Package resolver turns syntax imports into project or compiler-known package identities before type checking.
stdlib
Package stdlib describes compiler-known portable and platform packages.
Package stdlib describes compiler-known portable and platform packages.
typeprovider
Package typeprovider loads compiler-owned declaration graphs for explicitly imported platform packages.
Package typeprovider loads compiler-owned declaration graphs for explicitly imported platform packages.
typeprovider/rails
Package rails supplies TypeRB declarations for Rails and derives ActiveRecord model types from db/schema.rb.
Package rails supplies TypeRB declarations for Rails and derives ActiveRecord model types from db/schema.rb.
typeprovider/rails/schema
Package schema defines the normalized AST for the subset of Rails schema DSL that contributes model types.
Package schema defines the normalized AST for the subset of Rails schema DSL that contributes model types.
types
Package types contains target-independent semantic types.
Package types contains target-independent semantic types.
selfhost

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL