fx-ts
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

fx-ts: Computational environments

fx-ts: A library for writing effectful, functional programs in TypeScript.

Requirements

Install

npm install fx-ts --save

Introduction

Pure functions are easy to reason about and test because they aren't entangled with the environment in which they're called. They always give the same answer for the same inputs. Nevertheless, useful programs need to interact with their environment, e.g., databases, external services, or configuration.

The goal of fx-ts is to help in writing programs that interact with their environment and that are easy to reason about and test.

Environments and Generators in fx-ts

In fx-ts, generators yield Envs (environments) that express what they need from the environment in their signature. The Env type is basically a Reader type—which are suitable for passing (implicit) configuration information through a computation (but are also used to do that which in object-oriented programming is called dependency injection)—that also handles asynchronous operations.

The core of fx-ts is chainEnv, which aggregates capability requirements via intersection type, and the Use type-level function, which eliminates capability requirements.

The ideas are similar to those which ZIO enviroments are build on.

Readme

Keywords

none

Package Sidebar

Install

npm i fx-ts

Weekly Downloads

5

Version

1.4.0

License

MIT

Unpacked Size

15.7 kB

Total Files

20

Last publish

Collaborators

  • briancavalier