tta small language for TypeScript and TSX

Standard library

TResult<T, E>

Represent success as Ok(value) and failure as Err(error).

example.tt
import * as Result from "@tt/std/result";

const user = Result.fromThrowable(() => JSON.parse(raw))
|> Result.andThenP(validateUser)
|> Result.mapP(normalizeUser);

Features

  • Constructors infer their own variant: TOk<T> or TErr<E>.
  • andThen and andThenP preserve incoming errors and union new error types.
  • Use map, mapErr, orElse, flatten, transpose, collect, fromThrowable, and fromPromise.
  • TErrorOf<R> extracts the union of error types.
NextModules →