A readable syntax for Effect. EffScript is to
Effect what JSX was to React: a small language that compiles to the
TypeScript you would write by hand, minus the incantations. If you know
async function and await, you already know effect function and run.
Try it in the browser at effscript.vpagani.dev/playground.
error UserNotFound { id: UserId }
service UserRepo {
find(id: UserId): Effect<User, UserNotFound>;
}
export effect function greet(id: UserId) {
const repo = use UserRepo;
const user = run repo.find(id)
|> Effect.retry(Schedule.recurs(2))
|> Effect.timeout("1 second");
run Effect.log(`Hello, ${user.name}`);
return user;
}
export const main = greet(UserId.make("u-1"))
catch {
UserNotFound(e) => Effect.log(`no user ${e.id}`)
TimeoutError => Effect.log("too slow")
}
with UserRepoLive;
- Plain output. It compiles to ordinary Effect code (
Effect.fn,Context.Service,Data.TaggedError,Effect.catchTags), as TypeScript or JavaScript with source maps. There is no runtime. Core modules such asEffect,SchemaandConsoleneed no import (the prelude); the output imports them. - The whole ecosystem. Services, errors, schemas,
match, streams, layers (with Effect's ownLayerAPI), effect-machine state machines and Effect UI components with JSX-like markup. - Real types. Type checked by tsrs, the Rust port of the TypeScript 7 checker, with errors at EffScript positions. EffScript and TypeScript files import each other freely.
- Tooling included.
efsbuilds, checks, formats and lints, and runs a language server. Plugins for Vite, Rollup, Rolldown, esbuild, Bun and webpack.
cargo install --path crates/efs_cliefs init hello && cd hello && pnpm install && efs check && efs build- Website and playground
- Getting started
- Language guide: every construct and what it compiles to
- The
efscommand and lint rules - TypeScript interop, including effect-tsgo
- Bundlers and editors
- Library versions
- Architecture and contributing
An early release for Effect 4. Machines and components follow effect-machine and Effect UI, which are pre-1.0, so their syntax may change with them. See Not supported.
MIT