[
  {
    "path": ".babel.cjs.json",
    "content": "{\n  \"plugins\": [[\"@babel/transform-modules-commonjs\"], [\"annotate-pure-calls\"]]\n}\n"
  },
  {
    "path": ".babel.mjs.json",
    "content": "{\n  \"plugins\": [[\"annotate-pure-calls\"]]\n}\n"
  },
  {
    "path": ".changeset/README.md",
    "content": "# Changesets\n\nHello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works\nwith multi-package repos, or single-package repos to help you version and publish your code. You can\nfind the full documentation for it [in our repository](https://github.com/changesets/changesets)\n\nWe have a quick list of common questions to get you started engaging with this project in\n[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)\n"
  },
  {
    "path": ".changeset/beige-numbers-exist.md",
    "content": "---\n\"@fp-ts/core\": patch\n---\n\nTuple: add more APIs\n"
  },
  {
    "path": ".changeset/config.json",
    "content": "{\n  \"$schema\": \"https://unpkg.com/@changesets/config@1.6.4/schema.json\",\n  \"changelog\": [\"@changesets/changelog-github\", { \"repo\": \"fp-ts/core\" }],\n  \"commit\": false,\n  \"linked\": [],\n  \"access\": \"restricted\",\n  \"baseBranch\": \"main\",\n  \"updateInternalDependencies\": \"patch\",\n  \"ignore\": []\n}\n"
  },
  {
    "path": ".changeset/famous-spies-attend.md",
    "content": "---\n\"@fp-ts/core\": patch\n---\n\nexport productAll from Option, Either, Predicate\n"
  },
  {
    "path": ".changeset/flat-news-whisper.md",
    "content": "---\n\"@fp-ts/core\": patch\n---\n\nfix bounds flipping in reverse function\n"
  },
  {
    "path": ".changeset/hungry-comics-kneel.md",
    "content": "---\n\"@fp-ts/core\": patch\n---\n\nFunction: swap apply arguments\n"
  },
  {
    "path": ".changeset/mighty-meals-dream.md",
    "content": "---\n\"@fp-ts/core\": patch\n---\n\nadd missing boolean semigroups, monoids and combinators\n"
  },
  {
    "path": ".changeset/odd-hornets-wave.md",
    "content": "---\n\"@fp-ts/core\": patch\n---\n\nBigint: feature parity with Number\n"
  },
  {
    "path": ".changeset/sour-suits-press.md",
    "content": "---\n\"@fp-ts/core\": patch\n---\n\nNumber: add missing functions (derivable from Order)\n"
  },
  {
    "path": ".changeset/tough-planets-lick.md",
    "content": "---\n\"@fp-ts/core\": patch\n---\n\nReadonlyRecord: map: add support for structs\n"
  },
  {
    "path": ".eslintrc.cjs",
    "content": "/* eslint-disable no-undef */\nmodule.exports = {\n  ignorePatterns: [\"build\", \"dist\", \"dtslint\", \"benchmark\", \"*.mjs\", \"docs\", \"*.md\"],\n  parser: \"@typescript-eslint/parser\",\n  parserOptions: {\n    ecmaVersion: 2018,\n    sourceType: \"module\",\n    project: \"./tsconfig.eslint.json\"\n  },\n  settings: {\n    \"import/parsers\": {\n      \"@typescript-eslint/parser\": [\".ts\", \".tsx\"]\n    },\n    \"import/resolver\": {\n      typescript: {\n        alwaysTryTypes: true\n      }\n    }\n  },\n  extends: [\n    \"eslint:recommended\",\n    \"plugin:@typescript-eslint/eslint-recommended\",\n    \"plugin:@typescript-eslint/recommended\",\n    \"plugin:@repo-tooling/dprint/recommended\"\n  ],\n  plugins: [\"deprecation\", \"import\", \"sort-destructure-keys\", \"simple-import-sort\", \"codegen\"],\n  rules: {\n    \"codegen/codegen\": \"error\",\n    \"no-fallthrough\": \"off\",\n    \"no-irregular-whitespace\": \"off\",\n    \"object-shorthand\": \"error\",\n    \"prefer-destructuring\": \"off\",\n    \"sort-imports\": \"off\",\n    \"no-unused-vars\": \"off\",\n    \"prefer-rest-params\": \"off\",\n    \"prefer-spread\": \"off\",\n    \"import/first\": \"error\",\n    \"import/no-cycle\": \"error\",\n    \"import/newline-after-import\": \"error\",\n    \"import/no-duplicates\": \"error\",\n    \"import/no-unresolved\": \"off\",\n    \"import/order\": \"off\",\n    \"simple-import-sort/imports\": \"off\",\n    \"sort-destructure-keys/sort-destructure-keys\": \"error\",\n    \"deprecation/deprecation\": \"off\",\n    \"@typescript-eslint/array-type\": [\"warn\", { \"default\": \"generic\", \"readonly\": \"generic\" }],\n    \"@typescript-eslint/prefer-readonly\": \"warn\",\n    \"@typescript-eslint/member-delimiter-style\": 0,\n    \"@typescript-eslint/no-non-null-assertion\": \"off\",\n    \"@typescript-eslint/ban-types\": \"off\",\n    \"@typescript-eslint/no-explicit-any\": \"off\",\n    \"@typescript-eslint/no-empty-interface\": \"off\",\n    \"@typescript-eslint/consistent-type-imports\": \"warn\",\n    \"@typescript-eslint/no-unused-vars\": [\"error\", {\n      \"argsIgnorePattern\": \"^_\",\n      \"varsIgnorePattern\": \"^_\"\n    }],\n    \"@typescript-eslint/ban-ts-comment\": \"off\",\n    \"@typescript-eslint/camelcase\": \"off\",\n    \"@typescript-eslint/explicit-function-return-type\": \"off\",\n    \"@typescript-eslint/explicit-module-boundary-types\": \"off\",\n    \"@typescript-eslint/interface-name-prefix\": \"off\",\n    \"@typescript-eslint/no-array-constructor\": \"off\",\n    \"@typescript-eslint/no-use-before-define\": \"off\",\n    \"@typescript-eslint/no-namespace\": \"off\",\n    \"@repo-tooling/dprint/dprint\": [\n      \"error\",\n      {\n        config: {\n          \"indentWidth\": 2,\n          \"lineWidth\": 100,\n          \"semiColons\": \"asi\",\n          \"quoteStyle\": \"alwaysDouble\",\n          \"trailingCommas\": \"never\",\n          \"operatorPosition\": \"maintain\",\n          \"useParentheses\": \"preferNone\"\n        }\n      }\n    ]\n  }\n}\n"
  },
  {
    "path": ".github/CONTRIBUTING.md",
    "content": "# Contributing to `@fp-ts/core`\n\nWe welcome all contributions to the `@fp-ts/core` library. Your help makes the library better for everyone!\n\n## Creating an Issue\n\nBefore you begin working on a contribution, it's important to create an issue that describes what you would like to build or improve. This helps to ensure that someone else isn't already working on something similar, and also helps the maintainers understand your goals.\n\n## Development Workflow\n\n1. Fork the repository on GitHub.\n2. Clone your forked repository using the following command: `git clone git@github.com:{your_username}/core.git`\n3. Install dependencies with `pnpm install`.\n4. Make your contributions and commit your changes.\n5. If you have made changes to the code, run `pnpm changeset` and select the appropriate level of change (`patch`, `minor`, `major`)\n\n### Available Commands\n\n- `pnpm build`: Deletes the `dist` folder and recompiles the `src` code into `dist`.\n- `pnpm test`: Runs all vitest tests in watch mode.\n- `pnpm coverage`: Runs all vitest tests and collects coverage information.\n- `pnpm dtslint`: Runs type-level tests.\n\n### Writing Tests\n\n`@fp-ts/core` uses vitest for testing. After making your contributions, it's important to write tests to ensure that they work as intended. Before submitting your pull request, run `pnpm coverage` to make sure there are no unintended breaking changes and that your code has 100% coverage.\n\n### Documentation\n\nAPI documentation for `@fp-ts/core` can be found in the source code as JSDoc comments. Be sure to include documentation for any changes you make to the API.\n\n## Licensing\n\nBy contributing your code to the `@fp-ts/core` GitHub repository, you agree to license your contribution under the MIT license.\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "github: [gcanti]\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/Bug_report.md",
    "content": "# Bug Report\n\nThank you for reporting a bug in `@fp-ts/core`. Your contribution to this project is greatly appreciated and will help make the library better for everyone.\n\n## Describing the Bug\n\nPlease provide a clear and concise description of the issue you are encountering, including any error messages or unexpected behavior you have observed.\n\n## Steps to Reproduce\n\nIn order to help us understand and resolve the issue, please provide the steps to reproduce the behavior, along with a minimal, self-contained code example that demonstrates the problem.\n\n## Expected Behavior\n\nPlease describe what you expected to happen, and how the current behavior differs from your expectations.\n\n## Environment\n\nPlease provide the following information to help us understand your setup:\n\n- Library version: [e.g. `0.8.1`]\n- TypeScript version: [e.g. `4.2.2`]\n\n## Additional Context\n\nAny additional information or context that you think would be helpful in resolving the issue.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/Documentation.md",
    "content": "# Improving Documentation\n\nWe welcome all suggestions and improvements to the documentation of `@fp-ts/core`. Your contributions help make the library easier to understand and use for everyone.\n\n## How to Contribute\n\nTo contribute to the documentation, follow these steps:\n\n1. Make the desired changes to the documentation files.\n2. Submit a pull request with a clear description of the changes and why they are beneficial.\n\n## Content Guidelines\n\nWhen contributing to the documentation, please keep in mind the following guidelines:\n\n- Write clear and concise explanations of features and concepts.\n- Use examples and code snippets to help illustrate your explanations.\n- Follow the same formatting and style used in the existing documentation.\n\nThank you for your contributions to the `@fp-ts/core` documentation!\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/Feature_request.md",
    "content": "# Feature Request\n\nThank you for submitting a feature request for `@fp-ts/core`. Your contributions help shape the future of this library.\n\n## Describing the Feature\n\nPlease provide a clear and concise description of the new feature you would like to see added to `@fp-ts/core`.\n\n## Problem to Solve\n\nPlease describe the problem that this new feature will solve, and why it's important.\n\n## Use Case\n\nPlease provide a use case or an example of how this feature will be used.\n\n## Alternatives Considered\n\nPlease describe any alternatives you have considered and why you believe this new feature is a better solution.\n\n## Additional Context\n\nPlease provide any additional information or context that might be relevant to this feature request.\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "# Pull Request Template\n\n## Description\n\nPlease describe the changes you have made and the purpose of the changes. If applicable, provide context or links to relevant issues or discussions.\n\n## Types of Changes\n\nWhat types of changes does your code introduce to the library?\n\n- [ ] Bugfix\n- [ ] New feature\n- [ ] Documentation update\n\n## Checklist\n\n- [ ] I have read the [contributing guidelines](https://github.com/fp-ts/core/blob/main/.github/CONTRIBUTING.md) for this repository\n- [ ] I have written tests for the changes I have made\n- [ ] I have run `pnpm coverage` and my code is 100% covered\n- [ ] I have updated the documentation (if applicable)\n- [ ] I agree to license my contribution under the MIT license\n\n## Additional Information\n\nIs there anything else you would like to add? Are there any questions that need to be answered before merging this pull request?\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: Main Flow\n\non:\n  push:\n    branches: [main]\n\n  # Allows you to run this workflow manually from the Actions tab\n  workflow_dispatch:\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    strategy:\n      matrix:\n        node-version: [16.17.1]\n\n    steps:\n      - uses: actions/checkout@v3\n        with:\n          fetch-depth: 0\n      - name: Use Node.js ${{ matrix.node-version }}\n        uses: actions/setup-node@v3\n        with:\n          node-version: ${{ matrix.node-version }}\n      - uses: pnpm/action-setup@v2.0.1\n        name: Install pnpm\n        id: pnpm-install\n        with:\n          version: 7\n          run_install: false\n      - name: Get pnpm store directory\n        id: pnpm-cache\n        run: |\n          echo \"::set-output name=pnpm_cache_dir::$(pnpm store path)\"\n      - uses: actions/cache@v3\n        name: Setup pnpm cache\n        with:\n          path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}\n          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}\n          restore-keys: |\n            ${{ runner.os }}-pnpm-store-\n      - run: pnpm install\n      - run: pnpm build\n      - run: pnpm test\n      - run: pnpm dtslint\n      - run: pnpm lint\n      - run: pnpm run docs\n      - name: Create Release Pull Request or Publish\n        id: changesets\n        uses: changesets/action@v1\n        with:\n          version: pnpm run version\n          publish: pnpm exec changeset publish\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}\n"
  },
  {
    "path": ".github/workflows/pr.yml",
    "content": "name: PR Flow\n\non:\n  pull_request:\n    branches:\n      - 'main'\n\n  # Allows you to run this workflow manually from the Actions tab\n  workflow_dispatch:\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    strategy:\n      matrix:\n        node-version: [16.17.1]\n\n    steps:\n      - uses: actions/checkout@v3\n        with:\n          fetch-depth: 0\n      - name: Use Node.js ${{ matrix.node-version }}\n        uses: actions/setup-node@v3\n        with:\n          node-version: ${{ matrix.node-version }}\n      - uses: pnpm/action-setup@v2.0.1\n        name: Install pnpm\n        id: pnpm-install\n        with:\n          version: 7\n          run_install: false\n      - name: Get pnpm store directory\n        id: pnpm-cache\n        run: |\n          echo \"::set-output name=pnpm_cache_dir::$(pnpm store path)\"\n      - uses: actions/cache@v3\n        name: Setup pnpm cache\n        with:\n          path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}\n          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}\n          restore-keys: |\n            ${{ runner.os }}-pnpm-store-\n      - run: pnpm install\n      - run: pnpm build\n      - run: pnpm test\n      - run: pnpm dtslint\n      - run: pnpm lint\n      - run: pnpm run docs\n"
  },
  {
    "path": ".gitignore",
    "content": "coverage/\n*.tsbuildinfo\nnode_modules/\nyarn-error.log\n.ultra.cache.json\n.DS_Store\ntmp/\nbuild/\ndist/\n.idea/"
  },
  {
    "path": ".gitpod.yml",
    "content": "tasks:\n  - init: npm install -g pnpm && pnpm && pnpm run build\ngithub:\n  prebuilds:\n    addCheck: true\nvscode:\n  extensions:\n    - dbaeumer.vscode-eslint\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\n  \"typescript.tsdk\": \"node_modules/typescript/lib\",\n  \"typescript.preferences.importModuleSpecifier\": \"non-relative\",\n  \"typescript.enablePromptUseWorkspaceTsdk\": true,\n  \"editor.formatOnSave\": true,\n  \"eslint.format.enable\": true,\n  \"[json]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[javascript]\": {\n    \"editor.defaultFormatter\": \"dbaeumer.vscode-eslint\"\n  },\n  \"[javascriptreact]\": {\n    \"editor.defaultFormatter\": \"dbaeumer.vscode-eslint\"\n  },\n  \"[typescript]\": {\n    \"editor.defaultFormatter\": \"dbaeumer.vscode-eslint\"\n  },\n  \"[typescriptreact]\": {\n    \"editor.defaultFormatter\": \"dbaeumer.vscode-eslint\"\n  },\n  \"eslint.validate\": [\"markdown\", \"javascript\", \"typescript\"],\n  \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n  },\n  \"editor.quickSuggestions\": {\n    \"other\": true,\n    \"comments\": false,\n    \"strings\": false\n  },\n  \"editor.acceptSuggestionOnCommitCharacter\": true,\n  \"editor.acceptSuggestionOnEnter\": \"on\",\n  \"editor.quickSuggestionsDelay\": 10,\n  \"editor.suggestOnTriggerCharacters\": true,\n  \"editor.tabCompletion\": \"off\",\n  \"editor.suggest.localityBonus\": true,\n  \"editor.suggestSelection\": \"recentlyUsed\",\n  \"editor.wordBasedSuggestions\": true,\n  \"editor.parameterHints.enabled\": true,\n  \"files.watcherExclude\": {\n    \"**/target\": true\n  },\n  \"files.insertFinalNewline\": true\n}\n"
  },
  {
    "path": ".vscode/tasks.json",
    "content": "{\n  \"version\": \"2.0.0\",\n  \"tasks\": [\n    {\n      \"label\": \"clean\",\n      \"type\": \"shell\",\n      \"command\": \"yarn clean\",\n      \"isBackground\": false,\n      \"problemMatcher\": []\n    },\n    {\n      \"label\": \"build-watch\",\n      \"type\": \"shell\",\n      \"command\": \"yarn build-watch\",\n      \"problemMatcher\": [\"$tsc-watch\"],\n      \"isBackground\": true,\n      \"presentation\": {\n        \"focus\": false,\n        \"panel\": \"shared\",\n        \"group\": \"dev\",\n        \"showReuseMessage\": true,\n        \"clear\": false\n      }\n    },\n    {\n      \"label\": \"build\",\n      \"type\": \"shell\",\n      \"command\": \"yarn build\",\n      \"problemMatcher\": [],\n      \"isBackground\": false\n    },\n    {\n      \"label\": \"test-watch\",\n      \"dependsOn\": [\"build-watch\"],\n      \"type\": \"shell\",\n      \"command\": \"yarn test\",\n      \"problemMatcher\": []\n    }\n  ]\n}\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# @fp-ts/core\n\n## 0.2.1\n\n### Patch Changes\n\n- [#59](https://github.com/fp-ts/core/pull/59) [`5efa9c03`](https://github.com/fp-ts/core/commit/5efa9c03572c9f39dd0e801dfe404e9e18d5fba2) Thanks [@gcanti](https://github.com/gcanti)! - Predicate: add more guards\n\n- [#60](https://github.com/fp-ts/core/pull/60) [`c48d2f56`](https://github.com/fp-ts/core/commit/c48d2f56063c31db5a42d426fa9a9ef270977843) Thanks [@gcanti](https://github.com/gcanti)! - add getOrThrowWith to Option, Either, These\n\n- [#57](https://github.com/fp-ts/core/pull/57) [`549509b8`](https://github.com/fp-ts/core/commit/549509b8a02a515becd514cfbb00044b313d5ede) Thanks [@gcanti](https://github.com/gcanti)! - Number: add remainder\n\n- [#56](https://github.com/fp-ts/core/pull/56) [`cf4918de`](https://github.com/fp-ts/core/commit/cf4918de74504ec59dd00df0ff251a549fb51284) Thanks [@gcanti](https://github.com/gcanti)! - ReadonlyArray: handle mutable arrays in isEmpty, isNonEmpty guards\n\n## 0.2.0\n\n### Minor Changes\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`b3e7ff34`](https://github.com/fp-ts/core/commit/b3e7ff34596b9cf90cc94c7349cf340fb0df82ef) Thanks [@gcanti](https://github.com/gcanti)! - Identity: remove exports except do notation ones\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`a99a23a1`](https://github.com/fp-ts/core/commit/a99a23a15ccd1c9d1f623f39d4727cb3ff0be3f7) Thanks [@gcanti](https://github.com/gcanti)! - Either: make orElse, orElseEither lazy and remove catchAll\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`31b5fffc`](https://github.com/fp-ts/core/commit/31b5fffc175f4740c8f31f05afba48b6b8cb9cd6) Thanks [@gcanti](https://github.com/gcanti)! - Option: remove fromThrowable\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`14de6de2`](https://github.com/fp-ts/core/commit/14de6de207c63d460ecabcb6b13f5d9abb697f05) Thanks [@gcanti](https://github.com/gcanti)! - Option: remove coproductEither\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`f3cc9d2c`](https://github.com/fp-ts/core/commit/f3cc9d2cf2440586f2681f447ae9056d94a631d7) Thanks [@gcanti](https://github.com/gcanti)! - rename `element` to `appendElement`\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`2bb91d1e`](https://github.com/fp-ts/core/commit/2bb91d1e15ec62bfa762bb17aec6c97305b94692) Thanks [@gcanti](https://github.com/gcanti)! - Function: flip apply\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`9569811e`](https://github.com/fp-ts/core/commit/9569811ea5506fb4206c1b9dbde7dbdbe7e9a8bc) Thanks [@gcanti](https://github.com/gcanti)! - Covariant: flip flap\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`ae3338c0`](https://github.com/fp-ts/core/commit/ae3338c091284e0af7b24e1be818a96d59a77f09) Thanks [@gcanti](https://github.com/gcanti)! - Either: rename `firstSuccessOf` to `firstRightOf`\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`a4a6ebbc`](https://github.com/fp-ts/core/commit/a4a6ebbcf73b453e526fbc42a76424732b8fdb23) Thanks [@gcanti](https://github.com/gcanti)! - remove `orElseSucceed`\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`99088b21`](https://github.com/fp-ts/core/commit/99088b21a5945cb744a380947ee79378f19766f3) Thanks [@gcanti](https://github.com/gcanti)! - remove `imap` from exports\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`d4fcf63e`](https://github.com/fp-ts/core/commit/d4fcf63e16f15ac86a96e89b0b47c7d2647a6fe6) Thanks [@gcanti](https://github.com/gcanti)! - Option: make orElse, orElseEither lazy and remove catchAll\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`bfb22498`](https://github.com/fp-ts/core/commit/bfb22498cb9287d40e231b4992937e3313fae1fe) Thanks [@gcanti](https://github.com/gcanti)! - Option: remove `compact`\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`4463f4f1`](https://github.com/fp-ts/core/commit/4463f4f1649ca2f984d715d0aa22055a3a8d6519) Thanks [@gcanti](https://github.com/gcanti)! - Option: change `firstSomeOf` signature\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`18f70fcb`](https://github.com/fp-ts/core/commit/18f70fcb18c5e8f26980fd88c1192808df241631) Thanks [@gcanti](https://github.com/gcanti)! - Either: remove `fromThrowable`\n\n### Patch Changes\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`ce345a8d`](https://github.com/fp-ts/core/commit/ce345a8dd5bae7694cdbdd1bf5056b337175810d) Thanks [@gcanti](https://github.com/gcanti)! - add default handler to `getOrThrow`\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`615d492e`](https://github.com/fp-ts/core/commit/615d492ea79b47472da256b4dea6f33835f24d23) Thanks [@gcanti](https://github.com/gcanti)! - algebraic operations: add support for bigint\n\n- [#55](https://github.com/fp-ts/core/pull/55) [`14f87fb3`](https://github.com/fp-ts/core/commit/14f87fb33061ef1e36a5695c0f28578c9f860cf1) Thanks [@gcanti](https://github.com/gcanti)! - Option: add `reduceAll`\n\n- [#51](https://github.com/fp-ts/core/pull/51) [`175d6b9e`](https://github.com/fp-ts/core/commit/175d6b9e93dbf6bfbea80b34a06f26ceb3d725aa) Thanks [@gcanti](https://github.com/gcanti)! - Option, Either, These: switch to interfaces\n\n- [#51](https://github.com/fp-ts/core/pull/51) [`3efb6d8a`](https://github.com/fp-ts/core/commit/3efb6d8a9a343ca177ec7bcc3e360974aec307cf) Thanks [@gcanti](https://github.com/gcanti)! - Function: add dual utility\n\n## 0.1.1\n\n### Patch Changes\n\n- [#48](https://github.com/fp-ts/core/pull/48) [`da0bae84`](https://github.com/fp-ts/core/commit/da0bae8487d59d78c5ba6470d37727ccc66538bb) Thanks [@gcanti](https://github.com/gcanti)! - change structural tracking\n\n## 0.1.0\n\n### Minor Changes\n\n- [#46](https://github.com/fp-ts/core/pull/46) [`0bd0d604`](https://github.com/fp-ts/core/commit/0bd0d60454642d7b1692d923c2d240b747ac797b) Thanks [@gcanti](https://github.com/gcanti)! - add modules from @fp-ts/data\n\n### Patch Changes\n\n- [#46](https://github.com/fp-ts/core/pull/46) [`3c256fa8`](https://github.com/fp-ts/core/commit/3c256fa8b9bbb4379ad51c5e48781deaaac2990a) Thanks [@gcanti](https://github.com/gcanti)! - Add tracking code for Option\n\n## next\n\n**Breaking changes**\n\n- remove `NonEmptyTraversable` module\n- `Semigroup`\n  - make `combine` binary\n  - make `combineMany` binary\n- `SemiCoproduct`\n  - make `coproduct` binary\n  - make `coproductMany` binary\n- `SemiProduct`\n  - make `product` binary\n  - make `productMany` binary\n  - rename `productFlatten` to `element`\n- `Order`\n  - make `compare` binary\n\n**New Features**\n\n- `Boolean`\n  - add `not` combinator\n- `Order`\n  - add `array` combinator\n  - add `bigint` instance\n- `Monoid`\n  - add `array`, `readonlyArray` combinators\n- `Semigroup`\n  - add `array`, `readonlyArray` combinators\n- new modules\n  - `typeclass/Equivalence`\n  - `typeclass/Filterable`\n  - `typeclass/TraversableFilterable`\n  - `Bigint`\n  - `Boolean`\n  - `Either`\n  - `Function`\n  - `Identity`\n  - `Number`\n  - `Option`\n  - `Ordering`\n  - `Predicate`\n  - `ReadonlyArray`\n  - `ReadonyRecord`\n  - `String`\n  - `Struct`\n  - `Symbol`\n  - `These`\n  - `Tuple`\n\n## 0.0.11\n\n### Patch Changes\n\n- [#39](https://github.com/fp-ts/core/pull/39) [`c27db5e7`](https://github.com/fp-ts/core/commit/c27db5e796071966a64af1a860b56e417f99423e) Thanks [@gcanti](https://github.com/gcanti)! - revert 0.0.10 changes\n\n## 0.0.10\n\n### Patch Changes\n\n- [#36](https://github.com/fp-ts/core/pull/36) [`51bb90bd`](https://github.com/fp-ts/core/commit/51bb90bd4f32bd878575a159a2bc0c8c3b3ff57b) Thanks [@gcanti](https://github.com/gcanti)! - remove readonly\n\n## 0.0.9\n\n### Patch Changes\n\n- [#33](https://github.com/fp-ts/core/pull/33) [`c8246ea5`](https://github.com/fp-ts/core/commit/c8246ea56c07d44507b90be49bc529ddee2847d6) Thanks [@gcanti](https://github.com/gcanti)! - remove Compactable, Filterable, TraversableFilterable and /data folder\n\n## 0.0.8\n\n### Patch Changes\n\n- [#29](https://github.com/fp-ts/core/pull/29) [`c2e0f09d`](https://github.com/fp-ts/core/commit/c2e0f09dc0d5aca2cc3c200adbe25991ff1a8c0c) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyAlternative: rename to SemiAlternative\n\n- [#29](https://github.com/fp-ts/core/pull/29) [`adbf4dbc`](https://github.com/fp-ts/core/commit/adbf4dbc1e6d8ea2d85e897de8048be7ac6dd88c) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyProduct: rename to SemiProduct\n\n- [#29](https://github.com/fp-ts/core/pull/29) [`07b7061b`](https://github.com/fp-ts/core/commit/07b7061bcef03d405a47777bc89e979c1b58e335) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyProduct: rename bindKind to andThenBind\n\n- [#29](https://github.com/fp-ts/core/pull/29) [`1f116d3d`](https://github.com/fp-ts/core/commit/1f116d3ddfbb26afd9e92b7001de7f1425774d3e) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyApplicative: rename to SemiApplicative\n\n- [#29](https://github.com/fp-ts/core/pull/29) [`d539285e`](https://github.com/fp-ts/core/commit/d539285e270d69bd995a3ebc4e98a84b74665f46) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyCoproduct: rename to SemiCoproduct\n\n## 0.0.7\n\n### Patch Changes\n\n- [#26](https://github.com/fp-ts/core/pull/26) [`2aa35975`](https://github.com/fp-ts/core/commit/2aa35975d2803377c0a629603b308e3c2c6448b9) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyTraversable: rename nonEmptyTraverse to traverseNonEmpty, nonEmptySequence to sequenceNonEmpty\n\n- [#26](https://github.com/fp-ts/core/pull/26) [`9d4ac0bb`](https://github.com/fp-ts/core/commit/9d4ac0bb2dc82a33a9959565b6af8289af0f4403) Thanks [@gcanti](https://github.com/gcanti)! - Traversable: add sequence as member\n\n- [#26](https://github.com/fp-ts/core/pull/26) [`eb6020ca`](https://github.com/fp-ts/core/commit/eb6020ca6b8d1cbe3cb4ead58ab9b54cc9ce82a3) Thanks [@gcanti](https://github.com/gcanti)! - Foldable: remove reduceRight from typeclass\n\n- [#28](https://github.com/fp-ts/core/pull/28) [`9f6a193e`](https://github.com/fp-ts/core/commit/9f6a193e4580aadc18ccc172a9e3cf6ffde5c19d) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyCoproduct / Coproduct: fix getSemigroup / getMonoid type params\n\n- [#26](https://github.com/fp-ts/core/pull/26) [`29a94c17`](https://github.com/fp-ts/core/commit/29a94c17f0f018627892f1749acbdea07471374f) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyProduct: rename struct to nonEmptyStruct\n\n- [#26](https://github.com/fp-ts/core/pull/26) [`577f9597`](https://github.com/fp-ts/core/commit/577f9597db0a53728fca14e9a945e1e0d7164957) Thanks [@gcanti](https://github.com/gcanti)! - Foldable: add a default `reduceRight` implementation\n\n- [#26](https://github.com/fp-ts/core/pull/26) [`fc914c93`](https://github.com/fp-ts/core/commit/fc914c9319017abd3da4b11987342fbf56806eca) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyTraversable: add sequenceNonEmpty as member\n\n- [#26](https://github.com/fp-ts/core/pull/26) [`fc4d0aae`](https://github.com/fp-ts/core/commit/fc4d0aaef2aeca6b63f10432695c62e808c6310b) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyProduct: rename tuple to nonEmptyTuple\n\n## 0.0.6\n\n### Patch Changes\n\n- [#22](https://github.com/fp-ts/core/pull/22) [`e71d3d57`](https://github.com/fp-ts/core/commit/e71d3d57b0869ab3283a7bb68e76452bc0a2ffba) Thanks [@gcanti](https://github.com/gcanti)! - rename HKT params\n\n## 0.0.5\n\n### Patch Changes\n\n- [#18](https://github.com/fp-ts/core/pull/18) [`be638f44`](https://github.com/fp-ts/core/commit/be638f44764484c8d93943d916d3fc0285466cbd) Thanks [@gcanti](https://github.com/gcanti)! - Semigroup: fix reverse implementation\n\n- [#18](https://github.com/fp-ts/core/pull/18) [`ae9715f6`](https://github.com/fp-ts/core/commit/ae9715f6670fda76e25c955cdaab17c65af098ba) Thanks [@gcanti](https://github.com/gcanti)! - Foldable / FoldableWithIndex: add compositions\n\n- [#18](https://github.com/fp-ts/core/pull/18) [`ba899d76`](https://github.com/fp-ts/core/commit/ba899d76debfd15031d0fff9079332fd33394f9b) Thanks [@gcanti](https://github.com/gcanti)! - Foldable / FlodableWithIndex: curry toReadonlyArrayWith and add toReadonlyArray\n\n- [#18](https://github.com/fp-ts/core/pull/18) [`2d30a185`](https://github.com/fp-ts/core/commit/2d30a1852227ac4f5279ebafef46ac527f5048ee) Thanks [@gcanti](https://github.com/gcanti)! - add FunctorWithIndex module\n\n- [#18](https://github.com/fp-ts/core/pull/18) [`9c531794`](https://github.com/fp-ts/core/commit/9c531794ca69346f38740e002687e4bd55fcb6b9) Thanks [@gcanti](https://github.com/gcanti)! - Semigroupal: remove useless zipWith export\n\n- [#18](https://github.com/fp-ts/core/pull/18) [`9683f82d`](https://github.com/fp-ts/core/commit/9683f82d68e35bfa471a6b39d59830b078d868c9) Thanks [@gcanti](https://github.com/gcanti)! - Bounded: swap maximum, minimum arguments in fromSortable\n\n## 0.0.4\n\n### Patch Changes\n\n- [#14](https://github.com/fp-ts/core/pull/14) [`1cac5547`](https://github.com/fp-ts/core/commit/1cac5547815673308916236780b94c6263825cde) Thanks [@gcanti](https://github.com/gcanti)! - rename Succeed typeclass to Pointed / of\n\n- [#14](https://github.com/fp-ts/core/pull/14) [`6c9be695`](https://github.com/fp-ts/core/commit/6c9be6950e8bb004802dce959f8d133f7e911aa7) Thanks [@gcanti](https://github.com/gcanti)! - make all typeclass operations pipeable\n\n- [#14](https://github.com/fp-ts/core/pull/14) [`8ae84df9`](https://github.com/fp-ts/core/commit/8ae84df993f63d1255a9b40a614fcc79fea8ad68) Thanks [@gcanti](https://github.com/gcanti)! - SemigroupKind: fix combineKind signature\n\n- [#14](https://github.com/fp-ts/core/pull/14) [`51d62040`](https://github.com/fp-ts/core/commit/51d62040bf25ddc8e7911171d48b60282a35fb26) Thanks [@gcanti](https://github.com/gcanti)! - Ordering: remove sign function\n\n- [#14](https://github.com/fp-ts/core/pull/14) [`89665e87`](https://github.com/fp-ts/core/commit/89665e8768e1c9fac1894c12b74e5941341a9473) Thanks [@gcanti](https://github.com/gcanti)! - remove Show typeclass\n\n## 0.0.3\n\n### Patch Changes\n\n- [#12](https://github.com/fp-ts/core/pull/12) [`7c6fa2c4`](https://github.com/fp-ts/core/commit/7c6fa2c4992dd3aeffbd1e7a9aeb564a62c5f149) Thanks [@mikearnaldi](https://github.com/mikearnaldi)! - type class refactoring\n\n## 0.0.2\n\n### Patch Changes\n\n- [#8](https://github.com/fp-ts/core/pull/8) [`79b1237c`](https://github.com/fp-ts/core/commit/79b1237c22a16f8354f8c5f086922585ce26b572) Thanks [@mikearnaldi](https://github.com/mikearnaldi)! - Fix package json repository urls\n\n## 0.0.1\n\n### Patch Changes\n\n- [#1](https://github.com/fp-ts/core/pull/1) [`65983dd9`](https://github.com/fp-ts/core/commit/65983dd99a04cd2d1d6f503dabaa600df5c82d17) Thanks [@mikearnaldi](https://github.com/mikearnaldi)! - Dual ESM-CJS Support\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017-present Giulio Canti\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "**Announcement**: following the [official decision](https://dev.to/effect-ts/a-bright-future-for-effect-455m) to merge the `fp-ts` project with the Effect-TS ecosystem, active development has been transferred to the repository https://github.com/Effect-TS/data.\n"
  },
  {
    "path": "benchmark/Number/lessThan.ts",
    "content": "import { dual } from \"@fp-ts/core/Function\";\nimport { lessThan } from \"@fp-ts/core/Number\"\nimport * as Benchmark from \"benchmark\"\n\n/*\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst lessThanBaseline: {\n  (that: number): (self: number) => boolean;\n  (self: number, that: number): boolean;\n} = dual(2, (self: number, that: number): boolean => self < that)\n\nsuite\n  .add(\"lessThanBaseline\", function() {\n    lessThanBaseline(2, 1)\n  })\n  .add(\"lessThan\", function() {\n    lessThan(2, 1)\n  })\n  .on(\"cycle\", function(event: any) {\n    console.log(String(event.target))\n  })\n  .on(\"complete\", function(this: any) {\n    console.log(\"Fastest is \" + this.filter(\"fastest\").map(\"name\"))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "benchmark/These/product.ts",
    "content": "import { Product, right, fail } from \"@fp-ts/core/These\"\nimport * as Benchmark from \"benchmark\"\n\n/*\n*/\n\nconst suite = new Benchmark.Suite()\n\nsuite\n  .add(\"Product.product\", function() {\n    Product.product(right(1), fail('e'))\n  })\n  .add(\"Product.productAll\", function() {\n    Product.productAll([right(1), fail('e')])\n  })\n  .on(\"cycle\", function(event: any) {\n    console.log(String(event.target))\n  })\n  .on(\"complete\", function(this: any) {\n    console.log(\"Fastest is \" + this.filter(\"fastest\").map(\"name\"))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "benchmark/dual.ts",
    "content": "import { sum } from \"@fp-ts/core/Number\"\nimport * as Benchmark from \"benchmark\"\n\n/*\nsum(a, b) x 39,807,035 ops/sec ±0.79% (87 runs sampled)\nbinary(a, b) x 745,618,052 ops/sec ±0.53% (91 runs sampled)\nsum(b)(a) x 2,423,147 ops/sec ±1.50% (82 runs sampled)\ncurried(b)(a) x 737,608,819 ops/sec ±0.60% (88 runs sampled)\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst binary = (a: number, b: number): number =>  a + b\n\nconst curried = (a: number) => (b: number): number =>  a + b\n\nsuite\n  .add(\"sum(a, b)\", function() {\n    sum(1, 2)\n  })\n  .add(\"binary(a, b)\", function() {\n    binary(1, 2)\n  })\n  .add(\"sum(b)(a)\", function() {\n    sum(2)(1)\n  })\n  .add(\"curried(b)(a)\", function() {\n    curried(2)(1)\n  })\n  .on(\"cycle\", function(event: any) {\n    console.log(String(event.target))\n  })\n  .on(\"complete\", function(this: any) {\n    console.log(\"Fastest is \" + this.filter(\"fastest\").map(\"name\"))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "benchmark/sumAll.ts",
    "content": "import { fromIterable } from \"@fp-ts/core/internal/ReadonlyArray\"\nimport { sumAll } from \"@fp-ts/core/Number\"\nimport * as Benchmark from \"benchmark\"\n\n/*\nsumAll x 98,318,148 ops/sec ±0.46% (91 runs sampled)\nsum x 104,495,149 ops/sec ±0.76% (90 runs sampled)\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst sum = (collection: Iterable<number>): number => fromIterable(collection).reduce((a, b) => a + b, 0)\n\nsuite\n  .add(\"sumAll\", function() {\n    sumAll([1, 2, 3, 4, 5])\n  })\n  .add(\"sum\", function() {\n    sum([1, 2, 3, 4, 5])\n  })\n  .on(\"cycle\", function(event: any) {\n    console.log(String(event.target))\n  })\n  .on(\"complete\", function(this: any) {\n    console.log(\"Fastest is \" + this.filter(\"fastest\").map(\"name\"))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "benchmark/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"strict\": true,\n    \"module\": \"commonjs\",\n    \"paths\": {\n      \"@fp-ts/core\": [\"../src/index.ts\"],\n      \"@fp-ts/core/test/*\": [\"../test/*\"],\n      \"@fp-ts/core/examples/*\": [\"../examples/*\"],\n      \"@fp-ts/core/*\": [\"../src/*\"]\n    }\n  }\n}\n"
  },
  {
    "path": "docs/_config.yml",
    "content": "remote_theme: mikearnaldi/just-the-docs\n\n# Enable or disable the site search\nsearch_enabled: true\n\n# Aux links for the upper right navigation\naux_links:\n  \"Docs\":\n    - \"//fp-ts.github.io/core\"\n  \"API Reference\":\n    - \"//fp-ts.github.io/core/docs/modules\"\n  \"GitHub\":\n    - \"//github.com/fp-ts/core\"\n"
  },
  {
    "path": "docs/_sass/custom/custom.scss",
    "content": "$fp-ts-blue-000: #0088e6;\n$fp-ts-blue-100: #0075c5;\n\n$link-color: $fp-ts-blue-000;\n$btn-primary-color: $fp-ts-blue-100;\n"
  },
  {
    "path": "docs/index.md",
    "content": "---\ntitle: Introduction\npermalink: /\nnav_order: 1\nhas_children: false\nhas_toc: false\n---\n\n<img alt=\"fp-ts logo\" src=\"./fp-ts-logo.png\" style=\"display: block; width: 200px; margin-bottom: 2em;\">\n\n# Typed functional programming in TypeScript\n\n`@fp-ts/core` provides developers with popular patterns and reliable abstractions from typed functional languages in TypeScript.\n{: .fs-6 .fw-300 }\n\n**Disclaimer**. Teaching functional programming is out of scope of this project, so the documentation assumes you already know what FP is.\n"
  },
  {
    "path": "docs/modules/Bigint.ts.md",
    "content": "---\ntitle: Bigint.ts\nnav_order: 1\nparent: Modules\n---\n\n## Bigint overview\n\nThis module provides utility functions and type class instances for working with the `bigint` type in TypeScript.\nIt includes functions for basic arithmetic operations, as well as type class instances for\n`Equivalence`, `Order`, `Semigroup`, and `Monoid`.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [guards](#guards)\n  - [isBigint](#isbigint)\n- [instances](#instances)\n  - [Equivalence](#equivalence)\n  - [MonoidMultiply](#monoidmultiply)\n  - [MonoidSum](#monoidsum)\n  - [Order](#order)\n  - [SemigroupMax](#semigroupmax)\n  - [SemigroupMin](#semigroupmin)\n  - [SemigroupMultiply](#semigroupmultiply)\n  - [SemigroupSum](#semigroupsum)\n- [math](#math)\n  - [decrement](#decrement)\n  - [divide](#divide)\n  - [increment](#increment)\n  - [multiply](#multiply)\n  - [multiplyAll](#multiplyall)\n  - [sign](#sign)\n  - [subtract](#subtract)\n  - [sum](#sum)\n  - [sumAll](#sumall)\n- [predicates](#predicates)\n  - [between](#between)\n  - [greaterThan](#greaterthan)\n  - [greaterThanOrEqualTo](#greaterthanorequalto)\n  - [lessThan](#lessthan)\n  - [lessThanOrEqualTo](#lessthanorequalto)\n- [utils](#utils)\n  - [clamp](#clamp)\n  - [max](#max)\n  - [min](#min)\n\n---\n\n# guards\n\n## isBigint\n\nTests if a value is a `bigint`.\n\n**Signature**\n\n```ts\nexport declare const isBigint: (u: unknown) => u is bigint\n```\n\n**Example**\n\n```ts\nimport { isBigint } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(isBigint(1n), true)\nassert.deepStrictEqual(isBigint(1), false)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Equivalence\n\n**Signature**\n\n```ts\nexport declare const Equivalence: equivalence.Equivalence<bigint>\n```\n\nAdded in v1.0.0\n\n## MonoidMultiply\n\n`bigint` monoid under multiplication.\n\nThe `empty` value is `1n`.\n\n**Signature**\n\n```ts\nexport declare const MonoidMultiply: monoid.Monoid<bigint>\n```\n\n**Example**\n\n```ts\nimport { MonoidMultiply } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(MonoidMultiply.combine(2n, 3n), 6n)\nassert.deepStrictEqual(MonoidMultiply.combine(2n, MonoidMultiply.empty), 2n)\n```\n\nAdded in v1.0.0\n\n## MonoidSum\n\n`bigint` monoid under addition.\n\nThe `empty` value is `0n`.\n\n**Signature**\n\n```ts\nexport declare const MonoidSum: monoid.Monoid<bigint>\n```\n\n**Example**\n\n```ts\nimport { MonoidSum } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(MonoidSum.combine(2n, 3n), 5n)\nassert.deepStrictEqual(MonoidSum.combine(2n, MonoidSum.empty), 2n)\n```\n\nAdded in v1.0.0\n\n## Order\n\n**Signature**\n\n```ts\nexport declare const Order: order.Order<bigint>\n```\n\nAdded in v1.0.0\n\n## SemigroupMax\n\nA `Semigroup` that uses the maximum between two values.\n\n**Signature**\n\n```ts\nexport declare const SemigroupMax: semigroup.Semigroup<bigint>\n```\n\n**Example**\n\n```ts\nimport { SemigroupMax } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(SemigroupMax.combine(2n, 3n), 3n)\n```\n\nAdded in v1.0.0\n\n## SemigroupMin\n\nA `Semigroup` that uses the minimum between two values.\n\n**Signature**\n\n```ts\nexport declare const SemigroupMin: semigroup.Semigroup<bigint>\n```\n\n**Example**\n\n```ts\nimport { SemigroupMin } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(SemigroupMin.combine(2n, 3n), 2n)\n```\n\nAdded in v1.0.0\n\n## SemigroupMultiply\n\n`bigint` semigroup under multiplication.\n\n**Signature**\n\n```ts\nexport declare const SemigroupMultiply: semigroup.Semigroup<bigint>\n```\n\nAdded in v1.0.0\n\n## SemigroupSum\n\n`bigint` semigroup under addition.\n\n**Signature**\n\n```ts\nexport declare const SemigroupSum: semigroup.Semigroup<bigint>\n```\n\n**Example**\n\n```ts\nimport { SemigroupSum } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(SemigroupSum.combine(2n, 3n), 5n)\n```\n\nAdded in v1.0.0\n\n# math\n\n## decrement\n\nDecrements a number by `1n`.\n\n**Signature**\n\n```ts\nexport declare const decrement: (n: bigint) => bigint\n```\n\n**Example**\n\n```ts\nimport { decrement } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(decrement(3n), 2n)\n```\n\nAdded in v1.0.0\n\n## divide\n\nProvides a division operation on `bigint`s.\n\nIf the dividend is not a multiple of the divisor the result will be a `bigint` value\nwhich represents the integer division rounded down to the nearest integer.\n\n**Signature**\n\n```ts\nexport declare const divide: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }\n```\n\n**Example**\n\n```ts\nimport { divide } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(divide(6n, 3n), 2n)\nassert.deepStrictEqual(divide(6n, 4n), 1n)\n```\n\nAdded in v1.0.0\n\n## increment\n\nReturns the result of adding `1n` to a given number.\n\n**Signature**\n\n```ts\nexport declare const increment: (n: bigint) => bigint\n```\n\n**Example**\n\n```ts\nimport { increment } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(increment(2n), 3n)\n```\n\nAdded in v1.0.0\n\n## multiply\n\nProvides a multiplication operation on `bigint`s.\n\n**Signature**\n\n```ts\nexport declare const multiply: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }\n```\n\n**Example**\n\n```ts\nimport { multiply } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(multiply(2n, 3n), 6n)\n```\n\nAdded in v1.0.0\n\n## multiplyAll\n\nTakes an `Iterable` of `bigint`s and returns their multiplication as a single `number`.\n\n**Signature**\n\n```ts\nexport declare const multiplyAll: (collection: Iterable<bigint>) => bigint\n```\n\n**Example**\n\n```ts\nimport { multiplyAll } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(multiplyAll([2n, 3n, 4n]), 24n)\n```\n\nAdded in v1.0.0\n\n## sign\n\nDetermines the sign of a given `bigint`.\n\n**Signature**\n\n```ts\nexport declare const sign: (n: bigint) => Ordering\n```\n\n**Example**\n\n```ts\nimport { sign } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(sign(-5n), -1)\nassert.deepStrictEqual(sign(0n), 0)\nassert.deepStrictEqual(sign(5n), 1)\n```\n\nAdded in v1.0.0\n\n## subtract\n\nProvides a subtraction operation on `bigint`s.\n\n**Signature**\n\n```ts\nexport declare const subtract: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }\n```\n\n**Example**\n\n```ts\nimport { subtract } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(subtract(2n, 3n), -1n)\n```\n\nAdded in v1.0.0\n\n## sum\n\nProvides an addition operation on `bigint`s.\n\n**Signature**\n\n```ts\nexport declare const sum: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }\n```\n\n**Example**\n\n```ts\nimport { sum } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(sum(2n, 3n), 5n)\n```\n\nAdded in v1.0.0\n\n## sumAll\n\nTakes an `Iterable` of `bigint`s and returns their sum as a single `bigint\n\n**Signature**\n\n```ts\nexport declare const sumAll: (collection: Iterable<bigint>) => bigint\n```\n\n**Example**\n\n```ts\nimport { sumAll } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(sumAll([2n, 3n, 4n]), 9n)\n```\n\nAdded in v1.0.0\n\n# predicates\n\n## between\n\nChecks if a `bigint` is between a `minimum` and `maximum` value (inclusive).\n\n**Signature**\n\n```ts\nexport declare const between: {\n  (minimum: bigint, maximum: bigint): (self: bigint) => boolean\n  (self: bigint, minimum: bigint, maximum: bigint): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { between } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(between(0n, 5n)(3n), true)\nassert.deepStrictEqual(between(0n, 5n)(-1n), false)\nassert.deepStrictEqual(between(0n, 5n)(6n), false)\n```\n\nAdded in v1.0.0\n\n## greaterThan\n\nReturns `true` if the first argument is greater than the second, otherwise `false`.\n\n**Signature**\n\n```ts\nexport declare const greaterThan: { (that: bigint): (self: bigint) => boolean; (self: bigint, that: bigint): boolean }\n```\n\n**Example**\n\n```ts\nimport { greaterThan } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(greaterThan(2n, 3n), false)\nassert.deepStrictEqual(greaterThan(3n, 3n), false)\nassert.deepStrictEqual(greaterThan(4n, 3n), true)\n```\n\nAdded in v1.0.0\n\n## greaterThanOrEqualTo\n\nReturns a function that checks if a given `bigint` is greater than or equal to the provided one.\n\n**Signature**\n\n```ts\nexport declare const greaterThanOrEqualTo: {\n  (that: bigint): (self: bigint) => boolean\n  (self: bigint, that: bigint): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { greaterThanOrEqualTo } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(greaterThanOrEqualTo(2n, 3n), false)\nassert.deepStrictEqual(greaterThanOrEqualTo(3n, 3n), true)\nassert.deepStrictEqual(greaterThanOrEqualTo(4n, 3n), true)\n```\n\nAdded in v1.0.0\n\n## lessThan\n\nReturns `true` if the first argument is less than the second, otherwise `false`.\n\n**Signature**\n\n```ts\nexport declare const lessThan: { (that: bigint): (self: bigint) => boolean; (self: bigint, that: bigint): boolean }\n```\n\n**Example**\n\n```ts\nimport { lessThan } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(lessThan(2n, 3n), true)\nassert.deepStrictEqual(lessThan(3n, 3n), false)\nassert.deepStrictEqual(lessThan(4n, 3n), false)\n```\n\nAdded in v1.0.0\n\n## lessThanOrEqualTo\n\nReturns a function that checks if a given `bigint` is less than or equal to the provided one.\n\n**Signature**\n\n```ts\nexport declare const lessThanOrEqualTo: {\n  (that: bigint): (self: bigint) => boolean\n  (self: bigint, that: bigint): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { lessThanOrEqualTo } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(lessThanOrEqualTo(2n, 3n), true)\nassert.deepStrictEqual(lessThanOrEqualTo(3n, 3n), true)\nassert.deepStrictEqual(lessThanOrEqualTo(4n, 3n), false)\n```\n\nAdded in v1.0.0\n\n# utils\n\n## clamp\n\nRestricts the given `bigint` to be within the range specified by the `minimum` and `maximum` values.\n\n- If the `bigint` is less than the `minimum` value, the function returns the `minimum` value.\n- If the `bigint` is greater than the `maximum` value, the function returns the `maximum` value.\n- Otherwise, it returns the original `bigint`.\n\n**Signature**\n\n```ts\nexport declare const clamp: {\n  (minimum: bigint, maximum: bigint): (self: bigint) => bigint\n  (self: bigint, minimum: bigint, maximum: bigint): bigint\n}\n```\n\n**Example**\n\n```ts\nimport { clamp } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(clamp(0n, 5n)(3n), 3n)\nassert.deepStrictEqual(clamp(0n, 5n)(-1n), 0n)\nassert.deepStrictEqual(clamp(0n, 5n)(6n), 5n)\n```\n\nAdded in v1.0.0\n\n## max\n\nReturns the maximum between two `bigint`s.\n\n**Signature**\n\n```ts\nexport declare const max: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }\n```\n\n**Example**\n\n```ts\nimport { max } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(max(2n, 3n), 3n)\n```\n\nAdded in v1.0.0\n\n## min\n\nReturns the minimum between two `bigint`s.\n\n**Signature**\n\n```ts\nexport declare const min: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }\n```\n\n**Example**\n\n```ts\nimport { min } from '@fp-ts/core/Bigint'\n\nassert.deepStrictEqual(min(2n, 3n), 2n)\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Boolean.ts.md",
    "content": "---\ntitle: Boolean.ts\nnav_order: 2\nparent: Modules\n---\n\n## Boolean overview\n\nThis module provides utility functions and type class instances for working with the `boolean` type in TypeScript.\nIt includes functions for basic boolean operations, as well as type class instances for\n`Equivalence`, `Order`, `Semigroup`, and `Monoid`.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [and](#and)\n  - [eqv](#eqv)\n  - [implies](#implies)\n  - [nand](#nand)\n  - [nor](#nor)\n  - [not](#not)\n  - [or](#or)\n  - [xor](#xor)\n- [guards](#guards)\n  - [isBoolean](#isboolean)\n- [instances](#instances)\n  - [Equivalence](#equivalence)\n  - [MonoidAll](#monoidall)\n  - [MonoidAny](#monoidany)\n  - [MonoidEqv](#monoideqv)\n  - [MonoidXor](#monoidxor)\n  - [Order](#order)\n  - [SemigroupAll](#semigroupall)\n  - [SemigroupAny](#semigroupany)\n  - [SemigroupEqv](#semigroupeqv)\n  - [SemigroupXor](#semigroupxor)\n- [pattern matching](#pattern-matching)\n  - [match](#match)\n- [utils](#utils)\n  - [all](#all)\n  - [any](#any)\n\n---\n\n# combinators\n\n## and\n\nCombines two boolean using AND: `self && that`.\n\n**Signature**\n\n```ts\nexport declare const and: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }\n```\n\n**Example**\n\n```ts\nimport { and } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(and(true, true), true)\nassert.deepStrictEqual(and(true, false), false)\nassert.deepStrictEqual(and(false, true), false)\nassert.deepStrictEqual(and(false, false), false)\n```\n\nAdded in v1.0.0\n\n## eqv\n\nCombines two booleans using EQV (aka XNOR): `!xor(self, that)`.\n\n**Signature**\n\n```ts\nexport declare const eqv: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }\n```\n\n**Example**\n\n```ts\nimport { eqv } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(eqv(true, true), true)\nassert.deepStrictEqual(eqv(true, false), false)\nassert.deepStrictEqual(eqv(false, true), false)\nassert.deepStrictEqual(eqv(false, false), true)\n```\n\nAdded in v1.0.0\n\n## implies\n\nCombines two booleans using an implication: `(!self || that)`.\n\n**Signature**\n\n```ts\nexport declare const implies: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }\n```\n\n**Example**\n\n```ts\nimport { implies } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(implies(true, true), true)\nassert.deepStrictEqual(implies(true, false), false)\nassert.deepStrictEqual(implies(false, true), true)\nassert.deepStrictEqual(implies(false, false), true)\n```\n\nAdded in v1.0.0\n\n## nand\n\nCombines two boolean using NAND: `!(self && that)`.\n\n**Signature**\n\n```ts\nexport declare const nand: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }\n```\n\n**Example**\n\n```ts\nimport { nand } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(nand(true, true), false)\nassert.deepStrictEqual(nand(true, false), true)\nassert.deepStrictEqual(nand(false, true), true)\nassert.deepStrictEqual(nand(false, false), true)\n```\n\nAdded in v1.0.0\n\n## nor\n\nCombines two booleans using NOR: `!(self || that)`.\n\n**Signature**\n\n```ts\nexport declare const nor: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }\n```\n\n**Example**\n\n```ts\nimport { nor } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(nor(true, true), false)\nassert.deepStrictEqual(nor(true, false), false)\nassert.deepStrictEqual(nor(false, true), false)\nassert.deepStrictEqual(nor(false, false), true)\n```\n\nAdded in v1.0.0\n\n## not\n\nNegates the given boolean: `!self`\n\n**Signature**\n\n```ts\nexport declare const not: (self: boolean) => boolean\n```\n\n**Example**\n\n```ts\nimport { not } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(not(true), false)\nassert.deepStrictEqual(not(false), true)\n```\n\nAdded in v1.0.0\n\n## or\n\nCombines two boolean using OR: `self || that`.\n\n**Signature**\n\n```ts\nexport declare const or: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }\n```\n\n**Example**\n\n```ts\nimport { or } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(or(true, true), true)\nassert.deepStrictEqual(or(true, false), true)\nassert.deepStrictEqual(or(false, true), true)\nassert.deepStrictEqual(or(false, false), false)\n```\n\nAdded in v1.0.0\n\n## xor\n\nCombines two booleans using XOR: `(!self && that) || (self && !that)`.\n\n**Signature**\n\n```ts\nexport declare const xor: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }\n```\n\n**Example**\n\n```ts\nimport { xor } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(xor(true, true), false)\nassert.deepStrictEqual(xor(true, false), true)\nassert.deepStrictEqual(xor(false, true), true)\nassert.deepStrictEqual(xor(false, false), false)\n```\n\nAdded in v1.0.0\n\n# guards\n\n## isBoolean\n\nTests if a value is a `boolean`.\n\n**Signature**\n\n```ts\nexport declare const isBoolean: (input: unknown) => input is boolean\n```\n\n**Example**\n\n```ts\nimport { isBoolean } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(isBoolean(true), true)\nassert.deepStrictEqual(isBoolean('true'), false)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Equivalence\n\n**Signature**\n\n```ts\nexport declare const Equivalence: equivalence.Equivalence<boolean>\n```\n\nAdded in v1.0.0\n\n## MonoidAll\n\n`boolean` monoid under conjunction, see also {@link SemigroupAll}.\n\nThe `empty` value is `true`.\n\n**Signature**\n\n```ts\nexport declare const MonoidAll: monoid.Monoid<boolean>\n```\n\nAdded in v1.0.0\n\n## MonoidAny\n\n`boolean` monoid under disjunction, see also {@link SemigroupAny}.\n\nThe `empty` value is `false`.\n\n**Signature**\n\n```ts\nexport declare const MonoidAny: monoid.Monoid<boolean>\n```\n\nAdded in v1.0.0\n\n## MonoidEqv\n\n`boolean` monoid under equivalence.\n\nThe `empty` value is `true`.\n\n**Signature**\n\n```ts\nexport declare const MonoidEqv: monoid.Monoid<boolean>\n```\n\nAdded in v1.0.0\n\n## MonoidXor\n\n`boolean` monoid under exclusive disjunction, see also {@link SemigroupXor}.\n\nThe `empty` value is `false`.\n\n**Signature**\n\n```ts\nexport declare const MonoidXor: monoid.Monoid<boolean>\n```\n\nAdded in v1.0.0\n\n## Order\n\n**Signature**\n\n```ts\nexport declare const Order: order.Order<boolean>\n```\n\nAdded in v1.0.0\n\n## SemigroupAll\n\n`boolean` semigroup under conjunction.\n\n**Signature**\n\n```ts\nexport declare const SemigroupAll: semigroup.Semigroup<boolean>\n```\n\n**Example**\n\n```ts\nimport { SemigroupAll } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(SemigroupAll.combine(true, true), true)\nassert.deepStrictEqual(SemigroupAll.combine(true, false), false)\nassert.deepStrictEqual(SemigroupAll.combine(false, true), false)\nassert.deepStrictEqual(SemigroupAll.combine(false, false), false)\n```\n\nAdded in v1.0.0\n\n## SemigroupAny\n\n`boolean` semigroup under disjunction.\n\n**Signature**\n\n```ts\nexport declare const SemigroupAny: semigroup.Semigroup<boolean>\n```\n\n**Example**\n\n```ts\nimport { SemigroupAny } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(SemigroupAny.combine(true, true), true)\nassert.deepStrictEqual(SemigroupAny.combine(true, false), true)\nassert.deepStrictEqual(SemigroupAny.combine(false, true), true)\nassert.deepStrictEqual(SemigroupAny.combine(false, false), false)\n```\n\nAdded in v1.0.0\n\n## SemigroupEqv\n\n`boolean` semigroup under equivalence.\n\n**Signature**\n\n```ts\nexport declare const SemigroupEqv: semigroup.Semigroup<boolean>\n```\n\n**Example**\n\n```ts\nimport { SemigroupEqv } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(SemigroupEqv.combine(true, true), true)\nassert.deepStrictEqual(SemigroupEqv.combine(true, false), false)\nassert.deepStrictEqual(SemigroupEqv.combine(false, true), false)\nassert.deepStrictEqual(SemigroupEqv.combine(false, false), true)\n```\n\nAdded in v1.0.0\n\n## SemigroupXor\n\n`boolean` semigroup under exclusive disjunction.\n\n**Signature**\n\n```ts\nexport declare const SemigroupXor: semigroup.Semigroup<boolean>\n```\n\n**Example**\n\n```ts\nimport { SemigroupXor } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(SemigroupXor.combine(true, true), false)\nassert.deepStrictEqual(SemigroupXor.combine(true, false), true)\nassert.deepStrictEqual(SemigroupXor.combine(false, true), true)\nassert.deepStrictEqual(SemigroupXor.combine(false, false), false)\n```\n\nAdded in v1.0.0\n\n# pattern matching\n\n## match\n\nThis function returns the result of either of the given functions depending on the value of the boolean parameter.\nIt is useful when you have to run one of two functions depending on the boolean value.\n\n**Signature**\n\n```ts\nexport declare const match: {\n  <A, B = A>(onFalse: LazyArg<A>, onTrue: LazyArg<B>): (value: boolean) => A | B\n  <A, B>(value: boolean, onFalse: LazyArg<A>, onTrue: LazyArg<B>): A | B\n}\n```\n\n**Example**\n\n```ts\nimport * as B from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(\n  B.match(\n    true,\n    () => \"It's false!\",\n    () => \"It's true!\"\n  ),\n  \"It's true!\"\n)\n```\n\nAdded in v1.0.0\n\n# utils\n\n## all\n\nThis utility function is used to check if all the elements in a collection of boolean values are `true`.\n\n**Signature**\n\n```ts\nexport declare const all: (collection: Iterable<boolean>) => boolean\n```\n\n**Example**\n\n```ts\nimport { all } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(all([true, true, true]), true)\nassert.deepStrictEqual(all([true, false, true]), false)\n```\n\nAdded in v1.0.0\n\n## any\n\nThis utility function is used to check if at least one of the elements in a collection of boolean values is `true`.\n\n**Signature**\n\n```ts\nexport declare const any: (collection: Iterable<boolean>) => boolean\n```\n\n**Example**\n\n```ts\nimport { any } from '@fp-ts/core/Boolean'\n\nassert.deepStrictEqual(any([true, false, true]), true)\nassert.deepStrictEqual(any([false, false, false]), false)\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Either.ts.md",
    "content": "---\ntitle: Either.ts\nnav_order: 3\nparent: Modules\n---\n\n## Either overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n- [combining](#combining)\n  - [all](#all)\n  - [andThenDiscard](#andthendiscard)\n  - [flatMap](#flatmap)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatMapOption](#flatmapoption)\n  - [getFirstLeftMonoid](#getfirstleftmonoid)\n  - [getFirstLeftSemigroup](#getfirstleftsemigroup)\n  - [getFirstRightSemigroup](#getfirstrightsemigroup)\n  - [zipWith](#zipwith)\n- [constructors](#constructors)\n  - [left](#left)\n  - [of](#of)\n  - [right](#right)\n- [conversions](#conversions)\n  - [fromIterable](#fromiterable)\n  - [fromOption](#fromoption)\n  - [getLeft](#getleft)\n  - [getRight](#getright)\n  - [toArray](#toarray)\n  - [toOption](#tooption)\n  - [toRefinement](#torefinement)\n- [debugging](#debugging)\n  - [inspectLeft](#inspectleft)\n  - [inspectRight](#inspectright)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [andThenBind](#andthenbind)\n  - [appendElement](#appendelement)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n  - [tupled](#tupled)\n- [equivalence](#equivalence)\n  - [getEquivalence](#getequivalence)\n- [error handling](#error-handling)\n  - [firstRightOf](#firstrightof)\n  - [mapLeft](#mapleft)\n  - [orElse](#orelse)\n  - [orElseEither](#orelseeither)\n  - [orElseFail](#orelsefail)\n  - [tapError](#taperror)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n- [getters](#getters)\n  - [getOrElse](#getorelse)\n  - [getOrNull](#getornull)\n  - [getOrUndefined](#getorundefined)\n  - [lefts](#lefts)\n  - [rights](#rights)\n- [guards](#guards)\n  - [isEither](#iseither)\n  - [isLeft](#isleft)\n  - [isRight](#isright)\n- [instances](#instances)\n  - [Applicative](#applicative)\n  - [Bicovariant](#bicovariant)\n  - [Chainable](#chainable)\n  - [Covariant](#covariant)\n  - [FlatMap](#flatmap)\n  - [Foldable](#foldable)\n  - [Invariant](#invariant)\n  - [Monad](#monad)\n  - [Of](#of)\n  - [Pointed](#pointed)\n  - [Product](#product)\n  - [SemiAlternative](#semialternative)\n  - [SemiApplicative](#semiapplicative)\n  - [SemiCoproduct](#semicoproduct)\n  - [SemiProduct](#semiproduct)\n  - [Traversable](#traversable)\n  - [getOptionalSemigroup](#getoptionalsemigroup)\n- [interop](#interop)\n  - [fromNullable](#fromnullable)\n  - [getOrThrow](#getorthrow)\n  - [getOrThrowWith](#getorthrowwith)\n  - [liftNullable](#liftnullable)\n  - [liftThrowable](#liftthrowable)\n  - [merge](#merge)\n- [lifting](#lifting)\n  - [lift2](#lift2)\n  - [liftOption](#liftoption)\n  - [liftPredicate](#liftpredicate)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [map](#map)\n- [math](#math)\n  - [divide](#divide)\n  - [multiply](#multiply)\n  - [subtract](#subtract)\n  - [sum](#sum)\n- [models](#models)\n  - [Either (type alias)](#either-type-alias)\n  - [Left (interface)](#left-interface)\n  - [Right (interface)](#right-interface)\n- [pattern matching](#pattern-matching)\n  - [match](#match)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n  - [traverseTap](#traversetap)\n- [type lambdas](#type-lambdas)\n  - [EitherTypeLambda (interface)](#eithertypelambda-interface)\n- [utils](#utils)\n  - [andThen](#andthen)\n  - [ap](#ap)\n  - [composeKleisliArrow](#composekleisliarrow)\n  - [contains](#contains)\n  - [exists](#exists)\n  - [flatten](#flatten)\n  - [reverse](#reverse)\n  - [struct](#struct)\n  - [tuple](#tuple)\n  - [unit](#unit)\n\n---\n\n# combinators\n\n## tap\n\nReturns an effect that effectfully \"peeks\" at the success of this effect.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <E1, A, E2, _>(self: Either<E1, A>, f: (a: A) => Either<E2, _>): Either<E1 | E2, A>\n  <A, E2, _>(f: (a: A) => Either<E2, _>): <E1>(self: Either<E1, A>) => Either<E2 | E1, A>\n}\n```\n\nAdded in v1.0.0\n\n# combining\n\n## all\n\nSimilar to `Promise.all` but operates on `Either`s.\n\n```\nIterable<Either<E, A>> -> Either<E, A[]>\n```\n\nFlattens a collection of `Either`s into a single `Either` that contains a list of all the `Right` values.\nIf there is a `Left` value in the collection, it returns the first `Left` found as the result.\n\n**Signature**\n\n```ts\nexport declare const all: <E, A>(collection: Iterable<Either<E, A>>) => Either<E, A[]>\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(E.all([E.right(1), E.right(2), E.right(3)]), E.right([1, 2, 3]))\nassert.deepStrictEqual(E.all([E.right(1), E.left('error'), E.right(3)]), E.left('error'))\n```\n\nAdded in v1.0.0\n\n## andThenDiscard\n\nSequences the specified effect after this effect, but ignores the value\nproduced by the effect.\n\n**Signature**\n\n```ts\nexport declare const andThenDiscard: {\n  <E1, A, E2, _>(self: Either<E1, A>, that: Either<E2, _>): Either<E1 | E2, A>\n  <E2, _>(that: Either<E2, _>): <E1, A>(self: Either<E1, A>) => Either<E2 | E1, A>\n}\n```\n\nAdded in v1.0.0\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, E2, B>(f: (a: A) => Either<E2, B>): <E1>(self: Either<E1, A>) => Either<E2 | E1, B>\n  <E1, A, E2, B>(self: Either<E1, A>, f: (a: A) => Either<E2, B>): Either<E1 | E2, B>\n}\n```\n\nAdded in v1.0.0\n\n## flatMapNullable\n\n**Signature**\n\n```ts\nexport declare const flatMapNullable: {\n  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <E1>(\n    self: Either<E1, A>\n  ) => Either<E2 | E1, NonNullable<B>>\n  <E1, A, B, E2>(self: Either<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): Either<\n    E1 | E2,\n    NonNullable<B>\n  >\n}\n```\n\nAdded in v1.0.0\n\n## flatMapOption\n\n**Signature**\n\n```ts\nexport declare const flatMapOption: {\n  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <E1>(self: Either<E1, A>) => Either<E2 | E1, B>\n  <E1, A, B, E2>(self: Either<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): Either<E1 | E2, B>\n}\n```\n\nAdded in v1.0.0\n\n## getFirstLeftMonoid\n\n`Monoid` returning the left-most `Left` value. If both operands are `Right`s then the inner values\nare combined using the provided `Monoid`.\n\n- `combine` is provided by {@link getFirstLeftSemigroup}.\n- `empty` is `right(M.empty)`\n\n**Signature**\n\n```ts\nexport declare const getFirstLeftMonoid: <A, E>(M: Monoid<A>) => Monoid<Either<E, A>>\n```\n\nAdded in v1.0.0\n\n## getFirstLeftSemigroup\n\n`Semigroup` returning the left-most `Left` value. If both operands are `Right`s then the inner values\nare combined using the provided `Semigroup`.\n\n```\n| self       | that       | combine(self, that)     |\n| ---------- | ---------- | ----------------------- |\n| left(e1)   | left(e2)   | left(e1)                |\n| left(e1)   | right(a2)  | left(e1)                |\n| right(a1)  | left(e2)   | left(e2)                |\n| right(a1)  | right(a2)  | right(combine(a1, a2))  |\n```\n\n**Signature**\n\n```ts\nexport declare const getFirstLeftSemigroup: <A, E>(S: Semigroup<A>) => Semigroup<Either<E, A>>\n```\n\nAdded in v1.0.0\n\n## getFirstRightSemigroup\n\nSemigroup returning the left-most `Right` value.\n\n```\n| self       | that       | combine(self, that) |\n| ---------- | ---------- | ------------------- |\n| left(e1)   | left(e2)   | left(e2)            |\n| left(e1)   | right(a2)  | right(a2)           |\n| right(a1)  | left(e2)   | right(a1)           |\n| right(a1)  | right(a2)  | right(a1)           |\n```\n\n**Signature**\n\n```ts\nexport declare const getFirstRightSemigroup: <E, A>() => Semigroup<Either<E, A>>\n```\n\nAdded in v1.0.0\n\n## zipWith\n\n**Signature**\n\n```ts\nexport declare const zipWith: {\n  <E1, A, E2, B, C>(self: Either<E1, A>, that: Either<E2, B>, f: (a: A, b: B) => C): Either<E1 | E2, C>\n  <E2, B, A, C>(that: Either<E2, B>, f: (a: A, b: B) => C): <E1>(self: Either<E1, A>) => Either<E2 | E1, C>\n}\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## left\n\nConstructs a new `Either` holding a `Left` value. This usually represents a failure, due to the right-bias of this\nstructure.\n\n**Signature**\n\n```ts\nexport declare const left: <E>(e: E) => Either<E, never>\n```\n\nAdded in v1.0.0\n\n## of\n\nAlias of {@link right}.\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => Either<never, A>\n```\n\nAdded in v1.0.0\n\n## right\n\nConstructs a new `Either` holding a `Right` value. This usually represents a successful value due to the right bias\nof this structure.\n\n**Signature**\n\n```ts\nexport declare const right: <A>(a: A) => Either<never, A>\n```\n\nAdded in v1.0.0\n\n# conversions\n\n## fromIterable\n\n**Signature**\n\n```ts\nexport declare const fromIterable: {\n  <E>(onEmpty: LazyArg<E>): <A>(collection: Iterable<A>) => Either<E, A>\n  <A, E>(collection: Iterable<A>, onEmpty: LazyArg<E>): Either<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: {\n  <A, E>(fa: Option<A>, onNone: () => E): Either<E, A>\n  <E>(onNone: () => E): <A>(fa: Option<A>) => Either<E, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/Either'\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(\n  E.fromOption(O.some(1), () => 'error'),\n  E.right(1)\n)\nassert.deepStrictEqual(\n  E.fromOption(O.none(), () => 'error'),\n  E.left('error')\n)\n```\n\nAdded in v1.0.0\n\n## getLeft\n\nConverts a `Either` to an `Option` discarding the value.\n\n**Signature**\n\n```ts\nexport declare const getLeft: <E, A>(self: Either<E, A>) => Option<E>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(E.getLeft(E.right('ok')), O.none())\nassert.deepStrictEqual(E.getLeft(E.left('err')), O.some('err'))\n```\n\nAdded in v1.0.0\n\n## getRight\n\nConverts a `Either` to an `Option` discarding the error.\n\nAlias of {@link toOption}.\n\n**Signature**\n\n```ts\nexport declare const getRight: <E, A>(self: Either<E, A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(E.getRight(E.right('ok')), O.some('ok'))\nassert.deepStrictEqual(E.getRight(E.left('err')), O.none())\n```\n\nAdded in v1.0.0\n\n## toArray\n\nTransforms an `Either` into an `Array`.\nIf the input is `Left`, an empty array is returned.\nIf the input is `Right`, the value is wrapped in an array.\n\n**Signature**\n\n```ts\nexport declare const toArray: <E, A>(self: Either<E, A>) => A[]\n```\n\n**Example**\n\n```ts\nimport { right, left, toArray } from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(toArray(right(1)), [1])\nassert.deepStrictEqual(toArray(left('error')), [])\n```\n\nAdded in v1.0.0\n\n## toOption\n\nConverts a `Either` to an `Option` discarding the error.\n\n**Signature**\n\n```ts\nexport declare const toOption: <E, A>(self: Either<E, A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(E.toOption(E.right(1)), O.some(1))\nassert.deepStrictEqual(E.toOption(E.left('a')), O.none())\n```\n\nAdded in v1.0.0\n\n## toRefinement\n\nReturns a `Refinement` from a `Either` returning function.\nThis function ensures that a `Refinement` definition is type-safe.\n\n**Signature**\n\n```ts\nexport declare const toRefinement: <A, E, B extends A>(f: (a: A) => Either<E, B>) => Refinement<A, B>\n```\n\nAdded in v1.0.0\n\n# debugging\n\n## inspectLeft\n\n**Signature**\n\n```ts\nexport declare const inspectLeft: {\n  <E>(onLeft: (e: E) => void): <A>(self: Either<E, A>) => Either<E, A>\n  <E, A>(self: Either<E, A>, onLeft: (e: E) => void): Either<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## inspectRight\n\n**Signature**\n\n```ts\nexport declare const inspectRight: {\n  <A>(onRight: (a: A) => void): <E>(self: Either<E, A>) => Either<E, A>\n  <E, A>(self: Either<E, A>, onRight: (a: A) => void): Either<E, A>\n}\n```\n\nAdded in v1.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: Either<never, {}>\n```\n\nAdded in v1.0.0\n\n## andThenBind\n\nExtends the `Either` value with the value of another `Either` type.\n\nIf both `Either` instances are `Left`, then the result will be the first `Left`.\n\n**Signature**\n\n```ts\nexport declare const andThenBind: {\n  <N extends string, A extends object, E2, B>(name: Exclude<N, keyof A>, that: Either<E2, B>): <E1>(\n    self: Either<E1, A>\n  ) => Either<E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: Either<E1, A>,\n    name: Exclude<N, keyof A>,\n    that: Either<E2, B>\n  ): Either<E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/Either'\nimport { pipe } from '@fp-ts/core/Function'\n\nconst result = pipe(\n  E.Do,\n  E.bind('a', () => E.left('e1')),\n  E.andThenBind('b', E.left('e2'))\n)\n\nassert.deepStrictEqual(result, E.left('e1'))\n```\n\nAdded in v1.0.0\n\n## appendElement\n\nAppends an element to the end of a tuple.\n\n**Signature**\n\n```ts\nexport declare const appendElement: {\n  <E1, A extends readonly any[], E2, B>(self: Either<E1, A>, that: Either<E2, B>): Either<E1 | E2, [...A, B]>\n  <E2, B>(that: Either<E2, B>): <E1, A extends readonly any[]>(self: Either<E1, A>) => Either<E2 | E1, [...A, B]>\n}\n```\n\nAdded in v1.0.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: {\n  <N extends string, A extends object, E2, B>(name: Exclude<N, keyof A>, f: (a: A) => Either<E2, B>): <E1>(\n    self: Either<E1, A>\n  ) => Either<E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: Either<E1, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Either<E2, B>\n  ): Either<E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\nAdded in v1.0.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: {\n  <N extends string>(name: N): <E, A>(self: Either<E, A>) => Either<E, { [K in N]: A }>\n  <E, A, N extends string>(self: Either<E, A>, name: N): Either<E, { [K in N]: A }>\n}\n```\n\nAdded in v1.0.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): <E>(\n    self: Either<E, A>\n  ) => Either<E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E, A extends object, N extends string, B>(self: Either<E, A>, name: Exclude<N, keyof A>, f: (a: A) => B): Either<\n    E,\n    { [K in N | keyof A]: K extends keyof A ? A[K] : B }\n  >\n}\n```\n\nAdded in v1.0.0\n\n## tupled\n\n**Signature**\n\n```ts\nexport declare const tupled: <E, A>(self: Either<E, A>) => Either<E, [A]>\n```\n\nAdded in v1.0.0\n\n# equivalence\n\n## getEquivalence\n\n**Signature**\n\n```ts\nexport declare const getEquivalence: <E, A>(EE: Equivalence<E>, EA: Equivalence<A>) => Equivalence<Either<E, A>>\n```\n\nAdded in v1.0.0\n\n# error handling\n\n## firstRightOf\n\n**Signature**\n\n```ts\nexport declare const firstRightOf: {\n  <E, A>(collection: Iterable<Either<E, A>>): (self: Either<E, A>) => Either<E, A>\n  <E, A>(self: Either<E, A>, collection: Iterable<Either<E, A>>): Either<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## mapLeft\n\nMaps the `Left` side of an `Either` value to a new `Either` value.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: {\n  <E, G>(f: (e: E) => G): <A>(self: Either<E, A>) => Either<G, A>\n  <E, A, G>(self: Either<E, A>, f: (e: E) => G): Either<G, A>\n}\n```\n\nAdded in v1.0.0\n\n## orElse\n\nExecutes this effect and returns its value, if it succeeds, but otherwise\nexecutes the specified effect.\n\n**Signature**\n\n```ts\nexport declare const orElse: {\n  <E1, E2, B>(that: (e1: E1) => Either<E2, B>): <A>(self: Either<E1, A>) => Either<E2, B | A>\n  <E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, A | B>\n}\n```\n\nAdded in v1.0.0\n\n## orElseEither\n\nReturns an effect that will produce the value of this effect, unless it\nfails, in which case, it will produce the value of the specified effect.\n\n**Signature**\n\n```ts\nexport declare const orElseEither: {\n  <E1, E2, B>(that: (e1: E1) => Either<E2, B>): <A>(self: Either<E1, A>) => Either<E2, Either<A, B>>\n  <E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, Either<A, B>>\n}\n```\n\nAdded in v1.0.0\n\n## orElseFail\n\nExecutes this effect and returns its value, if it succeeds, but otherwise\nfails with the specified error.\n\n**Signature**\n\n```ts\nexport declare const orElseFail: {\n  <E2>(onLeft: LazyArg<E2>): <E1, A>(self: Either<E1, A>) => Either<E2, A>\n  <E1, A, E2>(self: Either<E1, A>, onLeft: LazyArg<E2>): Either<E2, A>\n}\n```\n\nAdded in v1.0.0\n\n## tapError\n\nReturns an effect that effectfully \"peeks\" at the failure of this effect.\n\n**Signature**\n\n```ts\nexport declare const tapError: {\n  <E1, E2, _>(onLeft: (e: E1) => Either<E2, _>): <A>(self: Either<E1, A>) => Either<E1 | E2, A>\n  <E1, A, E2, _>(self: Either<E1, A>, onLeft: (e: E1) => Either<E2, _>): Either<E1 | E2, A>\n}\n```\n\nAdded in v1.0.0\n\n# filtering\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: {\n  <E2>(onNone: LazyArg<E2>): <E1, A>(self: Either<E1, Option<A>>) => Either<E2 | E1, A>\n  <E1, A, E2>(self: Either<E1, Option<A>>, onNone: LazyArg<E2>): Either<E1 | E2, A>\n}\n```\n\nAdded in v1.0.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <C extends A, B extends A, E2, A = C>(refinement: Refinement<A, B>, onFalse: LazyArg<E2>): <E1>(\n    self: Either<E1, C>\n  ) => Either<E2 | E1, B>\n  <B extends A, E2, A = B>(predicate: Predicate<A>, onFalse: LazyArg<E2>): <E1>(\n    self: Either<E1, B>\n  ) => Either<E2 | E1, B>\n  <E1, C extends A, B extends A, E2, A = C>(\n    self: Either<E1, C>,\n    refinement: Refinement<A, B>,\n    onFalse: LazyArg<E2>\n  ): Either<E1 | E2, B>\n  <E1, B extends A, E2, A = B>(self: Either<E1, B>, predicate: Predicate<A>, onFalse: LazyArg<E2>): Either<E1 | E2, B>\n}\n```\n\nAdded in v1.0.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare const filterMap: {\n  <A, B, E2>(f: (a: A) => Option<B>, onNone: LazyArg<E2>): <E1>(self: Either<E1, A>) => Either<E2 | E1, B>\n  <E1, A, B, E2>(self: Either<E1, A>, f: (a: A) => Option<B>, onNone: LazyArg<E2>): Either<E1 | E2, B>\n}\n```\n\nAdded in v1.0.0\n\n# getters\n\n## getOrElse\n\nReturns the wrapped value if it's a `Right` or a default value if is a `Left`.\n\n**Signature**\n\n```ts\nexport declare const getOrElse: {\n  <E, B>(onLeft: (e: E) => B): <A>(self: Either<E, A>) => B | A\n  <E, A, B>(self: Either<E, A>, onLeft: (e: E) => B): A | B\n}\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/Either'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(\n  E.getOrElse(E.right(1), () => 0),\n  1\n)\nassert.deepStrictEqual(\n  E.getOrElse(E.left('error'), () => 0),\n  0\n)\n```\n\nAdded in v1.0.0\n\n## getOrNull\n\n**Signature**\n\n```ts\nexport declare const getOrNull: <E, A>(self: Either<E, A>) => A | null\n```\n\nAdded in v1.0.0\n\n## getOrUndefined\n\n**Signature**\n\n```ts\nexport declare const getOrUndefined: <E, A>(self: Either<E, A>) => A | undefined\n```\n\nAdded in v1.0.0\n\n## lefts\n\nReturn all the `Left` elements from an `Interable` of `Either`s.\n\n**Signature**\n\n```ts\nexport declare const lefts: <E, A>(self: Iterable<Either<E, A>>) => E[]\n```\n\nAdded in v1.0.0\n\n## rights\n\nReturn all the `Right` elements from an `Interable` of `Either`s.\n\n**Signature**\n\n```ts\nexport declare const rights: <E, A>(self: Iterable<Either<E, A>>) => A[]\n```\n\nAdded in v1.0.0\n\n# guards\n\n## isEither\n\nTests if a value is a `Either`.\n\n**Signature**\n\n```ts\nexport declare const isEither: (input: unknown) => input is Either<unknown, unknown>\n```\n\n**Example**\n\n```ts\nimport { isEither, left, right } from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(isEither(right(1)), true)\nassert.deepStrictEqual(isEither(left('error')), true)\nassert.deepStrictEqual(isEither({ right: 1 }), false)\n```\n\nAdded in v1.0.0\n\n## isLeft\n\nDetermine if a `Either` is a `Left`.\n\n**Signature**\n\n```ts\nexport declare const isLeft: <E, A>(self: Either<E, A>) => self is Left<E>\n```\n\n**Example**\n\n```ts\nimport { isLeft, left, right } from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(isLeft(right(1)), false)\nassert.deepStrictEqual(isLeft(left('error')), true)\n```\n\nAdded in v1.0.0\n\n## isRight\n\nDetermine if a `Either` is a `Right`.\n\n**Signature**\n\n```ts\nexport declare const isRight: <E, A>(self: Either<E, A>) => self is Right<A>\n```\n\n**Example**\n\n```ts\nimport { isRight, left, right } from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(isRight(right(1)), true)\nassert.deepStrictEqual(isRight(left('error')), false)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: applicative.Applicative<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Bicovariant\n\n**Signature**\n\n```ts\nexport declare const Bicovariant: bicovariant.Bicovariant<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Chainable\n\n**Signature**\n\n```ts\nexport declare const Chainable: chainable.Chainable<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Covariant\n\n**Signature**\n\n```ts\nexport declare const Covariant: covariant.Covariant<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## FlatMap\n\n**Signature**\n\n```ts\nexport declare const FlatMap: flatMap_.FlatMap<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: foldable.Foldable<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: monad.Monad<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Of\n\n**Signature**\n\n```ts\nexport declare const Of: of_.Of<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: pointed.Pointed<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Product\n\n**Signature**\n\n```ts\nexport declare const Product: product_.Product<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiAlternative\n\n**Signature**\n\n```ts\nexport declare const SemiAlternative: semiAlternative.SemiAlternative<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiApplicative\n\n**Signature**\n\n```ts\nexport declare const SemiApplicative: semiApplicative.SemiApplicative<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiCoproduct\n\n**Signature**\n\n```ts\nexport declare const SemiCoproduct: semiCoproduct.SemiCoproduct<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiProduct\n\n**Signature**\n\n```ts\nexport declare const SemiProduct: semiProduct.SemiProduct<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: traversable.Traversable<EitherTypeLambda>\n```\n\nAdded in v1.0.0\n\n## getOptionalSemigroup\n\nSemigroup that models the combination of values that may be absent, elements that are `Left` are ignored\nwhile elements that are `Right` are combined using the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const getOptionalSemigroup: <E, A>(S: Semigroup<A>) => Semigroup<Either<E, A>>\n```\n\nAdded in v1.0.0\n\n# interop\n\n## fromNullable\n\nTakes a lazy default and a nullable value, if the value is not nully, turn it into a `Right`, if the value is nully use\nthe provided default as a `Left`.\n\n**Signature**\n\n```ts\nexport declare const fromNullable: {\n  <A, E>(onNullable: (a: A) => E): (a: A) => Either<E, NonNullable<A>>\n  <A, E>(a: A, onNullable: (a: A) => E): Either<E, NonNullable<A>>\n}\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/Either'\n\nconst parse = E.fromNullable(() => 'nullable')\n\nassert.deepStrictEqual(parse(1), E.right(1))\nassert.deepStrictEqual(parse(null), E.left('nullable'))\n```\n\nAdded in v1.0.0\n\n## getOrThrow\n\nExtracts the value of an `Either` or throws if the `Either` is `Left`.\n\nThe thrown error is a default error. To configure the error thrown, see {@link getOrThrowWith}.\n\n**Signature**\n\n```ts\nexport declare const getOrThrow: <E, A>(self: Either<E, A>) => A\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(E.getOrThrow(E.right(1)), 1)\nassert.throws(() => E.getOrThrow(E.left('error')))\n```\n\nAdded in v1.0.0\n\n## getOrThrowWith\n\nExtracts the value of an `Either` or throws if the `Either` is `Left`.\n\nIf a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.\n\n**Signature**\n\n```ts\nexport declare const getOrThrowWith: {\n  <E>(onLeft: (e: E) => unknown): <A>(self: Either<E, A>) => A\n  <E, A>(self: Either<E, A>, onLeft: (e: E) => unknown): A\n}\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(\n  E.getOrThrowWith(E.right(1), () => new Error('Unexpected Left')),\n  1\n)\nassert.throws(() => E.getOrThrowWith(E.left('error'), () => new Error('Unexpected Left')))\n```\n\nAdded in v1.0.0\n\n## liftNullable\n\n**Signature**\n\n```ts\nexport declare const liftNullable: <A extends readonly unknown[], B, E>(\n  f: (...a: A) => B | null | undefined,\n  onNullable: (...a: A) => E\n) => (...a: A) => Either<E, NonNullable<B>>\n```\n\nAdded in v1.0.0\n\n## liftThrowable\n\nLifts a function that may throw to one returning a `Either`.\n\n**Signature**\n\n```ts\nexport declare const liftThrowable: <A extends readonly unknown[], B, E>(\n  f: (...a: A) => B,\n  onThrow: (error: unknown) => E\n) => (...a: A) => Either<E, B>\n```\n\nAdded in v1.0.0\n\n## merge\n\n**Signature**\n\n```ts\nexport declare const merge: <E, A>(self: Either<E, A>) => E | A\n```\n\nAdded in v1.0.0\n\n# lifting\n\n## lift2\n\nLifts a binary function into `Either`.\n\n**Signature**\n\n```ts\nexport declare const lift2: <A, B, C>(\n  f: (a: A, b: B) => C\n) => {\n  <E1, E2>(self: Either<E1, A>, that: Either<E2, B>): Either<E1 | E2, C>\n  <E2>(that: Either<E2, B>): <E1>(self: Either<E1, A>) => Either<E2 | E1, C>\n}\n```\n\nAdded in v1.0.0\n\n## liftOption\n\n**Signature**\n\n```ts\nexport declare const liftOption: <A extends readonly unknown[], B, E>(\n  f: (...a: A) => Option<B>,\n  onNone: (...a: A) => E\n) => (...a: A) => Either<E, B>\n```\n\nAdded in v1.0.0\n\n## liftPredicate\n\n**Signature**\n\n```ts\nexport declare const liftPredicate: {\n  <C extends A, B extends A, E, A = C>(refinement: Refinement<A, B>, onFalse: (c: C) => E): (c: C) => Either<E, B>\n  <B extends A, E, A = B>(predicate: Predicate<A>, onFalse: (b: B) => E): (b: B) => Either<E, B>\n}\n```\n\n**Example**\n\n```ts\nimport { liftPredicate, left, right } from '@fp-ts/core/Either'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(\n  pipe(\n    1,\n    liftPredicate(\n      (n) => n > 0,\n      () => 'error'\n    )\n  ),\n  right(1)\n)\nassert.deepStrictEqual(\n  pipe(\n    -1,\n    liftPredicate(\n      (n) => n > 0,\n      () => 'error'\n    )\n  ),\n  left('error')\n)\n```\n\nAdded in v1.0.0\n\n# mapping\n\n## as\n\nMaps the Right value of this effect to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <E, _, B>(self: Either<E, _>, b: B): Either<E, B>\n  <B>(b: B): <E, _>(self: Either<E, _>) => Either<E, B>\n}\n```\n\nAdded in v1.0.0\n\n## asUnit\n\nReturns the effect Eithering from mapping the Right of this effect to unit.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <E, _>(self: Either<E, _>) => Either<E, void>\n```\n\nAdded in v1.0.0\n\n## bimap\n\n**Signature**\n\n```ts\nexport declare const bimap: {\n  <E1, E2, A, B>(f: (e: E1) => E2, g: (a: A) => B): (self: Either<E1, A>) => Either<E2, B>\n  <E1, A, E2, B>(self: Either<E1, A>, f: (e: E1) => E2, g: (a: A) => B): Either<E2, B>\n}\n```\n\nAdded in v1.0.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: {\n  <A, E, B>(a: A, self: Either<E, (a: A) => B>): Either<E, B>\n  <E, A, B>(self: Either<E, (a: A) => B>): (a: A) => Either<E, B>\n}\n```\n\nAdded in v1.0.0\n\n## map\n\nMaps the `Right` side of an `Either` value to a new `Either` value.\n\n**Signature**\n\n```ts\nexport declare const map: {\n  <A, B>(f: (a: A) => B): <E>(self: Either<E, A>) => Either<E, B>\n  <E, A, B>(self: Either<E, A>, f: (a: A) => B): Either<E, B>\n}\n```\n\nAdded in v1.0.0\n\n# math\n\n## divide\n\n**Signature**\n\n```ts\nexport declare const divide: {\n  <E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>\n  <E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>\n}\n```\n\nAdded in v1.0.0\n\n## multiply\n\n**Signature**\n\n```ts\nexport declare const multiply: {\n  <E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>\n  <E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>\n}\n```\n\nAdded in v1.0.0\n\n## subtract\n\n**Signature**\n\n```ts\nexport declare const subtract: {\n  <E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>\n  <E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>\n}\n```\n\nAdded in v1.0.0\n\n## sum\n\n**Signature**\n\n```ts\nexport declare const sum: {\n  <E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>\n  <E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>\n}\n```\n\nAdded in v1.0.0\n\n# models\n\n## Either (type alias)\n\n**Signature**\n\n```ts\nexport type Either<E, A> = Left<E> | Right<A>\n```\n\nAdded in v1.0.0\n\n## Left (interface)\n\n**Signature**\n\n```ts\nexport interface Left<E> {\n  readonly _tag: 'Left'\n  readonly left: E\n}\n```\n\nAdded in v1.0.0\n\n## Right (interface)\n\n**Signature**\n\n```ts\nexport interface Right<A> {\n  readonly _tag: 'Right'\n  readonly right: A\n}\n```\n\nAdded in v1.0.0\n\n# pattern matching\n\n## match\n\nTakes two functions and an `Either` value, if the value is a `Left` the inner value is applied to the first function,\nif the value is a `Right` the inner value is applied to the second function.\n\n**Signature**\n\n```ts\nexport declare const match: {\n  <E, B, A, C = B>(onLeft: (e: E) => B, onRight: (a: A) => C): (self: Either<E, A>) => B | C\n  <E, A, B, C = B>(self: Either<E, A>, onLeft: (e: E) => B, onRight: (a: A) => C): B | C\n}\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/Either'\nimport { pipe } from '@fp-ts/core/Function'\n\nconst onLeft = (errors: ReadonlyArray<string>): string => `Errors: ${errors.join(', ')}`\n\nconst onRight = (value: number): string => `Ok: ${value}`\n\nassert.deepStrictEqual(pipe(E.right(1), E.match(onLeft, onRight)), 'Ok: 1')\nassert.deepStrictEqual(pipe(E.left(['error 1', 'error 2']), E.match(onLeft, onRight)), 'Errors: error 1, error 2')\n```\n\nAdded in v1.0.0\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => <TE, R, O, E, A>(self: Either<TE, Kind<F, R, O, E, A>>) => Kind<F, R, O, E, Either<TE, A>>\n```\n\nAdded in v1.0.0\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): <TE>(self: Either<TE, A>) => Kind<F, R, O, E, Either<TE, B>>\n  <TE, A, R, O, E, B>(self: Either<TE, A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Either<TE, B>>\n}\n```\n\nAdded in v1.0.0\n\n## traverseTap\n\n**Signature**\n\n```ts\nexport declare const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <TE, A, R, O, E, B>(self: Either<TE, A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Either<TE, A>>\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): <TE>(self: Either<TE, A>) => Kind<F, R, O, E, Either<TE, A>>\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## EitherTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface EitherTypeLambda extends TypeLambda {\n  readonly type: Either<this['Out1'], this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## andThen\n\n**Signature**\n\n```ts\nexport declare const andThen: {\n  <E1, _, E2, B>(self: Either<E1, _>, that: Either<E2, B>): Either<E1 | E2, B>\n  <E2, B>(that: Either<E2, B>): <E1, _>(self: Either<E1, _>) => Either<E2 | E1, B>\n}\n```\n\nAdded in v1.0.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: {\n  <E1, A, B, E2>(self: Either<E1, (a: A) => B>, that: Either<E2, A>): Either<E1 | E2, B>\n  <E2, A>(that: Either<E2, A>): <E1, B>(self: Either<E1, (a: A) => B>) => Either<E2 | E1, B>\n}\n```\n\nAdded in v1.0.0\n\n## composeKleisliArrow\n\n**Signature**\n\n```ts\nexport declare const composeKleisliArrow: {\n  <A, E1, B, E2, C>(afb: (a: A) => Either<E1, B>, bfc: (b: B) => Either<E2, C>): (a: A) => Either<E1 | E2, C>\n  <B, E2, C>(bfc: (b: B) => Either<E2, C>): <A, E1>(afb: (a: A) => Either<E1, B>) => (a: A) => Either<E2 | E1, C>\n}\n```\n\nAdded in v1.0.0\n\n## contains\n\nReturns a function that checks if an `Either` contains a given value using a provided `equivalence` function.\n\n**Signature**\n\n```ts\nexport declare const contains: <A>(isEquivalent: (self: A, that: A) => boolean) => {\n  (a: A): <E>(self: Either<E, A>) => boolean\n  <E>(self: Either<E, A>, a: A): boolean\n}\n```\n\nAdded in v1.0.0\n\n## exists\n\nReturns `false` if `Left` or returns the Either of the application of the given predicate to the `Right` value.\n\n**Signature**\n\n```ts\nexport declare const exists: {\n  <A>(predicate: Predicate<A>): <E>(self: Either<E, A>) => boolean\n  <E, A>(self: Either<E, A>, predicate: Predicate<A>): boolean\n}\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/Either'\n\nconst f = E.exists((n: number) => n > 2)\n\nassert.deepStrictEqual(f(E.left('a')), false)\nassert.deepStrictEqual(f(E.right(1)), false)\nassert.deepStrictEqual(f(E.right(3)), true)\n```\n\nAdded in v1.0.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <E1, E2, A>(self: Either<E1, Either<E2, A>>) => Either<E1 | E2, A>\n```\n\nAdded in v1.0.0\n\n## reverse\n\n**Signature**\n\n```ts\nexport declare const reverse: <E, A>(self: Either<E, A>) => Either<A, E>\n```\n\nAdded in v1.0.0\n\n## struct\n\n**Signature**\n\n```ts\nexport declare const struct: <R extends Record<string, Either<any, any>>>(\n  fields: R\n) => Either<\n  [R[keyof R]] extends [Either<infer E, any>] ? E : never,\n  { [K in keyof R]: [R[K]] extends [Either<any, infer A>] ? A : never }\n>\n```\n\nAdded in v1.0.0\n\n## tuple\n\nSimilar to `Promise.all` but operates on `Either`s.\n\n```\n[Either<E1, A>, Either<E1, B>, ...] -> Either<E1 \\| E2 \\| ..., [A, B, ...]>\n```\n\n**Signature**\n\n```ts\nexport declare const tuple: <T extends readonly Either<any, any>[]>(\n  ...elements: T\n) => Either<\n  [T[number]] extends [Either<infer E, any>] ? E : never,\n  { [I in keyof T]: [T[I]] extends [Either<any, infer A>] ? A : never }\n>\n```\n\nAdded in v1.0.0\n\n## unit\n\n**Signature**\n\n```ts\nexport declare const unit: Either<never, void>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Function.ts.md",
    "content": "---\ntitle: Function.ts\nnav_order: 4\nparent: Modules\n---\n\n## Function overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [guards](#guards)\n  - [isFunction](#isfunction)\n- [type lambdas](#type-lambdas)\n  - [FunctionTypeLambda (interface)](#functiontypelambda-interface)\n- [utils](#utils)\n  - [FunctionN (interface)](#functionn-interface)\n  - [LazyArg (interface)](#lazyarg-interface)\n  - [SK](#sk)\n  - [absurd](#absurd)\n  - [apply](#apply)\n  - [compose](#compose)\n  - [constFalse](#constfalse)\n  - [constNull](#constnull)\n  - [constTrue](#consttrue)\n  - [constUndefined](#constundefined)\n  - [constVoid](#constvoid)\n  - [constant](#constant)\n  - [dual](#dual)\n  - [flip](#flip)\n  - [flow](#flow)\n  - [hole](#hole)\n  - [identity](#identity)\n  - [pipe](#pipe)\n  - [tupled](#tupled)\n  - [unsafeCoerce](#unsafecoerce)\n  - [untupled](#untupled)\n\n---\n\n# guards\n\n## isFunction\n\nTests if a value is a `function`.\n\n**Signature**\n\n```ts\nexport declare const isFunction: (input: unknown) => input is Function\n```\n\n**Example**\n\n```ts\nimport { isFunction } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isFunction(isFunction), true)\nassert.deepStrictEqual(isFunction('function'), false)\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## FunctionTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface FunctionTypeLambda extends TypeLambda {\n  readonly type: (a: this['In']) => this['Target']\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## FunctionN (interface)\n\n**Signature**\n\n```ts\nexport interface FunctionN<A extends ReadonlyArray<unknown>, B> {\n  (...args: A): B\n}\n```\n\n**Example**\n\n```ts\nimport { FunctionN } from '@fp-ts/core/Function'\n\nexport const sum: FunctionN<[number, number], number> = (a, b) => a + b\n```\n\nAdded in v1.0.0\n\n## LazyArg (interface)\n\nA lazy argument.\n\n**Signature**\n\n```ts\nexport interface LazyArg<A> {\n  (): A\n}\n```\n\n**Example**\n\n```ts\nimport { LazyArg, constant } from '@fp-ts/core/Function'\n\nexport const constNull: LazyArg<null> = constant(null)\n```\n\nAdded in v1.0.0\n\n## SK\n\nThe SK combinator, also known as the \"S-K combinator\" or \"S-combinator\", is a fundamental combinator in the\nlambda calculus and the SKI combinator calculus.\n\nThis function is useful for discarding the first argument passed to it and returning the second argument.\n\n**Signature**\n\n```ts\nexport declare const SK: <A, B>(_: A, b: B) => B\n```\n\n**Example**\n\n```ts\nimport { SK } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(SK(0, 'hello'), 'hello')\n```\n\nAdded in v1.0.0\n\n## absurd\n\nThe `absurd` function is a stub for cases where a value of type `never` is encountered in your code,\nmeaning that it should be impossible for this code to be executed.\n\nThis function is particularly when it's necessary to specify that certain cases are impossible.\n\n**Signature**\n\n```ts\nexport declare const absurd: <A>(_: never) => A\n```\n\nAdded in v1.0.0\n\n## apply\n\nApply a function to a given value.\n\n**Signature**\n\n```ts\nexport declare const apply: <A>(a: A) => <B>(self: (a: A) => B) => B\n```\n\n**Example**\n\n```ts\nimport { pipe, apply } from '@fp-ts/core/Function'\nimport { length } from '@fp-ts/core/String'\n\nassert.deepStrictEqual(pipe(length, apply('hello')), 5)\n```\n\nAdded in v1.0.0\n\n## compose\n\nComposes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`.\nThe result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.\n\n**Signature**\n\n```ts\nexport declare const compose: {\n  <B, C>(bc: (b: B) => C): <A>(self: (a: A) => B) => (a: A) => C\n  <A, B, C>(self: (a: A) => B, bc: (b: B) => C): (a: A) => C\n}\n```\n\n**Example**\n\n```ts\nimport { compose } from '@fp-ts/core/Function'\n\nconst increment = (n: number) => n + 1\nconst square = (n: number) => n * n\n\nassert.strictEqual(compose(increment, square)(2), 9)\n```\n\nAdded in v1.0.0\n\n## constFalse\n\nA thunk that returns always `false`.\n\n**Signature**\n\n```ts\nexport declare const constFalse: LazyArg<boolean>\n```\n\n**Example**\n\n```ts\nimport { constFalse } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(constFalse(), false)\n```\n\nAdded in v1.0.0\n\n## constNull\n\nA thunk that returns always `null`.\n\n**Signature**\n\n```ts\nexport declare const constNull: LazyArg<null>\n```\n\n**Example**\n\n```ts\nimport { constNull } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(constNull(), null)\n```\n\nAdded in v1.0.0\n\n## constTrue\n\nA thunk that returns always `true`.\n\n**Signature**\n\n```ts\nexport declare const constTrue: LazyArg<boolean>\n```\n\n**Example**\n\n```ts\nimport { constTrue } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(constTrue(), true)\n```\n\nAdded in v1.0.0\n\n## constUndefined\n\nA thunk that returns always `undefined`.\n\n**Signature**\n\n```ts\nexport declare const constUndefined: LazyArg<undefined>\n```\n\n**Example**\n\n```ts\nimport { constUndefined } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(constUndefined(), undefined)\n```\n\nAdded in v1.0.0\n\n## constVoid\n\nA thunk that returns always `void`.\n\n**Signature**\n\n```ts\nexport declare const constVoid: LazyArg<void>\n```\n\n**Example**\n\n```ts\nimport { constVoid } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(constVoid(), undefined)\n```\n\nAdded in v1.0.0\n\n## constant\n\nCreates a constant value that never changes.\n\nThis is useful when you want to pass a value to a higher-order function (a function that takes another function as its argument)\nand want that inner function to always use the same value, no matter how many times it is called.\n\n**Signature**\n\n```ts\nexport declare const constant: <A>(value: A) => LazyArg<A>\n```\n\n**Example**\n\n```ts\nimport { constant } from '@fp-ts/core/Function'\n\nconst constNull = constant(null)\n\nassert.deepStrictEqual(constNull(), null)\nassert.deepStrictEqual(constNull(), null)\n```\n\nAdded in v1.0.0\n\n## dual\n\nCreates a function that can be used in a data-last (aka `pipe`able) or data-first style.\n\n**Signature**\n\n```ts\nexport declare const dual: <\n  DataLast extends (...args: Array<any>) => any,\n  DataFirst extends (...args: Array<any>) => any\n>(\n  arity: Parameters<DataFirst>['length'],\n  body: DataFirst\n) => DataLast & DataFirst\n```\n\n**Example**\n\n```ts\nimport { dual, pipe } from '@fp-ts/core/Function'\n\nexport const sum: {\n  (that: number): (self: number) => number\n  (self: number, that: number): number\n} = dual(2, (self: number, that: number): number => self + that)\n\nassert.deepStrictEqual(sum(2, 3), 5)\nassert.deepStrictEqual(pipe(2, sum(3)), 5)\n```\n\nAdded in v1.0.0\n\n## flip\n\nReverses the order of arguments for a curried function.\n\n**Signature**\n\n```ts\nexport declare const flip: <A extends unknown[], B extends unknown[], C>(\n  f: (...a: A) => (...b: B) => C\n) => (...b: B) => (...a: A) => C\n```\n\n**Example**\n\n```ts\nimport { flip } from '@fp-ts/core/Function'\n\nconst f = (a: number) => (b: string) => a - b.length\n\nassert.deepStrictEqual(flip(f)('aaa')(2), -1)\n```\n\nAdded in v1.0.0\n\n## flow\n\nPerforms left-to-right function composition. The first argument may have any arity, the remaining arguments must be unary.\n\nSee also {@link pipe}.\n\n**Signature**\n\n```ts\nexport declare function flow<A extends ReadonlyArray<unknown>, B>(ab: (...a: A) => B): (...a: A) => B\nexport declare function flow<A extends ReadonlyArray<unknown>, B, C>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C\n): (...a: A) => C\nexport declare function flow<A extends ReadonlyArray<unknown>, B, C, D>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D\n): (...a: A) => D\nexport declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E\n): (...a: A) => E\nexport declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F\n): (...a: A) => F\nexport declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G\n): (...a: A) => G\nexport declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H\n): (...a: A) => H\nexport declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I\n): (...a: A) => I\nexport declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I, J>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J\n): (...a: A) => J\n```\n\n**Example**\n\n```ts\nimport { flow } from '@fp-ts/core/Function'\n\nconst len = (s: string): number => s.length\nconst double = (n: number): number => n * 2\n\nconst f = flow(len, double)\n\nassert.deepStrictEqual(f('aaa'), 6)\n```\n\nAdded in v1.0.0\n\n## hole\n\nType hole simulation.\n\n**Signature**\n\n```ts\nexport declare const hole: <T>() => T\n```\n\nAdded in v1.0.0\n\n## identity\n\nThe identity function, i.e. A function that returns its input argument.\n\n**Signature**\n\n```ts\nexport declare const identity: <A>(a: A) => A\n```\n\n**Example**\n\n```ts\nimport { identity } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(identity(5), 5)\n```\n\nAdded in v1.0.0\n\n## pipe\n\nPipes the value of an expression into a pipeline of functions.\n\nThis is useful in combination with data-last functions as a simulation of methods:\n\n```\nas.map(f).filter(g) -> pipe(as, map(f), filter(g))\n```\n\nSee also {@link flow}.\n\n**Signature**\n\n```ts\nexport declare function pipe<A>(a: A): A\nexport declare function pipe<A, B>(a: A, ab: (a: A) => B): B\nexport declare function pipe<A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C\nexport declare function pipe<A, B, C, D>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D): D\nexport declare function pipe<A, B, C, D, E>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): E\nexport declare function pipe<A, B, C, D, E, F>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F\n): F\nexport declare function pipe<A, B, C, D, E, F, G>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G\n): G\nexport declare function pipe<A, B, C, D, E, F, G, H>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H\n): H\nexport declare function pipe<A, B, C, D, E, F, G, H, I>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I\n): I\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J\n): J\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K\n): K\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L\n): L\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M\n): M\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N\n): N\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O\n): O\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P\n): P\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P,\n  pq: (p: P) => Q\n): Q\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P,\n  pq: (p: P) => Q,\n  qr: (q: Q) => R\n): R\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P,\n  pq: (p: P) => Q,\n  qr: (q: Q) => R,\n  rs: (r: R) => S\n): S\nexport declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P,\n  pq: (p: P) => Q,\n  qr: (q: Q) => R,\n  rs: (r: R) => S,\n  st: (s: S) => T\n): T\n```\n\n**Example**\n\n```ts\nimport { pipe } from '@fp-ts/core/Function'\n\nconst length = (s: string): number => s.length\nconst double = (n: number): number => n * 2\nconst decrement = (n: number): number => n - 1\n\nassert.deepStrictEqual(pipe(length('hello'), double, decrement), 9)\n```\n\nAdded in v1.0.0\n\n## tupled\n\nCreates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument.\n\n**Signature**\n\n```ts\nexport declare const tupled: <A extends readonly unknown[], B>(f: (...a: A) => B) => (a: A) => B\n```\n\n**Example**\n\n```ts\nimport { tupled } from '@fp-ts/core/Function'\n\nconst sumTupled = tupled((x: number, y: number): number => x + y)\n\nassert.deepStrictEqual(sumTupled([1, 2]), 3)\n```\n\nAdded in v1.0.0\n\n## unsafeCoerce\n\nCasts the result to the specified type.\n\n**Signature**\n\n```ts\nexport declare const unsafeCoerce: <A, B>(a: A) => B\n```\n\n**Example**\n\n```ts\nimport { unsafeCoerce, identity } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(unsafeCoerce, identity)\n```\n\nAdded in v1.0.0\n\n## untupled\n\nInverse function of `tupled`\n\n**Signature**\n\n```ts\nexport declare const untupled: <A extends readonly unknown[], B>(f: (a: A) => B) => (...a: A) => B\n```\n\n**Example**\n\n```ts\nimport { untupled } from '@fp-ts/core/Function'\n\nconst getFirst = untupled(<A, B>(tuple: [A, B]): A => tuple[0])\n\nassert.deepStrictEqual(getFirst(1, 2), 1)\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/HKT.ts.md",
    "content": "---\ntitle: HKT.ts\nnav_order: 5\nparent: Modules\n---\n\n## HKT overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [utils](#utils)\n  - [Kind (type alias)](#kind-type-alias)\n  - [TypeClass (interface)](#typeclass-interface)\n  - [TypeLambda (interface)](#typelambda-interface)\n\n---\n\n# utils\n\n## Kind (type alias)\n\n**Signature**\n\n```ts\nexport type Kind<F extends TypeLambda, In, Out2, Out1, Target> = F extends {\n  readonly type: unknown\n}\n  ? (F & {\n      readonly In: In\n      readonly Out2: Out2\n      readonly Out1: Out1\n      readonly Target: Target\n    })['type']\n  : {\n      readonly F: F\n      readonly In: (_: In) => void\n      readonly Out2: () => Out2\n      readonly Out1: () => Out1\n      readonly Target: (_: Target) => Target\n    }\n```\n\nAdded in v1.0.0\n\n## TypeClass (interface)\n\n**Signature**\n\n```ts\nexport interface TypeClass<F extends TypeLambda> {\n  readonly [URI]?: F\n}\n```\n\nAdded in v1.0.0\n\n## TypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface TypeLambda {\n  readonly In: unknown\n  readonly Out2: unknown\n  readonly Out1: unknown\n  readonly Target: unknown\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Identity.ts.md",
    "content": "---\ntitle: Identity.ts\nnav_order: 6\nparent: Modules\n---\n\n## Identity overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [andThenBind](#andthenbind)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n- [instances](#instances)\n  - [Applicative](#applicative)\n  - [Chainable](#chainable)\n  - [Covariant](#covariant)\n  - [FlatMap](#flatmap)\n  - [Foldable](#foldable)\n  - [Invariant](#invariant)\n  - [Monad](#monad)\n  - [Of](#of)\n  - [Pointed](#pointed)\n  - [Product](#product)\n  - [SemiApplicative](#semiapplicative)\n  - [SemiProduct](#semiproduct)\n  - [Traversable](#traversable)\n  - [getSemiAlternative](#getsemialternative)\n  - [getSemiCoproduct](#getsemicoproduct)\n- [models](#models)\n  - [Identity (type alias)](#identity-type-alias)\n- [type lambdas](#type-lambdas)\n  - [IdentityTypeLambda (interface)](#identitytypelambda-interface)\n  - [IdentityTypeLambdaFix (interface)](#identitytypelambdafix-interface)\n\n---\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: {}\n```\n\nAdded in v1.0.0\n\n## andThenBind\n\nA variant of `bind` that sequentially ignores the scope.\n\n**Signature**\n\n```ts\nexport declare const andThenBind: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, that: B): (self: A) => {\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }\n  <A extends object, N extends string, B>(self: A, name: Exclude<N, keyof A>, that: B): {\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }\n}\n```\n\nAdded in v1.0.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): (self: A) => {\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }\n  <A extends object, N extends string, B>(self: A, name: Exclude<N, keyof A>, f: (a: A) => B): {\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }\n}\n```\n\nAdded in v1.0.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: {\n  <N extends string>(name: N): <A>(self: A) => { [K in N]: A }\n  <A, N extends string>(self: A, name: N): { [K in N]: A }\n}\n```\n\nAdded in v1.0.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): (self: A) => {\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }\n  <A extends object, N extends string, B>(self: A, name: Exclude<N, keyof A>, f: (a: A) => B): {\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }\n}\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: applicative.Applicative<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Chainable\n\n**Signature**\n\n```ts\nexport declare const Chainable: chainable.Chainable<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Covariant\n\n**Signature**\n\n```ts\nexport declare const Covariant: covariant.Covariant<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## FlatMap\n\n**Signature**\n\n```ts\nexport declare const FlatMap: flatMap_.FlatMap<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: foldable.Foldable<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: monad.Monad<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Of\n\n**Signature**\n\n```ts\nexport declare const Of: of_.Of<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: pointed.Pointed<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Product\n\n**Signature**\n\n```ts\nexport declare const Product: product_.Product<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiApplicative\n\n**Signature**\n\n```ts\nexport declare const SemiApplicative: semiApplicative.SemiApplicative<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiProduct\n\n**Signature**\n\n```ts\nexport declare const SemiProduct: semiProduct.SemiProduct<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: traversable.Traversable<IdentityTypeLambda>\n```\n\nAdded in v1.0.0\n\n## getSemiAlternative\n\n**Signature**\n\n```ts\nexport declare const getSemiAlternative: <A>(\n  S: Semigroup<A>\n) => semiAlternative.SemiAlternative<IdentityTypeLambdaFix<A>>\n```\n\nAdded in v1.0.0\n\n## getSemiCoproduct\n\n**Signature**\n\n```ts\nexport declare const getSemiCoproduct: <A>(S: Semigroup<A>) => semiCoproduct.SemiCoproduct<IdentityTypeLambdaFix<A>>\n```\n\nAdded in v1.0.0\n\n# models\n\n## Identity (type alias)\n\n**Signature**\n\n```ts\nexport type Identity<A> = A\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## IdentityTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface IdentityTypeLambda extends TypeLambda {\n  readonly type: Identity<this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n## IdentityTypeLambdaFix (interface)\n\n**Signature**\n\n```ts\nexport interface IdentityTypeLambdaFix<A> extends TypeLambda {\n  readonly type: Identity<A>\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Number.ts.md",
    "content": "---\ntitle: Number.ts\nnav_order: 8\nparent: Modules\n---\n\n## Number overview\n\nThis module provides utility functions and type class instances for working with the `number` type in TypeScript.\nIt includes functions for basic arithmetic operations, as well as type class instances for\n`Equivalence`, `Order`, `Semigroup`, and `Monoid`.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [guards](#guards)\n  - [isNumber](#isnumber)\n- [instances](#instances)\n  - [Bounded](#bounded)\n  - [Equivalence](#equivalence)\n  - [MonoidMax](#monoidmax)\n  - [MonoidMin](#monoidmin)\n  - [MonoidMultiply](#monoidmultiply)\n  - [MonoidSum](#monoidsum)\n  - [Order](#order)\n  - [SemigroupMax](#semigroupmax)\n  - [SemigroupMin](#semigroupmin)\n  - [SemigroupMultiply](#semigroupmultiply)\n  - [SemigroupSum](#semigroupsum)\n- [math](#math)\n  - [decrement](#decrement)\n  - [divide](#divide)\n  - [increment](#increment)\n  - [multiply](#multiply)\n  - [multiplyAll](#multiplyall)\n  - [remainder](#remainder)\n  - [sign](#sign)\n  - [subtract](#subtract)\n  - [sum](#sum)\n  - [sumAll](#sumall)\n- [predicates](#predicates)\n  - [between](#between)\n  - [greaterThan](#greaterthan)\n  - [greaterThanOrEqualTo](#greaterthanorequalto)\n  - [lessThan](#lessthan)\n  - [lessThanOrEqualTo](#lessthanorequalto)\n- [utils](#utils)\n  - [clamp](#clamp)\n  - [max](#max)\n  - [min](#min)\n\n---\n\n# guards\n\n## isNumber\n\nTests if a value is a `number`.\n\n**Signature**\n\n```ts\nexport declare const isNumber: (input: unknown) => input is number\n```\n\n**Example**\n\n```ts\nimport { isNumber } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(isNumber(2), true)\nassert.deepStrictEqual(isNumber('2'), false)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Bounded\n\n**Signature**\n\n```ts\nexport declare const Bounded: bounded.Bounded<number>\n```\n\nAdded in v1.0.0\n\n## Equivalence\n\n**Signature**\n\n```ts\nexport declare const Equivalence: equivalence.Equivalence<number>\n```\n\nAdded in v1.0.0\n\n## MonoidMax\n\nA `Monoid` that uses the maximum between two values.\n\nThe `empty` value is `Infinity`.\n\n**Signature**\n\n```ts\nexport declare const MonoidMax: monoid.Monoid<number>\n```\n\n**Example**\n\n```ts\nimport { MonoidMax } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(MonoidMax.combine(2, 3), 3)\nassert.deepStrictEqual(MonoidMax.combine(2, MonoidMax.empty), 2)\n```\n\nAdded in v1.0.0\n\n## MonoidMin\n\nA `Monoid` that uses the minimum between two values.\n\nThe `empty` value is `-Infinity`.\n\n**Signature**\n\n```ts\nexport declare const MonoidMin: monoid.Monoid<number>\n```\n\n**Example**\n\n```ts\nimport { MonoidMin } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(MonoidMin.combine(2, 3), 2)\nassert.deepStrictEqual(MonoidMin.combine(2, MonoidMin.empty), 2)\n```\n\nAdded in v1.0.0\n\n## MonoidMultiply\n\n`number` monoid under multiplication.\n\nThe `empty` value is `1`.\n\n**Signature**\n\n```ts\nexport declare const MonoidMultiply: monoid.Monoid<number>\n```\n\n**Example**\n\n```ts\nimport { MonoidMultiply } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(MonoidMultiply.combine(2, 3), 6)\nassert.deepStrictEqual(MonoidMultiply.combine(2, MonoidMultiply.empty), 2)\n```\n\nAdded in v1.0.0\n\n## MonoidSum\n\n`number` monoid under addition.\n\nThe `empty` value is `0`.\n\n**Signature**\n\n```ts\nexport declare const MonoidSum: monoid.Monoid<number>\n```\n\n**Example**\n\n```ts\nimport { MonoidSum } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(MonoidSum.combine(2, 3), 5)\nassert.deepStrictEqual(MonoidSum.combine(2, MonoidSum.empty), 2)\n```\n\nAdded in v1.0.0\n\n## Order\n\n**Signature**\n\n```ts\nexport declare const Order: order.Order<number>\n```\n\nAdded in v1.0.0\n\n## SemigroupMax\n\nA `Semigroup` that uses the maximum between two values.\n\n**Signature**\n\n```ts\nexport declare const SemigroupMax: semigroup.Semigroup<number>\n```\n\n**Example**\n\n```ts\nimport { SemigroupMax } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(SemigroupMax.combine(2, 3), 3)\n```\n\nAdded in v1.0.0\n\n## SemigroupMin\n\nA `Semigroup` that uses the minimum between two values.\n\n**Signature**\n\n```ts\nexport declare const SemigroupMin: semigroup.Semigroup<number>\n```\n\n**Example**\n\n```ts\nimport { SemigroupMin } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(SemigroupMin.combine(2, 3), 2)\n```\n\nAdded in v1.0.0\n\n## SemigroupMultiply\n\n`number` semigroup under multiplication.\n\n**Signature**\n\n```ts\nexport declare const SemigroupMultiply: semigroup.Semigroup<number>\n```\n\n**Example**\n\n```ts\nimport { SemigroupMultiply } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(SemigroupMultiply.combine(2, 3), 6)\n```\n\nAdded in v1.0.0\n\n## SemigroupSum\n\n`number` semigroup under addition.\n\n**Signature**\n\n```ts\nexport declare const SemigroupSum: semigroup.Semigroup<number>\n```\n\n**Example**\n\n```ts\nimport { SemigroupSum } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(SemigroupSum.combine(2, 3), 5)\n```\n\nAdded in v1.0.0\n\n# math\n\n## decrement\n\nDecrements a number by `1`.\n\n**Signature**\n\n```ts\nexport declare const decrement: (n: number) => number\n```\n\n**Example**\n\n```ts\nimport { decrement } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(decrement(3), 2)\n```\n\nAdded in v1.0.0\n\n## divide\n\nProvides a division operation on `number`s.\n\n**Signature**\n\n```ts\nexport declare const divide: { (that: number): (self: number) => number; (self: number, that: number): number }\n```\n\n**Example**\n\n```ts\nimport { divide } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(divide(6, 3), 2)\n```\n\nAdded in v1.0.0\n\n## increment\n\nReturns the result of adding `1` to a given number.\n\n**Signature**\n\n```ts\nexport declare const increment: (n: number) => number\n```\n\n**Example**\n\n```ts\nimport { increment } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(increment(2), 3)\n```\n\nAdded in v1.0.0\n\n## multiply\n\nProvides a multiplication operation on `number`s.\n\n**Signature**\n\n```ts\nexport declare const multiply: { (that: number): (self: number) => number; (self: number, that: number): number }\n```\n\n**Example**\n\n```ts\nimport { multiply } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(multiply(2, 3), 6)\n```\n\nAdded in v1.0.0\n\n## multiplyAll\n\nTakes an `Iterable` of `number`s and returns their multiplication as a single `number`.\n\n**Signature**\n\n```ts\nexport declare const multiplyAll: (collection: Iterable<number>) => number\n```\n\n**Example**\n\n```ts\nimport { multiplyAll } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(multiplyAll([2, 3, 4]), 24)\n```\n\nAdded in v1.0.0\n\n## remainder\n\nReturns the remainder left over when one operand is divided by a second operand.\n\nIt always takes the sign of the dividend.\n\n**Signature**\n\n```ts\nexport declare const remainder: { (divisor: number): (self: number) => number; (self: number, divisor: number): number }\n```\n\n**Example**\n\n```ts\nimport { remainder } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(remainder(2, 2), 0)\nassert.deepStrictEqual(remainder(3, 2), 1)\nassert.deepStrictEqual(remainder(-4, 2), -0)\n```\n\nAdded in v1.0.0\n\n## sign\n\nDetermines the sign of a given `number`.\n\n**Signature**\n\n```ts\nexport declare const sign: (n: number) => Ordering\n```\n\n**Example**\n\n```ts\nimport { sign } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(sign(-5), -1)\nassert.deepStrictEqual(sign(0), 0)\nassert.deepStrictEqual(sign(5), 1)\n```\n\nAdded in v1.0.0\n\n## subtract\n\nProvides a subtraction operation on `number`s.\n\n**Signature**\n\n```ts\nexport declare const subtract: { (that: number): (self: number) => number; (self: number, that: number): number }\n```\n\n**Example**\n\n```ts\nimport { subtract } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(subtract(2, 3), -1)\n```\n\nAdded in v1.0.0\n\n## sum\n\nProvides an addition operation on `number`s.\n\n**Signature**\n\n```ts\nexport declare const sum: { (that: number): (self: number) => number; (self: number, that: number): number }\n```\n\n**Example**\n\n```ts\nimport { sum } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(sum(2, 3), 5)\n```\n\nAdded in v1.0.0\n\n## sumAll\n\nTakes an `Iterable` of `number`s and returns their sum as a single `number`.\n\n**Signature**\n\n```ts\nexport declare const sumAll: (collection: Iterable<number>) => number\n```\n\n**Example**\n\n```ts\nimport { sumAll } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(sumAll([2, 3, 4]), 9)\n```\n\nAdded in v1.0.0\n\n# predicates\n\n## between\n\nChecks if a `number` is between a `minimum` and `maximum` value (inclusive).\n\n**Signature**\n\n```ts\nexport declare const between: {\n  (minimum: number, maximum: number): (self: number) => boolean\n  (self: number, minimum: number, maximum: number): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { between } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(between(0, 5)(3), true)\nassert.deepStrictEqual(between(0, 5)(-1), false)\nassert.deepStrictEqual(between(0, 5)(6), false)\n```\n\nAdded in v1.0.0\n\n## greaterThan\n\nReturns `true` if the first argument is greater than the second, otherwise `false`.\n\n**Signature**\n\n```ts\nexport declare const greaterThan: { (that: number): (self: number) => boolean; (self: number, that: number): boolean }\n```\n\n**Example**\n\n```ts\nimport { greaterThan } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(greaterThan(2, 3), false)\nassert.deepStrictEqual(greaterThan(3, 3), false)\nassert.deepStrictEqual(greaterThan(4, 3), true)\n```\n\nAdded in v1.0.0\n\n## greaterThanOrEqualTo\n\nReturns a function that checks if a given `number` is greater than or equal to the provided one.\n\n**Signature**\n\n```ts\nexport declare const greaterThanOrEqualTo: {\n  (that: number): (self: number) => boolean\n  (self: number, that: number): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { greaterThanOrEqualTo } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(greaterThanOrEqualTo(2, 3), false)\nassert.deepStrictEqual(greaterThanOrEqualTo(3, 3), true)\nassert.deepStrictEqual(greaterThanOrEqualTo(4, 3), true)\n```\n\nAdded in v1.0.0\n\n## lessThan\n\nReturns `true` if the first argument is less than the second, otherwise `false`.\n\n**Signature**\n\n```ts\nexport declare const lessThan: { (that: number): (self: number) => boolean; (self: number, that: number): boolean }\n```\n\n**Example**\n\n```ts\nimport { lessThan } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(lessThan(2, 3), true)\nassert.deepStrictEqual(lessThan(3, 3), false)\nassert.deepStrictEqual(lessThan(4, 3), false)\n```\n\nAdded in v1.0.0\n\n## lessThanOrEqualTo\n\nReturns a function that checks if a given `number` is less than or equal to the provided one.\n\n**Signature**\n\n```ts\nexport declare const lessThanOrEqualTo: {\n  (that: number): (self: number) => boolean\n  (self: number, that: number): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { lessThanOrEqualTo } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(lessThanOrEqualTo(2, 3), true)\nassert.deepStrictEqual(lessThanOrEqualTo(3, 3), true)\nassert.deepStrictEqual(lessThanOrEqualTo(4, 3), false)\n```\n\nAdded in v1.0.0\n\n# utils\n\n## clamp\n\nRestricts the given `number` to be within the range specified by the `minimum` and `maximum` values.\n\n- If the `number` is less than the `minimum` value, the function returns the `minimum` value.\n- If the `number` is greater than the `maximum` value, the function returns the `maximum` value.\n- Otherwise, it returns the original `number`.\n\n**Signature**\n\n```ts\nexport declare const clamp: {\n  (minimum: number, maximum: number): (self: number) => number\n  (self: number, minimum: number, maximum: number): number\n}\n```\n\n**Example**\n\n```ts\nimport { clamp } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(clamp(0, 5)(3), 3)\nassert.deepStrictEqual(clamp(0, 5)(-1), 0)\nassert.deepStrictEqual(clamp(0, 5)(6), 5)\n```\n\nAdded in v1.0.0\n\n## max\n\nReturns the maximum between two `number`s.\n\n**Signature**\n\n```ts\nexport declare const max: { (that: number): (self: number) => number; (self: number, that: number): number }\n```\n\n**Example**\n\n```ts\nimport { max } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(max(2, 3), 3)\n```\n\nAdded in v1.0.0\n\n## min\n\nReturns the minimum between two `number`s.\n\n**Signature**\n\n```ts\nexport declare const min: { (that: number): (self: number) => number; (self: number, that: number): number }\n```\n\n**Example**\n\n```ts\nimport { min } from '@fp-ts/core/Number'\n\nassert.deepStrictEqual(min(2, 3), 2)\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Option.ts.md",
    "content": "---\ntitle: Option.ts\nnav_order: 9\nparent: Modules\n---\n\n## Option overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combining](#combining)\n  - [all](#all)\n  - [ap](#ap)\n  - [getFailureMonoid](#getfailuremonoid)\n  - [getFailureSemigroup](#getfailuresemigroup)\n  - [getFirstSomeSemigroup](#getfirstsomesemigroup)\n  - [sequence](#sequence)\n  - [struct](#struct)\n  - [traverse](#traverse)\n  - [traverseTap](#traversetap)\n  - [tuple](#tuple)\n  - [zipWith](#zipwith)\n- [constructors](#constructors)\n  - [none](#none)\n  - [of](#of)\n  - [some](#some)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromIterable](#fromiterable)\n  - [fromNullable](#fromnullable)\n  - [getLeft](#getleft)\n  - [getOrThrow](#getorthrow)\n  - [getOrThrowWith](#getorthrowwith)\n  - [getRight](#getright)\n  - [liftNullable](#liftnullable)\n  - [liftThrowable](#liftthrowable)\n  - [toArray](#toarray)\n  - [toEither](#toeither)\n  - [toRefinement](#torefinement)\n- [debugging](#debugging)\n  - [inspectNone](#inspectnone)\n  - [inspectSome](#inspectsome)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [andThenBind](#andthenbind)\n  - [appendElement](#appendelement)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n  - [tupled](#tupled)\n- [equivalence](#equivalence)\n  - [getEquivalence](#getequivalence)\n- [error handling](#error-handling)\n  - [firstSomeOf](#firstsomeof)\n  - [orElse](#orelse)\n  - [orElseEither](#orelseeither)\n- [filtering](#filtering)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [partitionMap](#partitionmap)\n- [folding](#folding)\n  - [reduceCompact](#reducecompact)\n- [getters](#getters)\n  - [getOrElse](#getorelse)\n  - [getOrNull](#getornull)\n  - [getOrUndefined](#getorundefined)\n- [guards](#guards)\n  - [isNone](#isnone)\n  - [isOption](#isoption)\n  - [isSome](#issome)\n- [lifting](#lifting)\n  - [lift2](#lift2)\n  - [liftEither](#lifteither)\n  - [liftPredicate](#liftpredicate)\n- [math](#math)\n  - [divide](#divide)\n  - [multiply](#multiply)\n  - [multiplyCompact](#multiplycompact)\n  - [subtract](#subtract)\n  - [sum](#sum)\n  - [sumCompact](#sumcompact)\n- [models](#models)\n  - [None (interface)](#none-interface)\n  - [Option (type alias)](#option-type-alias)\n  - [Some (interface)](#some-interface)\n- [pattern matching](#pattern-matching)\n  - [match](#match)\n- [sorting](#sorting)\n  - [getOrder](#getorder)\n- [transforming](#transforming)\n  - [andThen](#andthen)\n  - [andThenDiscard](#andthendiscard)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [composeKleisliArrow](#composekleisliarrow)\n  - [flap](#flap)\n  - [flatMap](#flatmap)\n  - [flatMapEither](#flatmapeither)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatten](#flatten)\n  - [map](#map)\n  - [tap](#tap)\n- [type lambdas](#type-lambdas)\n  - [OptionTypeLambda (interface)](#optiontypelambda-interface)\n- [utils](#utils)\n  - [Alternative](#alternative)\n  - [Applicative](#applicative)\n  - [Chainable](#chainable)\n  - [Coproduct](#coproduct)\n  - [Covariant](#covariant)\n  - [Filterable](#filterable)\n  - [FlatMap](#flatmap)\n  - [Foldable](#foldable)\n  - [Invariant](#invariant)\n  - [Monad](#monad)\n  - [Of](#of)\n  - [Pointed](#pointed)\n  - [Product](#product)\n  - [SemiAlternative](#semialternative)\n  - [SemiApplicative](#semiapplicative)\n  - [SemiCoproduct](#semicoproduct)\n  - [SemiProduct](#semiproduct)\n  - [Traversable](#traversable)\n  - [contains](#contains)\n  - [exists](#exists)\n  - [getOptionalMonoid](#getoptionalmonoid)\n  - [unit](#unit)\n\n---\n\n# combining\n\n## all\n\nSimilar to `Promise.all` but operates on `Option`s.\n\n```\nIterable<Option<A>> -> Option<A[]>\n```\n\nFlattens a collection of `Option`s into a single `Option` that contains a list of all the `Some` values.\nIf there is a `None` value in the collection, it returns `None` as the result.\n\n**Signature**\n\n```ts\nexport declare const all: <A>(collection: Iterable<Option<A>>) => Option<A[]>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.all([O.some(1), O.some(2), O.some(3)]), O.some([1, 2, 3]))\nassert.deepStrictEqual(O.all([O.some(1), O.none(), O.some(3)]), O.none())\n```\n\nAdded in v1.0.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: {\n  <A, B>(self: Option<(a: A) => B>, that: Option<A>): Option<B>\n  <A>(that: Option<A>): <B>(self: Option<(a: A) => B>) => Option<B>\n}\n```\n\nAdded in v1.0.0\n\n## getFailureMonoid\n\nMonoid that models the combination of computations that can fail, if at least one element is `None`\nthen the resulting combination is `None`, otherwise if all elements are `Some` then the resulting combination\nis the combination of the wrapped elements using the provided `Monoid`.\n\nThe `empty` value is `some(M.empty)`.\n\nSee also `getFailureSemigroup` if you need a `Semigroup` instead of a `Monoid`.\n\n**Signature**\n\n```ts\nexport declare const getFailureMonoid: <A>(M: Monoid<A>) => Monoid<Option<A>>\n```\n\nAdded in v1.0.0\n\n## getFailureSemigroup\n\nSemigroup that models the combination of computations that can fail, if at least one element is `None`\nthen the resulting combination is `None`, otherwise if all elements are `Some` then the resulting combination\nis the combination of the wrapped elements using the provided `Semigroup`.\n\nSee also `getFailureMonoid` if you need a `Monoid` instead of a `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const getFailureSemigroup: <A>(S: Semigroup<A>) => Semigroup<Option<A>>\n```\n\nAdded in v1.0.0\n\n## getFirstSomeSemigroup\n\nSemigroup returning the first `Some` value encountered.\n\n**Signature**\n\n```ts\nexport declare const getFirstSomeSemigroup: <A>() => Semigroup<Option<A>>\n```\n\nAdded in v1.0.0\n\n## sequence\n\nCombines an `Option` of an `F`-structure to an `F`-structure of an `Option` with the same inner type.\n\n**Signature**\n\n```ts\nexport declare const sequence: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => <R, O, E, A>(self: Option<Kind<F, R, O, E, A>>) => Kind<F, R, O, E, Option<A>>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nconst sequence = O.sequence(E.Applicative)\n\nassert.deepStrictEqual(sequence(O.some(E.right(1))), E.right(O.some(1)))\nassert.deepStrictEqual(sequence(O.some(E.left('error'))), E.left('error'))\nassert.deepStrictEqual(sequence(O.none()), E.right(O.none()))\n```\n\nAdded in v1.0.0\n\n## struct\n\nTakes a struct of `Option`s and returns an `Option` of a struct of values.\n\n**Signature**\n\n```ts\nexport declare const struct: <R extends Record<string, Option<any>>>(\n  fields: R\n) => Option<{ [K in keyof R]: [R[K]] extends [Option<infer A>] ? A : never }>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.struct({ a: O.some(1), b: O.some('hello') }), O.some({ a: 1, b: 'hello' }))\nassert.deepStrictEqual(O.struct({ a: O.some(1), b: O.none() }), O.none())\n```\n\nAdded in v1.0.0\n\n## traverse\n\nApplies an `Option` value to an effectful function that returns an `F` value.\n\n**Signature**\n\n```ts\nexport declare const traverse: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): (self: Option<A>) => Kind<F, R, O, E, Option<B>>\n  <A, R, O, E, B>(self: Option<A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Option<B>>\n}\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nconst traverse = O.traverse(E.Applicative)\nconst f = (n: number) => (n >= 0 ? E.right(1) : E.left('negative'))\n\nassert.deepStrictEqual(traverse(O.some(1), f), E.right(O.some(1)))\nassert.deepStrictEqual(traverse(O.some(-1), f), E.left('negative'))\nassert.deepStrictEqual(traverse(O.none(), f), E.right(O.none()))\n```\n\nAdded in v1.0.0\n\n## traverseTap\n\n**Signature**\n\n```ts\nexport declare const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(self: Option<A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Option<A>>\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): (self: Option<A>) => Kind<F, R, O, E, Option<A>>\n}\n```\n\nAdded in v1.0.0\n\n## tuple\n\nSimilar to `Promise.all` but operates on `Option`s.\n\n```\n[Option<A>, Option<B>, ...] -> Option<[A, B, ...]>\n```\n\nTakes a tuple of `Option`s and returns an `Option` of a tuple of values.\n\n**Signature**\n\n```ts\nexport declare const tuple: <T extends readonly Option<any>[]>(\n  ...elements: T\n) => Option<{ [I in keyof T]: [T[I]] extends [Option<infer A>] ? A : never }>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.tuple(O.some(1), O.some('hello')), O.some([1, 'hello']))\nassert.deepStrictEqual(O.tuple(O.some(1), O.none()), O.none())\n```\n\nAdded in v1.0.0\n\n## zipWith\n\nZips two `Option` values together using a provided function, returning a new `Option` of the result.\n\n**Signature**\n\n```ts\nexport declare const zipWith: {\n  <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>\n  <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>\n}\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## none\n\nCreates a new `Option` that represents the absence of a value.\n\n**Signature**\n\n```ts\nexport declare const none: <A = never>() => Option<A>\n```\n\nAdded in v1.0.0\n\n## of\n\nAlias of {@link some}.\n\n**Signature**\n\n```ts\nexport declare const of: <A>(value: A) => Option<A>\n```\n\nAdded in v1.0.0\n\n## some\n\nCreates a new `Option` that wraps the given value.\n\n**Signature**\n\n```ts\nexport declare const some: <A>(value: A) => Option<A>\n```\n\nAdded in v1.0.0\n\n# conversions\n\n## fromEither\n\nConverts a `Either` to an `Option` discarding the error.\n\n**Signature**\n\n```ts\nexport declare const fromEither: <E, A>(self: Either<E, A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(O.fromEither(E.right(1)), O.some(1))\nassert.deepStrictEqual(O.fromEither(E.left('error message')), O.none())\n```\n\nAdded in v1.0.0\n\n## fromIterable\n\nConverts an `Iterable` of values into an `Option`. Returns the first value of the `Iterable` wrapped in a `Some`\nif the `Iterable` is not empty, otherwise returns `None`.\n\n**Signature**\n\n```ts\nexport declare const fromIterable: <A>(collection: Iterable<A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { fromIterable, some, none } from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(fromIterable([1, 2, 3]), some(1))\nassert.deepStrictEqual(fromIterable([]), none())\n```\n\nAdded in v1.0.0\n\n## fromNullable\n\nConstructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise\nreturns the value wrapped in a `Some`.\n\n**Signature**\n\n```ts\nexport declare const fromNullable: <A>(nullableValue: A) => Option<NonNullable<A>>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.fromNullable(undefined), O.none())\nassert.deepStrictEqual(O.fromNullable(null), O.none())\nassert.deepStrictEqual(O.fromNullable(1), O.some(1))\n```\n\nAdded in v1.0.0\n\n## getLeft\n\nConverts a `Either` to an `Option` discarding the value.\n\n**Signature**\n\n```ts\nexport declare const getLeft: <E, A>(self: Either<E, A>) => Option<E>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(O.getLeft(E.right('ok')), O.none())\nassert.deepStrictEqual(O.getLeft(E.left('error')), O.some('error'))\n```\n\nAdded in v1.0.0\n\n## getOrThrow\n\nExtracts the value of an `Option` or throws if the `Option` is `None`.\n\nThe thrown error is a default error. To configure the error thrown, see {@link getOrThrowWith}.\n\n**Signature**\n\n```ts\nexport declare const getOrThrow: <A>(self: Option<A>) => A\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.getOrThrow(O.some(1)), 1)\nassert.throws(() => O.getOrThrow(O.none()))\n```\n\nAdded in v1.0.0\n\n## getOrThrowWith\n\nExtracts the value of an `Option` or throws if the `Option` is `None`.\n\nIf a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.\n\n**Signature**\n\n```ts\nexport declare const getOrThrowWith: {\n  (onNone: () => unknown): <A>(self: Option<A>) => A\n  <A>(self: Option<A>, onNone: () => unknown): A\n}\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(\n  O.getOrThrowWith(O.some(1), () => new Error('Unexpected None')),\n  1\n)\nassert.throws(() => O.getOrThrowWith(O.none(), () => new Error('Unexpected None')))\n```\n\nAdded in v1.0.0\n\n## getRight\n\nConverts a `Either` to an `Option` discarding the error.\n\nAlias of {@link fromEither}.\n\n**Signature**\n\n```ts\nexport declare const getRight: <E, A>(self: Either<E, A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(O.getRight(E.right('ok')), O.some('ok'))\nassert.deepStrictEqual(O.getRight(E.left('err')), O.none())\n```\n\nAdded in v1.0.0\n\n## liftNullable\n\nThis API is useful for lifting a function that returns `null` or `undefined` into the `Option` context.\n\n**Signature**\n\n```ts\nexport declare const liftNullable: <A extends readonly unknown[], B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Option<NonNullable<B>>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nconst parse = (s: string): number | undefined => {\n  const n = parseFloat(s)\n  return isNaN(n) ? undefined : n\n}\n\nconst parseOption = O.liftNullable(parse)\n\nassert.deepStrictEqual(parseOption('1'), O.some(1))\nassert.deepStrictEqual(parseOption('not a number'), O.none())\n```\n\nAdded in v1.0.0\n\n## liftThrowable\n\nA utility function that lifts a function that throws exceptions into a function that returns an `Option`.\n\nThis function is useful for any function that might throw an exception, allowing the developer to handle\nthe exception in a more functional way.\n\n**Signature**\n\n```ts\nexport declare const liftThrowable: <A extends readonly unknown[], B>(f: (...a: A) => B) => (...a: A) => Option<B>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nconst parse = O.liftThrowable(JSON.parse)\n\nassert.deepStrictEqual(parse('1'), O.some(1))\nassert.deepStrictEqual(parse(''), O.none())\n```\n\nAdded in v1.0.0\n\n## toArray\n\nTransforms an `Option` into an `Array`.\nIf the input is `None`, an empty array is returned.\nIf the input is `Some`, the value is wrapped in an array.\n\n**Signature**\n\n```ts\nexport declare const toArray: <A>(self: Option<A>) => A[]\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.toArray(O.some(1)), [1])\nassert.deepStrictEqual(O.toArray(O.none()), [])\n```\n\nAdded in v1.0.0\n\n## toEither\n\nConverts an `Option` to an `Either`, allowing you to provide a value to be used in the case of a `None`.\n\n**Signature**\n\n```ts\nexport declare const toEither: {\n  <A, E>(self: Option<A>, onNone: () => E): Either<E, A>\n  <E>(onNone: () => E): <A>(self: Option<A>) => Either<E, A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from '@fp-ts/core/Function'\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nconst onNone = () => 'error'\nassert.deepStrictEqual(pipe(O.some(1), O.toEither(onNone)), E.right(1))\nassert.deepStrictEqual(pipe(O.none(), O.toEither(onNone)), E.left('error'))\n```\n\nAdded in v1.0.0\n\n## toRefinement\n\nReturns a type guard from a `Option` returning function.\nThis function ensures that a type guard definition is type-safe.\n\n**Signature**\n\n```ts\nexport declare const toRefinement: <A, B extends A>(f: (a: A) => Option<B>) => (a: A) => a is B\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nconst parsePositive = (n: number): O.Option<number> => (n > 0 ? O.some(n) : O.none())\n\nconst isPositive = O.toRefinement(parsePositive)\n\nassert.deepStrictEqual(isPositive(1), true)\nassert.deepStrictEqual(isPositive(-1), false)\n```\n\nAdded in v1.0.0\n\n# debugging\n\n## inspectNone\n\nUseful for debugging purposes, the `onNone` callback is is called if `self` is a `None`.\n\n**Signature**\n\n```ts\nexport declare const inspectNone: {\n  (onNone: () => void): <A>(self: Option<A>) => Option<A>\n  <A>(self: Option<A>, onNone: () => void): Option<A>\n}\n```\n\nAdded in v1.0.0\n\n## inspectSome\n\nUseful for debugging purposes, the `onSome` callback is called with the value of `self` if it is a `Some`.\n\n**Signature**\n\n```ts\nexport declare const inspectSome: {\n  <A>(onSome: (a: A) => void): (self: Option<A>) => Option<A>\n  <A>(self: Option<A>, onSome: (a: A) => void): Option<A>\n}\n```\n\nAdded in v1.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: Option<{}>\n```\n\nAdded in v1.0.0\n\n## andThenBind\n\nA variant of `bind` that sequentially ignores the scope.\n\n**Signature**\n\n```ts\nexport declare const andThenBind: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, that: Option<B>): (\n    self: Option<A>\n  ) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(self: Option<A>, name: Exclude<N, keyof A>, that: Option<B>): Option<{\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }>\n}\n```\n\nAdded in v1.0.0\n\n## appendElement\n\nAppends an element to the end of a tuple wrapped in an `Option` type.\n\n**Signature**\n\n```ts\nexport declare const appendElement: {\n  <A extends readonly any[], B>(self: Option<A>, that: Option<B>): Option<[...A, B]>\n  <B>(that: Option<B>): <A extends readonly any[]>(self: Option<A>) => Option<[...A, B]>\n}\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.appendElement(O.some([1, 2]), O.some(3)), O.some([1, 2, 3]))\nassert.deepStrictEqual(O.appendElement(O.some([1, 2]), O.none()), O.none())\n```\n\nAdded in v1.0.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => Option<B>): (\n    self: Option<A>\n  ) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(self: Option<A>, name: Exclude<N, keyof A>, f: (a: A) => Option<B>): Option<{\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }>\n}\n```\n\nAdded in v1.0.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: {\n  <N extends string>(name: N): <A>(self: Option<A>) => Option<{ [K in N]: A }>\n  <A, N extends string>(self: Option<A>, name: N): Option<{ [K in N]: A }>\n}\n```\n\nAdded in v1.0.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): (\n    self: Option<A>\n  ) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(self: Option<A>, name: Exclude<N, keyof A>, f: (a: A) => B): Option<{\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }>\n}\n```\n\nAdded in v1.0.0\n\n## tupled\n\n**Signature**\n\n```ts\nexport declare const tupled: <A>(self: Option<A>) => Option<[A]>\n```\n\nAdded in v1.0.0\n\n# equivalence\n\n## getEquivalence\n\n**Signature**\n\n```ts\nexport declare const getEquivalence: <A>(E: Equivalence<A>) => Equivalence<Option<A>>\n```\n\n**Example**\n\n```ts\nimport { none, some, getEquivalence } from '@fp-ts/core/Option'\nimport * as N from '@fp-ts/core/Number'\n\nconst isEquivalent = getEquivalence(N.Equivalence)\nassert.deepStrictEqual(isEquivalent(none(), none()), true)\nassert.deepStrictEqual(isEquivalent(none(), some(1)), false)\nassert.deepStrictEqual(isEquivalent(some(1), none()), false)\nassert.deepStrictEqual(isEquivalent(some(1), some(2)), false)\nassert.deepStrictEqual(isEquivalent(some(1), some(1)), true)\n```\n\nAdded in v1.0.0\n\n# error handling\n\n## firstSomeOf\n\nGiven an `Iterable` collection of `Option`s, returns the first `Some` found in the collection.\n\n**Signature**\n\n```ts\nexport declare const firstSomeOf: <A>(collection: Iterable<Option<A>>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.firstSomeOf([O.none(), O.some(1), O.some(2)]), O.some(1))\n```\n\nAdded in v1.0.0\n\n## orElse\n\nReturns the provided `Option` `that` if `self` is `None`, otherwise returns `self`.\n\n**Signature**\n\n```ts\nexport declare const orElse: {\n  <B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<B | A>\n  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<A | B>\n}\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(\n  pipe(\n    O.none(),\n    O.orElse(() => O.none())\n  ),\n  O.none()\n)\nassert.deepStrictEqual(\n  pipe(\n    O.some('a'),\n    O.orElse(() => O.none())\n  ),\n  O.some('a')\n)\nassert.deepStrictEqual(\n  pipe(\n    O.none(),\n    O.orElse(() => O.some('b'))\n  ),\n  O.some('b')\n)\nassert.deepStrictEqual(\n  pipe(\n    O.some('a'),\n    O.orElse(() => O.some('b'))\n  ),\n  O.some('a')\n)\n```\n\nAdded in v1.0.0\n\n## orElseEither\n\nSimilar to `orElse`, but instead of returning a simple union, it returns an `Either` object,\nwhich contains information about which of the two `Option`s has been chosen.\n\nThis is useful when it's important to know whether the value was retrieved from the first `Option` or the second option.\n\n**Signature**\n\n```ts\nexport declare const orElseEither: {\n  <B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<Either<A, B>>\n  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<Either<A, B>>\n}\n```\n\nAdded in v1.0.0\n\n# filtering\n\n## filter\n\nFilters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`.\n\nIf you need to change the type of the `Option` in addition to filtering, see `filterMap`.\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <C extends A, B extends A, A = C>(self: Option<C>, refinement: (a: A) => a is B): Option<B>\n  <B extends A, A = B>(self: Option<B>, predicate: (a: A) => boolean): Option<B>\n  <C extends A, B extends A, A = C>(refinement: (a: A) => a is B): (self: Option<C>) => Option<B>\n  <B extends A, A = B>(predicate: (a: A) => boolean): (self: Option<B>) => Option<B>\n}\n```\n\nAdded in v1.0.0\n\n## filterMap\n\nMaps over the value of an `Option` and filters out `None`s.\n\nUseful when in addition to filtering you also want to change the type of the `Option`.\n\n**Signature**\n\n```ts\nexport declare const filterMap: {\n  <A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>\n  <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>\n}\n```\n\nAdded in v1.0.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare const partitionMap: {\n  <A, B, C>(f: (a: A) => Either<B, C>): (self: Option<A>) => [Option<B>, Option<C>]\n  <A, B, C>(self: Option<A>, f: (a: A) => Either<B, C>): [Option<B>, Option<C>]\n}\n```\n\nAdded in v1.0.0\n\n# folding\n\n## reduceCompact\n\nReduces an `Iterable` of `Option<A>` to a single value of type `B`, elements that are `None` are ignored.\n\n**Signature**\n\n```ts\nexport declare const reduceCompact: {\n  <B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<Option<A>>) => B\n  <A, B>(self: Iterable<Option<A>>, b: B, f: (b: B, a: A) => B): B\n}\n```\n\n**Example**\n\n```ts\nimport { some, none, reduceCompact } from '@fp-ts/core/Option'\nimport { pipe } from '@fp-ts/core/Function'\n\nconst iterable = [some(1), none(), some(2), none()]\nassert.deepStrictEqual(\n  pipe(\n    iterable,\n    reduceCompact(0, (b, a) => b + a)\n  ),\n  3\n)\n```\n\nAdded in v1.0.0\n\n# getters\n\n## getOrElse\n\nReturns the value of the `Option` if it is `Some`, otherwise returns `onNone`\n\n**Signature**\n\n```ts\nexport declare const getOrElse: {\n  <B>(onNone: LazyArg<B>): <A>(self: Option<A>) => B | A\n  <A, B>(self: Option<A>, onNone: LazyArg<B>): A | B\n}\n```\n\n**Example**\n\n```ts\nimport { some, none, getOrElse } from '@fp-ts/core/Option'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(\n  pipe(\n    some(1),\n    getOrElse(() => 0)\n  ),\n  1\n)\nassert.deepStrictEqual(\n  pipe(\n    none(),\n    getOrElse(() => 0)\n  ),\n  0\n)\n```\n\nAdded in v1.0.0\n\n## getOrNull\n\nReturns the value of the `Option` if it is a `Some`, otherwise returns `null`.\n\n**Signature**\n\n```ts\nexport declare const getOrNull: <A>(self: Option<A>) => A | null\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.getOrNull(O.some(1)), 1)\nassert.deepStrictEqual(O.getOrNull(O.none()), null)\n```\n\nAdded in v1.0.0\n\n## getOrUndefined\n\nReturns the value of the `Option` if it is a `Some`, otherwise returns `undefined`.\n\n**Signature**\n\n```ts\nexport declare const getOrUndefined: <A>(self: Option<A>) => A | undefined\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(O.getOrUndefined(O.some(1)), 1)\nassert.deepStrictEqual(O.getOrUndefined(O.none()), undefined)\n```\n\nAdded in v1.0.0\n\n# guards\n\n## isNone\n\nDetermine if a `Option` is a `None`.\n\n**Signature**\n\n```ts\nexport declare const isNone: <A>(self: Option<A>) => self is None\n```\n\n**Example**\n\n```ts\nimport { some, none, isNone } from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(isNone(some(1)), false)\nassert.deepStrictEqual(isNone(none()), true)\n```\n\nAdded in v1.0.0\n\n## isOption\n\nTests if a value is a `Option`.\n\n**Signature**\n\n```ts\nexport declare const isOption: (input: unknown) => input is Option<unknown>\n```\n\n**Example**\n\n```ts\nimport { some, none, isOption } from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(isOption(some(1)), true)\nassert.deepStrictEqual(isOption(none()), true)\nassert.deepStrictEqual(isOption({}), false)\n```\n\nAdded in v1.0.0\n\n## isSome\n\nDetermine if a `Option` is a `Some`.\n\n**Signature**\n\n```ts\nexport declare const isSome: <A>(self: Option<A>) => self is Some<A>\n```\n\n**Example**\n\n```ts\nimport { some, none, isSome } from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(isSome(some(1)), true)\nassert.deepStrictEqual(isSome(none()), false)\n```\n\nAdded in v1.0.0\n\n# lifting\n\n## lift2\n\nLifts a binary function into `Option`.\n\n**Signature**\n\n```ts\nexport declare const lift2: <A, B, C>(\n  f: (a: A, b: B) => C\n) => { (self: Option<A>, that: Option<B>): Option<C>; (that: Option<B>): (self: Option<A>) => Option<C> }\n```\n\nAdded in v1.0.0\n\n## liftEither\n\nLifts an `Either` function to an `Option` function.\n\n**Signature**\n\n```ts\nexport declare const liftEither: <A extends readonly unknown[], E, B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => Option<B>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\n\nconst parse = (s: string) => (isNaN(+s) ? E.left(`Error: ${s} is not a number`) : E.right(+s))\n\nconst parseNumber = O.liftEither(parse)\n\nassert.deepEqual(parseNumber('12'), O.some(12))\nassert.deepEqual(parseNumber('not a number'), O.none())\n```\n\nAdded in v1.0.0\n\n## liftPredicate\n\nTransforms a `Predicate` function into a `Some` of the input value if the predicate returns `true` or `None`\nif the predicate returns `false`.\n\n**Signature**\n\n```ts\nexport declare const liftPredicate: {\n  <C extends A, B extends A, A = C>(refinement: Refinement<A, B>): (c: C) => Option<B>\n  <B extends A, A = B>(predicate: Predicate<A>): (b: B) => Option<B>\n}\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\n\nconst getOption = O.liftPredicate((n: number) => n >= 0)\n\nassert.deepStrictEqual(getOption(-1), O.none())\nassert.deepStrictEqual(getOption(1), O.some(1))\n```\n\nAdded in v1.0.0\n\n# math\n\n## divide\n\n**Signature**\n\n```ts\nexport declare const divide: {\n  (self: Option<number>, that: Option<number>): Option<number>\n  (that: Option<number>): (self: Option<number>) => Option<number>\n}\n```\n\nAdded in v1.0.0\n\n## multiply\n\n**Signature**\n\n```ts\nexport declare const multiply: {\n  (self: Option<number>, that: Option<number>): Option<number>\n  (that: Option<number>): (self: Option<number>) => Option<number>\n}\n```\n\nAdded in v1.0.0\n\n## multiplyCompact\n\nMultiply all numbers in an iterable of `Option<number>` ignoring the `None` values.\n\n**Signature**\n\n```ts\nexport declare const multiplyCompact: (self: Iterable<Option<number>>) => number\n```\n\n**Example**\n\n```ts\nimport { multiplyCompact, some, none } from '@fp-ts/core/Option'\n\nconst iterable = [some(2), none(), some(3), none()]\nassert.deepStrictEqual(multiplyCompact(iterable), 6)\n```\n\nAdded in v1.0.0\n\n## subtract\n\n**Signature**\n\n```ts\nexport declare const subtract: {\n  (self: Option<number>, that: Option<number>): Option<number>\n  (that: Option<number>): (self: Option<number>) => Option<number>\n}\n```\n\nAdded in v1.0.0\n\n## sum\n\n**Signature**\n\n```ts\nexport declare const sum: {\n  (self: Option<number>, that: Option<number>): Option<number>\n  (that: Option<number>): (self: Option<number>) => Option<number>\n}\n```\n\nAdded in v1.0.0\n\n## sumCompact\n\nSum all numbers in an iterable of `Option<number>` ignoring the `None` values.\n\n**Signature**\n\n```ts\nexport declare const sumCompact: (self: Iterable<Option<number>>) => number\n```\n\n**Example**\n\n```ts\nimport { sumCompact, some, none } from '@fp-ts/core/Option'\n\nconst iterable = [some(2), none(), some(3), none()]\nassert.deepStrictEqual(sumCompact(iterable), 5)\n```\n\nAdded in v1.0.0\n\n# models\n\n## None (interface)\n\n**Signature**\n\n```ts\nexport interface None {\n  readonly _tag: 'None'\n}\n```\n\nAdded in v1.0.0\n\n## Option (type alias)\n\n**Signature**\n\n```ts\nexport type Option<A> = None | Some<A>\n```\n\nAdded in v1.0.0\n\n## Some (interface)\n\n**Signature**\n\n```ts\nexport interface Some<A> {\n  readonly _tag: 'Some'\n  readonly value: A\n}\n```\n\nAdded in v1.0.0\n\n# pattern matching\n\n## match\n\nMatches the given `Option` and returns either the provided `onNone` value or the result of the provided `onSome`\nfunction when passed the `Option`'s value.\n\n**Signature**\n\n```ts\nexport declare const match: {\n  <B, A, C = B>(onNone: LazyArg<B>, onSome: (a: A) => C): (self: Option<A>) => B | C\n  <A, B, C = B>(self: Option<A>, onNone: LazyArg<B>, onSome: (a: A) => C): B | C\n}\n```\n\n**Example**\n\n```ts\nimport { some, none, match } from '@fp-ts/core/Option'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(\n  pipe(\n    some(1),\n    match(\n      () => 'a none',\n      (a) => `a some containing ${a}`\n    )\n  ),\n  'a some containing 1'\n)\n\nassert.deepStrictEqual(\n  pipe(\n    none(),\n    match(\n      () => 'a none',\n      (a) => `a some containing ${a}`\n    )\n  ),\n  'a none'\n)\n```\n\nAdded in v1.0.0\n\n# sorting\n\n## getOrder\n\nThe `Order` instance allows `Option` values to be compared with\n`compare`, whenever there is an `Order` instance for\nthe type the `Option` contains.\n\n`None` is considered to be less than any `Some` value.\n\n**Signature**\n\n```ts\nexport declare const getOrder: <A>(O: Order<A>) => Order<Option<A>>\n```\n\n**Example**\n\n```ts\nimport { none, some, getOrder } from '@fp-ts/core/Option'\nimport * as N from '@fp-ts/core/Number'\nimport { pipe } from '@fp-ts/core/Function'\n\nconst O = getOrder(N.Order)\nassert.deepStrictEqual(O.compare(none(), none()), 0)\nassert.deepStrictEqual(O.compare(none(), some(1)), -1)\nassert.deepStrictEqual(O.compare(some(1), none()), 1)\nassert.deepStrictEqual(O.compare(some(1), some(2)), -1)\nassert.deepStrictEqual(O.compare(some(1), some(1)), 0)\n```\n\nAdded in v1.0.0\n\n# transforming\n\n## andThen\n\n**Signature**\n\n```ts\nexport declare const andThen: {\n  <_, B>(self: Option<_>, that: Option<B>): Option<B>\n  <B>(that: Option<B>): <_>(self: Option<_>) => Option<B>\n}\n```\n\nAdded in v1.0.0\n\n## andThenDiscard\n\nSequences the specified `that` `Option` but ignores its value.\n\nIt is useful when we want to chain multiple operations, but only care about the result of `self`.\n\n**Signature**\n\n```ts\nexport declare const andThenDiscard: {\n  <A, _>(self: Option<A>, that: Option<_>): Option<A>\n  <_>(that: Option<_>): <A>(self: Option<A>) => Option<A>\n}\n```\n\nAdded in v1.0.0\n\n## as\n\nMaps the `Some` value of this `Option` to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: { <_, B>(self: Option<_>, b: B): Option<B>; <B>(b: B): <_>(self: Option<_>) => Option<B> }\n```\n\nAdded in v1.0.0\n\n## asUnit\n\nReturns the `Option` resulting from mapping the `Some` value to `void`.\n\nThis is useful when the value of the `Option` is not needed, but the presence or absence of the value is important.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <_>(self: Option<_>) => Option<void>\n```\n\nAdded in v1.0.0\n\n## composeKleisliArrow\n\n**Signature**\n\n```ts\nexport declare const composeKleisliArrow: {\n  <A, B, C>(afb: (a: A) => Option<B>, bfc: (b: B) => Option<C>): (a: A) => Option<C>\n  <B, C>(bfc: (b: B) => Option<C>): <A>(afb: (a: A) => Option<B>) => (a: A) => Option<C>\n}\n```\n\nAdded in v1.0.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: {\n  <A, B>(a: A, self: Option<(a: A) => B>): Option<B>\n  <A, B>(self: Option<(a: A) => B>): (a: A) => Option<B>\n}\n```\n\nAdded in v1.0.0\n\n## flatMap\n\nApplies a function to the value of an `Option` and flattens the result, if the input is `Some`.\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>\n  <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>\n}\n```\n\nAdded in v1.0.0\n\n## flatMapEither\n\nApplies a provided function that returns an `Either` to the contents of an `Option`, flattening the result into another `Option`.\n\n**Signature**\n\n```ts\nexport declare const flatMapEither: {\n  <A, E, B>(f: (a: A) => Either<E, B>): (self: Option<A>) => Option<B>\n  <A, E, B>(self: Option<A>, f: (a: A) => Either<E, B>): Option<B>\n}\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as E from '@fp-ts/core/Either'\nimport { pipe } from '@fp-ts/core/Function'\n\nconst f = (n: number) => (n > 2 ? E.left('Too big') : E.right(n + 1))\n\nassert.deepStrictEqual(pipe(O.some(1), O.flatMapEither(f)), O.some(2))\nassert.deepStrictEqual(pipe(O.some(3), O.flatMapEither(f)), O.none())\n```\n\nAdded in v1.0.0\n\n## flatMapNullable\n\nThis is `flatMap` + `fromNullable`, useful when working with optional values.\n\n**Signature**\n\n```ts\nexport declare const flatMapNullable: {\n  <A, B>(f: (a: A) => B | null | undefined): (self: Option<A>) => Option<NonNullable<B>>\n  <A, B>(self: Option<A>, f: (a: A) => B | null | undefined): Option<NonNullable<B>>\n}\n```\n\n**Example**\n\n```ts\nimport { some, none, flatMapNullable } from '@fp-ts/core/Option'\nimport { pipe } from '@fp-ts/core/Function'\n\ninterface Employee {\n  company?: {\n    address?: {\n      street?: {\n        name?: string\n      }\n    }\n  }\n}\n\nconst employee1: Employee = { company: { address: { street: { name: 'high street' } } } }\n\nassert.deepStrictEqual(\n  pipe(\n    some(employee1),\n    flatMapNullable((employee) => employee.company?.address?.street?.name)\n  ),\n  some('high street')\n)\n\nconst employee2: Employee = { company: { address: { street: {} } } }\n\nassert.deepStrictEqual(\n  pipe(\n    some(employee2),\n    flatMapNullable((employee) => employee.company?.address?.street?.name)\n  ),\n  none()\n)\n```\n\nAdded in v1.0.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(self: Option<Option<A>>) => Option<A>\n```\n\nAdded in v1.0.0\n\n## map\n\nMaps the `Some` side of an `Option` value to a new `Option` value.\n\n**Signature**\n\n```ts\nexport declare const map: {\n  <A, B>(f: (a: A) => B): (self: Option<A>) => Option<B>\n  <A, B>(self: Option<A>, f: (a: A) => B): Option<B>\n}\n```\n\nAdded in v1.0.0\n\n## tap\n\nApplies the provided function `f` to the value of the `Option` if it is `Some` and returns the original `Option`\nunless `f` returns `None`, in which case it returns `None`.\n\nThis function is useful for performing additional computations on the value of the input `Option` without affecting its value.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <A, _>(self: Option<A>, f: (a: A) => Option<_>): Option<A>\n  <A, _>(f: (a: A) => Option<_>): (self: Option<A>) => Option<A>\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## OptionTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface OptionTypeLambda extends TypeLambda {\n  readonly type: Option<this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## Alternative\n\n**Signature**\n\n```ts\nexport declare const Alternative: alternative.Alternative<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: applicative.Applicative<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Chainable\n\n**Signature**\n\n```ts\nexport declare const Chainable: chainable.Chainable<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Coproduct\n\n**Signature**\n\n```ts\nexport declare const Coproduct: coproduct_.Coproduct<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Covariant\n\n**Signature**\n\n```ts\nexport declare const Covariant: covariant.Covariant<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: filterable.Filterable<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## FlatMap\n\n**Signature**\n\n```ts\nexport declare const FlatMap: flatMap_.FlatMap<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: foldable.Foldable<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: monad.Monad<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Of\n\n**Signature**\n\n```ts\nexport declare const Of: of_.Of<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: pointed.Pointed<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Product\n\n**Signature**\n\n```ts\nexport declare const Product: product_.Product<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiAlternative\n\n**Signature**\n\n```ts\nexport declare const SemiAlternative: semiAlternative.SemiAlternative<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiApplicative\n\n**Signature**\n\n```ts\nexport declare const SemiApplicative: semiApplicative.SemiApplicative<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiCoproduct\n\n**Signature**\n\n```ts\nexport declare const SemiCoproduct: semiCoproduct.SemiCoproduct<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiProduct\n\n**Signature**\n\n```ts\nexport declare const SemiProduct: semiProduct.SemiProduct<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: traversable.Traversable<OptionTypeLambda>\n```\n\nAdded in v1.0.0\n\n## contains\n\nReturns a function that checks if an `Option` contains a given value using a provided `Equivalence` instance.\n\n**Signature**\n\n```ts\nexport declare const contains: <A>(isEquivalent: (self: A, that: A) => boolean) => {\n  (a: A): (self: Option<A>) => boolean\n  (self: Option<A>, a: A): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { some, none, contains } from '@fp-ts/core/Option'\nimport { Equivalence } from '@fp-ts/core/Number'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(pipe(some(2), contains(Equivalence)(2)), true)\nassert.deepStrictEqual(pipe(some(1), contains(Equivalence)(2)), false)\nassert.deepStrictEqual(pipe(none(), contains(Equivalence)(2)), false)\n```\n\nAdded in v1.0.0\n\n## exists\n\nCheck if a value in an `Option` type meets a certain predicate.\n\n**Signature**\n\n```ts\nexport declare const exists: {\n  <A>(predicate: Predicate<A>): (self: Option<A>) => boolean\n  <A>(self: Option<A>, predicate: Predicate<A>): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { some, none, exists } from '@fp-ts/core/Option'\nimport { pipe } from '@fp-ts/core/Function'\n\nconst isEven = (n: number) => n % 2 === 0\n\nassert.deepStrictEqual(pipe(some(2), exists(isEven)), true)\nassert.deepStrictEqual(pipe(some(1), exists(isEven)), false)\nassert.deepStrictEqual(pipe(none(), exists(isEven)), false)\n```\n\nAdded in v1.0.0\n\n## getOptionalMonoid\n\nMonoid that models the combination of values that may be absent, elements that are `None` are ignored\nwhile elements that are `Some` are combined using the provided `Semigroup`.\n\nThe `empty` value is `none()`.\n\n**Signature**\n\n```ts\nexport declare const getOptionalMonoid: <A>(Semigroup: Semigroup<A>) => Monoid<Option<A>>\n```\n\n**Example**\n\n```ts\nimport * as O from '@fp-ts/core/Option'\nimport * as N from '@fp-ts/core/Number'\nimport { pipe } from '@fp-ts/core/Function'\n\nconst M = O.getOptionalMonoid(N.SemigroupSum)\n\nassert.deepStrictEqual(M.combine(O.none(), O.none()), O.none())\nassert.deepStrictEqual(M.combine(O.some(1), O.none()), O.some(1))\nassert.deepStrictEqual(M.combine(O.none(), O.some(1)), O.some(1))\nassert.deepStrictEqual(M.combine(O.some(1), O.some(2)), O.some(3))\n```\n\nAdded in v1.0.0\n\n## unit\n\n**Signature**\n\n```ts\nexport declare const unit: Option<void>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Ordering.ts.md",
    "content": "---\ntitle: Ordering.ts\nnav_order: 10\nparent: Modules\n---\n\n## Ordering overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [Monoid](#monoid)\n  - [Semigroup](#semigroup)\n- [model](#model)\n  - [Ordering (type alias)](#ordering-type-alias)\n- [pattern matching](#pattern-matching)\n  - [match](#match)\n- [utils](#utils)\n  - [reverse](#reverse)\n\n---\n\n# instances\n\n## Monoid\n\n`Monoid` instance for `Ordering`, returns the left-most non-zero `Ordering`.\n\nThe `empty` value is `0`.\n\n**Signature**\n\n```ts\nexport declare const Monoid: monoid.Monoid<0 | 1 | -1>\n```\n\n**Example**\n\n```ts\nimport { Monoid } from '@fp-ts/core/Ordering'\n\nassert.deepStrictEqual(Monoid.combine(Monoid.empty, -1), -1)\nassert.deepStrictEqual(Monoid.combine(Monoid.empty, 1), 1)\nassert.deepStrictEqual(Monoid.combine(1, -1), 1)\n```\n\nAdded in v1.0.0\n\n## Semigroup\n\n`Semigroup` instance for `Ordering`, returns the left-most non-zero `Ordering`.\n\n**Signature**\n\n```ts\nexport declare const Semigroup: semigroup.Semigroup<0 | 1 | -1>\n```\n\n**Example**\n\n```ts\nimport { Semigroup } from '@fp-ts/core/Ordering'\n\nassert.deepStrictEqual(Semigroup.combine(0, -1), -1)\nassert.deepStrictEqual(Semigroup.combine(0, 1), 1)\nassert.deepStrictEqual(Semigroup.combine(1, -1), 1)\n```\n\nAdded in v1.0.0\n\n# model\n\n## Ordering (type alias)\n\n**Signature**\n\n```ts\nexport type Ordering = -1 | 0 | 1\n```\n\nAdded in v1.0.0\n\n# pattern matching\n\n## match\n\nDepending on the `Ordering` parameter given to it, returns a value produced by one of the 3 functions provided as parameters.\n\n**Signature**\n\n```ts\nexport declare const match: {\n  <A, B, C = B>(onLessThan: LazyArg<A>, onEqual: LazyArg<B>, onGreaterThan: LazyArg<C>): (self: Ordering) => A | B | C\n  <A, B, C = B>(o: Ordering, onLessThan: LazyArg<A>, onEqual: LazyArg<B>, onGreaterThan: LazyArg<C>): A | B | C\n}\n```\n\n**Example**\n\n```ts\nimport { match } from '@fp-ts/core/Ordering'\nimport { constant } from '@fp-ts/core/Function'\n\nconst toMessage = match(constant('less than'), constant('equal'), constant('greater than'))\n\nassert.deepStrictEqual(toMessage(-1), 'less than')\nassert.deepStrictEqual(toMessage(0), 'equal')\nassert.deepStrictEqual(toMessage(1), 'greater than')\n```\n\nAdded in v1.0.0\n\n# utils\n\n## reverse\n\nInverts the ordering of the input `Ordering`.\n\n**Signature**\n\n```ts\nexport declare const reverse: (o: Ordering) => Ordering\n```\n\n**Example**\n\n```ts\nimport { reverse } from '@fp-ts/core/Ordering'\n\nassert.deepStrictEqual(reverse(1), -1)\nassert.deepStrictEqual(reverse(-1), 1)\nassert.deepStrictEqual(reverse(0), 0)\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Predicate.ts.md",
    "content": "---\ntitle: Predicate.ts\nnav_order: 11\nparent: Modules\n---\n\n## Predicate overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [and](#and)\n  - [not](#not)\n  - [or](#or)\n- [constructors](#constructors)\n  - [contramap](#contramap)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [andThenBind](#andthenbind)\n  - [bindTo](#bindto)\n- [guards](#guards)\n  - [isBigint](#isbigint)\n  - [isBoolean](#isboolean)\n  - [isDate](#isdate)\n  - [isError](#iserror)\n  - [isFunction](#isfunction)\n  - [isNever](#isnever)\n  - [isNotNull](#isnotnull)\n  - [isNotNullable](#isnotnullable)\n  - [isNotUndefined](#isnotundefined)\n  - [isNull](#isnull)\n  - [isNullable](#isnullable)\n  - [isNumber](#isnumber)\n  - [isObject](#isobject)\n  - [isReadonlyRecord](#isreadonlyrecord)\n  - [isRecord](#isrecord)\n  - [isString](#isstring)\n  - [isSymbol](#issymbol)\n  - [isUndefined](#isundefined)\n  - [isUnknown](#isunknown)\n- [instances](#instances)\n  - [Contravariant](#contravariant)\n  - [Invariant](#invariant)\n  - [Of](#of)\n  - [Product](#product)\n  - [SemiProduct](#semiproduct)\n  - [getMonoidAll](#getmonoidall)\n  - [getMonoidAny](#getmonoidany)\n  - [getSemigroupAll](#getsemigroupall)\n  - [getSemigroupAny](#getsemigroupany)\n- [models](#models)\n  - [Predicate (interface)](#predicate-interface)\n  - [Refinement (interface)](#refinement-interface)\n- [type lambdas](#type-lambdas)\n  - [PredicateTypeLambda (interface)](#predicatetypelambda-interface)\n- [utils](#utils)\n  - [all](#all)\n  - [any](#any)\n  - [appendElement](#appendelement)\n  - [compose](#compose)\n  - [of](#of)\n  - [struct](#struct)\n  - [tuple](#tuple)\n  - [tupled](#tupled)\n  - [unit](#unit)\n\n---\n\n# combinators\n\n## and\n\nCombines two predicates into a new predicate that returns `true` if both of the predicates returns `true`.\n\n**Signature**\n\n```ts\nexport declare const and: {\n  <A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>\n  <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>\n}\n```\n\n**Example**\n\n```ts\nimport * as P from '@fp-ts/core/Predicate'\n\nconst minLength = (n: number) => (s: string) => s.length >= n\nconst maxLength = (n: number) => (s: string) => s.length <= n\n\nconst length = (n: number) => P.and(minLength(n), maxLength(n))\n\nassert.deepStrictEqual(length(2)('aa'), true)\nassert.deepStrictEqual(length(2)('a'), false)\nassert.deepStrictEqual(length(2)('aaa'), false)\n```\n\nAdded in v1.0.0\n\n## not\n\nNegates the result of a given predicate.\n\n**Signature**\n\n```ts\nexport declare const not: <A>(self: Predicate<A>) => Predicate<A>\n```\n\n**Example**\n\n```ts\nimport * as P from '@fp-ts/core/Predicate'\nimport * as N from '@fp-ts/core/Number'\n\nconst isPositive = P.not(N.lessThan(0))\n\nassert.deepStrictEqual(isPositive(-1), false)\nassert.deepStrictEqual(isPositive(0), true)\nassert.deepStrictEqual(isPositive(1), true)\n```\n\nAdded in v1.0.0\n\n## or\n\nCombines two predicates into a new predicate that returns `true` if at least one of the predicates returns `true`.\n\n**Signature**\n\n```ts\nexport declare const or: {\n  <A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>\n  <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>\n}\n```\n\n**Example**\n\n```ts\nimport * as P from '@fp-ts/core/Predicate'\nimport * as N from '@fp-ts/core/Number'\n\nconst nonZero = P.or(N.lessThan(0), N.greaterThan(0))\n\nassert.deepStrictEqual(nonZero(-1), true)\nassert.deepStrictEqual(nonZero(0), false)\nassert.deepStrictEqual(nonZero(1), true)\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## contramap\n\nGiven a `Predicate<A>` returns a `Predicate<B>`\n\n**Signature**\n\n```ts\nexport declare const contramap: {\n  <B, A>(f: (b: B) => A): (self: Predicate<A>) => Predicate<B>\n  <A, B>(self: Predicate<A>, f: (b: B) => A): Predicate<B>\n}\n```\n\n**Example**\n\n```ts\nimport * as P from '@fp-ts/core/Predicate'\nimport * as N from '@fp-ts/core/Number'\n\nconst minLength3 = P.contramap(N.greaterThan(2), (s: string) => s.length)\n\nassert.deepStrictEqual(minLength3('a'), false)\nassert.deepStrictEqual(minLength3('aa'), false)\nassert.deepStrictEqual(minLength3('aaa'), true)\nassert.deepStrictEqual(minLength3('aaaa'), true)\n```\n\nAdded in v1.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: Predicate<{}>\n```\n\nAdded in v1.0.0\n\n## andThenBind\n\nA variant of `bind` that sequentially ignores the scope.\n\n**Signature**\n\n```ts\nexport declare const andThenBind: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, that: Predicate<B>): (\n    self: Predicate<A>\n  ) => Predicate<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: Predicate<A>,\n    name: Exclude<N, keyof A>,\n    that: Predicate<B>\n  ): Predicate<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\nAdded in v1.0.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: {\n  <N extends string>(name: N): <A>(self: Predicate<A>) => Predicate<{ readonly [K in N]: A }>\n  <A, N extends string>(self: Predicate<A>, name: N): Predicate<{ readonly [K in N]: A }>\n}\n```\n\nAdded in v1.0.0\n\n# guards\n\n## isBigint\n\nTests if a value is a `bigint`.\n\n**Signature**\n\n```ts\nexport declare const isBigint: (input: unknown) => input is bigint\n```\n\n**Example**\n\n```ts\nimport { isBigint } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isBigint(1n), true)\n\nassert.deepStrictEqual(isBigint(1), false)\n```\n\nAdded in v1.0.0\n\n## isBoolean\n\nTests if a value is a `boolean`.\n\n**Signature**\n\n```ts\nexport declare const isBoolean: (input: unknown) => input is boolean\n```\n\n**Example**\n\n```ts\nimport { isBoolean } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isBoolean(true), true)\n\nassert.deepStrictEqual(isBoolean('true'), false)\n```\n\nAdded in v1.0.0\n\n## isDate\n\nA guard that succeeds when the input is a `Date`.\n\n**Signature**\n\n```ts\nexport declare const isDate: (input: unknown) => input is Date\n```\n\n**Example**\n\n```ts\nimport { isDate } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isDate(new Date()), true)\n\nassert.deepStrictEqual(isDate(null), false)\nassert.deepStrictEqual(isDate({}), false)\n```\n\nAdded in v1.0.0\n\n## isError\n\nA guard that succeeds when the input is an `Error`.\n\n**Signature**\n\n```ts\nexport declare const isError: (input: unknown) => input is Error\n```\n\n**Example**\n\n```ts\nimport { isError } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isError(new Error()), true)\n\nassert.deepStrictEqual(isError(null), false)\nassert.deepStrictEqual(isError({}), false)\n```\n\nAdded in v1.0.0\n\n## isFunction\n\nTests if a value is a `function`.\n\n**Signature**\n\n```ts\nexport declare const isFunction: (input: unknown) => input is Function\n```\n\n**Example**\n\n```ts\nimport { isFunction } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isFunction(isFunction), true)\n\nassert.deepStrictEqual(isFunction('function'), false)\n```\n\nAdded in v1.0.0\n\n## isNever\n\nA guard that always fails.\n\n**Signature**\n\n```ts\nexport declare const isNever: (input: unknown) => input is never\n```\n\n**Example**\n\n```ts\nimport { isNever } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isNever(null), false)\nassert.deepStrictEqual(isNever(undefined), false)\nassert.deepStrictEqual(isNever({}), false)\nassert.deepStrictEqual(isNever([]), false)\n```\n\nAdded in v1.0.0\n\n## isNotNull\n\nTests if a value is not `undefined`.\n\n**Signature**\n\n```ts\nexport declare const isNotNull: <A>(input: A) => input is Exclude<A, null>\n```\n\n**Example**\n\n```ts\nimport { isNotNull } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isNotNull(undefined), true)\nassert.deepStrictEqual(isNotNull('null'), true)\n\nassert.deepStrictEqual(isNotNull(null), false)\n```\n\nAdded in v1.0.0\n\n## isNotNullable\n\nA guard that succeeds when the input is not `null` or `undefined`.\n\n**Signature**\n\n```ts\nexport declare const isNotNullable: <A>(input: A) => input is NonNullable<A>\n```\n\n**Example**\n\n```ts\nimport { isNotNullable } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isNotNullable({}), true)\nassert.deepStrictEqual(isNotNullable([]), true)\n\nassert.deepStrictEqual(isNotNullable(null), false)\nassert.deepStrictEqual(isNotNullable(undefined), false)\n```\n\nAdded in v1.0.0\n\n## isNotUndefined\n\nTests if a value is not `undefined`.\n\n**Signature**\n\n```ts\nexport declare const isNotUndefined: <A>(input: A) => input is Exclude<A, undefined>\n```\n\n**Example**\n\n```ts\nimport { isNotUndefined } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isNotUndefined(null), true)\nassert.deepStrictEqual(isNotUndefined('undefined'), true)\n\nassert.deepStrictEqual(isNotUndefined(undefined), false)\n```\n\nAdded in v1.0.0\n\n## isNull\n\nTests if a value is `undefined`.\n\n**Signature**\n\n```ts\nexport declare const isNull: (input: unknown) => input is null\n```\n\n**Example**\n\n```ts\nimport { isNull } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isNull(null), true)\n\nassert.deepStrictEqual(isNull(undefined), false)\nassert.deepStrictEqual(isNull('null'), false)\n```\n\nAdded in v1.0.0\n\n## isNullable\n\nA guard that succeeds when the input is `null` or `undefined`.\n\n**Signature**\n\n```ts\nexport declare const isNullable: <A>(input: A) => input is Extract<A, null | undefined>\n```\n\n**Example**\n\n```ts\nimport { isNullable } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isNullable(null), true)\nassert.deepStrictEqual(isNullable(undefined), true)\n\nassert.deepStrictEqual(isNullable({}), false)\nassert.deepStrictEqual(isNullable([]), false)\n```\n\nAdded in v1.0.0\n\n## isNumber\n\nTests if a value is a `number`.\n\n**Signature**\n\n```ts\nexport declare const isNumber: (input: unknown) => input is number\n```\n\n**Example**\n\n```ts\nimport { isNumber } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isNumber(2), true)\n\nassert.deepStrictEqual(isNumber('2'), false)\n```\n\nAdded in v1.0.0\n\n## isObject\n\nTests if a value is an `object`.\n\n**Signature**\n\n```ts\nexport declare const isObject: (input: unknown) => input is object\n```\n\n**Example**\n\n```ts\nimport { isObject } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isObject({}), true)\nassert.deepStrictEqual(isObject([]), true)\n\nassert.deepStrictEqual(isObject(null), false)\nassert.deepStrictEqual(isObject(undefined), false)\n```\n\nAdded in v1.0.0\n\n## isReadonlyRecord\n\nA guard that succeeds when the input is a readonly record.\n\n**Signature**\n\n```ts\nexport declare const isReadonlyRecord: (input: unknown) => input is {}\n```\n\n**Example**\n\n```ts\nimport { isReadonlyRecord } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isReadonlyRecord({}), true)\nassert.deepStrictEqual(isReadonlyRecord({ a: 1 }), true)\n\nassert.deepStrictEqual(isReadonlyRecord([]), false)\nassert.deepStrictEqual(isReadonlyRecord([1, 2, 3]), false)\nassert.deepStrictEqual(isReadonlyRecord(null), false)\nassert.deepStrictEqual(isReadonlyRecord(undefined), false)\n```\n\nAdded in v1.0.0\n\n## isRecord\n\nA guard that succeeds when the input is a record.\n\n**Signature**\n\n```ts\nexport declare const isRecord: (input: unknown) => input is {}\n```\n\n**Example**\n\n```ts\nimport { isRecord } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isRecord({}), true)\nassert.deepStrictEqual(isRecord({ a: 1 }), true)\n\nassert.deepStrictEqual(isRecord([]), false)\nassert.deepStrictEqual(isRecord([1, 2, 3]), false)\nassert.deepStrictEqual(isRecord(null), false)\nassert.deepStrictEqual(isRecord(undefined), false)\n```\n\nAdded in v1.0.0\n\n## isString\n\nTests if a value is a `string`.\n\n**Signature**\n\n```ts\nexport declare const isString: (input: unknown) => input is string\n```\n\n**Example**\n\n```ts\nimport { isString } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isString('a'), true)\n\nassert.deepStrictEqual(isString(1), false)\n```\n\nAdded in v1.0.0\n\n## isSymbol\n\nTests if a value is a `symbol`.\n\n**Signature**\n\n```ts\nexport declare const isSymbol: (input: unknown) => input is symbol\n```\n\n**Example**\n\n```ts\nimport { isSymbol } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isSymbol(Symbol.for('a')), true)\n\nassert.deepStrictEqual(isSymbol('a'), false)\n```\n\nAdded in v1.0.0\n\n## isUndefined\n\nTests if a value is `undefined`.\n\n**Signature**\n\n```ts\nexport declare const isUndefined: (input: unknown) => input is undefined\n```\n\n**Example**\n\n```ts\nimport { isUndefined } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isUndefined(undefined), true)\n\nassert.deepStrictEqual(isUndefined(null), false)\nassert.deepStrictEqual(isUndefined('undefined'), false)\n```\n\nAdded in v1.0.0\n\n## isUnknown\n\nA guard that always succeeds.\n\n**Signature**\n\n```ts\nexport declare const isUnknown: (input: unknown) => input is unknown\n```\n\n**Example**\n\n```ts\nimport { isUnknown } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isUnknown(null), true)\nassert.deepStrictEqual(isUnknown(undefined), true)\n\nassert.deepStrictEqual(isUnknown({}), true)\nassert.deepStrictEqual(isUnknown([]), true)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Contravariant\n\n**Signature**\n\n```ts\nexport declare const Contravariant: contravariant.Contravariant<PredicateTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<PredicateTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Of\n\n**Signature**\n\n```ts\nexport declare const Of: of_.Of<PredicateTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Product\n\n**Signature**\n\n```ts\nexport declare const Product: product_.Product<PredicateTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiProduct\n\n**Signature**\n\n```ts\nexport declare const SemiProduct: semiProduct.SemiProduct<PredicateTypeLambda>\n```\n\nAdded in v1.0.0\n\n## getMonoidAll\n\n**Signature**\n\n```ts\nexport declare const getMonoidAll: <A>() => monoid.Monoid<Predicate<A>>\n```\n\nAdded in v1.0.0\n\n## getMonoidAny\n\n**Signature**\n\n```ts\nexport declare const getMonoidAny: <A>() => monoid.Monoid<Predicate<A>>\n```\n\nAdded in v1.0.0\n\n## getSemigroupAll\n\n**Signature**\n\n```ts\nexport declare const getSemigroupAll: <A>() => semigroup.Semigroup<Predicate<A>>\n```\n\nAdded in v1.0.0\n\n## getSemigroupAny\n\n**Signature**\n\n```ts\nexport declare const getSemigroupAny: <A>() => semigroup.Semigroup<Predicate<A>>\n```\n\nAdded in v1.0.0\n\n# models\n\n## Predicate (interface)\n\n**Signature**\n\n```ts\nexport interface Predicate<A> {\n  (a: A): boolean\n}\n```\n\nAdded in v1.0.0\n\n## Refinement (interface)\n\n**Signature**\n\n```ts\nexport interface Refinement<A, B extends A> {\n  (a: A): a is B\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## PredicateTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface PredicateTypeLambda extends TypeLambda {\n  readonly type: Predicate<this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## all\n\n**Signature**\n\n```ts\nexport declare const all: <A>(collection: Iterable<Predicate<A>>) => Predicate<A>\n```\n\nAdded in v1.0.0\n\n## any\n\n**Signature**\n\n```ts\nexport declare const any: <A>(collection: Iterable<Predicate<A>>) => Predicate<A>\n```\n\nAdded in v1.0.0\n\n## appendElement\n\nThis function appends a predicate to a tuple-like predicate, allowing you to create a new predicate that includes\nthe original elements and the new one.\n\n**Signature**\n\n```ts\nexport declare const appendElement: {\n  <A extends readonly any[], B>(self: Predicate<A>, that: Predicate<B>): Predicate<readonly [...A, B]>\n  <B>(that: Predicate<B>): <A extends readonly any[]>(self: Predicate<A>) => Predicate<readonly [...A, B]>\n}\n```\n\nAdded in v1.0.0\n\n## compose\n\n**Signature**\n\n```ts\nexport declare const compose: {\n  <A, B extends A, C extends B>(bc: Refinement<B, C>): (ab: Refinement<A, B>) => Refinement<A, C>\n  <A, B extends A, C extends B>(ab: Refinement<A, B>, bc: Refinement<B, C>): Refinement<A, C>\n}\n```\n\nAdded in v1.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(_: A) => Predicate<A>\n```\n\nAdded in v1.0.0\n\n## struct\n\n**Signature**\n\n```ts\nexport declare const struct: <R extends Record<string, Predicate<any>>>(\n  predicates: R\n) => Predicate<{ readonly [K in keyof R]: [R[K]] extends [Predicate<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n## tuple\n\nSimilar to `Promise.all` but operates on `Predicate`s.\n\n```\n[Predicate<A>, Predicate<B>, ...] -> Predicate<[A, B, ...]>\n```\n\n**Signature**\n\n```ts\nexport declare const tuple: <T extends readonly Predicate<any>[]>(\n  ...predicates: T\n) => Predicate<Readonly<{ [I in keyof T]: [T[I]] extends [Predicate<infer A>] ? A : never }>>\n```\n\nAdded in v1.0.0\n\n## tupled\n\n**Signature**\n\n```ts\nexport declare const tupled: <A>(self: Predicate<A>) => Predicate<readonly [A]>\n```\n\nAdded in v1.0.0\n\n## unit\n\n**Signature**\n\n```ts\nexport declare const unit: Predicate<void>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/ReadonlyArray.ts.md",
    "content": "---\ntitle: ReadonlyArray.ts\nnav_order: 12\nparent: Modules\n---\n\n## ReadonlyArray overview\n\nThis module provides utility functions for working with arrays in TypeScript.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combining](#combining)\n  - [flatMap](#flatmap)\n  - [flatMapNonEmpty](#flatmapnonempty)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatten](#flatten)\n  - [flattenNonEmpty](#flattennonempty)\n- [constructors](#constructors)\n  - [empty](#empty)\n  - [make](#make)\n  - [makeBy](#makeby)\n  - [of](#of)\n  - [range](#range)\n  - [replicate](#replicate)\n  - [unfold](#unfold)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromIterable](#fromiterable)\n  - [fromNullable](#fromnullable)\n  - [fromOption](#fromoption)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [andThenBind](#andthenbind)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [separate](#separate)\n  - [span](#span)\n  - [traverseFilterMap](#traversefiltermap)\n  - [traversePartitionMap](#traversepartitionmap)\n- [folding](#folding)\n  - [combineMap](#combinemap)\n  - [combineMapNonEmpty](#combinemapnonempty)\n  - [coproductMapKind](#coproductmapkind)\n  - [reduce](#reduce)\n  - [reduceKind](#reducekind)\n  - [reduceRight](#reduceright)\n  - [scan](#scan)\n  - [scanRight](#scanright)\n- [getters](#getters)\n  - [chunksOf](#chunksof)\n  - [chunksOfNonEmpty](#chunksofnonempty)\n  - [drop](#drop)\n  - [dropRight](#dropright)\n  - [dropWhile](#dropwhile)\n  - [findFirst](#findfirst)\n  - [findFirstIndex](#findfirstindex)\n  - [findLast](#findlast)\n  - [findLastIndex](#findlastindex)\n  - [get](#get)\n  - [head](#head)\n  - [headNonEmpty](#headnonempty)\n  - [init](#init)\n  - [initNonEmpty](#initnonempty)\n  - [last](#last)\n  - [lastNonEmpty](#lastnonempty)\n  - [lefts](#lefts)\n  - [length](#length)\n  - [rights](#rights)\n  - [splitAt](#splitat)\n  - [splitNonEmptyAt](#splitnonemptyat)\n  - [tail](#tail)\n  - [tailNonEmpty](#tailnonempty)\n  - [take](#take)\n  - [takeRight](#takeright)\n  - [takeWhile](#takewhile)\n  - [unappend](#unappend)\n  - [unprepend](#unprepend)\n- [grouping](#grouping)\n  - [group](#group)\n  - [groupBy](#groupby)\n- [guards](#guards)\n  - [isEmpty](#isempty)\n  - [isEmptyArray](#isemptyarray)\n  - [isNonEmpty](#isnonempty)\n  - [isNonEmptyArray](#isnonemptyarray)\n- [instances](#instances)\n  - [Applicative](#applicative)\n  - [Chainable](#chainable)\n  - [Covariant](#covariant)\n  - [Filterable](#filterable)\n  - [FlatMap](#flatmap)\n  - [Foldable](#foldable)\n  - [Invariant](#invariant)\n  - [Monad](#monad)\n  - [Of](#of)\n  - [Pointed](#pointed)\n  - [Product](#product)\n  - [SemiApplicative](#semiapplicative)\n  - [SemiProduct](#semiproduct)\n  - [Traversable](#traversable)\n  - [TraversableFilterable](#traversablefilterable)\n  - [getIntersectionSemigroup](#getintersectionsemigroup)\n  - [getMonoid](#getmonoid)\n  - [getSemigroup](#getsemigroup)\n  - [getUnionMonoid](#getunionmonoid)\n  - [getUnionSemigroup](#getunionsemigroup)\n- [lifting](#lifting)\n  - [getOrder](#getorder)\n  - [lift2](#lift2)\n  - [liftEither](#lifteither)\n  - [liftMonoid](#liftmonoid)\n  - [liftNullable](#liftnullable)\n  - [liftOption](#liftoption)\n  - [liftPredicate](#liftpredicate)\n- [mapping](#mapping)\n  - [as](#as)\n  - [flap](#flap)\n  - [map](#map)\n  - [mapNonEmpty](#mapnonempty)\n  - [tupled](#tupled)\n- [models](#models)\n  - [NonEmptyArray (type alias)](#nonemptyarray-type-alias)\n  - [NonEmptyReadonlyArray (type alias)](#nonemptyreadonlyarray-type-alias)\n- [pattern matching](#pattern-matching)\n  - [match](#match)\n  - [matchLeft](#matchleft)\n  - [matchRight](#matchright)\n- [predicates](#predicates)\n  - [contains](#contains)\n  - [every](#every)\n  - [some](#some)\n- [sorting](#sorting)\n  - [sort](#sort)\n  - [sortBy](#sortby)\n  - [sortByNonEmpty](#sortbynonempty)\n  - [sortNonEmpty](#sortnonempty)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [sequenceNonEmpty](#sequencenonempty)\n  - [traverse](#traverse)\n  - [traverseNonEmpty](#traversenonempty)\n  - [traverseTap](#traversetap)\n- [type lambdas](#type-lambdas)\n  - [ReadonlyArrayTypeLambda (interface)](#readonlyarraytypelambda-interface)\n- [unsafe](#unsafe)\n  - [unsafeGet](#unsafeget)\n- [utils](#utils)\n  - [ap](#ap)\n  - [append](#append)\n  - [appendAll](#appendall)\n  - [appendAllNonEmpty](#appendallnonempty)\n  - [chop](#chop)\n  - [chopNonEmpty](#chopnonempty)\n  - [composeKleisliArrow](#composekleisliarrow)\n  - [copy](#copy)\n  - [difference](#difference)\n  - [extend](#extend)\n  - [insertAt](#insertat)\n  - [intercalate](#intercalate)\n  - [intercalateNonEmpty](#intercalatenonempty)\n  - [intersection](#intersection)\n  - [intersperse](#intersperse)\n  - [intersperseNonEmpty](#interspersenonempty)\n  - [join](#join)\n  - [max](#max)\n  - [min](#min)\n  - [modify](#modify)\n  - [modifyNonEmptyHead](#modifynonemptyhead)\n  - [modifyNonEmptyLast](#modifynonemptylast)\n  - [modifyOption](#modifyoption)\n  - [prepend](#prepend)\n  - [prependAll](#prependall)\n  - [prependAllNonEmpty](#prependallnonempty)\n  - [remove](#remove)\n  - [replace](#replace)\n  - [replaceOption](#replaceoption)\n  - [reverse](#reverse)\n  - [reverseNonEmpty](#reversenonempty)\n  - [rotate](#rotate)\n  - [rotateNonEmpty](#rotatenonempty)\n  - [setNonEmptyHead](#setnonemptyhead)\n  - [setNonEmptyLast](#setnonemptylast)\n  - [traverseFilter](#traversefilter)\n  - [traversePartition](#traversepartition)\n  - [union](#union)\n  - [unionNonEmpty](#unionnonempty)\n  - [uniq](#uniq)\n  - [uniqNonEmpty](#uniqnonempty)\n  - [unzip](#unzip)\n  - [unzipNonEmpty](#unzipnonempty)\n  - [zip](#zip)\n  - [zipNonEmpty](#zipnonempty)\n  - [zipNonEmptyWith](#zipnonemptywith)\n  - [zipWith](#zipwith)\n\n---\n\n# combining\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A, i: number) => readonly B[]): (self: readonly A[]) => B[]\n  <A, B>(self: readonly A[], f: (a: A, i: number) => readonly B[]): B[]\n}\n```\n\nAdded in v1.0.0\n\n## flatMapNonEmpty\n\n**Signature**\n\n```ts\nexport declare const flatMapNonEmpty: {\n  <A, B>(f: (a: A, i: number) => readonly [B, ...B[]]): (self: readonly [A, ...A[]]) => [B, ...B[]]\n  <A, B>(self: readonly [A, ...A[]], f: (a: A, i: number) => readonly [B, ...B[]]): [B, ...B[]]\n}\n```\n\nAdded in v1.0.0\n\n## flatMapNullable\n\n**Signature**\n\n```ts\nexport declare const flatMapNullable: {\n  <A, B>(f: (a: A) => B | null | undefined): (self: readonly A[]) => NonNullable<B>[]\n  <A, B>(self: readonly A[], f: (a: A) => B | null | undefined): NonNullable<B>[]\n}\n```\n\nAdded in v1.0.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(self: readonly (readonly A[])[]) => A[]\n```\n\nAdded in v1.0.0\n\n## flattenNonEmpty\n\n**Signature**\n\n```ts\nexport declare const flattenNonEmpty: <A>(\n  self: readonly [readonly [A, ...A[]], ...(readonly [A, ...A[]])[]]\n) => [A, ...A[]]\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## empty\n\n**Signature**\n\n```ts\nexport declare const empty: <A = never>() => A[]\n```\n\nAdded in v1.0.0\n\n## make\n\nBuilds a `NonEmptyArray` from an non-empty collection of elements.\n\n**Signature**\n\n```ts\nexport declare const make: <Elements extends [any, ...any[]]>(\n  ...elements: Elements\n) => [Elements[number], ...Elements[number][]]\n```\n\nAdded in v1.0.0\n\n## makeBy\n\nReturn a `NonEmptyArray` of length `n` with element `i` initialized with `f(i)`.\n\n**Note**. `n` is normalized to an integer >= 1.\n\n**Signature**\n\n```ts\nexport declare const makeBy: <A>(n: number, f: (i: number) => A) => [A, ...A[]]\n```\n\n**Example**\n\n```ts\nimport { makeBy } from '@fp-ts/core/ReadonlyArray'\n\nassert.deepStrictEqual(\n  makeBy(5, (n) => n * 2),\n  [0, 2, 4, 6, 8]\n)\n```\n\nAdded in v1.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => [A, ...A[]]\n```\n\nAdded in v1.0.0\n\n## range\n\nReturn a `NonEmptyArray` containing a range of integers, including both endpoints.\n\n**Signature**\n\n```ts\nexport declare const range: (start: number, end: number) => [number, ...number[]]\n```\n\n**Example**\n\n```ts\nimport { range } from '@fp-ts/core/ReadonlyArray'\n\nassert.deepStrictEqual(range(1, 3), [1, 2, 3])\n```\n\nAdded in v1.0.0\n\n## replicate\n\nReturn a `NonEmptyArray` containing a value repeated the specified number of times.\n\n**Note**. `n` is normalized to an integer >= 1.\n\n**Signature**\n\n```ts\nexport declare const replicate: { (n: number): <A>(a: A) => [A, ...A[]]; <A>(a: A, n: number): [A, ...A[]] }\n```\n\n**Example**\n\n```ts\nimport { replicate } from '@fp-ts/core/ReadonlyArray'\n\nassert.deepStrictEqual(replicate('a', 3), ['a', 'a', 'a'])\n```\n\nAdded in v1.0.0\n\n## unfold\n\n**Signature**\n\n```ts\nexport declare const unfold: <B, A>(b: B, f: (b: B) => Option<readonly [A, B]>) => A[]\n```\n\nAdded in v1.0.0\n\n# conversions\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <E, A>(self: Either<E, A>) => A[]\n```\n\nAdded in v1.0.0\n\n## fromIterable\n\n**Signature**\n\n```ts\nexport declare const fromIterable: <A>(collection: Iterable<A>) => A[]\n```\n\nAdded in v1.0.0\n\n## fromNullable\n\n**Signature**\n\n```ts\nexport declare const fromNullable: <A>(a: A) => NonNullable<A>[]\n```\n\nAdded in v1.0.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <A>(self: Option<A>) => A[]\n```\n\nAdded in v1.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: readonly {}[]\n```\n\nAdded in v1.0.0\n\n## andThenBind\n\nA variant of `bind` that sequentially ignores the scope.\n\n**Signature**\n\n```ts\nexport declare const andThenBind: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, that: readonly B[]): (\n    self: readonly A[]\n  ) => { [K in N | keyof A]: K extends keyof A ? A[K] : B }[]\n  <A extends object, N extends string, B>(self: readonly A[], name: Exclude<N, keyof A>, that: readonly B[]): {\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }[]\n}\n```\n\nAdded in v1.0.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => readonly B[]): (\n    self: readonly A[]\n  ) => { [K in N | keyof A]: K extends keyof A ? A[K] : B }[]\n  <A extends object, N extends string, B>(self: readonly A[], name: Exclude<N, keyof A>, f: (a: A) => readonly B[]): {\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }[]\n}\n```\n\nAdded in v1.0.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: {\n  <N extends string>(name: N): <A>(self: readonly A[]) => { [K in N]: A }[]\n  <A, N extends string>(self: readonly A[], name: N): { [K in N]: A }[]\n}\n```\n\nAdded in v1.0.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): (\n    self: readonly A[]\n  ) => { [K in N | keyof A]: K extends keyof A ? A[K] : B }[]\n  <A extends object, N extends string, B>(self: readonly A[], name: Exclude<N, keyof A>, f: (a: A) => B): {\n    [K in N | keyof A]: K extends keyof A ? A[K] : B\n  }[]\n}\n```\n\nAdded in v1.0.0\n\n# filtering\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(self: Iterable<Option<A>>) => A[]\n```\n\nAdded in v1.0.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <C extends A, B extends A, A = C>(refinement: (a: A, i: number) => a is B): (self: Iterable<C>) => B[]\n  <B extends A, A = B>(predicate: (a: A, i: number) => boolean): (self: Iterable<B>) => B[]\n  <C extends A, B extends A, A = C>(self: Iterable<C>, refinement: (a: A, i: number) => a is B): B[]\n  <B extends A, A = B>(self: Iterable<B>, predicate: (a: A, i: number) => boolean): B[]\n}\n```\n\nAdded in v1.0.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare const filterMap: {\n  <A, B>(f: (a: A, i: number) => Option<B>): (self: Iterable<A>) => B[]\n  <A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): B[]\n}\n```\n\nAdded in v1.0.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <C extends A, B extends A, A = C>(refinement: (a: A, i: number) => a is B): (self: Iterable<C>) => [C[], B[]]\n  <B extends A, A = B>(predicate: (a: A, i: number) => boolean): (self: Iterable<B>) => [B[], B[]]\n  <C extends A, B extends A, A = C>(self: Iterable<C>, refinement: (a: A, i: number) => a is B): [C[], B[]]\n  <B extends A, A = B>(self: Iterable<B>, predicate: (a: A, i: number) => boolean): [B[], B[]]\n}\n```\n\nAdded in v1.0.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare const partitionMap: {\n  <A, B, C>(f: (a: A, i: number) => Either<B, C>): (self: Iterable<A>) => [B[], C[]]\n  <A, B, C>(self: Iterable<A>, f: (a: A, i: number) => Either<B, C>): [B[], C[]]\n}\n```\n\nAdded in v1.0.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare const separate: <A, B>(self: Iterable<Either<A, B>>) => [A[], B[]]\n```\n\nAdded in v1.0.0\n\n## span\n\nSplit an `Iterable` into two parts:\n\n1. the longest initial subarray for which all elements satisfy the specified predicate\n2. the remaining elements\n\n**Signature**\n\n```ts\nexport declare const span: {\n  <A, B extends A>(refinement: Refinement<A, B>): (self: Iterable<A>) => [init: B[], rest: A[]]\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => [init: B[], rest: B[]]\n  <A, B extends A>(self: Iterable<A>, refinement: Refinement<A, B>): [init: B[], rest: A[]]\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): [init: B[], rest: B[]]\n}\n```\n\nAdded in v1.0.0\n\n## traverseFilterMap\n\n**Signature**\n\n```ts\nexport declare const traverseFilterMap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, Option<B>>): (self: readonly A[]) => Kind<F, R, O, E, B[]>\n  <A, R, O, E, B>(self: readonly A[], f: (a: A) => Kind<F, R, O, E, Option<B>>): Kind<F, R, O, E, B[]>\n}\n```\n\nAdded in v1.0.0\n\n## traversePartitionMap\n\n**Signature**\n\n```ts\nexport declare const traversePartitionMap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B, C>(f: (a: A) => Kind<F, R, O, E, Either<B, C>>): (self: readonly A[]) => Kind<F, R, O, E, [B[], C[]]>\n  <A, R, O, E, B, C>(self: readonly A[], f: (a: A) => Kind<F, R, O, E, Either<B, C>>): Kind<F, R, O, E, [B[], C[]]>\n}\n```\n\nAdded in v1.0.0\n\n# folding\n\n## combineMap\n\n**Signature**\n\n```ts\nexport declare const combineMap: <M>(Monoid: Monoid<M>) => {\n  <A>(f: (a: A, i: number) => M): (self: Iterable<A>) => M\n  <A>(self: Iterable<A>, f: (a: A, i: number) => M): M\n}\n```\n\nAdded in v1.0.0\n\n## combineMapNonEmpty\n\n**Signature**\n\n```ts\nexport declare const combineMapNonEmpty: <S>(S: Semigroup<S>) => {\n  <A>(f: (a: A, i: number) => S): (self: readonly [A, ...A[]]) => S\n  <A>(self: readonly [A, ...A[]], f: (a: A, i: number) => S): S\n}\n```\n\nAdded in v1.0.0\n\n## coproductMapKind\n\n**Signature**\n\n```ts\nexport declare const coproductMapKind: <G extends TypeLambda>(\n  G: Coproduct<G>\n) => {\n  <A, R, O, E, B>(f: (a: A) => Kind<G, R, O, E, B>): (self: readonly A[]) => Kind<G, R, O, E, B>\n  <A, R, O, E, B>(self: readonly A[], f: (a: A) => Kind<G, R, O, E, B>): Kind<G, R, O, E, B>\n}\n```\n\nAdded in v1.0.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: {\n  <B, A>(b: B, f: (b: B, a: A, i: number) => B): (self: Iterable<A>) => B\n  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A, i: number) => B): B\n}\n```\n\nAdded in v1.0.0\n\n## reduceKind\n\n**Signature**\n\n```ts\nexport declare const reduceKind: <G extends TypeLambda>(\n  G: monad.Monad<G>\n) => {\n  <B, A, R, O, E>(b: B, f: (b: B, a: A) => Kind<G, R, O, E, B>): (self: readonly A[]) => Kind<G, R, O, E, B>\n  <A, B, R, O, E>(self: readonly A[], b: B, f: (b: B, a: A) => Kind<G, R, O, E, B>): Kind<G, R, O, E, B>\n}\n```\n\nAdded in v1.0.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: {\n  <B, A>(b: B, f: (b: B, a: A, i: number) => B): (self: Iterable<A>) => B\n  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A, i: number) => B): B\n}\n```\n\nAdded in v1.0.0\n\n## scan\n\nReduce an `Iterable` from the left, keeping all intermediate results instead of only the final result.\n\n**Signature**\n\n```ts\nexport declare const scan: {\n  <B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<A>) => [B, ...B[]]\n  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A) => B): [B, ...B[]]\n}\n```\n\nAdded in v1.0.0\n\n## scanRight\n\nReduce an `Iterable` from the right, keeping all intermediate results instead of only the final result.\n\n**Signature**\n\n```ts\nexport declare const scanRight: {\n  <B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<A>) => [B, ...B[]]\n  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A) => B): [B, ...B[]]\n}\n```\n\nAdded in v1.0.0\n\n# getters\n\n## chunksOf\n\nSplits an `Iterable` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\nthe `Iterable`. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive\ndefinition of `chunksOf`; it satisfies the property that\n\n```ts\nchunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys)))\n```\n\nwhenever `n` evenly divides the length of `self`.\n\n**Signature**\n\n```ts\nexport declare const chunksOf: {\n  (n: number): <A>(self: Iterable<A>) => [A, ...A[]][]\n  <A>(self: Iterable<A>, n: number): [A, ...A[]][]\n}\n```\n\nAdded in v1.0.0\n\n## chunksOfNonEmpty\n\nSplits a `NonEmptyReadonlyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\nthe `NonEmptyReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const chunksOfNonEmpty: {\n  (n: number): <A>(self: readonly [A, ...A[]]) => [[A, ...A[]], ...[A, ...A[]][]]\n  <A>(self: readonly [A, ...A[]], n: number): [[A, ...A[]], ...[A, ...A[]][]]\n}\n```\n\nAdded in v1.0.0\n\n## drop\n\nDrop a max number of elements from the start of an `Iterable`, creating a new `Array`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const drop: { (n: number): <A>(self: Iterable<A>) => A[]; <A>(self: Iterable<A>, n: number): A[] }\n```\n\nAdded in v1.0.0\n\n## dropRight\n\nDrop a max number of elements from the end of an `Iterable`, creating a new `Array`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const dropRight: { (n: number): <A>(self: Iterable<A>) => A[]; <A>(self: Iterable<A>, n: number): A[] }\n```\n\nAdded in v1.0.0\n\n## dropWhile\n\nRemove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.\n\n**Signature**\n\n```ts\nexport declare const dropWhile: {\n  <A, B extends A>(refinement: Refinement<A, B>): (self: Iterable<A>) => B[]\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => B[]\n  <A, B extends A>(self: Iterable<A>, refinement: Refinement<A, B>): B[]\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): B[]\n}\n```\n\nAdded in v1.0.0\n\n## findFirst\n\nFind the first element for which a predicate holds.\n\n**Signature**\n\n```ts\nexport declare const findFirst: {\n  <A, B extends A>(refinement: Refinement<A, B>): (self: Iterable<A>) => Option<B>\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => Option<B>\n  <A, B extends A>(self: Iterable<A>, refinement: Refinement<A, B>): Option<B>\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Option<B>\n}\n```\n\nAdded in v1.0.0\n\n## findFirstIndex\n\nReturn the first index for which a predicate holds.\n\n**Signature**\n\n```ts\nexport declare const findFirstIndex: {\n  <A>(predicate: Predicate<A>): (self: Iterable<A>) => Option<number>\n  <A>(self: Iterable<A>, predicate: Predicate<A>): Option<number>\n}\n```\n\nAdded in v1.0.0\n\n## findLast\n\nFind the last element for which a predicate holds.\n\n**Signature**\n\n```ts\nexport declare const findLast: {\n  <A, B extends A>(refinement: Refinement<A, B>): (self: Iterable<A>) => Option<B>\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => Option<B>\n  <A, B extends A>(self: Iterable<A>, refinement: Refinement<A, B>): Option<B>\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Option<B>\n}\n```\n\nAdded in v1.0.0\n\n## findLastIndex\n\nReturn the last index for which a predicate holds.\n\n**Signature**\n\n```ts\nexport declare const findLastIndex: {\n  <A>(predicate: Predicate<A>): (self: Iterable<A>) => Option<number>\n  <A>(self: Iterable<A>, predicate: Predicate<A>): Option<number>\n}\n```\n\nAdded in v1.0.0\n\n## get\n\nThis function provides a safe way to read a value at a particular index from a `ReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const get: {\n  (index: number): <A>(self: readonly A[]) => Option<A>\n  <A>(self: readonly A[], index: number): Option<A>\n}\n```\n\nAdded in v1.0.0\n\n## head\n\nGet the first element of a `ReadonlyArray`, or `None` if the `ReadonlyArray` is empty.\n\n**Signature**\n\n```ts\nexport declare const head: <A>(self: readonly A[]) => Option<A>\n```\n\nAdded in v1.0.0\n\n## headNonEmpty\n\n**Signature**\n\n```ts\nexport declare const headNonEmpty: <A>(self: readonly [A, ...A[]]) => A\n```\n\nAdded in v1.0.0\n\n## init\n\nGet all but the last element of an `Iterable`, creating a new `Array`, or `None` if the `Iterable` is empty.\n\n**Signature**\n\n```ts\nexport declare const init: <A>(self: Iterable<A>) => Option<A[]>\n```\n\nAdded in v1.0.0\n\n## initNonEmpty\n\nGet all but the last element of a non empty array, creating a new array.\n\n**Signature**\n\n```ts\nexport declare const initNonEmpty: <A>(self: readonly [A, ...A[]]) => A[]\n```\n\nAdded in v1.0.0\n\n## last\n\nGet the last element in a `ReadonlyArray`, or `None` if the `ReadonlyArray` is empty.\n\n**Signature**\n\n```ts\nexport declare const last: <A>(self: readonly A[]) => Option<A>\n```\n\nAdded in v1.0.0\n\n## lastNonEmpty\n\n**Signature**\n\n```ts\nexport declare const lastNonEmpty: <A>(self: readonly [A, ...A[]]) => A\n```\n\nAdded in v1.0.0\n\n## lefts\n\nReturn all the `Left` elements from an `Interable` of `Either`s.\n\n**Signature**\n\n```ts\nexport declare const lefts: <E, A>(self: Iterable<Either<E, A>>) => E[]\n```\n\nAdded in v1.0.0\n\n## length\n\nReturn the number of elements in a `ReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const length: <A>(self: readonly A[]) => number\n```\n\nAdded in v1.0.0\n\n## rights\n\nReturn all the `Right` elements from an `Interable` of `Either`s.\n\n**Signature**\n\n```ts\nexport declare const rights: <E, A>(self: Iterable<Either<E, A>>) => A[]\n```\n\nAdded in v1.0.0\n\n## splitAt\n\nSplits an `Iterable` into two pieces, the first piece has max `n` elements.\n\n**Signature**\n\n```ts\nexport declare const splitAt: {\n  (n: number): <A>(self: Iterable<A>) => [A[], A[]]\n  <A>(self: Iterable<A>, n: number): [A[], A[]]\n}\n```\n\nAdded in v1.0.0\n\n## splitNonEmptyAt\n\nSplits a `NonEmptyReadonlyArray` into two pieces, the first piece has max `n` elements.\n\n**Signature**\n\n```ts\nexport declare const splitNonEmptyAt: {\n  (n: number): <A>(self: readonly [A, ...A[]]) => [[A, ...A[]], A[]]\n  <A>(self: readonly [A, ...A[]], n: number): [[A, ...A[]], A[]]\n}\n```\n\nAdded in v1.0.0\n\n## tail\n\nGet all but the first element of an `Iterable`, creating a new `Array`, or `None` if the `Iterable` is empty.\n\n**Signature**\n\n```ts\nexport declare const tail: <A>(self: Iterable<A>) => Option<A[]>\n```\n\nAdded in v1.0.0\n\n## tailNonEmpty\n\n**Signature**\n\n```ts\nexport declare const tailNonEmpty: <A>(self: readonly [A, ...A[]]) => A[]\n```\n\nAdded in v1.0.0\n\n## take\n\nKeep only a max number of elements from the start of an `Iterable`, creating a new `Array`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const take: { (n: number): <A>(self: Iterable<A>) => A[]; <A>(self: Iterable<A>, n: number): A[] }\n```\n\nAdded in v1.0.0\n\n## takeRight\n\nKeep only a max number of elements from the end of an `Iterable`, creating a new `Array`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const takeRight: { (n: number): <A>(self: Iterable<A>) => A[]; <A>(self: Iterable<A>, n: number): A[] }\n```\n\nAdded in v1.0.0\n\n## takeWhile\n\nCalculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.\n\n**Signature**\n\n```ts\nexport declare const takeWhile: {\n  <A, B extends A>(refinement: Refinement<A, B>): (self: Iterable<A>) => B[]\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => B[]\n  <A, B extends A>(self: Iterable<A>, refinement: Refinement<A, B>): B[]\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): B[]\n}\n```\n\nAdded in v1.0.0\n\n## unappend\n\nReturn a tuple containing a copy of the `NonEmptyReadonlyArray` without its last element, and that last element.\n\n**Signature**\n\n```ts\nexport declare const unappend: <A>(self: readonly [A, ...A[]]) => [A[], A]\n```\n\nAdded in v1.0.0\n\n## unprepend\n\nReturn a tuple containing the first element, and a new `Array` of the remaining elements, if any.\n\n**Signature**\n\n```ts\nexport declare const unprepend: <A>(self: readonly [A, ...A[]]) => [A, A[]]\n```\n\nAdded in v1.0.0\n\n# grouping\n\n## group\n\nGroup equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s.\n\n**Signature**\n\n```ts\nexport declare const group: <A>(\n  isEquivalent: (self: A, that: A) => boolean\n) => (self: readonly [A, ...A[]]) => [[A, ...A[]], ...[A, ...A[]][]]\n```\n\nAdded in v1.0.0\n\n## groupBy\n\nSplits an `Iterable` into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning\nfunction on each element, and grouping the results according to values returned\n\n**Signature**\n\n```ts\nexport declare const groupBy: {\n  <A>(f: (a: A) => string): (self: Iterable<A>) => Record<string, [A, ...A[]]>\n  <A>(self: Iterable<A>, f: (a: A) => string): Record<string, [A, ...A[]]>\n}\n```\n\nAdded in v1.0.0\n\n# guards\n\n## isEmpty\n\nDetermine if a `ReadonlyArray` is empty narrowing down the type to `readonly []`.\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <A>(self: readonly A[]) => self is readonly []\n```\n\n**Example**\n\n```ts\nimport { isEmpty } from '@fp-ts/core/ReadonlyArray'\n\nassert.deepStrictEqual(isEmpty([]), true)\nassert.deepStrictEqual(isEmpty([1, 2, 3]), false)\n```\n\nAdded in v1.0.0\n\n## isEmptyArray\n\nDetermine if an `Array` is empty narrowing down the type to `[]`.\n\n**Signature**\n\n```ts\nexport declare const isEmptyArray: <A>(self: A[]) => self is []\n```\n\n**Example**\n\n```ts\nimport { isEmptyArray } from '@fp-ts/core/ReadonlyArray'\n\nassert.deepStrictEqual(isEmptyArray([]), true)\nassert.deepStrictEqual(isEmptyArray([1, 2, 3]), false)\n```\n\nAdded in v1.0.0\n\n## isNonEmpty\n\nDetermine if a `ReadonlyArray` is non empty narrowing down the type to `NonEmptyReadonlyArray`.\n\nA `ReadonlyArray` is considered to be a `NonEmptyReadonlyArray` if it contains at least one element.\n\n**Signature**\n\n```ts\nexport declare const isNonEmpty: <A>(self: readonly A[]) => self is readonly [A, ...A[]]\n```\n\n**Example**\n\n```ts\nimport { isNonEmpty } from '@fp-ts/core/ReadonlyArray'\n\nassert.deepStrictEqual(isNonEmpty([]), false)\nassert.deepStrictEqual(isNonEmpty([1, 2, 3]), true)\n```\n\nAdded in v1.0.0\n\n## isNonEmptyArray\n\nDetermine if an `Array` is non empty narrowing down the type to `NonEmptyArray`.\n\nAn `Array` is considered to be a `NonEmptyArray` if it contains at least one element.\n\n**Signature**\n\n```ts\nexport declare const isNonEmptyArray: <A>(self: A[]) => self is [A, ...A[]]\n```\n\n**Example**\n\n```ts\nimport { isNonEmptyArray } from '@fp-ts/core/ReadonlyArray'\n\nassert.deepStrictEqual(isNonEmptyArray([]), false)\nassert.deepStrictEqual(isNonEmptyArray([1, 2, 3]), true)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: applicative.Applicative<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Chainable\n\n**Signature**\n\n```ts\nexport declare const Chainable: chainable.Chainable<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Covariant\n\n**Signature**\n\n```ts\nexport declare const Covariant: covariant.Covariant<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: filterable.Filterable<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## FlatMap\n\n**Signature**\n\n```ts\nexport declare const FlatMap: flatMap_.FlatMap<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: foldable.Foldable<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: monad.Monad<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Of\n\n**Signature**\n\n```ts\nexport declare const Of: of_.Of<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: pointed.Pointed<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Product\n\n**Signature**\n\n```ts\nexport declare const Product: product_.Product<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiApplicative\n\n**Signature**\n\n```ts\nexport declare const SemiApplicative: semiApplicative.SemiApplicative<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiProduct\n\n**Signature**\n\n```ts\nexport declare const SemiProduct: semiProduct.SemiProduct<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: traversable.Traversable<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## TraversableFilterable\n\n**Signature**\n\n```ts\nexport declare const TraversableFilterable: traversableFilterable.TraversableFilterable<ReadonlyArrayTypeLambda>\n```\n\nAdded in v1.0.0\n\n## getIntersectionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getIntersectionSemigroup: <A>(\n  isEquivalent: (self: A, that: A) => boolean\n) => Semigroup<readonly A[]>\n```\n\nAdded in v1.0.0\n\n## getMonoid\n\nReturns a `Monoid` for `ReadonlyArray<A>`.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A>() => Monoid<readonly A[]>\n```\n\nAdded in v1.0.0\n\n## getSemigroup\n\nReturns a `Semigroup` for `ReadonlyArray<A>`.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A>() => Semigroup<readonly A[]>\n```\n\nAdded in v1.0.0\n\n## getUnionMonoid\n\n**Signature**\n\n```ts\nexport declare const getUnionMonoid: <A>(isEquivalent: (self: A, that: A) => boolean) => Monoid<readonly A[]>\n```\n\nAdded in v1.0.0\n\n## getUnionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <A>(isEquivalent: (self: A, that: A) => boolean) => Semigroup<readonly A[]>\n```\n\nAdded in v1.0.0\n\n# lifting\n\n## getOrder\n\nThis function creates and returns a new `Order` for an array of values based on a given `Order` for the elements of the array.\nThe returned `Order` compares two arrays by applying the given `Order` to each element in the arrays.\nIf all elements are equal, the arrays are then compared based on their length.\nIt is useful when you need to compare two arrays of the same type and you have a specific way of comparing each element of the array.\n\n**Signature**\n\n```ts\nexport declare const getOrder: <A>(O: order.Order<A>) => order.Order<readonly A[]>\n```\n\nAdded in v1.0.0\n\n## lift2\n\nLifts a binary function into `ReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const lift2: <A, B, C>(\n  f: (a: A, b: B) => C\n) => { (self: readonly A[], that: readonly B[]): C[]; (that: readonly B[]): (self: readonly A[]) => C[] }\n```\n\nAdded in v1.0.0\n\n## liftEither\n\n**Signature**\n\n```ts\nexport declare const liftEither: <A extends unknown[], E, B>(f: (...a: A) => Either<E, B>) => (...a: A) => B[]\n```\n\nAdded in v1.0.0\n\n## liftMonoid\n\n**Signature**\n\n```ts\nexport declare const liftMonoid: <A>(M: Monoid<A>) => Monoid<readonly A[]>\n```\n\nAdded in v1.0.0\n\n## liftNullable\n\n**Signature**\n\n```ts\nexport declare const liftNullable: <A extends unknown[], B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => NonNullable<B>[]\n```\n\nAdded in v1.0.0\n\n## liftOption\n\n**Signature**\n\n```ts\nexport declare const liftOption: <A extends unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => B[]\n```\n\nAdded in v1.0.0\n\n## liftPredicate\n\n**Signature**\n\n```ts\nexport declare const liftPredicate: {\n  <C extends A, B extends A, A = C>(refinement: Refinement<A, B>): (c: C) => B[]\n  <B extends A, A = B>(predicate: Predicate<A>): (b: B) => B[]\n}\n```\n\nAdded in v1.0.0\n\n# mapping\n\n## as\n\nMaps the success value of this effect to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: { <_, B>(self: readonly _[], b: B): B[]; <B>(b: B): <_>(self: readonly _[]) => B[] }\n```\n\nAdded in v1.0.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: {\n  <A, B>(a: A, self: readonly ((a: A) => B)[]): B[]\n  <A, B>(self: readonly ((a: A) => B)[]): (a: A) => B[]\n}\n```\n\nAdded in v1.0.0\n\n## map\n\n**Signature**\n\n```ts\nexport declare const map: {\n  <A, B>(f: (a: A, i: number) => B): (self: readonly A[]) => B[]\n  <A, B>(self: readonly A[], f: (a: A, i: number) => B): B[]\n}\n```\n\nAdded in v1.0.0\n\n## mapNonEmpty\n\n**Signature**\n\n```ts\nexport declare const mapNonEmpty: {\n  <A, B>(f: (a: A, i: number) => B): (self: readonly [A, ...A[]]) => [B, ...B[]]\n  <A, B>(self: readonly [A, ...A[]], f: (a: A, i: number) => B): [B, ...B[]]\n}\n```\n\nAdded in v1.0.0\n\n## tupled\n\n**Signature**\n\n```ts\nexport declare const tupled: <A>(self: readonly A[]) => [A][]\n```\n\nAdded in v1.0.0\n\n# models\n\n## NonEmptyArray (type alias)\n\n**Signature**\n\n```ts\nexport type NonEmptyArray<A> = [A, ...Array<A>]\n```\n\nAdded in v1.0.0\n\n## NonEmptyReadonlyArray (type alias)\n\n**Signature**\n\n```ts\nexport type NonEmptyReadonlyArray<A> = readonly [A, ...Array<A>]\n```\n\nAdded in v1.0.0\n\n# pattern matching\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: {\n  <B, A, C = B>(onEmpty: LazyArg<B>, onNonEmpty: (self: readonly [A, ...A[]]) => C): (self: readonly A[]) => B | C\n  <A, B, C = B>(self: readonly A[], onEmpty: LazyArg<B>, onNonEmpty: (self: readonly [A, ...A[]]) => C): B | C\n}\n```\n\nAdded in v1.0.0\n\n## matchLeft\n\n**Signature**\n\n```ts\nexport declare const matchLeft: {\n  <B, A, C = B>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: A[]) => C): (self: readonly A[]) => B | C\n  <A, B, C = B>(self: readonly A[], onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: A[]) => C): B | C\n}\n```\n\nAdded in v1.0.0\n\n## matchRight\n\n**Signature**\n\n```ts\nexport declare const matchRight: {\n  <B, A, C = B>(onEmpty: LazyArg<B>, onNonEmpty: (init: A[], last: A) => C): (self: readonly A[]) => B | C\n  <A, B, C = B>(self: readonly A[], onEmpty: LazyArg<B>, onNonEmpty: (init: A[], last: A) => C): B | C\n}\n```\n\nAdded in v1.0.0\n\n# predicates\n\n## contains\n\nReturns a function that checks if a `ReadonlyArray` contains a given value using a provided `equivalence` function.\n\n**Signature**\n\n```ts\nexport declare const contains: <A>(isEquivalent: (self: A, that: A) => boolean) => {\n  (a: A): (self: Iterable<A>) => boolean\n  (self: Iterable<A>, a: A): boolean\n}\n```\n\nAdded in v1.0.0\n\n## every\n\nCheck if a predicate holds true for every `ReadonlyArray` member.\n\n**Signature**\n\n```ts\nexport declare function every<A, B extends A>(\n  refinement: Refinement<A, B>\n): Refinement<ReadonlyArray<A>, ReadonlyArray<B>>\nexport declare function every<A>(predicate: Predicate<A>): Predicate<ReadonlyArray<A>>\n```\n\nAdded in v1.0.0\n\n## some\n\nCheck if a predicate holds true for some `ReadonlyArray` member.\n\n**Signature**\n\n```ts\nexport declare const some: <A>(predicate: Predicate<A>) => (self: readonly A[]) => self is readonly [A, ...A[]]\n```\n\nAdded in v1.0.0\n\n# sorting\n\n## sort\n\nSort the elements of an `Iterable` in increasing order, creating a new `Array`.\n\n**Signature**\n\n```ts\nexport declare const sort: <B>(O: order.Order<B>) => <A extends B>(self: Iterable<A>) => A[]\n```\n\nAdded in v1.0.0\n\n## sortBy\n\nSort the elements of an `Iterable` in increasing order, where elements are compared\nusing first `orders[0]`, then `orders[1]`, etc...\n\n**Signature**\n\n```ts\nexport declare const sortBy: <B>(...orders: readonly order.Order<B>[]) => <A extends B>(self: Iterable<A>) => A[]\n```\n\nAdded in v1.0.0\n\n## sortByNonEmpty\n\n**Signature**\n\n```ts\nexport declare const sortByNonEmpty: <B>(\n  ...orders: readonly order.Order<B>[]\n) => <A extends B>(as: readonly [A, ...A[]]) => [A, ...A[]]\n```\n\nAdded in v1.0.0\n\n## sortNonEmpty\n\nSort the elements of a `NonEmptyReadonlyArray` in increasing order, creating a new `NonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const sortNonEmpty: <B>(O: order.Order<B>) => <A extends B>(self: readonly [A, ...A[]]) => [A, ...A[]]\n```\n\nAdded in v1.0.0\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => <R, O, E, A>(self: readonly Kind<F, R, O, E, A>[]) => Kind<F, R, O, E, A[]>\n```\n\nAdded in v1.0.0\n\n## sequenceNonEmpty\n\n**Signature**\n\n```ts\nexport declare const sequenceNonEmpty: <F extends TypeLambda>(\n  F: semiApplicative.SemiApplicative<F>\n) => <R, O, E, A>(self: readonly [Kind<F, R, O, E, A>, ...Kind<F, R, O, E, A>[]]) => Kind<F, R, O, E, [A, ...A[]]>\n```\n\nAdded in v1.0.0\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A, i: number) => Kind<F, R, O, E, B>): (self: Iterable<A>) => Kind<F, R, O, E, B[]>\n  <A, R, O, E, B>(self: Iterable<A>, f: (a: A, i: number) => Kind<F, R, O, E, B>): Kind<F, R, O, E, B[]>\n}\n```\n\nAdded in v1.0.0\n\n## traverseNonEmpty\n\n**Signature**\n\n```ts\nexport declare const traverseNonEmpty: <F extends TypeLambda>(\n  F: semiApplicative.SemiApplicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A, i: number) => Kind<F, R, O, E, B>): (\n    self: readonly [A, ...A[]]\n  ) => Kind<F, R, O, E, [B, ...B[]]>\n  <A, R, O, E, B>(self: readonly [A, ...A[]], f: (a: A, i: number) => Kind<F, R, O, E, B>): Kind<\n    F,\n    R,\n    O,\n    E,\n    [B, ...B[]]\n  >\n}\n```\n\nAdded in v1.0.0\n\n## traverseTap\n\n**Signature**\n\n```ts\nexport declare const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(self: readonly A[], f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, A[]>\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): (self: readonly A[]) => Kind<F, R, O, E, A[]>\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## ReadonlyArrayTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface ReadonlyArrayTypeLambda extends TypeLambda {\n  readonly type: ReadonlyArray<this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n# unsafe\n\n## unsafeGet\n\nGets an element unsafely, will throw on out of bounds.\n\n**Signature**\n\n```ts\nexport declare const unsafeGet: {\n  (index: number): <A>(self: readonly A[]) => A\n  <A>(self: readonly A[], index: number): A\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: {\n  <A, B>(self: readonly ((a: A) => B)[], that: readonly A[]): B[]\n  <A>(that: readonly A[]): <B>(self: readonly ((a: A) => B)[]) => B[]\n}\n```\n\nAdded in v1.0.0\n\n## append\n\nAppend an element to the end of an `Iterable`, creating a new `NonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const append: {\n  <B>(last: B): <A>(self: Iterable<A>) => [B | A, ...(B | A)[]]\n  <A, B>(self: Iterable<A>, last: B): [A | B, ...(A | B)[]]\n}\n```\n\nAdded in v1.0.0\n\n## appendAll\n\n**Signature**\n\n```ts\nexport declare const appendAll: {\n  <B>(that: Iterable<B>): <A>(self: Iterable<A>) => (B | A)[]\n  <A, B>(self: Iterable<A>, that: Iterable<B>): (A | B)[]\n}\n```\n\nAdded in v1.0.0\n\n## appendAllNonEmpty\n\n**Signature**\n\n```ts\nexport declare const appendAllNonEmpty: {\n  <B>(that: readonly [B, ...B[]]): <A>(self: Iterable<A>) => [B | A, ...(B | A)[]]\n  <B>(that: Iterable<B>): <A>(self: readonly [A, ...A[]]) => [B | A, ...(B | A)[]]\n  <A, B>(self: Iterable<A>, that: readonly [B, ...B[]]): [A | B, ...(A | B)[]]\n  <A, B>(self: readonly [A, ...A[]], that: Iterable<B>): [A | B, ...(A | B)[]]\n}\n```\n\nAdded in v1.0.0\n\n## chop\n\nA useful recursion pattern for processing an `Iterable` to produce a new `Array`, often used for \"chopping\" up the input\n`Iterable`. Typically chop is called with some function that will consume an initial prefix of the `Iterable` and produce a\nvalue and the rest of the `Array`.\n\n**Signature**\n\n```ts\nexport declare const chop: {\n  <A, B>(f: (as: readonly [A, ...A[]]) => readonly [B, readonly A[]]): (self: Iterable<A>) => B[]\n  <A, B>(self: Iterable<A>, f: (as: readonly [A, ...A[]]) => readonly [B, readonly A[]]): B[]\n}\n```\n\nAdded in v1.0.0\n\n## chopNonEmpty\n\nA useful recursion pattern for processing a `NonEmptyReadonlyArray` to produce a new `NonEmptyReadonlyArray`, often used for \"chopping\" up the input\n`NonEmptyReadonlyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `NonEmptyReadonlyArray` and produce a\nvalue and the tail of the `NonEmptyReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const chopNonEmpty: {\n  <A, B>(f: (as: readonly [A, ...A[]]) => readonly [B, readonly A[]]): (self: readonly [A, ...A[]]) => [B, ...B[]]\n  <A, B>(self: readonly [A, ...A[]], f: (as: readonly [A, ...A[]]) => readonly [B, readonly A[]]): [B, ...B[]]\n}\n```\n\nAdded in v1.0.0\n\n## composeKleisliArrow\n\n**Signature**\n\n```ts\nexport declare const composeKleisliArrow: {\n  <A, B, C>(afb: (a: A) => readonly B[], bfc: (b: B) => readonly C[]): (a: A) => readonly C[]\n  <B, C>(bfc: (b: B) => readonly C[]): <A>(afb: (a: A) => readonly B[]) => (a: A) => readonly C[]\n}\n```\n\nAdded in v1.0.0\n\n## copy\n\n**Signature**\n\n```ts\nexport declare const copy: { <A>(self: readonly [A, ...A[]]): [A, ...A[]]; <A>(self: readonly A[]): A[] }\n```\n\nAdded in v1.0.0\n\n## difference\n\nCreates a `Array` of values not included in the other given `Iterable`.\nThe order and references of result values are determined by the first `Iterable`.\n\n**Signature**\n\n```ts\nexport declare const difference: <A>(isEquivalent: (self: A, that: A) => boolean) => {\n  (that: Iterable<A>): (self: Iterable<A>) => A[]\n  (self: Iterable<A>, that: Iterable<A>): A[]\n}\n```\n\nAdded in v1.0.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: {\n  <A, B>(f: (as: readonly A[]) => B): (self: readonly A[]) => B[]\n  <A, B>(self: readonly A[], f: (as: readonly A[]) => B): B[]\n}\n```\n\nAdded in v1.0.0\n\n## insertAt\n\nInsert an element at the specified index, creating a new `NonEmptyArray`,\nor return `None` if the index is out of bounds.\n\n**Signature**\n\n```ts\nexport declare const insertAt: {\n  <B>(i: number, b: B): <A>(self: Iterable<A>) => Option<[B | A, ...(B | A)[]]>\n  <A, B>(self: Iterable<A>, i: number, b: B): Option<[A | B, ...(A | B)[]]>\n}\n```\n\nAdded in v1.0.0\n\n## intercalate\n\nFold an `Iterable`, accumulating values in some `Monoid`, combining adjacent elements\nusing the specified separator.\n\n**Signature**\n\n```ts\nexport declare const intercalate: <A>(M: Monoid<A>) => {\n  (middle: A): (self: Iterable<A>) => A\n  (self: Iterable<A>, middle: A): A\n}\n```\n\nAdded in v1.0.0\n\n## intercalateNonEmpty\n\nPlaces an element in between members of a `NonEmptyReadonlyArray`, then folds the results using the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const intercalateNonEmpty: <A>(S: Semigroup<A>) => {\n  (middle: A): (self: readonly [A, ...A[]]) => A\n  (self: readonly [A, ...A[]], middle: A): A\n}\n```\n\nAdded in v1.0.0\n\n## intersection\n\nCreates an `Array` of unique values that are included in all given `Iterable`s.\nThe order and references of result values are determined by the first `Iterable`.\n\n**Signature**\n\n```ts\nexport declare const intersection: <A>(isEquivalent: (self: A, that: A) => boolean) => {\n  (that: Iterable<A>): (self: Iterable<A>) => A[]\n  (self: Iterable<A>, that: Iterable<A>): A[]\n}\n```\n\nAdded in v1.0.0\n\n## intersperse\n\nPlaces an element in between members of an `Iterable`\n\n**Signature**\n\n```ts\nexport declare const intersperse: {\n  <B>(middle: B): <A>(self: Iterable<A>) => (B | A)[]\n  <A, B>(self: Iterable<A>, middle: B): (A | B)[]\n}\n```\n\nAdded in v1.0.0\n\n## intersperseNonEmpty\n\nPlaces an element in between members of a `NonEmptyReadonlyArray`\n\n**Signature**\n\n```ts\nexport declare const intersperseNonEmpty: {\n  <B>(middle: B): <A>(self: readonly [A, ...A[]]) => [B | A, ...(B | A)[]]\n  <A, B>(self: readonly [A, ...A[]], middle: B): [A | B, ...(A | B)[]]\n}\n```\n\nAdded in v1.0.0\n\n## join\n\n**Signature**\n\n```ts\nexport declare const join: {\n  (middle: string): (self: ReadonlyArray<string>) => string\n  (self: ReadonlyArray<string>, middle: string): string\n}\n```\n\nAdded in v1.0.0\n\n## max\n\n**Signature**\n\n```ts\nexport declare const max: <A>(O: order.Order<A>) => (self: readonly [A, ...A[]]) => A\n```\n\nAdded in v1.0.0\n\n## min\n\n**Signature**\n\n```ts\nexport declare const min: <A>(O: order.Order<A>) => (self: readonly [A, ...A[]]) => A\n```\n\nAdded in v1.0.0\n\n## modify\n\nApply a function to the element at the specified index, creating a new `Array`,\nor return a copy of the input if the index is out of bounds.\n\n**Signature**\n\n```ts\nexport declare const modify: {\n  <A, B>(i: number, f: (a: A) => B): (self: Iterable<A>) => (A | B)[]\n  <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): (A | B)[]\n}\n```\n\nAdded in v1.0.0\n\n## modifyNonEmptyHead\n\nApply a function to the head, creating a new `NonEmptyReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const modifyNonEmptyHead: {\n  <A, B>(f: (a: A) => B): (self: readonly [A, ...A[]]) => [A | B, ...(A | B)[]]\n  <A, B>(self: readonly [A, ...A[]], f: (a: A) => B): [A | B, ...(A | B)[]]\n}\n```\n\nAdded in v1.0.0\n\n## modifyNonEmptyLast\n\nApply a function to the last element, creating a new `NonEmptyReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const modifyNonEmptyLast: {\n  <A, B>(f: (a: A) => B): (self: readonly [A, ...A[]]) => [A | B, ...(A | B)[]]\n  <A, B>(self: readonly [A, ...A[]], f: (a: A) => B): [A | B, ...(A | B)[]]\n}\n```\n\nAdded in v1.0.0\n\n## modifyOption\n\nApply a function to the element at the specified index, creating a new `Array`,\nor return `None` if the index is out of bounds.\n\n**Signature**\n\n```ts\nexport declare const modifyOption: {\n  <A, B>(i: number, f: (a: A) => B): (self: Iterable<A>) => Option<(A | B)[]>\n  <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Option<(A | B)[]>\n}\n```\n\nAdded in v1.0.0\n\n## prepend\n\nPrepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const prepend: {\n  <B>(head: B): <A>(self: Iterable<A>) => [B | A, ...(B | A)[]]\n  <A, B>(self: Iterable<A>, head: B): [A | B, ...(A | B)[]]\n}\n```\n\nAdded in v1.0.0\n\n## prependAll\n\n**Signature**\n\n```ts\nexport declare const prependAll: {\n  <B>(that: Iterable<B>): <A>(self: Iterable<A>) => (B | A)[]\n  <A, B>(self: Iterable<A>, that: Iterable<B>): (A | B)[]\n}\n```\n\nAdded in v1.0.0\n\n## prependAllNonEmpty\n\n**Signature**\n\n```ts\nexport declare const prependAllNonEmpty: {\n  <B>(that: readonly [B, ...B[]]): <A>(self: Iterable<A>) => [B | A, ...(B | A)[]]\n  <B>(that: Iterable<B>): <A>(self: readonly [A, ...A[]]) => [B | A, ...(B | A)[]]\n  <A, B>(self: Iterable<A>, that: readonly [B, ...B[]]): [A | B, ...(A | B)[]]\n  <A, B>(self: readonly [A, ...A[]], that: Iterable<B>): [A | B, ...(A | B)[]]\n}\n```\n\nAdded in v1.0.0\n\n## remove\n\nDelete the element at the specified index, creating a new `Array`,\nor return a copy of the input if the index is out of bounds.\n\n**Signature**\n\n```ts\nexport declare const remove: { (i: number): <A>(self: Iterable<A>) => A[]; <A>(self: Iterable<A>, i: number): A[] }\n```\n\nAdded in v1.0.0\n\n## replace\n\nChange the element at the specified index, creating a new `Array`,\nor return a copy of the input if the index is out of bounds.\n\n**Signature**\n\n```ts\nexport declare const replace: {\n  <B>(i: number, b: B): <A>(self: Iterable<A>) => (B | A)[]\n  <A, B>(self: Iterable<A>, i: number, b: B): (A | B)[]\n}\n```\n\nAdded in v1.0.0\n\n## replaceOption\n\n**Signature**\n\n```ts\nexport declare const replaceOption: {\n  <B>(i: number, b: B): <A>(self: Iterable<A>) => Option<(B | A)[]>\n  <A, B>(self: Iterable<A>, i: number, b: B): Option<(A | B)[]>\n}\n```\n\nAdded in v1.0.0\n\n## reverse\n\nReverse an `Iterable`, creating a new `Array`.\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(self: Iterable<A>) => A[]\n```\n\nAdded in v1.0.0\n\n## reverseNonEmpty\n\n**Signature**\n\n```ts\nexport declare const reverseNonEmpty: <A>(self: readonly [A, ...A[]]) => [A, ...A[]]\n```\n\nAdded in v1.0.0\n\n## rotate\n\nRotate an `Iterable` by `n` steps.\n\n**Signature**\n\n```ts\nexport declare const rotate: { (n: number): <A>(self: Iterable<A>) => A[]; <A>(self: Iterable<A>, n: number): A[] }\n```\n\nAdded in v1.0.0\n\n## rotateNonEmpty\n\nRotate a `NonEmptyReadonlyArray` by `n` steps.\n\n**Signature**\n\n```ts\nexport declare const rotateNonEmpty: {\n  (n: number): <A>(self: readonly [A, ...A[]]) => [A, ...A[]]\n  <A>(self: readonly [A, ...A[]], n: number): [A, ...A[]]\n}\n```\n\nAdded in v1.0.0\n\n## setNonEmptyHead\n\nChange the head, creating a new `NonEmptyReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const setNonEmptyHead: {\n  <B>(b: B): <A>(self: readonly [A, ...A[]]) => [B | A, ...(B | A)[]]\n  <A, B>(self: readonly [A, ...A[]], b: B): [A | B, ...(A | B)[]]\n}\n```\n\nAdded in v1.0.0\n\n## setNonEmptyLast\n\nChange the last element, creating a new `NonEmptyReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const setNonEmptyLast: {\n  <B>(b: B): <A>(self: readonly [A, ...A[]]) => [B | A, ...(B | A)[]]\n  <A, B>(self: readonly [A, ...A[]], b: B): [A | B, ...(A | B)[]]\n}\n```\n\nAdded in v1.0.0\n\n## traverseFilter\n\nFilter values inside a context.\n\n**Signature**\n\n```ts\nexport declare const traverseFilter: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(predicate: (a: A) => Kind<F, R, O, E, boolean>): (\n    self: readonly B[]\n  ) => Kind<F, R, O, E, B[]>\n  <B extends A, R, O, E, A = B>(self: readonly B[], predicate: (a: A) => Kind<F, R, O, E, boolean>): Kind<\n    F,\n    R,\n    O,\n    E,\n    B[]\n  >\n}\n```\n\nAdded in v1.0.0\n\n## traversePartition\n\n**Signature**\n\n```ts\nexport declare const traversePartition: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(predicate: (a: A) => Kind<F, R, O, E, boolean>): (\n    self: readonly B[]\n  ) => Kind<F, R, O, E, [B[], B[]]>\n  <B extends A, R, O, E, A = B>(self: readonly B[], predicate: (a: A) => Kind<F, R, O, E, boolean>): Kind<\n    F,\n    R,\n    O,\n    E,\n    [B[], B[]]\n  >\n}\n```\n\nAdded in v1.0.0\n\n## union\n\n**Signature**\n\n```ts\nexport declare const union: <A>(isEquivalent: (self: A, that: A) => boolean) => {\n  (that: readonly A[]): (self: readonly A[]) => A[]\n  (self: readonly A[], that: readonly A[]): A[]\n}\n```\n\nAdded in v1.0.0\n\n## unionNonEmpty\n\n**Signature**\n\n```ts\nexport declare const unionNonEmpty: <A>(isEquivalent: (self: A, that: A) => boolean) => {\n  (that: readonly [A, ...A[]]): (self: readonly A[]) => [A, ...A[]]\n  (that: readonly A[]): (self: readonly [A, ...A[]]) => [A, ...A[]]\n  (self: readonly A[], that: readonly [A, ...A[]]): [A, ...A[]]\n  (self: readonly [A, ...A[]], that: readonly A[]): [A, ...A[]]\n}\n```\n\nAdded in v1.0.0\n\n## uniq\n\nRemove duplicates from am `Iterable`, keeping the first occurrence of an element.\n\n**Signature**\n\n```ts\nexport declare const uniq: <A>(isEquivalent: (self: A, that: A) => boolean) => (self: Iterable<A>) => A[]\n```\n\nAdded in v1.0.0\n\n## uniqNonEmpty\n\nRemove duplicates from a `NonEmptyReadonlyArray`, keeping the first occurrence of an element.\n\n**Signature**\n\n```ts\nexport declare const uniqNonEmpty: <A>(\n  isEquivalent: (self: A, that: A) => boolean\n) => (self: readonly [A, ...A[]]) => [A, ...A[]]\n```\n\nAdded in v1.0.0\n\n## unzip\n\nThis function is the inverse of `zip`. Takes an `Iterable` of pairs and return two corresponding `Array`s.\n\n**Signature**\n\n```ts\nexport declare const unzip: <A, B>(self: Iterable<[A, B]>) => [A[], B[]]\n```\n\nAdded in v1.0.0\n\n## unzipNonEmpty\n\n**Signature**\n\n```ts\nexport declare const unzipNonEmpty: <A, B>(self: readonly [[A, B], ...[A, B][]]) => [[A, ...A[]], [B, ...B[]]]\n```\n\nAdded in v1.0.0\n\n## zip\n\nTakes two `Iterable`s and returns an `Array` of corresponding pairs.\nIf one input `Iterable` is short, excess elements of the\nlonger `Iterable` are discarded.\n\n**Signature**\n\n```ts\nexport declare const zip: {\n  <B>(that: Iterable<B>): <A>(self: Iterable<A>) => [A, B][]\n  <A, B>(self: Iterable<A>, that: Iterable<B>): [A, B][]\n}\n```\n\nAdded in v1.0.0\n\n## zipNonEmpty\n\n**Signature**\n\n```ts\nexport declare const zipNonEmpty: {\n  <B>(that: readonly [B, ...B[]]): <A>(self: readonly [A, ...A[]]) => [[A, B], ...[A, B][]]\n  <A, B>(self: readonly [A, ...A[]], that: readonly [B, ...B[]]): [[A, B], ...[A, B][]]\n}\n```\n\nAdded in v1.0.0\n\n## zipNonEmptyWith\n\n**Signature**\n\n```ts\nexport declare const zipNonEmptyWith: {\n  <B, A, C>(that: readonly [B, ...B[]], f: (a: A, b: B) => C): (self: readonly [A, ...A[]]) => [C, ...C[]]\n  <A, B, C>(self: readonly [A, ...A[]], that: readonly [B, ...B[]], f: (a: A, b: B) => C): [C, ...C[]]\n}\n```\n\nAdded in v1.0.0\n\n## zipWith\n\nApply a function to pairs of elements at the same index in two `Iterable`s, collecting the results in a new `Array`. If one\ninput `Iterable` is short, excess elements of the longer `Iterable` are discarded.\n\n**Signature**\n\n```ts\nexport declare const zipWith: {\n  <B, A, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => C[]\n  <B, A, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): C[]\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/ReadonlyRecord.ts.md",
    "content": "---\ntitle: ReadonlyRecord.ts\nnav_order: 13\nparent: Modules\n---\n\n## ReadonlyRecord overview\n\nThis module provides utility functions for working with records in TypeScript.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [empty](#empty)\n  - [fromIterable](#fromiterable)\n- [conversions](#conversions)\n  - [collect](#collect)\n  - [toArray](#toarray)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [separate](#separate)\n  - [traverseFilterMap](#traversefiltermap)\n  - [traversePartitionMap](#traversepartitionmap)\n- [guards](#guards)\n  - [isEmpty](#isempty)\n- [instances](#instances)\n  - [Covariant](#covariant)\n  - [Filterable](#filterable)\n  - [Invariant](#invariant)\n  - [Traversable](#traversable)\n  - [TraversableFilterable](#traversablefilterable)\n- [mapping](#mapping)\n  - [as](#as)\n  - [flap](#flap)\n  - [tupled](#tupled)\n- [models](#models)\n  - [ReadonlyRecord (interface)](#readonlyrecord-interface)\n- [record](#record)\n  - [pop](#pop)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n  - [traverseTap](#traversetap)\n- [type lambdas](#type-lambdas)\n  - [ReadonlyRecordTypeLambda (interface)](#readonlyrecordtypelambda-interface)\n- [utils](#utils)\n  - [filterMap](#filtermap)\n  - [get](#get)\n  - [has](#has)\n  - [map](#map)\n  - [modifyOption](#modifyoption)\n  - [remove](#remove)\n  - [replaceOption](#replaceoption)\n  - [size](#size)\n  - [traverseFilter](#traversefilter)\n  - [traversePartition](#traversepartition)\n\n---\n\n# constructors\n\n## empty\n\nCreates a new, empty record.\n\n**Signature**\n\n```ts\nexport declare const empty: <A>() => Record<string, A>\n```\n\nAdded in v1.0.0\n\n## fromIterable\n\nTakes an iterable and a projection function and returns a record.\nThe projection function maps each value of the iterable to a tuple of a key and a value, which is then added to the resulting record.\n\n**Signature**\n\n```ts\nexport declare const fromIterable: {\n  <A, B>(f: (a: A) => readonly [string, B]): (self: Iterable<A>) => Record<string, B>\n  <A, B>(self: Iterable<A>, f: (a: A) => readonly [string, B]): Record<string, B>\n}\n```\n\n**Example**\n\n```ts\nimport { fromIterable } from '@fp-ts/core/ReadonlyRecord'\n\nconst input = [1, 2, 3, 4]\n\nassert.deepStrictEqual(\n  fromIterable(input, (a) => [String(a), a * 2]),\n  { '1': 2, '2': 4, '3': 6, '4': 8 }\n)\n```\n\nAdded in v1.0.0\n\n# conversions\n\n## collect\n\nTransforms the values of a `ReadonlyRecord` into an `Array` with a custom mapping function.\n\n**Signature**\n\n```ts\nexport declare const collect: {\n  <A, B>(f: (key: string, a: A) => B): (self: ReadonlyRecord<A>) => B[]\n  <A, B>(self: ReadonlyRecord<A>, f: (key: string, a: A) => B): B[]\n}\n```\n\n**Example**\n\n```ts\nimport { collect } from '@fp-ts/core/ReadonlyRecord'\n\nconst x = { a: 1, b: 2, c: 3 }\nassert.deepStrictEqual(\n  collect(x, (key, n) => [key, n]),\n  [\n    ['a', 1],\n    ['b', 2],\n    ['c', 3],\n  ]\n)\n```\n\nAdded in v1.0.0\n\n## toArray\n\nConverts a `ReadonlyRecord` to an `Array` of key-value pairs.\n\n**Signature**\n\n```ts\nexport declare const toArray: <A>(self: ReadonlyRecord<A>) => [string, A][]\n```\n\n**Example**\n\n```ts\nimport { toArray } from '@fp-ts/core/ReadonlyRecord'\n\nconst x = { a: 1, b: 2 }\nassert.deepStrictEqual(toArray(x), [\n  ['a', 1],\n  ['b', 2],\n])\n```\n\nAdded in v1.0.0\n\n# filtering\n\n## compact\n\nGiven a `ReadonlyRecord` with `Option` values, returns a `Record` with only the `Some` values, with the same keys.\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(self: ReadonlyRecord<Option<A>>) => Record<string, A>\n```\n\n**Example**\n\n```ts\nimport { compact } from '@fp-ts/core/ReadonlyRecord'\nimport { some, none } from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(compact({ a: some(1), b: none(), c: some(2) }), { a: 1, c: 2 })\n```\n\nAdded in v1.0.0\n\n## filter\n\nSelects properties from a record whose values match the given predicate.\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <C extends A, B extends A, A = C>(refinement: (a: A, key: string) => a is B): (\n    self: ReadonlyRecord<C>\n  ) => Record<string, B>\n  <B extends A, A = B>(predicate: (a: A, key: string) => boolean): (self: ReadonlyRecord<B>) => Record<string, B>\n  <C extends A, B extends A, A = C>(self: ReadonlyRecord<C>, refinement: (a: A, key: string) => a is B): Record<\n    string,\n    B\n  >\n  <B extends A, A = B>(self: ReadonlyRecord<B>, predicate: (a: A, key: string) => boolean): Record<string, B>\n}\n```\n\n**Example**\n\n```ts\nimport { filter } from '@fp-ts/core/ReadonlyRecord'\n\nconst x = { a: 1, b: 2, c: 3, d: 4 }\nassert.deepStrictEqual(\n  filter(x, (n) => n > 2),\n  { c: 3, d: 4 }\n)\n```\n\nAdded in v1.0.0\n\n## partition\n\nPartitions a `ReadonlyRecord` into two separate `Record`s based on the result of a predicate function.\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <C extends A, B extends A, A = C>(refinement: (a: A, key: string) => a is B): (\n    self: ReadonlyRecord<C>\n  ) => [Record<string, C>, Record<string, B>]\n  <B extends A, A = B>(predicate: (a: A, key: string) => boolean): (\n    self: ReadonlyRecord<B>\n  ) => [Record<string, B>, Record<string, B>]\n  <C extends A, B extends A, A = C>(self: ReadonlyRecord<C>, refinement: (a: A, key: string) => a is B): [\n    Record<string, C>,\n    Record<string, B>\n  ]\n  <B extends A, A = B>(self: ReadonlyRecord<B>, predicate: (a: A, key: string) => boolean): [\n    Record<string, B>,\n    Record<string, B>\n  ]\n}\n```\n\n**Example**\n\n```ts\nimport { partition } from '@fp-ts/core/ReadonlyRecord'\n\nassert.deepStrictEqual(\n  partition({ a: 1, b: 3 }, (n) => n > 2),\n  [{ a: 1 }, { b: 3 }]\n)\n```\n\nAdded in v1.0.0\n\n## partitionMap\n\nPartitions the elements of a `ReadonlyRecord` into two groups: those that match a predicate, and those that don't.\n\n**Signature**\n\n```ts\nexport declare const partitionMap: {\n  <A, B, C>(f: (a: A, key: string) => Either<B, C>): (self: ReadonlyRecord<A>) => [Record<string, B>, Record<string, C>]\n  <A, B, C>(self: ReadonlyRecord<A>, f: (a: A, key: string) => Either<B, C>): [Record<string, B>, Record<string, C>]\n}\n```\n\n**Example**\n\n```ts\nimport { partitionMap } from '@fp-ts/core/ReadonlyRecord'\nimport { left, right } from '@fp-ts/core/Either'\n\nconst x = { a: 1, b: 2, c: 3 }\nconst f = (n: number) => (n % 2 === 0 ? right(n) : left(n))\nassert.deepStrictEqual(partitionMap(x, f), [{ a: 1, c: 3 }, { b: 2 }])\n```\n\nAdded in v1.0.0\n\n## separate\n\nPartitions a `ReadonlyRecord` of `Either` values into two separate records,\none with the `Left` values and one with the `Right` values.\n\n**Signature**\n\n```ts\nexport declare const separate: <A, B>(self: ReadonlyRecord<Either<A, B>>) => [Record<string, A>, Record<string, B>]\n```\n\n**Example**\n\n```ts\nimport { separate } from '@fp-ts/core/ReadonlyRecord'\nimport { left, right } from '@fp-ts/core/Either'\n\nassert.deepStrictEqual(separate({ a: left('e'), b: right(1) }), [{ a: 'e' }, { b: 1 }])\n```\n\nAdded in v1.0.0\n\n## traverseFilterMap\n\n**Signature**\n\n```ts\nexport declare const traverseFilterMap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, Option<B>>): (\n    self: ReadonlyRecord<A>\n  ) => Kind<F, R, O, E, Record<string, B>>\n  <A, R, O, E, B>(self: ReadonlyRecord<A>, f: (a: A) => Kind<F, R, O, E, Option<B>>): Kind<\n    F,\n    R,\n    O,\n    E,\n    Record<string, B>\n  >\n}\n```\n\nAdded in v1.0.0\n\n## traversePartitionMap\n\n**Signature**\n\n```ts\nexport declare const traversePartitionMap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B, C>(f: (a: A) => Kind<F, R, O, E, Either<B, C>>): (\n    self: ReadonlyRecord<A>\n  ) => Kind<F, R, O, E, [Record<string, B>, Record<string, C>]>\n  <A, R, O, E, B, C>(self: ReadonlyRecord<A>, f: (a: A) => Kind<F, R, O, E, Either<B, C>>): Kind<\n    F,\n    R,\n    O,\n    E,\n    [Record<string, B>, Record<string, C>]\n  >\n}\n```\n\nAdded in v1.0.0\n\n# guards\n\n## isEmpty\n\nDetermine if a `ReadonlyRecord` is empty.\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <A>(self: ReadonlyRecord<A>) => self is Record<string, never>\n```\n\n**Example**\n\n```ts\nimport { isEmpty } from '@fp-ts/core/ReadonlyRecord'\n\nassert.deepStrictEqual(isEmpty({}), true)\nassert.deepStrictEqual(isEmpty({ a: 3 }), false)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Covariant\n\n**Signature**\n\n```ts\nexport declare const Covariant: covariant.Covariant<ReadonlyRecordTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: filterable.Filterable<ReadonlyRecordTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<ReadonlyRecordTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: traversable.Traversable<ReadonlyRecordTypeLambda>\n```\n\nAdded in v1.0.0\n\n## TraversableFilterable\n\n**Signature**\n\n```ts\nexport declare const TraversableFilterable: traversableFilterable.TraversableFilterable<ReadonlyRecordTypeLambda>\n```\n\nAdded in v1.0.0\n\n# mapping\n\n## as\n\nMaps the success value of this effect to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <B>(b: B): <_>(self: ReadonlyRecord<_>) => Record<string, B>\n  <_, B>(self: ReadonlyRecord<_>, b: B): Record<string, B>\n}\n```\n\nAdded in v1.0.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: {\n  <A, B>(self: ReadonlyRecord<(a: A) => B>): (a: A) => Record<string, B>\n  <A, B>(a: A, self: ReadonlyRecord<(a: A) => B>): Record<string, B>\n}\n```\n\nAdded in v1.0.0\n\n## tupled\n\n**Signature**\n\n```ts\nexport declare const tupled: <A>(self: ReadonlyRecord<A>) => Record<string, [A]>\n```\n\nAdded in v1.0.0\n\n# models\n\n## ReadonlyRecord (interface)\n\n**Signature**\n\n```ts\nexport interface ReadonlyRecord<A> {\n  readonly [x: string]: A\n}\n```\n\nAdded in v1.0.0\n\n# record\n\n## pop\n\nRetrieves the value of the property with the given `key` from a `ReadonlyRecord` and returns an `Option`\nof a tuple with the value and the `ReadonlyRecord` with the removed property.\nIf the key is not present, returns `O.none`.\n\n**Signature**\n\n```ts\nexport declare const pop: {\n  (key: string): <A>(self: ReadonlyRecord<A>) => Option<readonly [A, ReadonlyRecord<A>]>\n  <A>(self: ReadonlyRecord<A>, key: string): Option<readonly [A, ReadonlyRecord<A>]>\n}\n```\n\n**Example**\n\n```ts\nimport { pop } from '@fp-ts/core/ReadonlyRecord'\nimport { some, none } from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(pop({ a: 1, b: 2 }, 'a'), some([1, { b: 2 }]))\nassert.deepStrictEqual(pop({ a: 1, b: 2 }, 'c'), none())\n```\n\nAdded in v1.0.0\n\n# traversing\n\n## sequence\n\nTransforms a `ReadonlyRecord` of `Kind` values into a `Kind` of `Record` values.\n\n**Signature**\n\n```ts\nexport declare const sequence: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => <R, O, E, A>(self: ReadonlyRecord<Kind<F, R, O, E, A>>) => Kind<F, R, O, E, Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport * as RR from '@fp-ts/core/ReadonlyRecord'\nimport { some, none, Applicative } from '@fp-ts/core/Option'\n\nconst sequence = RR.sequence(Applicative)\n\nassert.deepStrictEqual(sequence({ a: some(1), b: some(2) }), some({ a: 1, b: 2 }))\nassert.deepStrictEqual(sequence({ a: none(), b: some(2) }), none())\n```\n\nAdded in v1.0.0\n\n## traverse\n\nMaps each entry of a `ReadonlyRecord` to an effect and collects the results into a new record.\n\n**Signature**\n\n```ts\nexport declare const traverse: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A, key: string) => Kind<F, R, O, E, B>): (\n    self: ReadonlyRecord<A>\n  ) => Kind<F, R, O, E, Record<string, B>>\n  <A, R, O, E, B>(self: ReadonlyRecord<A>, f: (a: A, key: string) => Kind<F, R, O, E, B>): Kind<\n    F,\n    R,\n    O,\n    E,\n    Record<string, B>\n  >\n}\n```\n\n**Example**\n\n```ts\nimport { traverse } from '@fp-ts/core/ReadonlyRecord'\nimport { some, none, Applicative } from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(\n  traverse(Applicative)({ a: 1, b: 2 }, (n: number) => (n <= 2 ? some(n) : none())),\n  some({ a: 1, b: 2 })\n)\nassert.deepStrictEqual(\n  traverse(Applicative)({ a: 1, b: 2 }, (n: number) => (n >= 2 ? some(n) : none())),\n  none()\n)\n```\n\nAdded in v1.0.0\n\n## traverseTap\n\n**Signature**\n\n```ts\nexport declare const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): (self: ReadonlyRecord<A>) => Kind<F, R, O, E, Record<string, A>>\n  <A, R, O, E, B>(self: ReadonlyRecord<A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Record<string, A>>\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## ReadonlyRecordTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface ReadonlyRecordTypeLambda extends TypeLambda {\n  readonly type: ReadonlyRecord<this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## filterMap\n\nTransforms a `ReadonlyRecord` into a `Record` by applying the function `f` to each key and value in the original `ReadonlyRecord`.\nIf the function returns `Some`, the key-value pair is included in the output `Record`.\n\n**Signature**\n\n```ts\nexport declare const filterMap: {\n  <A, B>(f: (a: A, key: string) => Option<B>): (self: ReadonlyRecord<A>) => Record<string, B>\n  <A, B>(self: ReadonlyRecord<A>, f: (a: A, key: string) => Option<B>): Record<string, B>\n}\n```\n\n**Example**\n\n```ts\nimport { filterMap } from '@fp-ts/core/ReadonlyRecord'\nimport { some, none } from '@fp-ts/core/Option'\n\nconst x = { a: 1, b: 2, c: 3 }\nconst f = (a: number, key: string) => (a > 2 ? some(a * 2) : none())\nassert.deepStrictEqual(filterMap(x, f), { c: 6 })\n```\n\nAdded in v1.0.0\n\n## get\n\nRetrieve a value at a particular key from a `ReadonlyRecord`, returning it wrapped in an `Option`.\n\n**Signature**\n\n```ts\nexport declare const get: {\n  (key: string): <A>(self: ReadonlyRecord<A>) => Option<A>\n  <A>(self: ReadonlyRecord<A>, key: string): Option<A>\n}\n```\n\n**Example**\n\n```ts\nimport { get } from '@fp-ts/core/ReadonlyRecord'\nimport { some, none } from '@fp-ts/core/Option'\n\nconst person = { name: 'John Doe', age: 35 }\n\nassert.deepStrictEqual(get(person, 'name'), some('John Doe'))\nassert.deepStrictEqual(get(person, 'email'), none())\n```\n\nAdded in v1.0.0\n\n## has\n\nCheck if a given `key` exists in a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare const has: {\n  (key: string): <A>(self: ReadonlyRecord<A>) => boolean\n  <A>(self: ReadonlyRecord<A>, key: string): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { has } from '@fp-ts/core/ReadonlyRecord'\n\nassert.deepStrictEqual(has({ a: 1, b: 2 }, 'a'), true)\nassert.deepStrictEqual(has({ a: 1, b: 2 }, 'c'), false)\n```\n\nAdded in v1.0.0\n\n## map\n\nMaps a `ReadonlyRecord` into another `Record` by applying a transformation function to each of its values.\n\n**Signature**\n\n```ts\nexport declare const map: {\n  <K extends string, A, B>(f: (a: A, key: K) => B): (self: Readonly<Record<K, A>>) => Record<K, B>\n  <K extends string, A, B>(self: Readonly<Record<K, A>>, f: (a: A, key: K) => B): Record<K, B>\n}\n```\n\n**Example**\n\n```ts\nimport { map } from '@fp-ts/core/ReadonlyRecord'\n\nconst f = (n: number) => `-${n}`\n\nassert.deepStrictEqual(map({ a: 3, b: 5 }, f), { a: '-3', b: '-5' })\n\nconst g = (n: number, key: string) => `${key.toUpperCase()}-${n}`\n\nassert.deepStrictEqual(map({ a: 3, b: 5 }, g), { a: 'A-3', b: 'B-5' })\n```\n\nAdded in v1.0.0\n\n## modifyOption\n\nApply a function to the element at the specified key, creating a new record,\nor return `None` if the key doesn't exist.\n\n**Signature**\n\n```ts\nexport declare const modifyOption: {\n  <A, B>(key: string, f: (a: A) => B): (self: ReadonlyRecord<A>) => Option<Record<string, A | B>>\n  <A, B>(self: ReadonlyRecord<A>, key: string, f: (a: A) => B): Option<Record<string, A | B>>\n}\n```\n\n**Example**\n\n```ts\nimport { modifyOption } from '@fp-ts/core/ReadonlyRecord'\nimport { some, none } from '@fp-ts/core/Option'\n\nconst f = (x: number) => x * 2\n\nassert.deepStrictEqual(modifyOption({ a: 3 }, 'a', f), some({ a: 6 }))\nassert.deepStrictEqual(modifyOption({ a: 3 }, 'b', f), none())\n```\n\nAdded in v1.0.0\n\n## remove\n\nRemoves a key from a `ReadonlyRecord` and returns a new `Record`\n\n**Signature**\n\n```ts\nexport declare const remove: {\n  (key: string): <A>(self: ReadonlyRecord<A>) => Record<string, A>\n  <A>(self: ReadonlyRecord<A>, key: string): Record<string, A>\n}\n```\n\n**Example**\n\n```ts\nimport { remove } from '@fp-ts/core/ReadonlyRecord'\n\nassert.deepStrictEqual(remove({ a: 1, b: 2 }, 'a'), { b: 2 })\n```\n\nAdded in v1.0.0\n\n## replaceOption\n\nReplaces a value in the record with the new value passed as parameter.\n\n**Signature**\n\n```ts\nexport declare const replaceOption: {\n  <B>(key: string, b: B): <A>(self: ReadonlyRecord<A>) => Option<Record<string, B | A>>\n  <A, B>(self: ReadonlyRecord<A>, key: string, b: B): Option<Record<string, A | B>>\n}\n```\n\n**Example**\n\n```ts\nimport { replaceOption } from '@fp-ts/core/ReadonlyRecord'\nimport { some, none } from '@fp-ts/core/Option'\n\nassert.deepStrictEqual(replaceOption({ a: 1, b: 2, c: 3 }, 'a', 10), some({ a: 10, b: 2, c: 3 }))\nassert.deepStrictEqual(replaceOption({}, 'a', 10), none())\n```\n\nAdded in v1.0.0\n\n## size\n\nReturns the number of key/value pairs in a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare const size: <A>(self: ReadonlyRecord<A>) => number\n```\n\n**Example**\n\n```ts\nimport { size } from '@fp-ts/core/ReadonlyRecord'\n\nassert.deepStrictEqual(size({ a: 'a', b: 1, c: true }), 3)\n```\n\nAdded in v1.0.0\n\n## traverseFilter\n\nFilter values inside a context.\n\n**Signature**\n\n```ts\nexport declare const traverseFilter: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(predicate: (a: A) => Kind<F, R, O, E, boolean>): (\n    self: ReadonlyRecord<B>\n  ) => Kind<F, R, O, E, Record<string, B>>\n  <B extends A, R, O, E, A = B>(self: ReadonlyRecord<B>, predicate: (a: A) => Kind<F, R, O, E, boolean>): Kind<\n    F,\n    R,\n    O,\n    E,\n    Record<string, B>\n  >\n}\n```\n\nAdded in v1.0.0\n\n## traversePartition\n\n**Signature**\n\n```ts\nexport declare const traversePartition: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(predicate: (a: A) => Kind<F, R, O, E, boolean>): (\n    self: ReadonlyRecord<B>\n  ) => Kind<F, R, O, E, [Record<string, B>, Record<string, B>]>\n  <B extends A, R, O, E, A = B>(self: ReadonlyRecord<B>, predicate: (a: A) => Kind<F, R, O, E, boolean>): Kind<\n    F,\n    R,\n    O,\n    E,\n    [Record<string, B>, Record<string, B>]\n  >\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/String.ts.md",
    "content": "---\ntitle: String.ts\nnav_order: 14\nparent: Modules\n---\n\n## String overview\n\nThis module provides utility functions and type class instances for working with the `string` type in TypeScript.\nIt includes functions for basic string manipulation, as well as type class instances for\n`Equivalence`, `Order`, `Semigroup`, and `Monoid`.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [guards](#guards)\n  - [isString](#isstring)\n- [instances](#instances)\n  - [Equivalence](#equivalence)\n  - [Monoid](#monoid)\n  - [Order](#order)\n  - [Semigroup](#semigroup)\n- [utils](#utils)\n  - [concat](#concat)\n  - [empty](#empty)\n  - [endsWith](#endswith)\n  - [endsWithPosition](#endswithposition)\n  - [includes](#includes)\n  - [includesWithPosition](#includeswithposition)\n  - [isEmpty](#isempty)\n  - [isNonEmpty](#isnonempty)\n  - [length](#length)\n  - [replace](#replace)\n  - [slice](#slice)\n  - [split](#split)\n  - [startsWith](#startswith)\n  - [startsWithPosition](#startswithposition)\n  - [takeLeft](#takeleft)\n  - [takeRight](#takeright)\n  - [toLowerCase](#tolowercase)\n  - [toUpperCase](#touppercase)\n  - [trim](#trim)\n  - [trimEnd](#trimend)\n  - [trimStart](#trimstart)\n\n---\n\n# guards\n\n## isString\n\nTests if a value is a `string`.\n\n**Signature**\n\n```ts\nexport declare const isString: Refinement<unknown, string>\n```\n\n**Example**\n\n```ts\nimport { isString } from '@fp-ts/core/String'\n\nassert.deepStrictEqual(isString('a'), true)\nassert.deepStrictEqual(isString(1), false)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Equivalence\n\n**Signature**\n\n```ts\nexport declare const Equivalence: equivalence.Equivalence<string>\n```\n\nAdded in v1.0.0\n\n## Monoid\n\n`string` monoid under concatenation.\n\nThe `empty` value is `''`.\n\n**Signature**\n\n```ts\nexport declare const Monoid: monoid.Monoid<string>\n```\n\nAdded in v1.0.0\n\n## Order\n\n**Signature**\n\n```ts\nexport declare const Order: order.Order<string>\n```\n\nAdded in v1.0.0\n\n## Semigroup\n\n`string` semigroup under concatenation.\n\n**Signature**\n\n```ts\nexport declare const Semigroup: semigroup.Semigroup<string>\n```\n\nAdded in v1.0.0\n\n# utils\n\n## concat\n\n**Signature**\n\n```ts\nexport declare const concat: { (that: string): (self: string) => string; (self: string, that: string): string }\n```\n\nAdded in v1.0.0\n\n## empty\n\nThe empty string `\"\"`.\n\n**Signature**\n\n```ts\nexport declare const empty: ''\n```\n\nAdded in v1.0.0\n\n## endsWith\n\n**Signature**\n\n```ts\nexport declare const endsWith: {\n  (searchString: string): (self: string) => boolean\n  (self: string, searchString: string): boolean\n}\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.endsWith('abc', 'c'), true)\nassert.deepStrictEqual(S.endsWith('ab', 'c'), false)\n```\n\nAdded in v1.0.0\n\n## endsWithPosition\n\n**Signature**\n\n```ts\nexport declare const endsWithPosition: {\n  (searchString: string, position: number): (self: string) => boolean\n  (self: string, searchString: string, position: number): boolean\n}\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.endsWithPosition('abc', 'b', 2), true)\nassert.deepStrictEqual(S.endsWithPosition('abc', 'c', 2), false)\n```\n\nAdded in v1.0.0\n\n## includes\n\nReturns `true` if `searchString` appears as a substring of `self`, at one or more positions that are\ngreater than or equal to `0`; otherwise, returns `false`.\n\n**Signature**\n\n```ts\nexport declare const includes: {\n  (searchString: string): (self: string) => boolean\n  (self: string, searchString: string): boolean\n}\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.includes('abc', 'b'), true)\nassert.deepStrictEqual(S.includes('abc', 'd'), false)\n```\n\nAdded in v1.0.0\n\n## includesWithPosition\n\nReturns `true` if `searchString` appears as a substring of `self`, at one or more positions that are\ngreater than or equal to `position`; otherwise, returns `false`.\n\n**Signature**\n\n```ts\nexport declare const includesWithPosition: {\n  (searchString: string, position: number): (self: string) => boolean\n  (self: string, searchString: string, position: number): boolean\n}\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.includesWithPosition('abc', 'b', 1), true)\nassert.deepStrictEqual(S.includesWithPosition('abc', 'a', 1), false)\n```\n\nAdded in v1.0.0\n\n## isEmpty\n\nTest whether a `string` is empty.\n\n**Signature**\n\n```ts\nexport declare const isEmpty: (self: string) => self is ''\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.isEmpty(''), true)\nassert.deepStrictEqual(S.isEmpty('a'), false)\n```\n\nAdded in v1.0.0\n\n## isNonEmpty\n\nTest whether a `string` is non empty.\n\n**Signature**\n\n```ts\nexport declare const isNonEmpty: (self: string) => boolean\n```\n\nAdded in v1.0.0\n\n## length\n\nCalculate the number of characters in a `string`.\n\n**Signature**\n\n```ts\nexport declare const length: (self: string) => number\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.length('abc'), 3)\n```\n\nAdded in v1.0.0\n\n## replace\n\n**Signature**\n\n```ts\nexport declare const replace: {\n  (searchValue: string | RegExp, replaceValue: string): (self: string) => string\n  (self: string, searchValue: string | RegExp, replaceValue: string): string\n}\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(pipe('abc', S.replace('b', 'd')), 'adc')\n```\n\nAdded in v1.0.0\n\n## slice\n\n**Signature**\n\n```ts\nexport declare const slice: {\n  (start: number, end: number): (self: string) => string\n  (self: string, start: number, end: number): string\n}\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(pipe('abcd', S.slice(1, 3)), 'bc')\n```\n\nAdded in v1.0.0\n\n## split\n\n**Signature**\n\n```ts\nexport declare const split: {\n  (separator: string | RegExp): (self: string) => [string, ...string[]]\n  (self: string, separator: string | RegExp): [string, ...string[]]\n}\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(pipe('abc', S.split('')), ['a', 'b', 'c'])\nassert.deepStrictEqual(pipe('', S.split('')), [''])\n```\n\nAdded in v1.0.0\n\n## startsWith\n\nReturns `true` if the sequence of elements of `searchString` is the\nsame as the corresponding elements of `s` starting at\nposition. Otherwise returns false.\n\n**Signature**\n\n```ts\nexport declare const startsWith: {\n  (searchString: string): (self: string) => boolean\n  (self: string, searchString: string): boolean\n}\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.startsWith('abc', 'a'), true)\nassert.deepStrictEqual(S.startsWith('bc', 'a'), false)\n```\n\nAdded in v1.0.0\n\n## startsWithPosition\n\n**Signature**\n\n```ts\nexport declare const startsWithPosition: {\n  (searchString: string, position: number): (self: string) => boolean\n  (self: string, searchString: string, position: number): boolean\n}\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.startsWithPosition('abc', 'b', 1), true)\nassert.deepStrictEqual(S.startsWithPosition('bc', 'a', 1), false)\n```\n\nAdded in v1.0.0\n\n## takeLeft\n\nKeep the specified number of characters from the start of a string.\n\nIf `n` is larger than the available number of characters, the string will\nbe returned whole.\n\nIf `n` is not a positive number, an empty string will be returned.\n\nIf `n` is a float, it will be rounded down to the nearest integer.\n\n**Signature**\n\n```ts\nexport declare const takeLeft: { (n: number): (self: string) => string; (self: string, n: number): string }\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.takeLeft('Hello World', 5), 'Hello')\n```\n\nAdded in v1.0.0\n\n## takeRight\n\nKeep the specified number of characters from the end of a string.\n\nIf `n` is larger than the available number of characters, the string will\nbe returned whole.\n\nIf `n` is not a positive number, an empty string will be returned.\n\nIf `n` is a float, it will be rounded down to the nearest integer.\n\n**Signature**\n\n```ts\nexport declare const takeRight: { (n: number): (self: string) => string; (self: string, n: number): string }\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.takeRight('Hello World', 5), 'World')\n```\n\nAdded in v1.0.0\n\n## toLowerCase\n\n**Signature**\n\n```ts\nexport declare const toLowerCase: (self: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(pipe('A', S.toLowerCase), 'a')\n```\n\nAdded in v1.0.0\n\n## toUpperCase\n\n**Signature**\n\n```ts\nexport declare const toUpperCase: (self: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(pipe('a', S.toUpperCase), 'A')\n```\n\nAdded in v1.0.0\n\n## trim\n\n**Signature**\n\n```ts\nexport declare const trim: (self: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.trim(' a '), 'a')\n```\n\nAdded in v1.0.0\n\n## trimEnd\n\n**Signature**\n\n```ts\nexport declare const trimEnd: (self: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.trimEnd(' a '), ' a')\n```\n\nAdded in v1.0.0\n\n## trimStart\n\n**Signature**\n\n```ts\nexport declare const trimStart: (self: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from '@fp-ts/core/String'\n\nassert.deepStrictEqual(S.trimStart(' a '), 'a ')\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Struct.ts.md",
    "content": "---\ntitle: Struct.ts\nnav_order: 15\nparent: Modules\n---\n\n## Struct overview\n\nThis module provides utility functions for working with structs in TypeScript.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [getEquivalence](#getequivalence)\n  - [getMonoid](#getmonoid)\n  - [getOrder](#getorder)\n  - [getSemigroup](#getsemigroup)\n- [utils](#utils)\n  - [omit](#omit)\n  - [pick](#pick)\n\n---\n\n# combinators\n\n## getEquivalence\n\nGiven a struct of `Equivalence`s returns a new `Equivalence` that compares values of a struct\nby applying each `Equivalence` to the corresponding property of the struct.\n\nAlias of {@link equivalence.struct}.\n\n**Signature**\n\n```ts\nexport declare const getEquivalence: <R extends Record<string, equivalence.Equivalence<any>>>(\n  predicates: R\n) => equivalence.Equivalence<{ readonly [K in keyof R]: [R[K]] extends [equivalence.Equivalence<infer A>] ? A : never }>\n```\n\n**Example**\n\n```ts\nimport { getEquivalence } from '@fp-ts/core/Struct'\nimport * as S from '@fp-ts/core/String'\nimport * as N from '@fp-ts/core/Number'\n\nconst PersonEquivalence = getEquivalence({\n  name: S.Equivalence,\n  age: N.Equivalence,\n})\n\nassert.deepStrictEqual(PersonEquivalence({ name: 'John', age: 25 }, { name: 'John', age: 25 }), true)\nassert.deepStrictEqual(PersonEquivalence({ name: 'John', age: 25 }, { name: 'John', age: 40 }), false)\n```\n\nAdded in v1.0.0\n\n## getMonoid\n\nThis function creates and returns a new `Monoid` for a struct of values based on the given `Monoid`s for each property in the struct.\nThe returned `Monoid` combines two structs of the same type by applying the corresponding `Monoid` passed as arguments to each property in the struct.\n\nThe `empty` value of the returned `Monoid` is a struct where each property is the `empty` value of the corresponding `Monoid` in the input `monoids` object.\n\nIt is useful when you need to combine two structs of the same type and you have a specific way of combining each property of the struct.\n\nSee also {@link getSemigroup}.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <R extends { readonly [x: string]: monoid.Monoid<any> }>(\n  fields: R\n) => monoid.Monoid<{ [K in keyof R]: [R[K]] extends [monoid.Monoid<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n## getOrder\n\nThis function creates and returns a new `Order` for a struct of values based on the given `Order`s\nfor each property in the struct.\n\nAlias of {@link order.struct}.\n\n**Signature**\n\n```ts\nexport declare const getOrder: <R extends { readonly [x: string]: order.Order<any> }>(\n  fields: R\n) => order.Order<{ [K in keyof R]: [R[K]] extends [order.Order<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n## getSemigroup\n\nThis function creates and returns a new `Semigroup` for a struct of values based on the given `Semigroup`s for each property in the struct.\nThe returned `Semigroup` combines two structs of the same type by applying the corresponding `Semigroup` passed as arguments to each property in the struct.\n\nIt is useful when you need to combine two structs of the same type and you have a specific way of combining each property of the struct.\n\nSee also {@link getMonoid}.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <R extends { readonly [x: string]: semigroup.Semigroup<any> }>(\n  fields: R\n) => semigroup.Semigroup<{ [K in keyof R]: [R[K]] extends [semigroup.Semigroup<infer A>] ? A : never }>\n```\n\n**Example**\n\n```ts\nimport { getSemigroup } from '@fp-ts/core/Struct'\nimport * as Semigroup from '@fp-ts/core/typeclass/Semigroup'\nimport * as O from '@fp-ts/core/Option'\n\nconst PersonSemigroup = getSemigroup({\n  name: Semigroup.last<string>(),\n  age: O.getOptionalMonoid(Semigroup.last<number>()),\n})\n\nassert.deepStrictEqual(PersonSemigroup.combine({ name: 'John', age: O.none() }, { name: 'John', age: O.some(25) }), {\n  name: 'John',\n  age: O.some(25),\n})\nassert.deepStrictEqual(PersonSemigroup.combine({ name: 'John', age: O.some(25) }, { name: 'John', age: O.none() }), {\n  name: 'John',\n  age: O.some(25),\n})\n```\n\nAdded in v1.0.0\n\n# utils\n\n## omit\n\nCreate a new object by omitting properties of an existing object.\n\n**Signature**\n\n```ts\nexport declare const omit: <S, Keys extends readonly [keyof S, ...(keyof S)[]]>(\n  ...keys: Keys\n) => (s: S) => { [K in Exclude<keyof S, Keys[number]>]: S[K] }\n```\n\n**Example**\n\n```ts\nimport { omit } from '@fp-ts/core/Struct'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(pipe({ a: 'a', b: 1, c: true }, omit('c')), { a: 'a', b: 1 })\n```\n\nAdded in v1.0.0\n\n## pick\n\nCreate a new object by picking properties of an existing object.\n\n**Signature**\n\n```ts\nexport declare const pick: <S, Keys extends readonly [keyof S, ...(keyof S)[]]>(\n  ...keys: Keys\n) => (s: S) => { [K in Keys[number]]: S[K] }\n```\n\n**Example**\n\n```ts\nimport { pick } from '@fp-ts/core/Struct'\nimport { pipe } from '@fp-ts/core/Function'\n\nassert.deepStrictEqual(pipe({ a: 'a', b: 1, c: true }, pick('a', 'b')), { a: 'a', b: 1 })\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Symbol.ts.md",
    "content": "---\ntitle: Symbol.ts\nnav_order: 16\nparent: Modules\n---\n\n## Symbol overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [guards](#guards)\n  - [isSymbol](#issymbol)\n- [instances](#instances)\n  - [Equivalence](#equivalence)\n\n---\n\n# guards\n\n## isSymbol\n\nTests if a value is a `symbol`.\n\n**Signature**\n\n```ts\nexport declare const isSymbol: (u: unknown) => u is symbol\n```\n\n**Example**\n\n```ts\nimport { isSymbol } from '@fp-ts/core/Predicate'\n\nassert.deepStrictEqual(isSymbol(Symbol.for('a')), true)\nassert.deepStrictEqual(isSymbol('a'), false)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Equivalence\n\n**Signature**\n\n```ts\nexport declare const Equivalence: equivalence.Equivalence<symbol>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/These.ts.md",
    "content": "---\ntitle: These.ts\nnav_order: 17\nparent: Modules\n---\n\n## These overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n- [combining](#combining)\n  - [andThenDiscard](#andthendiscard)\n  - [flatMap](#flatmap)\n  - [flatMapEither](#flatmapeither)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatMapOption](#flatmapoption)\n  - [flatMapThese](#flatmapthese)\n  - [getFirstLeftMonoid](#getfirstleftmonoid)\n  - [getFirstLeftSemigroup](#getfirstleftsemigroup)\n  - [getFirstRightOrBothSemigroup](#getfirstrightorbothsemigroup)\n  - [zipWith](#zipwith)\n- [constructors](#constructors)\n  - [both](#both)\n  - [fail](#fail)\n  - [left](#left)\n  - [leftOrBoth](#leftorboth)\n  - [of](#of)\n  - [right](#right)\n  - [rightOrBoth](#rightorboth)\n  - [warn](#warn)\n- [conversions](#conversions)\n  - [absolve](#absolve)\n  - [condemn](#condemn)\n  - [fromEither](#fromeither)\n  - [fromIterable](#fromiterable)\n  - [fromNullable](#fromnullable)\n  - [fromOption](#fromoption)\n  - [fromTuple](#fromtuple)\n  - [toEither](#toeither)\n  - [toValidated](#tovalidated)\n- [debugging](#debugging)\n  - [inspectBoth](#inspectboth)\n  - [inspectLeft](#inspectleft)\n  - [inspectRight](#inspectright)\n  - [inspectRightOrBoth](#inspectrightorboth)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [andThenBind](#andthenbind)\n  - [bind](#bind)\n  - [bindEither](#bindeither)\n  - [bindThese](#bindthese)\n  - [bindTo](#bindto)\n  - [let](#let)\n- [equivalence](#equivalence)\n  - [getEquivalence](#getequivalence)\n- [error handling](#error-handling)\n  - [firstRightOrBothOf](#firstrightorbothof)\n  - [mapLeft](#mapleft)\n  - [orElse](#orelse)\n  - [orElseEither](#orelseeither)\n  - [orElseFail](#orelsefail)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n- [getters](#getters)\n  - [getBoth](#getboth)\n  - [getBothOrElse](#getbothorelse)\n  - [getLeft](#getleft)\n  - [getLeftOnly](#getleftonly)\n  - [getOrElse](#getorelse)\n  - [getOrNull](#getornull)\n  - [getOrUndefined](#getorundefined)\n  - [getRight](#getright)\n  - [getRightOnly](#getrightonly)\n- [guards](#guards)\n  - [isBoth](#isboth)\n  - [isLeft](#isleft)\n  - [isLeftOrBoth](#isleftorboth)\n  - [isRight](#isright)\n  - [isRightOrBoth](#isrightorboth)\n  - [isThese](#isthese)\n- [instances](#instances)\n  - [Applicative](#applicative)\n  - [Bicovariant](#bicovariant)\n  - [Chainable](#chainable)\n  - [Covariant](#covariant)\n  - [FlatMap](#flatmap)\n  - [Foldable](#foldable)\n  - [Invariant](#invariant)\n  - [Monad](#monad)\n  - [Of](#of)\n  - [Pointed](#pointed)\n  - [Product](#product)\n  - [SemiAlternative](#semialternative)\n  - [SemiApplicative](#semiapplicative)\n  - [SemiCoproduct](#semicoproduct)\n  - [SemiProduct](#semiproduct)\n  - [Traversable](#traversable)\n- [interop](#interop)\n  - [getOrThrow](#getorthrow)\n  - [getOrThrowWith](#getorthrowwith)\n  - [getRightOnlyOrThrow](#getrightonlyorthrow)\n  - [getRightOnlyOrThrowWith](#getrightonlyorthrowwith)\n  - [liftThrowable](#liftthrowable)\n- [lifting](#lifting)\n  - [lift2](#lift2)\n  - [liftEither](#lifteither)\n  - [liftNullable](#liftnullable)\n  - [liftOption](#liftoption)\n  - [liftPredicate](#liftpredicate)\n  - [liftThese](#liftthese)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [map](#map)\n  - [tupled](#tupled)\n- [math](#math)\n  - [divide](#divide)\n  - [multiply](#multiply)\n  - [subtract](#subtract)\n  - [sum](#sum)\n- [model](#model)\n  - [Both (interface)](#both-interface)\n  - [These (type alias)](#these-type-alias)\n  - [Validated (type alias)](#validated-type-alias)\n- [pattern matching](#pattern-matching)\n  - [match](#match)\n- [predicates](#predicates)\n  - [exists](#exists)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n  - [traverseTap](#traversetap)\n- [type lambdas](#type-lambdas)\n  - [TheseTypeLambda (interface)](#thesetypelambda-interface)\n  - [ValidatedTypeLambda (interface)](#validatedtypelambda-interface)\n- [utils](#utils)\n  - [andThen](#andthen)\n  - [ap](#ap)\n  - [appendElement](#appendelement)\n  - [composeKleisliArrow](#composekleisliarrow)\n  - [contains](#contains)\n  - [flatten](#flatten)\n  - [reverse](#reverse)\n  - [struct](#struct)\n  - [tuple](#tuple)\n  - [unit](#unit)\n\n---\n\n# combinators\n\n## tap\n\nReturns an effect that effectfully \"peeks\" at the success of this effect.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <E1, A, E2, _>(self: These<readonly [E1, ...E1[]], A>, f: (a: A) => These<readonly [E2, ...E2[]], _>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    A\n  >\n  <A, E2, _>(f: (a: A) => These<readonly [E2, ...E2[]], _>): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], A>\n}\n```\n\nAdded in v1.0.0\n\n# combining\n\n## andThenDiscard\n\nSequences the specified effect after this effect, but ignores the value\nproduced by the effect.\n\n**Signature**\n\n```ts\nexport declare const andThenDiscard: {\n  <E1, A, E2, _>(self: These<readonly [E1, ...E1[]], A>, that: These<readonly [E2, ...E2[]], _>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    A\n  >\n  <E2, _>(that: These<readonly [E2, ...E2[]], _>): <E1, A>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], A>\n}\n```\n\nAdded in v1.0.0\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, E2, B>(f: (a: A) => These<readonly [E2, ...E2[]], B>): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], B>\n  <E1, A, E2, B>(self: These<readonly [E1, ...E1[]], A>, f: (a: A) => These<readonly [E2, ...E2[]], B>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    B\n  >\n}\n```\n\nAdded in v1.0.0\n\n## flatMapEither\n\n**Signature**\n\n```ts\nexport declare const flatMapEither: {\n  <A, E2, B>(f: (a: A) => Either<E2, B>): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], B>\n  <E1, A, E2, B>(self: These<readonly [E1, ...E1[]], A>, f: (a: A) => Either<E2, B>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    B\n  >\n}\n```\n\nAdded in v1.0.0\n\n## flatMapNullable\n\n**Signature**\n\n```ts\nexport declare const flatMapNullable: {\n  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], NonNullable<B>>\n  <E1, A, B, E2>(\n    self: These<readonly [E1, ...E1[]], A>,\n    f: (a: A) => B | null | undefined,\n    onNullable: (a: A) => E2\n  ): These<readonly [E1 | E2, ...(E1 | E2)[]], NonNullable<B>>\n}\n```\n\nAdded in v1.0.0\n\n## flatMapOption\n\n**Signature**\n\n```ts\nexport declare const flatMapOption: {\n  <A, B, E2>(f: (a: A) => O.Option<B>, onNone: (a: A) => E2): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], B>\n  <E1, A, B, E2>(self: These<readonly [E1, ...E1[]], A>, f: (a: A) => O.Option<B>, onNone: (a: A) => E2): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    B\n  >\n}\n```\n\nAdded in v1.0.0\n\n## flatMapThese\n\n**Signature**\n\n```ts\nexport declare const flatMapThese: {\n  <A, E2, B>(f: (a: A) => These<E2, B>): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], B>\n  <E1, A, E2, B>(self: These<readonly [E1, ...E1[]], A>, f: (a: A) => These<E2, B>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    B\n  >\n}\n```\n\nAdded in v1.0.0\n\n## getFirstLeftMonoid\n\n**Signature**\n\n```ts\nexport declare const getFirstLeftMonoid: <A, E>(M: Monoid<A>) => Monoid<These<readonly [E, ...E[]], A>>\n```\n\nAdded in v1.0.0\n\n## getFirstLeftSemigroup\n\n**Signature**\n\n```ts\nexport declare const getFirstLeftSemigroup: <A, E>(S: Semigroup<A>) => Semigroup<These<readonly [E, ...E[]], A>>\n```\n\nAdded in v1.0.0\n\n## getFirstRightOrBothSemigroup\n\n**Signature**\n\n```ts\nexport declare const getFirstRightOrBothSemigroup: <E, A>() => Semigroup<These<E, A>>\n```\n\nAdded in v1.0.0\n\n## zipWith\n\n**Signature**\n\n```ts\nexport declare const zipWith: {\n  <E1, A, E2, B, C>(\n    self: These<readonly [E1, ...E1[]], A>,\n    that: These<readonly [E2, ...E2[]], B>,\n    f: (a: A, b: B) => C\n  ): These<readonly [E1 | E2, ...(E1 | E2)[]], C>\n  <E2, B, A, C>(that: These<readonly [E2, ...E2[]], B>, f: (a: A, b: B) => C): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], C>\n}\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## both\n\n**Signature**\n\n```ts\nexport declare const both: <E, A>(left: E, right: A) => These<E, A>\n```\n\nAdded in v1.0.0\n\n## fail\n\n**Signature**\n\n```ts\nexport declare const fail: <E>(e: E) => These<readonly [E, ...E[]], never>\n```\n\nAdded in v1.0.0\n\n## left\n\n**Signature**\n\n```ts\nexport declare const left: <E>(left: E) => These<E, never>\n```\n\nAdded in v1.0.0\n\n## leftOrBoth\n\n**Signature**\n\n```ts\nexport declare const leftOrBoth: {\n  <E>(onSome: LazyArg<E>): <A>(self: O.Option<A>) => These<E, A>\n  <A, E>(self: O.Option<A>, onSome: LazyArg<E>): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## of\n\nAlias of {@link right}.\n\n**Signature**\n\n```ts\nexport declare const of: <A>(right: A) => These<never, A>\n```\n\nAdded in v1.0.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare const right: <A>(right: A) => These<never, A>\n```\n\nAdded in v1.0.0\n\n## rightOrBoth\n\n**Signature**\n\n```ts\nexport declare const rightOrBoth: {\n  <A>(onNone: LazyArg<A>): <E>(self: O.Option<E>) => These<E, A>\n  <E, A>(self: O.Option<E>, onNone: LazyArg<A>): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## warn\n\n**Signature**\n\n```ts\nexport declare const warn: <E, A>(e: E, a: A) => These<readonly [E, ...E[]], A>\n```\n\nAdded in v1.0.0\n\n# conversions\n\n## absolve\n\n**Signature**\n\n```ts\nexport declare const absolve: <E, A>(self: These<E, A>) => Either<E, A>\n```\n\nAdded in v1.0.0\n\n## condemn\n\n**Signature**\n\n```ts\nexport declare const condemn: <E, A>(self: These<E, A>) => Either<E, A>\n```\n\nAdded in v1.0.0\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <E, A>(self: Either<E, A>) => These<readonly [E, ...E[]], A>\n```\n\nAdded in v1.0.0\n\n## fromIterable\n\n**Signature**\n\n```ts\nexport declare const fromIterable: {\n  <E>(onEmpty: LazyArg<E>): <A>(collection: Iterable<A>) => These<E, A>\n  <A, E>(collection: Iterable<A>, onEmpty: LazyArg<E>): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## fromNullable\n\n**Signature**\n\n```ts\nexport declare const fromNullable: {\n  <E>(onNullable: LazyArg<E>): <A>(a: A) => These<E, NonNullable<A>>\n  <A, E>(a: A, onNullable: LazyArg<E>): These<E, NonNullable<A>>\n}\n```\n\nAdded in v1.0.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: {\n  <E>(onNone: LazyArg<E>): <A>(self: O.Option<A>) => These<E, A>\n  <A, E>(self: O.Option<A>, onNone: LazyArg<E>): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## fromTuple\n\n**Signature**\n\n```ts\nexport declare const fromTuple: <E, A>(self: readonly [E, A]) => These<E, A>\n```\n\nAdded in v1.0.0\n\n## toEither\n\n**Signature**\n\n```ts\nexport declare const toEither: {\n  <E, A>(onBoth: (e: E, a: A) => Either<E, A>): (self: These<E, A>) => Either<E, A>\n  <E, A>(self: These<E, A>, onBoth: (e: E, a: A) => Either<E, A>): Either<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## toValidated\n\n**Signature**\n\n```ts\nexport declare const toValidated: <E, A>(self: These<E, A>) => These<readonly [E, ...E[]], A>\n```\n\nAdded in v1.0.0\n\n# debugging\n\n## inspectBoth\n\n**Signature**\n\n```ts\nexport declare const inspectBoth: {\n  <E, A>(onBoth: (e: E, a: A) => void): (self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, onBoth: (e: E, a: A) => void): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## inspectLeft\n\n**Signature**\n\n```ts\nexport declare const inspectLeft: {\n  <E>(onLeft: (e: E) => void): <A>(self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, onLeft: (e: E) => void): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## inspectRight\n\n**Signature**\n\n```ts\nexport declare const inspectRight: {\n  <A>(onRight: (a: A) => void): <E>(self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, onRight: (a: A) => void): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## inspectRightOrBoth\n\n**Signature**\n\n```ts\nexport declare const inspectRightOrBoth: {\n  <A>(onRightOrBoth: (a: A) => void): <E>(self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, onRightOrBoth: (a: A) => void): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: These<never, {}>\n```\n\nAdded in v1.0.0\n\n## andThenBind\n\n**Signature**\n\n```ts\nexport declare const andThenBind: {\n  <N extends string, A extends object, E2, B>(name: Exclude<N, keyof A>, that: These<readonly [E2, ...E2[]], B>): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: These<readonly [E1, ...E1[]], A>,\n    name: Exclude<N, keyof A>,\n    that: These<readonly [E2, ...E2[]], B>\n  ): These<readonly [E1 | E2, ...(E1 | E2)[]], { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\nAdded in v1.0.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: {\n  <N extends string, A extends object, E2, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => These<readonly [E2, ...E2[]], B>\n  ): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: These<readonly [E1, ...E1[]], A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => These<readonly [E2, ...E2[]], B>\n  ): These<readonly [E1 | E2, ...(E1 | E2)[]], { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\nAdded in v1.0.0\n\n## bindEither\n\n**Signature**\n\n```ts\nexport declare const bindEither: {\n  <N extends string, A extends object, E2, B>(name: Exclude<N, keyof A>, f: (a: A) => Either<E2, B>): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: These<readonly [E1, ...E1[]], A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Either<E2, B>\n  ): These<readonly [E1 | E2, ...(E1 | E2)[]], { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\nAdded in v1.0.0\n\n## bindThese\n\n**Signature**\n\n```ts\nexport declare const bindThese: {\n  <N extends string, A extends object, E2, B>(name: Exclude<N, keyof A>, f: (a: A) => These<E2, B>): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: These<readonly [E1, ...E1[]], A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => These<E2, B>\n  ): These<readonly [E1 | E2, ...(E1 | E2)[]], { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\nAdded in v1.0.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: {\n  <N extends string>(name: N): <E, A>(self: These<E, A>) => These<E, { [K in N]: A }>\n  <E, A, N extends string>(self: These<E, A>, name: N): These<E, { [K in N]: A }>\n}\n```\n\nAdded in v1.0.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): <E>(\n    self: These<E, A>\n  ) => These<E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E, A extends object, N extends string, B>(self: These<E, A>, name: Exclude<N, keyof A>, f: (a: A) => B): These<\n    E,\n    { [K in N | keyof A]: K extends keyof A ? A[K] : B }\n  >\n}\n```\n\nAdded in v1.0.0\n\n# equivalence\n\n## getEquivalence\n\n**Signature**\n\n```ts\nexport declare const getEquivalence: <E, A>(EE: Equivalence<E>, EA: Equivalence<A>) => Equivalence<These<E, A>>\n```\n\nAdded in v1.0.0\n\n# error handling\n\n## firstRightOrBothOf\n\n**Signature**\n\n```ts\nexport declare const firstRightOrBothOf: {\n  <E, A>(collection: Iterable<These<E, A>>): (self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, collection: Iterable<These<E, A>>): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## mapLeft\n\nMaps the `Left` side of an `These` value to a new `These` value.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: {\n  <E, G>(f: (e: E) => G): <A>(self: These<E, A>) => These<G, A>\n  <E, A, G>(self: These<E, A>, f: (e: E) => G): These<G, A>\n}\n```\n\nAdded in v1.0.0\n\n## orElse\n\nExecutes this effect and returns its value, if it succeeds, but otherwise\nexecutes the specified effect.\n\n**Signature**\n\n```ts\nexport declare const orElse: {\n  <E1, E2, B>(that: (e1: E1) => These<E2, B>): <A>(self: These<E1, A>) => These<E1 | E2, B | A>\n  <E1, A, E2, B>(self: These<E1, A>, that: (e1: E1) => These<E2, B>): These<E1 | E2, A | B>\n}\n```\n\nAdded in v1.0.0\n\n## orElseEither\n\nReturns an effect that will produce the value of this effect, unless it\nfails, in which case, it will produce the value of the specified effect.\n\n**Signature**\n\n```ts\nexport declare const orElseEither: {\n  <E1, E2, B>(that: (e1: E1) => These<E2, B>): <A>(self: These<E1, A>) => These<E1 | E2, Either<A, B>>\n  <E1, A, E2, B>(self: These<E1, A>, that: (e1: E1) => These<E2, B>): These<E1 | E2, Either<A, B>>\n}\n```\n\nAdded in v1.0.0\n\n## orElseFail\n\nExecutes this effect and returns its value, if it succeeds, but otherwise\nfails with the specified error.\n\n**Signature**\n\n```ts\nexport declare const orElseFail: {\n  <E2>(onLeft: LazyArg<E2>): <E1, A>(self: These<E1, A>) => These<E2 | E1, A>\n  <E1, A, E2>(self: These<E1, A>, onLeft: LazyArg<E2>): These<E1 | E2, A>\n}\n```\n\nAdded in v1.0.0\n\n# filtering\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: {\n  <E>(onNone: LazyArg<E>): <A>(self: These<E, O.Option<A>>) => These<E, A>\n  <E, A>(self: These<E, O.Option<A>>, onNone: LazyArg<E>): These<E, A>\n}\n```\n\nAdded in v1.0.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <C extends A, B extends A, E2, A = C>(refinement: Refinement<A, B>, onFalse: LazyArg<E2>): <E1>(\n    self: These<E1, C>\n  ) => These<E2 | E1, B>\n  <B extends A, E2, A = B>(predicate: Predicate<A>, onFalse: LazyArg<E2>): <E1>(self: These<E1, B>) => These<E2 | E1, B>\n  <E1, C extends A, B extends A, E2, A = C>(\n    self: These<E1, C>,\n    refinement: Refinement<A, B>,\n    onFalse: LazyArg<E2>\n  ): These<E1 | E2, B>\n  <E1, B extends A, E2, A = B>(self: These<E1, B>, predicate: Predicate<A>, onFalse: LazyArg<E2>): These<E1 | E2, B>\n}\n```\n\nAdded in v1.0.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare const filterMap: {\n  <A, B, E2>(f: (a: A) => O.Option<B>, onNone: LazyArg<E2>): <E1>(self: These<E1, A>) => These<E2 | E1, B>\n  <E1, A, B, E2>(self: These<E1, A>, f: (a: A) => O.Option<B>, onNone: LazyArg<E2>): These<E1 | E2, B>\n}\n```\n\nAdded in v1.0.0\n\n# getters\n\n## getBoth\n\n**Signature**\n\n```ts\nexport declare const getBoth: <E, A>(self: These<E, A>) => O.Option<readonly [E, A]>\n```\n\nAdded in v1.0.0\n\n## getBothOrElse\n\n**Signature**\n\n```ts\nexport declare const getBothOrElse: {\n  <E, A>(e: LazyArg<E>, a: LazyArg<A>): (self: These<E, A>) => [E, A]\n  <E, A>(self: These<E, A>, e: LazyArg<E>, a: LazyArg<A>): [E, A]\n}\n```\n\nAdded in v1.0.0\n\n## getLeft\n\nConverts a `These` to an `Option` discarding the value (`Both` included).\n\n**Signature**\n\n```ts\nexport declare const getLeft: <E, A>(self: These<E, A>) => O.Option<E>\n```\n\nAdded in v1.0.0\n\n## getLeftOnly\n\nReturns the error if and only if the value is a `Left` (i.e. `Both` is excluded).\n\n**Signature**\n\n```ts\nexport declare const getLeftOnly: <E, A>(self: These<E, A>) => O.Option<E>\n```\n\nAdded in v1.0.0\n\n## getOrElse\n\n**Signature**\n\n```ts\nexport declare const getOrElse: {\n  <B>(onLeft: LazyArg<B>): <E, A>(self: These<E, A>) => B | A\n  <E, A, B>(self: These<E, A>, onLeft: LazyArg<B>): A | B\n}\n```\n\nAdded in v1.0.0\n\n## getOrNull\n\n**Signature**\n\n```ts\nexport declare const getOrNull: <E, A>(self: These<E, A>) => A | null\n```\n\nAdded in v1.0.0\n\n## getOrUndefined\n\n**Signature**\n\n```ts\nexport declare const getOrUndefined: <E, A>(self: These<E, A>) => A | undefined\n```\n\nAdded in v1.0.0\n\n## getRight\n\nConverts a `These` to an `Option` discarding the error (`Both` included).\n\n**Signature**\n\n```ts\nexport declare const getRight: <E, A>(self: These<E, A>) => O.Option<A>\n```\n\nAdded in v1.0.0\n\n## getRightOnly\n\nReturns the value if and only if the value is a `Right` (i.e. `Both` is excluded).\n\n**Signature**\n\n```ts\nexport declare const getRightOnly: <E, A>(self: These<E, A>) => O.Option<A>\n```\n\nAdded in v1.0.0\n\n# guards\n\n## isBoth\n\nDetermine if a `These` is a `Both`.\n\n**Signature**\n\n```ts\nexport declare const isBoth: <E, A>(self: These<E, A>) => self is Both<E, A>\n```\n\n**Example**\n\n```ts\nimport { isBoth, left, right, both } from '@fp-ts/core/These'\n\nassert.deepStrictEqual(isBoth(right(1)), false)\nassert.deepStrictEqual(isBoth(left('error')), false)\nassert.deepStrictEqual(isBoth(both('error', 1)), true)\n```\n\nAdded in v1.0.0\n\n## isLeft\n\nDetermine if a `These` is a `Left`.\n\n**Signature**\n\n```ts\nexport declare const isLeft: <E, A>(self: These<E, A>) => self is Left<E>\n```\n\n**Example**\n\n```ts\nimport { isLeft, left, right, both } from '@fp-ts/core/These'\n\nassert.deepStrictEqual(isLeft(right(1)), false)\nassert.deepStrictEqual(isLeft(left('error')), true)\nassert.deepStrictEqual(isLeft(both('error', 1)), false)\n```\n\nAdded in v1.0.0\n\n## isLeftOrBoth\n\nDetermine if a `These` is a `Left` or a `Both`.\n\n**Signature**\n\n```ts\nexport declare const isLeftOrBoth: <E, A>(self: These<E, A>) => self is Left<E> | Both<E, A>\n```\n\n**Example**\n\n```ts\nimport { isLeftOrBoth, left, right, both } from '@fp-ts/core/These'\n\nassert.deepStrictEqual(isLeftOrBoth(right(1)), false)\nassert.deepStrictEqual(isLeftOrBoth(left('error')), true)\nassert.deepStrictEqual(isLeftOrBoth(both('error', 1)), true)\n```\n\nAdded in v1.0.0\n\n## isRight\n\nDetermine if a `These` is a `Right`.\n\n**Signature**\n\n```ts\nexport declare const isRight: <E, A>(self: These<E, A>) => self is Right<A>\n```\n\n**Example**\n\n```ts\nimport { isRight, left, right, both } from '@fp-ts/core/These'\n\nassert.deepStrictEqual(isRight(right(1)), true)\nassert.deepStrictEqual(isRight(left('error')), false)\nassert.deepStrictEqual(isRight(both('error', 1)), false)\n```\n\nAdded in v1.0.0\n\n## isRightOrBoth\n\nDetermine if a `These` is a `Right` or a `Both`.\n\n**Signature**\n\n```ts\nexport declare const isRightOrBoth: <E, A>(self: These<E, A>) => self is Right<A> | Both<E, A>\n```\n\n**Example**\n\n```ts\nimport { isRightOrBoth, left, right, both } from '@fp-ts/core/These'\n\nassert.deepStrictEqual(isRightOrBoth(right(1)), true)\nassert.deepStrictEqual(isRightOrBoth(left('error')), false)\nassert.deepStrictEqual(isRightOrBoth(both('error', 1)), true)\n```\n\nAdded in v1.0.0\n\n## isThese\n\nTests if a value is a `These`.\n\n**Signature**\n\n```ts\nexport declare const isThese: (input: unknown) => input is These<unknown, unknown>\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: applicative.Applicative<ValidatedTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Bicovariant\n\n**Signature**\n\n```ts\nexport declare const Bicovariant: bicovariant.Bicovariant<TheseTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Chainable\n\n**Signature**\n\n```ts\nexport declare const Chainable: chainable.Chainable<ValidatedTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Covariant\n\n**Signature**\n\n```ts\nexport declare const Covariant: covariant.Covariant<TheseTypeLambda>\n```\n\nAdded in v1.0.0\n\n## FlatMap\n\n**Signature**\n\n```ts\nexport declare const FlatMap: flatMap_.FlatMap<ValidatedTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: foldable.Foldable<TheseTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<TheseTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: monad.Monad<ValidatedTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Of\n\n**Signature**\n\n```ts\nexport declare const Of: of_.Of<TheseTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: pointed.Pointed<TheseTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Product\n\n**Signature**\n\n```ts\nexport declare const Product: product_.Product<ValidatedTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiAlternative\n\n**Signature**\n\n```ts\nexport declare const SemiAlternative: semiAlternative.SemiAlternative<TheseTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiApplicative\n\n**Signature**\n\n```ts\nexport declare const SemiApplicative: semiApplicative.SemiApplicative<ValidatedTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiCoproduct\n\n**Signature**\n\n```ts\nexport declare const SemiCoproduct: semiCoproduct.SemiCoproduct<TheseTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiProduct\n\n**Signature**\n\n```ts\nexport declare const SemiProduct: semiProduct.SemiProduct<ValidatedTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: traversable.Traversable<TheseTypeLambda>\n```\n\nAdded in v1.0.0\n\n# interop\n\n## getOrThrow\n\nExtracts the value of a `These` or throws if the `These` is `Left`.\n\nThe thrown error is a default error. To configure the error thrown, see {@link getOrThrowWith}.\n\n**Signature**\n\n```ts\nexport declare const getOrThrow: <E, A>(self: These<E, A>) => A\n```\n\n**Example**\n\n```ts\nimport * as T from '@fp-ts/core/These'\n\nassert.deepStrictEqual(T.getOrThrow(T.right(1)), 1)\nassert.deepStrictEqual(T.getOrThrow(T.both('warning', 1)), 1)\nassert.throws(() => T.getOrThrow(T.left('error')))\n```\n\nAdded in v1.0.0\n\n## getOrThrowWith\n\nExtracts the value of a `These` or throws if the `These` is `Left`.\n\nIf a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.\n\n**Signature**\n\n```ts\nexport declare const getOrThrowWith: {\n  <E>(onLeft: (e: E) => unknown): <A>(self: These<E, A>) => A\n  <E, A>(self: These<E, A>, onLeft: (e: E) => unknown): A\n}\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/These'\n\nassert.deepStrictEqual(\n  E.getOrThrowWith(E.right(1), () => new Error('Unexpected Left')),\n  1\n)\nassert.deepStrictEqual(\n  E.getOrThrowWith(E.both('warning', 1), () => new Error('Unexpected Left')),\n  1\n)\nassert.throws(() => E.getOrThrowWith(E.left('error'), () => new Error('Unexpected Left')))\n```\n\nAdded in v1.0.0\n\n## getRightOnlyOrThrow\n\nExtracts the value of a `These` or throws if the `These` is not a `Right`.\n\nThe thrown error is a default error. To configure the error thrown, see {@link getRightOnlyOrThrowWith}.\n\n**Signature**\n\n```ts\nexport declare const getRightOnlyOrThrow: <E, A>(self: These<E, A>) => A\n```\n\n**Example**\n\n```ts\nimport * as T from '@fp-ts/core/These'\n\nassert.deepStrictEqual(T.getRightOnlyOrThrow(T.right(1)), 1)\nassert.throws(() => T.getRightOnlyOrThrow(T.both('error', 1)))\nassert.throws(() => T.getRightOnlyOrThrow(T.left('error')))\n```\n\nAdded in v1.0.0\n\n## getRightOnlyOrThrowWith\n\nExtracts the value of a `These` or throws if the `These` is `Left`.\n\nIf a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.\n\n**Signature**\n\n```ts\nexport declare const getRightOnlyOrThrowWith: {\n  <E>(onLeftOrBoth: (e: E) => unknown): <A>(self: These<E, A>) => A\n  <E, A>(self: These<E, A>, onLeftOrBoth: (e: E) => unknown): A\n}\n```\n\n**Example**\n\n```ts\nimport * as E from '@fp-ts/core/These'\n\nassert.deepStrictEqual(\n  E.getRightOnlyOrThrowWith(E.right(1), () => new Error('Unexpected Left or Both')),\n  1\n)\nassert.throws(() => E.getRightOnlyOrThrowWith(E.both('warning', 1), () => new Error('Unexpected Left or Both')))\nassert.throws(() => E.getRightOnlyOrThrowWith(E.left('error'), () => new Error('Unexpected Left or Both')))\n```\n\nAdded in v1.0.0\n\n## liftThrowable\n\nLifts a function that may throw to one returning a `These`.\n\n**Signature**\n\n```ts\nexport declare const liftThrowable: <A extends readonly unknown[], B, E>(\n  f: (...a: A) => B,\n  onThrow: (error: unknown) => E\n) => (...a: A) => These<E, B>\n```\n\nAdded in v1.0.0\n\n# lifting\n\n## lift2\n\nLifts a binary function into `These`.\n\n**Signature**\n\n```ts\nexport declare const lift2: <A, B, C>(\n  f: (a: A, b: B) => C\n) => {\n  <E1, E2>(self: These<readonly [E1, ...E1[]], A>, that: These<readonly [E2, ...E2[]], B>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    C\n  >\n  <E2>(that: These<readonly [E2, ...E2[]], B>): <E1>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], C>\n}\n```\n\nAdded in v1.0.0\n\n## liftEither\n\n**Signature**\n\n```ts\nexport declare const liftEither: <A extends readonly unknown[], E, B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => These<readonly [E, ...E[]], B>\n```\n\nAdded in v1.0.0\n\n## liftNullable\n\n**Signature**\n\n```ts\nexport declare const liftNullable: <A extends readonly unknown[], B, E>(\n  f: (...a: A) => B | null | undefined,\n  onNullable: (...a: A) => E\n) => (...a: A) => These<E, NonNullable<B>>\n```\n\nAdded in v1.0.0\n\n## liftOption\n\n**Signature**\n\n```ts\nexport declare const liftOption: <A extends readonly unknown[], B, E>(\n  f: (...a: A) => O.Option<B>,\n  onNone: (...a: A) => E\n) => (...a: A) => These<E, B>\n```\n\nAdded in v1.0.0\n\n## liftPredicate\n\n**Signature**\n\n```ts\nexport declare const liftPredicate: {\n  <C extends A, B extends A, E, A = C>(refinement: Refinement<A, B>, onFalse: (c: C) => E): (c: C) => These<E, B>\n  <B extends A, E, A = B>(predicate: Predicate<A>, onFalse: (b: B) => E): (b: B) => These<E, B>\n}\n```\n\nAdded in v1.0.0\n\n## liftThese\n\n**Signature**\n\n```ts\nexport declare const liftThese: <A extends readonly unknown[], E, B>(\n  f: (...a: A) => These<E, B>\n) => (...a: A) => These<readonly [E, ...E[]], B>\n```\n\nAdded in v1.0.0\n\n# mapping\n\n## as\n\nMaps the right value of this effect to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <E, _, B>(self: These<E, _>, b: B): These<E, B>\n  <B>(b: B): <E, _>(self: These<E, _>) => These<E, B>\n}\n```\n\nAdded in v1.0.0\n\n## asUnit\n\nReturns the effect resulting from mapping the right of this effect to unit.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <E, _>(self: These<E, _>) => These<E, void>\n```\n\nAdded in v1.0.0\n\n## bimap\n\n**Signature**\n\n```ts\nexport declare const bimap: {\n  <E1, E2, A, B>(f: (e: E1) => E2, g: (a: A) => B): (self: These<E1, A>) => These<E2, B>\n  <E1, A, E2, B>(self: These<E1, A>, f: (e: E1) => E2, g: (a: A) => B): These<E2, B>\n}\n```\n\nAdded in v1.0.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: {\n  <A, E, B>(a: A, self: These<E, (a: A) => B>): These<E, B>\n  <E, A, B>(self: These<E, (a: A) => B>): (a: A) => These<E, B>\n}\n```\n\nAdded in v1.0.0\n\n## map\n\nMaps the `Right` side of an `These` value to a new `These` value.\n\n**Signature**\n\n```ts\nexport declare const map: {\n  <E, A, B>(self: These<E, A>, f: (a: A) => B): These<E, B>\n  <A, B>(f: (a: A) => B): <E>(self: These<E, A>) => These<E, B>\n}\n```\n\nAdded in v1.0.0\n\n## tupled\n\n**Signature**\n\n```ts\nexport declare const tupled: <E, A>(self: These<E, A>) => These<E, [A]>\n```\n\nAdded in v1.0.0\n\n# math\n\n## divide\n\n**Signature**\n\n```ts\nexport declare const divide: {\n  <E1, E2>(self: These<readonly [E1, ...E1[]], number>, that: These<readonly [E2, ...E2[]], number>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    number\n  >\n  <E2>(that: These<readonly [E2, ...E2[]], number>): <E1>(\n    self: These<readonly [E1, ...E1[]], number>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], number>\n}\n```\n\nAdded in v1.0.0\n\n## multiply\n\n**Signature**\n\n```ts\nexport declare const multiply: {\n  <E1, E2>(self: These<readonly [E1, ...E1[]], number>, that: These<readonly [E2, ...E2[]], number>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    number\n  >\n  <E2>(that: These<readonly [E2, ...E2[]], number>): <E1>(\n    self: These<readonly [E1, ...E1[]], number>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], number>\n}\n```\n\nAdded in v1.0.0\n\n## subtract\n\n**Signature**\n\n```ts\nexport declare const subtract: {\n  <E1, E2>(self: These<readonly [E1, ...E1[]], number>, that: These<readonly [E2, ...E2[]], number>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    number\n  >\n  <E2>(that: These<readonly [E2, ...E2[]], number>): <E1>(\n    self: These<readonly [E1, ...E1[]], number>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], number>\n}\n```\n\nAdded in v1.0.0\n\n## sum\n\n**Signature**\n\n```ts\nexport declare const sum: {\n  <E1, E2>(self: These<readonly [E1, ...E1[]], number>, that: These<readonly [E2, ...E2[]], number>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    number\n  >\n  <E2>(that: These<readonly [E2, ...E2[]], number>): <E1>(\n    self: These<readonly [E1, ...E1[]], number>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], number>\n}\n```\n\nAdded in v1.0.0\n\n# model\n\n## Both (interface)\n\n**Signature**\n\n```ts\nexport interface Both<E, A> {\n  readonly _tag: 'Both'\n  readonly left: E\n  readonly right: A\n}\n```\n\nAdded in v1.0.0\n\n## These (type alias)\n\n**Signature**\n\n```ts\nexport type These<E, A> = Either<E, A> | Both<E, A>\n```\n\nAdded in v1.0.0\n\n## Validated (type alias)\n\n**Signature**\n\n```ts\nexport type Validated<E, A> = These<NonEmptyReadonlyArray<E>, A>\n```\n\nAdded in v1.0.0\n\n# pattern matching\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: {\n  <E, B, A, C = B, D = B>(onLeft: (e: E) => B, onRight: (a: A) => C, onBoth: (e: E, a: A) => D): (\n    self: These<E, A>\n  ) => B | C | D\n  <E, B, A, C = B, D = B>(self: These<E, A>, onLeft: (e: E) => B, onRight: (a: A) => C, onBoth: (e: E, a: A) => D):\n    | B\n    | C\n    | D\n}\n```\n\nAdded in v1.0.0\n\n# predicates\n\n## exists\n\n**Signature**\n\n```ts\nexport declare const exists: {\n  <A>(predicate: Predicate<A>): <E>(self: These<E, A>) => boolean\n  <E, A>(self: These<E, A>, predicate: Predicate<A>): boolean\n}\n```\n\nAdded in v1.0.0\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => <TE, R, O, E, A>(self: These<TE, Kind<F, R, O, E, A>>) => Kind<F, R, O, E, These<TE, A>>\n```\n\nAdded in v1.0.0\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): <TE>(self: These<TE, A>) => Kind<F, R, O, E, These<TE, B>>\n  <TE, A, R, O, E, B>(self: These<TE, A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, These<TE, B>>\n}\n```\n\nAdded in v1.0.0\n\n## traverseTap\n\n**Signature**\n\n```ts\nexport declare const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <TE, A, R, O, E, B>(self: These<TE, A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, These<TE, A>>\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): <TE>(self: These<TE, A>) => Kind<F, R, O, E, These<TE, A>>\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## TheseTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface TheseTypeLambda extends TypeLambda {\n  readonly type: These<this['Out1'], this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n## ValidatedTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface ValidatedTypeLambda extends TypeLambda {\n  readonly type: Validated<this['Out1'], this['Target']>\n}\n```\n\nAdded in v3.0.0\n\n# utils\n\n## andThen\n\n**Signature**\n\n```ts\nexport declare const andThen: {\n  <E1, _, E2, B>(self: These<readonly [E1, ...E1[]], _>, that: These<readonly [E2, ...E2[]], B>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    B\n  >\n  <E2, B>(that: These<readonly [E2, ...E2[]], B>): <E1, _>(\n    self: These<readonly [E1, ...E1[]], _>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], B>\n}\n```\n\nAdded in v1.0.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: {\n  <E1, A, B, E2>(self: These<readonly [E1, ...E1[]], (a: A) => B>, that: These<readonly [E2, ...E2[]], A>): These<\n    readonly [E1 | E2, ...(E1 | E2)[]],\n    B\n  >\n  <E2, A>(that: These<readonly [E2, ...E2[]], A>): <E1, B>(\n    self: These<readonly [E1, ...E1[]], (a: A) => B>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], B>\n}\n```\n\nAdded in v1.0.0\n\n## appendElement\n\nAppends an element to the end of a tuple.\n\n**Signature**\n\n```ts\nexport declare const appendElement: {\n  <E1, A extends readonly any[], E2, B>(\n    self: These<readonly [E1, ...E1[]], A>,\n    that: These<readonly [E2, ...E2[]], B>\n  ): These<readonly [E1 | E2, ...(E1 | E2)[]], [...A, B]>\n  <E2, B>(that: These<readonly [E2, ...E2[]], B>): <E1, A extends readonly any[]>(\n    self: These<readonly [E1, ...E1[]], A>\n  ) => These<readonly [E2 | E1, ...(E2 | E1)[]], [...A, B]>\n}\n```\n\nAdded in v1.0.0\n\n## composeKleisliArrow\n\n**Signature**\n\n```ts\nexport declare const composeKleisliArrow: {\n  <A, E1, B, E2, C>(afb: (a: A) => These<readonly [E1, ...E1[]], B>, bfc: (b: B) => These<readonly [E2, ...E2[]], C>): (\n    a: A\n  ) => These<readonly [E1 | E2, ...(E1 | E2)[]], C>\n  <B, E2, C>(bfc: (b: B) => These<readonly [E2, ...E2[]], C>): <A, E1>(\n    afb: (a: A) => These<readonly [E1, ...E1[]], B>\n  ) => (a: A) => These<readonly [E2 | E1, ...(E2 | E1)[]], C>\n}\n```\n\nAdded in v1.0.0\n\n## contains\n\nReturns a function that checks if a `These` contains a given value using a provided `equivalence` function.\n\n**Signature**\n\n```ts\nexport declare const contains: <A>(isEquivalent: (self: A, that: A) => boolean) => {\n  (a: A): <E>(self: These<E, A>) => boolean\n  <E>(self: These<E, A>, a: A): boolean\n}\n```\n\nAdded in v1.0.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <E2, E1, A>(\n  self: These<readonly [E2, ...E2[]], These<readonly [E1, ...E1[]], A>>\n) => These<readonly [E2 | E1, ...(E2 | E1)[]], A>\n```\n\nAdded in v1.0.0\n\n## reverse\n\n**Signature**\n\n```ts\nexport declare const reverse: <E, A>(self: These<E, A>) => These<A, E>\n```\n\nAdded in v1.0.0\n\n## struct\n\n**Signature**\n\n```ts\nexport declare const struct: <R extends Record<string, These<readonly [any, ...any[]], any>>>(\n  r: R\n) => These<\n  readonly [\n    [R[keyof R]] extends [These<readonly [infer E, ...(infer E)[]], any>] ? E : never,\n    ...([R[keyof R]] extends [These<readonly [infer E, ...(infer E)[]], any>] ? E : never)[]\n  ],\n  { [K in keyof R]: [R[K]] extends [These<readonly [any, ...any[]], infer A>] ? A : never }\n>\n```\n\nAdded in v1.0.0\n\n## tuple\n\nSimilar to `Promise.all` but operates on `These`s.\n\n```\n[These<E1, A>, These<E1, B>, ...] -> These<E1 \\| E2 \\| ..., [A, B, ...]>\n```\n\n**Signature**\n\n```ts\nexport declare const tuple: <T extends readonly These<readonly [any, ...any[]], any>[]>(\n  ...tuple: T\n) => These<\n  readonly [\n    [T[number]] extends [These<readonly [infer E, ...(infer E)[]], any>] ? E : never,\n    ...([T[number]] extends [These<readonly [infer E, ...(infer E)[]], any>] ? E : never)[]\n  ],\n  { [I in keyof T]: [T[I]] extends [These<readonly [any, ...any[]], infer A>] ? A : never }\n>\n```\n\nAdded in v1.0.0\n\n## unit\n\n**Signature**\n\n```ts\nexport declare const unit: These<never, void>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/Tuple.ts.md",
    "content": "---\ntitle: Tuple.ts\nnav_order: 18\nparent: Modules\n---\n\n## Tuple overview\n\nThis module provides utility functions for working with tuples in TypeScript.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [getEquivalence](#getequivalence)\n  - [getMonoid](#getmonoid)\n  - [getOrder](#getorder)\n  - [getSemigroup](#getsemigroup)\n- [constructors](#constructors)\n  - [tuple](#tuple)\n- [getters](#getters)\n  - [getFirst](#getfirst)\n  - [getSecond](#getsecond)\n- [instances](#instances)\n  - [Bicovariant](#bicovariant)\n- [mapping](#mapping)\n  - [bimap](#bimap)\n  - [mapFirst](#mapfirst)\n  - [mapSecond](#mapsecond)\n- [type lambdas](#type-lambdas)\n  - [TupleTypeLambda (interface)](#tupletypelambda-interface)\n- [utils](#utils)\n  - [appendElement](#appendelement)\n  - [swap](#swap)\n\n---\n\n# combinators\n\n## getEquivalence\n\nGiven a tuple of `Equivalence`s returns a new `Equivalence` that compares values of a tuple\nby applying each `Equivalence` to the corresponding element of the tuple.\n\n**Signature**\n\n```ts\nexport declare const getEquivalence: <T extends readonly equivalence.Equivalence<any>[]>(\n  ...predicates: T\n) => equivalence.Equivalence<\n  Readonly<{ [I in keyof T]: [T[I]] extends [equivalence.Equivalence<infer A>] ? A : never }>\n>\n```\n\nAdded in v1.0.0\n\n## getMonoid\n\nThis function creates and returns a new `Monoid` for a tuple of values based on the given `Monoid`s for each element in the tuple.\nThe returned `Monoid` combines two tuples of the same type by applying the corresponding `Monoid` passed as arguments to each element in the tuple.\n\nThe `empty` value of the returned `Monoid` is the tuple of `empty` values of the input `Monoid`s.\n\nIt is useful when you need to combine two tuples of the same type and you have a specific way of combining each element of the tuple.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <T extends readonly monoid.Monoid<any>[]>(\n  ...elements: T\n) => monoid.Monoid<{ readonly [I in keyof T]: [T[I]] extends [monoid.Monoid<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n## getOrder\n\nThis function creates and returns a new `Order` for a tuple of values based on the given `Order`s for each element in the tuple.\nThe returned `Order` compares two tuples of the same type by applying the corresponding `Order` to each element in the tuple.\nIt is useful when you need to compare two tuples of the same type and you have a specific way of comparing each element\nof the tuple.\n\n**Signature**\n\n```ts\nexport declare const getOrder: <T extends readonly order.Order<any>[]>(\n  ...elements: T\n) => order.Order<{ [I in keyof T]: [T[I]] extends [order.Order<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n## getSemigroup\n\nThis function creates and returns a new `Semigroup` for a tuple of values based on the given `Semigroup`s for each element in the tuple.\nThe returned `Semigroup` combines two tuples of the same type by applying the corresponding `Semigroup` passed as arguments to each element in the tuple.\n\nIt is useful when you need to combine two tuples of the same type and you have a specific way of combining each element of the tuple.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <T extends readonly semigroup.Semigroup<any>[]>(\n  ...elements: T\n) => semigroup.Semigroup<{ readonly [I in keyof T]: [T[I]] extends [semigroup.Semigroup<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## tuple\n\nConstructs a new tuple from the provided values.\n\n**Signature**\n\n```ts\nexport declare const tuple: <A extends readonly any[]>(...elements: A) => A\n```\n\n**Example**\n\n```ts\nimport { tuple } from '@fp-ts/core/Tuple'\n\nassert.deepStrictEqual(tuple(1, 'hello', true), [1, 'hello', true])\n```\n\nAdded in v1.0.0\n\n# getters\n\n## getFirst\n\nReturn the first element of a tuple.\n\n**Signature**\n\n```ts\nexport declare const getFirst: <L, R>(self: readonly [L, R]) => L\n```\n\n**Example**\n\n```ts\nimport { getFirst } from '@fp-ts/core/Tuple'\n\nassert.deepStrictEqual(getFirst(['hello', 42]), 'hello')\n```\n\nAdded in v1.0.0\n\n## getSecond\n\nReturn the second element of a tuple.\n\n**Signature**\n\n```ts\nexport declare const getSecond: <L, R>(self: readonly [L, R]) => R\n```\n\n**Example**\n\n```ts\nimport { getSecond } from '@fp-ts/core/Tuple'\n\nassert.deepStrictEqual(getSecond(['hello', 42]), 42)\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Bicovariant\n\n**Signature**\n\n```ts\nexport declare const Bicovariant: bicovariant.Bicovariant<TupleTypeLambda>\n```\n\nAdded in v1.0.0\n\n# mapping\n\n## bimap\n\nTransforms both elements of a tuple using the given functions.\n\n**Signature**\n\n```ts\nexport declare const bimap: {\n  <L1, L2, R1, R2>(f: (e: L1) => L2, g: (a: R1) => R2): (self: readonly [L1, R1]) => [L2, R2]\n  <L1, R1, L2, R2>(self: readonly [L1, R1], f: (e: L1) => L2, g: (a: R1) => R2): [L2, R2]\n}\n```\n\n**Example**\n\n```ts\nimport { bimap } from '@fp-ts/core/Tuple'\n\nassert.deepStrictEqual(\n  bimap(\n    ['hello', 42],\n    (s) => s.toUpperCase(),\n    (n) => n.toString()\n  ),\n  ['HELLO', '42']\n)\n```\n\nAdded in v1.0.0\n\n## mapFirst\n\nTransforms the first component of a tuple using a given function.\n\n**Signature**\n\n```ts\nexport declare const mapFirst: {\n  <L1, L2>(f: (left: L1) => L2): <R>(self: readonly [L1, R]) => [L2, R]\n  <L1, R, L2>(self: readonly [L1, R], f: (left: L1) => L2): [L2, R]\n}\n```\n\n**Example**\n\n```ts\nimport { mapFirst } from '@fp-ts/core/Tuple'\n\nassert.deepStrictEqual(\n  mapFirst(['hello', 42], (s) => s.toUpperCase()),\n  ['HELLO', 42]\n)\n```\n\nAdded in v1.0.0\n\n## mapSecond\n\nTransforms the second component of a tuple using a given function.\n\n**Signature**\n\n```ts\nexport declare const mapSecond: {\n  <R1, R2>(f: (right: R1) => R2): <L>(self: readonly [L, R1]) => [L, R2]\n  <L, R1, R2>(self: readonly [L, R1], f: (right: R1) => R2): [L, R2]\n}\n```\n\n**Example**\n\n```ts\nimport { mapSecond } from '@fp-ts/core/Tuple'\n\nassert.deepStrictEqual(\n  mapSecond(['hello', 42], (n) => n.toString()),\n  ['hello', '42']\n)\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## TupleTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface TupleTypeLambda extends TypeLambda {\n  readonly type: [this['Out1'], this['Target']]\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## appendElement\n\nAppends an element to the end of a tuple.\n\n**Signature**\n\n```ts\nexport declare const appendElement: {\n  <B>(that: B): <A extends readonly unknown[]>(self: A) => [...A, B]\n  <A extends readonly unknown[], B>(self: A, that: B): [...A, B]\n}\n```\n\nAdded in v1.0.0\n\n## swap\n\nSwaps the two elements of a tuple.\n\n**Signature**\n\n```ts\nexport declare const swap: <L, R>(self: readonly [L, R]) => [R, L]\n```\n\n**Example**\n\n```ts\nimport { swap } from '@fp-ts/core/Tuple'\n\nassert.deepStrictEqual(swap(['hello', 42]), [42, 'hello'])\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/index.md",
    "content": "---\ntitle: Modules\nhas_children: true\npermalink: /docs/modules\nnav_order: 2\n---"
  },
  {
    "path": "docs/modules/index.ts.md",
    "content": "---\ntitle: index.ts\nnav_order: 7\nparent: Modules\n---\n\n## index overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [typeclass](#typeclass)\n  - [alternative](#alternative)\n  - [applicative](#applicative)\n  - [bicovariant](#bicovariant)\n  - [bounded](#bounded)\n  - [chainable](#chainable)\n  - [contravariant](#contravariant)\n  - [coproduct](#coproduct)\n  - [covariant](#covariant)\n  - [equivalence](#equivalence)\n  - [filterable](#filterable)\n  - [flatMap](#flatmap)\n  - [foldable](#foldable)\n  - [invariant](#invariant)\n  - [monad](#monad)\n  - [monoid](#monoid)\n  - [of](#of)\n  - [order](#order)\n  - [pointed](#pointed)\n  - [product](#product)\n  - [semiAlternative](#semialternative)\n  - [semiApplicative](#semiapplicative)\n  - [semiCoproduct](#semicoproduct)\n  - [semiProduct](#semiproduct)\n  - [semigroup](#semigroup)\n  - [traversable](#traversable)\n  - [traversableFilterable](#traversablefilterable)\n- [utils](#utils)\n  - [bigint](#bigint)\n  - [boolean](#boolean)\n  - [either](#either)\n  - [function](#function)\n  - [hkt](#hkt)\n  - [identity](#identity)\n  - [number](#number)\n  - [option](#option)\n  - [ordering](#ordering)\n  - [predicate](#predicate)\n  - [readonlyArray](#readonlyarray)\n  - [readonlyRecord](#readonlyrecord)\n  - [string](#string)\n  - [struct](#struct)\n  - [symbol](#symbol)\n  - [these](#these)\n  - [tuple](#tuple)\n\n---\n\n# typeclass\n\n## alternative\n\n**Signature**\n\n```ts\nexport declare const alternative: typeof alternative\n```\n\nAdded in v1.0.0\n\n## applicative\n\n**Signature**\n\n```ts\nexport declare const applicative: typeof applicative\n```\n\nAdded in v1.0.0\n\n## bicovariant\n\n**Signature**\n\n```ts\nexport declare const bicovariant: typeof bicovariant\n```\n\nAdded in v1.0.0\n\n## bounded\n\n**Signature**\n\n```ts\nexport declare const bounded: typeof bounded\n```\n\nAdded in v1.0.0\n\n## chainable\n\n**Signature**\n\n```ts\nexport declare const chainable: typeof chainable\n```\n\nAdded in v1.0.0\n\n## contravariant\n\n**Signature**\n\n```ts\nexport declare const contravariant: typeof contravariant\n```\n\nAdded in v1.0.0\n\n## coproduct\n\n**Signature**\n\n```ts\nexport declare const coproduct: typeof coproduct\n```\n\nAdded in v1.0.0\n\n## covariant\n\n**Signature**\n\n```ts\nexport declare const covariant: typeof covariant\n```\n\nAdded in v1.0.0\n\n## equivalence\n\n**Signature**\n\n```ts\nexport declare const equivalence: typeof equivalence\n```\n\nAdded in v1.0.0\n\n## filterable\n\n**Signature**\n\n```ts\nexport declare const filterable: typeof filterable\n```\n\nAdded in v1.0.0\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: typeof flatMap\n```\n\nAdded in v1.0.0\n\n## foldable\n\n**Signature**\n\n```ts\nexport declare const foldable: typeof foldable\n```\n\nAdded in v1.0.0\n\n## invariant\n\n**Signature**\n\n```ts\nexport declare const invariant: typeof invariant\n```\n\nAdded in v1.0.0\n\n## monad\n\n**Signature**\n\n```ts\nexport declare const monad: typeof monad\n```\n\nAdded in v1.0.0\n\n## monoid\n\n**Signature**\n\n```ts\nexport declare const monoid: typeof monoid\n```\n\nAdded in v1.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: typeof of\n```\n\nAdded in v1.0.0\n\n## order\n\n**Signature**\n\n```ts\nexport declare const order: typeof order\n```\n\nAdded in v1.0.0\n\n## pointed\n\n**Signature**\n\n```ts\nexport declare const pointed: typeof pointed\n```\n\nAdded in v1.0.0\n\n## product\n\n**Signature**\n\n```ts\nexport declare const product: typeof product\n```\n\nAdded in v1.0.0\n\n## semiAlternative\n\n**Signature**\n\n```ts\nexport declare const semiAlternative: typeof semiAlternative\n```\n\nAdded in v1.0.0\n\n## semiApplicative\n\n**Signature**\n\n```ts\nexport declare const semiApplicative: typeof semiApplicative\n```\n\nAdded in v1.0.0\n\n## semiCoproduct\n\n**Signature**\n\n```ts\nexport declare const semiCoproduct: typeof semiCoproduct\n```\n\nAdded in v1.0.0\n\n## semiProduct\n\n**Signature**\n\n```ts\nexport declare const semiProduct: typeof semiProduct\n```\n\nAdded in v1.0.0\n\n## semigroup\n\n**Signature**\n\n```ts\nexport declare const semigroup: typeof semigroup\n```\n\nAdded in v1.0.0\n\n## traversable\n\n**Signature**\n\n```ts\nexport declare const traversable: typeof traversable\n```\n\nAdded in v1.0.0\n\n## traversableFilterable\n\n**Signature**\n\n```ts\nexport declare const traversableFilterable: typeof traversableFilterable\n```\n\nAdded in v1.0.0\n\n# utils\n\n## bigint\n\n**Signature**\n\n```ts\nexport declare const bigint: typeof bigint\n```\n\nAdded in v1.0.0\n\n## boolean\n\n**Signature**\n\n```ts\nexport declare const boolean: typeof boolean\n```\n\nAdded in v1.0.0\n\n## either\n\n**Signature**\n\n```ts\nexport declare const either: typeof either\n```\n\nAdded in v1.0.0\n\n## function\n\n**Signature**\n\n```ts\nexport declare const function: typeof _function\n```\n\nAdded in v1.0.0\n\n## hkt\n\n**Signature**\n\n```ts\nexport declare const hkt: typeof hkt\n```\n\nAdded in v1.0.0\n\n## identity\n\n**Signature**\n\n```ts\nexport declare const identity: typeof identity\n```\n\nAdded in v1.0.0\n\n## number\n\n**Signature**\n\n```ts\nexport declare const number: typeof number\n```\n\nAdded in v1.0.0\n\n## option\n\n**Signature**\n\n```ts\nexport declare const option: typeof option\n```\n\nAdded in v1.0.0\n\n## ordering\n\n**Signature**\n\n```ts\nexport declare const ordering: typeof ordering\n```\n\nAdded in v1.0.0\n\n## predicate\n\n**Signature**\n\n```ts\nexport declare const predicate: typeof predicate\n```\n\nAdded in v1.0.0\n\n## readonlyArray\n\n**Signature**\n\n```ts\nexport declare const readonlyArray: typeof readonlyArray\n```\n\nAdded in v1.0.0\n\n## readonlyRecord\n\n**Signature**\n\n```ts\nexport declare const readonlyRecord: typeof readonlyRecord\n```\n\nAdded in v1.0.0\n\n## string\n\n**Signature**\n\n```ts\nexport declare const string: typeof string\n```\n\nAdded in v1.0.0\n\n## struct\n\n**Signature**\n\n```ts\nexport declare const struct: typeof struct\n```\n\nAdded in v1.0.0\n\n## symbol\n\n**Signature**\n\n```ts\nexport declare const symbol: typeof symbol\n```\n\nAdded in v1.0.0\n\n## these\n\n**Signature**\n\n```ts\nexport declare const these: typeof these\n```\n\nAdded in v1.0.0\n\n## tuple\n\n**Signature**\n\n```ts\nexport declare const tuple: typeof tuple\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Alternative.ts.md",
    "content": "---\ntitle: typeclass/Alternative.ts\nnav_order: 19\nparent: Modules\n---\n\n## Alternative overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Alternative (interface)](#alternative-interface)\n\n---\n\n# type class\n\n## Alternative (interface)\n\n**Signature**\n\n```ts\nexport interface Alternative<F extends TypeLambda> extends SemiAlternative<F>, Coproduct<F> {}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Applicative.ts.md",
    "content": "---\ntitle: typeclass/Applicative.ts\nnav_order: 20\nparent: Modules\n---\n\n## Applicative overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Applicative (interface)](#applicative-interface)\n- [utils](#utils)\n  - [getMonoid](#getmonoid)\n\n---\n\n# type class\n\n## Applicative (interface)\n\n**Signature**\n\n```ts\nexport interface Applicative<F extends TypeLambda> extends SemiApplicative<F>, Product<F> {}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## getMonoid\n\nLift a `Monoid` into `F`, combining the inner values using the provided `Monoid`:\n\n- `combine` is provided by {@link semiApplicative.getSemigroup}.\n- `empty` is `F.of(M.empty)`\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <F extends TypeLambda>(\n  F: Applicative<F>\n) => <A, R, O, E>(M: Monoid<A>) => Monoid<Kind<F, R, O, E, A>>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Bicovariant.ts.md",
    "content": "---\ntitle: typeclass/Bicovariant.ts\nnav_order: 21\nparent: Modules\n---\n\n## Bicovariant overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Bicovariant (interface)](#bicovariant-interface)\n- [utils](#utils)\n  - [bimapComposition](#bimapcomposition)\n  - [map](#map)\n  - [mapLeft](#mapleft)\n\n---\n\n# type class\n\n## Bicovariant (interface)\n\n**Signature**\n\n```ts\nexport interface Bicovariant<F extends TypeLambda> extends TypeClass<F> {\n  readonly bimap: {\n    <E1, E2, A, B>(f: (e: E1) => E2, g: (a: A) => B): <R, O>(self: Kind<F, R, O, E1, A>) => Kind<F, R, O, E2, B>\n    <R, O, E1, A, E2, B>(self: Kind<F, R, O, E1, A>, f: (e: E1) => E2, g: (a: A) => B): Kind<F, R, O, E2, B>\n  }\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## bimapComposition\n\nReturns a default ternary `bimap` composition.\n\n**Signature**\n\n```ts\nexport declare const bimapComposition: <F extends TypeLambda, G extends TypeLambda>(\n  CovariantF: Covariant<F>,\n  BicovariantG: Bicovariant<G>\n) => <FR, FO, FE, GR, GO, E1, A, E2, B>(\n  self: Kind<F, FR, FO, FE, Kind<G, GR, GO, E1, A>>,\n  f: (e: E1) => E2,\n  g: (a: A) => B\n) => Kind<F, FR, FO, FE, Kind<G, GR, GO, E2, B>>\n```\n\nAdded in v1.0.0\n\n## map\n\nReturns a default `map` implementation.\n\n**Signature**\n\n```ts\nexport declare const map: <F extends TypeLambda>(\n  F: Bicovariant<F>\n) => {\n  <A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n  <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Kind<F, R, O, E, B>\n}\n```\n\nAdded in v1.0.0\n\n## mapLeft\n\nReturns a default `mapLeft` implementation.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <F extends TypeLambda>(\n  F: Bicovariant<F>\n) => {\n  <E, G>(f: (e: E) => G): <R, O, A>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, G, A>\n  <R, O, E, A, G>(self: Kind<F, R, O, E, A>, f: (e: E) => G): Kind<F, R, O, G, A>\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Bounded.ts.md",
    "content": "---\ntitle: typeclass/Bounded.ts\nnav_order: 22\nparent: Modules\n---\n\n## Bounded overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [max](#max)\n  - [min](#min)\n- [instances](#instances)\n  - [number](#number)\n- [type class](#type-class)\n  - [Bounded (interface)](#bounded-interface)\n- [type lambdas](#type-lambdas)\n  - [BoundedTypeLambda (interface)](#boundedtypelambda-interface)\n- [utils](#utils)\n  - [clamp](#clamp)\n  - [reverse](#reverse)\n\n---\n\n# constructors\n\n## max\n\n`Monoid` that returns last maximum of elements.\n\n**Signature**\n\n```ts\nexport declare const max: <A>(B: Bounded<A>) => Monoid<A>\n```\n\nAdded in v1.0.0\n\n## min\n\n`Monoid` that returns last minimum of elements.\n\n**Signature**\n\n```ts\nexport declare const min: <A>(B: Bounded<A>) => Monoid<A>\n```\n\nAdded in v1.0.0\n\n# instances\n\n## number\n\n**Signature**\n\n```ts\nexport declare const number: Bounded<number>\n```\n\nAdded in v1.0.0\n\n# type class\n\n## Bounded (interface)\n\n**Signature**\n\n```ts\nexport interface Bounded<A> extends Order<A> {\n  readonly maxBound: A\n  readonly minBound: A\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## BoundedTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface BoundedTypeLambda extends TypeLambda {\n  readonly type: Bounded<this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## clamp\n\nClamp a value between `minBound` and `maxBound` values.\n\n**Signature**\n\n```ts\nexport declare const clamp: <A>(B: Bounded<A>) => (a: A) => A\n```\n\nAdded in v1.0.0\n\n## reverse\n\nReverses the `Order` of a `Bounded` and flips `maxBound` and `minBound` values.\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(B: Bounded<A>) => Bounded<A>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Chainable.ts.md",
    "content": "---\ntitle: typeclass/Chainable.ts\nnav_order: 23\nparent: Modules\n---\n\n## Chainable overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combining](#combining)\n  - [andThenDiscard](#andthendiscard)\n- [do notation](#do-notation)\n  - [bind](#bind)\n- [type class](#type-class)\n  - [Chainable (interface)](#chainable-interface)\n- [utils](#utils)\n  - [tap](#tap)\n\n---\n\n# combining\n\n## andThenDiscard\n\nSequences the specified effect after this effect, but ignores the value\nproduced by the effect.\n\n**Signature**\n\n```ts\nexport declare const andThenDiscard: <F extends TypeLambda>(\n  F: Chainable<F>\n) => {\n  <R2, O2, E2, _>(that: Kind<F, R2, O2, E2, _>): <R1, O1, E1, A>(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, A>\n  <R1, O1, E1, A, R2, O2, E2, _>(self: Kind<F, R1, O1, E1, A>, that: Kind<F, R2, O2, E2, _>): Kind<\n    F,\n    R1 & R2,\n    O1 | O2,\n    E1 | E2,\n    A\n  >\n}\n```\n\nAdded in v1.0.0\n\n# do notation\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <F extends TypeLambda>(\n  F: Chainable<F>\n) => {\n  <N extends string, A extends object, R2, O2, E2, B>(name: Exclude<N, keyof A>, f: (a: A) => Kind<F, R2, O2, E2, B>): <\n    R1,\n    O1,\n    E1\n  >(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <R1, O1, E1, A extends object, N extends string, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\nAdded in v1.0.0\n\n# type class\n\n## Chainable (interface)\n\n**Signature**\n\n```ts\nexport interface Chainable<F extends TypeLambda> extends FlatMap<F>, Covariant<F> {}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## tap\n\nReturns an effect that effectfully \"peeks\" at the success of this effect.\n\n**Signature**\n\n```ts\nexport declare const tap: <F extends TypeLambda>(\n  F: Chainable<F>\n) => {\n  <A, R2, O2, E2, _>(f: (a: A) => Kind<F, R2, O2, E2, _>): <R1, O1, E1>(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, A>\n  <R1, O1, E1, A, R2, O2, E2, _>(self: Kind<F, R1, O1, E1, A>, f: (a: A) => Kind<F, R2, O2, E2, _>): Kind<\n    F,\n    R1 & R2,\n    O1 | O2,\n    E1 | E2,\n    A\n  >\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Contravariant.ts.md",
    "content": "---\ntitle: typeclass/Contravariant.ts\nnav_order: 24\nparent: Modules\n---\n\n## Contravariant overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Contravariant (interface)](#contravariant-interface)\n- [utils](#utils)\n  - [contramapComposition](#contramapcomposition)\n  - [imap](#imap)\n\n---\n\n# type class\n\n## Contravariant (interface)\n\n**Signature**\n\n```ts\nexport interface Contravariant<F extends TypeLambda> extends Invariant<F> {\n  readonly contramap: {\n    <B, A>(f: (b: B) => A): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (b: B) => A): Kind<F, R, O, E, B>\n  }\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## contramapComposition\n\nComposing two contravariant functors yields a Covariant functor.\n\nReturns a default binary `map` composition.\n\n**Signature**\n\n```ts\nexport declare const contramapComposition: <F extends TypeLambda, G extends TypeLambda>(\n  F: Contravariant<F>,\n  G: Contravariant<G>\n) => <FR, FO, FE, GR, GO, GE, A, B>(\n  self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n  f: (a: A) => B\n) => Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>>\n```\n\nAdded in v1.0.0\n\n## imap\n\nReturns a default `imap` implementation.\n\n**Signature**\n\n```ts\nexport declare const imap: <F extends TypeLambda>(\n  contramap: <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (b: B) => A) => Kind<F, R, O, E, B>\n) => {\n  <A, B>(to: (a: A) => B, from: (b: B) => A): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n  <R, O, E, A, B>(self: Kind<F, R, O, E, A>, to: (a: A) => B, from: (b: B) => A): Kind<F, R, O, E, B>\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Coproduct.ts.md",
    "content": "---\ntitle: typeclass/Coproduct.ts\nnav_order: 25\nparent: Modules\n---\n\n## Coproduct overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Coproduct (interface)](#coproduct-interface)\n- [utils](#utils)\n  - [getMonoid](#getmonoid)\n\n---\n\n# type class\n\n## Coproduct (interface)\n\n**Signature**\n\n```ts\nexport interface Coproduct<F extends TypeLambda> extends SemiCoproduct<F> {\n  readonly zero: <A>() => Kind<F, unknown, never, never, A>\n\n  readonly coproductAll: <R, O, E, A>(collection: Iterable<Kind<F, R, O, E, A>>) => Kind<F, R, O, E, A>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## getMonoid\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <F extends TypeLambda>(F: Coproduct<F>) => <R, O, E, A>() => Monoid<Kind<F, R, O, E, A>>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Covariant.ts.md",
    "content": "---\ntitle: typeclass/Covariant.ts\nnav_order: 26\nparent: Modules\n---\n\n## Covariant overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [do notation](#do-notation)\n  - [let](#let)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n- [type class](#type-class)\n  - [Covariant (interface)](#covariant-interface)\n- [utils](#utils)\n  - [imap](#imap)\n  - [mapComposition](#mapcomposition)\n\n---\n\n# do notation\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <F extends TypeLambda>(\n  F: Covariant<F>\n) => {\n  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): <R, O, E>(\n    self: Kind<F, R, O, E, A>\n  ) => Kind<F, R, O, E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <R, O, E, A extends object, N extends string, B>(\n    self: Kind<F, R, O, E, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): Kind<F, R, O, E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\nAdded in v1.0.0\n\n# mapping\n\n## as\n\n**Signature**\n\n```ts\nexport declare const as: <F extends TypeLambda>(\n  F: Covariant<F>\n) => {\n  <B>(b: B): <R, O, E, _>(self: Kind<F, R, O, E, _>) => Kind<F, R, O, E, B>\n  <R, O, E, _, B>(self: Kind<F, R, O, E, _>, b: B): Kind<F, R, O, E, B>\n}\n```\n\nAdded in v1.0.0\n\n## asUnit\n\n**Signature**\n\n```ts\nexport declare const asUnit: <F extends TypeLambda>(\n  F: Covariant<F>\n) => <R, O, E, _>(self: Kind<F, R, O, E, _>) => Kind<F, R, O, E, void>\n```\n\nAdded in v1.0.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <F extends TypeLambda>(\n  F: Covariant<F>\n) => {\n  <R, O, E, A, B>(self: Kind<F, R, O, E, (a: A) => B>): (a: A) => Kind<F, R, O, E, B>\n  <A, R, O, E, B>(a: A, self: Kind<F, R, O, E, (a: A) => B>): Kind<F, R, O, E, B>\n}\n```\n\nAdded in v1.0.0\n\n# type class\n\n## Covariant (interface)\n\n**Signature**\n\n```ts\nexport interface Covariant<F extends TypeLambda> extends Invariant<F> {\n  readonly map: {\n    <A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Kind<F, R, O, E, B>\n  }\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## imap\n\nReturns a default `imap` implementation.\n\n**Signature**\n\n```ts\nexport declare const imap: <F extends TypeLambda>(\n  map: <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B) => Kind<F, R, O, E, B>\n) => {\n  <A, B>(to: (a: A) => B, from: (b: B) => A): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n  <R, O, E, A, B>(self: Kind<F, R, O, E, A>, to: (a: A) => B, from: (b: B) => A): Kind<F, R, O, E, B>\n}\n```\n\nAdded in v1.0.0\n\n## mapComposition\n\nReturns a default `map` composition.\n\n**Signature**\n\n```ts\nexport declare const mapComposition: <F extends TypeLambda, G extends TypeLambda>(\n  F: Covariant<F>,\n  G: Covariant<G>\n) => <FR, FO, FE, GR, GO, GE, A, B>(\n  self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n  f: (a: A) => B\n) => Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Equivalence.ts.md",
    "content": "---\ntitle: typeclass/Equivalence.ts\nnav_order: 27\nparent: Modules\n---\n\n## Equivalence overview\n\nThis module provides an implementation of the `Equivalence` type class, which defines a binary relation\nthat is reflexive, symmetric, and transitive. In other words, it defines a notion of equivalence between values of a certain type.\nThese properties are also known in mathematics as an \"equivalence relation\".\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [contramap](#contramap)\n  - [struct](#struct)\n  - [tuple](#tuple)\n- [constructors](#constructors)\n  - [make](#make)\n  - [strict](#strict)\n- [instances](#instances)\n  - [Contravariant](#contravariant)\n  - [Invariant](#invariant)\n  - [Product](#product)\n  - [SemiProduct](#semiproduct)\n  - [bigint](#bigint)\n  - [boolean](#boolean)\n  - [getMonoid](#getmonoid)\n  - [getSemigroup](#getsemigroup)\n  - [number](#number)\n  - [string](#string)\n  - [symbol](#symbol)\n- [type class](#type-class)\n  - [Equivalence (interface)](#equivalence-interface)\n- [type lambdas](#type-lambdas)\n  - [EquivalenceTypeLambda (interface)](#equivalencetypelambda-interface)\n\n---\n\n# combinators\n\n## contramap\n\n**Signature**\n\n```ts\nexport declare const contramap: {\n  <B, A>(f: (b: B) => A): (self: Equivalence<A>) => Equivalence<B>\n  <A, B>(self: Equivalence<A>, f: (b: B) => A): Equivalence<B>\n}\n```\n\nAdded in v1.0.0\n\n## struct\n\nGiven a struct of `Equivalence`s returns a new `Equivalence` that compares values of a struct\nby applying each `Equivalence` to the corresponding property of the struct.\n\n**Signature**\n\n```ts\nexport declare const struct: <R extends Record<string, Equivalence<any>>>(\n  predicates: R\n) => Equivalence<{ readonly [K in keyof R]: [R[K]] extends [Equivalence<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n## tuple\n\nSimilar to `Promise.all` but operates on `Equivalence`s.\n\n```\n[Equivalence<A>, Equivalence<B>, ...] -> Equivalence<[A, B, ...]>\n```\n\nGiven a tuple of `Equivalence`s returns a new `Equivalence` that compares values of a tuple\nby applying each `Equivalence` to the corresponding element of the tuple.\n\n**Signature**\n\n```ts\nexport declare const tuple: <T extends readonly Equivalence<any>[]>(\n  ...predicates: T\n) => Equivalence<Readonly<{ [I in keyof T]: [T[I]] extends [Equivalence<infer A>] ? A : never }>>\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## make\n\n**Signature**\n\n```ts\nexport declare const make: <A>(isEquivalent: (self: A, that: A) => boolean) => Equivalence<A>\n```\n\nAdded in v1.0.0\n\n## strict\n\nReturn an `Equivalence` that uses strict equality (===) to compare values.\n\n**Signature**\n\n```ts\nexport declare const strict: <A>() => Equivalence<A>\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Contravariant\n\n**Signature**\n\n```ts\nexport declare const Contravariant: contravariant.Contravariant<EquivalenceTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<EquivalenceTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Product\n\n**Signature**\n\n```ts\nexport declare const Product: product_.Product<EquivalenceTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiProduct\n\n**Signature**\n\n```ts\nexport declare const SemiProduct: semiProduct.SemiProduct<EquivalenceTypeLambda>\n```\n\nAdded in v1.0.0\n\n## bigint\n\n**Signature**\n\n```ts\nexport declare const bigint: Equivalence<bigint>\n```\n\nAdded in v1.0.0\n\n## boolean\n\n**Signature**\n\n```ts\nexport declare const boolean: Equivalence<boolean>\n```\n\nAdded in v1.0.0\n\n## getMonoid\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A>() => Monoid<Equivalence<A>>\n```\n\nAdded in v1.0.0\n\n## getSemigroup\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A>() => Semigroup<Equivalence<A>>\n```\n\nAdded in v1.0.0\n\n## number\n\n**Signature**\n\n```ts\nexport declare const number: Equivalence<number>\n```\n\nAdded in v1.0.0\n\n## string\n\n**Signature**\n\n```ts\nexport declare const string: Equivalence<string>\n```\n\nAdded in v1.0.0\n\n## symbol\n\n**Signature**\n\n```ts\nexport declare const symbol: Equivalence<symbol>\n```\n\nAdded in v1.0.0\n\n# type class\n\n## Equivalence (interface)\n\n**Signature**\n\n```ts\nexport interface Equivalence<A> {\n  (self: A, that: A): boolean\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## EquivalenceTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface EquivalenceTypeLambda extends TypeLambda {\n  readonly type: Equivalence<this['Target']>\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Filterable.ts.md",
    "content": "---\ntitle: typeclass/Filterable.ts\nnav_order: 28\nparent: Modules\n---\n\n## Filterable overview\n\n`Filterable` represents data structures which can be _partitioned_/_filtered_.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [models](#models)\n  - [Filterable (interface)](#filterable-interface)\n- [utils](#utils)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMapComposition](#filtermapcomposition)\n  - [partition](#partition)\n  - [partitionMapComposition](#partitionmapcomposition)\n  - [separate](#separate)\n\n---\n\n# models\n\n## Filterable (interface)\n\n**Signature**\n\n```ts\nexport interface Filterable<F extends TypeLambda> extends TypeClass<F> {\n  readonly partitionMap: {\n    <A, B, C>(f: (a: A) => Either<B, C>): <R, O, E>(\n      self: Kind<F, R, O, E, A>\n    ) => [Kind<F, R, O, E, B>, Kind<F, R, O, E, C>]\n    <R, O, E, A, B, C>(self: Kind<F, R, O, E, A>, f: (a: A) => Either<B, C>): [Kind<F, R, O, E, B>, Kind<F, R, O, E, C>]\n  }\n\n  readonly filterMap: {\n    <A, B>(f: (a: A) => Option<B>): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => Option<B>): Kind<F, R, O, E, B>\n  }\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <F extends TypeLambda>(\n  F: Filterable<F>\n) => <R, O, E, A>(self: Kind<F, R, O, E, Option<A>>) => Kind<F, R, O, E, A>\n```\n\nAdded in v1.0.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: <F extends TypeLambda>(\n  F: Filterable<F>\n) => {\n  <C extends A, B extends A, A = C>(refinement: (a: A) => a is B): <R, O, E>(\n    self: Kind<F, R, O, E, C>\n  ) => Kind<F, R, O, E, B>\n  <B extends A, A = B>(predicate: (a: A) => boolean): <R, O, E>(self: Kind<F, R, O, E, B>) => Kind<F, R, O, E, B>\n  <R, O, E, C extends A, B extends A, A = C>(self: Kind<F, R, O, E, C>, refinement: (a: A) => a is B): Kind<\n    F,\n    R,\n    O,\n    E,\n    B\n  >\n  <R, O, E, B extends A, A = B>(self: Kind<F, R, O, E, B>, predicate: (a: A) => boolean): Kind<F, R, O, E, B>\n}\n```\n\nAdded in v1.0.0\n\n## filterMapComposition\n\nReturns a default binary `filterMap` composition.\n\n**Signature**\n\n```ts\nexport declare const filterMapComposition: <F extends TypeLambda, G extends TypeLambda>(\n  F: Covariant<F>,\n  G: Filterable<G>\n) => <FR, FO, FE, GR, GO, GE, A, B>(\n  self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n  f: (a: A) => Option<B>\n) => Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>>\n```\n\nAdded in v1.0.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare const partition: <F extends TypeLambda>(\n  F: Filterable<F>\n) => {\n  <C extends A, B extends A, A = C>(refinement: (a: A) => a is B): <R, O, E>(\n    self: Kind<F, R, O, E, C>\n  ) => [Kind<F, R, O, E, C>, Kind<F, R, O, E, B>]\n  <B extends A, A = B>(predicate: (a: A) => boolean): <R, O, E>(\n    self: Kind<F, R, O, E, B>\n  ) => [Kind<F, R, O, E, B>, Kind<F, R, O, E, B>]\n  <R, O, E, C extends A, B extends A, A = C>(self: Kind<F, R, O, E, C>, refinement: (a: A) => a is B): [\n    Kind<F, R, O, E, C>,\n    Kind<F, R, O, E, B>\n  ]\n  <R, O, E, B extends A, A = B>(self: Kind<F, R, O, E, B>, predicate: (a: A) => boolean): [\n    Kind<F, R, O, E, B>,\n    Kind<F, R, O, E, B>\n  ]\n}\n```\n\nAdded in v1.0.0\n\n## partitionMapComposition\n\nReturns a default binary `partitionMap` composition.\n\n**Signature**\n\n```ts\nexport declare const partitionMapComposition: <F extends TypeLambda, G extends TypeLambda>(\n  F: Covariant<F>,\n  G: Filterable<G>\n) => <FR, FO, FE, GR, GO, GE, A, B, C>(\n  self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n  f: (a: A) => Either<B, C>\n) => [Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>>, Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, C>>]\n```\n\nAdded in v1.0.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare const separate: <F extends TypeLambda>(\n  F: Filterable<F>\n) => <R, O, E, A, B>(self: Kind<F, R, O, E, Either<A, B>>) => [Kind<F, R, O, E, A>, Kind<F, R, O, E, B>]\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/FlatMap.ts.md",
    "content": "---\ntitle: typeclass/FlatMap.ts\nnav_order: 29\nparent: Modules\n---\n\n## FlatMap overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [FlatMap (interface)](#flatmap-interface)\n- [utils](#utils)\n  - [andThen](#andthen)\n  - [composeKleisliArrow](#composekleisliarrow)\n  - [flatten](#flatten)\n\n---\n\n# type class\n\n## FlatMap (interface)\n\n**Signature**\n\n```ts\nexport interface FlatMap<F extends TypeLambda> extends TypeClass<F> {\n  readonly flatMap: {\n    <A, R2, O2, E2, B>(f: (a: A) => Kind<F, R2, O2, E2, B>): <R1, O1, E1>(\n      self: Kind<F, R1, O1, E1, A>\n    ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, B>\n    <R1, O1, E1, A, R2, O2, E2, B>(self: Kind<F, R1, O1, E1, A>, f: (a: A) => Kind<F, R2, O2, E2, B>): Kind<\n      F,\n      R1 & R2,\n      O1 | O2,\n      E1 | E2,\n      B\n    >\n  }\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## andThen\n\nA variant of `flatMap` that ignores the value produced by this effect.\n\n**Signature**\n\n```ts\nexport declare const andThen: <F extends TypeLambda>(\n  F: FlatMap<F>\n) => {\n  <R2, O2, E2, B>(that: Kind<F, R2, O2, E2, B>): <R1, O1, E1, _>(\n    self: Kind<F, R1, O1, E1, _>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, B>\n  <R1, O1, E1, _, R2, O2, E2, B>(self: Kind<F, R1, O1, E1, _>, that: Kind<F, R2, O2, E2, B>): Kind<\n    F,\n    R1 & R2,\n    O1 | O2,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v1.0.0\n\n## composeKleisliArrow\n\n**Signature**\n\n```ts\nexport declare const composeKleisliArrow: <F extends TypeLambda>(\n  F: FlatMap<F>\n) => {\n  <B, R2, O2, E2, C>(bfc: (b: B) => Kind<F, R2, O2, E2, C>): <A, R1, O1, E1>(\n    afb: (a: A) => Kind<F, R1, O1, E1, B>\n  ) => (a: A) => Kind<F, R1 & R2, O2 | O1, E2 | E1, C>\n  <A, R1, O1, E1, B, R2, O2, E2, C>(afb: (a: A) => Kind<F, R1, O1, E1, B>, bfc: (b: B) => Kind<F, R2, O2, E2, C>): (\n    a: A\n  ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, C>\n}\n```\n\nAdded in v1.0.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <F extends TypeLambda>(\n  F: FlatMap<F>\n) => <R2, O2, E2, R1, O1, E1, A>(\n  self: Kind<F, R2, O2, E2, Kind<F, R1, O1, E1, A>>\n) => Kind<F, R1 & R2, O2 | O1, E2 | E1, A>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Foldable.ts.md",
    "content": "---\ntitle: typeclass/Foldable.ts\nnav_order: 30\nparent: Modules\n---\n\n## Foldable overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Foldable (interface)](#foldable-interface)\n- [utils](#utils)\n  - [combineMap](#combinemap)\n  - [coproductMapKind](#coproductmapkind)\n  - [reduceComposition](#reducecomposition)\n  - [reduceKind](#reducekind)\n  - [toArray](#toarray)\n  - [toArrayMap](#toarraymap)\n\n---\n\n# type class\n\n## Foldable (interface)\n\n**Signature**\n\n```ts\nexport interface Foldable<F extends TypeLambda> extends TypeClass<F> {\n  readonly reduce: {\n    <A, B>(b: B, f: (b: B, a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => B\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, b: B, f: (b: B, a: A) => B): B\n  }\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## combineMap\n\n**Signature**\n\n```ts\nexport declare const combineMap: <F extends TypeLambda>(\n  F: Foldable<F>\n) => <M>(M: Monoid<M>) => {\n  <A>(f: (a: A) => M): <R, O, E>(self: Kind<F, R, O, E, A>) => M\n  <R, O, E, A>(self: Kind<F, R, O, E, A>, f: (a: A) => M): M\n}\n```\n\nAdded in v1.0.0\n\n## coproductMapKind\n\n**Signature**\n\n```ts\nexport declare const coproductMapKind: <F extends TypeLambda>(\n  F: Foldable<F>\n) => <G extends TypeLambda>(\n  G: Coproduct<G>\n) => {\n  <A, R, O, E, B>(f: (a: A) => Kind<G, R, O, E, B>): <FR, FO, FE>(self: Kind<F, FR, FO, FE, A>) => Kind<G, R, O, E, B>\n  <FR, FO, FE, A, R, O, E, B>(self: Kind<F, FR, FO, FE, A>, f: (a: A) => Kind<G, R, O, E, B>): Kind<G, R, O, E, B>\n}\n```\n\nAdded in v1.0.0\n\n## reduceComposition\n\nReturns a default ternary `reduce` composition.\n\n**Signature**\n\n```ts\nexport declare const reduceComposition: <F extends TypeLambda, G extends TypeLambda>(\n  F: Foldable<F>,\n  G: Foldable<G>\n) => <FR, FO, FE, GR, GO, GE, A, B>(self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>, b: B, f: (b: B, a: A) => B) => B\n```\n\nAdded in v1.0.0\n\n## reduceKind\n\n**Signature**\n\n```ts\nexport declare const reduceKind: <F extends TypeLambda>(\n  F: Foldable<F>\n) => <G extends TypeLambda>(\n  G: Monad<G>\n) => {\n  <B, A, R, O, E>(b: B, f: (b: B, a: A) => Kind<G, R, O, E, B>): <FR, FO, FE>(\n    self: Kind<F, FR, FO, FE, A>\n  ) => Kind<G, R, O, E, B>\n  <FR, FO, FE, A, B, R, O, E>(self: Kind<F, FR, FO, FE, A>, b: B, f: (b: B, a: A) => Kind<G, R, O, E, B>): Kind<\n    G,\n    R,\n    O,\n    E,\n    B\n  >\n}\n```\n\nAdded in v1.0.0\n\n## toArray\n\n**Signature**\n\n```ts\nexport declare const toArray: <F extends TypeLambda>(F: Foldable<F>) => <R, O, E, A>(self: Kind<F, R, O, E, A>) => A[]\n```\n\nAdded in v1.0.0\n\n## toArrayMap\n\n**Signature**\n\n```ts\nexport declare const toArrayMap: <F extends TypeLambda>(\n  F: Foldable<F>\n) => {\n  <A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => B[]\n  <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): B[]\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Invariant.ts.md",
    "content": "---\ntitle: typeclass/Invariant.ts\nnav_order: 31\nparent: Modules\n---\n\n## Invariant overview\n\nThe `Invariant` typeclass is a higher-order abstraction over types that allow mapping the contents of a type in both directions.\nIt is similar to the `Covariant` typeclass but provides an `imap` opration, which allows transforming a value in both directions.\nThis typeclass is useful when dealing with data types that can be converted to and from some other types.\nThe `imap` operation provides a way to convert such data types to other types that they can interact with while preserving their invariants.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [do notation](#do-notation)\n  - [bindTo](#bindto)\n- [type class](#type-class)\n  - [Invariant (interface)](#invariant-interface)\n- [utils](#utils)\n  - [imapComposition](#imapcomposition)\n  - [tupled](#tupled)\n\n---\n\n# do notation\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <F extends TypeLambda>(\n  F: Invariant<F>\n) => {\n  <N extends string>(name: N): <R, O, E, A>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, { [K in N]: A }>\n  <R, O, E, A, N extends string>(self: Kind<F, R, O, E, A>, name: N): Kind<F, R, O, E, { [K in N]: A }>\n}\n```\n\nAdded in v1.0.0\n\n# type class\n\n## Invariant (interface)\n\n**Signature**\n\n```ts\nexport interface Invariant<F extends TypeLambda> extends TypeClass<F> {\n  readonly imap: {\n    <A, B>(to: (a: A) => B, from: (b: B) => A): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, to: (a: A) => B, from: (b: B) => A): Kind<F, R, O, E, B>\n  }\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## imapComposition\n\nReturns a default ternary `imap` composition.\n\n**Signature**\n\n```ts\nexport declare const imapComposition: <F extends TypeLambda, G extends TypeLambda>(\n  F: Invariant<F>,\n  G: Invariant<G>\n) => <FR, FO, FE, GR, GO, GE, A, B>(\n  self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n  to: (a: A) => B,\n  from: (b: B) => A\n) => Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>>\n```\n\nAdded in v1.0.0\n\n## tupled\n\nConvert a value in a singleton array in a given effect.\n\n**Signature**\n\n```ts\nexport declare const tupled: <F extends TypeLambda>(\n  F: Invariant<F>\n) => <R, O, E, A>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, [A]>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Monad.ts.md",
    "content": "---\ntitle: typeclass/Monad.ts\nnav_order: 32\nparent: Modules\n---\n\n## Monad overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Monad (interface)](#monad-interface)\n\n---\n\n# type class\n\n## Monad (interface)\n\n**Signature**\n\n```ts\nexport interface Monad<F extends TypeLambda> extends FlatMap<F>, Pointed<F> {}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Monoid.ts.md",
    "content": "---\ntitle: typeclass/Monoid.ts\nnav_order: 33\nparent: Modules\n---\n\n## Monoid overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [array](#array)\n  - [reverse](#reverse)\n  - [struct](#struct)\n  - [tuple](#tuple)\n- [constructors](#constructors)\n  - [fromSemigroup](#fromsemigroup)\n  - [max](#max)\n  - [min](#min)\n- [instances](#instances)\n  - [bigintMultiply](#bigintmultiply)\n  - [bigintSum](#bigintsum)\n  - [booleanAll](#booleanall)\n  - [booleanAny](#booleanany)\n  - [booleanEqv](#booleaneqv)\n  - [booleanXor](#booleanxor)\n  - [numberMultiply](#numbermultiply)\n  - [numberSum](#numbersum)\n  - [string](#string)\n- [type class](#type-class)\n  - [Monoid (interface)](#monoid-interface)\n\n---\n\n# combinators\n\n## array\n\nGiven a type `A`, this function creates and returns a `Semigroup` for `ReadonlyArray<A>`.\n\nThe `empty` value is the empty array.\n\n**Signature**\n\n```ts\nexport declare const array: <A>() => Monoid<readonly A[]>\n```\n\nAdded in v1.0.0\n\n## reverse\n\nThe dual of a `Monoid`, obtained by swapping the arguments of `combine`.\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(M: Monoid<A>) => Monoid<A>\n```\n\nAdded in v1.0.0\n\n## struct\n\nThis function creates and returns a new `Monoid` for a struct of values based on the given `Monoid`s for each property in the struct.\nThe returned `Monoid` combines two structs of the same type by applying the corresponding `Monoid` passed as arguments to each property in the struct.\n\nThe `empty` value of the returned `Monoid` is a struct where each property is the `empty` value of the corresponding `Monoid` in the input `monoids` object.\n\nIt is useful when you need to combine two structs of the same type and you have a specific way of combining each property of the struct.\n\n**Signature**\n\n```ts\nexport declare const struct: <R extends { readonly [x: string]: Monoid<any> }>(\n  fields: R\n) => Monoid<{ readonly [K in keyof R]: [R[K]] extends [Monoid<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n## tuple\n\nSimilar to `Promise.all` but operates on `Monoid`s.\n\n```\n[Monoid<A>, Monoid<B>, ...] -> Monoid<[A, B, ...]>\n```\n\nThis function creates and returns a new `Monoid` for a tuple of values based on the given `Monoid`s for each element in the tuple.\nThe returned `Monoid` combines two tuples of the same type by applying the corresponding `Monoid` passed as arguments to each element in the tuple.\n\nThe `empty` value of the returned `Monoid` is the tuple of `empty` values of the input `Monoid`s.\n\nIt is useful when you need to combine two tuples of the same type and you have a specific way of combining each element of the tuple.\n\n**Signature**\n\n```ts\nexport declare const tuple: <T extends readonly Monoid<any>[]>(\n  ...elements: T\n) => Monoid<{ readonly [I in keyof T]: [T[I]] extends [Monoid<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## fromSemigroup\n\n**Signature**\n\n```ts\nexport declare const fromSemigroup: <A>(S: Semigroup<A>, empty: A) => Monoid<A>\n```\n\nAdded in v1.0.0\n\n## max\n\nGet a monoid where `combine` will return the maximum, based on the provided bounded order.\n\nThe `empty` value is the `minimum` value.\n\n**Signature**\n\n```ts\nexport declare const max: <A>(B: Bounded<A>) => Monoid<A>\n```\n\nAdded in v1.0.0\n\n## min\n\nGet a monoid where `combine` will return the minimum, based on the provided bounded order.\n\nThe `empty` value is the `maxBound` value.\n\n**Signature**\n\n```ts\nexport declare const min: <A>(B: Bounded<A>) => Monoid<A>\n```\n\nAdded in v1.0.0\n\n# instances\n\n## bigintMultiply\n\n`bigint` monoid under multiplication.\n\nThe `empty` value is `1n`.\n\n**Signature**\n\n```ts\nexport declare const bigintMultiply: Monoid<bigint>\n```\n\nAdded in v1.0.0\n\n## bigintSum\n\n`number` monoid under addition.\n\nThe `bigint` value is `0n`.\n\n**Signature**\n\n```ts\nexport declare const bigintSum: Monoid<bigint>\n```\n\nAdded in v1.0.0\n\n## booleanAll\n\n`boolean` monoid under conjunction.\n\nThe `empty` value is `true`.\n\n**Signature**\n\n```ts\nexport declare const booleanAll: Monoid<boolean>\n```\n\nAdded in v1.0.0\n\n## booleanAny\n\n`boolean` monoid under disjunction.\n\nThe `empty` value is `false`.\n\n**Signature**\n\n```ts\nexport declare const booleanAny: Monoid<boolean>\n```\n\nAdded in v1.0.0\n\n## booleanEqv\n\n`boolean` monoid under equivalence.\n\nThe `empty` value is `true`.\n\n**Signature**\n\n```ts\nexport declare const booleanEqv: Monoid<boolean>\n```\n\nAdded in v1.0.0\n\n## booleanXor\n\n`boolean` monoid under exclusive disjunction.\n\nThe `empty` value is `false`.\n\n**Signature**\n\n```ts\nexport declare const booleanXor: Monoid<boolean>\n```\n\nAdded in v1.0.0\n\n## numberMultiply\n\n`number` monoid under multiplication.\n\nThe `empty` value is `1`.\n\n**Signature**\n\n```ts\nexport declare const numberMultiply: Monoid<number>\n```\n\nAdded in v1.0.0\n\n## numberSum\n\n`number` monoid under addition.\n\nThe `empty` value is `0`.\n\n**Signature**\n\n```ts\nexport declare const numberSum: Monoid<number>\n```\n\nAdded in v1.0.0\n\n## string\n\n**Signature**\n\n```ts\nexport declare const string: Monoid<string>\n```\n\nAdded in v1.0.0\n\n# type class\n\n## Monoid (interface)\n\n**Signature**\n\n```ts\nexport interface Monoid<A> extends Semigroup<A> {\n  readonly empty: A\n  readonly combineAll: (collection: Iterable<A>) => A\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Of.ts.md",
    "content": "---\ntitle: typeclass/Of.ts\nnav_order: 34\nparent: Modules\n---\n\n## Of overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [do notation](#do-notation)\n  - [Do](#do)\n- [type class](#type-class)\n  - [Of (interface)](#of-interface)\n- [utils](#utils)\n  - [ofComposition](#ofcomposition)\n  - [unit](#unit)\n\n---\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: <F extends TypeLambda>(F: Of<F>) => Kind<F, unknown, never, never, {}>\n```\n\nAdded in v1.0.0\n\n# type class\n\n## Of (interface)\n\n**Signature**\n\n```ts\nexport interface Of<F extends TypeLambda> extends TypeClass<F> {\n  readonly of: <A>(a: A) => Kind<F, unknown, never, never, A>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## ofComposition\n\nReturns a default `of` composition.\n\n**Signature**\n\n```ts\nexport declare const ofComposition: <F extends TypeLambda, G extends TypeLambda>(\n  F: Of<F>,\n  G: Of<G>\n) => <A>(a: A) => Kind<F, unknown, never, never, Kind<G, unknown, never, never, A>>\n```\n\nAdded in v1.0.0\n\n## unit\n\n**Signature**\n\n```ts\nexport declare const unit: <F extends TypeLambda>(F: Of<F>) => Kind<F, unknown, never, never, void>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Order.ts.md",
    "content": "---\ntitle: typeclass/Order.ts\nnav_order: 35\nparent: Modules\n---\n\n## Order overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [array](#array)\n  - [contramap](#contramap)\n  - [struct](#struct)\n  - [tuple](#tuple)\n- [constructors](#constructors)\n  - [make](#make)\n- [instances](#instances)\n  - [Contravariant](#contravariant)\n  - [Invariant](#invariant)\n  - [Product](#product)\n  - [SemiProduct](#semiproduct)\n  - [bigint](#bigint)\n  - [boolean](#boolean)\n  - [getMonoid](#getmonoid)\n  - [getSemigroup](#getsemigroup)\n  - [number](#number)\n  - [string](#string)\n- [type class](#type-class)\n  - [Order (interface)](#order-interface)\n- [type lambdas](#type-lambdas)\n  - [OrderTypeLambda (interface)](#ordertypelambda-interface)\n- [utils](#utils)\n  - [between](#between)\n  - [clamp](#clamp)\n  - [greaterThan](#greaterthan)\n  - [greaterThanOrEqualTo](#greaterthanorequalto)\n  - [lessThan](#lessthan)\n  - [lessThanOrEqualTo](#lessthanorequalto)\n  - [max](#max)\n  - [min](#min)\n  - [reverse](#reverse)\n\n---\n\n# combinators\n\n## array\n\nThis function creates and returns a new `Order` for an array of values based on a given `Order` for the elements of the array.\nThe returned `Order` compares two arrays by applying the given `Order` to each element in the arrays.\nIf all elements are equal, the arrays are then compared based on their length.\nIt is useful when you need to compare two arrays of the same type and you have a specific way of comparing each element of the array.\n\n**Signature**\n\n```ts\nexport declare const array: <A>(O: Order<A>) => Order<readonly A[]>\n```\n\nAdded in v1.0.0\n\n## contramap\n\n**Signature**\n\n```ts\nexport declare const contramap: {\n  <B, A>(f: (b: B) => A): (self: Order<A>) => Order<B>\n  <A, B>(self: Order<A>, f: (b: B) => A): Order<B>\n}\n```\n\nAdded in v1.0.0\n\n## struct\n\nThis function creates and returns a new `Order` for a struct of values based on the given `Order`s\nfor each property in the struct.\n\n**Signature**\n\n```ts\nexport declare const struct: <R extends { readonly [x: string]: Order<any> }>(\n  fields: R\n) => Order<{ [K in keyof R]: [R[K]] extends [Order<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n## tuple\n\nSimilar to `Promise.all` but operates on `Order`s.\n\n```\n[Order<A>, Order<B>, ...] -> Order<[A, B, ...]>\n```\n\nThis function creates and returns a new `Order` for a tuple of values based on the given `Order`s for each element in the tuple.\nThe returned `Order` compares two tuples of the same type by applying the corresponding `Order` to each element in the tuple.\nIt is useful when you need to compare two tuples of the same type and you have a specific way of comparing each element\nof the tuple.\n\n**Signature**\n\n```ts\nexport declare const tuple: <T extends readonly Order<any>[]>(\n  ...elements: T\n) => Order<{ [I in keyof T]: [T[I]] extends [Order<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## make\n\n**Signature**\n\n```ts\nexport declare const make: <A>(compare: (self: A, that: A) => 0 | 1 | -1) => Order<A>\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Contravariant\n\n**Signature**\n\n```ts\nexport declare const Contravariant: contravariant.Contravariant<OrderTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<OrderTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Product\n\n**Signature**\n\n```ts\nexport declare const Product: product_.Product<OrderTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiProduct\n\n**Signature**\n\n```ts\nexport declare const SemiProduct: semiProduct.SemiProduct<OrderTypeLambda>\n```\n\nAdded in v1.0.0\n\n## bigint\n\n**Signature**\n\n```ts\nexport declare const bigint: Order<bigint>\n```\n\nAdded in v1.0.0\n\n## boolean\n\n**Signature**\n\n```ts\nexport declare const boolean: Order<boolean>\n```\n\nAdded in v1.0.0\n\n## getMonoid\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A>() => Monoid<Order<A>>\n```\n\nAdded in v1.0.0\n\n## getSemigroup\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A>() => Semigroup<Order<A>>\n```\n\nAdded in v1.0.0\n\n## number\n\n**Signature**\n\n```ts\nexport declare const number: Order<number>\n```\n\nAdded in v1.0.0\n\n## string\n\n**Signature**\n\n```ts\nexport declare const string: Order<string>\n```\n\nAdded in v1.0.0\n\n# type class\n\n## Order (interface)\n\n**Signature**\n\n```ts\nexport interface Order<A> {\n  readonly compare: (self: A, that: A) => -1 | 0 | 1\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## OrderTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface OrderTypeLambda extends TypeLambda {\n  readonly type: Order<this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## between\n\nTest whether a value is between a minimum and a maximum (inclusive).\n\n**Signature**\n\n```ts\nexport declare const between: <A>(O: Order<A>) => {\n  (minimum: A, maximum: A): (self: A) => boolean\n  (self: A, minimum: A, maximum: A): boolean\n}\n```\n\nAdded in v1.0.0\n\n## clamp\n\nClamp a value between a minimum and a maximum.\n\n**Signature**\n\n```ts\nexport declare const clamp: <A>(O: Order<A>) => {\n  (minimum: A, maximum: A): (self: A) => A\n  (self: A, minimum: A, maximum: A): A\n}\n```\n\nAdded in v1.0.0\n\n## greaterThan\n\nTest whether one value is _strictly greater than_ another.\n\n**Signature**\n\n```ts\nexport declare const greaterThan: <A>(O: Order<A>) => { (that: A): (self: A) => boolean; (self: A, that: A): boolean }\n```\n\nAdded in v1.0.0\n\n## greaterThanOrEqualTo\n\nTest whether one value is _non-strictly greater than_ another.\n\n**Signature**\n\n```ts\nexport declare const greaterThanOrEqualTo: <A>(O: Order<A>) => {\n  (that: A): (self: A) => boolean\n  (self: A, that: A): boolean\n}\n```\n\nAdded in v1.0.0\n\n## lessThan\n\nTest whether one value is _strictly less than_ another.\n\n**Signature**\n\n```ts\nexport declare const lessThan: <A>(O: Order<A>) => { (that: A): (self: A) => boolean; (self: A, that: A): boolean }\n```\n\nAdded in v1.0.0\n\n## lessThanOrEqualTo\n\nTest whether one value is _non-strictly less than_ another.\n\n**Signature**\n\n```ts\nexport declare const lessThanOrEqualTo: <A>(O: Order<A>) => {\n  (that: A): (self: A) => boolean\n  (self: A, that: A): boolean\n}\n```\n\nAdded in v1.0.0\n\n## max\n\nTake the maximum of two values. If they are considered equal, the first argument is chosen.\n\n**Signature**\n\n```ts\nexport declare const max: <A>(O: Order<A>) => { (that: A): (self: A) => A; (self: A, that: A): A }\n```\n\nAdded in v1.0.0\n\n## min\n\nTake the minimum of two values. If they are considered equal, the first argument is chosen.\n\n**Signature**\n\n```ts\nexport declare const min: <A>(O: Order<A>) => { (that: A): (self: A) => A; (self: A, that: A): A }\n```\n\nAdded in v1.0.0\n\n## reverse\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(O: Order<A>) => Order<A>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Pointed.ts.md",
    "content": "---\ntitle: typeclass/Pointed.ts\nnav_order: 36\nparent: Modules\n---\n\n## Pointed overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Pointed (interface)](#pointed-interface)\n\n---\n\n# type class\n\n## Pointed (interface)\n\n**Signature**\n\n```ts\nexport interface Pointed<F extends TypeLambda> extends Covariant<F>, Of<F> {}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Product.ts.md",
    "content": "---\ntitle: typeclass/Product.ts\nnav_order: 37\nparent: Modules\n---\n\n## Product overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Product (interface)](#product-interface)\n- [utils](#utils)\n  - [struct](#struct)\n  - [tuple](#tuple)\n\n---\n\n# type class\n\n## Product (interface)\n\n**Signature**\n\n```ts\nexport interface Product<F extends TypeLambda> extends SemiProduct<F>, Of<F> {\n  readonly productAll: <R, O, E, A>(collection: Iterable<Kind<F, R, O, E, A>>) => Kind<F, R, O, E, Array<A>>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## struct\n\n**Signature**\n\n```ts\nexport declare const struct: <F extends TypeLambda>(\n  F: Product<F>\n) => <R extends { readonly [x: string]: Kind<F, any, any, any, any> }>(\n  fields: R\n) => Kind<\n  F,\n  [R[keyof R]] extends [Kind<F, infer R, any, any, any>] ? R : never,\n  [R[keyof R]] extends [Kind<F, any, infer O, any, any>] ? O : never,\n  [R[keyof R]] extends [Kind<F, any, any, infer E, any>] ? E : never,\n  { [K in keyof R]: [R[K]] extends [Kind<F, any, any, any, infer A>] ? A : never }\n>\n```\n\nAdded in v1.0.0\n\n## tuple\n\n**Signature**\n\n```ts\nexport declare const tuple: <F extends TypeLambda>(\n  F: Product<F>\n) => <T extends readonly Kind<F, any, any, any, any>[]>(\n  ...elements: T\n) => Kind<\n  F,\n  [T[number]] extends [Kind<F, infer R, any, any, any>] ? R : never,\n  [T[number]] extends [Kind<F, any, infer O, any, any>] ? O : never,\n  [T[number]] extends [Kind<F, any, any, infer E, any>] ? E : never,\n  { [I in keyof T]: [T[I]] extends [Kind<F, any, any, any, infer A>] ? A : never }\n>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/SemiAlternative.ts.md",
    "content": "---\ntitle: typeclass/SemiAlternative.ts\nnav_order: 38\nparent: Modules\n---\n\n## SemiAlternative overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [SemiAlternative (interface)](#semialternative-interface)\n\n---\n\n# type class\n\n## SemiAlternative (interface)\n\n**Signature**\n\n```ts\nexport interface SemiAlternative<F extends TypeLambda> extends SemiCoproduct<F>, Covariant<F> {}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/SemiApplicative.ts.md",
    "content": "---\ntitle: typeclass/SemiApplicative.ts\nnav_order: 39\nparent: Modules\n---\n\n## SemiApplicative overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [lifting](#lifting)\n  - [getSemigroup](#getsemigroup)\n  - [lift2](#lift2)\n- [type class](#type-class)\n  - [SemiApplicative (interface)](#semiapplicative-interface)\n- [utils](#utils)\n  - [andThen](#andthen)\n  - [andThenDiscard](#andthendiscard)\n  - [ap](#ap)\n  - [zipWith](#zipwith)\n\n---\n\n# lifting\n\n## getSemigroup\n\nLift a `Semigroup` into 'F', the inner values are combined using the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <F extends TypeLambda>(\n  F: SemiApplicative<F>\n) => <A, R, O, E>(S: Semigroup<A>) => Semigroup<Kind<F, R, O, E, A>>\n```\n\nAdded in v1.0.0\n\n## lift2\n\nLifts a binary function into `F`.\n\n**Signature**\n\n```ts\nexport declare const lift2: <F extends TypeLambda>(\n  F: SemiApplicative<F>\n) => <A, B, C>(\n  f: (a: A, b: B) => C\n) => {\n  <R2, O2, E2>(that: Kind<F, R2, O2, E2, B>): <R1, O1, E1>(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, C>\n  <R1, O1, E1, R2, O2, E2>(self: Kind<F, R1, O1, E1, A>, that: Kind<F, R2, O2, E2, B>): Kind<\n    F,\n    R1 & R2,\n    O1 | O2,\n    E1 | E2,\n    C\n  >\n}\n```\n\nAdded in v1.0.0\n\n# type class\n\n## SemiApplicative (interface)\n\n**Signature**\n\n```ts\nexport interface SemiApplicative<F extends TypeLambda> extends SemiProduct<F>, Covariant<F> {}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## andThen\n\n**Signature**\n\n```ts\nexport declare const andThen: <F extends TypeLambda>(\n  F: SemiApplicative<F>\n) => {\n  <R2, O2, E2, B>(that: Kind<F, R2, O2, E2, B>): <R1, O1, E1, _>(\n    self: Kind<F, R1, O1, E1, _>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, B>\n  <R1, O1, E1, _, R2, O2, E2, B>(self: Kind<F, R1, O1, E1, _>, that: Kind<F, R2, O2, E2, B>): Kind<\n    F,\n    R1 & R2,\n    O1 | O2,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v1.0.0\n\n## andThenDiscard\n\n**Signature**\n\n```ts\nexport declare const andThenDiscard: <F extends TypeLambda>(\n  F: SemiApplicative<F>\n) => {\n  <R2, O2, E2, _>(that: Kind<F, R2, O2, E2, _>): <R1, O1, E1, A>(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, A>\n  <R1, O1, E1, A, R2, O2, E2, _>(self: Kind<F, R1, O1, E1, A>, that: Kind<F, R2, O2, E2, _>): Kind<\n    F,\n    R1 & R2,\n    O1 | O2,\n    E1 | E2,\n    A\n  >\n}\n```\n\nAdded in v1.0.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <F extends TypeLambda>(\n  F: SemiApplicative<F>\n) => {\n  <R2, O2, E2, A>(that: Kind<F, R2, O2, E2, A>): <R1, O1, E1, B>(\n    self: Kind<F, R1, O1, E1, (a: A) => B>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, B>\n  <R1, O1, E1, A, B, R2, O2, E2>(self: Kind<F, R1, O1, E1, (a: A) => B>, that: Kind<F, R2, O2, E2, A>): Kind<\n    F,\n    R1 & R2,\n    O1 | O2,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v1.0.0\n\n## zipWith\n\nZips two `F` values together using a provided function, returning a new `F` of the result.\n\n**Signature**\n\n```ts\nexport declare const zipWith: <F extends TypeLambda>(\n  F: SemiApplicative<F>\n) => {\n  <R2, O2, E2, B, A, C>(that: Kind<F, R2, O2, E2, B>, f: (a: A, b: B) => C): <R1, O1, E1>(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, C>\n  <R1, O1, E1, A, R2, O2, E2, B, C>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>,\n    f: (a: A, b: B) => C\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, C>\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/SemiCoproduct.ts.md",
    "content": "---\ntitle: typeclass/SemiCoproduct.ts\nnav_order: 40\nparent: Modules\n---\n\n## SemiCoproduct overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [SemiCoproduct (interface)](#semicoproduct-interface)\n- [utils](#utils)\n  - [getSemigroup](#getsemigroup)\n\n---\n\n# type class\n\n## SemiCoproduct (interface)\n\n**Signature**\n\n```ts\nexport interface SemiCoproduct<F extends TypeLambda> extends Invariant<F> {\n  readonly coproduct: <R1, O1, E1, A, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>\n  ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, A | B>\n\n  readonly coproductMany: <R, O, E, A>(\n    self: Kind<F, R, O, E, A>,\n    collection: Iterable<Kind<F, R, O, E, A>>\n  ) => Kind<F, R, O, E, A>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## getSemigroup\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <F extends TypeLambda>(\n  F: SemiCoproduct<F>\n) => <R, O, E, A>() => Semigroup<Kind<F, R, O, E, A>>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/SemiProduct.ts.md",
    "content": "---\ntitle: typeclass/SemiProduct.ts\nnav_order: 42\nparent: Modules\n---\n\n## SemiProduct overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [productMany](#productmany)\n- [do notation](#do-notation)\n  - [andThenBind](#andthenbind)\n- [type class](#type-class)\n  - [SemiProduct (interface)](#semiproduct-interface)\n- [utils](#utils)\n  - [appendElement](#appendelement)\n  - [nonEmptyStruct](#nonemptystruct)\n  - [nonEmptyTuple](#nonemptytuple)\n  - [productComposition](#productcomposition)\n  - [productManyComposition](#productmanycomposition)\n\n---\n\n# constructors\n\n## productMany\n\nReturns a default `productMany` implementation.\n\n**Signature**\n\n```ts\nexport declare const productMany: <F extends TypeLambda>(\n  map: {\n    <A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Kind<F, R, O, E, B>\n  },\n  product: <R1, O1, E1, A, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>\n  ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, [A, B]>\n) => <R, O, E, A>(self: Kind<F, R, O, E, A>, collection: Iterable<Kind<F, R, O, E, A>>) => Kind<F, R, O, E, [A, ...A[]]>\n```\n\nAdded in v1.0.0\n\n# do notation\n\n## andThenBind\n\n**Signature**\n\n```ts\nexport declare const andThenBind: <F extends TypeLambda>(\n  F: SemiProduct<F>\n) => {\n  <N extends string, A extends object, R2, O2, E2, B>(name: Exclude<N, keyof A>, that: Kind<F, R2, O2, E2, B>): <\n    R1,\n    O1,\n    E1\n  >(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <R1, O1, E1, A extends object, N extends string, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    name: Exclude<N, keyof A>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n}\n```\n\nAdded in v1.0.0\n\n# type class\n\n## SemiProduct (interface)\n\n**Signature**\n\n```ts\nexport interface SemiProduct<F extends TypeLambda> extends Invariant<F> {\n  readonly product: <R1, O1, E1, A, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>\n  ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, [A, B]>\n\n  readonly productMany: <R, O, E, A>(\n    self: Kind<F, R, O, E, A>,\n    collection: Iterable<Kind<F, R, O, E, A>>\n  ) => Kind<F, R, O, E, [A, ...Array<A>]>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## appendElement\n\nAppends an element to the end of a tuple.\n\n**Signature**\n\n```ts\nexport declare const appendElement: <F extends TypeLambda>(\n  F: SemiProduct<F>\n) => {\n  <R2, O2, E2, B>(that: Kind<F, R2, O2, E2, B>): <R1, O1, E1, A extends readonly any[]>(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, [...A, B]>\n  <R1, O1, E1, A extends readonly any[], R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, [...A, B]>\n}\n```\n\nAdded in v1.0.0\n\n## nonEmptyStruct\n\n**Signature**\n\n```ts\nexport declare const nonEmptyStruct: <F extends TypeLambda>(\n  F: SemiProduct<F>\n) => <R extends { readonly [x: string]: Kind<F, any, any, any, any> }>(\n  fields: EnforceNonEmptyRecord<R> & { readonly [x: string]: Kind<F, any, any, any, any> }\n) => Kind<\n  F,\n  [R[keyof R]] extends [Kind<F, infer R, any, any, any>] ? R : never,\n  [R[keyof R]] extends [Kind<F, any, infer O, any, any>] ? O : never,\n  [R[keyof R]] extends [Kind<F, any, any, infer E, any>] ? E : never,\n  { [K in keyof R]: [R[K]] extends [Kind<F, any, any, any, infer A>] ? A : never }\n>\n```\n\nAdded in v1.0.0\n\n## nonEmptyTuple\n\n**Signature**\n\n```ts\nexport declare const nonEmptyTuple: <F extends TypeLambda>(\n  F: SemiProduct<F>\n) => <T extends readonly [Kind<F, any, any, any, any>, ...Kind<F, any, any, any, any>[]]>(\n  ...elements: T\n) => Kind<\n  F,\n  [T[number]] extends [Kind<F, infer R, any, any, any>] ? R : never,\n  [T[number]] extends [Kind<F, any, infer O, any, any>] ? O : never,\n  [T[number]] extends [Kind<F, any, any, infer E, any>] ? E : never,\n  { [I in keyof T]: [T[I]] extends [Kind<F, any, any, any, infer A>] ? A : never }\n>\n```\n\nAdded in v1.0.0\n\n## productComposition\n\nReturns a default `product` composition.\n\n**Signature**\n\n```ts\nexport declare const productComposition: <F extends TypeLambda, G extends TypeLambda>(\n  F: SemiApplicative<F>,\n  G: SemiProduct<G>\n) => <FR1, FO1, FE1, GR1, GO1, GE1, A, FR2, FO2, FE2, GR2, GO2, GE2, B>(\n  self: Kind<F, FR1, FO1, FE1, Kind<G, GR1, GO1, GE1, A>>,\n  that: Kind<F, FR2, FO2, FE2, Kind<G, GR2, GO2, GE2, B>>\n) => Kind<F, FR1 & FR2, FO1 | FO2, FE1 | FE2, Kind<G, GR1 & GR2, GO1 | GO2, GE1 | GE2, [A, B]>>\n```\n\nAdded in v1.0.0\n\n## productManyComposition\n\nReturns a default `productMany` composition.\n\n**Signature**\n\n```ts\nexport declare const productManyComposition: <F extends TypeLambda, G extends TypeLambda>(\n  F: SemiApplicative<F>,\n  G: SemiProduct<G>\n) => <FR, FO, FE, GR, GO, GE, A>(\n  self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n  collection: Iterable<Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>>\n) => Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, [A, ...A[]]>>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Semigroup.ts.md",
    "content": "---\ntitle: typeclass/Semigroup.ts\nnav_order: 41\nparent: Modules\n---\n\n## Semigroup overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [array](#array)\n  - [struct](#struct)\n  - [tuple](#tuple)\n- [constructors](#constructors)\n  - [constant](#constant)\n  - [make](#make)\n  - [max](#max)\n  - [min](#min)\n- [instances](#instances)\n  - [Invariant](#invariant)\n  - [Product](#product)\n  - [SemiProduct](#semiproduct)\n  - [bigintMultiply](#bigintmultiply)\n  - [bigintSum](#bigintsum)\n  - [booleanAll](#booleanall)\n  - [booleanAny](#booleanany)\n  - [booleanEqv](#booleaneqv)\n  - [booleanXor](#booleanxor)\n  - [first](#first)\n  - [last](#last)\n  - [numberMultiply](#numbermultiply)\n  - [numberSum](#numbersum)\n  - [string](#string)\n- [type class](#type-class)\n  - [Semigroup (interface)](#semigroup-interface)\n- [type lambdas](#type-lambdas)\n  - [SemigroupTypeLambda (interface)](#semigrouptypelambda-interface)\n- [utils](#utils)\n  - [imap](#imap)\n  - [intercalate](#intercalate)\n  - [reverse](#reverse)\n\n---\n\n# combinators\n\n## array\n\nGiven a type `A`, this function creates and returns a `Semigroup` for `ReadonlyArray<A>`.\nThe returned `Semigroup` combines two arrays by concatenating them.\n\n**Signature**\n\n```ts\nexport declare const array: <A>() => Semigroup<readonly A[]>\n```\n\nAdded in v1.0.0\n\n## struct\n\nThis function creates and returns a new `Semigroup` for a struct of values based on the given `Semigroup`s for each property in the struct.\nThe returned `Semigroup` combines two structs of the same type by applying the corresponding `Semigroup` passed as arguments to each property in the struct.\n\nIt is useful when you need to combine two structs of the same type and you have a specific way of combining each property of the struct.\n\n**Signature**\n\n```ts\nexport declare const struct: <R extends { readonly [x: string]: Semigroup<any> }>(\n  fields: R\n) => Semigroup<{ readonly [K in keyof R]: [R[K]] extends [Semigroup<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n## tuple\n\nSimilar to `Promise.all` but operates on `Semigroup`s.\n\n```\n[Semigroup<A>, Semigroup<B>, ...] -> Semigroup<[A, B, ...]>\n```\n\nThis function creates and returns a new `Semigroup` for a tuple of values based on the given `Semigroup`s for each element in the tuple.\nThe returned `Semigroup` combines two tuples of the same type by applying the corresponding `Semigroup` passed as arguments to each element in the tuple.\n\nIt is useful when you need to combine two tuples of the same type and you have a specific way of combining each element of the tuple.\n\n**Signature**\n\n```ts\nexport declare const tuple: <T extends readonly Semigroup<any>[]>(\n  ...elements: T\n) => Semigroup<{ readonly [I in keyof T]: [T[I]] extends [Semigroup<infer A>] ? A : never }>\n```\n\nAdded in v1.0.0\n\n# constructors\n\n## constant\n\n**Signature**\n\n```ts\nexport declare const constant: <A>(a: A) => Semigroup<A>\n```\n\nAdded in v1.0.0\n\n## make\n\n**Signature**\n\n```ts\nexport declare const make: <A>(\n  combine: (self: A, that: A) => A,\n  combineMany?: (self: A, collection: Iterable<A>) => A\n) => Semigroup<A>\n```\n\nAdded in v1.0.0\n\n## max\n\n`Semigroup` that returns last maximum of elements.\n\n**Signature**\n\n```ts\nexport declare const max: <A>(O: Order<A>) => Semigroup<A>\n```\n\nAdded in v1.0.0\n\n## min\n\n`Semigroup` that returns last minimum of elements.\n\n**Signature**\n\n```ts\nexport declare const min: <A>(O: Order<A>) => Semigroup<A>\n```\n\nAdded in v1.0.0\n\n# instances\n\n## Invariant\n\n**Signature**\n\n```ts\nexport declare const Invariant: invariant.Invariant<SemigroupTypeLambda>\n```\n\nAdded in v1.0.0\n\n## Product\n\n**Signature**\n\n```ts\nexport declare const Product: product_.Product<SemigroupTypeLambda>\n```\n\nAdded in v1.0.0\n\n## SemiProduct\n\n**Signature**\n\n```ts\nexport declare const SemiProduct: semiProduct.SemiProduct<SemigroupTypeLambda>\n```\n\nAdded in v1.0.0\n\n## bigintMultiply\n\n`bigint` semigroup under multiplication.\n\n**Signature**\n\n```ts\nexport declare const bigintMultiply: Semigroup<bigint>\n```\n\nAdded in v1.0.0\n\n## bigintSum\n\n`bigint` semigroup under addition.\n\n**Signature**\n\n```ts\nexport declare const bigintSum: Semigroup<bigint>\n```\n\nAdded in v1.0.0\n\n## booleanAll\n\n`boolean` semigroup under conjunction.\n\n**Signature**\n\n```ts\nexport declare const booleanAll: Semigroup<boolean>\n```\n\nAdded in v1.0.0\n\n## booleanAny\n\n`boolean` semigroup under disjunction.\n\n**Signature**\n\n```ts\nexport declare const booleanAny: Semigroup<boolean>\n```\n\nAdded in v1.0.0\n\n## booleanEqv\n\n`boolean` semigroup under equivalence.\n\n**Signature**\n\n```ts\nexport declare const booleanEqv: Semigroup<boolean>\n```\n\nAdded in v1.0.0\n\n## booleanXor\n\n`boolean` semigroup under exclusive disjunction.\n\n**Signature**\n\n```ts\nexport declare const booleanXor: Semigroup<boolean>\n```\n\nAdded in v1.0.0\n\n## first\n\nAlways return the first argument.\n\n**Signature**\n\n```ts\nexport declare const first: <A = never>() => Semigroup<A>\n```\n\nAdded in v1.0.0\n\n## last\n\nAlways return the last argument.\n\n**Signature**\n\n```ts\nexport declare const last: <A = never>() => Semigroup<A>\n```\n\nAdded in v1.0.0\n\n## numberMultiply\n\n`number` semigroup under multiplication.\n\n**Signature**\n\n```ts\nexport declare const numberMultiply: Semigroup<number>\n```\n\nAdded in v1.0.0\n\n## numberSum\n\n`number` semigroup under addition.\n\n**Signature**\n\n```ts\nexport declare const numberSum: Semigroup<number>\n```\n\nAdded in v1.0.0\n\n## string\n\n**Signature**\n\n```ts\nexport declare const string: Semigroup<string>\n```\n\nAdded in v1.0.0\n\n# type class\n\n## Semigroup (interface)\n\n**Signature**\n\n```ts\nexport interface Semigroup<A> {\n  readonly combine: (self: A, that: A) => A\n  readonly combineMany: (self: A, collection: Iterable<A>) => A\n}\n```\n\nAdded in v1.0.0\n\n# type lambdas\n\n## SemigroupTypeLambda (interface)\n\n**Signature**\n\n```ts\nexport interface SemigroupTypeLambda extends TypeLambda {\n  readonly type: Semigroup<this['Target']>\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## imap\n\n**Signature**\n\n```ts\nexport declare const imap: {\n  <A, B>(to: (a: A) => B, from: (b: B) => A): (self: Semigroup<A>) => Semigroup<B>\n  <A, B>(self: Semigroup<A>, to: (a: A) => B, from: (b: B) => A): Semigroup<B>\n}\n```\n\nAdded in v1.0.0\n\n## intercalate\n\n**Signature**\n\n```ts\nexport declare const intercalate: {\n  <A>(separator: A): (S: Semigroup<A>) => Semigroup<A>\n  <A>(S: Semigroup<A>, separator: A): Semigroup<A>\n}\n```\n\nAdded in v1.0.0\n\n## reverse\n\nThe dual of a `Semigroup`, obtained by flipping the arguments of `combine`.\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(S: Semigroup<A>) => Semigroup<A>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/Traversable.ts.md",
    "content": "---\ntitle: typeclass/Traversable.ts\nnav_order: 43\nparent: Modules\n---\n\n## Traversable overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [type class](#type-class)\n  - [Traversable (interface)](#traversable-interface)\n- [utils](#utils)\n  - [sequence](#sequence)\n  - [traverseComposition](#traversecomposition)\n  - [traverseTap](#traversetap)\n\n---\n\n# type class\n\n## Traversable (interface)\n\n**Signature**\n\n```ts\nexport interface Traversable<T extends TypeLambda> extends TypeClass<T> {\n  readonly traverse: <F extends TypeLambda>(\n    F: Applicative<F>\n  ) => {\n    <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): <TR, TO, TE>(\n      self: Kind<T, TR, TO, TE, A>\n    ) => Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n    <TR, TO, TE, A, R, O, E, B>(self: Kind<T, TR, TO, TE, A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<\n      F,\n      R,\n      O,\n      E,\n      Kind<T, TR, TO, TE, B>\n    >\n  }\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## sequence\n\nReturns a default `sequence` implementation.\n\n**Signature**\n\n```ts\nexport declare const sequence: <T extends TypeLambda>(\n  T: Traversable<T>\n) => <F extends TypeLambda>(\n  F: Applicative<F>\n) => <TR, TO, TE, R, O, E, A>(\n  self: Kind<T, TR, TO, TE, Kind<F, R, O, E, A>>\n) => Kind<F, R, O, E, Kind<T, TR, TO, TE, A>>\n```\n\nAdded in v1.0.0\n\n## traverseComposition\n\nReturns a default binary `traverse` composition.\n\n**Signature**\n\n```ts\nexport declare const traverseComposition: <T extends TypeLambda, G extends TypeLambda>(\n  T: Traversable<T>,\n  G: Traversable<G>\n) => <F extends TypeLambda>(\n  F: Applicative<F>\n) => <TR, TO, TE, GR, GO, GE, A, R, O, E, B>(\n  self: Kind<T, TR, TO, TE, Kind<G, GR, GO, GE, A>>,\n  f: (a: A) => Kind<F, R, O, E, B>\n) => Kind<F, R, O, E, Kind<T, TR, TO, TE, Kind<G, GR, GO, GE, B>>>\n```\n\nAdded in v1.0.0\n\n## traverseTap\n\nGiven a function which returns a `F` effect, thread this effect\nthrough the running of this function on all the values in `T`,\nreturning an `T<A>` in a `F` context, ignoring the values\nreturned by the provided function.\n\n**Signature**\n\n```ts\nexport declare const traverseTap: <T extends TypeLambda>(\n  T: Traversable<T>\n) => <F extends TypeLambda>(\n  F: Applicative<F>\n) => {\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): <TR, TO, TE>(\n    self: Kind<T, TR, TO, TE, A>\n  ) => Kind<F, R, O, E, Kind<T, TR, TO, TE, A>>\n  <TR, TO, TE, A, R, O, E, B>(self: Kind<T, TR, TO, TE, A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<\n    F,\n    R,\n    O,\n    E,\n    Kind<T, TR, TO, TE, A>\n  >\n}\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs/modules/typeclass/TraversableFilterable.ts.md",
    "content": "---\ntitle: typeclass/TraversableFilterable.ts\nnav_order: 44\nparent: Modules\n---\n\n## TraversableFilterable overview\n\n`TraversableFilterable` represents data structures which can be _partitioned_ with effects in some `Applicative` functor.\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [models](#models)\n  - [TraversableFilterable (interface)](#traversablefilterable-interface)\n- [utils](#utils)\n  - [traverseFilter](#traversefilter)\n  - [traverseFilterMap](#traversefiltermap)\n  - [traversePartition](#traversepartition)\n  - [traversePartitionMap](#traversepartitionmap)\n\n---\n\n# models\n\n## TraversableFilterable (interface)\n\n**Signature**\n\n```ts\nexport interface TraversableFilterable<T extends TypeLambda> extends TypeClass<T> {\n  readonly traversePartitionMap: <F extends TypeLambda>(\n    F: Applicative<F>\n  ) => {\n    <A, R, O, E, B, C>(f: (a: A) => Kind<F, R, O, E, Either<B, C>>): <TR, TO, TE>(\n      self: Kind<T, TR, TO, TE, A>\n    ) => Kind<F, R, O, E, [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, C>]>\n    <TR, TO, TE, A, R, O, E, B, C>(self: Kind<T, TR, TO, TE, A>, f: (a: A) => Kind<F, R, O, E, Either<B, C>>): Kind<\n      F,\n      R,\n      O,\n      E,\n      [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, C>]\n    >\n  }\n\n  readonly traverseFilterMap: <F extends TypeLambda>(\n    F: Applicative<F>\n  ) => {\n    <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, Option<B>>): <TR, TO, TE>(\n      self: Kind<T, TR, TO, TE, A>\n    ) => Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n    <TR, TO, TE, A, R, O, E, B>(self: Kind<T, TR, TO, TE, A>, f: (a: A) => Kind<F, R, O, E, Option<B>>): Kind<\n      F,\n      R,\n      O,\n      E,\n      Kind<T, TR, TO, TE, B>\n    >\n  }\n}\n```\n\nAdded in v1.0.0\n\n# utils\n\n## traverseFilter\n\n**Signature**\n\n```ts\nexport declare const traverseFilter: <T extends TypeLambda>(\n  T: TraversableFilterable<T>\n) => <F extends TypeLambda>(\n  F: Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(predicate: (a: A) => Kind<F, R, O, E, boolean>): <TR, TO, TE>(\n    self: Kind<T, TR, TO, TE, B>\n  ) => Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n  <TR, TO, TE, B extends A, R, O, E, A = B>(\n    self: Kind<T, TR, TO, TE, B>,\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n}\n```\n\nAdded in v1.0.0\n\n## traverseFilterMap\n\nReturns a default binary `traverseFilterMap` implementation.\n\n**Signature**\n\n```ts\nexport declare const traverseFilterMap: <T extends TypeLambda>(\n  T: Traversable<T> & filterable.Filterable<T>\n) => <F extends TypeLambda>(\n  F: Applicative<F>\n) => <TR, TO, TE, A, R, O, E, B>(\n  self: Kind<T, TR, TO, TE, A>,\n  f: (a: A) => Kind<F, R, O, E, Option<B>>\n) => Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n```\n\nAdded in v1.0.0\n\n## traversePartition\n\n**Signature**\n\n```ts\nexport declare const traversePartition: <T extends TypeLambda>(\n  T: TraversableFilterable<T>\n) => <F extends TypeLambda>(\n  F: Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(predicate: (a: A) => Kind<F, R, O, E, boolean>): <TR, TO, TE>(\n    self: Kind<T, TR, TO, TE, B>\n  ) => Kind<F, R, O, E, [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, B>]>\n  <TR, TO, TE, B extends A, R, O, E, A = B>(\n    self: Kind<T, TR, TO, TE, B>,\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): Kind<F, R, O, E, [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, B>]>\n}\n```\n\nAdded in v1.0.0\n\n## traversePartitionMap\n\nReturns a default binary `traversePartitionMap` implementation.\n\n**Signature**\n\n```ts\nexport declare const traversePartitionMap: <T extends TypeLambda>(\n  T: Traversable<T> & Covariant<T> & filterable.Filterable<T>\n) => <F extends TypeLambda>(\n  F: Applicative<F>\n) => <TR, TO, TE, A, R, O, E, B, C>(\n  self: Kind<T, TR, TO, TE, A>,\n  f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n) => Kind<F, R, O, E, [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, C>]>\n```\n\nAdded in v1.0.0\n"
  },
  {
    "path": "docs-ts.json",
    "content": "{\n  \"exclude\": [\"src/internal/**/*.ts\"],\n  \"theme\": \"mikearnaldi/just-the-docs\"\n}\n"
  },
  {
    "path": "dtslint/index.d.ts",
    "content": "// TypeScript Version: 4.8\n"
  },
  {
    "path": "dtslint/ts4.8/FlatMap.ts",
    "content": "import * as _ from \"@fp-ts/core/typeclass/FlatMap\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport { pipe } from \"@fp-ts/core/Function\"\n\ninterface RAW<R, E, A> {\n  (r: R): () => Promise<readonly [E, A]>\n}\n\ninterface RAWTypeLambda extends TypeLambda {\n  readonly type: RAW<this[\"In\"], this[\"Out1\"], this[\"Target\"]>\n}\n\ndeclare const FlatMap: _.FlatMap<RAWTypeLambda>\n\ndeclare const ffa: RAW<{ a: string }, string, RAW<{ b: number }, number, 'a'>>\n\n// $ExpectType RAW<{ b: number; } & { a: string; }, string | number, \"a\">\npipe(ffa, _.flatten(FlatMap))\n"
  },
  {
    "path": "dtslint/ts4.8/Monoid.ts",
    "content": "import * as _ from \"@fp-ts/core/typeclass/Monoid\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as String from \"@fp-ts/core/String\"\n\n//\n// tuple\n//\n\n// $ExpectType Monoid<readonly [string, number]>\n_.tuple(\n  String.Monoid,\n  Number.MonoidSum\n)\n\n//\n// struct\n//\n\n// $ExpectType Monoid<{ readonly a: string; readonly b: number; }>\n_.struct({\n  a: String.Monoid,\n  b: Number.MonoidSum\n})\n"
  },
  {
    "path": "dtslint/ts4.8/Option.ts",
    "content": "import { pipe } from '@fp-ts/core/Function'\nimport * as _ from '@fp-ts/core/Option'\n\ndeclare const n: number\ndeclare const sn: string | number\ndeclare const isString: (u: unknown) => u is string\ndeclare const predicate: (sn: string | number) => boolean\ndeclare const on: _.Option<number>\ndeclare const osn: _.Option<string | number>\n\n// -------------------------------------------------------------------------------------\n// liftPredicate\n// -------------------------------------------------------------------------------------\n\n// $ExpectType Option<string>\npipe(sn, _.liftPredicate(isString))\npipe(\n  sn,\n  _.liftPredicate(\n    (\n      n // $ExpectType string | number\n    ): n is number => typeof n === 'number'\n  )\n)\n\n// $ExpectType Option<string | number>\npipe(sn, _.liftPredicate(predicate))\n// $ExpectType Option<number>\npipe(n, _.liftPredicate(predicate))\n// $ExpectType Option<number>\npipe(\n  n,\n  _.liftPredicate(\n    (\n      _n // $ExpectType number\n    ) => true\n  )\n)\n\n// -------------------------------------------------------------------------------------\n// getOrElse\n// -------------------------------------------------------------------------------------\n\n// $ExpectType string | null\npipe(_.some('a'), _.getOrElse(() => null))\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n// $ExpectType Option<{ a1: number; a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.some(1)),\n  _.bind('a2', () => _.some('b'))\n)\n\n// -------------------------------------------------------------------------------------\n// filter\n// -------------------------------------------------------------------------------------\n\n// $ExpectType Option<number>\npipe(on, _.filter(predicate))\n\n// $ExpectType Option<number>\n_.filter(on, predicate)\n\n// $ExpectType Option<string>\npipe(osn, _.filter(isString))\n\n// $ExpectType Option<string>\n_.filter(osn, isString)\n\n// $ExpectType Option<number>\npipe(\n  on,\n  _.filter(\n    (\n      x // $ExpectType number\n    ): x is number => true\n  )\n)\n\n// $ExpectType Option<number>\npipe(\n  on,\n  _.filter(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n"
  },
  {
    "path": "dtslint/ts4.8/Predicate.ts",
    "content": "import * as _ from '@fp-ts/core/Predicate'\n\ndeclare const u: unknown\ndeclare const anys: Array<any>\ndeclare const unknowns: Array<unknown>\ndeclare const numberOrNull: Array<number | null>\ndeclare const numberOrUndefined: Array<number | undefined>\ndeclare const numberOrNullOrUndefined: Array<number | null | undefined>\n\n// -------------------------------------------------------------------------------------\n// isString\n// -------------------------------------------------------------------------------------\n\n// $ExpectType string[]\nunknowns.filter(_.isString)\n\n// -------------------------------------------------------------------------------------\n// isNumber\n// -------------------------------------------------------------------------------------\n\n// $ExpectType number[]\nunknowns.filter(_.isNumber)\n\n// -------------------------------------------------------------------------------------\n// isBoolean\n// -------------------------------------------------------------------------------------\n\n// $ExpectType boolean[]\nunknowns.filter(_.isBoolean)\n\n// -------------------------------------------------------------------------------------\n// isBigint\n// -------------------------------------------------------------------------------------\n\n// $ExpectType bigint[]\nunknowns.filter(_.isBigint)\n\n// -------------------------------------------------------------------------------------\n// isSymbol\n// -------------------------------------------------------------------------------------\n\n// $ExpectType symbol[]\nunknowns.filter(_.isSymbol)\n\n// -------------------------------------------------------------------------------------\n// isUndefined\n// -------------------------------------------------------------------------------------\n\n// $ExpectType undefined[]\nunknowns.filter(_.isUndefined)\n\n// -------------------------------------------------------------------------------------\n// isNotUndefined\n// -------------------------------------------------------------------------------------\n\n// $ExpectType number[]\nnumberOrUndefined.filter(_.isNotUndefined)\n\n// $ExpectType (number | null)[]\nnumberOrNullOrUndefined.filter(_.isNotUndefined)\n\n// -------------------------------------------------------------------------------------\n// isUndefined\n// -------------------------------------------------------------------------------------\n\n// $ExpectType null[]\nunknowns.filter(_.isNull)\n\n// -------------------------------------------------------------------------------------\n// isNotUndefined\n// -------------------------------------------------------------------------------------\n\n// $ExpectType number[]\nnumberOrNull.filter(_.isNotNull)\n\n// $ExpectType (number | undefined)[]\nnumberOrNullOrUndefined.filter(_.isNotNull)\n\n// -------------------------------------------------------------------------------------\n// isNever\n// -------------------------------------------------------------------------------------\n\n// $ExpectType never[]\nunknowns.filter(_.isNever)\n\n// -------------------------------------------------------------------------------------\n// isUnknown\n// -------------------------------------------------------------------------------------\n\n// $ExpectType unknown[]\nanys.filter(_.isUnknown)\n\n// -------------------------------------------------------------------------------------\n// isObject\n// -------------------------------------------------------------------------------------\n\n// $ExpectType object[]\nanys.filter(_.isObject)\n\n// -------------------------------------------------------------------------------------\n// isNullable\n// -------------------------------------------------------------------------------------\n\n// $ExpectType null[]\nnumberOrNull.filter(_.isNullable)\n\n// $ExpectType undefined[]\nnumberOrUndefined.filter(_.isNullable)\n\n// $ExpectType (null | undefined)[]\nnumberOrNullOrUndefined.filter(_.isNullable)\n\nif (_.isNullable(u)) {\n  // $ExpectType never\n  u\n}\n\n// -------------------------------------------------------------------------------------\n// isNotNullable\n// -------------------------------------------------------------------------------------\n\n// $ExpectType number[]\nnumberOrNull.filter(_.isNotNullable)\n\n// $ExpectType number[]\nnumberOrUndefined.filter(_.isNotNullable)\n\n// $ExpectType number[]\nnumberOrNullOrUndefined.filter(_.isNotNullable)\n\nif (_.isNotNullable(u)) {\n  // $ExpectType {}\n  u\n}\n\n// -------------------------------------------------------------------------------------\n// isError\n// -------------------------------------------------------------------------------------\n\n// $ExpectType Error[]\nunknowns.filter(_.isError)\n\n// -------------------------------------------------------------------------------------\n// isDate\n// -------------------------------------------------------------------------------------\n\n// $ExpectType Date[]\nunknowns.filter(_.isDate)\n\n// -------------------------------------------------------------------------------------\n// isRecord\n// -------------------------------------------------------------------------------------\n\n// $ExpectType { [x: string]: unknown; [x: symbol]: unknown; }[]\nunknowns.filter(_.isRecord)\n\n// -------------------------------------------------------------------------------------\n// isReadonlyRecord\n// -------------------------------------------------------------------------------------\n\n// $ExpectType { readonly [x: string]: unknown; readonly [x: symbol]: unknown; }[]\nunknowns.filter(_.isReadonlyRecord)\n"
  },
  {
    "path": "dtslint/ts4.8/Product.ts",
    "content": "import * as _ from \"@fp-ts/core/typeclass/Product\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\n\ninterface RAW<R, E, A> {\n  (r: R): () => Promise<readonly [E, A]>\n}\n\ninterface RAWTypeLambda extends TypeLambda {\n  readonly type: RAW<this[\"In\"], this[\"Out1\"], this[\"Target\"]>\n}\n\ndeclare const fa: RAW<{ a: string }, \"a\", string>\ndeclare const fb: RAW<{ b: number }, \"b\", number>\ndeclare const fc: RAW<{ c: boolean }, \"c\", boolean>\n\nexport declare const Product: _.Product<RAWTypeLambda>\n\n// $ExpectType RAW<{ a: string; } & { b: number; } & { c: boolean; }, \"a\" | \"b\" | \"c\", [string, number, boolean]>\n_.tuple(Product)(fa, fb, fc)\n\n// $ExpectType RAW<{ a: string; } & { b: number; } & { c: boolean; }, \"a\" | \"b\" | \"c\", { fa: string; fb: number; fc: boolean; }>\n_.struct(Product)({ fa, fb, fc })\n\n_.tuple(Product)() // should allow empty tuple\n_.struct(Product)({}) // should allow empty structs\n"
  },
  {
    "path": "dtslint/ts4.8/ReadonlyArray.ts",
    "content": "import { pipe } from '@fp-ts/core/Function'\nimport * as RA from '@fp-ts/core/ReadonlyArray'\nimport * as O from '@fp-ts/core/Option'\n\ndeclare const neras: RA.NonEmptyReadonlyArray<number>\ndeclare const neas: RA.NonEmptyArray<number>\ndeclare const ras: ReadonlyArray<number>\ndeclare const as: Array<number>\n\n// -------------------------------------------------------------------------------------\n// isEmpty\n// -------------------------------------------------------------------------------------\n\nif (RA.isEmpty(ras)) {\n  // $ExpectType readonly []\n  ras\n}\n\n// $ExpectType <A>(c: readonly A[]) => Option<readonly []>\nO.liftPredicate(RA.isEmpty)\n\n// -------------------------------------------------------------------------------------\n// isEmptyArray\n// -------------------------------------------------------------------------------------\n\nif (RA.isEmptyArray(as)) {\n  // $ExpectType []\n  as\n}\n\n// $ExpectType <A>(c: A[]) => Option<[]>\nO.liftPredicate(RA.isEmptyArray)\n\n// -------------------------------------------------------------------------------------\n// isNonEmpty\n// -------------------------------------------------------------------------------------\n\nif (RA.isNonEmpty(ras)) {\n  // $ExpectType readonly [number, ...number[]]\n  ras\n}\n\n// $ExpectType <A>(c: readonly A[]) => Option<readonly [A, ...A[]]>\nO.liftPredicate(RA.isNonEmpty)\n\n// -------------------------------------------------------------------------------------\n// isNonEmptyArray\n// -------------------------------------------------------------------------------------\n\nif (RA.isNonEmptyArray(as)) {\n  // $ExpectType [number, ...number[]]\n  as\n}\n\n// $ExpectType <A>(c: A[]) => Option<[A, ...A[]]>\nO.liftPredicate(RA.isNonEmptyArray)\n\n// -------------------------------------------------------------------------------------\n// map\n// -------------------------------------------------------------------------------------\n\n// $ExpectType number[]\nRA.map(ras, n => n + 1)\n\n// $ExpectType number[]\npipe(ras, RA.map(n => n + 1))\n\n// $ExpectType number[]\nRA.map(as, n => n + 1)\n\n// $ExpectType number[]\npipe(as, RA.map(n => n + 1))\n\n// -------------------------------------------------------------------------------------\n// mapNonEmpty\n// -------------------------------------------------------------------------------------\n\n// $ExpectType [number, ...number[]]\nRA.mapNonEmpty(neras, n => n + 1)\n\n// $ExpectType [number, ...number[]]\npipe(neras, RA.mapNonEmpty(n => n + 1))\n\n// $ExpectType [number, ...number[]]\nRA.mapNonEmpty(neas, n => n + 1)\n\n// $ExpectType [number, ...number[]]\npipe(neas, RA.mapNonEmpty(n => n + 1))\n"
  },
  {
    "path": "dtslint/ts4.8/ReadonlyRecord.ts",
    "content": "import { pipe } from '@fp-ts/core/Function'\nimport * as RR from '@fp-ts/core/ReadonlyRecord'\n\ndeclare const r: Record<string, number>\ndeclare const struct: Record<'a' | 'b', number>\n\n//\n// map\n//\n\n// $ExpectType Record<string, boolean>\nRR.map(r, (\n  value, // $ExpectType number\n  _key, // $ExpectType string\n) => value > 0)\n\n// $ExpectType Record<string, boolean>\npipe(r, RR.map((\n  value, // $ExpectType number\n  _key, // $ExpectType string\n) => value > 0))\n\n// $ExpectType Record<\"a\" | \"b\", boolean>\nRR.map(struct, (\n  value, // $ExpectType number\n  _key, // $ExpectType \"a\" | \"b\"\n) => value > 0)\n\n// $ExpectType Record<\"a\" | \"b\", boolean>\npipe(struct, RR.map((\n  value, // $ExpectType number\n  _key, // $ExpectType \"a\" | \"b\"\n) => value > 0))\n\nconst constStruct = { a: 1, b: 2 } as const;\n\nfunction mapToBoolean(): { [K in keyof typeof constStruct]: boolean } {\n  return RR.map(constStruct, () => true);\n}\n\n// $ExpectType { readonly a: boolean; readonly b: boolean; }\nmapToBoolean()\n\n//\n// get\n//\n\n// $ExpectType Option<number>\npipe(r, RR.get('a'))\n\n//\n// replaceOption\n//\n\n// $ExpectType Option<Record<string, number>>\npipe(r, RR.replaceOption('a', 2))\n\n// $ExpectType Option<Record<string, number | boolean>>\npipe(r, RR.replaceOption('a', true))\n\n//\n// modifyOption\n//\n\n// $ExpectType Option<Record<string, number>>\npipe(r, RR.modifyOption('a', () => 2))\n\n// $ExpectType Option<Record<string, number | boolean>>\npipe(r, RR.modifyOption('a', () => true))\n"
  },
  {
    "path": "dtslint/ts4.8/SemiAlternative.ts",
    "content": "import * as _ from \"@fp-ts/core/typeclass/SemiAlternative\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport { pipe } from \"@fp-ts/core/Function\"\n\ninterface RAW<R, E, A> {\n  (r: R): () => Promise<readonly [E, A]>\n}\n\ninterface RAWTypeLambda extends TypeLambda {\n  readonly type: RAW<this[\"In\"], this[\"Out1\"], this[\"Target\"]>\n}\n\ndeclare const fa: RAW<{ a: string }, string, \"fa\">\ndeclare const fb: RAW<{ b: number }, number, \"fb\">\n\ndeclare const SemiAlternative: _.SemiAlternative<RAWTypeLambda>\n\n// $ExpectType RAW<{ a: string; } & { b: number; }, string | number, \"fa\" | \"fb\">\nSemiAlternative.coproduct(fa, fb)\n"
  },
  {
    "path": "dtslint/ts4.8/SemiProduct.ts",
    "content": "import { OptionTypeLambda } from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/typeclass/SemiProduct\"\n\nexport declare const SemiProduct: _.SemiProduct<OptionTypeLambda>\n\n// $ExpectError\n_.nonEmptyTuple(SemiProduct)() // should not allow empty tuples\n\n// $ExpectError\n_.nonEmptyStruct(SemiProduct)({}) // should not allow empty structs\n"
  },
  {
    "path": "dtslint/ts4.8/Semigroup.ts",
    "content": "import * as _ from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as String from \"@fp-ts/core/String\"\n\n//\n// tuple\n//\n\n// $ExpectType Semigroup<readonly [string, number]>\n_.tuple(\n  String.Semigroup,\n  Number.SemigroupSum\n)\n\n//\n// struct\n//\n\n// $ExpectType Semigroup<{ readonly a: string; readonly b: number; }>\n_.struct({\n  a: String.Semigroup,\n  b: Number.SemigroupSum\n})\n"
  },
  {
    "path": "dtslint/ts4.8/Tuple.ts",
    "content": "import * as T from '@fp-ts/core/Tuple'\nimport { pipe } from '@fp-ts/core/Function'\n\n//\n// tuple\n//\n\n// $ExpectType [string, number, boolean]\nT.tuple('a', 1, true)\n\n//\n// appendElement\n//\n\n// $ExpectType [string, number, boolean]\npipe(T.tuple('a', 1), T.appendElement(true))\n"
  },
  {
    "path": "dtslint/ts4.8/index.d.ts",
    "content": ""
  },
  {
    "path": "dtslint/ts4.8/index.ts",
    "content": "import * as _ from '../../src/HKT'\n\n// issue #536\nfunction testIssue536<F extends _.TypeLambda, G extends _.TypeLambda, R, W, E, A>(\n  x: _.Kind<F, R, W, E, A>\n): _.Kind<G, R, W, E, A> {\n  // $ExpectError\n  return x\n}\n"
  },
  {
    "path": "dtslint/ts4.8/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"noEmit\": true,\n    \"strict\": true,\n    \"noImplicitAny\": false,\n    \"noImplicitThis\": true,\n    \"strictNullChecks\": true,\n    \"strictFunctionTypes\": true,\n    \"noImplicitReturns\": false,\n    \"noUnusedLocals\": false,\n    \"noUnusedParameters\": false,\n    \"noFallthroughCasesInSwitch\": true,\n    \"moduleResolution\": \"node\",\n    \"target\": \"ES2021\",\n    \"lib\": [\"ES2021\"],\n    \"paths\": {\n      \"@fp-ts/core\": [\"../../src/index.ts\"],\n      \"@fp-ts/core/test/*\": [\"../../test/*\"],\n      \"@fp-ts/core/examples/*\": [\"../../examples/*\"],\n      \"@fp-ts/core/*\": [\"../../src/*\"]\n    }\n  }\n}\n"
  },
  {
    "path": "dtslint/ts4.8/tslint.json",
    "content": "{\n  \"extends\": \"dtslint/dtslint.json\",\n  \"rules\": {\n    \"no-duplicate-imports\": false,\n    \"semicolon\": false,\n    \"array-type\": false,\n    \"no-unnecessary-generics\": false,\n    \"member-access\": false,\n    \"no-empty-interface\": false,\n    \"no-arg\": false,\n    \"no-object-literal-type-assertion\": false,\n    \"no-unnecessary-class\": false,\n    \"radix\": false,\n    \"no-angle-bracket-type-assertion\": false,\n    \"object-literal-shorthand\": false,\n    \"prefer-object-spread\": false,\n    \"whitespace\": false,\n    \"use-default-type-parameter\": false,\n    \"no-relative-import-in-test\": false,\n    \"no-null-undefined-union\": false,\n    \"invalid-void\": false,\n    \"max-line-length\": false,\n    \"no-useless-files\": false\n  }\n}\n"
  },
  {
    "path": "guides/Either.md",
    "content": "# The `Either` data type\n\nThe `Either` data type is a powerful and flexible tool for handling potentially failed computations in functional programming. It can be found in the `@fp-ts/core/Either` module, and it has two variants, `Left` and `Right`, which can be used to represent different outcomes.\n\nThe `Left` variant is used to represent a failure, and it can contain useful information such as an error message or a failure code. The `Right` variant, on the other hand, is used to represent a successful outcome, and it can contain the result of the computation.\n\nUnlike the `Option` type, `Either` allows you to attach additional information to the failure case, making it more informative.\nIn this usage, `None` is replaced with a `Left` which can contain useful information. `Right` takes the place of `Some`.\n\n# Definition\n\nThe `Either` data type is the union of two members: `Left` and `Right`. The way chosen by the `@fp-ts/core` library to model this union in TypeScript is to use a feature of the language called [Discriminating Unions](https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#discriminating-unions).\n\n> A common technique for working with unions is to have a single field which uses literal types which you can use to let TypeScript narrow down the possible current type\n\nBy convention in `@fp-ts/core`, this single field which uses literal types is named \"\\_tag\" (but you can use any name when defining your unions).\n\nFurthermore, `Either` is a \"polymorphic\" data type, that is, it makes use of a feature of TypeScript named [\"Generics\"](https://www.typescriptlang.org/docs/handbook/2/generics.html), meaning that the `Either` data type is a container that can hold any type.\n\nHere's the complete definition of the `Either` type:\n\n```ts\n// Holds the information for a failure case\nexport type Left<E> = {\n  // Discriminating field used to identify the variant\n  readonly _tag: \"Left\";\n  // The actual error\n  readonly left: E;\n};\n\n// Holds the result of a successful computation\nexport type Right<A> = {\n  // Discriminating field used to identify the variant\n  readonly _tag: \"Right\";\n  // The actual value\n  readonly right: A;\n};\n\nexport type Either<E, A> = Left<E> | Right<A>;\n```\n\nThe `Either` data type is defined as a union of two other types, `Left` and `Right`, that represent the two possible outcomes of a computation: a failure or a success.\n\nThe type parameters `E` and `A` are used to specify the type of the failure value and the success value that the `Either` holds respectively.\n\nThe `_tag` field is used to distinguish between the two variants, `Left` and `Right`.\n\n# Using `Either`\n\nTo create an instance of `Either`, you can use the `right` and `left` constructors, which construct a new `Either` holding a `Right` or `Left` value respectively.\n\n```ts\nimport { left, right } from \"@fp-ts/core/Either\";\n\nconst success: Either<string, number> = right(1);\nconst failure: Either<string, number> = left(\"error message\");\n```\n\nLet's summarize the two cases in a table:\n\n**Cheat sheet** (constructors)\n\n| Name    | Given | To                 |\n| ------- | ----- | ------------------ |\n| `right` | `A`   | `Either<never, A>` |\n| `left`  | `E`   | `Either<E, never>` |\n\n# Conversions\n\nYou can also use the `fromOption` function to convert an `Option` to an `Either`.\n\n```ts\nimport { Either, fromOption } from \"@fp-ts/core/Either\";\nimport { none, some } from \"@fp-ts/core/Option\";\n\nconst success: Either<string, number> = fromOption(\n  some(1),\n  () => \"error message\"\n);\nconst failure: Either<string, number> = fromOption(\n  none(),\n  () => \"error message\"\n);\n```\n\nThe `fromOption` function requires a second argument because it needs to know what value to use for the `Left` variant of the `Either` type when given a `None`. In the example, the argument \"error message\" is used as the value for the `Left` variant when `None` is encountered. This allows `Either` to provide more information about why a failure occurred.\n\n**Cheat sheet** (conversions)\n\n| Name           | Given                                | To                 | Note                |\n| -------------- | ------------------------------------ | ------------------ | ------------------- |\n| `fromOption`   | `Option<A>`, `onNone: LazyArg<E>`    | `Either<E, A>`     |                     |\n| `toOption`     | `Either<E, A>`                       | `Option<A>`        |                     |\n| `getRight`     | `Either<E, A>`                       | `Option<A>`        | alias of `toOption` |\n| `getLeft`      | `Either<E, A>`                       | `Option<E>`        |                     |\n| `toRefinement` | `A => Either<E, B>`                  | `Refinement<A, B>` |                     |\n| `fromIterable` | `Iterable<A>`, `onEmpty: LazyArg<E>` | `Either<E, A>`     |                     |\n| `toArray`      | `Either<E, A>`                       | `Array<A>`         |                     |\n\n# Working with `Either`\n\nOnce you have an instance of `Either`, you can use the various functions provided in the `@fp-ts/core/Either` module to work with it.\n\nThe `map` function can be used to transform the `Right` values:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Either, right, map } from \"@fp-ts/core/Either\";\n\nconst success: Either<string, number> = pipe(\n  right(1),\n  map((x) => x + 1)\n); // right(2)\n```\n\nAs you can see you can transform the result of your computation without unwrapping and wrapping the underlying value of `Either`.\n\nWhat is very convenient about `Either` is how the absence of value (i.e. a `Left`) is handled. See the example below:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Either, left, map } from \"@fp-ts/core/Either\";\n\nconst failure: Either<string, number> = pipe(\n  left(\"error\"),\n  // tries to map the value inside the `Right`, but it does not exist, resulting in `Left`\n  map((x) => x + 1)\n);\n```\n\nAs you can see, even though we started with a `Left` value, we can still operate on our `Either`. No errors are thrown or shown to the user, unless we do it intentionally. What happens is that when the `Either` is `Left`, the mapping doesn't even happen and the `Left` value representing the failed computation is returned unchanged.\n\nIn case you want to map the value contained in the `Left`, for example to change the type of error you want to express, you can use the `mapLeft` API which acts like `map` but this time on the `Left` part of an `Either`:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Either, left, mapLeft } from \"@fp-ts/core/Either\";\n\nconst failure: Either<string, number> = pipe(\n  left(\"error message\"),\n  mapLeft((x) => x + \"!\")\n); // left(\"error message!\")\n```\n\n# Handling failing computations\n\nLet's see how to use the `Either` data type to model a computation that can fail, such as a function that can throw an exception based on certain conditions. Let's take the case of the following function:\n\n```ts\nfunction parseNumber(s: string): number {\n  const n = parseFloat(s);\n  if (isNaN(n)) {\n    throw new Error(`Cannot parse '${s}' as a number`);\n  }\n  return n;\n}\n```\n\nAn alternative to throwing an exception is to always return a value, but this value will be of type `Either<string, number>` instead of `number`, with the following interpretation:\n\n- if `parseNumber` returns a `Left<string>` value, it means that the computation failed, and the `Left` contains an error message or other information about the failure\n- if the result is instead a `Right<number>` value, it means that the computation succeeded and the computed value is wrapped inside the `Right`\n\nLet's see how we can rewrite the `parseNumber` function without throwing exceptions and using the `Either` data type instead:\n\n```ts\nimport { Either, left, right } from \"@fp-ts/core/Either\";\n\nfunction parseNumber(s: string): Either<string, number> {\n  const n = parseFloat(s);\n  return isNaN(n) ? left(`Cannot parse '${s}' as a number`) : right(n);\n}\n\nconsole.log(parseNumber(\"2\")); // right(2)\nconsole.log(parseNumber(\"Not a number\")); // left(\"Cannot parse 'Not a number' as a number\")\n```\n\nWhat happens if we add a call to the `parseNumber` function to a pipeline that already involves an `Either`?\n\n```ts\nconst result = pipe(\n  right(\"2\"),\n  map((s) => parseNumber(s)),\n  map((n) => n2) // type-checker error!\n);\n```\n\nThere's something wrong, we received an error from the type checker, what happened?\n\nThe problem is that in the second `map` the parameter `n` is of type `Either<string, number>` and not `number`.\n\n```ts\nconst result = pipe(\n  right(\"2\"),\n  map((s) => parseNumber(s)),\n  map((x: Either<string, number>) => ...)\n);\n```\n\nFortunately, the fix is simple, when adding a computation that returns an `Either` to our pipeline we should use the `flatMap` function instead of the `map` function:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { right, flatMap, map } from \"@fp-ts/core/Either\";\n\nconst result = pipe(\n  right(\"2\"),\n  flatMap((s) => parseNumber(s)),\n  map((n) => n2) // ok! now `n` has type `number`\n);\n```\n\nLet's summarize the two cases in a table:\n\n**Cheat sheet** (sequencing)\n\n| Name      | Given                                  | To                    |\n| --------- | -------------------------------------- | --------------------- |\n| `map`     | `Either<E, A>`, `A => B`               | `Either<E, B>`        |\n| `flatMap` | `Either<E1, A>`, `E1 => Either<E2, B>` | `Either<E1 \\| E2, B>` |\n\nThe `flatMap` function offers the same convenience as the `map` function, which only continues with the computations contained in the pipeline if a `Left` value is **not** encountered:\n\n**Happy path, starting with a valid input**\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Either, right, flatMap, map } from \"@fp-ts/core/Either\";\n\nconst success: Either<string, number> = pipe(\n  right(\"2\"),\n  flatMap((s) => parseNumber(s)), // parse the input to number\n  map((x) => x2), // double the parsed number\n  map((x) => x - 3) // subtract 3\n); // right(1)\n```\n\n**Error path, starting with an invalid input**\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Either, right, flatMap, map } from \"@fp-ts/core/Either\";\n\nconst failure: Either<string, number> = pipe(\n  right(\"Not a number\"),\n  flatMap((s) => parseNumber(s)), // parse the input to number\n  map((x) => x2), // This will not be executed because parseNumber will return Left\n  map((x) => x - 3) // This will not be executed\n); // left(\"Cannot parse 'Not a number' as a number\")\n```\n\n**Error path, starting with None**\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Either, left, flatMap, map } from \"@fp-ts/core/Either\";\n\nconst leftStart: Either<string, number> = pipe(\n  left(\"error message\"),\n  flatMap((s) => parseNumber(s)), // This will not be executed because it starts with Left\n  map((x) => x2), // This will not be executed\n  map((x) => x - 3) // This will not be executed\n); // left(\"error message\")\n```\n\nWhen using this approach, the **desired outcome** is always in clear view while defining your pipeline. This allows you to focus on the expected result, while leaving it to `Either` to handle any potential errors that may arise seamlessly and transparently.\n\nYou can focus on the successful scenario and let `Either` handle the tedious task of managing potential errors at every step of the pipeline, without the need for explicit handling.\n\n# Debugging\n\nAt any time, it is possible to inspect what is happening in your pipeline using two utility functions:\n\n**Cheat sheet** (debugging)\n\n| Name           | Given                       | To             | Note                                  |\n| -------------- | --------------------------- | -------------- | ------------------------------------- |\n| `inspectRight` | `Either<E, A>`, `A => void` | `Either<E, A>` | callback called if it is a `Right<A>` |\n| `inspectLeft`  | `Either<E, A>`, `E => void` | `Either<E, A>` | callback called if it is a `Left<E>`  |\n\nLet's see an example where both are in action:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport {\n  Either,\n  right,\n  inspectRight,\n  flatMap,\n  inspectLeft,\n  map,\n} from \"@fp-ts/core/Option\";\n\nconst failure: Either<string, number> = pipe(\n  right(\"Not a number\"),\n  inspectRight(console.log),\n  flatMap((s) => parseNumber(s)),\n  inspectLeft(console.error),\n  map((x) => x2),\n  map((x) => x - 3)\n);\n// \"Not a number\"\n// \"Cannot parse 'Not a number' as a number\"\n```\n\nPlease note that these two functions should only be used for debugging purposes and it is not recommended to use them for performing side effects or encoding business logic.\n\n# Pattern matching and error handling\n\nWe have seen how easy and convenient it is to build pipelines involving the `Either` data type, leaving it to handle any errors that may occur at any step. However, at some point, you will be interested in manually handling the error to understand the overall result obtained from the pipeline and decide what to do accordingly.\n\nThe fastest way to get the value wrapped in an `Either` is to call the `getOrThrow` function, but be aware that, as the name suggests, an exception will be thrown in case the `Either` you are querying is a `Left`:\n\n```ts\nimport { getOrThrow } from \"@fp-ts/core/Either\";\n\nconsole.log(getOrThrow(right(10)); // 10\nconsole.log(getOrThrow(left(\"error message\")); // throws new Error(\"getOrThrow called on a Left\")\n```\n\nA more safe alternative is using the `isRight` and `isLeft` guards:\n\n```ts\nimport { right, left, isRight, isLeft } from \"@fp-ts/core/Either\";\n\nconst success = some(1);\n\n// Use the `isRight` function to check if the `success` is an instance of `Right`\nif (isRight(success)) {\n  console.log(`Either has a value: ${success.right}`);\n} else {\n  console.log(`Either is a Left.`);\n}\n// Either has a value: 1\n\nconst failure = left(\"error message\");\n\n// Use the `isLeft` function to check if the `failure` is an instance of `Left`\nif (isLeft(failure)) {\n  console.log(`Either has error: ${failure.left}`);\n} else {\n  console.log(`Either is a Right.`);\n}\n// Either has error: error message\n```\n\nAnother alternative is [pattern matching](https://github.com/gvergnaud/ts-pattern#what-is-pattern-matching) on the `Either`.\n\nThe `match` function allows us to match on the `Left` and `Right` cases of an `Either` value and provide different actions for each.\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { right, match } from \"@fp-ts/core/Either\";\n\nconst either = right(1);\n\n/**\n * Use the `match` function to conditionally return a string based on whether the `Either` is `Left` or `Right`.\n * If the `Either` is `Left`, the `left` will be passed to the first function.\n * If the `Either` is `Right`, the `right` will be passed to the second function.\n */\nconst output = match(\n  option,\n  (left) => `Either has error. ${left}`,\n  (right) => `Either has a value: ${right}`\n);\n\nconsole.log(output); // Either has a value: 1\n```\n\nOne reason to use `match` instead of `isRight` or `isLeft` is that `match` is more expressive and provides a clear way to handle both cases of an `Either`. With `match`, you can directly provide two functions to handle the case of the `Either` being `Left` or `Right`, respectively. On the other hand, with `isRight` or `isLeft`, you would need to manually check the value and take separate actions based on whether it's `Right` or `Left`. With `match`, the code can be more concise and easy to understand. Additionally, if you have complex logic to handle both cases, using `match` can make the code easier to read and maintain.\n\nThere are specializations of `match` to make working with code that does not use `Either` more convenient and faster, particularly `getOrNull` and `getOrUndefined`.\n\n```ts\nimport { getOrNull, getOrUndefined, right, left } from \"@fp-ts/core/Either\";\n\ngetOrNull(right(5)); // 5\ngetOrNull(left(\"error\")); // null\n\ngetOrUndefined(right(5)); // 5\ngetOrUndefined(left(\"error\")); // undefined\n```\n\nFor greater flexibility, there is also the `getOrElse` function which allows you to set what value corresponds to the `Left` case:\n\n```ts\nimport { getOrElse, right, left } from \"@fp-ts/core/Either\";\n\ngetOrElse(right(5), () => 0); // 5\ngetOrElse(left(\"error\"), () => 0); // 0\n```\n\nIt often happens that the action you want to take when a computation returns `None` is to continue with another computation that returns an `Option`, in this case you can use the `orElse` API:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Either, some, none, orElse } from \"@fp-ts/core/Either\";\n\nconst fetchData = (): Either<string, string> => {\n  // Imagine we have a function that returns an `Either` of data\n  return Math.random() < 0.5\n    ? right(\"Data fetched successfully\")\n    : left(\"Data fetched unsuccessfully\");\n};\n\nconst retryFetchData = (): Either<string, string> =>\n  pipe(\n    fetchData(), // Call the function for the first time\n    orElse(() => fetchData()) // If it fails, call it again\n  );\n\nconst result = retryFetchData();\n```\n\n**Cheat sheet** (error handling)\n\n| Name             | Given                                               | To                   |\n| ---------------- | --------------------------------------------------- | -------------------- |\n| `match`          | `Either<E, A>`, `onLeft: E => B`, `onRight: A => C` | `B \\| C`             |\n| `getOrThrow`     | `Either<E, A>`                                      | `A` (may throw)      |\n| `getOrNull`      | `Either<E, A>`                                      | `A \\| null`          |\n| `getOrUndefined` | `Either<E, A>`                                      | `A \\| undefined`     |\n| `getOrElse`      | `Either<E, A>`, `onLeft: E => B`                    | `A \\| B`             |\n| `orElse`         | `Either<E1, A>`, `LazyArg<Either<E2, B>>`           | `Either<E1, A \\| B>` |\n| `firstRightOf`   | `Either<E, A>`, `Iterable<Either<E, A>>`            | `Either<E, A>`       |\n\n# Interop\n\nA need that arises quickly when using the `Either` data type is the ability to interoperate with code that does not share the same style, in particular code that for example uses `undefined` or `null` to indicate that a value is optional, or code that throws exceptions.\n\nThe `Either` data type offers a series of APIs to make this task easier, let's start with the first of the two cases, that is when the need is to interoperate with code that use a nullable type to indicate that a value is optional.\n\nIt is possible to create an `Eitehr` from a nullable value using the `fromNullable` API, let's see an example:\n\n```ts\nimport { fromNullable, right, left } from \"@fp-ts/core/Either\";\n\nconsole.log(fromNullable(null, () => \"error\")); // left(\"erro\")\nconsole.log(fromNullable(undefined, () => \"error\")); // left(\"erro\")\nconsole.log(fromNullable(1, () => \"error\")); // right(1)\n```\n\nInstead of a single value, we can also modify the definition of a function that returns a nullable value to a function that returns an `Either` (a process that goes by the name of \"lifting\"):\n\n```ts\nimport { liftNullable, left, right } from \"@fp-ts/core/Either\";\n\nconst parse = (s: string): number | undefined => {\n  const n = parseFloat(s);\n  return isNaN(n) ? undefined : n;\n};\n\n// const parseEither: (s: string) => Either<string, number>\nconst parseEither = liftNullable(\n  parse,\n  (s) => `Cannot parse '${s}' as a number`\n);\n\nconsole.log(parseEither(\"1\")); // right(1)\nconsole.log(parseEither(\"not a number\")); // left(\"Cannot parse 'not a number' as a number\")\n```\n\nOn the other hand, if we have a value of type `Either` and we want to convert it into a nullable value we have two possibilities:\n\n- convert `Left` to `null`\n- convert `Left` to `undefined`\n\nThe two APIs `getOrNull` and `getOrUndefined` respectively achieve these two tasks:\n\n```ts\nimport { getOrNull, getOrUndefined, right, left } from \"@fp-ts/core/Either\";\n\nconsole.log(getOrNull(right(1))); // 1\nconsole.log(getOrNull(left(\"error message\"))); // null\n\nconsole.log(getOrUndefined(right(1))); // 1\nconsole.log(getOrUndefined(left(\"error message\"))); // undefined\n```\n\n**Cheat sheet** (interop - nullable)\n\n| Name              | Given                                                             | To                                      |\n| ----------------- | ----------------------------------------------------------------- | --------------------------------------- |\n| `fromNullable`    | `A`, `A => E`                                                     | `Either<E, NonNullable<A>>`             |\n| `liftNullable`    | `(...a: A) => B \\| null \\| undefined`, `(...a: A) => E`           | `(...a: A) => Either<E, NonNullable<B>` |\n| `flatMapNullable` | `Either<E1, A>`, `(...a: A) => B \\| null \\| undefined`, `A => E2` | `Either<E1 \\| E2, NonNullable<B>>`      |\n| `getOrNull`       | `Either<E, A>`                                                    | `A \\| null`                             |\n| `getOrUndefined`  | `Either<E, A>`                                                    | `A \\| undefined`                        |\n| `merge`           | `Either<E, A>`                                                    | `E \\| A`                                |\n\nNow let's see the other case, that is when we need to interoperate with code that throws exceptions.\n\nIn a previous section, we saw how to convert the following function that can throw exceptions:\n\n```ts\nfunction parseNumber(s: string): number {\n  const n = parseFloat(s);\n  if (isNaN(n)) {\n    throw new Error(`Cannot parse '${s}' as a number`);\n  }\n  return n;\n}\n```\n\ninto a function that returns a `Option`:\n\n```ts\nimport { Either, left, right } from \"@fp-ts/core/Either\";\n\nfunction parseNumber(s: string): Either<string, number> {\n  const n = parseFloat(s);\n  return isNaN(n) ? left(`Cannot parse '${s}' as a number`) : right(n);\n}\n```\n\nHowever, this involves tedious, error-prone, and boilerplate-heavy work. It would be much more convenient not to have to rewrite the `parseNumber` function from scratch but only to transform it into the desired result in one step, and that's exactly what the `fromThrowable` API takes care of doing:\n\n```ts\nimport { liftThrowable } from \"@fp-ts/core/Either\";\n\nconst parse = liftThrowable(JSON.parse, () => \"parse error\");\n\nconsole.log(parse(\"1\")); // right(1)\nconsole.log(parse(\"\")); // left(\"parse error\")\n```\n\nOn the other hand, if we have a value of type `Option` and want to get the wrapped value, accepting the fact that if the `Option` is a `None` we will get an exception, we can use the `getOrThrow` API:\n\n```ts\nimport { getOrThrow, right, left } from \"@fp-ts/core/Either\";\n\nconsole.log(getOrThrow(right(10)); // 10\nconsole.log(getOrThrow(left(\"error message\")); // throws new Error(\"getOrThrow called on a Left\")\n```\n\n**Cheat sheet** (interop - throwing)\n\n| Name            | Given                                        | To                          |\n| --------------- | -------------------------------------------- | --------------------------- |\n| `liftThrowable` | `(...a: A) => B` (may throw), `unknown => E` | `(...a: A) => Either<E, B>` |\n| `getOrThrow`    | `Either<E, A>`                               | `A` (may throw)             |\n\n# Combining two or more `Either`s\n\nThe `zipWith` function allows you to combine two `Either`s using a provided function. The resulting value is a new `Either` that holds the combined value of both original `Either`s.\n\nLet's consider the following example where we have two `Either`s that hold values of two different types, `string` and `number`:\n\n```ts\nimport { Either, right } from \"@fp-ts/core/Either\";\n\nconst name: Either<string, string> = right(\"John\");\nconst age: Either<string, number> = right(25);\n```\n\nIf we want to combine these two `Either`s into a single `Either` that holds an object with properties `name` and `age`, we can use the `zipWith` function:\n\n```ts\nimport { zipWith } from \"@fp-ts/core/Either\";\n\nconst combine = zipWith(name, age, (n, a) => ({ name: n, age: a }));\nconsole.log(combine); // right({ name: 'John', age: 25 })\n```\n\nThe `zipWith` function takes three arguments: the two `Either`s that you want to combine, and a function that takes two arguments - the values held by the two `Either`s - and returns the combined value.\n\nIf either of the two `Either`s is `Left`, the resulting `Either` will be `Left` as well:\n\n```ts\nconst name: Either<string, string> = left(\"missing name\");\nconst age: Either<string, number> = right(25);\nconst combine = zipWith(name, age, (n, a) => ({ name: n, age: a }));\nconsole.log(combine); // left(\"missing name\")\n```\n\nThis is because the `zipWith` function only combines the values if both `Either`s are `Right`.\n\n**Cheat sheet** (combining)\n\n| Name            | Given                                           | To                                             |\n| --------------- | ----------------------------------------------- | ---------------------------------------------- |\n| `zipWith`       | `Either<E1, A>`, `Either<E2, B>`, `(A, B) => C` | `Either<E1 \\| E2, C>`                          |\n| `tuple`         | `[Either<E1, A>, Either<E1, B>, ...]`           | `Either<E1 \\| E2 \\| ..., [A, B, ...]>`         |\n| `struct`        | `{ a: Either<E1, A>, b: Either<E1, B>, ... }`   | `Either<E1 \\| E2 \\| ..., { a: A, b: B, ... }>` |\n| `all`           | `Iterable<Either<E, A>>`                        | `Either<E, A[]>`                               |\n| `appendElement` | `Either<E1, [A, B, ...]>`, `Either<E2, C>`      | `Either<E1 \\| E2, [A, B, ..., C]>`             |\n| `ap`            | `Either<E1, (a: A) => B>`, `Either<E2, A>`      | `Either<E1 \\| E2, B>`                          |\n\nFor convenience, a series of algebraic operations such as sums and products are exported.\n\n```ts\nimport { right, left, sum } from \"@fp-ts/core/Either\";\n\nconst num1 = right(3);\nconst num2 = right(4);\nconst num3 = left(\"not a number\");\n\n// Summing two `Right` values will result in a `Right` with the sum of the values\nconst sumOfRight = sum(num1, num2);\nconsole.log(sumOfRight); // right(7)\n\n// Summing a `Right` and a `Left` will result in a `Left`\nconst sumOfRightAndLeft = sum(num1, num3);\nconsole.log(sumOfRightAndLeft); // left(\"not a number\")\n```\n\n**Cheat sheet** (algebraic operations)\n\n| Name       | Given                                      | To                         |\n| ---------- | ------------------------------------------ | -------------------------- |\n| `sum`      | `Either<E1, number>`, `Either<E2, number>` | `Either<E1 \\| E2, number>` |\n| `multiply` | `Either<E1, number>`, `Either<E2, number>` | `Either<E1 \\| E2, number>` |\n| `subtract` | `Either<E1, number>`, `Either<E2, number>` | `Either<E1 \\| E2, number>` |\n| `divide`   | `Either<E1, number>`, `Either<E2, number>` | `Either<E1 \\| E2, number>` |\n\n# Validations\n\nSay you must implement a web form to signup for an account. The form contains two field: `username` and `password` and the following validation rules must hold:\n\n- `username` must not be empty\n- `username` can't have dashes in it\n- `password` needs to have at least 6 characters\n- `password` needs to have at least one capital letter\n- `password` needs to have at least one number\n\nThe `Either<E, A>` type represents a computation that might fail with an error of type `E` or succeed with a value of type `A`, so is a good candidate for implementing our validation rules.\n\nFor example let's encode each `password` rule:\n\n```ts\nimport * as E from \"@fp-ts/core/Either\";\n\nconst minLength = (s: string): E.Either<string, string> =>\n  s.length >= 6 ? E.right(s) : E.left(\"at least 6 characters\");\n\nconst oneCapital = (s: string): E.Either<string, string> =>\n  /[A-Z]/g.test(s) ? E.right(s) : E.left(\"at least one capital letter\");\n\nconst oneNumber = (s: string): E.Either<string, string> =>\n  /[0-9]/g.test(s) ? E.right(s) : E.left(\"at least one number\");\n```\n\nWe can chain all the rules using `flatMap`:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\n\nconst validatePassword = (s: string): E.Either<string, string> =>\n  pipe(minLength(s), E.flatMap(oneCapital), E.flatMap(oneNumber));\n```\n\nBecause we are using `Either` the checks are **fail-fast**. That is, any failed check shortcircuits subsequent checks so we will only ever get one error.\n\n```ts\nassert.deepStrictEqual(validatePassword(\"ab\"), E.left(\"at least 6 characters\"));\n\nassert.deepStrictEqual(\n  validatePassword(\"abcdef\"),\n  E.left(\"at least one capital letter\")\n);\n\nassert.deepStrictEqual(\n  validatePassword(\"Abcdef\"),\n  E.left(\"at least one number\")\n);\n```\n\nHowever this could lead to a bad UX, it would be nice to have all of these errors be reported simultaneously.\n\nThe `Validated` abstraction may help here.\n\n## Validated\n\nValidations are similar to `Either<E, A>`, where they represent a computation that may fail with an error of type `E` or succeed with a value of type `A`. Unlike typical computations involving `Either`, however, validations are capable of **accumulating multiple failures**.\n\nFor this to be possible, the `Validated` data type must have the ability to combine two or more values of type `E` and the simplest way is to wrap them in a (non-empty) `ReadonlyArray`.\n\nThis is the definition of the `Validated` data type:\n\n```ts\n/**\n * Represents a computation that may fail with one or more errors of type `E`\n * or succeed with a value of type `A`.\n */\nexport type Validated<E, A> = Either<NonEmptyReadonlyArray<E>, A>;\n```\n\nTo proceed, we must first modify all the rules so that they return a `Validated<string, string>` value.\n\nInstead of having to rewrite all previous functions, which can be cumbersome, we can use the `liftEither` helper. This helper converts a check that outputs an `Either<E, A>` into a check that outputs a `Validate<E, A>`.\n\n```ts\nconst minLengthValidated = E.liftEither(minLength);\n//    ^? const minLengthValidated: (s: string) => E.Validated<string, string>\nconst oneCapitalValidated = E.liftEither(oneCapital);\n//    ^? const oneCapitalValidated: (s: string) => E.Validated<string, string>\nconst oneNumberValidated = E.liftEither(oneNumber);\n//    ^? const oneNumberValidated: (s: string) => E.Validated<string, string>\n```\n\nLet's bring it all together. The `validatePassword` function takes a string `s` as input, and uses the `tupleValidated` helper to perform all three validation checks, returning a `Validated` value that collects all the validation error messages. If all the checks pass, the function returns the original string s as a successful `Validated` value:\n\n```ts\nconst validatePassword = (s: string): E.Validated<string, string> =>\n  pipe(\n    E.tupleValidated(\n      minLengthValidated(s),\n      oneCapitalValidated(s),\n      oneNumberValidated(s)\n    ),\n    E.map(() => s)\n  );\n\nassert.deepStrictEqual(\n  validatePassword(\"ab\"),\n  E.left([\n    \"at least 6 characters\",\n    \"at least one capital letter\",\n    \"at least one number\",\n  ])\n);\n\nassert.deepStrictEqual(validatePassword(\"Abcde6\"), E.right(\"Abcde6\"));\n```\n"
  },
  {
    "path": "guides/FAQ.md",
    "content": "# FAQ\n\n## HKT implementation\n\n**What’s that second branch of conditional type in `Kind` type?**\n\nThat's to enforce variance.\n\nFor example let's say we define the following typeclass\n\n```ts\nimport { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\";\n\nexport interface Zippable<F extends TypeLambda> extends TypeClass<F> {\n  readonly zip: <S, R1, O1, E1, A, R2, O2, E2, B>(\n    first: Kind<F, S, R1, O1, E1, A>,\n    second: Kind<F, S, R2, O2, E2, B>\n  ) => Kind<F, S, R1 & R2, O1 | O2, E1 | E2, readonly [A, B]>;\n}\n```\n\nand then derive a `pipe`-able version of `zip`\n\n```ts\nexport const zip =\n  <F extends TypeLambda>(Zippable: Zippable<F>) =>\n  <S, R2, O2, E2, B>(that: Kind<F, S, R2, O2, E2, B>) =>\n  <R1, O1, E1, A>(\n    self: Kind<F, S, R1, O1, E1, A>\n  ): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, readonly [A, B]> =>\n    Zippable.zip(self, that);\n```\n\nNow let's say we make a mistake while typing the return type of `zip` (`R1` instead of `R1 & R2`)\n\n```diff\n-  ): Kind<F, S, R1 & R2, O1 | O2, E1 | E2, readonly [A, B]> =>\n+  ): Kind<F, S, R1, O1 | O2, E1 | E2, readonly [A, B]> =>\n```\n\nIt doesn't type check with the following error\n\n```\nType 'Kind<F, S, R1 & R2, O2 | O1, E2 | E1, readonly [A, B]>' is not assignable to type 'Kind<F, S, R1, O2 | O1, E2 | E1, readonly [A, B]>'.\n  Type '(F & { readonly InOut1: S; readonly In1: R1 & R2; readonly Out3: O2 | O1; readonly Out2: E2 | E1; readonly Out1: readonly [A, B]; })[\"type\"] | { readonly F: F; ... 4 more ...; readonly Out1: () => readonly [...]; }' is not assignable to type 'Kind<F, S, R1, O2 | O1, E2 | E1, readonly [A, B]>'.\n    Type 'F[\"type\"]' is not assignable to type 'Kind<F, S, R1, O2 | O1, E2 | E1, readonly [A, B]>'.\n      Type '{ readonly F: F; readonly InOut1: (_: S) => S; readonly In1: (_: R1 & R2) => void; readonly Out3: () => O2 | O1; readonly Out2: () => E2 | E1; readonly Out1: () => readonly [A, B]; }' is not assignable to type '{ readonly F: F; readonly InOut1: (_: S) => S; readonly In1: (_: R1) => void; readonly Out3: () => O2 | O1; readonly Out2: () => E2 | E1; readonly Out1: () => readonly [A, B]; }'.\n        Types of property 'In1' are incompatible.\n          Type '(_: R1 & R2) => void' is not assignable to type '(_: R1) => void'.\n            Types of parameters '_' and '_' are incompatible.\n              Type 'R1' is not assignable to type 'R1 & R2'.\n```\n"
  },
  {
    "path": "guides/Option.md",
    "content": "# The `Option` data type\n\nThe `Option` data type represents an optional value: every `Option` is either `Some` and contains a value, or `None`, and does not. `Option` types are very common in functional programming, as they have a number of uses:\n\n- Initial values\n- Return values for functions that are not defined over their entire input range (partial functions)\n- Return value for otherwise reporting simple errors, where `None` is returned on error\n- Optional struct fields\n- Optional function arguments\n\n# Definition\n\nThe `Option` data type is a union of two members: `None` and `Some`. The `@fp-ts/core` library models this union in TypeScript using a feature called [Discriminating Unions](https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#discriminatory-unions).\n\nA common approach for working with unions is to have a single field that uses literal types, which helps TypeScript narrow down the possible current type. In `@fp-ts/core`, this single field is named \"\\_tag\" (but any name can be used when defining your own unions).\n\nThe `Option` data type is a \"polymorphic\" data type, which makes use of a feature of TypeScript named [\"Generics\"](https://www.typescriptlang.org/docs/handbook/2/generics.html). This means that the `Option` data type is a container that can hold any type.\n\nHere is the complete definition of the `Option` data type:\n\n```ts\n// Represents the absence of a value\nexport type None = {\n  // Discriminating field used to identify the variant\n  readonly _tag: \"None\";\n};\n\n// Represents the presence of a value\nexport type Some<A> = {\n  // Discriminatory field used to identify the variant\n  readonly _tag: \"Some\";\n  // The actual value\n  readonly value: A;\n};\n\n// Define the `Option` data type as the union of `None` and `Some`\nexport type Option<A> = None | Some<A>;\n```\n\nThe type parameter `A` is used to specify the type of the `value` that the `Option` holds.\nThe `_tag` field is used to distinguish between the two variants, `None` and `Some`.\n\n# Using `Option`\n\nThe `Option` data type can be used to handle the presence or absence of a value in a safe and predictable manner. The `Option` data type has two constructors `some` and `none` that can be used to create a new instance of `Option` holding either a `Some` value or a `None` value, respectively.\n\n## Constructing a `Some` value\n\nThe `some` constructor takes a value of type `A` and returns an instance of `Option<A>` that holds that value:\n\n```ts\nimport { some } from \"@fp-ts/core/Option\";\n\nconst value: Option<number> = some(1); // an Option holding the number 1\n```\n\n## Constructing a `None` value\n\nThe `none` constructor returns an instance of `Option<never`> representing the absence of a value:\n\n```ts\nimport { none } from \"@fp-ts/core/Option\";\n\nconst empty: Option<never> = none(); // an Option holding no value\n```\n\nBy default, `none` returns an instance of `Option<never>`, which can be assigned to any `Option<A>` regardless of the type `A`:\n\n```ts\nconst optionNumber: Option<number> = none();\nconst optionString: Option<string> = none();\nconst optionBoolean: Option<boolean> = none();\n```\n\nHowever, if you prefer, you can specify the desired type at the call site by explicitly indicating the type `A` you're interested in. In this case, you won't need to provide type annotations:\n\n```ts\nconst optionNumber = none<number>();\nconst optionString = none<string>();\nconst optionBoolean = none<boolean>();\n```\n\nHere's a quick reference guide for the two constructors:\n\n**Cheat sheet** (constructors)\n\n| **Function** | **Given input** | **Resulting Output** |\n| ------------ | --------------- | -------------------- |\n| `some`       | `A`             | `Option<A>`          |\n| `none`       |                 | `Option<never>`      |\n\nWith these two constructors, you can construct an `Option` holding either a `Some` value or a `None` value, depending on your needs.\n\n# Conversions\n\nThe following table provides a quick reference for the various conversion functions available in this module:\n\n**Cheat sheet** (conversions)\n\n| **Function**   | **Given input**                   | **Resulting Output** |\n| -------------- | --------------------------------- | -------------------- | --------------------- |\n| `fromEither`   | `Either<E, A>`                    | `Option<A>`          |                       |\n| `toEither`     | `Option<A>`, `onNone: LazyArg<E>` | `Either<E, A>`       |                       |\n| `getRight`     | `Either<E, A>`                    | `Option<A>`          | alias of `fromEither` |\n| `getLeft`      | `Either<E, A>`                    | `Option<E>`          |                       |\n| `toRefinement` | `A => Option<B>`                  | `Refinement<A, B>`   |                       |\n| `fromIterable` | `Iterable<A>`                     | `Option<A>`          |                       |\n| `toArray`      | `Option<A>`                       | `Array<A>`           |                       |\n\n## fromEither\n\nThe `fromEither` function takes in an `Either<E, A>` value and returns an `Option<A>`. This is useful when you have a value that can either be of type `E` (an error) or `A` (the correct value), and you want to convert it to an `Option` discarding the error.\n\nExample:\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\nimport * as E from \"@fp-ts/core/Either\";\n\nconsole.log(O.fromEither(E.right(1))); // some(1)\nconsole.log(O.fromEither(E.left(\"error message\"))); // none()\n```\n\nIn this example, `fromEither` is used to convert the `Either` value `E.right(1)` to an `Option<number>`. The result is `some(1)`, which indicates that the input `Either` was of type `Right` and contained the value `1`.\n\nIf the input `Either` was of type `Left` (`E.left(\"error message\")` in this case), the result would be `none()`, which indicates that the input contained an error and no valid value was present.\n\n## toEither\n\nThe `toEither` function takes in an `Option<A>` value and a `LazyArg<E>` value and returns an `Either<E, A>`.\n\nThe `LazyArg<E>` value is a lazy (or \"deferred\") argument that is only executed if the input `Option` is `None`. If the input `Option` is `None`, the `toEither` function returns an `Either<E, A>` with the `Left` value being the result of the lazy argument. If the input `Option` is `Some`, the `toEither` function returns an `Either<E, A>` with the `Right` value being the value contained in the `Some` case of the `Option`.\n\nHere's an example of how to use toEither:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport * as O from \"@fp-ts/core/Option\";\nimport * as E from \"@fp-ts/core/Either\";\n\nconst onNone = () => \"error\";\nconsole.log(pipe(O.some(1), O.toEither(onNone))); // right(1)\nconsole.log(pipe(O.none(), O.toEither(onNone))); // left(\"error\")\n```\n\n## getRight\n\nThe `getRight` function is an alias for `fromEither`, and is used to convert an `Either<E, A>` value to an `Option<A>`. See the explanation and example for `fromEither` for more information.\n\n## getLeft\n\nThe `getLeft` function is a utility function that is used to extract the `Left` value from an `Either<E, A>` value. The function takes in a single argument - an `Either<E, A>` value and returns an `Option<E>` value.\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\nimport * as E from \"@fp-ts/core/Either\";\n\nconsole.log(O.getLeft(E.right(\"ok\"))); // none()\nconsole.log(O.getLeft(E.left(\"error\"))); // some(\"error\")\n```\n\nNote that the `Option<E>` value returned by the `getLeft` function will be `Some(value)` if the input `Either<E, A>` value is a `Left` value, and `None` if the input `Either<E, A>` value is a `Right` value.\n\n## toRefinement\n\nThis function allows to convert a function `A => Option<B>` into a `(a: A) => a is B`, which can be used as a predefined type guard.\nA type guard function is used to check if a value is of a certain type.\n\nThe `toRefinement` ensures that a type guard definition is type-safe.\n\nHere is an example of using `toRefinement` to create a type guard for positive numbers:\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\n\n// This function checks if a given number is positive\nconst parsePositive = (n: number): O.Option<number> =>\n  n > 0 ? O.some(n) : O.none();\n\n// convert the `parsePositive` function into a type guard\nconst isPositive = O.toRefinement(parsePositive);\n\nconsole.log(isPositive(1)); // true\nconsole.log(isPositive(-1)); // false\n```\n\nIn this example, `parsePositive` is a function that takes in a number and returns an `Option<number>`. If the number is positive, it returns `some(n)`, where `n` is the positive number. If the number is not positive, it returns `none()`.\n\n`toRefinement` takes in the `parsePositive` function and returns a type guard function `isPositive`. The `isPositive` function can be used to check if a value is a positive number and can be used in type refinement statements to provide type-safety for your code.\n\n## fromIterable\n\nThe `fromIterable` function takes an iterable (something you can loop over, for example arrays, sets, maps, etc.) and returns an `Option` value.\n\nIf the iterable is not empty (i.e., it has at least one item), `fromIterable` returns the first value of the iterable wrapped in a `Some` value. If the iterable is empty, `fromIterable` returns `None`.\n\nHere are two examples to demonstrate the usage of `fromIterable`:\n\n```ts\nimport { fromIterable, some, none } from \"@fp-ts/core/Option\";\n\nconsole.log(fromIterable([1, 2, 3])); // some(1)\n```\n\nIn this example, `fromIterable` is passed an array with three values. Since the array is not empty, `fromIterable` returns the first value, `1`, wrapped in a `Some` value.\n\n```ts\nconsole.log(fromIterable([])); // none()\n```\n\nIn this example, `fromIterable` is passed an empty array. Since the array is empty, `fromIterable` returns `None`.\n\n## toArray\n\nThe `toArray` function takes in an `Option` value and returns an array.\n\nIf the input is a `Some` value, the value inside the `Some` is wrapped in an array and returned.\n\nIf the input is a `None` value, an empty array is returned.\n\nHere are two examples of how `toArray` can be used:\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\n\nconsole.log(O.toArray(O.some(1))); // [1]\n```\n\nIn this example, `some(1)` is passed as the argument to `toArray`, which returns an array with the value `1`.\n\n```ts\nconsole.log(O.toArray(O.none())); // []\n```\n\nIn this example, `none()` is passed as the argument to `toArray`, which returns an empty array.\n\n# Modeling optional properties with `Option`\n\nHere is an example of a `User` model where the `email` field is of type `Option<string>`. This means that the value of the `email` field may or may not be present and will be of type `string` when it is present.\n\n```ts\ninterface User {\n  id: number;\n  username: string;\n  email: Option<string>;\n}\n\nimport { some, none } from \"@fp-ts/core/Option\";\n\n// case with email\nconst user1: User = {\n  id: 1,\n  username: \"john_doe\",\n  email: some(\"john.doe@example.com\"),\n};\n\n// case without email\nconst user2: User = {\n  id: 2,\n  username: \"jane_doe\",\n  email: none(),\n};\n```\n\nIt's important to note that the optionality only concerns the **value** of the `email` field, while the key `\"email\"` will always be present in the object.\n\n# Working with `Option`\n\nOnce you have an instance of `Option`, you can use the various functions provided in the `@fp-ts/core/Option` module to work with it.\n\nThe `map` function can be used to transform the `Some` values:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Opiton, some, map } from \"@fp-ts/core/Option\";\n\nconst success: Option<number> = pipe(\n  some(1),\n  // maps the value inside the Option, adding 1, resulting in some(2)\n  map((x) => x + 1)\n);\n```\n\nAs you can see you can transform the result of your computation without unwrapping and wrapping the underlying value of `Option`.\nThis allows for a safe and convenient way of transforming optional values.\n\nWhat is also convenient about `Option` is how the absence of value (i.e. a `None`) is handled. See the example below:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Option, none, map } from \"@fp-ts/core/Option\";\n\nconst failure: Option<number> = pipe(\n  none(),\n  // tries to map the value inside the `Some`, but it does not exist, resulting in `None`\n  map((x) => x + 1)\n);\n```\n\nAs you can see, even though we started with a `None` value, we can still operate on our `Option`. No errors are thrown or shown to the user, unless we do it intentionally. When the `Option` is `None, the mapping doesn't even occur, and the `None` value representing the absence of value is returned unchanged.\n\n# Handling failing computations\n\nIn software development, there are times when a function can \"fail\" to produce a result, either because of invalid inputs, lack of data, or other reasons. The `Option` data type helps us to handle these cases in a clean and functional way.\n\nHere's an example of a function `parseNumber` that takes a `string` as input and returns either a `number` or `null` depending on the input:\n\n```ts\nfunction parseNumber(s: string): number | null {\n  const n = parseFloat(s);\n  if (isNaN(n)) {\n    return null;\n  }\n  return n;\n}\n```\n\nA better way to handle these types of computations is to use the `Option` data type. This data type offers a cleaner way to model the \"success\" or \"failure\" of a computation. With `Option`, we can eliminate the need to return a `null` value. Instead, we will always return a value, but this value will be of type `Option<number>`.\n\n- if `parseNumber` returns a `None` value, it means that the computation \"failed\"\n- if the result is a `Some<number>` value, it means that the computation \"succeeded\" and the computed value is wrapped inside the `Some`\n\nHere's how the `parseNumber` function would look using the `Option` data type:\n\n```ts\nimport { Option, none, some } from \"@fp-ts/core/Option\";\n\nfunction parseNumber(s: string): Option<number> {\n  const n = parseFloat(s);\n  return isNaN(n) ? none() : some(n);\n}\n\nconsole.log(parseNumber(\"2\")); // some(2)\nconsole.log(parseNumber(\"Not a number\")); // none()\n```\n\nNow, let's say we have a pipeline of computations that already involves the `Option` data type and we want to add a call to the `parseNumber` function. We might run into an issue with the following code:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { some, map } from \"@fp-ts/core/Option\";\n\nconst result = pipe(\n  some(\"2\"),\n  map((s) => parseNumber(s)),\n  map((n) => n2) // type-checker error!\n);\n```\n\nThe code above generates a type-checker error. This happens because the second `map` function expects the input `n` to be of type `number`, but `n` is of type `Option<number>`.\n\n```ts\nconst result = pipe(\n  some(\"2\"),\n  map((s) => parseNumber(s)),\n  map((x: Option<number>) => ...)\n);\n```\n\nTo solve this issue, we need to use the `flatMap` function instead of the `map` function when adding a computation that returns an `Option` to our pipeline:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { some, flatMap, map } from \"@fp-ts/core/Option\";\n\nconst result = pipe(\n  some(\"2\"),\n  flatMap((s) => parseNumber(s)),\n  map((n) => n2) // ok! now `n` has type `number`\n);\n```\n\nLet's summarize the two cases in a table:\n\n**Cheat sheet** (sequencing)\n\n| **Function** | **Given input**               | **Resulting Output** |\n| ------------ | ----------------------------- | -------------------- |\n| `map`        | `Option<A>`, `A => B`         | `Option<B>`          |\n| `flatMap`    | `Option<A>`, `A => Option<B>` | `Option<B>`          |\n\nThe `flatMap` function works similarly to the `map` function, but with the added feature of only continuing with the computations if a `None` value is not encountered. Let's look at some code examples to understand how these functions work in practice.\n\n**Example 1: Successful Path with Valid Input**\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Option, some, flatMap, map } from \"@fp-ts/core/Option\";\n\nconst success: Option<number> = pipe(\n  some(\"2\"),\n  flatMap((s) => parseNumber(s)), // parse the input to number\n  map((x) => x2), // double the parsed number\n  map((x) => x - 3) // subtract 3\n); // some(1)\n```\n\nIn this example, the `pipe` function is used to chain together a series of computations, starting with a string value of `\"2\"`. This value is first passed to the `flatMap` function which applies the `parseNumber` function to parse the input string to a number. If the parsing is successful, the resulting number is then passed to the `map` function which doubles it. Finally, the resulting value is passed to another `map` function which subtracts `3` from it. The final output of the pipeline is the `Option` value of `some(1)`.\n\n**Example 2: Error Path with Invalid Input**\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Option, some, flatMap, map } from \"@fp-ts/core/Option\";\n\nconst failure: Option<number> = pipe(\n  some(\"Not a number\"),\n  flatMap((s) => parseNumber(s)), // parse the input to number\n  map((x) => x2), // This will not be executed because parseNumber will return None\n  map((x) => x - 3) // This will not be executed\n); // none()\n```\n\nIn this example, the input to the pipeline is the string value of `\"Not a number\"`. When this value is passed to the `flatMap` function which applies the `parseNumber` function, it will return `None` as the string cannot be parsed to a number. This means that the following `map `functions will not be executed and the final output of the pipeline will be `None`.\n\n**Example 3: Error Path Starting with None**\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { Option, none, flatMap, map } from \"@fp-ts/core/Option\";\n\nconst noneStart: Option<number> = pipe(\n  none,\n  flatMap((s) => parseNumber(s)), // This will not be executed because it starts with None\n  map((x) => x2), // This will not be executed\n  map((x) => x - 3) // This will not be executed\n); // none()\n```\n\nIn this example, we start the pipeline with the `None` value, which represents an absent or empty value. This means that the `flatMap` step will not be executed and any subsequent steps in the pipeline will not be executed either.\n\nThe advantage of using this approach is that the desired outcome is always in clear view while defining your pipeline. This allows you to focus on the expected result, while leaving it to the `Option` type to handle any potential errors that may arise seamlessly and transparently.\n\nYou can concentrate on the successful scenario and let `Option` handle the management of potential errors at every step of the pipeline, without the need for explicit error handling.\n\n# Debugging\n\nDebugging your code can be difficult, especially when you have multiple transformations happening in a pipeline. The `Option` module provides two utility functions, `inspectSome` and `inspectNone`, that can help you inspect what is happening in your code and diagnose issues.\n\nThe `inspectSome` function returns the original `Option<A>` value, but if it is a `Some<A>`, the provided callback function is called with the value wrapped inside the `Some`.\n\nThe `inspectNone` function returns the original `Option<A>` value, but if it is a `None`, the provided callback function is called without any arguments.\n\nHere is an example of how you can use `inspectSome` and `inspectNone` to debug a pipeline:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport * as O from \"@fp-ts/core/Option\";\n\nconst failure: O.Option<number> = pipe(\n  O.some(\"Not a number\"), // start with a Some containing the string \"Not a number\"\n  O.inspectSome(console.log), // log the value if it is a Some\n  O.flatMap((s) => parseNumber(s)), // attempt to parse the string as a number\n  O.inspectNone(() => console.error(\"none\")), // log an error if the parseNumber function returns None\n  O.map((x) => x * 2), // double the number if it is a Some\n  O.map((x) => x - 3) // subtract 3 from the number if it is a Some\n);\n// logs \"Not a number\" to the console\n// logs \"none\" to the console (because the parseNumber function returns None)\n```\n\nIt is important to note that `inspectSome` and `inspectNone` should only be used for debugging purposes, and it is not recommended to use them for performing side effects or encoding business logic.\n\n**Cheat sheet** (debugging)\n\n| **Function**  | **Given input**           | **Resulting Output** | **Note**                             |\n| ------------- | ------------------------- | -------------------- | ------------------------------------ |\n| `inspectSome` | `Option<A>`, `A => void`  | `Option<A>`          | callback called if it is a `Some<A>` |\n| `inspectNone` | `Option<A>`, `() => void` | `Option<A>`          | callback called if it is a `None`    |\n\n# Pattern matching\n\nWe have seen how easy and convenient it is to build pipelines involving the `Option` data type, leaving it to handle any errors that may occur at any step. However, at some point, you will be interested in manually handling the error to understand the overall result obtained from the pipeline and decide what to do accordingly.\n\n## Getting the value from an `Option`\n\nTo extract the value from an `Option`, you can use the `getOrThrow` function, which retrieves the value wrapped in an `Option`, or throws an error if the `Option` you are querying is a `None`.\n\nHere's an example of how you can use `getOrThrow`:\n\n```ts\nimport { getOrThrow, some, none } from \"@fp-ts/core/Option\";\n\nconsole.log(getOrThrow(some(10)); // 10\nconsole.log(getOrThrow(none()); // throws new Error(\"getOrThrow called on a None\")\n```\n\nHowever, using `getOrThrow` can lead to exceptions being thrown in your code, which can lead to unexpected behavior and crashes. To avoid this, you can use the `isSome` and `isNone` guards:\n\n```ts\nimport { some, isSome } from \"@fp-ts/core/Option\";\n\nconst option = some(1);\n\n// Use the `isSome` function to check if the `option` is an instance of `Some`\nif (isSome(option)) {\n  console.log(`Option has a value: ${option.value}`);\n} else {\n  console.log(`Option is empty.`);\n}\n// Output: Option has a value: 1\n```\n\n## Pattern matching with `Option`\n\nAn alternative way to handle the cases of an `Option` being `None` or `Some` is by using the `match` function. The `match` function allows you to provide different actions for each case of the `Option` value.\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport { some, match } from \"@fp-ts/core/Option\";\n\nconst option = some(1);\n\n/**\n * Use the `match` function to conditionally return a string based on whether the `Option` is `None` or `Some`.\n * If the `Option` is `None`, the first function will be called with no arguments.\n * If the `Option` is `Some`, the `value` will be passed to the second function.\n */\nconst output = match(\n  option,\n  () => `Option is empty.`,\n  (value) => `Option has a value: ${value}`\n);\n\nconsole.log(output); // Output: Option has a value: 1\n```\n\nUsing `match` instead of `isSome` or `isNone` can be more expressive and provide a clear way to handle both cases of an `Option`. Additionally, if you have complex logic to handle both cases, using `match` can make your code easier to read and maintain.\n\n## Other functions for extracting values from an `Option`\n\nTo make working with code that does not use `Option` more convenient, there are specializations of `match` called `getOrNull` and `getOrUndefined`, which allow you to retrieve the value of an `Option` or `null` or `undefined`, respectively.\n\nHere's an example of how you can use `getOrNull` and `getOrUndefined`:\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\n\nO.getOrNull(O.some(5)); // 5\nO.getOrNull(O.none()); // null\n\nO.getOrUndefined(O.some(5)); // 5\nO.getOrUndefined(O.none()); // undefined\n```\n\n`getOrElse` allows you to specify a default value that should be returned if the `Option` is `None`. Here's an example of how you can use `getOrElse`:\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\n\nO.getOrElse(O.some(5), () => 0); // 5\nO.getOrElse(O.none(), () => 0); // 0\n```\n\nSometimes, when a computation returns `None`, you may want to continue with another computation that returns an `Option`. In this case, you can use the `orElse` function. This is useful for implementing retry logic, for example, where you want to attempt a computation multiple times until you either succeed or exhaust all possible attempts.\n\nHere's an example:\n\n```ts\nimport { pipe } from \"@fp-ts/core/Function\";\nimport * as O from \"@fp-ts/core/Option\";\n\nconst tryToConnect = (): O.Option<string> => {\n  // Imagine we have a function that returns an `Option` of connection status\n  return Math.random() < 0.5 ? O.some(\"Connected successfully\") : O.none();\n};\n\nconst retryConnect = (attemptsLeft: number): O.Option<string> =>\n  pipe(\n    tryToConnect(), // Try to connect for the first time\n    O.orElse(() => {\n      // If it fails, check if we still have attempts left\n      if (attemptsLeft > 0) {\n        return retryConnect(attemptsLeft - 1); // If we do, try again with one less attempt\n      }\n      return O.none(); // If we don't, return none\n    })\n  );\n\nconst result = retryConnect(3); // Try to connect three times\n```\n\nIn this example, the function `tryToConnect` returns an `Option` representing the connection status. We use `orElse` to implement retry logic by attempting the connection again if the first attempt fails (returns `None`) and we still have attempts left. If all attempts fail, `retryConnect` returns `None`.\n\nThe `firstSomeOf` function is used to retrieve the first value that is present within an `Iterable` of `Option` values. The function takes an `Iterable` of `Option` values and returns the first `Option` value that is `Some`, or `None` if there are no `Some` values in the `Iterable`.\n\nHere is an example of how you can use `firstSomeOf`:\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\n\nconst arr = [O.none(), O.some(2), O.none(), O.some(3)];\n\nconst first = O.firstSomeOf(arr); // some(2)\n```\n\n**Cheat sheet** (pattern matching)\n\n| **Function**     | **Given input**                                     | **Resulting Output** |\n| ---------------- | --------------------------------------------------- | -------------------- |\n| `match`          | `Option<A>`, `onNone: LazyArg<B>`, `onSome: A => C` | `B \\| C`             |\n| `getOrThrow`     | `Option<A>`                                         | `A` (may throw)      |\n| `getOrThrowWith` | `Option<A>`, `onNone: () => unknown`                | `A` (may throw)      |\n| `getOrNull`      | `Option<A>`                                         | `A \\| null`          |\n| `getOrUndefined` | `Option<A>`                                         | `A \\| undefined`     |\n| `getOrElse`      | `Option<A>`, `onNone: LazyArg<B>`                   | `A \\| B`             |\n| `orElse`         | `Option<A>`, `LazyArg<Option<B>>`                   | `Option<A \\| B>`     |\n| `firstSomeOf`    | `Iterable<Option<A>>`                               | `Option<A>`          |\n\n# Interop with Code Using Nullable Types\n\nWhen using the `Option` data type, you may need to interact with code that uses `undefined` or `null` to indicate optional values. The `Option` data type provides several APIs to make this task easier.\n\n## Converting a Nullable Value to an Option\n\nYou can create an `Option` from a nullable value using the `fromNullable` API.\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\n\nconsole.log(O.fromNullable(null)); // none()\nconsole.log(O.fromNullable(undefined)); // none()\nconsole.log(O.fromNullable(1)); // some(1)\n```\n\nYou can also modify a function that returns a nullable value to a function that returns an `Option` using the `liftNullable` API. This process is known as \"lifting.\"\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\n\nconst parse = (s: string): number | undefined => {\n  const n = parseFloat(s);\n  return isNaN(n) ? undefined : n;\n};\n\n// const parseOption: (s: string) => Option<number>\nconst parseOption = O.liftNullable(parse);\n\nconsole.log(parseOption(\"1\")); // some(1)\nconsole.log(parseOption(\"not a number\")); // none()\n```\n\n## Converting an Option to a Nullable Value\n\nIf you have a value of type `Option` and want to convert it to a nullable value, you have two options:\n\n- Convert `None` to `null` using the `getOrNull` API\n- Convert `None` to `undefined` using the `getOrUndefined` API\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\n\nconsole.log(O.getOrNull(O.some(1))); // 1\nconsole.log(O.getOrNull(O.none())); // null\n\nconsole.log(O.getOrUndefined(O.some(1))); // 1\nconsole.log(O.getOrUndefined(O.none())); // undefined\n```\n\n**Cheat sheet** (interop - nullable)\n\n| **Function**      | **Given input**                                    | **Resulting Output**                 |\n| ----------------- | -------------------------------------------------- | ------------------------------------ |\n| `fromNullable`    | `A`                                                | `Option<NonNullable<A>>`             |\n| `liftNullable`    | `(...a: A) => B \\| null \\| undefined`              | `(...a: A) => Option<NonNullable<B>` |\n| `flatMapNullable` | `Option<A>`, `(...a: A) => B \\| null \\| undefined` | `Option<NonNullable<B>>`             |\n| `getOrNull`       | `Option<A>`                                        | `A \\| null`                          |\n| `getOrUndefined`  | `Option<A>`                                        | `A \\| undefined`                     |\n\n# Combining two or more `Option`s\n\nThe `zipWith` function allows you to combine two `Option`s using a provided function. The resulting value is a new `Option` that holds the combined value of both original `Option`s.\n\nLet's consider the following example where we have two `Option`s that hold values of two different types, `string` and `number`:\n\n```ts\nimport { Option, some } from \"@fp-ts/core/Option\";\n\nconst name: Option<string> = some(\"John\");\nconst age: Option<number> = some(25);\n```\n\nIf we want to combine these two `Option`s into a single `Option` that holds an object with properties `name` and `age`, we can use the `zipWith` function:\n\n```ts\nimport { zipWith } from \"@fp-ts/core/Option\";\n\nconst combine = zipWith(name, age, (n, a) => ({ name: n, age: a }));\nconsole.log(combine); // some({ name: 'John', age: 25 })\n```\n\nThe `zipWith` function takes three arguments:\n\n- The first `Option` you want to combine\n- The second `Option` you want to combine\n- A function that takes two arguments, which are the values held by the two `Options`, and returns the combined value\n\nIt's important to note that if either of the two `Option`s is `None`, the resulting `Option` will also be `None`. This is because the `zipWith` function only combines the values if both `Option`s are `Some`.\n\nFor example:\n\n```ts\nconst name: Option<string> = none();\nconst age: Option<number> = some(25);\nconst combine = zipWith(name, age, (n, a) => ({ name: n, age: a }));\nconsole.log(combine); // none()\n```\n\n**Cheat sheet** (combining)\n\n| **Function**    | **Given input**                         | **Resulting Output**          |\n| --------------- | --------------------------------------- | ----------------------------- |\n| `zipWith`       | `Option<A>`, `Option<B>`, `(A, B) => C` | `Option<C>`                   |\n| `tuple`         | `[Option<A>, Option<B>, ...]`           | `Option<[A, B, ...]>`         |\n| `struct`        | `{ a: Option<A>, b: Option<B>, ... }`   | `Option<{ a: A, b: B, ... }>` |\n| `all`           | `Iterable<Option<A>>`                   | `Option<A[]>`                 |\n| `appendElement` | `Option<[A, B, ...]>`, `Option<C>`      | `Option<[A, B, ..., C]>`      |\n| `ap`            | `Option<(a: A) => B>`, `Option<A>`      | `Option<B>`                   |\n\n## Algebraic operations with `Option`s\n\nIn addition to `zipWith`, a series of algebraic operations such as sums, products, subtractions, and divisions are exported to make it easier to work with `Option`s.\n\nFor example, consider the following `Option`s holding numbers:\n\n```ts\nimport * as O from \"@fp-ts/core/Option\";\n\nconst num1 = O.some(3);\nconst num2 = O.some(4);\nconst num3 = O.none();\n```\n\nSumming two `Some` values will result in a `Some` with the sum of the values:\n\n```ts\n// Summing two `Some` values will result in a `Some` with the sum of the values\nconst sumOfSome = sum(num1, num2);\nconsole.log(sumOfSome); // some(7)\n```\n\nSumming a `Some` and a `None` will result in a `None`:\n\n```ts\n// Summing a `Some` and a `None` will result in a `None`\nconst sumOfSomeAndNone = sum(num1, num3);\nconsole.log(sumOfSomeAndNone); // none()\n```\n\n**Cheat sheet** (algebraic operations)\n\n| **Function** | **Given input**                    | **Resulting Output** |\n| ------------ | ---------------------------------- | -------------------- |\n| `sum`        | `Option<number>`, `Option<number>` | `Option<number>`     |\n| `multiply`   | `Option<number>`, `Option<number>` | `Option<number>`     |\n| `subtract`   | `Option<number>`, `Option<number>` | `Option<number>`     |\n| `divide`     | `Option<number>`, `Option<number>` | `Option<number>`     |\n"
  },
  {
    "path": "guides/These.md",
    "content": "# The `These` data type\n\n## A data structure providing \"inclusive-or\" as opposed to `Either`'s \"exclusive-or\".\n\nIf you interpret `Either<E, A>` as suggesting the computation may either fail or succeed (exclusively), then\n`These<E, A>` may fail, succeed, or do both at the same time.\n\nThere are a few ways to interpret the `Both` case:\n\n1.  You can think of a computation that has a non-fatal error.\n2.  You can think of a computation that went as far as it could before erroring.\n3.  You can think of a computation that keeps track of errors as it completes.\n\nAnother way you can think of `These<E, A>` is saying that we want to handle `E` kind of data, `A` kind of data, or\nboth `E` and `A` kind of data at the same time. This is particularly useful when it comes to displaying UI's.\n"
  },
  {
    "path": "guides/ts-types.md",
    "content": "# Standard TypeScript types\n\n## strings\n\n| Module      | Name        | Given | To                            |\n| ----------- | ----------- | ----- | ----------------------------- |\n| Equivalence | string      |       | `Equivalence<string>`         |\n| Order       | string      |       | `Order<string>`               |\n| Semigroup   | string      |       | `Semigroup<string>`           |\n| Monoid      | string      |       | `Monoid<string>`              |\n| Predicate   | isString    |       | `Refinement<unknown, string>` |\n| String      | Equivalence |       | `Equivalence<string>`         |\n| String      | Order       |       | `Order<string>`               |\n| String      | Semigroup   |       | `Semigroup<string>`           |\n| String      | Monoid      |       | `Monoid<string>`              |\n| String      | isString    |       | `Refinement<unknown, string>` |\n\n## numbers\n\n| Module      | Name              | Given | To                            |\n| ----------- | ----------------- | ----- | ----------------------------- |\n| Equivalence | number            |       | `Equivalence<number>`         |\n| Order       | number            |       | `Order<number>`               |\n| Bounded     | number            |       | `Bounded<number>`             |\n| Semigroup   | numberSum         |       | `Semigroup<number>`           |\n| Semigroup   | numberMultiply    |       | `Semigroup<number>`           |\n| Monoid      | numberSum         |       | `Monoid<number>`              |\n| Monoid      | numberMultiply    |       | `Monoid<number>`              |\n| Predicate   | isNumber          |       | `Refinement<unknown, number>` |\n| Number      | Equivalence       |       | `Equivalence<number>`         |\n| Number      | Order             |       | `Order<number>`               |\n| Number      | SemigroupSum      |       | `Semigroup<number>`           |\n| Number      | SemigroupMultiply |       | `Semigroup<number>`           |\n| Number      | SemigroupMax      |       | `Semigroup<number>`           |\n| Number      | SemigroupMin      |       | `Semigroup<number>`           |\n| Number      | MonoidSum         |       | `Monoid<number>`              |\n| Number      | MonoidMultiply    |       | `Monoid<number>`              |\n| Number      | MonoidMax         |       | `Monoid<number>`              |\n| Number      | MonoidMin         |       | `Monoid<number>`              |\n| Number      | isNumber          |       | `Refinement<unknown, number>` |\n\n## booleans\n\n| Module      | Name        | Given | To                             |\n| ----------- | ----------- | ----- | ------------------------------ |\n| Equivalence | boolean     |       | `Equivalence<boolean>`         |\n| Order       | boolean     |       | `Order<boolean>`               |\n| Semigroup   | booleanAny  |       | `Semigroup<boolean>`           |\n| Semigroup   | booleanAll  |       | `Semigroup<boolean>`           |\n| Monoid      | booleanAny  |       | `Monoid<boolean>`              |\n| Monoid      | booleanAll  |       | `Monoid<boolean>`              |\n| Predicate   | isBoolean   |       | `Refinement<unknown, boolean>` |\n| Boolean     | Equivalence |       | `Equivalence<boolean>`         |\n| Boolean     | Order       |       | `Order<boolean>`               |\n| Boolean     | booleanAny  |       | `Semigroup<boolean>`           |\n| Boolean     | booleanAll  |       | `Semigroup<boolean>`           |\n| Boolean     | booleanAny  |       | `Monoid<boolean>`              |\n| Boolean     | booleanAll  |       | `Monoid<boolean>`              |\n| Boolean     | isBoolean   |       | `Refinement<unknown, boolean>` |\n\n## bigints\n\n| Module      | Name              | Given | To                            |\n| ----------- | ----------------- | ----- | ----------------------------- |\n| Equivalence | bigint            |       | `Equivalence<bigint>`         |\n| Order       | bigint            |       | `Order<bigint>`               |\n| Semigroup   | bigintSum         |       | `Semigroup<bigint>`           |\n| Semigroup   | bigintMultiply    |       | `Semigroup<bigint>`           |\n| Monoid      | bigintSum         |       | `Monoid<bigint>`              |\n| Monoid      | bigintMultiply    |       | `Monoid<bigint>`              |\n| Predicate   | isBigint          |       | `Refinement<unknown, bigint>` |\n| Bigint      | Equivalence       |       | `Equivalence<bigint>`         |\n| Bigint      | Order             |       | `Order<bigint>`               |\n| Bigint      | SemigroupSum      |       | `Semigroup<bigint>`           |\n| Bigint      | SemigroupMultiply |       | `Semigroup<bigint>`           |\n| Bigint      | MonoidSum         |       | `Monoid<bigint>`              |\n| Bigint      | MonoidMultiply    |       | `Monoid<bigint>`              |\n| Bigint      | isBigint          |       | `Refinement<unknown, bigint>` |\n\n## symbols\n\n| Module      | Name     | Given | To                            |\n| ----------- | -------- | ----- | ----------------------------- |\n| Equivalence | symbol   |       | `Equivalence<symbol>`         |\n| Predicate   | isSymbol |       | `Refinement<unknown, symbol>` |\n| Symbol      | isSymbol |       | `Refinement<unknown, symbol>` |\n\n## tuples\n\nThis section covers the various modules and combinators that work with tuples.\n\n| Module      | Name            | Given                                   | To                                     |\n| ----------- | --------------- | --------------------------------------- | -------------------------------------- |\n| Equivalence | tuple           | `[Equivalence<A>, Equivalence<B>, ...]` | `Equivalence<readonly [A, B, ...]>`    |\n| Order       | tuple           | `[Order<A>, Order<B>, ...]`             | `Order<readonly [A, B, ...]>`          |\n| Semigroup   | tuple           | `[Semigroup<A>, Semigroup<B>, ...]`     | `Semigroup<[A, B, ...]>`               |\n| Monoid      | tuple           | `[Monoid<A>, Monoid<B>, ...]`           | `Monoid<[A, B, ...]>`                  |\n| SemiProduct | nonEmptyTuple   | `[F<A>, F<B>, ...]` (cannot be empty)   | `F<[A, B, ...]>`                       |\n| Product     | tuple           | `[F<A>, F<B>, ...]`                     | `F<[A, B, ...]>`                       |\n| Either      | tuple           | `[Either<E1, A>, Either<E2, B>, ...]`   | `Either<E1 \\| E2 \\| ..., [A, B, ...]>` |\n| Option      | tuple           | `[Option<A>, Option<B>, ...]`           | `Option<[A, B, ...]>`                  |\n| Predicate   | tuple           | `[Predicate<A>, Predicate<B>, ...]`     | `Predicate<readonly [A, B, ...]>`      |\n| These       | tuple           | `[These<E1, A>, These<E2, B>, ...]`     | `These<E1 \\| E2 \\| ..., [A, B, ...]>`  |\n| Tuple       | getEquivalence  | `[Equivalence<A>, Equivalence<B>, ...]` | `Equivalence<readonly [A, B, ...]>`    |\n| Tuple       | getOrder        | `[Order<A>, Order<B>, ...]`             | `Order<readonly [A, B, ...]>`          |\n| Tuple       | getSemigroup    | `[Semigroup<A>, Semigroup<B>, ...]`     | `Semigroup<[A, B, ...]>`               |\n| Tuple       | getMonoid       | `[Monoid<A>, Monoid<B>, ...]`           | `Monoid<[A, B, ...]>`                  |\n| Tuple       | nonEmptyProduct | `[F<A>, F<B>, ...]` (cannot be empty)   | `F<[A, B, ...]>`                       |\n| Tuple       | product         | `[F<A>, F<B>, ...]`                     | `F<[A, B, ...]>`                       |\n\n## arrays\n\nThis section covers the various modules and combinators that work with arrays.\n\n| Module        | Name          | Given            | To                              |\n| ------------- | ------------- | ---------------- | ------------------------------- |\n| Equivalence   | array         | `Equivalence<A>` | `Equivalence<ReadonlyArray<A>>` |\n| Order         | array         | `Order<A>`       | `Order<ReadonlyArray<A>>`       |\n| Semigroup     | array         | `A`              | `Semigroup<Array<A>>`           |\n| Semigroup     | readonlyArray | `A`              | `Semigroup<ReadonlyArray<A>>`   |\n| Monoid        | array         | `A`              | `Monoid<Array<A>>`              |\n| Monoid        | readonlyArray | `A`              | `Monoid<ReadonlyArray<A>>`      |\n| ReadonlyArray | getSemigroup  | `A`              | `Semigroup<ReadonlyArray<A>>`   |\n| ReadonlyArray | getMonoid     | `A`              | `Monoid<ReadonlyArray<A>>`      |\n\n## structs\n\nThis section covers the various modules and combinators that work with structs.\n\n| Module      | Name            | Given                                           | To                                        |\n| ----------- | --------------- | ----------------------------------------------- | ----------------------------------------- |\n| Equivalence | struct          | `{ a: Equivalence<A>, b: Equivalence<B>, ... }` | `Equivalence<{ a: A, b: B, ... }>`        |\n| Order       | struct          | `{ a: Order<A>, b: Order<B>, ... }`             | `Order<{ a: A, b: B, ... }>`              |\n| Semigroup   | struct          | `{ a: Semigroup<A>, b: Semigroup<B>, ... }`     | `Semigroup<{ a: A, b: B, ... }>`          |\n| Monoid      | struct          | `{ a: Monoid<A>, b: Monoid<B>, ... }`           | `Monoid<{ a: A, b: B, ... }>`             |\n| SemiProduct | nonEmptyStruct  | `{ a: F<A>, b: F<B>, ... }` (cannot be empty)   | `F<{ a: A, b: B, ... }>`                  |\n| Product     | struct          | `{ a: F<A>, b: F<B>, ... }`                     | `F<{ a: A, b: B, ... }>`                  |\n| Either      | struct          | `{ a: Either<E1, A>, b: Either<E2, B>, ... }`   | `Either<E1 \\| E2 \\| ..., { a: A, b: B }>` |\n| Option      | struct          | `{ a: Option<A>, b: Option<B>, ... }`           | `Option<{ a: A, b: B }>`                  |\n| Predicate   | struct          | `{ a: Predicate<A>, b: Predicate<B>, ... }`     | `Predicate<Readonly<{ a: A, b: B }>>`     |\n| These       | struct          | `{ a: These<E1, A>, b: These<E2, B>, ... }`     | `These<E1 \\| E2 \\| ..., { a: A, b: B }>`  |\n| Struct      | getEquivalence  | `{ a: Equivalence<A>, b: Equivalence<B>, ... }` | `Equivalence<{ a: A, b: B, ... }>`        |\n| Struct      | getOrder        | `{ a: Order<A>, b: Order<B>, ... }`             | `Order<{ a: A, b: B, ... }>`              |\n| Struct      | getSemigroup    | `{ a: Semigroup<A>, b: Semigroup<B>, ... }`     | `Semigroup<{ a: A, b: B, ... }>`          |\n| Struct      | getMonoid       | `{ a: Monoid<A>, b: Monoid<B>, ... }`           | `Monoid<{ a: A, b: B, ... }>`             |\n| Struct      | nonEmptyProduct | `{ a: F<A>, b: F<B>, ... }` (cannot be empty)   | `F<{ a: A, b: B, ... }>`                  |\n| Struct      | product         | `{ a: F<A>, b: F<B>, ... }`                     | `F<{ a: A, b: B, ... }>`                  |\n\n## records\n\nThis section covers the various modules and combinators that work with records.\n\n| Module         | Name          | Given                                        | To                               |\n| -------------- | ------------- | -------------------------------------------- | -------------------------------- |\n| Equivalence    | record        | `Equivalence<A>`                             | `Equivalence<ReadonlyRecord<A>>` |\n| ReadonlyRecord | get           | `key: string`, `ReadonlyRecord<A>`           | `Option<A>`                      |\n| ReadonlyRecord | replaceOption | `key: string`, `B`, `ReadonlyRecord<A>`      | `Option<Record<string, A \\| B>>` |\n| ReadonlyRecord | modifyOption  | `key: string`, `A => B`, `ReadonlyRecord<A>` | `Option<Record<string, A \\| B>>` |\n"
  },
  {
    "path": "guides/typeclass.md",
    "content": "# Introduction\n\nThe functional abstractions in `@fp-ts/core` can be broadly divided into two categories.\n\n- Abstractions For Concrete Types - These abstractions define properties of concrete types, such as `number` and `string`, as well as ways of combining those values.\n- Abstractions For Parameterized Types - These abstractions define properties of parameterized types such as `ReadonlyArray` and `Option` and ways of combining them.\n\n# Concrete Types\n\n## Members and derived functions\n\nNote: members are in bold.\n\n### Bounded\n\nA type class used to name the lower limit and the upper limit of a type.\n\nExtends:\n\n- `Order`\n\n| Name         | Given        | To           |\n| ------------ | ------------ | ------------ |\n| **maxBound** |              | `A`          |\n| **minBound** |              | `A`          |\n| reverse      | `Bounded<A>` | `Bounded<A>` |\n| clamp        | `A`          | `A`          |\n\n### Equivalence\n\n`Equivalence` defines a binary relation that is reflexive, symmetric, and transitive.\nIn other words, it defines a notion of equivalence between values of a certain type.\nThese properties are also known in mathematics as an \"equivalence relation\".\n\n| Name         | Given                                           | To                                         |\n| ------------ | ----------------------------------------------- | ------------------------------------------ |\n| strict       | `A`                                             | `Equivalence<A>`                           |\n| tuple        | `[Equivalence<A>, Equivalence<B>, ...]`         | `Equivalence<[A, B, ...]>`                 |\n| array        | `Equivalence<A>`                                | `Equivalence<A[]>`                         |\n| struct       | `{ a: Equivalence<A>, b: Equivalence<B>, ... }` | `Equivalence<{ a: A, b: B, ... }>`         |\n| record       | `Equivalence<A>`                                | `Equivalence<{ readonly [x: string]: A }>` |\n| getSemigroup | `A`                                             | `Semigroup<Equivalence<A>>`                |\n| getMonoid    | `A`                                             | `Monoid<Equivalence<A>>`                   |\n| contramap    | `Equivalence<A>`, `B => A`                      | `Equivalence<B>`                           |\n\n### Monoid\n\nA `Monoid` is a `Semigroup` with an identity. A `Monoid` is a specialization of a\n`Semigroup`, so its operation must be associative. Additionally,\n`x |> combine(empty) == empty |> combine(x) == x`. For example, if we have `Monoid<String>`,\nwith `combine` as string concatenation, then `empty = \"\"`.\n\nExtends:\n\n- `Semigroup`\n\n| Name           | Given                                 | To                            |\n| -------------- | ------------------------------------- | ----------------------------- |\n| **empty**      |                                       | `A`                           |\n| **combineAll** | `Iterable<A>`                         | `A`                           |\n| reverse        | `Monoid<A>`                           | `Monoid<A>`                   |\n| tuple          | `[Monoid<A>, Monoid<B>, ...]`         | `Monoid<[A, B, ...]>`         |\n| struct         | `{ a: Monoid<A>, b: Monoid<B>, ... }` | `Monoid<{ a: A, b: B, ... }>` |\n| min            | `Bounded<A>`                          | `Monoid<A>`                   |\n| max            | `Bounded<A>`                          | `Monoid<A>`                   |\n\n### Order\n\nThe `Order` type class is used to define a total ordering on some type `A`.\nAn order is defined by a relation `<=`, which obeys the following laws:\n\n- either `x <= y` or `y <= x` (totality)\n- if `x <= y` and `y <= x`, then `x == y` (antisymmetry)\n- if `x <= y` and `y <= z`, then `x <= z` (transitivity)\n\nThe truth table for compare is defined as follows:\n\n| `x <= y` | `x >= y` | Ordering |                       |\n| -------- | -------- | -------- | --------------------- |\n| `true`   | `true`   | `0`      | corresponds to x == y |\n| `true`   | `false`  | `< 0`    | corresponds to x < y  |\n| `false`  | `true`   | `> 0`    | corresponds to x > y  |\n\nBy the totality law, `x <= y` and `y <= x` cannot be both `false`.\n\n| Name                 | Given                       | To                    |\n| -------------------- | --------------------------- | --------------------- |\n| **compare**          | `A`, `A`                    | `Ordering`            |\n| reverse              | `Order<A>`                  | `Order<A>`            |\n| contramap            | `Order<A>`, `B => A`        | `Order<B>`            |\n| getSemigroup         |                             | `Semigroup<Order<A>>` |\n| getMonoid            |                             | `Monoid<Order<A>>`    |\n| tuple                | `[Order<A>, Order<B>, ...]` | `Order<[A, B, ...]>`  |\n| lessThan             | `A`, `A`                    | `boolean`             |\n| greaterThan          | `A`, `A`                    | `boolean`             |\n| lessThanOrEqualTo    | `A`, `A`                    | `boolean`             |\n| greaterThanOrEqualTo | `A`, `A`                    | `boolean`             |\n| min                  | `A`, `A`                    | `boolean`             |\n| max                  | `A`, `A`                    | `boolean`             |\n| clamp                | `A`, `A`                    | `A`                   |\n| between              | `A`                         | `boolean`             |\n\n### Semigroup\n\nA `Semigroup` is any set `A` with an associative operation (`combine`):\n\n`x |> combine(y) |> combine(z) == x |> combine(y |> combine(z))`\n\n| Name            | Given                                       | To                               |\n| --------------- | ------------------------------------------- | -------------------------------- |\n| **combine**     | `A`, `A`                                    | `A`                              |\n| **combineMany** | `A`, `Iterable<A>`                          | `A`                              |\n| reverse         | `Semigroup<A>`                              | `Semigroup<A>`                   |\n| tuple           | `[Semigroup<A>, Semigroup<B>, ...]`         | `Semigroup<[A, B, ...]>`         |\n| struct          | `{ a: Semigroup<A>, b: Semigroup<B>, ... }` | `Semigroup<{ a: A, b: B, ... }>` |\n| min             | `Order<A>`                                  | `Semigroup<A>`                   |\n| max             | `Order<A>`                                  | `Semigroup<A>`                   |\n| constant        | `A`                                         | `Semigroup<A>`                   |\n| intercalate     | `A`, `Semigroup<A>`                         | `Semigroup<A>`                   |\n| first           |                                             | `Semigroup<A>`                   |\n| last            |                                             | `Semigroup<A>`                   |\n\n# Parameterized Types\n\n**Parameterized Types Hierarchy**\n\n```mermaid\nflowchart TD\n    Alternative --> SemiAlternative\n    Alternative --> Coproduct\n    Applicative --> Product\n    Coproduct --> SemiCoproduct\n    SemiAlternative --> Covariant\n    SemiAlternative --> SemiCoproduct\n    SemiApplicative --> SemiProduct\n    SemiApplicative --> Covariant\n    Applicative --> SemiApplicative\n    Chainable --> FlatMap\n    Chainable ---> Covariant\n    Monad --> FlatMap\n    Monad --> Pointed\n    Pointed --> Of\n    Pointed --> Covariant\n    Product --> SemiProduct\n    Product --> Of\n    SemiProduct --> Invariant\n    Covariant --> Invariant\n    SemiCoproduct --> Invariant\n```\n\n## Members and derived functions\n\nNote: members are in bold.\n\n### Alternative\n\nExtends:\n\n- `SemiAlternative`\n- `Coproduct`\n\n### Applicative\n\nExtends:\n\n- `SemiApplicative`\n- `Product`\n\n| Name       | Given       | To             |\n| ---------- | ----------- | -------------- |\n| liftMonoid | `Monoid<A>` | `Monoid<F<A>>` |\n\n### Bicovariant\n\nA type class of types which give rise to two independent, covariant\nfunctors.\n\n| Name      | Given                            | To         |\n| --------- | -------------------------------- | ---------- |\n| **bimap** | `F<E1, A>`, `E1 => E2`, `A => B` | `F<E2, B>` |\n| mapLeft   | `F<E1, A>`, `E1 => E2`           | `F<E2, A>` |\n| map       | `F<A>`, `A => B`                 | `F<B>`     |\n\n### Chainable\n\nExtends:\n\n- `FlatMap`\n- `Covariant`\n\n| Name           | Given                               | To                     |\n| -------------- | ----------------------------------- | ---------------------- |\n| tap            | `F<A>`, `A => F<B>`                 | `F<A>`                 |\n| andThenDiscard | `F<A>`, `F<B>`                      | `F<A>`                 |\n| bind           | `F<A>`, `name: string`, `A => F<B>` | `F<A & { [name]: B }>` |\n\n### Contravariant\n\nContravariant functors.\n\nExtends:\n\n- `Invariant`\n\n| Name                 | Given               | To        |\n| -------------------- | ------------------- | --------- |\n| **contramap**        | `F<A>`, `B => A`    | `F<B>`    |\n| contramapComposition | `F<G<A>>`, `A => B` | `F<G<B>>` |\n| imap                 | `contramap`         | `imap`    |\n\n### Coproduct\n\n`Coproduct` is a universal monoid which operates on kinds.\n\nThis type class is useful when its type parameter `F<_>` has a\nstructure that can be combined for any particular type, and which\nalso has a \"zero\" representation. Thus, `Coproduct` is like a `Monoid`\nfor kinds (i.e. parametrized types).\n\nA `Coproduct<F>` can produce a `Monoid<F<A>>` for any type `A`.\n\nHere's how to distinguish `Monoid` and `Coproduct`:\n\n- `Monoid<A>` allows `A` values to be combined, and also means there\n  is an \"empty\" `A` value that functions as an identity.\n\n- `Coproduct<F>` allows two `F<A>` values to be combined, for any `A`. It\n  also means that for any `A`, there is an \"zero\" `F<A>` value. The\n  combination operation and zero value just depend on the\n  structure of `F`, but not on the structure of `A`.\n\nExtends:\n\n- `SemiCoproduct`\n\n| Name             | Given            | To             |\n| ---------------- | ---------------- | -------------- |\n| **zero**         |                  | `F<A>`         |\n| **coproductAll** | `Iterable<F<A>>` | `F<A>`         |\n| getMonoid        |                  | `Monoid<F<A>>` |\n\n### Covariant\n\nCovariant functors.\n\nExtends:\n\n- `Invariant`\n\n| Name           | Given               | To        |\n| -------------- | ------------------- | --------- |\n| **map**        | `F<A>`, `A => B`    | `F<B>`    |\n| mapComposition | `F<G<A>>`, `A => B` | `F<G<B>>` |\n| imap           | `map`               | `imap`    |\n| flap           | `A`, `F<A => B>`    | `F<B>`    |\n| as             | `F<A>`, `B`         | `F<B>`    |\n| asUnit         | `F<A>`              | `F<void>` |\n\n### Filterable\n\n`Filterable<F>` allows you to `map` and filter out elements simultaneously.\n\n| Name                    | Given                          | To                   |\n| ----------------------- | ------------------------------ | -------------------- |\n| **partitionMap**        | `F<A>`, `A => Either<B, C>`    | `[F<B>, F<C>]`       |\n| **filterMap**           | `F<A>`, `A => Option<B>`       | `F<B>`               |\n| compact                 | `F<Option<A>>`                 | `F<A>`               |\n| separate                | `F<Either<A, B>>`              | `[F<A>, F<B>]`       |\n| filter                  | `F<A>`, `A => boolean`         | `F<A>`               |\n| partition               | `F<A>`, `A => boolean`         | `[F<A>, F<A>]`       |\n| partitionMapComposition | `F<G<A>>`, `A => Either<B, C>` | `[F<G<B>>, F<G<C>>]` |\n| filterMapComposition    | `F<G<A>>`, `A => Option<B>`    | `F<G<B>>`            |\n\n### FlatMap\n\n| Name                | Given                    | To          |\n| ------------------- | ------------------------ | ----------- |\n| **flatMap**         | `F<A>`, `A => F<B>`      | `F<B>`      |\n| flatten             | `F<F<A>>`                | `F<A>`      |\n| andThen             | `F<A>`, `F<B>`           | `F<B>`      |\n| composeKleisliArrow | `A => F<B>`, `B => F<C>` | `A => F<C>` |\n\n### Foldable\n\nData structures that can be folded to a summary value.\n\nIn the case of a collection (such as `ReadonlyArray`), these\nmethods will fold together (combine) the values contained in the\ncollection to produce a single result. Most collection types have\n`reduce` methods, which will usually be used by the associated\n`Foldable<F>` instance.\n\n| Name                | Given                                     | To                 |\n| ------------------- | ----------------------------------------- | ------------------ |\n| **reduce**          | `F<A>`, `B`, `(B, A) => B`                | `B`                |\n| reduceComposition   | `F<G<A>>`, `B`, `(B, A) => B`             | `B`                |\n| reduceRight         | `F<A>`, `B`, `(B, A) => B`                | `B`                |\n| foldMap             | `F<A>`, `Monoid<M>`, `A => M`             | `M`                |\n| toReadonlyArray     | `F<A>`                                    | `ReadonlyArray<A>` |\n| toReadonlyArrayWith | `F<A>`, `A => B`                          | `ReadonlyArray<B>` |\n| reduceKind          | `Monad<G>`, `F<A>`, `B`, `(B, A) => G<B>` | `G<B>`             |\n| reduceRightKind     | `Monad<G>`, `F<A>`, `B`, `(B, A) => G<B>` | `G<B>`             |\n| foldMapKind         | `Coproduct<G>`, `F<A>`, `(A) => G<B>`     | `G<B>`             |\n\n### Invariant\n\nInvariant functors.\n\n| Name            | Given                         | To                 |\n| --------------- | ----------------------------- | ------------------ |\n| **imap**        | `F<A>`, `A => B`, `B => A`    | `F<B>`             |\n| imapComposition | `F<G<A>>`, `A => B`, `B => A` | `F<G<B>>`          |\n| bindTo          | `F<A>`, `name: string`        | `F<{ [name]: A }>` |\n| tupled          | `F<A>`                        | `F<[A]>`           |\n\n### Monad\n\nAllows composition of dependent effectful functions.\n\nExtends:\n\n- `FlatMap`\n- `Pointed`\n\n### Of\n\n| Name          | Given | To        |\n| ------------- | ----- | --------- |\n| **of**        | `A`   | `F<A>`    |\n| ofComposition | `A`   | `F<G<A>>` |\n| unit          |       | `F<void>` |\n| Do            |       | `F<{}>`   |\n\n### Pointed\n\nExtends:\n\n- `Covariant`\n- `Of`\n\n### Product\n\nExtends:\n\n- `SemiProduct`\n- `Of`\n\n| Name           | Given                       | To                       |\n| -------------- | --------------------------- | ------------------------ |\n| **productAll** | `Iterable<F<A>>`            | `F<ReadonlyArray<A>>`    |\n| tuple          | `[F<A>, F<B>, ...]`         | `F<[A, B, ...]>`         |\n| struct         | `{ a: F<A>, b: F<B>, ... }` | `F<{ a: A, b: B, ... }>` |\n\n### SemiAlternative\n\nExtends:\n\n- `SemiCoproduct`\n- `Covariant`\n\n### SemiApplicative\n\nExtends:\n\n- `SemiProduct`\n- `Covariant`\n\n| Name           | Given               | To                           |\n| -------------- | ------------------- | ---------------------------- |\n| liftSemigroup  | `Semigroup<A>`      | `Semigroup<F<A>>`            |\n| ap             | `F<A => B>`, `F<A>` | `F<B>`                       |\n| andThenDiscard | `F<A>`, `F<B>`      | `F<A>`                       |\n| andThen        | `F<A>`, `F<B>`      | `F<B>`                       |\n| lift2          | `(A, B) => C`       | `(F<A>, F<B>) => F<C>`       |\n| lift3          | `(A, B, C) => D`    | `(F<A>, F<B>, F<C>) => F<D>` |\n\n### SemiCoproduct\n\n`SemiCoproduct` is a universal semigroup which operates on kinds.\n\nThis type class is useful when its type parameter `F<_>` has a\nstructure that can be combined for any particular type. Thus,\n`SemiCoproduct` is like a `Semigroup` for kinds (i.e. parametrized\ntypes).\n\nA `SemiCoproduct<F>` can produce a `Semigroup<F<A>>` for any type A.\n\nHere's how to distinguish `Semigroup` and `SemiCoproduct`:\n\n- `Semigroup<A>` allows two `A` values to be combined.\n\n- `SemiCoproduct<F>` allows two `F<A>` values to be combined, for any `A`.\n  The combination operation just depends on the structure of `F`,\n  but not the structure of `A`.\n\nExtends:\n\n- `Invariant`\n\n| Name              | Given            | To                |\n| ----------------- | ---------------- | ----------------- |\n| **coproduct**     | `F<A>`, `F<B>`   | `F<A \\| B>`       |\n| **coproductMany** | `Iterable<F<A>>` | `F<A>`            |\n| getSemigroup      |                  | `Semigroup<F<A>>` |\n| coproductEither   | `F<A>`, `F<B>`   | `F<Either<A, B>>` |\n\n### SemiProduct\n\nExtends:\n\n- `Invariant`\n\n| Name                   | Given                          | To                               |\n| ---------------------- | ------------------------------ | -------------------------------- |\n| **product**            | `F<A>`, `F<B>`                 | `F<[A, B]>`                      |\n| **productMany**        | `F<A>`, `Iterable<F<A>>`       | `F<[A, ...ReadonlyArray<A>]>`    |\n| productComposition     | `F<G<A>>`, `F<G<B>>`           | `F<G<[A, B]>>`                   |\n| productManyComposition | `F<G<A>>`, `Iterable<F<G<A>>>` | `F<G<[A, ...ReadonlyArray<A>]>>` |\n| nonEmptyTuple          | `[F<A>, F<B>, ...]`            | `F<[A, B, ...]>`                 |\n| nonEmptyStruct         | `{ a: F<A>, b: F<B>, ... }`    | `F<{ a: A, b: B, ... }>`         |\n| andThenBind            | `F<A>`, `name: string`, `F<B>` | `F<A & { [name]: B }>`           |\n| productFlatten         | `F<A>`, `F<B>`                 | `F<[...A, B]>`                   |\n\n### Traversable\n\nTraversal over a structure with an effect.\n\n| Name                | Given                                    | To           |\n| ------------------- | ---------------------------------------- | ------------ |\n| **traverse**        | `Applicative<F>`, `T<A>`, `A => F<B>`    | `F<T<B>>`    |\n| traverseComposition | `Applicative<F>`, `T<G<A>>`, `A => F<B>` | `F<T<G<B>>>` |\n| sequence            | `Applicative<F>`, `T<F<A>>`              | `F<T<A>>`    |\n| traverseTap         | `Applicative<F>`, `T<A>`, `A => F<B>`    | `F<T<A>>`    |\n\n### TraversableFilterable\n\n`TraversableFilterable`, also known as `Witherable`, represents list-like structures\nthat can essentially have a `traverse` and a `filter` applied as a single\ncombined operation (`traverseFilter`).\n\n| Name                     | Given                                            | To                |\n| ------------------------ | ------------------------------------------------ | ----------------- |\n| **traversePartitionMap** | `Applicative<F>`, `T<A>`, `A => F<Either<B, C>>` | `F<[T<B>, T<C>]>` |\n| **traverseFilterMap**    | `Applicative<F>`, `T<A>`, `A => F<Option<B>>`    | `F<T<B>>`         |\n| traverseFilter           | `Applicative<F>`, `T<A>`, `A => F<boolean>`      | `F<T<A>>`         |\n| traversePartition        | `Applicative<F>`, `T<A>`, `A => F<boolean>`      | `F<[T<A>, T<A>]>` |\n\n# Data Types\n\nAdditionaly `@fp-ts/core` exports a few data types (types only, implementations are in `@fp-ts/data`)\n\n- `Either<out E, out A>`\n- `Option<out A>`\n\n---\n\nAdapted from:\n\n- [cats](https://github.com/typelevel/cats)\n- [zio-prelude](https://github.com/zio/zio-prelude)\n- [zio-cheatsheet](https://github.com/ghostdogpr/zio-cheatsheet)\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"@fp-ts/core\",\n  \"version\": \"0.2.1\",\n  \"publishConfig\": {\n    \"access\": \"public\",\n    \"directory\": \"dist\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/fp-ts/core.git\"\n  },\n  \"author\": \"Giulio Canti <giulio.canti@gmail.com>\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/fp-ts/core/issues\"\n  },\n  \"homepage\": \"https://github.com/fp-ts/core\",\n  \"description\": \"Functional programming in TypeScript\",\n  \"tags\": [\n    \"typescript\",\n    \"algebraic-data-types\",\n    \"functional-programming\"\n  ],\n  \"keywords\": [\n    \"typescript\",\n    \"algebraic-data-types\",\n    \"functional-programming\"\n  ],\n  \"scripts\": {\n    \"version\": \"changeset version && pnpm install --no-frozen-lockfile && pnpm run docs-update\",\n    \"release\": \"pnpm run build && changeset publish\",\n    \"clean\": \"rimraf build tsbuildinfo dist .ultra.cache.json\",\n    \"build\": \"pnpm build-all && pnpm build-pack\",\n    \"build-cjs\": \"babel build/esm --config-file ./.babel.cjs.json --out-dir build/cjs --out-file-extension .js --source-maps\",\n    \"build-mjs\": \"babel build/esm --config-file ./.babel.mjs.json --out-dir build/mjs --out-file-extension .mjs --source-maps\",\n    \"build-post\": \"build-utils pack-v3\",\n    \"build-pack\": \"concurrently \\\"pnpm build-cjs\\\" \\\"pnpm build-mjs\\\" && pnpm build-post\",\n    \"build-all\": \"tsc -b tsconfig.json\",\n    \"build-watch\": \"tsc -b tsconfig.json --watch\",\n    \"dtslint\": \"dtslint dtslint\",\n    \"lint\": \"eslint . --ext .ts,.tsx\",\n    \"autofix\": \"pnpm lint --fix\",\n    \"tc\": \"tsc --noEmit\",\n    \"docs\": \"docs-ts\",\n    \"docs-update\": \"git add --force --all docs/modules || true\",\n    \"circular\": \"madge --ts-config ./tsconfig.madge.json --circular --no-color --no-spinner --warning build/esm\",\n    \"test\": \"vitest\",\n    \"test-all\": \"npm run circular && npm run dtslint && vitest run\",\n    \"coverage\": \"vitest run --coverage\"\n  },\n  \"exports\": {\n    \".\": {\n      \"require\": \"./build/cjs/index.js\"\n    },\n    \"./*\": {\n      \"require\": \"./build/cjs/*.js\"\n    }\n  },\n  \"config\": {\n    \"side\": [],\n    \"modules\": [],\n    \"global\": []\n  },\n  \"devDependencies\": {\n    \"@babel/cli\": \"^7.18.6\",\n    \"@babel/core\": \"^7.20.5\",\n    \"@babel/plugin-transform-modules-commonjs\": \"^7.19.6\",\n    \"@changesets/changelog-github\": \"^0.4.7\",\n    \"@changesets/cli\": \"^2.25.2\",\n    \"@effect-ts/build-utils\": \"0.40.3\",\n    \"@effect-ts/core\": \"^0.60.2\",\n    \"@effect/language-service\": \"^0.0.17\",\n    \"@repo-tooling/eslint-plugin-dprint\": \"^0.0.4\",\n    \"@types/benchmark\": \"^2.1.2\",\n    \"@types/glob\": \"^8.0.0\",\n    \"@types/jest\": \"^29.2.3\",\n    \"@types/node\": \"^18.11.9\",\n    \"@types/prettier\": \"2.7.1\",\n    \"@types/rimraf\": \"^3.0.2\",\n    \"@typescript-eslint/eslint-plugin\": \"^5.44.0\",\n    \"@typescript-eslint/parser\": \"^5.44.0\",\n    \"@vitest/coverage-c8\": \"^0.27.1\",\n    \"babel-plugin-annotate-pure-calls\": \"^0.4.0\",\n    \"benchmark\": \"^2.1.4\",\n    \"c8\": \"^7.11.3\",\n    \"concurrently\": \"^7.6.0\",\n    \"cpx\": \"^1.5.0\",\n    \"docs-ts\": \"0.6.10\",\n    \"dtslint\": \"github:gcanti/dtslint\",\n    \"eslint\": \"^8.28.0\",\n    \"eslint-import-resolver-typescript\": \"^3.5.2\",\n    \"eslint-plugin-codegen\": \"0.16.1\",\n    \"eslint-plugin-deprecation\": \"^1.3.3\",\n    \"eslint-plugin-import\": \"^2.26.0\",\n    \"eslint-plugin-simple-import-sort\": \"^8.0.0\",\n    \"eslint-plugin-sort-destructure-keys\": \"^1.4.0\",\n    \"fast-check\": \"^3.3.0\",\n    \"glob\": \"^8.0.3\",\n    \"madge\": \"^5.0.1\",\n    \"picocolors\": \"^1.0.0\",\n    \"prettier\": \"^2.8.0\",\n    \"rimraf\": \"^3.0.2\",\n    \"ts-node\": \"^10.9.1\",\n    \"tslint\": \"^6.1.3\",\n    \"typescript\": \"^4.9.3\",\n    \"ultra-runner\": \"^3.10.5\",\n    \"vite\": \"^3.2.4\",\n    \"vitest\": \"0.25.3\"\n  },\n  \"pnpm\": {\n    \"patchedDependencies\": {\n      \"@effect-ts/build-utils@0.40.3\": \"patches/@effect-ts__build-utils@0.40.3.patch\",\n      \"docs-ts@0.6.10\": \"patches/docs-ts@0.6.10.patch\"\n    }\n  }\n}\n"
  },
  {
    "path": "patches/@effect-ts__build-utils@0.40.3.patch",
    "content": "diff --git a/pack-v3.js b/pack-v3.js\nindex c12e36a7f85c59e8d219df0eec1001c495be4f64..129b8d678ff6796f9a3d78056da47b5f2d99895d 100644\n--- a/pack-v3.js\n+++ b/pack-v3.js\n@@ -43,7 +43,7 @@ function carry(s, root, target) {\n }\n const writePackageJsonContent = (0, Function_1.pipe)(TE.do, TE.bind(\"content\", () => loadPackageJson), TE.bind(\"modules\", ({ content }) => getModules(content)), TE.bind(\"side\", ({ content }) => getSide(content)), TE.bind(\"global\", ({ content }) => getGlobal(content)), TE.tap(({ global }) => global._tag === \"None\"\n     ? TE.unit\n-    : TE.forEach_(global.value.filter((gi) => gi.startsWith(\"_src/\")), (gi) => (0, _common_1.copy)(gi, \"dist\", { update: true }))), TE.map(({ content, global, modules, side }) => {\n+    : TE.forEach_(global.value.filter((gi) => gi.startsWith(\"src/\")), (gi) => (0, _common_1.copy)(gi, \"dist\", { update: true }))), TE.map(({ content, global, modules, side }) => {\n     const packageJson = {};\n     carry(\"name\", content, packageJson);\n     carry(\"version\", content, packageJson);\n@@ -60,7 +60,7 @@ const writePackageJsonContent = (0, Function_1.pipe)(TE.do, TE.bind(\"content\", (\n     if (fs.existsSync(`./build/mjs/index.mjs`)) {\n         mainExports[\"import\"] = {\n             types: `./index.d.ts`,\n-            default: `./_mjs/index.mjs`\n+            default: `./mjs/index.mjs`\n         };\n     }\n     if (fs.existsSync(`./build/cjs/index.js`)) {\n@@ -80,14 +80,14 @@ const writePackageJsonContent = (0, Function_1.pipe)(TE.do, TE.bind(\"content\", (\n     }\n     if (global._tag === \"Some\") {\n         global.value\n-            .filter((gi) => gi.startsWith(\"_src/\"))\n+            .filter((gi) => gi.startsWith(\"src/\"))\n             .forEach((gi) => {\n-            exports[`./${gi.replace(\"_src/\", \"\").replace(\".d.ts\", \"\")}`] = {\n+            exports[`./${gi.replace(\"src/\", \"\").replace(\".d.ts\", \"\")}`] = {\n                 import: {\n-                    types: `./${gi.replace(\"_src/\", \"\")}`\n+                    types: `./${gi.replace(\"src/\", \"\")}`\n                 },\n                 require: {\n-                    types: `./${gi.replace(\"_src/\", \"\")}`\n+                    types: `./${gi.replace(\"src/\", \"\")}`\n                 }\n             };\n         });\n@@ -97,7 +97,7 @@ const writePackageJsonContent = (0, Function_1.pipe)(TE.do, TE.bind(\"content\", (\n         if (fs.existsSync(`./build/mjs/${m}/index.mjs`)) {\n             exports[`./${m}`][\"import\"] = {\n                 types: `./${m}/index.d.ts`,\n-                default: `./_mjs/${m}/index.mjs`\n+                default: `./mjs/${m}/index.mjs`\n             };\n         }\n         if (fs.existsSync(`./build/cjs/${m}/index.js`)) {\n@@ -113,7 +113,7 @@ const writePackageJsonContent = (0, Function_1.pipe)(TE.do, TE.bind(\"content\", (\n     exports[\"./*\"] = {\n         import: {\n             types: \"./*.d.ts\",\n-            default: \"./_mjs/*.mjs\"\n+            default: \"./mjs/*.mjs\"\n         },\n         require: {\n             types: \"./*.d.ts\",\n@@ -131,7 +131,7 @@ const writePackageJsonContent = (0, Function_1.pipe)(TE.do, TE.bind(\"content\", (\n                 map.push(`./${m}/index.js`);\n             }\n             if (fs.existsSync(`./build/mjs/${m}/index.mjs`)) {\n-                map.push(`./_mjs/${m}/index.mjs`);\n+                map.push(`./mjs/${m}/index.mjs`);\n             }\n             return map;\n         }),\n@@ -141,13 +141,13 @@ const writePackageJsonContent = (0, Function_1.pipe)(TE.do, TE.bind(\"content\", (\n const MAP_GLOB_PATTERN = \"dist/**/*.map\";\n const replaceString = (path) => {\n     const dir = path_1.posix.dirname(path);\n-    const patch = path.startsWith(\"dist/_mjs/\")\n-        ? (x) => x.replace(/(.*)\\.\\.\\/_src(.*)/gm, \"$1_src$2\")\n-        : (x) => x.replace(/(.*)\\.\\.\\/\\.\\.\\/_src(.*)/gm, \"$1_src$2\");\n+    const patch = path.startsWith(\"dist/mjs/\")\n+        ? (x) => x.replace(/(.*)\\.\\.\\/src(.*)/gm, \"$1src$2\")\n+        : (x) => x.replace(/(.*)\\.\\.\\/\\.\\.\\/src(.*)/gm, \"$1src$2\");\n     return (0, Function_1.flow)(patch, (x) => path_1.posix.relative(dir, path_1.posix.join(dir, x)), (x) => (x.startsWith(\".\") ? x : \"./\" + x));\n };\n const replace = (content, path) => JSON.stringify((0, Function_1.pipe)(Object.entries(JSON.parse(content)), A.map(([k, v]) => k === \"sources\"\n     ? [k, A.map_(v, replaceString(path))]\n     : [k, v]), A.reduce({}, (acc, [k, v]) => ({ ...acc, [k]: v }))));\n-(0, Function_1.pipe)((0, _common_1.exec)(\"rm -rf build/dist\"), TE.tap(() => (0, _common_1.exec)(\"mkdir -p dist\")), TE.tap(() => TE.when(() => fs.existsSync(`./_src`))((0, _common_1.exec)(`mkdir -p ./dist/_src && cp -r ./_src/* ./dist/_src`))), TE.tap(() => TE.when(() => fs.existsSync(`./build/mjs`))((0, _common_1.exec)(`mkdir -p ./dist/_mjs && cp -r ./build/mjs/* ./dist/_mjs`))), TE.tap(() => TE.when(() => fs.existsSync(`./build/cjs`))((0, _common_1.exec)(`cp -r ./build/cjs/* ./dist`))), TE.tap(() => TE.when(() => fs.existsSync(`./build/dts`))((0, _common_1.exec)(`cp -r ./build/dts/* ./dist`))), TE.tap(() => writePackageJsonContent), TE.tap(() => copyReadme), TE.tap(() => (0, _common_1.modifyGlob)(replace)(MAP_GLOB_PATTERN)), TE.fold(_common_1.onLeft, (0, _common_1.onRight)(\"pack succeeded!\")), _common_1.runMain);\n+(0, Function_1.pipe)((0, _common_1.exec)(\"rm -rf build/dist\"), TE.tap(() => (0, _common_1.exec)(\"mkdir -p dist\")), TE.tap(() => TE.when(() => fs.existsSync(`./src`))((0, _common_1.exec)(`mkdir -p ./dist/src && cp -r ./src/* ./dist/src`))), TE.tap(() => TE.when(() => fs.existsSync(`./build/mjs`))((0, _common_1.exec)(`mkdir -p ./dist/mjs && cp -r ./build/mjs/* ./dist/mjs`))), TE.tap(() => TE.when(() => fs.existsSync(`./build/cjs`))((0, _common_1.exec)(`cp -r ./build/cjs/* ./dist`))), TE.tap(() => TE.when(() => fs.existsSync(`./build/dts`))((0, _common_1.exec)(`cp -r ./build/dts/* ./dist`))), TE.tap(() => writePackageJsonContent), TE.tap(() => copyReadme), TE.tap(() => (0, _common_1.modifyGlob)(replace)(MAP_GLOB_PATTERN)), TE.fold(_common_1.onLeft, (0, _common_1.onRight)(\"pack succeeded!\")), _common_1.runMain);\n //# sourceMappingURL=pack-v3.js.map"
  },
  {
    "path": "patches/docs-ts@0.6.10.patch",
    "content": "diff --git a/lib/Core.js b/lib/Core.js\nindex c0f282ca9e3ddd93e44a62e1d05c1cc45b9f5c6a..616f7f6223459e0621522279ea7fc1cf1868abe8 100644\n--- a/lib/Core.js\n+++ b/lib/Core.js\n@@ -167,7 +167,30 @@ var typeCheckExamples = function (modules) {\n     return function_1.pipe(getExampleFiles(modules), RTE.chain(handleImports), RTE.chain(function (examples) {\n         return examples.length === 0\n             ? cleanExamples\n-            : function_1.pipe(writeExamples(examples), RTE.chain(function () { return spawnTsNode; }), RTE.chain(function () { return cleanExamples; }));\n+            : function_1.pipe(writeExamples(examples), RTE.chain(function () { return writeFile({\"path\": \"./docs/examples/tsconfig.json\", \"content\": JSON.stringify({\n+                \"compilerOptions\": {\n+                  \"noEmit\": true,\n+                  \"strict\": true,\n+                  \"noImplicitAny\": true,\n+                  \"noImplicitThis\": true,\n+                  \"strictNullChecks\": true,\n+                  \"strictFunctionTypes\": true,\n+                  \"noImplicitReturns\": false,\n+                  \"noUnusedLocals\": false,\n+                  \"noUnusedParameters\": false,\n+                  \"noFallthroughCasesInSwitch\": true,\n+                  \"moduleResolution\": \"node\",\n+                  \"target\": \"ES2021\",\n+                  \"lib\": [\"ES2021\"],\n+                  \"paths\": {\n+                    \"@fp-ts/core\": [\"../../src/index.ts\"],\n+                    \"@fp-ts/core/test/*\": [\"../../test/*\"],\n+                    \"@fp-ts/core/examples/*\": [\"../../examples/*\"],\n+                    \"@fp-ts/core/*\": [\"../../src/*\"]\n+                  }\n+                }\n+              }\n+              )}); }), RTE.chain(function () { return spawnTsNode; }), RTE.chain(function () { return cleanExamples; }));\n     }));\n };\n // -------------------------------------------------------------------------------------\ndiff --git a/lib/index.js b/lib/index.js\nindex 51bdb346c4c33e8835bbda0c16aea71bc0c3115e..7d084d363efd3f8aad76051f4253b0b59cd0c5cd 100644\n--- a/lib/index.js\n+++ b/lib/index.js\n@@ -33,7 +33,13 @@ exports.exit = TE.fold(onLeft, function () { return onRight; });\n  * @internal\n  */\n exports.compilerOptions = {\n-    strict: true\n+    strict: true,\n+    paths: {\n+      \"@fp-ts/core\": [\"./src/index.ts\"],\n+      \"@fp-ts/core/test/*\": [\"./test/*\"],\n+      \"@fp-ts/core/examples/*\": [\"./examples/*\"],\n+      \"@fp-ts/core/*\": [\"./src/*\"]\n+    }\n };\n var capabilities = {\n     example: Example_1.Example,\n"
  },
  {
    "path": "src/Bigint.ts",
    "content": "/**\n * This module provides utility functions and type class instances for working with the `bigint` type in TypeScript.\n * It includes functions for basic arithmetic operations, as well as type class instances for\n * `Equivalence`, `Order`, `Semigroup`, and `Monoid`.\n *\n * @since 1.0.0\n */\n\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Ordering } from \"@fp-ts/core/Ordering\"\nimport * as predicate from \"@fp-ts/core/Predicate\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * Tests if a value is a `bigint`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isBigint } from \"@fp-ts/core/Bigint\"\n *\n * assert.deepStrictEqual(isBigint(1n), true)\n * assert.deepStrictEqual(isBigint(1), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isBigint: (u: unknown) => u is bigint = predicate.isBigint\n\n/**\n * Provides an addition operation on `bigint`s.\n *\n * @param self - The first operand.\n * @param that - The second operand.\n *\n * @example\n * import { sum } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(sum(2n, 3n), 5n)\n *\n * @category math\n * @since 1.0.0\n */\nexport const sum: {\n  (that: bigint): (self: bigint) => bigint\n  (self: bigint, that: bigint): bigint\n} = dual(2, semigroup.bigintSum.combine)\n\n/**\n * Provides a multiplication operation on `bigint`s.\n *\n * @param self - The first operand.\n * @param that - The second operand.\n *\n * @example\n * import { multiply } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(multiply(2n, 3n), 6n)\n *\n * @category math\n * @since 1.0.0\n */\nexport const multiply: {\n  (that: bigint): (self: bigint) => bigint\n  (self: bigint, that: bigint): bigint\n} = dual(2, semigroup.bigintMultiply.combine)\n\n/**\n * Provides a subtraction operation on `bigint`s.\n *\n * @param self - The first operand.\n * @param that - The second operand.\n *\n * @example\n * import { subtract } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(subtract(2n, 3n), -1n)\n *\n * @category math\n * @since 1.0.0\n */\nexport const subtract: {\n  (that: bigint): (self: bigint) => bigint\n  (self: bigint, that: bigint): bigint\n} = dual(2, (self: bigint, that: bigint): bigint => self - that)\n\n/**\n * Provides a division operation on `bigint`s.\n *\n * If the dividend is not a multiple of the divisor the result will be a `bigint` value\n * which represents the integer division rounded down to the nearest integer.\n *\n * @param self - The dividend operand.\n * @param that - The divisor operand.\n *\n * @example\n * import { divide } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(divide(6n, 3n), 2n)\n * assert.deepStrictEqual(divide(6n, 4n), 1n)\n *\n * @category math\n * @since 1.0.0\n * @since 1.0.0\n */\nexport const divide: {\n  (that: bigint): (self: bigint) => bigint\n  (self: bigint, that: bigint): bigint\n} = dual(2, (self: bigint, that: bigint): bigint => self / that)\n\n/**\n * Returns the result of adding `1n` to a given number.\n *\n * @param n - A `bigint` to be incremented.\n *\n * @example\n * import { increment } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(increment(2n), 3n)\n *\n * @category math\n * @since 1.0.0\n */\nexport const increment = (n: bigint): bigint => n + 1n\n\n/**\n * Decrements a number by `1n`.\n *\n * @param n - A `bigint` to be decremented.\n *\n * @example\n * import { decrement } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(decrement(3n), 2n)\n *\n * @category math\n * @since 1.0.0\n */\nexport const decrement = (n: bigint): bigint => n - 1n\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Equivalence: equivalence.Equivalence<bigint> = equivalence.bigint\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Order: order.Order<bigint> = order.bigint\n\n/**\n * Returns `true` if the first argument is less than the second, otherwise `false`.\n *\n * @param self - The first argument.\n * @param that - The second argument.\n *\n * @example\n * import { lessThan } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(lessThan(2n, 3n), true)\n * assert.deepStrictEqual(lessThan(3n, 3n), false)\n * assert.deepStrictEqual(lessThan(4n, 3n), false)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const lessThan: {\n  (that: bigint): (self: bigint) => boolean\n  (self: bigint, that: bigint): boolean\n} = order.lessThan(Order)\n\n/**\n * Returns a function that checks if a given `bigint` is less than or equal to the provided one.\n *\n * @param self - The first `bigint` to compare with.\n * @param that - The second `bigint` to compare with.\n *\n * @example\n * import { lessThanOrEqualTo } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(lessThanOrEqualTo(2n, 3n), true)\n * assert.deepStrictEqual(lessThanOrEqualTo(3n, 3n), true)\n * assert.deepStrictEqual(lessThanOrEqualTo(4n, 3n), false)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const lessThanOrEqualTo: {\n  (that: bigint): (self: bigint) => boolean\n  (self: bigint, that: bigint): boolean\n} = order.lessThanOrEqualTo(Order)\n\n/**\n * Returns `true` if the first argument is greater than the second, otherwise `false`.\n *\n * @param self - The first argument.\n * @param that - The second argument.\n *\n * @example\n * import { greaterThan } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(greaterThan(2n, 3n), false)\n * assert.deepStrictEqual(greaterThan(3n, 3n), false)\n * assert.deepStrictEqual(greaterThan(4n, 3n), true)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const greaterThan: {\n  (that: bigint): (self: bigint) => boolean\n  (self: bigint, that: bigint): boolean\n} = order.greaterThan(Order)\n\n/**\n * Returns a function that checks if a given `bigint` is greater than or equal to the provided one.\n *\n * @param self - The first `bigint` to compare with.\n * @param that - The second `bigint` to compare with.\n *\n * @example\n * import { greaterThanOrEqualTo } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(greaterThanOrEqualTo(2n, 3n), false)\n * assert.deepStrictEqual(greaterThanOrEqualTo(3n, 3n), true)\n * assert.deepStrictEqual(greaterThanOrEqualTo(4n, 3n), true)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const greaterThanOrEqualTo: {\n  (that: bigint): (self: bigint) => boolean\n  (self: bigint, that: bigint): boolean\n} = order.greaterThanOrEqualTo(Order)\n\n/**\n * Checks if a `bigint` is between a `minimum` and `maximum` value (inclusive).\n *\n * @param self - The `number` to check.\n * @param minimum - The `minimum` value to check.\n * @param maximum - The `maximum` value to check.\n *\n * @example\n * import { between } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(between(0n, 5n)(3n), true)\n * assert.deepStrictEqual(between(0n, 5n)(-1n), false)\n * assert.deepStrictEqual(between(0n, 5n)(6n), false)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const between: {\n  (minimum: bigint, maximum: bigint): (self: bigint) => boolean\n  (self: bigint, minimum: bigint, maximum: bigint): boolean\n} = order.between(Order)\n\n/**\n * Restricts the given `bigint` to be within the range specified by the `minimum` and `maximum` values.\n *\n * - If the `bigint` is less than the `minimum` value, the function returns the `minimum` value.\n * - If the `bigint` is greater than the `maximum` value, the function returns the `maximum` value.\n * - Otherwise, it returns the original `bigint`.\n *\n * @param self - The `bigint` to be clamped.\n * @param minimum - The lower end of the range.\n * @param maximum - The upper end of the range.\n *\n * @example\n * import { clamp } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(clamp(0n, 5n)(3n), 3n)\n * assert.deepStrictEqual(clamp(0n, 5n)(-1n), 0n)\n * assert.deepStrictEqual(clamp(0n, 5n)(6n), 5n)\n *\n * @since 1.0.0\n */\nexport const clamp: {\n  (minimum: bigint, maximum: bigint): (self: bigint) => bigint\n  (self: bigint, minimum: bigint, maximum: bigint): bigint\n} = order.clamp(Order)\n\n/**\n * Returns the minimum between two `bigint`s.\n *\n * @param self - The first `bigint`.\n * @param that - The second `bigint`.\n *\n * @example\n * import { min } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(min(2n, 3n), 2n)\n *\n * @since 1.0.0\n */\nexport const min: {\n  (that: bigint): (self: bigint) => bigint\n  (self: bigint, that: bigint): bigint\n} = order.min(Order)\n\n/**\n * Returns the maximum between two `bigint`s.\n *\n * @param self - The first `bigint`.\n * @param that - The second `bigint`.\n *\n * @example\n * import { max } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(max(2n, 3n), 3n)\n *\n * @since 1.0.0\n */\nexport const max: {\n  (that: bigint): (self: bigint) => bigint\n  (self: bigint, that: bigint): bigint\n} = order.max(Order)\n\n/**\n * `bigint` semigroup under addition.\n *\n * @example\n * import { SemigroupSum } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(SemigroupSum.combine(2n, 3n), 5n)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupSum: semigroup.Semigroup<bigint> = semigroup.bigintSum\n\n/**\n * `bigint` semigroup under multiplication.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupMultiply: semigroup.Semigroup<bigint> = semigroup.bigintMultiply\n\n/**\n * A `Semigroup` that uses the minimum between two values.\n *\n * @example\n * import { SemigroupMin } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(SemigroupMin.combine(2n, 3n), 2n)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupMin: semigroup.Semigroup<bigint> = semigroup.min(Order)\n\n/**\n * A `Semigroup` that uses the maximum between two values.\n *\n * @example\n * import { SemigroupMax } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(SemigroupMax.combine(2n, 3n), 3n)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupMax: semigroup.Semigroup<bigint> = semigroup.max(Order)\n\n/**\n * `bigint` monoid under addition.\n *\n * The `empty` value is `0n`.\n *\n * @example\n * import { MonoidSum } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(MonoidSum.combine(2n, 3n), 5n)\n * assert.deepStrictEqual(MonoidSum.combine(2n, MonoidSum.empty), 2n)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidSum: monoid.Monoid<bigint> = monoid.bigintSum\n\n/**\n * `bigint` monoid under multiplication.\n *\n * The `empty` value is `1n`.\n *\n * @example\n * import { MonoidMultiply } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(MonoidMultiply.combine(2n, 3n), 6n)\n * assert.deepStrictEqual(MonoidMultiply.combine(2n, MonoidMultiply.empty), 2n)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidMultiply: monoid.Monoid<bigint> = monoid.bigintMultiply\n\n/**\n * Determines the sign of a given `bigint`.\n *\n * @param n - The `bigint` to determine the sign of.\n *\n * @example\n * import { sign } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(sign(-5n), -1)\n * assert.deepStrictEqual(sign(0n), 0)\n * assert.deepStrictEqual(sign(5n), 1)\n *\n * @category math\n * @since 1.0.0\n */\nexport const sign = (n: bigint): Ordering => Order.compare(n, 0n)\n\n/**\n * Takes an `Iterable` of `bigint`s and returns their sum as a single `bigint\n *\n * @param collection - The collection of `bigint`s to sum.\n *\n * @example\n * import { sumAll } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(sumAll([2n, 3n, 4n]), 9n)\n *\n * @category math\n * @since 1.0.0\n */\nexport const sumAll: (collection: Iterable<bigint>) => bigint = MonoidSum.combineAll\n\n/**\n * Takes an `Iterable` of `bigint`s and returns their multiplication as a single `number`.\n *\n * @param collection - The collection of `bigint`s to multiply.\n *\n * @example\n * import { multiplyAll } from '@fp-ts/core/Bigint'\n *\n * assert.deepStrictEqual(multiplyAll([2n, 3n, 4n]), 24n)\n *\n * @category math\n * @since 1.0.0\n */\nexport const multiplyAll: (collection: Iterable<bigint>) => bigint = MonoidMultiply.combineAll\n"
  },
  {
    "path": "src/Boolean.ts",
    "content": "/**\n * This module provides utility functions and type class instances for working with the `boolean` type in TypeScript.\n * It includes functions for basic boolean operations, as well as type class instances for\n * `Equivalence`, `Order`, `Semigroup`, and `Monoid`.\n *\n * @since 1.0.0\n */\nimport type { LazyArg } from \"@fp-ts/core/Function\"\nimport { dual, flow } from \"@fp-ts/core/Function\"\nimport * as predicate from \"@fp-ts/core/Predicate\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * Tests if a value is a `boolean`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isBoolean } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(isBoolean(true), true)\n * assert.deepStrictEqual(isBoolean(\"true\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isBoolean: (input: unknown) => input is boolean = predicate.isBoolean\n\n/**\n * This function returns the result of either of the given functions depending on the value of the boolean parameter.\n * It is useful when you have to run one of two functions depending on the boolean value.\n *\n * @param value - the boolean value that decides which function will be executed.\n * @param onFalse - a lazy evaluation function that will be executed when the `value` is `false`.\n * @param onTrue - a lazy evaluation function that will be executed when the `value` is `true`.\n *\n * @example\n * import * as B from \"@fp-ts/core/Boolean\"\n *\n * assert.deepStrictEqual(\n *  B.match(true, () => \"It's false!\", () => \"It's true!\"),\n *  \"It's true!\"\n * )\n *\n * @category pattern matching\n * @since 1.0.0\n */\nexport const match: {\n  <A, B = A>(onFalse: LazyArg<A>, onTrue: LazyArg<B>): (value: boolean) => A | B\n  <A, B>(value: boolean, onFalse: LazyArg<A>, onTrue: LazyArg<B>): A | B\n} = dual(\n  3,\n  <A, B>(value: boolean, onFalse: LazyArg<A>, onTrue: LazyArg<B>): A | B =>\n    value ? onTrue() : onFalse()\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Equivalence: equivalence.Equivalence<boolean> = equivalence.boolean\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Order: order.Order<boolean> = order.boolean\n\n/**\n * `boolean` semigroup under conjunction.\n *\n * @example\n * import { SemigroupAll } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(SemigroupAll.combine(true, true), true)\n * assert.deepStrictEqual(SemigroupAll.combine(true, false), false)\n * assert.deepStrictEqual(SemigroupAll.combine(false, true), false)\n * assert.deepStrictEqual(SemigroupAll.combine(false, false), false)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupAll: semigroup.Semigroup<boolean> = semigroup.booleanAll\n\n/**\n * `boolean` semigroup under disjunction.\n *\n * @example\n * import { SemigroupAny } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(SemigroupAny.combine(true, true), true)\n * assert.deepStrictEqual(SemigroupAny.combine(true, false), true)\n * assert.deepStrictEqual(SemigroupAny.combine(false, true), true)\n * assert.deepStrictEqual(SemigroupAny.combine(false, false), false)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupAny: semigroup.Semigroup<boolean> = semigroup.booleanAny\n\n/**\n * `boolean` semigroup under exclusive disjunction.\n *\n * @example\n * import { SemigroupXor } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(SemigroupXor.combine(true, true), false)\n * assert.deepStrictEqual(SemigroupXor.combine(true, false), true)\n * assert.deepStrictEqual(SemigroupXor.combine(false, true), true)\n * assert.deepStrictEqual(SemigroupXor.combine(false, false), false)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupXor: semigroup.Semigroup<boolean> = semigroup.booleanXor\n\n/**\n * `boolean` semigroup under equivalence.\n *\n * @example\n * import { SemigroupEqv } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(SemigroupEqv.combine(true, true), true)\n * assert.deepStrictEqual(SemigroupEqv.combine(true, false), false)\n * assert.deepStrictEqual(SemigroupEqv.combine(false, true), false)\n * assert.deepStrictEqual(SemigroupEqv.combine(false, false), true)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupEqv: semigroup.Semigroup<boolean> = semigroup.booleanEqv\n\n/**\n * `boolean` monoid under conjunction, see also {@link SemigroupAll}.\n *\n * The `empty` value is `true`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidAll: monoid.Monoid<boolean> = monoid.booleanAll\n\n/**\n * `boolean` monoid under disjunction, see also {@link SemigroupAny}.\n *\n * The `empty` value is `false`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidAny: monoid.Monoid<boolean> = monoid.booleanAny\n\n/**\n * `boolean` monoid under exclusive disjunction, see also {@link SemigroupXor}.\n *\n * The `empty` value is `false`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidXor: monoid.Monoid<boolean> = monoid.booleanXor\n\n/**\n * `boolean` monoid under equivalence.\n *\n * The `empty` value is `true`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidEqv: monoid.Monoid<boolean> = monoid.booleanEqv\n\n/**\n * Negates the given boolean: `!self`\n *\n * @example\n * import { not } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(not(true), false)\n * assert.deepStrictEqual(not(false), true)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const not = (self: boolean): boolean => !self\n\n/**\n * Combines two boolean using AND: `self && that`.\n *\n * @example\n * import { and } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(and(true, true), true)\n * assert.deepStrictEqual(and(true, false), false)\n * assert.deepStrictEqual(and(false, true), false)\n * assert.deepStrictEqual(and(false, false), false)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const and: {\n  (that: boolean): (self: boolean) => boolean\n  (self: boolean, that: boolean): boolean\n} = dual(2, semigroup.booleanAll.combine)\n\n/**\n * Combines two boolean using NAND: `!(self && that)`.\n *\n * @example\n * import { nand } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(nand(true, true), false)\n * assert.deepStrictEqual(nand(true, false), true)\n * assert.deepStrictEqual(nand(false, true), true)\n * assert.deepStrictEqual(nand(false, false), true)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const nand: {\n  (that: boolean): (self: boolean) => boolean\n  (self: boolean, that: boolean): boolean\n} = dual(2, flow(semigroup.booleanAll.combine, not))\n\n/**\n * Combines two boolean using OR: `self || that`.\n *\n * @example\n * import { or } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(or(true, true), true)\n * assert.deepStrictEqual(or(true, false), true)\n * assert.deepStrictEqual(or(false, true), true)\n * assert.deepStrictEqual(or(false, false), false)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const or: {\n  (that: boolean): (self: boolean) => boolean\n  (self: boolean, that: boolean): boolean\n} = dual(2, semigroup.booleanAny.combine)\n\n/**\n * Combines two booleans using NOR: `!(self || that)`.\n *\n * @example\n * import { nor } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(nor(true, true), false)\n * assert.deepStrictEqual(nor(true, false), false)\n * assert.deepStrictEqual(nor(false, true), false)\n * assert.deepStrictEqual(nor(false, false), true)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const nor: {\n  (that: boolean): (self: boolean) => boolean\n  (self: boolean, that: boolean): boolean\n} = dual(2, flow(semigroup.booleanAny.combine, not))\n\n/**\n * Combines two booleans using XOR: `(!self && that) || (self && !that)`.\n *\n * @example\n * import { xor } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(xor(true, true), false)\n * assert.deepStrictEqual(xor(true, false), true)\n * assert.deepStrictEqual(xor(false, true), true)\n * assert.deepStrictEqual(xor(false, false), false)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const xor: {\n  (that: boolean): (self: boolean) => boolean\n  (self: boolean, that: boolean): boolean\n} = dual(2, semigroup.booleanXor.combine)\n\n/**\n * Combines two booleans using EQV (aka XNOR): `!xor(self, that)`.\n *\n * @example\n * import { eqv } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(eqv(true, true), true)\n * assert.deepStrictEqual(eqv(true, false), false)\n * assert.deepStrictEqual(eqv(false, true), false)\n * assert.deepStrictEqual(eqv(false, false), true)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const eqv: {\n  (that: boolean): (self: boolean) => boolean\n  (self: boolean, that: boolean): boolean\n} = dual(2, semigroup.booleanEqv.combine)\n\n/**\n * Combines two booleans using an implication: `(!self || that)`.\n *\n * @example\n * import { implies } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(implies(true, true), true)\n * assert.deepStrictEqual(implies(true, false), false)\n * assert.deepStrictEqual(implies(false, true), true)\n * assert.deepStrictEqual(implies(false, false), true)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const implies: {\n  (that: boolean): (self: boolean) => boolean\n  (self: boolean, that: boolean): boolean\n} = dual(2, (self, that) => self ? that : true)\n\n/**\n * This utility function is used to check if all the elements in a collection of boolean values are `true`.\n *\n * @param collection - An iterable collection of booleans.\n *\n * @example\n * import { all } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(all([true, true, true]), true)\n * assert.deepStrictEqual(all([true, false, true]), false)\n *\n * @since 1.0.0\n */\nexport const all: (collection: Iterable<boolean>) => boolean = MonoidAll.combineAll\n\n/**\n * This utility function is used to check if at least one of the elements in a collection of boolean values is `true`.\n *\n * @param collection - An iterable collection of booleans.\n *\n * @example\n * import { any } from '@fp-ts/core/Boolean'\n *\n * assert.deepStrictEqual(any([true, false, true]), true)\n * assert.deepStrictEqual(any([false, false, false]), false)\n *\n * @since 1.0.0\n */\nexport const any: (collection: Iterable<boolean>) => boolean = MonoidAny.combineAll\n"
  },
  {
    "path": "src/Either.ts",
    "content": "/**\n * @since 1.0.0\n */\n\nimport type { LazyArg } from \"@fp-ts/core/Function\"\nimport { constNull, constUndefined, dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport { structural } from \"@fp-ts/core/internal/effect\"\nimport * as either from \"@fp-ts/core/internal/Either\"\nimport * as option from \"@fp-ts/core/internal/Option\"\nimport * as N from \"@fp-ts/core/Number\"\nimport type { Option } from \"@fp-ts/core/Option\"\nimport type { Predicate, Refinement } from \"@fp-ts/core/Predicate\"\nimport * as applicative from \"@fp-ts/core/typeclass/Applicative\"\nimport * as bicovariant from \"@fp-ts/core/typeclass/Bicovariant\"\nimport * as chainable from \"@fp-ts/core/typeclass/Chainable\"\nimport * as covariant from \"@fp-ts/core/typeclass/Covariant\"\nimport type { Equivalence } from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as flatMap_ from \"@fp-ts/core/typeclass/FlatMap\"\nimport * as foldable from \"@fp-ts/core/typeclass/Foldable\"\nimport * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport type * as monad from \"@fp-ts/core/typeclass/Monad\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\nimport * as of_ from \"@fp-ts/core/typeclass/Of\"\nimport type * as pointed from \"@fp-ts/core/typeclass/Pointed\"\nimport * as product_ from \"@fp-ts/core/typeclass/Product\"\nimport type * as semiAlternative from \"@fp-ts/core/typeclass/SemiAlternative\"\nimport * as semiApplicative from \"@fp-ts/core/typeclass/SemiApplicative\"\nimport * as semiCoproduct from \"@fp-ts/core/typeclass/SemiCoproduct\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\nimport * as traversable from \"@fp-ts/core/typeclass/Traversable\"\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport type Either<E, A> = Left<E> | Right<A>\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport interface Left<E> {\n  readonly _tag: \"Left\"\n  readonly left: E\n}\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport interface Right<A> {\n  readonly _tag: \"Right\"\n  readonly right: A\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface EitherTypeLambda extends TypeLambda {\n  readonly type: Either<this[\"Out1\"], this[\"Target\"]>\n}\n\n/**\n * Constructs a new `Either` holding a `Right` value. This usually represents a successful value due to the right bias\n * of this structure.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const right: <A>(a: A) => Either<never, A> = either.right\n\n/**\n * Constructs a new `Either` holding a `Left` value. This usually represents a failure, due to the right-bias of this\n * structure.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const left: <E>(e: E) => Either<E, never> = either.left\n\n/**\n * Alias of {@link right}.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const of: <A>(a: A) => Either<never, A> = right\n\n/**\n * Tests if a value is a `Either`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isEither, left, right } from '@fp-ts/core/Either'\n *\n * assert.deepStrictEqual(isEither(right(1)), true)\n * assert.deepStrictEqual(isEither(left(\"error\")), true)\n * assert.deepStrictEqual(isEither({ right: 1 }), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isEither = (input: unknown): input is Either<unknown, unknown> =>\n  typeof input === \"object\" && input != null && structural in input && \"_tag\" in input &&\n  (input[\"_tag\"] === \"Left\" || input[\"_tag\"] === \"Right\")\n\n/**\n * Determine if a `Either` is a `Left`.\n *\n * @param self - The `Either` to check.\n *\n * @example\n * import { isLeft, left, right } from '@fp-ts/core/Either'\n *\n * assert.deepStrictEqual(isLeft(right(1)), false)\n * assert.deepStrictEqual(isLeft(left(\"error\")), true)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isLeft: <E, A>(self: Either<E, A>) => self is Left<E> = either.isLeft\n\n/**\n * Determine if a `Either` is a `Right`.\n *\n * @param self - The `Either` to check.\n *\n * @example\n * import { isRight, left, right } from '@fp-ts/core/Either'\n *\n * assert.deepStrictEqual(isRight(right(1)), true)\n * assert.deepStrictEqual(isRight(left(\"error\")), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isRight: <E, A>(self: Either<E, A>) => self is Right<A> = either.isRight\n\n/**\n * Returns a `Refinement` from a `Either` returning function.\n * This function ensures that a `Refinement` definition is type-safe.\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const toRefinement = <A, E, B extends A>(f: (a: A) => Either<E, B>): Refinement<A, B> =>\n  (a: A): a is B => isRight(f(a))\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromIterable: {\n  <E>(onEmpty: LazyArg<E>): <A>(collection: Iterable<A>) => Either<E, A>\n  <A, E>(collection: Iterable<A>, onEmpty: LazyArg<E>): Either<E, A>\n} = dual(2, <A, E>(collection: Iterable<A>, onEmpty: LazyArg<E>): Either<E, A> => {\n  for (const a of collection) {\n    return right(a)\n  }\n  return left(onEmpty())\n})\n\n/**\n * Converts a `Either` to an `Option` discarding the error.\n *\n * @param self - The `Either` to convert to an `Option`.\n *\n * @example\n * import * as O from '@fp-ts/core/Option'\n * import * as E from '@fp-ts/core/Either'\n *\n * assert.deepStrictEqual(E.toOption(E.right(1)), O.some(1))\n * assert.deepStrictEqual(E.toOption(E.left('a')), O.none())\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const toOption: <E, A>(self: Either<E, A>) => Option<A> = either.getRight\n\n/**\n * Converts a `Either` to an `Option` discarding the error.\n *\n * Alias of {@link toOption}.\n *\n * @example\n * import * as O from '@fp-ts/core/Option'\n * import * as E from '@fp-ts/core/Either'\n *\n * assert.deepStrictEqual(E.getRight(E.right('ok')), O.some('ok'))\n * assert.deepStrictEqual(E.getRight(E.left('err')), O.none())\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const getRight: <E, A>(self: Either<E, A>) => Option<A> = toOption\n\n/**\n * Converts a `Either` to an `Option` discarding the value.\n *\n * @example\n * import * as O from '@fp-ts/core/Option'\n * import * as E from '@fp-ts/core/Either'\n *\n * assert.deepStrictEqual(E.getLeft(E.right('ok')), O.none())\n * assert.deepStrictEqual(E.getLeft(E.left('err')), O.some('err'))\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const getLeft: <E, A>(self: Either<E, A>) => Option<E> = either.getLeft\n\n/**\n * @example\n * import * as E from '@fp-ts/core/Either'\n * import * as O from '@fp-ts/core/Option'\n *\n * assert.deepStrictEqual(E.fromOption(O.some(1), () => 'error'), E.right(1))\n * assert.deepStrictEqual(E.fromOption(O.none(), () => 'error'), E.left('error'))\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const fromOption: {\n  <A, E>(fa: Option<A>, onNone: () => E): Either<E, A>\n  <E>(onNone: () => E): <A>(fa: Option<A>) => Either<E, A>\n} = either.fromOption\n\n/**\n * @category equivalence\n * @since 1.0.0\n */\nexport const getEquivalence = <E, A>(\n  EE: Equivalence<E>,\n  EA: Equivalence<A>\n): Equivalence<Either<E, A>> =>\n  equivalence.make((x, y) =>\n    x === y ||\n    (isLeft(x) ?\n      isLeft(y) && EE(x.left, y.left) :\n      isRight(y) && EA(x.right, y.right))\n  )\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const bimap: {\n  <E1, E2, A, B>(f: (e: E1) => E2, g: (a: A) => B): (self: Either<E1, A>) => Either<E2, B>\n  <E1, A, E2, B>(self: Either<E1, A>, f: (e: E1) => E2, g: (a: A) => B): Either<E2, B>\n} = dual(\n  3,\n  <E1, A, E2, B>(self: Either<E1, A>, f: (e: E1) => E2, g: (a: A) => B): Either<E2, B> =>\n    isLeft(self) ? left(f(self.left)) : right(g(self.right))\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Bicovariant: bicovariant.Bicovariant<EitherTypeLambda> = {\n  bimap\n}\n\n/**\n * Maps the `Left` side of an `Either` value to a new `Either` value.\n *\n * @param self - The input `Either` value to map.\n * @param f - A transformation function to apply to the `Left` value of the input `Either`.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const mapLeft: {\n  <E, G>(f: (e: E) => G): <A>(self: Either<E, A>) => Either<G, A>\n  <E, A, G>(self: Either<E, A>, f: (e: E) => G): Either<G, A>\n} = bicovariant.mapLeft(Bicovariant)\n\n/**\n * Maps the `Right` side of an `Either` value to a new `Either` value.\n *\n * @param self - An `Either` to map\n * @param f - The function to map over the value of the `Either`\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const map: {\n  <A, B>(f: (a: A) => B): <E>(self: Either<E, A>) => Either<E, B>\n  <E, A, B>(self: Either<E, A>, f: (a: A) => B): Either<E, B>\n} = dual(\n  2,\n  <E, A, B>(self: Either<E, A>, f: (a: A) => B): Either<E, B> =>\n    isRight(self) ? right(f(self.right)) : self\n)\n\nconst imap = covariant.imap<EitherTypeLambda>(map)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Covariant: covariant.Covariant<EitherTypeLambda> = {\n  imap,\n  map\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<EitherTypeLambda> = {\n  imap\n}\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const flap: {\n  <A, E, B>(a: A, self: Either<E, (a: A) => B>): Either<E, B>\n  <E, A, B>(self: Either<E, (a: A) => B>): (a: A) => Either<E, B>\n} = covariant.flap(Covariant)\n\n/**\n * Maps the Right value of this effect to the specified constant value.\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const as: {\n  <E, _, B>(self: Either<E, _>, b: B): Either<E, B>\n  <B>(b: B): <E, _>(self: Either<E, _>) => Either<E, B>\n} = covariant.as(Covariant)\n\n/**\n * Returns the effect Eithering from mapping the Right of this effect to unit.\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const asUnit: <E, _>(self: Either<E, _>) => Either<E, void> = covariant.asUnit(\n  Covariant\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Of: of_.Of<EitherTypeLambda> = {\n  of\n}\n\n/**\n * @since 1.0.0\n */\nexport const unit: Either<never, void> = of_.unit(Of)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Pointed: pointed.Pointed<EitherTypeLambda> = {\n  of,\n  imap,\n  map\n}\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMap: {\n  <A, E2, B>(f: (a: A) => Either<E2, B>): <E1>(self: Either<E1, A>) => Either<E1 | E2, B>\n  <E1, A, E2, B>(self: Either<E1, A>, f: (a: A) => Either<E2, B>): Either<E1 | E2, B>\n} = dual(\n  2,\n  <E1, A, E2, B>(self: Either<E1, A>, f: (a: A) => Either<E2, B>): Either<E1 | E2, B> =>\n    isLeft(self) ? self : f(self.right)\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const FlatMap: flatMap_.FlatMap<EitherTypeLambda> = {\n  flatMap\n}\n\n/**\n * @since 1.0.0\n */\nexport const flatten: <E1, E2, A>(self: Either<E1, Either<E2, A>>) => Either<E1 | E2, A> = flatMap_\n  .flatten(FlatMap)\n\n/**\n * @since 1.0.0\n */\nexport const andThen: {\n  <E1, _, E2, B>(self: Either<E1, _>, that: Either<E2, B>): Either<E1 | E2, B>\n  <E2, B>(that: Either<E2, B>): <E1, _>(self: Either<E1, _>) => Either<E2 | E1, B>\n} = flatMap_.andThen(FlatMap)\n\n/**\n * @since 1.0.0\n */\nexport const composeKleisliArrow: {\n  <A, E1, B, E2, C>(\n    afb: (a: A) => Either<E1, B>,\n    bfc: (b: B) => Either<E2, C>\n  ): (a: A) => Either<E1 | E2, C>\n  <B, E2, C>(\n    bfc: (b: B) => Either<E2, C>\n  ): <A, E1>(afb: (a: A) => Either<E1, B>) => (a: A) => Either<E2 | E1, C>\n} = flatMap_.composeKleisliArrow(FlatMap)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Chainable: chainable.Chainable<EitherTypeLambda> = {\n  imap,\n  map,\n  flatMap\n}\n\n/**\n * Sequences the specified effect after this effect, but ignores the value\n * produced by the effect.\n *\n * @category combining\n * @since 1.0.0\n */\nexport const andThenDiscard: {\n  <E1, A, E2, _>(self: Either<E1, A>, that: Either<E2, _>): Either<E1 | E2, A>\n  <E2, _>(that: Either<E2, _>): <E1, A>(self: Either<E1, A>) => Either<E2 | E1, A>\n} = chainable.andThenDiscard(Chainable)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Monad: monad.Monad<EitherTypeLambda> = {\n  imap,\n  of,\n  map,\n  flatMap\n}\n\nconst product = <E1, A, E2, B>(self: Either<E1, A>, that: Either<E2, B>): Either<E1 | E2, [A, B]> =>\n  isRight(self) ? (isRight(that) ? right([self.right, that.right]) : that) : self\n\nconst productMany = <E, A>(\n  self: Either<E, A>,\n  collection: Iterable<Either<E, A>>\n): Either<E, [A, ...Array<A>]> => {\n  if (isLeft(self)) {\n    return self\n  }\n  const out: [A, ...Array<A>] = [self.right]\n  for (const e of collection) {\n    if (isLeft(e)) {\n      return e\n    }\n    out.push(e.right)\n  }\n  return right(out)\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiProduct: semiProduct.SemiProduct<EitherTypeLambda> = {\n  imap,\n  product,\n  productMany\n}\n\n/**\n * Similar to `Promise.all` but operates on `Either`s.\n *\n * ```\n * Iterable<Either<E, A>> -> Either<E, A[]>\n * ```\n *\n * Flattens a collection of `Either`s into a single `Either` that contains a list of all the `Right` values.\n * If there is a `Left` value in the collection, it returns the first `Left` found as the result.\n *\n * @param collection - An iterable collection of `Either`s to flatten.\n *\n * @example\n * import * as E from \"@fp-ts/core/Either\"\n *\n * assert.deepStrictEqual(E.all([E.right(1), E.right(2), E.right(3)]), E.right([1, 2, 3]))\n * assert.deepStrictEqual(E.all([E.right(1), E.left(\"error\"), E.right(3)]), E.left(\"error\"))\n *\n * @category combining\n * @since 1.0.0\n */\nexport const all = <E, A>(\n  collection: Iterable<Either<E, A>>\n): Either<E, Array<A>> => {\n  const out: Array<A> = []\n  for (const e of collection) {\n    if (isLeft(e)) {\n      return e\n    }\n    out.push(e.right)\n  }\n  return right(out)\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Product: product_.Product<EitherTypeLambda> = {\n  of,\n  imap,\n  product,\n  productMany,\n  productAll: all\n}\n\n/**\n * Similar to `Promise.all` but operates on `Either`s.\n *\n * ```\n * [Either<E1, A>, Either<E1, B>, ...] -> Either<E1 \\| E2 \\| ..., [A, B, ...]>\n * ```\n *\n * @since 1.0.0\n */\nexport const tuple: <T extends ReadonlyArray<Either<any, any>>>(\n  ...elements: T\n) => Either<\n  [T[number]] extends [Either<infer E, any>] ? E : never,\n  { [I in keyof T]: [T[I]] extends [Either<any, infer A>] ? A : never }\n> = product_.tuple(Product)\n\n/**\n * @since 1.0.0\n */\nexport const struct: <R extends Record<string, Either<any, any>>>(\n  fields: R\n) => Either<\n  [R[keyof R]] extends [Either<infer E, any>] ? E : never,\n  { [K in keyof R]: [R[K]] extends [Either<any, infer A>] ? A : never }\n> = product_.struct(Product)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiApplicative: semiApplicative.SemiApplicative<EitherTypeLambda> = {\n  imap,\n  map,\n  product,\n  productMany\n}\n\n/**\n * Lifts a binary function into `Either`.\n *\n * @param f - The function to lift.\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const lift2: <A, B, C>(f: (a: A, b: B) => C) => {\n  <E1, E2>(self: Either<E1, A>, that: Either<E2, B>): Either<E1 | E2, C>\n  <E2>(that: Either<E2, B>): <E1>(self: Either<E1, A>) => Either<E2 | E1, C>\n} = semiApplicative.lift2(SemiApplicative)\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const zipWith: {\n  <E1, A, E2, B, C>(\n    self: Either<E1, A>,\n    that: Either<E2, B>,\n    f: (a: A, b: B) => C\n  ): Either<E1 | E2, C>\n  <E2, B, A, C>(\n    that: Either<E2, B>,\n    f: (a: A, b: B) => C\n  ): <E1>(self: Either<E1, A>) => Either<E2 | E1, C>\n} = semiApplicative.zipWith(SemiApplicative)\n\n/**\n * @since 1.0.0\n */\nexport const ap: {\n  <E1, A, B, E2>(self: Either<E1, (a: A) => B>, that: Either<E2, A>): Either<E1 | E2, B>\n  <E2, A>(that: Either<E2, A>): <E1, B>(self: Either<E1, (a: A) => B>) => Either<E2 | E1, B>\n} = semiApplicative.ap(SemiApplicative)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Applicative: applicative.Applicative<EitherTypeLambda> = {\n  imap,\n  of,\n  map,\n  product,\n  productMany,\n  productAll: all\n}\n\n/**\n * `Semigroup` returning the left-most `Left` value. If both operands are `Right`s then the inner values\n * are combined using the provided `Semigroup`.\n *\n * ```\n * | self       | that       | combine(self, that)     |\n * | ---------- | ---------- | ----------------------- |\n * | left(e1)   | left(e2)   | left(e1)                |\n * | left(e1)   | right(a2)  | left(e1)                |\n * | right(a1)  | left(e2)   | left(e2)                |\n * | right(a1)  | right(a2)  | right(combine(a1, a2))  |\n * ```\n *\n * @category combining\n * @since 1.0.0\n */\nexport const getFirstLeftSemigroup: <A, E>(S: Semigroup<A>) => Semigroup<Either<E, A>> =\n  semiApplicative.getSemigroup(SemiApplicative)\n\n/**\n * `Monoid` returning the left-most `Left` value. If both operands are `Right`s then the inner values\n * are combined using the provided `Monoid`.\n *\n * - `combine` is provided by {@link getFirstLeftSemigroup}.\n * - `empty` is `right(M.empty)`\n *\n * @category combining\n * @since 1.0.0\n */\nexport const getFirstLeftMonoid: <A, E>(M: Monoid<A>) => Monoid<Either<E, A>> = applicative\n  .getMonoid(Applicative)\n\nconst coproduct = <E1, A, E2, B>(\n  self: Either<E1, A>,\n  that: Either<E2, B>\n): Either<E1 | E2, A | B> => isRight(self) ? self : that\n\nconst coproductMany = <E, A>(\n  self: Either<E, A>,\n  collection: Iterable<Either<E, A>>\n): Either<E, A> => {\n  let out = self\n  if (isRight(out)) {\n    return out\n  }\n  for (out of collection) {\n    if (isRight(out)) {\n      return out\n    }\n  }\n  return out\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiCoproduct: semiCoproduct.SemiCoproduct<EitherTypeLambda> = {\n  imap,\n  coproduct,\n  coproductMany\n}\n\n/**\n * @category error handling\n * @since 1.0.0\n */\nexport const firstRightOf: {\n  <E, A>(collection: Iterable<Either<E, A>>): (self: Either<E, A>) => Either<E, A>\n  <E, A>(self: Either<E, A>, collection: Iterable<Either<E, A>>): Either<E, A>\n} = dual(2, coproductMany)\n\n/**\n * Semigroup returning the left-most `Right` value.\n *\n * ```\n * | self       | that       | combine(self, that) |\n * | ---------- | ---------- | ------------------- |\n * | left(e1)   | left(e2)   | left(e2)            |\n * | left(e1)   | right(a2)  | right(a2)           |\n * | right(a1)  | left(e2)   | right(a1)           |\n * | right(a1)  | right(a2)  | right(a1)           |\n * ```\n *\n * @category combining\n * @since 1.0.0\n */\nexport const getFirstRightSemigroup: <E, A>() => Semigroup<Either<E, A>> = semiCoproduct\n  .getSemigroup(SemiCoproduct)\n\n/**\n * Returns the wrapped value if it's a `Right` or a default value if is a `Left`.\n *\n * @example\n * import * as E from '@fp-ts/core/Either'\n * import { pipe } from '@fp-ts/core/Function'\n *\n * assert.deepStrictEqual(\n *   E.getOrElse(E.right(1), () => 0),\n *   1\n * )\n * assert.deepStrictEqual(\n *   E.getOrElse(E.left('error'), () => 0),\n *   0\n * )\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getOrElse: {\n  <E, B>(onLeft: (e: E) => B): <A>(self: Either<E, A>) => B | A\n  <E, A, B>(self: Either<E, A>, onLeft: (e: E) => B): A | B\n} = dual(\n  2,\n  <E, A, B>(self: Either<E, A>, onLeft: (e: E) => B): A | B =>\n    isLeft(self) ? onLeft(self.left) : self.right\n)\n\n/**\n * Executes this effect and returns its value, if it succeeds, but otherwise\n * executes the specified effect.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const orElse: {\n  <E1, E2, B>(that: (e1: E1) => Either<E2, B>): <A>(self: Either<E1, A>) => Either<E2, A | B>\n  <E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, A | B>\n} = dual(\n  2,\n  <E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, A | B> =>\n    isLeft(self) ? that(self.left) : self\n)\n\n/**\n * Returns an effect that will produce the value of this effect, unless it\n * fails, in which case, it will produce the value of the specified effect.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const orElseEither: {\n  <E1, E2, B>(that: (e1: E1) => Either<E2, B>): <A>(self: Either<E1, A>) => Either<E2, Either<A, B>>\n  <E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, Either<A, B>>\n} = dual(\n  2,\n  <E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, Either<A, B>> =>\n    isLeft(self) ?\n      map(that(self.left), right) :\n      map(self, left)\n)\n\n/**\n * Executes this effect and returns its value, if it succeeds, but otherwise\n * fails with the specified error.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const orElseFail: {\n  <E2>(onLeft: LazyArg<E2>): <E1, A>(self: Either<E1, A>) => Either<E2, A>\n  <E1, A, E2>(self: Either<E1, A>, onLeft: LazyArg<E2>): Either<E2, A>\n} = dual(\n  2,\n  <E1, A, E2>(self: Either<E1, A>, onLeft: LazyArg<E2>): Either<E2, A> =>\n    orElse(self, () => left(onLeft()))\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiAlternative: semiAlternative.SemiAlternative<EitherTypeLambda> = {\n  map,\n  imap,\n  coproduct,\n  coproductMany: firstRightOf\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Foldable: foldable.Foldable<EitherTypeLambda> = {\n  reduce: dual(\n    3,\n    <E, A, B>(self: Either<E, A>, b: B, f: (b: B, a: A) => B): B =>\n      isLeft(self) ? b : f(b, self.right)\n  )\n}\n\n/**\n * Transforms an `Either` into an `Array`.\n * If the input is `Left`, an empty array is returned.\n * If the input is `Right`, the value is wrapped in an array.\n *\n * @param self - The `Either` to convert to an array.\n *\n * @example\n * import { right, left, toArray } from '@fp-ts/core/Either'\n *\n * assert.deepStrictEqual(toArray(right(1)), [1])\n * assert.deepStrictEqual(toArray(left(\"error\")), [])\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const toArray: <E, A>(self: Either<E, A>) => Array<A> = foldable.toArray(Foldable)\n\n/**\n * Takes two functions and an `Either` value, if the value is a `Left` the inner value is applied to the first function,\n * if the value is a `Right` the inner value is applied to the second function.\n *\n * @example\n * import * as E from '@fp-ts/core/Either'\n * import { pipe } from '@fp-ts/core/Function'\n *\n * const onLeft  = (errors: ReadonlyArray<string>): string => `Errors: ${errors.join(', ')}`\n *\n * const onRight = (value: number): string => `Ok: ${value}`\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     E.right(1),\n *     E.match(onLeft , onRight)\n *   ),\n *   'Ok: 1'\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.left(['error 1', 'error 2']),\n *     E.match(onLeft , onRight)\n *   ),\n *   'Errors: error 1, error 2'\n * )\n *\n * @category pattern matching\n * @since 1.0.0\n */\nexport const match: {\n  <E, B, A, C = B>(onLeft: (e: E) => B, onRight: (a: A) => C): (self: Either<E, A>) => B | C\n  <E, A, B, C = B>(self: Either<E, A>, onLeft: (e: E) => B, onRight: (a: A) => C): B | C\n} = dual(\n  3,\n  <E, A, B, C = B>(self: Either<E, A>, onLeft: (e: E) => B, onRight: (a: A) => C): B | C =>\n    isLeft(self) ? onLeft(self.left) : onRight(self.right)\n)\n\n/**\n * Takes a lazy default and a nullable value, if the value is not nully, turn it into a `Right`, if the value is nully use\n * the provided default as a `Left`.\n *\n * @example\n * import * as E from '@fp-ts/core/Either'\n *\n * const parse = E.fromNullable(() => 'nullable')\n *\n * assert.deepStrictEqual(parse(1), E.right(1))\n * assert.deepStrictEqual(parse(null), E.left('nullable'))\n *\n * @category interop\n * @since 1.0.0\n */\nexport const fromNullable: {\n  <A, E>(onNullable: (a: A) => E): (a: A) => Either<E, NonNullable<A>>\n  <A, E>(a: A, onNullable: (a: A) => E): Either<E, NonNullable<A>>\n} = dual(\n  2,\n  <A, E>(a: A, onNullable: (a: A) => E): Either<E, NonNullable<A>> =>\n    a == null ? left(onNullable(a)) : right(a as NonNullable<A>)\n)\n\n/**\n * @category interop\n * @since 1.0.0\n */\nexport const liftNullable = <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => B | null | undefined,\n  onNullable: (...a: A) => E\n) => (...a: A): Either<E, NonNullable<B>> => fromNullable(f(...a), () => onNullable(...a))\n\n/**\n * @category interop\n * @since 1.0.0\n */\nexport const merge: <E, A>(self: Either<E, A>) => E | A = match(identity, identity)\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMapNullable: {\n  <A, B, E2>(\n    f: (a: A) => B | null | undefined,\n    onNullable: (a: A) => E2\n  ): <E1>(self: Either<E1, A>) => Either<E1 | E2, NonNullable<B>>\n  <E1, A, B, E2>(\n    self: Either<E1, A>,\n    f: (a: A) => B | null | undefined,\n    onNullable: (a: A) => E2\n  ): Either<E1 | E2, NonNullable<B>>\n} = dual(3, <E1, A, B, E2>(\n  self: Either<E1, A>,\n  f: (a: A) => B | null | undefined,\n  onNullable: (a: A) => E2\n): Either<E1 | E2, NonNullable<B>> => flatMap(self, liftNullable(f, onNullable)))\n\n/**\n * Extracts the value of an `Either` or throws if the `Either` is `Left`.\n *\n * If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.\n *\n * @param self - The `Either` to extract the value from.\n * @param onLeft - A function that will be called if the `Either` is `Left`. It returns the error to be thrown.\n *\n * @example\n * import * as E from \"@fp-ts/core/Either\"\n *\n * assert.deepStrictEqual(\n *   E.getOrThrowWith(E.right(1), () => new Error('Unexpected Left')),\n *   1\n * )\n * assert.throws(() => E.getOrThrowWith(E.left(\"error\"), () => new Error('Unexpected Left')))\n *\n * @category interop\n * @since 1.0.0\n */\nexport const getOrThrowWith: {\n  <E>(onLeft: (e: E) => unknown): <A>(self: Either<E, A>) => A\n  <E, A>(self: Either<E, A>, onLeft: (e: E) => unknown): A\n} = dual(2, <E, A>(self: Either<E, A>, onLeft: (e: E) => unknown): A => {\n  if (isRight(self)) {\n    return self.right\n  }\n  throw onLeft(self.left)\n})\n\n/**\n * Extracts the value of an `Either` or throws if the `Either` is `Left`.\n *\n * The thrown error is a default error. To configure the error thrown, see  {@link getOrThrowWith}.\n *\n * @param self - The `Either` to extract the value from.\n * @throws `Error(\"getOrThrow called on a Left\")`\n *\n * @example\n * import * as E from \"@fp-ts/core/Either\"\n *\n * assert.deepStrictEqual(E.getOrThrow(E.right(1)), 1)\n * assert.throws(() => E.getOrThrow(E.left(\"error\")))\n *\n * @category interop\n * @since 1.0.0\n */\nexport const getOrThrow: <E, A>(self: Either<E, A>) => A = getOrThrowWith(() =>\n  new Error(\"getOrThrow called on a Left\")\n)\n\n/**\n * Lifts a function that may throw to one returning a `Either`.\n *\n * @category interop\n * @since 1.0.0\n */\nexport const liftThrowable = <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => B,\n  onThrow: (error: unknown) => E\n): ((...a: A) => Either<E, B>) =>\n  (...a) => {\n    try {\n      return right(f(...a))\n    } catch (e) {\n      return left(onThrow(e))\n    }\n  }\n\n/**\n * @since 1.0.0\n */\nexport const reverse = <E, A>(self: Either<E, A>): Either<A, E> =>\n  isLeft(self) ? right(self.left) : left(self.right)\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const filter: {\n  <C extends A, B extends A, E2, A = C>(refinement: Refinement<A, B>, onFalse: LazyArg<E2>): <E1>(\n    self: Either<E1, C>\n  ) => Either<E1 | E2, B>\n  <B extends A, E2, A = B>(\n    predicate: Predicate<A>,\n    onFalse: LazyArg<E2>\n  ): <E1>(self: Either<E1, B>) => Either<E1 | E2, B>\n  <E1, C extends A, B extends A, E2, A = C>(\n    self: Either<E1, C>,\n    refinement: Refinement<A, B>,\n    onFalse: LazyArg<E2>\n  ): Either<E1 | E2, B>\n  <E1, B extends A, E2, A = B>(\n    self: Either<E1, B>,\n    predicate: Predicate<A>,\n    onFalse: LazyArg<E2>\n  ): Either<E1 | E2, B>\n} = dual(3, <E1, B extends A, E2, A = B>(\n  self: Either<E1, B>,\n  predicate: Predicate<A>,\n  onFalse: LazyArg<E2>\n): Either<E1 | E2, B> => isLeft(self) ? self : predicate(self.right) ? self : left(onFalse()))\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const filterMap: {\n  <A, B, E2>(\n    f: (a: A) => Option<B>,\n    onNone: LazyArg<E2>\n  ): <E1>(self: Either<E1, A>) => Either<E1 | E2, B>\n  <E1, A, B, E2>(\n    self: Either<E1, A>,\n    f: (a: A) => Option<B>,\n    onNone: LazyArg<E2>\n  ): Either<E1 | E2, B>\n} = dual(3, <E1, A, B, E2>(\n  self: Either<E1, A>,\n  f: (a: A) => Option<B>,\n  onNone: LazyArg<E2>\n): Either<E1 | E2, B> =>\n  flatMap(self, (a) => {\n    const ob = f(a)\n    return option.isNone(ob) ? left(onNone()) : right(ob.value)\n  }))\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const compact: {\n  <E2>(onNone: LazyArg<E2>): <E1, A>(self: Either<E1, Option<A>>) => Either<E1 | E2, A>\n  <E1, A, E2>(self: Either<E1, Option<A>>, onNone: LazyArg<E2>): Either<E1 | E2, A>\n} = dual(\n  2,\n  <E1, A, E2>(self: Either<E1, Option<A>>, onNone: LazyArg<E2>): Either<E1 | E2, A> =>\n    filterMap(self, identity, onNone)\n)\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const traverse = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): {\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): <TE>(self: Either<TE, A>) => Kind<F, R, O, E, Either<TE, B>>\n  <TE, A, R, O, E, B>(\n    self: Either<TE, A>,\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Either<TE, B>>\n} =>\n  dual(2, <TE, A, R, O, E, B>(\n    self: Either<TE, A>,\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Either<TE, B>> =>\n    isLeft(self) ?\n      F.of<Either<TE, B>>(self) :\n      F.map<R, O, E, B, Either<TE, B>>(f(self.right), right))\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Traversable: traversable.Traversable<EitherTypeLambda> = {\n  traverse\n}\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const sequence: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => <TE, R, O, E, A>(\n  self: Either<TE, Kind<F, R, O, E, A>>\n) => Kind<F, R, O, E, Either<TE, A>> = traversable.sequence(Traversable)\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <TE, A, R, O, E, B>(\n    self: Either<TE, A>,\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Either<TE, A>>\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): <TE>(self: Either<TE, A>) => Kind<F, R, O, E, Either<TE, A>>\n} = traversable.traverseTap(Traversable)\n\n/**\n * Returns an effect that effectfully \"peeks\" at the success of this effect.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const tap: {\n  <E1, A, E2, _>(self: Either<E1, A>, f: (a: A) => Either<E2, _>): Either<E1 | E2, A>\n  <A, E2, _>(f: (a: A) => Either<E2, _>): <E1>(self: Either<E1, A>) => Either<E2 | E1, A>\n} = chainable.tap(Chainable)\n\n/**\n * @category debugging\n * @since 1.0.0\n */\nexport const inspectRight: {\n  <A>(onRight: (a: A) => void): <E>(self: Either<E, A>) => Either<E, A>\n  <E, A>(self: Either<E, A>, onRight: (a: A) => void): Either<E, A>\n} = dual(2, <E, A>(self: Either<E, A>, onRight: (a: A) => void): Either<E, A> => {\n  if (isRight(self)) {\n    onRight(self.right)\n  }\n  return self\n})\n\n/**\n * @category debugging\n * @since 1.0.0\n */\nexport const inspectLeft: {\n  <E>(onLeft: (e: E) => void): <A>(self: Either<E, A>) => Either<E, A>\n  <E, A>(self: Either<E, A>, onLeft: (e: E) => void): Either<E, A>\n} = dual(2, <E, A>(self: Either<E, A>, onLeft: (e: E) => void): Either<E, A> => {\n  if (isLeft(self)) {\n    onLeft(self.left)\n  }\n  return self\n})\n\n/**\n * Returns an effect that effectfully \"peeks\" at the failure of this effect.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const tapError: {\n  <E1, E2, _>(onLeft: (e: E1) => Either<E2, _>): <A>(self: Either<E1, A>) => Either<E1 | E2, A>\n  <E1, A, E2, _>(self: Either<E1, A>, onLeft: (e: E1) => Either<E2, _>): Either<E1 | E2, A>\n} = dual(\n  2,\n  <E1, A, E2, _>(self: Either<E1, A>, onLeft: (e: E1) => Either<E2, _>): Either<E1 | E2, A> => {\n    if (isRight(self)) {\n      return self\n    }\n    const out = onLeft(self.left)\n    return isLeft(out) ? out : self\n  }\n)\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const getOrNull: <E, A>(self: Either<E, A>) => A | null = getOrElse(constNull)\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const getOrUndefined: <E, A>(self: Either<E, A>) => A | undefined = getOrElse(constUndefined)\n\n/**\n * @example\n * import { liftPredicate, left, right } from '@fp-ts/core/Either'\n * import { pipe } from '@fp-ts/core/Function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     1,\n *     liftPredicate((n) => n > 0, () => 'error')\n *   ),\n *   right(1)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     -1,\n *     liftPredicate((n) => n > 0, () => 'error')\n *   ),\n *   left('error')\n * )\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const liftPredicate: {\n  <C extends A, B extends A, E, A = C>(\n    refinement: Refinement<A, B>,\n    onFalse: (c: C) => E\n  ): (c: C) => Either<E, B>\n  <B extends A, E, A = B>(predicate: Predicate<A>, onFalse: (b: B) => E): (b: B) => Either<E, B>\n} = <B extends A, E, A = B>(predicate: Predicate<A>, onFalse: (b: B) => E) =>\n  (b: B) => predicate(b) ? right(b) : left(onFalse(b))\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftOption = <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => Option<B>,\n  onNone: (...a: A) => E\n) => (...a: A): Either<E, B> => fromOption(() => onNone(...a))(f(...a))\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMapOption: {\n  <A, B, E2>(\n    f: (a: A) => Option<B>,\n    onNone: (a: A) => E2\n  ): <E1>(self: Either<E1, A>) => Either<E1 | E2, B>\n  <E1, A, B, E2>(\n    self: Either<E1, A>,\n    f: (a: A) => Option<B>,\n    onNone: (a: A) => E2\n  ): Either<E1 | E2, B>\n} = dual(3, <E1, A, B, E2>(\n  self: Either<E1, A>,\n  f: (a: A) => Option<B>,\n  onNone: (a: A) => E2\n): Either<E1 | E2, B> => flatMap(self, liftOption(f, onNone)))\n\n/**\n * Returns a function that checks if an `Either` contains a given value using a provided `equivalence` function.\n *\n * @since 1.0.0\n */\nexport const contains = <A>(isEquivalent: (self: A, that: A) => boolean): {\n  (a: A): <E>(self: Either<E, A>) => boolean\n  <E>(self: Either<E, A>, a: A): boolean\n} =>\n  dual(\n    2,\n    <E>(self: Either<E, A>, a: A): boolean => isLeft(self) ? false : isEquivalent(self.right, a)\n  )\n\n/**\n * Returns `false` if `Left` or returns the Either of the application of the given predicate to the `Right` value.\n *\n * @example\n * import * as E from '@fp-ts/core/Either'\n *\n * const f = E.exists((n: number) => n > 2)\n *\n * assert.deepStrictEqual(f(E.left('a')), false)\n * assert.deepStrictEqual(f(E.right(1)), false)\n * assert.deepStrictEqual(f(E.right(3)), true)\n *\n * @since 1.0.0\n */\nexport const exists: {\n  <A>(predicate: Predicate<A>): <E>(self: Either<E, A>) => boolean\n  <E, A>(self: Either<E, A>, predicate: Predicate<A>): boolean\n} = dual(\n  2,\n  <E, A>(self: Either<E, A>, predicate: Predicate<A>): boolean =>\n    isLeft(self) ? false : predicate(self.right)\n)\n\n/**\n * Semigroup that models the combination of values that may be absent, elements that are `Left` are ignored\n * while elements that are `Right` are combined using the provided `Semigroup`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const getOptionalSemigroup = <E, A>(S: Semigroup<A>): Semigroup<Either<E, A>> =>\n  semigroup.make((\n    x,\n    y\n  ) => (isLeft(y) ? x : isLeft(x) ? y : right(S.combine(x.right, y.right))))\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const sum: {\n  <E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>\n  <E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>\n} = lift2(N.sum)\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const multiply: {\n  <E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>\n  <E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>\n} = lift2(N.multiply)\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const subtract: {\n  <E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>\n  <E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>\n} = lift2(N.subtract)\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const divide: {\n  <E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>\n  <E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>\n} = lift2(N.divide)\n\n/**\n * Return all the `Right` elements from an `Interable` of `Either`s.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const rights = <E, A>(self: Iterable<Either<E, A>>): Array<A> => {\n  const out: Array<A> = []\n  for (const a of self) {\n    if (isRight(a)) {\n      out.push(a.right)\n    }\n  }\n  return out\n}\n\n/**\n * Return all the `Left` elements from an `Interable` of `Either`s.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const lefts = <E, A>(self: Iterable<Either<E, A>>): Array<E> => {\n  const out: Array<E> = []\n  for (const a of self) {\n    if (isLeft(a)) {\n      out.push(a.left)\n    }\n  }\n  return out\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const tupled: <E, A>(self: Either<E, A>) => Either<E, [A]> = invariant.tupled(\n  Invariant\n)\n\n/**\n * Appends an element to the end of a tuple.\n *\n * @category do notation\n * @since 1.0.0\n */\nexport const appendElement: {\n  <E1, A extends ReadonlyArray<any>, E2, B>(\n    self: Either<E1, A>,\n    that: Either<E2, B>\n  ): Either<E1 | E2, [...A, B]>\n  <E2, B>(\n    that: Either<E2, B>\n  ): <E1, A extends ReadonlyArray<any>>(self: Either<E1, A>) => Either<E2 | E1, [...A, B]>\n} = semiProduct.appendElement(SemiProduct)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bindTo: {\n  <N extends string>(\n    name: N\n  ): <E, A>(self: Either<E, A>) => Either<E, { [K in N]: A }>\n  <E, A, N extends string>(self: Either<E, A>, name: N): Either<E, { [K in N]: A }>\n} = invariant.bindTo(Invariant)\n\nconst let_: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): <E>(\n    self: Either<E, A>\n  ) => Either<E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E, A extends object, N extends string, B>(\n    self: Either<E, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): Either<E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = covariant.let(Covariant)\n\nexport {\n  /**\n   * @category do notation\n   * @since 1.0.0\n   */\n  let_ as let\n}\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const Do: Either<never, {}> = of_.Do(Of)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bind: {\n  <N extends string, A extends object, E2, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Either<E2, B>\n  ): <E1>(\n    self: Either<E1, A>\n  ) => Either<E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: Either<E1, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Either<E2, B>\n  ): Either<E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = chainable.bind(Chainable)\n\n/**\n * Extends the `Either` value with the value of another `Either` type.\n *\n * If both `Either` instances are `Left`, then the result will be the first `Left`.\n *\n * @param self - The original `Either` value.\n * @param name - The name of the property that will be added to the original `Either` type.\n * @param that - The `Either` value that will be added to the original `Either` type.\n *\n * @example\n * import * as E from '@fp-ts/core/Either'\n * import { pipe } from '@fp-ts/core/Function'\n *\n * const result = pipe(\n *   E.Do,\n *   E.bind(\"a\", () => E.left(\"e1\")),\n *   E.andThenBind(\"b\", E.left(\"e2\"))\n * )\n *\n * assert.deepStrictEqual(result, E.left(\"e1\"))\n *\n * @category do notation\n * @since 1.0.0\n */\nexport const andThenBind: {\n  <N extends string, A extends object, E2, B>(\n    name: Exclude<N, keyof A>,\n    that: Either<E2, B>\n  ): <E1>(\n    self: Either<E1, A>\n  ) => Either<E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: Either<E1, A>,\n    name: Exclude<N, keyof A>,\n    that: Either<E2, B>\n  ): Either<E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = semiProduct.andThenBind(SemiProduct)\n"
  },
  {
    "path": "src/Function.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface FunctionTypeLambda extends TypeLambda {\n  readonly type: (a: this[\"In\"]) => this[\"Target\"]\n}\n\n/**\n * Tests if a value is a `function`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isFunction } from '@fp-ts/core/Predicate'\n *\n * assert.deepStrictEqual(isFunction(isFunction), true)\n * assert.deepStrictEqual(isFunction(\"function\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isFunction = (input: unknown): input is Function => typeof input === \"function\"\n\n/**\n * Creates a function that can be used in a data-last (aka `pipe`able) or data-first style.\n *\n * @param arity - The arity of the uncurried function.\n * @param body - The definition of the uncurried function.\n *\n * @example\n * import { dual, pipe } from \"@fp-ts/core/Function\"\n *\n * export const sum: {\n *   (that: number): (self: number) => number\n *   (self: number, that: number): number\n * } = dual(2, (self: number, that: number): number => self + that)\n *\n * assert.deepStrictEqual(sum(2, 3), 5)\n * assert.deepStrictEqual(pipe(2, sum(3)), 5)\n *\n * @since 1.0.0\n */\nexport const dual = <\n  DataLast extends (...args: Array<any>) => any,\n  DataFirst extends (...args: Array<any>) => any\n>(\n  arity: Parameters<DataFirst>[\"length\"],\n  body: DataFirst\n): DataLast & DataFirst => {\n  // @ts-expect-error\n  return function() {\n    if (arguments.length >= arity) {\n      // @ts-expect-error\n      return body.apply(this, arguments)\n    }\n    return ((self: any) => body(self, ...arguments)) as any\n  }\n}\n\n/**\n * Apply a function to a given value.\n *\n * @param a - The value that the function will be applied to.\n * @param self - The function to be applied to a value.\n *\n * @example\n * import { pipe, apply } from \"@fp-ts/core/Function\"\n * import { length } from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(pipe(length, apply(\"hello\")), 5)\n *\n * @since 1.0.0\n */\nexport const apply = <A>(a: A) => <B>(self: (a: A) => B): B => self(a)\n\n/**\n * A lazy argument.\n *\n * @example\n * import { LazyArg, constant } from \"@fp-ts/core/Function\"\n *\n * export const constNull: LazyArg<null> = constant(null)\n *\n * @since 1.0.0\n */\nexport interface LazyArg<A> {\n  (): A\n}\n\n/**\n * @example\n * import { FunctionN } from \"@fp-ts/core/Function\"\n *\n * export const sum: FunctionN<[number, number], number> = (a, b) => a + b\n *\n * @since 1.0.0\n */\nexport interface FunctionN<A extends ReadonlyArray<unknown>, B> {\n  (...args: A): B\n}\n\n/**\n * The identity function, i.e. A function that returns its input argument.\n *\n * @param a - The input argument.\n *\n * @example\n * import { identity } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(identity(5), 5)\n *\n * @since 1.0.0\n */\nexport const identity = <A>(a: A): A => a\n\n/**\n * Casts the result to the specified type.\n *\n * @param a - The value to be casted to the target type.\n *\n * @example\n * import { unsafeCoerce, identity } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(unsafeCoerce, identity)\n *\n * @since 1.0.0\n */\nexport const unsafeCoerce: <A, B>(a: A) => B = identity as any\n\n/**\n * Creates a constant value that never changes.\n *\n * This is useful when you want to pass a value to a higher-order function (a function that takes another function as its argument)\n * and want that inner function to always use the same value, no matter how many times it is called.\n *\n * @param value - The constant value to be returned.\n *\n * @example\n * import { constant } from \"@fp-ts/core/Function\"\n *\n * const constNull = constant(null)\n *\n * assert.deepStrictEqual(constNull(), null)\n * assert.deepStrictEqual(constNull(), null)\n *\n * @since 1.0.0\n */\nexport const constant = <A>(value: A): LazyArg<A> => () => value\n\n/**\n * A thunk that returns always `true`.\n *\n * @example\n * import { constTrue } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(constTrue(), true)\n *\n * @since 1.0.0\n */\nexport const constTrue: LazyArg<boolean> = constant(true)\n\n/**\n * A thunk that returns always `false`.\n *\n * @example\n * import { constFalse } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(constFalse(), false)\n *\n * @since 1.0.0\n */\nexport const constFalse: LazyArg<boolean> = constant(false)\n\n/**\n * A thunk that returns always `null`.\n *\n * @example\n * import { constNull } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(constNull(), null)\n *\n * @since 1.0.0\n */\nexport const constNull: LazyArg<null> = constant(null)\n\n/**\n * A thunk that returns always `undefined`.\n *\n * @example\n * import { constUndefined } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(constUndefined(), undefined)\n *\n * @since 1.0.0\n */\nexport const constUndefined: LazyArg<undefined> = constant(undefined)\n\n/**\n * A thunk that returns always `void`.\n *\n * @example\n * import { constVoid } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(constVoid(), undefined)\n *\n * @since 1.0.0\n */\nexport const constVoid: LazyArg<void> = constUndefined\n\n/**\n * Reverses the order of arguments for a curried function.\n *\n * @param f - A curried function that takes multiple arguments.\n *\n * @example\n * import { flip } from \"@fp-ts/core/Function\"\n *\n * const f = (a: number) => (b: string) => a - b.length\n *\n * assert.deepStrictEqual(flip(f)('aaa')(2), -1)\n *\n * @since 1.0.0\n */\nexport const flip = <A extends Array<unknown>, B extends Array<unknown>, C>(\n  f: (...a: A) => (...b: B) => C\n): ((...b: B) => (...a: A) => C) => (...b) => (...a) => f(...a)(...b)\n\n/**\n * Performs left-to-right function composition. The first argument may have any arity, the remaining arguments must be unary.\n *\n * See also {@link pipe}.\n *\n * @example\n * import { flow } from \"@fp-ts/core/Function\"\n *\n * const len = (s: string): number => s.length\n * const double = (n: number): number => n * 2\n *\n * const f = flow(len, double)\n *\n * assert.deepStrictEqual(f('aaa'), 6)\n *\n * @since 1.0.0\n */\nexport function flow<A extends ReadonlyArray<unknown>, B>(ab: (...a: A) => B): (...a: A) => B\nexport function flow<A extends ReadonlyArray<unknown>, B, C>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C\n): (...a: A) => C\nexport function flow<A extends ReadonlyArray<unknown>, B, C, D>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D\n): (...a: A) => D\nexport function flow<A extends ReadonlyArray<unknown>, B, C, D, E>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E\n): (...a: A) => E\nexport function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F\n): (...a: A) => F\nexport function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G\n): (...a: A) => G\nexport function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H\n): (...a: A) => H\nexport function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I\n): (...a: A) => I\nexport function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I, J>(\n  ab: (...a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J\n): (...a: A) => J\nexport function flow(\n  ab: Function,\n  bc?: Function,\n  cd?: Function,\n  de?: Function,\n  ef?: Function,\n  fg?: Function,\n  gh?: Function,\n  hi?: Function,\n  ij?: Function\n): unknown {\n  switch (arguments.length) {\n    case 1:\n      return ab\n    case 2:\n      return function(this: unknown) {\n        return bc!(ab.apply(this, arguments))\n      }\n    case 3:\n      return function(this: unknown) {\n        return cd!(bc!(ab.apply(this, arguments)))\n      }\n    case 4:\n      return function(this: unknown) {\n        return de!(cd!(bc!(ab.apply(this, arguments))))\n      }\n    case 5:\n      return function(this: unknown) {\n        return ef!(de!(cd!(bc!(ab.apply(this, arguments)))))\n      }\n    case 6:\n      return function(this: unknown) {\n        return fg!(ef!(de!(cd!(bc!(ab.apply(this, arguments))))))\n      }\n    case 7:\n      return function(this: unknown) {\n        return gh!(fg!(ef!(de!(cd!(bc!(ab.apply(this, arguments)))))))\n      }\n    case 8:\n      return function(this: unknown) {\n        return hi!(gh!(fg!(ef!(de!(cd!(bc!(ab.apply(this, arguments))))))))\n      }\n    case 9:\n      return function(this: unknown) {\n        return ij!(hi!(gh!(fg!(ef!(de!(cd!(bc!(ab.apply(this, arguments)))))))))\n      }\n  }\n  return\n}\n\n/**\n * Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`.\n * The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.\n *\n * @param ab - A function that maps from `A` to `B`.\n * @param bc - A function that maps from `B` to `C`.\n *\n * @example\n * import { compose } from \"@fp-ts/core/Function\"\n *\n * const increment = (n: number) => n + 1;\n * const square = (n: number) => n * n;\n *\n * assert.strictEqual(compose(increment, square)(2), 9);\n *\n * @since 1.0.0\n */\nexport const compose: {\n  <B, C>(bc: (b: B) => C): <A>(self: (a: A) => B) => (a: A) => C\n  <A, B, C>(self: (a: A) => B, bc: (b: B) => C): (a: A) => C\n} = dual(2, <A, B, C>(ab: (a: A) => B, bc: (b: B) => C): (a: A) => C => flow(ab, bc))\n\n/**\n * The `absurd` function is a stub for cases where a value of type `never` is encountered in your code,\n * meaning that it should be impossible for this code to be executed.\n *\n * This function is particularly when it's necessary to specify that certain cases are impossible.\n *\n * @since 1.0.0\n */\nexport const absurd = <A>(_: never): A => {\n  throw new Error(\"Called `absurd` function which should be uncallable\")\n}\n\n/**\n * Creates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument.\n *\n * @example\n * import { tupled } from \"@fp-ts/core/Function\"\n *\n * const sumTupled = tupled((x: number, y: number): number => x + y)\n *\n * assert.deepStrictEqual(sumTupled([1, 2]), 3)\n *\n * @since 1.0.0\n */\nexport const tupled = <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): ((a: A) => B) =>\n  (a) => f(...a)\n\n/**\n * Inverse function of `tupled`\n *\n * @example\n * import { untupled } from \"@fp-ts/core/Function\"\n *\n * const getFirst = untupled(<A, B>(tuple: [A, B]): A => tuple[0])\n *\n * assert.deepStrictEqual(getFirst(1, 2), 1)\n *\n * @since 1.0.0\n */\nexport const untupled = <A extends ReadonlyArray<unknown>, B>(f: (a: A) => B): ((...a: A) => B) =>\n  (...a) => f(a)\n\n/**\n * Pipes the value of an expression into a pipeline of functions.\n *\n * This is useful in combination with data-last functions as a simulation of methods:\n *\n * ```\n * as.map(f).filter(g) -> pipe(as, map(f), filter(g))\n * ```\n *\n * See also {@link flow}.\n *\n * @example\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * const length = (s: string): number => s.length\n * const double = (n: number): number => n * 2\n * const decrement = (n: number): number => n - 1\n *\n * assert.deepStrictEqual(pipe(length(\"hello\"), double, decrement), 9)\n *\n * @since 1.0.0\n */\nexport function pipe<A>(a: A): A\nexport function pipe<A, B>(a: A, ab: (a: A) => B): B\nexport function pipe<A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C\nexport function pipe<A, B, C, D>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D): D\nexport function pipe<A, B, C, D, E>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E\n): E\nexport function pipe<A, B, C, D, E, F>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F\n): F\nexport function pipe<A, B, C, D, E, F, G>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G\n): G\nexport function pipe<A, B, C, D, E, F, G, H>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H\n): H\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I\n): I\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J\n): J\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K\n): K\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L\n): L\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M\n): M\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N\n): N\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O\n): O\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P\n): P\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P,\n  pq: (p: P) => Q\n): Q\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P,\n  pq: (p: P) => Q,\n  qr: (q: Q) => R\n): R\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P,\n  pq: (p: P) => Q,\n  qr: (q: Q) => R,\n  rs: (r: R) => S\n): S\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(\n  a: A,\n  ab: (a: A) => B,\n  bc: (b: B) => C,\n  cd: (c: C) => D,\n  de: (d: D) => E,\n  ef: (e: E) => F,\n  fg: (f: F) => G,\n  gh: (g: G) => H,\n  hi: (h: H) => I,\n  ij: (i: I) => J,\n  jk: (j: J) => K,\n  kl: (k: K) => L,\n  lm: (l: L) => M,\n  mn: (m: M) => N,\n  no: (n: N) => O,\n  op: (o: O) => P,\n  pq: (p: P) => Q,\n  qr: (q: Q) => R,\n  rs: (r: R) => S,\n  st: (s: S) => T\n): T\nexport function pipe(\n  a: unknown,\n  ab?: Function,\n  bc?: Function,\n  cd?: Function,\n  de?: Function,\n  ef?: Function,\n  fg?: Function,\n  gh?: Function,\n  hi?: Function\n): unknown {\n  switch (arguments.length) {\n    case 1:\n      return a\n    case 2:\n      return ab!(a)\n    case 3:\n      return bc!(ab!(a))\n    case 4:\n      return cd!(bc!(ab!(a)))\n    case 5:\n      return de!(cd!(bc!(ab!(a))))\n    case 6:\n      return ef!(de!(cd!(bc!(ab!(a)))))\n    case 7:\n      return fg!(ef!(de!(cd!(bc!(ab!(a))))))\n    case 8:\n      return gh!(fg!(ef!(de!(cd!(bc!(ab!(a)))))))\n    case 9:\n      return hi!(gh!(fg!(ef!(de!(cd!(bc!(ab!(a))))))))\n    default: {\n      let ret = arguments[0]\n      for (let i = 1; i < arguments.length; i++) {\n        ret = arguments[i](ret)\n      }\n      return ret\n    }\n  }\n}\n\n/**\n * Type hole simulation.\n *\n * @since 1.0.0\n */\nexport const hole: <T>() => T = unsafeCoerce(absurd)\n\n/**\n * The SK combinator, also known as the \"S-K combinator\" or \"S-combinator\", is a fundamental combinator in the\n * lambda calculus and the SKI combinator calculus.\n *\n * This function is useful for discarding the first argument passed to it and returning the second argument.\n *\n * @param _ - The first argument to be discarded.\n * @param b - The second argument to be returned.\n *\n * @example\n * import { SK } from \"@fp-ts/core/Function\";\n *\n * assert.deepStrictEqual(SK(0, \"hello\"), \"hello\")\n *\n * @since 1.0.0\n */\nexport const SK = <A, B>(_: A, b: B): B => b\n"
  },
  {
    "path": "src/HKT.ts",
    "content": "/**\n * @since 1.0.0\n */\n\n/**\n * @since 1.0.0\n */\nexport declare const URI: unique symbol\n\n/**\n * @since 1.0.0\n */\nexport interface TypeClass<F extends TypeLambda> {\n  readonly [URI]?: F\n}\n\n/**\n * @since 1.0.0\n */\nexport interface TypeLambda {\n  readonly In: unknown\n  readonly Out2: unknown\n  readonly Out1: unknown\n  readonly Target: unknown\n}\n\n/**\n * @since 1.0.0\n */\nexport type Kind<F extends TypeLambda, In, Out2, Out1, Target> = F extends {\n  readonly type: unknown\n} ? (F & {\n  readonly In: In\n  readonly Out2: Out2\n  readonly Out1: Out1\n  readonly Target: Target\n})[\"type\"]\n  : {\n    readonly F: F\n    readonly In: (_: In) => void\n    readonly Out2: () => Out2\n    readonly Out1: () => Out1\n    readonly Target: (_: Target) => Target\n  }\n"
  },
  {
    "path": "src/Identity.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as readonlyArray from \"@fp-ts/core/internal/ReadonlyArray\"\nimport type * as applicative from \"@fp-ts/core/typeclass/Applicative\"\nimport * as chainable from \"@fp-ts/core/typeclass/Chainable\"\nimport * as covariant from \"@fp-ts/core/typeclass/Covariant\"\nimport type * as flatMap_ from \"@fp-ts/core/typeclass/FlatMap\"\nimport type * as foldable from \"@fp-ts/core/typeclass/Foldable\"\nimport * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport type * as monad from \"@fp-ts/core/typeclass/Monad\"\nimport * as of_ from \"@fp-ts/core/typeclass/Of\"\nimport type * as pointed from \"@fp-ts/core/typeclass/Pointed\"\nimport type * as product_ from \"@fp-ts/core/typeclass/Product\"\nimport type * as semiAlternative from \"@fp-ts/core/typeclass/SemiAlternative\"\nimport type * as semiApplicative from \"@fp-ts/core/typeclass/SemiApplicative\"\nimport type * as semiCoproduct from \"@fp-ts/core/typeclass/SemiCoproduct\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\nimport type * as traversable from \"@fp-ts/core/typeclass/Traversable\"\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport type Identity<A> = A\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface IdentityTypeLambda extends TypeLambda {\n  readonly type: Identity<this[\"Target\"]>\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface IdentityTypeLambdaFix<A> extends TypeLambda {\n  readonly type: Identity<A>\n}\n\nconst map: {\n  <A, B>(f: (a: A) => B): (self: Identity<A>) => Identity<B>\n  <A, B>(self: Identity<A>, f: (a: A) => B): Identity<B>\n} = dual(2, <A, B>(self: Identity<A>, f: (a: A) => B): Identity<B> => f(self))\n\nconst imap = covariant.imap<IdentityTypeLambda>(map)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Covariant: covariant.Covariant<IdentityTypeLambda> = {\n  imap,\n  map\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<IdentityTypeLambda> = {\n  imap\n}\n\nconst of: <A>(a: A) => Identity<A> = identity\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Of: of_.Of<IdentityTypeLambda> = {\n  of\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Pointed: pointed.Pointed<IdentityTypeLambda> = {\n  of,\n  imap,\n  map\n}\n\nconst flatMap: {\n  <A, B>(f: (a: A) => B): (self: Identity<A>) => Identity<B>\n  <A, B>(self: Identity<A>, f: (a: A) => B): Identity<B>\n} = dual(2, <A, B>(self: Identity<A>, f: (a: A) => B): Identity<B> => f(self))\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const FlatMap: flatMap_.FlatMap<IdentityTypeLambda> = {\n  flatMap\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Chainable: chainable.Chainable<IdentityTypeLambda> = {\n  imap,\n  map,\n  flatMap\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Monad: monad.Monad<IdentityTypeLambda> = {\n  imap,\n  of,\n  map,\n  flatMap\n}\n\nconst product = <A, B>(self: Identity<A>, that: Identity<B>): Identity<[A, B]> => [self, that]\n\nconst productMany = <A>(\n  self: Identity<A>,\n  collection: Iterable<A>\n): [A, ...Array<A>] => [self, ...collection]\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiProduct: semiProduct.SemiProduct<IdentityTypeLambda> = {\n  imap,\n  product,\n  productMany\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Product: product_.Product<IdentityTypeLambda> = {\n  of,\n  imap,\n  product,\n  productMany,\n  productAll: readonlyArray.fromIterable\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiApplicative: semiApplicative.SemiApplicative<IdentityTypeLambda> = {\n  imap,\n  map,\n  product,\n  productMany\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Applicative: applicative.Applicative<IdentityTypeLambda> = {\n  imap,\n  of,\n  map,\n  product,\n  productMany,\n  productAll: readonlyArray.fromIterable\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getSemiCoproduct = <A>(\n  S: Semigroup<A>\n): semiCoproduct.SemiCoproduct<IdentityTypeLambdaFix<A>> => ({\n  imap,\n  coproduct: dual(2, S.combine),\n  coproductMany: dual(2, S.combineMany)\n})\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getSemiAlternative = <A>(\n  S: Semigroup<A>\n): semiAlternative.SemiAlternative<IdentityTypeLambdaFix<A>> => ({\n  ...getSemiCoproduct(S),\n  map\n})\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Foldable: foldable.Foldable<IdentityTypeLambda> = {\n  reduce: dual(3, <A, B>(self: Identity<A>, b: B, f: (b: B, a: A) => B): B => f(b, self))\n}\n\nconst traverse = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): {\n  <A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): (self: Identity<A>) => Kind<F, R, O, E, B>\n  <A, R, O, E, B>(self: Identity<A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, B>\n} =>\n  dual(\n    2,\n    <A, R, O, E, B>(self: Identity<A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, B> =>\n      f(self)\n  )\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Traversable: traversable.Traversable<IdentityTypeLambda> = {\n  traverse\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bindTo: {\n  <N extends string>(name: N): <A>(self: Identity<A>) => Identity<{ [K in N]: A }>\n  <A, N extends string>(self: Identity<A>, name: N): Identity<{ [K in N]: A }>\n} = invariant.bindTo(Invariant)\n\nconst let_: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): (self: Identity<A>) => Identity<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: Identity<A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): Identity<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = covariant.let(Covariant)\n\nexport {\n  /**\n   * @category do notation\n   * @since 1.0.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const Do: Identity<{}> = of_.Do(Of)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bind: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Identity<B>\n  ): (self: Identity<A>) => Identity<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: Identity<A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Identity<B>\n  ): Identity<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = chainable.bind(Chainable)\n\n/**\n * A variant of `bind` that sequentially ignores the scope.\n *\n * @category do notation\n * @since 1.0.0\n */\nexport const andThenBind: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    that: Identity<B>\n  ): (self: Identity<A>) => Identity<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: Identity<A>,\n    name: Exclude<N, keyof A>,\n    that: Identity<B>\n  ): Identity<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = semiProduct.andThenBind(SemiProduct)\n"
  },
  {
    "path": "src/Number.ts",
    "content": "/**\n * This module provides utility functions and type class instances for working with the `number` type in TypeScript.\n * It includes functions for basic arithmetic operations, as well as type class instances for\n * `Equivalence`, `Order`, `Semigroup`, and `Monoid`.\n *\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Ordering } from \"@fp-ts/core/Ordering\"\nimport * as predicate from \"@fp-ts/core/Predicate\"\nimport * as bounded from \"@fp-ts/core/typeclass/Bounded\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * Tests if a value is a `number`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isNumber } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(isNumber(2), true)\n * assert.deepStrictEqual(isNumber(\"2\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNumber: (input: unknown) => input is number = predicate.isNumber\n\n/**\n * Provides an addition operation on `number`s.\n *\n * @param self - The first operand.\n * @param that - The second operand.\n *\n * @example\n * import { sum } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(sum(2, 3), 5)\n *\n * @category math\n * @since 1.0.0\n */\nexport const sum: {\n  (that: number): (self: number) => number\n  (self: number, that: number): number\n} = dual(2, semigroup.numberSum.combine)\n\n/**\n * Provides a multiplication operation on `number`s.\n *\n * @param self - The first operand.\n * @param that - The second operand.\n *\n * @example\n * import { multiply } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(multiply(2, 3), 6)\n *\n * @category math\n * @since 1.0.0\n */\nexport const multiply: {\n  (that: number): (self: number) => number\n  (self: number, that: number): number\n} = dual(2, semigroup.numberMultiply.combine)\n\n/**\n * Provides a subtraction operation on `number`s.\n *\n * @param self - The first operand.\n * @param that - The second operand.\n *\n * @example\n * import { subtract } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(subtract(2, 3), -1)\n *\n * @category math\n * @since 1.0.0\n */\nexport const subtract: {\n  (that: number): (self: number) => number\n  (self: number, that: number): number\n} = dual(2, (self: number, that: number): number => self - that)\n\n/**\n * Provides a division operation on `number`s.\n *\n * @param self - The dividend operand.\n * @param that - The divisor operand.\n *\n * @example\n * import { divide } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(divide(6, 3), 2)\n *\n * @category math\n * @since 1.0.0\n */\nexport const divide: {\n  (that: number): (self: number) => number\n  (self: number, that: number): number\n} = dual(2, (self: number, that: number): number => self / that)\n\n/**\n * Returns the result of adding `1` to a given number.\n *\n * @param n - A `number` to be incremented.\n *\n * @example\n * import { increment } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(increment(2), 3)\n *\n * @category math\n * @since 1.0.0\n */\nexport const increment = (n: number): number => n + 1\n\n/**\n * Decrements a number by `1`.\n *\n * @param n - A `number` to be decremented.\n *\n * @example\n * import { decrement } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(decrement(3), 2)\n *\n * @category math\n * @since 1.0.0\n */\nexport const decrement = (n: number): number => n - 1\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Equivalence: equivalence.Equivalence<number> = equivalence.number\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Order: order.Order<number> = order.number\n\n/**\n * Returns `true` if the first argument is less than the second, otherwise `false`.\n *\n * @param self - The first argument.\n * @param that - The second argument.\n *\n * @example\n * import { lessThan } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(lessThan(2, 3), true)\n * assert.deepStrictEqual(lessThan(3, 3), false)\n * assert.deepStrictEqual(lessThan(4, 3), false)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const lessThan: {\n  (that: number): (self: number) => boolean\n  (self: number, that: number): boolean\n} = order.lessThan(Order)\n\n/**\n * Returns a function that checks if a given `number` is less than or equal to the provided one.\n *\n * @param self - The first `number` to compare with.\n * @param that - The second `number` to compare with.\n *\n * @example\n * import { lessThanOrEqualTo } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(lessThanOrEqualTo(2, 3), true)\n * assert.deepStrictEqual(lessThanOrEqualTo(3, 3), true)\n * assert.deepStrictEqual(lessThanOrEqualTo(4, 3), false)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const lessThanOrEqualTo: {\n  (that: number): (self: number) => boolean\n  (self: number, that: number): boolean\n} = order.lessThanOrEqualTo(Order)\n\n/**\n * Returns `true` if the first argument is greater than the second, otherwise `false`.\n *\n * @param self - The first argument.\n * @param that - The second argument.\n *\n * @example\n * import { greaterThan } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(greaterThan(2, 3), false)\n * assert.deepStrictEqual(greaterThan(3, 3), false)\n * assert.deepStrictEqual(greaterThan(4, 3), true)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const greaterThan: {\n  (that: number): (self: number) => boolean\n  (self: number, that: number): boolean\n} = order.greaterThan(Order)\n\n/**\n * Returns a function that checks if a given `number` is greater than or equal to the provided one.\n *\n * @param self - The first `number` to compare with.\n * @param that - The second `number` to compare with.\n *\n * @example\n * import { greaterThanOrEqualTo } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(greaterThanOrEqualTo(2, 3), false)\n * assert.deepStrictEqual(greaterThanOrEqualTo(3, 3), true)\n * assert.deepStrictEqual(greaterThanOrEqualTo(4, 3), true)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const greaterThanOrEqualTo: {\n  (that: number): (self: number) => boolean\n  (self: number, that: number): boolean\n} = order.greaterThanOrEqualTo(Order)\n\n/**\n * Checks if a `number` is between a `minimum` and `maximum` value (inclusive).\n *\n * @param self - The `number` to check.\n * @param minimum - The `minimum` value to check.\n * @param maximum - The `maximum` value to check.\n *\n * @example\n * import { between } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(between(0, 5)(3), true)\n * assert.deepStrictEqual(between(0, 5)(-1), false)\n * assert.deepStrictEqual(between(0, 5)(6), false)\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const between: {\n  (minimum: number, maximum: number): (self: number) => boolean\n  (self: number, minimum: number, maximum: number): boolean\n} = order.between(Order)\n\n/**\n * Restricts the given `number` to be within the range specified by the `minimum` and `maximum` values.\n *\n * - If the `number` is less than the `minimum` value, the function returns the `minimum` value.\n * - If the `number` is greater than the `maximum` value, the function returns the `maximum` value.\n * - Otherwise, it returns the original `number`.\n *\n * @param self - The `number` to be clamped.\n * @param minimum - The lower end of the range.\n * @param maximum - The upper end of the range.\n *\n * @example\n * import { clamp } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(clamp(0, 5)(3), 3)\n * assert.deepStrictEqual(clamp(0, 5)(-1), 0)\n * assert.deepStrictEqual(clamp(0, 5)(6), 5)\n *\n * @since 1.0.0\n */\nexport const clamp: {\n  (minimum: number, maximum: number): (self: number) => number\n  (self: number, minimum: number, maximum: number): number\n} = order.clamp(Order)\n\n/**\n * Returns the minimum between two `number`s.\n *\n * @param self - The first `number`.\n * @param that - The second `number`.\n *\n * @example\n * import { min } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(min(2, 3), 2)\n *\n * @since 1.0.0\n */\nexport const min: {\n  (that: number): (self: number) => number\n  (self: number, that: number): number\n} = order.min(Order)\n\n/**\n * Returns the maximum between two `number`s.\n *\n * @param self - The first `number`.\n * @param that - The second `number`.\n *\n * @example\n * import { max } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(max(2, 3), 3)\n *\n * @since 1.0.0\n */\nexport const max: {\n  (that: number): (self: number) => number\n  (self: number, that: number): number\n} = order.max(Order)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Bounded: bounded.Bounded<number> = bounded.number\n\n/**\n * `number` semigroup under addition.\n *\n * @example\n * import { SemigroupSum } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(SemigroupSum.combine(2, 3), 5)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupSum: semigroup.Semigroup<number> = semigroup.numberSum\n\n/**\n * `number` semigroup under multiplication.\n *\n * @example\n * import { SemigroupMultiply } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(SemigroupMultiply.combine(2, 3), 6)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupMultiply: semigroup.Semigroup<number> = semigroup.numberMultiply\n\n/**\n * A `Semigroup` that uses the minimum between two values.\n *\n * @example\n * import { SemigroupMin } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(SemigroupMin.combine(2, 3), 2)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupMin: semigroup.Semigroup<number> = semigroup.min(Order)\n\n/**\n * A `Semigroup` that uses the maximum between two values.\n *\n * @example\n * import { SemigroupMax } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(SemigroupMax.combine(2, 3), 3)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const SemigroupMax: semigroup.Semigroup<number> = semigroup.max(Order)\n\n/**\n * `number` monoid under addition.\n *\n * The `empty` value is `0`.\n *\n * @example\n * import { MonoidSum } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(MonoidSum.combine(2, 3), 5)\n * assert.deepStrictEqual(MonoidSum.combine(2, MonoidSum.empty), 2)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidSum: monoid.Monoid<number> = monoid.numberSum\n\n/**\n * `number` monoid under multiplication.\n *\n * The `empty` value is `1`.\n *\n * @example\n * import { MonoidMultiply } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(MonoidMultiply.combine(2, 3), 6)\n * assert.deepStrictEqual(MonoidMultiply.combine(2, MonoidMultiply.empty), 2)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidMultiply: monoid.Monoid<number> = monoid.numberMultiply\n\n/**\n * A `Monoid` that uses the minimum between two values.\n *\n * The `empty` value is `-Infinity`.\n *\n * @example\n * import { MonoidMin } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(MonoidMin.combine(2, 3), 2)\n * assert.deepStrictEqual(MonoidMin.combine(2, MonoidMin.empty), 2)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidMin: monoid.Monoid<number> = bounded.min(Bounded)\n\n/**\n * A `Monoid` that uses the maximum between two values.\n *\n * The `empty` value is `Infinity`.\n *\n * @example\n * import { MonoidMax } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(MonoidMax.combine(2, 3), 3)\n * assert.deepStrictEqual(MonoidMax.combine(2, MonoidMax.empty), 2)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const MonoidMax: monoid.Monoid<number> = bounded.max(Bounded)\n\n/**\n * Determines the sign of a given `number`.\n *\n * @param n - The `number` to determine the sign of.\n *\n * @example\n * import { sign } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(sign(-5), -1)\n * assert.deepStrictEqual(sign(0), 0)\n * assert.deepStrictEqual(sign(5), 1)\n *\n * @category math\n * @since 1.0.0\n */\nexport const sign = (n: number): Ordering => Order.compare(n, 0)\n\n/**\n * Takes an `Iterable` of `number`s and returns their sum as a single `number`.\n *\n * @param collection - The collection of `number`s to sum.\n *\n * @example\n * import { sumAll } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(sumAll([2, 3, 4]), 9)\n *\n * @category math\n * @since 1.0.0\n */\nexport const sumAll: (collection: Iterable<number>) => number = MonoidSum.combineAll\n\n/**\n * Takes an `Iterable` of `number`s and returns their multiplication as a single `number`.\n *\n * @param collection - The collection of `number`s to multiply.\n *\n * @example\n * import { multiplyAll } from '@fp-ts/core/Number'\n *\n * assert.deepStrictEqual(multiplyAll([2, 3, 4]), 24)\n *\n * @category math\n * @since 1.0.0\n */\nexport const multiplyAll: (collection: Iterable<number>) => number = MonoidMultiply.combineAll\n\n/**\n * Returns the remainder left over when one operand is divided by a second operand.\n *\n * It always takes the sign of the dividend.\n *\n * @param self - The dividend.\n * @param divisor - The divisor.\n *\n * @example\n * import { remainder } from \"@fp-ts/core/Number\"\n *\n * assert.deepStrictEqual(remainder(2, 2), 0)\n * assert.deepStrictEqual(remainder(3, 2), 1)\n * assert.deepStrictEqual(remainder(-4, 2), -0)\n *\n * @category math\n * @since 1.0.0\n */\nexport const remainder: {\n  (divisor: number): (self: number) => number\n  (self: number, divisor: number): number\n} = dual(2, (self: number, divisor: number): number => {\n  // https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034\n  const selfDecCount = (self.toString().split(\".\")[1] || \"\").length\n  const divisorDecCount = (divisor.toString().split(\".\")[1] || \"\").length\n  const decCount = selfDecCount > divisorDecCount ? selfDecCount : divisorDecCount\n  const selfInt = parseInt(self.toFixed(decCount).replace(\".\", \"\"))\n  const divisorInt = parseInt(divisor.toFixed(decCount).replace(\".\", \"\"))\n  return (selfInt % divisorInt) / Math.pow(10, decCount)\n})\n"
  },
  {
    "path": "src/Option.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { Either } from \"@fp-ts/core/Either\"\nimport type { LazyArg } from \"@fp-ts/core/Function\"\nimport { constNull, constUndefined, dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport { structural } from \"@fp-ts/core/internal/effect\"\nimport * as either from \"@fp-ts/core/internal/Either\"\nimport * as option from \"@fp-ts/core/internal/Option\"\nimport * as N from \"@fp-ts/core/Number\"\nimport type { Predicate, Refinement } from \"@fp-ts/core/Predicate\"\nimport type * as alternative from \"@fp-ts/core/typeclass/Alternative\"\nimport * as applicative from \"@fp-ts/core/typeclass/Applicative\"\nimport * as chainable from \"@fp-ts/core/typeclass/Chainable\"\nimport type * as coproduct_ from \"@fp-ts/core/typeclass/Coproduct\"\nimport * as covariant from \"@fp-ts/core/typeclass/Covariant\"\nimport type { Equivalence } from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as filterable from \"@fp-ts/core/typeclass/Filterable\"\nimport * as flatMap_ from \"@fp-ts/core/typeclass/FlatMap\"\nimport * as foldable from \"@fp-ts/core/typeclass/Foldable\"\nimport * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport type * as monad from \"@fp-ts/core/typeclass/Monad\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as of_ from \"@fp-ts/core/typeclass/Of\"\nimport type { Order } from \"@fp-ts/core/typeclass/Order\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport type * as pointed from \"@fp-ts/core/typeclass/Pointed\"\nimport * as product_ from \"@fp-ts/core/typeclass/Product\"\nimport type * as semiAlternative from \"@fp-ts/core/typeclass/SemiAlternative\"\nimport * as semiApplicative from \"@fp-ts/core/typeclass/SemiApplicative\"\nimport * as semiCoproduct from \"@fp-ts/core/typeclass/SemiCoproduct\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\nimport * as traversable from \"@fp-ts/core/typeclass/Traversable\"\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport type Option<A> = None | Some<A>\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport interface None {\n  readonly _tag: \"None\"\n}\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport interface Some<A> {\n  readonly _tag: \"Some\"\n  readonly value: A\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface OptionTypeLambda extends TypeLambda {\n  readonly type: Option<this[\"Target\"]>\n}\n\n/**\n * Creates a new `Option` that represents the absence of a value.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const none = <A = never>(): Option<A> => option.none\n\n/**\n * Creates a new `Option` that wraps the given value.\n *\n * @param value - The value to wrap.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const some: <A>(value: A) => Option<A> = option.some\n\n/**\n * Alias of {@link some}.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const of: <A>(value: A) => Option<A> = some\n\n/**\n * Tests if a value is a `Option`.\n *\n * @param input - The value to check.\n *\n * @example\n * import { some, none, isOption } from '@fp-ts/core/Option'\n *\n * assert.deepStrictEqual(isOption(some(1)), true)\n * assert.deepStrictEqual(isOption(none()), true)\n * assert.deepStrictEqual(isOption({}), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isOption = (input: unknown): input is Option<unknown> =>\n  typeof input === \"object\" && input != null && structural in input && \"_tag\" in input &&\n  (input[\"_tag\"] === \"None\" || input[\"_tag\"] === \"Some\")\n\n/**\n * Determine if a `Option` is a `None`.\n *\n * @param self - The `Option` to check.\n *\n * @example\n * import { some, none, isNone } from '@fp-ts/core/Option'\n *\n * assert.deepStrictEqual(isNone(some(1)), false)\n * assert.deepStrictEqual(isNone(none()), true)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNone: <A>(self: Option<A>) => self is None = option.isNone\n\n/**\n * Determine if a `Option` is a `Some`.\n *\n * @param self - The `Option` to check.\n *\n * @example\n * import { some, none, isSome } from '@fp-ts/core/Option'\n *\n * assert.deepStrictEqual(isSome(some(1)), true)\n * assert.deepStrictEqual(isSome(none()), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isSome: <A>(self: Option<A>) => self is Some<A> = option.isSome\n\n/**\n * Matches the given `Option` and returns either the provided `onNone` value or the result of the provided `onSome`\n * function when passed the `Option`'s value.\n *\n * @param self - The `Option` to match\n * @param onNone - The value to be returned if the `Option` is `None`\n * @param onSome - The function to be called if the `Option` is `Some`, it will be passed the `Option`'s value and its result will be returned\n *\n * @example\n * import { some, none, match } from '@fp-ts/core/Option'\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     some(1),\n *     match(() => 'a none', a => `a some containing ${a}`)\n *   ),\n *   'a some containing 1'\n * )\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     none(),\n *     match(() => 'a none', a => `a some containing ${a}`)\n *   ),\n *   'a none'\n * )\n *\n * @category pattern matching\n * @since 1.0.0\n */\nexport const match: {\n  <B, A, C = B>(onNone: LazyArg<B>, onSome: (a: A) => C): (self: Option<A>) => B | C\n  <A, B, C = B>(self: Option<A>, onNone: LazyArg<B>, onSome: (a: A) => C): B | C\n} = dual(\n  3,\n  <A, B, C = B>(self: Option<A>, onNone: LazyArg<B>, onSome: (a: A) => C): B | C =>\n    isNone(self) ? onNone() : onSome(self.value)\n)\n\n/**\n * Returns a type guard from a `Option` returning function.\n * This function ensures that a type guard definition is type-safe.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * const parsePositive = (n: number): O.Option<number> =>\n *   n > 0 ? O.some(n) : O.none()\n *\n * const isPositive = O.toRefinement(parsePositive)\n *\n * assert.deepStrictEqual(isPositive(1), true)\n * assert.deepStrictEqual(isPositive(-1), false)\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const toRefinement = <A, B extends A>(f: (a: A) => Option<B>): (a: A) => a is B =>\n  (a: A): a is B => isSome(f(a))\n\n/**\n * Converts an `Iterable` of values into an `Option`. Returns the first value of the `Iterable` wrapped in a `Some`\n * if the `Iterable` is not empty, otherwise returns `None`.\n *\n * @param collection - The `Iterable` to be converted to an `Option`.\n *\n * @example\n * import { fromIterable, some, none } from '@fp-ts/core/Option'\n *\n * assert.deepStrictEqual(fromIterable([1, 2, 3]), some(1))\n * assert.deepStrictEqual(fromIterable([]), none())\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const fromIterable = <A>(collection: Iterable<A>): Option<A> => {\n  for (const a of collection) {\n    return some(a)\n  }\n  return none()\n}\n\n/**\n * Converts a `Either` to an `Option` discarding the error.\n *\n * @param self - The `Either` to convert to an `Option`.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n * import * as E from \"@fp-ts/core/Either\"\n *\n * assert.deepStrictEqual(O.fromEither(E.right(1)), O.some(1))\n * assert.deepStrictEqual(O.fromEither(E.left('error message')), O.none())\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const fromEither: <E, A>(self: Either<E, A>) => Option<A> = either.getRight\n\n/**\n * Converts a `Either` to an `Option` discarding the error.\n *\n * Alias of {@link fromEither}.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n * import * as E from \"@fp-ts/core/Either\"\n *\n * assert.deepStrictEqual(O.getRight(E.right('ok')), O.some('ok'))\n * assert.deepStrictEqual(O.getRight(E.left('err')), O.none())\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const getRight: <E, A>(self: Either<E, A>) => Option<A> = fromEither\n\n/**\n * Converts a `Either` to an `Option` discarding the value.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n * import * as E from \"@fp-ts/core/Either\"\n *\n * assert.deepStrictEqual(O.getLeft(E.right(\"ok\")), O.none())\n * assert.deepStrictEqual(O.getLeft(E.left(\"error\")), O.some(\"error\"))\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const getLeft: <E, A>(self: Either<E, A>) => Option<E> = either.getLeft\n\n/**\n * Converts an `Option` to an `Either`, allowing you to provide a value to be used in the case of a `None`.\n *\n * @param self - the `Option` to convert.\n * @param onNone - a function that produces an error value when the `Option` is `None`.\n *\n * @example\n * import { pipe } from \"@fp-ts/core/Function\"\n * import * as O from \"@fp-ts/core/Option\"\n * import * as E from \"@fp-ts/core/Either\"\n *\n * const onNone = () => 'error'\n * assert.deepStrictEqual(pipe(O.some(1), O.toEither(onNone)), E.right(1))\n * assert.deepStrictEqual(pipe(O.none(), O.toEither(onNone)), E.left('error'))\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const toEither: {\n  <A, E>(self: Option<A>, onNone: () => E): Either<E, A>\n  <E>(onNone: () => E): <A>(self: Option<A>) => Either<E, A>\n} = either.fromOption\n\n/**\n * Returns the value of the `Option` if it is `Some`, otherwise returns `onNone`\n *\n * @param self - The `Option` to get the value of.\n * @param onNone - Function that returns the default value to return if the `Option` is `None`.\n *\n * @example\n * import { some, none, getOrElse } from '@fp-ts/core/Option'\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(pipe(some(1), getOrElse(() => 0)), 1)\n * assert.deepStrictEqual(pipe(none(), getOrElse(() => 0)), 0)\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getOrElse: {\n  <B>(onNone: LazyArg<B>): <A>(self: Option<A>) => B | A\n  <A, B>(self: Option<A>, onNone: LazyArg<B>): A | B\n} = dual(\n  2,\n  <A, B>(self: Option<A>, onNone: LazyArg<B>): A | B => isNone(self) ? onNone() : self.value\n)\n\n/**\n * Returns the provided `Option` `that` if `self` is `None`, otherwise returns `self`.\n *\n * @param self - The first `Option` to be checked.\n * @param that - The `Option` to return if `self` is `None`.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     O.none(),\n *     O.orElse(() => O.none())\n *   ),\n *   O.none()\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     O.some('a'),\n *     O.orElse(() => O.none())\n *   ),\n *   O.some('a')\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     O.none(),\n *     O.orElse(() => O.some('b'))\n *   ),\n *   O.some('b')\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     O.some('a'),\n *     O.orElse(() => O.some('b'))\n *   ),\n *   O.some('a')\n * )\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const orElse: {\n  <B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<B | A>\n  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<A | B>\n} = dual(\n  2,\n  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<A | B> => isNone(self) ? that() : self\n)\n\n/**\n * Similar to `orElse`, but instead of returning a simple union, it returns an `Either` object,\n * which contains information about which of the two `Option`s has been chosen.\n *\n * This is useful when it's important to know whether the value was retrieved from the first `Option` or the second option.\n *\n * @param self - The first `Option` to be checked.\n * @param that - The second `Option` to be considered if the first `Option` is `None`.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const orElseEither: {\n  <B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<Either<A, B>>\n  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<Either<A, B>>\n} = dual(\n  2,\n  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<Either<A, B>> =>\n    isNone(self) ? map(that(), either.right) : map(self, either.left)\n)\n\n/**\n * Given an `Iterable` collection of `Option`s, returns the first `Some` found in the collection.\n *\n * @param collection - An iterable collection of `Option` to be searched.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.firstSomeOf([O.none(), O.some(1), O.some(2)]), O.some(1))\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const firstSomeOf = <A>(collection: Iterable<Option<A>>): Option<A> => {\n  let out: Option<A> = none()\n  for (out of collection) {\n    if (isSome(out)) {\n      return out\n    }\n  }\n  return out\n}\n\n/**\n * Similar to `Promise.all` but operates on `Option`s.\n *\n * ```\n * Iterable<Option<A>> -> Option<A[]>\n * ```\n *\n * Flattens a collection of `Option`s into a single `Option` that contains a list of all the `Some` values.\n * If there is a `None` value in the collection, it returns `None` as the result.\n *\n * @param collection - An iterable collection of `Option`s to flatten.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.all([O.some(1), O.some(2), O.some(3)]), O.some([1, 2, 3]))\n * assert.deepStrictEqual(O.all([O.some(1), O.none(), O.some(3)]), O.none())\n *\n * @category combining\n * @since 1.0.0\n */\nexport const all = <A>(collection: Iterable<Option<A>>): Option<Array<A>> => {\n  const out: Array<A> = []\n  for (const o of collection) {\n    if (isNone(o)) {\n      return none()\n    }\n    out.push(o.value)\n  }\n  return some(out)\n}\n\n/**\n * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise\n * returns the value wrapped in a `Some`.\n *\n * @param nullableValue - The nullable value to be converted to an `Option`.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.fromNullable(undefined), O.none())\n * assert.deepStrictEqual(O.fromNullable(null), O.none())\n * assert.deepStrictEqual(O.fromNullable(1), O.some(1))\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const fromNullable = <A>(\n  nullableValue: A\n): Option<\n  NonNullable<A>\n> => (nullableValue == null ? none() : some(nullableValue as NonNullable<A>))\n\n/**\n * This API is useful for lifting a function that returns `null` or `undefined` into the `Option` context.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * const parse = (s: string): number | undefined => {\n *   const n = parseFloat(s)\n *   return isNaN(n) ? undefined : n\n * }\n *\n * const parseOption = O.liftNullable(parse)\n *\n * assert.deepStrictEqual(parseOption('1'), O.some(1))\n * assert.deepStrictEqual(parseOption('not a number'), O.none())\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const liftNullable = <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n): ((...a: A) => Option<NonNullable<B>>) => (...a) => fromNullable(f(...a))\n\n/**\n * Returns the value of the `Option` if it is a `Some`, otherwise returns `null`.\n *\n * @param self - The `Option` to extract the value from.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.getOrNull(O.some(1)), 1)\n * assert.deepStrictEqual(O.getOrNull(O.none()), null)\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getOrNull: <A>(self: Option<A>) => A | null = getOrElse(constNull)\n\n/**\n * Returns the value of the `Option` if it is a `Some`, otherwise returns `undefined`.\n *\n * @param self - The `Option` to extract the value from.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.getOrUndefined(O.some(1)), 1)\n * assert.deepStrictEqual(O.getOrUndefined(O.none()), undefined)\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getOrUndefined: <A>(self: Option<A>) => A | undefined = getOrElse(constUndefined)\n\n/**\n * A utility function that lifts a function that throws exceptions into a function that returns an `Option`.\n *\n * This function is useful for any function that might throw an exception, allowing the developer to handle\n * the exception in a more functional way.\n *\n * @param f - the function that can throw exceptions.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * const parse = O.liftThrowable(JSON.parse)\n *\n * assert.deepStrictEqual(parse(\"1\"), O.some(1))\n * assert.deepStrictEqual(parse(\"\"), O.none())\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const liftThrowable = <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B\n): ((...a: A) => Option<B>) =>\n  (...a) => {\n    try {\n      return some(f(...a))\n    } catch (e) {\n      return none()\n    }\n  }\n\n/**\n * Extracts the value of an `Option` or throws if the `Option` is `None`.\n *\n * If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.\n *\n * @param self - The `Option` to extract the value from.\n * @param onNone - A function that will be called if the `Option` is `None`. It returns the error to be thrown.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(\n *   O.getOrThrowWith(O.some(1), () => new Error('Unexpected None')),\n *   1\n * )\n * assert.throws(() => O.getOrThrowWith(O.none(), () => new Error('Unexpected None')))\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const getOrThrowWith: {\n  (onNone: () => unknown): <A>(self: Option<A>) => A\n  <A>(self: Option<A>, onNone: () => unknown): A\n} = dual(2, <A>(self: Option<A>, onNone: () => unknown): A => {\n  if (isSome(self)) {\n    return self.value\n  }\n  throw onNone()\n})\n\n/**\n * Extracts the value of an `Option` or throws if the `Option` is `None`.\n *\n * The thrown error is a default error. To configure the error thrown, see  {@link getOrThrowWith}.\n *\n * @param self - The `Option` to extract the value from.\n * @throws `Error(\"getOrThrow called on a None\")`\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.getOrThrow(O.some(1)), 1)\n * assert.throws(() => O.getOrThrow(O.none()))\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const getOrThrow: <A>(self: Option<A>) => A = getOrThrowWith(() =>\n  new Error(\"getOrThrow called on a None\")\n)\n\n/**\n * Maps the `Some` side of an `Option` value to a new `Option` value.\n *\n * @param self - An `Option` to map\n * @param f - The function to map over the value of the `Option`\n *\n * @category transforming\n * @since 1.0.0\n */\nexport const map: {\n  <A, B>(f: (a: A) => B): (self: Option<A>) => Option<B>\n  <A, B>(self: Option<A>, f: (a: A) => B): Option<B>\n} = dual(\n  2,\n  <A, B>(self: Option<A>, f: (a: A) => B): Option<B> => isNone(self) ? none() : some(f(self.value))\n)\n\nconst imap = covariant.imap<OptionTypeLambda>(map)\n\n/**\n * @since 1.0.0\n */\nexport const Covariant: covariant.Covariant<OptionTypeLambda> = {\n  imap,\n  map\n}\n\n/**\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<OptionTypeLambda> = {\n  imap\n}\n\n/**\n * @category transforming\n * @since 1.0.0\n */\nexport const flap: {\n  <A, B>(a: A, self: Option<(a: A) => B>): Option<B>\n  <A, B>(self: Option<(a: A) => B>): (a: A) => Option<B>\n} = covariant.flap(Covariant)\n\n/**\n * Maps the `Some` value of this `Option` to the specified constant value.\n *\n * @category transforming\n * @since 1.0.0\n */\nexport const as: {\n  <_, B>(self: Option<_>, b: B): Option<B>\n  <B>(b: B): <_>(self: Option<_>) => Option<B>\n} = covariant.as(Covariant)\n\n/**\n * Returns the `Option` resulting from mapping the `Some` value to `void`.\n *\n * This is useful when the value of the `Option` is not needed, but the presence or absence of the value is important.\n *\n * @category transforming\n * @since 1.0.0\n */\nexport const asUnit: <_>(self: Option<_>) => Option<void> = covariant.asUnit(Covariant)\n\n/**\n * @since 1.0.0\n */\nexport const Of: of_.Of<OptionTypeLambda> = {\n  of\n}\n\n/**\n * @since 1.0.0\n */\nexport const unit: Option<void> = of_.unit(Of)\n\n/**\n * @since 1.0.0\n */\nexport const Pointed: pointed.Pointed<OptionTypeLambda> = {\n  of,\n  imap,\n  map\n}\n\n/**\n * Applies a function to the value of an `Option` and flattens the result, if the input is `Some`.\n *\n * @category transforming\n * @since 1.0.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>\n  <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>\n} = dual(\n  2,\n  <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B> =>\n    isNone(self) ? none() : f(self.value)\n)\n\n/**\n * Applies a provided function that returns an `Either` to the contents of an `Option`, flattening the result into another `Option`.\n *\n * @param self - The `Option` to apply the function to.\n * @param f - The function to be applied to the contents of the `Option`.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n * import * as E from \"@fp-ts/core/Either\"\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * const f = (n: number) => (n > 2 ? E.left('Too big') : E.right(n + 1))\n *\n * assert.deepStrictEqual(pipe(O.some(1), O.flatMapEither(f)), O.some(2))\n * assert.deepStrictEqual(pipe(O.some(3), O.flatMapEither(f)), O.none())\n *\n * @category transforming\n * @since 1.0.0\n */\nexport const flatMapEither: {\n  <A, E, B>(f: (a: A) => Either<E, B>): (self: Option<A>) => Option<B>\n  <A, E, B>(self: Option<A>, f: (a: A) => Either<E, B>): Option<B>\n} = dual(\n  2,\n  <A, E, B>(self: Option<A>, f: (a: A) => Either<E, B>): Option<B> => flatMap(self, liftEither(f))\n)\n\n/**\n * This is `flatMap` + `fromNullable`, useful when working with optional values.\n *\n * @example\n * import { some, none, flatMapNullable } from '@fp-ts/core/Option'\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * interface Employee {\n *   company?: {\n *     address?: {\n *       street?: {\n *         name?: string\n *       }\n *     }\n *   }\n * }\n *\n * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     some(employee1),\n *     flatMapNullable(employee => employee.company?.address?.street?.name),\n *   ),\n *   some('high street')\n * )\n *\n * const employee2: Employee = { company: { address: { street: {} } } }\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     some(employee2),\n *     flatMapNullable(employee => employee.company?.address?.street?.name),\n *   ),\n *   none()\n * )\n *\n * @category transforming\n * @since 1.0.0\n */\nexport const flatMapNullable: {\n  <A, B>(f: (a: A) => B | null | undefined): (self: Option<A>) => Option<NonNullable<B>>\n  <A, B>(self: Option<A>, f: (a: A) => B | null | undefined): Option<NonNullable<B>>\n} = dual(\n  2,\n  <A, B>(self: Option<A>, f: (a: A) => B | null | undefined): Option<NonNullable<B>> =>\n    isNone(self) ? none() : fromNullable(f(self.value))\n)\n\n/**\n * @since 1.0.0\n */\nexport const FlatMap: flatMap_.FlatMap<OptionTypeLambda> = {\n  flatMap\n}\n\n/**\n * @category transforming\n * @since 1.0.0\n */\nexport const flatten: <A>(self: Option<Option<A>>) => Option<A> = flatMap_.flatten(FlatMap)\n\n/**\n * @category transforming\n * @since 1.0.0\n */\nexport const andThen: {\n  <_, B>(self: Option<_>, that: Option<B>): Option<B>\n  <B>(that: Option<B>): <_>(self: Option<_>) => Option<B>\n} = flatMap_.andThen(FlatMap)\n\n/**\n * @category transforming\n * @since 1.0.0\n */\nexport const composeKleisliArrow: {\n  <A, B, C>(afb: (a: A) => Option<B>, bfc: (b: B) => Option<C>): (a: A) => Option<C>\n  <B, C>(bfc: (b: B) => Option<C>): <A>(afb: (a: A) => Option<B>) => (a: A) => Option<C>\n} = flatMap_.composeKleisliArrow(FlatMap)\n\n/**\n * @since 1.0.0\n */\nexport const Chainable: chainable.Chainable<OptionTypeLambda> = {\n  imap,\n  map,\n  flatMap\n}\n\n/**\n * Sequences the specified `that` `Option` but ignores its value.\n *\n * It is useful when we want to chain multiple operations, but only care about the result of `self`.\n *\n * @param that - The `Option` that will be ignored in the chain and discarded\n * @param self - The `Option` we care about\n *\n * @category transforming\n * @since 1.0.0\n */\nexport const andThenDiscard: {\n  <A, _>(self: Option<A>, that: Option<_>): Option<A>\n  <_>(that: Option<_>): <A>(self: Option<A>) => Option<A>\n} = chainable.andThenDiscard(Chainable)\n\n/**\n * Applies the provided function `f` to the value of the `Option` if it is `Some` and returns the original `Option`\n * unless `f` returns `None`, in which case it returns `None`.\n *\n * This function is useful for performing additional computations on the value of the input `Option` without affecting its value.\n *\n * @param f - Function to apply to the value of the `Option` if it is `Some`\n * @param self - The `Option` to apply the function to\n *\n * @category transforming\n * @since 1.0.0\n */\nexport const tap: {\n  <A, _>(self: Option<A>, f: (a: A) => Option<_>): Option<A>\n  <A, _>(f: (a: A) => Option<_>): (self: Option<A>) => Option<A>\n} = chainable.tap(Chainable)\n\n/**\n * Useful for debugging purposes, the `onSome` callback is called with the value of `self` if it is a `Some`.\n *\n * @param self - the `Option` to inspect\n * @param onSome - callback function that is called with the value of `self` if it is a `Some`\n *\n * @category debugging\n * @since 1.0.0\n */\nexport const inspectSome: {\n  <A>(onSome: (a: A) => void): (self: Option<A>) => Option<A>\n  <A>(self: Option<A>, onSome: (a: A) => void): Option<A>\n} = dual(2, <A>(self: Option<A>, onSome: (a: A) => void): Option<A> => {\n  if (isSome(self)) {\n    onSome(self.value)\n  }\n  return self\n})\n\n/**\n * Useful for debugging purposes, the `onNone` callback is is called if `self` is a `None`.\n *\n * @param self - the `Option` to inspect\n * @param onNone - callback function that is is called if `self` is a `None`\n *\n * @category debugging\n * @since 1.0.0\n */\nexport const inspectNone: {\n  (onNone: () => void): <A>(self: Option<A>) => Option<A>\n  <A>(self: Option<A>, onNone: () => void): Option<A>\n} = dual(2, <A>(self: Option<A>, onNone: () => void): Option<A> => {\n  if (isNone(self)) {\n    onNone()\n  }\n  return self\n})\n\n/**\n * @since 1.0.0\n */\nexport const Monad: monad.Monad<OptionTypeLambda> = {\n  imap,\n  of,\n  map,\n  flatMap\n}\n\nconst product = <A, B>(self: Option<A>, that: Option<B>): Option<[A, B]> =>\n  isSome(self) && isSome(that) ? some([self.value, that.value]) : none()\n\nconst productMany = <A>(\n  self: Option<A>,\n  collection: Iterable<Option<A>>\n): Option<[A, ...Array<A>]> => {\n  if (isNone(self)) {\n    return none()\n  }\n  const out: [A, ...Array<A>] = [self.value]\n  for (const o of collection) {\n    if (isNone(o)) {\n      return none()\n    }\n    out.push(o.value)\n  }\n  return some(out)\n}\n\n/**\n * @since 1.0.0\n */\nexport const SemiProduct: semiProduct.SemiProduct<OptionTypeLambda> = {\n  imap,\n  product,\n  productMany\n}\n\n/**\n * @since 1.0.0\n */\nexport const Product: product_.Product<OptionTypeLambda> = {\n  of,\n  imap,\n  product,\n  productMany,\n  productAll: all\n}\n\n/**\n * Similar to `Promise.all` but operates on `Option`s.\n *\n * ```\n * [Option<A>, Option<B>, ...] -> Option<[A, B, ...]>\n * ```\n *\n * Takes a tuple of `Option`s and returns an `Option` of a tuple of values.\n *\n * @param elements - the tuple of `Option`s to be sequenced.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.tuple(O.some(1), O.some(\"hello\")), O.some([1, \"hello\"]))\n * assert.deepStrictEqual(O.tuple(O.some(1), O.none()), O.none())\n *\n * @category combining\n * @since 1.0.0\n */\nexport const tuple: <T extends ReadonlyArray<Option<any>>>(\n  ...elements: T\n) => Option<{ [I in keyof T]: [T[I]] extends [Option<infer A>] ? A : never }> = product_.tuple(\n  Product\n)\n\n/**\n * Takes a struct of `Option`s and returns an `Option` of a struct of values.\n *\n * @param fields - the struct of `Option`s to be sequenced.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.struct({ a: O.some(1), b: O.some(\"hello\") }), O.some({ a: 1, b: \"hello\" }))\n * assert.deepStrictEqual(O.struct({ a: O.some(1), b: O.none() }), O.none())\n *\n * @category combining\n * @since 1.0.0\n */\nexport const struct: <R extends Record<string, Option<any>>>(\n  fields: R\n) => Option<{ [K in keyof R]: [R[K]] extends [Option<infer A>] ? A : never }> = product_\n  .struct(Product)\n\n/**\n * @since 1.0.0\n */\nexport const SemiApplicative: semiApplicative.SemiApplicative<OptionTypeLambda> = {\n  imap,\n  map,\n  product,\n  productMany\n}\n\n/**\n * Monoid that models the combination of values that may be absent, elements that are `None` are ignored\n * while elements that are `Some` are combined using the provided `Semigroup`.\n *\n * The `empty` value is `none()`.\n *\n * @param Semigroup - The `Semigroup` used to combine two values of type `A`.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n * import * as N from '@fp-ts/core/Number'\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * const M = O.getOptionalMonoid(N.SemigroupSum)\n *\n * assert.deepStrictEqual(M.combine(O.none(), O.none()), O.none())\n * assert.deepStrictEqual(M.combine(O.some(1), O.none()), O.some(1))\n * assert.deepStrictEqual(M.combine(O.none(), O.some(1)), O.some(1))\n * assert.deepStrictEqual(M.combine(O.some(1), O.some(2)), O.some(3))\n *\n * @since 1.0.0\n */\nexport const getOptionalMonoid = <A>(\n  Semigroup: Semigroup<A>\n): Monoid<Option<A>> =>\n  monoid.fromSemigroup(\n    semigroup.make((self, that) =>\n      isNone(self) ? that : isNone(that) ? self : some(Semigroup.combine(self.value, that.value))\n    ),\n    none()\n  )\n\n/**\n * Zips two `Option` values together using a provided function, returning a new `Option` of the result.\n *\n * @param self - The left-hand side of the zip operation\n * @param that - The right-hand side of the zip operation\n * @param f - The function used to combine the values of the two `Option`s\n *\n * @category combining\n * @since 1.0.0\n */\nexport const zipWith: {\n  <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>\n  <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>\n} = semiApplicative.zipWith(SemiApplicative)\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const ap: {\n  <A, B>(self: Option<(a: A) => B>, that: Option<A>): Option<B>\n  <A>(that: Option<A>): <B>(self: Option<(a: A) => B>) => Option<B>\n} = semiApplicative.ap(SemiApplicative)\n\n/**\n * Semigroup that models the combination of computations that can fail, if at least one element is `None`\n * then the resulting combination is `None`, otherwise if all elements are `Some` then the resulting combination\n * is the combination of the wrapped elements using the provided `Semigroup`.\n *\n * See also `getFailureMonoid` if you need a `Monoid` instead of a `Semigroup`.\n *\n * @category combining\n * @since 1.0.0\n */\nexport const getFailureSemigroup: <A>(S: Semigroup<A>) => Semigroup<Option<A>> = semiApplicative\n  .getSemigroup(SemiApplicative)\n\n/**\n * @since 1.0.0\n */\nexport const Applicative: applicative.Applicative<OptionTypeLambda> = {\n  imap,\n  of,\n  map,\n  product,\n  productMany,\n  productAll: all\n}\n\n/**\n * Monoid that models the combination of computations that can fail, if at least one element is `None`\n * then the resulting combination is `None`, otherwise if all elements are `Some` then the resulting combination\n * is the combination of the wrapped elements using the provided `Monoid`.\n *\n * The `empty` value is `some(M.empty)`.\n *\n * See also `getFailureSemigroup` if you need a `Semigroup` instead of a `Monoid`.\n *\n * @category combining\n * @since 1.0.0\n */\nexport const getFailureMonoid: <A>(M: Monoid<A>) => Monoid<Option<A>> = applicative.getMonoid(\n  Applicative\n)\n\nconst coproduct = <A, B>(self: Option<A>, that: Option<B>): Option<A | B> =>\n  isSome(self) ? self : that\n\nconst coproductMany = <A>(self: Option<A>, collection: Iterable<Option<A>>): Option<A> =>\n  isSome(self) ? self : firstSomeOf(collection)\n\n/**\n * @since 1.0.0\n */\nexport const SemiCoproduct: semiCoproduct.SemiCoproduct<OptionTypeLambda> = {\n  imap,\n  coproduct,\n  coproductMany\n}\n\n/**\n * Semigroup returning the first `Some` value encountered.\n *\n * @category combining\n * @since 1.0.0\n */\nexport const getFirstSomeSemigroup: <A>() => Semigroup<Option<A>> = semiCoproduct.getSemigroup(\n  SemiCoproduct\n)\n\n/**\n * @since 1.0.0\n */\nexport const Coproduct: coproduct_.Coproduct<OptionTypeLambda> = {\n  imap,\n  coproduct,\n  coproductMany,\n  zero: none,\n  coproductAll: firstSomeOf\n}\n\n/**\n * @since 1.0.0\n */\nexport const SemiAlternative: semiAlternative.SemiAlternative<OptionTypeLambda> = {\n  map,\n  imap,\n  coproduct,\n  coproductMany\n}\n\n/**\n * @since 1.0.0\n */\nexport const Alternative: alternative.Alternative<OptionTypeLambda> = {\n  map,\n  imap,\n  coproduct,\n  coproductMany,\n  coproductAll: firstSomeOf,\n  zero: none\n}\n\n/**\n * Reduces an `Iterable` of `Option<A>` to a single value of type `B`, elements that are `None` are ignored.\n *\n * @param self - The Iterable of `Option<A>` to be reduced.\n * @param b - The initial value of the accumulator.\n * @param f - The reducing function that takes the current accumulator value and the unwrapped value of an `Option<A>`.\n *\n * @example\n * import { some, none, reduceCompact } from '@fp-ts/core/Option'\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * const iterable = [some(1), none(), some(2), none()]\n * assert.deepStrictEqual(pipe(iterable, reduceCompact(0, (b, a) => b + a)), 3)\n *\n * @category folding\n * @since 1.0.0\n */\nexport const reduceCompact: {\n  <B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<Option<A>>) => B\n  <A, B>(self: Iterable<Option<A>>, b: B, f: (b: B, a: A) => B): B\n} = dual(\n  3,\n  <A, B>(self: Iterable<Option<A>>, b: B, f: (b: B, a: A) => B): B => {\n    let out: B = b\n    for (const oa of self) {\n      if (isSome(oa)) {\n        out = f(out, oa.value)\n      }\n    }\n    return out\n  }\n)\n\n/**\n * @since 1.0.0\n */\nexport const Foldable: foldable.Foldable<OptionTypeLambda> = {\n  reduce: dual(\n    3,\n    <A, B>(self: Option<A>, b: B, f: (b: B, a: A) => B): B => isNone(self) ? b : f(b, self.value)\n  )\n}\n\n/**\n * Transforms an `Option` into an `Array`.\n * If the input is `None`, an empty array is returned.\n * If the input is `Some`, the value is wrapped in an array.\n *\n * @param self - The `Option` to convert to an array.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.toArray(O.some(1)), [1])\n * assert.deepStrictEqual(O.toArray(O.none()), [])\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const toArray: <A>(self: Option<A>) => Array<A> = foldable.toArray(Foldable)\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const partitionMap: {\n  <A, B, C>(f: (a: A) => Either<B, C>): (self: Option<A>) => [Option<B>, Option<C>]\n  <A, B, C>(self: Option<A>, f: (a: A) => Either<B, C>): [Option<B>, Option<C>]\n} = dual(2, <A, B, C>(\n  self: Option<A>,\n  f: (a: A) => Either<B, C>\n): [Option<B>, Option<C>] => {\n  if (isNone(self)) {\n    return [none(), none()]\n  }\n  const e = f(self.value)\n  return either.isLeft(e) ? [some(e.left), none()] : [none(), some(e.right)]\n})\n\n/**\n * Maps over the value of an `Option` and filters out `None`s.\n *\n * Useful when in addition to filtering you also want to change the type of the `Option`.\n *\n * @param self - The `Option` to map over.\n * @param f - A function to apply to the value of the `Option`.\n *\n * @category filtering\n * @since 1.0.0\n */\nexport const filterMap: {\n  <A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>\n  <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>\n} = dual(\n  2,\n  <A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B> =>\n    isNone(self) ? none() : f(self.value)\n)\n\n/**\n * @since 1.0.0\n */\nexport const Filterable: filterable.Filterable<OptionTypeLambda> = {\n  partitionMap,\n  filterMap\n}\n\n/**\n * Filters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`.\n *\n * If you need to change the type of the `Option` in addition to filtering, see `filterMap`.\n *\n * @param predicate - A predicate function to apply to the `Option` value.\n * @param fb - The `Option` to filter.\n *\n * @category filtering\n * @since 1.0.0\n */\nexport const filter: {\n  <C extends A, B extends A, A = C>(self: Option<C>, refinement: (a: A) => a is B): Option<B>\n  <B extends A, A = B>(self: Option<B>, predicate: (a: A) => boolean): Option<B>\n  <C extends A, B extends A, A = C>(refinement: (a: A) => a is B): (self: Option<C>) => Option<B>\n  <B extends A, A = B>(predicate: (a: A) => boolean): (self: Option<B>) => Option<B>\n} = filterable.filter(Filterable)\n\n/**\n * Applies an `Option` value to an effectful function that returns an `F` value.\n *\n * @param F - {@link applicative.Applicative} instance\n * @param self - The `Option` value.\n * @param f - An effectful function that returns an `F` value.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n * import * as E from \"@fp-ts/core/Either\"\n *\n * const traverse = O.traverse(E.Applicative)\n * const f = (n: number) => n >= 0 ? E.right(1) : E.left(\"negative\")\n *\n * assert.deepStrictEqual(traverse(O.some(1), f), E.right(O.some(1)))\n * assert.deepStrictEqual(traverse(O.some(-1), f), E.left(\"negative\"))\n * assert.deepStrictEqual(traverse(O.none(), f), E.right(O.none()))\n *\n * @category combining\n * @since 1.0.0\n */\nexport const traverse = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): {\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): (self: Option<A>) => Kind<F, R, O, E, Option<B>>\n  <A, R, O, E, B>(self: Option<A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Option<B>>\n} =>\n  dual(\n    2,\n    <A, R, O, E, B>(\n      self: Option<A>,\n      f: (a: A) => Kind<F, R, O, E, B>\n    ): Kind<F, R, O, E, Option<B>> => isNone(self) ? F.of(none()) : F.map(f(self.value), some)\n  )\n\n/**\n * @since 1.0.0\n */\nexport const Traversable: traversable.Traversable<OptionTypeLambda> = {\n  traverse\n}\n\n/**\n * Combines an `Option` of an `F`-structure to an `F`-structure of an `Option` with the same inner type.\n *\n * @param F - {@link applicative.Applicative} instance\n * @param self - `Option` of Kind `F`\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n * import * as E from \"@fp-ts/core/Either\"\n *\n * const sequence = O.sequence(E.Applicative)\n *\n * assert.deepStrictEqual(sequence(O.some(E.right(1))), E.right(O.some(1)))\n * assert.deepStrictEqual(sequence(O.some(E.left(\"error\"))), E.left(\"error\"))\n * assert.deepStrictEqual(sequence(O.none()), E.right(O.none()))\n *\n * @category combining\n * @since 1.0.0\n */\nexport const sequence: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => <R, O, E, A>(self: Option<Kind<F, R, O, E, A>>) => Kind<F, R, O, E, Option<A>> = traversable\n  .sequence(Traversable)\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(\n    self: Option<A>,\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Option<A>>\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): (self: Option<A>) => Kind<F, R, O, E, Option<A>>\n} = traversable.traverseTap(Traversable)\n\n/**\n * @example\n * import { none, some, getEquivalence } from '@fp-ts/core/Option'\n * import * as N from '@fp-ts/core/Number'\n *\n * const isEquivalent = getEquivalence(N.Equivalence)\n * assert.deepStrictEqual(isEquivalent(none(), none()), true)\n * assert.deepStrictEqual(isEquivalent(none(), some(1)), false)\n * assert.deepStrictEqual(isEquivalent(some(1), none()), false)\n * assert.deepStrictEqual(isEquivalent(some(1), some(2)), false)\n * assert.deepStrictEqual(isEquivalent(some(1), some(1)), true)\n *\n * @category equivalence\n * @since 1.0.0\n */\nexport const getEquivalence = <A>(E: Equivalence<A>): Equivalence<Option<A>> =>\n  equivalence.make((x, y) =>\n    x === y || (isNone(x) ? isNone(y) : isNone(y) ? false : E(x.value, y.value))\n  )\n\n/**\n * The `Order` instance allows `Option` values to be compared with\n * `compare`, whenever there is an `Order` instance for\n * the type the `Option` contains.\n *\n * `None` is considered to be less than any `Some` value.\n *\n * @example\n * import { none, some, getOrder } from '@fp-ts/core/Option'\n * import * as N from '@fp-ts/core/Number'\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * const O = getOrder(N.Order)\n * assert.deepStrictEqual(O.compare(none(), none()), 0)\n * assert.deepStrictEqual(O.compare(none(), some(1)), -1)\n * assert.deepStrictEqual(O.compare(some(1), none()), 1)\n * assert.deepStrictEqual(O.compare(some(1), some(2)), -1)\n * assert.deepStrictEqual(O.compare(some(1), some(1)), 0)\n *\n * @category sorting\n * @since 1.0.0\n */\nexport const getOrder = <A>(O: Order<A>): Order<Option<A>> =>\n  order.make((self, that) =>\n    isSome(self) ? (isSome(that) ? O.compare(self.value, that.value) : 1) : -1\n  )\n\n/**\n * Lifts a binary function into `Option`.\n *\n * @param f - The function to lift.\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const lift2: <A, B, C>(f: (a: A, b: B) => C) => {\n  (self: Option<A>, that: Option<B>): Option<C>\n  (that: Option<B>): (self: Option<A>) => Option<C>\n} = semiApplicative.lift2(SemiApplicative)\n\n/**\n * Transforms a `Predicate` function into a `Some` of the input value if the predicate returns `true` or `None`\n * if the predicate returns `false`.\n *\n * @param predicate - A `Predicate` function that takes in a value of type `A` and returns a boolean.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * const getOption = O.liftPredicate((n: number) => n >= 0)\n *\n * assert.deepStrictEqual(getOption(-1), O.none())\n * assert.deepStrictEqual(getOption(1), O.some(1))\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const liftPredicate: {\n  <C extends A, B extends A, A = C>(refinement: Refinement<A, B>): (c: C) => Option<B>\n  <B extends A, A = B>(predicate: Predicate<A>): (b: B) => Option<B>\n} = <B extends A, A = B>(predicate: Predicate<A>) => (b: B) => predicate(b) ? some(b) : none()\n\n/**\n * Lifts an `Either` function to an `Option` function.\n *\n * @param f - Any variadic function that returns an `Either`.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n * import * as E from \"@fp-ts/core/Either\"\n *\n * const parse = (s: string) =>\n *   isNaN(+s) ? E.left(`Error: ${s} is not a number`) : E.right(+s)\n *\n * const parseNumber = O.liftEither(parse)\n *\n * assert.deepEqual(parseNumber('12'), O.some(12))\n * assert.deepEqual(parseNumber('not a number'), O.none())\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const liftEither = <A extends ReadonlyArray<unknown>, E, B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A): Option<B> => fromEither(f(...a))\n\n/**\n * Returns a function that checks if an `Option` contains a given value using a provided `Equivalence` instance.\n *\n * @param equivalent - An `Equivalence` instance to compare values of the `Option`.\n * @param self - The `Option` to apply the comparison to.\n * @param a - The value to compare against the `Option`.\n *\n * @example\n * import { some, none, contains } from '@fp-ts/core/Option'\n * import { Equivalence } from '@fp-ts/core/Number'\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(pipe(some(2), contains(Equivalence)(2)), true)\n * assert.deepStrictEqual(pipe(some(1), contains(Equivalence)(2)), false)\n * assert.deepStrictEqual(pipe(none(), contains(Equivalence)(2)), false)\n *\n * @since 1.0.0\n */\nexport const contains = <A>(isEquivalent: (self: A, that: A) => boolean): {\n  (a: A): (self: Option<A>) => boolean\n  (self: Option<A>, a: A): boolean\n} => dual(2, (self: Option<A>, a: A): boolean => isNone(self) ? false : isEquivalent(self.value, a))\n\n/**\n * Check if a value in an `Option` type meets a certain predicate.\n *\n * @param self - The `Option` to check.\n * @param predicate - The condition to check.\n *\n * @example\n * import { some, none, exists } from '@fp-ts/core/Option'\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * const isEven = (n: number) => n % 2 === 0\n *\n * assert.deepStrictEqual(pipe(some(2), exists(isEven)), true)\n * assert.deepStrictEqual(pipe(some(1), exists(isEven)), false)\n * assert.deepStrictEqual(pipe(none(), exists(isEven)), false)\n *\n * @since 1.0.0\n */\nexport const exists: {\n  <A>(predicate: Predicate<A>): (self: Option<A>) => boolean\n  <A>(self: Option<A>, predicate: Predicate<A>): boolean\n} = dual(\n  2,\n  <A>(self: Option<A>, predicate: Predicate<A>): boolean =>\n    isNone(self) ? false : predicate(self.value)\n)\n\n// -------------------------------------------------------------------------------------\n// math\n// -------------------------------------------------------------------------------------\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const sum: {\n  (self: Option<number>, that: Option<number>): Option<number>\n  (that: Option<number>): (self: Option<number>) => Option<number>\n} = lift2(N.sum)\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const multiply: {\n  (self: Option<number>, that: Option<number>): Option<number>\n  (that: Option<number>): (self: Option<number>) => Option<number>\n} = lift2(N.multiply)\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const subtract: {\n  (self: Option<number>, that: Option<number>): Option<number>\n  (that: Option<number>): (self: Option<number>) => Option<number>\n} = lift2(N.subtract)\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const divide: {\n  (self: Option<number>, that: Option<number>): Option<number>\n  (that: Option<number>): (self: Option<number>) => Option<number>\n} = lift2(N.divide)\n\n/**\n * Sum all numbers in an iterable of `Option<number>` ignoring the `None` values.\n *\n * @param self - The iterable of `Option<number>` to be summed.\n *\n * @example\n * import { sumCompact, some, none } from '@fp-ts/core/Option'\n *\n * const iterable = [some(2), none(), some(3), none()]\n * assert.deepStrictEqual(sumCompact(iterable), 5)\n *\n * @category math\n * @since 1.0.0\n */\nexport const sumCompact = (self: Iterable<Option<number>>): number => {\n  let out = 0\n  for (const oa of self) {\n    if (isSome(oa)) {\n      out += oa.value\n    }\n  }\n  return out\n}\n\n/**\n * Multiply all numbers in an iterable of `Option<number>` ignoring the `None` values.\n *\n * @param self - The iterable of `Option<number>` to be multiplied.\n *\n * @example\n * import { multiplyCompact, some, none } from '@fp-ts/core/Option'\n *\n * const iterable = [some(2), none(), some(3), none()]\n * assert.deepStrictEqual(multiplyCompact(iterable), 6)\n *\n * @category math\n * @since 1.0.0\n */\nexport const multiplyCompact = (self: Iterable<Option<number>>): number => {\n  let out = 1\n  for (const oa of self) {\n    if (isSome(oa)) {\n      const a: number = oa.value\n      if (a === 0) {\n        return 0\n      }\n      out *= a\n    }\n  }\n  return out\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const tupled: <A>(self: Option<A>) => Option<[A]> = invariant.tupled(Invariant)\n\n/**\n * Appends an element to the end of a tuple wrapped in an `Option` type.\n *\n * @param self - The option of a tuple to which an element needs to be added.\n * @param that - The element which needs to be added to the tuple.\n *\n * @example\n * import * as O from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(O.appendElement(O.some([1, 2]), O.some(3)), O.some([1, 2, 3]))\n * assert.deepStrictEqual(O.appendElement(O.some([1, 2]), O.none()), O.none())\n *\n * @category do notation\n * @since 1.0.0\n */\nexport const appendElement: {\n  <A extends ReadonlyArray<any>, B>(self: Option<A>, that: Option<B>): Option<[...A, B]>\n  <B>(that: Option<B>): <A extends ReadonlyArray<any>>(self: Option<A>) => Option<[...A, B]>\n} = semiProduct.appendElement(SemiProduct)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bindTo: {\n  <N extends string>(name: N): <A>(self: Option<A>) => Option<{ [K in N]: A }>\n  <A, N extends string>(self: Option<A>, name: N): Option<{ [K in N]: A }>\n} = invariant.bindTo(Invariant)\n\nconst let_: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): (self: Option<A>) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: Option<A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = covariant.let(Covariant)\n\nexport {\n  /**\n   * @category do notation\n   * @since 1.0.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bind: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Option<B>\n  ): (self: Option<A>) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: Option<A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Option<B>\n  ): Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = chainable.bind(Chainable)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const Do: Option<{}> = of_.Do(Of)\n\n/**\n * A variant of `bind` that sequentially ignores the scope.\n *\n * @category do notation\n * @since 1.0.0\n */\nexport const andThenBind: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    that: Option<B>\n  ): (self: Option<A>) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: Option<A>,\n    name: Exclude<N, keyof A>,\n    that: Option<B>\n  ): Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = semiProduct.andThenBind(SemiProduct)\n"
  },
  {
    "path": "src/Ordering.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { LazyArg } from \"@fp-ts/core/Function\"\nimport { dual } from \"@fp-ts/core/Function\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * @category model\n * @since 1.0.0\n */\nexport type Ordering = -1 | 0 | 1\n\n/**\n * Inverts the ordering of the input `Ordering`.\n *\n * @param o - The input `Ordering`.\n *\n * @example\n * import { reverse } from \"@fp-ts/core/Ordering\"\n *\n * assert.deepStrictEqual(reverse(1), -1)\n * assert.deepStrictEqual(reverse(-1), 1)\n * assert.deepStrictEqual(reverse(0), 0)\n *\n * @since 1.0.0\n */\nexport const reverse = (o: Ordering): Ordering => (o === -1 ? 1 : o === 1 ? -1 : 0)\n\n/**\n * Depending on the `Ordering` parameter given to it, returns a value produced by one of the 3 functions provided as parameters.\n *\n * @param self - The `Ordering` parameter to match against.\n * @param onLessThan - A function that will be called if the `Ordering` parameter is `-1`.\n * @param onEqual - A function that will be called if the `Ordering` parameter is `0`.\n * @param onGreaterThan - A function that will be called if the `Ordering` parameter is `1`.\n *\n * @example\n * import { match } from \"@fp-ts/core/Ordering\"\n * import { constant } from \"@fp-ts/core/Function\"\n *\n * const toMessage = match(\n *   constant('less than'),\n *   constant('equal'),\n *   constant('greater than')\n * )\n *\n * assert.deepStrictEqual(toMessage(-1), \"less than\")\n * assert.deepStrictEqual(toMessage(0), \"equal\")\n * assert.deepStrictEqual(toMessage(1), \"greater than\")\n *\n * @category pattern matching\n * @since 1.0.0\n */\nexport const match: {\n  <A, B, C = B>(\n    onLessThan: LazyArg<A>,\n    onEqual: LazyArg<B>,\n    onGreaterThan: LazyArg<C>\n  ): (self: Ordering) => A | B | C\n  <A, B, C = B>(\n    o: Ordering,\n    onLessThan: LazyArg<A>,\n    onEqual: LazyArg<B>,\n    onGreaterThan: LazyArg<C>\n  ): A | B | C\n} = dual(4, <A, B, C = B>(\n  self: Ordering,\n  onLessThan: LazyArg<A>,\n  onEqual: LazyArg<B>,\n  onGreaterThan: LazyArg<C>\n): A | B | C => self === -1 ? onLessThan() : self === 0 ? onEqual() : onGreaterThan())\n\n/**\n * `Semigroup` instance for `Ordering`, returns the left-most non-zero `Ordering`.\n *\n * @example\n * import { Semigroup } from \"@fp-ts/core/Ordering\"\n *\n * assert.deepStrictEqual(Semigroup.combine(0, -1), -1)\n * assert.deepStrictEqual(Semigroup.combine(0, 1), 1)\n * assert.deepStrictEqual(Semigroup.combine(1, -1), 1)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const Semigroup: semigroup.Semigroup<Ordering> = semigroup.make(\n  (self, that) => self !== 0 ? self : that,\n  (self, collection) => {\n    let ordering = self\n    if (ordering !== 0) {\n      return ordering\n    }\n    for (ordering of collection) {\n      if (ordering !== 0) {\n        return ordering\n      }\n    }\n    return ordering\n  }\n)\n\n/**\n * `Monoid` instance for `Ordering`, returns the left-most non-zero `Ordering`.\n *\n * The `empty` value is `0`.\n *\n * @example\n * import { Monoid } from \"@fp-ts/core/Ordering\"\n *\n * assert.deepStrictEqual(Monoid.combine(Monoid.empty, -1), -1)\n * assert.deepStrictEqual(Monoid.combine(Monoid.empty, 1), 1)\n * assert.deepStrictEqual(Monoid.combine(1, -1), 1)\n *\n * @category instances\n * @since 1.0.0\n */\nexport const Monoid: monoid.Monoid<Ordering> = monoid.fromSemigroup(Semigroup, 0)\n"
  },
  {
    "path": "src/Predicate.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { constFalse, constTrue, dual, isFunction as isFunction_ } from \"@fp-ts/core/Function\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as readonlyArray from \"@fp-ts/core/internal/ReadonlyArray\"\nimport * as contravariant from \"@fp-ts/core/typeclass/Contravariant\"\nimport * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as of_ from \"@fp-ts/core/typeclass/Of\"\nimport * as product_ from \"@fp-ts/core/typeclass/Product\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport interface Predicate<A> {\n  (a: A): boolean\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface PredicateTypeLambda extends TypeLambda {\n  readonly type: Predicate<this[\"Target\"]>\n}\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport interface Refinement<A, B extends A> {\n  (a: A): a is B\n}\n\n/**\n * Given a `Predicate<A>` returns a `Predicate<B>`\n *\n * @param self - the `Predicate<A>` to be transformed to `Predicate<B>`.\n * @param f - a function to transform `B` to `A`.\n *\n * @example\n * import * as P from \"@fp-ts/core/Predicate\"\n * import * as N from \"@fp-ts/core/Number\"\n *\n * const minLength3 = P.contramap(N.greaterThan(2), (s: string) => s.length)\n *\n * assert.deepStrictEqual(minLength3(\"a\"), false)\n * assert.deepStrictEqual(minLength3(\"aa\"), false)\n * assert.deepStrictEqual(minLength3(\"aaa\"), true)\n * assert.deepStrictEqual(minLength3(\"aaaa\"), true)\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const contramap: {\n  <B, A>(f: (b: B) => A): (self: Predicate<A>) => Predicate<B>\n  <A, B>(self: Predicate<A>, f: (b: B) => A): Predicate<B>\n} = dual(2, <A, B>(self: Predicate<A>, f: (b: B) => A): Predicate<B> => (b) => self(f(b)))\n\n/**\n * Tests if a value is a `string`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isString } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isString(\"a\"), true)\n *\n * assert.deepStrictEqual(isString(1), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isString = (input: unknown): input is string => typeof input === \"string\"\n\n/**\n * Tests if a value is a `number`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isNumber } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isNumber(2), true)\n *\n * assert.deepStrictEqual(isNumber(\"2\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNumber = (input: unknown): input is number => typeof input === \"number\"\n\n/**\n * Tests if a value is a `boolean`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isBoolean } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isBoolean(true), true)\n *\n * assert.deepStrictEqual(isBoolean(\"true\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isBoolean = (input: unknown): input is boolean => typeof input === \"boolean\"\n\n/**\n * Tests if a value is a `bigint`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isBigint } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isBigint(1n), true)\n *\n * assert.deepStrictEqual(isBigint(1), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isBigint = (input: unknown): input is bigint => typeof input === \"bigint\"\n\n/**\n * Tests if a value is a `symbol`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isSymbol } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isSymbol(Symbol.for(\"a\")), true)\n *\n * assert.deepStrictEqual(isSymbol(\"a\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isSymbol = (input: unknown): input is symbol => typeof input === \"symbol\"\n\n/**\n * Tests if a value is a `function`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isFunction } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isFunction(isFunction), true)\n *\n * assert.deepStrictEqual(isFunction(\"function\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isFunction: (input: unknown) => input is Function = isFunction_\n\n/**\n * Tests if a value is `undefined`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isUndefined } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isUndefined(undefined), true)\n *\n * assert.deepStrictEqual(isUndefined(null), false)\n * assert.deepStrictEqual(isUndefined(\"undefined\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isUndefined = (input: unknown): input is undefined => input === undefined\n\n/**\n * Tests if a value is not `undefined`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isNotUndefined } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isNotUndefined(null), true)\n * assert.deepStrictEqual(isNotUndefined(\"undefined\"), true)\n *\n * assert.deepStrictEqual(isNotUndefined(undefined), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNotUndefined = <A>(input: A): input is Exclude<A, undefined> => input !== undefined\n\n/**\n * Tests if a value is `undefined`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isNull } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isNull(null), true)\n *\n * assert.deepStrictEqual(isNull(undefined), false)\n * assert.deepStrictEqual(isNull(\"null\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNull = (input: unknown): input is null => input === null\n\n/**\n * Tests if a value is not `undefined`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isNotNull } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isNotNull(undefined), true)\n * assert.deepStrictEqual(isNotNull(\"null\"), true)\n *\n * assert.deepStrictEqual(isNotNull(null), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNotNull = <A>(input: A): input is Exclude<A, null> => input !== null\n\n/**\n * A guard that always fails.\n *\n * @param _ - The value to test.\n *\n * @example\n * import { isNever } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isNever(null), false)\n * assert.deepStrictEqual(isNever(undefined), false)\n * assert.deepStrictEqual(isNever({}), false)\n * assert.deepStrictEqual(isNever([]), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNever: (input: unknown) => input is never = (_: unknown): _ is never => false\n\n/**\n * A guard that always succeeds.\n *\n * @param _ - The value to test.\n *\n * @example\n * import { isUnknown } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isUnknown(null), true)\n * assert.deepStrictEqual(isUnknown(undefined), true)\n *\n * assert.deepStrictEqual(isUnknown({}), true)\n * assert.deepStrictEqual(isUnknown([]), true)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isUnknown: (input: unknown) => input is unknown = (_): _ is unknown => true\n\n/**\n * Tests if a value is an `object`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isObject } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isObject({}), true)\n * assert.deepStrictEqual(isObject([]), true)\n *\n * assert.deepStrictEqual(isObject(null), false)\n * assert.deepStrictEqual(isObject(undefined), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isObject = (input: unknown): input is object =>\n  typeof input === \"object\" && input != null\n\n/**\n * A guard that succeeds when the input is `null` or `undefined`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isNullable } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isNullable(null), true)\n * assert.deepStrictEqual(isNullable(undefined), true)\n *\n * assert.deepStrictEqual(isNullable({}), false)\n * assert.deepStrictEqual(isNullable([]), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNullable = <A>(input: A): input is Extract<A, null | undefined> =>\n  input === null || input === undefined\n\n/**\n * A guard that succeeds when the input is not `null` or `undefined`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isNotNullable } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isNotNullable({}), true)\n * assert.deepStrictEqual(isNotNullable([]), true)\n *\n * assert.deepStrictEqual(isNotNullable(null), false)\n * assert.deepStrictEqual(isNotNullable(undefined), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNotNullable = <A>(input: A): input is NonNullable<A> =>\n  input !== null && input !== undefined\n\n/**\n * A guard that succeeds when the input is an `Error`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isError } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isError(new Error()), true)\n *\n * assert.deepStrictEqual(isError(null), false)\n * assert.deepStrictEqual(isError({}), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isError = (input: unknown): input is Error => input instanceof Error\n\n/**\n * A guard that succeeds when the input is a `Date`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isDate } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isDate(new Date()), true)\n *\n * assert.deepStrictEqual(isDate(null), false)\n * assert.deepStrictEqual(isDate({}), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isDate = (input: unknown): input is Date => input instanceof Date\n\n/**\n * A guard that succeeds when the input is a record.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isRecord } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isRecord({}), true)\n * assert.deepStrictEqual(isRecord({ a: 1 }), true)\n *\n * assert.deepStrictEqual(isRecord([]), false)\n * assert.deepStrictEqual(isRecord([1, 2, 3]), false)\n * assert.deepStrictEqual(isRecord(null), false)\n * assert.deepStrictEqual(isRecord(undefined), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isRecord = (input: unknown): input is { [x: string | symbol]: unknown } =>\n  isObject(input) && !Array.isArray(input)\n\n/**\n * A guard that succeeds when the input is a readonly record.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isReadonlyRecord } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isReadonlyRecord({}), true)\n * assert.deepStrictEqual(isReadonlyRecord({ a: 1 }), true)\n *\n * assert.deepStrictEqual(isReadonlyRecord([]), false)\n * assert.deepStrictEqual(isReadonlyRecord([1, 2, 3]), false)\n * assert.deepStrictEqual(isReadonlyRecord(null), false)\n * assert.deepStrictEqual(isReadonlyRecord(undefined), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isReadonlyRecord: (\n  input: unknown\n) => input is { readonly [x: string | symbol]: unknown } = isRecord\n\n/**\n * @since 1.0.0\n */\nexport const compose: {\n  <A, B extends A, C extends B>(bc: Refinement<B, C>): (ab: Refinement<A, B>) => Refinement<A, C>\n  <A, B extends A, C extends B>(ab: Refinement<A, B>, bc: Refinement<B, C>): Refinement<A, C>\n} = dual(\n  2,\n  <A, B extends A, C extends B>(ab: Refinement<A, B>, bc: Refinement<B, C>): Refinement<A, C> =>\n    (a): a is C => ab(a) && bc(a)\n)\n\nconst imap = contravariant.imap<PredicateTypeLambda>(contramap)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Contravariant: contravariant.Contravariant<PredicateTypeLambda> = {\n  imap,\n  contramap\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<PredicateTypeLambda> = {\n  imap\n}\n\n/**\n * @since 1.0.0\n */\nexport const tupled: <A>(self: Predicate<A>) => Predicate<readonly [A]> = invariant.tupled(\n  Invariant\n) as any\n\n/**\n * @since 1.0.0\n */\nexport const of = <A>(_: A): Predicate<A> => isUnknown\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Of: of_.Of<PredicateTypeLambda> = {\n  of\n}\n\n/**\n * @since 1.0.0\n */\nexport const unit: Predicate<void> = of_.unit(Of)\n\nconst product = <A, B>(self: Predicate<A>, that: Predicate<B>): Predicate<readonly [A, B]> =>\n  ([a, b]) => self(a) && that(b)\n\nconst productAll = <A>(\n  collection: Iterable<Predicate<A>>\n): Predicate<ReadonlyArray<A>> => {\n  const predicates = readonlyArray.fromIterable(collection)\n  return (as) => {\n    const len = Math.min(as.length, predicates.length)\n    for (let i = 0; i < len; i++) {\n      if (predicates[i](as[i]) === false) {\n        return false\n      }\n    }\n    return true\n  }\n}\n\nconst productMany = <A>(\n  self: Predicate<A>,\n  collection: Iterable<Predicate<A>>\n): Predicate<readonly [A, ...Array<A>]> => {\n  const rest = productAll(collection)\n  return ([head, ...tail]) => self(head) === false ? false : rest(tail)\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiProduct: semiProduct.SemiProduct<PredicateTypeLambda> = {\n  imap,\n  product,\n  productMany\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Product: product_.Product<PredicateTypeLambda> = {\n  of,\n  imap,\n  product,\n  productMany,\n  productAll\n}\n\n/**\n * This function appends a predicate to a tuple-like predicate, allowing you to create a new predicate that includes\n * the original elements and the new one.\n *\n * @param self - The tuple-like predicate to append to.\n * @param that - The predicate to append.\n *\n * @since 1.0.0\n */\nexport const appendElement: {\n  <A extends ReadonlyArray<any>, B>(\n    self: Predicate<A>,\n    that: Predicate<B>\n  ): Predicate<readonly [...A, B]>\n  <B>(\n    that: Predicate<B>\n  ): <A extends ReadonlyArray<any>>(self: Predicate<A>) => Predicate<readonly [...A, B]>\n} = semiProduct.appendElement(SemiProduct) as any\n\n/**\n * Similar to `Promise.all` but operates on `Predicate`s.\n *\n * ```\n * [Predicate<A>, Predicate<B>, ...] -> Predicate<[A, B, ...]>\n * ```\n *\n * @since 1.0.0\n */\nexport const tuple: <T extends ReadonlyArray<Predicate<any>>>(\n  ...predicates: T\n) => Predicate<Readonly<{ [I in keyof T]: [T[I]] extends [Predicate<infer A>] ? A : never }>> =\n  product_.tuple(Product)\n\n/**\n * @since 1.0.0\n */\nexport const struct: <R extends Record<string, Predicate<any>>>(\n  predicates: R\n) => Predicate<{ readonly [K in keyof R]: [R[K]] extends [Predicate<infer A>] ? A : never }> =\n  product_.struct(Product)\n\n/**\n * Negates the result of a given predicate.\n *\n * @param self - A predicate.\n *\n * @example\n * import * as P from \"@fp-ts/core/Predicate\"\n * import * as N from \"@fp-ts/core/Number\"\n *\n * const isPositive = P.not(N.lessThan(0))\n *\n * assert.deepStrictEqual(isPositive(-1), false)\n * assert.deepStrictEqual(isPositive(0), true)\n * assert.deepStrictEqual(isPositive(1), true)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const not = <A>(self: Predicate<A>): Predicate<A> => (a) => !self(a)\n\n/**\n * Combines two predicates into a new predicate that returns `true` if at least one of the predicates returns `true`.\n *\n * @param self - A predicate.\n * @param that - A predicate.\n *\n * @example\n * import * as P from \"@fp-ts/core/Predicate\"\n * import * as N from \"@fp-ts/core/Number\"\n *\n * const nonZero = P.or(N.lessThan(0), N.greaterThan(0))\n *\n * assert.deepStrictEqual(nonZero(-1), true)\n * assert.deepStrictEqual(nonZero(0), false)\n * assert.deepStrictEqual(nonZero(1), true)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const or: {\n  <A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>\n  <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>\n} = dual(2, <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A> => (a) => self(a) || that(a))\n\n/**\n * Combines two predicates into a new predicate that returns `true` if both of the predicates returns `true`.\n *\n * @param self - A predicate.\n * @param that - A predicate.\n *\n * @example\n * import * as P from \"@fp-ts/core/Predicate\"\n *\n * const minLength = (n: number) => (s: string) => s.length >= n\n * const maxLength = (n: number) => (s: string) => s.length <= n\n *\n * const length = (n: number) => P.and(minLength(n), maxLength(n))\n *\n * assert.deepStrictEqual(length(2)(\"aa\"), true)\n * assert.deepStrictEqual(length(2)(\"a\"), false)\n * assert.deepStrictEqual(length(2)(\"aaa\"), false)\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const and: {\n  <A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>\n  <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>\n} = dual(2, <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A> => (a) => self(a) && that(a))\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getSemigroupAny = <A>(): Semigroup<Predicate<A>> =>\n  semigroup.make<Predicate<A>>(\n    or,\n    (self, collection) =>\n      a => {\n        if (self(a)) {\n          return true\n        }\n        for (const p of collection) {\n          if (p(a)) {\n            return true\n          }\n        }\n        return false\n      }\n  )\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getMonoidAny = <A>(): monoid.Monoid<Predicate<A>> =>\n  monoid.fromSemigroup(getSemigroupAny<A>(), constFalse)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getSemigroupAll = <A>(): Semigroup<Predicate<A>> =>\n  semigroup.make<Predicate<A>>(\n    and,\n    (self, collection) =>\n      a => {\n        if (!self(a)) {\n          return false\n        }\n        for (const p of collection) {\n          if (!p(a)) {\n            return false\n          }\n        }\n        return true\n      }\n  )\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getMonoidAll = <A>(): monoid.Monoid<Predicate<A>> =>\n  monoid.fromSemigroup(getSemigroupAll<A>(), constTrue)\n\n/**\n * @since 1.0.0\n */\nexport const all = <A>(collection: Iterable<Predicate<A>>): Predicate<A> =>\n  getMonoidAll<A>().combineAll(collection)\n\n/**\n * @since 1.0.0\n */\nexport const any = <A>(collection: Iterable<Predicate<A>>): Predicate<A> =>\n  getMonoidAny<A>().combineAll(collection)\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bindTo: {\n  <N extends string>(name: N): <A>(self: Predicate<A>) => Predicate<{ readonly [K in N]: A }>\n  <A, N extends string>(self: Predicate<A>, name: N): Predicate<{ readonly [K in N]: A }>\n} = invariant.bindTo(Invariant)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const Do: Predicate<{}> = of_.Do(Of)\n\n/**\n * A variant of `bind` that sequentially ignores the scope.\n *\n * @category do notation\n * @since 1.0.0\n */\nexport const andThenBind: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    that: Predicate<B>\n  ): (\n    self: Predicate<A>\n  ) => Predicate<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: Predicate<A>,\n    name: Exclude<N, keyof A>,\n    that: Predicate<B>\n  ): Predicate<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = semiProduct.andThenBind(SemiProduct)\n"
  },
  {
    "path": "src/ReadonlyArray.ts",
    "content": "/**\n * This module provides utility functions for working with arrays in TypeScript.\n *\n * @since 1.0.0\n */\n\nimport type { Either } from \"@fp-ts/core/Either\"\nimport * as E from \"@fp-ts/core/Either\"\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { LazyArg } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as readonlyArray from \"@fp-ts/core/internal/ReadonlyArray\"\nimport type { Option } from \"@fp-ts/core/Option\"\nimport * as O from \"@fp-ts/core/Option\"\nimport type { Predicate, Refinement } from \"@fp-ts/core/Predicate\"\nimport * as string from \"@fp-ts/core/String\"\nimport * as applicative from \"@fp-ts/core/typeclass/Applicative\"\nimport * as chainable from \"@fp-ts/core/typeclass/Chainable\"\nimport type { Coproduct } from \"@fp-ts/core/typeclass/Coproduct\"\nimport * as covariant from \"@fp-ts/core/typeclass/Covariant\"\nimport type * as filterable from \"@fp-ts/core/typeclass/Filterable\"\nimport * as flatMap_ from \"@fp-ts/core/typeclass/FlatMap\"\nimport * as foldable from \"@fp-ts/core/typeclass/Foldable\"\nimport * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport type * as monad from \"@fp-ts/core/typeclass/Monad\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as of_ from \"@fp-ts/core/typeclass/Of\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport type { Order } from \"@fp-ts/core/typeclass/Order\"\nimport type * as pointed from \"@fp-ts/core/typeclass/Pointed\"\nimport type * as product_ from \"@fp-ts/core/typeclass/Product\"\nimport * as semiApplicative from \"@fp-ts/core/typeclass/SemiApplicative\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\nimport * as traversable from \"@fp-ts/core/typeclass/Traversable\"\nimport * as traversableFilterable from \"@fp-ts/core/typeclass/TraversableFilterable\"\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface ReadonlyArrayTypeLambda extends TypeLambda {\n  readonly type: ReadonlyArray<this[\"Target\"]>\n}\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport type NonEmptyReadonlyArray<A> = readonly [A, ...Array<A>]\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport type NonEmptyArray<A> = [A, ...Array<A>]\n\n/**\n * Builds a `NonEmptyArray` from an non-empty collection of elements.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const make = <Elements extends NonEmptyArray<any>>(\n  ...elements: Elements\n): NonEmptyArray<Elements[number]> => elements\n\n/**\n * Return a `NonEmptyArray` of length `n` with element `i` initialized with `f(i)`.\n *\n * **Note**. `n` is normalized to an integer >= 1.\n *\n * @example\n * import { makeBy } from '@fp-ts/core/ReadonlyArray'\n *\n * assert.deepStrictEqual(makeBy(5, n => n * 2), [0, 2, 4, 6, 8])\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const makeBy = <A>(n: number, f: (i: number) => A): NonEmptyArray<A> => {\n  const max = Math.max(1, Math.floor(n))\n  const out: NonEmptyArray<A> = [f(0)]\n  for (let i = 1; i < max; i++) {\n    out.push(f(i))\n  }\n  return out\n}\n\n/**\n * Return a `NonEmptyArray` containing a range of integers, including both endpoints.\n *\n * @example\n * import { range } from '@fp-ts/core/ReadonlyArray'\n *\n * assert.deepStrictEqual(range(1, 3), [1, 2, 3])\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const range = (start: number, end: number): NonEmptyArray<number> =>\n  start <= end ? makeBy(end - start + 1, (i) => start + i) : [start]\n\n/**\n * Return a `NonEmptyArray` containing a value repeated the specified number of times.\n *\n * **Note**. `n` is normalized to an integer >= 1.\n *\n * @example\n * import { replicate } from '@fp-ts/core/ReadonlyArray'\n *\n * assert.deepStrictEqual(replicate(\"a\", 3), [\"a\", \"a\", \"a\"])\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const replicate: {\n  (n: number): <A>(a: A) => NonEmptyArray<A>\n  <A>(a: A, n: number): NonEmptyArray<A>\n} = dual(2, <A>(a: A, n: number): NonEmptyArray<A> => makeBy(n, () => a))\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromIterable: <A>(collection: Iterable<A>) => Array<A> = readonlyArray.fromIterable\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromOption: <A>(self: Option<A>) => Array<A> = O.toArray\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromEither: <E, A>(self: Either<E, A>) => Array<A> = E.toArray\n\n/**\n * @category pattern matching\n * @since 1.0.0\n */\nexport const match: {\n  <B, A, C = B>(\n    onEmpty: LazyArg<B>,\n    onNonEmpty: (self: NonEmptyReadonlyArray<A>) => C\n  ): (self: ReadonlyArray<A>) => B | C\n  <A, B, C = B>(\n    self: ReadonlyArray<A>,\n    onEmpty: LazyArg<B>,\n    onNonEmpty: (self: NonEmptyReadonlyArray<A>) => C\n  ): B | C\n} = dual(3, <A, B, C = B>(\n  self: ReadonlyArray<A>,\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (self: NonEmptyReadonlyArray<A>) => C\n): B | C => isNonEmpty(self) ? onNonEmpty(self) : onEmpty())\n\n/**\n * @category pattern matching\n * @since 1.0.0\n */\nexport const matchLeft: {\n  <B, A, C = B>(\n    onEmpty: LazyArg<B>,\n    onNonEmpty: (head: A, tail: Array<A>) => C\n  ): (self: ReadonlyArray<A>) => B | C\n  <A, B, C = B>(\n    self: ReadonlyArray<A>,\n    onEmpty: LazyArg<B>,\n    onNonEmpty: (head: A, tail: Array<A>) => C\n  ): B | C\n} = dual(3, <A, B, C = B>(\n  self: ReadonlyArray<A>,\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (head: A, tail: Array<A>) => C\n): B | C => isNonEmpty(self) ? onNonEmpty(headNonEmpty(self), tailNonEmpty(self)) : onEmpty())\n\n/**\n * @category pattern matching\n * @since 1.0.0\n */\nexport const matchRight: {\n  <B, A, C = B>(\n    onEmpty: LazyArg<B>,\n    onNonEmpty: (init: Array<A>, last: A) => C\n  ): (self: ReadonlyArray<A>) => B | C\n  <A, B, C = B>(\n    self: ReadonlyArray<A>,\n    onEmpty: LazyArg<B>,\n    onNonEmpty: (init: Array<A>, last: A) => C\n  ): B | C\n} = dual(3, <A, B, C = B>(\n  self: ReadonlyArray<A>,\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (init: Array<A>, last: A) => C\n): B | C =>\n  isNonEmpty(self) ?\n    onNonEmpty(initNonEmpty(self), lastNonEmpty(self)) :\n    onEmpty())\n\n/**\n * Prepend an element to the front of an `Iterable`, creating a new `NonEmptyArray`.\n *\n * @since 1.0.0\n */\nexport const prepend: {\n  <B>(head: B): <A>(self: Iterable<A>) => NonEmptyArray<A | B>\n  <A, B>(self: Iterable<A>, head: B): NonEmptyArray<A | B>\n} = dual(2, <A, B>(self: Iterable<A>, head: B): NonEmptyArray<A | B> => [head, ...self])\n\n/**\n * @since 1.0.0\n */\nexport const prependAll: {\n  <B>(that: Iterable<B>): <A>(self: Iterable<A>) => Array<A | B>\n  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B>\n} = dual(\n  2,\n  <A>(self: Iterable<A>, that: Iterable<A>): Array<A> =>\n    fromIterable(that).concat(fromIterable(self))\n)\n\n/**\n * @since 1.0.0\n */\nexport const prependAllNonEmpty: {\n  <B>(that: NonEmptyReadonlyArray<B>): <A>(self: Iterable<A>) => NonEmptyArray<A | B>\n  <B>(that: Iterable<B>): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>\n  <A, B>(self: Iterable<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<A | B>\n  <A, B>(self: NonEmptyReadonlyArray<A>, that: Iterable<B>): NonEmptyArray<A | B>\n} = dual(\n  2,\n  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B> => prependAll(self, that)\n)\n\n/**\n * Append an element to the end of an `Iterable`, creating a new `NonEmptyArray`.\n *\n * @since 1.0.0\n */\nexport const append: {\n  <B>(last: B): <A>(self: Iterable<A>) => NonEmptyArray<A | B>\n  <A, B>(self: Iterable<A>, last: B): NonEmptyArray<A | B>\n} = dual(2, <A, B>(self: Iterable<A>, last: B): Array<A | B> => [...self, last])\n\n/**\n * @since 1.0.0\n */\nexport const appendAll: {\n  <B>(that: Iterable<B>): <A>(self: Iterable<A>) => Array<A | B>\n  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B>\n} = dual(\n  2,\n  <A>(self: Iterable<A>, that: Iterable<A>): Array<A> =>\n    fromIterable(self).concat(fromIterable(that))\n)\n\n/**\n * @since 1.0.0\n */\nexport const appendAllNonEmpty: {\n  <B>(that: NonEmptyReadonlyArray<B>): <A>(self: Iterable<A>) => NonEmptyArray<A | B>\n  <B>(that: Iterable<B>): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>\n  <A, B>(self: Iterable<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<A | B>\n  <A, B>(self: NonEmptyReadonlyArray<A>, that: Iterable<B>): NonEmptyArray<A | B>\n} = dual(\n  2,\n  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<A | B> => appendAll(self, that)\n)\n\n/**\n * Reduce an `Iterable` from the left, keeping all intermediate results instead of only the final result.\n *\n * @category folding\n * @since 1.0.0\n */\nexport const scan: {\n  <B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<A>) => NonEmptyArray<B>\n  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A) => B): NonEmptyArray<B>\n} = dual(3, <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A) => B): NonEmptyArray<B> => {\n  const out: NonEmptyArray<B> = [b]\n  let i = 0\n  for (const a of self) {\n    out[i + 1] = f(out[i], a)\n    i++\n  }\n  return out\n})\n\n/**\n * Reduce an `Iterable` from the right, keeping all intermediate results instead of only the final result.\n *\n * @category folding\n * @since 1.0.0\n */\nexport const scanRight: {\n  <B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<A>) => NonEmptyArray<B>\n  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A) => B): NonEmptyArray<B>\n} = dual(3, <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A) => B): NonEmptyArray<B> => {\n  const input = fromIterable(self)\n  const out: NonEmptyArray<B> = new Array(input.length + 1) as any\n  out[input.length] = b\n  for (let i = input.length - 1; i >= 0; i--) {\n    out[i] = f(out[i + 1], input[i])\n  }\n  return out\n})\n\n/**\n * Determine if an `Array` is empty narrowing down the type to `[]`.\n *\n * @param self - The `Array` to check.\n *\n * @example\n * import { isEmptyArray } from \"@fp-ts/core/ReadonlyArray\"\n *\n * assert.deepStrictEqual(isEmptyArray([]), true);\n * assert.deepStrictEqual(isEmptyArray([1, 2, 3]), false);\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isEmptyArray = <A>(self: Array<A>): self is [] => self.length === 0\n\n/**\n * Determine if a `ReadonlyArray` is empty narrowing down the type to `readonly []`.\n *\n * @param self - The `ReadonlyArray` to check.\n *\n * @example\n * import { isEmpty } from \"@fp-ts/core/ReadonlyArray\"\n *\n * assert.deepStrictEqual(isEmpty([]), true);\n * assert.deepStrictEqual(isEmpty([1, 2, 3]), false);\n *\n * @category guards\n * @since 1.0.0\n */\n// TODO: rename to isEmptyReadonlyArray\nexport const isEmpty: <A>(self: ReadonlyArray<A>) => self is readonly [] = isEmptyArray as any\n\n/**\n * Determine if an `Array` is non empty narrowing down the type to `NonEmptyArray`.\n *\n * An `Array` is considered to be a `NonEmptyArray` if it contains at least one element.\n *\n * @param self - The `Array` to check.\n *\n * @example\n * import { isNonEmptyArray } from \"@fp-ts/core/ReadonlyArray\"\n *\n * assert.deepStrictEqual(isNonEmptyArray([]), false);\n * assert.deepStrictEqual(isNonEmptyArray([1, 2, 3]), true);\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isNonEmptyArray: <A>(self: Array<A>) => self is NonEmptyArray<A> =\n  readonlyArray.isNonEmptyArray\n\n/**\n * Determine if a `ReadonlyArray` is non empty narrowing down the type to `NonEmptyReadonlyArray`.\n *\n * A `ReadonlyArray` is considered to be a `NonEmptyReadonlyArray` if it contains at least one element.\n *\n * @param self - The `ReadonlyArray` to check.\n *\n * @example\n * import { isNonEmpty } from \"@fp-ts/core/ReadonlyArray\"\n *\n * assert.deepStrictEqual(isNonEmpty([]), false);\n * assert.deepStrictEqual(isNonEmpty([1, 2, 3]), true);\n *\n * @category guards\n * @since 1.0.0\n */\n// TODO: rename to isNonEmptyReadonlyArray\nexport const isNonEmpty: <A>(self: ReadonlyArray<A>) => self is NonEmptyReadonlyArray<A> =\n  readonlyArray.isNonEmptyArray\n\n/**\n * Return the number of elements in a `ReadonlyArray`.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const length = <A>(self: ReadonlyArray<A>): number => self.length\n\nconst isOutOfBound = <A>(i: number, as: ReadonlyArray<A>): boolean => i < 0 || i >= as.length\n\nconst clamp = <A>(i: number, as: ReadonlyArray<A>): number =>\n  Math.floor(Math.min(Math.max(0, i), as.length))\n\n/**\n * This function provides a safe way to read a value at a particular index from a `ReadonlyArray`.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const get: {\n  (index: number): <A>(self: ReadonlyArray<A>) => Option<A>\n  <A>(self: ReadonlyArray<A>, index: number): Option<A>\n} = dual(2, <A>(self: ReadonlyArray<A>, index: number): Option<A> => {\n  const i = Math.floor(index)\n  return isOutOfBound(i, self) ? O.none() : O.some(self[i])\n})\n\n/**\n * Gets an element unsafely, will throw on out of bounds.\n *\n * @since 1.0.0\n * @category unsafe\n */\nexport const unsafeGet: {\n  (index: number): <A>(self: ReadonlyArray<A>) => A\n  <A>(self: ReadonlyArray<A>, index: number): A\n} = dual(2, <A>(self: ReadonlyArray<A>, index: number): A => {\n  const i = Math.floor(index)\n  if (isOutOfBound(i, self)) {\n    throw new Error(`Index ${i} out of bounds`)\n  }\n  return self[i]\n})\n\n/**\n * Return a tuple containing the first element, and a new `Array` of the remaining elements, if any.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const unprepend = <A>(\n  self: NonEmptyReadonlyArray<A>\n): [A, Array<A>] => [headNonEmpty(self), tailNonEmpty(self)]\n\n/**\n * Return a tuple containing a copy of the `NonEmptyReadonlyArray` without its last element, and that last element.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const unappend = <A>(\n  self: NonEmptyReadonlyArray<A>\n): [Array<A>, A] => [initNonEmpty(self), lastNonEmpty(self)]\n\n/**\n * Get the first element of a `ReadonlyArray`, or `None` if the `ReadonlyArray` is empty.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const head: <A>(self: ReadonlyArray<A>) => Option<A> = get(0)\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const headNonEmpty: <A>(self: NonEmptyReadonlyArray<A>) => A = unsafeGet(0)\n\n/**\n * Get the last element in a `ReadonlyArray`, or `None` if the `ReadonlyArray` is empty.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const last = <A>(self: ReadonlyArray<A>): Option<A> =>\n  isNonEmpty(self) ? O.some(lastNonEmpty(self)) : O.none()\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const lastNonEmpty = <A>(self: NonEmptyReadonlyArray<A>): A => self[self.length - 1]\n\n/**\n * Get all but the first element of an `Iterable`, creating a new `Array`, or `None` if the `Iterable` is empty.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const tail = <A>(self: Iterable<A>): Option<Array<A>> => {\n  const input = fromIterable(self)\n  return isNonEmpty(input) ? O.some(tailNonEmpty(input)) : O.none()\n}\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const tailNonEmpty = <A>(self: NonEmptyReadonlyArray<A>): Array<A> => self.slice(1)\n\n/**\n * Get all but the last element of an `Iterable`, creating a new `Array`, or `None` if the `Iterable` is empty.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const init = <A>(self: Iterable<A>): Option<Array<A>> => {\n  const input = fromIterable(self)\n  return isNonEmpty(input) ? O.some(initNonEmpty(input)) : O.none()\n}\n\n/**\n * Get all but the last element of a non empty array, creating a new array.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const initNonEmpty = <A>(self: NonEmptyReadonlyArray<A>): Array<A> => self.slice(0, -1)\n\n/**\n * Keep only a max number of elements from the start of an `Iterable`, creating a new `Array`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const take: {\n  (n: number): <A>(self: Iterable<A>) => Array<A>\n  <A>(self: Iterable<A>, n: number): Array<A>\n} = dual(2, <A>(self: Iterable<A>, n: number): Array<A> => {\n  const input = fromIterable(self)\n  return input.slice(0, clamp(n, input))\n})\n\n/**\n * Keep only a max number of elements from the end of an `Iterable`, creating a new `Array`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const takeRight: {\n  (n: number): <A>(self: Iterable<A>) => Array<A>\n  <A>(self: Iterable<A>, n: number): Array<A>\n} = dual(2, <A>(self: Iterable<A>, n: number): Array<A> => {\n  const input = fromIterable(self)\n  const i = clamp(n, input)\n  return i === 0 ? [] : input.slice(-i)\n})\n\n/**\n * Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const takeWhile: {\n  <A, B extends A>(refinement: Refinement<A, B>): (self: Iterable<A>) => Array<B>\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => Array<B>\n  <A, B extends A>(self: Iterable<A>, refinement: Refinement<A, B>): Array<B>\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Array<B>\n} = dual(2, <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Array<B> => {\n  const out: Array<B> = []\n  for (const a of self) {\n    if (!predicate(a)) {\n      break\n    }\n    out.push(a)\n  }\n  return out\n})\n\nconst spanIndex = <A>(self: Iterable<A>, predicate: Predicate<A>): number => {\n  let i = 0\n  for (const a of self) {\n    if (!predicate(a)) {\n      break\n    }\n    i++\n  }\n  return i\n}\n\n/**\n * Split an `Iterable` into two parts:\n *\n * 1. the longest initial subarray for which all elements satisfy the specified predicate\n * 2. the remaining elements\n *\n * @category filtering\n * @since 1.0.0\n */\nexport const span: {\n  <A, B extends A>(\n    refinement: Refinement<A, B>\n  ): (self: Iterable<A>) => [init: Array<B>, rest: Array<A>]\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => [init: Array<B>, rest: Array<B>]\n  <A, B extends A>(\n    self: Iterable<A>,\n    refinement: Refinement<A, B>\n  ): [init: Array<B>, rest: Array<A>]\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): [init: Array<B>, rest: Array<B>]\n} = dual(\n  2,\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): [init: Array<B>, rest: Array<B>] =>\n    splitAt(self, spanIndex(self, predicate))\n)\n\n/**\n * Drop a max number of elements from the start of an `Iterable`, creating a new `Array`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const drop: {\n  (n: number): <A>(self: Iterable<A>) => Array<A>\n  <A>(self: Iterable<A>, n: number): Array<A>\n} = dual(2, <A>(self: Iterable<A>, n: number): Array<A> => {\n  const input = fromIterable(self)\n  return input.slice(clamp(n, input), input.length)\n})\n\n/**\n * Drop a max number of elements from the end of an `Iterable`, creating a new `Array`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const dropRight: {\n  (n: number): <A>(self: Iterable<A>) => Array<A>\n  <A>(self: Iterable<A>, n: number): Array<A>\n} = dual(2, <A>(self: Iterable<A>, n: number): Array<A> => {\n  const input = fromIterable(self)\n  return input.slice(0, input.length - clamp(n, input))\n})\n\n/**\n * Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new `Array`.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const dropWhile: {\n  <A, B extends A>(refinement: Refinement<A, B>): (self: Iterable<A>) => Array<B>\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => Array<B>\n  <A, B extends A>(self: Iterable<A>, refinement: Refinement<A, B>): Array<B>\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Array<B>\n} = dual(\n  2,\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Array<B> =>\n    fromIterable(self).slice(spanIndex(self, predicate))\n)\n\n/**\n * Return the first index for which a predicate holds.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const findFirstIndex: {\n  <A>(predicate: Predicate<A>): (self: Iterable<A>) => Option<number>\n  <A>(self: Iterable<A>, predicate: Predicate<A>): Option<number>\n} = dual(2, <A>(self: Iterable<A>, predicate: Predicate<A>): Option<number> => {\n  let i = 0\n  for (const a of self) {\n    if (predicate(a)) {\n      return O.some(i)\n    }\n    i++\n  }\n  return O.none()\n})\n\n/**\n * Return the last index for which a predicate holds.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const findLastIndex: {\n  <A>(predicate: Predicate<A>): (self: Iterable<A>) => Option<number>\n  <A>(self: Iterable<A>, predicate: Predicate<A>): Option<number>\n} = dual(2, <A>(self: Iterable<A>, predicate: Predicate<A>): Option<number> => {\n  const input = fromIterable(self)\n  for (let i = input.length - 1; i >= 0; i--) {\n    if (predicate(input[i])) {\n      return O.some(i)\n    }\n  }\n  return O.none()\n})\n\n/**\n * Find the first element for which a predicate holds.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const findFirst: {\n  <A, B extends A>(refinement: Refinement<A, B>): (self: Iterable<A>) => Option<B>\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => Option<B>\n  <A, B extends A>(self: Iterable<A>, refinement: Refinement<A, B>): Option<B>\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Option<B>\n} = dual(2, <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Option<B> => {\n  const input = fromIterable(self)\n  for (let i = 0; i < input.length; i++) {\n    if (predicate(input[i])) {\n      return O.some(input[i])\n    }\n  }\n  return O.none()\n})\n\n/**\n * Find the last element for which a predicate holds.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const findLast: {\n  <A, B extends A>(refinement: Refinement<A, B>): (self: Iterable<A>) => Option<B>\n  <A>(predicate: Predicate<A>): <B extends A>(self: Iterable<B>) => Option<B>\n  <A, B extends A>(self: Iterable<A>, refinement: Refinement<A, B>): Option<B>\n  <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Option<B>\n} = dual(2, <B extends A, A>(self: Iterable<B>, predicate: Predicate<A>): Option<B> => {\n  const input = fromIterable(self)\n  for (let i = input.length - 1; i >= 0; i--) {\n    if (predicate(input[i])) {\n      return O.some(input[i])\n    }\n  }\n  return O.none()\n})\n\n/**\n * Insert an element at the specified index, creating a new `NonEmptyArray`,\n * or return `None` if the index is out of bounds.\n *\n * @since 1.0.0\n */\nexport const insertAt: {\n  <B>(i: number, b: B): <A>(self: Iterable<A>) => Option<NonEmptyArray<A | B>>\n  <A, B>(self: Iterable<A>, i: number, b: B): Option<NonEmptyArray<A | B>>\n} = dual(3, <A, B>(self: Iterable<A>, i: number, b: B): Option<NonEmptyArray<A | B>> => {\n  const out: Array<A | B> = Array.from(self)\n  //             v--- `= self.length` is ok, it means inserting in last position\n  if (i < 0 || i > out.length) {\n    return O.none()\n  }\n  out.splice(i, 0, b)\n  return O.some(out) as any\n})\n\n/**\n * Change the element at the specified index, creating a new `Array`,\n * or return a copy of the input if the index is out of bounds.\n *\n * @since 1.0.0\n */\nexport const replace: {\n  <B>(i: number, b: B): <A>(self: Iterable<A>) => Array<A | B>\n  <A, B>(self: Iterable<A>, i: number, b: B): Array<A | B>\n} = dual(3, <A, B>(self: Iterable<A>, i: number, b: B): Array<A | B> => modify(self, i, () => b))\n\n/**\n * @since 1.0.0\n */\nexport const replaceOption: {\n  <B>(i: number, b: B): <A>(self: Iterable<A>) => Option<Array<A | B>>\n  <A, B>(self: Iterable<A>, i: number, b: B): Option<Array<A | B>>\n} = dual(\n  3,\n  <A, B>(self: Iterable<A>, i: number, b: B): Option<Array<A | B>> => modifyOption(self, i, () => b)\n)\n\n/**\n * Apply a function to the element at the specified index, creating a new `Array`,\n * or return a copy of the input if the index is out of bounds.\n *\n * @since 1.0.0\n */\nexport const modify: {\n  <A, B>(i: number, f: (a: A) => B): (self: Iterable<A>) => Array<A | B>\n  <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Array<A | B>\n} = dual(\n  3,\n  <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Array<A | B> =>\n    O.getOrElse(modifyOption(self, i, f), () => Array.from(self))\n)\n\n/**\n * Apply a function to the element at the specified index, creating a new `Array`,\n * or return `None` if the index is out of bounds.\n *\n * @since 1.0.0\n */\nexport const modifyOption: {\n  <A, B>(i: number, f: (a: A) => B): (self: Iterable<A>) => Option<Array<A | B>>\n  <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Option<Array<A | B>>\n} = dual(3, <A, B>(self: Iterable<A>, i: number, f: (a: A) => B): Option<Array<A | B>> => {\n  const out = Array.from(self)\n  if (isOutOfBound(i, out)) {\n    return O.none()\n  }\n  const next = f(out[i])\n  // @ts-expect-error\n  out[i] = next\n  return O.some(out)\n})\n\n/**\n * Delete the element at the specified index, creating a new `Array`,\n * or return a copy of the input if the index is out of bounds.\n *\n * @since 1.0.0\n */\nexport const remove: {\n  (i: number): <A>(self: Iterable<A>) => Array<A>\n  <A>(self: Iterable<A>, i: number): Array<A>\n} = dual(2, <A>(self: Iterable<A>, i: number): Array<A> => {\n  const out = Array.from(self)\n  if (isOutOfBound(i, out)) {\n    return out\n  }\n  out.splice(i, 1)\n  return out\n})\n\n/**\n * Reverse an `Iterable`, creating a new `Array`.\n *\n * @since 1.0.0\n */\nexport const reverse = <A>(self: Iterable<A>): Array<A> => Array.from(self).reverse()\n\n/**\n * @since 1.0.0\n */\nexport const reverseNonEmpty = <A>(\n  self: NonEmptyReadonlyArray<A>\n): NonEmptyArray<A> => [lastNonEmpty(self), ...self.slice(0, -1).reverse()]\n\n/**\n * Return all the `Right` elements from an `Interable` of `Either`s.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const rights: <E, A>(self: Iterable<Either<E, A>>) => Array<A> = E.rights\n\n/**\n * Return all the `Left` elements from an `Interable` of `Either`s.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const lefts: <E, A>(self: Iterable<Either<E, A>>) => Array<E> = E.lefts\n\n/**\n * Sort the elements of an `Iterable` in increasing order, creating a new `Array`.\n *\n * @category sorting\n * @since 1.0.0\n */\nexport const sort = <B>(O: Order<B>) =>\n  <A extends B>(self: Iterable<A>): Array<A> => {\n    const out = Array.from(self)\n    out.sort(O.compare)\n    return out\n  }\n\n/**\n * Sort the elements of a `NonEmptyReadonlyArray` in increasing order, creating a new `NonEmptyArray`.\n *\n * @category sorting\n * @since 1.0.0\n */\nexport const sortNonEmpty = <B>(O: Order<B>) =>\n  <A extends B>(self: NonEmptyReadonlyArray<A>): NonEmptyArray<A> => sort(O)(self) as any\n\n/**\n * Sort the elements of an `Iterable` in increasing order, where elements are compared\n * using first `orders[0]`, then `orders[1]`, etc...\n *\n * @category sorting\n * @since 1.0.0\n */\nexport const sortBy = <B>(...orders: ReadonlyArray<Order<B>>) =>\n  <A extends B>(self: Iterable<A>): Array<A> => {\n    const input = fromIterable(self)\n    return (isNonEmpty(input) ? sortByNonEmpty(...orders)(input) : [])\n  }\n\n/**\n * @category sorting\n * @since 1.0.0\n */\nexport const sortByNonEmpty = <B>(\n  ...orders: ReadonlyArray<Order<B>>\n): (<A extends B>(as: NonEmptyReadonlyArray<A>) => NonEmptyArray<A>) =>\n  sortNonEmpty(order.getMonoid<B>().combineAll(orders))\n\n/**\n * Takes two `Iterable`s and returns an `Array` of corresponding pairs.\n * If one input `Iterable` is short, excess elements of the\n * longer `Iterable` are discarded.\n *\n * @since 1.0.0\n */\nexport const zip: {\n  <B>(that: Iterable<B>): <A>(self: Iterable<A>) => Array<[A, B]>\n  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<[A, B]>\n} = dual(\n  2,\n  <A, B>(self: Iterable<A>, that: Iterable<B>): Array<[A, B]> =>\n    zipWith(self, that, (a, b) => [a, b])\n)\n\n/**\n * Apply a function to pairs of elements at the same index in two `Iterable`s, collecting the results in a new `Array`. If one\n * input `Iterable` is short, excess elements of the longer `Iterable` are discarded.\n *\n * @since 1.0.0\n */\nexport const zipWith: {\n  <B, A, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Array<C>\n  <B, A, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Array<C>\n} = dual(3, <B, A, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Array<C> => {\n  const as = fromIterable(self)\n  const bs = fromIterable(that)\n  return isNonEmpty(as) && isNonEmpty(bs) ? zipNonEmptyWith(bs, f)(as) : []\n})\n\n/**\n * @since 1.0.0\n */\nexport const zipNonEmpty: {\n  <B>(that: NonEmptyReadonlyArray<B>): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<[A, B]>\n  <A, B>(self: NonEmptyReadonlyArray<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<[A, B]>\n} = dual(\n  2,\n  <A, B>(self: NonEmptyReadonlyArray<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<[A, B]> =>\n    zipNonEmptyWith(self, that, (a, b) => [a, b])\n)\n\n/**\n * @since 1.0.0\n */\nexport const zipNonEmptyWith: {\n  <B, A, C>(\n    that: NonEmptyReadonlyArray<B>,\n    f: (a: A, b: B) => C\n  ): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<C>\n  <A, B, C>(\n    self: NonEmptyReadonlyArray<A>,\n    that: NonEmptyReadonlyArray<B>,\n    f: (a: A, b: B) => C\n  ): NonEmptyArray<C>\n} = dual(3, <A, B, C>(\n  self: NonEmptyReadonlyArray<A>,\n  that: NonEmptyReadonlyArray<B>,\n  f: (a: A, b: B) => C\n): NonEmptyArray<C> => {\n  const cs: NonEmptyArray<C> = [f(headNonEmpty(self), headNonEmpty(that))]\n  const len = Math.min(self.length, that.length)\n  for (let i = 1; i < len; i++) {\n    cs[i] = f(self[i], that[i])\n  }\n  return cs\n})\n\n/**\n * This function is the inverse of `zip`. Takes an `Iterable` of pairs and return two corresponding `Array`s.\n *\n * @since 1.0.0\n */\nexport const unzip = <A, B>(self: Iterable<[A, B]>): [Array<A>, Array<B>] => {\n  const input = fromIterable(self)\n  return isNonEmpty(input) ? unzipNonEmpty(input) : [[], []]\n}\n\n/**\n * @since 1.0.0\n */\nexport const unzipNonEmpty = <A, B>(\n  self: NonEmptyReadonlyArray<[A, B]>\n): [NonEmptyArray<A>, NonEmptyArray<B>] => {\n  const fa: NonEmptyArray<A> = [self[0][0]]\n  const fb: NonEmptyArray<B> = [self[0][1]]\n  for (let i = 1; i < self.length; i++) {\n    fa[i] = self[i][0]\n    fb[i] = self[i][1]\n  }\n  return [fa, fb]\n}\n\n/**\n * Places an element in between members of an `Iterable`\n *\n * @since 1.0.0\n */\nexport const intersperse: {\n  <B>(middle: B): <A>(self: Iterable<A>) => Array<A | B>\n  <A, B>(self: Iterable<A>, middle: B): Array<A | B>\n} = dual(2, <A, B>(self: Iterable<A>, middle: B): Array<A | B> => {\n  const input = fromIterable(self)\n  return (isNonEmpty(input) ? intersperseNonEmpty(input, middle) : [])\n})\n\n/**\n * Places an element in between members of a `NonEmptyReadonlyArray`\n *\n * @since 1.0.0\n */\nexport const intersperseNonEmpty: {\n  <B>(middle: B): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>\n  <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>\n} = dual(2, <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B> => {\n  const out: NonEmptyArray<A | B> = [headNonEmpty(self)]\n  const tail = tailNonEmpty(self)\n  for (let i = 0; i < tail.length; i++) {\n    if (i < tail.length) {\n      out.push(middle)\n    }\n    out.push(tail[i])\n  }\n  return out\n})\n\n/**\n * Apply a function to the head, creating a new `NonEmptyReadonlyArray`.\n *\n * @since 1.0.0\n */\nexport const modifyNonEmptyHead: {\n  <A, B>(f: (a: A) => B): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>\n  <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B): NonEmptyArray<A | B>\n} = dual(\n  2,\n  <A, B>(\n    self: NonEmptyReadonlyArray<A>,\n    f: (a: A) => B\n  ): NonEmptyArray<A | B> => [f(headNonEmpty(self)), ...tailNonEmpty(self)]\n)\n\n/**\n * Change the head, creating a new `NonEmptyReadonlyArray`.\n *\n * @since 1.0.0\n */\nexport const setNonEmptyHead: {\n  <B>(b: B): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>\n  <A, B>(self: NonEmptyReadonlyArray<A>, b: B): NonEmptyArray<A | B>\n} = dual(\n  2,\n  <A, B>(self: NonEmptyReadonlyArray<A>, b: B): NonEmptyArray<A | B> =>\n    modifyNonEmptyHead(self, () => b)\n)\n\n/**\n * Apply a function to the last element, creating a new `NonEmptyReadonlyArray`.\n *\n * @since 1.0.0\n */\nexport const modifyNonEmptyLast: {\n  <A, B>(f: (a: A) => B): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>\n  <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B): NonEmptyArray<A | B>\n} = dual(\n  2,\n  <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B): NonEmptyArray<A | B> =>\n    append(initNonEmpty(self), f(lastNonEmpty(self)))\n)\n\n/**\n * Change the last element, creating a new `NonEmptyReadonlyArray`.\n *\n * @since 1.0.0\n */\nexport const setNonEmptyLast: {\n  <B>(b: B): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>\n  <A, B>(self: NonEmptyReadonlyArray<A>, b: B): NonEmptyArray<A | B>\n} = dual(\n  2,\n  <A, B>(self: NonEmptyReadonlyArray<A>, b: B): NonEmptyArray<A | B> =>\n    modifyNonEmptyLast(self, () => b)\n)\n\n/**\n * Rotate an `Iterable` by `n` steps.\n *\n * @since 1.0.0\n */\nexport const rotate: {\n  (n: number): <A>(self: Iterable<A>) => Array<A>\n  <A>(self: Iterable<A>, n: number): Array<A>\n} = dual(2, <A>(self: Iterable<A>, n: number): Array<A> => {\n  const input = fromIterable(self)\n  return isNonEmpty(input) ? rotateNonEmpty(input, n) : []\n})\n\n/**\n * Rotate a `NonEmptyReadonlyArray` by `n` steps.\n *\n * @since 1.0.0\n */\nexport const rotateNonEmpty: {\n  (n: number): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A>\n  <A>(self: NonEmptyReadonlyArray<A>, n: number): NonEmptyArray<A>\n} = dual(2, <A>(self: NonEmptyReadonlyArray<A>, n: number): NonEmptyArray<A> => {\n  const len = self.length\n  const m = Math.round(n) % len\n  if (isOutOfBound(Math.abs(m), self) || m === 0) {\n    return copy(self)\n  }\n  if (m < 0) {\n    const [f, s] = splitNonEmptyAt(self, -m)\n    return appendAllNonEmpty(s, f)\n  } else {\n    return rotateNonEmpty(self, m - len)\n  }\n})\n\n/**\n * Returns a function that checks if a `ReadonlyArray` contains a given value using a provided `equivalence` function.\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const contains = <A>(isEquivalent: (self: A, that: A) => boolean): {\n  (a: A): (self: Iterable<A>) => boolean\n  (self: Iterable<A>, a: A): boolean\n} =>\n  dual(2, (self: Iterable<A>, a: A): boolean => {\n    for (const i of self) {\n      if (isEquivalent(a, i)) {\n        return true\n      }\n    }\n    return false\n  })\n\n/**\n * Remove duplicates from am `Iterable`, keeping the first occurrence of an element.\n *\n * @since 1.0.0\n */\nexport const uniq = <A>(isEquivalent: (self: A, that: A) => boolean) =>\n  (self: Iterable<A>): Array<A> => {\n    const input = fromIterable(self)\n    return isNonEmpty(input) ? uniqNonEmpty(isEquivalent)(input) : []\n  }\n\n/**\n * Remove duplicates from a `NonEmptyReadonlyArray`, keeping the first occurrence of an element.\n *\n * @since 1.0.0\n */\nexport const uniqNonEmpty = <A>(isEquivalent: (self: A, that: A) => boolean) =>\n  (self: NonEmptyReadonlyArray<A>): NonEmptyArray<A> => {\n    const out: NonEmptyArray<A> = [headNonEmpty(self)]\n    const rest = tailNonEmpty(self)\n    for (const a of rest) {\n      if (out.every((o) => !isEquivalent(a, o))) {\n        out.push(a)\n      }\n    }\n    return out\n  }\n\n/**\n * A useful recursion pattern for processing an `Iterable` to produce a new `Array`, often used for \"chopping\" up the input\n * `Iterable`. Typically chop is called with some function that will consume an initial prefix of the `Iterable` and produce a\n * value and the rest of the `Array`.\n *\n * @since 1.0.0\n */\nexport const chop: {\n  <A, B>(\n    f: (as: NonEmptyReadonlyArray<A>) => readonly [B, ReadonlyArray<A>]\n  ): (self: Iterable<A>) => Array<B>\n  <A, B>(\n    self: Iterable<A>,\n    f: (as: NonEmptyReadonlyArray<A>) => readonly [B, ReadonlyArray<A>]\n  ): Array<B>\n} = dual(2, <A, B>(\n  self: Iterable<A>,\n  f: (as: NonEmptyReadonlyArray<A>) => readonly [B, ReadonlyArray<A>]\n): Array<B> => {\n  const input = fromIterable(self)\n  return isNonEmpty(input) ? chopNonEmpty(input, f) : []\n})\n\n/**\n * A useful recursion pattern for processing a `NonEmptyReadonlyArray` to produce a new `NonEmptyReadonlyArray`, often used for \"chopping\" up the input\n * `NonEmptyReadonlyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `NonEmptyReadonlyArray` and produce a\n * value and the tail of the `NonEmptyReadonlyArray`.\n *\n * @since 1.0.0\n */\nexport const chopNonEmpty: {\n  <A, B>(\n    f: (as: NonEmptyReadonlyArray<A>) => readonly [B, ReadonlyArray<A>]\n  ): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<B>\n  <A, B>(\n    self: NonEmptyReadonlyArray<A>,\n    f: (as: NonEmptyReadonlyArray<A>) => readonly [B, ReadonlyArray<A>]\n  ): NonEmptyArray<B>\n} = dual(2, <A, B>(\n  self: NonEmptyReadonlyArray<A>,\n  f: (as: NonEmptyReadonlyArray<A>) => readonly [B, ReadonlyArray<A>]\n): NonEmptyArray<B> => {\n  const [b, rest] = f(self)\n  const out: NonEmptyArray<B> = [b]\n  let next: ReadonlyArray<A> = rest\n  while (readonlyArray.isNonEmptyArray(next)) {\n    const [b, rest] = f(next)\n    out.push(b)\n    next = rest\n  }\n  return out\n})\n\n/**\n * Splits an `Iterable` into two pieces, the first piece has max `n` elements.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const splitAt: {\n  (n: number): <A>(self: Iterable<A>) => [Array<A>, Array<A>]\n  <A>(self: Iterable<A>, n: number): [Array<A>, Array<A>]\n} = dual(2, <A>(self: Iterable<A>, n: number): [Array<A>, Array<A>] => {\n  const input = Array.from(self)\n  return n >= 1 && isNonEmpty(input) ?\n    splitNonEmptyAt(input, n) :\n    isEmpty(input) ?\n    [input, []] :\n    [[], input]\n})\n\n/**\n * @since 1.0.0\n */\nexport const copy: {\n  <A>(self: NonEmptyReadonlyArray<A>): NonEmptyArray<A>\n  <A>(self: ReadonlyArray<A>): Array<A>\n} = (<A>(self: ReadonlyArray<A>): Array<A> => self.slice()) as any\n\n/**\n * Splits a `NonEmptyReadonlyArray` into two pieces, the first piece has max `n` elements.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const splitNonEmptyAt: {\n  (n: number): <A>(self: NonEmptyReadonlyArray<A>) => [NonEmptyArray<A>, Array<A>]\n  <A>(self: NonEmptyReadonlyArray<A>, n: number): [NonEmptyArray<A>, Array<A>]\n} = dual(2, <A>(self: NonEmptyReadonlyArray<A>, n: number): [NonEmptyArray<A>, Array<A>] => {\n  const m = Math.max(1, n)\n  return m >= self.length ?\n    [copy(self), []] :\n    [prepend(self.slice(1, m), headNonEmpty(self)), self.slice(m)]\n})\n\n/**\n * Splits an `Iterable` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\n * the `Iterable`. Note that `chunksOf(n)([])` is `[]`, not `[[]]`. This is intentional, and is consistent with a recursive\n * definition of `chunksOf`; it satisfies the property that\n *\n * ```ts\n * chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys)))\n * ```\n *\n * whenever `n` evenly divides the length of `self`.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const chunksOf: {\n  (n: number): <A>(self: Iterable<A>) => Array<NonEmptyArray<A>>\n  <A>(self: Iterable<A>, n: number): Array<NonEmptyArray<A>>\n} = dual(2, <A>(self: Iterable<A>, n: number): Array<NonEmptyArray<A>> => {\n  const input = fromIterable(self)\n  return isNonEmpty(input) ? chunksOfNonEmpty(input, n) : []\n})\n\n/**\n * Splits a `NonEmptyReadonlyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\n * the `NonEmptyReadonlyArray`.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const chunksOfNonEmpty: {\n  (n: number): <A>(self: NonEmptyReadonlyArray<A>) => NonEmptyArray<NonEmptyArray<A>>\n  <A>(self: NonEmptyReadonlyArray<A>, n: number): NonEmptyArray<NonEmptyArray<A>>\n} = dual(\n  2,\n  <A>(self: NonEmptyReadonlyArray<A>, n: number): NonEmptyArray<NonEmptyArray<A>> =>\n    chopNonEmpty(self, splitNonEmptyAt(n))\n)\n\n/**\n * Group equal, consecutive elements of a `NonEmptyReadonlyArray` into `NonEmptyArray`s.\n *\n * @category grouping\n * @since 1.0.0\n */\nexport const group = <A>(isEquivalent: (self: A, that: A) => boolean) =>\n  (self: NonEmptyReadonlyArray<A>): NonEmptyArray<NonEmptyArray<A>> =>\n    chopNonEmpty(self, (as) => {\n      const h = headNonEmpty(as)\n      const out: NonEmptyArray<A> = [h]\n      let i = 1\n      for (; i < as.length; i++) {\n        const a = as[i]\n        if (isEquivalent(a, h)) {\n          out.push(a)\n        } else {\n          break\n        }\n      }\n      return [out, as.slice(i)]\n    })\n\n/**\n * Splits an `Iterable` into sub-non-empty-arrays stored in an object, based on the result of calling a `string`-returning\n * function on each element, and grouping the results according to values returned\n *\n * @category grouping\n * @since 1.0.0\n */\nexport const groupBy: {\n  <A>(f: (a: A) => string): (self: Iterable<A>) => Record<string, NonEmptyArray<A>>\n  <A>(self: Iterable<A>, f: (a: A) => string): Record<string, NonEmptyArray<A>>\n} = dual(2, <A>(self: Iterable<A>, f: (a: A) => string): Record<string, NonEmptyArray<A>> => {\n  const out: Record<string, NonEmptyArray<A>> = {}\n  for (const a of self) {\n    const k = f(a)\n    if (Object.prototype.hasOwnProperty.call(out, k)) {\n      out[k].push(a)\n    } else {\n      out[k] = [a]\n    }\n  }\n  return out\n})\n\n/**\n * @since 1.0.0\n */\nexport const union = <A>(isEquivalent: (self: A, that: A) => boolean): {\n  (that: ReadonlyArray<A>): (self: ReadonlyArray<A>) => Array<A>\n  (self: ReadonlyArray<A>, that: ReadonlyArray<A>): Array<A>\n} =>\n  dual(2, (self: ReadonlyArray<A>, that: ReadonlyArray<A>): Array<A> => {\n    const a = Array.from(self)\n    const b = Array.from(that)\n    return isNonEmpty(a) && isNonEmpty(b) ?\n      unionNonEmpty(isEquivalent)(a, b) :\n      isNonEmpty(a) ?\n      a :\n      b\n  })\n\n/**\n * @since 1.0.0\n */\nexport const unionNonEmpty = <A>(isEquivalent: (self: A, that: A) => boolean): {\n  (that: NonEmptyReadonlyArray<A>): (self: ReadonlyArray<A>) => NonEmptyArray<A>\n  (that: ReadonlyArray<A>): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A>\n  (self: ReadonlyArray<A>, that: NonEmptyReadonlyArray<A>): NonEmptyArray<A>\n  (self: NonEmptyReadonlyArray<A>, that: ReadonlyArray<A>): NonEmptyArray<A>\n} =>\n  dual(\n    2,\n    (self: NonEmptyReadonlyArray<A>, that: ReadonlyArray<A>): NonEmptyArray<A> =>\n      uniqNonEmpty(isEquivalent)(appendAllNonEmpty(self, that))\n  )\n\n/**\n * Creates an `Array` of unique values that are included in all given `Iterable`s.\n * The order and references of result values are determined by the first `Iterable`.\n *\n * @since 1.0.0\n */\nexport const intersection = <A>(isEquivalent: (self: A, that: A) => boolean): {\n  (that: Iterable<A>): (self: Iterable<A>) => Array<A>\n  (self: Iterable<A>, that: Iterable<A>): Array<A>\n} => {\n  const has = contains(isEquivalent)\n  return dual(\n    2,\n    (self: Iterable<A>, that: Iterable<A>): Array<A> =>\n      fromIterable(self).filter((a) => has(that, a))\n  )\n}\n\n/**\n * Creates a `Array` of values not included in the other given `Iterable`.\n * The order and references of result values are determined by the first `Iterable`.\n *\n * @since 1.0.0\n */\nexport const difference = <A>(isEquivalent: (self: A, that: A) => boolean): {\n  (that: Iterable<A>): (self: Iterable<A>) => Array<A>\n  (self: Iterable<A>, that: Iterable<A>): Array<A>\n} => {\n  const has = contains(isEquivalent)\n  return dual(\n    2,\n    (self: Iterable<A>, that: Iterable<A>): Array<A> =>\n      fromIterable(self).filter((a) => !has(that, a))\n  )\n}\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const of = <A>(a: A): NonEmptyArray<A> => [a]\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const empty: <A = never>() => Array<A> = () => []\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Of: of_.Of<ReadonlyArrayTypeLambda> = {\n  of\n}\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const map: {\n  <A, B>(f: (a: A, i: number) => B): (self: ReadonlyArray<A>) => Array<B>\n  <A, B>(self: ReadonlyArray<A>, f: (a: A, i: number) => B): Array<B>\n} = dual(2, <A, B>(self: ReadonlyArray<A>, f: (a: A, i: number) => B): Array<B> => self.map(f))\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const mapNonEmpty: {\n  <A, B>(f: (a: A, i: number) => B): (self: readonly [A, ...Array<A>]) => [B, ...Array<B>]\n  <A, B>(self: readonly [A, ...Array<A>], f: (a: A, i: number) => B): [B, ...Array<B>]\n} = map as any\n\nconst imap = covariant.imap<ReadonlyArrayTypeLambda>(map)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Covariant: covariant.Covariant<ReadonlyArrayTypeLambda> = {\n  imap,\n  map\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<ReadonlyArrayTypeLambda> = {\n  imap\n}\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const tupled: <A>(self: ReadonlyArray<A>) => Array<[A]> = invariant\n  .tupled(Invariant) as any\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const flap: {\n  <A, B>(a: A, self: ReadonlyArray<(a: A) => B>): Array<B>\n  <A, B>(self: ReadonlyArray<(a: A) => B>): (a: A) => Array<B>\n} = covariant.flap(Covariant) as any\n\n/**\n * Maps the success value of this effect to the specified constant value.\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const as: {\n  <_, B>(self: ReadonlyArray<_>, b: B): Array<B>\n  <B>(b: B): <_>(self: ReadonlyArray<_>) => Array<B>\n} = covariant.as(Covariant) as any\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Pointed: pointed.Pointed<ReadonlyArrayTypeLambda> = {\n  of,\n  imap,\n  map\n}\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A, i: number) => ReadonlyArray<B>): (self: ReadonlyArray<A>) => Array<B>\n  <A, B>(self: ReadonlyArray<A>, f: (a: A, i: number) => ReadonlyArray<B>): Array<B>\n} = dual(\n  2,\n  <A, B>(self: ReadonlyArray<A>, f: (a: A, i: number) => ReadonlyArray<B>): Array<B> => {\n    if (isEmpty(self)) {\n      return []\n    }\n    const out: Array<B> = []\n    for (let i = 0; i < self.length; i++) {\n      out.push(...f(self[i], i))\n    }\n    return out\n  }\n)\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMapNonEmpty: {\n  <A, B>(\n    f: (a: A, i: number) => NonEmptyReadonlyArray<B>\n  ): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<B>\n  <A, B>(\n    self: NonEmptyReadonlyArray<A>,\n    f: (a: A, i: number) => NonEmptyReadonlyArray<B>\n  ): NonEmptyArray<B>\n} = flatMap as any\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const FlatMap: flatMap_.FlatMap<ReadonlyArrayTypeLambda> = {\n  flatMap\n}\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatten: <A>(self: ReadonlyArray<ReadonlyArray<A>>) => Array<A> = flatMap_\n  .flatten(FlatMap) as any\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flattenNonEmpty: <A>(\n  self: NonEmptyReadonlyArray<NonEmptyReadonlyArray<A>>\n) => NonEmptyArray<A> = flatMapNonEmpty(identity)\n\n/**\n * @since 1.0.0\n */\nexport const composeKleisliArrow: {\n  <A, B, C>(\n    afb: (a: A) => ReadonlyArray<B>,\n    bfc: (b: B) => ReadonlyArray<C>\n  ): (a: A) => ReadonlyArray<C>\n  <B, C>(\n    bfc: (b: B) => ReadonlyArray<C>\n  ): <A>(afb: (a: A) => ReadonlyArray<B>) => (a: A) => ReadonlyArray<C>\n} = flatMap_.composeKleisliArrow(FlatMap)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Chainable: chainable.Chainable<ReadonlyArrayTypeLambda> = {\n  imap,\n  map,\n  flatMap\n}\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const filterMap: {\n  <A, B>(f: (a: A, i: number) => Option<B>): (self: Iterable<A>) => Array<B>\n  <A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Array<B>\n} = dual(\n  2,\n  <A, B>(self: Iterable<A>, f: (a: A, i: number) => Option<B>): Array<B> => {\n    const as = fromIterable(self)\n    const out: Array<B> = []\n    for (let i = 0; i < as.length; i++) {\n      const o = f(as[i], i)\n      if (O.isSome(o)) {\n        out.push(o.value)\n      }\n    }\n    return out\n  }\n)\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const partitionMap: {\n  <A, B, C>(f: (a: A, i: number) => Either<B, C>): (self: Iterable<A>) => [Array<B>, Array<C>]\n  <A, B, C>(self: Iterable<A>, f: (a: A, i: number) => Either<B, C>): [Array<B>, Array<C>]\n} = dual(\n  2,\n  <A, B, C>(self: Iterable<A>, f: (a: A, i: number) => Either<B, C>): [Array<B>, Array<C>] => {\n    const left: Array<B> = []\n    const right: Array<C> = []\n    const as = fromIterable(self)\n    for (let i = 0; i < as.length; i++) {\n      const e = f(as[i], i)\n      if (E.isLeft(e)) {\n        left.push(e.left)\n      } else {\n        right.push(e.right)\n      }\n    }\n    return [left, right]\n  }\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Filterable: filterable.Filterable<ReadonlyArrayTypeLambda> = {\n  partitionMap,\n  filterMap\n}\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const compact: <A>(self: Iterable<Option<A>>) => Array<A> = filterMap(identity)\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const filter: {\n  <C extends A, B extends A, A = C>(\n    refinement: (a: A, i: number) => a is B\n  ): (self: Iterable<C>) => Array<B>\n  <B extends A, A = B>(predicate: (a: A, i: number) => boolean): (self: Iterable<B>) => Array<B>\n  <C extends A, B extends A, A = C>(\n    self: Iterable<C>,\n    refinement: (a: A, i: number) => a is B\n  ): Array<B>\n  <B extends A, A = B>(self: Iterable<B>, predicate: (a: A, i: number) => boolean): Array<B>\n} = dual(\n  2,\n  <B extends A, A = B>(self: Iterable<B>, predicate: (a: A, i: number) => boolean): Array<B> => {\n    const as = fromIterable(self)\n    const out: Array<B> = []\n    for (let i = 0; i < as.length; i++) {\n      if (predicate(as[i], i)) {\n        out.push(as[i])\n      }\n    }\n    return out\n  }\n)\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const partition: {\n  <C extends A, B extends A, A = C>(refinement: (a: A, i: number) => a is B): (\n    self: Iterable<C>\n  ) => [Array<C>, Array<B>]\n  <B extends A, A = B>(\n    predicate: (a: A, i: number) => boolean\n  ): (self: Iterable<B>) => [Array<B>, Array<B>]\n  <C extends A, B extends A, A = C>(\n    self: Iterable<C>,\n    refinement: (a: A, i: number) => a is B\n  ): [Array<C>, Array<B>]\n  <B extends A, A = B>(\n    self: Iterable<B>,\n    predicate: (a: A, i: number) => boolean\n  ): [Array<B>, Array<B>]\n} = dual(\n  2,\n  <B extends A, A = B>(\n    self: Iterable<B>,\n    predicate: (a: A, i: number) => boolean\n  ): [Array<B>, Array<B>] => {\n    const left: Array<B> = []\n    const right: Array<B> = []\n    const as = fromIterable(self)\n    for (let i = 0; i < as.length; i++) {\n      if (predicate(as[i], i)) {\n        right.push(as[i])\n      } else {\n        left.push(as[i])\n      }\n    }\n    return [left, right]\n  }\n)\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const separate: <A, B>(self: Iterable<Either<A, B>>) => [Array<A>, Array<B>] = partitionMap(\n  identity\n)\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const traverseNonEmpty = <F extends TypeLambda>(\n  F: semiApplicative.SemiApplicative<F>\n): {\n  <A, R, O, E, B>(\n    f: (a: A, i: number) => Kind<F, R, O, E, B>\n  ): (self: NonEmptyReadonlyArray<A>) => Kind<F, R, O, E, NonEmptyArray<B>>\n  <A, R, O, E, B>(\n    self: NonEmptyReadonlyArray<A>,\n    f: (a: A, i: number) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, NonEmptyArray<B>>\n} =>\n  dual(2, <A, R, O, E, B>(\n    self: NonEmptyReadonlyArray<A>,\n    f: (a: A, i: number) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, NonEmptyArray<B>> => {\n    const [head, ...tail] = mapNonEmpty(self, f)\n    return F.productMany(head, tail)\n  })\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const traverse = <F extends TypeLambda>(F: applicative.Applicative<F>): {\n  <A, R, O, E, B>(\n    f: (a: A, i: number) => Kind<F, R, O, E, B>\n  ): (self: Iterable<A>) => Kind<F, R, O, E, Array<B>>\n  <A, R, O, E, B>(\n    self: Iterable<A>,\n    f: (a: A, i: number) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Array<B>>\n} =>\n  dual(2, <A, R, O, E, B>(\n    self: Iterable<A>,\n    f: (a: A, i: number) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Array<B>> => F.productAll(fromIterable(self).map(f)))\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const sequence = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): <R, O, E, A>(\n  self: ReadonlyArray<Kind<F, R, O, E, A>>\n) => Kind<F, R, O, E, Array<A>> => traverse(F)(identity)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Traversable: traversable.Traversable<ReadonlyArrayTypeLambda> = {\n  traverse: traverse as any\n}\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(\n    self: ReadonlyArray<A>,\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Array<A>>\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): (self: ReadonlyArray<A>) => Kind<F, R, O, E, Array<A>>\n} = traversable.traverseTap(Traversable) as any\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const sequenceNonEmpty = <F extends TypeLambda>(\n  F: semiApplicative.SemiApplicative<F>\n): (<R, O, E, A>(\n  self: NonEmptyReadonlyArray<Kind<F, R, O, E, A>>\n) => Kind<F, R, O, E, NonEmptyArray<A>>) => traverseNonEmpty(F)(identity)\n\nconst product = <A, B>(self: ReadonlyArray<A>, that: ReadonlyArray<B>): ReadonlyArray<[A, B]> => {\n  if (isEmpty(self) || isEmpty(that)) {\n    return empty()\n  }\n  const out: Array<[A, B]> = []\n  for (let i = 0; i < self.length; i++) {\n    for (let j = 0; j < that.length; j++) {\n      out.push([self[i], that[j]])\n    }\n  }\n  return out\n}\n\nconst productMany = semiProduct.productMany<ReadonlyArrayTypeLambda>(map, product)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiProduct: semiProduct.SemiProduct<ReadonlyArrayTypeLambda> = {\n  imap,\n  product,\n  productMany\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiApplicative: semiApplicative.SemiApplicative<ReadonlyArrayTypeLambda> = {\n  imap,\n  map,\n  product,\n  productMany\n}\n\n/**\n * @since 1.0.0\n */\nexport const ap: {\n  <A, B>(self: ReadonlyArray<(a: A) => B>, that: ReadonlyArray<A>): Array<B>\n  <A>(that: ReadonlyArray<A>): <B>(self: ReadonlyArray<(a: A) => B>) => Array<B>\n} = semiApplicative.ap(SemiApplicative) as any\n\n/**\n * Lifts a binary function into `ReadonlyArray`.\n *\n * @param f - The function to lift.\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const lift2: <A, B, C>(f: (a: A, b: B) => C) => {\n  (self: ReadonlyArray<A>, that: ReadonlyArray<B>): Array<C>\n  (that: ReadonlyArray<B>): (self: ReadonlyArray<A>) => Array<C>\n} = semiApplicative.lift2(SemiApplicative) as any\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Product: product_.Product<ReadonlyArrayTypeLambda> = {\n  of,\n  imap,\n  product,\n  productMany,\n  productAll: (collection) => {\n    const arrays = fromIterable(collection)\n    return isEmpty(arrays) ? empty() : SemiProduct.productMany(arrays[0], arrays.slice(1))\n  }\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Applicative: applicative.Applicative<ReadonlyArrayTypeLambda> = {\n  imap,\n  of,\n  map,\n  product,\n  productMany,\n  productAll: Product.productAll\n}\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftMonoid: <A>(M: Monoid<A>) => Monoid<ReadonlyArray<A>> = applicative\n  .getMonoid(\n    Applicative\n  )\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Monad: monad.Monad<ReadonlyArrayTypeLambda> = {\n  imap,\n  of,\n  map,\n  flatMap\n}\n\n/**\n * @category folding\n * @since 1.0.0\n */\nexport const reduce: {\n  <B, A>(b: B, f: (b: B, a: A, i: number) => B): (self: Iterable<A>) => B\n  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A, i: number) => B): B\n} = dual(\n  3,\n  <B, A>(self: Iterable<A>, b: B, f: (b: B, a: A, i: number) => B): B =>\n    fromIterable(self).reduce((b, a, i) => f(b, a, i), b)\n)\n\n/**\n * @category folding\n * @since 1.0.0\n */\nexport const reduceRight: {\n  <B, A>(b: B, f: (b: B, a: A, i: number) => B): (self: Iterable<A>) => B\n  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A, i: number) => B): B\n} = dual(\n  3,\n  <A, B>(self: Iterable<A>, b: B, f: (b: B, a: A, i: number) => B): B =>\n    fromIterable(self).reduceRight((b, a, i) => f(b, a, i), b)\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Foldable: foldable.Foldable<ReadonlyArrayTypeLambda> = {\n  reduce\n}\n\n/**\n * @category folding\n * @since 1.0.0\n */\nexport const combineMap = <M>(Monoid: Monoid<M>): {\n  <A>(f: (a: A, i: number) => M): (self: Iterable<A>) => M\n  <A>(self: Iterable<A>, f: (a: A, i: number) => M): M\n} =>\n  dual(\n    2,\n    <A>(self: Iterable<A>, f: (a: A, i: number) => M): M =>\n      fromIterable(self).reduce((m, a, i) => Monoid.combine(m, f(a, i)), Monoid.empty)\n  )\n\n/**\n * @category folding\n * @since 1.0.0\n */\nexport const combineMapNonEmpty = <S>(S: Semigroup<S>): {\n  <A>(f: (a: A, i: number) => S): (self: NonEmptyReadonlyArray<A>) => S\n  <A>(self: NonEmptyReadonlyArray<A>, f: (a: A, i: number) => S): S\n} =>\n  dual(\n    2,\n    <A>(self: NonEmptyReadonlyArray<A>, f: (a: A, i: number) => S): S =>\n      tailNonEmpty(self).reduce((s, a, i) => S.combine(s, f(a, i + 1)), f(headNonEmpty(self), 0))\n  )\n\n/**\n * @category folding\n * @since 1.0.0\n */\nexport const reduceKind: <G extends TypeLambda>(\n  G: monad.Monad<G>\n) => {\n  <B, A, R, O, E>(\n    b: B,\n    f: (b: B, a: A) => Kind<G, R, O, E, B>\n  ): (self: ReadonlyArray<A>) => Kind<G, R, O, E, B>\n  <A, B, R, O, E>(\n    self: ReadonlyArray<A>,\n    b: B,\n    f: (b: B, a: A) => Kind<G, R, O, E, B>\n  ): Kind<G, R, O, E, B>\n} = foldable.reduceKind(Foldable)\n\n/**\n * @category folding\n * @since 1.0.0\n */\nexport const coproductMapKind: <G extends TypeLambda>(\n  G: Coproduct<G>\n) => {\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<G, R, O, E, B>\n  ): (self: ReadonlyArray<A>) => Kind<G, R, O, E, B>\n  <A, R, O, E, B>(\n    self: ReadonlyArray<A>,\n    f: (a: A) => Kind<G, R, O, E, B>\n  ): Kind<G, R, O, E, B>\n} = foldable.coproductMapKind(Foldable)\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const traversePartitionMap = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): {\n  <A, R, O, E, B, C>(\n    f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n  ): (self: ReadonlyArray<A>) => Kind<F, R, O, E, [Array<B>, Array<C>]>\n  <A, R, O, E, B, C>(\n    self: ReadonlyArray<A>,\n    f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n  ): Kind<F, R, O, E, [Array<B>, Array<C>]>\n} =>\n  dual(2, <A, R, O, E, B, C>(\n    self: ReadonlyArray<A>,\n    f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n  ): Kind<F, R, O, E, [Array<B>, Array<C>]> => {\n    return F.map(traverse(F)(self, f), separate)\n  })\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const traverseFilterMap = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): {\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, Option<B>>\n  ): (self: ReadonlyArray<A>) => Kind<F, R, O, E, Array<B>>\n  <A, R, O, E, B>(\n    self: ReadonlyArray<A>,\n    f: (a: A) => Kind<F, R, O, E, Option<B>>\n  ): Kind<F, R, O, E, Array<B>>\n} =>\n  dual(2, <A, R, O, E, B>(\n    self: ReadonlyArray<A>,\n    f: (a: A) => Kind<F, R, O, E, Option<B>>\n  ): Kind<F, R, O, E, Array<B>> => {\n    return F.map(traverse(F)(self, f), compact)\n  })\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const TraversableFilterable: traversableFilterable.TraversableFilterable<\n  ReadonlyArrayTypeLambda\n> = {\n  traversePartitionMap: traversePartitionMap as any,\n  traverseFilterMap: traverseFilterMap as any\n}\n\n/**\n * Filter values inside a context.\n *\n * @since 1.0.0\n */\nexport const traverseFilter: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): (self: ReadonlyArray<B>) => Kind<F, R, O, E, Array<B>>\n  <B extends A, R, O, E, A = B>(\n    self: ReadonlyArray<B>,\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): Kind<F, R, O, E, Array<B>>\n} = traversableFilterable.traverseFilter(TraversableFilterable) as any\n\n/**\n * @since 1.0.0\n */\nexport const traversePartition: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): (self: ReadonlyArray<B>) => Kind<F, R, O, E, [Array<B>, Array<B>]>\n  <B extends A, R, O, E, A = B>(\n    self: ReadonlyArray<B>,\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): Kind<F, R, O, E, [Array<B>, Array<B>]>\n} = traversableFilterable.traversePartition(TraversableFilterable) as any\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftPredicate: {\n  <C extends A, B extends A, A = C>(refinement: Refinement<A, B>): (c: C) => Array<B>\n  <B extends A, A = B>(predicate: Predicate<A>): (b: B) => Array<B>\n} = <B extends A, A = B>(predicate: Predicate<A>) => (b: B) => predicate(b) ? [b] : []\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftOption = <A extends Array<unknown>, B>(\n  f: (...a: A) => Option<B>\n) => (...a: A): Array<B> => fromOption(f(...a))\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromNullable = <A>(a: A): Array<NonNullable<A>> =>\n  a == null ? empty() : [a as NonNullable<A>]\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftNullable = <A extends Array<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n): (...a: A) => Array<NonNullable<B>> => (...a) => fromNullable(f(...a))\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMapNullable: {\n  <A, B>(f: (a: A) => B | null | undefined): (self: ReadonlyArray<A>) => Array<NonNullable<B>>\n  <A, B>(self: ReadonlyArray<A>, f: (a: A) => B | null | undefined): Array<NonNullable<B>>\n} = dual(\n  2,\n  <A, B>(self: ReadonlyArray<A>, f: (a: A) => B | null | undefined): Array<NonNullable<B>> =>\n    isNonEmpty(self) ? fromNullable(f(headNonEmpty(self))) : empty()\n)\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftEither = <A extends Array<unknown>, E, B>(\n  f: (...a: A) => Either<E, B>\n) =>\n  (...a: A): Array<B> => {\n    const e = f(...a)\n    return E.isLeft(e) ? [] : [e.right]\n  }\n\n/**\n * Check if a predicate holds true for every `ReadonlyArray` member.\n *\n * @category predicates\n * @since 1.0.0\n */\nexport function every<A, B extends A>(\n  refinement: Refinement<A, B>\n): Refinement<ReadonlyArray<A>, ReadonlyArray<B>>\nexport function every<A>(predicate: Predicate<A>): Predicate<ReadonlyArray<A>>\nexport function every<A>(predicate: Predicate<A>): Predicate<ReadonlyArray<A>> {\n  return (self) => self.every(predicate)\n}\n\n/**\n * Check if a predicate holds true for some `ReadonlyArray` member.\n *\n * @category predicates\n * @since 1.0.0\n */\nexport const some = <A>(predicate: Predicate<A>) =>\n  (self: ReadonlyArray<A>): self is NonEmptyReadonlyArray<A> => self.some(predicate)\n\n/**\n * Fold an `Iterable`, accumulating values in some `Monoid`, combining adjacent elements\n * using the specified separator.\n *\n * @since 1.0.0\n */\nexport const intercalate = <A>(M: Monoid<A>): {\n  (middle: A): (self: Iterable<A>) => A\n  (self: Iterable<A>, middle: A): A\n} =>\n  dual(\n    2,\n    (self: Iterable<A>, middle: A): A => {\n      const as = fromIterable(self)\n      return isNonEmpty(as) ? intercalateNonEmpty(M)(as, middle) : M.empty\n    }\n  )\n\n/**\n * Places an element in between members of a `NonEmptyReadonlyArray`, then folds the results using the provided `Semigroup`.\n *\n * @since 1.0.0\n */\nexport const intercalateNonEmpty = <A>(\n  S: Semigroup<A>\n): {\n  (middle: A): (self: NonEmptyReadonlyArray<A>) => A\n  (self: NonEmptyReadonlyArray<A>, middle: A): A\n} =>\n  dual(\n    2,\n    (self: NonEmptyReadonlyArray<A>, middle: A): A =>\n      semigroup.intercalate(S, middle).combineMany(headNonEmpty(self), tailNonEmpty(self))\n  )\n\n/**\n * @since 1.0.0\n */\nexport const join: {\n  (middle: string): (self: ReadonlyArray<string>) => string\n  (self: ReadonlyArray<string>, middle: string): string\n} = intercalate(string.Monoid)\n\n/**\n * @since 1.0.0\n */\nexport const extend: {\n  <A, B>(f: (as: ReadonlyArray<A>) => B): (self: ReadonlyArray<A>) => Array<B>\n  <A, B>(self: ReadonlyArray<A>, f: (as: ReadonlyArray<A>) => B): Array<B>\n} = dual(\n  2,\n  <A, B>(self: ReadonlyArray<A>, f: (as: ReadonlyArray<A>) => B): Array<B> =>\n    self.map((_, i, as) => f(as.slice(i)))\n)\n\n/**\n * @since 1.0.0\n */\nexport const min = <A>(O: Order<A>): ((self: NonEmptyReadonlyArray<A>) => A) => {\n  const S = semigroup.min(O)\n  return (self) => self.reduce(S.combine)\n}\n\n/**\n * @since 1.0.0\n */\nexport const max = <A>(O: Order<A>): ((self: NonEmptyReadonlyArray<A>) => A) => {\n  const S = semigroup.max(O)\n  return (self) => self.reduce(S.combine)\n}\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const unfold = <B, A>(b: B, f: (b: B) => Option<readonly [A, B]>): Array<A> => {\n  const out: Array<A> = []\n  let next: B = b\n  let o: Option<readonly [A, B]>\n  while (O.isSome(o = f(next))) {\n    const [a, b] = o.value\n    out.push(a)\n    next = b\n  }\n  return out\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getUnionSemigroup = <A>(\n  isEquivalent: (self: A, that: A) => boolean\n): Semigroup<ReadonlyArray<A>> => semigroup.make(union(isEquivalent)) as any\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getUnionMonoid = <A>(\n  isEquivalent: (self: A, that: A) => boolean\n): Monoid<ReadonlyArray<A>> => {\n  const S = getUnionSemigroup<A>(isEquivalent)\n  return ({\n    combine: S.combine,\n    combineMany: S.combineMany,\n    combineAll: (collection) => S.combineMany([], collection),\n    empty: []\n  })\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getIntersectionSemigroup = <A>(\n  isEquivalent: (self: A, that: A) => boolean\n): Semigroup<ReadonlyArray<A>> => semigroup.make(intersection(isEquivalent)) as any\n\n/**\n * Returns a `Semigroup` for `ReadonlyArray<A>`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const getSemigroup: <A>() => Semigroup<ReadonlyArray<A>> = semigroup.array\n\n/**\n * Returns a `Monoid` for `ReadonlyArray<A>`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const getMonoid: <A>() => Monoid<ReadonlyArray<A>> = monoid.array\n\n/**\n * This function creates and returns a new `Order` for an array of values based on a given `Order` for the elements of the array.\n * The returned `Order` compares two arrays by applying the given `Order` to each element in the arrays.\n * If all elements are equal, the arrays are then compared based on their length.\n * It is useful when you need to compare two arrays of the same type and you have a specific way of comparing each element of the array.\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const getOrder: <A>(O: Order<A>) => Order<ReadonlyArray<A>> = order.array\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bindTo: {\n  <N extends string>(name: N): <A>(self: ReadonlyArray<A>) => Array<{ [K in N]: A }>\n  <A, N extends string>(self: ReadonlyArray<A>, name: N): Array<{ [K in N]: A }>\n} = invariant.bindTo(Invariant) as any\n\nconst let_: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): (self: ReadonlyArray<A>) => Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: ReadonlyArray<A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = covariant.let(Covariant) as any\n\nexport {\n  /**\n   * @category do notation\n   * @since 1.0.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const Do: ReadonlyArray<{}> = of_.Do(Of)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bind: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => ReadonlyArray<B>\n  ): (self: ReadonlyArray<A>) => Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: ReadonlyArray<A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => ReadonlyArray<B>\n  ): Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = chainable.bind(Chainable) as any\n\n/**\n * A variant of `bind` that sequentially ignores the scope.\n *\n * @category do notation\n * @since 1.0.0\n */\nexport const andThenBind: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    that: ReadonlyArray<B>\n  ): (self: ReadonlyArray<A>) => Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <A extends object, N extends string, B>(\n    self: ReadonlyArray<A>,\n    name: Exclude<N, keyof A>,\n    that: ReadonlyArray<B>\n  ): Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = semiProduct.andThenBind(SemiProduct) as any\n"
  },
  {
    "path": "src/ReadonlyRecord.ts",
    "content": "/**\n * This module provides utility functions for working with records in TypeScript.\n *\n * @since 1.0.0\n */\n\nimport type { Either } from \"@fp-ts/core/Either\"\nimport * as E from \"@fp-ts/core/Either\"\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Option } from \"@fp-ts/core/Option\"\nimport * as O from \"@fp-ts/core/Option\"\nimport type * as applicative from \"@fp-ts/core/typeclass/Applicative\"\nimport * as covariant from \"@fp-ts/core/typeclass/Covariant\"\nimport type * as filterable from \"@fp-ts/core/typeclass/Filterable\"\nimport * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport * as traversable from \"@fp-ts/core/typeclass/Traversable\"\nimport * as traversableFilterable from \"@fp-ts/core/typeclass/TraversableFilterable\"\n\n// -------------------------------------------------------------------------------------\n// models\n// -------------------------------------------------------------------------------------\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport interface ReadonlyRecord<A> {\n  readonly [x: string]: A\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface ReadonlyRecordTypeLambda extends TypeLambda {\n  readonly type: ReadonlyRecord<this[\"Target\"]>\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Creates a new, empty record.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const empty = <A>(): Record<string, A> => ({})\n\n/**\n * Takes an iterable and a projection function and returns a record.\n * The projection function maps each value of the iterable to a tuple of a key and a value, which is then added to the resulting record.\n *\n * @param self - An iterable of values to be mapped to a record.\n * @param f - A projection function that maps values of the iterable to a tuple of a key and a value.\n *\n * @example\n * import { fromIterable } from '@fp-ts/core/ReadonlyRecord'\n *\n * const input = [1, 2, 3, 4]\n *\n * assert.deepStrictEqual(\n *   fromIterable(input, a => [String(a), a * 2]),\n *   { '1': 2, '2': 4, '3': 6, '4': 8 }\n * )\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const fromIterable: {\n  <A, B>(f: (a: A) => readonly [string, B]): (self: Iterable<A>) => Record<string, B>\n  <A, B>(self: Iterable<A>, f: (a: A) => readonly [string, B]): Record<string, B>\n} = dual(2, <A, B>(self: Iterable<A>, f: (a: A) => readonly [string, B]): Record<string, B> => {\n  const out: Record<string, B> = {}\n  for (const a of self) {\n    const [k, b] = f(a)\n    out[k] = b\n  }\n  return out\n})\n\n// -------------------------------------------------------------------------------------\n// guards\n// -------------------------------------------------------------------------------------\n\n/**\n * Determine if a `ReadonlyRecord` is empty.\n *\n * @param self - `ReadonlyRecord` to test for emptiness.\n *\n * @example\n * import { isEmpty } from \"@fp-ts/core/ReadonlyRecord\"\n *\n * assert.deepStrictEqual(isEmpty({}), true);\n * assert.deepStrictEqual(isEmpty({ a: 3 }), false);\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isEmpty = <A>(self: ReadonlyRecord<A>): self is Record<string, never> => {\n  for (const k in self) {\n    if (has(self, k)) {\n      return false\n    }\n  }\n  return true\n}\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * Transforms the values of a `ReadonlyRecord` into an `Array` with a custom mapping function.\n *\n * @param self - The `ReadonlyRecord` to transform.\n * @param f - The custom mapping function to apply to each key/value of the `ReadonlyRecord`.\n *\n * @example\n * import { collect } from '@fp-ts/core/ReadonlyRecord'\n *\n * const x = { a: 1, b: 2, c: 3 }\n * assert.deepStrictEqual(collect(x, (key, n) => [key, n]), [[\"a\", 1], [\"b\", 2], [\"c\", 3]])\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const collect: {\n  <A, B>(f: (key: string, a: A) => B): (self: ReadonlyRecord<A>) => Array<B>\n  <A, B>(self: ReadonlyRecord<A>, f: (key: string, a: A) => B): Array<B>\n} = dual(\n  2,\n  <A, B>(self: ReadonlyRecord<A>, f: (key: string, a: A) => B): Array<B> => {\n    const out: Array<B> = []\n    for (const key of Object.keys(self)) {\n      out.push(f(key, self[key]))\n    }\n    return out\n  }\n)\n\n/**\n * Converts a `ReadonlyRecord` to an `Array` of key-value pairs.\n *\n * @param self - A `ReadonlyRecord` to convert to an `Array`.\n *\n * @example\n * import { toArray } from '@fp-ts/core/ReadonlyRecord'\n *\n * const x = { a: 1, b: 2 }\n * assert.deepStrictEqual(toArray(x), [[\"a\", 1], [\"b\", 2]])\n *\n * @category conversions\n * @since 1.0.0\n */\nexport const toArray: <A>(self: ReadonlyRecord<A>) => Array<[string, A]> = collect((\n  key,\n  a\n) => [key, a])\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Returns the number of key/value pairs in a `ReadonlyRecord`.\n *\n * @param self - A `ReadonlyRecord` to calculate the number of key/value pairs in.\n *\n * @example\n * import { size } from \"@fp-ts/core/ReadonlyRecord\";\n *\n * assert.deepStrictEqual(size({ a: \"a\", b: 1, c: true }), 3);\n *\n * @since 1.0.0\n */\nexport const size = <A>(self: ReadonlyRecord<A>): number => Object.keys(self).length\n\n/**\n * Check if a given `key` exists in a `ReadonlyRecord`.\n *\n * @param self - the `ReadonlyRecord` to look in.\n * @param key - the key to look for in the `ReadonlyRecord`.\n *\n * @example\n * import { has } from '@fp-ts/core/ReadonlyRecord'\n *\n * assert.deepStrictEqual(has({ a: 1, b: 2 }, \"a\"), true);\n * assert.deepStrictEqual(has({ a: 1, b: 2 }, \"c\"), false);\n *\n * @since 1.0.0\n */\nexport const has: {\n  (key: string): <A>(self: ReadonlyRecord<A>) => boolean\n  <A>(self: ReadonlyRecord<A>, key: string): boolean\n} = dual(\n  2,\n  <A>(self: ReadonlyRecord<A>, key: string): boolean =>\n    Object.prototype.hasOwnProperty.call(self, key)\n)\n\n/**\n * Retrieve a value at a particular key from a `ReadonlyRecord`, returning it wrapped in an `Option`.\n *\n * @param self - The `ReadonlyRecord` to retrieve value from.\n * @param key - Key to retrieve from `ReadonlyRecord`.\n *\n * @example\n * import { get } from \"@fp-ts/core/ReadonlyRecord\"\n * import { some, none } from \"@fp-ts/core/Option\"\n *\n * const person = { name: \"John Doe\", age: 35 }\n *\n * assert.deepStrictEqual(get(person, \"name\"), some(\"John Doe\"))\n * assert.deepStrictEqual(get(person, \"email\"), none())\n *\n * @since 1.0.0\n */\nexport const get: {\n  (key: string): <A>(self: ReadonlyRecord<A>) => Option<A>\n  <A>(self: ReadonlyRecord<A>, key: string): Option<A>\n} = dual(\n  2,\n  <A>(self: ReadonlyRecord<A>, key: string): Option<A> =>\n    has(self, key) ? O.some(self[key]) : O.none()\n)\n\n/**\n * Apply a function to the element at the specified key, creating a new record,\n * or return `None` if the key doesn't exist.\n *\n * @param self - The `ReadonlyRecord` to be updated.\n * @param key - The key of the element to modify.\n * @param f - The function to apply to the element.\n *\n * @example\n * import { modifyOption } from \"@fp-ts/core/ReadonlyRecord\"\n * import { some, none } from \"@fp-ts/core/Option\"\n *\n * const f = (x: number) => x * 2\n *\n * assert.deepStrictEqual(\n *  modifyOption({ a: 3 }, 'a', f),\n *  some({ a: 6 })\n * )\n * assert.deepStrictEqual(\n *  modifyOption({ a: 3 }, 'b', f),\n *  none()\n * )\n *\n * @since 1.0.0\n */\nexport const modifyOption: {\n  <A, B>(key: string, f: (a: A) => B): (self: ReadonlyRecord<A>) => Option<Record<string, A | B>>\n  <A, B>(self: ReadonlyRecord<A>, key: string, f: (a: A) => B): Option<Record<string, A | B>>\n} = dual(\n  3,\n  <A, B>(self: ReadonlyRecord<A>, key: string, f: (a: A) => B): Option<Record<string, A | B>> => {\n    if (!has(self, key)) {\n      return O.none()\n    }\n    const out: Record<string, A | B> = { ...self }\n    out[key] = f(self[key])\n    return O.some(out)\n  }\n)\n\n/**\n * Replaces a value in the record with the new value passed as parameter.\n *\n * @param self - The `ReadonlyRecord` to be updated.\n * @param key - The key to search for in the record.\n * @param b - The new value to replace the existing value with.\n *\n * @example\n * import { replaceOption } from \"@fp-ts/core/ReadonlyRecord\"\n * import { some, none } from \"@fp-ts/core/Option\"\n *\n * assert.deepStrictEqual(\n *   replaceOption({ a: 1, b: 2, c: 3 }, 'a', 10),\n *   some({ a: 10, b: 2, c: 3 })\n * )\n * assert.deepStrictEqual(replaceOption({}, 'a', 10), none())\n *\n * @since 1.0.0\n */\nexport const replaceOption: {\n  <B>(key: string, b: B): <A>(self: ReadonlyRecord<A>) => Option<Record<string, B | A>>\n  <A, B>(self: ReadonlyRecord<A>, key: string, b: B): Option<Record<string, A | B>>\n} = dual(\n  3,\n  <A, B>(self: ReadonlyRecord<A>, key: string, b: B): Option<Record<string, A | B>> =>\n    modifyOption(self, key, () => b)\n)\n\n/**\n * Removes a key from a `ReadonlyRecord` and returns a new `Record`\n *\n * @param self - the `ReadonlyRecord` to remove the key from.\n * @param key - the key to remove from the `ReadonlyRecord`.\n *\n * @example\n * import { remove } from '@fp-ts/core/ReadonlyRecord'\n *\n * assert.deepStrictEqual(remove({ a: 1, b: 2 }, \"a\"), { b: 2 })\n *\n * @since 1.0.0\n */\nexport const remove: {\n  (key: string): <A>(self: ReadonlyRecord<A>) => Record<string, A>\n  <A>(self: ReadonlyRecord<A>, key: string): Record<string, A>\n} = dual(2, <A>(self: ReadonlyRecord<A>, key: string): Record<string, A> => {\n  const out: Record<string, A> = { ...self }\n  delete out[key]\n  return out\n})\n\n/**\n * Retrieves the value of the property with the given `key` from a `ReadonlyRecord` and returns an `Option`\n * of a tuple with the value and the `ReadonlyRecord` with the removed property.\n * If the key is not present, returns `O.none`.\n *\n * @param self - The input `ReadonlyRecord`.\n * @param key - The key of the property to retrieve.\n *\n * @example\n * import { pop } from '@fp-ts/core/ReadonlyRecord'\n * import { some, none } from '@fp-ts/core/Option'\n *\n * assert.deepStrictEqual(pop({ a: 1, b: 2 }, \"a\"), some([1, { b: 2 }]))\n * assert.deepStrictEqual(pop({ a: 1, b: 2 }, \"c\"), none())\n *\n * @category record\n * @since 1.0.0\n */\nexport const pop: {\n  (key: string): <A>(self: ReadonlyRecord<A>) => Option<readonly [A, ReadonlyRecord<A>]>\n  <A>(self: ReadonlyRecord<A>, key: string): Option<readonly [A, ReadonlyRecord<A>]>\n} = dual(2, <A>(\n  self: ReadonlyRecord<A>,\n  key: string\n): Option<readonly [A, ReadonlyRecord<A>]> =>\n  has(self, key) ? O.some([self[key], remove(self, key)]) : O.none())\n\n/**\n * Maps a `ReadonlyRecord` into another `Record` by applying a transformation function to each of its values.\n *\n * @param self - The `ReadonlyRecord` to be mapped.\n * @param f - A transformation function that will be applied to each of the values in the `ReadonlyRecord`.\n *\n * @example\n * import { map } from \"@fp-ts/core/ReadonlyRecord\"\n *\n * const f = (n: number) => `-${n}`\n *\n * assert.deepStrictEqual(map({ a: 3, b: 5 }, f), { a: \"-3\", b: \"-5\" })\n *\n * const g = (n: number, key: string) => `${key.toUpperCase()}-${n}`\n *\n * assert.deepStrictEqual(map({ a: 3, b: 5 }, g), { a: \"A-3\", b: \"B-5\" })\n *\n * @since 1.0.0\n */\nexport const map: {\n  <K extends string, A, B>(f: (a: A, key: K) => B): (self: Readonly<Record<K, A>>) => Record<K, B>\n  <K extends string, A, B>(self: Readonly<Record<K, A>>, f: (a: A, key: K) => B): Record<K, B>\n} = dual(\n  2,\n  <A, B>(self: ReadonlyRecord<A>, f: (a: A, key: string) => B): Record<string, B> => {\n    const out: Record<string, B> = {}\n    for (const key of Object.keys(self)) {\n      out[key] = f(self[key], key)\n    }\n    return out\n  }\n)\n\n/**\n * Transforms a `ReadonlyRecord` into a `Record` by applying the function `f` to each key and value in the original `ReadonlyRecord`.\n * If the function returns `Some`, the key-value pair is included in the output `Record`.\n *\n * @param self - The input `ReadonlyRecord`.\n * @param f - The transformation function.\n *\n * @example\n * import { filterMap } from '@fp-ts/core/ReadonlyRecord'\n * import { some, none } from '@fp-ts/core/Option'\n *\n * const x = { a: 1, b: 2, c: 3 }\n * const f = (a: number, key: string) => a > 2 ? some(a * 2) : none()\n * assert.deepStrictEqual(filterMap(x, f), { c: 6 })\n *\n * @since 1.0.0\n */\nexport const filterMap: {\n  <A, B>(f: (a: A, key: string) => Option<B>): (self: ReadonlyRecord<A>) => Record<string, B>\n  <A, B>(self: ReadonlyRecord<A>, f: (a: A, key: string) => Option<B>): Record<string, B>\n} = dual(2, <A, B>(\n  self: ReadonlyRecord<A>,\n  f: (a: A, key: string) => Option<B>\n): Record<string, B> => {\n  const out: Record<string, B> = {}\n  for (const key of Object.keys(self)) {\n    const o = f(self[key], key)\n    if (O.isSome(o)) {\n      out[key] = o.value\n    }\n  }\n  return out\n})\n\n/**\n * Selects properties from a record whose values match the given predicate.\n *\n * @param self - The `ReadonlyRecord` to filter.\n * @param predicate - A function that returns a `boolean` value to determine if the entry should be included in the new record.\n *\n * @example\n * import { filter } from '@fp-ts/core/ReadonlyRecord'\n *\n * const x = { a: 1, b: 2, c: 3, d: 4 }\n * assert.deepStrictEqual(filter(x, (n) => n > 2), { c: 3, d: 4 })\n *\n * @category filtering\n * @since 1.0.0\n */\nexport const filter: {\n  <C extends A, B extends A, A = C>(\n    refinement: (a: A, key: string) => a is B\n  ): (self: ReadonlyRecord<C>) => Record<string, B>\n  <B extends A, A = B>(\n    predicate: (a: A, key: string) => boolean\n  ): (self: ReadonlyRecord<B>) => Record<string, B>\n  <C extends A, B extends A, A = C>(\n    self: ReadonlyRecord<C>,\n    refinement: (a: A, key: string) => a is B\n  ): Record<string, B>\n  <B extends A, A = B>(\n    self: ReadonlyRecord<B>,\n    predicate: (a: A, key: string) => boolean\n  ): Record<string, B>\n} = dual(\n  2,\n  <B extends A, A = B>(\n    self: ReadonlyRecord<B>,\n    predicate: (a: A, key: string) => boolean\n  ): Record<string, B> => {\n    const out: Record<string, B> = {}\n    for (const key of Object.keys(self)) {\n      if (predicate(self[key], key)) {\n        out[key] = self[key]\n      }\n    }\n    return out\n  }\n)\n\n/**\n * Given a `ReadonlyRecord` with `Option` values, returns a `Record` with only the `Some` values, with the same keys.\n *\n * @param self - A `ReadonlyRecord` with `Option` values.\n *\n * @example\n * import { compact } from '@fp-ts/core/ReadonlyRecord'\n * import { some, none } from '@fp-ts/core/Option'\n *\n * assert.deepStrictEqual(\n *   compact({ a: some(1), b: none(), c: some(2) }),\n *   { a: 1, c: 2 }\n * )\n *\n * @category filtering\n * @since 1.0.0\n */\nexport const compact: <A>(self: ReadonlyRecord<Option<A>>) => Record<string, A> = filterMap(\n  identity\n)\n\n/**\n * Partitions the elements of a `ReadonlyRecord` into two groups: those that match a predicate, and those that don't.\n *\n * @param self - The `ReadonlyRecord` to partition.\n * @param f - The predicate function to apply to each element.\n *\n * @example\n * import { partitionMap } from '@fp-ts/core/ReadonlyRecord'\n * import { left, right } from '@fp-ts/core/Either'\n *\n * const x = { a: 1, b: 2, c: 3 }\n * const f = (n: number) => (n % 2 === 0 ? right(n) : left(n))\n * assert.deepStrictEqual(partitionMap(x, f), [{ a: 1, c: 3 }, { b: 2}])\n *\n * @category filtering\n * @since 1.0.0\n */\nexport const partitionMap: {\n  <A, B, C>(\n    f: (a: A, key: string) => Either<B, C>\n  ): (self: ReadonlyRecord<A>) => [Record<string, B>, Record<string, C>]\n  <A, B, C>(\n    self: ReadonlyRecord<A>,\n    f: (a: A, key: string) => Either<B, C>\n  ): [Record<string, B>, Record<string, C>]\n} = dual(\n  2,\n  <A, B, C>(\n    self: ReadonlyRecord<A>,\n    f: (a: A, key: string) => Either<B, C>\n  ): [Record<string, B>, Record<string, C>] => {\n    const left: Record<string, B> = {}\n    const right: Record<string, C> = {}\n    for (const key of Object.keys(self)) {\n      const e = f(self[key], key)\n      if (E.isLeft(e)) {\n        left[key] = e.left\n      } else {\n        right[key] = e.right\n      }\n    }\n    return [left, right]\n  }\n)\n\n/**\n * Partitions a `ReadonlyRecord` of `Either` values into two separate records,\n * one with the `Left` values and one with the `Right` values.\n *\n * @param self - the `ReadonlyRecord` to partition.\n *\n * @example\n * import { separate } from '@fp-ts/core/ReadonlyRecord'\n * import { left, right } from '@fp-ts/core/Either'\n *\n * assert.deepStrictEqual(\n *   separate({ a: left(\"e\"), b: right(1) }),\n *   [{ a: \"e\" }, { b: 1 }]\n * )\n *\n * @category filtering\n * @since 1.0.0\n */\nexport const separate: <A, B>(\n  self: ReadonlyRecord<Either<A, B>>\n) => [Record<string, A>, Record<string, B>] = partitionMap(identity)\n\n/**\n * Partitions a `ReadonlyRecord` into two separate `Record`s based on the result of a predicate function.\n *\n * @param self - The input `ReadonlyRecord` to partition.\n * @param predicate - The partitioning function to determine the partitioning of each value of the `ReadonlyRecord`.\n *\n * @example\n * import { partition } from '@fp-ts/core/ReadonlyRecord'\n *\n * assert.deepStrictEqual(\n *   partition({ a: 1, b: 3 }, (n) => n > 2),\n *   [{ a: 1 }, { b: 3 }]\n * )\n *\n * @category filtering\n * @since 1.0.0\n */\nexport const partition: {\n  <C extends A, B extends A, A = C>(refinement: (a: A, key: string) => a is B): (\n    self: ReadonlyRecord<C>\n  ) => [Record<string, C>, Record<string, B>]\n  <B extends A, A = B>(\n    predicate: (a: A, key: string) => boolean\n  ): (self: ReadonlyRecord<B>) => [Record<string, B>, Record<string, B>]\n  <C extends A, B extends A, A = C>(\n    self: ReadonlyRecord<C>,\n    refinement: (a: A, key: string) => a is B\n  ): [Record<string, C>, Record<string, B>]\n  <B extends A, A = B>(\n    self: ReadonlyRecord<B>,\n    predicate: (a: A, key: string) => boolean\n  ): [Record<string, B>, Record<string, B>]\n} = dual(\n  2,\n  <B extends A, A = B>(\n    self: ReadonlyRecord<B>,\n    predicate: (a: A, key: string) => boolean\n  ): [Record<string, B>, Record<string, B>] => {\n    const left: Record<string, B> = {}\n    const right: Record<string, B> = {}\n    for (const key of Object.keys(self)) {\n      if (predicate(self[key], key)) {\n        right[key] = self[key]\n      } else {\n        left[key] = self[key]\n      }\n    }\n    return [left, right]\n  }\n)\n\n/**\n * Maps each entry of a `ReadonlyRecord` to an effect and collects the results into a new record.\n *\n * @param F - an {@link applicative.Applicative Applicative} instance.\n * @param self - a `ReadonlyRecord` to map over.\n * @param f - the mapping function, which maps an entry `a` and its corresponding `key` to an effect.\n *\n * @example\n * import { traverse } from '@fp-ts/core/ReadonlyRecord'\n * import { some, none, Applicative } from '@fp-ts/core/Option'\n *\n * assert.deepStrictEqual(\n *   traverse(Applicative)({ a: 1, b: 2 }, (n: number) => (n <= 2 ? some(n) : none())),\n *   some({ a: 1, b: 2 })\n * )\n * assert.deepStrictEqual(\n *   traverse(Applicative)({ a: 1, b: 2 }, (n: number) => (n >= 2 ? some(n) : none())),\n *   none()\n * )\n *\n * @category traversing\n * @since 1.0.0\n */\nexport const traverse = <F extends TypeLambda>(F: applicative.Applicative<F>): {\n  <A, R, O, E, B>(\n    f: (a: A, key: string) => Kind<F, R, O, E, B>\n  ): (self: ReadonlyRecord<A>) => Kind<F, R, O, E, Record<string, B>>\n  <A, R, O, E, B>(\n    self: ReadonlyRecord<A>,\n    f: (a: A, key: string) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Record<string, B>>\n} =>\n  dual(2, <A, R, O, E, B>(\n    self: ReadonlyRecord<A>,\n    f: (a: A, key: string) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Record<string, B>> =>\n    F.map(\n      F.productAll(\n        Object.entries(self).map(([key, a]) => F.map(f(a, key), b => [key, b] as const))\n      ),\n      Object.fromEntries\n    ))\n\n/**\n * Transforms a `ReadonlyRecord` of `Kind` values into a `Kind` of `Record` values.\n *\n * @param F - an {@link applicative.Applicative Applicative} instance.\n * @param self - the `ReadonlyRecord` of `Kind` values.\n *\n * @example\n * import * as RR from '@fp-ts/core/ReadonlyRecord'\n * import { some, none, Applicative } from '@fp-ts/core/Option'\n *\n * const sequence = RR.sequence(Applicative)\n *\n * assert.deepStrictEqual(sequence({ a: some(1), b: some(2) }), some({ a: 1, b: 2 }))\n * assert.deepStrictEqual(sequence({ a: none(), b: some(2) }), none())\n *\n * @category traversing\n * @since 1.0.0\n */\nexport const sequence = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): <R, O, E, A>(\n  self: ReadonlyRecord<Kind<F, R, O, E, A>>\n) => Kind<F, R, O, E, Record<string, A>> => traverse(F)(identity)\n\nconst imap = covariant.imap<ReadonlyRecordTypeLambda>(map)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Covariant: covariant.Covariant<ReadonlyRecordTypeLambda> = {\n  imap,\n  map\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<ReadonlyRecordTypeLambda> = {\n  imap\n}\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const tupled: <A>(self: ReadonlyRecord<A>) => Record<string, [A]> = invariant.tupled(\n  Invariant\n)\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const flap: {\n  <A, B>(self: ReadonlyRecord<(a: A) => B>): (a: A) => Record<string, B>\n  <A, B>(a: A, self: ReadonlyRecord<(a: A) => B>): Record<string, B>\n} = covariant.flap(Covariant)\n\n/**\n * Maps the success value of this effect to the specified constant value.\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const as: {\n  <B>(b: B): <_>(self: ReadonlyRecord<_>) => Record<string, B>\n  <_, B>(self: ReadonlyRecord<_>, b: B): Record<string, B>\n} = covariant.as(Covariant)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Filterable: filterable.Filterable<ReadonlyRecordTypeLambda> = {\n  partitionMap,\n  filterMap\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Traversable: traversable.Traversable<ReadonlyRecordTypeLambda> = {\n  traverse\n}\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): (self: ReadonlyRecord<A>) => Kind<F, R, O, E, Record<string, A>>\n  <A, R, O, E, B>(\n    self: ReadonlyRecord<A>,\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, Record<string, A>>\n} = traversable.traverseTap(Traversable)\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const traversePartitionMap = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): {\n  <A, R, O, E, B, C>(\n    f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n  ): (\n    self: ReadonlyRecord<A>\n  ) => Kind<F, R, O, E, [Record<string, B>, Record<string, C>]>\n  <A, R, O, E, B, C>(\n    self: ReadonlyRecord<A>,\n    f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n  ): Kind<F, R, O, E, [Record<string, B>, Record<string, C>]>\n} =>\n  dual(2, <A, R, O, E, B, C>(\n    self: ReadonlyRecord<A>,\n    f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n  ): Kind<F, R, O, E, [Record<string, B>, Record<string, C>]> => {\n    return F.map(traverse(F)(self, f), separate)\n  })\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const traverseFilterMap = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): {\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, Option<B>>\n  ): (self: ReadonlyRecord<A>) => Kind<F, R, O, E, Record<string, B>>\n  <A, R, O, E, B>(\n    self: ReadonlyRecord<A>,\n    f: (a: A) => Kind<F, R, O, E, Option<B>>\n  ): Kind<F, R, O, E, Record<string, B>>\n} =>\n  dual(2, <A, R, O, E, B>(\n    self: ReadonlyRecord<A>,\n    f: (a: A) => Kind<F, R, O, E, Option<B>>\n  ): Kind<F, R, O, E, Record<string, B>> => {\n    return F.map(traverse(F)(self, f), compact)\n  })\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const TraversableFilterable: traversableFilterable.TraversableFilterable<\n  ReadonlyRecordTypeLambda\n> = {\n  traversePartitionMap,\n  traverseFilterMap\n}\n\n/**\n * Filter values inside a context.\n *\n * @since 1.0.0\n */\nexport const traverseFilter: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): (self: ReadonlyRecord<B>) => Kind<F, R, O, E, Record<string, B>>\n  <B extends A, R, O, E, A = B>(\n    self: ReadonlyRecord<B>,\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): Kind<F, R, O, E, Record<string, B>>\n} = traversableFilterable.traverseFilter(TraversableFilterable)\n\n/**\n * @since 1.0.0\n */\nexport const traversePartition: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <B extends A, R, O, E, A = B>(\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): (\n    self: ReadonlyRecord<B>\n  ) => Kind<F, R, O, E, [Record<string, B>, Record<string, B>]>\n  <B extends A, R, O, E, A = B>(\n    self: ReadonlyRecord<B>,\n    predicate: (a: A) => Kind<F, R, O, E, boolean>\n  ): Kind<F, R, O, E, [Record<string, B>, Record<string, B>]>\n} = traversableFilterable.traversePartition(TraversableFilterable)\n"
  },
  {
    "path": "src/String.ts",
    "content": "/**\n * This module provides utility functions and type class instances for working with the `string` type in TypeScript.\n * It includes functions for basic string manipulation, as well as type class instances for\n * `Equivalence`, `Order`, `Semigroup`, and `Monoid`.\n *\n * @since 1.0.0\n */\n\nimport { dual } from \"@fp-ts/core/Function\"\nimport * as readonlyArray from \"@fp-ts/core/internal/ReadonlyArray\"\nimport type { Refinement } from \"@fp-ts/core/Predicate\"\nimport * as predicate from \"@fp-ts/core/Predicate\"\nimport type { NonEmptyArray } from \"@fp-ts/core/ReadonlyArray\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * Tests if a value is a `string`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isString } from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(isString(\"a\"), true)\n * assert.deepStrictEqual(isString(1), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isString: Refinement<unknown, string> = predicate.isString\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Equivalence: equivalence.Equivalence<string> = equivalence.string\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Order: order.Order<string> = order.string\n\n/**\n * `string` semigroup under concatenation.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const Semigroup: semigroup.Semigroup<string> = semigroup.string\n\n/**\n * `string` monoid under concatenation.\n *\n * The `empty` value is `''`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const Monoid: monoid.Monoid<string> = monoid.string\n\n/**\n * The empty string `\"\"`.\n *\n * @since 1.0.0\n */\nexport const empty: \"\" = \"\" as const\n\n/**\n * @since 1.0.0\n */\nexport const concat: {\n  (that: string): (self: string) => string\n  (self: string, that: string): string\n} = dual(2, Semigroup.combine)\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n * import { pipe } from '@fp-ts/core/Function'\n *\n * assert.deepStrictEqual(pipe('a', S.toUpperCase), 'A')\n *\n * @since 1.0.0\n */\nexport const toUpperCase = (self: string): string => self.toUpperCase()\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n * import { pipe } from '@fp-ts/core/Function'\n *\n * assert.deepStrictEqual(pipe('A', S.toLowerCase), 'a')\n *\n * @since 1.0.0\n */\nexport const toLowerCase = (self: string): string => self.toLowerCase()\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n * import { pipe } from '@fp-ts/core/Function'\n *\n * assert.deepStrictEqual(pipe('abc', S.replace('b', 'd')), 'adc')\n *\n * @since 1.0.0\n */\nexport const replace: {\n  (searchValue: string | RegExp, replaceValue: string): (self: string) => string\n  (self: string, searchValue: string | RegExp, replaceValue: string): string\n} = dual(\n  3,\n  (self: string, searchValue: string | RegExp, replaceValue: string): string =>\n    self.replace(searchValue, replaceValue)\n)\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.trim(' a '), 'a')\n *\n * @since 1.0.0\n */\nexport const trim = (self: string): string => self.trim()\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.trimStart(' a '), 'a ')\n *\n * @since 1.0.0\n */\nexport const trimStart = (self: string): string => self.trimStart()\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.trimEnd(' a '), ' a')\n *\n * @since 1.0.0\n */\nexport const trimEnd = (self: string): string => self.trimEnd()\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n * import { pipe } from '@fp-ts/core/Function'\n *\n * assert.deepStrictEqual(pipe('abcd', S.slice(1, 3)), 'bc')\n *\n * @since 1.0.0\n */\nexport const slice: {\n  (start: number, end: number): (self: string) => string\n  (self: string, start: number, end: number): string\n} = dual(3, (self: string, start: number, end: number): string => self.slice(start, end))\n\n/**\n * Test whether a `string` is empty.\n *\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.isEmpty(''), true)\n * assert.deepStrictEqual(S.isEmpty('a'), false)\n *\n * @since 1.0.0\n */\nexport const isEmpty = (self: string): self is \"\" => self.length === 0\n\n/**\n * Test whether a `string` is non empty.\n *\n * @since 1.0.0\n */\nexport const isNonEmpty = (self: string): boolean => self.length > 0\n\n/**\n * Calculate the number of characters in a `string`.\n *\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.length('abc'), 3)\n *\n * @since 1.0.0\n */\nexport const length = (self: string): number => self.length\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n * import { pipe } from '@fp-ts/core/Function'\n *\n * assert.deepStrictEqual(pipe('abc', S.split('')), ['a', 'b', 'c'])\n * assert.deepStrictEqual(pipe('', S.split('')), [''])\n *\n * @since 1.0.0\n */\nexport const split: {\n  (separator: string | RegExp): (self: string) => NonEmptyArray<string>\n  (self: string, separator: string | RegExp): NonEmptyArray<string>\n} = dual(2, (self: string, separator: string | RegExp): NonEmptyArray<string> => {\n  const out = self.split(separator)\n  return readonlyArray.isNonEmptyArray(out) ? out : [self]\n})\n\n/**\n * Returns `true` if `searchString` appears as a substring of `self`, at one or more positions that are\n * greater than or equal to `0`; otherwise, returns `false`.\n *\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.includes(\"abc\", \"b\"), true)\n * assert.deepStrictEqual(S.includes(\"abc\", \"d\"), false)\n *\n * @since 1.0.0\n */\nexport const includes: {\n  (searchString: string): (self: string) => boolean\n  (self: string, searchString: string): boolean\n} = dual(2, (self: string, searchString: string): boolean => self.includes(searchString))\n\n/**\n * Returns `true` if `searchString` appears as a substring of `self`, at one or more positions that are\n * greater than or equal to `position`; otherwise, returns `false`.\n *\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.includesWithPosition(\"abc\", \"b\", 1), true)\n * assert.deepStrictEqual(S.includesWithPosition(\"abc\", \"a\", 1), false)\n *\n * @since 1.0.0\n */\nexport const includesWithPosition: {\n  (searchString: string, position: number): (self: string) => boolean\n  (self: string, searchString: string, position: number): boolean\n} = dual(\n  3,\n  (self: string, searchString: string, position: number): boolean =>\n    self.includes(searchString, position)\n)\n\n/**\n * Returns `true` if the sequence of elements of `searchString` is the\n * same as the corresponding elements of `s` starting at\n * position. Otherwise returns false.\n *\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.startsWith(\"abc\", \"a\"), true)\n * assert.deepStrictEqual(S.startsWith(\"bc\", \"a\"), false)\n *\n * @since 1.0.0\n */\nexport const startsWith: {\n  (searchString: string): (self: string) => boolean\n  (self: string, searchString: string): boolean\n} = dual(\n  2,\n  (self: string, searchString: string): boolean => self.startsWith(searchString)\n)\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.startsWithPosition(\"abc\", \"b\", 1), true)\n * assert.deepStrictEqual(S.startsWithPosition(\"bc\", \"a\", 1), false)\n *\n * @since 1.0.0\n */\nexport const startsWithPosition: {\n  (searchString: string, position: number): (self: string) => boolean\n  (self: string, searchString: string, position: number): boolean\n} = dual(\n  3,\n  (self: string, searchString: string, position: number): boolean =>\n    self.startsWith(searchString, position)\n)\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.endsWith(\"abc\", \"c\"), true)\n * assert.deepStrictEqual(S.endsWith(\"ab\", \"c\"), false)\n *\n * @since 1.0.0\n */\nexport const endsWith: {\n  (searchString: string): (self: string) => boolean\n  (self: string, searchString: string): boolean\n} = dual(2, (self: string, searchString: string): boolean => self.endsWith(searchString))\n\n/**\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.endsWithPosition(\"abc\", \"b\", 2), true)\n * assert.deepStrictEqual(S.endsWithPosition(\"abc\", \"c\", 2), false)\n *\n * @since 1.0.0\n */\nexport const endsWithPosition: {\n  (searchString: string, position: number): (self: string) => boolean\n  (self: string, searchString: string, position: number): boolean\n} = dual(\n  3,\n  (self: string, searchString: string, position: number): boolean =>\n    self.endsWith(searchString, position)\n)\n\n/**\n * Keep the specified number of characters from the start of a string.\n *\n * If `n` is larger than the available number of characters, the string will\n * be returned whole.\n *\n * If `n` is not a positive number, an empty string will be returned.\n *\n * If `n` is a float, it will be rounded down to the nearest integer.\n *\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.takeLeft(\"Hello World\", 5), \"Hello\")\n *\n * @since 1.0.0\n */\nexport const takeLeft: {\n  (n: number): (self: string) => string\n  (self: string, n: number): string\n} = dual(2, (self: string, n: number): string => self.slice(0, Math.max(n, 0)))\n\n/**\n * Keep the specified number of characters from the end of a string.\n *\n * If `n` is larger than the available number of characters, the string will\n * be returned whole.\n *\n * If `n` is not a positive number, an empty string will be returned.\n *\n * If `n` is a float, it will be rounded down to the nearest integer.\n *\n * @example\n * import * as S from '@fp-ts/core/String'\n *\n * assert.deepStrictEqual(S.takeRight(\"Hello World\", 5), \"World\")\n *\n * @since 1.0.0\n */\nexport const takeRight: {\n  (n: number): (self: string) => string\n  (self: string, n: number): string\n} = dual(\n  2,\n  (self: string, n: number): string =>\n    self.slice(Math.max(0, self.length - Math.floor(n)), Infinity)\n)\n\n/*\n\n  Missing:\n\n  - charCodeAt\n  - substring\n  - at\n  - charAt\n  - codePointAt\n  - indexOf\n  - lastIndexOf\n  - localeCompare\n  - match\n  - matchAll\n  - normalize\n  - padEnd\n  - padStart\n  - repeat\n  - replaceAll\n  - search\n  - toLocaleLowerCase\n  - toLocaleUpperCase\n*/\n\n// TODO: 100% coverage tests (ask Max)\n// const CR = 0x0d\n// const LF = 0x0a\n\n// /**\n//  * Returns an `IterableIterator` which yields each line contained within the\n//  * string, trimming off the trailing newline character.\n//  *\n//  * @since 1.0.0\n//  */\n// // export const linesIterator = (self: string): LinesIterator => linesSeparated(self, true)\n\n// /**\n//  * Returns an `IterableIterator` which yields each line contained within the\n//  * string as well as the trailing newline character.\n//  *\n//  * @since 1.0.0\n//  */\n// export const linesWithSeparators = (s: string): LinesIterator => linesSeparated(s, false)\n\n// /**\n//  * For every line in this string, strip a leading prefix consisting of blanks\n//  * or control characters followed by the character specified by `marginChar`\n//  * from the line.\n//  *\n//  * @since 1.0.0\n//  */\n// export const stripMarginWith = (marginChar: string) =>\n//   (self: string): string => {\n//     let out = \"\"\n\n//     for (const line of linesWithSeparators(self)) {\n//       let index = 0\n\n//       while (index < line.length && line.charAt(index) <= \" \") {\n//         index = index + 1\n//       }\n\n//       const stripped = index < line.length && line.charAt(index) === marginChar\n//         ? line.substring(index + 1)\n//         : line\n\n//       out = out + stripped\n//     }\n\n//     return out\n//   }\n\n// /**\n//  * For every line in this string, strip a leading prefix consisting of blanks\n//  * or control characters followed by the `\"|\"` character from the line.\n//  *\n//  * @since 1.0.0\n//  */\n// export const stripMargin = (self: string): string => stripMarginWith(\"|\")(self)\n\n// class LinesIterator implements IterableIterator<string> {\n//   private index: number\n//   private readonly length: number\n\n//   constructor(readonly s: string, readonly stripped: boolean = false) {\n//     this.index = 0\n//     this.length = s.length\n//   }\n\n//   next(): IteratorResult<string> {\n//     if (this.done) {\n//       return { done: true, value: undefined }\n//     }\n//     const start = this.index\n//     while (!this.done && !isLineBreak(this.s[this.index]!)) {\n//       this.index = this.index + 1\n//     }\n//     let end = this.index\n//     if (!this.done) {\n//       const char = this.s[this.index]!\n//       this.index = this.index + 1\n//       if (!this.done && isLineBreak2(char, this.s[this.index]!)) {\n//         this.index = this.index + 1\n//       }\n//       if (!this.stripped) {\n//         end = this.index\n//       }\n//     }\n//     return { done: false, value: this.s.substring(start, end) }\n//   }\n\n//   [Symbol.iterator](): IterableIterator<string> {\n//     return new LinesIterator(this.s, this.stripped)\n//   }\n\n//   private get done(): boolean {\n//     return this.index >= this.length\n//   }\n// }\n\n// /**\n//  * Test if the provided character is a line break character (i.e. either `\"\\r\"`\n//  * or `\"\\n\"`).\n//  */\n// const isLineBreak = (char: string): boolean => {\n//   const code = char.charCodeAt(0)\n//   return code === CR || code === LF\n// }\n\n// /**\n//  * Test if the provided characters combine to form a carriage return/line-feed\n//  * (i.e. `\"\\r\\n\"`).\n//  */\n// const isLineBreak2 = (char0: string, char1: string): boolean =>\n//   char0.charCodeAt(0) === CR && char1.charCodeAt(0) === LF\n\n// const linesSeparated = (self: string, stripped: boolean): LinesIterator =>\n//   new LinesIterator(self, stripped)\n"
  },
  {
    "path": "src/Struct.ts",
    "content": "/**\n * This module provides utility functions for working with structs in TypeScript.\n *\n * @since 1.0.0\n */\n\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * Create a new object by picking properties of an existing object.\n *\n * @example\n * import { pick } from \"@fp-ts/core/Struct\"\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(pipe({ a: \"a\", b: 1, c: true }, pick(\"a\", \"b\")), { a: \"a\", b: 1 })\n *\n * @since 1.0.0\n */\nexport const pick = <S, Keys extends readonly [keyof S, ...Array<keyof S>]>(\n  ...keys: Keys\n) =>\n  (s: S): { [K in Keys[number]]: S[K] } => {\n    const out: any = {}\n    for (const k of keys) {\n      out[k] = s[k]\n    }\n    return out\n  }\n\n/**\n * Create a new object by omitting properties of an existing object.\n *\n * @example\n * import { omit } from \"@fp-ts/core/Struct\"\n * import { pipe } from \"@fp-ts/core/Function\"\n *\n * assert.deepStrictEqual(pipe({ a: \"a\", b: 1, c: true }, omit(\"c\")), { a: \"a\", b: 1 })\n *\n * @since 1.0.0\n */\nexport const omit = <S, Keys extends readonly [keyof S, ...Array<keyof S>]>(\n  ...keys: Keys\n) =>\n  (s: S): { [K in Exclude<keyof S, Keys[number]>]: S[K] } => {\n    const out: any = { ...s }\n    for (const k of keys) {\n      delete out[k]\n    }\n    return out\n  }\n\n/**\n * Given a struct of `Equivalence`s returns a new `Equivalence` that compares values of a struct\n * by applying each `Equivalence` to the corresponding property of the struct.\n *\n * Alias of {@link equivalence.struct}.\n *\n * @example\n * import { getEquivalence } from \"@fp-ts/core/Struct\"\n * import * as S from \"@fp-ts/core/String\"\n * import * as N from \"@fp-ts/core/Number\"\n *\n * const PersonEquivalence = getEquivalence({\n *   name: S.Equivalence,\n *   age: N.Equivalence\n * })\n *\n * assert.deepStrictEqual(\n *   PersonEquivalence({ name: \"John\", age: 25 }, { name: \"John\", age: 25 }),\n *   true\n * )\n * assert.deepStrictEqual(\n *   PersonEquivalence({ name: \"John\", age: 25 }, { name: \"John\", age: 40 }),\n *   false\n * )\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const getEquivalence: <R extends Record<string, equivalence.Equivalence<any>>>(\n  predicates: R\n) => equivalence.Equivalence<\n  { readonly [K in keyof R]: [R[K]] extends [equivalence.Equivalence<infer A>] ? A : never }\n> = equivalence.struct\n\n/**\n * This function creates and returns a new `Order` for a struct of values based on the given `Order`s\n * for each property in the struct.\n *\n * Alias of {@link order.struct}.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const getOrder: <R extends { readonly [x: string]: order.Order<any> }>(\n  fields: R\n) => order.Order<{ [K in keyof R]: [R[K]] extends [order.Order<infer A>] ? A : never }> =\n  order.struct\n\n/**\n * This function creates and returns a new `Semigroup` for a struct of values based on the given `Semigroup`s for each property in the struct.\n * The returned `Semigroup` combines two structs of the same type by applying the corresponding `Semigroup` passed as arguments to each property in the struct.\n *\n * It is useful when you need to combine two structs of the same type and you have a specific way of combining each property of the struct.\n *\n * See also {@link getMonoid}.\n *\n * @example\n * import { getSemigroup } from \"@fp-ts/core/Struct\"\n * import * as Semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n * import * as O from \"@fp-ts/core/Option\"\n *\n * const PersonSemigroup = getSemigroup({\n *   name: Semigroup.last<string>(),\n *   age: O.getOptionalMonoid(Semigroup.last<number>())\n * })\n *\n * assert.deepStrictEqual(\n *   PersonSemigroup.combine({ name: \"John\", age: O.none() }, { name: \"John\", age: O.some(25) }),\n *   { name: \"John\", age: O.some(25) }\n * )\n * assert.deepStrictEqual(\n *   PersonSemigroup.combine({ name: \"John\", age: O.some(25) }, { name: \"John\", age: O.none() }),\n *   { name: \"John\", age: O.some(25) }\n * )\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const getSemigroup: <R extends { readonly [x: string]: semigroup.Semigroup<any> }>(\n  fields: R\n) => semigroup.Semigroup<\n  { [K in keyof R]: [R[K]] extends [semigroup.Semigroup<infer A>] ? A : never }\n> = semigroup.struct\n\n/**\n * This function creates and returns a new `Monoid` for a struct of values based on the given `Monoid`s for each property in the struct.\n * The returned `Monoid` combines two structs of the same type by applying the corresponding `Monoid` passed as arguments to each property in the struct.\n *\n * The `empty` value of the returned `Monoid` is a struct where each property is the `empty` value of the corresponding `Monoid` in the input `monoids` object.\n *\n * It is useful when you need to combine two structs of the same type and you have a specific way of combining each property of the struct.\n *\n * See also {@link getSemigroup}.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const getMonoid: <R extends { readonly [x: string]: monoid.Monoid<any> }>(\n  fields: R\n) => monoid.Monoid<{ [K in keyof R]: [R[K]] extends [monoid.Monoid<infer A>] ? A : never }> =\n  monoid.struct\n"
  },
  {
    "path": "src/Symbol.ts",
    "content": "/**\n * @since 1.0.0\n */\n\nimport * as predicate from \"@fp-ts/core/Predicate\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\n\n/**\n * Tests if a value is a `symbol`.\n *\n * @param input - The value to test.\n *\n * @example\n * import { isSymbol } from \"@fp-ts/core/Predicate\"\n *\n * assert.deepStrictEqual(isSymbol(Symbol.for(\"a\")), true)\n * assert.deepStrictEqual(isSymbol(\"a\"), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isSymbol: (u: unknown) => u is symbol = predicate.isSymbol\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Equivalence: equivalence.Equivalence<symbol> = equivalence.symbol\n"
  },
  {
    "path": "src/These.ts",
    "content": "/**\n * @since 1.0.0\n */\n\nimport type { Either, Left, Right } from \"@fp-ts/core/Either\"\nimport * as E from \"@fp-ts/core/Either\"\nimport type { LazyArg } from \"@fp-ts/core/Function\"\nimport { constNull, constUndefined, dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport { proto, structural } from \"@fp-ts/core/internal/effect\"\nimport * as N from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Option\"\nimport type { Option } from \"@fp-ts/core/Option\"\nimport type { Predicate, Refinement } from \"@fp-ts/core/Predicate\"\nimport type { NonEmptyReadonlyArray } from \"@fp-ts/core/ReadonlyArray\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as applicative from \"@fp-ts/core/typeclass/Applicative\"\nimport * as bicovariant from \"@fp-ts/core/typeclass/Bicovariant\"\nimport * as chainable from \"@fp-ts/core/typeclass/Chainable\"\nimport * as covariant from \"@fp-ts/core/typeclass/Covariant\"\nimport type { Equivalence } from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as flatMap_ from \"@fp-ts/core/typeclass/FlatMap\"\nimport type * as foldable from \"@fp-ts/core/typeclass/Foldable\"\nimport * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport type * as monad from \"@fp-ts/core/typeclass/Monad\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\nimport * as of_ from \"@fp-ts/core/typeclass/Of\"\nimport type * as pointed from \"@fp-ts/core/typeclass/Pointed\"\nimport * as product_ from \"@fp-ts/core/typeclass/Product\"\nimport type * as semiAlternative from \"@fp-ts/core/typeclass/SemiAlternative\"\nimport * as semiApplicative from \"@fp-ts/core/typeclass/SemiApplicative\"\nimport * as semiCoproduct from \"@fp-ts/core/typeclass/SemiCoproduct\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\nimport * as traversable from \"@fp-ts/core/typeclass/Traversable\"\n\n/**\n * @category model\n * @since 1.0.0\n */\nexport interface Both<E, A> {\n  readonly _tag: \"Both\"\n  readonly left: E\n  readonly right: A\n}\n\n/**\n * @category model\n * @since 1.0.0\n */\nexport type These<E, A> = Either<E, A> | Both<E, A>\n\n/**\n * @category model\n * @since 1.0.0\n */\nexport type Validated<E, A> = These<NonEmptyReadonlyArray<E>, A>\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface TheseTypeLambda extends TypeLambda {\n  readonly type: These<this[\"Out1\"], this[\"Target\"]>\n}\n\n/**\n * @category type lambdas\n * @since 3.0.0\n */\nexport interface ValidatedTypeLambda extends TypeLambda {\n  readonly type: Validated<this[\"Out1\"], this[\"Target\"]>\n}\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const left: <E>(left: E) => These<E, never> = E.left\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const right: <A>(right: A) => These<never, A> = E.right\n\n/**\n * Alias of {@link right}.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const of: <A>(right: A) => These<never, A> = right\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const both = <E, A>(left: E, right: A): These<E, A> =>\n  Object.setPrototypeOf({ _tag: \"Both\", left, right }, proto)\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const leftOrBoth: {\n  <E>(onSome: LazyArg<E>): <A>(self: Option<A>) => These<E, A>\n  <A, E>(self: Option<A>, onSome: LazyArg<E>): These<E, A>\n} = dual(\n  2,\n  <A, E>(self: Option<A>, onSome: LazyArg<E>): These<E, A> =>\n    O.isNone(self) ? left(onSome()) : both(onSome(), self.value)\n)\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const rightOrBoth: {\n  <A>(onNone: LazyArg<A>): <E>(self: Option<E>) => These<E, A>\n  <E, A>(self: Option<E>, onNone: LazyArg<A>): These<E, A>\n} = dual(\n  2,\n  <E, A>(self: Option<E>, onNone: LazyArg<A>): These<E, A> =>\n    O.isNone(self) ? right(onNone()) : both(self.value, onNone())\n)\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const fail = <E>(e: E): Validated<E, never> => left([e])\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const warn = <E, A>(e: E, a: A): Validated<E, A> => both([e], a)\n\n// -------------------------------------------------------------------------------------\n// equivalence\n// -------------------------------------------------------------------------------------\n\n/**\n * @category equivalence\n * @since 1.0.0\n */\nexport const getEquivalence = <E, A>(\n  EE: Equivalence<E>,\n  EA: Equivalence<A>\n): Equivalence<These<E, A>> =>\n  equivalence.make((x, y) =>\n    isLeft(x)\n      ? isLeft(y) && EE(x.left, y.left)\n      : isRight(x)\n      ? isRight(y) && EA(x.right, y.right)\n      : isBoth(y) && EE(x.left, y.left) && EA(x.right, y.right)\n  )\n\n/**\n * @category pattern matching\n * @since 1.0.0\n */\nexport const match: {\n  <E, B, A, C = B, D = B>(\n    onLeft: (e: E) => B,\n    onRight: (a: A) => C,\n    onBoth: (e: E, a: A) => D\n  ): (self: These<E, A>) => B | C | D\n  <E, B, A, C = B, D = B>(\n    self: These<E, A>,\n    onLeft: (e: E) => B,\n    onRight: (a: A) => C,\n    onBoth: (e: E, a: A) => D\n  ): B | C | D\n} = dual(4, <E, B, A, C = B, D = B>(\n  self: These<E, A>,\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C,\n  onBoth: (e: E, a: A) => D\n): B | C | D => {\n  switch (self._tag) {\n    case \"Left\":\n      return onLeft(self.left)\n    case \"Right\":\n      return onRight(self.right)\n    case \"Both\":\n      return onBoth(self.left, self.right)\n  }\n})\n\n/**\n * @since 1.0.0\n */\nexport const reverse: <E, A>(self: These<E, A>) => These<A, E> = match(\n  right,\n  left,\n  (e, a) => both(a, e)\n)\n\n// -------------------------------------------------------------------------------------\n// guards\n// -------------------------------------------------------------------------------------\n\n/**\n * Tests if a value is a `These`.\n *\n * @param input - The value to check.\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isThese = (input: unknown): input is These<unknown, unknown> =>\n  typeof input === \"object\" && input != null && structural in input && \"_tag\" in input &&\n  (input[\"_tag\"] === \"Left\" || input[\"_tag\"] === \"Right\" || input[\"_tag\"] === \"Both\")\n\n/**\n * Determine if a `These` is a `Left`.\n *\n * @param self - The `These` to check.\n *\n * @example\n * import { isLeft, left, right, both } from '@fp-ts/core/These'\n *\n * assert.deepStrictEqual(isLeft(right(1)), false)\n * assert.deepStrictEqual(isLeft(left(\"error\")), true)\n * assert.deepStrictEqual(isLeft(both(\"error\", 1)), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isLeft = <E, A>(self: These<E, A>): self is Left<E> => self._tag === \"Left\"\n\n/**\n * Determine if a `These` is a `Left` or a `Both`.\n *\n * @param self - The `These` to check.\n *\n * @example\n * import { isLeftOrBoth, left, right, both } from '@fp-ts/core/These'\n *\n * assert.deepStrictEqual(isLeftOrBoth(right(1)), false)\n * assert.deepStrictEqual(isLeftOrBoth(left(\"error\")), true)\n * assert.deepStrictEqual(isLeftOrBoth(both(\"error\", 1)), true)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isLeftOrBoth = <E, A>(self: These<E, A>): self is Left<E> | Both<E, A> =>\n  self._tag !== \"Right\"\n\n/**\n * Determine if a `These` is a `Right`.\n *\n * @param self - The `These` to check.\n *\n * @example\n * import { isRight, left, right, both } from '@fp-ts/core/These'\n *\n * assert.deepStrictEqual(isRight(right(1)), true)\n * assert.deepStrictEqual(isRight(left(\"error\")), false)\n * assert.deepStrictEqual(isRight(both(\"error\", 1)), false)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isRight = <E, A>(self: These<E, A>): self is Right<A> => self._tag === \"Right\"\n\n/**\n * Determine if a `These` is a `Right` or a `Both`.\n *\n * @param self - The `These` to check.\n *\n * @example\n * import { isRightOrBoth, left, right, both } from '@fp-ts/core/These'\n *\n * assert.deepStrictEqual(isRightOrBoth(right(1)), true)\n * assert.deepStrictEqual(isRightOrBoth(left(\"error\")), false)\n * assert.deepStrictEqual(isRightOrBoth(both(\"error\", 1)), true)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isRightOrBoth = <E, A>(self: These<E, A>): self is Right<A> | Both<E, A> =>\n  self._tag !== \"Left\"\n\n/**\n * Determine if a `These` is a `Both`.\n *\n * @param self - The `These` to check.\n *\n * @example\n * import { isBoth, left, right, both } from '@fp-ts/core/These'\n *\n * assert.deepStrictEqual(isBoth(right(1)), false)\n * assert.deepStrictEqual(isBoth(left(\"error\")), false)\n * assert.deepStrictEqual(isBoth(both(\"error\", 1)), true)\n *\n * @category guards\n * @since 1.0.0\n */\nexport const isBoth = <E, A>(self: These<E, A>): self is Both<E, A> => self._tag === \"Both\"\n\n/**\n * Lifts a function that may throw to one returning a `These`.\n *\n * @category interop\n * @since 1.0.0\n */\nexport const liftThrowable: <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => B,\n  onThrow: (error: unknown) => E\n) => ((...a: A) => These<E, B>) = E.liftThrowable\n\n/**\n * Extracts the value of a `These` or throws if the `These` is `Left`.\n *\n * If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.\n *\n * @param self - The `These` to extract the value from.\n * @param onLeft - A function that will be called if the `These` is `Left`. It returns the error to be thrown.\n *\n * @example\n * import * as E from \"@fp-ts/core/These\"\n *\n * assert.deepStrictEqual(\n *   E.getOrThrowWith(E.right(1), () => new Error('Unexpected Left')),\n *   1\n * )\n * assert.deepStrictEqual(\n *   E.getOrThrowWith(E.both(\"warning\", 1), () => new Error('Unexpected Left')),\n *   1\n * )\n * assert.throws(() => E.getOrThrowWith(E.left(\"error\"), () => new Error('Unexpected Left')))\n *\n * @category interop\n * @since 1.0.0\n */\nexport const getOrThrowWith: {\n  <E>(onLeft: (e: E) => unknown): <A>(self: These<E, A>) => A\n  <E, A>(self: These<E, A>, onLeft: (e: E) => unknown): A\n} = dual(2, <E, A>(self: These<E, A>, onLeft: (e: E) => unknown): A => {\n  if (isRightOrBoth(self)) {\n    return self.right\n  }\n  throw onLeft(self.left)\n})\n\n/**\n * Extracts the value of a `These` or throws if the `These` is `Left`.\n *\n * The thrown error is a default error. To configure the error thrown, see {@link getOrThrowWith}.\n *\n * @param self - The `These` to extract the value from.\n * @throws `Error(\"getOrThrow called on a Left\")`\n *\n * @example\n * import * as T from \"@fp-ts/core/These\"\n *\n * assert.deepStrictEqual(T.getOrThrow(T.right(1)), 1)\n * assert.deepStrictEqual(T.getOrThrow(T.both(\"warning\", 1)), 1)\n * assert.throws(() => T.getOrThrow(T.left(\"error\")))\n *\n * @category interop\n * @since 1.0.0\n */\nexport const getOrThrow: <E, A>(self: These<E, A>) => A = getOrThrowWith(() =>\n  new Error(\"getOrThrow called on a Left\")\n)\n\n/**\n * Extracts the value of a `These` or throws if the `These` is `Left`.\n *\n * If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.\n *\n * @param self - The `These` to extract the value from.\n * @param onLeft - A function that will be called if the `These` is `Left`. It returns the error to be thrown.\n *\n * @example\n * import * as E from \"@fp-ts/core/These\"\n *\n * assert.deepStrictEqual(\n *   E.getRightOnlyOrThrowWith(\n *     E.right(1),\n *     () => new Error(\"Unexpected Left or Both\")\n *   ),\n *   1\n * )\n * assert.throws(() => E.getRightOnlyOrThrowWith(E.both(\"warning\", 1), () => new Error(\"Unexpected Left or Both\")))\n * assert.throws(() => E.getRightOnlyOrThrowWith(E.left(\"error\"), () => new Error(\"Unexpected Left or Both\")))\n *\n * @category interop\n * @since 1.0.0\n */\nexport const getRightOnlyOrThrowWith: {\n  <E>(onLeftOrBoth: (e: E) => unknown): <A>(self: These<E, A>) => A\n  <E, A>(self: These<E, A>, onLeftOrBoth: (e: E) => unknown): A\n} = dual(2, <E, A>(self: These<E, A>, onLeftOrBoth: (e: E) => unknown): A => {\n  if (isRight(self)) {\n    return self.right\n  }\n  throw onLeftOrBoth(self.left)\n})\n\n/**\n * Extracts the value of a `These` or throws if the `These` is not a `Right`.\n *\n * The thrown error is a default error. To configure the error thrown, see {@link getRightOnlyOrThrowWith}.\n *\n * @param self - The `These` to extract the value from.\n * @throws `Error(\"getOrThrow called on a Left\")`\n *\n * @example\n * import * as T from \"@fp-ts/core/These\"\n *\n * assert.deepStrictEqual(T.getRightOnlyOrThrow(T.right(1)), 1)\n * assert.throws(() => T.getRightOnlyOrThrow(T.both(\"error\", 1)))\n * assert.throws(() => T.getRightOnlyOrThrow(T.left(\"error\")))\n *\n * @category interop\n * @since 1.0.0\n */\nexport const getRightOnlyOrThrow: <E, A>(self: These<E, A>) => A = getRightOnlyOrThrowWith(() =>\n  new Error(\"getRightOnlyOrThrow called on a Left or a Both\")\n)\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromNullable: {\n  <E>(onNullable: LazyArg<E>): <A>(a: A) => These<E, NonNullable<A>>\n  <A, E>(a: A, onNullable: LazyArg<E>): These<E, NonNullable<A>>\n} = dual(\n  2,\n  <A, E>(a: A, onNullable: LazyArg<E>): These<E, NonNullable<A>> =>\n    a == null ? left(onNullable()) : right(a as NonNullable<A>)\n)\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromEither = <E, A>(self: Either<E, A>): Validated<E, A> =>\n  E.isLeft(self) ? left([self.left]) : self\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const toEither: {\n  <E, A>(onBoth: (e: E, a: A) => Either<E, A>): (self: These<E, A>) => Either<E, A>\n  <E, A>(self: These<E, A>, onBoth: (e: E, a: A) => Either<E, A>): Either<E, A>\n} = dual(\n  2,\n  <E, A>(self: These<E, A>, onBoth: (e: E, a: A) => Either<E, A>): Either<E, A> =>\n    isBoth(self) ? onBoth(self.left, self.right) : self\n)\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const absolve: <E, A>(self: These<E, A>) => Either<E, A> = toEither((\n  _,\n  a\n) => E.right(a))\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const condemn: <E, A>(self: These<E, A>) => Either<E, A> = toEither((\n  e,\n  _\n) => E.left(e))\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftNullable = <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => B | null | undefined,\n  onNullable: (...a: A) => E\n) => (...a: A): These<E, NonNullable<B>> => fromNullable(() => onNullable(...a))(f(...a))\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMapNullable: {\n  <A, B, E2>(\n    f: (a: A) => B | null | undefined,\n    onNullable: (a: A) => E2\n  ): <E1>(self: Validated<E1, A>) => Validated<E1 | E2, NonNullable<B>>\n  <E1, A, B, E2>(\n    self: Validated<E1, A>,\n    f: (a: A) => B | null | undefined,\n    onNullable: (a: A) => E2\n  ): Validated<E1 | E2, NonNullable<B>>\n} = dual(3, <E1, A, B, E2>(\n  self: Validated<E1, A>,\n  f: (a: A) => B | null | undefined,\n  onNullable: (a: A) => E2\n): Validated<E1 | E2, NonNullable<B>> => flatMap(self, liftNullable(f, (a) => [onNullable(a)])))\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftPredicate: {\n  <C extends A, B extends A, E, A = C>(\n    refinement: Refinement<A, B>,\n    onFalse: (c: C) => E\n  ): (c: C) => These<E, B>\n  <B extends A, E, A = B>(predicate: Predicate<A>, onFalse: (b: B) => E): (b: B) => These<E, B>\n} = <B extends A, E, A = B>(predicate: Predicate<A>, onFalse: (b: B) => E) =>\n  (b: B) => predicate(b) ? right(b) : left(onFalse(b))\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromIterable: {\n  <E>(onEmpty: LazyArg<E>): <A>(collection: Iterable<A>) => These<E, A>\n  <A, E>(collection: Iterable<A>, onEmpty: LazyArg<E>): These<E, A>\n} = dual(2, <A, E>(collection: Iterable<A>, onEmpty: LazyArg<E>): These<E, A> => {\n  for (const a of collection) {\n    return right(a)\n  }\n  return left(onEmpty())\n})\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromOption: {\n  <E>(onNone: LazyArg<E>): <A>(self: Option<A>) => These<E, A>\n  <A, E>(self: Option<A>, onNone: LazyArg<E>): These<E, A>\n} = dual(\n  2,\n  <A, E>(self: Option<A>, onNone: LazyArg<E>): These<E, A> =>\n    O.isNone(self) ? left(onNone()) : right(self.value)\n)\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const fromTuple = <E, A>(self: readonly [E, A]): These<E, A> => both(self[0], self[1])\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftOption = <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => Option<B>,\n  onNone: (...a: A) => E\n) => (...a: A): These<E, B> => fromOption(() => onNone(...a))(f(...a))\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftEither = <A extends ReadonlyArray<unknown>, E, B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A): Validated<E, B> => fromEither(f(...a))\n\n/**\n * @category lifting\n * @since 1.0.0\n */\nexport const liftThese = <A extends ReadonlyArray<unknown>, E, B>(\n  f: (...a: A) => These<E, B>\n) => (...a: A): Validated<E, B> => toValidated(f(...a))\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMapOption: {\n  <A, B, E2>(\n    f: (a: A) => Option<B>,\n    onNone: (a: A) => E2\n  ): <E1>(self: Validated<E1, A>) => Validated<E1 | E2, B>\n  <E1, A, B, E2>(\n    self: Validated<E1, A>,\n    f: (a: A) => Option<B>,\n    onNone: (a: A) => E2\n  ): Validated<E1 | E2, B>\n} = dual(3, <E1, A, B, E2>(\n  self: Validated<E1, A>,\n  f: (a: A) => Option<B>,\n  onNone: (a: A) => E2\n): Validated<E1 | E2, B> => flatMap(self, liftOption(f, (a) => [onNone(a)])))\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMapEither: {\n  <A, E2, B>(f: (a: A) => Either<E2, B>): <E1>(self: Validated<E1, A>) => Validated<E1 | E2, B>\n  <E1, A, E2, B>(self: Validated<E1, A>, f: (a: A) => Either<E2, B>): Validated<E1 | E2, B>\n} = dual(\n  2,\n  <E1, A, E2, B>(self: Validated<E1, A>, f: (a: A) => Either<E2, B>): Validated<E1 | E2, B> =>\n    flatMap(self, liftEither(f))\n)\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMapThese: {\n  <A, E2, B>(f: (a: A) => These<E2, B>): <E1>(self: Validated<E1, A>) => Validated<E1 | E2, B>\n  <E1, A, E2, B>(self: Validated<E1, A>, f: (a: A) => These<E2, B>): Validated<E1 | E2, B>\n} = dual(\n  2,\n  <E1, A, E2, B>(self: Validated<E1, A>, f: (a: A) => These<E2, B>): Validated<E1 | E2, B> =>\n    flatMap(self, liftThese(f))\n)\n\n/**\n * Converts a `These` to an `Option` discarding the error (`Both` included).\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getRight = <E, A>(\n  self: These<E, A>\n): Option<A> => isLeft(self) ? O.none() : O.some(self.right)\n\n/**\n * Returns the value if and only if the value is a `Right` (i.e. `Both` is excluded).\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getRightOnly = <E, A>(\n  self: These<E, A>\n): Option<A> => isRight(self) ? O.some(self.right) : O.none()\n\n/**\n * Converts a `These` to an `Option` discarding the value (`Both` included).\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getLeft = <E, A>(\n  self: These<E, A>\n): Option<E> => isRight(self) ? O.none() : O.some(self.left)\n\n/**\n * Returns the error if and only if the value is a `Left` (i.e. `Both` is excluded).\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getLeftOnly = <E, A>(\n  self: These<E, A>\n): Option<E> => isLeft(self) ? O.some(self.left) : O.none()\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const getBoth = <E, A>(\n  self: These<E, A>\n): Option<readonly [E, A]> => isBoth(self) ? O.some([self.left, self.right]) : O.none()\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const getBothOrElse: {\n  <E, A>(e: LazyArg<E>, a: LazyArg<A>): (self: These<E, A>) => [E, A]\n  <E, A>(self: These<E, A>, e: LazyArg<E>, a: LazyArg<A>): [E, A]\n} = dual(3, <E, A>(self: These<E, A>, e: LazyArg<E>, a: LazyArg<A>): [E, A] =>\n  isLeft(self) ?\n    [self.left, a()] :\n    isRight(self) ?\n    [e(), self.right] :\n    [self.left, self.right])\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const getOrElse: {\n  <B>(onLeft: LazyArg<B>): <E, A>(self: These<E, A>) => A | B\n  <E, A, B>(self: These<E, A>, onLeft: LazyArg<B>): A | B\n} = dual(\n  2,\n  <E, A, B>(self: These<E, A>, onLeft: LazyArg<B>): A | B => isLeft(self) ? onLeft() : self.right\n)\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const getOrNull: <E, A>(self: These<E, A>) => A | null = getOrElse(constNull)\n\n/**\n * @category getters\n * @since 1.0.0\n */\nexport const getOrUndefined: <E, A>(self: These<E, A>) => A | undefined = getOrElse(constUndefined)\n\n/**\n * @category debugging\n * @since 1.0.0\n */\nexport const inspectRight: {\n  <A>(onRight: (a: A) => void): <E>(self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, onRight: (a: A) => void): These<E, A>\n} = dual(2, <E, A>(self: These<E, A>, onRight: (a: A) => void): These<E, A> => {\n  if (isRight(self)) {\n    onRight(self.right)\n  }\n  return self\n})\n\n/**\n * @category debugging\n * @since 1.0.0\n */\nexport const inspectRightOrBoth: {\n  <A>(onRightOrBoth: (a: A) => void): <E>(self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, onRightOrBoth: (a: A) => void): These<E, A>\n} = dual(2, <E, A>(self: These<E, A>, onRightOrBoth: (a: A) => void): These<E, A> => {\n  if (isRightOrBoth(self)) {\n    onRightOrBoth(self.right)\n  }\n  return self\n})\n\n/**\n * @category debugging\n * @since 1.0.0\n */\nexport const inspectLeft: {\n  <E>(onLeft: (e: E) => void): <A>(self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, onLeft: (e: E) => void): These<E, A>\n} = dual(2, <E, A>(self: These<E, A>, onLeft: (e: E) => void): These<E, A> => {\n  if (isLeft(self)) {\n    onLeft(self.left)\n  }\n  return self\n})\n\n/**\n * @category debugging\n * @since 1.0.0\n */\nexport const inspectBoth: {\n  <E, A>(onBoth: (e: E, a: A) => void): (self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, onBoth: (e: E, a: A) => void): These<E, A>\n} = dual(2, <E, A>(self: These<E, A>, onBoth: (e: E, a: A) => void): These<E, A> => {\n  if (isBoth(self)) {\n    onBoth(self.left, self.right)\n  }\n  return self\n})\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const bimap: {\n  <E1, E2, A, B>(f: (e: E1) => E2, g: (a: A) => B): (self: These<E1, A>) => These<E2, B>\n  <E1, A, E2, B>(self: These<E1, A>, f: (e: E1) => E2, g: (a: A) => B): These<E2, B>\n} = dual(\n  3,\n  <E1, A, E2, B>(self: These<E1, A>, f: (e: E1) => E2, g: (a: A) => B): These<E2, B> =>\n    isLeft(self) ?\n      left(f(self.left)) :\n      isRight(self) ?\n      right(g(self.right)) :\n      both(f(self.left), g(self.right))\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Bicovariant: bicovariant.Bicovariant<TheseTypeLambda> = {\n  bimap\n}\n\n/**\n * Maps the `Left` side of an `These` value to a new `These` value.\n *\n * @param self - The input `These` value to map.\n * @param f - A transformation function to apply to the `Left` value of the input `These`.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const mapLeft: {\n  <E, G>(f: (e: E) => G): <A>(self: These<E, A>) => These<G, A>\n  <E, A, G>(self: These<E, A>, f: (e: E) => G): These<G, A>\n} = bicovariant.mapLeft(Bicovariant)\n\n/**\n * @category conversions\n * @since 1.0.0\n */\nexport const toValidated: <E, A>(self: These<E, A>) => Validated<E, A> = mapLeft((e) => [e])\n\n/**\n * Maps the `Right` side of an `These` value to a new `These` value.\n *\n * @param self - An `These` to map\n * @param f - The function to map over the value of the `These`\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const map: {\n  <E, A, B>(self: These<E, A>, f: (a: A) => B): These<E, B>\n  <A, B>(f: (a: A) => B): <E>(self: These<E, A>) => These<E, B>\n} = bicovariant.map(Bicovariant)\n\nconst imap = covariant.imap<TheseTypeLambda>(map)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Covariant: covariant.Covariant<TheseTypeLambda> = {\n  imap,\n  map\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<TheseTypeLambda> = {\n  imap\n}\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const tupled: <E, A>(self: These<E, A>) => These<E, [A]> = invariant.tupled(\n  Invariant\n)\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const flap: {\n  <A, E, B>(a: A, self: These<E, (a: A) => B>): These<E, B>\n  <E, A, B>(self: These<E, (a: A) => B>): (a: A) => These<E, B>\n} = covariant.flap(Covariant)\n\n/**\n * Maps the right value of this effect to the specified constant value.\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const as: {\n  <E, _, B>(self: These<E, _>, b: B): These<E, B>\n  <B>(b: B): <E, _>(self: These<E, _>) => These<E, B>\n} = covariant.as(Covariant)\n\n/**\n * Returns the effect resulting from mapping the right of this effect to unit.\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const asUnit: <E, _>(self: These<E, _>) => These<E, void> = covariant.asUnit(Covariant)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Of: of_.Of<TheseTypeLambda> = {\n  of\n}\n\n/**\n * @since 1.0.0\n */\nexport const unit: These<never, void> = of_.unit(Of)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Pointed: pointed.Pointed<TheseTypeLambda> = {\n  of,\n  imap,\n  map\n}\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const traverse = <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n): {\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): <TE>(self: These<TE, A>) => Kind<F, R, O, E, These<TE, B>>\n  <TE, A, R, O, E, B>(\n    self: These<TE, A>,\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, These<TE, B>>\n} =>\n  dual(2, <TE, A, R, O, E, B>(\n    self: These<TE, A>,\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, These<TE, B>> =>\n    isLeft(self)\n      ? F.of<These<TE, B>>(self)\n      : isRight(self)\n      ? F.map<R, O, E, B, These<TE, B>>(f(self.right), right)\n      : F.map(f(self.right), (b) => both(self.left, b)))\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Traversable: traversable.Traversable<TheseTypeLambda> = {\n  traverse\n}\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const sequence: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => <TE, R, O, E, A>(\n  self: These<TE, Kind<F, R, O, E, A>>\n) => Kind<F, R, O, E, These<TE, A>> = traversable.sequence(Traversable)\n\n/**\n * @category traversing\n * @since 1.0.0\n */\nexport const traverseTap: <F extends TypeLambda>(\n  F: applicative.Applicative<F>\n) => {\n  <TE, A, R, O, E, B>(\n    self: These<TE, A>,\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): Kind<F, R, O, E, These<TE, A>>\n  <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, B>\n  ): <TE>(self: These<TE, A>) => Kind<F, R, O, E, These<TE, A>>\n} = traversable.traverseTap(Traversable)\n\n/**\n * Returns a function that checks if a `These` contains a given value using a provided `equivalence` function.\n *\n * @since 1.0.0\n */\nexport const contains = <A>(isEquivalent: (self: A, that: A) => boolean): {\n  (a: A): <E>(self: These<E, A>) => boolean\n  <E>(self: These<E, A>, a: A): boolean\n} =>\n  dual(\n    2,\n    <E>(self: These<E, A>, a: A): boolean => isLeft(self) ? false : isEquivalent(self.right, a)\n  )\n\n/**\n * @category predicates\n * @since 1.0.0\n */\nexport const exists: {\n  <A>(predicate: Predicate<A>): <E>(self: These<E, A>) => boolean\n  <E, A>(self: These<E, A>, predicate: Predicate<A>): boolean\n} = dual(\n  2,\n  <E, A>(self: These<E, A>, predicate: Predicate<A>): boolean =>\n    isLeft(self) ? false : predicate(self.right)\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Foldable: foldable.Foldable<TheseTypeLambda> = {\n  reduce: dual(\n    3,\n    <E, A, B>(self: These<E, A>, b: B, f: (b: B, a: A) => B): B =>\n      isLeft(self) ? b : f(b, self.right)\n  )\n}\n\n/**\n * Executes this effect and returns its value, if it succeeds, but otherwise\n * executes the specified effect.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const orElse: {\n  <E1, E2, B>(that: (e1: E1) => These<E2, B>): <A>(self: These<E1, A>) => These<E1 | E2, A | B>\n  <E1, A, E2, B>(self: These<E1, A>, that: (e1: E1) => These<E2, B>): These<E1 | E2, A | B>\n} = dual(\n  2,\n  <E1, A, E2, B>(self: These<E1, A>, that: (e1: E1) => These<E2, B>): These<E1 | E2, A | B> =>\n    isLeft(self) ? that(self.left) : self\n)\n\n/**\n * Returns an effect that will produce the value of this effect, unless it\n * fails, in which case, it will produce the value of the specified effect.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const orElseEither: {\n  <E1, E2, B>(\n    that: (e1: E1) => These<E2, B>\n  ): <A>(self: These<E1, A>) => These<E1 | E2, Either<A, B>>\n  <E1, A, E2, B>(\n    self: These<E1, A>,\n    that: (e1: E1) => These<E2, B>\n  ): These<E1 | E2, Either<A, B>>\n} = dual(2, <E1, A, E2, B>(\n  self: These<E1, A>,\n  that: (e1: E1) => These<E2, B>\n): These<E1 | E2, Either<A, B>> =>\n  isLeft(self) ?\n    map(that(self.left), E.right) :\n    map(self, E.left))\n\n/**\n * Executes this effect and returns its value, if it succeeds, but otherwise\n * fails with the specified error.\n *\n * @category error handling\n * @since 1.0.0\n */\nexport const orElseFail: {\n  <E2>(onLeft: LazyArg<E2>): <E1, A>(self: These<E1, A>) => These<E1 | E2, A>\n  <E1, A, E2>(self: These<E1, A>, onLeft: LazyArg<E2>): These<E1 | E2, A>\n} = dual(\n  2,\n  <E1, A, E2>(self: These<E1, A>, onLeft: LazyArg<E2>): These<E1 | E2, A> =>\n    orElse(self, () => left(onLeft()))\n)\n\nconst coproduct = <E1, A, E2, B>(self: These<E1, A>, that: These<E2, B>): These<E1 | E2, A | B> =>\n  isRightOrBoth(self) ? self : that\n\nconst coproductMany = <E, A>(self: These<E, A>, collection: Iterable<These<E, A>>): These<E, A> => {\n  let out = self\n  if (isRightOrBoth(out)) {\n    return out\n  }\n  for (out of collection) {\n    if (isRightOrBoth(out)) {\n      return out\n    }\n  }\n  return out\n}\n\n/**\n * @category error handling\n * @since 1.0.0\n */\nexport const firstRightOrBothOf: {\n  <E, A>(collection: Iterable<These<E, A>>): (self: These<E, A>) => These<E, A>\n  <E, A>(self: These<E, A>, collection: Iterable<These<E, A>>): These<E, A>\n} = dual(2, coproductMany)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiCoproduct: semiCoproduct.SemiCoproduct<TheseTypeLambda> = {\n  imap,\n  coproduct,\n  coproductMany\n}\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const getFirstRightOrBothSemigroup: <E, A>() => Semigroup<These<E, A>> = semiCoproduct\n  .getSemigroup(SemiCoproduct)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiAlternative: semiAlternative.SemiAlternative<TheseTypeLambda> = {\n  map,\n  imap,\n  coproduct,\n  coproductMany: firstRightOrBothOf\n}\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const filter: {\n  <C extends A, B extends A, E2, A = C>(refinement: Refinement<A, B>, onFalse: LazyArg<E2>): <E1>(\n    self: These<E1, C>\n  ) => These<E1 | E2, B>\n  <B extends A, E2, A = B>(\n    predicate: Predicate<A>,\n    onFalse: LazyArg<E2>\n  ): <E1>(self: These<E1, B>) => These<E1 | E2, B>\n  <E1, C extends A, B extends A, E2, A = C>(\n    self: These<E1, C>,\n    refinement: Refinement<A, B>,\n    onFalse: LazyArg<E2>\n  ): These<E1 | E2, B>\n  <E1, B extends A, E2, A = B>(\n    self: These<E1, B>,\n    predicate: Predicate<A>,\n    onFalse: LazyArg<E2>\n  ): These<E1 | E2, B>\n} = dual(3, <E1, B extends A, E2, A = B>(\n  self: These<E1, B>,\n  predicate: Predicate<A>,\n  onFalse: LazyArg<E2>\n): These<E1 | E2, B> => isLeft(self) ? self : predicate(self.right) ? self : left(onFalse()))\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const filterMap: {\n  <A, B, E2>(\n    f: (a: A) => Option<B>,\n    onNone: LazyArg<E2>\n  ): <E1>(self: These<E1, A>) => These<E1 | E2, B>\n  <E1, A, B, E2>(\n    self: These<E1, A>,\n    f: (a: A) => Option<B>,\n    onNone: LazyArg<E2>\n  ): These<E1 | E2, B>\n} = dual(3, <E1, A, B, E2>(\n  self: These<E1, A>,\n  f: (a: A) => Option<B>,\n  onNone: LazyArg<E2>\n): These<E1 | E2, B> => {\n  if (isLeft(self)) {\n    return self\n  }\n  if (isRight(self)) {\n    const ob = f(self.right)\n    return O.isNone(ob) ? left(onNone()) : right(ob.value)\n  }\n  const ob = f(self.right)\n  return O.isNone(ob) ? left(onNone()) : both(self.left, ob.value)\n})\n\n/**\n * @category filtering\n * @since 1.0.0\n */\nexport const compact: {\n  <E>(onNone: LazyArg<E>): <A>(self: These<E, Option<A>>) => These<E, A>\n  <E, A>(self: These<E, Option<A>>, onNone: LazyArg<E>): These<E, A>\n} = dual(\n  2,\n  <E, A>(self: These<E, Option<A>>, onNone: LazyArg<E>): These<E, A> =>\n    filterMap(self, identity, onNone)\n)\n\nconst product = <E1, A, E2, B>(\n  self: Validated<E1, A>,\n  that: Validated<E2, B>\n): Validated<E1 | E2, [A, B]> => {\n  if (isLeft(self)) {\n    return self\n  }\n  if (isRight(self)) {\n    if (isLeft(that)) {\n      return that\n    }\n    if (isRight(that)) {\n      return right([self.right, that.right])\n    }\n    return both(that.left, [self.right, that.right])\n  }\n  if (isLeft(that)) {\n    return left(RA.appendAllNonEmpty(self.left, that.left))\n  }\n  if (isRight(that)) {\n    return both(self.left, [self.right, that.right])\n  }\n  return both(RA.appendAllNonEmpty(self.left, that.left), [self.right, that.right])\n}\n\n/**\n * Similar to `Promise.all` but operates on `These`s.\n *\n * ```\n * Iterable<These<E, A>> -> These<E, A[]>\n * ```\n *\n * @category combining\n * @since 1.0.0\n */\nconst all = <E, A>(\n  collection: Iterable<Validated<E, A>>\n): Validated<E, Array<A>> => {\n  const rights: Array<A> = []\n  const lefts: Array<E> = []\n  let isFatal = false\n  for (const t of collection) {\n    if (isLeft(t)) {\n      lefts.push(...t.left)\n      isFatal = true\n      break\n    } else if (isRight(t)) {\n      rights.push(t.right)\n    } else {\n      lefts.push(...t.left)\n      rights.push(t.right)\n    }\n  }\n  if (RA.isNonEmpty(lefts)) {\n    return isFatal ? left(lefts) : both(lefts, rights)\n  }\n  return right(rights)\n}\n\nconst productMany = <E, A>(\n  self: Validated<E, A>,\n  collection: Iterable<Validated<E, A>>\n): Validated<E, [A, ...Array<A>]> => map(product(self, all(collection)), ([a, as]) => [a, ...as])\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiProduct: semiProduct.SemiProduct<ValidatedTypeLambda> = {\n  imap,\n  product,\n  productMany\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiApplicative: semiApplicative.SemiApplicative<ValidatedTypeLambda> = {\n  imap,\n  map,\n  product,\n  productMany\n}\n\n/**\n * Lifts a binary function into `These`.\n *\n * @param f - The function to lift.\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const lift2: <A, B, C>(f: (a: A, b: B) => C) => {\n  <E1, E2>(self: Validated<E1, A>, that: Validated<E2, B>): Validated<E1 | E2, C>\n  <E2>(that: Validated<E2, B>): <E1>(self: Validated<E1, A>) => Validated<E2 | E1, C>\n} = semiApplicative.lift2(SemiApplicative)\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const zipWith: {\n  <E1, A, E2, B, C>(\n    self: Validated<E1, A>,\n    that: Validated<E2, B>,\n    f: (a: A, b: B) => C\n  ): Validated<E1 | E2, C>\n  <E2, B, A, C>(\n    that: Validated<E2, B>,\n    f: (a: A, b: B) => C\n  ): <E1>(self: Validated<E1, A>) => Validated<E2 | E1, C>\n} = semiApplicative.zipWith(SemiApplicative)\n\n/**\n * @since 1.0.0\n */\nexport const ap: {\n  <E1, A, B, E2>(self: Validated<E1, (a: A) => B>, that: Validated<E2, A>): Validated<E1 | E2, B>\n  <E2, A>(\n    that: Validated<E2, A>\n  ): <E1, B>(self: Validated<E1, (a: A) => B>) => Validated<E2 | E1, B>\n} = semiApplicative.ap(SemiApplicative)\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const getFirstLeftSemigroup: <A, E>(S: Semigroup<A>) => Semigroup<Validated<E, A>> =\n  semiApplicative.getSemigroup(SemiApplicative)\n\n/**\n * Appends an element to the end of a tuple.\n *\n * @since 1.0.0\n */\nexport const appendElement: {\n  <E1, A extends ReadonlyArray<any>, E2, B>(\n    self: Validated<E1, A>,\n    that: Validated<E2, B>\n  ): Validated<E1 | E2, [...A, B]>\n  <E2, B>(\n    that: Validated<E2, B>\n  ): <E1, A extends ReadonlyArray<any>>(self: Validated<E1, A>) => Validated<E2 | E1, [...A, B]>\n} = semiProduct.appendElement(SemiProduct)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Product: product_.Product<ValidatedTypeLambda> = {\n  of,\n  imap,\n  product,\n  productMany,\n  productAll: all\n}\n\n/**\n * Similar to `Promise.all` but operates on `These`s.\n *\n * ```\n * [These<E1, A>, These<E1, B>, ...] -> These<E1 \\| E2 \\| ..., [A, B, ...]>\n * ```\n *\n * @since 1.0.0\n */\nexport const tuple: <T extends ReadonlyArray<Validated<any, any>>>(...tuple: T) => Validated<\n  [T[number]] extends [Validated<infer E, any>] ? E : never,\n  { [I in keyof T]: [T[I]] extends [Validated<any, infer A>] ? A : never }\n> = product_.tuple(Product)\n\n/**\n * @since 1.0.0\n */\nexport const struct: <R extends Record<string, Validated<any, any>>>(\n  r: R\n) => Validated<\n  [R[keyof R]] extends [Validated<infer E, any>] ? E : never,\n  { [K in keyof R]: [R[K]] extends [Validated<any, infer A>] ? A : never }\n> = product_\n  .struct(Product)\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const flatMap: {\n  <A, E2, B>(f: (a: A) => Validated<E2, B>): <E1>(self: Validated<E1, A>) => Validated<E1 | E2, B>\n  <E1, A, E2, B>(self: Validated<E1, A>, f: (a: A) => Validated<E2, B>): Validated<E1 | E2, B>\n} = dual(\n  2,\n  <E1, A, E2, B>(self: Validated<E1, A>, f: (a: A) => Validated<E2, B>): Validated<E1 | E2, B> => {\n    if (isLeft(self)) {\n      return self\n    }\n    if (isRight(self)) {\n      return f(self.right)\n    }\n    const that = f(self.right)\n    if (isLeft(that)) {\n      return left(RA.appendAllNonEmpty(that.left)(self.left))\n    }\n    if (isRight(that)) {\n      return both(self.left, that.right)\n    }\n    return both(RA.appendAllNonEmpty(that.left)(self.left), that.right)\n  }\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Applicative: applicative.Applicative<ValidatedTypeLambda> = {\n  imap,\n  of,\n  map,\n  product,\n  productMany,\n  productAll: all\n}\n\n/**\n * @category combining\n * @since 1.0.0\n */\nexport const getFirstLeftMonoid: <A, E>(M: Monoid<A>) => Monoid<Validated<E, A>> = applicative\n  .getMonoid(\n    Applicative\n  )\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const FlatMap: flatMap_.FlatMap<ValidatedTypeLambda> = {\n  flatMap\n}\n\n/**\n * @since 1.0.0\n */\nexport const flatten: <E2, E1, A>(\n  self: Validated<E2, Validated<E1, A>>\n) => Validated<E2 | E1, A> = flatMap_.flatten(FlatMap)\n\n/**\n * @since 1.0.0\n */\nexport const andThen: {\n  <E1, _, E2, B>(self: Validated<E1, _>, that: Validated<E2, B>): Validated<E1 | E2, B>\n  <E2, B>(that: Validated<E2, B>): <E1, _>(self: Validated<E1, _>) => Validated<E2 | E1, B>\n} = flatMap_.andThen(FlatMap)\n\n/**\n * @since 1.0.0\n */\nexport const composeKleisliArrow: {\n  <A, E1, B, E2, C>(\n    afb: (a: A) => Validated<E1, B>,\n    bfc: (b: B) => Validated<E2, C>\n  ): (a: A) => Validated<E1 | E2, C>\n  <B, E2, C>(\n    bfc: (b: B) => Validated<E2, C>\n  ): <A, E1>(afb: (a: A) => Validated<E1, B>) => (a: A) => Validated<E2 | E1, C>\n} = flatMap_.composeKleisliArrow(FlatMap)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Chainable: chainable.Chainable<ValidatedTypeLambda> = {\n  imap,\n  map,\n  flatMap\n}\n\n/**\n * Sequences the specified effect after this effect, but ignores the value\n * produced by the effect.\n *\n * @category combining\n * @since 1.0.0\n */\nexport const andThenDiscard: {\n  <E1, A, E2, _>(self: Validated<E1, A>, that: Validated<E2, _>): Validated<E1 | E2, A>\n  <E2, _>(that: Validated<E2, _>): <E1, A>(self: Validated<E1, A>) => Validated<E2 | E1, A>\n} = chainable.andThenDiscard(Chainable)\n\n/**\n * Returns an effect that effectfully \"peeks\" at the success of this effect.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const tap: {\n  <E1, A, E2, _>(self: Validated<E1, A>, f: (a: A) => Validated<E2, _>): Validated<E1 | E2, A>\n  <A, E2, _>(f: (a: A) => Validated<E2, _>): <E1>(self: Validated<E1, A>) => Validated<E2 | E1, A>\n} = chainable.tap(Chainable)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Monad: monad.Monad<ValidatedTypeLambda> = {\n  imap,\n  of,\n  map,\n  flatMap\n}\n\n// -------------------------------------------------------------------------------------\n// math\n// -------------------------------------------------------------------------------------\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const sum: {\n  <E1, E2>(self: Validated<E1, number>, that: Validated<E2, number>): Validated<E1 | E2, number>\n  <E2>(that: Validated<E2, number>): <E1>(self: Validated<E1, number>) => Validated<E2 | E1, number>\n} = lift2(N.sum)\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const multiply: {\n  <E1, E2>(self: Validated<E1, number>, that: Validated<E2, number>): Validated<E1 | E2, number>\n  <E2>(that: Validated<E2, number>): <E1>(self: Validated<E1, number>) => Validated<E2 | E1, number>\n} = lift2(N.multiply)\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const subtract: {\n  <E1, E2>(self: Validated<E1, number>, that: Validated<E2, number>): Validated<E1 | E2, number>\n  <E2>(that: Validated<E2, number>): <E1>(self: Validated<E1, number>) => Validated<E2 | E1, number>\n} = lift2(N.subtract)\n\n/**\n * @category math\n * @since 1.0.0\n */\nexport const divide: {\n  <E1, E2>(self: Validated<E1, number>, that: Validated<E2, number>): Validated<E1 | E2, number>\n  <E2>(that: Validated<E2, number>): <E1>(self: Validated<E1, number>) => Validated<E2 | E1, number>\n} = lift2(N.divide)\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bindTo: {\n  <N extends string>(name: N): <E, A>(self: These<E, A>) => These<E, { [K in N]: A }>\n  <E, A, N extends string>(self: These<E, A>, name: N): These<E, { [K in N]: A }>\n} = invariant.bindTo(Invariant)\n\nconst let_: {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): <E>(self: These<E, A>) => These<E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E, A extends object, N extends string, B>(\n    self: These<E, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): These<E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = covariant.let(Covariant)\n\nexport {\n  /**\n   * @category do notation\n   * @since 1.0.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const Do: These<never, {}> = of_.Do(Of)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bind: {\n  <N extends string, A extends object, E2, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Validated<E2, B>\n  ): <E1>(\n    self: Validated<E1, A>\n  ) => Validated<E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: Validated<E1, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Validated<E2, B>\n  ): Validated<E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = chainable.bind(Chainable)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bindEither: {\n  <N extends string, A extends object, E2, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Either<E2, B>\n  ): <E1>(\n    self: Validated<E1, A>\n  ) => Validated<E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: Validated<E1, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Either<E2, B>\n  ): Validated<E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n} = dual(3, <E1, A extends object, N extends string, E2, B>(\n  self: Validated<E1, A>,\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Either<E2, B>\n): Validated<E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }> =>\n  bind(self, name, (a) => fromEither(f(a))))\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bindThese: {\n  <N extends string, A extends object, E2, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => These<E2, B>\n  ): <E1>(\n    self: Validated<E1, A>\n  ) => Validated<E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: Validated<E1, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => These<E2, B>\n  ): Validated<E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n} = dual(3, <E1, A extends object, N extends string, E2, B>(\n  self: Validated<E1, A>,\n  name: Exclude<N, keyof A>,\n  f: (a: A) => These<E2, B>\n): Validated<E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }> =>\n  bind(self, name, (a) => toValidated(f(a))))\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const andThenBind: {\n  <N extends string, A extends object, E2, B>(\n    name: Exclude<N, keyof A>,\n    that: Validated<E2, B>\n  ): <E1>(\n    self: Validated<E1, A>\n  ) => Validated<E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n  <E1, A extends object, N extends string, E2, B>(\n    self: Validated<E1, A>,\n    name: Exclude<N, keyof A>,\n    that: Validated<E2, B>\n  ): Validated<E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n} = semiProduct.andThenBind(SemiProduct)\n"
  },
  {
    "path": "src/Tuple.ts",
    "content": "/**\n * This module provides utility functions for working with tuples in TypeScript.\n *\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as bicovariant from \"@fp-ts/core/typeclass/Bicovariant\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface TupleTypeLambda extends TypeLambda {\n  readonly type: [this[\"Out1\"], this[\"Target\"]]\n}\n\n/**\n * Constructs a new tuple from the provided values.\n *\n * @param elements - The list of elements to create the tuple from.\n *\n * @example\n * import { tuple } from \"@fp-ts/core/Tuple\"\n *\n * assert.deepStrictEqual(tuple(1, 'hello', true), [1, 'hello', true])\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const tuple = <A extends ReadonlyArray<any>>(...elements: A): A => elements\n\n/**\n * Return the first element of a tuple.\n *\n * @param self - A tuple of length `2`.\n *\n * @example\n * import { getFirst } from \"@fp-ts/core/Tuple\"\n *\n * assert.deepStrictEqual(getFirst([\"hello\", 42]), \"hello\")\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getFirst = <L, R>(self: readonly [L, R]): L => self[0]\n\n/**\n * Return the second element of a tuple.\n *\n * @param self - A tuple of length `2`.\n *\n * @example\n * import { getSecond } from \"@fp-ts/core/Tuple\"\n *\n * assert.deepStrictEqual(getSecond([\"hello\", 42]), 42)\n *\n * @category getters\n * @since 1.0.0\n */\nexport const getSecond = <L, R>(self: readonly [L, R]): R => self[1]\n\n/**\n * Transforms both elements of a tuple using the given functions.\n *\n * @param self - A tuple of length `2`.\n * @param f - The function to transform the first element of the tuple.\n * @param g - The function to transform the second element of the tuple.\n *\n * @example\n * import { bimap } from \"@fp-ts/core/Tuple\"\n *\n * assert.deepStrictEqual(\n *   bimap([\"hello\", 42], s => s.toUpperCase(), n => n.toString()),\n *   [\"HELLO\", \"42\"]\n * )\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const bimap: {\n  <L1, L2, R1, R2>(f: (e: L1) => L2, g: (a: R1) => R2): (self: readonly [L1, R1]) => [L2, R2]\n  <L1, R1, L2, R2>(self: readonly [L1, R1], f: (e: L1) => L2, g: (a: R1) => R2): [L2, R2]\n} = dual(\n  3,\n  <L1, R1, L2, R2>(\n    self: readonly [L1, R1],\n    f: (e: L1) => L2,\n    g: (a: R1) => R2\n  ): [L2, R2] => [f(self[0]), g(self[1])]\n)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Bicovariant: bicovariant.Bicovariant<TupleTypeLambda> = {\n  bimap\n}\n\n/**\n * Transforms the first component of a tuple using a given function.\n *\n * @param self - A tuple of length `2`.\n * @param f - The function to transform the first element of the tuple.\n *\n * @example\n * import { mapFirst } from \"@fp-ts/core/Tuple\"\n *\n * assert.deepStrictEqual(\n *   mapFirst([\"hello\", 42], s => s.toUpperCase()),\n *   [\"HELLO\", 42]\n * )\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const mapFirst: {\n  <L1, L2>(f: (left: L1) => L2): <R>(self: readonly [L1, R]) => [L2, R]\n  <L1, R, L2>(self: readonly [L1, R], f: (left: L1) => L2): [L2, R]\n} = bicovariant.mapLeft(Bicovariant) as any\n\n/**\n * Transforms the second component of a tuple using a given function.\n *\n * @param self - A tuple of length `2`.\n * @param f - The function to transform the second element of the tuple.\n *\n * @example\n * import { mapSecond } from \"@fp-ts/core/Tuple\"\n *\n * assert.deepStrictEqual(\n *   mapSecond([\"hello\", 42], n => n.toString()),\n *   [\"hello\", \"42\"]\n * )\n *\n * @category mapping\n * @since 1.0.0\n */\nexport const mapSecond: {\n  <R1, R2>(f: (right: R1) => R2): <L>(self: readonly [L, R1]) => [L, R2]\n  <L, R1, R2>(self: readonly [L, R1], f: (right: R1) => R2): [L, R2]\n} = bicovariant.map(Bicovariant) as any\n\n/**\n * Swaps the two elements of a tuple.\n *\n * @param self - A tuple of length `2`.\n *\n * @example\n * import { swap } from \"@fp-ts/core/Tuple\"\n *\n * assert.deepStrictEqual(swap([\"hello\", 42]), [42, \"hello\"])\n *\n * @since 1.0.0\n */\nexport const swap = <L, R>(self: readonly [L, R]): [R, L] => [self[1], self[0]]\n\n/**\n * Given a tuple of `Equivalence`s returns a new `Equivalence` that compares values of a tuple\n * by applying each `Equivalence` to the corresponding element of the tuple.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const getEquivalence: <T extends ReadonlyArray<equivalence.Equivalence<any>>>(\n  ...predicates: T\n) => equivalence.Equivalence<\n  Readonly<{ [I in keyof T]: [T[I]] extends [equivalence.Equivalence<infer A>] ? A : never }>\n> = equivalence.tuple\n\n/**\n * This function creates and returns a new `Order` for a tuple of values based on the given `Order`s for each element in the tuple.\n * The returned `Order` compares two tuples of the same type by applying the corresponding `Order` to each element in the tuple.\n * It is useful when you need to compare two tuples of the same type and you have a specific way of comparing each element\n * of the tuple.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const getOrder: <T extends ReadonlyArray<order.Order<any>>>(\n  ...elements: T\n) => order.Order<{ [I in keyof T]: [T[I]] extends [order.Order<infer A>] ? A : never }> =\n  order.tuple\n\n/**\n * This function creates and returns a new `Semigroup` for a tuple of values based on the given `Semigroup`s for each element in the tuple.\n * The returned `Semigroup` combines two tuples of the same type by applying the corresponding `Semigroup` passed as arguments to each element in the tuple.\n *\n * It is useful when you need to combine two tuples of the same type and you have a specific way of combining each element of the tuple.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const getSemigroup = semigroup.tuple\n\n/**\n * This function creates and returns a new `Monoid` for a tuple of values based on the given `Monoid`s for each element in the tuple.\n * The returned `Monoid` combines two tuples of the same type by applying the corresponding `Monoid` passed as arguments to each element in the tuple.\n *\n * The `empty` value of the returned `Monoid` is the tuple of `empty` values of the input `Monoid`s.\n *\n * It is useful when you need to combine two tuples of the same type and you have a specific way of combining each element of the tuple.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const getMonoid = monoid.tuple\n\n/**\n * Appends an element to the end of a tuple.\n *\n * @since 1.0.0\n */\nexport const appendElement: {\n  <B>(that: B): <A extends ReadonlyArray<unknown>>(self: A) => [...A, B]\n  <A extends ReadonlyArray<unknown>, B>(self: A, that: B): [...A, B]\n} = dual(2, <A extends ReadonlyArray<unknown>, B>(self: A, that: B): [...A, B] => [...self, that])\n\n/*\n\n  TODO:\n\n  - at\n  - swap\n\n*/\n"
  },
  {
    "path": "src/index.ts",
    "content": "/**\n * @since 1.0.0\n */\n\n// -------------------------------------------------------------------------------------\n// HKT\n// -------------------------------------------------------------------------------------\n\nimport * as hkt from \"@fp-ts/core/HKT\"\n\n// -------------------------------------------------------------------------------------\n// data types\n// -------------------------------------------------------------------------------------\n\nimport * as bigint from \"@fp-ts/core/Bigint\"\nimport * as boolean from \"@fp-ts/core/Boolean\"\nimport * as either from \"@fp-ts/core/Either\"\nimport * as _function from \"@fp-ts/core/Function\"\nimport * as identity from \"@fp-ts/core/Identity\"\nimport * as number from \"@fp-ts/core/Number\"\nimport * as option from \"@fp-ts/core/Option\"\nimport * as ordering from \"@fp-ts/core/Ordering\"\nimport * as predicate from \"@fp-ts/core/Predicate\"\nimport * as readonlyArray from \"@fp-ts/core/ReadonlyArray\"\nimport * as readonlyRecord from \"@fp-ts/core/ReadonlyRecord\"\nimport * as string from \"@fp-ts/core/String\"\nimport * as struct from \"@fp-ts/core/Struct\"\nimport * as symbol from \"@fp-ts/core/Symbol\"\nimport * as these from \"@fp-ts/core/These\"\nimport * as tuple from \"@fp-ts/core/Tuple\"\n\n// -------------------------------------------------------------------------------------\n// typeclasses\n// -------------------------------------------------------------------------------------\n\nimport * as alternative from \"@fp-ts/core/typeclass/Alternative\"\nimport * as applicative from \"@fp-ts/core/typeclass/Applicative\"\nimport * as bicovariant from \"@fp-ts/core/typeclass/Bicovariant\"\nimport * as bounded from \"@fp-ts/core/typeclass/Bounded\"\nimport * as chainable from \"@fp-ts/core/typeclass/Chainable\"\nimport * as contravariant from \"@fp-ts/core/typeclass/Contravariant\"\nimport * as coproduct from \"@fp-ts/core/typeclass/Coproduct\"\nimport * as covariant from \"@fp-ts/core/typeclass/Covariant\"\nimport * as equivalence from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as filterable from \"@fp-ts/core/typeclass/Filterable\"\nimport * as flatMap from \"@fp-ts/core/typeclass/FlatMap\"\nimport * as foldable from \"@fp-ts/core/typeclass/Foldable\"\nimport * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport * as monad from \"@fp-ts/core/typeclass/Monad\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as of from \"@fp-ts/core/typeclass/Of\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport * as pointed from \"@fp-ts/core/typeclass/Pointed\"\nimport * as product from \"@fp-ts/core/typeclass/Product\"\nimport * as semiAlternative from \"@fp-ts/core/typeclass/SemiAlternative\"\nimport * as semiApplicative from \"@fp-ts/core/typeclass/SemiApplicative\"\nimport * as semiCoproduct from \"@fp-ts/core/typeclass/SemiCoproduct\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\nimport * as traversable from \"@fp-ts/core/typeclass/Traversable\"\nimport * as traversableFilterable from \"@fp-ts/core/typeclass/TraversableFilterable\"\n\nexport {\n  /**\n   * @since 1.0.0\n   */\n  _function as function,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  alternative,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  applicative,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  bicovariant,\n  /**\n   * @since 1.0.0\n   */\n  bigint,\n  /**\n   * @since 1.0.0\n   */\n  boolean,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  bounded,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  chainable,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  contravariant,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  coproduct,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  covariant,\n  /**\n   * @since 1.0.0\n   */\n  either,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  equivalence,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  filterable,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  flatMap,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  foldable,\n  /**\n   * @since 1.0.0\n   */\n  hkt,\n  /**\n   * @since 1.0.0\n   */\n  identity,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  invariant,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  monad,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  monoid,\n  /**\n   * @since 1.0.0\n   */\n  number,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  of,\n  /**\n   * @since 1.0.0\n   */\n  option,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  order,\n  /**\n   * @since 1.0.0\n   */\n  ordering,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  pointed,\n  /**\n   * @since 1.0.0\n   */\n  predicate,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  product,\n  /**\n   * @since 1.0.0\n   */\n  readonlyArray,\n  /**\n   * @since 1.0.0\n   */\n  readonlyRecord,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  semiAlternative,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  semiApplicative,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  semiCoproduct,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  semigroup,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  semiProduct,\n  /**\n   * @since 1.0.0\n   */\n  string,\n  /**\n   * @since 1.0.0\n   */\n  struct,\n  /**\n   * @since 1.0.0\n   */\n  symbol,\n  /**\n   * @since 1.0.0\n   */\n  these,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  traversable,\n  /**\n   * @category typeclass\n   * @since 1.0.0\n   */\n  traversableFilterable,\n  /**\n   * @since 1.0.0\n   */\n  tuple\n}\n"
  },
  {
    "path": "src/internal/Either.ts",
    "content": "/**\n * @since 1.0.0\n */\n\nimport type { Either, Left, Right } from \"@fp-ts/core/Either\"\nimport { dual } from \"@fp-ts/core/Function\"\nimport { proto } from \"@fp-ts/core/internal/effect\"\nimport * as option from \"@fp-ts/core/internal/Option\"\nimport type { Option } from \"@fp-ts/core/Option\"\n\n/** @internal */\nexport const isLeft = <E, A>(ma: Either<E, A>): ma is Left<E> => ma._tag === \"Left\"\n\n/** @internal */\nexport const isRight = <E, A>(ma: Either<E, A>): ma is Right<A> => ma._tag === \"Right\"\n\n/** @internal */\nexport const left = <E>(e: E): Either<E, never> =>\n  Object.setPrototypeOf({ _tag: \"Left\", left: e }, proto)\n\n/** @internal */\nexport const right = <A>(a: A): Either<never, A> =>\n  Object.setPrototypeOf({ _tag: \"Right\", right: a }, proto)\n\n/** @internal */\nexport const getLeft = <E, A>(\n  self: Either<E, A>\n): Option<E> => (isRight(self) ? option.none : option.some(self.left))\n\n/** @internal */\nexport const getRight = <E, A>(\n  self: Either<E, A>\n): Option<A> => (isLeft(self) ? option.none : option.some(self.right))\n\n/** @internal */\nexport const fromOption = dual(\n  2,\n  <A, E>(self: Option<A>, onNone: () => E): Either<E, A> =>\n    option.isNone(self) ? left(onNone()) : right(self.value)\n)\n"
  },
  {
    "path": "src/internal/Option.ts",
    "content": "/**\n * @since 1.0.0\n */\n\nimport { proto } from \"@fp-ts/core/internal/effect\"\nimport type { None, Option, Some } from \"@fp-ts/core/Option\"\n\n/** @internal */\nexport const isNone = <A>(fa: Option<A>): fa is None => fa._tag === \"None\"\n\n/** @internal */\nexport const isSome = <A>(fa: Option<A>): fa is Some<A> => fa._tag === \"Some\"\n\n/** @internal */\nexport const none: Option<never> = Object.setPrototypeOf({ _tag: \"None\" }, proto)\n\n/** @internal */\nexport const some = <A>(a: A): Option<A> => Object.setPrototypeOf({ _tag: \"Some\", value: a }, proto)\n"
  },
  {
    "path": "src/internal/ReadonlyArray.ts",
    "content": "/**\n * @since 1.0.0\n */\n\nimport type { NonEmptyArray } from \"@fp-ts/core/ReadonlyArray\"\n\n/** @internal */\nexport const isNonEmptyArray = <A>(self: ReadonlyArray<A>): self is NonEmptyArray<A> =>\n  self.length > 0\n\n/** @internal */\nexport const fromIterable = <A>(collection: Iterable<A>): Array<A> =>\n  Array.isArray(collection) ? collection : Array.from(collection)\n"
  },
  {
    "path": "src/internal/effect.ts",
    "content": "/**\n * @since 1.0.0\n */\n\n/** @internal */\nexport const structural = Symbol.for(\"@effect/data/Equal/structural\")\n\n/** @internal */\nexport const proto = Object.setPrototypeOf({ [structural]: true }, Object.prototype)\n"
  },
  {
    "path": "src/typeclass/Alternative.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Coproduct } from \"@fp-ts/core/typeclass/Coproduct\"\nimport type { SemiAlternative } from \"@fp-ts/core/typeclass/SemiAlternative\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Alternative<F extends TypeLambda> extends SemiAlternative<F>, Coproduct<F> {}\n"
  },
  {
    "path": "src/typeclass/Applicative.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport type { Product } from \"@fp-ts/core/typeclass/Product\"\nimport type { SemiApplicative } from \"@fp-ts/core/typeclass/SemiApplicative\"\nimport * as semiApplicative from \"@fp-ts/core/typeclass/SemiApplicative\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Applicative<F extends TypeLambda> extends SemiApplicative<F>, Product<F> {}\n\n/**\n * Lift a `Monoid` into `F`, combining the inner values using the provided `Monoid`:\n *\n * - `combine` is provided by {@link semiApplicative.getSemigroup}.\n * - `empty` is `F.of(M.empty)`\n *\n * @param F - The `Applicative` instance for `F`.\n * @param M - The `Monoid` instance for `A`.\n *\n * @since 1.0.0\n */\nexport const getMonoid = <F extends TypeLambda>(F: Applicative<F>) =>\n  <A, R, O, E>(M: Monoid<A>): Monoid<Kind<F, R, O, E, A>> =>\n    monoid.fromSemigroup(\n      semiApplicative.getSemigroup(F)<A, R, O, E>(M),\n      F.of(M.empty)\n    )\n"
  },
  {
    "path": "src/typeclass/Bicovariant.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Bicovariant<F extends TypeLambda> extends TypeClass<F> {\n  readonly bimap: {\n    <E1, E2, A, B>(\n      f: (e: E1) => E2,\n      g: (a: A) => B\n    ): <R, O>(self: Kind<F, R, O, E1, A>) => Kind<F, R, O, E2, B>\n    <R, O, E1, A, E2, B>(\n      self: Kind<F, R, O, E1, A>,\n      f: (e: E1) => E2,\n      g: (a: A) => B\n    ): Kind<F, R, O, E2, B>\n  }\n}\n\n/**\n * Returns a default ternary `bimap` composition.\n *\n * @since 1.0.0\n */\nexport const bimapComposition = <F extends TypeLambda, G extends TypeLambda>(\n  CovariantF: Covariant<F>,\n  BicovariantG: Bicovariant<G>\n) =>\n  <FR, FO, FE, GR, GO, E1, A, E2, B>(\n    self: Kind<F, FR, FO, FE, Kind<G, GR, GO, E1, A>>,\n    f: (e: E1) => E2,\n    g: (a: A) => B\n  ): Kind<F, FR, FO, FE, Kind<G, GR, GO, E2, B>> => CovariantF.map(self, BicovariantG.bimap(f, g))\n\n/**\n * Returns a default `mapLeft` implementation.\n *\n * @since 1.0.0\n */\nexport const mapLeft = <F extends TypeLambda>(\n  F: Bicovariant<F>\n): {\n  <E, G>(f: (e: E) => G): <R, O, A>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, G, A>\n  <R, O, E, A, G>(self: Kind<F, R, O, E, A>, f: (e: E) => G): Kind<F, R, O, G, A>\n} =>\n  dual(\n    2,\n    <R, O, E, A, G>(self: Kind<F, R, O, E, A>, f: (e: E) => G): Kind<F, R, O, G, A> =>\n      F.bimap(self, f, identity)\n  )\n\n/**\n * Returns a default `map` implementation.\n *\n * @since 1.0.0\n */\nexport const map = <F extends TypeLambda>(\n  F: Bicovariant<F>\n): Covariant<F>[\"map\"] =>\n  dual(\n    2,\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Kind<F, R, O, E, B> =>\n      F.bimap(self, identity, f)\n  )\n"
  },
  {
    "path": "src/typeclass/Bounded.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport type { Order } from \"@fp-ts/core/typeclass/Order\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Bounded<A> extends Order<A> {\n  readonly maxBound: A\n  readonly minBound: A\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface BoundedTypeLambda extends TypeLambda {\n  readonly type: Bounded<this[\"Target\"]>\n}\n\n/**\n * `Monoid` that returns last minimum of elements.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const min = <A>(B: Bounded<A>): Monoid<A> =>\n  monoid.fromSemigroup(semigroup.min(B), B.maxBound)\n\n/**\n * `Monoid` that returns last maximum of elements.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const max = <A>(B: Bounded<A>): Monoid<A> =>\n  monoid.fromSemigroup(semigroup.max(B), B.minBound)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const number: Bounded<number> = {\n  compare: order.number.compare,\n  maxBound: Infinity,\n  minBound: -Infinity\n}\n\n/**\n * Clamp a value between `minBound` and `maxBound` values.\n *\n * @since 1.0.0\n */\nexport const clamp = <A>(B: Bounded<A>): (a: A) => A => order.clamp(B)(B.minBound, B.maxBound)\n\n/**\n * Reverses the `Order` of a `Bounded` and flips `maxBound` and `minBound` values.\n *\n * @since 1.0.0\n */\nexport const reverse = <A>(B: Bounded<A>): Bounded<A> => ({\n  ...order.reverse(B),\n  minBound: B.maxBound,\n  maxBound: B.minBound\n})\n"
  },
  {
    "path": "src/typeclass/Chainable.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\nimport type { FlatMap } from \"@fp-ts/core/typeclass/FlatMap\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Chainable<F extends TypeLambda> extends FlatMap<F>, Covariant<F> {}\n\n/**\n * Sequences the specified effect after this effect, but ignores the value\n * produced by the effect.\n *\n * @category combining\n * @since 1.0.0\n */\nexport const andThenDiscard = <F extends TypeLambda>(F: Chainable<F>): {\n  <R2, O2, E2, _>(\n    that: Kind<F, R2, O2, E2, _>\n  ): <R1, O1, E1, A>(self: Kind<F, R1, O1, E1, A>) => Kind<F, R1 & R2, O2 | O1, E2 | E1, A>\n  <R1, O1, E1, A, R2, O2, E2, _>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, _>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, A>\n} =>\n  dual(2, <R1, O1, E1, A, R2, O2, E2, _>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, _>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, A> => tap(F)(self, () => that))\n\n/**\n * Returns an effect that effectfully \"peeks\" at the success of this effect.\n *\n * @since 1.0.0\n */\nexport const tap = <F extends TypeLambda>(F: Chainable<F>): {\n  <A, R2, O2, E2, _>(\n    f: (a: A) => Kind<F, R2, O2, E2, _>\n  ): <R1, O1, E1>(self: Kind<F, R1, O1, E1, A>) => Kind<F, R1 & R2, O2 | O1, E2 | E1, A>\n  <R1, O1, E1, A, R2, O2, E2, _>(\n    self: Kind<F, R1, O1, E1, A>,\n    f: (a: A) => Kind<F, R2, O2, E2, _>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, A>\n} =>\n  dual(\n    2,\n    <R1, O1, E1, A, R2, O2, E2, _>(\n      self: Kind<F, R1, O1, E1, A>,\n      f: (a: A) => Kind<F, R2, O2, E2, _>\n    ): Kind<F, R1 & R2, O1 | O2, E1 | E2, A> => F.flatMap(self, a => F.map(f(a), () => a))\n  )\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bind = <F extends TypeLambda>(F: Chainable<F>): {\n  <N extends string, A extends object, R2, O2, E2, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Kind<F, R2, O2, E2, B>\n  ): <R1, O1, E1>(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n  <R1, O1, E1, A extends object, N extends string, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n} =>\n  dual(3, <R1, O1, E1, A, N extends string, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }> =>\n    F.flatMap(self, a => F.map(f(a), b => Object.assign({}, a, { [name]: b }) as any)))\n"
  },
  {
    "path": "src/typeclass/Contravariant.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Invariant } from \"@fp-ts/core/typeclass/Invariant\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Contravariant<F extends TypeLambda> extends Invariant<F> {\n  readonly contramap: {\n    <B, A>(f: (b: B) => A): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (b: B) => A): Kind<F, R, O, E, B>\n  }\n}\n\n/**\n * Composing two contravariant functors yields a Covariant functor.\n *\n * Returns a default binary `map` composition.\n *\n * @since 1.0.0\n */\nexport const contramapComposition = <F extends TypeLambda, G extends TypeLambda>(\n  F: Contravariant<F>,\n  G: Contravariant<G>\n) =>\n  <FR, FO, FE, GR, GO, GE, A, B>(\n    self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n    f: (a: A) => B\n  ): Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>> => F.contramap(self, G.contramap(f))\n\n/**\n * Returns a default `imap` implementation.\n *\n * @since 1.0.0\n */\nexport const imap = <F extends TypeLambda>(\n  contramap: <R, O, E, A, B>(\n    self: Kind<F, R, O, E, A>,\n    f: (b: B) => A\n  ) => Kind<F, R, O, E, B>\n): Invariant<F>[\"imap\"] => dual(3, (self, _, from) => contramap(self, from))\n"
  },
  {
    "path": "src/typeclass/Coproduct.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\nimport type { SemiCoproduct } from \"@fp-ts/core/typeclass/SemiCoproduct\"\nimport * as semiCoproduct from \"@fp-ts/core/typeclass/SemiCoproduct\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Coproduct<F extends TypeLambda> extends SemiCoproduct<F> {\n  readonly zero: <A>() => Kind<F, unknown, never, never, A>\n\n  readonly coproductAll: <R, O, E, A>(\n    collection: Iterable<Kind<F, R, O, E, A>>\n  ) => Kind<F, R, O, E, A>\n}\n\n/**\n * @since 1.0.0\n */\nexport const getMonoid = <F extends TypeLambda>(F: Coproduct<F>) =>\n  <R, O, E, A>(): Monoid<\n    Kind<F, R, O, E, A>\n  > => ({\n    ...semiCoproduct.getSemigroup(F)(),\n    empty: F.zero(),\n    combineAll: F.coproductAll\n  })\n"
  },
  {
    "path": "src/typeclass/Covariant.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Invariant } from \"@fp-ts/core/typeclass/Invariant\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Covariant<F extends TypeLambda> extends Invariant<F> {\n  readonly map: {\n    <A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Kind<F, R, O, E, B>\n  }\n}\n\n/**\n * Returns a default `map` composition.\n *\n * @since 1.0.0\n */\nexport const mapComposition = <F extends TypeLambda, G extends TypeLambda>(\n  F: Covariant<F>,\n  G: Covariant<G>\n): (<FR, FO, FE, GR, GO, GE, A, B>(\n  self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n  f: (a: A) => B\n) => Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>>) => (self, f) => F.map(self, G.map(f))\n\n/**\n * Returns a default `imap` implementation.\n *\n * @since 1.0.0\n */\nexport const imap = <F extends TypeLambda>(\n  map: <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B) => Kind<F, R, O, E, B>\n): Invariant<F>[\"imap\"] => dual(3, (self, to, _) => map(self, to))\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const flap = <F extends TypeLambda>(F: Covariant<F>): {\n  <R, O, E, A, B>(self: Kind<F, R, O, E, (a: A) => B>): (a: A) => Kind<F, R, O, E, B>\n  <A, R, O, E, B>(a: A, self: Kind<F, R, O, E, (a: A) => B>): Kind<F, R, O, E, B>\n} =>\n  dual(\n    2,\n    <A, R, O, E, B>(a: A, self: Kind<F, R, O, E, (a: A) => B>): Kind<F, R, O, E, B> =>\n      F.map(self, f => f(a))\n  )\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const as = <F extends TypeLambda>(F: Covariant<F>): {\n  <B>(b: B): <R, O, E, _>(self: Kind<F, R, O, E, _>) => Kind<F, R, O, E, B>\n  <R, O, E, _, B>(self: Kind<F, R, O, E, _>, b: B): Kind<F, R, O, E, B>\n} =>\n  dual(\n    2,\n    <R, O, E, _, B>(self: Kind<F, R, O, E, _>, b: B): Kind<F, R, O, E, B> => F.map(self, () => b)\n  )\n\n/**\n * @category mapping\n * @since 1.0.0\n */\nexport const asUnit = <F extends TypeLambda>(\n  F: Covariant<F>\n): (<R, O, E, _>(self: Kind<F, R, O, E, _>) => Kind<F, R, O, E, void>) => as(F)<void>(undefined)\n\nconst let_ = <F extends TypeLambda>(\n  F: Covariant<F>\n): {\n  <N extends string, A extends object, B>(\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): <R, O, E>(\n    self: Kind<F, R, O, E, A>\n  ) => Kind<F, R, O, E, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n  <R, O, E, A extends object, N extends string, B>(\n    self: Kind<F, R, O, E, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): Kind<F, R, O, E, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n} =>\n  dual(3, <R, O, E, A extends object, N extends string, B>(\n    self: Kind<F, R, O, E, A>,\n    name: Exclude<N, keyof A>,\n    f: (a: A) => B\n  ): Kind<F, R, O, E, { [K in keyof A | N]: K extends keyof A ? A[K] : B }> =>\n    F.map(self, a => Object.assign({}, a, { [name]: f(a) }) as any))\n\nexport {\n  /**\n   * @category do notation\n   * @since 1.0.0\n   */\n  let_ as let\n}\n"
  },
  {
    "path": "src/typeclass/Equivalence.ts",
    "content": "/**\n * This module provides an implementation of the `Equivalence` type class, which defines a binary relation\n * that is reflexive, symmetric, and transitive. In other words, it defines a notion of equivalence between values of a certain type.\n * These properties are also known in mathematics as an \"equivalence relation\".\n *\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as readonlyArray from \"@fp-ts/core/internal/ReadonlyArray\"\nimport * as contravariant from \"@fp-ts/core/typeclass/Contravariant\"\nimport type * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as product_ from \"@fp-ts/core/typeclass/Product\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport type * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Equivalence<A> {\n  (self: A, that: A): boolean\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface EquivalenceTypeLambda extends TypeLambda {\n  readonly type: Equivalence<this[\"Target\"]>\n}\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const make = <A>(isEquivalent: (self: A, that: A) => boolean): Equivalence<A> =>\n  (self: A, that: A): boolean => self === that || isEquivalent(self, that)\n\nconst isStrictEquivalent = (x: unknown, y: unknown) => x === y\n\n/**\n * Return an `Equivalence` that uses strict equality (===) to compare values.\n *\n * @since 1.0.0\n * @category constructors\n */\nexport const strict: <A>() => Equivalence<A> = () => isStrictEquivalent\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const string: Equivalence<string> = strict()\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const number: Equivalence<number> = strict()\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const boolean: Equivalence<boolean> = strict()\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const bigint: Equivalence<bigint> = strict()\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const symbol: Equivalence<symbol> = strict()\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getSemigroup = <A>(): Semigroup<Equivalence<A>> =>\n  semigroup.make(\n    (self, that) => make((x, y) => self(x, y) && that(x, y)),\n    (self, collection) =>\n      make((x, y) => {\n        if (!self(x, y)) {\n          return false\n        }\n        for (const equivalence of collection) {\n          if (!equivalence(x, y)) {\n            return false\n          }\n        }\n        return true\n      })\n  )\n\nconst isAlwaysEquivalent: Equivalence<unknown> = (_x, _y) => true\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getMonoid = <A>(): Monoid<Equivalence<A>> =>\n  monoid.fromSemigroup(getSemigroup<A>(), isAlwaysEquivalent)\n\n/**\n * @category combinators\n * @since 1.0.0\n */\nexport const contramap: {\n  <B, A>(f: (b: B) => A): (self: Equivalence<A>) => Equivalence<B>\n  <A, B>(self: Equivalence<A>, f: (b: B) => A): Equivalence<B>\n} = dual(\n  2,\n  <A, B>(self: Equivalence<A>, f: (b: B) => A): Equivalence<B> => make((x, y) => self(f(x), f(y)))\n)\n\nconst imap = contravariant.imap<EquivalenceTypeLambda>(contramap)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Contravariant: contravariant.Contravariant<EquivalenceTypeLambda> = {\n  imap,\n  contramap\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<EquivalenceTypeLambda> = {\n  imap\n}\n\nconst product = <A, B>(self: Equivalence<A>, that: Equivalence<B>): Equivalence<[A, B]> =>\n  make(([xa, xb], [ya, yb]) => self(xa, ya) && that(xb, yb))\n\nconst productAll = <A>(collection: Iterable<Equivalence<A>>): Equivalence<Array<A>> => {\n  const equivalences = readonlyArray.fromIterable(collection)\n  return make((x, y) => {\n    const len = Math.min(x.length, y.length, equivalences.length)\n    for (let i = 0; i < len; i++) {\n      if (!equivalences[i](x[i], y[i])) {\n        return false\n      }\n    }\n    return true\n  })\n}\n\nconst productMany = <A>(\n  self: Equivalence<A>,\n  collection: Iterable<Equivalence<A>>\n): Equivalence<[A, ...Array<A>]> => {\n  const equivalence = productAll(collection)\n  return make((x, y) => !self(x[0], y[0]) ? false : equivalence(x.slice(1), y.slice(1)))\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiProduct: semiProduct.SemiProduct<EquivalenceTypeLambda> = {\n  imap,\n  product,\n  productMany\n}\n\nconst of: <A>(a: A) => Equivalence<A> = () => isAlwaysEquivalent\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Product: product_.Product<EquivalenceTypeLambda> = {\n  of,\n  imap,\n  product,\n  productMany,\n  productAll\n}\n\n/**\n * Similar to `Promise.all` but operates on `Equivalence`s.\n *\n * ```\n * [Equivalence<A>, Equivalence<B>, ...] -> Equivalence<[A, B, ...]>\n * ```\n *\n * Given a tuple of `Equivalence`s returns a new `Equivalence` that compares values of a tuple\n * by applying each `Equivalence` to the corresponding element of the tuple.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const tuple: <T extends ReadonlyArray<Equivalence<any>>>(\n  ...predicates: T\n) => Equivalence<Readonly<{ [I in keyof T]: [T[I]] extends [Equivalence<infer A>] ? A : never }>> =\n  product_.tuple(Product)\n\n/**\n * Given a struct of `Equivalence`s returns a new `Equivalence` that compares values of a struct\n * by applying each `Equivalence` to the corresponding property of the struct.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const struct: <R extends Record<string, Equivalence<any>>>(\n  predicates: R\n) => Equivalence<{ readonly [K in keyof R]: [R[K]] extends [Equivalence<infer A>] ? A : never }> =\n  product_.struct(Product)\n"
  },
  {
    "path": "src/typeclass/Filterable.ts",
    "content": "/**\n * `Filterable` represents data structures which can be _partitioned_/_filtered_.\n *\n * @since 1.0.0\n */\nimport type { Either } from \"@fp-ts/core/Either\"\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as either from \"@fp-ts/core/internal/Either\"\nimport * as option from \"@fp-ts/core/internal/Option\"\nimport type { Option } from \"@fp-ts/core/Option\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport interface Filterable<F extends TypeLambda> extends TypeClass<F> {\n  readonly partitionMap: {\n    <A, B, C>(\n      f: (a: A) => Either<B, C>\n    ): <R, O, E>(self: Kind<F, R, O, E, A>) => [Kind<F, R, O, E, B>, Kind<F, R, O, E, C>]\n    <R, O, E, A, B, C>(\n      self: Kind<F, R, O, E, A>,\n      f: (a: A) => Either<B, C>\n    ): [Kind<F, R, O, E, B>, Kind<F, R, O, E, C>]\n  }\n\n  readonly filterMap: {\n    <A, B>(f: (a: A) => Option<B>): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => Option<B>): Kind<F, R, O, E, B>\n  }\n}\n\n/**\n * Returns a default binary `partitionMap` composition.\n *\n * @since 1.0.0\n */\nexport const partitionMapComposition = <F extends TypeLambda, G extends TypeLambda>(\n  F: Covariant<F>,\n  G: Filterable<G>\n) =>\n  <FR, FO, FE, GR, GO, GE, A, B, C>(\n    self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n    f: (a: A) => Either<B, C>\n  ): [Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>>, Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, C>>] => {\n    const filterMap = filterMapComposition(F, G)\n    return [filterMap(self, a => either.getLeft(f(a))), filterMap(self, a => either.getRight(f(a)))]\n  }\n\n/**\n * Returns a default binary `filterMap` composition.\n *\n * @since 1.0.0\n */\nexport const filterMapComposition = <F extends TypeLambda, G extends TypeLambda>(\n  F: Covariant<F>,\n  G: Filterable<G>\n) =>\n  <FR, FO, FE, GR, GO, GE, A, B>(\n    self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n    f: (a: A) => Option<B>\n  ): Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>> => F.map(self, G.filterMap(f))\n\n/**\n * @since 1.0.0\n */\nexport const compact = <F extends TypeLambda>(\n  F: Filterable<F>\n): <R, O, E, A>(self: Kind<F, R, O, E, Option<A>>) => Kind<F, R, O, E, A> => F.filterMap(identity)\n\n/**\n * @since 1.0.0\n */\nexport const separate = <F extends TypeLambda>(\n  F: Filterable<F>\n): <R, O, E, A, B>(\n  self: Kind<F, R, O, E, Either<A, B>>\n) => [Kind<F, R, O, E, A>, Kind<F, R, O, E, B>] => F.partitionMap(identity)\n\n/**\n * @since 1.0.0\n */\nexport const filter: <F extends TypeLambda>(\n  F: Filterable<F>\n) => {\n  <C extends A, B extends A, A = C>(refinement: (a: A) => a is B): <R, O, E>(\n    self: Kind<F, R, O, E, C>\n  ) => Kind<F, R, O, E, B>\n  <B extends A, A = B>(\n    predicate: (a: A) => boolean\n  ): <R, O, E>(self: Kind<F, R, O, E, B>) => Kind<F, R, O, E, B>\n  <R, O, E, C extends A, B extends A, A = C>(\n    self: Kind<F, R, O, E, C>,\n    refinement: (a: A) => a is B\n  ): Kind<F, R, O, E, B>\n  <R, O, E, B extends A, A = B>(\n    self: Kind<F, R, O, E, B>,\n    predicate: (a: A) => boolean\n  ): Kind<F, R, O, E, B>\n} = <F extends TypeLambda>(Filterable: Filterable<F>) =>\n  dual(\n    2,\n    <R, O, E, A>(self: Kind<F, R, O, E, A>, predicate: (a: A) => boolean): Kind<F, R, O, E, A> =>\n      Filterable.filterMap(self, (b) => (predicate(b) ? option.some(b) : option.none))\n  )\n\n/**\n * @since 1.0.0\n */\nexport const partition = <F extends TypeLambda>(\n  F: Filterable<F>\n): {\n  <C extends A, B extends A, A = C>(refinement: (a: A) => a is B): <R, O, E>(\n    self: Kind<F, R, O, E, C>\n  ) => [Kind<F, R, O, E, C>, Kind<F, R, O, E, B>]\n  <B extends A, A = B>(predicate: (a: A) => boolean): <R, O, E>(\n    self: Kind<F, R, O, E, B>\n  ) => [Kind<F, R, O, E, B>, Kind<F, R, O, E, B>]\n  <R, O, E, C extends A, B extends A, A = C>(\n    self: Kind<F, R, O, E, C>,\n    refinement: (a: A) => a is B\n  ): [Kind<F, R, O, E, C>, Kind<F, R, O, E, B>]\n  <R, O, E, B extends A, A = B>(\n    self: Kind<F, R, O, E, B>,\n    predicate: (a: A) => boolean\n  ): [Kind<F, R, O, E, B>, Kind<F, R, O, E, B>]\n} =>\n  dual(\n    2,\n    <R, O, E, B extends A, A = B>(\n      self: Kind<F, R, O, E, B>,\n      predicate: (a: A) => boolean\n    ): [Kind<F, R, O, E, B>, Kind<F, R, O, E, B>] =>\n      F.partitionMap(self, (b) => (predicate(b) ? either.right(b) : either.left(b)))\n  )\n"
  },
  {
    "path": "src/typeclass/FlatMap.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface FlatMap<F extends TypeLambda> extends TypeClass<F> {\n  readonly flatMap: {\n    <A, R2, O2, E2, B>(\n      f: (a: A) => Kind<F, R2, O2, E2, B>\n    ): <R1, O1, E1>(self: Kind<F, R1, O1, E1, A>) => Kind<F, R1 & R2, O1 | O2, E1 | E2, B>\n    <R1, O1, E1, A, R2, O2, E2, B>(\n      self: Kind<F, R1, O1, E1, A>,\n      f: (a: A) => Kind<F, R2, O2, E2, B>\n    ): Kind<F, R1 & R2, O1 | O2, E1 | E2, B>\n  }\n}\n\n/**\n * @since 1.0.0\n */\nexport const flatten = <F extends TypeLambda>(F: FlatMap<F>) =>\n  <R2, O2, E2, R1, O1, E1, A>(\n    self: Kind<F, R2, O2, E2, Kind<F, R1, O1, E1, A>>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, A> => F.flatMap(self, identity)\n\n/**\n * A variant of `flatMap` that ignores the value produced by this effect.\n *\n * @since 1.0.0\n */\nexport const andThen = <F extends TypeLambda>(F: FlatMap<F>): {\n  <R2, O2, E2, B>(\n    that: Kind<F, R2, O2, E2, B>\n  ): <R1, O1, E1, _>(self: Kind<F, R1, O1, E1, _>) => Kind<F, R1 & R2, O2 | O1, E2 | E1, B>\n  <R1, O1, E1, _, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, _>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, B>\n} =>\n  dual(2, <R1, O1, E1, _, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, _>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, B> => F.flatMap(self, () => that))\n\n/**\n * @since 1.0.0\n */\nexport const composeKleisliArrow = <F extends TypeLambda>(\n  F: FlatMap<F>\n): {\n  <B, R2, O2, E2, C>(\n    bfc: (b: B) => Kind<F, R2, O2, E2, C>\n  ): <A, R1, O1, E1>(\n    afb: (a: A) => Kind<F, R1, O1, E1, B>\n  ) => (a: A) => Kind<F, R1 & R2, O2 | O1, E2 | E1, C>\n  <A, R1, O1, E1, B, R2, O2, E2, C>(\n    afb: (a: A) => Kind<F, R1, O1, E1, B>,\n    bfc: (b: B) => Kind<F, R2, O2, E2, C>\n  ): (a: A) => Kind<F, R1 & R2, O1 | O2, E1 | E2, C>\n} =>\n  dual(\n    2,\n    <A, R1, O1, E1, B, R2, O2, E2, C>(\n      afb: (a: A) => Kind<F, R1, O1, E1, B>,\n      bfc: (b: B) => Kind<F, R2, O2, E2, C>\n    ): ((a: A) => Kind<F, R1 & R2, O1 | O2, E1 | E2, C>) => a => F.flatMap(afb(a), bfc)\n  )\n"
  },
  {
    "path": "src/typeclass/Foldable.ts",
    "content": "/**\n * @since 1.0.0\n */\n\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Coproduct } from \"@fp-ts/core/typeclass/Coproduct\"\nimport type { Monad } from \"@fp-ts/core/typeclass/Monad\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Foldable<F extends TypeLambda> extends TypeClass<F> {\n  readonly reduce: {\n    <A, B>(b: B, f: (b: B, a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => B\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, b: B, f: (b: B, a: A) => B): B\n  }\n}\n\n/**\n * Returns a default ternary `reduce` composition.\n *\n * @since 1.0.0\n */\nexport const reduceComposition = <F extends TypeLambda, G extends TypeLambda>(\n  F: Foldable<F>,\n  G: Foldable<G>\n) =>\n  <FR, FO, FE, GR, GO, GE, A, B>(\n    self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n    b: B,\n    f: (b: B, a: A) => B\n  ): B => F.reduce(self, b, (b, ga) => G.reduce(ga, b, f))\n\n/**\n * @since 1.0.0\n */\nexport const toArrayMap = <F extends TypeLambda>(\n  F: Foldable<F>\n): {\n  <A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => Array<B>\n  <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Array<B>\n} =>\n  dual(\n    2,\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Array<B> =>\n      F.reduce(self, [], (out: Array<B>, a) => [...out, f(a)])\n  )\n\n/**\n * @since 1.0.0\n */\nexport const toArray = <F extends TypeLambda>(\n  F: Foldable<F>\n): <R, O, E, A>(self: Kind<F, R, O, E, A>) => Array<A> => toArrayMap(F)(identity)\n\n/**\n * @since 1.0.0\n */\nexport const combineMap = <F extends TypeLambda>(F: Foldable<F>) =>\n  <M>(M: Monoid<M>): {\n    <A>(f: (a: A) => M): <R, O, E>(self: Kind<F, R, O, E, A>) => M\n    <R, O, E, A>(self: Kind<F, R, O, E, A>, f: (a: A) => M): M\n  } =>\n    dual(2, <R, O, E, A>(self: Kind<F, R, O, E, A>, f: (a: A) => M): M =>\n      F.reduce(self, M.empty, (m, a) =>\n        M.combine(m, f(a))))\n\n/**\n * @since 1.0.0\n */\nexport const reduceKind = <F extends TypeLambda>(F: Foldable<F>) =>\n  <G extends TypeLambda>(G: Monad<G>): {\n    <B, A, R, O, E>(\n      b: B,\n      f: (b: B, a: A) => Kind<G, R, O, E, B>\n    ): <FR, FO, FE>(self: Kind<F, FR, FO, FE, A>) => Kind<G, R, O, E, B>\n    <FR, FO, FE, A, B, R, O, E>(\n      self: Kind<F, FR, FO, FE, A>,\n      b: B,\n      f: (b: B, a: A) => Kind<G, R, O, E, B>\n    ): Kind<G, R, O, E, B>\n  } =>\n    dual(3, <FR, FO, FE, A, B, R, O, E>(\n      self: Kind<F, FR, FO, FE, A>,\n      b: B,\n      f: (b: B, a: A) => Kind<G, R, O, E, B>\n    ): Kind<G, R, O, E, B> =>\n      F.reduce(\n        self,\n        G.of(b),\n        (gb: Kind<G, R, O, E, B>, a) => G.flatMap(gb, b => f(b, a))\n      ))\n\n/**\n * @since 1.0.0\n */\nexport const coproductMapKind = <F extends TypeLambda>(F: Foldable<F>) =>\n  <G extends TypeLambda>(G: Coproduct<G>): {\n    <A, R, O, E, B>(\n      f: (a: A) => Kind<G, R, O, E, B>\n    ): <FR, FO, FE>(self: Kind<F, FR, FO, FE, A>) => Kind<G, R, O, E, B>\n    <FR, FO, FE, A, R, O, E, B>(\n      self: Kind<F, FR, FO, FE, A>,\n      f: (a: A) => Kind<G, R, O, E, B>\n    ): Kind<G, R, O, E, B>\n  } =>\n    dual(2, <FR, FO, FE, A, R, O, E, B>(\n      self: Kind<F, FR, FO, FE, A>,\n      f: (a: A) => Kind<G, R, O, E, B>\n    ): Kind<G, R, O, E, B> =>\n      F.reduce(self, G.zero(), (gb: Kind<G, R, O, E, B>, a) => G.coproduct(gb, f(a))))\n"
  },
  {
    "path": "src/typeclass/Invariant.ts",
    "content": "/**\n * The `Invariant` typeclass is a higher-order abstraction over types that allow mapping the contents of a type in both directions.\n * It is similar to the `Covariant` typeclass but provides an `imap` opration, which allows transforming a value in both directions.\n * This typeclass is useful when dealing with data types that can be converted to and from some other types.\n * The `imap` operation provides a way to convert such data types to other types that they can interact with while preserving their invariants.\n *\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Invariant<F extends TypeLambda> extends TypeClass<F> {\n  readonly imap: {\n    <A, B>(\n      to: (a: A) => B,\n      from: (b: B) => A\n    ): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n    <R, O, E, A, B>(\n      self: Kind<F, R, O, E, A>,\n      to: (a: A) => B,\n      from: (b: B) => A\n    ): Kind<F, R, O, E, B>\n  }\n}\n\n/**\n * Returns a default ternary `imap` composition.\n *\n * @since 1.0.0\n */\nexport const imapComposition = <F extends TypeLambda, G extends TypeLambda>(\n  F: Invariant<F>,\n  G: Invariant<G>\n) =>\n  <FR, FO, FE, GR, GO, GE, A, B>(\n    self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n    to: (a: A) => B,\n    from: (b: B) => A\n  ): Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>> => F.imap(self, G.imap(to, from), G.imap(from, to))\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const bindTo = <F extends TypeLambda>(F: Invariant<F>): {\n  <N extends string>(\n    name: N\n  ): <R, O, E, A>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, { [K in N]: A }>\n  <R, O, E, A, N extends string>(\n    self: Kind<F, R, O, E, A>,\n    name: N\n  ): Kind<F, R, O, E, { [K in N]: A }>\n} =>\n  dual(2, <R, O, E, A, N extends string>(\n    self: Kind<F, R, O, E, A>,\n    name: N\n  ): Kind<F, R, O, E, { [K in N]: A }> =>\n    F.imap(self, a => ({ [name]: a } as any), ({ [name]: a }) => a))\n\n/**\n * Convert a value in a singleton array in a given effect.\n *\n * @since 1.0.0\n */\nexport const tupled = <F extends TypeLambda>(\n  F: Invariant<F>\n): (<R, O, E, A>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, [A]>) =>\n  F.imap(a => [a], ([a]) => a)\n"
  },
  {
    "path": "src/typeclass/Monad.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { FlatMap } from \"@fp-ts/core/typeclass/FlatMap\"\nimport type { Pointed } from \"@fp-ts/core/typeclass/Pointed\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Monad<F extends TypeLambda> extends FlatMap<F>, Pointed<F> {}\n"
  },
  {
    "path": "src/typeclass/Monoid.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { Bounded } from \"@fp-ts/core/typeclass/Bounded\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Monoid<A> extends Semigroup<A> {\n  readonly empty: A\n  readonly combineAll: (collection: Iterable<A>) => A\n}\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const fromSemigroup = <A>(S: Semigroup<A>, empty: Monoid<A>[\"empty\"]): Monoid<A> => ({\n  combine: S.combine,\n  combineMany: S.combineMany,\n  empty,\n  combineAll: collection => S.combineMany(empty, collection)\n})\n\n/**\n * Get a monoid where `combine` will return the minimum, based on the provided bounded order.\n *\n * The `empty` value is the `maxBound` value.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const min = <A>(B: Bounded<A>): Monoid<A> => fromSemigroup(semigroup.min(B), B.maxBound)\n\n/**\n * Get a monoid where `combine` will return the maximum, based on the provided bounded order.\n *\n * The `empty` value is the `minimum` value.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const max = <A>(B: Bounded<A>): Monoid<A> => fromSemigroup(semigroup.max(B), B.minBound)\n\n/**\n * The dual of a `Monoid`, obtained by swapping the arguments of `combine`.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const reverse = <A>(M: Monoid<A>): Monoid<A> => fromSemigroup(semigroup.reverse(M), M.empty)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const string: Monoid<string> = fromSemigroup(semigroup.string, \"\")\n\n/**\n * `number` monoid under addition.\n *\n * The `empty` value is `0`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const numberSum: Monoid<number> = fromSemigroup(semigroup.numberSum, 0)\n\n/**\n * `number` monoid under multiplication.\n *\n * The `empty` value is `1`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const numberMultiply: Monoid<number> = fromSemigroup(semigroup.numberMultiply, 1)\n\n/**\n * `number` monoid under addition.\n *\n * The `bigint` value is `0n`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const bigintSum: Monoid<bigint> = fromSemigroup(semigroup.bigintSum, 0n)\n\n/**\n * `bigint` monoid under multiplication.\n *\n * The `empty` value is `1n`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const bigintMultiply: Monoid<bigint> = fromSemigroup(semigroup.bigintMultiply, 1n)\n\n/**\n * `boolean` monoid under conjunction.\n *\n * The `empty` value is `true`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const booleanAll: Monoid<boolean> = fromSemigroup(semigroup.booleanAll, true)\n\n/**\n * `boolean` monoid under disjunction.\n *\n * The `empty` value is `false`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const booleanAny: Monoid<boolean> = fromSemigroup(semigroup.booleanAny, false)\n\n/**\n * `boolean` monoid under exclusive disjunction.\n *\n * The `empty` value is `false`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const booleanXor: Monoid<boolean> = fromSemigroup(semigroup.booleanXor, false)\n\n/**\n * `boolean` monoid under equivalence.\n *\n * The `empty` value is `true`.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const booleanEqv: Monoid<boolean> = fromSemigroup(semigroup.booleanEqv, true)\n\n/**\n * Similar to `Promise.all` but operates on `Monoid`s.\n *\n * ```\n * [Monoid<A>, Monoid<B>, ...] -> Monoid<[A, B, ...]>\n * ```\n *\n * This function creates and returns a new `Monoid` for a tuple of values based on the given `Monoid`s for each element in the tuple.\n * The returned `Monoid` combines two tuples of the same type by applying the corresponding `Monoid` passed as arguments to each element in the tuple.\n *\n * The `empty` value of the returned `Monoid` is the tuple of `empty` values of the input `Monoid`s.\n *\n * It is useful when you need to combine two tuples of the same type and you have a specific way of combining each element of the tuple.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const tuple = <T extends ReadonlyArray<Monoid<any>>>(\n  ...elements: T\n): Monoid<{ readonly [I in keyof T]: [T[I]] extends [Monoid<infer A>] ? A : never }> => {\n  const empty = elements.map((m) => m.empty) as any\n  return fromSemigroup(semigroup.tuple(...elements), empty)\n}\n\n/**\n * Given a type `A`, this function creates and returns a `Semigroup` for `ReadonlyArray<A>`.\n *\n * The `empty` value is the empty array.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const array = <A>(): Monoid<ReadonlyArray<A>> => fromSemigroup(semigroup.array<A>(), [])\n\n/**\n * This function creates and returns a new `Monoid` for a struct of values based on the given `Monoid`s for each property in the struct.\n * The returned `Monoid` combines two structs of the same type by applying the corresponding `Monoid` passed as arguments to each property in the struct.\n *\n * The `empty` value of the returned `Monoid` is a struct where each property is the `empty` value of the corresponding `Monoid` in the input `monoids` object.\n *\n * It is useful when you need to combine two structs of the same type and you have a specific way of combining each property of the struct.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const struct = <R extends { readonly [x: string]: Monoid<any> }>(\n  fields: R\n): Monoid<{ readonly [K in keyof R]: [R[K]] extends [Monoid<infer A>] ? A : never }> => {\n  const empty = {} as any\n  for (const k in fields) {\n    if (Object.prototype.hasOwnProperty.call(fields, k)) {\n      empty[k] = fields[k].empty\n    }\n  }\n  return fromSemigroup(semigroup.struct(fields), empty)\n}\n"
  },
  {
    "path": "src/typeclass/Of.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Of<F extends TypeLambda> extends TypeClass<F> {\n  readonly of: <A>(a: A) => Kind<F, unknown, never, never, A>\n}\n\n/**\n * Returns a default `of` composition.\n *\n * @since 1.0.0\n */\nexport const ofComposition = <F extends TypeLambda, G extends TypeLambda>(\n  F: Of<F>,\n  G: Of<G>\n) => <A>(a: A): Kind<F, unknown, never, never, Kind<G, unknown, never, never, A>> => F.of(G.of(a))\n\n/**\n * @since 1.0.0\n */\nexport const unit = <F extends TypeLambda>(\n  F: Of<F>\n): Kind<F, unknown, never, never, void> => F.of<void>(undefined)\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const Do = <F extends TypeLambda>(\n  F: Of<F>\n): Kind<F, unknown, never, never, {}> => F.of({})\n"
  },
  {
    "path": "src/typeclass/Order.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as readonlyArray from \"@fp-ts/core/internal/ReadonlyArray\"\nimport * as contravariant from \"@fp-ts/core/typeclass/Contravariant\"\nimport type * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport type { Monoid } from \"@fp-ts/core/typeclass/Monoid\"\nimport * as monoid from \"@fp-ts/core/typeclass/Monoid\"\nimport * as product_ from \"@fp-ts/core/typeclass/Product\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport type * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Order<A> {\n  readonly compare: (self: A, that: A) => -1 | 0 | 1\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface OrderTypeLambda extends TypeLambda {\n  readonly type: Order<this[\"Target\"]>\n}\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const make = <A>(\n  compare: Order<A>[\"compare\"]\n): Order<A> => ({\n  compare: (self, that) => self === that ? 0 : compare(self, that)\n})\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const string: Order<string> = make((self, that) => self < that ? -1 : 1)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const number: Order<number> = make((self, that) => self < that ? -1 : 1)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const boolean: Order<boolean> = make((self, that) => self < that ? -1 : 1)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const bigint: Order<bigint> = make((self, that) => self < that ? -1 : 1)\n\n/**\n * @since 1.0.0\n */\nexport const reverse = <A>(O: Order<A>): Order<A> => make((self, that) => O.compare(that, self))\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getSemigroup = <A>(): Semigroup<Order<A>> =>\n  semigroup.make(\n    (O1, O2) =>\n      make((self, that) => {\n        const out = O1.compare(self, that)\n        if (out !== 0) {\n          return out\n        }\n        return O2.compare(self, that)\n      }),\n    (self, collection) =>\n      make((a1, a2) => {\n        let out = self.compare(a1, a2)\n        if (out !== 0) {\n          return out\n        }\n        for (const O of collection) {\n          out = O.compare(a1, a2)\n          if (out !== 0) {\n            return out\n          }\n        }\n        return out\n      })\n  )\n\nconst empty: Order<unknown> = make(() => 0)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const getMonoid = <A>(): Monoid<Order<A>> => monoid.fromSemigroup(getSemigroup<A>(), empty)\n\n/**\n * @category combinators\n * @since 1.0.0\n */\nexport const contramap: {\n  <B, A>(f: (b: B) => A): (self: Order<A>) => Order<B>\n  <A, B>(self: Order<A>, f: (b: B) => A): Order<B>\n} = dual(\n  2,\n  <A, B>(self: Order<A>, f: (b: B) => A): Order<B> => make((b1, b2) => self.compare(f(b1), f(b2)))\n)\n\nconst imap = contravariant.imap<OrderTypeLambda>(contramap)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Contravariant: contravariant.Contravariant<OrderTypeLambda> = {\n  imap,\n  contramap\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<OrderTypeLambda> = {\n  imap\n}\n\nconst product = <A, B>(self: Order<A>, that: Order<B>): Order<[A, B]> =>\n  make(([xa, xb], [ya, yb]) => {\n    const o = self.compare(xa, ya)\n    return o !== 0 ? o : that.compare(xb, yb)\n  })\n\nconst productAll = <A>(collection: Iterable<Order<A>>): Order<Array<A>> => {\n  const orders = readonlyArray.fromIterable(collection)\n  return make((x, y) => {\n    const len = Math.min(x.length, y.length, orders.length)\n    for (let i = 0; i < len; i++) {\n      const o = orders[i].compare(x[i], y[i])\n      if (o !== 0) {\n        return o\n      }\n    }\n    return 0\n  })\n}\n\nconst productMany = <A>(\n  self: Order<A>,\n  collection: Iterable<Order<A>>\n): Order<[A, ...Array<A>]> => {\n  const order = productAll(collection)\n  return make((x, y) => {\n    const o = self.compare(x[0], y[0])\n    return o !== 0 ? o : order.compare(x.slice(1), y.slice(1))\n  })\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiProduct: semiProduct.SemiProduct<OrderTypeLambda> = {\n  imap,\n  product,\n  productMany\n}\n\nconst of: <A>(a: A) => Order<A> = () => empty\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Product: product_.Product<OrderTypeLambda> = {\n  of,\n  imap,\n  product,\n  productMany,\n  productAll\n}\n\n/**\n * Similar to `Promise.all` but operates on `Order`s.\n *\n * ```\n * [Order<A>, Order<B>, ...] -> Order<[A, B, ...]>\n * ```\n *\n * This function creates and returns a new `Order` for a tuple of values based on the given `Order`s for each element in the tuple.\n * The returned `Order` compares two tuples of the same type by applying the corresponding `Order` to each element in the tuple.\n * It is useful when you need to compare two tuples of the same type and you have a specific way of comparing each element\n * of the tuple.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const tuple: <T extends ReadonlyArray<Order<any>>>(\n  ...elements: T\n) => Order<{ [I in keyof T]: [T[I]] extends [Order<infer A>] ? A : never }> = product_.tuple(\n  Product\n)\n\n/**\n * This function creates and returns a new `Order` for an array of values based on a given `Order` for the elements of the array.\n * The returned `Order` compares two arrays by applying the given `Order` to each element in the arrays.\n * If all elements are equal, the arrays are then compared based on their length.\n * It is useful when you need to compare two arrays of the same type and you have a specific way of comparing each element of the array.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const array = <A>(O: Order<A>): Order<ReadonlyArray<A>> =>\n  make((self, that) => {\n    const aLen = self.length\n    const bLen = that.length\n    const len = Math.min(aLen, bLen)\n    for (let i = 0; i < len; i++) {\n      const o = O.compare(self[i], that[i])\n      if (o !== 0) {\n        return o\n      }\n    }\n    return number.compare(aLen, bLen)\n  })\n\n/**\n * This function creates and returns a new `Order` for a struct of values based on the given `Order`s\n * for each property in the struct.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const struct: <R extends { readonly [x: string]: Order<any> }>(\n  fields: R\n) => Order<{ [K in keyof R]: [R[K]] extends [Order<infer A>] ? A : never }> = product_.struct(\n  Product\n)\n\n/**\n * Test whether one value is _strictly less than_ another.\n *\n * @since 1.0.0\n */\nexport const lessThan = <A>(O: Order<A>): {\n  (that: A): (self: A) => boolean\n  (self: A, that: A): boolean\n} => dual(2, (self: A, that: A) => O.compare(self, that) === -1)\n\n/**\n * Test whether one value is _strictly greater than_ another.\n *\n * @since 1.0.0\n */\nexport const greaterThan = <A>(O: Order<A>): {\n  (that: A): (self: A) => boolean\n  (self: A, that: A): boolean\n} => dual(2, (self: A, that: A) => O.compare(self, that) === 1)\n\n/**\n * Test whether one value is _non-strictly less than_ another.\n *\n * @since 1.0.0\n */\nexport const lessThanOrEqualTo = <A>(O: Order<A>): {\n  (that: A): (self: A) => boolean\n  (self: A, that: A): boolean\n} => dual(2, (self: A, that: A) => O.compare(self, that) !== 1)\n\n/**\n * Test whether one value is _non-strictly greater than_ another.\n *\n * @since 1.0.0\n */\nexport const greaterThanOrEqualTo = <A>(O: Order<A>): {\n  (that: A): (self: A) => boolean\n  (self: A, that: A): boolean\n} => dual(2, (self: A, that: A) => O.compare(self, that) !== -1)\n\n/**\n * Take the minimum of two values. If they are considered equal, the first argument is chosen.\n *\n * @since 1.0.0\n */\nexport const min = <A>(O: Order<A>): {\n  (that: A): (self: A) => A\n  (self: A, that: A): A\n} => dual(2, (self: A, that: A) => self === that || O.compare(self, that) < 1 ? self : that)\n\n/**\n * Take the maximum of two values. If they are considered equal, the first argument is chosen.\n *\n * @since 1.0.0\n */\nexport const max = <A>(O: Order<A>): {\n  (that: A): (self: A) => A\n  (self: A, that: A): A\n} => dual(2, (self: A, that: A) => self === that || O.compare(self, that) > -1 ? self : that)\n\n/**\n * Clamp a value between a minimum and a maximum.\n *\n * @since 1.0.0\n */\nexport const clamp = <A>(O: Order<A>): {\n  (minimum: A, maximum: A): (self: A) => A\n  (self: A, minimum: A, maximum: A): A\n} =>\n  dual(\n    3,\n    (self: A, minimum: A, maximum: A): A => min(O)(maximum, max(O)(minimum, self))\n  )\n\n/**\n * Test whether a value is between a minimum and a maximum (inclusive).\n *\n * @since 1.0.0\n */\nexport const between = <A>(O: Order<A>): {\n  (minimum: A, maximum: A): (self: A) => boolean\n  (self: A, minimum: A, maximum: A): boolean\n} =>\n  dual(\n    3,\n    (self: A, minimum: A, maximum: A): boolean =>\n      !lessThan(O)(self, minimum) && !greaterThan(O)(self, maximum)\n  )\n"
  },
  {
    "path": "src/typeclass/Pointed.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\nimport type { Of } from \"@fp-ts/core/typeclass/Of\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Pointed<F extends TypeLambda> extends Covariant<F>, Of<F> {}\n"
  },
  {
    "path": "src/typeclass/Product.ts",
    "content": "/**\n * @since 1.0.0\n */\n\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Of } from \"@fp-ts/core/typeclass/Of\"\nimport type { SemiProduct } from \"@fp-ts/core/typeclass/SemiProduct\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Product<F extends TypeLambda> extends SemiProduct<F>, Of<F> {\n  readonly productAll: <R, O, E, A>(\n    collection: Iterable<Kind<F, R, O, E, A>>\n  ) => Kind<F, R, O, E, Array<A>>\n}\n\n/**\n * @since 1.0.0\n */\nexport const tuple = <F extends TypeLambda>(F: Product<F>) =>\n  <T extends ReadonlyArray<Kind<F, any, any, any, any>>>(...elements: T): Kind<\n    F,\n    ([T[number]] extends [Kind<F, infer R, any, any, any>] ? R : never),\n    ([T[number]] extends [Kind<F, any, infer O, any, any>] ? O : never),\n    ([T[number]] extends [Kind<F, any, any, infer E, any>] ? E : never),\n    { [I in keyof T]: [T[I]] extends [Kind<F, any, any, any, infer A>] ? A : never }\n  > => F.productAll(elements) as any\n\n/**\n * @since 1.0.0\n */\nexport const struct = <F extends TypeLambda>(F: Product<F>) =>\n  <R extends { readonly [x: string]: Kind<F, any, any, any, any> }>(fields: R): Kind<\n    F,\n    ([R[keyof R]] extends [Kind<F, infer R, any, any, any>] ? R : never),\n    ([R[keyof R]] extends [Kind<F, any, infer O, any, any>] ? O : never),\n    ([R[keyof R]] extends [Kind<F, any, any, infer E, any>] ? E : never),\n    { [K in keyof R]: [R[K]] extends [Kind<F, any, any, any, infer A>] ? A : never }\n  > => {\n    const keys = Object.keys(fields)\n    return F.imap(F.productAll(keys.map(k => fields[k])), values => {\n      const out: any = {}\n      for (let i = 0; i < values.length; i++) {\n        out[keys[i]] = values[i]\n      }\n      return out\n    }, (r) => keys.map(k => r[k]))\n  }\n"
  },
  {
    "path": "src/typeclass/SemiAlternative.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\nimport type { SemiCoproduct } from \"@fp-ts/core/typeclass/SemiCoproduct\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface SemiAlternative<F extends TypeLambda> extends SemiCoproduct<F>, Covariant<F> {}\n"
  },
  {
    "path": "src/typeclass/SemiApplicative.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual, identity, SK } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport type { SemiProduct } from \"@fp-ts/core/typeclass/SemiProduct\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface SemiApplicative<F extends TypeLambda> extends SemiProduct<F>, Covariant<F> {}\n\n/**\n * Lift a `Semigroup` into 'F', the inner values are combined using the provided `Semigroup`.\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const getSemigroup = <F extends TypeLambda>(F: SemiApplicative<F>) =>\n  <A, R, O, E>(S: Semigroup<A>): Semigroup<Kind<F, R, O, E, A>> =>\n    semigroup.make(\n      (self, that) => F.map(F.product(self, that), ([a1, a2]) => S.combine(a1, a2)),\n      (self, collection) =>\n        F.map(F.productMany(self, collection), ([head, ...tail]) => S.combineMany(head, tail))\n    )\n\n/**\n * Zips two `F` values together using a provided function, returning a new `F` of the result.\n *\n * @param self - The left-hand side of the zip operation\n * @param that - The right-hand side of the zip operation\n * @param f - The function used to combine the values of the two `Option`s\n *\n * @since 1.0.0\n */\nexport const zipWith = <F extends TypeLambda>(F: SemiApplicative<F>): {\n  <R2, O2, E2, B, A, C>(\n    that: Kind<F, R2, O2, E2, B>,\n    f: (a: A, b: B) => C\n  ): <R1, O1, E1>(self: Kind<F, R1, O1, E1, A>) => Kind<F, R1 & R2, O2 | O1, E2 | E1, C>\n  <R1, O1, E1, A, R2, O2, E2, B, C>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>,\n    f: (a: A, b: B) => C\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, C>\n} =>\n  dual(\n    3,\n    <R1, O1, E1, A, R2, O2, E2, B, C>(\n      self: Kind<F, R1, O1, E1, A>,\n      that: Kind<F, R2, O2, E2, B>,\n      f: (a: A, b: B) => C\n    ): Kind<F, R1 & R2, O1 | O2, E1 | E2, C> => F.map(F.product(self, that), ([a, b]) => f(a, b))\n  )\n\n/**\n * @since 1.0.0\n */\nexport const ap = <F extends TypeLambda>(F: SemiApplicative<F>): {\n  <R2, O2, E2, A>(\n    that: Kind<F, R2, O2, E2, A>\n  ): <R1, O1, E1, B>(\n    self: Kind<F, R1, O1, E1, (a: A) => B>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, B>\n  <R1, O1, E1, A, B, R2, O2, E2>(\n    self: Kind<F, R1, O1, E1, (a: A) => B>,\n    that: Kind<F, R2, O2, E2, A>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, B>\n} =>\n  dual(2, <R1, O1, E1, A, B, R2, O2, E2>(\n    self: Kind<F, R1, O1, E1, (a: A) => B>,\n    that: Kind<F, R2, O2, E2, A>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, B> => zipWith(F)(self, that, (f, a) => f(a)))\n\n/**\n * @since 1.0.0\n */\nexport const andThenDiscard = <F extends TypeLambda>(F: SemiApplicative<F>): {\n  <R2, O2, E2, _>(\n    that: Kind<F, R2, O2, E2, _>\n  ): <R1, O1, E1, A>(self: Kind<F, R1, O1, E1, A>) => Kind<F, R1 & R2, O2 | O1, E2 | E1, A>\n  <R1, O1, E1, A, R2, O2, E2, _>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, _>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, A>\n} =>\n  dual(2, <R1, O1, E1, A, R2, O2, E2, _>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, _>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, A> => zipWith(F)(self, that, identity))\n\n/**\n * @since 1.0.0\n */\nexport const andThen = <F extends TypeLambda>(F: SemiApplicative<F>): {\n  <R2, O2, E2, B>(\n    that: Kind<F, R2, O2, E2, B>\n  ): <R1, O1, E1, _>(self: Kind<F, R1, O1, E1, _>) => Kind<F, R1 & R2, O2 | O1, E2 | E1, B>\n  <R1, O1, E1, _, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, _>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, B>\n} =>\n  dual(2, <R1, O1, E1, _, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, _>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, B> => zipWith(F)(self, that, SK))\n\n/**\n * Lifts a binary function into `F`.\n *\n * @param f - The function to lift.\n *\n * @category lifting\n * @since 1.0.0\n */\nexport const lift2 = <F extends TypeLambda>(F: SemiApplicative<F>) =>\n  <A, B, C>(f: (a: A, b: B) => C): {\n    <R2, O2, E2>(\n      that: Kind<F, R2, O2, E2, B>\n    ): <R1, O1, E1>(self: Kind<F, R1, O1, E1, A>) => Kind<F, R1 & R2, O2 | O1, E2 | E1, C>\n    <R1, O1, E1, R2, O2, E2>(\n      self: Kind<F, R1, O1, E1, A>,\n      that: Kind<F, R2, O2, E2, B>\n    ): Kind<F, R1 & R2, O1 | O2, E1 | E2, C>\n  } =>\n    dual(2, <R1, O1, E1, R2, O2, E2>(\n      self: Kind<F, R1, O1, E1, A>,\n      that: Kind<F, R2, O2, E2, B>\n    ): Kind<F, R1 & R2, O1 | O2, E1 | E2, C> => zipWith(F)(self, that, f))\n"
  },
  {
    "path": "src/typeclass/SemiCoproduct.ts",
    "content": "/**\n * @since 1.0.0\n */\n\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Invariant } from \"@fp-ts/core/typeclass/Invariant\"\nimport type { Semigroup } from \"@fp-ts/core/typeclass/Semigroup\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface SemiCoproduct<F extends TypeLambda> extends Invariant<F> {\n  readonly coproduct: <R1, O1, E1, A, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>\n  ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, A | B>\n\n  readonly coproductMany: <R, O, E, A>(\n    self: Kind<F, R, O, E, A>,\n    collection: Iterable<Kind<F, R, O, E, A>>\n  ) => Kind<F, R, O, E, A>\n}\n\n/**\n * @since 1.0.0\n */\nexport const getSemigroup = <F extends TypeLambda>(F: SemiCoproduct<F>) =>\n  <R, O, E, A>(): Semigroup<Kind<F, R, O, E, A>> => ({\n    combine: F.coproduct,\n    combineMany: F.coproductMany\n  })\n"
  },
  {
    "path": "src/typeclass/SemiProduct.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\nimport type { Invariant } from \"@fp-ts/core/typeclass/Invariant\"\nimport type { SemiApplicative } from \"@fp-ts/core/typeclass/SemiApplicative\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface SemiProduct<F extends TypeLambda> extends Invariant<F> {\n  readonly product: <R1, O1, E1, A, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>\n  ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, [A, B]>\n\n  readonly productMany: <R, O, E, A>(\n    self: Kind<F, R, O, E, A>,\n    collection: Iterable<Kind<F, R, O, E, A>>\n  ) => Kind<F, R, O, E, [A, ...Array<A>]>\n}\n\n/**\n * Returns a default `productMany` implementation.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const productMany = <F extends TypeLambda>(\n  map: Covariant<F>[\"map\"],\n  product: SemiProduct<F>[\"product\"]\n): SemiProduct<F>[\"productMany\"] =>\n  <R, O, E, A>(\n    self: Kind<F, R, O, E, A>,\n    collection: Iterable<Kind<F, R, O, E, A>>\n  ) => {\n    let out = map(self, (a): [A, ...Array<A>] => [a])\n    for (const fa of collection) {\n      out = map(\n        product(out, fa),\n        ([[head, ...tail], a]): [A, ...Array<A>] => [head, ...tail, a]\n      )\n    }\n    return out\n  }\n\n/**\n * Returns a default `product` composition.\n *\n * @since 1.0.0\n */\nexport const productComposition = <F extends TypeLambda, G extends TypeLambda>(\n  F: SemiApplicative<F>,\n  G: SemiProduct<G>\n) =>\n  <FR1, FO1, FE1, GR1, GO1, GE1, A, FR2, FO2, FE2, GR2, GO2, GE2, B>(\n    self: Kind<F, FR1, FO1, FE1, Kind<G, GR1, GO1, GE1, A>>,\n    that: Kind<F, FR2, FO2, FE2, Kind<G, GR2, GO2, GE2, B>>\n  ): Kind<\n    F,\n    FR1 & FR2,\n    FO1 | FO2,\n    FE1 | FE2,\n    Kind<G, GR1 & GR2, GO1 | GO2, GE1 | GE2, [A, B]>\n  > => F.map(F.product(self, that), ([ga, gb]) => G.product(ga, gb))\n\n/**\n * Returns a default `productMany` composition.\n *\n * @since 1.0.0\n */\nexport const productManyComposition = <F extends TypeLambda, G extends TypeLambda>(\n  F: SemiApplicative<F>,\n  G: SemiProduct<G>\n) =>\n  <FR, FO, FE, GR, GO, GE, A>(\n    self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,\n    collection: Iterable<Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>>\n  ): Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, [A, ...Array<A>]>> =>\n    F.map(F.productMany(self, collection), ([ga, ...gas]) => G.productMany(ga, gas))\n\n/**\n * @category do notation\n * @since 1.0.0\n */\nexport const andThenBind = <F extends TypeLambda>(F: SemiProduct<F>): {\n  <N extends string, A extends object, R2, O2, E2, B>(\n    name: Exclude<N, keyof A>,\n    that: Kind<F, R2, O2, E2, B>\n  ): <R1, O1, E1>(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n  <R1, O1, E1, A extends object, N extends string, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    name: Exclude<N, keyof A>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n} =>\n  dual(3, <R1, O1, E1, A extends object, N extends string, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    name: Exclude<N, keyof A>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }> =>\n    F.imap(\n      F.product(self, that),\n      ([a, b]) => Object.assign({}, a, { [name]: b }) as any,\n      ({ [name]: b, ...rest }) => [rest, b] as any\n    ))\n\n/**\n * Appends an element to the end of a tuple.\n *\n * @since 1.0.0\n */\nexport const appendElement = <F extends TypeLambda>(F: SemiProduct<F>): {\n  <R2, O2, E2, B>(\n    that: Kind<F, R2, O2, E2, B>\n  ): <R1, O1, E1, A extends ReadonlyArray<any>>(\n    self: Kind<F, R1, O1, E1, A>\n  ) => Kind<F, R1 & R2, O2 | O1, E2 | E1, [...A, B]>\n  <R1, O1, E1, A extends ReadonlyArray<any>, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, [...A, B]>\n} =>\n  dual(2, <R1, O1, E1, A extends ReadonlyArray<any>, R2, O2, E2, B>(\n    self: Kind<F, R1, O1, E1, A>,\n    that: Kind<F, R2, O2, E2, B>\n  ): Kind<F, R1 & R2, O1 | O2, E1 | E2, [...A, B]> =>\n    F.imap(F.product(self, that), ([a, b]) => [...a, b], ab =>\n      [ab.slice(0, -1), ab[ab.length - 1]] as any))\n\n/**\n * @since 1.0.0\n */\nexport const nonEmptyTuple = <F extends TypeLambda>(F: SemiProduct<F>) =>\n  <T extends readonly [Kind<F, any, any, any, any>, ...Array<Kind<F, any, any, any, any>>]>(\n    ...elements: T\n  ): Kind<\n    F,\n    ([T[number]] extends [Kind<F, infer R, any, any, any>] ? R : never),\n    ([T[number]] extends [Kind<F, any, infer O, any, any>] ? O : never),\n    ([T[number]] extends [Kind<F, any, any, infer E, any>] ? E : never),\n    { [I in keyof T]: [T[I]] extends [Kind<F, any, any, any, infer A>] ? A : never }\n  > => F.productMany(elements[0], elements.slice(1)) as any\n\ntype EnforceNonEmptyRecord<R> = keyof R extends never ? never : R\n\n/**\n * @since 1.0.0\n */\nexport const nonEmptyStruct = <F extends TypeLambda>(F: SemiProduct<F>) =>\n  <R extends { readonly [x: string]: Kind<F, any, any, any, any> }>(\n    fields: EnforceNonEmptyRecord<R> & { readonly [x: string]: Kind<F, any, any, any, any> }\n  ): Kind<\n    F,\n    ([R[keyof R]] extends [Kind<F, infer R, any, any, any>] ? R : never),\n    ([R[keyof R]] extends [Kind<F, any, infer O, any, any>] ? O : never),\n    ([R[keyof R]] extends [Kind<F, any, any, infer E, any>] ? E : never),\n    { [K in keyof R]: [R[K]] extends [Kind<F, any, any, any, infer A>] ? A : never }\n  > => {\n    const keys = Object.keys(fields)\n    return F.imap(\n      F.productMany(fields[keys[0]], keys.slice(1).map(k => fields[k])),\n      ([value, ...values]) => {\n        const out: any = { [keys[0]]: value }\n        for (let i = 0; i < values.length; i++) {\n          out[keys[i + 1]] = values[i]\n        }\n        return out\n      },\n      (r) => keys.map(k => r[k]) as any\n    )\n  }\n"
  },
  {
    "path": "src/typeclass/Semigroup.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport { fromIterable } from \"@fp-ts/core/internal/ReadonlyArray\"\nimport * as readonlyArray from \"@fp-ts/core/internal/ReadonlyArray\"\nimport type * as invariant from \"@fp-ts/core/typeclass/Invariant\"\nimport type { Order } from \"@fp-ts/core/typeclass/Order\"\nimport * as product_ from \"@fp-ts/core/typeclass/Product\"\nimport type * as semiProduct from \"@fp-ts/core/typeclass/SemiProduct\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Semigroup<A> {\n  readonly combine: (self: A, that: A) => A\n  readonly combineMany: (self: A, collection: Iterable<A>) => A\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface SemigroupTypeLambda extends TypeLambda {\n  readonly type: Semigroup<this[\"Target\"]>\n}\n\n/**\n * @param combineMany - Useful when `combineMany` can be optimised\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const make = <A>(\n  combine: Semigroup<A>[\"combine\"],\n  combineMany: Semigroup<A>[\"combineMany\"] = (self, collection) =>\n    fromIterable(collection).reduce(combine, self)\n): Semigroup<A> => ({\n  combine,\n  combineMany\n})\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const string: Semigroup<string> = make((self, that) => self + that)\n\n/**\n * `number` semigroup under addition.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const numberSum: Semigroup<number> = make((self, that) => self + that)\n\n/**\n * `number` semigroup under multiplication.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const numberMultiply: Semigroup<number> = make(\n  (self, that) => self * that,\n  (self, collection) => {\n    if (self === 0) {\n      return 0\n    }\n    let out = self\n    for (const n of collection) {\n      if (n === 0) {\n        return 0\n      }\n      out = out * n\n    }\n    return out\n  }\n)\n\n/**\n * `bigint` semigroup under addition.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const bigintSum: Semigroup<bigint> = make((self, that) => self + that)\n\n/**\n * `bigint` semigroup under multiplication.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const bigintMultiply: Semigroup<bigint> = make(\n  (self, that) => self * that,\n  (self, collection) => {\n    if (self === 0n) {\n      return 0n\n    }\n    let out = self\n    for (const n of collection) {\n      if (n === 0n) {\n        return 0n\n      }\n      out = out * n\n    }\n    return out\n  }\n)\n\n/**\n * `boolean` semigroup under conjunction.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const booleanAll: Semigroup<boolean> = make(\n  (self, that) => self && that,\n  (self, collection) => {\n    if (self === false) {\n      return false\n    }\n    for (const b of collection) {\n      if (b === false) {\n        return false\n      }\n    }\n    return true\n  }\n)\n\n/**\n * `boolean` semigroup under disjunction.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const booleanAny: Semigroup<boolean> = make(\n  (self, that) => self || that,\n  (self, collection) => {\n    if (self === true) {\n      return true\n    }\n    for (const b of collection) {\n      if (b === true) {\n        return true\n      }\n    }\n    return false\n  }\n)\n\n/**\n * `boolean` semigroup under exclusive disjunction.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const booleanXor: Semigroup<boolean> = make((self, that) => self !== that)\n\n/**\n * `boolean` semigroup under equivalence.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const booleanEqv: Semigroup<boolean> = make((self, that) => self === that)\n\n/**\n * `Semigroup` that returns last minimum of elements.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const min = <A>(O: Order<A>): Semigroup<A> =>\n  make((self, that) => O.compare(self, that) === -1 ? self : that)\n\n/**\n * `Semigroup` that returns last maximum of elements.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const max = <A>(O: Order<A>): Semigroup<A> =>\n  make((self, that) => O.compare(self, that) === 1 ? self : that)\n\n/**\n * @category constructors\n * @since 1.0.0\n */\nexport const constant = <A>(a: A): Semigroup<A> => make(() => a, () => a)\n\n/**\n * The dual of a `Semigroup`, obtained by flipping the arguments of `combine`.\n *\n * @since 1.0.0\n */\nexport const reverse = <A>(S: Semigroup<A>): Semigroup<A> =>\n  make(\n    (self, that) => S.combine(that, self),\n    (self, collection) => {\n      const reversed = Array.from(collection).reverse()\n      return reversed.length > 0 ?\n        S.combine(S.combineMany(reversed[0], reversed.slice(1)), self) :\n        self\n    }\n  )\n\n/**\n * @since 1.0.0\n */\nexport const intercalate: {\n  <A>(separator: A): (S: Semigroup<A>) => Semigroup<A>\n  <A>(S: Semigroup<A>, separator: A): Semigroup<A>\n} = dual(\n  2,\n  <A>(S: Semigroup<A>, separator: A): Semigroup<A> =>\n    make((self, that) => S.combineMany(self, [separator, that]))\n)\n\n/**\n * Always return the first argument.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const first = <A = never>(): Semigroup<A> => make((a) => a, (a) => a)\n\n/**\n * Always return the last argument.\n *\n * @category instances\n * @since 1.0.0\n */\nexport const last = <A = never>(): Semigroup<A> =>\n  make(\n    (_, second) => second,\n    (self, collection) => {\n      let a: A = self\n      // eslint-disable-next-line no-empty\n      for (a of collection) {}\n      return a\n    }\n  )\n\n/**\n * @since 1.0.0\n */\nexport const imap: {\n  <A, B>(to: (a: A) => B, from: (b: B) => A): (self: Semigroup<A>) => Semigroup<B>\n  <A, B>(self: Semigroup<A>, to: (a: A) => B, from: (b: B) => A): Semigroup<B>\n} = dual(3, <A, B>(S: Semigroup<A>, to: (a: A) => B, from: (b: B) => A): Semigroup<B> =>\n  make(\n    (self, that) => to(S.combine(from(self), from(that))),\n    (self, collection) => to(S.combineMany(from(self), (fromIterable(collection)).map(from)))\n  ))\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Invariant: invariant.Invariant<SemigroupTypeLambda> = {\n  imap\n}\n\nconst product = <A, B>(self: Semigroup<A>, that: Semigroup<B>): Semigroup<[A, B]> =>\n  make(([xa, xb], [ya, yb]) => [self.combine(xa, ya), that.combine(xb, yb)])\n\nconst productAll = <A>(collection: Iterable<Semigroup<A>>): Semigroup<Array<A>> => {\n  const semigroups = readonlyArray.fromIterable(collection)\n  return make((x, y) => {\n    const len = Math.min(x.length, y.length, semigroups.length)\n    const out: Array<A> = []\n    for (let i = 0; i < len; i++) {\n      out.push(semigroups[i].combine(x[i], y[i]))\n    }\n    return out\n  })\n}\n\nconst productMany = <A>(\n  self: Semigroup<A>,\n  collection: Iterable<Semigroup<A>>\n): Semigroup<[A, ...Array<A>]> => {\n  const semigroup = productAll(collection)\n  return make((x, y) => [self.combine(x[0], y[0]), ...semigroup.combine(x.slice(1), y.slice(1))])\n}\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const SemiProduct: semiProduct.SemiProduct<SemigroupTypeLambda> = {\n  imap,\n  product,\n  productMany\n}\n\nconst of: <A>(a: A) => Semigroup<A> = constant\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const Product: product_.Product<SemigroupTypeLambda> = {\n  of,\n  imap,\n  product,\n  productMany,\n  productAll\n}\n\n/**\n * Similar to `Promise.all` but operates on `Semigroup`s.\n *\n * ```\n * [Semigroup<A>, Semigroup<B>, ...] -> Semigroup<[A, B, ...]>\n * ```\n *\n * This function creates and returns a new `Semigroup` for a tuple of values based on the given `Semigroup`s for each element in the tuple.\n * The returned `Semigroup` combines two tuples of the same type by applying the corresponding `Semigroup` passed as arguments to each element in the tuple.\n *\n * It is useful when you need to combine two tuples of the same type and you have a specific way of combining each element of the tuple.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const tuple: <T extends ReadonlyArray<Semigroup<any>>>(\n  ...elements: T\n) => Semigroup<{ readonly [I in keyof T]: [T[I]] extends [Semigroup<infer A>] ? A : never }> =\n  product_.tuple(Product)\n\n/**\n * Given a type `A`, this function creates and returns a `Semigroup` for `ReadonlyArray<A>`.\n * The returned `Semigroup` combines two arrays by concatenating them.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const array = <A>(): Semigroup<ReadonlyArray<A>> => make((self, that) => self.concat(that))\n\n/**\n * This function creates and returns a new `Semigroup` for a struct of values based on the given `Semigroup`s for each property in the struct.\n * The returned `Semigroup` combines two structs of the same type by applying the corresponding `Semigroup` passed as arguments to each property in the struct.\n *\n * It is useful when you need to combine two structs of the same type and you have a specific way of combining each property of the struct.\n *\n * @category combinators\n * @since 1.0.0\n */\nexport const struct: <R extends { readonly [x: string]: Semigroup<any> }>(\n  fields: R\n) => Semigroup<{ readonly [K in keyof R]: [R[K]] extends [Semigroup<infer A>] ? A : never }> =\n  product_.struct(Product)\n"
  },
  {
    "path": "src/typeclass/Traversable.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Applicative } from \"@fp-ts/core/typeclass/Applicative\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Traversable<T extends TypeLambda> extends TypeClass<T> {\n  readonly traverse: <F extends TypeLambda>(\n    F: Applicative<F>\n  ) => {\n    <A, R, O, E, B>(\n      f: (a: A) => Kind<F, R, O, E, B>\n    ): <TR, TO, TE>(self: Kind<T, TR, TO, TE, A>) => Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n    <TR, TO, TE, A, R, O, E, B>(\n      self: Kind<T, TR, TO, TE, A>,\n      f: (a: A) => Kind<F, R, O, E, B>\n    ): Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n  }\n}\n\n/**\n * Returns a default binary `traverse` composition.\n *\n * @since 1.0.0\n */\nexport const traverseComposition = <T extends TypeLambda, G extends TypeLambda>(\n  T: Traversable<T>,\n  G: Traversable<G>\n) =>\n  <F extends TypeLambda>(F: Applicative<F>) =>\n    <TR, TO, TE, GR, GO, GE, A, R, O, E, B>(\n      self: Kind<T, TR, TO, TE, Kind<G, GR, GO, GE, A>>,\n      f: (a: A) => Kind<F, R, O, E, B>\n    ): Kind<F, R, O, E, Kind<T, TR, TO, TE, Kind<G, GR, GO, GE, B>>> =>\n      T.traverse(F)(self, G.traverse(F)(f))\n\n/**\n * Returns a default `sequence` implementation.\n *\n * @since 1.0.0\n */\nexport const sequence = <T extends TypeLambda>(T: Traversable<T>) =>\n  <F extends TypeLambda>(F: Applicative<F>) =>\n    <TR, TO, TE, R, O, E, A>(\n      self: Kind<T, TR, TO, TE, Kind<F, R, O, E, A>>\n    ): Kind<F, R, O, E, Kind<T, TR, TO, TE, A>> => T.traverse(F)(self, identity)\n\n/**\n * Given a function which returns a `F` effect, thread this effect\n * through the running of this function on all the values in `T`,\n * returning an `T<A>` in a `F` context, ignoring the values\n * returned by the provided function.\n *\n * @since 1.0.0\n */\nexport const traverseTap = <T extends TypeLambda>(T: Traversable<T>) =>\n  <F extends TypeLambda>(F: Applicative<F>): {\n    <A, R, O, E, B>(\n      f: (a: A) => Kind<F, R, O, E, B>\n    ): <TR, TO, TE>(self: Kind<T, TR, TO, TE, A>) => Kind<F, R, O, E, Kind<T, TR, TO, TE, A>>\n    <TR, TO, TE, A, R, O, E, B>(\n      self: Kind<T, TR, TO, TE, A>,\n      f: (a: A) => Kind<F, R, O, E, B>\n    ): Kind<F, R, O, E, Kind<T, TR, TO, TE, A>>\n  } =>\n    dual(2, <TR, TO, TE, A, R, O, E, B>(\n      self: Kind<T, TR, TO, TE, A>,\n      f: (a: A) => Kind<F, R, O, E, B>\n    ): Kind<F, R, O, E, Kind<T, TR, TO, TE, A>> => T.traverse(F)(self, a => F.map(f(a), () => a)))\n"
  },
  {
    "path": "src/typeclass/TraversableFilterable.ts",
    "content": "/**\n * `TraversableFilterable` represents data structures which can be _partitioned_ with effects in some `Applicative` functor.\n *\n * @since 1.0.0\n */\nimport type { Either } from \"@fp-ts/core/Either\"\nimport * as E from \"@fp-ts/core/Either\"\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Option } from \"@fp-ts/core/Option\"\nimport * as O from \"@fp-ts/core/Option\"\nimport type { TraversableFilterable } from \"@fp-ts/core/ReadonlyArray\"\nimport type { Applicative } from \"@fp-ts/core/typeclass/Applicative\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\nimport * as filterable from \"@fp-ts/core/typeclass/Filterable\"\nimport type { Filterable } from \"@fp-ts/core/typeclass/Filterable\"\nimport type { Traversable } from \"@fp-ts/core/typeclass/Traversable\"\n\n/**\n * @category models\n * @since 1.0.0\n */\nexport interface TraversableFilterable<T extends TypeLambda> extends TypeClass<T> {\n  readonly traversePartitionMap: <F extends TypeLambda>(\n    F: Applicative<F>\n  ) => {\n    <A, R, O, E, B, C>(\n      f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n    ): <TR, TO, TE>(\n      self: Kind<T, TR, TO, TE, A>\n    ) => Kind<F, R, O, E, [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, C>]>\n    <TR, TO, TE, A, R, O, E, B, C>(\n      self: Kind<T, TR, TO, TE, A>,\n      f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n    ): Kind<F, R, O, E, [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, C>]>\n  }\n\n  readonly traverseFilterMap: <F extends TypeLambda>(\n    F: Applicative<F>\n  ) => {\n    <A, R, O, E, B>(\n      f: (a: A) => Kind<F, R, O, E, Option<B>>\n    ): <TR, TO, TE>(self: Kind<T, TR, TO, TE, A>) => Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n    <TR, TO, TE, A, R, O, E, B>(\n      self: Kind<T, TR, TO, TE, A>,\n      f: (a: A) => Kind<F, R, O, E, Option<B>>\n    ): Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n  }\n}\n\n/**\n * Returns a default binary `traversePartitionMap` implementation.\n *\n * @since 1.0.0\n */\nexport const traversePartitionMap = <T extends TypeLambda>(\n  T: Traversable<T> & Covariant<T> & Filterable<T>\n): <F extends TypeLambda>(\n  F: Applicative<F>\n) => <TR, TO, TE, A, R, O, E, B, C>(\n  self: Kind<T, TR, TO, TE, A>,\n  f: (a: A) => Kind<F, R, O, E, Either<B, C>>\n) => Kind<F, R, O, E, [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, C>]> =>\n  (F) => (self, f) => F.map(T.traverse(F)(self, f), filterable.separate(T))\n\n/**\n * Returns a default binary `traverseFilterMap` implementation.\n *\n * @since 1.0.0\n */\nexport const traverseFilterMap = <T extends TypeLambda>(\n  T: Traversable<T> & Filterable<T>\n): <F extends TypeLambda>(\n  F: Applicative<F>\n) => <TR, TO, TE, A, R, O, E, B>(\n  self: Kind<T, TR, TO, TE, A>,\n  f: (a: A) => Kind<F, R, O, E, Option<B>>\n) => Kind<F, R, O, E, Kind<T, TR, TO, TE, B>> =>\n  (F) => (self, f) => F.map(T.traverse(F)(self, f), filterable.compact(T))\n\n/**\n * @since 1.0.0\n */\nexport const traverseFilter = <T extends TypeLambda>(\n  T: TraversableFilterable<T>\n) =>\n  <F extends TypeLambda>(\n    F: Applicative<F>\n  ): {\n    <B extends A, R, O, E, A = B>(\n      predicate: (a: A) => Kind<F, R, O, E, boolean>\n    ): <TR, TO, TE>(\n      self: Kind<T, TR, TO, TE, B>\n    ) => Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n    <TR, TO, TE, B extends A, R, O, E, A = B>(\n      self: Kind<T, TR, TO, TE, B>,\n      predicate: (a: A) => Kind<F, R, O, E, boolean>\n    ): Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n  } =>\n    dual(2, <TR, TO, TE, B extends A, R, O, E, A = B>(\n      self: Kind<T, TR, TO, TE, B>,\n      predicate: (a: A) => Kind<F, R, O, E, boolean>\n    ): Kind<F, R, O, E, Kind<T, TR, TO, TE, B>> =>\n      T.traverseFilterMap(F)(self, (b) =>\n        F.map(predicate(b), (keep) => (keep ? O.some(b) : O.none()))))\n\n/**\n * @since 1.0.0\n */\nexport const traversePartition = <T extends TypeLambda>(\n  T: TraversableFilterable<T>\n) =>\n  <F extends TypeLambda>(\n    F: Applicative<F>\n  ): {\n    <B extends A, R, O, E, A = B>(\n      predicate: (a: A) => Kind<F, R, O, E, boolean>\n    ): <TR, TO, TE>(\n      self: Kind<T, TR, TO, TE, B>\n    ) => Kind<F, R, O, E, [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, B>]>\n    <TR, TO, TE, B extends A, R, O, E, A = B>(\n      self: Kind<T, TR, TO, TE, B>,\n      predicate: (a: A) => Kind<F, R, O, E, boolean>\n    ): Kind<F, R, O, E, [Kind<T, TR, TO, TE, B>, Kind<T, TR, TO, TE, B>]>\n  } =>\n    dual(2, (self, predicate) =>\n      T.traversePartitionMap(F)(self, (b) =>\n        F.map(predicate(b), (keep) => (keep ? E.right(b) : E.left(b)))))\n"
  },
  {
    "path": "test/Bigint.ts",
    "content": "import * as Bigint from \"@fp-ts/core/Bigint\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport { deepStrictEqual } from \"@fp-ts/core/test/util\"\n\ndescribe.concurrent(\"Bigint\", () => {\n  it(\"exports\", () => {\n    expect(Bigint.SemigroupMax).exists\n    expect(Bigint.SemigroupMin).exists\n    expect(Bigint.sumAll).exists\n    expect(Bigint.multiplyAll).exists\n    expect(Bigint.lessThan).exists\n    expect(Bigint.lessThanOrEqualTo).exists\n    expect(Bigint.greaterThan).exists\n    expect(Bigint.greaterThanOrEqualTo).exists\n    expect(Bigint.between).exists\n    expect(Bigint.clamp).exists\n    expect(Bigint.min).exists\n    expect(Bigint.max).exists\n  })\n\n  it(\"sign\", () => {\n    assert.deepStrictEqual(Bigint.sign(-5n), -1)\n    assert.deepStrictEqual(Bigint.sign(0n), 0)\n    assert.deepStrictEqual(Bigint.sign(5n), 1)\n  })\n\n  it(\"isBigint\", () => {\n    expect(Bigint.isBigint(1n)).toEqual(true)\n    expect(Bigint.isBigint(1)).toEqual(false)\n    expect(Bigint.isBigint(\"a\")).toEqual(false)\n    expect(Bigint.isBigint(true)).toEqual(false)\n  })\n\n  it(\"sum\", () => {\n    deepStrictEqual(pipe(1n, Bigint.sum(2n)), 3n)\n  })\n\n  it(\"multiply\", () => {\n    deepStrictEqual(pipe(2n, Bigint.multiply(3n)), 6n)\n  })\n\n  it(\"subtract\", () => {\n    deepStrictEqual(pipe(3n, Bigint.subtract(1n)), 2n)\n  })\n\n  it(\"divide\", () => {\n    deepStrictEqual(pipe(6n, Bigint.divide(2n)), 3n)\n  })\n\n  it(\"increment\", () => {\n    deepStrictEqual(Bigint.increment(2n), 3n)\n  })\n\n  it(\"decrement\", () => {\n    deepStrictEqual(Bigint.decrement(2n), 1n)\n  })\n\n  it(\"Equivalence\", () => {\n    expect(Bigint.Equivalence(1n, 1n)).toBe(true)\n    expect(Bigint.Equivalence(1n, 2n)).toBe(false)\n  })\n\n  it(\"Order\", () => {\n    deepStrictEqual(Bigint.Order.compare(1n, 2n), -1)\n    deepStrictEqual(Bigint.Order.compare(2n, 1n), 1)\n    deepStrictEqual(Bigint.Order.compare(2n, 2n), 0)\n  })\n\n  it(\"SemigroupSum\", () => {\n    deepStrictEqual(Bigint.SemigroupSum.combine(2n, 3n), 5n)\n  })\n\n  it(\"MonoidSum\", () => {\n    deepStrictEqual(Bigint.MonoidSum.combineAll([1n, 2n, 3n]), 6n)\n  })\n\n  it(\"SemigroupMultiply\", () => {\n    deepStrictEqual(Bigint.SemigroupMultiply.combine(2n, 3n), 6n)\n    deepStrictEqual(Bigint.SemigroupMultiply.combineMany(0n, [1n, 2n, 3n]), 0n)\n    deepStrictEqual(Bigint.SemigroupMultiply.combineMany(2n, [1n, 0n, 3n]), 0n)\n  })\n\n  it(\"MonoidMultiply\", () => {\n    deepStrictEqual(Bigint.MonoidMultiply.combineAll([2n, 3n, 4n]), 24n)\n  })\n})\n"
  },
  {
    "path": "test/Boolean.ts",
    "content": "import * as Boolean from \"@fp-ts/core/Boolean\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport { deepStrictEqual } from \"@fp-ts/core/test/util\"\n\ndescribe.concurrent(\"Boolean\", () => {\n  it(\"exports\", () => {\n    expect(Boolean.SemigroupAll).exist\n    expect(Boolean.MonoidAll).exist\n    expect(Boolean.SemigroupAny).exist\n    expect(Boolean.MonoidAny).exist\n    expect(Boolean.SemigroupXor).exist\n    expect(Boolean.MonoidXor).exist\n    expect(Boolean.SemigroupEqv).exist\n    expect(Boolean.MonoidEqv).exist\n    expect(Boolean.all).exist\n    expect(Boolean.any).exist\n    expect(Boolean.xor).exist\n    expect(Boolean.eqv).exist\n    expect(Boolean.nand).exist\n    expect(Boolean.nor).exist\n    expect(Boolean.implies).exist\n  })\n\n  it(\"isBoolean\", () => {\n    expect(Boolean.isBoolean(true)).toEqual(true)\n    expect(Boolean.isBoolean(false)).toEqual(true)\n    expect(Boolean.isBoolean(\"a\")).toEqual(false)\n    expect(Boolean.isBoolean(1)).toEqual(false)\n  })\n\n  it(\"and\", () => {\n    deepStrictEqual(pipe(true, Boolean.and(true)), true)\n    deepStrictEqual(pipe(true, Boolean.and(false)), false)\n    deepStrictEqual(pipe(false, Boolean.and(true)), false)\n    deepStrictEqual(pipe(false, Boolean.and(false)), false)\n  })\n\n  it(\"nand\", () => {\n    deepStrictEqual(pipe(true, Boolean.nand(true)), false)\n    deepStrictEqual(pipe(true, Boolean.nand(false)), true)\n    deepStrictEqual(pipe(false, Boolean.nand(true)), true)\n    deepStrictEqual(pipe(false, Boolean.nand(false)), true)\n  })\n\n  it(\"or\", () => {\n    deepStrictEqual(pipe(true, Boolean.or(true)), true)\n    deepStrictEqual(pipe(true, Boolean.or(false)), true)\n    deepStrictEqual(pipe(false, Boolean.or(true)), true)\n    deepStrictEqual(pipe(false, Boolean.or(false)), false)\n  })\n\n  it(\"nor\", () => {\n    deepStrictEqual(pipe(true, Boolean.nor(true)), false)\n    deepStrictEqual(pipe(true, Boolean.nor(false)), false)\n    deepStrictEqual(pipe(false, Boolean.nor(true)), false)\n    deepStrictEqual(pipe(false, Boolean.nor(false)), true)\n  })\n\n  it(\"xor\", () => {\n    deepStrictEqual(pipe(true, Boolean.xor(true)), false)\n    deepStrictEqual(pipe(true, Boolean.xor(false)), true)\n    deepStrictEqual(pipe(false, Boolean.xor(true)), true)\n    deepStrictEqual(pipe(false, Boolean.xor(false)), false)\n  })\n\n  it(\"eqv\", () => {\n    deepStrictEqual(pipe(true, Boolean.eqv(true)), true)\n    deepStrictEqual(pipe(true, Boolean.eqv(false)), false)\n    deepStrictEqual(pipe(false, Boolean.eqv(true)), false)\n    deepStrictEqual(pipe(false, Boolean.eqv(false)), true)\n  })\n\n  it(\"implies\", () => {\n    deepStrictEqual(pipe(true, Boolean.implies(true)), true)\n    deepStrictEqual(pipe(true, Boolean.implies(false)), false)\n    deepStrictEqual(pipe(false, Boolean.implies(true)), true)\n    deepStrictEqual(pipe(false, Boolean.implies(false)), true)\n  })\n\n  it(\"not\", () => {\n    deepStrictEqual(pipe(true, Boolean.not), false)\n    deepStrictEqual(pipe(false, Boolean.not), true)\n  })\n\n  describe.concurrent(\"MonoidXor\", () => {\n    it(\"baseline\", () => {\n      deepStrictEqual(Boolean.MonoidXor.combineMany(true, []), true)\n      deepStrictEqual(Boolean.MonoidXor.combineMany(false, []), false)\n      deepStrictEqual(Boolean.MonoidXor.combineMany(false, [true]), true)\n      deepStrictEqual(Boolean.MonoidXor.combineMany(false, [false]), false)\n      deepStrictEqual(Boolean.MonoidXor.combineMany(true, [true]), false)\n      deepStrictEqual(Boolean.MonoidXor.combineMany(true, [false]), true)\n      deepStrictEqual(Boolean.MonoidXor.combineMany(true, [true, false]), false)\n      deepStrictEqual(Boolean.MonoidXor.combineMany(true, [false, true]), false)\n      deepStrictEqual(Boolean.MonoidXor.combineAll([true, false]), true)\n      deepStrictEqual(Boolean.MonoidXor.combineAll([false, true]), true)\n    })\n\n    it(\"should handle iterables\", () => {\n      deepStrictEqual(Boolean.MonoidXor.combineAll(new Set([true, true])), true)\n      deepStrictEqual(Boolean.MonoidXor.combineAll(new Set([true, false])), true)\n      deepStrictEqual(Boolean.MonoidXor.combineAll(new Set([false, false])), false)\n    })\n  })\n\n  describe.concurrent(\"MonoidEqv\", () => {\n    it(\"baseline\", () => {\n      deepStrictEqual(Boolean.MonoidEqv.combineMany(true, []), true)\n      deepStrictEqual(Boolean.MonoidEqv.combineMany(false, []), false)\n      deepStrictEqual(Boolean.MonoidEqv.combineMany(false, [true]), false)\n      deepStrictEqual(Boolean.MonoidEqv.combineMany(false, [false]), true)\n      deepStrictEqual(Boolean.MonoidEqv.combineMany(true, [true]), true)\n      deepStrictEqual(Boolean.MonoidEqv.combineMany(true, [false]), false)\n      deepStrictEqual(Boolean.MonoidEqv.combineMany(true, [true, false]), false)\n      deepStrictEqual(Boolean.MonoidEqv.combineMany(true, [false, true]), false)\n      deepStrictEqual(Boolean.MonoidEqv.combineAll([true, false]), false)\n      deepStrictEqual(Boolean.MonoidEqv.combineAll([false, true]), false)\n    })\n\n    it(\"should handle iterables\", () => {\n      deepStrictEqual(Boolean.MonoidEqv.combineAll(new Set([true, true])), true)\n      deepStrictEqual(Boolean.MonoidEqv.combineAll(new Set([true, false])), false)\n      deepStrictEqual(Boolean.MonoidEqv.combineAll(new Set([false, false])), false)\n    })\n  })\n\n  describe.concurrent(\"MonoidAll\", () => {\n    it(\"baseline\", () => {\n      deepStrictEqual(Boolean.MonoidAll.combineMany(true, [true, true]), true)\n      deepStrictEqual(Boolean.MonoidAll.combineMany(true, [true, false]), false)\n      deepStrictEqual(Boolean.MonoidAll.combineMany(false, [true, false]), false)\n      deepStrictEqual(Boolean.MonoidAll.combineAll([true, true, true]), true)\n      deepStrictEqual(Boolean.MonoidAll.combineAll([true, true, false]), false)\n    })\n\n    it(\"should handle iterables\", () => {\n      deepStrictEqual(Boolean.MonoidAll.combineAll(new Set([true, true])), true)\n      deepStrictEqual(Boolean.MonoidAll.combineAll(new Set([true, false])), false)\n      deepStrictEqual(Boolean.MonoidAll.combineAll(new Set([false, false])), false)\n    })\n  })\n\n  describe.concurrent(\"MonoidAny\", () => {\n    it(\"baseline\", () => {\n      deepStrictEqual(Boolean.MonoidAny.combineMany(true, [true, true]), true)\n      deepStrictEqual(Boolean.MonoidAny.combineMany(true, [true, false]), true)\n      deepStrictEqual(Boolean.MonoidAny.combineMany(false, [false, false]), false)\n      deepStrictEqual(Boolean.MonoidAny.combineAll([true, true, true]), true)\n      deepStrictEqual(Boolean.MonoidAny.combineAll([true, true, false]), true)\n      deepStrictEqual(Boolean.MonoidAny.combineAll([false, false, false]), false)\n    })\n\n    it(\"should handle iterables\", () => {\n      deepStrictEqual(Boolean.MonoidAny.combineAll(new Set([true, true])), true)\n      deepStrictEqual(Boolean.MonoidAny.combineAll(new Set([true, false])), true)\n      deepStrictEqual(Boolean.MonoidAny.combineAll(new Set([false, false])), false)\n    })\n  })\n\n  it(\"match\", () => {\n    const match = Boolean.match(() => \"false\", () => \"true\")\n    deepStrictEqual(match(true), \"true\")\n    deepStrictEqual(match(false), \"false\")\n  })\n\n  it(\"Equivalence\", () => {\n    expect(Boolean.Equivalence(true, true)).toBe(true)\n    expect(Boolean.Equivalence(false, false)).toBe(true)\n    expect(Boolean.Equivalence(true, false)).toBe(false)\n    expect(Boolean.Equivalence(false, true)).toBe(false)\n  })\n\n  it(\"Order\", () => {\n    deepStrictEqual(Boolean.Order.compare(false, true), -1)\n    deepStrictEqual(Boolean.Order.compare(true, false), 1)\n    deepStrictEqual(Boolean.Order.compare(true, true), 0)\n  })\n})\n"
  },
  {
    "path": "test/Either.ts",
    "content": "import * as E from \"@fp-ts/core/Either\"\nimport { flow, identity, pipe } from \"@fp-ts/core/Function\"\nimport { structural } from \"@fp-ts/core/internal/effect\"\nimport * as N from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as S from \"@fp-ts/core/String\"\nimport * as Util from \"@fp-ts/core/test/util\"\n\ndescribe.concurrent(\"Either\", () => {\n  it(\"exports\", () => {\n    expect(E.toOption).exist\n    expect(E.getRight).exist\n    expect(E.getLeft).exist\n\n    expect(E.Invariant).exist\n    expect(E.tupled).exist\n    expect(E.bindTo).exist\n\n    expect(E.Covariant).exist\n    expect(E.map).exist\n    expect(E.let).exist\n    expect(E.flap).exist\n    expect(E.as).exist\n    expect(E.asUnit).exist\n\n    expect(E.Bicovariant).exist\n    expect(E.bimap).exist\n    expect(E.mapLeft).exist\n\n    expect(E.Of).exist\n    expect(E.of).exist\n    expect(E.unit).exist\n    expect(E.Do).exist\n\n    expect(E.Pointed).exist\n\n    expect(E.FlatMap).exist\n    expect(E.flatMap).exist\n    expect(E.flatten).exist\n    expect(E.andThen).exist\n    expect(E.composeKleisliArrow).exist\n\n    expect(E.Chainable).exist\n    expect(E.bind).exist\n    expect(E.tap).exist\n    expect(E.andThenDiscard).exist\n\n    expect(E.Monad).exist\n\n    expect(E.SemiProduct).exist\n\n    expect(E.Product).exist\n    expect(E.all).exist\n    expect(E.tuple).exist\n    expect(E.struct).exist\n\n    expect(E.SemiApplicative).exist\n    expect(E.getFirstLeftSemigroup).exist // liftSemigroup\n    expect(E.lift2).exist\n    expect(E.ap).exist\n    expect(E.andThenDiscard).exist\n    expect(E.andThen).exist\n\n    expect(E.Applicative).exist\n    expect(E.getFirstLeftMonoid).exist // liftMonoid\n\n    expect(E.SemiCoproduct).exist\n    expect(E.getFirstRightSemigroup).exist // getSemigroup\n\n    expect(E.SemiAlternative).exist\n\n    expect(E.Foldable).exist\n\n    expect(E.Traversable).exist\n    expect(E.traverse).exist\n    expect(E.sequence).exist\n    expect(E.traverseTap).exist\n  })\n\n  it(\"structural tracking\", () => {\n    expect(Util.ownKeys(E.left(\"a\"))).toEqual([\"_tag\", \"left\"])\n    expect(Util.ownKeys(E.right(1))).toEqual([\"_tag\", \"right\"])\n\n    expect(Object.prototype.hasOwnProperty.call(E.left(\"a\"), structural)).toEqual(false)\n    expect(Object.prototype.hasOwnProperty.call(E.right(1), structural)).toEqual(false)\n\n    expect(Util.isStructural(E.left(\"a\"))).toEqual(true)\n    expect(Util.isStructural(E.right(1))).toEqual(true)\n  })\n\n  it(\"toRefinement\", () => {\n    const f = (s: string | number): E.Either<string, string> =>\n      typeof s === \"string\" ? E.right(s) : E.left(\"not a string\")\n    const isString = E.toRefinement(f)\n    Util.deepStrictEqual(isString(\"s\"), true)\n    Util.deepStrictEqual(isString(1), false)\n    type A = { readonly type: \"A\" }\n    type B = { readonly type: \"B\" }\n    type C = A | B\n    const isA = E.toRefinement((\n      c: C\n    ) => (c.type === \"A\" ? E.right(c) : E.left(\"not as A\")))\n    Util.deepStrictEqual(isA({ type: \"A\" }), true)\n    Util.deepStrictEqual(isA({ type: \"B\" }), false)\n  })\n\n  it(\"isEither\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.isEither), true)\n    Util.deepStrictEqual(pipe(E.left(\"e\"), E.isEither), true)\n    Util.deepStrictEqual(pipe(O.some(1), E.isEither), false)\n  })\n\n  it(\"orElseFail\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.orElseFail(() => \"e2\")), E.right(1))\n    Util.deepStrictEqual(pipe(E.left(\"e1\"), E.orElseFail(() => \"e2\")), E.left(\"e2\"))\n  })\n\n  it(\"reduce\", () => {\n    Util.deepStrictEqual(pipe(E.right(\"bar\"), E.Foldable.reduce(\"foo\", (b, a) => b + a)), \"foobar\")\n    Util.deepStrictEqual(pipe(E.left(\"bar\"), E.Foldable.reduce(\"foo\", (b, a) => b + a)), \"foo\")\n  })\n\n  it(\"getRight\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.getRight), O.some(1))\n    Util.deepStrictEqual(pipe(E.left(\"a\"), E.getRight), O.none())\n  })\n\n  it(\"getLeft\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.getLeft), O.none())\n    Util.deepStrictEqual(pipe(E.left(\"e\"), E.getLeft), O.some(\"e\"))\n  })\n\n  it(\"getOrNull\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.getOrNull), 1)\n    Util.deepStrictEqual(pipe(E.left(\"a\"), E.getOrNull), null)\n  })\n\n  it(\"getOrUndefined\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.getOrUndefined), 1)\n    Util.deepStrictEqual(pipe(E.left(\"a\"), E.getOrUndefined), undefined)\n  })\n\n  it(\"compact\", () => {\n    Util.deepStrictEqual(pipe(E.right(O.some(1)), E.compact(() => \"e2\")), E.right(1))\n    Util.deepStrictEqual(pipe(E.right(O.none()), E.compact(() => \"e2\")), E.left(\"e2\"))\n    Util.deepStrictEqual(pipe(E.left(\"e1\"), E.compact(() => \"e2\")), E.left(\"e1\"))\n  })\n\n  it(\"inspectRight\", () => {\n    const log: Array<number> = []\n    pipe(E.right(1), E.inspectRight((e) => log.push(e)))\n    pipe(E.left(\"e\"), E.inspectRight((e) => log.push(e)))\n    Util.deepStrictEqual(log, [1])\n  })\n\n  it(\"tapError\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.tapError(() => E.right(2))), E.right(1))\n    Util.deepStrictEqual(pipe(E.left(\"a\"), E.tapError(() => E.right(2))), E.left(\"a\"))\n    Util.deepStrictEqual(pipe(E.left(\"a\"), E.tapError(() => E.left(\"b\"))), E.left(\"b\"))\n  })\n\n  it(\"inspectLeft\", () => {\n    const log: Array<string> = []\n    pipe(E.right(1), E.inspectLeft((e) => log.push(e)))\n    pipe(E.left(\"e\"), E.inspectLeft((e) => log.push(e)))\n    Util.deepStrictEqual(log, [\"e\"])\n  })\n\n  it(\"getOrThrow\", () => {\n    expect(pipe(E.right(1), E.getOrThrow)).toEqual(1)\n    expect(() => pipe(E.left(\"e\"), E.getOrThrow)).toThrowError(\n      new Error(\"getOrThrow called on a Left\")\n    )\n  })\n\n  it(\"getOrThrowWith\", () => {\n    expect(pipe(E.right(1), E.getOrThrowWith((e) => new Error(`Unexpected Left: ${e}`)))).toEqual(1)\n    expect(() => pipe(E.left(\"e\"), E.getOrThrowWith((e) => new Error(`Unexpected Left: ${e}`))))\n      .toThrowError(\n        new Error(\"Unexpected Left: e\")\n      )\n  })\n\n  it(\"andThenDiscard\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.andThenDiscard(E.right(\"a\"))), E.right(1))\n    Util.deepStrictEqual(pipe(E.right(1), E.andThenDiscard(E.left(true))), E.left(true))\n    Util.deepStrictEqual(pipe(E.left(1), E.andThenDiscard(E.right(\"a\"))), E.left(1))\n    Util.deepStrictEqual(pipe(E.left(1), E.andThenDiscard(E.left(true))), E.left(1))\n  })\n\n  it(\"andThen\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.andThen(E.right(\"a\"))), E.right(\"a\"))\n    Util.deepStrictEqual(pipe(E.right(1), E.andThen(E.left(true))), E.left(true))\n    Util.deepStrictEqual(pipe(E.left(1), E.andThen(E.right(\"a\"))), E.left(1))\n    Util.deepStrictEqual(pipe(E.left(1), E.andThen(E.left(true))), E.left(1))\n  })\n\n  it(\"orElse\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.orElse(() => E.right(2))), E.right(1))\n    Util.deepStrictEqual(pipe(E.right(1), E.orElse(() => E.left(\"b\"))), E.right(1))\n    Util.deepStrictEqual(pipe(E.left(\"a\"), E.orElse(() => E.right(2))), E.right(2))\n    Util.deepStrictEqual(pipe(E.left(\"a\"), E.orElse(() => E.left(\"b\"))), E.left(\"b\"))\n  })\n\n  it(\"orElseEither\", () => {\n    expect(pipe(E.right(1), E.orElseEither(() => E.right(2)))).toEqual(E.right(E.left(1)))\n    expect(pipe(E.right(1), E.orElseEither(() => E.left(\"b\")))).toEqual(E.right(E.left(1)))\n    expect(pipe(E.left(\"a\"), E.orElseEither(() => E.right(2)))).toEqual(E.right(E.right(2)))\n    expect(pipe(E.left(\"a\"), E.orElseEither(() => E.left(\"b\")))).toEqual(E.left(\"b\"))\n  })\n\n  it(\"map\", () => {\n    const f = E.map(S.length)\n    Util.deepStrictEqual(pipe(E.right(\"abc\"), f), E.right(3))\n    Util.deepStrictEqual(pipe(E.left(\"s\"), f), E.left(\"s\"))\n  })\n\n  it(\"flatMap\", () => {\n    const f = E.flatMap<string, string, number>(flow(S.length, E.right))\n    Util.deepStrictEqual(pipe(E.right(\"abc\"), f), E.right(3))\n    Util.deepStrictEqual(pipe(E.left(\"maError\"), f), E.left(\"maError\"))\n  })\n\n  it(\"bimap\", () => {\n    const f = E.bimap(S.length, (n: number) => n > 2)\n    Util.deepStrictEqual(pipe(E.right(1), f), E.right(false))\n  })\n\n  it(\"mapLeft\", () => {\n    const f = E.mapLeft(Util.double)\n    Util.deepStrictEqual(pipe(E.right(\"a\"), f), E.right(\"a\"))\n    Util.deepStrictEqual(pipe(E.left(1), f), E.left(2))\n  })\n\n  it(\"traverse\", () => {\n    const traverse = E.traverse(O.Applicative)((\n      n: number\n    ) => (n >= 2 ? O.some(n) : O.none()))\n    Util.deepStrictEqual(pipe(E.left(\"a\"), traverse), O.some(E.left(\"a\")))\n    Util.deepStrictEqual(pipe(E.right(1), traverse), O.none())\n    Util.deepStrictEqual(pipe(E.right(3), traverse), O.some(E.right(3)))\n  })\n\n  it(\"sequence\", () => {\n    const sequence = E.sequence(O.Applicative)\n    Util.deepStrictEqual(sequence(E.right(O.some(1))), O.some(E.right(1)))\n    Util.deepStrictEqual(sequence(E.left(\"a\")), O.some(E.left(\"a\")))\n    Util.deepStrictEqual(sequence(E.right(O.none())), O.none())\n  })\n\n  it(\"match\", () => {\n    const f = (s: string) => `left${s.length}`\n    const g = (s: string) => `right${s.length}`\n    const match = E.match(f, g)\n    Util.deepStrictEqual(match(E.left(\"abc\")), \"left3\")\n    Util.deepStrictEqual(match(E.right(\"abc\")), \"right3\")\n  })\n\n  it(\"getOrElse\", () => {\n    Util.deepStrictEqual(pipe(E.right(12), E.getOrElse(() => 17)), 12)\n    Util.deepStrictEqual(pipe(E.left(\"a\"), E.getOrElse(() => 17)), 17)\n  })\n\n  it(\"contains\", () => {\n    const contains = E.contains(N.Equivalence)\n    Util.deepStrictEqual(pipe(E.left(\"a\"), contains(2)), false)\n    Util.deepStrictEqual(pipe(E.right(2), contains(2)), true)\n    Util.deepStrictEqual(pipe(E.right(2), contains(1)), false)\n  })\n\n  it(\"filter\", () => {\n    const predicate = (n: number) => n > 10\n    Util.deepStrictEqual(pipe(E.right(12), E.filter(predicate, () => -1)), E.right(12))\n    Util.deepStrictEqual(pipe(E.right(7), E.filter(predicate, () => -1)), E.left(-1))\n    Util.deepStrictEqual(pipe(E.left(12), E.filter(predicate, () => -1)), E.left(12))\n  })\n\n  it(\"isLeft\", () => {\n    Util.deepStrictEqual(E.isLeft(E.right(1)), false)\n    Util.deepStrictEqual(E.isLeft(E.left(1)), true)\n  })\n\n  it(\"isRight\", () => {\n    Util.deepStrictEqual(E.isRight(E.right(1)), true)\n    Util.deepStrictEqual(E.isRight(E.left(1)), false)\n  })\n\n  it(\"swap\", () => {\n    Util.deepStrictEqual(E.reverse(E.right(\"a\")), E.left(\"a\"))\n    Util.deepStrictEqual(E.reverse(E.left(\"b\")), E.right(\"b\"))\n  })\n\n  it(\"liftPredicate\", () => {\n    const f = E.liftPredicate((n: number) => n >= 2, () => \"e\")\n    Util.deepStrictEqual(f(3), E.right(3))\n    Util.deepStrictEqual(f(1), E.left(\"e\"))\n  })\n\n  it(\"fromNullable\", () => {\n    Util.deepStrictEqual(E.fromNullable(() => \"default\")(null), E.left(\"default\"))\n    Util.deepStrictEqual(E.fromNullable(() => \"default\")(undefined), E.left(\"default\"))\n    Util.deepStrictEqual(E.fromNullable(() => \"default\")(1), E.right(1))\n  })\n\n  it(\"filterMap\", () => {\n    const p = (n: number) => n > 2\n    const f = (n: number) => (p(n) ? O.some(n + 1) : O.none())\n    Util.deepStrictEqual(pipe(E.left(\"123\"), E.filterMap(f, () => \"\")), E.left(\"123\"))\n    Util.deepStrictEqual(pipe(E.right(1), E.filterMap(f, () => \"\")), E.left(S.Monoid.empty))\n    Util.deepStrictEqual(pipe(E.right(3), E.filterMap(f, () => \"\")), E.right(4))\n  })\n\n  it(\"fromIterable\", () => {\n    Util.deepStrictEqual(E.fromIterable(() => \"e\")([]), E.left(\"e\"))\n    Util.deepStrictEqual(E.fromIterable(() => \"e\")([\"a\"]), E.right(\"a\"))\n  })\n\n  it(\"firstRightOf\", () => {\n    Util.deepStrictEqual(pipe(E.right(1), E.firstRightOf([])), E.right(1))\n    Util.deepStrictEqual(pipe(E.left(\"e\"), E.firstRightOf([])), E.left(\"e\"))\n    Util.deepStrictEqual(\n      pipe(E.left(\"e1\"), E.firstRightOf([E.left(\"e2\"), E.left(\"e3\"), E.left(\"e4\"), E.right(1)])),\n      E.right(1)\n    )\n    Util.deepStrictEqual(\n      pipe(E.left(\"e1\"), E.firstRightOf([E.left(\"e2\"), E.left(\"e3\"), E.left(\"e4\")])),\n      E.left(\"e4\")\n    )\n  })\n\n  it(\"fromOption\", () => {\n    Util.deepStrictEqual(E.fromOption(() => \"none\")(O.none()), E.left(\"none\"))\n    Util.deepStrictEqual(E.fromOption(() => \"none\")(O.some(1)), E.right(1))\n  })\n\n  it(\"liftOption\", () => {\n    const f = E.liftOption((n: number) => (n > 0 ? O.some(n) : O.none()), () => \"a\")\n    Util.deepStrictEqual(f(1), E.right(1))\n    Util.deepStrictEqual(f(-1), E.left(\"a\"))\n  })\n\n  it(\"flatMapOption\", () => {\n    const f = E.flatMapOption((n: number) => (n > 0 ? O.some(n) : O.none()), () => \"a\")\n    Util.deepStrictEqual(f(E.right(1)), E.right(1))\n    Util.deepStrictEqual(f(E.right(-1)), E.left(\"a\"))\n    Util.deepStrictEqual(f(E.left(\"b\")), E.left(\"b\"))\n  })\n\n  it(\"exists\", () => {\n    const gt2 = E.exists((n: number) => n > 2)\n    Util.deepStrictEqual(gt2(E.left(\"a\")), false)\n    Util.deepStrictEqual(gt2(E.right(1)), false)\n    Util.deepStrictEqual(gt2(E.right(3)), true)\n  })\n\n  it(\"do notation\", () => {\n    Util.deepStrictEqual(\n      pipe(\n        E.right(1),\n        E.bindTo(\"a\"),\n        E.bind(\"b\", () => E.right(\"b\")),\n        E.let(\"c\", ({ a, b }) => [a, b])\n      ),\n      E.right({ a: 1, b: \"b\", c: [1, \"b\"] })\n    )\n  })\n\n  it(\"andThenBind\", () => {\n    Util.deepStrictEqual(\n      pipe(E.right(1), E.bindTo(\"a\"), E.andThenBind(\"b\", E.right(\"b\"))),\n      E.right({ a: 1, b: \"b\" })\n    )\n  })\n\n  it(\"product\", () => {\n    const product = E.SemiProduct.product\n    Util.deepStrictEqual(product(E.right(1), E.right(\"a\")), E.right([1, \"a\"]))\n    Util.deepStrictEqual(product(E.right(1), E.left(\"e2\")), E.left(\"e2\"))\n    Util.deepStrictEqual(product(E.left(\"e1\"), E.right(\"a\")), E.left(\"e1\"))\n    Util.deepStrictEqual(product(E.left(\"e1\"), E.left(\"2\")), E.left(\"e1\"))\n  })\n\n  it(\"productMany\", () => {\n    const productMany: <E, A>(\n      self: E.Either<E, A>,\n      collection: Iterable<E.Either<E, A>>\n    ) => E.Either<E, [A, ...Array<A>]> = E.SemiProduct.productMany\n\n    Util.deepStrictEqual(productMany(E.right(1), []), E.right([1]))\n    Util.deepStrictEqual(\n      productMany(E.right(1), [E.right(2), E.right(3)]),\n      E.right([1, 2, 3])\n    )\n    Util.deepStrictEqual(\n      productMany(E.right(1), [E.left(\"e\"), E.right(3)]),\n      E.left(\"e\")\n    )\n    expect(\n      productMany(E.left(\"e\"), [E.right(2), E.right(3)])\n    ).toEqual(E.left(\"e\"))\n  })\n\n  it(\"productAll\", () => {\n    const productAll = E.Product.productAll\n    Util.deepStrictEqual(productAll([]), E.right([]))\n    Util.deepStrictEqual(\n      productAll([E.right(1), E.right(2), E.right(3)]),\n      E.right([1, 2, 3])\n    )\n    Util.deepStrictEqual(\n      productAll([E.left(\"e\"), E.right(2), E.right(3)]),\n      E.left(\"e\")\n    )\n  })\n\n  it(\"coproduct\", () => {\n    const coproduct = E.SemiCoproduct.coproduct\n    Util.deepStrictEqual(coproduct(E.right(1), E.right(2)), E.right(1))\n    Util.deepStrictEqual(coproduct(E.right(1), E.left(\"e2\")), E.right(1))\n    Util.deepStrictEqual(coproduct(E.left(\"e1\"), E.right(2)), E.right(2))\n    Util.deepStrictEqual(coproduct(E.left(\"e1\"), E.left(\"e2\")), E.left(\"e2\"))\n  })\n\n  it(\"coproductMany\", () => {\n    const coproductMany = E.SemiCoproduct.coproductMany\n    Util.deepStrictEqual(coproductMany(E.right(1), [E.right(2)]), E.right(1))\n    Util.deepStrictEqual(\n      coproductMany(E.right(1), [E.left(\"e2\")]),\n      E.right(1)\n    )\n    Util.deepStrictEqual(coproductMany(E.left(\"e1\"), [E.right(2)]), E.right(2))\n    Util.deepStrictEqual(coproductMany(E.left(\"e1\"), [E.left(\"e2\")]), E.left(\"e2\"))\n  })\n\n  it(\"element\", () => {\n    expect(pipe(E.right(1), E.tupled, E.appendElement(E.right(\"b\")))).toEqual(\n      E.right([1, \"b\"])\n    )\n  })\n\n  it(\"liftNullable\", () => {\n    const f = E.liftNullable((n: number) => (n > 0 ? n : null), () => \"error\")\n    Util.deepStrictEqual(f(1), E.right(1))\n    Util.deepStrictEqual(f(-1), E.left(\"error\"))\n  })\n\n  it(\"flatMapNullable\", () => {\n    const f = E.flatMapNullable((n: number) => (n > 0 ? n : null), () => \"error\")\n    Util.deepStrictEqual(f(E.right(1)), E.right(1))\n    Util.deepStrictEqual(f(E.right(-1)), E.left(\"error\"))\n    Util.deepStrictEqual(f(E.left(\"a\")), E.left(\"a\"))\n  })\n\n  it(\"merge\", () => {\n    Util.deepStrictEqual(E.merge(E.right(1)), 1)\n    Util.deepStrictEqual(E.merge(E.left(\"a\")), \"a\")\n  })\n\n  it(\"liftThrowable\", () => {\n    const f = E.liftThrowable((s: string) => {\n      const len = s.length\n      if (len > 0) {\n        return len\n      }\n      throw new Error(\"empty string\")\n    }, identity)\n    Util.deepStrictEqual(f(\"a\"), E.right(1))\n    Util.deepStrictEqual(f(\"\"), E.left(new Error(\"empty string\")))\n  })\n\n  it(\"zipWith\", () => {\n    expect(pipe(E.left(\"a\"), E.zipWith(E.right(2), (a, b) => a + b))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(1), E.zipWith(E.left(\"a\"), (a, b) => a + b))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(1), E.zipWith(E.right(2), (a, b) => a + b))).toEqual(E.right(3))\n  })\n\n  it(\"sum\", () => {\n    expect(pipe(E.left(\"a\"), E.sum(E.right(2)))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(1), E.sum(E.left(\"a\")))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(2), E.sum(E.right(3)))).toEqual(E.right(5))\n  })\n\n  it(\"multiply\", () => {\n    expect(pipe(E.left(\"a\"), E.multiply(E.right(2)))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(1), E.multiply(E.left(\"a\")))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(2), E.multiply(E.right(3)))).toEqual(E.right(6))\n  })\n\n  it(\"subtract\", () => {\n    expect(pipe(E.left(\"a\"), E.subtract(E.right(2)))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(1), E.subtract(E.left(\"a\")))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(2), E.subtract(E.right(3)))).toEqual(E.right(-1))\n  })\n\n  it(\"divide\", () => {\n    expect(pipe(E.left(\"a\"), E.divide(E.right(2)))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(1), E.divide(E.left(\"a\")))).toEqual(E.left(\"a\"))\n    expect(pipe(E.right(6), E.divide(E.right(3)))).toEqual(E.right(2))\n  })\n\n  it(\"getOptionalSemigroup\", () => {\n    const OS = E.getOptionalSemigroup(S.Semigroup)\n    Util.deepStrictEqual(OS.combine(E.left(\"e\"), E.left(\"e\")), E.left(\"e\"))\n    Util.deepStrictEqual(OS.combine(E.left(\"e\"), E.right(\"a\")), E.right(\"a\"))\n    Util.deepStrictEqual(OS.combine(E.right(\"a\"), E.left(\"e\")), E.right(\"a\"))\n    Util.deepStrictEqual(OS.combine(E.right(\"b\"), E.right(\"a\")), E.right(\"ba\"))\n    Util.deepStrictEqual(OS.combine(E.right(\"a\"), E.right(\"b\")), E.right(\"ab\"))\n\n    Util.deepStrictEqual(OS.combineMany(E.right(\"a\"), [E.right(\"b\")]), E.right(\"ab\"))\n    Util.deepStrictEqual(OS.combineMany(E.left(\"e\"), [E.right(\"b\")]), E.right(\"b\"))\n    Util.deepStrictEqual(OS.combineMany(E.right(\"a\"), [E.left(\"e\")]), E.right(\"a\"))\n  })\n\n  it(\"getEquivalence\", () => {\n    const isEquivalent = E.getEquivalence(S.Equivalence, N.Equivalence)\n    Util.deepStrictEqual(isEquivalent(E.right(1), E.right(1)), true)\n    Util.deepStrictEqual(isEquivalent(E.right(1), E.right(2)), false)\n    Util.deepStrictEqual(isEquivalent(E.right(1), E.left(\"foo\")), false)\n    Util.deepStrictEqual(isEquivalent(E.left(\"foo\"), E.left(\"foo\")), true)\n    Util.deepStrictEqual(isEquivalent(E.left(\"foo\"), E.left(\"bar\")), false)\n    Util.deepStrictEqual(isEquivalent(E.left(\"foo\"), E.right(1)), false)\n  })\n\n  it(\"toArray\", () => {\n    expect(E.toArray(E.right(1))).toEqual([1])\n    expect(E.toArray(E.left(\"error\"))).toEqual([])\n  })\n})\n"
  },
  {
    "path": "test/Function.ts",
    "content": "import * as _ from \"@fp-ts/core/Function\"\nimport * as String from \"@fp-ts/core/String\"\nimport { deepStrictEqual, double } from \"@fp-ts/core/test/util\"\nimport * as assert from \"assert\"\n\nconst f = (n: number): number => n + 1\nconst g = double\n\ndescribe.concurrent(\"Function\", () => {\n  it(\"apply\", () => {\n    deepStrictEqual(_.pipe(String.length, _.apply(\"a\")), 1)\n  })\n\n  it(\"compose\", () => {\n    deepStrictEqual(_.pipe(String.length, _.compose(double))(\"aaa\"), 6)\n    deepStrictEqual(_.compose(String.length, double)(\"aaa\"), 6)\n  })\n\n  it(\"flip\", () => {\n    const f = (a: number) => (b: string) => a - b.length\n    const g = (a: number, i = 0) => (b: number) => a ** b + i\n\n    deepStrictEqual(_.flip(f)(\"aaa\")(2), -1)\n    deepStrictEqual(_.flip(g)(2)(2, 1), 5)\n  })\n\n  it(\"unsafeCoerce\", () => {\n    deepStrictEqual(_.unsafeCoerce, _.identity)\n  })\n\n  it(\"constant\", () => {\n    deepStrictEqual(_.constant(\"a\")(), \"a\")\n  })\n\n  it(\"constTrue\", () => {\n    deepStrictEqual(_.constTrue(), true)\n  })\n\n  it(\"constFalse\", () => {\n    deepStrictEqual(_.constFalse(), false)\n  })\n\n  it(\"constNull\", () => {\n    deepStrictEqual(_.constNull(), null)\n  })\n\n  it(\"constUndefined\", () => {\n    deepStrictEqual(_.constUndefined(), undefined)\n  })\n\n  it(\"constVoid\", () => {\n    deepStrictEqual(_.constVoid(), undefined)\n  })\n\n  it(\"absurd\", () => {\n    assert.throws(() => _.absurd<string>(null as any as never))\n  })\n\n  it(\"hole\", () => {\n    assert.throws(() => _.hole<string>())\n  })\n\n  it(\"SK\", () => {\n    expect(_.SK(1, 2)).toEqual(2)\n  })\n\n  it(\"flow\", () => {\n    deepStrictEqual(_.flow(f)(2), 3)\n    deepStrictEqual(_.flow(f, g)(2), 6)\n    deepStrictEqual(_.flow(f, g, f)(2), 7)\n    deepStrictEqual(_.flow(f, g, f, g)(2), 14)\n    deepStrictEqual(_.flow(f, g, f, g, f)(2), 15)\n    deepStrictEqual(_.flow(f, g, f, g, f, g)(2), 30)\n    deepStrictEqual(_.flow(f, g, f, g, f, g, f)(2), 31)\n    deepStrictEqual(_.flow(f, g, f, g, f, g, f, g)(2), 62)\n    deepStrictEqual(_.flow(f, g, f, g, f, g, f, g, f)(2), 63)\n    // this is just to satisfy noImplicitReturns and 100% coverage\n    deepStrictEqual((_.flow as any)(...[f, g, f, g, f, g, f, g, f, g]), undefined)\n  })\n\n  it(\"tupled\", () => {\n    const f1 = (a: number): number => a * 2\n    const f2 = (a: number, b: number): number => a + b\n    const u1 = _.tupled(f1)\n    const u2 = _.tupled(f2)\n    deepStrictEqual(u1([1]), 2)\n    deepStrictEqual(u2([1, 2]), 3)\n  })\n\n  it(\"untupled\", () => {\n    const f1 = (a: readonly [number]): number => a[0] * 2\n    const f2 = (a: readonly [number, number]): number => a[0] + a[1]\n    const u1 = _.untupled(f1)\n    const u2 = _.untupled(f2)\n    deepStrictEqual(u1(1), 2)\n    deepStrictEqual(u2(1, 2), 3)\n  })\n\n  it(\"pipe\", () => {\n    deepStrictEqual(_.pipe(2), 2)\n    deepStrictEqual(_.pipe(2, f), 3)\n    deepStrictEqual(_.pipe(2, f, g), 6)\n    deepStrictEqual(_.pipe(2, f, g, f), 7)\n    deepStrictEqual(_.pipe(2, f, g, f, g), 14)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f), 15)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g), 30)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f), 31)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g), 62)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f), 63)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g), 126)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f), 127)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g), 254)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f), 255)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g), 510)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f), 511)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g), 1022)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f), 1023)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g), 2046)\n    deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f), 2047)\n    deepStrictEqual(\n      (_.pipe as any)(...[2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g]),\n      4094\n    )\n  })\n\n  it(\"dual\", () => {\n    const f = _.dual<\n      (that: number) => (self: number) => number,\n      (self: number, that: number) => number\n    >(2, (a: number, b: number): number => a - b)\n    deepStrictEqual(f(3, 2), 1)\n    deepStrictEqual(_.pipe(3, f(2)), 1)\n  })\n})\n"
  },
  {
    "path": "test/Identity.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as _ from \"@fp-ts/core/Identity\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as String from \"@fp-ts/core/String\"\nimport * as U from \"./util\"\n\ndescribe.concurrent(\"Identity\", () => {\n  it(\"instances and derived exports\", () => {\n    expect(_.Invariant).exist\n    expect(_.Covariant).exist\n    expect(_.Of).exist\n    expect(_.Pointed).exist\n    expect(_.FlatMap).exist\n    expect(_.Chainable).exist\n    expect(_.Monad).exist\n    expect(_.SemiProduct).exist\n    expect(_.Product).exist\n    expect(_.SemiApplicative).exist\n    expect(_.Applicative).exist\n    expect(_.Foldable).exist\n    expect(_.Traversable).exist\n\n    expect(_.bindTo).exist\n    expect(_.let).exist\n    expect(_.Do).exist\n    expect(_.bind).exist\n  })\n\n  it(\"Of\", () => {\n    U.deepStrictEqual(_.Of.of(\"a\"), \"a\")\n  })\n\n  it(\"SemiProduct\", () => {\n    U.deepStrictEqual(_.SemiProduct.productMany(\"a\", [\"b\", \"c\"]), [\"a\", \"b\", \"c\"])\n  })\n\n  it(\"Product\", () => {\n    U.deepStrictEqual(_.Product.productAll([]), [])\n    U.deepStrictEqual(_.Product.productAll([\"a\", \"b\", \"c\"]), [\"a\", \"b\", \"c\"])\n  })\n\n  it(\"Covariant\", () => {\n    assert.deepStrictEqual(_.Covariant.map(1, n => n * 2), 2)\n  })\n\n  it(\"FlatMap\", () => {\n    U.deepStrictEqual(\n      pipe(\"a\", _.FlatMap.flatMap((a) => a + \"b\")),\n      \"ab\"\n    )\n  })\n\n  it(\"SemiProduct\", () => {\n    const product = _.SemiProduct.product\n    U.deepStrictEqual(product(\"a\", \"b\"), [\"a\", \"b\"])\n  })\n\n  it(\"getSemiCoproduct\", () => {\n    const F = _.getSemiCoproduct(String.Semigroup)\n    U.deepStrictEqual(F.coproduct(\"a\", \"b\"), \"ab\")\n    U.deepStrictEqual(F.coproductMany(\"a\", [\"b\", \"c\"]), \"abc\")\n  })\n\n  it(\"getSemiAlternative\", () => {\n    const F = _.getSemiAlternative(String.Semigroup)\n    U.deepStrictEqual(F.coproduct(\"a\", \"b\"), \"ab\")\n    U.deepStrictEqual(F.coproductMany(\"a\", [\"b\", \"c\"]), \"abc\")\n  })\n\n  it(\"Foldable\", () => {\n    U.deepStrictEqual(pipe(\"b\", _.Foldable.reduce(\"a\", (b, a) => b + a)), \"ab\")\n  })\n\n  it(\"Traversable\", () => {\n    U.deepStrictEqual(pipe(1, _.Traversable.traverse(O.Applicative)(O.some)), O.some(1))\n    U.deepStrictEqual(pipe(1, _.Traversable.traverse(O.Applicative)(() => O.none())), O.none())\n  })\n})\n"
  },
  {
    "path": "test/Number.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport { deepStrictEqual } from \"@fp-ts/core/test/util\"\n\ndescribe.concurrent(\"Number\", () => {\n  it(\"exports\", () => {\n    expect(Number.SemigroupMax).exists\n    expect(Number.SemigroupMin).exists\n    expect(Number.MonoidMax).exists\n    expect(Number.MonoidMin).exists\n    expect(Number.sumAll).exists\n    expect(Number.multiplyAll).exists\n    expect(Number.lessThan).exists\n    expect(Number.lessThanOrEqualTo).exists\n    expect(Number.greaterThan).exists\n    expect(Number.greaterThanOrEqualTo).exists\n    expect(Number.between).exists\n    expect(Number.clamp).exists\n    expect(Number.min).exists\n    expect(Number.max).exists\n  })\n\n  it(\"isNumber\", () => {\n    expect(Number.isNumber(1)).toEqual(true)\n    expect(Number.isNumber(\"a\")).toEqual(false)\n    expect(Number.isNumber(true)).toEqual(false)\n  })\n\n  it(\"sum\", () => {\n    deepStrictEqual(pipe(1, Number.sum(2)), 3)\n  })\n\n  it(\"multiply\", () => {\n    deepStrictEqual(pipe(2, Number.multiply(3)), 6)\n  })\n\n  it(\"subtract\", () => {\n    deepStrictEqual(pipe(3, Number.subtract(1)), 2)\n  })\n\n  it(\"divide\", () => {\n    deepStrictEqual(pipe(6, Number.divide(2)), 3)\n  })\n\n  it(\"increment\", () => {\n    deepStrictEqual(Number.increment(2), 3)\n  })\n\n  it(\"decrement\", () => {\n    deepStrictEqual(Number.decrement(2), 1)\n  })\n\n  it(\"Equivalence\", () => {\n    expect(Number.Equivalence(1, 1)).toBe(true)\n    expect(Number.Equivalence(1, 2)).toBe(false)\n  })\n\n  it(\"Order\", () => {\n    deepStrictEqual(Number.Order.compare(1, 2), -1)\n    deepStrictEqual(Number.Order.compare(2, 1), 1)\n    deepStrictEqual(Number.Order.compare(2, 2), 0)\n  })\n\n  it(\"Bounded\", () => {\n    expect(Number.Bounded.maxBound).toEqual(Infinity)\n    expect(Number.Bounded.minBound).toEqual(-Infinity)\n  })\n\n  it(\"SemigroupSum\", () => {\n    deepStrictEqual(Number.SemigroupSum.combine(2, 3), 5)\n  })\n\n  it(\"MonoidSum\", () => {\n    deepStrictEqual(Number.MonoidSum.combineAll([1, 2, 3]), 6)\n  })\n\n  it(\"SemigroupMultiply\", () => {\n    deepStrictEqual(Number.SemigroupMultiply.combine(2, 3), 6)\n    deepStrictEqual(Number.SemigroupMultiply.combineMany(0, [1, 2, 3]), 0)\n    deepStrictEqual(Number.SemigroupMultiply.combineMany(2, [1, 0, 3]), 0)\n  })\n\n  it(\"MonoidMultiply\", () => {\n    deepStrictEqual(Number.MonoidMultiply.combineAll([2, 3, 4]), 24)\n  })\n\n  it(\"sign\", () => {\n    deepStrictEqual(Number.sign(0), 0)\n    deepStrictEqual(Number.sign(0.0), 0)\n    deepStrictEqual(Number.sign(-0.1), -1)\n    deepStrictEqual(Number.sign(-10), -1)\n    deepStrictEqual(Number.sign(10), 1)\n    deepStrictEqual(Number.sign(0.1), 1)\n  })\n\n  it(\"remainder\", () => {\n    assert.deepStrictEqual(Number.remainder(2, 2), 0)\n    assert.deepStrictEqual(Number.remainder(3, 2), 1)\n    assert.deepStrictEqual(Number.remainder(4, 2), 0)\n    assert.deepStrictEqual(Number.remainder(2.5, 2), 0.5)\n    assert.deepStrictEqual(Number.remainder(-2, 2), -0)\n    assert.deepStrictEqual(Number.remainder(-3, 2), -1)\n    assert.deepStrictEqual(Number.remainder(-4, 2), -0)\n    assert.deepStrictEqual(Number.remainder(-2.8, -.2), -0)\n    assert.deepStrictEqual(Number.remainder(-2, -.2), -0)\n    assert.deepStrictEqual(Number.remainder(-1.5, -.2), -0.1)\n    assert.deepStrictEqual(Number.remainder(0, -.2), 0)\n    assert.deepStrictEqual(Number.remainder(1, -.2), 0)\n    assert.deepStrictEqual(Number.remainder(2.6, -.2), 0)\n    assert.deepStrictEqual(Number.remainder(3.1, -.2), 0.1)\n  })\n})\n"
  },
  {
    "path": "test/Option.ts",
    "content": "import { equivalence } from \"@fp-ts/core\"\nimport * as E from \"@fp-ts/core/Either\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport { structural } from \"@fp-ts/core/internal/effect\"\nimport * as N from \"@fp-ts/core/Number\"\nimport * as _ from \"@fp-ts/core/Option\"\nimport * as ReadonlyArray from \"@fp-ts/core/ReadonlyArray\"\nimport * as S from \"@fp-ts/core/String\"\nimport * as Util from \"@fp-ts/core/test/util\"\n\nconst p = (n: number): boolean => n > 2\n\ndescribe.concurrent(\"Option\", () => {\n  it(\"exports\", () => {\n    expect(_.toEither).exist\n    expect(_.getRight).exist\n    expect(_.getLeft).exist\n\n    expect(_.Invariant).exist\n    expect(_.tupled).exist\n    expect(_.bindTo).exist\n\n    expect(_.Covariant).exist\n    expect(_.map).exist\n    expect(_.let).exist\n    expect(_.flap).exist\n    expect(_.as).exist\n    expect(_.asUnit).exist\n\n    expect(_.Of).exist\n    expect(_.of).exist\n    expect(_.Do).exist\n\n    expect(_.Pointed).exist\n\n    expect(_.FlatMap).exist\n    expect(_.flatMap).exist\n    expect(_.flatten).exist\n    expect(_.andThen).exist\n    expect(_.composeKleisliArrow).exist\n\n    expect(_.Chainable).exist\n    expect(_.bind).exist\n    expect(_.tap).exist\n    expect(_.andThenDiscard).exist\n\n    expect(_.Monad).exist\n\n    expect(_.SemiProduct).exist\n\n    expect(_.Product).exist\n    expect(_.all).exist\n    expect(_.tuple).exist\n    expect(_.struct).exist\n\n    expect(_.SemiApplicative).exist\n    expect(_.getFailureSemigroup).exist // liftSemigroup\n    expect(_.lift2).exist\n    expect(_.ap).exist\n    expect(_.andThenDiscard).exist\n    expect(_.andThen).exist\n\n    expect(_.Applicative).exist\n    expect(_.getFailureMonoid).exist // liftMonoid\n\n    expect(_.SemiCoproduct).exist\n    expect(_.getFirstSomeSemigroup).exist // getSemigroup\n\n    expect(_.Coproduct).exist\n\n    expect(_.SemiAlternative).exist\n\n    expect(_.Alternative).exist\n\n    expect(_.Foldable).exist\n    expect(_.reduceCompact).exist\n    expect(_.toArray).exist\n\n    expect(_.Traversable).exist\n    expect(_.traverse).exist\n    expect(_.sequence).exist\n    expect(_.traverseTap).exist\n\n    expect(_.Filterable).exist\n    expect(_.filterMap).exist\n    expect(_.filter).exist\n  })\n\n  it(\"structural tracking\", () => {\n    expect(Util.ownKeys(_.none())).toEqual([\"_tag\"])\n    expect(Util.ownKeys(_.some(1))).toEqual([\"_tag\", \"value\"])\n\n    expect(Object.prototype.hasOwnProperty.call(_.none(), structural)).toEqual(false)\n    expect(Object.prototype.hasOwnProperty.call(_.some(1), structural)).toEqual(false)\n\n    expect(Util.isStructural(_.none())).toEqual(true)\n    expect(Util.isStructural(_.some(1))).toEqual(true)\n  })\n\n  it(\"toRefinement\", () => {\n    const f = (\n      s: string | number\n    ): _.Option<string> => (typeof s === \"string\" ? _.some(s) : _.none())\n    const isString = _.toRefinement(f)\n    Util.deepStrictEqual(isString(\"s\"), true)\n    Util.deepStrictEqual(isString(1), false)\n    type A = { readonly type: \"A\" }\n    type B = { readonly type: \"B\" }\n    type C = A | B\n    const isA = _.toRefinement<C, A>((c) => (c.type === \"A\" ? _.some(c) : _.none()))\n    Util.deepStrictEqual(isA({ type: \"A\" }), true)\n    Util.deepStrictEqual(isA({ type: \"B\" }), false)\n  })\n\n  it(\"isOption\", () => {\n    Util.deepStrictEqual(pipe(_.some(1), _.isOption), true)\n    Util.deepStrictEqual(pipe(_.none(), _.isOption), true)\n    Util.deepStrictEqual(pipe(E.right(1), _.isOption), false)\n  })\n\n  it(\"coproductMany\", () => {\n    const coproductMany = _.SemiCoproduct.coproductMany\n    Util.deepStrictEqual(coproductMany(_.some(1), []), _.some(1))\n    Util.deepStrictEqual(coproductMany(_.none(), []), _.none())\n    Util.deepStrictEqual(\n      coproductMany(_.none(), [_.none(), _.none(), _.none(), _.some(1)]),\n      _.some(1)\n    )\n    Util.deepStrictEqual(\n      coproductMany(_.none(), [_.none(), _.none(), _.none()]),\n      _.none()\n    )\n  })\n\n  it(\"firstSomeOf\", () => {\n    Util.deepStrictEqual(_.firstSomeOf([]), _.none())\n    Util.deepStrictEqual(_.firstSomeOf([_.some(1)]), _.some(1))\n    Util.deepStrictEqual(_.firstSomeOf([_.none()]), _.none())\n    Util.deepStrictEqual(\n      _.firstSomeOf([_.none(), _.none(), _.none(), _.none(), _.some(1)]),\n      _.some(1)\n    )\n    Util.deepStrictEqual(\n      _.firstSomeOf([_.none(), _.none(), _.none(), _.none()]),\n      _.none()\n    )\n  })\n\n  it(\"orElseEither\", () => {\n    expect(pipe(_.some(1), _.orElseEither(() => _.some(2)))).toEqual(_.some(E.left(1)))\n    expect(pipe(_.some(1), _.orElseEither(() => _.none()))).toEqual(_.some(E.left(1)))\n    expect(pipe(_.none(), _.orElseEither(() => _.some(2)))).toEqual(_.some(E.right(2)))\n    expect(pipe(_.none(), _.orElseEither(() => _.none()))).toEqual(_.none())\n  })\n\n  it(\"inspectSome\", () => {\n    const log: Array<number> = []\n    pipe(\n      _.some(1),\n      _.inspectSome(() => log.push(1))\n    )\n    pipe(\n      _.none(),\n      _.inspectSome(() => log.push(2))\n    )\n    Util.deepStrictEqual(\n      log,\n      [1]\n    )\n  })\n\n  it(\"inspectNone\", () => {\n    const log: Array<number> = []\n    pipe(\n      _.some(1),\n      _.inspectNone(() => log.push(1))\n    )\n    pipe(\n      _.none(),\n      _.inspectNone(() => log.push(2))\n    )\n    Util.deepStrictEqual(\n      log,\n      [2]\n    )\n  })\n\n  it(\"getOrThrow\", () => {\n    expect(pipe(_.some(1), _.getOrThrow)).toEqual(1)\n    expect(() => pipe(_.none(), _.getOrThrow)).toThrowError(\n      new Error(\"getOrThrow called on a None\")\n    )\n  })\n\n  it(\"getOrThrowWith\", () => {\n    expect(pipe(_.some(1), _.getOrThrowWith(() => new Error(\"Unexpected None\")))).toEqual(1)\n    expect(() => pipe(_.none(), _.getOrThrowWith(() => new Error(\"Unexpected None\")))).toThrowError(\n      new Error(\"Unexpected None\")\n    )\n  })\n\n  it(\"of\", () => {\n    Util.deepStrictEqual(_.of(1), _.some(1))\n  })\n\n  it(\"Foldable\", () => {\n    expect(pipe(_.none(), _.Foldable.reduce(\"a\", (s, n: number) => s + String(n)))).toEqual(\"a\")\n    expect(pipe(_.some(1), _.Foldable.reduce(\"a\", (s, n: number) => s + String(n)))).toEqual(\n      \"a1\"\n    )\n  })\n\n  it(\"coproductAll\", () => {\n    const coproductAll = _.Coproduct.coproductAll\n    Util.deepStrictEqual(coproductAll([]), _.none())\n    Util.deepStrictEqual(coproductAll([_.some(1)]), _.some(1))\n    Util.deepStrictEqual(coproductAll([_.none(), _.some(1)]), _.some(1))\n    Util.deepStrictEqual(coproductAll([_.some(1), _.some(2)]), _.some(1))\n  })\n\n  it(\"unit\", () => {\n    Util.deepStrictEqual(_.unit, _.some(undefined))\n  })\n\n  it(\"product\", () => {\n    const product = _.SemiProduct.product\n    Util.deepStrictEqual(product(_.none(), _.none()), _.none())\n    Util.deepStrictEqual(product(_.some(1), _.none()), _.none())\n    Util.deepStrictEqual(product(_.none(), _.some(\"a\")), _.none())\n    Util.deepStrictEqual(\n      product(_.some(1), _.some(\"a\")),\n      _.some([1, \"a\"])\n    )\n  })\n\n  it(\"productMany\", () => {\n    const productMany = _.SemiProduct.productMany\n    Util.deepStrictEqual(productMany(_.none(), []), _.none())\n    Util.deepStrictEqual(productMany(_.some(1), []), _.some([1]))\n    Util.deepStrictEqual(productMany(_.some(1), [_.none()]), _.none())\n    Util.deepStrictEqual(productMany(_.some(1), [_.some(2)]), _.some([1, 2]))\n  })\n\n  it(\"productAll\", () => {\n    const productAll = _.Applicative.productAll\n    Util.deepStrictEqual(productAll([]), _.some([]))\n    Util.deepStrictEqual(productAll([_.none()]), _.none())\n    Util.deepStrictEqual(productAll([_.some(1), _.some(2)]), _.some([1, 2]))\n    Util.deepStrictEqual(productAll([_.some(1), _.none()]), _.none())\n  })\n\n  it(\"SemiCoproduct\", () => {\n    const coproduct = _.SemiCoproduct.coproduct\n    Util.deepStrictEqual(coproduct(_.none(), _.none()), _.none())\n    Util.deepStrictEqual(coproduct(_.none(), _.some(2)), _.some(2))\n    Util.deepStrictEqual(coproduct(_.some(1), _.none()), _.some(1))\n    Util.deepStrictEqual(coproduct(_.some(1), _.some(2)), _.some(1))\n\n    const coproductMany = _.SemiCoproduct.coproductMany\n    Util.deepStrictEqual(coproductMany(_.none(), []), _.none())\n    Util.deepStrictEqual(coproductMany(_.none(), [_.none()]), _.none())\n    Util.deepStrictEqual(coproductMany(_.none(), [_.some(2)]), _.some(2))\n    Util.deepStrictEqual(coproductMany(_.some(1), []), _.some(1))\n    Util.deepStrictEqual(coproductMany(_.some(1), [_.none() as _.Option<number>]), _.some(1))\n    Util.deepStrictEqual(coproductMany(_.some(1), [_.some(2)]), _.some(1))\n  })\n\n  it(\"fromIterable\", () => {\n    Util.deepStrictEqual(_.fromIterable([]), _.none())\n    Util.deepStrictEqual(_.fromIterable([\"a\"]), _.some(\"a\"))\n  })\n\n  it(\"map\", () => {\n    Util.deepStrictEqual(pipe(_.some(2), _.map(Util.double)), _.some(4))\n    Util.deepStrictEqual(pipe(_.none(), _.map(Util.double)), _.none())\n  })\n\n  it(\"flatMap\", () => {\n    const f = (n: number) => _.some(n * 2)\n    const g = () => _.none()\n    Util.deepStrictEqual(pipe(_.some(1), _.flatMap(f)), _.some(2))\n    Util.deepStrictEqual(pipe(_.none(), _.flatMap(f)), _.none())\n    Util.deepStrictEqual(pipe(_.some(1), _.flatMap(g)), _.none())\n    Util.deepStrictEqual(pipe(_.none(), _.flatMap(g)), _.none())\n  })\n\n  it(\"orElse\", () => {\n    const assertAlt = (\n      a: _.Option<number>,\n      b: _.Option<number>,\n      expected: _.Option<number>\n    ) => {\n      Util.deepStrictEqual(pipe(a, _.orElse(() => b)), expected)\n    }\n    assertAlt(_.some(1), _.some(2), _.some(1))\n    assertAlt(_.some(1), _.none(), _.some(1))\n    assertAlt(_.none(), _.some(2), _.some(2))\n    assertAlt(_.none(), _.none(), _.none())\n  })\n\n  it(\"partitionMap\", () => {\n    const f = (n: number) => (p(n) ? E.right(n + 1) : E.left(n - 1))\n    assert.deepStrictEqual(pipe(_.none(), _.partitionMap(f)), [_.none(), _.none()])\n    assert.deepStrictEqual(pipe(_.some(1), _.partitionMap(f)), [_.some(0), _.none()])\n    assert.deepStrictEqual(pipe(_.some(3), _.partitionMap(f)), [_.none(), _.some(4)])\n  })\n\n  it(\"filterMap\", () => {\n    const f = (n: number) => (p(n) ? _.some(n + 1) : _.none())\n    Util.deepStrictEqual(pipe(_.none(), _.filterMap(f)), _.none())\n    Util.deepStrictEqual(pipe(_.some(1), _.filterMap(f)), _.none())\n    Util.deepStrictEqual(pipe(_.some(3), _.filterMap(f)), _.some(4))\n  })\n\n  it(\"traverse\", () => {\n    Util.deepStrictEqual(\n      pipe(\n        _.some(\"hello\"),\n        _.traverse(ReadonlyArray.Applicative)(() => [])\n      ),\n      []\n    )\n    Util.deepStrictEqual(\n      pipe(\n        _.some(\"hello\"),\n        _.traverse(ReadonlyArray.Applicative)((s) => [s.length])\n      ),\n      [_.some(5)]\n    )\n    Util.deepStrictEqual(\n      pipe(\n        _.none(),\n        _.traverse(ReadonlyArray.Applicative)((s) => [s])\n      ),\n      [_.none()]\n    )\n  })\n\n  it(\"toEither\", () => {\n    Util.deepStrictEqual(pipe(_.none(), _.toEither(() => \"e\")), E.left(\"e\"))\n    Util.deepStrictEqual(pipe(_.some(1), _.toEither(() => \"e\")), E.right(1))\n  })\n\n  it(\"match\", () => {\n    const f = () => \"none\"\n    const g = (s: string) => `some${s.length}`\n    const match = _.match(f, g)\n    Util.deepStrictEqual(match(_.none()), \"none\")\n    Util.deepStrictEqual(match(_.some(\"abc\")), \"some3\")\n  })\n\n  it(\"getOrElse\", () => {\n    Util.deepStrictEqual(pipe(_.some(1), _.getOrElse(() => 0)), 1)\n    Util.deepStrictEqual(pipe(_.none(), _.getOrElse(() => 0)), 0)\n  })\n\n  it(\"getOrNull\", () => {\n    Util.deepStrictEqual(_.getOrNull(_.none()), null)\n    Util.deepStrictEqual(_.getOrNull(_.some(1)), 1)\n  })\n\n  it(\"getOrUndefined\", () => {\n    Util.deepStrictEqual(_.getOrUndefined(_.none()), undefined)\n    Util.deepStrictEqual(_.getOrUndefined(_.some(1)), 1)\n  })\n\n  it(\"getOrder\", () => {\n    const OS = _.getOrder(S.Order)\n    Util.deepStrictEqual(OS.compare(_.none(), _.none()), 0)\n    Util.deepStrictEqual(OS.compare(_.some(\"a\"), _.none()), 1)\n    Util.deepStrictEqual(OS.compare(_.none(), _.some(\"a\")), -1)\n    Util.deepStrictEqual(OS.compare(_.some(\"a\"), _.some(\"a\")), 0)\n    Util.deepStrictEqual(OS.compare(_.some(\"a\"), _.some(\"b\")), -1)\n    Util.deepStrictEqual(OS.compare(_.some(\"b\"), _.some(\"a\")), 1)\n  })\n\n  it(\"flatMapNullable\", () => {\n    interface X {\n      readonly a?: {\n        readonly b?: {\n          readonly c?: {\n            readonly d: number\n          }\n        }\n      }\n    }\n    const x1: X = { a: {} }\n    const x2: X = { a: { b: {} } }\n    const x3: X = { a: { b: { c: { d: 1 } } } }\n    Util.deepStrictEqual(\n      pipe(\n        _.fromNullable(x1.a),\n        _.flatMapNullable((x) => x.b),\n        _.flatMapNullable((x) => x.c),\n        _.flatMapNullable((x) => x.d)\n      ),\n      _.none()\n    )\n    Util.deepStrictEqual(\n      pipe(\n        _.fromNullable(x2.a),\n        _.flatMapNullable((x) => x.b),\n        _.flatMapNullable((x) => x.c),\n        _.flatMapNullable((x) => x.d)\n      ),\n      _.none()\n    )\n    Util.deepStrictEqual(\n      pipe(\n        _.fromNullable(x3.a),\n        _.flatMapNullable((x) => x.b),\n        _.flatMapNullable((x) => x.c),\n        _.flatMapNullable((x) => x.d)\n      ),\n      _.some(1)\n    )\n  })\n\n  it(\"getOptionalMonoid\", () => {\n    const M = _.getOptionalMonoid(S.Semigroup)\n    Util.deepStrictEqual(M.combine(_.none(), _.none()), _.none())\n    Util.deepStrictEqual(M.combine(_.none(), _.some(\"a\")), _.some(\"a\"))\n    Util.deepStrictEqual(M.combine(_.some(\"a\"), _.none()), _.some(\"a\"))\n    Util.deepStrictEqual(M.combine(_.some(\"b\"), _.some(\"a\")), _.some(\"ba\"))\n    Util.deepStrictEqual(M.combine(_.some(\"a\"), _.some(\"b\")), _.some(\"ab\"))\n\n    Util.deepStrictEqual(M.combineMany(_.some(\"a\"), [_.some(\"b\")]), _.some(\"ab\"))\n    Util.deepStrictEqual(M.combineMany(_.none(), [_.some(\"b\")]), _.some(\"b\"))\n    Util.deepStrictEqual(M.combineMany(_.some(\"a\"), [_.none()]), _.some(\"a\"))\n\n    Util.deepStrictEqual(pipe(M.combineAll([])), _.none())\n    Util.deepStrictEqual(pipe(M.combineAll([_.some(\"a\")])), _.some(\"a\"))\n    Util.deepStrictEqual(pipe(M.combineAll([_.some(\"a\"), _.some(\"b\")])), _.some(\"ab\"))\n    Util.deepStrictEqual(pipe(M.combineAll([_.some(\"a\"), _.none()])), _.some(\"a\"))\n  })\n\n  it(\"fromNullable\", () => {\n    Util.deepStrictEqual(_.fromNullable(2), _.some(2))\n    Util.deepStrictEqual(_.fromNullable(null), _.none())\n    Util.deepStrictEqual(_.fromNullable(undefined), _.none())\n  })\n\n  it(\"liftPredicate\", () => {\n    const f = _.liftPredicate(p)\n    Util.deepStrictEqual(f(1), _.none())\n    Util.deepStrictEqual(f(3), _.some(3))\n\n    type Direction = \"asc\" | \"desc\"\n    const parseDirection = _.liftPredicate((s: string): s is Direction =>\n      s === \"asc\" || s === \"desc\"\n    )\n    Util.deepStrictEqual(parseDirection(\"asc\"), _.some(\"asc\"))\n    Util.deepStrictEqual(parseDirection(\"foo\"), _.none())\n  })\n\n  it(\"contains\", () => {\n    const contains = _.contains(equivalence.number)\n    Util.deepStrictEqual(pipe(_.none(), contains(2)), false)\n    Util.deepStrictEqual(pipe(_.some(2), contains(2)), true)\n    Util.deepStrictEqual(pipe(_.some(2), contains(1)), false)\n  })\n\n  it(\"isNone\", () => {\n    Util.deepStrictEqual(_.isNone(_.none()), true)\n    Util.deepStrictEqual(_.isNone(_.some(1)), false)\n  })\n\n  it(\"isSome\", () => {\n    Util.deepStrictEqual(_.isSome(_.none()), false)\n    Util.deepStrictEqual(_.isSome(_.some(1)), true)\n  })\n\n  it(\"exists\", () => {\n    const predicate = (a: number) => a === 2\n    Util.deepStrictEqual(pipe(_.none(), _.exists(predicate)), false)\n    Util.deepStrictEqual(pipe(_.some(1), _.exists(predicate)), false)\n    Util.deepStrictEqual(pipe(_.some(2), _.exists(predicate)), true)\n  })\n\n  it(\"fromEither\", () => {\n    Util.deepStrictEqual(_.fromEither(E.right(1)), _.some(1))\n    Util.deepStrictEqual(_.fromEither(E.left(\"e\")), _.none())\n  })\n\n  it(\"do notation\", () => {\n    Util.deepStrictEqual(\n      pipe(\n        _.some(1),\n        _.bindTo(\"a\"),\n        _.bind(\"b\", () => _.some(\"b\"))\n      ),\n      _.some({ a: 1, b: \"b\" })\n    )\n  })\n\n  it(\"andThenBind\", () => {\n    Util.deepStrictEqual(\n      pipe(_.some(1), _.bindTo(\"a\"), _.andThenBind(\"b\", _.some(\"b\"))),\n      _.some({ a: 1, b: \"b\" })\n    )\n  })\n\n  it(\"element\", () => {\n    expect(pipe(_.some(1), _.tupled, _.appendElement(_.some(\"b\")))).toEqual(\n      _.some([1, \"b\"])\n    )\n  })\n\n  it(\"liftNullable\", () => {\n    const f = _.liftNullable((n: number) => (n > 0 ? n : null))\n    Util.deepStrictEqual(f(1), _.some(1))\n    Util.deepStrictEqual(f(-1), _.none())\n  })\n\n  it(\"liftThrowable\", () => {\n    const parse = _.liftThrowable(JSON.parse)\n    Util.deepStrictEqual(parse(\"1\"), _.some(1))\n    Util.deepStrictEqual(parse(\"\"), _.none())\n  })\n\n  it(\"liftEither\", () => {\n    const f = _.liftEither((n: number) => (n > 0 ? E.right(n) : E.left(\"e\")))\n    Util.deepStrictEqual(f(1), _.some(1))\n    Util.deepStrictEqual(f(-1), _.none())\n  })\n\n  it(\"flatMapEither\", () => {\n    const f = _.flatMapEither((n: number) => (n > 0 ? E.right(n) : E.left(\"e\")))\n    Util.deepStrictEqual(pipe(_.none(), f), _.none())\n    Util.deepStrictEqual(pipe(_.some(0), f), _.none())\n    Util.deepStrictEqual(pipe(_.some(1), f), _.some(1))\n  })\n\n  it(\"guard\", () => {\n    Util.deepStrictEqual(\n      pipe(\n        _.Do,\n        _.bind(\"x\", () => _.some(\"a\")),\n        _.bind(\"y\", () => _.some(\"a\")),\n        _.filter(({ x, y }) => x === y)\n      ),\n      _.some({ x: \"a\", y: \"a\" })\n    )\n    Util.deepStrictEqual(\n      pipe(\n        _.Do,\n        _.bind(\"x\", () => _.some(\"a\")),\n        _.bind(\"y\", () => _.some(\"b\")),\n        _.filter(({ x, y }) => x === y)\n      ),\n      _.none()\n    )\n  })\n\n  it(\"zipWith\", () => {\n    expect(pipe(_.none(), _.zipWith(_.some(2), (a, b) => a + b))).toEqual(_.none())\n    expect(pipe(_.some(1), _.zipWith(_.none(), (a, b) => a + b))).toEqual(_.none())\n    expect(pipe(_.some(1), _.zipWith(_.some(2), (a, b) => a + b))).toEqual(_.some(3))\n  })\n\n  it(\"reduceCompact\", () => {\n    const sumCompact = _.reduceCompact(0, N.sum)\n    expect(sumCompact([])).toEqual(0)\n    expect(sumCompact([_.some(2), _.some(3)])).toEqual(5)\n    expect(sumCompact([_.some(2), _.none(), _.some(3)])).toEqual(5)\n  })\n\n  it(\"sum\", () => {\n    expect(pipe(_.none(), _.sum(_.some(2)))).toEqual(_.none())\n    expect(pipe(_.some(1), _.sum(_.none()))).toEqual(_.none())\n    expect(pipe(_.some(2), _.sum(_.some(3)))).toEqual(_.some(5))\n  })\n\n  it(\"multiply\", () => {\n    expect(pipe(_.none(), _.multiply(_.some(2)))).toEqual(_.none())\n    expect(pipe(_.some(1), _.multiply(_.none()))).toEqual(_.none())\n    expect(pipe(_.some(2), _.multiply(_.some(3)))).toEqual(_.some(6))\n  })\n\n  it(\"subtract\", () => {\n    expect(pipe(_.none(), _.subtract(_.some(2)))).toEqual(_.none())\n    expect(pipe(_.some(1), _.subtract(_.none()))).toEqual(_.none())\n    expect(pipe(_.some(2), _.subtract(_.some(3)))).toEqual(_.some(-1))\n  })\n\n  it(\"divide\", () => {\n    expect(pipe(_.none(), _.divide(_.some(2)))).toEqual(_.none())\n    expect(pipe(_.some(1), _.divide(_.none()))).toEqual(_.none())\n    expect(pipe(_.some(6), _.divide(_.some(3)))).toEqual(_.some(2))\n  })\n\n  it(\"reduce\", () => {\n    expect(pipe(_.none(), _.Foldable.reduce(0, (b, a) => b + a))).toEqual(0)\n    expect(pipe(_.some(1), _.Foldable.reduce(0, (b, a) => b + a))).toEqual(1)\n  })\n\n  it(\"sumCompact\", () => {\n    expect(_.sumCompact([])).toEqual(0)\n    expect(_.sumCompact([_.some(2), _.some(3)])).toEqual(5)\n    expect(_.sumCompact([_.some(2), _.none(), _.some(3)])).toEqual(5)\n  })\n\n  it(\"multiplyCompact\", () => {\n    expect(_.multiplyCompact([])).toEqual(1)\n    expect(_.multiplyCompact([_.some(2), _.some(3)])).toEqual(6)\n    expect(_.multiplyCompact([_.some(2), _.none(), _.some(3)])).toEqual(6)\n    expect(_.multiplyCompact([_.some(2), _.some(0), _.some(3)])).toEqual(0)\n  })\n\n  it(\"getEquivalence\", () => {\n    const isEquivalent = _.getEquivalence(N.Equivalence)\n    expect(isEquivalent(_.none(), _.none())).toEqual(true)\n    expect(isEquivalent(_.none(), _.some(1))).toEqual(false)\n    expect(isEquivalent(_.some(1), _.none())).toEqual(false)\n    expect(isEquivalent(_.some(2), _.some(1))).toEqual(false)\n    expect(isEquivalent(_.some(1), _.some(2))).toEqual(false)\n    expect(isEquivalent(_.some(2), _.some(2))).toEqual(true)\n  })\n})\n"
  },
  {
    "path": "test/Ordering.ts",
    "content": "import * as _ from \"@fp-ts/core/Ordering\"\nimport { deepStrictEqual } from \"./util\"\n\ndescribe(\"Ordering\", () => {\n  it(\"match\", () => {\n    const f = _.match(\n      () => \"lt\",\n      () => \"eq\",\n      () => \"gt\"\n    )\n    deepStrictEqual(f(-1), \"lt\")\n    deepStrictEqual(f(0), \"eq\")\n    deepStrictEqual(f(1), \"gt\")\n  })\n\n  it(\"reverse\", () => {\n    deepStrictEqual(_.reverse(-1), 1)\n    deepStrictEqual(_.reverse(0), 0)\n    deepStrictEqual(_.reverse(1), -1)\n  })\n\n  it(\"Semigroup\", () => {\n    deepStrictEqual(_.Semigroup.combine(0, 0), 0)\n    deepStrictEqual(_.Semigroup.combine(0, 1), 1)\n    deepStrictEqual(_.Semigroup.combine(1, -1), 1)\n    deepStrictEqual(_.Semigroup.combine(-1, 1), -1)\n\n    deepStrictEqual(_.Semigroup.combineMany(0, []), 0)\n    deepStrictEqual(_.Semigroup.combineMany(1, []), 1)\n    deepStrictEqual(_.Semigroup.combineMany(-1, []), -1)\n    deepStrictEqual(_.Semigroup.combineMany(0, [0, 0, 0]), 0)\n    deepStrictEqual(_.Semigroup.combineMany(0, [0, 0, 1]), 1)\n    deepStrictEqual(_.Semigroup.combineMany(1, [0, 0, -1]), 1)\n    deepStrictEqual(_.Semigroup.combineMany(-1, [0, 0, 1]), -1)\n  })\n\n  it(\"Monoid\", () => {\n    deepStrictEqual(_.Monoid.combine(_.Monoid.empty, 0), 0)\n    deepStrictEqual(_.Monoid.combine(_.Monoid.empty, 1), 1)\n    deepStrictEqual(_.Monoid.combine(_.Monoid.empty, -1), -1)\n    deepStrictEqual(_.Monoid.combine(0, _.Monoid.empty), 0)\n    deepStrictEqual(_.Monoid.combine(1, _.Monoid.empty), 1)\n    deepStrictEqual(_.Monoid.combine(-1, _.Monoid.empty), -1)\n  })\n})\n"
  },
  {
    "path": "test/Predicate.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as _ from \"@fp-ts/core/Predicate\"\nimport { deepStrictEqual } from \"@fp-ts/core/test/util\"\n\nconst isPositive: _.Predicate<number> = (n) => n > 0\nconst isNegative: _.Predicate<number> = (n) => n < 0\nconst isLessThan2: _.Predicate<number> = (n) => n < 2\nconst isString: _.Refinement<unknown, string> = (u: unknown): u is string => typeof u === \"string\"\n\ninterface NonEmptyStringBrand {\n  readonly NonEmptyString: unique symbol\n}\n\ntype NonEmptyString = string & NonEmptyStringBrand\n\nconst NonEmptyString: _.Refinement<string, NonEmptyString> = (s): s is NonEmptyString =>\n  s.length > 0\n\ndescribe.concurrent(\"Predicate\", () => {\n  it(\"instances and derived exports\", () => {\n    expect(_.Invariant).exist\n    expect(_.tupled).exist\n    expect(_.bindTo).exist\n\n    expect(_.Contravariant).exist\n    expect(_.contramap).exist\n\n    expect(_.Of).exist\n    expect(_.of).exist\n    expect(_.unit).exist\n    expect(_.Do).exist\n\n    expect(_.SemiProduct).exist\n    expect(_.andThenBind).exist\n    expect(_.appendElement).exist\n\n    expect(_.Product).exist\n    expect(_.tuple).exist\n    expect(_.struct).exist\n  })\n\n  it(\"compose\", () => {\n    const refinement = pipe(isString, _.compose(NonEmptyString))\n    deepStrictEqual(refinement(\"a\"), true)\n    deepStrictEqual(refinement(null), false)\n    deepStrictEqual(refinement(\"\"), false)\n  })\n\n  it(\"contramap\", () => {\n    type A = {\n      readonly a: number\n    }\n    const predicate = pipe(\n      isPositive,\n      _.contramap((a: A) => a.a)\n    )\n    deepStrictEqual(predicate({ a: -1 }), false)\n    deepStrictEqual(predicate({ a: 0 }), false)\n    deepStrictEqual(predicate({ a: 1 }), true)\n  })\n\n  it(\"product\", () => {\n    const product = _.SemiProduct.product\n    const p = product(isPositive, isNegative)\n    deepStrictEqual(p([1, -1]), true)\n    deepStrictEqual(p([1, 1]), false)\n    deepStrictEqual(p([-1, -1]), false)\n    deepStrictEqual(p([-1, 1]), false)\n  })\n\n  it(\"productMany\", () => {\n    const productMany = _.SemiProduct.productMany\n    const p = productMany(isPositive, [isNegative])\n    deepStrictEqual(p([1, -1]), true)\n    deepStrictEqual(p([1, 1]), false)\n    deepStrictEqual(p([-1, -1]), false)\n    deepStrictEqual(p([-1, 1]), false)\n  })\n\n  it(\"productAll\", () => {\n    const p = _.Product.productAll([isPositive, isNegative])\n    deepStrictEqual(p([1]), true)\n    deepStrictEqual(p([1, -1]), true)\n    deepStrictEqual(p([1, 1]), false)\n    deepStrictEqual(p([-1, -1]), false)\n    deepStrictEqual(p([-1, 1]), false)\n  })\n\n  it(\"not\", () => {\n    const p = _.not(isPositive)\n    deepStrictEqual(p(1), false)\n    deepStrictEqual(p(0), true)\n    deepStrictEqual(p(-1), true)\n  })\n\n  it(\"or\", () => {\n    const p = pipe(isPositive, _.or(isNegative))\n    deepStrictEqual(p(-1), true)\n    deepStrictEqual(p(1), true)\n    deepStrictEqual(p(0), false)\n  })\n\n  it(\"and\", () => {\n    const p = pipe(isPositive, _.and(isLessThan2))\n    deepStrictEqual(p(1), true)\n    deepStrictEqual(p(-1), false)\n    deepStrictEqual(p(3), false)\n  })\n\n  it(\"getSemigroupAny\", () => {\n    const S = _.getSemigroupAny<number>()\n    const p1 = S.combine(isPositive, isNegative)\n    deepStrictEqual(p1(0), false)\n    deepStrictEqual(p1(-1), true)\n    deepStrictEqual(p1(1), true)\n    const p2 = S.combineMany(isPositive, [isNegative])\n    deepStrictEqual(p2(0), false)\n    deepStrictEqual(p2(-1), true)\n    deepStrictEqual(p2(1), true)\n  })\n\n  it(\"getMonoidAny\", () => {\n    const M = _.getMonoidAny<number>()\n    const predicate = M.combine(isPositive, M.empty)\n    deepStrictEqual(predicate(0), isPositive(0))\n    deepStrictEqual(predicate(-1), isPositive(-1))\n    deepStrictEqual(predicate(1), isPositive(1))\n  })\n\n  it(\"getSemigroupAll\", () => {\n    const S = _.getSemigroupAll<number>()\n    const p1 = S.combine(isPositive, isLessThan2)\n    deepStrictEqual(p1(0), false)\n    deepStrictEqual(p1(-2), false)\n    deepStrictEqual(p1(1), true)\n    const p2 = S.combineMany(isPositive, [isLessThan2])\n    deepStrictEqual(p2(0), false)\n    deepStrictEqual(p2(-2), false)\n    deepStrictEqual(p2(1), true)\n  })\n\n  it(\"getMonoidAll\", () => {\n    const M = _.getMonoidAll<number>()\n    const predicate = M.combine(isPositive, M.empty)\n    deepStrictEqual(predicate(0), isPositive(0))\n    deepStrictEqual(predicate(-1), isPositive(-1))\n    deepStrictEqual(predicate(1), isPositive(1))\n  })\n\n  it(\"any\", () => {\n    const predicate = _.any([isPositive, isNegative])\n    deepStrictEqual(predicate(0), false)\n    deepStrictEqual(predicate(-1), true)\n    deepStrictEqual(predicate(1), true)\n  })\n\n  it(\"all\", () => {\n    const predicate = _.all([isPositive, isLessThan2])\n    deepStrictEqual(predicate(0), false)\n    deepStrictEqual(predicate(-2), false)\n    deepStrictEqual(predicate(1), true)\n  })\n\n  it(\"isFunction\", () => {\n    assert.deepStrictEqual(_.isFunction(_.isFunction), true)\n    assert.deepStrictEqual(_.isFunction(\"function\"), false)\n  })\n\n  it(\"isUndefined\", () => {\n    assert.deepStrictEqual(_.isUndefined(undefined), true)\n    assert.deepStrictEqual(_.isUndefined(null), false)\n    assert.deepStrictEqual(_.isUndefined(\"undefined\"), false)\n  })\n\n  it(\"isNotUndefined\", () => {\n    assert.deepStrictEqual(_.isNotUndefined(undefined), false)\n    assert.deepStrictEqual(_.isNotUndefined(null), true)\n    assert.deepStrictEqual(_.isNotUndefined(\"undefined\"), true)\n  })\n\n  it(\"isNull\", () => {\n    assert.deepStrictEqual(_.isNull(null), true)\n    assert.deepStrictEqual(_.isNull(undefined), false)\n    assert.deepStrictEqual(_.isNull(\"null\"), false)\n  })\n\n  it(\"isNotNull\", () => {\n    assert.deepStrictEqual(_.isNotNull(null), false)\n    assert.deepStrictEqual(_.isNotNull(undefined), true)\n    assert.deepStrictEqual(_.isNotNull(\"null\"), true)\n  })\n\n  it(\"isNever\", () => {\n    assert.deepStrictEqual(_.isNever(null), false)\n    assert.deepStrictEqual(_.isNever(undefined), false)\n    assert.deepStrictEqual(_.isNever({}), false)\n    assert.deepStrictEqual(_.isNever([]), false)\n  })\n\n  it(\"isUnknown\", () => {\n    assert.deepStrictEqual(_.isUnknown(null), true)\n    assert.deepStrictEqual(_.isUnknown(undefined), true)\n    assert.deepStrictEqual(_.isUnknown({}), true)\n    assert.deepStrictEqual(_.isUnknown([]), true)\n  })\n\n  it(\"isObject\", () => {\n    assert.deepStrictEqual(_.isObject({}), true)\n    assert.deepStrictEqual(_.isObject([]), true)\n    assert.deepStrictEqual(_.isObject(null), false)\n    assert.deepStrictEqual(_.isObject(undefined), false)\n  })\n\n  it(\"isNullable\", () => {\n    assert.deepStrictEqual(_.isNullable(null), true)\n    assert.deepStrictEqual(_.isNullable(undefined), true)\n    assert.deepStrictEqual(_.isNullable({}), false)\n    assert.deepStrictEqual(_.isNullable([]), false)\n  })\n\n  it(\"isNotNullable\", () => {\n    assert.deepStrictEqual(_.isNotNullable({}), true)\n    assert.deepStrictEqual(_.isNotNullable([]), true)\n    assert.deepStrictEqual(_.isNotNullable(null), false)\n    assert.deepStrictEqual(_.isNotNullable(undefined), false)\n  })\n\n  it(\"isError\", () => {\n    assert.deepStrictEqual(_.isError(new Error()), true)\n    assert.deepStrictEqual(_.isError(null), false)\n    assert.deepStrictEqual(_.isError({}), false)\n  })\n\n  it(\"isDate\", () => {\n    assert.deepStrictEqual(_.isDate(new Date()), true)\n    assert.deepStrictEqual(_.isDate(null), false)\n    assert.deepStrictEqual(_.isDate({}), false)\n  })\n\n  it(\"isRecord\", () => {\n    assert.deepStrictEqual(_.isRecord({}), true)\n    assert.deepStrictEqual(_.isRecord({ a: 1 }), true)\n\n    assert.deepStrictEqual(_.isRecord([]), false)\n    assert.deepStrictEqual(_.isRecord([1, 2, 3]), false)\n    assert.deepStrictEqual(_.isRecord(null), false)\n    assert.deepStrictEqual(_.isRecord(undefined), false)\n  })\n\n  it(\"isReadonlyRecord\", () => {\n    assert.deepStrictEqual(_.isReadonlyRecord({}), true)\n    assert.deepStrictEqual(_.isReadonlyRecord({ a: 1 }), true)\n\n    assert.deepStrictEqual(_.isReadonlyRecord([]), false)\n    assert.deepStrictEqual(_.isReadonlyRecord([1, 2, 3]), false)\n    assert.deepStrictEqual(_.isReadonlyRecord(null), false)\n    assert.deepStrictEqual(_.isReadonlyRecord(undefined), false)\n  })\n})\n"
  },
  {
    "path": "test/ReadonlyArray.ts",
    "content": "import * as E from \"@fp-ts/core/Either\"\nimport { identity, pipe } from \"@fp-ts/core/Function\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Option\"\nimport type { Predicate } from \"@fp-ts/core/Predicate\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as String from \"@fp-ts/core/String\"\nimport { deepStrictEqual, double, strictEqual } from \"@fp-ts/core/test/util\"\nimport * as Order from \"@fp-ts/core/typeclass/Order\"\nimport * as assert from \"assert\"\nimport * as fc from \"fast-check\"\n\ndescribe.concurrent(\"ReadonlyArray\", () => {\n  it(\"exports\", () => {\n    expect(RA.Invariant).exist\n    expect(RA.tupled).exist\n    expect(RA.bindTo).exist\n\n    expect(RA.Covariant).exist\n    expect(RA.map).exist\n    expect(RA.let).exist\n    expect(RA.flap).exist\n    expect(RA.as).exist\n\n    expect(RA.Of).exist\n    expect(RA.of).exist\n    expect(RA.Do).exist\n\n    expect(RA.Pointed).exist\n\n    expect(RA.FlatMap).exist\n    expect(RA.flatMap).exist\n    expect(RA.flatten).exist\n    expect(RA.composeKleisliArrow).exist\n\n    expect(RA.Chainable).exist\n    expect(RA.bind).exist\n\n    expect(RA.Monad).exist\n\n    expect(RA.SemiProduct).exist\n    expect(RA.andThenBind).exist\n\n    expect(RA.Product).exist\n\n    expect(RA.SemiApplicative).exist\n    expect(RA.lift2).exist\n    expect(RA.ap).exist\n\n    expect(RA.Applicative).exist\n    expect(RA.liftMonoid).exist\n\n    expect(RA.Foldable).exist\n    expect(RA.reduce).exist\n    expect(RA.reduceRight).exist\n    expect(RA.reduceKind).exist\n    expect(RA.coproductMapKind).exist\n\n    expect(RA.Traversable).exist\n    expect(RA.traverse).exist\n    expect(RA.sequence).exist\n    expect(RA.traverseTap).exist\n\n    expect(RA.compact).exist\n\n    expect(RA.Filterable).exist\n    expect(RA.filterMap).exist\n    expect(RA.filter).exist\n    expect(RA.partition).exist\n    expect(RA.partitionMap).exist\n\n    expect(RA.TraversableFilterable).exist\n    expect(RA.traverseFilter).exist\n    expect(RA.traversePartition).exist\n\n    expect(RA.liftPredicate).exist\n    expect(RA.liftOption).exist\n    expect(RA.liftNullable).exist\n    expect(RA.flatMapNullable).exist\n  })\n\n  it(\"fromIterable/Array should return the same reference if the iterable is an Array\", () => {\n    const i = [1, 2, 3]\n    expect(RA.fromIterable(i) === i).toEqual(true)\n  })\n\n  it(\"fromIterable/Iterable\", () => {\n    expect(RA.fromIterable(new Set([1, 2, 3]))).toEqual([1, 2, 3])\n  })\n\n  describe(\"iterable inputs\", () => {\n    it(\"prepend\", () => {\n      deepStrictEqual(pipe([1, 2, 3], RA.prepend(0)), [0, 1, 2, 3])\n      deepStrictEqual(pipe([[2]], RA.prepend([1])), [[1], [2]])\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.prepend(0)), [0, 1, 2, 3])\n      deepStrictEqual(pipe(new Set([[2]]), RA.prepend([1])), [[1], [2]])\n    })\n\n    it(\"prependAll\", () => {\n      deepStrictEqual(pipe([3, 4], RA.prependAll([1, 2])), [1, 2, 3, 4])\n\n      deepStrictEqual(pipe([3, 4], RA.prependAll(new Set([1, 2]))), [1, 2, 3, 4])\n      deepStrictEqual(pipe(new Set([3, 4]), RA.prependAll([1, 2])), [1, 2, 3, 4])\n    })\n\n    it(\"prependAllNonEmpty\", () => {\n      deepStrictEqual(pipe([3, 4], RA.prependAllNonEmpty([1, 2])), [1, 2, 3, 4])\n\n      deepStrictEqual(pipe(RA.make(3, 4), RA.prependAllNonEmpty(new Set([1, 2]))), [1, 2, 3, 4])\n      deepStrictEqual(pipe(new Set([3, 4]), RA.prependAllNonEmpty([1, 2])), [1, 2, 3, 4])\n    })\n\n    it(\"append\", () => {\n      deepStrictEqual(pipe([1, 2, 3], RA.append(4)), [1, 2, 3, 4])\n      deepStrictEqual(pipe([[1]], RA.append([2])), [[1], [2]])\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.append(4)), [1, 2, 3, 4])\n      deepStrictEqual(pipe(new Set([[1]]), RA.append([2])), [[1], [2]])\n    })\n\n    it(\"appendAll\", () => {\n      deepStrictEqual(pipe([1, 2], RA.appendAll([3, 4])), [1, 2, 3, 4])\n\n      deepStrictEqual(pipe([1, 2], RA.appendAll(new Set([3, 4]))), [1, 2, 3, 4])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.appendAll([3, 4])), [1, 2, 3, 4])\n    })\n\n    it(\"appendAllNonEmpty\", () => {\n      deepStrictEqual(pipe([1, 2], RA.appendAllNonEmpty([3, 4])), [1, 2, 3, 4])\n\n      deepStrictEqual(pipe(RA.make(1, 2), RA.appendAllNonEmpty(new Set([3, 4]))), [1, 2, 3, 4])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.appendAllNonEmpty([3, 4])), [1, 2, 3, 4])\n    })\n\n    it(\"scan\", () => {\n      const f = (b: number, a: number) => b - a\n      deepStrictEqual(pipe([1, 2, 3], RA.scan(10, f)), [10, 9, 7, 4])\n      deepStrictEqual(pipe([0], RA.scan(10, f)), [10, 10])\n      deepStrictEqual(pipe([], RA.scan(10, f)), [10])\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.scan(10, f)), [10, 9, 7, 4])\n      deepStrictEqual(pipe(new Set([0]), RA.scan(10, f)), [10, 10])\n      deepStrictEqual(pipe(new Set([]), RA.scan(10, f)), [10])\n    })\n\n    it(\"scanRight\", () => {\n      const f = (b: number, a: number) => a - b\n      deepStrictEqual(pipe([1, 2, 3], RA.scanRight(10, f)), [-8, 9, -7, 10])\n      deepStrictEqual(pipe([0], RA.scanRight(10, f)), [-10, 10])\n      deepStrictEqual(pipe([], RA.scanRight(10, f)), [10])\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.scanRight(10, f)), [-8, 9, -7, 10])\n      deepStrictEqual(pipe(new Set([0]), RA.scanRight(10, f)), [-10, 10])\n      deepStrictEqual(pipe(new Set([]), RA.scanRight(10, f)), [10])\n    })\n\n    it(\"tail\", () => {\n      deepStrictEqual(RA.tail([1, 2, 3]), O.some([2, 3]))\n      deepStrictEqual(RA.tail([]), O.none())\n\n      deepStrictEqual(RA.tail(new Set([1, 2, 3])), O.some([2, 3]))\n      deepStrictEqual(RA.tail(new Set([])), O.none())\n    })\n\n    it(\"init\", () => {\n      deepStrictEqual(RA.init([1, 2, 3]), O.some([1, 2]))\n      deepStrictEqual(RA.init([]), O.none())\n\n      deepStrictEqual(RA.init(new Set([1, 2, 3])), O.some([1, 2]))\n      deepStrictEqual(RA.init(new Set([])), O.none())\n    })\n\n    it(\"take\", () => {\n      expect(pipe([1, 2, 3, 4], RA.take(2))).toEqual([1, 2])\n      expect(pipe([1, 2, 3, 4], RA.take(0))).toEqual([])\n      // out of bounds\n      expect(pipe([1, 2, 3, 4], RA.take(-10))).toEqual([])\n      expect(pipe([1, 2, 3, 4], RA.take(10))).toEqual([1, 2, 3, 4])\n\n      expect(pipe(new Set([1, 2, 3, 4]), RA.take(2))).toEqual([1, 2])\n      expect(pipe(new Set([1, 2, 3, 4]), RA.take(0))).toEqual([])\n      // out of bounds\n      expect(pipe(new Set([1, 2, 3, 4]), RA.take(-10))).toEqual([])\n      expect(pipe(new Set([1, 2, 3, 4]), RA.take(10))).toEqual([1, 2, 3, 4])\n    })\n\n    it(\"takeRight\", () => {\n      deepStrictEqual(pipe(RA.empty(), RA.takeRight(0)), [])\n      deepStrictEqual(pipe([1, 2], RA.takeRight(0)), [])\n      deepStrictEqual(pipe([1, 2], RA.takeRight(1)), [2])\n      deepStrictEqual(pipe([1, 2], RA.takeRight(2)), [1, 2])\n      // out of bound\n      deepStrictEqual(pipe(RA.empty(), RA.takeRight(1)), [])\n      deepStrictEqual(pipe(RA.empty(), RA.takeRight(-1)), [])\n      deepStrictEqual(pipe([1, 2], RA.takeRight(3)), [1, 2])\n      deepStrictEqual(pipe([1, 2], RA.takeRight(-1)), [])\n\n      deepStrictEqual(pipe(new Set(), RA.takeRight(0)), [])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.takeRight(0)), [])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.takeRight(1)), [2])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.takeRight(2)), [1, 2])\n      // out of bound\n      deepStrictEqual(pipe(new Set(), RA.takeRight(1)), [])\n      deepStrictEqual(pipe(new Set(), RA.takeRight(-1)), [])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.takeRight(3)), [1, 2])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.takeRight(-1)), [])\n    })\n\n    it(\"takeWhile\", () => {\n      const f = (n: number) => n % 2 === 0\n      deepStrictEqual(pipe([2, 4, 3, 6], RA.takeWhile(f)), [2, 4])\n      deepStrictEqual(pipe(RA.empty(), RA.takeWhile(f)), [])\n      deepStrictEqual(pipe([1, 2, 4], RA.takeWhile(f)), [])\n      deepStrictEqual(pipe([2, 4], RA.takeWhile(f)), [2, 4])\n\n      deepStrictEqual(pipe(new Set([2, 4, 3, 6]), RA.takeWhile(f)), [2, 4])\n      deepStrictEqual(pipe(new Set<number>(), RA.takeWhile(f)), [])\n      deepStrictEqual(pipe(new Set([1, 2, 4]), RA.takeWhile(f)), [])\n      deepStrictEqual(pipe(new Set([2, 4]), RA.takeWhile(f)), [2, 4])\n    })\n\n    it(\"span\", () => {\n      const f = RA.span((n: number) => n % 2 === 1)\n      const assertSpan = (\n        input: Iterable<number>,\n        expectedInit: ReadonlyArray<number>,\n        expectedRest: ReadonlyArray<number>\n      ) => {\n        const [init, rest] = f(input)\n        deepStrictEqual(init, expectedInit)\n        deepStrictEqual(rest, expectedRest)\n      }\n      assertSpan([1, 3, 2, 4, 5], [1, 3], [2, 4, 5])\n      assertSpan(RA.empty(), RA.empty(), RA.empty())\n      assertSpan([1, 3], [1, 3], RA.empty())\n      assertSpan([2, 4], RA.empty(), [2, 4])\n\n      assertSpan(new Set([1, 3, 2, 4, 5]), [1, 3], [2, 4, 5])\n      assertSpan(new Set(), RA.empty(), RA.empty())\n      assertSpan(new Set([1, 3]), [1, 3], RA.empty())\n      assertSpan(new Set([2, 4]), RA.empty(), [2, 4])\n    })\n\n    it(\"drop\", () => {\n      deepStrictEqual(pipe(RA.empty(), RA.drop(0)), [])\n      deepStrictEqual(pipe([1, 2], RA.drop(0)), [1, 2])\n      deepStrictEqual(pipe([1, 2], RA.drop(1)), [2])\n      deepStrictEqual(pipe([1, 2], RA.drop(2)), [])\n      // out of bound\n      deepStrictEqual(pipe(RA.empty(), RA.drop(1)), [])\n      deepStrictEqual(pipe(RA.empty(), RA.drop(-1)), [])\n      deepStrictEqual(pipe([1, 2], RA.drop(3)), [])\n      deepStrictEqual(pipe([1, 2], RA.drop(-1)), [1, 2])\n\n      deepStrictEqual(pipe(new Set(), RA.drop(0)), [])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.drop(0)), [1, 2])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.drop(1)), [2])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.drop(2)), [])\n      // out of bound\n      deepStrictEqual(pipe(new Set(), RA.drop(1)), [])\n      deepStrictEqual(pipe(new Set(), RA.drop(-1)), [])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.drop(3)), [])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.drop(-1)), [1, 2])\n    })\n\n    it(\"dropRight\", () => {\n      deepStrictEqual(pipe([], RA.dropRight(0)), [])\n      deepStrictEqual(pipe([1, 2], RA.dropRight(0)), [1, 2])\n      deepStrictEqual(pipe([1, 2], RA.dropRight(1)), [1])\n      deepStrictEqual(pipe([1, 2], RA.dropRight(2)), [])\n      // out of bound\n      deepStrictEqual(pipe([], RA.dropRight(1)), [])\n      deepStrictEqual(pipe([1, 2], RA.dropRight(3)), [])\n      deepStrictEqual(pipe([], RA.dropRight(-1)), [])\n      deepStrictEqual(pipe([1, 2], RA.dropRight(-1)), [1, 2])\n\n      deepStrictEqual(pipe(new Set(), RA.dropRight(0)), [])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.dropRight(0)), [1, 2])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.dropRight(1)), [1])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.dropRight(2)), [])\n      // out of bound\n      deepStrictEqual(pipe(new Set(), RA.dropRight(1)), [])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.dropRight(3)), [])\n      deepStrictEqual(pipe(new Set(), RA.dropRight(-1)), [])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.dropRight(-1)), [1, 2])\n    })\n\n    it(\"dropWhile\", () => {\n      const f = RA.dropWhile((n: number) => n > 0)\n\n      deepStrictEqual(f([]), [])\n      deepStrictEqual(f([1, 2]), RA.empty())\n      deepStrictEqual(f([-1, -2]), [-1, -2])\n      deepStrictEqual(f([-1, 2]), [-1, 2])\n      deepStrictEqual(f([1, -2, 3]), [-2, 3])\n\n      deepStrictEqual(f(new Set<number>()), [])\n      deepStrictEqual(f(new Set([1, 2])), RA.empty())\n      deepStrictEqual(f(new Set([-1, -2])), [-1, -2])\n      deepStrictEqual(f(new Set([-1, 2])), [-1, 2])\n      deepStrictEqual(f(new Set([1, -2, 3])), [-2, 3])\n    })\n\n    it(\"findFirstIndex\", () => {\n      deepStrictEqual(pipe([], RA.findFirstIndex((n) => n % 2 === 0)), O.none())\n      deepStrictEqual(pipe([1, 2, 3], RA.findFirstIndex((n) => n % 2 === 0)), O.some(1))\n      deepStrictEqual(pipe([1, 2, 3, 1], RA.findFirstIndex((n) => n % 2 === 0)), O.some(1))\n\n      deepStrictEqual(pipe(new Set<number>(), RA.findFirstIndex((n) => n % 2 === 0)), O.none())\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.findFirstIndex((n) => n % 2 === 0)), O.some(1))\n      deepStrictEqual(pipe(new Set([1, 2, 3, 4]), RA.findFirstIndex((n) => n % 2 === 0)), O.some(1))\n    })\n\n    it(\"findLastIndex\", () => {\n      deepStrictEqual(pipe([], RA.findLastIndex((n) => n % 2 === 0)), O.none())\n      deepStrictEqual(pipe([1, 2, 3], RA.findLastIndex((n) => n % 2 === 0)), O.some(1))\n      deepStrictEqual(pipe([1, 2, 3, 4], RA.findLastIndex((n) => n % 2 === 0)), O.some(3))\n\n      deepStrictEqual(pipe(new Set<number>(), RA.findLastIndex((n) => n % 2 === 0)), O.none())\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.findLastIndex((n) => n % 2 === 0)), O.some(1))\n      deepStrictEqual(pipe(new Set([1, 2, 3, 4]), RA.findLastIndex((n) => n % 2 === 0)), O.some(3))\n    })\n\n    it(\"findFirst\", () => {\n      deepStrictEqual(pipe([], RA.findFirst((n) => n % 2 === 0)), O.none())\n      deepStrictEqual(pipe([1, 2, 3], RA.findFirst((n) => n % 2 === 0)), O.some(2))\n      deepStrictEqual(pipe([1, 2, 3, 4], RA.findFirst((n) => n % 2 === 0)), O.some(2))\n\n      deepStrictEqual(pipe(new Set<number>(), RA.findFirst((n) => n % 2 === 0)), O.none())\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.findFirst((n) => n % 2 === 0)), O.some(2))\n      deepStrictEqual(pipe(new Set([1, 2, 3, 4]), RA.findFirst((n) => n % 2 === 0)), O.some(2))\n    })\n\n    it(\"findLast\", () => {\n      deepStrictEqual(pipe([], RA.findLast((n) => n % 2 === 0)), O.none())\n      deepStrictEqual(pipe([1, 2, 3], RA.findLast((n) => n % 2 === 0)), O.some(2))\n      deepStrictEqual(pipe([1, 2, 3, 4], RA.findLast((n) => n % 2 === 0)), O.some(4))\n\n      deepStrictEqual(pipe(new Set<number>(), RA.findLast((n) => n % 2 === 0)), O.none())\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.findLast((n) => n % 2 === 0)), O.some(2))\n      deepStrictEqual(pipe(new Set([1, 2, 3, 4]), RA.findLast((n) => n % 2 === 0)), O.some(4))\n    })\n\n    it(\"insertAt\", () => {\n      deepStrictEqual(RA.insertAt(1, 1)([]), O.none())\n      deepStrictEqual(RA.insertAt(0, 1)([]), O.some([1]))\n      deepStrictEqual(RA.insertAt(2, 5)([1, 2, 3, 4]), O.some([1, 2, 5, 3, 4]))\n      // out of bound\n      deepStrictEqual(RA.insertAt(-1, 5)([1, 2, 3, 4]), O.none())\n      deepStrictEqual(RA.insertAt(10, 5)([1, 2, 3, 4]), O.none())\n\n      deepStrictEqual(RA.insertAt(1, 1)(new Set([])), O.none())\n      deepStrictEqual(RA.insertAt(0, 1)(new Set([])), O.some([1]))\n      deepStrictEqual(RA.insertAt(2, 5)(new Set([1, 2, 3, 4])), O.some([1, 2, 5, 3, 4]))\n      // out of bound\n      deepStrictEqual(RA.insertAt(-1, 5)(new Set([1, 2, 3, 4])), O.none())\n      deepStrictEqual(RA.insertAt(10, 5)(new Set([1, 2, 3, 4])), O.none())\n    })\n\n    it(\"replace\", () => {\n      deepStrictEqual(pipe([1, 2, 3], RA.replace(1, \"a\")), [1, \"a\", 3])\n      // out of bound\n      deepStrictEqual(pipe([], RA.replace(1, \"a\")), [])\n      deepStrictEqual(pipe([1, 2, 3], RA.replace(-1, \"a\")), [1, 2, 3])\n      deepStrictEqual(pipe([1, 2, 3], RA.replace(10, \"a\")), [1, 2, 3])\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.replace(1, \"a\")), [1, \"a\", 3])\n      // out of bound\n      deepStrictEqual(pipe(new Set([]), RA.replace(1, \"a\")), [])\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.replace(-1, \"a\")), [1, 2, 3])\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.replace(10, \"a\")), [1, 2, 3])\n    })\n\n    it(\"replaceOption\", () => {\n      deepStrictEqual(pipe([1, 2, 3], RA.replaceOption(1, \"a\")), O.some([1, \"a\", 3]))\n      // out of bound\n      deepStrictEqual(pipe([], RA.replaceOption(1, \"a\")), O.none())\n      deepStrictEqual(pipe([1, 2, 3], RA.replaceOption(-1, \"a\")), O.none())\n      deepStrictEqual(pipe([1, 2, 3], RA.replaceOption(10, \"a\")), O.none())\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.replaceOption(1, \"a\")), O.some([1, \"a\", 3]))\n      // out of bound\n      deepStrictEqual(pipe(new Set([]), RA.replaceOption(1, \"a\")), O.none())\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.replaceOption(-1, \"a\")), O.none())\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.replaceOption(10, \"a\")), O.none())\n    })\n\n    it(\"modify\", () => {\n      deepStrictEqual(pipe([1, 2, 3], RA.modify(1, double)), [1, 4, 3])\n      // out of bound\n      deepStrictEqual(pipe([], RA.modify(1, double)), [])\n      deepStrictEqual(pipe([1, 2, 3], RA.modify(10, double)), [1, 2, 3])\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.modify(1, double)), [1, 4, 3])\n      // out of bound\n      deepStrictEqual(pipe(new Set([]), RA.modify(1, double)), [])\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.modify(10, double)), [1, 2, 3])\n    })\n\n    it(\"modifyOption\", () => {\n      deepStrictEqual(pipe([1, 2, 3], RA.modifyOption(1, double)), O.some([1, 4, 3]))\n      // out of bound\n      deepStrictEqual(pipe([], RA.modifyOption(1, double)), O.none())\n      deepStrictEqual(pipe([1, 2, 3], RA.modifyOption(10, double)), O.none())\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.modifyOption(1, double)), O.some([1, 4, 3]))\n      // out of bound\n      deepStrictEqual(pipe(new Set([]), RA.modifyOption(1, double)), O.none())\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.modifyOption(10, double)), O.none())\n    })\n\n    it(\"remove\", () => {\n      deepStrictEqual(pipe([1, 2, 3], RA.remove(0)), [2, 3])\n      // out of bound\n      deepStrictEqual(pipe([], RA.remove(0)), [])\n      deepStrictEqual(pipe([1, 2, 3], RA.remove(-1)), [1, 2, 3])\n      deepStrictEqual(pipe([1, 2, 3], RA.remove(10)), [1, 2, 3])\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.remove(0)), [2, 3])\n      // out of bound\n      deepStrictEqual(pipe(new Set([]), RA.remove(0)), [])\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.remove(-1)), [1, 2, 3])\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.remove(10)), [1, 2, 3])\n    })\n\n    it(\"reverse\", () => {\n      deepStrictEqual(RA.reverse([]), [])\n      deepStrictEqual(RA.reverse([1]), [1])\n      deepStrictEqual(RA.reverse([1, 2, 3]), [3, 2, 1])\n\n      deepStrictEqual(RA.reverse(new Set([])), [])\n      deepStrictEqual(RA.reverse(new Set([1])), [1])\n      deepStrictEqual(RA.reverse(new Set([1, 2, 3])), [3, 2, 1])\n    })\n\n    it(\"rights\", () => {\n      deepStrictEqual(RA.rights([]), [])\n      deepStrictEqual(RA.rights([E.right(1), E.left(\"a\"), E.right(2)]), [1, 2])\n\n      deepStrictEqual(RA.rights(new Set<E.Either<unknown, unknown>>()), [])\n      deepStrictEqual(RA.rights(new Set([E.right(1), E.left(\"a\"), E.right(2)])), [1, 2])\n    })\n\n    it(\"lefts\", () => {\n      deepStrictEqual(RA.lefts([]), [])\n      deepStrictEqual(RA.lefts([E.right(1), E.left(\"a\"), E.right(2)]), [\"a\"])\n\n      deepStrictEqual(RA.lefts(new Set<E.Either<unknown, unknown>>()), [])\n      deepStrictEqual(RA.lefts(new Set([E.right(1), E.left(\"a\"), E.right(2)])), [\"a\"])\n    })\n\n    it(\"sort\", () => {\n      deepStrictEqual(RA.sort(Number.Order)([]), [])\n      deepStrictEqual(RA.sort(Number.Order)([1, 3, 2]), [1, 2, 3])\n\n      deepStrictEqual(RA.sort(Number.Order)(new Set<number>()), [])\n      deepStrictEqual(RA.sort(Number.Order)(new Set([1, 3, 2])), [1, 2, 3])\n    })\n\n    it(\"zip\", () => {\n      deepStrictEqual(pipe(new Set([]), RA.zip(new Set([\"a\", \"b\", \"c\", \"d\"]))), [])\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.zip(new Set([]))), [])\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.zip(new Set([\"a\", \"b\", \"c\", \"d\"]))), [\n        [1, \"a\"],\n        [2, \"b\"],\n        [3, \"c\"]\n      ])\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.zip(new Set([\"a\", \"b\", \"c\", \"d\"]))), [\n        [1, \"a\"],\n        [2, \"b\"],\n        [3, \"c\"]\n      ])\n    })\n\n    it(\"zipWith\", () => {\n      deepStrictEqual(\n        pipe(new Set([1, 2, 3]), RA.zipWith(new Set([]), (n, s) => s + n)),\n        []\n      )\n      deepStrictEqual(\n        pipe(new Set([]), RA.zipWith(new Set([\"a\", \"b\", \"c\", \"d\"]), (n, s) => s + n)),\n        []\n      )\n      deepStrictEqual(\n        pipe(new Set([]), RA.zipWith(new Set([]), (n, s) => s + n)),\n        []\n      )\n      deepStrictEqual(\n        pipe(new Set([1, 2, 3]), RA.zipWith(new Set([\"a\", \"b\", \"c\", \"d\"]), (n, s) => s + n)),\n        [\"a1\", \"b2\", \"c3\"]\n      )\n    })\n\n    it(\"unzip\", () => {\n      deepStrictEqual(RA.unzip(new Set([])), [[], []])\n      deepStrictEqual(\n        RA.unzip(\n          new Set([\n            [1, \"a\"],\n            [2, \"b\"],\n            [3, \"c\"]\n          ])\n        ),\n        [\n          [1, 2, 3],\n          [\"a\", \"b\", \"c\"]\n        ]\n      )\n    })\n\n    it(\"intersperse\", () => {\n      deepStrictEqual(pipe([], RA.intersperse(0)), [])\n      deepStrictEqual(pipe([1], RA.intersperse(0)), [1])\n      deepStrictEqual(pipe([1, 2, 3], RA.intersperse(0)), [1, 0, 2, 0, 3])\n      deepStrictEqual(pipe([1, 2], RA.intersperse(0)), [1, 0, 2])\n      deepStrictEqual(pipe([1, 2, 3, 4], RA.intersperse(0)), [1, 0, 2, 0, 3, 0, 4])\n\n      deepStrictEqual(pipe(new Set([]), RA.intersperse(0)), [])\n      deepStrictEqual(pipe(new Set([1]), RA.intersperse(0)), [1])\n      deepStrictEqual(pipe(new Set([1, 2, 3]), RA.intersperse(0)), [1, 0, 2, 0, 3])\n      deepStrictEqual(pipe(new Set([1, 2]), RA.intersperse(0)), [1, 0, 2])\n      deepStrictEqual(pipe(new Set([1, 2, 3, 4]), RA.intersperse(0)), [1, 0, 2, 0, 3, 0, 4])\n    })\n\n    it(\"rotate\", () => {\n      deepStrictEqual(RA.rotate(0)(RA.empty()), RA.empty())\n      deepStrictEqual(RA.rotate(1)(RA.empty()), RA.empty())\n      deepStrictEqual(RA.rotate(1)([1]), [1])\n      deepStrictEqual(RA.rotate(2)([1]), [1])\n      deepStrictEqual(RA.rotate(-1)([1]), [1])\n      deepStrictEqual(RA.rotate(-2)([1]), [1])\n      deepStrictEqual(RA.rotate(2)([1, 2]), [1, 2])\n      deepStrictEqual(RA.rotate(0)([1, 2]), [1, 2])\n      deepStrictEqual(RA.rotate(-2)([1, 2]), [1, 2])\n      deepStrictEqual(RA.rotate(1)([1, 2]), [2, 1])\n      deepStrictEqual(RA.rotate(1)(new Set([1, 2, 3, 4, 5])), [5, 1, 2, 3, 4])\n      deepStrictEqual(RA.rotate(2)(new Set([1, 2, 3, 4, 5])), [4, 5, 1, 2, 3])\n      deepStrictEqual(RA.rotate(-1)(new Set([1, 2, 3, 4, 5])), [2, 3, 4, 5, 1])\n      deepStrictEqual(RA.rotate(-2)(new Set([1, 2, 3, 4, 5])), [3, 4, 5, 1, 2])\n      // out of bounds\n      deepStrictEqual(RA.rotate(7)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n      deepStrictEqual(RA.rotate(-7)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n      deepStrictEqual(RA.rotate(2.2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n      deepStrictEqual(RA.rotate(-2.2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n    })\n\n    it(\"contains\", () => {\n      const contains = RA.contains(Number.Equivalence)\n      deepStrictEqual(pipe([1, 2, 3], contains(2)), true)\n      deepStrictEqual(pipe([1, 2, 3], contains(0)), false)\n\n      deepStrictEqual(pipe(new Set([1, 2, 3]), contains(2)), true)\n      deepStrictEqual(pipe(new Set([1, 2, 3]), contains(0)), false)\n    })\n\n    it(\"uniq\", () => {\n      const uniq = RA.uniq(Number.Equivalence)\n      deepStrictEqual(uniq([]), [])\n      deepStrictEqual(uniq([-0, -0]), [-0])\n      deepStrictEqual(uniq([0, -0]), [0])\n      deepStrictEqual(uniq([1]), [1])\n      deepStrictEqual(uniq([2, 1, 2]), [2, 1])\n      deepStrictEqual(uniq([1, 2, 1]), [1, 2])\n      deepStrictEqual(uniq([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n      deepStrictEqual(uniq([1, 1, 2, 2, 3, 3, 4, 4, 5, 5]), [1, 2, 3, 4, 5])\n      deepStrictEqual(uniq([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n    })\n\n    it(\"splitAt\", () => {\n      const assertSplitAt = (\n        input: ReadonlyArray<number>,\n        index: number,\n        expectedInit: ReadonlyArray<number>,\n        expectedRest: ReadonlyArray<number>\n      ) => {\n        const [init, rest] = RA.splitAt(index)(input)\n        deepStrictEqual(init, expectedInit)\n        deepStrictEqual(rest, expectedRest)\n      }\n      deepStrictEqual(RA.splitAt(1)([1, 2]), [[1], [2]])\n      assertSplitAt([1, 2], 2, [1, 2], [])\n      deepStrictEqual(RA.splitAt(2)([1, 2, 3, 4, 5]), [\n        [1, 2],\n        [3, 4, 5]\n      ])\n      deepStrictEqual(RA.splitAt(2)(new Set([1, 2, 3, 4, 5])), [\n        [1, 2],\n        [3, 4, 5]\n      ])\n      assertSplitAt([], 0, [], [])\n      assertSplitAt([1, 2], 0, [], [1, 2])\n\n      // out of bounds\n      assertSplitAt([], -1, [], [])\n      assertSplitAt([1, 2], -1, [], [1, 2])\n      assertSplitAt([1, 2], 3, [1, 2], [])\n      assertSplitAt([], 3, [], [])\n    })\n  })\n\n  it(\"splitNonEmptyAt\", () => {\n    deepStrictEqual(pipe(RA.make(1, 2, 3, 4), RA.splitNonEmptyAt(2)), [[1, 2], [3, 4]])\n  })\n\n  it(\"rotateNonEmpty\", () => {\n    deepStrictEqual(RA.rotateNonEmpty(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n  })\n\n  it(\"intersperseNonEmpty\", () => {\n    deepStrictEqual(pipe(RA.make(1), RA.intersperseNonEmpty(0)), [1])\n    deepStrictEqual(pipe(RA.make(1, 2, 3), RA.intersperseNonEmpty(0)), [1, 0, 2, 0, 3])\n  })\n\n  it(\"sortNonEmpty\", () => {\n    deepStrictEqual(RA.sortNonEmpty(Number.Order)([1]), [1])\n    deepStrictEqual(RA.sortNonEmpty(Number.Order)([1, 3, 2]), [1, 2, 3])\n  })\n\n  describe(\"unsafeGet\", () => {\n    it(\"should throw on index out of bound\", () => {\n      expect(() => pipe([], RA.unsafeGet(100))).toThrowError(new Error(\"Index 100 out of bounds\"))\n    })\n  })\n\n  it(\"fromNullable\", () => {\n    deepStrictEqual(RA.fromNullable(undefined), [])\n    deepStrictEqual(RA.fromNullable(null), [])\n    deepStrictEqual(RA.fromNullable(1), [1])\n  })\n\n  it(\"liftNullable\", () => {\n    const f = RA.liftNullable((n: number) => (n > 0 ? n : null))\n    deepStrictEqual(f(1), [1])\n    deepStrictEqual(f(-1), [])\n  })\n\n  it(\"flatMapNullable\", () => {\n    const f = RA.flatMapNullable((n: number) => (n > 0 ? n : null))\n    deepStrictEqual(pipe([], f), [])\n    deepStrictEqual(pipe([1], f), [1])\n    deepStrictEqual(pipe([-1], f), [])\n  })\n\n  it(\"liftPredicate\", () => {\n    const p = (n: number): boolean => n > 2\n    const f = RA.liftPredicate(p)\n    deepStrictEqual(f(1), [])\n    deepStrictEqual(f(3), [3])\n  })\n\n  it(\"liftOption\", () => {\n    const f = RA.liftOption((n: number) => (n > 0 ? O.some(n) : O.none()))\n    deepStrictEqual(f(1), [1])\n    deepStrictEqual(f(-1), [])\n  })\n\n  it(\"unprepend\", () => {\n    deepStrictEqual(RA.unprepend([0]), [0, []])\n    deepStrictEqual(RA.unprepend([1, 2, 3, 4]), [1, [2, 3, 4]])\n  })\n\n  it(\"unappend\", () => {\n    deepStrictEqual(RA.unappend([0]), [[], 0])\n    deepStrictEqual(RA.unappend([1, 2, 3, 4]), [\n      RA.make(1, 2, 3),\n      4\n    ])\n    deepStrictEqual(RA.unappend([0]), [[], 0])\n    deepStrictEqual(RA.unappend([1, 2, 3, 4]), [\n      RA.make(1, 2, 3),\n      4\n    ])\n  })\n\n  it(\"modifyNonEmptyHead\", () => {\n    const f = (s: string) => s + \"!\"\n    deepStrictEqual(pipe([\"a\"], RA.modifyNonEmptyHead(f)), [\"a!\"])\n    deepStrictEqual(pipe([\"a\", \"b\"], RA.modifyNonEmptyHead(f)), [\"a!\", \"b\"])\n    deepStrictEqual(pipe([\"a\", \"b\", \"c\"], RA.modifyNonEmptyHead(f)), [\"a!\", \"b\", \"c\"])\n  })\n\n  it(\"modifyNonEmptyLast\", () => {\n    const f = (s: string) => s + \"!\"\n    deepStrictEqual(pipe([\"a\"], RA.modifyNonEmptyLast(f)), [\"a!\"])\n    deepStrictEqual(pipe([\"a\", \"b\"], RA.modifyNonEmptyLast(f)), [\"a\", \"b!\"])\n    deepStrictEqual(pipe([\"a\", \"b\", \"c\"], RA.modifyNonEmptyLast(f)), [\"a\", \"b\", \"c!\"])\n  })\n\n  it(\"setNonEmptyHead\", () => {\n    deepStrictEqual(pipe(RA.make(\"a\"), RA.setNonEmptyHead(\"d\")), [\"d\"])\n    deepStrictEqual(pipe(RA.make(\"a\", \"b\"), RA.setNonEmptyHead(\"d\")), [\"d\", \"b\"])\n    deepStrictEqual(pipe(RA.make(\"a\", \"b\", \"c\"), RA.setNonEmptyHead(\"d\")), [\"d\", \"b\", \"c\"])\n  })\n\n  it(\"setNonEmptyLast\", () => {\n    deepStrictEqual(pipe(RA.make(\"a\"), RA.setNonEmptyLast(\"d\")), [\"d\"])\n    deepStrictEqual(pipe(RA.make(\"a\", \"b\"), RA.setNonEmptyLast(\"d\")), [\"a\", \"d\"])\n    deepStrictEqual(pipe(RA.make(\"a\", \"b\", \"c\"), RA.setNonEmptyLast(\"d\")), [\"a\", \"b\", \"d\"])\n  })\n\n  it(\"liftEither\", () => {\n    const f = RA.liftEither((s: string) => s.length > 2 ? E.right(s.length) : E.left(\"e\"))\n    deepStrictEqual(f(\"a\"), [])\n    deepStrictEqual(f(\"aaa\"), [3])\n  })\n\n  it(\"headNonEmpty\", () => {\n    deepStrictEqual(RA.headNonEmpty(RA.make(1, 2)), 1)\n  })\n\n  it(\"tailNonEmpty\", () => {\n    deepStrictEqual(RA.tailNonEmpty(RA.make(1, 2)), [2])\n  })\n\n  it(\"lastNonEmpty\", () => {\n    deepStrictEqual(RA.lastNonEmpty(RA.make(1, 2, 3)), 3)\n    deepStrictEqual(RA.lastNonEmpty([1]), 1)\n  })\n\n  it(\"initNonEmpty\", () => {\n    deepStrictEqual(\n      RA.initNonEmpty(RA.make(1, 2, 3)),\n      RA.make(1, 2)\n    )\n    deepStrictEqual(RA.initNonEmpty([1]), [])\n  })\n\n  it(\"traverse\", () => {\n    const traverse = RA.traverse(O.Applicative)((\n      n: number\n    ): O.Option<number> => (n % 2 === 0 ? O.none() : O.some(n)))\n    deepStrictEqual(traverse([1, 2]), O.none())\n    deepStrictEqual(traverse([1, 3]), O.some([1, 3]))\n    deepStrictEqual(\n      pipe(\n        [\"a\", \"bb\"],\n        RA.traverse(O.Applicative)((\n          s,\n          i\n        ) => (s.length >= 1 ? O.some(s + i) : O.none()))\n      ),\n      O.some([\"a0\", \"bb1\"])\n    )\n    deepStrictEqual(\n      pipe(\n        [\"a\", \"bb\"],\n        RA.traverse(O.Applicative)((\n          s,\n          i\n        ) => (s.length > 1 ? O.some(s + i) : O.none()))\n      ),\n      O.none()\n    )\n  })\n\n  it(\"sequence\", () => {\n    const sequence = RA.sequence(O.Applicative)\n    deepStrictEqual(sequence([O.some(1), O.some(3)]), O.some([1, 3]))\n    deepStrictEqual(sequence([O.some(1), O.none()]), O.none())\n  })\n\n  it(\"get\", () => {\n    deepStrictEqual(pipe([1, 2, 3], RA.get(0)), O.some(1))\n    deepStrictEqual(pipe([1, 2, 3], RA.get(3)), O.none())\n  })\n\n  it(\"unfold\", () => {\n    const as = RA.unfold(5, (n) => (n > 0 ? O.some([n, n - 1]) : O.none()))\n    deepStrictEqual(as, [5, 4, 3, 2, 1])\n  })\n\n  it(\"map\", () => {\n    deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        RA.map((n) => n * 2)\n      ),\n      [2, 4, 6]\n    )\n    deepStrictEqual(\n      pipe(\n        [\"a\", \"b\"],\n        RA.map((s, i) => s + i)\n      ),\n      [\"a0\", \"b1\"]\n    )\n  })\n\n  it(\"ap\", () => {\n    deepStrictEqual(\n      pipe([(x: number) => x * 2, (x: number) => x * 3], RA.ap([1, 2, 3])),\n      [\n        2,\n        4,\n        6,\n        3,\n        6,\n        9\n      ]\n    )\n  })\n\n  it(\"flatMap\", () => {\n    deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        RA.flatMap((n) => [n, n + 1])\n      ),\n      [1, 2, 2, 3, 3, 4]\n    )\n    const f = RA.flatMap((n: number, i) => [n + i])\n    deepStrictEqual(pipe([], f), [])\n    deepStrictEqual(pipe([1, 2, 3], f), [1, 3, 5])\n  })\n\n  it(\"extend\", () => {\n    deepStrictEqual(pipe([1, 2, 3, 4], RA.extend(Number.sumAll)), [10, 9, 7, 4])\n    deepStrictEqual(pipe([1, 2, 3, 4], RA.extend(identity)), [\n      [1, 2, 3, 4],\n      [2, 3, 4],\n      [3, 4],\n      [4]\n    ])\n  })\n\n  it(\"combineMap\", () => {\n    deepStrictEqual(pipe([\"a\", \"b\", \"c\"], RA.combineMap(String.Monoid)(identity)), \"abc\")\n    deepStrictEqual(pipe([], RA.combineMap(String.Monoid)(identity)), \"\")\n  })\n\n  it(\"compact\", () => {\n    assert.deepStrictEqual(RA.compact([]), [])\n    assert.deepStrictEqual(RA.compact([O.some(1), O.some(2), O.some(3)]), [\n      1,\n      2,\n      3\n    ])\n    assert.deepStrictEqual(RA.compact([O.some(1), O.none(), O.some(3)]), [\n      1,\n      3\n    ])\n  })\n\n  it(\"separate\", () => {\n    assert.deepStrictEqual(RA.separate([]), [[], []])\n    assert.deepStrictEqual(pipe([E.right(1), E.left(\"e\"), E.right(2)], RA.separate), [\n      [\"e\"],\n      [1, 2]\n    ])\n  })\n\n  it(\"filter\", () => {\n    const g = (n: number) => n % 2 === 1\n    deepStrictEqual(pipe([1, 2, 3], RA.filter(g)), [1, 3])\n    const x = pipe(\n      [O.some(3), O.some(2), O.some(1)],\n      RA.filter(O.isSome)\n    )\n    assert.deepStrictEqual(x, [O.some(3), O.some(2), O.some(1)])\n    const y = pipe(\n      [O.some(3), O.none(), O.some(1)],\n      RA.filter(O.isSome)\n    )\n    assert.deepStrictEqual(y, [O.some(3), O.some(1)])\n\n    const f = (n: number) => n % 2 === 0\n    deepStrictEqual(pipe([\"a\", \"b\", \"c\"], RA.filter((_, i) => f(i))), [\n      \"a\",\n      \"c\"\n    ])\n  })\n\n  it(\"filterMap\", () => {\n    const f = (n: number) => (n % 2 === 0 ? O.none() : O.some(n))\n    deepStrictEqual(pipe([1, 2, 3], RA.filterMap(f)), [1, 3])\n    deepStrictEqual(pipe([], RA.filterMap(f)), [])\n    const g = (n: number, i: number) => ((i + n) % 2 === 0 ? O.none() : O.some(n))\n    deepStrictEqual(pipe([1, 2, 4], RA.filterMap(g)), [1, 2])\n    deepStrictEqual(pipe([], RA.filterMap(g)), [])\n  })\n\n  it(\"combineMap\", () => {\n    deepStrictEqual(\n      pipe(\n        [\"a\", \"b\"],\n        RA.combineMap(String.Monoid)((a, i) => i + a)\n      ),\n      \"0a1b\"\n    )\n  })\n\n  it(\"partitionMap\", () => {\n    deepStrictEqual(pipe([], RA.partitionMap(identity)), [[], []])\n    deepStrictEqual(\n      pipe(\n        [E.right(1), E.left(\"foo\"), E.right(2)],\n        RA.partitionMap(identity)\n      ),\n      [[\"foo\"], [1, 2]]\n    )\n    deepStrictEqual(\n      pipe(\n        [E.right(1), E.left(\"foo\"), E.right(2)],\n        RA.partitionMap((a, i) => pipe(a, E.filter((n) => n > i, () => \"err\")))\n      ),\n      [[\"foo\", \"err\"], [1]]\n    )\n  })\n\n  it(\"partition\", () => {\n    deepStrictEqual(\n      pipe([], RA.partition((n) => n > 2)),\n      [[], []]\n    )\n    deepStrictEqual(\n      pipe([1, 3], RA.partition((n) => n > 2)),\n      [[1], [3]]\n    )\n    deepStrictEqual(\n      pipe([], RA.partition((i, n) => i + n > 2)),\n      [[], []]\n    )\n    deepStrictEqual(\n      pipe([1, 2], RA.partition((i, n) => i + n > 2)),\n      [[1], [2]]\n    )\n  })\n\n  it(\"reduce\", () => {\n    deepStrictEqual(pipe([\"a\", \"b\", \"c\"], RA.reduce(\"\", (b, a) => b + a)), \"abc\")\n    deepStrictEqual(\n      pipe(\n        [\"a\", \"b\"],\n        RA.reduce(\"\", (b, a, i) => b + i + a)\n      ),\n      \"0a1b\"\n    )\n  })\n\n  it(\"reduceRight\", () => {\n    const f = (b: string, a: string) => b + a\n    deepStrictEqual(pipe([\"a\", \"b\", \"c\"], RA.reduceRight(\"\", f)), \"cba\")\n    deepStrictEqual(pipe([], RA.reduceRight(\"\", f)), \"\")\n    deepStrictEqual(\n      pipe(\n        [\"a\", \"b\"],\n        RA.reduceRight(\"\", (b, a, i) => b + i + a)\n      ),\n      \"1b0a\"\n    )\n  })\n\n  it(\"traverseNonEmpty\", () => {\n    const traverseNonEmpty = RA.traverseNonEmpty(O.Applicative)\n    deepStrictEqual(\n      pipe(\n        RA.make(1, 2, 3),\n        traverseNonEmpty((n) => (n >= 0 ? O.some(n) : O.none()))\n      ),\n      O.some(RA.make(1, 2, 3))\n    )\n    deepStrictEqual(\n      pipe(\n        RA.make(1, 2, 3),\n        traverseNonEmpty((n) => (n >= 2 ? O.some(n) : O.none()))\n      ),\n      O.none()\n    )\n    deepStrictEqual(\n      pipe(\n        RA.make(\"a\", \"bb\"),\n        RA.traverseNonEmpty(O.Applicative)((s, i) => (s.length >= 1 ? O.some(s + i) : O.none()))\n      ),\n      O.some(RA.make(\"a0\", \"bb1\"))\n    )\n    deepStrictEqual(\n      pipe(\n        RA.make(\"a\", \"bb\"),\n        RA.traverseNonEmpty(O.Applicative)((s, i) => (s.length > 1 ? O.some(s + i) : O.none()))\n      ),\n      O.none()\n    )\n  })\n\n  it(\"getMonoid\", () => {\n    const M = RA.getMonoid<number>()\n    deepStrictEqual(M.combine([1, 2], [3, 4]), [1, 2, 3, 4])\n    const x = [1, 2]\n    deepStrictEqual(M.combine(x, M.empty), x)\n    deepStrictEqual(M.combine(M.empty, x), x)\n\n    deepStrictEqual(M.combineAll([[1, 2], [3, 4, 5], [5, 6, 7, 1]]), [1, 2, 3, 4, 5, 5, 6, 7, 1])\n  })\n\n  it(\"getOrder\", () => {\n    const O = RA.getOrder(String.Order)\n    deepStrictEqual(O.compare([], []), 0)\n    deepStrictEqual(O.compare([\"a\"], [\"a\"]), 0)\n\n    deepStrictEqual(O.compare([\"a\"], [\"b\"]), -1)\n    deepStrictEqual(O.compare([\"b\"], [\"a\"]), 1)\n\n    deepStrictEqual(O.compare([], [\"a\"]), -1)\n    deepStrictEqual(O.compare([\"a\"], []), 1)\n    deepStrictEqual(O.compare([\"a\"], [\"a\", \"a\"]), -1)\n    deepStrictEqual(O.compare([\"b\"], [\"a\", \"a\"]), 1)\n\n    deepStrictEqual(O.compare([\"a\", \"a\"], [\"a\", \"a\"]), 0)\n    deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"b\"]), 0)\n\n    deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"a\"]), 1)\n    deepStrictEqual(O.compare([\"a\", \"a\"], [\"a\", \"b\"]), -1)\n\n    deepStrictEqual(O.compare([\"b\", \"a\"], [\"a\", \"b\"]), 1)\n    deepStrictEqual(O.compare([\"a\", \"a\"], [\"b\", \"a\"]), -1)\n    deepStrictEqual(O.compare([\"a\", \"b\"], [\"b\", \"a\"]), -1)\n    deepStrictEqual(O.compare([\"b\", \"a\"], [\"b\", \"b\"]), -1)\n    deepStrictEqual(O.compare([\"b\", \"b\"], [\"b\", \"a\"]), 1)\n  })\n\n  it(\"isEmpty\", () => {\n    deepStrictEqual(RA.isEmpty([1, 2, 3]), false)\n    deepStrictEqual(RA.isEmpty([]), true)\n  })\n\n  it(\"isEmptyArray\", () => {\n    deepStrictEqual(RA.isEmptyArray([1, 2, 3]), false)\n    deepStrictEqual(RA.isEmptyArray([]), true)\n  })\n\n  it(\"isNotEmpty\", () => {\n    deepStrictEqual(RA.isNonEmpty([1, 2, 3]), true)\n    deepStrictEqual(RA.isNonEmpty([]), false)\n  })\n\n  it(\"isNonEmptyArray\", () => {\n    deepStrictEqual(RA.isNonEmptyArray([1, 2, 3]), true)\n    deepStrictEqual(RA.isNonEmptyArray([]), false)\n  })\n\n  it(\"head\", () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    deepStrictEqual(RA.head(as), O.some(1))\n    deepStrictEqual(RA.head([]), O.none())\n  })\n\n  it(\"last\", () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    deepStrictEqual(RA.last(as), O.some(3))\n    deepStrictEqual(RA.last([]), O.none())\n  })\n\n  it(\"zipNonEmptyWith\", () => {\n    deepStrictEqual(\n      pipe([1, 2, 3], RA.zipNonEmptyWith([\"a\", \"b\", \"c\", \"d\"], (n, s) => s + n)),\n      [\"a1\", \"b2\", \"c3\"]\n    )\n  })\n\n  it(\"zipNonEmpty\", () => {\n    deepStrictEqual(pipe(RA.make(1, 2, 3), RA.zipNonEmpty([\"a\", \"b\", \"c\", \"d\"])), [\n      [1, \"a\"],\n      [2, \"b\"],\n      [3, \"c\"]\n    ])\n  })\n\n  it(\"unzipNonEmpty\", () => {\n    deepStrictEqual(\n      RA.unzipNonEmpty([\n        [1, \"a\"],\n        [2, \"b\"],\n        [3, \"c\"]\n      ]),\n      [\n        [1, 2, 3],\n        [\"a\", \"b\", \"c\"]\n      ]\n    )\n  })\n\n  it(\"flatMapNonEmpty\", () => {\n    const f = (a: number): RA.NonEmptyReadonlyArray<number> => [a, 4]\n    deepStrictEqual(pipe(RA.make(1, 2), RA.flatMapNonEmpty(f)), [1, 4, 2, 4])\n    const g = (a: number, i: number): RA.NonEmptyReadonlyArray<number> => [a + i, 4]\n    deepStrictEqual(pipe(RA.make(1, 2), RA.flatMapNonEmpty(g)), [1, 4, 3, 4])\n  })\n\n  it(\"chunksOfNonEmpty\", () => {\n    deepStrictEqual(RA.chunksOfNonEmpty(2)([1, 2, 3, 4, 5]), [\n      RA.make(1, 2),\n      [3, 4],\n      [5]\n    ])\n    deepStrictEqual(RA.chunksOfNonEmpty(2)([1, 2, 3, 4, 5, 6]), [\n      RA.make(1, 2),\n      [3, 4],\n      [5, 6]\n    ])\n    deepStrictEqual(RA.chunksOfNonEmpty(1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n    deepStrictEqual(RA.chunksOfNonEmpty(5)([1, 2, 3, 4, 5]), [[1, 2, 3, 4, 5]])\n    // out of bounds\n    deepStrictEqual(RA.chunksOfNonEmpty(0)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n    deepStrictEqual(RA.chunksOfNonEmpty(-1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n\n    const assertSingleChunk = (\n      input: RA.NonEmptyReadonlyArray<number>,\n      n: number\n    ) => {\n      const chunks = RA.chunksOfNonEmpty(n)(input)\n      strictEqual(chunks.length, 1)\n      deepStrictEqual(RA.headNonEmpty(chunks), input)\n    }\n    // n = length\n    assertSingleChunk(RA.make(1, 2), 2)\n    // n out of bounds\n    assertSingleChunk(RA.make(1, 2), 3)\n  })\n\n  it(\"mapNonEmpty\", () => {\n    deepStrictEqual(\n      pipe(\n        RA.make(RA.make(1, 2), RA.make(3, 4)),\n        RA.flattenNonEmpty\n      ),\n      [1, 2, 3, 4]\n    )\n    deepStrictEqual(\n      pipe(RA.make(\"a\", \"b\"), RA.mapNonEmpty((s: string, i: number) => s + i)),\n      [\"a0\", \"b1\"]\n    )\n  })\n\n  it(\"sequenceNonEmpty\", () => {\n    const sequence = RA.sequenceNonEmpty(O.Applicative)\n    deepStrictEqual(\n      sequence([O.some(1), O.some(2), O.some(3)]),\n      O.some(RA.make(1, 2, 3))\n    )\n    deepStrictEqual(sequence([O.none(), O.some(2), O.some(3)]), O.none())\n  })\n\n  it(\"mapNonEmpty\", () => {\n    deepStrictEqual(\n      pipe(\n        RA.make(1, 2),\n        RA.mapNonEmpty((n) => n * 2)\n      ),\n      [2, 4]\n    )\n  })\n\n  it(\"min\", () => {\n    deepStrictEqual(RA.min(Number.Order)([2, 1, 3]), 1)\n    deepStrictEqual(RA.min(Number.Order)([3]), 3)\n  })\n\n  it(\"max\", () => {\n    deepStrictEqual(\n      RA.max(Number.Order)(RA.make(1, 2, 3)),\n      3\n    )\n    deepStrictEqual(RA.max(Number.Order)([1]), 1)\n  })\n\n  it(\"flatten\", () => {\n    deepStrictEqual(RA.flatten([[1], [2], [3]]), [1, 2, 3])\n  })\n\n  it(\"intercalate\", () => {\n    deepStrictEqual(RA.intercalate(String.Monoid)(\"-\")([]), \"\")\n    deepStrictEqual(RA.intercalate(String.Monoid)(\"-\")([\"a\"]), \"a\")\n    deepStrictEqual(RA.intercalate(String.Monoid)(\"-\")([\"a\", \"b\", \"c\"]), \"a-b-c\")\n    deepStrictEqual(RA.intercalate(String.Monoid)(\"-\")([\"a\", \"\", \"c\"]), \"a--c\")\n    deepStrictEqual(RA.intercalate(String.Monoid)(\"-\")([\"a\", \"b\"]), \"a-b\")\n    deepStrictEqual(RA.intercalate(String.Monoid)(\"-\")([\"a\", \"b\", \"c\", \"d\"]), \"a-b-c-d\")\n  })\n\n  it(\"group\", () => {\n    const group = RA.group(Number.Equivalence)\n    deepStrictEqual(group([1, 2, 1, 1]), [[1], [2], [1, 1]])\n    deepStrictEqual(group([1, 2, 1, 1, 3]), [[1], [2], [1, 1], [3]])\n  })\n\n  it(\"groupBy\", () => {\n    deepStrictEqual(RA.groupBy((_) => \"\")([]), {})\n    deepStrictEqual(RA.groupBy((a) => `${a}`)([1]), { \"1\": [1] })\n    deepStrictEqual(\n      RA.groupBy((s: string) => `${s.length}`)([\"foo\", \"bar\", \"foobar\"]),\n      {\n        \"3\": [\"foo\", \"bar\"],\n        \"6\": [\"foobar\"]\n      }\n    )\n  })\n\n  it(\"reverseNonEmpty\", () => {\n    deepStrictEqual(RA.reverseNonEmpty([1]), [1])\n    deepStrictEqual(RA.reverseNonEmpty(RA.make(1, 2, 3)), [3, 2, 1])\n  })\n\n  it(\"match\", () => {\n    const len: <A>(as: ReadonlyArray<A>) => number = RA.match(\n      () => 0,\n      (as) => 1 + len(as.slice(1))\n    )\n    deepStrictEqual(len([1, 2, 3]), 3)\n  })\n\n  it(\"matchLeft\", () => {\n    const len: <A>(as: ReadonlyArray<A>) => number = RA.matchLeft(\n      () => 0,\n      (_, tail) => 1 + len(tail)\n    )\n    deepStrictEqual(len([1, 2, 3]), 3)\n  })\n\n  it(\"matchRight\", () => {\n    const len: <A>(as: ReadonlyArray<A>) => number = RA.matchRight(\n      () => 0,\n      (init, _) => 1 + len(init)\n    )\n    deepStrictEqual(len([1, 2, 3]), 3)\n  })\n\n  it(\"uniqNonEmpty\", () => {\n    const uniqNonEmpty = RA.uniqNonEmpty(String.Equivalence)\n    deepStrictEqual(uniqNonEmpty([\"a\", \"b\", \"A\"]), [\"a\", \"b\", \"A\"])\n  })\n\n  it(\"sortBy / sortByNonEmpty\", () => {\n    interface X {\n      readonly a: string\n      readonly b: number\n      readonly c: boolean\n    }\n\n    const byName = pipe(\n      String.Order,\n      Order.contramap((p: { readonly a: string; readonly b: number }) => p.a)\n    )\n\n    const byAge = pipe(\n      Number.Order,\n      Order.contramap((p: { readonly a: string; readonly b: number }) => p.b)\n    )\n\n    const sortByNameByAge = RA.sortBy(byName, byAge)\n\n    const xs: RA.NonEmptyArray<X> = [\n      { a: \"a\", b: 1, c: true },\n      { a: \"b\", b: 3, c: true },\n      { a: \"c\", b: 2, c: true },\n      { a: \"b\", b: 2, c: true }\n    ]\n\n    deepStrictEqual(RA.sortBy()(xs), xs)\n    deepStrictEqual(sortByNameByAge([]), [])\n    deepStrictEqual(sortByNameByAge(xs), [\n      { a: \"a\", b: 1, c: true },\n      { a: \"b\", b: 2, c: true },\n      { a: \"b\", b: 3, c: true },\n      { a: \"c\", b: 2, c: true }\n    ])\n\n    deepStrictEqual(RA.sortBy()(new Set(xs)), xs)\n    deepStrictEqual(sortByNameByAge(new Set([])), [])\n    deepStrictEqual(sortByNameByAge(new Set(xs)), [\n      { a: \"a\", b: 1, c: true },\n      { a: \"b\", b: 2, c: true },\n      { a: \"b\", b: 3, c: true },\n      { a: \"c\", b: 2, c: true }\n    ])\n\n    const sortByAgeByName = RA.sortByNonEmpty(byAge, byName)\n    deepStrictEqual(sortByAgeByName(xs), [\n      { a: \"a\", b: 1, c: true },\n      { a: \"b\", b: 2, c: true },\n      { a: \"c\", b: 2, c: true },\n      { a: \"b\", b: 3, c: true }\n    ])\n  })\n\n  it(\"copy\", () => {\n    expect(pipe([], RA.copy)).toEqual([])\n    expect(pipe([1, 2, 3], RA.copy)).toEqual([1, 2, 3])\n  })\n\n  it(\"intercalateNonEmpty\", () => {\n    expect(pipe([\"a\"], RA.intercalateNonEmpty(String.Semigroup)(\"b\"))).toEqual(\"a\")\n    expect(pipe([\"a1\", \"a2\"], RA.intercalateNonEmpty(String.Semigroup)(\"b\"))).toEqual(\"a1ba2\")\n  })\n\n  it(\"join\", () => {\n    expect(pipe([], RA.join(\", \"))).toEqual(\"\")\n    expect(pipe([\"a\"], RA.join(\", \"))).toEqual(\"a\")\n    expect(pipe([\"a\", \"b\"], RA.join(\", \"))).toEqual(\"a, b\")\n  })\n\n  it(\"chop\", () => {\n    const f = RA.chop<number, number>((as) => [as[0] * 2, as.slice(1)])\n    const empty: ReadonlyArray<number> = []\n    deepStrictEqual(f(empty), RA.empty())\n    deepStrictEqual(f(RA.empty()), RA.empty())\n    deepStrictEqual(f([1, 2, 3]), [2, 4, 6])\n    deepStrictEqual(RA.chopNonEmpty<number, number>((as) => [as[0] * 2, as.slice(1)])([1, 2, 3]), [\n      2,\n      4,\n      6\n    ])\n  })\n\n  describe.concurrent(\"chunksOf\", () => {\n    it(\"should split a `ReadonlyArray` into length-n pieces\", () => {\n      deepStrictEqual(RA.chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])\n      deepStrictEqual(RA.chunksOf(2)([1, 2, 3, 4, 5, 6]), [\n        [1, 2],\n        [3, 4],\n        [5, 6]\n      ])\n      deepStrictEqual(RA.chunksOf(1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n      deepStrictEqual(RA.chunksOf(5)([1, 2, 3, 4, 5]), [[1, 2, 3, 4, 5]])\n      // out of bounds\n      deepStrictEqual(RA.chunksOf(0)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n      deepStrictEqual(RA.chunksOf(-1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n\n      const assertSingleChunk = (input: ReadonlyArray<number>, n: number) => {\n        const chunks = RA.chunksOf(n)(input)\n        deepStrictEqual(chunks.length, 1)\n        deepStrictEqual(chunks[0], input)\n      }\n      // n = length\n      assertSingleChunk([1, 2], 2)\n      // n out of bounds\n      assertSingleChunk([1, 2], 3)\n    })\n\n    it(\"returns an empty array if provided an empty array\", () => {\n      const empty: ReadonlyArray<number> = []\n      deepStrictEqual(RA.chunksOf(0)(empty), RA.empty())\n      deepStrictEqual(RA.chunksOf(0)(RA.empty()), RA.empty())\n      deepStrictEqual(RA.chunksOf(1)(empty), RA.empty())\n      deepStrictEqual(RA.chunksOf(1)(RA.empty()), RA.empty())\n      deepStrictEqual(RA.chunksOf(2)(empty), RA.empty())\n      deepStrictEqual(RA.chunksOf(2)(RA.empty()), RA.empty())\n    })\n\n    it(\"should respect the law: chunksOf(n)(xs).concat(chunksOf(n)(ys)) == chunksOf(n)(xs.concat(ys)))\", () => {\n      const xs: ReadonlyArray<number> = []\n      const ys: ReadonlyArray<number> = [1, 2]\n      deepStrictEqual(\n        RA.chunksOf(2)(xs).concat(RA.chunksOf(2)(ys)),\n        RA.chunksOf(2)(xs.concat(ys))\n      )\n      fc.assert(\n        fc.property(\n          fc.array(fc.integer()).filter((xs) => xs.length % 2 === 0), // Ensures `xs.length` is even\n          fc.array(fc.integer()),\n          fc.integer({ min: 1, max: 1 }).map((x) => x * 2), // Generates `n` to be even so that it evenly divides `xs`\n          (xs, ys, n) => {\n            const as = RA.chunksOf(n)(xs).concat(RA.chunksOf(n)(ys))\n            const bs = RA.chunksOf(n)(xs.concat(ys))\n            deepStrictEqual(as, bs)\n          }\n        )\n      )\n    })\n  })\n\n  it(\"makeBy\", () => {\n    deepStrictEqual(RA.makeBy(5, n => n * 2), [0, 2, 4, 6, 8])\n    deepStrictEqual(RA.makeBy(2.2, n => n * 2), [0, 2])\n  })\n\n  it(\"replicate\", () => {\n    deepStrictEqual(RA.replicate(\"a\", 0), [\"a\"])\n    deepStrictEqual(RA.replicate(\"a\", -1), [\"a\"])\n    deepStrictEqual(RA.replicate(\"a\", 3), [\"a\", \"a\", \"a\"])\n    deepStrictEqual(RA.replicate(\"a\", 2.2), [\"a\", \"a\"])\n  })\n\n  it(\"range\", () => {\n    deepStrictEqual(RA.range(0, 0), [0])\n    deepStrictEqual(RA.range(0, 1), [0, 1])\n    deepStrictEqual(RA.range(1, 5), [1, 2, 3, 4, 5])\n    deepStrictEqual(RA.range(10, 15), [10, 11, 12, 13, 14, 15])\n    deepStrictEqual(RA.range(-1, 0), [-1, 0])\n    deepStrictEqual(RA.range(-5, -1), [-5, -4, -3, -2, -1])\n    // out of bound\n    deepStrictEqual(RA.range(2, 1), [2])\n    deepStrictEqual(RA.range(-1, -2), [-1])\n  })\n\n  it(\"union\", () => {\n    const union = RA.union(Number.Equivalence)\n    const two: ReadonlyArray<number> = [1, 2]\n    deepStrictEqual(pipe(two, union([3, 4])), [1, 2, 3, 4])\n    deepStrictEqual(pipe(two, union([2, 3])), [1, 2, 3])\n    deepStrictEqual(pipe(two, union([1, 2])), [1, 2])\n    deepStrictEqual(pipe(two, union(RA.empty())), two)\n    deepStrictEqual(pipe(RA.empty(), union(two)), two)\n    deepStrictEqual(\n      pipe(RA.empty(), union(RA.empty())),\n      RA.empty()\n    )\n    deepStrictEqual(RA.unionNonEmpty(Number.Equivalence)([3, 4])([1, 2]), [1, 2, 3, 4])\n  })\n\n  it(\"getSemigroup\", () => {\n    const S = RA.getSemigroup<number>()\n    expect(S.combine([1, 2], [2, 3])).toEqual([1, 2, 2, 3])\n  })\n\n  it(\"getUnionSemigroup\", () => {\n    const S = RA.getUnionSemigroup(Number.Equivalence)\n    expect(S.combine([1, 2], [2, 3])).toEqual([1, 2, 3])\n  })\n\n  it(\"intersection\", () => {\n    const intersection = RA.intersection(Number.Equivalence)\n    deepStrictEqual(pipe([1, 2], intersection([3, 4])), [])\n    deepStrictEqual(pipe([1, 2], intersection([2, 3])), [2])\n    deepStrictEqual(pipe([1, 2], intersection([1, 2])), [1, 2])\n  })\n\n  it(\"difference\", () => {\n    const difference = RA.difference(Number.Equivalence)\n    deepStrictEqual(pipe([1, 2], difference([3, 4])), [1, 2])\n    deepStrictEqual(pipe([1, 2], difference([2, 3])), [1])\n    deepStrictEqual(pipe([1, 2], difference([1, 2])), [])\n  })\n\n  it(\"getUnionMonoid\", () => {\n    const M = RA.getUnionMonoid(Number.Equivalence)\n    const two: ReadonlyArray<number> = [1, 2]\n    deepStrictEqual(M.combine(two, [3, 4]), [1, 2, 3, 4])\n    deepStrictEqual(M.combine(two, [2, 3]), [1, 2, 3])\n    deepStrictEqual(M.combine(two, [1, 2]), [1, 2])\n\n    deepStrictEqual(M.combine(M.empty, two), two)\n    deepStrictEqual(M.combine(two, M.empty), two)\n    deepStrictEqual(M.combine(M.empty, M.empty), M.empty)\n\n    deepStrictEqual(M.combineAll([[1, 2], [3, 4, 5], [5, 6, 7, 1]]), [1, 2, 3, 4, 5, 6, 7])\n  })\n\n  it(\"getIntersectionSemigroup\", () => {\n    const S = RA.getIntersectionSemigroup(Number.Equivalence)\n    deepStrictEqual(S.combine([3, 4], [1, 2]), [])\n    deepStrictEqual(S.combine([2, 3], [1, 2]), [2])\n    deepStrictEqual(S.combine([1, 2], [1, 2]), [1, 2])\n  })\n\n  it(\"empty\", () => {\n    deepStrictEqual(RA.empty.length, 0)\n  })\n\n  it(\"do notation\", () => {\n    deepStrictEqual(\n      pipe(\n        RA.Do,\n        RA.bind(\"a\", () => [1, 2, 3]),\n        RA.map(({ a }) => a * 2)\n      ),\n      [2, 4, 6]\n    )\n\n    deepStrictEqual(\n      pipe(\n        RA.Do,\n        RA.bind(\"a\", () => [1, 2, 3]),\n        RA.bind(\"b\", () => [\"a\", \"b\"]),\n        RA.map(({ a, b }) => [a, b] as const)\n      ),\n      [\n        [1, \"a\"],\n        [1, \"b\"],\n        [2, \"a\"],\n        [2, \"b\"],\n        [3, \"a\"],\n        [3, \"b\"]\n      ]\n    )\n\n    deepStrictEqual(\n      pipe(\n        RA.Do,\n        RA.bind(\"a\", () => [1, 2, 3]),\n        RA.bind(\"b\", () => [\"a\", \"b\"]),\n        RA.map(({ a, b }) => [a, b] as const),\n        RA.filter(([a, b]) => (a + b.length) % 2 === 0)\n      ),\n      [\n        [1, \"a\"],\n        [1, \"b\"],\n        [3, \"a\"],\n        [3, \"b\"]\n      ]\n    )\n  })\n\n  it(\"every\", () => {\n    const isPositive: Predicate<number> = (n) => n > 0\n    deepStrictEqual(pipe([1, 2, 3], RA.every(isPositive)), true)\n    deepStrictEqual(pipe([1, 2, -3], RA.every(isPositive)), false)\n  })\n\n  it(\"combineMapNonEmpty\", () => {\n    deepStrictEqual(\n      pipe(\n        RA.make(\"a\", \"b\", \"c\"),\n        RA.combineMapNonEmpty(String.Semigroup)(identity)\n      ),\n      \"abc\"\n    )\n    deepStrictEqual(\n      pipe(\n        RA.make(\"a\", \"b\"),\n        RA.combineMapNonEmpty(String.Semigroup)((a, i) => i + a)\n      ),\n      \"0a1b\"\n    )\n  })\n\n  it(\"some\", () => {\n    const isPositive: Predicate<number> = (n) => n > 0\n    deepStrictEqual(pipe([-1, -2, 3], RA.some(isPositive)), true)\n    deepStrictEqual(pipe([-1, -2, -3], RA.some(isPositive)), false)\n  })\n\n  it(\"length\", () => {\n    deepStrictEqual(RA.length(RA.empty()), 0)\n    deepStrictEqual(RA.length([]), 0)\n    deepStrictEqual(RA.length([\"a\"]), 1)\n  })\n\n  it(\"fromOption\", () => {\n    deepStrictEqual(RA.fromOption(O.some(\"hello\")), [\"hello\"])\n    deepStrictEqual(RA.fromOption(O.none()), [])\n  })\n\n  it(\"fromResult\", () => {\n    deepStrictEqual(RA.fromEither(E.right(1)), [1])\n    deepStrictEqual(RA.fromEither(E.left(\"a\")), RA.empty())\n  })\n\n  test(\"product\", () => {\n    const product = RA.SemiProduct.product\n    expect(product([], [\"a\", \"b\"])).toEqual([])\n    expect(product([1, 2], [])).toEqual([])\n    expect(product([1, 2], [\"a\", \"b\"])).toEqual([\n      [1, \"a\"],\n      [1, \"b\"],\n      [2, \"a\"],\n      [2, \"b\"]\n    ])\n  })\n\n  test(\"productAll\", () => {\n    const productAll = RA.Product.productAll\n    expect(productAll([])).toEqual([])\n    expect(productAll([[1, 2, 3]])).toEqual([[1], [2], [3]])\n    expect(productAll([[1, 2, 3], [4, 5]])).toEqual([[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [\n      3,\n      5\n    ]])\n  })\n\n  it(\"traversePartitionMap\", () => {\n    const traversePartitionMap = RA.traversePartitionMap(O.Applicative)\n    const f = (s: string) =>\n      s.length > 1 ? O.some(E.right(s)) : s.length > 0 ? O.some(E.left(s)) : O.none()\n    assert.deepStrictEqual(traversePartitionMap([], f), O.some([[], []]))\n    assert.deepStrictEqual(traversePartitionMap([\"\"], f), O.none())\n    assert.deepStrictEqual(traversePartitionMap([\"a\"], f), O.some([[\"a\"], []]))\n    assert.deepStrictEqual(traversePartitionMap([\"aa\"], f), O.some([[], [\"aa\"]]))\n    assert.deepStrictEqual(traversePartitionMap([\"aa\", \"a\", \"\"], f), O.none())\n    assert.deepStrictEqual(\n      traversePartitionMap([\"aa\", \"a\", \"aaa\"], f),\n      O.some([[\"a\"], [\"aa\", \"aaa\"]])\n    )\n  })\n\n  it(\"traverseFilterMap\", () => {\n    const traverseFilterMap = RA.traverseFilterMap(O.Applicative)\n    const f = (s: string) =>\n      s.length > 1 ? O.some(O.some(s)) : s.length > 0 ? O.some(O.none()) : O.none()\n    assert.deepStrictEqual(traverseFilterMap([], f), O.some([]))\n    assert.deepStrictEqual(traverseFilterMap([\"\"], f), O.none())\n    assert.deepStrictEqual(traverseFilterMap([\"a\"], f), O.some([]))\n    assert.deepStrictEqual(traverseFilterMap([\"aa\"], f), O.some([\"aa\"]))\n    assert.deepStrictEqual(traverseFilterMap([\"aa\", \"a\", \"\"], f), O.none())\n    assert.deepStrictEqual(\n      traverseFilterMap([\"aa\", \"a\", \"aaa\"], f),\n      O.some([\"aa\", \"aaa\"])\n    )\n  })\n})\n"
  },
  {
    "path": "test/ReadonlyRecord.ts",
    "content": "import * as E from \"@fp-ts/core/Either\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RR from \"@fp-ts/core/ReadonlyRecord\"\n\ndescribe.concurrent(\"ReadonlyRecord\", () => {\n  it(\"exports\", () => {\n    expect(RR.Invariant).exist\n    expect(RR.tupled).exist\n    expect(RR.Covariant).exist\n    expect(RR.flap).exist\n    expect(RR.as).exist\n    expect(RR.Filterable).exist\n    expect(RR.Traversable).exist\n    expect(RR.traverseTap).exist\n    expect(RR.TraversableFilterable).exist\n    expect(RR.traverseFilter).exist\n    expect(RR.traversePartition).exist\n  })\n\n  it(\"get\", () => {\n    expect(pipe({}, RR.get(\"a\"))).toEqual(O.none())\n    expect(pipe({ a: 1 }, RR.get(\"a\"))).toEqual(O.some(1))\n  })\n\n  it(\"modifyOption\", () => {\n    expect(pipe({}, RR.replaceOption(\"a\", 2))).toEqual(O.none())\n    expect(pipe({ a: 1 }, RR.replaceOption(\"a\", 2))).toEqual(O.some({ a: 2 }))\n    expect(pipe({ a: 1 }, RR.replaceOption(\"a\", true))).toEqual(O.some({ a: true }))\n  })\n\n  it(\"modifyOption\", () => {\n    expect(pipe({}, RR.modifyOption(\"a\", (n: number) => n + 1))).toEqual(O.none())\n    expect(pipe({ a: 1 }, RR.modifyOption(\"a\", (n: number) => n + 1))).toEqual(O.some({ a: 2 }))\n    expect(pipe({ a: 1 }, RR.modifyOption(\"a\", (n: number) => String(n)))).toEqual(\n      O.some({ a: \"1\" })\n    )\n  })\n\n  it(\"map\", () => {\n    expect(pipe({ a: 1, b: 2 }, RR.map(n => n * 2))).toEqual({ a: 2, b: 4 })\n    expect(pipe({ a: 1, b: 2 }, RR.map((n, k) => `${k}-${n}`))).toEqual({\n      a: \"a-1\",\n      b: \"b-2\"\n    })\n  })\n\n  it(\"fromIterable\", () => {\n    const input = [1, 2, 3, 4]\n    expect(RR.fromIterable(input, a => [String(a), a * 2])).toEqual({\n      \"1\": 2,\n      \"2\": 4,\n      \"3\": 6,\n      \"4\": 8\n    })\n  })\n\n  it(\"collect\", () => {\n    const x = { a: 1, b: 2, c: 3 }\n    assert.deepStrictEqual(RR.collect(x, (key, n) => [key, n]), [[\"a\", 1], [\"b\", 2], [\"c\", 3]])\n  })\n\n  it(\"toArray\", () => {\n    const x = { a: 1, b: 2 }\n    assert.deepStrictEqual(RR.toArray(x), [[\"a\", 1], [\"b\", 2]])\n  })\n\n  it(\"remove\", () => {\n    assert.deepStrictEqual(RR.remove({ a: 1, b: 2 }, \"a\"), { b: 2 })\n    assert.deepStrictEqual(RR.remove({ a: 1, b: 2 }, \"c\"), { a: 1, b: 2 })\n  })\n\n  describe(\"pop\", () => {\n    it(\"should return the value associated with the given key, if the key is present in the record\", () => {\n      const record = { a: 1, b: 2 }\n      const result = RR.pop(\"a\")(record)\n\n      assert.deepStrictEqual(result, O.some([1, { b: 2 }]))\n    })\n\n    it(\"should return none if the key is not present in the record\", () => {\n      const record = { a: 1, b: 2 }\n      const result = RR.pop(\"c\")(record)\n\n      assert.deepStrictEqual(result, O.none())\n    })\n  })\n\n  describe(\"filterMap\", () => {\n    it(\"should filter the properties of an object\", () => {\n      const obj = { a: 1, b: 2, c: 3 }\n      const filtered = RR.filterMap(obj, (value, key) => (value > 2 ? O.some(key) : O.none()))\n      expect(filtered).toEqual({ c: \"c\" })\n    })\n  })\n\n  it(\"compact\", () => {\n    const x = { a: O.some(1), b: O.none(), c: O.some(2) }\n    assert.deepStrictEqual(RR.compact(x), { a: 1, c: 2 })\n  })\n\n  it(\"filter\", () => {\n    const x = { a: 1, b: 2, c: 3, d: 4 }\n    assert.deepStrictEqual(RR.filter(x, (value) => value > 2), { c: 3, d: 4 })\n  })\n\n  it(\"partitionMap\", () => {\n    const f = (n: number) => (n > 2 ? E.right(n + 1) : E.left(n - 1))\n    assert.deepStrictEqual(RR.partitionMap({}, f), [{}, {}])\n    assert.deepStrictEqual(RR.partitionMap({ a: 1, b: 3 }, f), [{ a: 0 }, { b: 4 }])\n  })\n\n  it(\"partition\", () => {\n    const f = (n: number) => n > 2\n    assert.deepStrictEqual(RR.partition({}, f), [{}, {}])\n    assert.deepStrictEqual(RR.partition({ a: 1, b: 3 }, f), [{ a: 1 }, { b: 3 }])\n  })\n\n  it(\"separate\", () => {\n    assert.deepStrictEqual(\n      RR.separate({ a: E.left(\"e\"), b: E.right(1) }),\n      [{ a: \"e\" }, { b: 1 }]\n    )\n    // should ignore non own properties\n    const o: RR.ReadonlyRecord<E.Either<string, number>> = Object.create({ a: 1 })\n    assert.deepStrictEqual(pipe(o, RR.separate), [{}, {}])\n  })\n\n  it(\"traverse\", () => {\n    assert.deepStrictEqual(\n      RR.traverse(O.Applicative)({ a: 1, b: 2 }, (n: number) => (n <= 2 ? O.some(n) : O.none())),\n      O.some({ a: 1, b: 2 })\n    )\n    assert.deepStrictEqual(\n      RR.traverse(O.Applicative)((n: number) => (n <= 2 ? O.some(n) : O.none()))({ a: 1, b: 2 }),\n      O.some({ a: 1, b: 2 })\n    )\n    assert.deepStrictEqual(\n      RR.traverse(O.Applicative)({ a: 1, b: 2 }, (n: number) => (n >= 2 ? O.some(n) : O.none())),\n      O.none()\n    )\n    assert.deepStrictEqual(\n      RR.traverse(O.Applicative)((n: number) => (n >= 2 ? O.some(n) : O.none()))({ a: 1, b: 2 }),\n      O.none()\n    )\n  })\n\n  it(\"sequence\", () => {\n    const sequence = RR.sequence(O.Applicative)\n    assert.deepStrictEqual(sequence({ a: O.some(1), b: O.some(2) }), O.some({ a: 1, b: 2 }))\n    assert.deepStrictEqual(sequence({ a: O.none(), b: O.some(2) }), O.none())\n  })\n\n  it(\"empty\", () => {\n    expect(RR.empty()).toEqual({})\n  })\n\n  it(\"isEmpty\", () => {\n    assert.deepStrictEqual(RR.isEmpty({}), true)\n    assert.deepStrictEqual(RR.isEmpty({ a: 3 }), false)\n  })\n\n  it(\"size\", () => {\n    assert.deepStrictEqual(RR.size({ a: \"a\", b: 1, c: true }), 3)\n  })\n\n  it(\"has\", () => {\n    assert.deepStrictEqual(RR.has({ a: 1, b: 2 }, \"a\"), true)\n    assert.deepStrictEqual(RR.has({ a: 1, b: 2 }, \"c\"), false)\n  })\n\n  it(\"traversePartitionMap\", () => {\n    const traversePartitionMap = RR.traversePartitionMap(O.Applicative)\n    const f = (s: string) =>\n      s.length > 1 ? O.some(E.right(s)) : s.length > 0 ? O.some(E.left(s)) : O.none()\n    assert.deepStrictEqual(traversePartitionMap({}, f), O.some([{}, {}]))\n    assert.deepStrictEqual(traversePartitionMap({ \"\": \"\" }, f), O.none())\n    assert.deepStrictEqual(traversePartitionMap({ a: \"a\" }, f), O.some([{ a: \"a\" }, {}]))\n    assert.deepStrictEqual(traversePartitionMap({ aa: \"aa\" }, f), O.some([{}, { aa: \"aa\" }]))\n    assert.deepStrictEqual(traversePartitionMap({ aa: \"aa\", a: \"a\", \"\": \"\" }, f), O.none())\n    assert.deepStrictEqual(\n      traversePartitionMap({ aa: \"aa\", a: \"a\", aaa: \"aaa\" }, f),\n      O.some([{ a: \"a\" }, { aa: \"aa\", aaa: \"aaa\" }])\n    )\n  })\n\n  it(\"traverseFilterMap\", () => {\n    const traverseFilterMap = RR.traverseFilterMap(O.Applicative)\n    const f = (s: string) =>\n      s.length > 1 ? O.some(O.some(s)) : s.length > 0 ? O.some(O.none()) : O.none()\n    assert.deepStrictEqual(traverseFilterMap({}, f), O.some({}))\n    assert.deepStrictEqual(traverseFilterMap({ \"\": \"\" }, f), O.none())\n    assert.deepStrictEqual(traverseFilterMap({ a: \"a\" }, f), O.some({}))\n    assert.deepStrictEqual(traverseFilterMap({ aa: \"aa\" }, f), O.some({ aa: \"aa\" }))\n    assert.deepStrictEqual(traverseFilterMap({ aa: \"aa\", a: \"a\", \"\": \"\" }, f), O.none())\n    assert.deepStrictEqual(\n      traverseFilterMap({ aa: \"aa\", a: \"a\", aaa: \"aaa\" }, f),\n      O.some({ aa: \"aa\", aaa: \"aaa\" })\n    )\n  })\n})\n"
  },
  {
    "path": "test/String.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as S from \"@fp-ts/core/String\"\nimport { deepStrictEqual } from \"@fp-ts/core/test/util\"\nimport * as Order from \"@fp-ts/core/typeclass/Order\"\n\ndescribe.concurrent(\"String\", () => {\n  it(\"isString\", () => {\n    expect(S.isString(\"a\")).toEqual(true)\n    expect(S.isString(1)).toEqual(false)\n    expect(S.isString(true)).toEqual(false)\n  })\n\n  it(\"empty\", () => {\n    expect(S.empty).toEqual(\"\")\n  })\n\n  it(\"Semigroup\", () => {\n    expect(S.Semigroup.combine(\"a\", \"b\")).toEqual(\"ab\")\n    expect(S.Semigroup.combineMany(\"a\", [\"b\", \"c\"])).toEqual(\"abc\")\n    expect(S.Semigroup.combineMany(\"a\", [])).toEqual(\"a\")\n  })\n\n  it(\"Monoid\", () => {\n    expect(S.Monoid.combineAll([])).toEqual(\"\")\n  })\n\n  it(\"Equivalence\", () => {\n    expect(S.Equivalence(\"a\", \"a\")).toBe(true)\n    expect(S.Equivalence(\"a\", \"b\")).toBe(false)\n  })\n\n  it(\"Order\", () => {\n    const lessThan = Order.lessThan(S.Order)\n    const lessThanOrEqualTo = Order.lessThanOrEqualTo(S.Order)\n    expect(pipe(\"a\", lessThan(\"b\"))).toEqual(true)\n    expect(pipe(\"a\", lessThan(\"a\"))).toEqual(false)\n    expect(pipe(\"a\", lessThanOrEqualTo(\"a\"))).toEqual(true)\n    expect(pipe(\"b\", lessThan(\"a\"))).toEqual(false)\n    expect(pipe(\"b\", lessThanOrEqualTo(\"a\"))).toEqual(false)\n  })\n\n  it(\"concat\", () => {\n    deepStrictEqual(pipe(\"a\", S.concat(\"b\")), \"ab\")\n  })\n\n  it(\"isEmpty\", () => {\n    deepStrictEqual(S.isEmpty(\"\"), true)\n    deepStrictEqual(S.isEmpty(\"a\"), false)\n  })\n\n  it(\"isNonEmpty\", () => {\n    deepStrictEqual(S.isNonEmpty(\"\"), false)\n    deepStrictEqual(S.isNonEmpty(\"a\"), true)\n  })\n\n  it(\"length\", () => {\n    deepStrictEqual(S.length(\"\"), 0)\n    deepStrictEqual(S.length(\"a\"), 1)\n    deepStrictEqual(S.length(\"aaa\"), 3)\n  })\n\n  it(\"toUpperCase\", () => {\n    deepStrictEqual(S.toUpperCase(\"a\"), \"A\")\n  })\n\n  it(\"toLowerCase\", () => {\n    deepStrictEqual(S.toLowerCase(\"A\"), \"a\")\n  })\n\n  it(\"replace\", () => {\n    deepStrictEqual(pipe(\"abc\", S.replace(\"b\", \"d\")), \"adc\")\n  })\n\n  it(\"split\", () => {\n    deepStrictEqual(pipe(\"abc\", S.split(\"\")), [\"a\", \"b\", \"c\"])\n    deepStrictEqual(pipe(\"\", S.split(\"\")), [\"\"])\n  })\n\n  it(\"trim\", () => {\n    deepStrictEqual(pipe(\" a \", S.trim), \"a\")\n  })\n\n  it(\"trimStart\", () => {\n    deepStrictEqual(pipe(\" a \", S.trimStart), \"a \")\n  })\n\n  it(\"trimEnd\", () => {\n    deepStrictEqual(pipe(\" a \", S.trimEnd), \" a\")\n  })\n\n  it(\"includes\", () => {\n    assert.deepStrictEqual(S.includes(\"abc\", \"b\"), true)\n    assert.deepStrictEqual(S.includes(\"abc\", \"d\"), false)\n  })\n\n  it(\"includesWithPosition\", () => {\n    assert.deepStrictEqual(S.includesWithPosition(\"abc\", \"b\", 1), true)\n    assert.deepStrictEqual(S.includesWithPosition(\"abc\", \"a\", 1), false)\n  })\n\n  it(\"startsWith\", () => {\n    assert.deepStrictEqual(S.startsWith(\"abc\", \"a\"), true)\n    assert.deepStrictEqual(S.startsWith(\"bc\", \"a\"), false)\n  })\n\n  it(\"startsWithPosition\", () => {\n    assert.deepStrictEqual(S.startsWithPosition(\"abc\", \"b\", 1), true)\n    assert.deepStrictEqual(S.startsWithPosition(\"bc\", \"a\", 1), false)\n  })\n\n  it(\"endsWith\", () => {\n    assert.deepStrictEqual(S.endsWith(\"abc\", \"c\"), true)\n    assert.deepStrictEqual(S.endsWith(\"ab\", \"c\"), false)\n  })\n\n  it(\"endsWithPosition\", () => {\n    assert.deepStrictEqual(S.endsWithPosition(\"abc\", \"b\", 2), true)\n    assert.deepStrictEqual(S.endsWithPosition(\"abc\", \"c\", 2), false)\n  })\n\n  it(\"slice\", () => {\n    deepStrictEqual(pipe(\"abcd\", S.slice(1, 3)), \"bc\")\n  })\n\n  describe.concurrent(\"takeLeft\", () => {\n    it(\"should take the specified number of characters from the left side of a string\", () => {\n      const string = \"Hello, World!\"\n\n      const result = pipe(string, S.takeLeft(7))\n\n      assert.strictEqual(result, \"Hello, \")\n    })\n\n    it(\"should return the string for `n` larger than the string length\", () => {\n      const string = \"Hello, World!\"\n\n      const result = pipe(string, S.takeLeft(100))\n\n      assert.strictEqual(result, string)\n    })\n\n    it(\"should return the empty string for a negative `n`\", () => {\n      const string = \"Hello, World!\"\n\n      const result = pipe(string, S.takeLeft(-1))\n\n      assert.strictEqual(result, \"\")\n    })\n\n    it(\"should round down if `n` is a float\", () => {\n      const string = \"Hello, World!\"\n\n      const result = pipe(string, S.takeLeft(5.5))\n\n      assert.strictEqual(result, \"Hello\")\n    })\n  })\n\n  describe.concurrent(\"takeRight\", () => {\n    it(\"should take the specified number of characters from the right side of a string\", () => {\n      const string = \"Hello, World!\"\n\n      const result = pipe(string, S.takeRight(7))\n\n      assert.strictEqual(result, \" World!\")\n    })\n\n    it(\"should return the string for `n` larger than the string length\", () => {\n      const string = \"Hello, World!\"\n\n      const result = pipe(string, S.takeRight(100))\n\n      assert.strictEqual(result, string)\n    })\n\n    it(\"should return the empty string for a negative `n`\", () => {\n      const string = \"Hello, World!\"\n\n      const result = pipe(string, S.takeRight(-1))\n\n      assert.strictEqual(result, \"\")\n    })\n\n    it(\"should round down if `n` is a float\", () => {\n      const string = \"Hello, World!\"\n\n      const result = pipe(string, S.takeRight(6.5))\n\n      assert.strictEqual(result, \"World!\")\n    })\n  })\n\n  // TODO: 100% coverage tests (ask Max)\n  // describe.concurrent(\"stripMargin\", () => {\n  //   it(\"should strip a leading prefix from each line\", () => {\n  //     const string = `|\n  //   |Hello,\n  //   |World!\n  //   |`\n\n  //     const result = pipe(string, String.stripMargin)\n\n  //     assert.strictEqual(result, \"\\nHello,\\nWorld!\\n\")\n  //   })\n\n  //   it(\"should strip a leading prefix from each line using a margin character\", () => {\n  //     const string = `$\n  //   $Hello,\n  //   $World!\n  //   $`\n\n  //     const result = pipe(string, String.stripMarginWith(\"$\"))\n\n  //     assert.strictEqual(result, \"\\nHello,\\nWorld!\\n\")\n  //   })\n  // })\n})\n"
  },
  {
    "path": "test/Struct.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as S from \"@fp-ts/core/Struct\"\n\ndescribe.concurrent(\"Struct\", () => {\n  it(\"exports\", () => {\n    expect(S.getEquivalence).exists\n    expect(S.getOrder).exists\n    expect(S.getSemigroup).exists\n    expect(S.getMonoid).exists\n  })\n\n  it(\"pick\", () => {\n    expect(pipe({ a: \"a\", b: 1, c: true }, S.pick(\"a\", \"b\"))).toEqual({ a: \"a\", b: 1 })\n  })\n\n  it(\"omit\", () => {\n    expect(pipe({ a: \"a\", b: 1, c: true }, S.omit(\"c\"))).toEqual({ a: \"a\", b: 1 })\n  })\n})\n"
  },
  {
    "path": "test/Symbol.ts",
    "content": "import * as S from \"@fp-ts/core/Symbol\"\n\ndescribe.concurrent(\"Symbol\", () => {\n  it(\"isSymbol\", () => {\n    expect(S.isSymbol(Symbol.for(\"@fp-ts/core/test/a\"))).toEqual(true)\n    expect(S.isSymbol(1n)).toEqual(false)\n    expect(S.isSymbol(1)).toEqual(false)\n    expect(S.isSymbol(\"a\")).toEqual(false)\n    expect(S.isSymbol(true)).toEqual(false)\n  })\n\n  it(\"Equivalence\", () => {\n    const eq = S.Equivalence\n    expect(eq(Symbol.for(\"@fp-ts/core/test/a\"), Symbol.for(\"@fp-ts/core/test/a\"))).toBe(true)\n    expect(eq(Symbol.for(\"@fp-ts/core/test/a\"), Symbol.for(\"@fp-ts/core/test/b\"))).toBe(false)\n  })\n})\n"
  },
  {
    "path": "test/These.ts",
    "content": "import * as E from \"@fp-ts/core/Either\"\nimport { identity, pipe } from \"@fp-ts/core/Function\"\nimport { structural } from \"@fp-ts/core/internal/effect\"\nimport * as N from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as S from \"@fp-ts/core/String\"\nimport * as _ from \"@fp-ts/core/These\"\nimport { number } from \"@fp-ts/core/typeclass/Equivalence\"\nimport * as Util from \"./util\"\n\ndescribe(\"These\", () => {\n  it(\"instances and derived exports\", () => {\n    expect(_.Invariant).exist\n    expect(_.tupled).exist\n    expect(_.bindTo).exist\n\n    expect(_.Bicovariant).exist\n    expect(_.mapLeft).exist\n\n    expect(_.Covariant).exist\n    expect(_.map).exist\n    expect(_.let).exist\n    expect(_.flap).exist\n    expect(_.as).exist\n    expect(_.asUnit).exist\n\n    expect(_.Of).exist\n    expect(_.of).exist\n    expect(_.unit).exist\n    expect(_.Do).exist\n\n    expect(_.Pointed).exist\n\n    expect(_.FlatMap).exist\n    expect(_.flatMap).exist\n    expect(_.flatten).exist\n    expect(_.andThen).exist\n    expect(_.composeKleisliArrow).exist\n\n    expect(_.Chainable).exist\n    expect(_.bind).exist\n    expect(_.tap).exist\n    expect(_.andThenDiscard).exist\n\n    expect(_.Monad).exist\n\n    expect(_.SemiProduct).exist\n    expect(_.andThenBind).exist\n    expect(_.appendElement).exist\n\n    expect(_.Product).exist\n    expect(_.tuple).exist\n    expect(_.struct).exist\n\n    expect(_.SemiApplicative).exist\n    expect(_.getFirstLeftSemigroup).exist // liftSemigroup\n    expect(_.lift2).exist\n    expect(_.ap).exist\n    expect(_.andThenDiscard).exist\n    expect(_.andThen).exist\n\n    expect(_.Applicative).exist\n    expect(_.getFirstLeftMonoid).exist // liftMonoid\n\n    expect(_.SemiCoproduct).exist\n    // expect(_.coproduct).exist\n    expect(_.firstRightOrBothOf).exist // coproductMany\n    expect(_.getFirstRightOrBothSemigroup).exist // getSemigroup\n    // expect(_.coproductEither).exist // orElseEither\n\n    expect(_.SemiAlternative).exist\n\n    expect(_.Foldable).exist\n\n    expect(_.Traversable).exist\n    expect(_.traverse).exist\n    expect(_.sequence).exist\n    expect(_.traverseTap).exist\n  })\n\n  it(\"structural tracking\", () => {\n    expect(Util.ownKeys(_.left(\"a\"))).toEqual([\"_tag\", \"left\"])\n    expect(Util.ownKeys(_.right(1))).toEqual([\"_tag\", \"right\"])\n    expect(Util.ownKeys(_.both(\"a\", 1))).toEqual([\"_tag\", \"left\", \"right\"])\n\n    expect(Object.prototype.hasOwnProperty.call(_.left(\"a\"), structural)).toEqual(false)\n    expect(Object.prototype.hasOwnProperty.call(_.right(1), structural)).toEqual(false)\n    expect(Object.prototype.hasOwnProperty.call(_.both(\"a\", 1), structural)).toEqual(false)\n\n    expect(Util.isStructural(_.left(\"a\"))).toEqual(true)\n    expect(Util.isStructural(_.right(1))).toEqual(true)\n    expect(Util.isStructural(_.both(\"a\", 1))).toEqual(true)\n  })\n\n  it(\"reduce\", () => {\n    Util.deepStrictEqual(pipe(_.right(\"a\"), _.Foldable.reduce(\"-\", (b, a) => b + a)), \"-a\")\n    Util.deepStrictEqual(pipe(_.left(\"e\"), _.Foldable.reduce(\"-\", (b, a) => b + a)), \"-\")\n    Util.deepStrictEqual(pipe(_.both(\"e\", \"a\"), _.Foldable.reduce(\"-\", (b, a) => b + a)), \"-a\")\n  })\n\n  it(\"map\", () => {\n    Util.deepStrictEqual(pipe(_.left(\"e\"), _.map(Util.double)), _.left(\"e\"))\n    Util.deepStrictEqual(pipe(_.right(2), _.map(Util.double)), _.right(4))\n    Util.deepStrictEqual(pipe(_.both(\"e\", 2), _.map(Util.double)), _.both(\"e\", 4))\n  })\n\n  it(\"bimap\", () => {\n    const f = _.bimap(S.length, Util.double)\n    Util.deepStrictEqual(pipe(_.left(\"e\"), f), _.left(1))\n    Util.deepStrictEqual(pipe(_.right(2), f), _.right(4))\n    Util.deepStrictEqual(pipe(_.both(\"eee\", 1), f), _.both(3, 2))\n  })\n\n  it(\"mapLeft\", () => {\n    const f = _.mapLeft(S.length)\n    Util.deepStrictEqual(pipe(_.left(\"e\"), f), _.left(1))\n    Util.deepStrictEqual(pipe(_.right(2), f), _.right(2))\n    Util.deepStrictEqual(pipe(_.both(\"eee\", 1), f), _.both(3, 1))\n  })\n\n  it(\"traverse\", () => {\n    const traverse = _.traverse(O.Applicative)((n: number) => (n > 1 ? O.some(n) : O.none()))\n    Util.deepStrictEqual(pipe(_.left(\"a\"), traverse), O.some(_.left(\"a\")))\n    Util.deepStrictEqual(pipe(_.right(2), traverse), O.some(_.right(2)))\n    Util.deepStrictEqual(pipe(_.right(1), traverse), O.none())\n    Util.deepStrictEqual(pipe(_.both(\"a\", 2), traverse), O.some(_.both(\"a\", 2)))\n    Util.deepStrictEqual(\n      pipe(\n        _.both(\"a\", 1),\n        _.traverse(O.Applicative)((n) => (n >= 2 ? O.some(n) : O.none()))\n      ),\n      O.none()\n    )\n  })\n\n  it(\"andThenBind\", () => {\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.right(1)), _.bindEither(\"b\", () => E.right(2))),\n      _.right({ a: 1, b: 2 })\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.right(1)), _.bindEither(\"b\", () => E.left(\"e2\"))),\n      _.fail(\"e2\")\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.fail(\"e1\")), _.bindEither(\"b\", () => E.right(2))),\n      _.fail(\"e1\")\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.fail(\"e1\")), _.bindEither(\"b\", () => E.left(\"e2\"))),\n      _.fail(\"e1\")\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.warn(\"e1\", 1)), _.bindEither(\"b\", () => E.right(2))),\n      _.warn(\"e1\", { a: 1, b: 2 })\n    )\n    expect(\n      pipe(_.Do, _.bind(\"a\", () => _.warn(\"e1\", 1)), _.bindEither(\"b\", () => E.left(\"e2\")))\n    ).toEqual(\n      _.left([\"e1\", \"e2\"])\n    )\n  })\n\n  it(\"andThenBind\", () => {\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.right(1)), _.bindThese(\"b\", () => _.right(2))),\n      _.right({ a: 1, b: 2 })\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.right(1)), _.bindThese(\"b\", () => _.left(\"e2\"))),\n      _.fail(\"e2\")\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.right(1)), _.bindThese(\"b\", () => _.both(\"e2\", 2))),\n      _.warn(\"e2\", { a: 1, b: 2 })\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.fail(\"e1\")), _.bindThese(\"b\", () => _.right(2))),\n      _.fail(\"e1\")\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.fail(\"e1\")), _.bindThese(\"b\", () => _.left(\"e2\"))),\n      _.fail(\"e1\")\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.fail(\"e1\")), _.bindThese(\"b\", () => _.both(\"e2\", 2))),\n      _.fail(\"e1\")\n    )\n    Util.deepStrictEqual(\n      pipe(_.Do, _.bind(\"a\", () => _.warn(\"e1\", 1)), _.bindThese(\"b\", () => _.right(2))),\n      _.warn(\"e1\", { a: 1, b: 2 })\n    )\n    expect(\n      pipe(_.Do, _.bind(\"a\", () => _.warn(\"e1\", 1)), _.bindThese(\"b\", () => _.left(\"e2\")))\n    ).toEqual(\n      _.left([\"e1\", \"e2\"])\n    )\n    expect(\n      pipe(_.Do, _.bind(\"a\", () => _.warn(\"e1\", 1)), _.bindThese(\"b\", () => _.both(\"e2\", 2)))\n    ).toEqual(\n      _.both([\"e1\", \"e2\"], { a: 1, b: 2 })\n    )\n  })\n\n  it(\"sequence\", () => {\n    const sequence = _.sequence(O.Applicative)\n    Util.deepStrictEqual(sequence(_.left(\"a\")), O.some(_.left(\"a\")))\n    Util.deepStrictEqual(sequence(_.right(O.some(1))), O.some(_.right(1)))\n    Util.deepStrictEqual(sequence(_.right(O.none())), O.none())\n    Util.deepStrictEqual(sequence(_.both(\"a\", O.some(1))), O.some(_.both(\"a\", 1)))\n    Util.deepStrictEqual(sequence(_.both(\"a\", O.none())), O.none())\n  })\n\n  it(\"product\", () => {\n    const a = [\"a\"] as const\n    const b = [\"b\"] as const\n    const ab = [\"a\", \"b\"] as const\n\n    const product = _.SemiProduct.product\n    expect(product(_.right(1), _.right(2))).toEqual(_.right([1, 2]))\n    Util.deepStrictEqual(product(_.right(1), _.left(b)), _.left(b))\n    expect(product(_.right(1), _.both(b, 2))).toEqual(_.both(b, [1, 2]))\n\n    Util.deepStrictEqual(product(_.left(a), _.right(2)), _.left(a))\n    Util.deepStrictEqual(product(_.left(a), _.left(b)), _.left(a))\n    Util.deepStrictEqual(product(_.left(a), _.both(b, 2)), _.left(a))\n\n    expect(product(_.both(a, 1), _.right(2))).toEqual(_.both(a, [1, 2]))\n    expect(product(_.both(a, 1), _.left(b))).toEqual(_.left(ab))\n    expect(product(_.both(a, 1), _.both(b, 2))).toEqual(_.both(ab, [1, 2]))\n  })\n\n  it(\"productMany\", () => {\n    const a = [\"a\"] as const\n    const b = [\"b\"] as const\n    const ab = [\"a\", \"b\"] as const\n\n    const productMany: <E, A>(\n      self: _.Validated<E, A>,\n      collection: Iterable<_.Validated<E, A>>\n    ) => _.Validated<E, [A, ...Array<A>]> = _.SemiProduct.productMany\n\n    expect(productMany(_.right(1), [_.right(2)])).toEqual(_.right([1, 2]))\n    Util.deepStrictEqual(\n      productMany(_.right(1), [_.left(b)]),\n      _.left(b)\n    )\n    expect(\n      productMany(_.right(1), [_.both(b, 2)])\n    ).toEqual(\n      _.both(b, [1, 2])\n    )\n\n    Util.deepStrictEqual(productMany(_.left(a), [_.right(2)]), _.left(a))\n    Util.deepStrictEqual(productMany(_.left(a), [_.left(b)]), _.left(a))\n    Util.deepStrictEqual(\n      productMany(_.left(a), [_.both(b, 2)]),\n      _.left(a)\n    )\n\n    expect(productMany(_.both(a, 1), [_.right(2)])).toEqual(_.both(a, [1, 2]))\n    expect(productMany(_.both(a, 1), [_.left(b)])).toEqual(_.left(ab))\n    expect(productMany(_.both(a, 1), [_.both(b, 2)])).toEqual(\n      _.both(ab, [1, 2])\n    )\n  })\n\n  it(\"productAll\", () => {\n    const a = [\"a\"] as const\n    const b = [\"b\"] as const\n    const ab = [\"a\", \"b\"] as const\n\n    const productAll = _.Product.productAll\n    Util.deepStrictEqual(productAll([_.right(1), _.right(2)]), _.right([1, 2]))\n    Util.deepStrictEqual(productAll([_.right(1), _.left(b)]), _.left(b))\n    Util.deepStrictEqual(productAll([_.right(1), _.both(b, 2)]), _.both(b, [1, 2]))\n\n    Util.deepStrictEqual(productAll([_.left(a), _.right(2)]), _.left(a))\n    Util.deepStrictEqual(productAll([_.left(a), _.left(b)]), _.left(a))\n    Util.deepStrictEqual(productAll([_.left(a), _.both(b, 2)]), _.left(a))\n\n    Util.deepStrictEqual(productAll([_.both(a, 1), _.right(2)]), _.both(a, [1, 2]))\n    expect(productAll([_.both(a, 1), _.left(b)])).toEqual(_.left(ab))\n    expect(productAll([_.both(a, 1), _.both(b, 2)])).toEqual(_.both(ab, [1, 2]))\n  })\n\n  it(\"flatMap\", () => {\n    const f = (\n      n: number\n    ) => (n >= 2 ?\n      (n <= 5 ? _.right(n * 2) : _.warn(\"e2\", n)) :\n      _.fail(\"e3\"))\n    Util.deepStrictEqual(\n      pipe(_.fail(\"e1\"), _.flatMap(f)),\n      _.fail(\"e1\")\n    )\n    Util.deepStrictEqual(pipe(_.right(2), _.flatMap(f)), _.right(4))\n    Util.deepStrictEqual(pipe(_.right(1), _.flatMap(f)), _.fail(\"e3\"))\n    Util.deepStrictEqual(pipe(_.right(6), _.flatMap(f)), _.warn(\"e2\", 6))\n    Util.deepStrictEqual(\n      pipe(_.warn(\"e1\", 2), _.flatMap(f)),\n      _.warn(\"e1\", 4)\n    )\n    expect(pipe(_.warn(\"e1\", 1), _.flatMap(f))).toEqual(_.left([\"e1\", \"e3\"]))\n    expect(pipe(_.warn(\"e1\", 6), _.flatMap(f))).toEqual(_.both([\"e1\", \"e2\"], 6))\n  })\n\n  it(\"flatMapNullable\", () => {\n    const f = _.flatMapNullable((n: number) => (n > 0 ? n : null), () => \"e2\")\n    Util.deepStrictEqual(f(_.right(1)), _.right(1))\n    Util.deepStrictEqual(f(_.right(-1)), _.fail(\"e2\"))\n    Util.deepStrictEqual(f(_.fail(\"e1\")), _.fail(\"e1\"))\n    Util.deepStrictEqual(f(_.warn(\"e1\", 1)), _.warn(\"e1\", 1))\n    expect(f(_.warn(\"e1\", -1))).toEqual(_.left([\"e1\", \"e2\"]))\n  })\n\n  it(\"flatMapOption\", () => {\n    const f = _.flatMapOption((n: number) => (n > 0 ? O.some(n) : O.none()), () => \"e2\")\n    Util.deepStrictEqual(f(_.right(1)), _.right(1))\n    Util.deepStrictEqual(f(_.right(-1)), _.fail(\"e2\"))\n    Util.deepStrictEqual(f(_.fail(\"e1\")), _.fail(\"e1\"))\n    Util.deepStrictEqual(f(_.warn(\"e1\", 1)), _.warn(\"e1\", 1))\n    expect(f(_.warn(\"e1\", -1))).toEqual(_.left([\"e1\", \"e2\"]))\n  })\n\n  it(\"flatMapEither\", () => {\n    const f = _.flatMapEither((n: number) => (n > 0 ? E.right(n) : E.left(\"e2\")))\n    Util.deepStrictEqual(f(_.right(1)), _.right(1))\n    Util.deepStrictEqual(f(_.right(-1)), _.fail(\"e2\"))\n    Util.deepStrictEqual(f(_.fail(\"e1\")), _.fail(\"e1\"))\n    Util.deepStrictEqual(f(_.warn(\"e1\", 1)), _.warn(\"e1\", 1))\n    expect(f(_.warn(\"e1\", -1))).toEqual(_.left([\"e1\", \"e2\"]))\n  })\n\n  it(\"flatMapThese\", () => {\n    const f = _.flatMapThese((\n      n: number\n    ) => (n > 10 ? _.both(\"e3\", n) : n > 0 ? _.right(n) : _.left(\"e2\")))\n    Util.deepStrictEqual(f(_.right(1)), _.right(1))\n    Util.deepStrictEqual(f(_.right(-1)), _.fail(\"e2\"))\n    Util.deepStrictEqual(f(_.right(11)), _.warn(\"e3\", 11))\n    Util.deepStrictEqual(f(_.fail(\"e1\")), _.fail(\"e1\"))\n    Util.deepStrictEqual(f(_.warn(\"e1\", 1)), _.warn(\"e1\", 1))\n    expect(f(_.warn(\"e1\", -1))).toEqual(_.left([\"e1\", \"e2\"]))\n    expect(f(_.warn(\"e1\", 11))).toEqual(_.both([\"e1\", \"e3\"], 11))\n  })\n\n  it(\"leftOrBoth\", () => {\n    Util.deepStrictEqual(_.leftOrBoth(() => \"a\")(O.none()), _.left(\"a\"))\n    Util.deepStrictEqual(_.leftOrBoth(() => \"a\")(O.some(1)), _.both(\"a\", 1))\n  })\n\n  it(\"rightOrBoth\", () => {\n    Util.deepStrictEqual(_.rightOrBoth(() => 1)(O.none()), _.right(1))\n    Util.deepStrictEqual(_.rightOrBoth(() => 1)(O.some(\"a\")), _.both(\"a\", 1))\n  })\n\n  it(\"match\", () => {\n    const f = (s: string, n: number) => S.length(s) + Util.double(n)\n    const match = _.match(S.length, Util.double, f)\n    Util.deepStrictEqual(match(_.left(\"foo\")), 3)\n    Util.deepStrictEqual(match(_.right(1)), 2)\n    Util.deepStrictEqual(match(_.both(\"foo\", 1)), 5)\n  })\n\n  it(\"getBothOrElse\", () => {\n    const f = _.getBothOrElse(() => \"a\", () => 1)\n    Util.deepStrictEqual(pipe(_.left(\"b\"), f), [\"b\", 1])\n    Util.deepStrictEqual(pipe(_.right(2), f), [\"a\", 2])\n    Util.deepStrictEqual(pipe(_.both(\"b\", 2), f), [\"b\", 2])\n  })\n\n  it(\"getBoth\", () => {\n    Util.deepStrictEqual(pipe(_.left(\"e\"), _.getBoth), O.none())\n    Util.deepStrictEqual(pipe(_.right(1), _.getBoth), O.none())\n    expect(pipe(_.both(\"e\", 1), _.getBoth)).toEqual(O.some([\"e\", 1]))\n  })\n\n  it(\"getLeft\", () => {\n    Util.deepStrictEqual(_.getLeft(_.left(\"e\")), O.some(\"e\"))\n    Util.deepStrictEqual(_.getLeft(_.right(1)), O.none())\n    Util.deepStrictEqual(_.getLeft(_.both(\"e\", 1)), O.some(\"e\"))\n  })\n\n  it(\"getRight\", () => {\n    Util.deepStrictEqual(_.getRight(_.left(\"e\")), O.none())\n    Util.deepStrictEqual(_.getRight(_.right(1)), O.some(1))\n    Util.deepStrictEqual(_.getRight(_.both(\"e\", 1)), O.some(1))\n  })\n\n  it(\"getLeftOnly\", () => {\n    Util.deepStrictEqual(_.getLeftOnly(_.left(\"e\")), O.some(\"e\"))\n    Util.deepStrictEqual(_.getLeftOnly(_.right(1)), O.none())\n    Util.deepStrictEqual(_.getLeftOnly(_.both(\"e\", 1)), O.none())\n  })\n\n  it(\"getRightOnly\", () => {\n    Util.deepStrictEqual(_.getRightOnly(_.left(\"e\")), O.none())\n    Util.deepStrictEqual(_.getRightOnly(_.right(1)), O.some(1))\n    Util.deepStrictEqual(_.getRightOnly(_.both(\"e\", 1)), O.none())\n  })\n\n  it(\"isLeft\", () => {\n    Util.deepStrictEqual(_.isLeft(_.left(\"e\")), true)\n    Util.deepStrictEqual(_.isLeft(_.right(1)), false)\n    Util.deepStrictEqual(_.isLeft(_.both(\"e\", 1)), false)\n  })\n\n  it(\"isLeftOrBoth\", () => {\n    Util.deepStrictEqual(_.isLeftOrBoth(_.left(\"e\")), true)\n    Util.deepStrictEqual(_.isLeftOrBoth(_.right(1)), false)\n    Util.deepStrictEqual(_.isLeftOrBoth(_.both(\"e\", 1)), true)\n  })\n\n  it(\"isRight\", () => {\n    Util.deepStrictEqual(_.isRight(_.left(\"e\")), false)\n    Util.deepStrictEqual(_.isRight(_.right(1)), true)\n    Util.deepStrictEqual(_.isRight(_.both(\"\", 1)), false)\n  })\n\n  it(\"isRightOrBoth\", () => {\n    Util.deepStrictEqual(_.isRightOrBoth(_.left(\"e\")), false)\n    Util.deepStrictEqual(_.isRightOrBoth(_.right(1)), true)\n    Util.deepStrictEqual(_.isRightOrBoth(_.both(\"e\", 1)), true)\n  })\n\n  it(\"isThese\", () => {\n    Util.deepStrictEqual(_.isThese(_.left(\"e\")), true)\n    Util.deepStrictEqual(_.isThese(_.right(1)), true)\n    Util.deepStrictEqual(_.isThese(_.both(\"e\", 1)), true)\n    Util.deepStrictEqual(_.isThese(E.left(\"e\")), true)\n    Util.deepStrictEqual(_.isThese(E.right(1)), true)\n    Util.deepStrictEqual(_.isThese(O.some(1)), false)\n  })\n\n  it(\"isBoth\", () => {\n    Util.deepStrictEqual(_.isBoth(_.left(\"e\")), false)\n    Util.deepStrictEqual(_.isBoth(_.right(1)), false)\n    Util.deepStrictEqual(_.isBoth(_.both(\"e\", 1)), true)\n  })\n\n  it(\"liftThrowable\", () => {\n    const f = _.liftThrowable((s: string) => {\n      const len = s.length\n      if (len > 0) {\n        return len\n      }\n      throw new Error(\"empty string\")\n    }, identity)\n    Util.deepStrictEqual(f(\"a\"), _.right(1))\n    Util.deepStrictEqual(f(\"\"), _.left(new Error(\"empty string\")))\n  })\n\n  it(\"inspectRight\", () => {\n    const log: Array<number> = []\n    pipe(_.right(1), _.inspectRight((a) => log.push(a)))\n    pipe(_.left(\"e1\"), _.inspectRight((a) => log.push(a)))\n    pipe(_.both(\"e2\", 1), _.inspectRight((a) => log.push(a)))\n    Util.deepStrictEqual(log, [1])\n  })\n\n  it(\"inspectRightOrBoth\", () => {\n    const log: Array<number> = []\n    pipe(_.right(1), _.inspectRightOrBoth((a) => log.push(a)))\n    pipe(_.left(\"e1\"), _.inspectRightOrBoth((a) => log.push(a)))\n    pipe(_.both(\"e2\", 2), _.inspectRightOrBoth((a) => log.push(a)))\n    Util.deepStrictEqual(log, [1, 2])\n  })\n\n  it(\"inspectBoth\", () => {\n    const log: Array<string | number> = []\n    pipe(_.right(1), _.inspectBoth((e, a) => log.push(e, a)))\n    pipe(_.left(\"e1\"), _.inspectBoth((e, a) => log.push(e, a)))\n    pipe(_.both(\"e2\", 2), _.inspectBoth((e, a) => log.push(e, a)))\n    Util.deepStrictEqual(log, [\"e2\", 2])\n  })\n\n  it(\"inspectLeft\", () => {\n    const log: Array<string> = []\n    pipe(_.right(1), _.inspectLeft((e) => log.push(e)))\n    pipe(_.left(\"e1\"), _.inspectLeft((e) => log.push(e)))\n    pipe(_.both(\"e2\", 1), _.inspectLeft((e) => log.push(e)))\n    Util.deepStrictEqual(log, [\"e1\"])\n  })\n\n  it(\"getOrThrow\", () => {\n    expect(pipe(_.right(1), _.getOrThrow)).toEqual(1)\n    expect(pipe(_.both(\"e\", 1), _.getOrThrow)).toEqual(1)\n    expect(() => pipe(_.left(\"e\"), _.getOrThrow)).toThrowError(\n      new Error(\"getOrThrow called on a Left\")\n    )\n  })\n\n  it(\"getOrThrowWith\", () => {\n    expect(pipe(_.right(1), _.getOrThrowWith((e) => new Error(`Unexpected Left: ${e}`)))).toEqual(1)\n    expect(pipe(_.both(\"w\", 1), _.getOrThrowWith((e) => new Error(`Unexpected Left: ${e}`))))\n      .toEqual(1)\n    expect(() => pipe(_.left(\"e\"), _.getOrThrowWith((e) => new Error(`Unexpected Left: ${e}`))))\n      .toThrowError(\n        new Error(\"Unexpected Left: e\")\n      )\n  })\n\n  it(\"getRightOnlyOrThrow\", () => {\n    expect(pipe(_.right(1), _.getRightOnlyOrThrow)).toEqual(1)\n    expect(() => pipe(_.left(\"e\"), _.getRightOnlyOrThrow)).toThrow(\n      new Error(\"getRightOnlyOrThrow called on a Left or a Both\")\n    )\n    expect(() => pipe(_.both(\"e\", 1), _.getRightOnlyOrThrow)).toThrow(\n      new Error(\"getRightOnlyOrThrow called on a Left or a Both\")\n    )\n  })\n\n  it(\"getRightOnlyOrThrowWith\", () => {\n    expect(\n      pipe(_.right(1), _.getRightOnlyOrThrowWith((e) => new Error(`Unexpected Left or Both: ${e}`)))\n    ).toEqual(1)\n    expect(() =>\n      pipe(\n        _.left(\"e\"),\n        _.getRightOnlyOrThrowWith((e) => new Error(`Unexpected Left or Both: ${e}`))\n      )\n    ).toThrow(\n      new Error(\"Unexpected Left or Both: e\")\n    )\n    expect(() =>\n      pipe(\n        _.both(\"e\", 1),\n        _.getRightOnlyOrThrowWith((e) => new Error(`Unexpected Left or Both: ${e}`))\n      )\n    ).toThrow(\n      new Error(\"Unexpected Left or Both: e\")\n    )\n  })\n\n  it(\"getOrElse\", () => {\n    Util.deepStrictEqual(pipe(_.right(1), _.getOrElse(() => 2)), 1)\n    Util.deepStrictEqual(pipe(_.left(\"e\"), _.getOrElse(() => 2)), 2)\n    Util.deepStrictEqual(pipe(_.both(\"e\", 1), _.getOrElse(() => 2)), 1)\n  })\n\n  it(\"getOrNull\", () => {\n    Util.deepStrictEqual(pipe(_.right(1), _.getOrNull), 1)\n    Util.deepStrictEqual(pipe(_.left(\"e\"), _.getOrNull), null)\n    Util.deepStrictEqual(pipe(_.both(\"e\", 1), _.getOrNull), 1)\n  })\n\n  it(\"getOrUndefined\", () => {\n    Util.deepStrictEqual(pipe(_.right(1), _.getOrUndefined), 1)\n    Util.deepStrictEqual(pipe(_.left(\"e\"), _.getOrUndefined), undefined)\n    Util.deepStrictEqual(pipe(_.both(\"e\", 1), _.getOrUndefined), 1)\n  })\n\n  it(\"fromNullable\", () => {\n    Util.deepStrictEqual(_.fromNullable(() => \"default\")(null), _.left(\"default\"))\n    Util.deepStrictEqual(_.fromNullable(() => \"default\")(undefined), _.left(\"default\"))\n    Util.deepStrictEqual(_.fromNullable(() => \"default\")(1), _.right(1))\n  })\n\n  it(\"liftNullable\", () => {\n    const f = _.liftNullable((n: number) => (n > 0 ? n : null), () => \"error\")\n    Util.deepStrictEqual(f(1), _.right(1))\n    Util.deepStrictEqual(f(-1), _.left(\"error\"))\n  })\n\n  it(\"liftPredicate\", () => {\n    const f = _.liftPredicate((n: number) => n >= 2, () => \"e\")\n    Util.deepStrictEqual(f(3), _.right(3))\n    Util.deepStrictEqual(f(1), _.left(\"e\"))\n  })\n\n  it(\"fromIterable\", () => {\n    Util.deepStrictEqual(_.fromIterable(() => \"e\")([]), _.left(\"e\"))\n    Util.deepStrictEqual(_.fromIterable(() => \"e\")([\"a\"]), _.right(\"a\"))\n  })\n\n  it(\"fromOption\", () => {\n    Util.deepStrictEqual(_.fromOption(() => \"e\")(O.none()), _.left(\"e\"))\n    Util.deepStrictEqual(_.fromOption(() => \"e\")(O.some(1)), _.right(1))\n  })\n\n  it(\"fromEither\", () => {\n    Util.deepStrictEqual(_.fromEither(E.right(1)), _.right(1))\n    expect(_.fromEither(E.left(\"e\"))).toEqual(_.left([\"e\"]))\n  })\n\n  it(\"toValidated\", () => {\n    Util.deepStrictEqual(_.toValidated(_.right(1)), _.right(1))\n    Util.deepStrictEqual(_.toValidated(_.left(\"e\")), _.fail(\"e\"))\n    Util.deepStrictEqual(_.toValidated(_.both(\"e\", 1)), _.warn(\"e\", 1))\n  })\n\n  it(\"toEither\", () => {\n    expect(_.toEither).exist\n  })\n\n  it(\"absolve\", () => {\n    Util.deepStrictEqual(_.absolve(_.right(1)), E.right(1))\n    Util.deepStrictEqual(_.absolve(_.left(\"e\")), E.left(\"e\"))\n    Util.deepStrictEqual(_.absolve(_.both(\"e\", 1)), E.right(1))\n  })\n\n  it(\"condemn\", () => {\n    Util.deepStrictEqual(_.condemn(_.right(1)), E.right(1))\n    Util.deepStrictEqual(_.condemn(_.left(\"e\")), E.left(\"e\"))\n    Util.deepStrictEqual(_.condemn(_.both(\"e\", 1)), E.left(\"e\"))\n  })\n\n  it(\"liftOption\", () => {\n    const f = _.liftOption((n: number) => (n > 0 ? O.some(n) : O.none()), () => \"e\")\n    Util.deepStrictEqual(f(1), _.right(1))\n    Util.deepStrictEqual(f(-1), _.left(\"e\"))\n  })\n\n  it(\"liftEither\", () => {\n    const f = _.liftEither((n: number) => (n > 0 ? E.right(n) : E.left(\"e\")))\n    Util.deepStrictEqual(f(1), _.right(1))\n    Util.deepStrictEqual(f(-1), _.fail(\"e\"))\n  })\n\n  it(\"liftThese\", () => {\n    const f = _.liftThese((n: number) => (n > 0 ? _.right(n) : _.left(\"e\")))\n    Util.deepStrictEqual(f(1), _.right(1))\n    Util.deepStrictEqual(f(-1), _.fail(\"e\"))\n  })\n\n  it(\"fromTuple\", () => {\n    expect(pipe([\"e\", 1] as [string, number], _.fromTuple)).toEqual(_.both(\"e\", 1))\n  })\n\n  it(\"reverse\", () => {\n    Util.deepStrictEqual(_.reverse(_.left(\"e\")), _.right(\"e\"))\n    Util.deepStrictEqual(_.reverse(_.right(1)), _.left(1))\n    Util.deepStrictEqual(_.reverse(_.both(\"e\", 1)), _.both(1, \"e\"))\n  })\n\n  it(\"exists\", () => {\n    const gt2 = _.exists((n: number) => n > 2)\n    Util.deepStrictEqual(gt2(_.left(\"a\")), false)\n    Util.deepStrictEqual(gt2(_.right(1)), false)\n    Util.deepStrictEqual(gt2(_.right(3)), true)\n    Util.deepStrictEqual(gt2(_.both(\"a\", 1)), false)\n    Util.deepStrictEqual(gt2(_.both(\"a\", 3)), true)\n  })\n\n  it(\"contains\", () => {\n    const contains = _.contains(number)\n    Util.deepStrictEqual(contains(2)(_.left(\"a\")), false)\n    Util.deepStrictEqual(contains(2)(_.right(2)), true)\n    Util.deepStrictEqual(contains(1)(_.right(2)), false)\n    Util.deepStrictEqual(contains(2)(_.both(\"a\", 2)), true)\n    Util.deepStrictEqual(contains(1)(_.both(\"a\", 2)), false)\n  })\n\n  it(\"of\", () => {\n    Util.deepStrictEqual(_.of(1), _.right(1))\n  })\n\n  it(\"orElse\", () => {\n    Util.deepStrictEqual(pipe(_.right(1), _.orElse(() => _.right(2))), _.right(1))\n    Util.deepStrictEqual(pipe(_.right(1), _.orElse(() => _.left(\"b\"))), _.right(1))\n    Util.deepStrictEqual(pipe(_.right(1), _.orElse(() => _.both(\"b\", 2))), _.right(1))\n    Util.deepStrictEqual(pipe(_.left(\"a\"), _.orElse(() => _.right(2))), _.right(2))\n    Util.deepStrictEqual(pipe(_.left(\"a\"), _.orElse(() => _.left(\"b\"))), _.left(\"b\"))\n    Util.deepStrictEqual(pipe(_.left(\"a\"), _.orElse(() => _.both(\"b\", 2))), _.both(\"b\", 2))\n    Util.deepStrictEqual(pipe(_.both(\"a\", 1), _.orElse(() => _.right(2))), _.both(\"a\", 1))\n    Util.deepStrictEqual(pipe(_.both(\"a\", 1), _.orElse(() => _.left(\"b\"))), _.both(\"a\", 1))\n    Util.deepStrictEqual(pipe(_.both(\"a\", 1), _.orElse(() => _.both(\"b\", 2))), _.both(\"a\", 1))\n  })\n\n  it(\"orElseEither\", () => {\n    expect(pipe(_.right(1), _.orElseEither(() => _.right(2)))).toEqual(_.right(E.left(1)))\n    expect(pipe(_.right(1), _.orElseEither(() => _.left(\"b\")))).toEqual(_.right(E.left(1)))\n    expect(pipe(_.right(1), _.orElseEither(() => _.both(\"b\", 2)))).toEqual(_.right(E.left(1)))\n    expect(pipe(_.left(\"a\"), _.orElseEither(() => _.right(2)))).toEqual(_.right(E.right(2)))\n    expect(pipe(_.left(\"a\"), _.orElseEither(() => _.left(\"b\")))).toEqual(_.left(\"b\"))\n    expect(pipe(_.left(\"a\"), _.orElseEither(() => _.both(\"b\", 2)))).toEqual(_.both(\"b\", E.right(2)))\n    expect(pipe(_.both(\"a\", 1), _.orElseEither(() => _.right(2)))).toEqual(_.both(\"a\", E.left(1)))\n    expect(pipe(_.both(\"a\", 1), _.orElseEither(() => _.left(\"b\")))).toEqual(_.both(\"a\", E.left(1)))\n    expect(pipe(_.both(\"a\", 1), _.orElseEither(() => _.both(\"b\", 2)))).toEqual(\n      _.both(\"a\", E.left(1))\n    )\n  })\n\n  it(\"orElseFail\", () => {\n    Util.deepStrictEqual(pipe(_.right(1), _.orElseFail(() => \"e2\")), _.right(1))\n    Util.deepStrictEqual(pipe(_.left(\"e1\"), _.orElseFail(() => \"e2\")), _.left(\"e2\"))\n    Util.deepStrictEqual(pipe(_.both(\"e1\", 1), _.orElseFail(() => \"e2\")), _.both(\"e1\", 1))\n  })\n\n  it(\"firstSuccessOf\", () => {\n    Util.deepStrictEqual(pipe(_.right(1), _.firstRightOrBothOf([])), _.right(1))\n    Util.deepStrictEqual(pipe(_.left(\"e\"), _.firstRightOrBothOf([])), _.left(\"e\"))\n    Util.deepStrictEqual(\n      pipe(\n        _.left(\"e1\"),\n        _.firstRightOrBothOf([_.left(\"e2\"), _.left(\"e3\"), _.left(\"e4\"), _.right(1)])\n      ),\n      _.right(1)\n    )\n    Util.deepStrictEqual(\n      pipe(\n        _.left(\"e1\"),\n        _.firstRightOrBothOf([_.left(\"e2\"), _.left(\"e3\"), _.left(\"e4\"), _.both(\"e5\", 1)])\n      ),\n      _.both(\"e5\", 1)\n    )\n    Util.deepStrictEqual(\n      pipe(_.left(\"e1\"), _.firstRightOrBothOf([_.left(\"e2\"), _.left(\"e3\"), _.left(\"e4\")])),\n      _.left(\"e4\")\n    )\n  })\n\n  it(\"coproduct\", () => {\n    const coproduct = _.SemiCoproduct.coproduct\n    Util.deepStrictEqual(coproduct(_.right(1), _.right(2)), _.right(1))\n    Util.deepStrictEqual(coproduct(_.right(1), _.left(\"e2\")), _.right(1))\n    Util.deepStrictEqual(coproduct(_.left(\"e1\"), _.right(2)), _.right(2))\n    Util.deepStrictEqual(coproduct(_.left(\"e1\"), _.left(\"e2\")), _.left(\"e2\"))\n    Util.deepStrictEqual(coproduct(_.both(\"e1\", 1), _.right(2)), _.both(\"e1\", 1))\n    Util.deepStrictEqual(coproduct(_.both(\"e1\", 1), _.left(\"e2\")), _.both(\"e1\", 1))\n  })\n\n  it(\"coproduct\", () => {\n    const coproductMany = _.SemiCoproduct.coproductMany\n    Util.deepStrictEqual(coproductMany(_.right(1), [_.right(2)]), _.right(1))\n    Util.deepStrictEqual(coproductMany(_.right(1), [_.left(\"e2\")]), _.right(1))\n    Util.deepStrictEqual(coproductMany(_.left(\"e1\"), [_.right(2)]), _.right(2))\n    Util.deepStrictEqual(coproductMany(_.left(\"e1\"), [_.left(\"e2\")]), _.left(\"e2\"))\n    Util.deepStrictEqual(coproductMany(_.both(\"e1\", 1), [_.right(2)]), _.both(\"e1\", 1))\n    Util.deepStrictEqual(coproductMany(_.both(\"e1\", 1), [_.left(\"e2\")]), _.both(\"e1\", 1))\n  })\n\n  it(\"compact\", () => {\n    Util.deepStrictEqual(pipe(_.right(O.some(1)), _.compact(() => \"e2\")), _.right(1))\n    Util.deepStrictEqual(pipe(_.right(O.none()), _.compact(() => \"e2\")), _.left(\"e2\"))\n    Util.deepStrictEqual(pipe(_.left(\"e1\"), _.compact(() => \"e2\")), _.left(\"e1\"))\n    Util.deepStrictEqual(pipe(_.both(\"e1\", O.some(1)), _.compact(() => \"e2\")), _.both(\"e1\", 1))\n    Util.deepStrictEqual(pipe(_.both(\"e1\", O.none()), _.compact(() => \"e2\")), _.left(\"e2\"))\n  })\n\n  it(\"filter\", () => {\n    const predicate = (n: number) => n > 10\n    Util.deepStrictEqual(pipe(_.right(12), _.filter(predicate, () => \"e2\")), _.right(12))\n    Util.deepStrictEqual(pipe(_.right(7), _.filter(predicate, () => \"e2\")), _.left(\"e2\"))\n    Util.deepStrictEqual(pipe(_.left(\"e1\"), _.filter(predicate, () => \"e2\")), _.left(\"e1\"))\n    Util.deepStrictEqual(pipe(_.both(\"e1\", 12), _.filter(predicate, () => \"e2\")), _.both(\"e1\", 12))\n    Util.deepStrictEqual(pipe(_.both(\"e1\", 7), _.filter(predicate, () => \"e2\")), _.left(\"e2\"))\n  })\n\n  it(\"filterMap\", () => {\n    const f = (n: number) => (n > 2 ? O.some(n + 1) : O.none())\n    Util.deepStrictEqual(pipe(_.left(\"e1\"), _.filterMap(f, () => \"e2\")), _.left(\"e1\"))\n    Util.deepStrictEqual(pipe(_.right(1), _.filterMap(f, () => \"e2\")), _.left(\"e2\"))\n    Util.deepStrictEqual(pipe(_.right(3), _.filterMap(f, () => \"e2\")), _.right(4))\n    Util.deepStrictEqual(pipe(_.both(\"e1\", 1), _.filterMap(f, () => \"e2\")), _.left(\"e2\"))\n    Util.deepStrictEqual(pipe(_.both(\"e1\", 3), _.filterMap(f, () => \"e2\")), _.both(\"e1\", 4))\n  })\n\n  it(\"zipWith\", () => {\n    const e: _.Validated<string, number> = _.left([\"a\"])\n    expect(pipe(e, _.zipWith(_.right(2), (a, b) => a + b))).toEqual(e)\n    expect(pipe(_.right(1), _.zipWith(e, (a, b) => a + b))).toEqual(e)\n    expect(pipe(_.right(1), _.zipWith(_.right(2), (a, b) => a + b))).toEqual(_.right(3))\n  })\n\n  it(\"sum\", () => {\n    const e: _.Validated<string, number> = _.left([\"a\"])\n    expect(pipe(e, _.sum(_.right(2)))).toEqual(e)\n    expect(pipe(_.right(1), _.sum(e))).toEqual(e)\n    expect(pipe(_.right(2), _.sum(_.right(3)))).toEqual(_.right(5))\n  })\n\n  it(\"multiply\", () => {\n    const e: _.Validated<string, number> = _.left([\"a\"])\n    expect(pipe(e, _.multiply(_.right(2)))).toEqual(e)\n    expect(pipe(_.right(1), _.multiply(e))).toEqual(e)\n    expect(pipe(_.right(2), _.multiply(_.right(3)))).toEqual(_.right(6))\n  })\n\n  it(\"subtract\", () => {\n    const e: _.Validated<string, number> = _.left([\"a\"])\n    expect(pipe(e, _.subtract(_.right(2)))).toEqual(e)\n    expect(pipe(_.right(1), _.subtract(e))).toEqual(e)\n    expect(pipe(_.right(2), _.subtract(_.right(3)))).toEqual(_.right(-1))\n  })\n\n  it(\"divide\", () => {\n    const e: _.Validated<string, number> = _.left([\"a\"])\n    expect(pipe(e, _.divide(_.right(2)))).toEqual(e)\n    expect(pipe(_.right(1), _.divide(e))).toEqual(e)\n    expect(pipe(_.right(6), _.divide(_.right(3)))).toEqual(_.right(2))\n  })\n\n  it(\"getEquivalence\", () => {\n    const isEquivalent = _.getEquivalence(N.Equivalence, N.Equivalence)\n    Util.deepStrictEqual(isEquivalent(_.left(2), _.left(2)), true)\n    Util.deepStrictEqual(isEquivalent(_.left(2), _.left(3)), false)\n    Util.deepStrictEqual(isEquivalent(_.left(3), _.left(2)), false)\n    Util.deepStrictEqual(isEquivalent(_.left(2), _.right(2)), false)\n    Util.deepStrictEqual(isEquivalent(_.left(2), _.both(2, 2)), false)\n    Util.deepStrictEqual(isEquivalent(_.right(2), _.right(2)), true)\n    Util.deepStrictEqual(isEquivalent(_.right(2), _.right(3)), false)\n    Util.deepStrictEqual(isEquivalent(_.right(3), _.right(2)), false)\n    Util.deepStrictEqual(isEquivalent(_.right(2), _.both(2, 2)), false)\n    Util.deepStrictEqual(isEquivalent(_.both(2, 2), _.both(2, 2)), true)\n    Util.deepStrictEqual(isEquivalent(_.both(2, 3), _.both(3, 2)), false)\n  })\n})\n"
  },
  {
    "path": "test/Tuple.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as T from \"@fp-ts/core/Tuple\"\n\ndescribe.concurrent(\"Tuple\", () => {\n  it(\"exports\", () => {\n    expect(T.Bicovariant).exists\n    expect(T.mapFirst).exists\n    expect(T.mapSecond).exists\n    expect(T.appendElement).exists\n    expect(T.getEquivalence).exists\n    expect(T.getOrder).exists\n    expect(T.getSemigroup).exists\n    expect(T.getMonoid).exists\n  })\n\n  it(\"tuple\", () => {\n    expect(T.tuple(\"a\", 1, true)).toEqual([\"a\", 1, true])\n  })\n\n  it(\"appendElement\", () => {\n    expect(pipe(T.tuple(\"a\", 1), T.appendElement(true))).toEqual([\"a\", 1, true])\n  })\n\n  it(\"getFirst\", () => {\n    expect(T.getFirst(T.tuple(\"a\", 1))).toEqual(\"a\")\n  })\n\n  it(\"getSecond\", () => {\n    expect(T.getSecond(T.tuple(\"a\", 1))).toEqual(1)\n  })\n\n  it(\"bimap\", () => {\n    expect(T.bimap(T.tuple(\"a\", 1), s => s + \"!\", n => n * 2)).toEqual([\"a!\", 2])\n  })\n\n  it(\"swap\", () => {\n    expect(T.swap(T.tuple(\"a\", 1))).toEqual([1, \"a\"])\n  })\n})\n"
  },
  {
    "path": "test/index.ts",
    "content": "import * as _ from \"@fp-ts/core\"\nimport * as assert from \"assert\"\nimport * as glob from \"glob\"\nimport * as path from \"path\"\n\nconst getExportName = (name: string): string => {\n  if (name === \"HKT\") {\n    return name.toLowerCase()\n  }\n  return name.substring(0, 1).toLowerCase() + name.substring(1)\n}\n\nfunction getModuleNames(): ReadonlyArray<string> {\n  return glob\n    .sync(\"./src/**/*.ts\")\n    .map((file) => path.parse(file))\n    .filter((file) => !file.dir.startsWith(\"./src/internal\"))\n    .map((file) => file.name)\n}\n\ndescribe.concurrent(\"index\", () => {\n  it(\"check exported modules\", () => {\n    const moduleNames = getModuleNames()\n    moduleNames.forEach((name) => {\n      if (name !== \"index\") {\n        const exportName = getExportName(name)\n        assert.deepStrictEqual(\n          // tslint:disable-next-line: strict-type-predicates\n          (_ as Record<string, unknown>)[exportName] !== undefined,\n          true,\n          `The \"${name}\" module is not exported in src/index.ts as ${exportName}`\n        )\n      }\n    })\n  })\n})\n"
  },
  {
    "path": "test/limbo/Category.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Composable } from \"./Composable\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Category<F extends TypeLambda> extends Composable<F> {\n  readonly identity: <R>() => Kind<F, R, never, never, R>\n}\n"
  },
  {
    "path": "test/limbo/Comonad.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Extendable } from \"@fp-ts/core/test/limbo/Extendable\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Comonad<F extends TypeLambda> extends Extendable<F> {\n  readonly extract: <R, O, E, A>(self: Kind<F, R, O, E, A>) => A\n}\n"
  },
  {
    "path": "test/limbo/Composable.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Composable<F extends TypeLambda> extends TypeClass<F> {\n  readonly compose: <B, O2, E2, C>(\n    bc: Kind<F, B, O2, E2, C>\n  ) => <A, O1, E1>(ab: Kind<F, A, O1, E1, B>) => Kind<F, A, O1 | O2, E1 | E2, C>\n}\n"
  },
  {
    "path": "test/limbo/Extendable.ts",
    "content": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface Extendable<F extends TypeLambda> extends Covariant<F> {\n  readonly extend: <R, O, E, A, B>(\n    f: (self: Kind<F, R, O, E, A>) => B\n  ) => (self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>\n}\n"
  },
  {
    "path": "test/limbo/NonEmptyTraversable.ts",
    "content": "/**\n * NonEmptyTraversable<T> describes a parameterized type T<A> that contains one or more values of type `A`.\n *\n * @since 1.0.0\n */\nimport { identity, pipe } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/typeclass/Covariant\"\nimport type { SemiApplicative } from \"@fp-ts/core/typeclass/SemiApplicative\"\n\n/**\n * @category type class\n * @since 1.0.0\n */\nexport interface NonEmptyTraversable<T extends TypeLambda> extends TypeClass<T> {\n  readonly traverseNonEmpty: <F extends TypeLambda>(\n    F: SemiApplicative<F>\n  ) => <A, R, O, E, B>(\n    f: (a: A) => Kind<F, R, O, E, B>\n  ) => <TR, TO, TE>(\n    self: Kind<T, TR, TO, TE, A>\n  ) => Kind<F, R, O, E, Kind<T, TR, TO, TE, B>>\n\n  readonly sequenceNonEmpty: <F extends TypeLambda>(\n    F: SemiApplicative<F>\n  ) => <TR, TO, TE, R, O, E, A>(\n    self: Kind<T, TR, TO, TE, Kind<F, R, O, E, A>>\n  ) => Kind<F, R, O, E, Kind<T, TR, TO, TE, A>>\n}\n\n/**\n * Returns a default `traverseNonEmpty` composition.\n *\n * @since 1.0.0\n */\nexport const traverseNonEmptyComposition = <T extends TypeLambda, F extends TypeLambda>(\n  T: NonEmptyTraversable<T>,\n  G: NonEmptyTraversable<F>\n) =>\n  <G extends TypeLambda>(F: SemiApplicative<G>) =>\n    <A, R, O, E, B>(\n      f: (a: A) => Kind<G, R, O, E, B>\n    ): (<TR, TO, TE, GR, GO, GE>(\n      self: Kind<T, TR, TO, TE, Kind<F, GR, GO, GE, A>>\n    ) => Kind<G, R, O, E, Kind<T, TR, TO, TE, Kind<F, GR, GO, GE, B>>>) =>\n      T.traverseNonEmpty(F)(G.traverseNonEmpty(F)(f))\n\n/**\n * Returns a default `sequenceNonEmpty` composition.\n *\n * @since 1.0.0\n */\nexport const sequenceNonEmptyComposition = <T extends TypeLambda, F extends TypeLambda>(\n  T: NonEmptyTraversable<T> & Covariant<T>,\n  G: NonEmptyTraversable<F>\n) =>\n  <G extends TypeLambda>(F: SemiApplicative<G>) =>\n    <TR, TO, TE, GR, GO, GE, R, O, E, A>(\n      self: Kind<T, TR, TO, TE, Kind<F, GR, GO, GE, Kind<G, R, O, E, A>>>\n    ): Kind<G, R, O, E, Kind<T, TR, TO, TE, Kind<F, GR, GO, GE, A>>> =>\n      T.sequenceNonEmpty(F)(pipe(self, T.map(G.sequenceNonEmpty(F))))\n\n/**\n * Returns a default `sequenceNonEmpty` implementation.\n *\n * @since 1.0.0\n */\nexport const sequenceNonEmpty = <T extends TypeLambda>(\n  traverseNonEmpty: NonEmptyTraversable<T>[\"traverseNonEmpty\"]\n): NonEmptyTraversable<T>[\"sequenceNonEmpty\"] =>\n  <F extends TypeLambda>(\n    F: SemiApplicative<F>\n  ): (<TR, TO, TE, R, O, E, A>(\n    self: Kind<T, TR, TO, TE, Kind<F, R, O, E, A>>\n  ) => Kind<F, R, O, E, Kind<T, TR, TO, TE, A>>) => traverseNonEmpty(F)(identity)\n"
  },
  {
    "path": "test/typeclass/Applicative.ts",
    "content": "import * as N from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/typeclass/Applicative\"\nimport * as U from \"../util\"\n\ndescribe(\"Applicative\", () => {\n  it(\"liftMonoid\", () => {\n    const liftMonoid = _.getMonoid(O.Applicative)\n    const M = liftMonoid(N.MonoidSum)\n    U.deepStrictEqual(M.combine(O.none(), O.none()), O.none())\n    U.deepStrictEqual(M.combine(O.some(1), O.none()), O.none())\n    U.deepStrictEqual(M.combine(O.none(), O.some(2)), O.none())\n    U.deepStrictEqual(M.combine(O.some(1), O.some(2)), O.some(3))\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Bicovariant.ts",
    "content": "import * as E from \"@fp-ts/core/Either\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/typeclass/Bicovariant\"\nimport * as U from \"../util\"\n\ndescribe(\"Bicovariant\", () => {\n  it(\"mapLeft\", () => {\n    const mapLeft = _.mapLeft(E.Bicovariant)\n    const f = (s: string) => s.length\n    U.deepStrictEqual(pipe(E.right(1), mapLeft(f)), E.right(1))\n    U.deepStrictEqual(pipe(E.left(\"eee\"), mapLeft(f)), E.left(3))\n  })\n\n  it(\"map\", () => {\n    const map = _.map(E.Bicovariant)\n    const g = (n: number) => n * 2\n    U.deepStrictEqual(pipe(E.right(1), map(g)), E.right(2))\n    U.deepStrictEqual(pipe(E.left(\"eee\"), map(g)), E.left(\"eee\"))\n  })\n\n  it(\"bimapComposition\", () => {\n    const bimap = _.bimapComposition(RA.Covariant, E.Bicovariant)\n    const f = (s: string) => s.length\n    const g = (n: number) => n * 2\n    U.deepStrictEqual(bimap([E.right(1), E.right(2), E.left(\"eee\")], f, g), [\n      E.right(2),\n      E.right(4),\n      E.left(3)\n    ])\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Bounded.ts",
    "content": "import * as Number from \"@fp-ts/core/Number\"\nimport * as _ from \"@fp-ts/core/typeclass/Bounded\"\nimport * as U from \"../util\"\n\ndescribe(\"Bounded\", () => {\n  it(\"clamp\", () => {\n    const clamp = _.clamp({ ...Number.Order, minBound: 1, maxBound: 10 })\n    U.deepStrictEqual(clamp(2), 2)\n    U.deepStrictEqual(clamp(10), 10)\n    U.deepStrictEqual(clamp(20), 10)\n    U.deepStrictEqual(clamp(1), 1)\n    U.deepStrictEqual(clamp(-10), 1)\n  })\n\n  it(\"reverse\", () => {\n    const B = _.reverse({ ...Number.Order, minBound: 10, maxBound: 1 })\n    U.deepStrictEqual(B.maxBound, 10)\n    U.deepStrictEqual(B.minBound, 1)\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Chainable.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/typeclass/Chainable\"\nimport * as U from \"../util\"\n\ndescribe(\"Chainable\", () => {\n  it(\"andThenDiscard\", () => {\n    const andThenDiscard = _.andThenDiscard(O.Chainable)\n    U.deepStrictEqual(pipe(O.none(), andThenDiscard(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.none(), andThenDiscard(O.some(2))), O.none())\n    U.deepStrictEqual(pipe(O.some(1), andThenDiscard(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.some(1), andThenDiscard(O.some(2))), O.some(1))\n  })\n\n  it(\"bind\", () => {\n    const bind = _.bind(O.Chainable)\n    U.deepStrictEqual(pipe(O.Do, bind(\"a\", () => O.none())), O.none())\n    U.deepStrictEqual(pipe(O.Do, bind(\"a\", () => O.some(1))), O.some({ a: 1 }))\n  })\n\n  it(\"tap\", () => {\n    const tap = _.tap(O.Chainable)\n    U.deepStrictEqual(pipe(O.none(), tap(() => O.none())), O.none())\n    U.deepStrictEqual(pipe(O.none(), tap(() => O.some(2))), O.none())\n    U.deepStrictEqual(pipe(O.some(1), tap(() => O.none())), O.none())\n    U.deepStrictEqual(pipe(O.some(1), tap(() => O.some(2))), O.some(1))\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Contravariant.ts",
    "content": "import * as P from \"@fp-ts/core/Predicate\"\nimport * as S from \"@fp-ts/core/String\"\nimport * as _ from \"@fp-ts/core/typeclass/Contravariant\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport * as U from \"../util\"\n\ndescribe(\"Contravariant\", () => {\n  it(\"mapComposition\", () => {\n    const map = _.contramapComposition(P.Contravariant, P.Contravariant)\n    const emptyString: P.Predicate<P.Predicate<string>> = p => p(\"\") === true\n    const a = map(emptyString, s => s.length)\n    U.deepStrictEqual(a(S.isString), false)\n    U.deepStrictEqual(a(n => n === 0), true)\n  })\n\n  it(\"imap\", () => {\n    const O = _.imap<order.OrderTypeLambda>(order.contramap)(\n      (s: string) => [s],\n      ([s]) => s\n    )(\n      S.Order\n    )\n    U.deepStrictEqual(O.compare([\"a\"], [\"b\"]), -1)\n    U.deepStrictEqual(O.compare([\"a\"], [\"a\"]), 0)\n    U.deepStrictEqual(O.compare([\"b\"], [\"a\"]), 1)\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Coproduct.ts",
    "content": "import * as O from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/typeclass/Coproduct\"\nimport * as U from \"../util\"\n\ndescribe(\"Coproduct\", () => {\n  it(\"getMonoid\", () => {\n    const M = _.getMonoid(O.Alternative)<unknown, never, never, number>()\n    U.deepStrictEqual(M.combine(O.none(), O.none()), O.none())\n    U.deepStrictEqual(M.combine(O.some(1), O.none()), O.some(1))\n    U.deepStrictEqual(M.combine(O.none(), O.some(2)), O.some(2))\n    U.deepStrictEqual(M.combine(O.some(1), O.some(2)), O.some(1))\n\n    U.deepStrictEqual(M.combine(M.empty, O.none()), O.none())\n    U.deepStrictEqual(M.combine(M.empty, O.some(2)), O.some(2))\n    U.deepStrictEqual(M.combine(O.some(1), M.empty), O.some(1))\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Covariant.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/typeclass/Covariant\"\nimport * as U from \"../util\"\n\ndescribe(\"Covariant\", () => {\n  it(\"mapComposition\", () => {\n    const map = _.mapComposition(RA.Covariant, RA.Covariant)\n    const f = (a: string) => a + \"!\"\n    U.deepStrictEqual(map([], f), [])\n    U.deepStrictEqual(map([[]], f), [[]])\n    U.deepStrictEqual(map([[\"a\"]], f), [[\"a!\"]])\n    U.deepStrictEqual(map([[\"a\"], [\"b\"]], f), [[\"a!\"], [\"b!\"]])\n    U.deepStrictEqual(map([[\"a\", \"c\"], [\"b\", \"d\", \"e\"]], f), [[\"a!\", \"c!\"], [\n      \"b!\",\n      \"d!\",\n      \"e!\"\n    ]])\n  })\n\n  it(\"flap\", () => {\n    const flap = _.flap(O.Covariant)\n    U.deepStrictEqual(pipe(1, flap(O.none())), O.none())\n    U.deepStrictEqual(pipe(1, flap(O.some(U.double))), O.some(2))\n  })\n\n  it(\"as\", () => {\n    const as = _.as(O.Covariant)\n    U.deepStrictEqual(pipe(O.none(), as(1)), O.none())\n    U.deepStrictEqual(pipe(O.some(1), as(2)), O.some(2))\n  })\n\n  it(\"asUnit\", () => {\n    const asUnit = _.asUnit(O.Covariant)\n    U.deepStrictEqual(pipe(O.none(), asUnit), O.none())\n    U.deepStrictEqual(pipe(O.some(1), asUnit), O.some(undefined))\n  })\n\n  it(\"let\", () => {\n    const letOption = _.let(O.Covariant)\n    U.deepStrictEqual(\n      pipe(O.some({ a: 1, b: 2 }), letOption(\"c\", ({ a, b }) => a + b)),\n      O.some({ a: 1, b: 2, c: 3 })\n    )\n  })\n\n  it(\"imap\", () => {\n    const f = _.imap<O.OptionTypeLambda>(O.map)((s: string) => [s], ([s]) => s)\n    U.deepStrictEqual(pipe(O.none(), f), O.none())\n    U.deepStrictEqual(pipe(O.some(\"a\"), f), O.some([\"a\"]))\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Equivalence.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as _ from \"@fp-ts/core/typeclass/Equivalence\"\n\ndescribe(\"Equivalence\", () => {\n  it(\"exports\", () => {\n    expect(_.Invariant).exists\n    expect(_.Contravariant).exists\n    expect(_.SemiProduct).exists\n    expect(_.Product).exists\n    expect(_.tuple).exists\n    expect(_.struct).exists\n  })\n\n  test(\"strict returns an Equivalence that uses strict equality (===) to compare values\", () => {\n    const eq = _.strict<{ a: number }>()\n    const a = { a: 1 }\n    expect(eq(a, a)).toBe(true)\n    expect(eq({ a: 1 }, { a: 1 })).toBe(false)\n  })\n\n  it(\"contramap\", () => {\n    interface Person {\n      readonly name: string\n      readonly age: number\n    }\n    const eqPerson = pipe(_.string, _.contramap((p: Person) => p.name))\n    expect(eqPerson({ name: \"a\", age: 1 }, { name: \"a\", age: 2 })).toEqual(true)\n    expect(eqPerson({ name: \"a\", age: 1 }, { name: \"a\", age: 1 })).toEqual(true)\n    expect(eqPerson({ name: \"a\", age: 1 }, { name: \"b\", age: 1 })).toEqual(false)\n    expect(eqPerson({ name: \"a\", age: 1 }, { name: \"b\", age: 2 })).toEqual(false)\n  })\n\n  it(\"getSemigroup\", () => {\n    type T = readonly [string, number, boolean]\n    const S = _.getSemigroup<T>()\n    const E0: _.Equivalence<T> = _.contramap((x: T) => x[0])(_.string)\n    const E1: _.Equivalence<T> = _.contramap((x: T) => x[1])(_.number)\n    const eqE0E1 = S.combine(E0, E1)\n    expect(eqE0E1([\"a\", 1, true], [\"a\", 1, true])).toEqual(true)\n    expect(eqE0E1([\"a\", 1, true], [\"a\", 1, false])).toEqual(true)\n    expect(eqE0E1([\"a\", 1, true], [\"b\", 1, true])).toEqual(false)\n    expect(eqE0E1([\"a\", 1, true], [\"a\", 2, false])).toEqual(false)\n    const E2: _.Equivalence<T> = _.contramap((x: T) => x[2])(_.boolean)\n    const eqE0E1E2 = S.combineMany(E0, [E1, E2])\n    expect(eqE0E1E2([\"a\", 1, true], [\"a\", 1, true])).toEqual(true)\n    expect(eqE0E1E2([\"a\", 1, true], [\"b\", 1, true])).toEqual(false)\n    expect(eqE0E1E2([\"a\", 1, true], [\"a\", 2, true])).toEqual(false)\n    expect(eqE0E1E2([\"a\", 1, true], [\"a\", 1, false])).toEqual(false)\n  })\n\n  it(\"getMonoid\", () => {\n    type T = readonly [string, number, boolean]\n    const M = _.getMonoid<T>()\n    const E0: _.Equivalence<T> = _.contramap((x: T) => x[0])(_.string)\n    const E1: _.Equivalence<T> = _.contramap((x: T) => x[1])(_.number)\n    const E2: _.Equivalence<T> = _.contramap((x: T) => x[2])(_.boolean)\n    const eqE0E1E2 = M.combineAll([E0, E1, E2])\n    expect(eqE0E1E2([\"a\", 1, true], [\"a\", 1, true])).toEqual(true)\n    expect(eqE0E1E2([\"a\", 1, true], [\"b\", 1, true])).toEqual(false)\n    expect(eqE0E1E2([\"a\", 1, true], [\"a\", 2, true])).toEqual(false)\n    expect(eqE0E1E2([\"a\", 1, true], [\"a\", 1, false])).toEqual(false)\n  })\n\n  it(\"of\", () => {\n    const eq = _.Product.of([])\n    expect(eq([], [])).toEqual(true)\n  })\n\n  it(\"product\", () => {\n    const eq = _.Product.product(_.string, _.string)\n    expect(eq([\"a\", \"b\"], [\"a\", \"b\"])).toEqual(true)\n    expect(eq([\"a\", \"b\"], [\"c\", \"b\"])).toEqual(false)\n    expect(eq([\"a\", \"b\"], [\"a\", \"c\"])).toEqual(false)\n  })\n\n  it(\"productMany\", () => {\n    const eq = _.Product.productMany(_.string, [_.string])\n    expect(eq([\"a\", \"b\"], [\"a\", \"b\"])).toEqual(true)\n    expect(eq([\"a\", \"b\"], [\"a\", \"b\", \"c\"])).toEqual(true)\n    expect(eq([\"a\", \"b\", \"c\"], [\"a\", \"b\"])).toEqual(true)\n    expect(eq([\"a\", \"b\"], [\"c\", \"b\"])).toEqual(false)\n    expect(eq([\"a\", \"b\"], [\"a\", \"c\"])).toEqual(false)\n  })\n\n  it(\"productAll\", () => {\n    const eq = _.Product.productAll([_.string, _.string])\n    expect(eq([\"a\"], [\"a\"])).toEqual(true)\n    expect(eq([\"a\"], [\"b\"])).toEqual(false)\n    expect(eq([\"a\", \"b\"], [\"a\", \"b\"])).toEqual(true)\n    expect(eq([\"a\", \"b\"], [\"a\", \"c\"])).toEqual(false)\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Filterable.ts",
    "content": "import * as E from \"@fp-ts/core/Either\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/typeclass/Filterable\"\nimport * as U from \"../util\"\n\ndescribe(\"Filterable\", () => {\n  it(\"filterMapComposition\", () => {\n    const filterMap = _.filterMapComposition(RA.Covariant, O.Filterable)\n    const f = (s: string) => s.length > 1 ? O.some(s.length) : O.none()\n    U.deepStrictEqual(filterMap([], f), [])\n    U.deepStrictEqual(filterMap([O.none()], f), [O.none()])\n    U.deepStrictEqual(filterMap([O.some(\"a\")], f), [O.none()])\n    U.deepStrictEqual(filterMap([O.some(\"aa\")], f), [O.some(2)])\n  })\n\n  it(\"partitionMapComposition\", () => {\n    const partitionMap = _.partitionMapComposition(RA.Covariant, O.Filterable)\n    const f = (s: string) => s.length > 1 ? E.right(s.length) : E.left(s + \"!\")\n    U.deepStrictEqual(partitionMap([], f), [[], []])\n    U.deepStrictEqual(partitionMap([O.none()], f), [[O.none()], [O.none()]])\n    U.deepStrictEqual(partitionMap([O.some(\"a\")], f), [[O.some(\"a!\")], [O.none()]])\n    U.deepStrictEqual(partitionMap([O.some(\"aa\")], f), [[O.none()], [O.some(2)]])\n  })\n\n  it(\"filter\", () => {\n    const filter = _.filter(RA.Filterable)\n    const f = filter((n: number) => n > 0)\n    U.deepStrictEqual(pipe([], f), [])\n    U.deepStrictEqual(pipe([1], f), [1])\n    U.deepStrictEqual(pipe([-1], f), [])\n    U.deepStrictEqual(pipe([1, -1], f), [1])\n  })\n\n  it(\"partition\", () => {\n    const partition = _.partition(RA.Filterable)\n    const f = partition((n: number) => n > 0)\n    U.deepStrictEqual(pipe([], f), [[], []])\n    U.deepStrictEqual(pipe([1], f), [[], [1]])\n    U.deepStrictEqual(pipe([-1], f), [[-1], []])\n    U.deepStrictEqual(pipe([1, -1], f), [[-1], [1]])\n  })\n\n  it(\"compact\", () => {\n    const compact = _.compact(RA.Filterable)\n    assert.deepStrictEqual(compact([]), [])\n    assert.deepStrictEqual(compact([O.some(1), O.some(2), O.some(3)]), [\n      1,\n      2,\n      3\n    ])\n    assert.deepStrictEqual(compact([O.some(1), O.none(), O.some(3)]), [\n      1,\n      3\n    ])\n  })\n\n  it(\"separate\", () => {\n    const separate = _.separate(RA.Filterable)\n    U.deepStrictEqual(pipe([], separate), [[], []])\n    U.deepStrictEqual(pipe([E.right(1), E.left(\"e\"), E.right(2)], separate), [\n      [\"e\"],\n      [1, 2]\n    ])\n  })\n})\n"
  },
  {
    "path": "test/typeclass/FlatMap.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/typeclass/FlatMap\"\nimport * as U from \"../util\"\n\ndescribe(\"FlatMap\", () => {\n  it(\"flatten\", () => {\n    const flatten = _.flatten(O.FlatMap)\n    U.deepStrictEqual(pipe(O.none(), flatten), O.none())\n    U.deepStrictEqual(pipe(O.some(O.none()), flatten), O.none())\n    U.deepStrictEqual(pipe(O.some(O.some(1)), flatten), O.some(1))\n  })\n\n  it(\"andThen\", () => {\n    const andThen = _.andThen(O.FlatMap)\n    U.deepStrictEqual(pipe(O.none(), andThen(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.none(), andThen(O.some(2))), O.none())\n    U.deepStrictEqual(pipe(O.some(1), andThen(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.some(1), andThen(O.some(2))), O.some(2))\n  })\n\n  it(\"composeKleisliArrow\", () => {\n    const composeKleisliArrow = _.composeKleisliArrow(O.FlatMap)\n    const f = (s: string): O.Option<number> => s.length > 0 ? O.some(s.length) : O.none()\n    const g = (n: number): O.Option<number> => n > 1 ? O.some(n) : O.none()\n    const h = pipe(f, composeKleisliArrow(g))\n    U.deepStrictEqual(h(\"\"), O.none())\n    U.deepStrictEqual(h(\"a\"), O.none())\n    U.deepStrictEqual(h(\"aa\"), O.some(2))\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Foldable.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as N from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/typeclass/Foldable\"\nimport * as U from \"../util\"\n\ndescribe(\"Foldable\", () => {\n  it(\"reduceComposition\", () => {\n    const reduce = _.reduceComposition(RA.Foldable, RA.Foldable)\n    const f = (b: string, a: string) => b + a\n    U.deepStrictEqual(reduce([], \"-\", f), \"-\")\n    U.deepStrictEqual(reduce([[]], \"-\", f), \"-\")\n    U.deepStrictEqual(reduce([[\"a\", \"c\"], [\"b\", \"d\"]], \"-\", f), \"-acbd\")\n  })\n\n  it(\"toArray\", () => {\n    const toArray = _.toArray(O.Foldable)\n    U.deepStrictEqual(toArray(O.none()), [])\n    U.deepStrictEqual(toArray(O.some(2)), [2])\n  })\n\n  it(\"toArrayMap\", () => {\n    const toArrayMap = _.toArrayMap(O.Foldable)\n    U.deepStrictEqual(toArrayMap(O.none(), U.double), [])\n    U.deepStrictEqual(toArrayMap(O.some(2), U.double), [4])\n  })\n\n  it(\"combineMap\", () => {\n    const combineMap = _.combineMap(RA.Foldable)\n    U.deepStrictEqual(combineMap(N.MonoidSum)([1, 2, 3], U.double), 12)\n  })\n\n  it(\"reduceKind\", () => {\n    const reduceKind = _.reduceKind(RA.Foldable)(O.Monad)\n    U.deepStrictEqual(reduceKind([], \"-\", () => O.none()), O.some(\"-\"))\n    U.deepStrictEqual(reduceKind([\"a\"], \"-\", () => O.none()), O.none())\n    U.deepStrictEqual(\n      reduceKind([\"a\", \"b\", \"c\"], \"-\", (b, a) => O.some(b + a)),\n      O.some(\"-abc\")\n    )\n    U.deepStrictEqual(\n      reduceKind([\"a\", \"b\", \"c\"], \"-\", (b, a) => a === \"b\" ? O.none() : O.some(b + a)),\n      O.none()\n    )\n  })\n\n  it(\"coproductMapKind\", () => {\n    const coproductMapKind = _.coproductMapKind(RA.Foldable)(O.Alternative)\n    U.deepStrictEqual(pipe([], coproductMapKind(() => O.none())), O.none())\n    U.deepStrictEqual(pipe([\"a\"], coproductMapKind(() => O.none())), O.none())\n    U.deepStrictEqual(pipe([\"a\", \"b\", \"c\"], coproductMapKind((a) => O.some(a))), O.some(\"a\"))\n    U.deepStrictEqual(\n      pipe([\"a\", \"b\", \"c\"], coproductMapKind((a) => a === \"b\" ? O.none() : O.some(a))),\n      O.some(\"a\")\n    )\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Invariant.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as P from \"@fp-ts/core/Predicate\"\nimport * as String from \"@fp-ts/core/String\"\nimport * as _ from \"@fp-ts/core/typeclass/Invariant\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as U from \"../util\"\n\ndescribe(\"Invariant\", () => {\n  it(\"imapComposition\", () => {\n    const imap = _.imapComposition(semigroup.Invariant, O.Invariant)\n    const S = imap(O.getOptionalMonoid(String.Semigroup), s => [s], ([s]) => s)\n    U.deepStrictEqual(S.combine(O.none(), O.none()), O.none())\n    U.deepStrictEqual(S.combine(O.none(), O.some([\"b\"])), O.some([\"b\"]))\n    U.deepStrictEqual(S.combine(O.some([\"a\"]), O.none()), O.some([\"a\"]))\n    U.deepStrictEqual(\n      S.combine(O.some([\"a\"]), O.some([\"b\"])),\n      O.some([\"ab\"])\n    )\n  })\n\n  describe(\"bindTo\", () => {\n    it(\"Covariant (Option)\", () => {\n      const bindTo = _.bindTo(O.Invariant)\n      U.deepStrictEqual(pipe(O.none(), bindTo(\"a\")), O.none())\n      U.deepStrictEqual(pipe(O.some(1), bindTo(\"a\")), O.some({ a: 1 }))\n    })\n\n    it(\"Contravariant (Predicate)\", () => {\n      const bindTo = _.bindTo(P.Invariant)\n      const p = pipe(String.isString, bindTo(\"a\"))\n      U.deepStrictEqual(p({ a: \"a\" }), true)\n      U.deepStrictEqual(p({ a: 1 }), false)\n    })\n  })\n\n  describe(\"tupled\", () => {\n    it(\"Covariant (Option)\", () => {\n      const tupled = _.tupled(O.Invariant)\n      U.deepStrictEqual(pipe(O.none(), tupled), O.none())\n      U.deepStrictEqual(pipe(O.some(1), tupled), O.some([1]))\n    })\n\n    it(\"Contravariant (Predicate)\", () => {\n      const tupled = _.tupled(P.Invariant)\n      const p = pipe(String.isString, tupled)\n      U.deepStrictEqual(p([\"a\"]), true)\n      U.deepStrictEqual(p([1]), false)\n    })\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Monoid.ts",
    "content": "import * as N from \"@fp-ts/core/Number\"\nimport * as String from \"@fp-ts/core/String\"\nimport * as _ from \"@fp-ts/core/typeclass/Monoid\"\nimport * as U from \"../util\"\n\ndescribe(\"Monoid\", () => {\n  it(\"min\", () => {\n    const M = _.min(N.Bounded)\n    U.deepStrictEqual(M.combineAll([]), +Infinity)\n    U.deepStrictEqual(M.combineAll([1]), 1)\n    U.deepStrictEqual(M.combineAll([1, -1]), -1)\n  })\n\n  it(\"max\", () => {\n    const M = _.max(N.Bounded)\n    U.deepStrictEqual(M.combineAll([]), -Infinity)\n    U.deepStrictEqual(M.combineAll([1]), 1)\n    U.deepStrictEqual(M.combineAll([1, -1]), 1)\n  })\n\n  it(\"reverse\", () => {\n    const M = _.reverse(String.Monoid)\n    U.deepStrictEqual(M.combine(\"a\", \"b\"), \"ba\")\n    U.deepStrictEqual(M.combine(\"a\", M.empty), \"a\")\n    U.deepStrictEqual(M.combine(M.empty, \"a\"), \"a\")\n    U.deepStrictEqual(M.combineMany(\"a\", []), \"a\")\n    U.deepStrictEqual(M.combineMany(\"a\", [\"b\", \"c\", \"d\"]), \"dcba\")\n    U.deepStrictEqual(M.combineMany(\"a\", [M.empty]), \"a\")\n    U.deepStrictEqual(M.combineMany(M.empty, [\"a\"]), \"a\")\n  })\n\n  describe(\"struct\", () => {\n    it(\"baseline\", () => {\n      const M = _.struct({\n        name: String.Monoid,\n        age: N.MonoidSum\n      })\n      U.deepStrictEqual(M.empty, { name: \"\", age: 0 })\n      U.deepStrictEqual(M.combine({ name: \"a\", age: 10 }, { name: \"b\", age: 20 }), {\n        name: \"ab\",\n        age: 30\n      })\n    })\n\n    it(\"should ignore non own properties\", () => {\n      const monoids = Object.create({ a: 1 })\n      const M = _.struct(monoids)\n      U.deepStrictEqual(M.empty, {})\n    })\n  })\n\n  it(\"tuple\", () => {\n    const M = _.tuple(\n      String.Monoid,\n      N.MonoidSum\n    )\n    U.deepStrictEqual(M.empty, [\"\", 0])\n    U.deepStrictEqual(M.combine([\"a\", 10], [\"b\", 20]), [\"ab\", 30])\n  })\n})\n"
  },
  {
    "path": "test/typeclass/NonEmptyTraversable.ts",
    "content": "import { identity, pipe } from \"@fp-ts/core/Function\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/test/limbo/NonEmptyTraversable\"\nimport * as covariant from \"@fp-ts/core/typeclass/Covariant\"\nimport * as U from \"../util\"\n\nconst NonEmptyTraversable: _.NonEmptyTraversable<NonEmptyReadonlyArrayTypeLambda> = {\n  // @ts-expect-error\n  traverseNonEmpty: RA.traverseNonEmpty,\n  // @ts-expect-error\n  sequenceNonEmpty: F => self => pipe(self, RA.traverseNonEmpty(F)(identity))\n}\n\n/**\n * @category type lambdas\n * @since 1.0.0\n */\nexport interface NonEmptyReadonlyArrayTypeLambda extends TypeLambda {\n  readonly type: RA.NonEmptyReadonlyArray<this[\"Target\"]>\n}\n\nconst imap = covariant.imap<NonEmptyReadonlyArrayTypeLambda>(RA.mapNonEmpty)\n\n/**\n * @category instances\n * @since 1.0.0\n */\nexport const NonEmptyCovariant: covariant.Covariant<NonEmptyReadonlyArrayTypeLambda> = {\n  imap,\n  map: RA.mapNonEmpty\n}\n\ndescribe(\"NonEmptyTraversable\", () => {\n  it(\"traverseNonEmptyComposition\", () => {\n    const traverseNonEmpty = _.traverseNonEmptyComposition(\n      NonEmptyTraversable,\n      NonEmptyTraversable\n    )(O.SemiApplicative)((n: number) => (n > 0 ? O.some(n) : O.none()))\n    U.deepStrictEqual(traverseNonEmpty([[1]]), O.some([[1]] as const))\n    U.deepStrictEqual(traverseNonEmpty([[1, -1]]), O.none())\n    U.deepStrictEqual(traverseNonEmpty([[1, 2, 3], [4, 5]]), O.some([[1, 2, 3], [4, 5]] as const))\n    U.deepStrictEqual(traverseNonEmpty([[1, 2, 3], [4, -1]]), O.none())\n  })\n\n  it(\"traverseNonEmptyComposition\", () => {\n    const sequence = _.sequenceNonEmptyComposition(\n      { ...NonEmptyTraversable, ...NonEmptyCovariant },\n      NonEmptyTraversable\n    )(O.SemiApplicative)\n    U.deepStrictEqual(sequence([[O.some(1)]]), O.some([[1]] as const))\n    U.deepStrictEqual(sequence([[O.some(1), O.none()]]), O.none())\n    U.deepStrictEqual(\n      sequence([[O.some(1), O.some(2), O.some(3)], [O.some(4), O.some(5)]]),\n      O.some([[1, 2, 3], [4, 5]] as const)\n    )\n    U.deepStrictEqual(\n      sequence([[O.some(1), O.some(2), O.some(3)], [O.some(4), O.none()]]),\n      O.none()\n    )\n  })\n\n  it(\"sequenceNonEmpty\", () => {\n    const sequenceNonEmpty = _.sequenceNonEmpty<NonEmptyReadonlyArrayTypeLambda>(\n      NonEmptyTraversable.traverseNonEmpty\n    )(O.SemiApplicative)\n    U.deepStrictEqual(sequenceNonEmpty([O.none()]), O.none())\n    U.deepStrictEqual(sequenceNonEmpty([O.some(1)]), O.some([1] as const))\n    U.deepStrictEqual(sequenceNonEmpty([O.none()]), O.none())\n    U.deepStrictEqual(sequenceNonEmpty([O.some(1), O.none()]), O.none())\n    U.deepStrictEqual(sequenceNonEmpty([O.some(1), O.some(2)]), O.some([1, 2] as const))\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Of.ts",
    "content": "import * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/typeclass/Of\"\nimport * as U from \"../util\"\n\ndescribe(\"Of\", () => {\n  it(\"ofComposition\", () => {\n    const of = _.ofComposition(RA.Of, O.Of)\n    U.deepStrictEqual(of(1), [O.some(1)])\n  })\n\n  it(\"unit\", () => {\n    U.deepStrictEqual(_.unit(O.Pointed), O.some(undefined))\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Order.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport { sort } from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/typeclass/Order\"\nimport * as U from \"../util\"\n\ndescribe(\"Order\", () => {\n  it(\"exports\", () => {\n    expect(_.Invariant).exist\n    expect(_.Contravariant).exist\n    expect(_.string).exist\n    expect(_.number).exist\n    expect(_.boolean).exist\n    expect(_.bigint).exist\n  })\n\n  it(\"productAll\", () => {\n    const O = _.Product.productAll([_.string, _.string])\n    U.deepStrictEqual(O.compare([\"a\"], [\"b\"]), -1)\n    U.deepStrictEqual(O.compare([\"a\"], [\"a\"]), 0)\n    U.deepStrictEqual(O.compare([\"b\"], [\"a\"]), 1)\n    U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"c\"]), -1)\n    U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"b\"]), 0)\n    U.deepStrictEqual(O.compare([\"a\", \"c\"], [\"a\", \"b\"]), 1)\n  })\n\n  it(\"contramap\", () => {\n    const O = _.contramap(_.number, (s: string) => s.length)\n    U.deepStrictEqual(O.compare(\"a\", \"b\"), 0)\n    U.deepStrictEqual(O.compare(\"a\", \"bb\"), -1)\n    U.deepStrictEqual(O.compare(\"aa\", \"b\"), 1)\n  })\n\n  it(\"getSemigroup\", () => {\n    type T = [number, string]\n    const tuples: Array<T> = [\n      [2, \"c\"],\n      [1, \"b\"],\n      [2, \"a\"],\n      [1, \"c\"]\n    ]\n    const S = _.getSemigroup<T>()\n    const sortByFst = pipe(\n      _.number,\n      _.contramap((x: T) => x[0])\n    )\n    const sortBySnd = pipe(\n      _.string,\n      _.contramap((x: T) => x[1])\n    )\n    U.deepStrictEqual(sort(S.combine(sortByFst, sortBySnd))(tuples), [\n      [1, \"b\"],\n      [1, \"c\"],\n      [2, \"a\"],\n      [2, \"c\"]\n    ])\n    U.deepStrictEqual(sort(S.combine(sortBySnd, sortByFst))(tuples), [\n      [2, \"a\"],\n      [1, \"b\"],\n      [1, \"c\"],\n      [2, \"c\"]\n    ])\n    U.deepStrictEqual(sort(S.combineMany(sortBySnd, []))(tuples), [\n      [2, \"a\"],\n      [1, \"b\"],\n      [2, \"c\"],\n      [1, \"c\"]\n    ])\n    U.deepStrictEqual(sort(S.combineMany(sortBySnd, [sortByFst]))(tuples), [\n      [2, \"a\"],\n      [1, \"b\"],\n      [1, \"c\"],\n      [2, \"c\"]\n    ])\n  })\n\n  it(\"getMonoid\", () => {\n    type T = [number, string]\n    const tuples: Array<T> = [\n      [2, \"c\"],\n      [1, \"b\"],\n      [2, \"a\"],\n      [1, \"c\"]\n    ]\n    const M = _.getMonoid<T>()\n    const sortByFst = pipe(\n      _.number,\n      _.contramap((x: T) => x[0])\n    )\n    const sortBySnd = pipe(\n      _.string,\n      _.contramap((x: T) => x[1])\n    )\n    U.deepStrictEqual(sort(M.combineMany(M.empty, [sortByFst, sortBySnd]))(tuples), [\n      [1, \"b\"],\n      [1, \"c\"],\n      [2, \"a\"],\n      [2, \"c\"]\n    ])\n    U.deepStrictEqual(sort(M.combineMany(sortBySnd, [sortByFst, M.empty]))(tuples), [\n      [2, \"a\"],\n      [1, \"b\"],\n      [1, \"c\"],\n      [2, \"c\"]\n    ])\n  })\n\n  it(\"clamp\", () => {\n    const clamp = _.clamp(_.number)\n    U.deepStrictEqual(clamp(2, 1, 10), 2)\n    U.deepStrictEqual(clamp(10, 1, 10), 10)\n    U.deepStrictEqual(clamp(20, 1, 10), 10)\n    U.deepStrictEqual(clamp(1, 1, 10), 1)\n    U.deepStrictEqual(clamp(-10, 1, 10), 1)\n  })\n\n  it(\"between\", () => {\n    const between = _.between(_.number)\n    U.deepStrictEqual(between(2, 1, 10), true)\n    U.deepStrictEqual(between(10, 1, 10), true)\n    U.deepStrictEqual(between(20, 1, 10), false)\n    U.deepStrictEqual(between(1, 1, 10), true)\n    U.deepStrictEqual(between(-10, 1, 10), false)\n  })\n\n  it(\"reverse\", () => {\n    const O = _.reverse(_.number)\n    U.deepStrictEqual(O.compare(1, 2), 1)\n    U.deepStrictEqual(O.compare(2, 1), -1)\n    U.deepStrictEqual(O.compare(2, 2), 0)\n  })\n\n  it(\"lessThan\", () => {\n    const lessThan = _.lessThan(_.number)\n    U.deepStrictEqual(lessThan(0, 1), true)\n    U.deepStrictEqual(lessThan(1, 1), false)\n    U.deepStrictEqual(lessThan(2, 1), false)\n  })\n\n  it(\"lessThanOrEqualTo\", () => {\n    const lessThanOrEqualTo = _.lessThanOrEqualTo(_.number)\n    U.deepStrictEqual(lessThanOrEqualTo(0, 1), true)\n    U.deepStrictEqual(lessThanOrEqualTo(1, 1), true)\n    U.deepStrictEqual(lessThanOrEqualTo(2, 1), false)\n  })\n\n  it(\"greaterThan\", () => {\n    const greaterThan = _.greaterThan(_.number)\n    U.deepStrictEqual(greaterThan(0, 1), false)\n    U.deepStrictEqual(greaterThan(1, 1), false)\n    U.deepStrictEqual(greaterThan(2, 1), true)\n  })\n\n  it(\"greaterThanOrEqualTo\", () => {\n    const greaterThanOrEqualTo = _.greaterThanOrEqualTo(_.number)\n    U.deepStrictEqual(greaterThanOrEqualTo(0, 1), false)\n    U.deepStrictEqual(greaterThanOrEqualTo(1, 1), true)\n    U.deepStrictEqual(greaterThanOrEqualTo(2, 1), true)\n  })\n\n  it(\"min\", () => {\n    type A = { a: number }\n    const min = _.min(\n      pipe(\n        _.number,\n        _.contramap((a: A) => a.a)\n      )\n    )\n    U.deepStrictEqual(min({ a: 1 }, { a: 2 }), { a: 1 })\n    U.deepStrictEqual(min({ a: 2 }, { a: 1 }), { a: 1 })\n    const first = { a: 1 }\n    const second = { a: 1 }\n    U.strictEqual(min(first, second), first)\n  })\n\n  it(\"max\", () => {\n    type A = { a: number }\n    const max = _.max(\n      pipe(\n        _.number,\n        _.contramap((a: A) => a.a)\n      )\n    )\n    U.deepStrictEqual(max({ a: 1 }, { a: 2 }), { a: 2 })\n    U.deepStrictEqual(max({ a: 2 }, { a: 1 }), { a: 2 })\n    const first = { a: 1 }\n    const second = { a: 1 }\n    U.strictEqual(max(first, second), first)\n  })\n\n  describe(\"SemiProduct\", () => {\n    it(\"product\", () => {\n      const O = _.SemiProduct.product(_.string, _.number)\n      U.deepStrictEqual(O.compare([\"a\", 1], [\"a\", 2]), -1)\n      U.deepStrictEqual(O.compare([\"a\", 1], [\"a\", 1]), 0)\n      U.deepStrictEqual(O.compare([\"a\", 1], [\"a\", 0]), 1)\n      U.deepStrictEqual(O.compare([\"a\", 1], [\"b\", 1]), -1)\n    })\n\n    it(\"productMany\", () => {\n      const O = _.SemiProduct.productMany(_.string, [_.string, _.string])\n      U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"c\"]), -1)\n      U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"b\"]), 0)\n      U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"a\"]), 1)\n      U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"b\", \"a\"]), -1)\n    })\n  })\n\n  describe(\"Product\", () => {\n    it(\"of\", () => {\n      const O = _.Product.of(\"a\")\n      U.deepStrictEqual(O.compare(\"b\", \"a\"), 0)\n      U.deepStrictEqual(O.compare(\"a\", \"a\"), 0)\n      U.deepStrictEqual(O.compare(\"a\", \"b\"), 0)\n    })\n\n    it(\"productAll\", () => {\n      const O = pipe(\n        _.Product.productAll([_.string, _.string, _.string])\n      )\n      U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"c\"]), -1)\n      U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"b\"]), 0)\n      U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"a\", \"a\"]), 1)\n      U.deepStrictEqual(O.compare([\"a\", \"b\"], [\"b\", \"a\"]), -1)\n    })\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Product.ts",
    "content": "import * as Boolean from \"@fp-ts/core/Boolean\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as P from \"@fp-ts/core/Predicate\"\nimport * as String from \"@fp-ts/core/String\"\nimport * as _ from \"@fp-ts/core/typeclass/Product\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as U from \"../util\"\n\ndescribe(\"Product\", () => {\n  describe(\"tuple\", () => {\n    it(\"Covariant (Option)\", () => {\n      const tuple = _.tuple(O.Product)\n      U.deepStrictEqual(tuple(), O.some([]))\n      U.deepStrictEqual(tuple(O.some(\"a\")), O.some([\"a\"]))\n      U.deepStrictEqual(\n        tuple(O.some(\"a\"), O.some(1), O.some(true)),\n        O.some([\"a\", 1, true])\n      )\n      U.deepStrictEqual(tuple(O.some(\"a\"), O.some(1), O.none()), O.none())\n    })\n\n    it(\"Invariant (Semigroup)\", () => {\n      const tuple = _.tuple(semigroup.Product)\n      U.deepStrictEqual(tuple().combine([], []), [])\n      const S = tuple(String.Semigroup, Number.SemigroupSum)\n      U.deepStrictEqual(S.combine([\"a\", 2], [\"b\", 3]), [\"ab\", 5])\n    })\n\n    it(\"Contravariant (Predicate)\", () => {\n      const tuple = _.tuple(P.Product)\n      U.deepStrictEqual(tuple()([]), true)\n      const p = tuple(String.isString, Number.isNumber, Boolean.isBoolean)\n      U.deepStrictEqual(p([\"a\", 1, true]), true)\n      U.deepStrictEqual(p([\"a\", 1, \"b\"]), false)\n    })\n  })\n\n  describe(\"struct\", () => {\n    it(\"Covariant (Option)\", () => {\n      const struct = _.struct(O.Product)\n      U.deepStrictEqual(struct({}), O.some({}))\n      U.deepStrictEqual(struct({ a: O.some(\"a\") }), O.some({ a: \"a\" }))\n      U.deepStrictEqual(\n        struct({ a: O.some(\"a\"), b: O.some(1), c: O.some(true) }),\n        O.some({ a: \"a\", b: 1, c: true })\n      )\n      U.deepStrictEqual(\n        struct({ a: O.some(\"a\"), b: O.some(1), c: O.none() }),\n        O.none()\n      )\n    })\n\n    it(\"Invariant (Semigroup)\", () => {\n      const struct = _.struct(semigroup.Product)\n      U.deepStrictEqual(struct({}).combine({}, {}), {})\n      const S = struct({ x: String.Semigroup, y: Number.SemigroupSum })\n      U.deepStrictEqual(S.combine({ x: \"a\", y: 2 }, { x: \"b\", y: 3 }), { x: \"ab\", y: 5 })\n    })\n\n    it(\"Contravariant (Predicate)\", () => {\n      const struct = _.struct(P.Product)\n      U.deepStrictEqual(struct({})({}), true)\n      const p = struct({ x: String.isString, y: Number.isNumber, z: Boolean.isBoolean })\n      U.deepStrictEqual(p({ x: \"a\", y: 1, z: true }), true)\n      U.deepStrictEqual(p({ x: \"a\", y: 1, z: \"b\" }), false)\n    })\n  })\n})\n"
  },
  {
    "path": "test/typeclass/SemiApplicative.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as String from \"@fp-ts/core/String\"\nimport * as _ from \"@fp-ts/core/typeclass/SemiApplicative\"\nimport * as U from \"../util\"\n\ndescribe(\"SemiApplicative\", () => {\n  it(\"ap\", () => {\n    const ap = _.ap(O.SemiApplicative)\n    const double = (n: number) => n * 2\n    U.deepStrictEqual(pipe(O.none(), ap(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.none(), ap(O.some(1))), O.none())\n    U.deepStrictEqual(pipe(O.some(double), ap(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.some(double), ap(O.some(1))), O.some(2))\n  })\n\n  it(\"andThenDiscard\", () => {\n    const andThenDiscard = _.andThenDiscard(O.SemiApplicative)\n    U.deepStrictEqual(pipe(O.none(), andThenDiscard(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.none(), andThenDiscard(O.some(2))), O.none())\n    U.deepStrictEqual(pipe(O.some(1), andThenDiscard(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.some(1), andThenDiscard(O.some(2))), O.some(1))\n  })\n\n  it(\"andThen\", () => {\n    const andThen = _.andThen(O.SemiApplicative)\n    U.deepStrictEqual(pipe(O.none(), andThen(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.none(), andThen(O.some(2))), O.none())\n    U.deepStrictEqual(pipe(O.some(1), andThen(O.none())), O.none())\n    U.deepStrictEqual(pipe(O.some(1), andThen(O.some(2))), O.some(2))\n  })\n\n  it(\"liftSemigroup\", () => {\n    const liftSemigroup = _.getSemigroup(O.SemiApplicative)\n    const S = liftSemigroup(String.Semigroup)\n    U.deepStrictEqual(S.combine(O.none(), O.none()), O.none())\n    U.deepStrictEqual(S.combine(O.none(), O.some(\"b\")), O.none())\n    U.deepStrictEqual(S.combine(O.some(\"a\"), O.none()), O.none())\n    U.deepStrictEqual(S.combine(O.some(\"a\"), O.some(\"b\")), O.some(\"ab\"))\n\n    U.deepStrictEqual(S.combineMany(O.some(\"a\"), [O.some(\"b\"), O.some(\"c\")]), O.some(\"abc\"))\n  })\n})\n"
  },
  {
    "path": "test/typeclass/SemiCoproduct.ts",
    "content": "import * as E from \"@fp-ts/core/Either\"\nimport * as _ from \"@fp-ts/core/typeclass/SemiCoproduct\"\nimport * as U from \"../util\"\n\ndescribe(\"SemiCoproduct\", () => {\n  it(\"getSemigroup\", () => {\n    const S = _.getSemigroup(E.SemiCoproduct)<unknown, never, string, number>()\n    U.deepStrictEqual(S.combine(E.right(1), E.right(2)), E.right(1))\n    U.deepStrictEqual(S.combine(E.left(\"a\"), E.right(2)), E.right(2))\n    U.deepStrictEqual(S.combine(E.right(1), E.left(\"b\")), E.right(1))\n    U.deepStrictEqual(S.combine(E.left(\"a\"), E.left(\"b\")), E.left(\"b\"))\n    U.deepStrictEqual(S.combineMany(E.left(\"a\"), [E.left(\"b\")]), E.left(\"b\"))\n  })\n})\n"
  },
  {
    "path": "test/typeclass/SemiProduct.ts",
    "content": "import * as Boolean from \"@fp-ts/core/Boolean\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as P from \"@fp-ts/core/Predicate\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as String from \"@fp-ts/core/String\"\nimport * as semiApplicative from \"@fp-ts/core/typeclass/SemiApplicative\"\nimport * as semigroup from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as _ from \"@fp-ts/core/typeclass/SemiProduct\"\nimport * as U from \"../util\"\n\ndescribe(\"SemiProduct\", () => {\n  it(\"productMany should be equivalent to `ap`\", () => {\n    const curry = (f: Function, n: number, acc: ReadonlyArray<unknown>) =>\n      (x: unknown) => {\n        const combined = Array(acc.length + 1)\n        for (let i = 0; i < acc.length; i++) {\n          combined[i] = acc[i]\n        }\n        combined[acc.length] = x\n        return n === 0 ? f.apply(null, combined) : curry(f, n - 1, combined)\n      }\n\n    const getCurriedTupleConstructor = (len: number): (a: any) => any =>\n      curry(<T extends ReadonlyArray<any>>(...t: T): T => t, len - 1, [])\n\n    const assertSameResult = <F extends TypeLambda>(\n      SemiApplicative: semiApplicative.SemiApplicative<F>\n    ) =>\n      <R, O, E, A>(collection: Iterable<Kind<F, R, O, E, A>>) =>\n        (self: Kind<F, R, O, E, A>) => {\n          const ap = semiApplicative.ap(SemiApplicative)\n          const productManyFromAp = <R, O, E, A>(collection: Iterable<Kind<F, R, O, E, A>>) =>\n            (\n              self: Kind<F, R, O, E, A>\n            ): Kind<F, R, O, E, [A, ...Array<A>]> => {\n              const args = [self, ...Array.from(collection)]\n              const len = args.length\n              const f = getCurriedTupleConstructor(len)\n              let fas = pipe(args[0], SemiApplicative.map(f))\n              for (let i = 1; i < len; i++) {\n                fas = pipe(fas, ap(args[i]))\n              }\n              return fas\n            }\n          const actual = SemiApplicative.productMany(self, collection)\n          const expected = pipe(self, productManyFromAp(collection))\n          U.deepStrictEqual(actual, expected)\n        }\n\n    assertSameResult(RA.SemiApplicative)([])([])\n    assertSameResult(RA.SemiApplicative)([])([1, 2, 3])\n    assertSameResult(RA.SemiApplicative)([[4]])([1, 2, 3])\n    assertSameResult(RA.SemiApplicative)([[4, 5, 6], [7, 8], [9, 10, 11]])([1, 2, 3])\n  })\n\n  describe(\"productComposition\", () => {\n    it(\"ReadonlyArray\", () => {\n      const product = _.productComposition(RA.SemiApplicative, O.SemiProduct)\n      U.deepStrictEqual(product([], [O.none()]), [])\n      U.deepStrictEqual(product([O.none()], []), [])\n      U.deepStrictEqual(product([O.none()], [O.none()]), [O.none()])\n      expect(product([O.some(1)], [O.some(2)])).toEqual([O.some([1, 2])])\n    })\n\n    it(\"Option\", () => {\n      const product = _.productComposition(O.SemiApplicative, O.SemiProduct)\n      U.deepStrictEqual(product(O.none(), O.none()), O.none())\n      U.deepStrictEqual(product(O.some(O.none()), O.none()), O.none())\n      U.deepStrictEqual(product(O.some(O.some(1)), O.none()), O.none())\n      U.deepStrictEqual(product(O.some(O.some(1)), O.some(O.none())), O.some(O.none()))\n      U.deepStrictEqual(product(O.some(O.none()), O.some(O.some(2))), O.some(O.none()))\n      U.deepStrictEqual(\n        product(O.some(O.some(1)), O.some(O.some(2))),\n        O.some(O.some([1, 2]))\n      )\n    })\n  })\n\n  describe(\"productManyComposition\", () => {\n    it(\"ReadonlyArray\", () => {\n      const productMany = _.productManyComposition(RA.SemiApplicative, O.SemiProduct)\n      expect(productMany([O.some(1), O.none()], [])).toEqual([\n        O.some([1]),\n        O.none()\n      ])\n      expect(productMany([O.some(1), O.none()], [[O.some(2), O.none()]])).toEqual([\n        O.some([1, 2]),\n        O.none(),\n        O.none(),\n        O.none()\n      ])\n      expect(\n        productMany([O.some(1), O.some(2)], [[O.some(3), O.some(4)], [O.some(5)]])\n      ).toEqual(\n        [\n          O.some([1, 3, 5]),\n          O.some([1, 4, 5]),\n          O.some([2, 3, 5]),\n          O.some([2, 4, 5])\n        ]\n      )\n    })\n\n    it(\"Option\", () => {\n      const productMany = _.productManyComposition(O.SemiApplicative, O.SemiProduct)\n      U.deepStrictEqual(productMany(O.none(), []), O.none())\n      U.deepStrictEqual(productMany(O.some(O.none()), []), O.some(O.none()))\n      U.deepStrictEqual(productMany(O.some(O.some(1)), []), O.some(O.some([1])))\n      U.deepStrictEqual(productMany(O.none(), [O.none()]), O.none())\n      U.deepStrictEqual(productMany(O.some(O.none()), [O.none()]), O.none())\n      U.deepStrictEqual(productMany(O.some(O.none()), [O.some(O.none())]), O.some(O.none()))\n      U.deepStrictEqual(\n        productMany(O.some(O.none()), [O.some(O.some(\"a\"))]),\n        O.some(O.none())\n      )\n      U.deepStrictEqual(\n        productMany(O.some(O.some(1)), [O.some(O.some(2))]),\n        O.some(O.some([1, 2]))\n      )\n    })\n  })\n\n  describe(\"andThenBind\", () => {\n    it(\"Covariant (Option)\", () => {\n      const andThenBind = _.andThenBind(O.Applicative)\n      U.deepStrictEqual(pipe(O.some({ a: 1 }), andThenBind(\"b\", O.none())), O.none())\n      U.deepStrictEqual(pipe(O.some({ a: 1 }), andThenBind(\"b\", O.some(2))), O.some({ a: 1, b: 2 }))\n    })\n\n    it(\"Contravariant (Predicate)\", () => {\n      const p = pipe(\n        P.Do,\n        P.andThenBind(\"x\", String.isString),\n        P.andThenBind(\"y\", Number.isNumber)\n      )\n      U.deepStrictEqual(p({ x: \"a\", y: 1 }), true)\n      U.deepStrictEqual(p({ x: \"a\", y: \"x\" }), false)\n    })\n  })\n\n  describe(\"appendElement\", () => {\n    it(\"Covariant (Option)\", () => {\n      const appendElement = _.appendElement(O.SemiProduct)\n      U.deepStrictEqual(pipe(O.some([1, 2]), appendElement(O.none())), O.none())\n      expect(pipe(O.some([1, 2]), appendElement(O.some(3)))).toEqual(O.some([1, 2, 3]))\n    })\n\n    it(\"Contravariant (Predicate)\", () => {\n      const appendElement = _.appendElement(P.SemiProduct)\n      const p = pipe(P.tuple(String.isString, String.isString), appendElement(Number.isNumber))\n      U.deepStrictEqual(p([\"a\", \"b\", 3]), true)\n      U.deepStrictEqual(p([\"a\", \"b\", \"c\"]), false)\n      U.deepStrictEqual(p([1, \"b\", 1]), false)\n    })\n  })\n\n  describe(\"nonEmptyTuple\", () => {\n    it(\"Covariant (Option)\", () => {\n      const nonEmptyTuple = _.nonEmptyTuple(O.SemiProduct)\n      expect(nonEmptyTuple(O.some(\"a\"))).toEqual(O.some([\"a\"]))\n      expect(\n        nonEmptyTuple(O.some(\"a\"), O.some(1), O.some(true))\n      ).toEqual(\n        O.some([\"a\", 1, true])\n      )\n      U.deepStrictEqual(nonEmptyTuple(O.some(\"a\"), O.some(1), O.none()), O.none())\n    })\n\n    it(\"Invariant (Semigroup)\", () => {\n      const nonEmptyTuple = _.nonEmptyTuple(semigroup.SemiProduct)\n      const S = nonEmptyTuple(String.Semigroup, Number.SemigroupSum)\n      U.deepStrictEqual(S.combine([\"a\", 2], [\"b\", 3]), [\"ab\", 5])\n    })\n\n    it(\"Contravariant (Predicate)\", () => {\n      const nonEmptyTuple = _.nonEmptyTuple(P.SemiProduct)\n      const p = nonEmptyTuple(String.isString, Number.isNumber, Boolean.isBoolean)\n      U.deepStrictEqual(p([\"a\", 1, true]), true)\n      U.deepStrictEqual(p([\"a\", 1, \"b\"]), false)\n    })\n  })\n\n  describe(\"nonEmptyStruct\", () => {\n    it(\"Covariant (Option)\", () => {\n      const nonEmptyStruct = _.nonEmptyStruct(O.Product)\n      U.deepStrictEqual(nonEmptyStruct({ a: O.some(\"a\") }), O.some({ a: \"a\" }))\n      U.deepStrictEqual(\n        nonEmptyStruct({ a: O.some(\"a\"), b: O.some(1), c: O.some(true) }),\n        O.some({ a: \"a\", b: 1, c: true })\n      )\n      U.deepStrictEqual(\n        nonEmptyStruct({ a: O.some(\"a\"), b: O.some(1), c: O.none() }),\n        O.none()\n      )\n    })\n\n    it(\"Invariant (Semigroup)\", () => {\n      const nonEmptyStruct = _.nonEmptyStruct(semigroup.Product)\n      const S = nonEmptyStruct({ x: String.Semigroup, y: Number.SemigroupSum })\n      U.deepStrictEqual(S.combine({ x: \"a\", y: 2 }, { x: \"b\", y: 3 }), { x: \"ab\", y: 5 })\n    })\n\n    it(\"Contravariant (Predicate)\", () => {\n      const nonEmptyStruct = _.nonEmptyStruct(P.Product)\n      const p = nonEmptyStruct({ x: String.isString, y: Number.isNumber, z: Boolean.isBoolean })\n      U.deepStrictEqual(p({ x: \"a\", y: 1, z: true }), true)\n      U.deepStrictEqual(p({ x: \"a\", y: 1, z: \"b\" }), false)\n    })\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Semigroup.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as String from \"@fp-ts/core/String\"\nimport * as order from \"@fp-ts/core/typeclass/Order\"\nimport * as _ from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as U from \"../util\"\n\ndescribe(\"Semigroup\", () => {\n  it(\"exports\", () => {\n    expect(_.Invariant).exist\n  })\n\n  it(\"reverse\", () => {\n    const S = _.reverse(String.Semigroup)\n    U.deepStrictEqual(S.combine(\"a\", \"b\"), \"ba\")\n    U.deepStrictEqual(S.combineMany(\"a\", []), \"a\")\n    U.deepStrictEqual(S.combineMany(\"a\", [\"b\"]), \"ba\")\n    U.deepStrictEqual(S.combineMany(\"a\", [\"b\", \"c\", \"d\"]), \"dcba\")\n  })\n\n  it(\"constant\", () => {\n    const S = _.constant(\"-\")\n    U.deepStrictEqual(S.combine(\"a\", \"b\"), \"-\")\n    U.deepStrictEqual(S.combineMany(\"a\", []), \"-\")\n    U.deepStrictEqual(S.combineMany(\"a\", [\"b\", \"c\", \"d\"]), \"-\")\n  })\n\n  it(\"intercalate\", () => {\n    const S = pipe(String.Semigroup, _.intercalate(\"|\"))\n    U.deepStrictEqual(S.combine(\"a\", \"b\"), \"a|b\")\n    U.deepStrictEqual(S.combineMany(\"a\", []), \"a\")\n    U.deepStrictEqual(S.combineMany(\"a\", [\"b\"]), \"a|b\")\n    U.deepStrictEqual(S.combineMany(\"a\", [\"b\", \"c\", \"d\"]), \"a|b|c|d\")\n  })\n\n  describe(\"min\", () => {\n    it(\"should return the minimum\", () => {\n      const S = _.min(Number.Order)\n      U.deepStrictEqual(S.combineMany(1, []), 1)\n      U.deepStrictEqual(S.combineMany(1, [3, 2]), 1)\n    })\n\n    it(\"should return the last minimum\", () => {\n      type Item = { a: number }\n      const A = _.min(pipe(Number.Order, order.contramap((_: Item) => _.a)))\n      const item: Item = { a: 1 }\n      U.strictEqual(A.combineMany({ a: 2 }, [{ a: 1 }, item]), item)\n      U.strictEqual(A.combineMany(item, []), item)\n    })\n  })\n\n  describe(\"max\", () => {\n    it(\"should return the maximum\", () => {\n      const S = _.max(Number.Order)\n      U.deepStrictEqual(S.combineMany(1, []), 1)\n      U.deepStrictEqual(S.combineMany(1, [3, 2]), 3)\n    })\n\n    it(\"should return the last minimum\", () => {\n      type Item = { a: number }\n      const S = _.max(pipe(Number.Order, order.contramap((_: Item) => _.a)))\n      const item: Item = { a: 2 }\n      U.strictEqual(S.combineMany({ a: 1 }, [{ a: 2 }, item]), item)\n      U.strictEqual(S.combineMany(item, []), item)\n    })\n  })\n\n  it(\"first\", () => {\n    const S = _.first<number>()\n    U.deepStrictEqual(S.combine(1, 2), 1)\n    U.deepStrictEqual(S.combineMany(1, []), 1)\n    U.deepStrictEqual(S.combineMany(1, [2, 3, 4, 5, 6]), 1)\n  })\n\n  it(\"last\", () => {\n    const S = _.last<number>()\n    U.deepStrictEqual(S.combine(1, 2), 2)\n    U.deepStrictEqual(S.combineMany(1, []), 1)\n    U.deepStrictEqual(S.combineMany(1, [2, 3, 4, 5, 6]), 6)\n  })\n\n  it(\"imap\", () => {\n    const imap = _.imap\n    const S1 = imap((s: string) => [s], ([s]) => s)(String.Semigroup)\n    U.deepStrictEqual(S1.combine([\"a\"], [\"b\"]), [\"ab\"])\n    U.deepStrictEqual(S1.combineMany([\"a\"], []), [\"a\"])\n    U.deepStrictEqual(S1.combineMany([\"a\"], [[\"b\"]]), [\"ab\"])\n    U.deepStrictEqual(S1.combineMany([\"a\"], [[\"b\"], [\"c\"]]), [\"abc\"])\n    // should handle an Iterable\n    U.deepStrictEqual(S1.combineMany([\"a\"], new Set([[\"b\"], [\"c\"]])), [\"abc\"])\n\n    const S2 = pipe(String.Semigroup, _.Invariant.imap((s: string) => [s], ([s]) => s))\n    U.deepStrictEqual(S2.combineMany([\"a\"], [[\"b\"], [\"c\"]]), [\"abc\"])\n  })\n\n  it(\"product\", () => {\n    const S = pipe(\n      _.SemiProduct.product(\n        _.SemiProduct.product(String.Semigroup, Number.SemigroupSum),\n        Number.SemigroupMultiply\n      ),\n      _.imap(\n        ([[a, b], c]): [string, number, number] => [a, b, c],\n        ([a, b, c]): [[string, number], number] => [[a, b], c]\n      )\n    )\n    U.deepStrictEqual(S.combine([\"a\", 2, 3], [\"b\", 3, 4]), [\"ab\", 5, 12])\n  })\n\n  it(\"productMany\", () => {\n    const S = _.SemiProduct.productMany(String.Semigroup, [String.Semigroup, String.Semigroup])\n    U.deepStrictEqual(S.combine([\"a\", \"b\", \"c\"], [\"d\", \"e\", \"f\"]), [\"ad\", \"be\", \"cf\"])\n  })\n\n  it(\"productAll\", () => {\n    const S = _.Product.productAll([String.Semigroup, String.Semigroup])\n    U.deepStrictEqual(S.combine([\"a1\", \"b1\"], [\"a2\", \"b2\"]), [\"a1a2\", \"b1b2\"])\n  })\n})\n"
  },
  {
    "path": "test/typeclass/Traversable.ts",
    "content": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/typeclass/Traversable\"\nimport * as U from \"../util\"\n\ndescribe(\"Traversable\", () => {\n  it(\"traverseComposition\", () => {\n    const traverse = _.traverseComposition(RA.Traversable, RA.Traversable)(O.Applicative)\n    U.deepStrictEqual(\n      traverse([[1, 2], [3]], (a) => (a > 0 ? O.some(a) : O.none())),\n      O.some([[1, 2], [3]])\n    )\n    U.deepStrictEqual(\n      traverse([[1, -2], [3]], (a) => (a > 0 ? O.some(a) : O.none())),\n      O.none()\n    )\n  })\n\n  it(\"traverseTap\", () => {\n    const traverseTap = _.traverseTap(RA.Traversable)(O.Applicative)\n    U.deepStrictEqual(\n      pipe([], traverseTap(n => n > 0 ? O.some(n) : O.none())),\n      O.some([])\n    )\n    U.deepStrictEqual(\n      pipe([\"a\", \"b\", \"c\"], traverseTap(s => s.length > 0 ? O.some(s.length) : O.none())),\n      O.some([\"a\", \"b\", \"c\"])\n    )\n    U.deepStrictEqual(\n      pipe([\"a\", \"\", \"c\"], traverseTap(s => s.length > 0 ? O.some(s) : O.none())),\n      O.none()\n    )\n  })\n})\n"
  },
  {
    "path": "test/typeclass/TraversableFilterable.ts",
    "content": "import * as E from \"@fp-ts/core/Either\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/typeclass/TraversableFilterable\"\nimport * as U from \"../util\"\n\ndescribe(\"TraversableFilterable\", () => {\n  it(\"traversePartitionMap\", () => {\n    const traversePartitionMap: <A, B, C>(\n      self: ReadonlyArray<A>,\n      f: (a: A) => O.Option<E.Either<B, C>>\n    ) => O.Option<[ReadonlyArray<B>, ReadonlyArray<C>]> = _.traversePartitionMap({\n      ...RA.Traversable,\n      ...RA.Covariant,\n      ...RA.Filterable\n    })(O.Applicative)\n    const f = (s: string) =>\n      s.length > 1 ? O.some(E.right(s)) : s.length > 0 ? O.some(E.left(s)) : O.none()\n    assert.deepStrictEqual(traversePartitionMap([], f), O.some([[], []]))\n    assert.deepStrictEqual(traversePartitionMap([\"\"], f), O.none())\n    assert.deepStrictEqual(traversePartitionMap([\"a\"], f), O.some([[\"a\"], []]))\n    assert.deepStrictEqual(traversePartitionMap([\"aa\"], f), O.some([[], [\"aa\"]]))\n    assert.deepStrictEqual(traversePartitionMap([\"aa\", \"a\", \"\"], f), O.none())\n    assert.deepStrictEqual(\n      traversePartitionMap([\"aa\", \"a\", \"aaa\"], f),\n      O.some([[\"a\"], [\"aa\", \"aaa\"]])\n    )\n  })\n\n  it(\"traverseFilterMap\", () => {\n    const traverseFilterMap: <A, B>(\n      self: ReadonlyArray<A>,\n      f: (a: A) => O.Option<O.Option<B>>\n    ) => O.Option<ReadonlyArray<B>> = _.traverseFilterMap({\n      ...RA.Traversable,\n      ...RA.Filterable\n    })(O.Applicative)\n    const f = (s: string) =>\n      s.length > 1 ? O.some(O.some(s)) : s.length > 0 ? O.some(O.none()) : O.none()\n    assert.deepStrictEqual(traverseFilterMap([], f), O.some([]))\n    assert.deepStrictEqual(traverseFilterMap([\"\"], f), O.none())\n    assert.deepStrictEqual(traverseFilterMap([\"a\"], f), O.some([]))\n    assert.deepStrictEqual(traverseFilterMap([\"aa\"], f), O.some([\"aa\"]))\n    assert.deepStrictEqual(traverseFilterMap([\"aa\", \"a\", \"\"], f), O.none())\n    assert.deepStrictEqual(\n      traverseFilterMap([\"aa\", \"a\", \"aaa\"], f),\n      O.some([\"aa\", \"aaa\"])\n    )\n  })\n\n  it(\"traverseFilter\", () => {\n    const traverseFilter = _.traverseFilter(\n      RA.TraversableFilterable\n    )(O.Applicative)\n    const f = traverseFilter((s: string) =>\n      s.length > 2 ? O.some(false) : s.length > 1 ? O.some(true) : O.none()\n    )\n    U.deepStrictEqual(f([]), O.some([]))\n    U.deepStrictEqual(f([\"a\"]), O.none())\n    U.deepStrictEqual(f([\"a\", \"aa\"]), O.none())\n    U.deepStrictEqual(f([\"aa\"]), O.some([\"aa\"]))\n    U.deepStrictEqual(f([\"aaa\"]), O.some([]))\n    U.deepStrictEqual(f([\"aaa\", \"aa\"]), O.some([\"aa\"]))\n  })\n\n  it(\"traversePartition\", () => {\n    const traversePartition = _.traversePartition(\n      RA.TraversableFilterable\n    )(O.Applicative)\n    const f = traversePartition((s: string) =>\n      s.length > 2 ? O.some(false) : s.length > 1 ? O.some(true) : O.none()\n    )\n    expect(f([])).toEqual(O.some([[], []]))\n    expect(f([\"a\"])).toEqual(O.none())\n    expect(f([\"a\", \"aa\"])).toEqual(O.none())\n    expect(f([\"aa\"])).toEqual(O.some([[], [\"aa\"]]))\n    expect(f([\"aaa\"])).toEqual(O.some([[\"aaa\"], []]))\n    expect(f([\"aaa\", \"aa\"])).toEqual(O.some([[\"aaa\"], [\"aa\"]]))\n  })\n})\n"
  },
  {
    "path": "test/util.ts",
    "content": "import { structural } from \"@fp-ts/core/internal/effect\"\nimport * as assert from \"assert\"\n\nexport const deepStrictEqual = <A>(actual: A, expected: A) => {\n  assert.deepStrictEqual(actual, expected)\n}\n\nexport const strictEqual = <A>(actual: A, expected: A) => {\n  assert.strictEqual(actual, expected)\n}\n\nexport const double = (n: number): number => n * 2\n\nexport const ownKeys = (o: object): ReadonlyArray<PropertyKey> =>\n  (Object.keys(o) as ReadonlyArray<PropertyKey>).concat(Object.getOwnPropertySymbols(o))\n\nexport const isStructural = (u: unknown) => typeof u === \"object\" && u != null && structural in u\n"
  },
  {
    "path": "tsconfig.base.json",
    "content": "{\n  \"compilerOptions\": {\n    \"moduleDetection\": \"force\",\n    \"composite\": true,\n    \"downlevelIteration\": true,\n    \"resolveJsonModule\": true,\n    \"esModuleInterop\": true,\n    \"declaration\": true,\n    \"skipLibCheck\": true,\n    \"emitDecoratorMetadata\": true,\n    \"experimentalDecorators\": true,\n    \"preserveSymlinks\": true,\n    \"moduleResolution\": \"node\",\n    \"noEmit\": false,\n    \"lib\": [\"ES2021\"],\n    \"sourceMap\": true,\n    \"declarationMap\": true,\n    \"strict\": true,\n    \"noImplicitReturns\": false,\n    \"noUnusedLocals\": true,\n    \"noUnusedParameters\": false,\n    \"noFallthroughCasesInSwitch\": true,\n    \"noEmitOnError\": false,\n    \"noErrorTruncation\": false,\n    \"allowJs\": false,\n    \"checkJs\": false,\n    \"forceConsistentCasingInFileNames\": true,\n    \"suppressImplicitAnyIndexErrors\": true,\n    \"stripInternal\": true,\n    \"noImplicitAny\": true,\n    \"noImplicitThis\": true,\n    \"noUncheckedIndexedAccess\": false,\n    \"strictNullChecks\": true,\n    \"baseUrl\": \".\",\n    \"target\": \"ES2021\",\n    \"module\": \"ES6\",\n    \"incremental\": true,\n    \"removeComments\": false,\n    \"paths\": {\n      \"@fp-ts/core\": [\"./src/index.ts\"],\n      \"@fp-ts/core/test/*\": [\"./test/*\"],\n      \"@fp-ts/core/examples/*\": [\"./examples/*\"],\n      \"@fp-ts/core/*\": [\"./src/*\"]\n    },\n    \"plugins\": [{ \"name\": \"@effect/language-service\" }]\n  },\n  \"include\": [],\n  \"exclude\": [\"node_modules\", \"build\", \"lib\"]\n}\n"
  },
  {
    "path": "tsconfig.build-test.json",
    "content": "{\n  \"extends\": \"./tsconfig.base.json\",\n  \"compilerOptions\": {\n    \"tsBuildInfoFile\": \"build/tsbuildinfo/test.tsbuildinfo\",\n    \"rootDir\": \"./\",\n    \"noEmit\": true,\n    \"types\": [\"vitest/globals\", \"node\"]\n  },\n  \"include\": [\"test/**/*.ts\", \"src/**/*.ts\"]\n}\n"
  },
  {
    "path": "tsconfig.build.json",
    "content": "{\n  \"extends\": \"./tsconfig.base.json\",\n  \"compilerOptions\": {\n    \"outDir\": \"build/esm\",\n    \"declarationDir\": \"build/dts\",\n    \"tsBuildInfoFile\": \"build/tsbuildinfo/esm.tsbuildinfo\",\n    \"rootDir\": \"src\"\n  },\n  \"include\": [\"src/**/*.ts\"]\n}\n"
  },
  {
    "path": "tsconfig.eslint.json",
    "content": "{\n  \"compilerOptions\": {\n    \"noEmit\": true,\n    \"allowJs\": true,\n    \"baseUrl\": \".\"\n  },\n  \"include\": [\n    \"./src/**/*.ts\",\n    \"./test/**/*.ts\",\n    \"./dtslint/**/*.ts\",\n    \"./examples/**/*.ts\",\n    \"./vitest.config.ts\",\n    \"./.eslintrc.cjs\"\n  ]\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"extends\": \"./tsconfig.base.json\",\n  \"references\": [\n    {\n      \"path\": \"./tsconfig.build.json\"\n    },\n    {\n      \"path\": \"./tsconfig.build-test.json\"\n    }\n  ]\n}\n"
  },
  {
    "path": "tsconfig.madge.json",
    "content": "{\n  \"compilerOptions\": {\n    \"noEmit\": true,\n    \"allowJs\": true,\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"@fp-ts/core\": [\"./build/esm/index.js\"],\n      \"@fp-ts/core/*\": [\"./build/esm/*\"]\n    }\n  },\n  \"include\": [\"./build/esm/**/*.js\"]\n}\n"
  },
  {
    "path": "vitest.config.ts",
    "content": "/// <reference types=\"vitest\" />\nimport path from \"path\"\nimport { defineConfig } from \"vite\"\n\nexport default defineConfig({\n  test: {\n    include: [\"./test/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}\"],\n    exclude: [\n      \"./test/util.ts\",\n      \"./test/limbo/*.ts\"\n    ],\n    globals: true\n  },\n  resolve: {\n    alias: {\n      \"@fp-ts/core/test\": path.resolve(__dirname, \"/test\"),\n      \"@fp-ts/core\": path.resolve(__dirname, \"/src\")\n    }\n  }\n})\n"
  }
]