{"id":13200,"library":"fp-ts-contrib","title":"fp-ts Community Contributions","description":"fp-ts-contrib is a community-driven utility package designed to extend the core functionalities of `fp-ts`, a popular TypeScript library for functional programming. It provides additional data types, combinators, and instances for existing types that are not part of the `fp-ts` core but are frequently requested or useful in a functional programming context. Currently at version 0.1.29, the library exhibits a consistent release cadence with new features and bug fixes, as seen in the frequent micro-version bumps. Its key differentiator is providing a shared space for useful `fp-ts` extensions, reducing boilerplate and fostering a more robust functional ecosystem by incorporating patterns like `IOOption`, `ReaderIO`, and `Zipper`, which are not directly in `fp-ts` itself. It primarily targets TypeScript environments and maintains compatibility with `fp-ts` via peer dependencies.","status":"active","version":"0.1.29","language":"javascript","source_language":"en","source_url":"https://github.com/gcanti/fp-ts-contrib","tags":["javascript","typescript","fp-ts","functional-programming"],"install":[{"cmd":"npm install fp-ts-contrib","lang":"bash","label":"npm"},{"cmd":"yarn add fp-ts-contrib","lang":"bash","label":"yarn"},{"cmd":"pnpm add fp-ts-contrib","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core functional programming utilities extended by this library; listed as a peer dependency.","package":"fp-ts","optional":false}],"imports":[{"note":"Many modules within `fp-ts-contrib` are exposed as default exports of their respective paths, often imported as a namespace.","wrong":"import { IOOption } from 'fp-ts-contrib'","symbol":"IOOption","correct":"import * as IOOption from 'fp-ts-contrib/IOOption'"},{"note":"The library is primarily designed for ESM imports with TypeScript. While CommonJS might work, it's not the idiomatic usage.","wrong":"const ReaderIO = require('fp-ts-contrib/ReaderIO');","symbol":"ReaderIO","correct":"import * as ReaderIO from 'fp-ts-contrib/ReaderIO'"},{"note":"Import specific modules from their direct path to avoid bundling unnecessary code. Types are bundled with the package.","symbol":"Zipper","correct":"import * as Zipper from 'fp-ts-contrib/Zipper'"}],"quickstart":{"code":"import * as IOOption from 'fp-ts-contrib/IOOption';\nimport * as O from 'fp-ts/Option';\nimport * as IO from 'fp-ts/IO';\nimport { pipe } from 'fp-ts/function';\n\n// Example using IOOption: an IO that might produce an Option\nconst getUserInput = (prompt: string): IO.IO<O.Option<string>> => \n  IO.of(() => {\n    const input = 'some user value'; // In a real app, this would be `prompt()` or similar\n    return input ? O.some(input) : O.none;\n  });\n\nconst processInput = (input: string): IO.IO<number> => \n  IO.of(() => input.length);\n\nconst mainIOOption = pipe(\n  getUserInput('Enter a value:'),\n  IOOption.chainIOK((input: string) => processInput(input)),\n  IOOption.map((length: number) => `Processed length: ${length}`),\n  IOOption.getOrElse(() => IO.of('No input provided.')),\n);\n\n// Execute the IO to see the result\nconst result = mainIOOption();\nconsole.log(result());","lang":"typescript","description":"Demonstrates the use of `IOOption` to handle potentially absent input within an `IO` context, processing it if present."},"warnings":[{"fix":"Ensure `fp-ts` is explicitly installed in your project: `npm install fp-ts` or `yarn add fp-ts`.","message":"Starting from version 0.1.0, `fp-ts-contrib` transitioned to using `fp-ts` as a `peerDependency`. This means `fp-ts` must be manually installed in your project, it will not be installed automatically.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always import modules directly from their path, e.g., `import * as IOOption from 'fp-ts-contrib/IOOption'`.","message":"The package exposes its modules via specific paths (e.g., `fp-ts-contrib/IOOption`). Importing directly from `fp-ts-contrib` as a named import (e.g., `import { IOOption } from 'fp-ts-contrib'`) might lead to undefined symbols or larger bundle sizes due to incorrect tree-shaking.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Upgrade your TypeScript version to 3.5 or newer: `npm install typescript@^3.5` or `yarn add typescript@^3.5`.","message":"TypeScript compatibility requires a minimum version of TypeScript 3.5+ for `fp-ts-contrib` versions 0.1.x and above. Using older TypeScript versions may lead to compilation errors.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install `fp-ts` manually: `npm install fp-ts` or `yarn add fp-ts`.","cause":"`fp-ts` is a peer dependency and was not installed in the project.","error":"Error: Cannot find module 'fp-ts' or its corresponding type declarations."},{"fix":"Ensure `fp-ts-contrib` is installed (`npm i fp-ts-contrib`) and check import paths. Also verify your `tsconfig.json` includes `node_modules` in its types.","cause":"Incorrect import path or `fp-ts-contrib` not installed.","error":"TS2307: Cannot find module 'fp-ts-contrib' or its corresponding type declarations."},{"fix":"Import the module from its direct path as a namespace: `import * as IOOption from 'fp-ts-contrib/IOOption'`.","cause":"Attempting to named import a module that is exposed as a default export from a subpath.","error":"TS2305: Module '\"fp-ts-contrib\"' has no exported member 'IOOption'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}