{"id":13609103,"url":"https://github.com/briancavalier/fx-ts","last_synced_at":"2025-03-17T04:31:17.406Z","repository":{"id":37870968,"uuid":"221468836","full_name":"briancavalier/fx-ts","owner":"briancavalier","description":"Computational environments and effects for TypeScript","archived":false,"fork":false,"pushed_at":"2023-01-24T01:40:50.000Z","size":2274,"stargazers_count":59,"open_issues_count":23,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-20T07:45:55.141Z","etag":null,"topics":["algebraic-effects","effects","functional-programming","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/briancavalier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-13T13:43:54.000Z","updated_at":"2024-06-29T06:41:04.000Z","dependencies_parsed_at":"2023-02-13T09:31:07.649Z","dependency_job_id":null,"html_url":"https://github.com/briancavalier/fx-ts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancavalier%2Ffx-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancavalier%2Ffx-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancavalier%2Ffx-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancavalier%2Ffx-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/briancavalier","download_url":"https://codeload.github.com/briancavalier/fx-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221671732,"owners_count":16861299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algebraic-effects","effects","functional-programming","typescript"],"created_at":"2024-08-01T19:01:32.465Z","updated_at":"2024-10-27T11:55:37.384Z","avatar_url":"https://github.com/briancavalier.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003efx-ts\u003c/h1\u003e\n\n\u003ch3 align=\"center\"\u003eCapabilities \u0026 Effects for TypeScript\u003c/h3\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e • \u003ca href=\"#install\"\u003eInstall\u003c/a\u003e • \u003ca href=\"#examples\"\u003eExamples\u003c/a\u003e • \u003ca href=\"#documentation\"\u003eDocumentation\u003c/a\u003e\n\u003c/p\u003e\n\n## Features\n\n* **Do-notation for effects**: Write _imperative-looking_ code that's fully referentially transparent\n* **Asychronous effects with cancelation**: Seamlessly mix synchronous and asynchronous effects without worry\n* **Effect inference**: Effects can be inferred without explicit type annotations\n* **Extensible**: Implement new effects in user land\n* **Testable**: Code to interfaces, and easily use different implementations for development, production, and testing\n* **Efficient**: Synchronous and Asynchronous effects run in _constant stack_\n\n## Install\n\n```shell\nnpm install --save fx-ts\n```\n\n## Examples\n\nThese examples are intended to be run against master using ts-node.  For example:\n\n```sh\n$ ./node_modules/.bin/ts-node -O '{ \"module\": \"commonjs\" }' ./examples/echo-console.ts\n```\n\n* [echo-console](examples/echo-console.ts): A simple read-print loop. A good introduction to the basics of capabilities and effects.\n* [fp-to-the-max](examples/fp-to-the-max-1.ts): A more involved example number guessing game example from https://www.youtube.com/watch?v=sxudIMiOo68\n\nThis example runs on AWS Lambda.  [**If you have a serverless account and have setup your AWS credentials**](https://www.serverless.com/framework/docs/getting-started#set-up-your-free-pro-account), you can deploy it using `serverless`:\n\n```sh\n$ cd examples/lambda-pets\n$ ./node_modules/.bin/serverless deploy\n```\n\n* [lambda-pets](examples/lambda-pets): A realistic AWS Lambda application that shows adoptable pets near the user's IP Address using https://ipstack.com and https://petfinder.com\n\n### Running the examples\n\nThe\n\n## Documentation\n\nPure 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.  They need access to databases, external services, or configuration, and need to perform effects like reading and writing files, updating databases, etc.\n\nThe goal of fx-ts is to help in writing programs that interact with their environment _and_ are easy to reason about and test.\n\n```ts\n// Abstract Print \u0026 Read capabilities\n\ntype Print = { print(s: string): Fx\u003cunknown, void\u003e }\n\ntype Read = { read: Fx\u003cAsync, string\u003e }\n\nconst main = doFx(function* () {\n  const { print, read } = yield* get\u003cPrint \u0026 Read\u003e()\n  while (true) {\n    yield* print('\u003e ')\n    const s = yield* read\n    yield* print(`${s}${EOL}`)\n  }\n})\n\nconst capabilities = {\n  // ...Concrete implementation of Print and Read...\n}\n\nrunFx(main(), capabilities)\n```\n\n## API\n\n_Coming soon_\n\n## Inspiration\n\n* [koka](https://github.com/koka-lang/koka)\n* [ZIO](https://zio.dev)\n* [forgefx](https://github.com/briancavalier/forgefx)\n* [ambient](https://github.com/briancavalier/ambient)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriancavalier%2Ffx-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbriancavalier%2Ffx-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriancavalier%2Ffx-ts/lists"}