Getting Started with T

Welcome to T! This guide will help you install T, create your first project, and understand the basic layout of a T workspace.

Prerequisites

T requires the Nix package manager with flakes enabled. Nix ensures that your T environment is perfectly reproducible across Linux and macOS.

We strongly recommend installing Nix using the Determinate Systems Nix Installer. For detailed, platform-specific steps, please see our:

πŸ‘‰ Nix Installation Guide

Running T

As a user, you don’t need to clone the repository or build the compiler from source! You can run the T shell directly from GitHub using Nix:

nix shell github:b-rodrigues/tlang

This command will download the T executable, fetch all required dependencies, and drop you into a temporary shell where the t command is available, for as long as you stay in that shell.

Starting a New Workspace

T provides a built-in scaffolding tool to initialize your workspaces. There are two types of workspaces in T: - Projects: Designed for data analysis, scripts, and reproducible pipelines. - Packages: Designed for creating reusable functions and libraries to share with others.

Creating a Project

To start a new data analysis project, navigate to your desired folder and run (while in the temporary shell you dropped in before):

t init --project my_analysis

The scaffolding tool will generate a reproducible workspace with the following layout:

my_analysis/
β”œβ”€β”€ tproject.toml       # Project configuration and dependencies
β”œβ”€β”€ flake.nix           # Reproducible environment definition
β”œβ”€β”€ README.md           # Project overview
β”œβ”€β”€ src/
β”‚   └── pipeline.t      # Your main analysis script
β”œβ”€β”€ data/               # Place your raw data files here
β”œβ”€β”€ outputs/            # Output directory for results
└── tests/              # Unit tests for your analysis

Creating a Package

If you want to create a reusable library of T functions, initialize a package instead:

t init --package my_package

The tree layout for a package is structured for development and testing:

my_package/
β”œβ”€β”€ DESCRIPTION.toml    # Package metadata (name, version, exports)
β”œβ”€β”€ flake.nix           # Reproducible environment definition
β”œβ”€β”€ README.md           # Package overview
β”œβ”€β”€ src/
β”‚   └── main.t          # Package source code
β”œβ”€β”€ tests/
β”‚   └── test-my_package.t  # Unit tests for your package
β”œβ”€β”€ examples/           # Usage examples
└── docs/               # Documentation

Running Your Code

Now that you’ve bootstrapped your project or package, you can leave the temporary Nix shell using exit. Move into the project’s directory (if not there already), and type nix develop to drop into the development environment of the project. You may be prompted to make the flake.nix discoverable, you can copy and paste the suggested command or simply run git add . to stage the whole project. Try nix develop again to drop into the development environment. You should see the following:

==================================================
T Project: start_t
==================================================

Available commands:
  t repl              - Start T REPL
  t run <file>        - Run a T file
  t test              - Run tests

To add dependencies:
  * Add them to tproject.toml
  * Run 't update' to sync flake.nix

Inside your project or package directory, you can start the interactive REPL to explore your data:

t repl

(or simply t).

To execute a script from end-to-end, use:

t run scripts/main.t

Next Steps

Now that you have your first project set up and understand the folder structure, you are ready to explore the language features and build reproducible data pipelines!

  1. Configure Editors β€” Configure your editor to play well with T.
  2. Language Overview β€” Explore T’s syntax, types, and standard library functions.
  3. Pipeline Tutorial β€” Learn how to build reproducible, DAG-based data analysis workflows (the core feature of T).
  4. Project Development β€” Dive deeper into managing your tproject.toml and Nix environments.