[
  {
    "path": ".editorconfig",
    "content": "[*]\nindent_style = space\nindent_size = 2\n"
  },
  {
    "path": ".eslintrc.json",
    "content": "{\n  \"parserOptions\": {\n    \"project\": \"./tsconfig.eslint.json\"\n  },\n  \"extends\": [\n    \"eslint:recommended\",\n    \"plugin:@typescript-eslint/eslint-recommended\",\n    \"plugin:@typescript-eslint/recommended\"\n  ],\n  \"plugins\": [\"deprecation\", \"import\", \"simple-import-sort\"],\n  \"rules\": {\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/ban-ts-comment\": \"off\",\n    \"@typescript-eslint/no-explicit-any\": \"off\",\n    \"@typescript-eslint/no-empty-interface\": \"off\",\n    \"no-unused-vars\": \"off\",\n    \"@typescript-eslint/no-unused-vars\": [\"error\", { \"argsIgnorePattern\": \"^_\" }],\n    \"prefer-rest-params\": \"off\",\n    \"prefer-spread\": \"off\",\n    \"deprecation/deprecation\": \"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\": \"error\",\n    \"no-restricted-syntax\": [\n      \"error\",\n      {\n        \"selector\": \"CallExpression[callee.property.name='push'] > SpreadElement.arguments\",\n        \"message\": \"Do not use spread arguments in Array.push\"\n      }\n    ]\n  }\n}\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "github: [gcanti]\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/Bug_report.md",
    "content": "---\nname: \"\\U0001F41B Bug report\"\nabout: Create a report to help make fp-ts better\n---\n\n## 🐛 Bug report\n\n### Current Behavior\n\n<!-- If applicable, add screenshots to help explain your problem. -->\n\n### Expected behavior\n\n<!-- A clear and concise description of what you expected to happen. -->\n\n### Reproducible example\n\n### Suggested solution(s)\n\n<!-- How could we solve this bug? What changes would need to made to fp-ts? -->\n\n### Additional context\n\n<!-- Add any other context about the problem here.  -->\n\n### Your environment\n\nWhich versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts?\n\n<!-- PLEASE FILL THIS OUT -->\n\n| Software   | Version(s) |\n| ---------- | ---------- |\n| fp-ts      |            |\n| TypeScript |            |\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/Documentation.md",
    "content": "---\nname: \"\\U0001F41B Documentation\"\nabout: Improvements or suggestions of fp-ts documentation\n---\n\n## 📖 Documentation\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/Feature_request.md",
    "content": "---\nname: \"\\U0001F680Feature request\"\nabout: Suggest an idea for fp-ts\n---\n\n## 🚀 Feature request\n\n### Current Behavior\n\n<!-- A clear and concise description of what is the current behavior / use.  -->\n\n### Desired Behavior\n\n<!-- A clear and concise description of what you want to happen.  -->\n\n### Suggested Solution\n\n<!-- Suggest a solution that the community/maintainers/you may take to enable the desired behavior  -->\n\n<!-- NOTE: Feature Requests without suggested solutions may not be addressed or treated with the same level of urgency as those that have suggested solutions. -->\n\n### Who does this impact? Who is this for?\n\n<!-- Who is this for? All users? TypeScript users? Beginners? Advanced? Yourself? People using X, Y, X, etc.? -->\n\n### Describe alternatives you've considered\n\n<!-- A clear and concise description of any alternative solutions or features you've considered.  -->\n\n### Additional context\n\n<!-- Add any other context or links about the feature request here. -->\n\n### Your environment\n\n<!-- PLEASE FILL THIS OUT -->\n\n| Software   | Version(s) |\n| ---------- | ---------- |\n| fp-ts      |            |\n| TypeScript |            |\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "**Before submitting a pull request,** please make sure the following is done:\n\n- Fork [the repository](https://github.com/gcanti/fp-ts) and create your branch from `master`.\n- Run `npm install` in the repository root.\n- If you've fixed a bug or added code that should be tested, add tests!\n- Ensure the test suite passes (`npm test`).\n\n**Note**. If you've fixed a bug please link the related issue or, if missing, open an issue before sending a PR.\n\n**Note**. If you find a typo in the **documentation**, make sure to modify the corresponding source (docs are generated).\n\n**Note**. If you want to send a PR related to `fp-ts@1.x` please create your branch from `1.x`\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: Node.js CI\n\non:\n  push:\n    branches: [master]\n  pull_request:\n    branches: [master]\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: [20.12.2]\n\n    steps:\n      - uses: actions/checkout@v2\n      - name: Use Node.js ${{ matrix.node-version }}\n        uses: actions/setup-node@v1\n        with:\n          node-version: ${{ matrix.node-version }}\n      - run: npm install\n      - run: npm run build --if-present\n      - run: npm test\n"
  },
  {
    "path": ".gitignore",
    "content": "*.log\nnode_modules\n/dist\ndev\n.idea\ncoverage\ndocs/examples\n"
  },
  {
    "path": ".prettierrc",
    "content": "{\n  \"semi\": false,\n  \"singleQuote\": true,\n  \"printWidth\": 120,\n  \"trailingComma\": \"none\"\n}\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\n  \"typescript.tsdk\": \"./node_modules/typescript/lib\",\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n  \"eslint.validate\": [\"typescript\"],\n  \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": \"explicit\"\n  },\n  \"files.insertFinalNewline\": true\n}\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\n> **Tags:**\n>\n> - [New Feature]\n> - [Bug Fix]\n> - [Breaking Change]\n> - [Documentation]\n> - [Internal]\n> - [Polish]\n> - [Experimental]\n> - [Deprecation]\n\n**Note**: Gaps between patch versions are faulty/broken releases.\n\n**Note**: A feature tagged as Experimental is in a\nhigh state of flux, you're at risk of it changing without notice.\n\n# 2.16.11\n\n**Bug Fix**\n\nFix Option.getOrd definition, #1963\n\n# 2.16.10\n\n**Polish**\n\nAdd apFirstW and apSecondW to ReaderTask, #1958\n\n# 2.16.9\n\n**Polish**\n\nSupport `strictBuiltinIteratorReturn`, #1949\n\n# 2.16.8\n\n**Polish**\n\nRemove useless pure comment, closes #1937\n\n# 2.16.7\n\n**Polish**\n\nAdd tap for Identity #1943\n\n# 2.16.6\n\n**Polish**\n\nAllow dependencies to be widen when using orLeft #1938\n\n# 2.16.5\n\n**Polish**\n\nResolved a RangeError where the maximum call stack size was exceeded when invoking `chainWithIndex`, #1931\n\n# 2.16.4\n\n**Polish**\n\nFix `__PURE__` annotation placement, closes #1926\n\n# 2.16.3\n\n**Polish**\n\n`Either.ts`: `toError`: Don't fail when a value can't be converted to a primitive, #1924\n\n# 2.16.2\n\n**Polish**\n\nFix `\"__PURE__\"` annotation placement #1919, closes #1916\n\n# 2.16.1\n\n**Bug Fix**\n\n- fix type signature of `ReaderTaskEither.tapReaderIO`, #1895\n\n# 2.16.0\n\n- `tapEither` (dual) (aka `chainFirstEitherK` / `chainFirstEitherKW`) https://github.com/gcanti/fp-ts/pull/1864\n- `tapIO` (dual) (aka `chainFirstIOK`) https://github.com/gcanti/fp-ts/pull/1865\n- `as` / `asUnit` https://github.com/gcanti/fp-ts/pull/1867\n- `tapTask` (dual) (aka `chainFirstTaskK`) https://github.com/gcanti/fp-ts/pull/1869\n- `mapError` (dual) (aka `mapLeft`) https://github.com/gcanti/fp-ts/pull/1870\n- `mapBoth` (dual) (aka `bimap`) https://github.com/gcanti/fp-ts/pull/1872\n- `tapReader` (dual) (aka `chainFirstReaderK` / `chainFirstIReaderKW`) https://github.com/gcanti/fp-ts/pull/1871\n- `tapReaderEither` (dual) (aka `chainFirstReaderEitherK` / `chainFirstEitherKW`) https://github.com/gcanti/fp-ts/pull/1873\n- `tapReaderIO` (dual) (aka `chainFirstReaderIOK`) https://github.com/gcanti/fp-ts/pull/1873\n- `tapReaderTask` (dual) (aka `chainFirstReaderTaskK`) https://github.com/gcanti/fp-ts/pull/1873\n- `tapTaskEither` (dual) (aka `chainFirstTaskEitherK` / `chainFirstTaskEitherKW`) https://github.com/gcanti/fp-ts/pull/1873\n- `flatMapReaderTask` (dual) (aka `chainReaderTaskK` / `chainReaderTaskKW`) https://github.com/gcanti/fp-ts/pull/1874\n- `flatMapTaskEither` (dual) (aka `chainTaskEitherK` / `chainTaskEitherKW`) https://github.com/gcanti/fp-ts/pull/1874\n- `flatMapIO` (dual) (aka `chainIOK`) https://github.com/gcanti/fp-ts/pull/1874\n- `Option.orElse` (dual) (aka `alt` / `altW`) https://github.com/gcanti/fp-ts/pull/1868\n- `flatMapTask` (dual) (aka `chainTaskK`) https://github.com/gcanti/fp-ts/pull/1876\n- `flatMapReader` (dual) (aka `chainReaderK` / `chainReaderKW`) https://github.com/gcanti/fp-ts/pull/1876\n- `flatMapReaderIO` (dual) (aka `chainReaderIOK` / `chainReaderIOKW`) https://github.com/gcanti/fp-ts/pull/1879\n- `flatMap*` (aka `chain*K` / `chain*KW`) https://github.com/gcanti/fp-ts/pull/1880\n\n# 2.15.0\n\n**New Feature**\n\n- `function`\n  - add `LazyArg`\n- add `tap` to\n  - `Either`\n  - `IO`\n  - `IOEither`\n  - `IOOption`\n  - `Option`\n  - `Reader`\n  - `ReaderEither`\n  - `ReaderIO`\n  - `ReaderTask`\n  - `ReaderTaskEither`\n  - `State`\n  - `StateReaderTaskEither`\n  - `Task`\n  - `TaskEither`\n  - `TaskOption`\n- add `flatMapNullable` (dual) to\n  - `Either`\n  - `IOEither`\n  - `ReaderEither`\n  - `ReaderTaskEither`\n  - `StateReaderTaskEither`\n  - `TaskEither`\n- add `flatMapOption` (dual) to\n  - `Either`\n  - `IOEither`\n  - `ReaderEither`\n  - `ReaderTaskEither`\n  - `StateReaderTaskEither`\n  - `TaskEither`\n- add `liftNullable` to\n  - `Either`\n  - `IOEither`\n  - `ReaderEither`\n  - `ReaderTaskEither`\n  - `StateReaderTaskEither`\n  - `TaskEither`\n- add `liftOption` to\n  - `Either`\n  - `IOEither`\n  - `ReaderEither`\n  - `ReaderTaskEither`\n  - `StateReaderTaskEither`\n  - `TaskEither`\n- add `flatMapEither` (dual) to\n  - `IOEither`\n  - `ReaderEither`\n  - `ReaderTaskEither`\n  - `TaskEither`\n- `Array`\n  - add index to `flatMap`\n- `NonEmptyArray`\n  - add index to `flatMap`\n- `ReadonlyArray`\n  - add index to `flatMap`\n- `ReadonlyNonEmptyArray`\n  - add index to `flatMap`\n\n# 2.14.0\n\n**New Feature**\n\n- add `flatMap` to\n  - `Either`\n  - `IOEither`\n  - `Reader`\n  - `ReaderEither`\n  - `ReaderIO`\n  - `ReaderTask`\n  - `ReaderTaskEither`\n  - `StateReaderTaskEither`\n  - `TaskEither`\n  - `NonEmptyArray`\n  - `ReadonlyNonEmptyArray`\n  - `Tree`\n  - `Array`\n  - `Identity`\n  - `IO`\n  - `IOOption`\n  - `Option`\n  - `ReadonlyArray`\n  - `State`\n  - `Task`\n  - `TaskOption`\n\n# 2.13.2\n\n- add `chainOptionKW`, #1846 (@DenisFrezzato)\n\n# 2.13.1\n\n- **New Feature**\n  - new modules:\n    - `ReaderIO`, #1738 (@sukovanej)\n  - do notation:\n    - add `let` helpers, #1725 (@Punie)\n  - `Alternative`\n    - add `getAlternativeMonoid`, #1717 (@willheslam)\n  - `function`\n    - `flip` is now curried, #1748 (@thewilkybarkid)\n  - `pipeable`\n    - add pipeable helpers, #1764 (@gcanti)\n      - `alt`\n      - `ap`\n      - `bimap`\n      - `chain`\n      - `compose`\n      - `contramap`\n      - `extend`\n      - `filter`\n      - `filterMap`\n      - `filterMapWithIndex`\n      - `filterWithIndex`\n      - `foldMap`\n      - `foldMapWithIndex`\n      - `map`\n      - `mapLeft`\n      - `mapWithIndex`\n      - `partition`\n      - `partitionMap`\n      - `partitionMapWithIndex`\n      - `partitionWithIndex`\n      - `promap`\n      - `reduce`\n      - `reduceRight`\n      - `reduceRightWithIndex`\n      - `reduceWithIndex`\n  - `ReaderTask`\n    - add `ReaderIO` constructors/combinators, #1773 (@thewilkybarkid)\n  - `ReaderTaskEither`\n    - add `ReaderIO` constructors/combinators, #1774 (@thewilkybarkid)\n  - `TaskEither`\n    - add `chainTaskOptionKW`, #1744 (@AmirabbasJ)\n- **Polish**\n  - backport from v3 some handy defaults defined in natural transformations/combinators/constructors (@gcanti)\n  - fix wrong type parameter order:\n    - `FromIO`\n      - `chainIOK`\n    - `FromTask`\n      - `chainTaskK`\n      - `chainFirstTaskK`\n    - `Whiterable`\n      - `FilterE1`\n    - `TheseT`\n      - `both`\n    - `Either`\n      - `apFirstW`\n      - `apSecondW`\n    - `IOEither`\n      - `apFirstW`\n      - `apSecondW`\n    - `Reader`\n      - `apFirstW`\n      - `apSecondW`\n    - `ReaderEither`\n      - `apFirstW`\n      - `apSecondW`\n    - `ReaderTaskEither`\n      - `apFirstW`\n      - `apSecondW`\n    - `StateReaderTaskEither`\n      - `apFirstW`\n      - `apSecondW`\n    - `TaskEither`\n      - `apFirstW`\n      - `apSecondW`\n  - `Apply`\n    - add `ap` overloadings, #1721 (@waynevanson)\n  - `Either`\n    - remove useless type parameter in `exists` (@gcanti)\n  - `ReadonlyRecord`\n    - fix `fromEntries` return type, closes #1745 (@gcanti)\n  - `TaskEither`\n    - fix `fromPredicate` signature (@gcanti)\n  - `These`\n    - add missing `fromPredicate` (@gcanti)\n    - remove useless type parameter in `exists` (@gcanti)\n  - `Traversable`\n    - add more overloadings to traverse / sequence helpers, #1758 (@gcanti)\n  - `Writer`\n    - `getChain` requires a `Semigroup` instead of a `Monoid` (@gcanti)\n- **Deprecation**\n  - `function`\n    - deprecate uncurried `flip` function, #1748 (@thewilkybarkid)\n\n# 2.12.2\n\n- **Polish**\n  - `ReadonlyRecord` / `Record`\n    - add `Applicative4` overloadings to `traverse` / `traverseWithIndex`, #1733 (@mlegenhausen)\n\n# 2.12.1\n\n- **Bug Fix**\n  - `ReadonlyRecord`\n    - fix `traverseWithIndex` implementation, #1704 (@waynevanson)\n\n# 2.12.0\n\n- **New Feature**\n  - add `IOOption` module (@gcanti)\n  - `Array`\n    - add `intercalate`, #1678 (@thewilkybarkid)\n  - `Bounded`\n    - add `clamp` (@gcanti)\n    - add `reverse` (@gcanti)\n  - `Either`\n    - add `apFirstW`, #1564 (@DenisFrezzato)\n    - add `apSecondW`, #1564 (@DenisFrezzato)\n  - `EitherT`\n    - add `chainNullableK`, #1619 (@cwstra)\n    - add `fromNullable`, #1619 (@cwstra)\n    - add `fromNullableK`, #1619 (@cwstra)\n  - `FromEither`\n    - add `chainFirstEitherK` (@gcanti)\n  - `IOEither`\n    - add `apFirstW`, #1564 (@DenisFrezzato)\n    - add `apSecondW`, #1564 (@DenisFrezzato)\n    - add `chainFirstEitherK` (@gcanti)\n    - add `chainFirstEitherKW` (@gcanti)\n    - add `orElseFirstIOK`, #1655 (@thewilkybarkid)\n    - add `bracketW`, #1627 (@thomasvargiu)\n  - `NonEmptyArray`\n    - add `intercalate`, #1678 (@thewilkybarkid)\n  - `Option`\n    - add `chainFirstEitherK` (@gcanti)\n  - `Ordering`\n    - add `matchW`, #1535 (@mlegenhausen)\n  - `Reader`\n    - add `apFirstW`, #1564 (@DenisFrezzato)\n    - add `apSecondW`, #1564 (@DenisFrezzato)\n  - `ReaderEither`\n    - add `apFirstW`, #1564 (@DenisFrezzato)\n    - add `apSecondW`, #1564 (@DenisFrezzato)\n    - add `chainFirstEitherK` (@gcanti)\n    - add `chainFirstEitherKW` (@gcanti)\n  - `ReaderTaskEither`\n    - add `apFirstW`, #1564 (@DenisFrezzato)\n    - add `apSecondW`, #1564 (@DenisFrezzato)\n    - add `chainFirstEitherK`, #1562 (@DenisFrezzato)\n    - add `chainFirstEitherKW`, #1562 (@DenisFrezzato)\n    - add `bracketW`, #1627 (@thomasvargiu)\n    - add `chainNullableK` (@gcanti)\n    - add `fromNullable` (@gcanti)\n    - add `fromNullableK` (@gcanti)\n  - `ReadonlyArray`\n    - add `intercalate`, #1678 (@thewilkybarkid)\n  - `ReadonlyNonEmptyArray`\n    - add `intercalate`, #1678 (@thewilkybarkid)\n  - `ReadonlyRecord`\n    - add `toEntries`, #1552 (@bravely)\n    - add `fromEntries`, #1552 (@bravely)\n  - `Record`\n    - add `toEntries`, #1552 (@bravely)\n    - add `fromEntries`, #1552 (@bravely)\n  - `StateReaderTaskEither`\n    - add `apFirstW`, #1564 (@DenisFrezzato)\n    - add `apSecondW`, #1564 (@DenisFrezzato)\n    - add `chainFirstEitherK` (@gcanti)\n    - add `chainFirstEitherKW` (@gcanti)\n  - `TaskEither`\n    - add `apFirstW`, #1564 (@DenisFrezzato)\n    - add `apSecondW`, #1564 (@DenisFrezzato)\n    - add `chainFirstEitherK`, #1659 (@vinassefranche)\n    - add `chainFirstEitherKW`, #1659 (@vinassefranche)\n    - add `orElseFirstIOK`, #1655 (@thewilkybarkid)\n    - add `orElseFirstTaskK`, #1655 (@thewilkybarkid)\n    - add `bracketW`, #1627 (@thomasvargiu)\n    - add `chainNullableK`, #1619 (@cwstra)\n    - add `fromNullable`, #1619 (@cwstra)\n    - add `fromNullableK`, #1619 (@cwstra)\n  - `TaskOption`\n    - add `fromEitherK` (@gcanti)\n    - add `chainEitherK` (@gcanti)\n    - add `chainFirstEitherK` (@gcanti)\n\n# 2.11.10\n\n- **Polish**\n  - `TaskEither` / `TaskOption`\n    - now `tryCatch` / `tryCatchK` will catch synchronous errors too, #1676 (@thewilkybarkid)\n\n# 2.11.9\n\n- **Polish**\n  - add `Refinement` overload to 'every' functions, #1681 (@mlegenhausen)\n\n# 2.11.8\n\n- **Polish**\n  - Add missing pure annotations, #1658 (@OliverJAsh)\n\n# 2.11.7\n\n- **Polish**\n  - more `Functor.map` overloadings, closes #1623 (@gcanti)\n\n# 2.11.6\n\n- **Polish**\n  - `ReaderEither`\n    - `orElseFirstW`: intersect dependencies like `orElseW` (@gcanti)\n  - `ReaderTaskEither`\n    - `orElseFirstW`: intersect dependencies like `orElseW`, #1635 (@OliverJAsh)\n\n# 2.11.5\n\n- **Polish**\n  - more curried `elem` overloads, #1602 (@ammut)\n\n# 2.11.4\n\n- **Polish**\n  - fix `chainNullableK` signature, #1589 (@bwlt)\n  - stack safety for `Task` via microtasks suspension, #1591 (@mikearnaldi)\n\n# 2.11.3\n\n- **Polish**\n  - pipe: fix v8 performance cliff for >10 case stmts, #1585 (@pbadenski)\n\n# 2.11.2\n\n- **Polish**\n  - Add/fix pure comments, #1555 (@OliverJAsh)\n\n# 2.11.1\n\n- **Deprecation**\n  - `Array`\n    - deprecate `range`, use `NonEmptyArray` module instead.\n  - `function`\n    - deprecate `Endomorphism`, use `Endomorphism` module instead.\n    - deprecate `getEndomorphismMonoid`, use `Endomorphism` module instead.\n    - deprecate `Predicate`, use `Predicate` module instead.\n    - deprecate `not`, use `Predicate` module instead.\n    - deprecate `Refinement`, use `Refinement` module instead.\n  - `Monoid`\n    - deprecate `monoidVoid`, use `void` module instead.\n  - `NonEmptyArray`\n    - deprecate `groupSort` (it's just `sort` followed by `group`)\n  - `Option`\n    - deprecate `getRefinement`, use `Refinement` module instead.\n    - deprecate `getFirstMonoid`, use `getMonoid` module instead.\n    - deprecate `getLastMonoid`, use `getMonoid` module instead.\n  - `ReadonlyArray`\n    - deprecate `range`, use `ReadonlyNonEmptyArray` module instead.\n  - `ReadonlyNonEmptyArray`\n    - deprecate `groupSort` (it's just `sort` followed by `group`)\n  - `Record` / `ReadonlyRecord`: deprecate overloads without `Ord` constraint (@anthonyjoeseph):\n    - `collect`\n    - `reduce`\n    - `foldMap`\n    - `reduceRight`\n    - `reduceWithIndex`\n    - `foldMapWithIndex`\n    - `reduceRightWithIndex`\n    - `getShow`\n    - deprecate `Foldable` in favour of `getFoldable` (@anthonyjoeseph)\n    - deprecate `FoldableWithIndex` in favour of `getFoldableWithIndex` (@anthonyjoeseph)\n    - deprecate `Traversable` in favour of `getTraversable` (@anthonyjoeseph)\n    - deprecate `TraversableWithIndex` in favour of `getTraversableWithIndex` (@anthonyjoeseph)\n    - deprecate `Witherable` in favour of `getWitherable` (@anthonyjoeseph)\n  - `Semigroup`\n    - deprecate `semigroupVoid`, use `void` module instead.\n- **New Feature**\n  - add `Endomorphism` module\n  - add `Predicate` module\n  - add `Refinement` module\n  - add `FromState` module\n  - add `FromThese` module\n  - add `void` module\n  - add `FromReader` module\n  - add `NaturalTransformation` module\n  - add `Zero` module\n  - `Alt`\n    - add `altAll`\n  - `Alternative`\n    - add `altAll`\n  - `Array`\n    - add `prependW`, `appendW` (@thewilkybarkid)\n    - add `fromOption`, `fromPredicate` (@cdimitroulas)\n    - add `filterE`\n    - add `ChainRecDepthFirst` instance (@qlonik)\n    - add `chainRecDepthFirst`\n    - add `ChainRecBreadthFirst` instance (@qlonik)\n    - add `chainRecBreadthFirst`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n    - add `fromEither`\n    - add `FromEither` instance\n    - add `fromEitherK`\n    - make `isEmpty` a user defined guard\n    - add `concat` / `concatW`\n    - add `match`, `matchW`, `matchLeftW`, `matchRightW`\n    - add `fromOptionK`\n    - add `Zero` instance\n    - add `guard` constructor\n    - add `exists` alias\n  - `boolean`\n    - add `isBoolean`\n  - `Either`\n    - add `chainOptionK`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `EitherT`\n    - add `orElseFirst`\n    - add `orLeft`\n  - `function`\n    - add `SK` (@cdimitroulas)\n    - add `apply`\n  - `IO`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `IOEither`\n    - add `orElseFirst` / `orElseFirstW`\n    - add `orLeft`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `Magma`\n    - add `reverse`\n    - add `filterFirst`\n    - add `filterSecond`\n    - add `endo`\n    - add `concatAll`\n  - `Map`\n    - add `union`\n    - add `intersection`\n    - add `difference`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n    - add `getFoldable`\n    - add `foldMap`\n    - add `reduceRight`\n    - add `reduceWithIndex`\n    - add `foldMapWithIndex`\n    - add `reduceRightWithIndex`\n  - `NonEmptyArray`\n    - add `matchLeft`, `matchRight`, `modifyHead`, `modifyLast` (@cdimitroulas)\n    - add `union`\n    - add `getUnionSemigroup`\n    - add `makeBy`\n    - add `range`\n    - make `concat` pipeable\n  - `number`\n    - add `MagmaSub`\n    - add `isNumber`\n  - `string`\n    - add `isString`\n  - `Option`\n    - add `FromEither` instance\n    - add `fromEitherK`\n    - add `chainEitherK`\n    - add `Zero` instance\n    - add `guard` constructor\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `Ord`\n    - add `trivial` instance\n    - add `equals`\n  - `Reader`\n    - add `asksReaderW`, `asksReader`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `ReaderEither`\n    - add `asksReaderEitherW`, `asksReaderEither`\n    - add `orElseFirst` / `orElseFirstW`\n    - add `orLeft`\n    - add `chainReaderKW`\n    - add `chainFirstReaderK`, `chainFirstReaderKW`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `ReaderTask`\n    - add `asksReaderTaskW`, `asksReaderTask`\n    - add `chainReaderKW`\n    - add `chainFirstReaderK`, `chainFirstReaderKW`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `ReaderTaskEither`\n    - add `asksReaderTaskEitherW`, `asksReaderTaskEither`\n    - add `orElseFirst` / `orElseFirstW`\n    - add `orLeft`\n    - add `fromReaderTaskK`\n    - add `fromReaderEitherK`\n    - add `chainReaderKW`\n    - add `chainReaderTaskK`, `chainReaderTaskKW`\n    - add `chainFirstReaderK`, `chainFirstReaderKW`\n    - add `chainFirstReaderTaskK`, `chainFirstReaderTaskKW`\n    - add `chainReaderEitherK`, `chainReaderEitherKW`\n    - add `chainFirstReaderEitherK`, `chainFirstReaderEitherKW`\n    - add `chainFirstTaskEitherK`, `chainFirstTaskEitherKW`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `ReadonlyArray`\n    - add `prependW`, `appendW` (@thewilkybarkid)\n    - add `filterE`\n    - add `ChainRecDepthFirst` instance (@qlonik)\n    - add `chainRecDepthFirst`\n    - add `ChainRecBreadthFirst` instance (@qlonik)\n    - add `chainRecBreadthFirst`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n    - add `fromOption`\n    - add `fromPredicate`\n    - add `fromEither`\n    - add `FromEither` instance\n    - add `fromEitherK`\n    - make `isEmpty` a user defined guard\n    - add `concat` / `concatW`\n    - add `match`, `matchW`, `matchLeftW`, `matchRightW`\n    - add `fromOptionK`\n    - add `Zero` instance\n    - add `guard` constructor\n    - add `exists` alias\n  - `ReadonlyMap`\n    - add `union`\n    - add `intersection`\n    - add `difference`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n    - add `reduce`\n    - add `foldMap`\n    - add `reduceRight`\n    - add `reduceWithIndex`\n    - add `foldMapWithIndex`\n    - add `reduceRightWithIndex`\n  - `ReadonlyNonEmptyArray`\n    - add `matchLeft`, `matchRight`, `modifyHead`, `modifyLast` (@cdimitroulas)\n    - add `union`\n    - add `getUnionSemigroup`\n    - add `makeBy`\n    - add `range`\n    - make `concat` pipeable\n  - `ReadonlyRecord`\n    - add `union` (@anthonyjoeseph)\n    - add `intersection` (@anthonyjoeseph)\n    - add `difference` (@anthonyjoeseph)\n    - add `getUnionSemigroup` (@anthonyjoeseph)\n    - add `getUnionMonoid` (@anthonyjoeseph)\n    - add `getIntersectionSemigroup` (@anthonyjoeseph)\n    - add `getDifferenceMagma` (@anthonyjoeseph)\n  - `ReadonlySet`\n    - add `getUnionSemigroup`\n    - add `getDifferenceMagma`\n  - `Record`\n    - add `union`\n    - add `intersection`\n    - add `difference`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n  - `Set`\n    - add `getUnionSemigroup`\n    - add `getDifferenceMagma`\n  - `State`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `StateReaderTaskEither`\n    - add `fromStateK`\n    - add `chainStateK`\n    - add `local`\n    - add `asksStateReaderTaskEitherW`, `asksStateReaderTaskEither`\n    - add `chainReaderKW`\n    - add `chainFirstReaderK`, `chainFirstReaderKW`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `string`\n    - add `toUpperCase`\n    - add `toLowerCase`\n    - add `replace`\n    - add `split`\n    - add `trim`\n    - add `trimLeft`\n    - add `trimRight`\n    - add `includes`\n    - add `startsWith`\n    - add `endsWith`\n    - add `slice`\n  - `struct`\n    - add `evolve`\n  - `Task`\n    - add `ApT`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `TaskEither`\n    - add `fromTaskOption` (@thewilkybarkid)\n    - add `fromTaskOptionK`\n    - add `chainTaskOptionK`\n    - add `orElseFirst` / `orElseFirstW`\n    - add `orLeft`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `TaskOption`\n    - add `fromTaskEither` (@thewilkybarkid)\n    - add `Zero` instance\n    - add `guard` constructor\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n    - add missing `FromEither` instance\n  - `TaskThese`\n    - add `ApT`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `These`\n    - add `elem`\n    - add `exists`\n    - add `ApT`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `Tree`\n    - add `exists`\n  - `Witherable`\n    - add `filterE`, #1458 (@vinassefranche)\n    - add `wiltDefault`\n    - add `witherDefault`\n- **Polish**\n  - remove unnecessary type parameters\n    - `Either`\n      - `isLeft`\n      - `isRight`\n    - `Option`\n      - `isNone`\n    - `These`\n      - `isLeft`\n      - `isRight`\n\n# 2.11.0-rc.2\n\n- `string`\n  - `split` now returns a `ReadonlyNonEmptyArray`\n- `TaskOption`\n  - add missing `FromEither` instance\n- some signature changes in `2.11.0-rc.1` caused type inference issues\n  - `Array` / `ReadonlyArray`\n    - revert `isOutOfBound` signature change\n    - revert `isEmpty` signature change\n    - revert `size` signature change\n  - `Either`\n    - revert `exists` signature change\n    - revert `elem` signature change\n  - `These`\n    - revert `exists` signature change\n    - revert `elem` signature change\n  - `NonEmptyArray` / `ReadonlyNonEmptyArray`\n    - revert `isOutOfBound` signature change\n  - `Set` / `ReadonlySet`\n    - revert `isEmpty` signature change\n    - revert `size` signature change\n  - `Map` / `ReadonlyMap`\n    - revert `isEmpty` signature change\n    - revert `size` signature change\n\n# 2.11.0-rc.1\n\n- **Deprecation**\n  - `Array`\n    - deprecate `range`, use `NonEmptyArray` module instead.\n  - `function`\n    - deprecate `Endomorphism`, use `Endomorphism` module instead.\n    - deprecate `getEndomorphismMonoid`, use `Endomorphism` module instead.\n    - deprecate `Predicate`, use `Predicate` module instead.\n    - deprecate `not`, use `Predicate` module instead.\n    - deprecate `Refinement`, use `Refinement` module instead.\n  - `Monoid`\n    - deprecate `monoidVoid`, use `void` module instead.\n  - `NonEmptyArray`\n    - deprecate `groupSort` (it's just `sort` followed by `group`)\n  - `Option`\n    - deprecate `getRefinement`, use `Refinement` module instead.\n    - deprecate `getFirstMonoid`, use `getMonoid` module instead.\n    - deprecate `getLastMonoid`, use `getMonoid` module instead.\n  - `ReadonlyArray`\n    - deprecate `range`, use `ReadonlyNonEmptyArray` module instead.\n  - `ReadonlyNonEmptyArray`\n    - deprecate `groupSort` (it's just `sort` followed by `group`)\n  - `Record` / `ReadonlyRecord`: deprecate overloads without `Ord` constraint (@anthonyjoeseph):\n    - `collect`\n    - `reduce`\n    - `foldMap`\n    - `reduceRight`\n    - `reduceWithIndex`\n    - `foldMapWithIndex`\n    - `reduceRightWithIndex`\n    - `getShow`\n    - deprecate `Foldable` in favour of `getFoldable` (@anthonyjoeseph)\n    - deprecate `FoldableWithIndex` in favour of `getFoldableWithIndex` (@anthonyjoeseph)\n    - deprecate `Traversable` in favour of `getTraversable` (@anthonyjoeseph)\n    - deprecate `TraversableWithIndex` in favour of `getTraversableWithIndex` (@anthonyjoeseph)\n    - deprecate `Witherable` in favour of `getWitherable` (@anthonyjoeseph)\n  - `Semigroup`\n    - deprecate `semigroupVoid`, use `void` module instead.\n- **New Feature**\n  - add `Endomorphism` module\n  - add `Predicate` module\n  - add `Refinement` module\n  - add `FromState` module\n  - add `FromThese` module\n  - add `void` module\n  - add `FromReader` module\n  - add `NaturalTransformation` module\n  - add `Zero` module\n  - `Alt`\n    - add `altAll`\n  - `Alternative`\n    - add `altAll`\n  - `Array`\n    - add `prependW`, `appendW` (@thewilkybarkid)\n    - add `fromOption`, `fromPredicate` (@cdimitroulas)\n    - add `filterE`\n    - add `ChainRecDepthFirst` instance (@qlonik)\n    - add `chainRecDepthFirst`\n    - add `ChainRecBreadthFirst` instance (@qlonik)\n    - add `chainRecBreadthFirst`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n    - add `fromEither`\n    - add `FromEither` instance\n    - add `fromEitherK`\n    - make `isEmpty` a user defined guard\n    - add `concat` / `concatW`\n    - add `match`, `matchW`, `matchLeftW`, `matchRightW`\n    - add `fromOptionK`\n    - add `Zero` instance\n    - add `guard` constructor\n    - add `exists` alias\n  - `boolean`\n    - add `isBoolean`\n  - `Either`\n    - add `chainOptionK`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `EitherT`\n    - add `orElseFirst`\n    - add `orLeft`\n  - `function`\n    - add `SK` (@cdimitroulas)\n    - add `apply`\n  - `IO`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `IOEither`\n    - add `orElseFirst` / `orElseFirstW`\n    - add `orLeft`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `Magma`\n    - add `reverse`\n    - add `filterFirst`\n    - add `filterSecond`\n    - add `endo`\n    - add `concatAll`\n  - `Map`\n    - add `union`\n    - add `intersection`\n    - add `difference`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n    - add `getFoldable`\n    - add `foldMap`\n    - add `reduceRight`\n    - add `reduceWithIndex`\n    - add `foldMapWithIndex`\n    - add `reduceRightWithIndex`\n  - `NonEmptyArray`\n    - add `matchLeft`, `matchRight`, `modifyHead`, `modifyLast` (@cdimitroulas)\n    - add `union`\n    - add `getUnionSemigroup`\n    - add `makeBy`\n    - add `range`\n    - make `concat` pipeable\n  - `number`\n    - add `MagmaSub`\n    - add `isNumber`\n  - `string`\n    - add `isString`\n  - `Option`\n    - add `FromEither` instance\n    - add `fromEitherK`\n    - add `chainEitherK`\n    - add `Zero` instance\n    - add `guard` constructor\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `Ord`\n    - add `trivial` instance\n    - add `equals`\n  - `Reader`\n    - add `asksReaderW`, `asksReader`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `ReaderEither`\n    - add `asksReaderEitherW`, `asksReaderEither`\n    - add `orElseFirst` / `orElseFirstW`\n    - add `orLeft`\n    - add `chainReaderKW`\n    - add `chainFirstReaderK`, `chainFirstReaderKW`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `ReaderTask`\n    - add `asksReaderTaskW`, `asksReaderTask`\n    - add `chainReaderKW`\n    - add `chainFirstReaderK`, `chainFirstReaderKW`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `ReaderTaskEither`\n    - add `asksReaderTaskEitherW`, `asksReaderTaskEither`\n    - add `orElseFirst` / `orElseFirstW`\n    - add `orLeft`\n    - add `fromReaderTaskK`\n    - add `fromReaderEitherK`\n    - add `chainReaderKW`\n    - add `chainReaderTaskK`, `chainReaderTaskKW`\n    - add `chainFirstReaderK`, `chainFirstReaderKW`\n    - add `chainFirstReaderTaskK`, `chainFirstReaderTaskKW`\n    - add `chainReaderEitherK`, `chainReaderEitherKW`\n    - add `chainFirstReaderEitherK`, `chainFirstReaderEitherKW`\n    - add `chainFirstTaskEitherK`, `chainFirstTaskEitherKW`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `ReadonlyArray`\n    - add `prependW`, `appendW` (@thewilkybarkid)\n    - add `filterE`\n    - add `ChainRecDepthFirst` instance (@qlonik)\n    - add `chainRecDepthFirst`\n    - add `ChainRecBreadthFirst` instance (@qlonik)\n    - add `chainRecBreadthFirst`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n    - add `fromOption`\n    - add `fromPredicate`\n    - add `fromEither`\n    - add `FromEither` instance\n    - add `fromEitherK`\n    - make `isEmpty` a user defined guard\n    - add `concat` / `concatW`\n    - add `match`, `matchW`, `matchLeftW`, `matchRightW`\n    - add `fromOptionK`\n    - add `Zero` instance\n    - add `guard` constructor\n    - add `exists` alias\n  - `ReadonlyMap`\n    - add `union`\n    - add `intersection`\n    - add `difference`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n    - add `reduce`\n    - add `foldMap`\n    - add `reduceRight`\n    - add `reduceWithIndex`\n    - add `foldMapWithIndex`\n    - add `reduceRightWithIndex`\n  - `ReadonlyNonEmptyArray`\n    - add `matchLeft`, `matchRight`, `modifyHead`, `modifyLast` (@cdimitroulas)\n    - add `union`\n    - add `getUnionSemigroup`\n    - add `makeBy`\n    - add `range`\n    - make `concat` pipeable\n  - `ReadonlyRecord`\n    - add `union` (@anthonyjoeseph)\n    - add `intersection` (@anthonyjoeseph)\n    - add `difference` (@anthonyjoeseph)\n    - add `getUnionSemigroup` (@anthonyjoeseph)\n    - add `getUnionMonoid` (@anthonyjoeseph)\n    - add `getIntersectionSemigroup` (@anthonyjoeseph)\n    - add `getDifferenceMagma` (@anthonyjoeseph)\n  - `ReadonlySet`\n    - add `getUnionSemigroup`\n    - add `getDifferenceMagma`\n  - `Record`\n    - add `union`\n    - add `intersection`\n    - add `difference`\n    - add `getUnionSemigroup`\n    - add `getUnionMonoid`\n    - add `getIntersectionSemigroup`\n    - add `getDifferenceMagma`\n  - `Set`\n    - add `getUnionSemigroup`\n    - add `getDifferenceMagma`\n  - `State`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `StateReaderTaskEither`\n    - add `fromStateK`\n    - add `chainStateK`\n    - add `local`\n    - add `asksStateReaderTaskEitherW`, `asksStateReaderTaskEither`\n    - add `chainReaderKW`\n    - add `chainFirstReaderK`, `chainFirstReaderKW`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `string`\n    - add `toUpperCase`\n    - add `toLowerCase`\n    - add `replace`\n    - add `split`\n    - add `trim`\n    - add `trimLeft`\n    - add `trimRight`\n    - add `includes`\n    - add `startsWith`\n    - add `endsWith`\n    - add `slice`\n  - `struct`\n    - add `evolve`\n  - `Task`\n    - add `ApT`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `TaskEither`\n    - add `fromTaskOption` (@thewilkybarkid)\n    - add `fromTaskOptionK`\n    - add `chainTaskOptionK`\n    - add `orElseFirst` / `orElseFirstW`\n    - add `orLeft`\n    - add `flattenW`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `TaskOption`\n    - add `fromTaskEither` (@thewilkybarkid)\n    - add `Zero` instance\n    - add `guard` constructor\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `TaskThese`\n    - add `ApT`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n    - add `traverseReadonlyNonEmptyArrayWithIndexSeq`\n    - add `traverseReadonlyArrayWithIndexSeq`\n  - `These`\n    - add `elem`\n    - add `exists`\n    - add `ApT`\n    - add `traverseReadonlyNonEmptyArrayWithIndex`\n    - add `traverseReadonlyArrayWithIndex`\n  - `Tree`\n    - add `exists`\n  - `Witherable`\n    - add `filterE`, #1458 (@vinassefranche)\n    - add `wiltDefault`\n    - add `witherDefault`\n- **Polish**\n  - remove unnecessary type parameters\n    - `Either`\n      - `exists`\n      - `isLeft`\n      - `isRight`\n      - `elem`\n    - `Option`\n      - `isNone`\n    - `These`\n      - `isLeft`\n      - `isRight`\n    - `Set` / `ReadonlySet`\n      - `isEmpty`\n      - `size`\n    - `Array` / `ReadonlyArray`\n      - `isEmpty`\n      - `isOutOfBound`\n      - `size`\n    - `Map` / `ReadonlyMap`\n      - `isEmpty`\n      - `size`\n    - `NonEmptyArray` / `ReadonlyNonEmptyArray`\n      - `isOutOfBound`\n\n# 2.10.5\n\n- **Bug Fix**\n  - `StateT`\n    - fix typo in `fromF`, #1503 (@DKurilo)\n\n# 2.10.4\n\n- **Bug Fix**\n  - `altW` left type is too wide in `Either`-based data types, #1488 (@wmaurer)\n\n# 2.10.3\n\n- **Bug Fix**\n  - `StateReaderTaskEither`\n    - `traverseArrayWithIndex` does not pass the output state from each step to the subsequent step, #1486\n\n# 2.10.2\n\n- **Bug Fix**\n  - `Record`\n    - `hasOwnProperty` should be an alias of `ReadonlyRecord.hasOwnProperty`\n\n# 2.10.1\n\n- **Bug Fix**\n  - rename `hasOwnProperty` in `internal` module, #1481 (@OliverJAsh)\n\n# 2.10.0\n\n- **Deprecations**\n  - deprecate `pipeable` module, use the specific helpers instead\n  - deprecate `ValidationT` module, use `EitherT` instead\n  - deprecate \"mega instances\", use small, specific instances instead\n  - deprecate the old monad transformers, use the specific helpers instead\n  - `Applicative`\n    - deprecate `getApplicativeComposition`, use `ap` helper instead\n  - `Array`\n    - deprecate `prependToAll`, use `prependAll` instead\n    - deprecate `cons` in favour of `prepend`\n    - deprecate `snoc` in favour of `append`\n    - deprecate `empty`\n  - `BooleanAlgebra`\n    - deprecate `booleanAlgebraBoolean`, use `boolean.BooleanAlgebra` instead\n    - deprecate `getFunctionBooleanAlgebra`, use `function.getBooleanAlgebra` instead\n    - deprecate `getDualBooleanAlgebra`, use `reverse` instead\n  - `Bounded`\n    - deprecate `boundedNumber`, use `number.Bounded` instead\n  - `Choice`\n    - deprecate `splitChoice` in favour of `split`\n    - deprecate `fanin` in favour of `fanIn`\n  - `Compactable`\n    - deprecate `getCompactableComposition`, use `compact`, `separate` helpers instead\n    - deprecate `Separated`, use `Separated.Separated` instead\n  - `Either`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getValidationSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getValidationMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getValidation`, use `getApplicativeValidation` and `getAltValidation` instead\n    - deprecate `Json` type, use the `Json` module instead\n    - deprecate `parseJSON` type, use the `Json` module instead\n    - deprecate `stringifyJSON` type, use the `Json` module instead\n  - `Eq`\n    - deprecate `eqBoolean`, use `boolean.Eq` instead\n    - deprecate `eqString`, use `string.Eq` instead\n    - deprecate `eqNumber`, use `number.Eq` instead\n    - deprecate `eqDate`, use `Date.Eq` instead\n    - deprecate `getStructEq`, use `struct` instead\n    - deprecate `getTupleEq`, use `tuple` instead\n  - `Filterable`\n    - deprecate `getFilterableComposition`, use `filter`, `filterMap`, `partition`, `partitionMap` helpers instead\n  - `Foldable`\n    - deprecate `toArray` in favour of `toReadonlyArray`\n    - deprecate `getFoldableComposition`, use `reduce`, `foldMap`, `reduceRight` helpers instead\n  - `FoldableWithIndex`\n    - deprecate `getFoldableWithIndexComposition`, use `reduceWithIndex`, `foldMapWithIndex`, `reduceRightWithIndex` helpers instead\n  - `Functor`\n    - deprecate `getFunctorComposition`, use `map` helper instead\n  - `FunctorWithIndex`\n    - deprecate `getFunctorWithIndexComposition`, use `mapWithIndex` helper instead\n  - `IO`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `fromIO`\n  - `IOEither`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - daprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getIOValidation`, use `getApplicativeIOValidation` and `getAltIOValidation` instead\n  - `Map`\n    - deprecate `insertAt` in favour of `upsertAt`\n    - deprecate `empty`\n  - `Monoid`\n    - deprecate `monoidAll`, use `boolean.MonoidAll` instead\n    - deprecate `monoidAny`, use `boolean.MonoidAny` instead\n    - deprecate `getFunctionMonoid`, use `function.getMonoid` instead\n    - deprecate `getEndomorphismMonoid`, use `function.getEndomorphismMonoid` instead (**Note**. The execution order in\n      `function.getEndomorphismMonoid` is reversed)\n    - deprecate `monoidString`, use `string.Monoid` instead\n    - deprecate `monoidSum`, use `number.MonoidSum` instead\n    - deprecate `monoidProduct`, use `number.MonoidProduct` instead\n    - deprecate `fold`, use `concatAll` instead\n    - deprecate `getMeetMonoid`, use `min` instead\n    - deprecate `getJoinMonoid`, use `max` instead\n    - deprecate `getDualMonoid`, use `reverse` instead\n    - deprecate `getStructMonoid`, use `struct` instead\n    - deprecate `getTupleMonoid`, use `tuple` instead\n  - `NonEmptyArray`\n    - deprecate `fold`, use `concatAll` instead\n    - deprecate `prependToAll`, use `prependAll` instead\n    - deprecate `cons` in favour of `prepend`\n    - deprecate `snoc` in favour of `append`\n    - deprecate `uncons` in favour of `unprepend`\n    - deprecate `unsnoc` in favour of `unappend`\n    - deprecate `filter` in favour of `Array`'s `filter`\n    - deprecate `filterWithIndex` in favour of `Array`'s `filterWithIndex`\n  - `Option`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n  - `Ord`\n    - deprecate `ordBoolean`, use `boolean.Ord` instead\n    - deprecate `ordString`, use `string.Ord` instead\n    - deprecate `ordNumber`, use `number.Ord` instead\n    - deprecate `ordDate`, use `Date.Ord` instead\n    - deprecate `getDualOrd`, use `reverse` instead\n    - deprecate `getTupleOrd`, use `tuple` instead\n  - `Ordering`\n    - deprecate `eqOrdering`, use `Eq` instead\n    - deprecate `monoidOrdering`, use `Monoid` instead\n    - deprecate `invert` in favour of `reverse`\n  - `Ring`\n    - deprecate `getFunctionRing`, use `function.getRing` instead\n  - `Reader`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getMonoid` in favour of `Applicative.getApplicativeMonoid`\n  - `ReaderEither`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getReaderValidation`, use `getApplicativeReaderValidation` and `getAltReaderValidation` instead\n    - deprecate `local`, Use `Reader`'s `local` instead\n  - `ReaderTask`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `run`\n    - deprecate `local`, Use `Reader`'s `local` instead\n  - `ReaderTaskEither`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getReaderTaskValidation`, use `getApplicativeReaderTaskValidation` and `getAltReaderTaskValidation` instead\n    - deprecate `run`\n    - deprecate `local`, Use `Reader`'s `local` instead\n  - `ReaderTaskEither`\n    - deprecate `run`\n  - `ReadonlyArray`\n    - deprecate `prependToAll`, use `prependAll` instead\n    - deprecate `cons` in favour of `prepend`\n    - deprecate `snoc` in favour of `append`\n  - `ReadonlyNonEmptyArray`\n    - deprecate `fold`, use `concatAll` instead\n    - deprecate `prependToAll`, use `prependAll` instead\n    - deprecate `insertAt`, Use `ReadonlyArray`'s `insertAt` instead\n    - deprecate `cons` in favour of `prepend`\n    - deprecate `snoc` in favour of `append`\n    - deprecate `uncons` in favour of `unprepend`\n    - deprecate `unsnoc` in favour of `unappend`\n    - deprecate `filter` in favour of `ReadonlyArray`'s `filter`\n    - deprecate `filterWithIndex` in favour of `ReadonlyArray`'s `filterWithIndex`\n  - `ReadonlyMap`\n    - deprecate `insertAt` in favour of `upsertAt`\n  - `ReadonlyRecord`\n    - deprecate `hasOwnProperty`, use `has` instead\n    - deprecate `insertAt` in favour of `upsertAt`\n  - `ReadonlySet`\n    - deprecate `fromArray` in favour of `fromReadonlyArray`\n  - `ReadonlyTuple`\n    - deprecate `mapLeft` in favour of `mapSnd`\n    - deprecate `map` in favour of `mapFst`\n  - `Record`\n    - deprecate `hasOwnProperty`, use `has` instead\n    - deprecate `insertAt` in favour of `upsertAt`\n    - deprecate `empty`\n  - `Ring`\n    - deprecate `getTupleRing`, use `tuple` instead\n  - `Semigroup`\n    - deprecate `semigroupAll`, use `boolean.SemigroupAll` instead\n    - deprecate `semigroupAny`, use `boolean.SemigroupAny` instead\n    - deprecate `getFunctionSemigroup`, use `function.getSemigroup` instead\n    - deprecate `semigroupString`, use `string.Semigroup` instead\n    - deprecate `semigroupSum`, use `number.SemigroupSum` instead\n    - deprecate `semigroupProduct`, use `number.SemigroupProduct` instead\n    - deprecate `fold`, use `concatAll` instead\n    - deprecate `getIntercalateSemigroup`, use `intercalate` instead\n    - deprecate `getMeetSemigroup`, use `min` instead\n    - deprecate `getJoinSemigroup`, use `max` instead\n    - deprecate `getDualSemigroup`, use `reverse` instead\n    - deprecate `getStructSemigroup`, use `struct` instead\n    - deprecate `getTupleSemigroup`, use `tuple` instead\n    - deprecate `getFirstSemigroup`, use `first` instead\n    - deprecate `getLastSemigroup`, use `last` instead\n    - deprecate `getObjectSemigroup`, use `assign` instead\n  - `Set`\n    - deprecate `subset` in favour of `isSubset`\n  - `Show`\n    - deprecate `showBoolean`, use `boolean.Show` instead\n    - deprecate `showString`, use `string.Show` instead\n    - deprecate `showNumber`, use `number.Show` instead\n    - deprecate `getStructShow`, use `struct` instead\n    - deprecate `getTupleShow`, use `tuple` instead\n  - `Strong`\n    - deprecate `splitStrong` in favour of `split`\n    - deprecate `fanout` in favour of `fanOut`\n  - `Task`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `fromTask`\n  - `TaskEither`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getTaskValidation`, use `getApplicativeTaskValidation` and `getAltTaskValidation` instead\n  - `TaskThese`\n    - deprecate `functorTaskThese` instance in favour of `Functor`\n    - deprecate `bifunctorTaskThese` instance in favour of `Bifunctor`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `toTuple` in favour of `toTuple2`\n  - `These`\n    - deprecate `toTuple` in favour of `toTuple2`\n  - `Traversable`\n    - deprecate `getTraversableComposition`, use `traverse`, `sequence` helpers instead\n  - `Tuple`\n    - deprecate `mapLeft` in favour of `mapSnd`\n    - deprecate `map` in favour of `mapFst`\n- **New Feature**\n  - add `Pointed` type class\n  - add `FromEither` type class\n  - add `FromIO` type class\n  - add `FromTask` type class\n  - add `TaskOption` module\n  - add `string` module\n  - add `number` module\n  - add `Separated` module (@YBogomolov)\n  - add `Json` module\n  - `Apply`\n    - add `ap` helper\n    - add `apS` helper\n    - add `apFirst` helper\n    - add `apSecond` helper\n    - add `getApplySemigroup`\n  - `Applicative`\n    - add `getApplicativeMonoid`\n  - `Array`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `matchLeft` alias\n    - add `matchRight` alias\n    - add `size`\n    - better `unsafeInsertAt` signature\n    - better `chunksOf` signature\n    - add `getSemigroup`\n  - `boolean`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `Eq` instance\n    - add `BooleanAlgebra` instance\n    - add `SemigroupAll` instance\n    - add `SemigroupAny` instance\n    - add `MonoidAll` instance\n    - add `MonoidAny` instance\n    - add `Ord` instance\n    - add `Show` instance\n  - `BooleanAlgebra`\n    - add `reverse`\n  - `Chain`\n    - add `bind` helper\n    - add `chainFirst` helper\n  - `Compactable`\n    - add `compact` helper\n    - add `separate` helper\n    - add `separated` constructor\n  - `Date`\n    - add `Eq` instance\n    - add `Ord` instance\n  - `Filterable`\n    - add `filter` helper\n    - add `filterMap` helper\n    - add `partition` helper\n    - add `partitionMap` helper\n  - `Foldable`\n    - add `reduce` helper\n    - add `foldaMap` helper\n    - add `reduceRight` helper\n  - `FoldableWithIndex`\n    - add `reduceWithIndex` helper\n    - add `foldaMapWithIndex` helper\n    - add `reduceRightWithIndex` helper\n  - `function`\n    - add `getBooleanAlgebra`\n    - add `getSemigroup`\n    - add `getMonoid`\n    - add `getSemiring`\n    - add `getRing`\n    - add `getEndomorphismMonoid`\n  - `Functor`\n    - add `map` helper\n    - add `bindTo` helper\n    - add `flap` derivable, #1393 (@williamareynolds)\n  - `FunctorWithIndex`\n    - add `mapWithIndex` helper\n  - `Either`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `getCompactable`\n    - add `getFilterable`\n    - add `FromEither` instance\n    - add `toUnion`, closes #1362\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `tryCatchK`\n    - add `fromOptionK`\n    - add `chainOptionK`\n  - `EitherT`\n    - split `getEitherM` into separated functions\n  - `Eq`\n    - add `getSemigroup`\n    - add `struct`\n    - add `tuple`\n  - `Identity`\n    - add `Pointed` instance\n    - add `Apply` instance\n  - `IO`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `FromIO` instance\n  - `IOEither`\n    - add `Pointed` instance\n    - add `getCompactable`\n    - add `FromIO` instance\n    - add `FromEither` instance\n    - add `tryCatchK` combinator\n    - add `toUnion`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `fromOptionK`\n    - add `chainOptionK`\n  - `Map`\n    - add `filterWithIndex` combinator\n    - add `filterMapWithIndex` combinator\n    - add `partitionWithIndex` combinator\n    - add `partitionMapWithIndex` combinator\n    - add `getTraversableWithIndex` instance\n    - add `getFoldableWithIndex` instance\n  - `Monoid`\n    - add `concatAll`\n    - add `min`\n    - add `max`\n    - add `reverse`\n    - add `struct`\n    - add `tuple`\n  - `NonEmptyArray`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `concatAll`\n    - add `isNonEmpty` guard\n    - add `fromReadonlyNonEmptyArray` constructor\n    - add `chainWithIndex` combinator\n    - add `chop`\n    - add `splitAt`\n    - add `chunksOf`\n  - `Option`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `tryCatchK`\n  - `OptionT`\n    - split `getOptionM` into separated functions\n  - `Ord`\n    - add `equalsDefault`\n    - add `reverse`\n    - add `tuple`\n  - `Ordering`\n    - add `Eq` instance\n    - add `Semigroup` instance\n    - add `Monoid` instance\n    - add `match`\n  - `Random`\n    - add `randomElem`\n  - `Reader`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - export `first`, `second`, `left`, `right`\n  - `ReaderT`\n    - split `getReaderM` into separated functions\n  - `ReaderEither`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `FromEither` instance\n    - add `getCompactable`\n    - add `getFilterable`\n    - add `toUnion`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `fromOptionK`\n    - add `chainOptionK`\n  - `ReaderTask`\n    - add `Pointed` instance\n    - add `ApplyPar` instance\n    - add `ApplySeq` instance\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `traverseSeqArrayWithIndex`\n    - add `traverseSeqArray`\n    - add `sequenceSeqArray`\n    - export `Chain` instance\n    - export `Monad` instance\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n  - `ReaderTaskEither`\n    - add `Pointed` instance\n    - add `ApplyPar` instance\n    - add `ApplySeq` instance\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `FromEither` instance\n    - add `getCompactable`\n    - add `getFilterable`\n    - add `toUnion`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `fromOptionK`\n    - add `chainOptionK`\n    - export `Chain` instance\n    - export `Monad` instance\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n    - export `MonadThrow` instance\n  - `ReadonlyArray`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `getSemigroup`\n    - add `matchLeft` instance\n    - add `matchRight` instance\n    - add `size`\n    - better `unsafeInsertAt` signature\n    - better `chunksOf` signature, closes #1407\n  - `ReadonlyMap`\n    - add `filterWithIndex` combinator\n    - add `filterMapWithIndex` combinator\n    - add `partitionWithIndex` combinator\n    - add `partitionMapWithIndex` combinator\n    - add `getFunctorWithIndex`\n    - add `getFoldable`\n    - add `getFoldableWithIndex`\n    - add `getTraversable`\n    - add `getTraversableWithIndex`\n  - `ReadonlyNonEmptyArray`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `concatAll`\n    - add `isNonEmpty`\n    - add `chainWithIndex`\n    - add `chop`\n    - add `splitAt`\n    - add `chunksOf`\n  - `ReadonlySet`\n    - add `isEmpty`\n    - add `size`\n    - add `toggle`\n  - `Ring`\n    - add `tuple`\n  - `Set`\n    - add `isEmpty`\n    - add `size`\n  - `Semigroup`\n    - add `constant`\n    - add `concatAll`\n    - add `intercalate`\n    - add `min`\n    - add `max`\n    - add `struct`\n    - add `tuple`\n    - add `first`\n    - add `last`\n    - add `assign`\n  - `Show`\n    - add `struct`\n    - add `tuple`\n  - `State`\n    - add `Pointed` instance\n    - add `Apply` instance\n  - `StateT`\n    - split `getStateM` into separated functions\n  - `StateReaderTaskEither`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `Monad` instance\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `FromEither` instance\n    - add `fromOptionK`\n    - add `chainOptionK`\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n    - export `MonadThrow` instance\n  - `Task`\n    - add `Pointed` instance\n    - add `ApplyPar` instance\n    - add `ApplySeq` instance\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - export `Chain` instance\n    - export `Monad` instance\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n  - `TaskEither`\n    - add `Pointed` instance\n    - add `ApplyPar` instance\n    - add `ApplySeq` instance\n    - add `getCompactable`\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `FromEither` instance\n    - add `toUnion`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `fromOptionK`\n    - add `chainOptionK`\n    - export `Chain` instance\n    - export `Monad` instance\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n    - export `MonadThrow` instance\n  - `TaskThese`\n    - add `Functor` instance\n    - add `Pointed` instance\n    - add `Bifunctor` instance\n    - add `toTuple2`\n    - add `getApply`\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `fromEither` function\n    - add `FromEither` instance\n    - add `getChain` instance\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `fromOption`\n    - add `fromOptionK`\n    - add `fromPredicate`\n  - `These`\n    - add `Pointed` instance\n    - add `of` function\n    - add `getApply`\n    - add `toTuple2`\n    - add `FromEither` instance\n    - add `fromOption` constructor\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `fromOptionK`\n  - `TaskOption`\n    - export `Chain` instance\n    - export `Monad` instance\n  - `TheseT`\n    - split `getTheseM` into separated functions\n  - `Traversable`\n    - add `traverse` helper\n    - add `sequence` helper\n  - `Tree`\n    - add `Pointed` instance\n    - add `Apply` instance\n  - `Writer`\n    - add `getPointed`\n    - add `getApply`\n    - add `getApplicative`\n    - add `getChain`\n- **Bug Fix**\n  - `ReadonlyRecord` / `Record`: remove `extends string` constraints in `singleton` / `insertAt`, closes #1413\n  - `TaskOption`\n    - fix `getOrElseW` signature\n- **Internal**\n  - add `internal` module\n- **Polish**\n  - the scope in `bindTo`, `bind`, `bindW`, `apS`, `apSW` is now correctly `readonly`\n  - fix `FromEither` type parameter order\n  - `Array` / `ReadonlyArray`\n    - assert arrays as non-empty when using `some`, #1424 (@thewilkybarkid)\n    - fix `matchLeft`, `matchRight` type parameter order\n  - `EitherT`\n    - add overloads for `Kind2`, `Kind3`, `Kind4`\n  - `OptionT`\n    - add overloads for `Kind2`, `Kind3`, `Kind4`\n  - `ReaderT`\n    - add overloads for `Kind2`, `Kind3`, `Kind4`\n  - `ReadonlyMap`\n    - sort keys in `getShow`\n  - `ReadonlySet`\n    - sort keys in `getShow`\n  - `StateT`\n    - add overloads for `Kind2`, `Kind3`\n  - `TheseT`\n    - add overloads for `Kind2`, `Kind3`, `Kind4`\n\n# 2.10.0-rc.8\n\n- **Polish**\n  - the scope in `bindTo`, `bind`, `bindW`, `apS`, `apSW` is now correctly `readonly`\n  - fix `FromEither` type parameter order\n\n# 2.10.0-rc.7\n\n- **Breaking Change** (with respect to `2.10.0-rc`)\n  - rename module `object` to `struct`\n\n# 2.10.0-rc.6\n\n- **Bug Fix**\n  - `ReadonlyNonEmptyArray`\n    - remove circular dependency on `NonEmptyArray`, closes #1443\n- **Breaking Change** (with respect to `2.10.0-rc`)\n  - `EitherT`\n    - rename `match` to `matchE` and add `match`\n  - `IOEither`\n    - rename `match` / `matchW` to `matchE` / `matchWE` and add `match` / `matchW`\n  - `OptionT`\n    - rename `match` to `matchE` and add `match`\n  - `ReaderEither`\n    - rename `match` / `matchW` to `matchE` / `matchWE` and add `match` / `matchW`\n  - `ReaderTaskEither`\n    - rename `match` / `matchW` to `matchE` / `matchWE` and add `match` / `matchW`\n  - `TheseT`\n    - rename `match` to `matchE` and add `match`\n  - `TaskEither`\n    - rename `match` / `matchW` to `matchE` / `matchWE` and add `match` / `matchW`\n  - `TaskOption`\n    - rename `match` / `matchW` to `matchE` / `matchWE` and add `match` / `matchW`\n  - `TaskThese`\n    - rename `match` / `matchW` to `matchE` / `matchWE` and add `match` / `matchW`\n\n# 2.10.0-rc.5\n\n- **Bug Fix**\n  - `TaskOption`\n    - fix `getOrElseW` signature\n- **Breaking Change** (with respect to `2.10.0-rc`)\n  - `OptionT`\n    - rename `none` to `zero` and change signature\n  - `ReaderT`\n    - remove `ask`, `asks` (they will be derived from the `FromReader` type-class in `2.11`)\n  - `Semigroup`\n    - move `assign` to `object` module and rename to `getAssignSemigroup`\n  - `ReaderT`\n    - remove `get`, `put`, `modify`, `gets` (they will be derived from the `FromState` type-class in `2.11`)\n- **Deprecation**\n  - `Tuple`\n    - deprecate `mapLeft` in favour of `mapSnd`\n    - deprecate `map` in favour of `mapFst`\n  - `ReadonlyTuple`\n    - deprecate `mapLeft` in favour of `mapSnd`\n    - deprecate `map` in favour of `mapFst`\n- **Polish**\n  - `Array` / `ReadonlyArray`\n    - assert arrays as non-empty when using `some`, #1424 (@thewilkybarkid)\n    - fix `matchLeft`, `matchRight` type parameter order\n  - `EitherT`\n    - add overloads for `Kind2`, `Kind3`, `Kind4`\n  - `OptionT`\n    - add overloads for `Kind2`, `Kind3`, `Kind4`\n  - `ReaderT`\n    - add overloads for `Kind2`, `Kind3`, `Kind4`\n  - `ReadonlyMap`\n    - sort keys in `getShow`\n  - `ReadonlySet`\n    - sort keys in `getShow`\n  - `StateT`\n    - add overloads for `Kind2`, `Kind3`\n  - `TheseT`\n    - add overloads for `Kind2`, `Kind3`, `Kind4`\n- **Internal**\n  - add `internal` module\n\n# 2.10.0-rc.4\n\n- **Deprecations**\n  - `Array`\n    - deprecate `empty`\n  - `Map`\n    - deprecate `empty`\n  - `NonEmptyArray`\n    - deprecate `filter` in favour of `Array`'s `filter`\n    - deprecate `filterWithIndex` in favour of `Array`'s `filterWithIndex`\n  - `ReadonlyNonEmptyArray`\n    - deprecate `filter` in favour of `ReadonlyArray`'s `filter`\n    - deprecate `filterWithIndex` in favour of `ReadonlyArray`'s `filterWithIndex`\n  - `Record`\n    - deprecate `empty`\n- **Polish**\n  - `NonEmptyArray`\n    - remove duplicated `append`, `prepend`, `isNonEmpty`\n  - `ReadonlyNonEmptyArray`\n    - remove duplicated `append`, `prepend`, `isNonEmpty`\n\n# 2.10.0-rc.3\n\n- **Deprecations**\n  - `Array`\n    - deprecate `cons` in favour of `prepend`\n    - deprecate `snoc` in favour of `append`\n  - `Ordering`\n    - deprecate `invert` in favour of `reverse`\n  - `ReadonlyMap`\n    - deprecate `insertAt` in favour of `upsertAt`\n  - `ReadonlyRecord`\n    - deprecate `insertAt` in favour of `upsertAt`\n  - `Map`\n    - deprecate `insertAt` in favour of `upsertAt`\n  - `NonEmptyArray`\n    - deprecate `cons` in favour of `prepend`\n    - deprecate `snoc` in favour of `append`\n    - deprecate `uncons` in favour of `unprepend`\n    - deprecate `unsnoc` in favour of `unappend`\n  - `Record`\n    - deprecate `insertAt` in favour of `upsertAt`\n  - `ReadonlyArray`\n    - deprecate `cons` in favour of `prepend`\n    - deprecate `snoc` in favour of `append`\n  - `ReadonlyNonEmptyArray`\n    - deprecate `insertAt`, Use `ReadonlyArray`'s `insertAt` instead\n    - deprecate `cons` in favour of `prepend`\n    - deprecate `snoc` in favour of `append`\n    - deprecate `uncons` in favour of `unprepend`\n    - deprecate `unsnoc` in favour of `unappend`\n  - `ReadonlySet`\n    - deprecate `fromArray` in favour of `fromReadonlyArray`\n  - `Set`\n    - deprecate `subset` in favour of `isSubset`\n- **New Feature**\n  - `Array`\n    - add `size`\n    - better `unsafeInsertAt` signature\n    - better `chunksOf` signature\n    - add `getSemigroup`\n  - `Map`\n    - add `filterWithIndex` combinator\n    - add `filterMapWithIndex` combinator\n    - add `partitionWithIndex` combinator\n    - add `partitionMapWithIndex` combinator\n    - add `getTraversableWithIndex` instance\n    - add `getFoldableWithIndex` instance\n  - `NonEmptyArray`\n    - add `isNonEmpty` guard\n    - add `fromReadonlyNonEmptyArray` constructor\n    - add `chainWithIndex` combinator\n    - add `chop`\n    - add `splitAt`\n    - add `chunksOf`\n  - `Ordering`\n    - add `match`\n  - `ReadonlyArray`\n    - add `size`\n    - better `unsafeInsertAt` signature\n    - better `chunksOf` signature, closes #1407\n  - `ReadonlyNonEmptyArray`\n    - add `isNonEmpty`\n    - add `chainWithIndex`\n    - add `chop`\n    - add `splitAt`\n    - add `chunksOf`\n  - `ReadonlySet`\n    - add `isEmpty`\n    - add `size`\n    - add `toggle`\n  - `Set`\n    - add `isEmpty`\n    - add `size`\n  - `string`\n    - add `empty`\n    - add `isEmpty`\n    - add `size`\n- **Bug Fix**\n  - `ReadonlyRecord` / `Record`: remove `extends string` constraints in `singleton` / `insertAt`, closes #1413\n\n# 2.10.0-rc.2\n\n- **Deprecations**\n  - `Choice`\n    - deprecate `splitChoice` in favour of `split`\n    - deprecate `fanin` in favour of `fanIn`\n  - `Strong`\n    - deprecate `splitStrong` in favour of `split`\n    - deprecate `fanout` in favour of `fanOut`\n- **New Feature**\n  - `Reader`\n    - export `first`, `second`, `left`, `right`\n  - `ReaderTask`\n    - export `Chain` instance\n    - export `Monad` instance\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n  - `ReaderTaskEither`\n    - export `Chain` instance\n    - export `Monad` instance\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n    - export `MonadThrow` instance\n  - `StateReaderTaskEither`\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n    - export `MonadThrow` instance\n  - `Task`\n    - export `Chain` instance\n    - export `Monad` instance\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n  - `TaskEither`\n    - export `Chain` instance\n    - export `Monad` instance\n    - export `MonadIO` instance\n    - export `MonadTask` instance\n    - export `MonadThrow` instance\n  - `TaskOption`\n    - export `Chain` instance\n    - export `Monad` instance\n- **Polish**\n  - `Compactable`\n    - split `compact` / `separate` constraints\n\n# 2.10.0-rc.1\n\n- **Deprecations**\n  - deprecate `pipeable` module, use the specific helpers instead\n  - deprecate `ValidationT` module, use `EitherT` instead\n  - deprecate \"mega instances\", use small, specific instances instead\n  - deprecate the old monad transformers, use the specific helpers instead\n  - `Applicative`\n    - deprecate `getApplicativeComposition`, use `ap` helper instead\n  - `Array`\n    - deprecate `prependToAll`, use `prependAll` instead\n  - `BooleanAlgebra`\n    - deprecate `booleanAlgebraBoolean`, use `boolean.BooleanAlgebra` instead\n    - deprecate `getFunctionBooleanAlgebra`, use `function.getBooleanAlgebra` instead\n    - deprecate `getDualBooleanAlgebra`, use `reverse` instead\n  - `Bounded`\n    - deprecate `boundedNumber`, use `number.Bounded` instead\n  - `Compactable`\n    - deprecate `getCompactableComposition`, use `compact`, `separate` helpers instead\n    - deprecate `Separated`, use `Separated.Separated` instead\n  - `Either`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getValidationSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getValidationMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getValidation`, use `getApplicativeValidation` and `getAltValidation` instead\n    - deprecate `Json` type, use the `Json` module instead\n    - deprecate `parseJSON` type, use the `Json` module instead\n    - deprecate `stringifyJSON` type, use the `Json` module instead\n  - `Eq`\n    - deprecate `eqBoolean`, use `boolean.Eq` instead\n    - deprecate `eqString`, use `string.Eq` instead\n    - deprecate `eqNumber`, use `number.Eq` instead\n    - deprecate `eqDate`, use `Date.Eq` instead\n    - deprecate `getStructEq`, use `struct` instead\n    - deprecate `getTupleEq`, use `tuple` instead\n  - `Filterable`\n    - deprecate `getFilterableComposition`, use `filter`, `filterMap`, `partition`, `partitionMap` helpers instead\n  - `Foldable`\n    - deprecate `toArray` in favour of `toReadonlyArray`\n    - deprecate `getFoldableComposition`, use `reduce`, `foldMap`, `reduceRight` helpers instead\n  - `FoldableWithIndex`\n    - deprecate `getFoldableWithIndexComposition`, use `reduceWithIndex`, `foldMapWithIndex`, `reduceRightWithIndex` helpers instead\n  - `Functor`\n    - deprecate `getFunctorComposition`, use `map` helper instead\n  - `FunctorWithIndex`\n    - deprecate `getFunctorWithIndexComposition`, use `mapWithIndex` helper instead\n  - `IO`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `fromIO`\n  - `IOEither`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getIOValidation`, use `getApplicativeIOValidation` and `getAltIOValidation` instead\n  - `Monoid`\n    - deprecate `monoidAll`, use `boolean.MonoidAll` instead\n    - deprecate `monoidAny`, use `boolean.MonoidAny` instead\n    - deprecate `getFunctionMonoid`, use `function.getMonoid` instead\n    - deprecate `getEndomorphismMonoid`, use `function.getEndomorphismMonoid` instead (**Note**. The execution order in\n      `function.getEndomorphismMonoid` is reversed)\n    - deprecate `monoidString`, use `string.Monoid` instead\n    - deprecate `monoidSum`, use `number.MonoidSum` instead\n    - deprecate `monoidProduct`, use `number.MonoidProduct` instead\n    - deprecate `fold`, use `concatAll` instead\n    - deprecate `getMeetMonoid`, use `min` instead\n    - deprecate `getJoinMonoid`, use `max` instead\n    - deprecate `getDualMonoid`, use `reverse` instead\n    - deprecate `getStructMonoid`, use `struct` instead\n    - deprecate `getTupleMonoid`, use `tuple` instead\n  - `NonEmptyArray`\n    - deprecate `fold`, use `concatAll` instead\n    - deprecate `prependToAll`, use `prependAll` instead\n  - `Option`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n  - `Ord`\n    - deprecate `ordBoolean`, use `boolean.Ord` instead\n    - deprecate `ordString`, use `string.Ord` instead\n    - deprecate `ordNumber`, use `number.Ord` instead\n    - deprecate `ordDate`, use `Date.Ord` instead\n    - deprecate `getDualOrd`, use `reverse` instead\n    - deprecate `getTupleOrd`, use `tuple` instead\n  - `Ordering`\n    - deprecate `eqOrdering`, use `Eq` instead\n    - deprecate `monoidOrdering`, use `Monoid` instead\n  - `Ring`\n    - deprecate `getFunctionRing`, use `function.getRing` instead\n  - `Reader`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getMonoid` in favour of `Applicative.getApplicativeMonoid`\n  - `ReaderEither`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getReaderValidation`, use `getApplicativeReaderValidation` and `getAltReaderValidation` instead\n    - deprecate `local`, Use `Reader`'s `local` instead\n  - `ReaderTask`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `run`\n    - deprecate `local`, Use `Reader`'s `local` instead\n  - `ReaderTaskEither`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getReaderTaskValidation`, use `getApplicativeReaderTaskValidation` and `getAltReaderTaskValidation` instead\n    - deprecate `run`\n    - deprecate `local`, Use `Reader`'s `local` instead\n  - `ReaderTaskEither`\n    - deprecate `run`\n  - `ReadonlyArray`\n    - deprecate `prependToAll`, use `prependAll` instead\n  - `ReadonlyNonEmptyArray`\n    - deprecate `fold`, use `concatAll` instead\n    - deprecate `prependToAll`, use `prependAll` instead\n  - `ReadonlyRecord`\n    - deprecate `hasOwnProperty`, use `has` instead\n  - `Record`\n    - deprecate `hasOwnProperty`, use `has` instead\n  - `Ring`\n    - deprecate `getTupleRing`, use `tuple` instead\n  - `Semigroup`\n    - deprecate `semigroupAll`, use `boolean.SemigroupAll` instead\n    - deprecate `semigroupAny`, use `boolean.SemigroupAny` instead\n    - deprecate `getFunctionSemigroup`, use `function.getSemigroup` instead\n    - deprecate `semigroupString`, use `string.Semigroup` instead\n    - deprecate `semigroupSum`, use `number.SemigroupSum` instead\n    - deprecate `semigroupProduct`, use `number.SemigroupProduct` instead\n    - deprecate `fold`, use `concatAll` instead\n    - deprecate `getIntercalateSemigroup`, use `intercalate` instead\n    - deprecate `getMeetSemigroup`, use `min` instead\n    - deprecate `getJoinSemigroup`, use `max` instead\n    - deprecate `getDualSemigroup`, use `reverse` instead\n    - deprecate `getStructSemigroup`, use `struct` instead\n    - deprecate `getTupleSemigroup`, use `tuple` instead\n    - deprecate `getFirstSemigroup`, use `first` instead\n    - deprecate `getLastSemigroup`, use `last` instead\n    - deprecate `getObjectSemigroup`, use `assign` instead\n  - `Show`\n    - deprecate `showBoolean`, use `boolean.Show` instead\n    - deprecate `showString`, use `string.Show` instead\n    - deprecate `showNumber`, use `number.Show` instead\n    - deprecate `getStructShow`, use `struct` instead\n    - deprecate `getTupleShow`, use `tuple` instead\n  - `Task`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `fromTask`\n  - `TaskEither`\n    - deprecate `getApplySemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getApplyMonoid` in favour of `Applicative.getApplicativeMonoid`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `getTaskValidation`, use `getApplicativeTaskValidation` and `getAltTaskValidation` instead\n  - `TaskThese`\n    - deprecate `functorTaskThese` instance in favour of `Functor`\n    - deprecate `bifunctorTaskThese` instance in favour of `Bifunctor`\n    - deprecate `getSemigroup` in favour of `Apply.getApplySemigroup`\n    - deprecate `toTuple` in favour of `toTuple2`\n  - `These`\n    - deprecate `toTuple` in favour of `toTuple2`\n  - `Traversable`\n    - deprecate `getTraversableComposition`, use `traverse`, `sequence` helpers instead\n- **New Feature**\n  - add `Pointed` type class\n  - add `FromEither` type class\n  - add `FromIO` type class\n  - add `FromTask` type class\n  - add `TaskOption` module\n  - add `string` module\n  - add `number` module\n  - add `Separated` module (@YBogomolov)\n  - add `Json` module\n  - `Apply`\n    - add `ap` helper\n    - add `apS` helper\n    - add `apFirst` helper\n    - add `apSecond` helper\n    - add `getApplySemigroup`\n  - `Applicative`\n    - add `getApplicativeMonoid`\n  - `Array`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `matchLeft` alias\n    - add `matchRight` alias\n  - `boolean`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `Eq` instance\n    - add `BooleanAlgebra` instance\n    - add `SemigroupAll` instance\n    - add `SemigroupAny` instance\n    - add `MonoidAll` instance\n    - add `MonoidAny` instance\n    - add `Ord` instance\n    - add `Show` instance\n  - `BooleanAlgebra`\n    - add `reverse`\n  - `Chain`\n    - add `bind` helper\n    - add `chainFirst` helper\n  - `Compactable`\n    - add `compact` helper\n    - add `separate` helper\n    - add `separated` constructor\n  - `Date`\n    - add `Eq` instance\n    - add `Ord` instance\n  - `Filterable`\n    - add `filter` helper\n    - add `filterMap` helper\n    - add `partition` helper\n    - add `partitionMap` helper\n  - `Foldable`\n    - add `reduce` helper\n    - add `foldaMap` helper\n    - add `reduceRight` helper\n  - `FoldableWithIndex`\n    - add `reduceWithIndex` helper\n    - add `foldaMapWithIndex` helper\n    - add `reduceRightWithIndex` helper\n  - `function`\n    - add `getBooleanAlgebra`\n    - add `getSemigroup`\n    - add `getMonoid`\n    - add `getSemiring`\n    - add `getRing`\n    - add `getEndomorphismMonoid`\n  - `Functor`\n    - add `map` helper\n    - add `bindTo` helper\n    - add `flap` derivable, #1393 (@williamareynolds)\n  - `FunctorWithIndex`\n    - add `mapWithIndex` helper\n  - `Either`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `getCompactable`\n    - add `getFilterable`\n    - add `FromEither` instance\n    - add `toUnion`, closes #1362\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `tryCatchK`\n    - add `fromOptionK`\n    - add `chainOptionK`\n  - `EitherT`\n    - split `getEitherM` into separated functions\n  - `Eq`\n    - add `getSemigroup`\n    - add `struct`\n    - add `tuple`\n  - `Identity`\n    - add `Pointed` instance\n    - add `Apply` instance\n  - `IO`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `FromIO` instance\n  - `IOEither`\n    - add `Pointed` instance\n    - add `getCompactable`\n    - add `FromIO` instance\n    - add `FromEither` instance\n    - add `tryCatchK` combinator\n    - add `toUnion`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `fromOptionK`\n    - add `chainOptionK`\n  - `Monoid`\n    - add `concatAll`\n    - add `min`\n    - add `max`\n    - add `reverse`\n    - add `struct`\n    - add `tuple`\n  - `NonEmptyArray`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `concatAll`\n  - `Option`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `tryCatchK`\n  - `OptionT`\n    - split `getOptionM` into separated functions\n  - `Ord`\n    - add `equalsDefault`\n    - add `reverse`\n    - add `tuple`\n  - `Ordering`\n    - add `Eq` instance\n    - add `Semigroup` instance\n    - add `Monoid` instance\n  - `Random`\n    - add `randomElem`\n  - `Reader`\n    - add `Pointed` instance\n    - add `Apply` instance\n  - `ReaderT`\n    - split `getReaderM` into separated functions\n  - `ReaderEither`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `FromEither` instance\n    - add `getCompactable`\n    - add `getFilterable`\n    - add `toUnion`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `fromOptionK`\n    - add `chainOptionK`\n  - `ReaderTask`\n    - add `Pointed` instance\n    - add `ApplyPar` instance\n    - add `ApplySeq` instance\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `traverseSeqArrayWithIndex`\n    - add `traverseSeqArray`\n    - add `sequenceSeqArray`\n  - `ReaderTaskEither`\n    - add `Pointed` instance\n    - add `ApplyPar` instance\n    - add `ApplySeq` instance\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `FromEither` instance\n    - add `getCompactable`\n    - add `getFilterable`\n    - add `toUnion`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `fromOptionK`\n    - add `chainOptionK`\n  - `ReadonlyArray`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `getSemigroup`\n    - add `matchLeft` instance\n    - add `matchRight` instance\n  - `ReadonlyMap`\n    - add `filterWithIndex` combinator\n    - add `filterMapWithIndex` combinator\n    - add `partitionWithIndex` combinator\n    - add `partitionMapWithIndex` combinator\n    - add `getFunctorWithIndex`\n    - add `getFoldable`\n    - add `getFoldableWithIndex`\n    - add `getTraversable`\n    - add `getTraversableWithIndex`\n  - `ReadonlyNonEmptyArray`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `concatAll`\n  - `Ring`\n    - add `tuple`\n  - `Semigroup`\n    - add `constant`\n    - add `concatAll`\n    - add `intercalate`\n    - add `min`\n    - add `max`\n    - add `struct`\n    - add `tuple`\n    - add `first`\n    - add `last`\n    - add `assign`\n  - `Show`\n    - add `struct`\n    - add `tuple`\n  - `State`\n    - add `Pointed` instance\n    - add `Apply` instance\n  - `StateT`\n    - split `getStateM` into separated functions\n  - `StateReaderTaskEither`\n    - add `Pointed` instance\n    - add `Apply` instance\n    - add `Monad` instance\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `FromEither` instance\n    - add `fromOptionK`\n    - add `chainOptionK`\n  - `Task`\n    - add `Pointed` instance\n    - add `ApplyPar` instance\n    - add `ApplySeq` instance\n    - add `FromIO` instance\n    - add `FromTask` instance\n  - `TaskEither`\n    - add `Pointed` instance\n    - add `ApplyPar` instance\n    - add `ApplySeq` instance\n    - add `getCompactable`\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `FromEither` instance\n    - add `toUnion`\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `orElseW`\n    - add `fromOptionK`\n    - add `chainOptionK`\n  - `TaskThese`\n    - add `Functor` instance\n    - add `Pointed` instance\n    - add `Bifunctor` instance\n    - add `toTuple2`\n    - add `getApply`\n    - add `FromIO` instance\n    - add `FromTask` instance\n    - add `fromEither` function\n    - add `FromEither` instance\n    - add `getChain` instance\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `fromOption`\n    - add `fromOptionK`\n    - add `fromPredicate`\n  - `These`\n    - add `Pointed` instance\n    - add `of` function\n    - add `getApply`\n    - add `toTuple2`\n    - add `FromEither` instance\n    - add `fromOption` constructor\n    - add `foldW`\n    - add `match` alias\n    - add `matchW` alias\n    - add `fromOptionK`\n  - `TheseT`\n    - split `getTheseM` into separated functions\n  - `Traversable`\n    - add `traverse` helper\n    - add `sequence` helper\n  - `Tree`\n    - add `Pointed` instance\n    - add `Apply` instance\n  - `Writer`\n    - add `getPointed`\n    - add `getApply`\n    - add `getApplicative`\n    - add `getChain`\n\n# 2.9.5\n\n- **Polish**\n  - `Array`, `ReadonlyArray`: change `scanLeft` and `scanRight` to return `NonEmptyArray`, `ReadonlyNonEmptyArray`, #1391 (@willheslam)\n\n# 2.9.4\n\n- **Bug Fix**\n  - fix `filter` overloads in `NonEmptyArray` / `ReadonlyNonEmptyArray`, closes #1388 (@gcanti)\n\n# 2.9.3\n\n- **Polish**\n  - add more `/*#__PURE__*/` comments to improve tree shaking, #1370 (@OliverJAsh)\n\n# 2.9.2\n\n- **Polish**\n  - add more `/*#__PURE__*/` comments to improve tree shaking, #1368 (@OliverJAsh)\n\n# 2.9.1\n\n- **Polish**\n  - `Array` / `ReadonlyArray`\n    - `sort`: return the input when length <= 1, closes #1357 (@gcanti)\n    - `uniq`: return the input when length <= 1 (@gcanti)\n\n# 2.9.0\n\n- **New Feature**\n\n  - `Array`\n    - add `altW` (@gcanti)\n    - add `intersperse` (@marcotoniut)\n    - add `prependToAll` (@marcotoniut)\n    - add `every` (@gcanti)\n    - add `some` (@gcanti)\n    - add `Do` (@gcanti)\n  - `Either`\n    - add `altW` (@gcanti)\n    - add `fromNullableK` (@gcanti)\n    - add `chainNullableK` (@gcanti)\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n    - add `filterOrElseW` (@gcanti)\n  - `Identity`\n    - add `altW` (@gcanti)\n    - add `Do` (@gcanti)\n  - `IO`\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n  - `IOEither`\n    - add `altW` (@gcanti)\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `traverseSeqArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseSeqArray` (@mohaalak @iamomiid)\n    - add `sequenceSeqArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n    - add `filterOrElseW` (@gcanti)\n  - `NonEmptyArray`\n    - add `altW` (@gcanti)\n    - add `uncons` (@marcotoniut)\n    - add `unsnoc` (@marcotoniut)\n    - add `intersperse` (@marcotoniut)\n    - add `prependToAll` (@marcotoniut)\n    - add `Do` (@gcanti)\n  - `Option`\n    - add `altW` (@gcanti)\n    - add `fromNullableK` (@gcanti)\n    - add `chainNullableK` (@gcanti)\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n  - `Reader`\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n  - `ReaderEither`\n    - add `altW` (@gcanti)\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n    - add `filterOrElseW` (@gcanti)\n  - `ReaderTask`\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `traverseSeqArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseSeqArray` (@mohaalak @iamomiid)\n    - add `sequenceSeqArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n  - `ReaderTaskEither`\n    - add `altW` (@gcanti)\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `traverseSeqArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseSeqArray` (@mohaalak @iamomiid)\n    - add `sequenceSeqArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n    - add `filterOrElseW` (@gcanti)\n  - `ReadonlyArray`\n    - add `altW` (@gcanti)\n    - add `intersperse` (@marcotoniut)\n    - add `prependToAll` (@marcotoniut)\n    - add `every` (@gcanti)\n    - add `some` (@gcanti)\n    - add `Do` (@gcanti)\n  - `ReadonlyNonEmptyArray`\n    - add `altW` (@gcanti)\n    - add `uncons` (@marcotoniut)\n    - add `unsnoc` (@marcotoniut)\n    - add `intersperse` (@marcotoniut)\n    - add `prependToAll` (@marcotoniut)\n    - add `Do` (@gcanti)\n  - `State`\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n  - `StateReaderTaskEither`\n    - add `altW` (@gcanti)\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `filterOrElseW` (@gcanti)\n  - `Task`\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `traverseSeqArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseSeqArray` (@mohaalak @iamomiid)\n    - add `sequenceSeqArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n  - `TaskEither`\n    - add `altW` (@gcanti)\n    - add `traverseArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseArray` (@mohaalak @iamomiid)\n    - add `sequenceArray` (@mohaalak @iamomiid)\n    - add `traverseSeqArrayWithIndex` (@mohaalak @iamomiid)\n    - add `traverseSeqArray` (@mohaalak @iamomiid)\n    - add `sequenceSeqArray` (@mohaalak @iamomiid)\n    - add `Do` (@gcanti)\n    - add `filterOrElseW` (@gcanti)\n  - `Tree`\n    - add `Do` (@gcanti)\n\n- **Deprecation**\n  - `Option`\n    - deprecate `mapNullable` in favour of `chainNullableK` (@gcanti)\n  - `StateReaderTaskEither`\n    - deprecate `stateReaderTaskEitherSeq` because is useless, `stateReaderTaskEither` is already sequential (@gcanti)\n\n# 2.8.6\n\n- **Bug Fix**\n  - fix #1350 (@gcanti)\n\n# 2.8.5\n\n- **Polish**\n  - `IOEither`\n    - export missing `of` function (@gcanti)\n  - `ReaderEither`\n    - export missing `of` function (@gcanti)\n\n# 2.8.4\n\n- **Polish**\n  - `IOEither`\n    - add `ApplicativePar` instance (@gcanti)\n    - add `ApplicativeSeq` instance (@gcanti)\n- **Deprecation**\n  - `IOEither`\n    - deprecate `Applicative` in favour of `ApplicativePar` (@gcanti)\n\n# 2.8.3\n\n- **Polish**\n  - `Reader`\n    - export `Strong` instance (@urgent)\n    - export `Choice` instance (@gcanti)\n\n# 2.8.2\n\n- **Polish**\n  - increase the supported number of arguments of pipe function (@heka1024)\n- **Bug fix**\n  - revert `groupBy` change in #1286 (@gcanti)\n- **Internal**\n  - define all non-pipeable internal functions in terms of the corresponding pipeable versions (@gcanti)\n\n# 2.8.1\n\n- **Polish**\n  - fix `HKT` typings duplication (which might break module augmentation)\n\n# 2.8.0\n\n- **New Feature**\n  - expose `fp-ts` modules without lib/es6 prefix, #1241 (@StefanoMagrassi)\n  - `Array`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n  - `Either`\n    - add `apW` (@gcanti)\n    - add `apS` (@gcanti)\n    - add `apSW` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - add `bindW` (@gcanti)\n    - add `chainFirstW`, #1273 (@leemhenson)\n    - add `getFilterable` (@gcanti)\n  - `Foldable`\n    - add `toArray`, #1272 (@newswim)\n    - add `reduceM` (@gcanti)\n  - `Identity`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n  - `IO`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n  - `IOEither`\n    - add `apS` (@gcanti)\n    - add `apSW` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - add `bindW` (@gcanti)\n    - add `chainFirstW`, #1273 (@leemhenson)\n  - `NonEmptyArray`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - relax `group` signature (@gcanti)\n    - relax `groupBy` signature (@gcanti)\n    - relax `groupSort` signature (@gcanti)\n    - relax `sort` signature (@gcanti)\n  - `Option`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n  - `Reader`\n    - add `apW` (@gcanti)\n    - add `apS` (@gcanti)\n    - add `apSW` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - add `bindW` (@gcanti)\n  - `ReaderEither`\n    - add `apS` (@gcanti)\n    - add `apSW` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - add `bindW` (@gcanti)\n    - add `chainFirstW`, #1273 (@leemhenson)\n  - `ReaderTask`\n    - add `apS` (@gcanti)\n    - add `apSW` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - add `bindW` (@gcanti)\n  - `ReaderTaskEither`\n    - add `apS` (@gcanti)\n    - add `apSW` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - add `bindW` (@gcanti)\n    - add `chainFirstW`, #1273 (@leemhenson)\n  - `ReadonlyArray`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n  - `ReadonlyNonEmptyArray`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - relax `group` signature (@gcanti)\n    - relax `groupBy` signature (@gcanti)\n    - relax `groupSort` signature (@gcanti)\n    - relax `sort` signature (@gcanti)\n  - `State`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - add `evaluate` (@gcanti)\n    - add `execute` (@gcanti)\n  - `StateReaderTaskEither`\n    - add `apS` (@gcanti)\n    - add `apSW` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - add `bindW` (@gcanti)\n    - add `chainFirstW`, #1273 (@leemhenson)\n    - add `evaluate` (@gcanti)\n    - add `execute` (@gcanti)\n  - `Task`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n  - `TaskEither`\n    - add `apS` (@gcanti)\n    - add `apSW` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n    - add `bindW` (@gcanti)\n    - add `chainFirstW`, #1273 (@leemhenson)\n  - `Tree`\n    - add `apS` (@gcanti)\n    - add `bind` (@gcanti)\n    - add `bindTo` (@gcanti)\n  - `Writer`\n    - add `evaluate` (@gcanti)\n    - add `execute` (@gcanti)\n- **Deprecation**\n  - `Foldable`\n    - deprecate `foldM` in favour of `reduceM` (@gcanti)\n  - `State`\n    - deprecate `evalState` in favour of `evaluate` (@gcanti)\n    - deprecate `execState` in favour of `execute` (@gcanti)\n  - `StateReaderTaskEither`\n    - deprecate `evalState` in favour of `evaluate` (@gcanti)\n    - deprecate `execState` in favour of `execute` (@gcanti)\n  - `Writer`\n    - deprecate `evalWriter` in favour of `evaluate` (@gcanti)\n    - deprecate `execWriter` in favour of `execute` (@gcanti)\n\n# 2.7.1\n\n- **Bug Fix**\n  - `ReadonlyArray`\n    - fix `FunctorWithIndex` instance name (@gcanti)\n    - fix `Functor` instance name (@gcanti)\n- **Polish**\n  - `Array`\n    - relax `sort` signature (@gcanti)\n    - relax `sortBy` signature (@gcanti)\n  - `Map`\n    - export `mapWithIndex` (@gcanti)\n  - `ReadonlyArray`\n    - relax `sort` signature (@gcanti)\n    - relax `sortBy` signature (@gcanti)\n  - `ReadonlyMap`\n    - export `mapWithIndex` (@gcanti)\n\n# 2.7.0\n\n- **Bug Fix**\n  - `These`\n    - fix `ap` implementation in `getMonad` function (@gcanti)\n- **Polish**\n  - improve performance of sequenceT and sequenceS, fix #1255 (@gcanti)\n- **New Feature**\n  - `function`\n    - add `hole` (type hole simulation) (@gcanti)\n  - `Array`\n    - add `chainWithIndex`, #1256 (@OliverJAsh)\n    - add `Functor` instance (@gcanti)\n    - add `FunctorWithIndex` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Unfoldable` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n    - add `Alternative` instance (@gcanti)\n    - add `Extend` instance (@gcanti)\n    - add `Compactable` instance (@gcanti)\n    - add `Filterable` instance (@gcanti)\n    - add `FilterableWithIndex` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `FoldableWithIndex` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `TraversableWithIndex` instance (@gcanti)\n    - add `Witherable` instance (@gcanti)\n  - `Const`\n    - add `Functor` instance (@gcanti)\n    - add `Contravariant` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n  - `Either`\n    - add `getApplicativeValidation` constrained instance (@gcanti)\n    - add `getAltValidation` constrained instance (@gcanti)\n    - add `Functor` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n    - add `Extend` instance (@gcanti)\n    - add `ChainRec` instance (@gcanti)\n    - add `MonadThrow` instance (@gcanti)\n  - `Eq`\n    - add `Contravariant` instance (@gcanti)\n  - `Identity`\n    - add `Functor` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n    - add `Comonad` instance (@gcanti)\n    - add `ChainRec` instance (@gcanti)\n  - `IO`\n    - add `Functor` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `MonadIO` instance (@gcanti)\n    - add `ChainRec` instance (@gcanti)\n  - `IOEither`\n    - add `getApplicativeIOValidation` constrained instance (@gcanti)\n    - add `getAltIOValidation` constrained instance (@gcanti)\n    - add `Functor` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n    - add `MonadIO` instance (@gcanti)\n    - add `MonadThrow` instance (@gcanti)\n  - `Map`\n    - add `Functor` instance (@gcanti)\n    - add `Compactable` instance (@gcanti)\n    - add `Filterable` instance (@gcanti)\n  - `NonEmptyArray`\n    - add `Functor` instance (@gcanti)\n    - add `FunctorWithIndex` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `FoldableWithIndex` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `TraversableWithIndex` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n    - add `Comonad` instance (@gcanti)\n  - `Option`\n    - add `Functor` instance (@gcanti)\n    - add `Applicativ` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n    - add `Alternative` instance (@gcanti)\n    - add `Extend` instance (@gcanti)\n    - add `Compactable` instance (@gcanti)\n    - add `Filterable` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `Witherable` instance (@gcanti)\n    - add `MonadThrow` instance (@gcanti)\n  - `Ord`\n    - add `ContravariantOrd` instance (@gcanti)\n  - `Reader`\n    - add `Functor` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Profunctor` instance (@gcanti)\n    - add `Category` instance (@gcanti)\n    - add `String` instance (@gcanti)\n    - add `Choice` instance (@gcanti)\n  - `ReaderEither`\n    - add `getApplicativeReaderValidation` constrained instance (@gcanti)\n    - add `getAltReaderValidation` constrained instance (@gcanti)\n    - add `Functor` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n    - add `MonadThrow` instance (@gcanti)\n  - `ReaderTask`\n    - add `Functor` instance (@gcanti)\n    - add `ApplicativePar` instance (@gcanti)\n    - add `ApplicativeSeq` instance (@gcanti)\n  - `ReaderTaskEither`\n    - add `getApplicativeReaderTaskValidation` constrained instance (@gcanti)\n    - add `getAltReaderTaskValidation` constrained instance (@gcanti)\n    - add `Functor` instance (@gcanti)\n    - add `ApplicativePar` instance (@gcanti)\n    - add `ApplicativeSeq` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n  - `ReadonlyArray`\n    - add `chainWithIndex`, #1256 (@OliverJAsh)\n    - add `Functor` instance (@gcanti)\n    - add `FunctorWithIndex` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Unfoldable` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n    - add `Alternative` instance (@gcanti)\n    - add `Extend` instance (@gcanti)\n    - add `Compactable` instance (@gcanti)\n    - add `Filterable` instance (@gcanti)\n    - add `FilterableWithIndex` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `FoldableWithIndex` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `TraversableWithIndex` instance (@gcanti)\n    - add `Witherable` instance (@gcanti)\n  - `ReadonlyMap`\n    - add `Functor` instance (@gcanti)\n    - add `Compactable` instance (@gcanti)\n    - add `Filterable` instance (@gcanti)\n  - `ReadonlyNonEmptyArray`\n    - add `Functor` instance (@gcanti)\n    - add `FunctorWithIndex` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `FoldableWithIndex` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `TraversableWithIndex` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n    - add `Comonad` instance (@gcanti)\n  - `ReadonlyRecord`\n    - add `Functor` instance (@gcanti)\n    - add `FunctorWithIndex` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `Compactable` instance (@gcanti)\n    - add `Filterable` instance (@gcanti)\n    - add `FilterableWithIndex` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `TraversableWithIndex` instance (@gcanti)\n    - add `Witherable` instance (@gcanti)\n  - `ReadonlyTuple`\n    - add `Functor` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n    - add `Semigroupoid` instance (@gcanti)\n    - add `Comonad` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n  - `Record`\n    - add `Functor` instance (@gcanti)\n    - add `FunctorWithIndex` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `Compactable` instance (@gcanti)\n    - add `Filterable` instance (@gcanti)\n    - add `FilterableWithIndex` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `TraversableWithIndex` instance (@gcanti)\n    - add `Witherable` instance (@gcanti)\n  - `State`\n    - add `Functor` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n  - `Store`\n    - add `Functor` instance (@gcanti)\n    - add `Comonad` instance (@gcanti)\n  - `StateReaderTaskEither`\n    - add `Functor` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n  - `Task`\n    - add `Functor` instance (@gcanti)\n    - add `ApplicativePar` instance (@gcanti)\n    - add `ApplicativeSeq` instance (@gcanti)\n  - `TaskEither`\n    - add `getApplicativeTaskValidation` constrained instance (@gcanti)\n    - add `getAltTaskValidation` constrained instance (@gcanti)\n    - add `Functor` instance (@gcanti)\n    - add `ApplicativePar` instance (@gcanti)\n    - add `ApplicativeSeq` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n    - add `Alt` instance (@gcanti)\n  - `TaskThese`\n    - add `Functor` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n  - `These`\n    - add `getApplicative` constrained instance (@gcanti)\n    - add `Functor` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n  - `Traced`\n    - rename `traced` to `Functor` for consistency (@gcanti)\n  - `Tree`\n    - add `Functor` instance (@gcanti)\n    - add `Applicative` instance (@gcanti)\n    - add `Monad` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n    - add `Comonad` instance (@gcanti)\n  - `Writer`\n    - add `Functor` instance (@gcanti)\n  - `Tuple`\n    - add `Functor` instance (@gcanti)\n    - add `Bifunctor` instance (@gcanti)\n    - add `Semigroupoid` instance (@gcanti)\n    - add `Comonad` instance (@gcanti)\n    - add `Foldable` instance (@gcanti)\n    - add `Traversable` instance (@gcanti)\n\n# 2.6.7\n\n- **Polish**\n  - refine `Either.parseJSON` return type, #1252 (@OliverJAsh)\n  - add missing `chainW` to `ReaderTask`, #1254 (@adameier)\n\n# 2.6.6\n\n- **Polish**\n  - `Array`\n    - export `unfold` (@gcanti)\n    - make `lookup` data-last (@gcanti)\n    - make `elem` data-last (@gcanti)\n    - make `difference` data-last (@gcanti)\n    - make `intersection` data-last (@gcanti)\n    - make `union` data-last (@gcanti)\n    - make `zip` data-last (@gcanti)\n    - make `cons` data-last (@gcanti)\n  - `Map`\n    - make `member` data-last (@gcanti)\n    - make `elem` data-last (@gcanti)\n    - make `lookup` data-last (@gcanti)\n    - make `lookupWithKey` data-last (@gcanti)\n    - make `isSubmap` data-last (@gcanti)\n  - `NonEmptyArray`\n    - make `zip` data-last (@gcanti)\n  - `ReadonlyArray`\n    - export `unfold` (@gcanti)\n    - make `lookup` data-last (@gcanti)\n    - make `elem` data-last (@gcanti)\n    - make `difference` data-last (@gcanti)\n    - make `intersection` data-last (@gcanti)\n    - make `union` data-last (@gcanti)\n    - make `zip` data-last (@gcanti)\n    - make `cons` data-last (@gcanti)\n  - `ReadonlyMap`\n    - make `member` data-last (@gcanti)\n    - make `elem` data-last (@gcanti)\n    - make `lookup` data-last (@gcanti)\n    - make `lookupWithKey` data-last (@gcanti)\n    - make `isSubmap` data-last (@gcanti)\n  - `ReadonlyNonEmptyArray`\n    - make `zip` data-last (@gcanti)\n  - `ReadonlyRecord`\n    - make `isSubrecord` data-last (@gcanti)\n    - make `lookup` data-last (@gcanti)\n    - make `elem` data-last (@gcanti)\n  - `ReadonlySet`\n    - make `isSubset` data-last (@gcanti)\n    - make `elem` data-last (@gcanti)\n    - make `union` data-last (@gcanti)\n    - make `intersection` data-last (@gcanti)\n    - make `difference` data-last (@gcanti)\n  - `Record`\n    - make `isSubrecord` data-last (@gcanti)\n    - make `lookup` data-last (@gcanti)\n    - make `elem` data-last (@gcanti)\n  - `Set`\n    - make `subset` data-last (@gcanti)\n    - make `elem` data-last (@gcanti)\n    - make `union` data-last (@gcanti)\n    - make `intersection` data-last (@gcanti)\n    - make `difference` data-last (@gcanti)\n  - `Semigroup`\n    - make `fold` data-last (@gcanti)\n\n# 2.6.5\n\n- **Polish**\n  - export a pipeable `wither` function from all modules which admit a `Witherable` instance (@gcanti)\n  - export a pipeable `wilt` function from all modules which admit a `Witherable` instance (@gcanti)\n\n# 2.6.4\n\n- **Bug Fix**\n  - `ReadonlyMap`\n    - `traverseWithIndex` should sort the keys (@gcanti)\n  - `ReadonlyRecord`\n    - `traverseWithIndex` should sort the keys (@gcanti)\n\n# 2.6.3\n\n- **Polish**\n  - change `ReadonlyNonEmptyArray` definition to get better type inference (@gcanti)\n  - move `pipe` to `function` module (@gcanti)\n  - export `sequence` from all modules which admit a `Traversable` instance (@gcanti)\n  - export a pipeable `traverse` function from all modules which admit a `Traversable` instance (@gcanti)\n  - export a pipeable `traverseWithIndex` function from all modules which admit a `TraversableWithIndex` instance (@gcanti)\n  - remove monad transformers imports from all modules (@gcanti)\n\n# 2.6.2\n\nThe goal of this release is to make `fp-ts` more \"tree shaking\" friendly.\n\n- **Polish**\n  - add `/*@__PURE__*/` comments to pipeables (@gcanti)\n  - add `/*@__PURE__*/` comments to transformers (@gcanti)\n  - remove `pipeable.ts` module imports (@gcanti)\n\n# 2.6.1\n\n- **New Feature**\n  - add W variants, closes #904 (@gcanti)\n  - `Const`\n    - add missing instances, #1201 (@gcanti)\n  - `Date`\n    - add `eqDate`, `eqMonth`, `eqYear` (@gcanti)\n  - `Either`\n    - add `getOrElseW` (@gcanti)\n    - add `chainW` (@gcanti)\n  - `Eq`\n    - add `getMonoid` (@gcanti)\n  - `IOEither`\n    - add `getOrElseW` (@gcanti)\n    - add `chainW` (@gcanti)\n    - add `chainEitherKW` (@giogonzo)\n  - `Option`\n    - add `getOrElseW` (@gcanti)\n  - `Reader`\n    - add `chainW` (@gcanti)\n  - `ReaderEither`\n    - add `getOrElseW` (@gcanti)\n    - add `chainW` (@gcanti)\n    - add `chainEitherKW` (@giogonzo)\n  - `ReaderTaskEither`\n    - add `getOrElseW` (@gcanti)\n    - add `chainW` (@gcanti)\n    - add `chainEitherKW` (@giogonzo)\n    - add `chainTaskEitherKW` (@giogonzo)\n    - add `chainIOEitherKW` (@giogonzo)\n  - `StateReaderTaskEither`\n    - add `chainW` (@gcanti)\n    - add `chainEitherKW` (@giogonzo)\n    - add `chainTaskEitherKW` (@giogonzo)\n    - add `chainReaderTaskEitherKW` (@giogonzo)\n    - add `chainIOEitherKW` (@giogonzo)\n  - `TaskEither`\n    - add `getOrElseW` (@gcanti)\n    - add `chainW` (@gcanti)\n    - add `chainEitherKW` (@giogonzo)\n    - add `chainIOEitherKW` (@giogonzo)\n  - `Tree`\n    - add `fold` function (@gcanti)\n\n# 2.5.4\n\n- **Polish**\n  - `StateT`\n    - add missing `StateM2C` and `StateM3C` (@qlonik)\n\n# 2.5.3\n\n- **Polish**\n  - `Either`\n    - add missing instances to `getValidation` (@gcanti)\n  - `IOEither`\n    - relax `Bifunctor2C` to `Bifunctor2` in `getIOValidation` (@gcanti)\n  - `ReaderEither`\n    - relax `Bifunctor3C` to `Bifunctor3` in `getReaderValidation` (@gcanti)\n  - `ReaderTaskEither`\n    - relax `Bifunctor3C` to `Bifunctor3` in `getReaderTaskValidation` (@gcanti)\n  - `TaskEither`\n    - relax `Bifunctor2C` to `Bifunctor2` in `getTaskValidation` (@gcanti)\n\n# 2.5.1\n\n- **New Feature**\n  - `Eq`\n    - add `eqStrict`, closes #965 (@gcanti)\n  - `NonEmptyArray`\n    - add `fold` (@vicrac)\n    - add `zip`, `zipWith` and `unzip`, closes #1109 (@gcanti)\n  - `Semigroup`\n    - add `getIntercalateSemigroup` (@gcanti)\n  - `Set`\n    - add `toggle` (@ryota-ka)\n  - `TaskEither`\n    - add `tryCatchK` (@DenisFrezzato)\n  - `These`\n    - add missing `MonadThrow` instance (@gcanti)\n  - `ReaderTaskEither`\n    - add missing `leftReaderTask`, `rightReaderTask` functions (@gcanti)\n  - `StateReaderTaskEither`\n    - add missing `Bifunctor`, `Alt` instances (@gcanti)\n- **Experimental**\n  - add `ReadonlyArray` module (@gcanti)\n  - add `ReadonlyNonEmptyArray` module (@gcanti)\n  - add `ReadonlySet` module (@gcanti)\n  - add `ReadonlyMap` module (@gcanti)\n  - add `ReadonlyRecord` module (@gcanti)\n  - add `ReadonlyTuple` module (@gcanti)\n\n# 2.4.4\n\n- **Polish**\n  - add missing `MonadIO4` (@mlegenhausen)\n  - add missing `MonadTask4` (@mlegenhausen)\n  - `StateReaderTaskEither`\n    - add missing `MonadTask4` instance (@mlegenhausen)\n    - add missing `filterOrElse`, `fromPredicate` combinators (@mlegenhausen)\n\n# 2.4.3\n\n- **Bug Fix**\n  - don't set `target: es6` in `tsconfig.build-es6.json`, fix #1110 (@gcanti)\n\n# 2.4.2\n\n- **Bug Fix**\n  - fix `Invariant` definition (@gcanti)\n\n# 2.4.1\n\n- **Polish**\n  - `NonEmptyArray`\n    - add overloading to `group` managing non empty arrays, closes #831 (@gcanti)\n    - `foldMap` and `foldMapWithIndex` now require a `Semigroup` instead of a `Monoid` (@gcanti)\n\n# 2.4.0\n\n- **New Feature**\n  - add `WriterT` module, closes #1050 (@gcanti)\n  - add `TheseT` module (@gcanti)\n  - add `TaskThese` module (@gcanti)\n  - `function`\n    - add `tupled`, `untupled` functions, closes #1062 (@gcanti)\n  - `IOEither`\n    - add `fromEitherK`, `chainEitherK` (@gcanti)\n  - `ReaderEither`\n    - add `fromEitherK`, `chainEitherK` (@gcanti)\n  - `ReaderTask`\n    - add `run` (@gcanti)\n    - add `fromIOK`, `chainIOK`, `fromTaskK`, `chainTaskK` (@gcanti)\n  - `ReaderTaskEither`\n    - add `fromEitherK`, `chainEitherK`, `fromIOEitherK`, `chainIOEitherK`, `fromTaskEitherK`, `chainTaskEitherK` (@gcanti)\n  - `These`\n    - add `swap` (@gcanti)\n  - `Ord`\n    - add `getMonoid` (@vicrac)\n  - `Ordering`\n    - add `monoidOrdering` (@gcanti)\n  - `StateReaderTaskEither`\n    - add `fromEitherK`, `chainEitherK`, `fromIOEitherK`, `chainIOEitherK`, `fromTaskEitherK`, `chainTaskEitherK`, `fromReaderTaskEitherK`, `chainReaderTaskEitherK` (@gcanti)\n  - `Task`\n    - add `fromIOK`, `chainIOK` (@gcanti)\n  - `TaskEither`\n    - add `fromEitherK`, `chainEitherK`, `fromIOEitherK`, `chainIOEitherK` (@gcanti)\n- **Deprecation**\n  - `Ord`\n    - deprecate `getSemigroup` in favor of `getMonoid` (@gcanti)\n  - `Ordering`\n    - deprecate `semigroupOrdering` in favor of `monoidOrdering` (@gcanti)\n- **Internal**\n  - use native `Promise.race` in `Task.getRaceMonoid` (@gcanti)\n\n# 2.3.1\n\n- **Bug Fix**\n  - `Array.ts`\n    - fix `sortBy` failing on empty list of ords, #1046 (@vicrac)\n\n# 2.3.0\n\n- **New Feature**\n  - add `ReaderTask` module (@sledorze)\n  - `ReaderTaskEither`\n    - add `getReaderTaskValidation` (@sledorze)\n  - `ReaderEither`\n    - add `getReaderValidation` (@gcanti)\n  - `TaskEither`\n    - improve `getTaskValidation` (@gcanti)\n  - `IOEither`\n    - improve `getIOValidation` (@gcanti)\n\n# 2.2.0\n\n- **New Feature**\n  - add `boolean` module, closes #930 (@giogonzo)\n  - add `ChainRec` instance to `IO` (@gcanti)\n  - `NonEmptyArray`\n    - add `init` (@steida)\n    - add `Alt` instance (@gcanti)\n- **Internal**\n  - add new 3C variants and related overloads (@sledorze)\n\n# 2.1.2\n\n- **Bug Fix**\n  - `fromNullable` now uses `NonNullable` in its return type, fixes #1004 (@gcanti)\n\n# 2.1.1\n\n- **Bug Fix**\n  - add `sequenceT` and `sequenceS` overload signatures for `Kind4`, fixes #969 (@pfgray)\n\n# 2.1.0\n\n- **New Feature**\n  - add constrained `Filterable` instance to `IOEither`, `TaskEither`, #959 (@giogonzo)\n\n# 2.0.5\n\n- **Bug Fix**\n  - fix `PipeableApply2C` definition (@gcanti)\n\n# 2.0.4\n\n- **Polish**\n  - `ReaderTaskEither`\n    - add missing `bracket` function (@mlegenhausen)\n\n# 2.0.3\n\n- **Bug Fix**\n  - fix `sequenceT`, `sequenceS` implementations, closes #914 (@gcanti)\n\n# 2.0.2\n\n- **Bug Fix**\n  - add `reduce` to `FoldableComposition2C1` (@anilanar)\n\n# 2.0.1\n\n- **Bug Fix**\n  - fix `PipeableBifunctor` definition (@gcanti)\n  - fix `chunksOf` implementation, #897 (@gcanti)\n\n# 2.0.0\n\n- **Breaking Change**\n  - remove deprecated APIs (@gcanti)\n  - remove classes (@gcanti)\n  - remove all phantom fields (@gcanti)\n"
  },
  {
    "path": "Do.md",
    "content": "# Do notation\n\n**Cheatsheet**\n\n| Haskell       | TypeScript                     |\n| ------------- | ------------------------------ |\n| `a <- action` | `bind('a', (scope) => action)` |\n| `_ <- action` | `tap((scope) => action)`       |\n| `return ...`  | `map((scope) => ...)`          |\n\n**Example**\n\nHaskell\n\n```Haskell\nnameDo :: IO ()\nnameDo = do putStrLn \"What is your first name? \"\n            first <- getLine\n            putStrLn \"And your last name? \"\n            last <- getLine\n            let full = first ++ \" \" ++ last\n            putStrLn (\"Pleased to meet you, \" ++ full ++ \"!\")\n```\n\nTypeScript\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as T from 'fp-ts/Task'\n\ndeclare const putStrLn: (s: string) => T.Task<void>\ndeclare const getLine: T.Task<string>\n\nconst nameDo: T.Task<void> = pipe(\n  T.Do,\n  T.tap(() => putStrLn('What is your first name? ')),\n  T.bind('first', () => getLine),\n  T.tap(() => putStrLn('And your last name? ')),\n  T.bind('last', () => getLine),\n  T.bind('full', ({ first, last }) => T.of(first + ' ' + last)),\n  T.flatMap(({ full }) => putStrLn('Pleased to meet you, ' + full + '!'))\n)\n```\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": "<h3 align=\"center\">\n  <a href=\"https://gcanti.github.io/fp-ts/\">\n    <img src=\"./docs/fp-ts-logo.png\">\n  </a>\n</h3>\n\n<p align=\"center\">\nFunctional programming in TypeScript\n</p>\n\n<p align=\"center\">\n  <a href=\"https://github.com/gcanti/fp-ts/actions\">\n    <img src=\"https://github.com/gcanti/fp-ts/actions/workflows/main.yml/badge.svg?branch=master\" alt=\"build status\" height=\"20\">\n  </a>\n  <a href=\"https://www.npmjs.com/package/fp-ts\">\n    <img src=\"https://img.shields.io/npm/dm/fp-ts.svg\" alt=\"npm downloads\" height=\"20\">\n  </a>\n</p>\n\n**📢 Important Announcement: fp-ts is Joining the Effect-TS Ecosystem!**\n\nWe are excited to announce that the `fp-ts` project is officially merging with the Effect-TS ecosystem. This is a significant step forward in the functional programming landscape, bringing together two powerful libraries under one roof. Giulio Canti, the author of `fp-ts`, is being welcomed into the Effect organization, promising an exciting future with enhanced capabilities and support.\n\n**What This Means for New Users:**\n\nEffect-TS can be regarded as the successor to `fp-ts v2` and embodies what would be considered `fp-ts v3`. This merger marks a significant evolution in the library's capabilities, integrating more features and functionalities tailored towards robust, type-safe, and scalable functional programming.\n\nFor more details on this merger and what it entails, please refer to the official [announcement here](https://dev.to/effect/a-bright-future-for-effect-455m). Additionally, you can explore more about Effect-TS and its offerings on our [website and documentation](https://effect.website/).\n\n# Introduction\n\n`fp-ts` is a library for _typed functional programming_ in TypeScript.\n\n`fp-ts` aims to allow developers to use _popular patterns and abstractions_ that are available in most functional languages. For this, it includes the most popular data types, type classes and abstractions such as [Option](https://gcanti.github.io/fp-ts/modules/Option.ts), [Either](https://gcanti.github.io/fp-ts/modules/Either.ts), [IO](https://gcanti.github.io/fp-ts/modules/IO.ts), [Task](https://gcanti.github.io/fp-ts/modules/Task.ts), [Functor](https://gcanti.github.io/fp-ts/modules/Functor.ts), [Applicative](https://gcanti.github.io/fp-ts/modules/Applicative.ts), [Monad](https://gcanti.github.io/fp-ts/modules/Monad.ts) to empower users to write pure FP apps and libraries built atop higher order abstractions.\n\nA distinctive feature of `fp-ts` with respect to other functional libraries is its implementation of [Higher Kinded Types](<https://en.wikipedia.org/wiki/Kind_(type_theory)>), which TypeScript doesn't support natively.\n\n**Inspired by**\n\n- [Haskell](https://www.haskell.org)\n- [PureScript](https://www.purescript.org)\n- [Scala](https://www.scala-lang.org)\n\n# Sponsors\n\n<table>\n  <tr>\n    <td align=\"center\">\n      <a href=\"https://unsplash.com/\">\n        <img src=\"https://avatars.githubusercontent.com/u/9951955?s=200&v=4\" width=\"200px;\" alt=\"Unsplash\" />\n      </a>\n      <br />\n      <b>Unsplash</b>\n      <br />\n      <a href=\"https://unsplash.com/\">https://unsplash.com/</a>\n      <br />\n      <p width=\"200px\">\n        The internet’s source for visuals.<br/>\n        Powered by creators everywhere.\n    </td>\n  </tr>\n</table>\n\n# Installation\n\nTo install the stable version:\n\n```\nnpm install fp-ts\n```\n\nMake sure to always have a single version of `fp-ts` installed in your project. Multiple versions are known to cause `tsc` to hang during compilation. You can check the versions currently installed using `npm ls fp-ts` (make sure there's a single version and all the others are marked as `deduped`).\n\n## TypeScript compatibility\n\n**Strictness** – This library is conceived, tested and is supposed to be consumed by TypeScript with the `strict` flag turned on.\n\n| `fp-ts` version | required `typescript` version |\n| --------------- | ----------------------------- |\n| 2.0.x+          | 3.5+                          |\n| 1.15.x+         | 3.1+                          |\n| <= 1.14.4       | 2.8+ (\\*)                     |\n\n(\\*) If you are running `< typescript@3.0.1` you have to polyfill the `unknown` type. You can use [unknown-ts](https://github.com/gcanti/unknown-ts) as a polyfill.\n\n# Documentation\n\n**Disclaimer**. Teaching functional programming is out of scope of this project, so the documentation assumes you already know what FP is.\n\n- [Docs](https://gcanti.github.io/fp-ts)\n- [Learning Resources](https://gcanti.github.io/fp-ts/learning-resources/)\n- [Ecosystem](https://gcanti.github.io/fp-ts/ecosystem/)\n- API Reference\n  - [version 2.x (current)](https://gcanti.github.io/fp-ts/modules/)\n  - [version 1.x](https://github.com/gcanti/fp-ts/tree/1.x/docs/modules/)\n\n# Help\n\nIf you need help with `fp-ts` check out:\n\n- this [Discord server](https://discord.gg/HVWmBBXM8A)\n- the `#fp-ts` channel on [FP slack](https://fpslack.com/).\n\n# Development\n\n- [Code conventions](https://gcanti.github.io/fp-ts/guides/code-conventions)\n\n# License\n\nThe MIT License (MIT)\n"
  },
  {
    "path": "code2comment.html",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"UTF-8\" />\n    <title>code 2 comment</title>\n  </head>\n\n  <body>\n    <div id=\"app\">\n      <textarea id=\"code\" cols=\"100\" rows=\"20\"></textarea>\n      <textarea id=\"comment\" cols=\"100\" rows=\"20\"></textarea>\n      <button id=\"transform\">transform</button>\n    </div>\n    <script>\n      const transform = document.getElementById('transform')\n      const code = document.getElementById('code')\n      const comment = document.getElementById('comment')\n      transform.onclick = () => {\n        comment.value = t(code.value)\n      }\n      function t(src) {\n        const lines = src.split('\\n').map((line) => '* ' + line.replace('../src/', 'fp-ts/'))\n        return '*\\n* @example\\n' + lines.join('\\n') + '\\n'\n      }\n    </script>\n  </body>\n</html>\n"
  },
  {
    "path": "docs/_config.yml",
    "content": "remote_theme: pmarsceill/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    - \"//gcanti.github.io/fp-ts/\"\n  \"API Reference\":\n    - \"//gcanti.github.io/fp-ts/modules/\"\n  \"GitHub\":\n    - \"//github.com/gcanti/fp-ts\"\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/ecosystem.md",
    "content": "---\ntitle: Ecosystem\npermalink: /ecosystem/\nnav_order: 3\nhas_children: false\nhas_toc: false\n---\n\n# Ecosystem\n\n## Tooling\n\n- [create-fp-ts-lib](https://github.com/no-day/create-fp-ts-lib) - Bootstrap libraries that follow common fp-ts coding, documentation and testing patterns\n- [docs-ts](https://github.com/gcanti/docs-ts) - Documentation generator used by fp-ts and many fp-ts libraries\n\n## Libraries\n\n- [fp-ts-contrib](https://github.com/gcanti/fp-ts-contrib) - A community driven utility package for fp-ts\n- [fp-ts-codegen](https://github.com/gcanti/fp-ts-codegen) - TypeScript code generation from a haskell-like syntax for ADT\n- [io-ts](https://github.com/gcanti/io-ts) - TypeScript compatible runtime type system for IO validation\n- [monocle-ts](https://github.com/gcanti/monocle-ts) - Functional optics: a (partial) porting of scala monocle to\n  TypeScript\n- [spectacles-ts](https://github.com/anthonyjoeseph/spectacles-ts/) - A simple facade built on top of monocle-ts (autocompletes possible combinators)\n- [newtype-ts](https://github.com/gcanti/newtype-ts) - Implementation of newtypes in TypeScript\n- [logging-ts](https://github.com/gcanti/logging-ts) - Composable loggers for TypeScript\n- [logger-fp-ts](https://github.com/thewilkybarkid/logger-fp-ts) - Logger built on top of logging-ts\n- [fp-ts-routing](https://github.com/gcanti/fp-ts-routing) - A type-safe bidirectional routing library for TypeScript\n- [parser-ts](https://github.com/gcanti/parser-ts) - String parser combinators for TypeScript\n- [remote-data-ts](https://github.com/devex-web-frontend/remote-data-ts) - RemoteData type (check [this article](https://medium.com/@gcanti/slaying-a-ui-antipattern-with-flow-5eed0cfb627b))\n- [retry-ts](https://github.com/gcanti/retry-ts) - Retry combinators for monadic actions that may fail\n- [fp-ts-local-storage](https://github.com/gcanti/fp-ts-local-storage) - fp-ts bindings for LocalStorage\n- [circuit-breaker-monad](https://github.com/YBogomolov/circuit-breaker-monad) - Circuit Breaker pattern as a monad\n- [waveguide](https://github.com/rzeigler/waveguide) - Bifunctor effect type and concurrent data structures.\n- [kleisli-ts](https://github.com/YBogomolov/kleisli-ts) - Kleisli arrows for bifunctor MonadThrow (IOEither, TaskEither)\n- [@nll/datum](https://github.com/nullpub/datum) - Datum and DatumEither types, another take on RemoteData and [flow](https://medium.com/@gcanti/slaying-a-ui-antipattern-with-flow-5eed0cfb627b)\n- [fetcher-ts](https://github.com/YBogomolov/fetcher-ts) - Type-safe REST HTTP client with io-ts response validation\n- [alga-ts](https://github.com/algebraic-graphs/typescript) – Algebraic encoding for graphs, which makes invalid graphs unrepresentable\n- [morphic-ts](https://github.com/sledorze/morphic-ts) - Code first Domain modeling with extensive pattern supports (matchers, predicates, lenses) with useful, extensible, customisable derivations (Show, Eq, io-ts, fast-check, jsonSchema, ..).\n- [graphics-ts](https://github.com/gcanti/graphics-ts) - A porting of purescript-{canvas, drawing} featuring fp-ts\n- [expressive-ts](https://github.com/IMax153/expressive-ts) - Comonadic builders for writing complex regular expressions\n- [fp-fetch](https://github.com/monstasat/fp-fetch) - Functional style, non-throwing utils for data fetching\n- [fp-ts-std](https://github.com/samhh/fp-ts-std) - The missing pseudo-standard library for fp-ts.\n- [fp-ts-lcg](https://github.com/no-day/fp-ts-lcg) - A seeded pseudorandom number generator\n- [fp-ts-graph](https://github.com/no-day/fp-ts-graph) - Immutable, functional graph data structure\n- [fp-ts-bigint](https://github.com/ericcrosson/fp-ts-bigint) - Opt-in BigInt functions\n- [fp-ts-generators](https://github.com/no-day/fp-ts-generators) - Seeded pseudorandom generators for structured data\n- [fp-ts-sized-vectors](https://github.com/no-day/fp-ts-sized-vectors) - Fixed size generic vector type carrying its length at the typelevel\n- [fp-ts-number-instances](https://github.com/no-day/fp-ts-number-instances) - Not fully law abiding instances for the number type\n- [fp-ts-react-stable-hooks](https://github.com/mblink/fp-ts-react-stable-hooks) - Reduce unnecessary rerenders when using fp-ts data types with React hooks\n\n## Bindings\n\n- [fp-ts-rxjs](https://github.com/gcanti/fp-ts-rxjs) - fp-ts bindings for [RxJS](https://rxjs-dev.firebaseapp.com/)\n- [fp-ts-fluture](https://github.com/gcanti/fp-ts-fluture) - fp-ts bindings for [Fluture](https://github.com/fluture-js/Fluture)\n- [fp-ts-most](https://github.com/joshburgess/fp-ts-most) - fp-ts bindings for [@most/core](https://github.com/cujojs/most)\n- [fp-ts-ixjs](https://github.com/werk85/fp-ts-ixjs) - fp-ts bindings for [IxJS](https://github.com/ReactiveX/IxJS)\n\n## Plugins\n\n- [fastify-funky](https://github.com/fastify/fastify-funky) - plugin that adds support for returning fp-ts Either and Task entities as handler execution results for [fastify](https://github.com/fastify/fastify) web framework\n"
  },
  {
    "path": "docs/guides/HKT.md",
    "content": "---\ntitle: Write type class instances\nparent: Guides\nnav_order: 2\n---\n\n# How to write type class instances for your data type\n\nLet's start from a simple data structure: `Identity`\n\n```ts\n// Identity.ts\n\nexport type Identity<A> = A\n```\n\n## Functor instance\n\nLet's see how to add an instance of the `Functor` type class for `Identity`\n\n```ts\n// Identity.ts\n\nimport { Functor1 } from 'fp-ts/Functor'\n\nexport const URI = 'Identity'\n\nexport type URI = typeof URI\n\ndeclare module 'fp-ts/HKT' {\n  interface URItoKind<A> {\n    readonly Identity: Identity<A>\n  }\n}\n\nexport type Identity<A> = A\n\n// Functor instance\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: (ma, f) => f(ma)\n}\n```\n\nHere's the definition of `Functor1`\n\n```ts\n// fp-ts/Functor.ts\n\nexport interface Functor1<F extends URIS> {\n  readonly URI: F\n  readonly map: <A, B>(fa: Kind<F, A>, f: (a: A) => B) => Kind<F, B>\n}\n```\n\nSo what's `URItoKind`, `URIS` and `Kind`?\n\n`URItoKind` is type-level map, it maps a `URI` to a concrete data type, and is populated using the [module augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html) feature\n\n```ts\n// fp-ts/HKT.ts\n\nexport interface URItoKind<A> {}\n```\n\n```ts\n// Identity.ts\n\ndeclare module 'fp-ts/HKT' {\n  interface URItoKind<A> {\n    readonly Identity: Identity<A> // maps the key \"Identity\" to the type `Identity`\n  }\n}\n```\n\n`URIS` is just `keyof URItoKind<any>` and is used as a constraint in the `Functor1` interface\n\n`Kind<F, A>` is using `URItoKind` internally so is able to project an abstract data type to a concrete data type.\nSo if `URI = 'Identity'`, then `Kind<URI, number>` is `Identity<number>`.\n\n## What about type constructors of kind `* -> * -> *`?\n\nThere's another triple for that: `URItoKind2`, `URIS2` and `Kind2`\n\nExample: `Either`\n\n```ts\n// Either.ts\n\nimport { Functor2 } from 'fp-ts/Functor'\n\nexport const URI = 'Either'\n\nexport type URI = typeof URI\n\ndeclare module 'fp-ts/HKT' {\n  interface URItoKind2<E, A> {\n    readonly Either: Either<E, A>\n  }\n}\n\nexport interface Left<E> {\n  readonly _tag: 'Left'\n  readonly left: E\n}\n\nexport interface Right<A> {\n  readonly _tag: 'Right'\n  readonly right: A\n}\n\nexport type Either<E, A> = Left<E> | Right<A>\n\nexport const right = <A, E = never>(a: A): Either<E, A> => ({ _tag: 'Right', right: a })\n\n// Functor instance\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: (ma, f) => (ma._tag === 'Left' ? ma : right(f(ma.right)))\n}\n```\n\nAnd here's the definition of `Functor2`\n\n```ts\n// fp-ts/Functor.ts\n\nexport interface Functor2<F extends URIS2> {\n  readonly URI: F\n  readonly map: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>\n}\n```\n\n## How to type functions which abstracts over type classes\n\nLet's see how to type `lift`\n\n```ts\nimport { HKT } from 'fp-ts/HKT'\n\nexport function lift<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B> {\n  return (f) => (fa) => F.map(fa, f)\n}\n```\n\nHere's the definition of `HKT`\n\n```ts\n// fp-ts/HKT.ts\n\nexport interface HKT<URI, A> {\n  readonly _URI: URI\n  readonly _A: A\n}\n```\n\nThe `HKT` type represents a type constructor of kind `* -> *`.\n\nThere are other `HKT<n>` types defined in the `fp-ts/HKT.ts`, one for each kind (up to four):\n\n- `HKT2` for type constructors of kind `* -> * -> *`\n- `HKT3` for type constructors of kind `* -> * -> * -> *`\n- `HKT4` for type constructors of kind `* -> * -> * -> * -> *`\n\nThere's a problem though, this doesn't type check\n\n```ts\nconst double = (n: number): number => n * 2\n\n//                             v-- the Functor instance of Identity\nconst doubleIdentity = lift(identity)(double)\n```\n\nWith the following error\n\n```\nArgument of type 'Functor1<\"Identity\">' is not assignable to parameter of type 'Functor<\"Identity\">'\n```\n\nWe need to add some overloading, one for each kind we want to support\n\n```ts\nexport function lift<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function lift<F extends URIS>(F: Functor1<F>): <A, B>(f: (a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>\nexport function lift<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>\nexport function lift<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B> {\n  return (f) => (fa) => F.map(fa, f)\n}\n```\n\nNow we can lift `double` to both `Identity` and `Either`\n\n```ts\n//                             v-- the Functor instance of Identity\nconst doubleIdentity = lift(identity)(double)\n\n//                           v-- the Functor instance of Either\nconst doubleEither = lift(either)(double)\n```\n\n- `doubleIdentity` has type `(fa: Identity<number>) => Identity<number>`\n- `doubleEither` has type `<E>(fa: Either<E, number>) => Either<E, number>`\n"
  },
  {
    "path": "docs/guides/code-conventions.md",
    "content": "---\ntitle: Code Conventions\nparent: Guides\nnav_order: 1\n---\n\n# Code Conventions\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n**Table of contents**\n\n- [Module structure](#module-structure)\n- [FAQ](#faq)\n  - [What a `C` suffix means, e.g. `Functor2C` vs `Functor2`](#what-a-c-suffix-means-eg-functor2c-vs-functor2)\n  - [What an `E` suffix means, e.g. `matchE`](#what-an-e-suffix-means-eg-matche)\n  - [What a `K` suffix means, e.g. `fromEitherK` or `chainEitherK`](#what-a-k-suffix-means-eg-fromeitherk-or-chaineitherk)\n  - [What a `T` suffix means, e.g. `sequenceT`](#what-a-t-suffix-means-eg-sequencet)\n  - [What a `W` suffix means, e.g. `chainW` or `chainEitherKW`](#what-a-w-suffix-means-eg-chainw-or-chaineitherkw)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Import Statements\n\nTo properly import modules from `fp-ts`, you should use the following syntax:\n\n```ts\nimport ... from 'fp-ts/<module>'\n```\n\nFor instance, when importing the `Option` module, you can use the following code:\n\n```ts\nimport * as Option from 'fp-ts/Option'\n```\n\nThis ensures that you're importing the required modules correctly.\n\n## Module structure\n\nIn general a module containing the definition of a data structure has the following structure\n\n- `URI` definition and module augmentation\n- data structure definition\n- companion functions\n- instance functions (private)\n- type class instance definitions (either constants or functions)\n\n## FAQ\n\n### What a `C` suffix means, e.g. `Functor2C` vs `Functor2`\n\nThe naming convention is:\n\n- the number means the kind\n- `C` means *C*onstrained\n\n| Kind               | Type class           | Type defunctionalization | Note                                                     |\n| ------------------ | -------------------- | ------------------------ | -------------------------------------------------------- |\n| all                | `Functor<F>`         | `HKT<F, A>`              |                                                          |\n| `* -> *`           | `Functor1<F>`        | `Kind<F, A>`             |                                                          |\n| `* -> * -> *`      | `Functor2<F>`        | `Kind2<F, E, A>`         |                                                          |\n| `* -> * -> *`      | `Functor2C<F, E>`    | `Kind2<F, E, A>`         | A variant of `Functor2` where `E` is fixed               |\n| `* -> * -> * -> *` | `Functor3<F>`        | `Kind3<F, R, E, A>`      |                                                          |\n| `* -> * -> * -> *` | `Functor3C<F, R, E>` | `Kind3<F, R, E, A>`      | A variant of `Functor3` where both `R` and `E` are fixed |\n\n**Example** `Functor`\n\nThe base definition\n\n```ts\nexport interface Functor<F> {\n  readonly URI: F\n  readonly map: <A, B>(fa: HKT<F, A>, f: (a: A) => B) => HKT<F, B>\n}\n```\n\nThe definition for type constructors of kind `* -> * -> *` (e.g. `Either`)\n\n```ts\nexport interface Functor2<F extends URIS2> {\n  readonly URI: F\n  //             v-- here E is free\n  readonly map: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>\n}\n```\n\nThe definition for type constructors that start with kind `* -> * -> *` but need to be constrained in order to admit an instance (e.g. `Validation`).\n\n```ts\n//                           this fixes E --v\nexport interface Functor2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  //                                v-- here E is fixed ---------------v\n  readonly map: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>\n}\n```\n\nFor example, `Validation` admits a `Functor` instance only if you provide a `Semigroup` instance for the failure part\n\n```ts\n//   this fixes E --v                                            v-- here E is fixed\nconst getFunctor = <E>(S: Semigroup<E>): Functor2C<\"Validation\", E> = { ... }\n```\n\n### What an `E` suffix means, e.g. `matchE`\n\n`E` means *E*ffect. An example of its use is in the `matchE` destructor on monad transformers like `TaskOption` or `ReaderTaskEither`.\n\n**Example**\n\nBoth of these destructions result in a `Task<number>`, but in the case of `matchE` an effect (in this case in the form of a `Task`) is returned on match.\n\n```ts\nimport * as T from 'fp-ts/Task'\nimport * as TO from 'fp-ts/TaskOption'\nimport { pipe } from 'fp-ts/function'\n\nconst value = TO.of('hello')\n\n// T.Task<number>\npipe(\n  value,\n  TO.match(\n    () => 0,\n    (str) => str.length\n  )\n)\n\n// T.Task<number>\npipe(\n  value,\n  TO.matchE(\n    () => T.of(0),\n    (str) => T.of(str.length)\n  )\n)\n```\n\n### What a `K` suffix means, e.g. `fromEitherK` or `chainEitherK`\n\n`K` means *K*leisli. A _Kleisli arrow_ is a function with the following signature\n\n```ts\n;(a: A) => F<B>\n```\n\nwhere `F` is a type constructor.\n\n**Example**\n\nLet's say we have the following parser\n\n```ts\nimport * as E from 'fp-ts/Either'\n\nfunction parse(s: string): E.Either<Error, number> {\n  const n = parseFloat(s)\n  return isNaN(n) ? E.left(new Error(`cannot decode ${JSON.stringify(s)} to number`)) : E.right(n)\n}\n```\n\nand a value of type `IOEither<Error, string>`\n\n```ts\nimport * as IE from 'fp-ts/IOEither'\n\nconst input: IE.IOEither<Error, string> = IE.right('foo')\n```\n\nhow can we parse `input`?\n\nWe could lift the Kleisli arrow `parse`, i.e. transform a function\n\n```ts\n;(s: string) => E.Either<Error, number>\n```\n\ninto a function\n\n```ts\n;(s: string) => IE.IOEither<Error, number>\n```\n\nThat's what `fromEitherK` is all about\n\n```ts\nimport { pipe } from 'fp-ts/function'\n\npipe(input, IE.chain(IE.fromEitherK(parse)))() // left(new Error('cannot decode \"foo\" to number'))\n\n// or with less boilerplate\npipe(input, IE.chainEitherK(parse))() // left(new Error('cannot decode \"foo\" to number'))\n```\n\n### What a `T` suffix means, e.g. `sequenceT`\n\nin `sequenceT` means *T*uple, I borrowed the name from the corresponding [Haskell function](http://hackage.haskell.org/package/tuple-0.3.0.2/docs/Data-Tuple-Sequence.html)\n\nHowever usually it means *T*ransformer like in \"monad transformers\" (e.g. `OptionT`, `EitherT`, `ReaderT`, `StateT`)\n\n### What a `W` suffix means, e.g. `chainW` or `chainEitherKW`\n\n`W` means *W*iden. Functions that end with `W` are able to aggregate errors into a union (for `Either` based data types) or environments into an intersection (for `Reader` based data types).\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport * as TE from 'fp-ts/TaskEither'\nimport { pipe } from 'fp-ts/pipeable'\n\ndeclare function parseString(s: string): E.Either<string, number>\ndeclare function fetchUser(id: number): TE.TaskEither<Error, User>\n\n// this raises an error because: Type 'string' is not assignable to type 'Error'\nconst program_ = (s: string) => pipe(s, TE.fromEitherK(parseString), TE.chain(fetchUser))\n\n// const program: (s: string) => TE.TaskEither<string | Error, User>\nconst program = (s: string) => pipe(s, TE.fromEitherK(parseString), TE.chainW(fetchUser))\n```\n"
  },
  {
    "path": "docs/guides/do-notation.md",
    "content": "---\ntitle: Do notation\nparent: Guides\nnav_order: 4\n---\n\n# Do Notation\n\nBoth [Haskell](https://wiki.haskell.org/Monad#do-notation)\nand [PureScript](https://github.com/purescript/documentation/blob/master/language/Syntax.md#do-notation)\nlanguages provide syntactic sugar for working with monads in the form of do notation.\n\n`fp-ts` provides it's own implementation of do notation which can help to simplify effectful\ncode.\n\nLet's take a look at an example of how do notation can help to simplify our code. Here we have\na bit of code which reads two values from the command line, prints them and stores them\nin an object with `x` and `y` properties.\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as T from 'fp-ts/Task'\n\ndeclare const print: (s: string) => T.Task<void>\ndeclare const readLine: T.Task<string>\n\nconst main: T.Task<{ x: string; y: string }> = pipe(\n  readLine,\n  T.map((x) => ({ x })),\n  T.flatMap(({ x }) =>\n    pipe(\n      readLine,\n      T.map((y) => ({ x, y }))\n    )\n  ),\n  T.tap(({ x }) => print(x)),\n  T.tap(({ y }) => print(y))\n)\n```\n\nNotice how we need a nested `pipe` to allow the combination of `x` and `y` values into a single\nobject.\n\nHere's how we can write `main` with do notation (we'll call it `mainDo`):\n\n```ts\nconst mainDo: T.Task<{ x: string; y: string }> = pipe(\n  T.Do,\n  T.bind('x', () => readLine),\n  T.bind('y', () => readLine),\n  T.tap(({ x }) => print(x)),\n  T.tap(({ y }) => print(y))\n)\n```\n\nThis will look very familiar to those who have prior experience with Purescript or Haskell\nwhere we could write something like:\n\n```haskell\nmain :: IO (String, String)\nmain = do\n  x <- readLn\n  y <- readLn\n  print x\n  print y\n  return (x, y)\n```\n\nNote that due to the lack of type-classes in Typescript, when working with `fp-ts` we need to\nimport everything from the appropriate module. In the previous example, we use specific `Do`,\n`bind`, `map` and `chainFirst` functions imported from the `Task` module as we were working\nwith the `Task` type.\n\nIf we were to write the same code using the `IO` monad, we would need to import everything from the `IO`\nmodule like so:\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as IO from 'fp-ts/IO'\n\ndeclare const print: (s: string) => IO.IO<void>\ndeclare const readLine: IO.IO<string>\n\nconst mainDo: IO.IO<{ x: string; y: string }> = pipe(\n  IO.Do,\n  IO.bind('x', () => readLine),\n  IO.bind('y', () => readLine),\n  IO.tap(({ x }) => print(x)),\n  IO.tap(({ y }) => print(y))\n)\n```\n\n## Examples\n\nUsing `bindTo`:\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as T from 'fp-ts/Task'\n\ndeclare const print: (s: string) => T.Task<void>\ndeclare const readLine: T.Task<string>\n\npipe(\n  readLine,\n  T.bindTo('x'),\n  T.bind('y', () => readLine),\n  T.tap(({ x }) => print(x)),\n  T.tap(({ y }) => print(y))\n)\n```\n\nPerforming actions in parallel with `apS`:\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as T from 'fp-ts/Task'\n\ndeclare const encryptValue: (val: string) => T.Task<string>\n\npipe(\n  T.Do,\n  T.apS('x', encryptValue('hello')),\n  T.apS('y', encryptValue('world')),\n  T.map(({ x, y }) => {\n    /* ... */\n  })\n)\n```\n\n# FAQ\n\n> What does `IO.Do` do exactly?\n\n`IO.Do` is just an alias for `IO.of({})` where `{}` is an empty record.\n\nYou build up a record using `bind` which accepts a key and a function that accepts the current state of the record and returns an effect of some value to store under the key.\n\nThe record becomes kind of like a scope to put intermediate values in when you are chaining effects.\n"
  },
  {
    "path": "docs/guides/index.md",
    "content": "---\ntitle: Guides\npermalink: /guides/\nnav_order: 5\nhas_children: true\nhas_toc: true\n---\n\n# Guides\n"
  },
  {
    "path": "docs/guides/purescript.md",
    "content": "---\ntitle: Migrate from PureScript/Haskell\nparent: Guides\nnav_order: 3\n---\n\n# Migrate from PureScript/Haskell\n\nThis guide shows you how to use `fp-ts` concepts if you have prior experience with [PureScript](http://www.purescript.org/) or [Haskell](https://www.haskell.org/).\n\n---\n\n## Do notation\n\nPureScript\n\n```purescript\ndo\n  print \"foo\"\n  print \"bar\"\n  x <- readLine\n  print x\n```\n\nTypeScript\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as T from 'fp-ts/Task'\n\ndeclare const print: (s: string) => T.Task<void>\ndeclare const readLine: T.Task<string>\n\npipe(\n  T.Do,\n  T.tap(() => print('foo')),\n  T.tap(() => print('bar')),\n  T.bind('x', () => readLine),\n  T.flatMap(({ x }) => print(x))\n)\n```\n\n## Data\n\nPureScript\n\n```purescript\n--   ↓-- type\ndata Foo = Bar String | Baz Boolean\n--         ↑------------↑-- constructors\n```\n\nTypeScript\n\n```ts\ninterface Bar {\n  readonly _tag: 'Bar'\n  readonly value: string\n}\n\ninterface Baz {\n  readonly _tag: 'Baz'\n  readonly value: boolean\n}\n\n// type\ntype Foo = Bar | Baz\n\n// constructors\nconst Bar = (value: string): Foo => ({ _tag: 'Bar', value })\n\nconst Baz = (value: boolean): Foo => ({ _tag: 'Baz', value })\n```\n\n## Polymorphic data\n\nPureScript\n\n```purescript\ndata Option a = None | Some a\n```\n\nTypeScript\n\n```ts\nexport const URI = 'Option'\n\nexport type URI = typeof URI\n\ndeclare module 'fp-ts/HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Option<A>\n  }\n}\n\nexport interface None {\n  readonly _tag: 'None'\n}\n\nexport interface Some<A> {\n  readonly _tag: 'Some'\n  readonly value: A\n}\n\nexport type Option<A> = None | Some<A>\n\nexport const none: Option<never> = { _tag: 'None' }\n\nexport const some = <A>(a: A): Option<A> => ({ _tag: 'Some', value: a })\n```\n\n## Pattern matching\n\nPureScript\n\n```purescript\nmaybe :: forall a b. b -> (a -> b) -> Option a -> b\nmaybe b _ None = b\nmaybe _ f (Some a) = f a\n```\n\nTypeScript\n\n```ts\n// here TypeScript also provides exhaustiveness check\nconst maybe =\n  <A, B>(onNone: () => B, onSome: (a: A) => B) =>\n  (fa: Option<A>): B => {\n    switch (fa._tag) {\n      case 'None':\n        return onNone()\n      case 'Some':\n        return onSome(fa.value)\n    }\n  }\n```\n\n## Type classes\n\nPureScript\n\n```purescript\nclass Functor f where\n  map :: forall a b. (a -> b) -> f a -> f b\n```\n\nTypeScript\n\n```ts\nexport interface Functor<F> {\n  readonly URI: F\n  readonly map: <A, B>(fa: HKT<F, A>, f: (a: A) => B) => HKT<F, B>\n}\n\nexport interface Functor1<F extends URIS> {\n  readonly URI: F\n  readonly map: <A, B>(fa: Kind<F, A>, f: (a: A) => B) => Kind<F, B>\n}\n\nexport interface Functor2<F extends URIS2> {\n  readonly URI: F\n  readonly map: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>\n}\n\n// etc...\n```\n\n## Instances\n\nPureScript\n\n```purescript\ninstance functorOption :: Functor Option where\n  map fn (Some x) = Some (fn x)\n  map _  _        = None\n```\n\nTypeScript\n\n```ts\nimport { Functor1 } from 'fp-ts/Functor'\nimport { pipe } from 'fp-ts/function'\n\nconst functorOption: Functor1<URI> = {\n  URI,\n  map: (fa, f) =>\n    pipe(\n      fa,\n      maybe(\n        () => none,\n        (a) => some(f(a))\n      )\n    )\n}\n```\n\n## Type constraints\n\nPureScript\n\n```purescript\ninstance semigroupOption :: Semigroup a => Semigroup (Option a) where\n  append None y = y\n  append x None = x\n  append (Some x) (Some y) = Some (x <> y)\n\ninstance monoidOption :: Semigroup a => Monoid (Option a) where\n  mempty = None\n```\n\nTypeScript\n\n```ts\nimport { Semigroup } from 'fp-ts/Semigroup'\nimport { Monoid } from 'fp-ts/Monoid'\n\n//                    ↓ the constraint is implemented as an additional parameter\nfunction getMonoid<A>(S: Semigroup<A>): Monoid<Option<A>> {\n  return {\n    concat: (x, y) => {\n      if (x._tag === 'Some' && y._tag === 'Some') {\n        return some(S.concat(x.value, y.value))\n      } else if (x._tag === 'Some') {\n        return y\n      } else {\n        return x\n      }\n    },\n    empty: none\n  }\n}\n```\n\n## Where's my `f <$> fa <*> fb`?\n\nA few options:\n\n```ts\nimport * as T from 'fp-ts/Task'\nimport { pipe } from 'fp-ts/function'\n\ndeclare const fa: T.Task<number>\ndeclare const fb: T.Task<string>\ndeclare const f: (a: number) => (b: string) => boolean\n\nconst result1 = pipe(fa, T.map(f), T.ap(fb))\n\n// ..or..\nconst result2 = pipe(T.of(f), T.ap(fa), T.ap(fb))\n```\n"
  },
  {
    "path": "docs/guides/upgrade-to-v2.md",
    "content": "---\ntitle: Upgrade to fp-ts 2.x\nparent: Guides\nnav_order: 5\n---\n\n# Upgrade to version 2.x\n\n`fp-ts@2.x` brings with it some major improvements, but also breaking changes and the removal of deprecated APIs. This document will help you understand what changed and how you can upgrade your existing codebase.\n{: .fs-6 .fw-300 }\n\n---\n\nThe major changes in `fp-ts@2.x` are:\n\n- Requires TypeScript 3.5+\n- `fp-ts@1.19.x` has been released with backported 2.x features for a gradual upgrade path\n- Data types are no longer implemented as classes, resulting in a new API using `pipe`\n- The `run()` method on `IO`, `Task`, etc. has been replaced with a thunk\n- Functions accepting fallback values are now always lazy (e.g. `getOrElseL` is now just `getOrElse`)\n- Deprecations\n  - `HKT`: Replaced `Type<n>` with `Kind<n>`\n  - Replaced `Setoid` with `Eq`\n  - Several modules were removed, e.g. `Exception`, `Free`, `StrMap`, `Trace`, `Validation`, …\n  - Read the [full changelog](https://github.com/gcanti/fp-ts/pull/881) for all the changes\n\n## Upgrading from version 1.x\n\nYou can gradually upgrade your existing codebase using the `fp-ts@1.19.x` release; the new `fp-ts@2.x` APIs have been backported to this release.\n\n1. Upgrade TypeScript to version 3.5+\n1. Install `fp-ts@1.19.x`, which contains the new `fp-ts@2.x` APIs\n1. Optional: activate the `@obsolete` rule for `tslint` to get guidance on what to change\n1. Familiarise yourself with [the new API](https://github.com/gcanti/fp-ts/pull/881)\n1. Gradually replace the existing code with the new API\n1. Upgrade to `fp-ts@2.x` and make sure to also upgrade all dependencies that rely on `fp-ts`\n\n### tslint rule\n\nIn order to make easier to spot all the occurrences of chainable APIs without depending on `@deprecated`, which would force you to migrate in one shot, a custom tslint rule is provided (`@obsolete`).\n\nAdd the following lines to your `tslint.json` to turn the `@obsolete` rule on:\n\n```diff\n{\n+  \"rulesDirectory\": [\"./node_modules/fp-ts/rules\"],\n   \"rules\": {\n+    \"obsolete\": true\n   }\n}\n```\n\nThis rule is available in the [1.19.x branch](https://github.com/gcanti/fp-ts/blob/1.19.5/rules/obsoleteRule.js).\n\n### Dependencies\n\nDon't forget to update your dependencies: libraries that use `fp-ts` like [io-ts](https://github.com/gcanti/io-ts) or [monocle-ts](https://github.com/gcanti/monocle-ts) have to be upgraded to their `fp-ts@2.x` compatible versions.\n\n## The new API\n\nIn `fp-ts@2.x` data types are no longer implemented with classes; the biggest change resulting from this is that the chainable API has been removed. As an alternative, a `pipe` function is provided, along with suitable data-last top level functions (one for each deprecated method). This is best shown with an example:\n\nv1 (deprecated)\n{: .label .label-red .mt-5 }\n\n```ts\nimport * as O from 'fp-ts/Option'\n\nO.some(1)\n  .map((n) => n * 2)\n  .chain((n) => (n === 0 ? O.none : O.some(1 / n)))\n  .filter((n) => n > 1)\n  .foldL(\n    () => 'ko',\n    () => 'ok'\n  )\n```\n\nv2 (new)\n{: .label .label-green .mt-5 }\n\n```ts\nimport * as O from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/pipeable'\n\npipe(\n  O.some(1),\n  O.map((n) => n * 2),\n  O.chain((n) => (n === 0 ? O.none : O.some(1 / n))),\n  O.filter((n) => n > 1),\n  O.fold(\n    () => 'ko',\n    () => 'ok'\n  )\n)\n```\n\nWe recommend to use `pipe` even if you work with just one function, as it allows TypeScript to infer the types automatically. It's also easier to migrate existing code, because the argument order remains the same.\n\n```ts\nimport * as O from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\npipe(\n  O.some(1),\n  O.fold(\n    () => 'ko',\n    (n) => `ok: ${n}`\n  )\n)\n```\n\nIf you are interested, read about the [benefits of the new API](https://github.com/gcanti/fp-ts/issues/823#issuecomment-486066792) in the technical discussion leading to `fp-ts@2.x`.\n\n### Replacement of the `run()` method\n\nThe `run()` method on `IO`, `Task`, etc. has been replaced with a thunk:\n\nv1 (deprecated)\n{: .label .label-red .mt-5 }\n\n```ts\nimport { Task } from 'fp-ts/Task'\n\nconst deepThought = new Task<number>(() => Promise.resolve(42))\n\ndeepThought.run().then((n) => {\n  console.log(`The answer is ${n}.`)\n})\n```\n\nv2 (new)\n{: .label .label-green .mt-5 }\n\n```ts\nimport { Task } from 'fp-ts/Task'\n\nconst deepThought: Task<number> = () => Promise.resolve(42)\n\ndeepThought().then((n) => {\n  console.log(`The answer is ${n}.`)\n})\n```\n\n### Functions accepting fallback values are now always lazy\n\nIn many places `fp-ts@1.x` provided two versions of methods:\n\nv1 (deprecated)\n{: .label .label-red .mt-5 }\n\n```ts\nimport * as O from 'fp-ts/Option'\n\nO.some(1).getOrElse(0) // Direct\nO.some(1).getOrElseL(() => 0) // Lazy, i.e. only run if needed\n```\n\nv2 (new)\n{: .label .label-green .mt-5 }\n\nIn `fp-ts@2.x` the API has been simplified, only the lazy variants have been kept with the `L` suffix removed.\n\n```ts\nimport * as O from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\npipe(\n  O.some(1),\n  O.getOrElse(() => 0)\n)\n```\n\n### Removed modules\n\n- `Exception`\n- `Free`\n- `FreeGroup`\n- `IxIO`\n- `IxMonad`\n- `Monoidal`\n- `Pair`\n- `StrMap` (use [Record](../modules/Record.ts) instead)\n- `Trace`\n- `Validation` (use [Either](../modules/Either.ts)'s `getValidation`)\n- `Zipper`\n\n## References\n\nIf you're interested in reading up on how this release came to be, have a look at the following discussions:\n\n- The technical [discussion leading to v2](https://github.com/gcanti/fp-ts/issues/823)\n- [Version 1.19 (backport)](https://github.com/gcanti/fp-ts/pull/881)\n- [The 2.0.0 release](https://github.com/gcanti/fp-ts/commit/7bda18e34eed996a08afdd6a0a61025087f99593)\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` 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\n## Core Concepts\n\nThe goal of `fp-ts` is to empower developers to write pure FP apps and libraries built atop higher order abstractions. It includes the most popular data types, type classes, and abstractions from languages like [Haskell](https://www.haskell.org), [PureScript](https://www.purescript.org), and [Scala](https://www.scala-lang.org).\n\n## Functions\n\nFunctional programming is all about pure functions and how to compose them into bigger structures. `fp-ts` provides a few general [functions](./modules/function.ts.html) to support you with composition, constant functions, and more.\n\n## Data Types\n\nData types are the practical part of `fp-ts`: you can instantiate them with your data to gain properties and functionality that are useful for solving a specific need. Because data types all share common interfaces (through [type classes](#type-classes)), once you learn how to use one data type, you can apply the same concepts to the others.\n\nMany functions in `fp-ts` use [ad hoc polymorphism](https://en.wikipedia.org/wiki/Ad_hoc_polymorphism), meaning that they have a single implementation that can deal with arguments of different types. To make this work, it is often necessary to provide a data type _instance_ that provides functionality that is specific to the data type.\n\n**Note**. Data types are not stack safe and there is no trampolining implementation. But for traversing and sequencing lists there is a stack safe and optimized version in each data types.\n\n## Type Classes\n\nType classes provide the theoretical underpinnings of `fp-ts`: they describe what you can do with your data. To guarantee that they can be safely composed, they are built on laws rooted in abstract algebra and [category theory](https://en.wikipedia.org/wiki/Category_theory).\n\n## Higher Kinded Types\n\nA distinctive feature of `fp-ts` with respect to other functional libraries is its implementation of [Higher Kinded Types](<https://en.wikipedia.org/wiki/Kind_(type_theory)>), which TypeScript doesn't support natively. The idea for emulating higher kinded types in TypeScript is based on [Lightweight higher-kinded polymorphism](https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf).\n"
  },
  {
    "path": "docs/learning-resources.md",
    "content": "---\ntitle: Learning Resources\npermalink: /learning-resources/\nnav_order: 2\nhas_children: false\nhas_toc: false\n---\n\n# Learning Resources\n\n- [Mostly adequate guide to FP](https://github.com/MostlyAdequate/mostly-adequate-guide) by [@DrBoolean](https://github.com/DrBoolean)\n- [The State monad](https://paulgray.net/the-state-monad/) by Paul Gray\n- [Functional Programming with TypeScript](https://www.youtube.com/playlist?list=PLuPevXgCPUIMbCxBEnc1dNwboH6e2ImQo) by Sahand Javid\n- [fp-ts Tutorial series on YouTube](https://www.youtube.com/playlist?list=PLUMXrUa_EuePN94nJ2hAui5nWDj8RO3lH) by [@MrFunctor](https://github.com/MrFunctor)\n\n## Getting started with fp-ts series\n\n- [Interoperability with non functional code](https://dev.to/gcanti/interoperability-with-non-functional-code-using-fp-ts-432e)\n- [Eq](https://dev.to/gcanti/getting-started-with-fp-ts-setoid-39f3)\n- [Ord](https://dev.to/gcanti/getting-started-with-fp-ts-ord-5f1e)\n- [Semigroup](https://dev.to/gcanti/getting-started-with-fp-ts-semigroup-2mf7)\n- [Monoid](https://dev.to/gcanti/getting-started-with-fp-ts-monoid-ja0)\n- [Category](https://dev.to/gcanti/getting-started-with-fp-ts-category-4c9a)\n- [Functor](https://dev.to/gcanti/getting-started-with-fp-ts-functor-36ek)\n- [Applicative](https://dev.to/gcanti/getting-started-with-fp-ts-applicative-1kb3)\n- [Monad](https://dev.to/gcanti/getting-started-with-fp-ts-monad-6k)\n- [Either vs Validation](https://dev.to/gcanti/getting-started-with-fp-ts-either-vs-validation-5eja)\n- [IO](https://dev.to/gcanti/getting-started-with-fp-ts-io-36p6)\n- [Reader](https://dev.to/gcanti/getting-started-with-fp-ts-reader-1ie5)\n\n## Functional design series\n\n- [Combinators Part I](https://dev.to/gcanti/functional-design-combinators-14pn)\n- [Combinators Part II](https://dev.to/gcanti/functional-design-how-to-make-the-time-combinator-more-general-3fge)\n- [Tagless final](https://dev.to/gcanti/functional-design-tagless-final-332k)\n- [Smart constructors](https://dev.to/gcanti/functional-design-smart-constructors-14nb)\n- [Introduction to property based testing](https://dev.to/gcanti/introduction-to-property-based-testing-17nk)\n- [Algebraic Data Types](https://dev.to/gcanti/functional-design-algebraic-data-types-36kf)\n\n## Advanced code examples\n\n- \"`fp-ts` to the max\" (TypeScript port of John De Goes's [\"FP to the max\"](https://www.youtube.com/watch?v=sxudIMiOo68) in Scala)\n  - [Part I](https://github.com/gcanti/fp-ts/blob/master/examples/fp-ts-to-the-max-I.ts)\n  - [Part II](https://github.com/gcanti/fp-ts/blob/master/examples/fp-ts-to-the-max-II.ts)\n\n## Community documentation\n\n- [fp-ts recipes](https://grossbart.github.io/fp-ts-recipes/) – A collection of practical recipes for working with `fp-ts`\n- [Mostly adequate guide to FP-TS](https://cjonas.gitbook.io/mostly-adequate-fp-ts/) partial rewrite by ChuckJonas\n- [Book: Introduction to Functional Programming by Giulio Canti](https://github.com/enricopolanski/functional-programming) English translation by Enrico Polanski\n\n\n## Community Blog Posts\n\n- [When An Error Is Not An Exception](https://dev.to/vncz/forewords-and-domain-model-1p13) — How we rewrote the core of Prism to make it almost totally functional\n- [Introduction series to FP-TS](https://ybogomolov.me/01-higher-kinded-types) by Yuriy Bogomolov\n- [The ReaderTaskMonad](https://andywhite.xyz/posts/) by Andy White\n- [FP-TS for HTTP-requests](https://kimmosaaskilahti.fi/blog/2019/08/29/using-fp-ts-for-http-requests-and-validation/) by Kimmo Sasskilahti\n- [Basic introduction to FP-TS](https://davetayls.me/blog/2018/06/09/fp-ts-02-handling-error-cases) by Dave Tayls\n- [Practical guide to FP-TS](https://rlee.dev/practical-guide-to-fp-ts-part-1) by Ryan Lee\n"
  },
  {
    "path": "docs/modules/Alt.ts.md",
    "content": "---\ntitle: Alt.ts\nnav_order: 1\nparent: Modules\n---\n\n## Alt overview\n\nThe `Alt` type class identifies an associative operation on a type constructor. It is similar to `Semigroup`, except\nthat it applies to types of kind `* -> *`, like `Array` or `Option`, rather than concrete types like `string` or\n`number`.\n\n`Alt` instances are required to satisfy the following laws:\n\n1. Associativity: `A.alt(A.alt(fa, ga), ha) <-> A.alt(fa, A.alt(ga, ha))`\n2. Distributivity: `A.map(A.alt(fa, ga), ab) <-> A.alt(A.map(fa, ab), A.map(ga, ab))`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Alt (interface)](#alt-interface)\n  - [Alt1 (interface)](#alt1-interface)\n  - [Alt2 (interface)](#alt2-interface)\n  - [Alt2C (interface)](#alt2c-interface)\n  - [Alt3 (interface)](#alt3-interface)\n  - [Alt3C (interface)](#alt3c-interface)\n  - [Alt4 (interface)](#alt4-interface)\n- [utils](#utils)\n  - [altAll](#altall)\n\n---\n\n# model\n\n## Alt (interface)\n\n**Signature**\n\n```ts\nexport interface Alt<F> extends Functor<F> {\n  readonly alt: <A>(fa: HKT<F, A>, that: LazyArg<HKT<F, A>>) => HKT<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## Alt1 (interface)\n\n**Signature**\n\n```ts\nexport interface Alt1<F extends URIS> extends Functor1<F> {\n  readonly alt: <A>(fa: Kind<F, A>, that: LazyArg<Kind<F, A>>) => Kind<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## Alt2 (interface)\n\n**Signature**\n\n```ts\nexport interface Alt2<F extends URIS2> extends Functor2<F> {\n  readonly alt: <E, A>(fa: Kind2<F, E, A>, that: LazyArg<Kind2<F, E, A>>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Alt2C (interface)\n\n**Signature**\n\n```ts\nexport interface Alt2C<F extends URIS2, E> extends Functor2C<F, E> {\n  readonly alt: <A>(fa: Kind2<F, E, A>, that: LazyArg<Kind2<F, E, A>>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Alt3 (interface)\n\n**Signature**\n\n```ts\nexport interface Alt3<F extends URIS3> extends Functor3<F> {\n  readonly alt: <R, E, A>(fa: Kind3<F, R, E, A>, that: LazyArg<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Alt3C (interface)\n\n**Signature**\n\n```ts\nexport interface Alt3C<F extends URIS3, E> extends Functor3C<F, E> {\n  readonly alt: <R, A>(fa: Kind3<F, R, E, A>, that: LazyArg<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.2.0\n\n## Alt4 (interface)\n\n**Signature**\n\n```ts\nexport interface Alt4<F extends URIS4> extends Functor4<F> {\n  readonly alt: <S, R, E, A>(fa: Kind4<F, S, R, E, A>, that: LazyArg<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## altAll\n\n**Signature**\n\n```ts\nexport declare function altAll<F extends URIS4>(\n  F: Alt4<F>\n): <S, R, E, A>(startWith: Kind4<F, S, R, E, A>) => (as: ReadonlyArray<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>\nexport declare function altAll<F extends URIS3>(\n  F: Alt3<F>\n): <R, E, A>(startWith: Kind3<F, R, E, A>) => (as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\nexport declare function altAll<F extends URIS3, E>(\n  F: Alt3C<F, E>\n): <R, A>(startWith: Kind3<F, R, E, A>) => (as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\nexport declare function altAll<F extends URIS2>(\n  F: Alt2<F>\n): <E, A>(startWith: Kind2<F, E, A>) => (as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>\nexport declare function altAll<F extends URIS2, E>(\n  F: Alt2C<F, E>\n): <A>(startWith: Kind2<F, E, A>) => (as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>\nexport declare function altAll<F extends URIS>(\n  F: Alt1<F>\n): <A>(startWith: Kind<F, A>) => (as: ReadonlyArray<Kind<F, A>>) => Kind<F, A>\nexport declare function altAll<F>(F: Alt<F>): <A>(startWith: HKT<F, A>) => (as: ReadonlyArray<HKT<F, A>>) => HKT<F, A>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/Alternative.ts.md",
    "content": "---\ntitle: Alternative.ts\nnav_order: 2\nparent: Modules\n---\n\n## Alternative overview\n\nThe `Alternative` type class extends the `Alt` type class with a value that should be the left and right identity for `alt`.\n\nIt is similar to `Monoid`, except that it applies to types of kind `* -> *`, like `Array` or `Option`, rather than\nconcrete types like `string` or `number`.\n\n`Alternative` instances should satisfy the following laws:\n\n1. Left identity: `A.alt(zero, fa) <-> fa`\n2. Right identity: `A.alt(fa, zero) <-> fa`\n3. Annihilation: `A.map(zero, f) <-> zero`\n4. Distributivity: `A.ap(A.alt(fab, gab), fa) <-> A.alt(A.ap(fab, fa), A.ap(gab, fa))`\n5. Annihilation: `A.ap(zero, fa) <-> zero`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Alternative (interface)](#alternative-interface)\n  - [Alternative1 (interface)](#alternative1-interface)\n  - [Alternative2 (interface)](#alternative2-interface)\n  - [Alternative2C (interface)](#alternative2c-interface)\n  - [Alternative3 (interface)](#alternative3-interface)\n  - [Alternative3C (interface)](#alternative3c-interface)\n  - [Alternative4 (interface)](#alternative4-interface)\n- [utils](#utils)\n  - [altAll](#altall)\n  - [getAlternativeMonoid](#getalternativemonoid)\n\n---\n\n# model\n\n## Alternative (interface)\n\n**Signature**\n\n```ts\nexport interface Alternative<F> extends Applicative<F>, Alt<F>, Zero<F> {}\n```\n\nAdded in v2.0.0\n\n## Alternative1 (interface)\n\n**Signature**\n\n```ts\nexport interface Alternative1<F extends URIS> extends Applicative1<F>, Alt1<F>, Zero1<F> {}\n```\n\nAdded in v2.0.0\n\n## Alternative2 (interface)\n\n**Signature**\n\n```ts\nexport interface Alternative2<F extends URIS2> extends Applicative2<F>, Alt2<F>, Zero2<F> {}\n```\n\nAdded in v2.0.0\n\n## Alternative2C (interface)\n\n**Signature**\n\n```ts\nexport interface Alternative2C<F extends URIS2, E> extends Applicative2C<F, E>, Alt2C<F, E>, Zero2C<F, E> {}\n```\n\nAdded in v2.0.0\n\n## Alternative3 (interface)\n\n**Signature**\n\n```ts\nexport interface Alternative3<F extends URIS3> extends Applicative3<F>, Alt3<F>, Zero3<F> {}\n```\n\nAdded in v2.0.0\n\n## Alternative3C (interface)\n\n**Signature**\n\n```ts\nexport interface Alternative3C<F extends URIS3, E> extends Applicative3C<F, E>, Alt3C<F, E>, Zero3C<F, E> {}\n```\n\nAdded in v2.10.0\n\n## Alternative4 (interface)\n\n**Signature**\n\n```ts\nexport interface Alternative4<F extends URIS4> extends Applicative4<F>, Alt4<F>, Zero4<F> {}\n```\n\nAdded in v2.10.0\n\n# utils\n\n## altAll\n\n**Signature**\n\n```ts\nexport declare function altAll<F extends URIS4>(\n  F: Alternative4<F>\n): <S, R, E, A>(as: ReadonlyArray<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>\nexport declare function altAll<F extends URIS3>(\n  F: Alternative3<F>\n): <R, E, A>(as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\nexport declare function altAll<F extends URIS3, E>(\n  F: Alternative3C<F, E>\n): <R, A>(as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\nexport declare function altAll<F extends URIS2>(\n  F: Alternative2<F>\n): <E, A>(as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>\nexport declare function altAll<F extends URIS2, E>(\n  F: Alternative2C<F, E>\n): <A>(as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>\nexport declare function altAll<F extends URIS>(F: Alternative1<F>): <A>(as: ReadonlyArray<Kind<F, A>>) => Kind<F, A>\nexport declare function altAll<F>(F: Alternative<F>): <A>(as: ReadonlyArray<HKT<F, A>>) => HKT<F, A>\n```\n\nAdded in v2.11.0\n\n## getAlternativeMonoid\n\nLift a semigroup into a monoid alternative 'F', the inner values are concatenated using the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare function getAlternativeMonoid<F extends URIS4>(\n  F: Alternative4<F>\n): <A, S, R, E>(S: Semigroup<A>) => Monoid<Kind4<F, S, R, E, A>>\nexport declare function getAlternativeMonoid<F extends URIS3>(\n  F: Alternative3<F>\n): <A, R, E>(S: Semigroup<A>) => Monoid<Kind3<F, R, E, A>>\nexport declare function getAlternativeMonoid<F extends URIS3, E>(\n  F: Alternative3C<F, E>\n): <A, R>(S: Semigroup<A>) => Monoid<Kind3<F, R, E, A>>\nexport declare function getAlternativeMonoid<F extends URIS2>(\n  F: Alternative2<F>\n): <A, E>(S: Semigroup<A>) => Monoid<Kind2<F, E, A>>\nexport declare function getAlternativeMonoid<F extends URIS2, E>(\n  F: Alternative2C<F, E>\n): <A>(S: Semigroup<A>) => Monoid<Kind2<F, E, A>>\nexport declare function getAlternativeMonoid<F extends URIS>(\n  F: Alternative1<F>\n): <A>(S: Semigroup<A>) => Monoid<Kind<F, A>>\nexport declare function getAlternativeMonoid<F>(F: Alternative<F>): <A>(S: Semigroup<A>) => Monoid<HKT<F, A>>\n```\n\nAdded in v2.13.0\n"
  },
  {
    "path": "docs/modules/Applicative.ts.md",
    "content": "---\ntitle: Applicative.ts\nnav_order: 3\nparent: Modules\n---\n\n## Applicative overview\n\nThe `Applicative` type class extends the `Apply` type class with a `of` function, which can be used to create values\nof type `f a` from values of type `a`.\n\nWhere `Apply` provides the ability to lift functions of two or more arguments to functions whose arguments are\nwrapped using `f`, and `Functor` provides the ability to lift functions of one argument, `pure` can be seen as the\nfunction which lifts functions of _zero_ arguments. That is, `Applicative` functors support a lifting operation for\nany number of function arguments.\n\nInstances must satisfy the following laws in addition to the `Apply` laws:\n\n1. Identity: `A.ap(A.of(a => a), fa) <-> fa`\n2. Homomorphism: `A.ap(A.of(ab), A.of(a)) <-> A.of(ab(a))`\n3. Interchange: `A.ap(fab, A.of(a)) <-> A.ap(A.of(ab => ab(a)), fab)`\n\nNote. `Functor`'s `map` can be derived: `A.map(x, f) = A.ap(A.of(f), x)`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Applicative (interface)](#applicative-interface)\n  - [Applicative1 (interface)](#applicative1-interface)\n  - [Applicative2 (interface)](#applicative2-interface)\n  - [Applicative2C (interface)](#applicative2c-interface)\n  - [Applicative3 (interface)](#applicative3-interface)\n  - [Applicative3C (interface)](#applicative3c-interface)\n  - [Applicative4 (interface)](#applicative4-interface)\n- [utils](#utils)\n  - [getApplicativeMonoid](#getapplicativemonoid)\n- [zone of death](#zone-of-death)\n  - [~~ApplicativeComposition11~~ (interface)](#applicativecomposition11-interface)\n  - [~~ApplicativeComposition12C~~ (interface)](#applicativecomposition12c-interface)\n  - [~~ApplicativeComposition12~~ (interface)](#applicativecomposition12-interface)\n  - [~~ApplicativeComposition21~~ (interface)](#applicativecomposition21-interface)\n  - [~~ApplicativeComposition22C~~ (interface)](#applicativecomposition22c-interface)\n  - [~~ApplicativeComposition22~~ (interface)](#applicativecomposition22-interface)\n  - [~~ApplicativeComposition2C1~~ (interface)](#applicativecomposition2c1-interface)\n  - [~~ApplicativeCompositionHKT1~~ (interface)](#applicativecompositionhkt1-interface)\n  - [~~ApplicativeCompositionHKT2C~~ (interface)](#applicativecompositionhkt2c-interface)\n  - [~~ApplicativeCompositionHKT2~~ (interface)](#applicativecompositionhkt2-interface)\n  - [~~ApplicativeComposition~~ (interface)](#applicativecomposition-interface)\n  - [~~getApplicativeComposition~~](#getapplicativecomposition)\n\n---\n\n# model\n\n## Applicative (interface)\n\n**Signature**\n\n```ts\nexport interface Applicative<F> extends Apply<F>, Pointed<F> {}\n```\n\nAdded in v2.0.0\n\n## Applicative1 (interface)\n\n**Signature**\n\n```ts\nexport interface Applicative1<F extends URIS> extends Apply1<F>, Pointed1<F> {}\n```\n\nAdded in v2.0.0\n\n## Applicative2 (interface)\n\n**Signature**\n\n```ts\nexport interface Applicative2<F extends URIS2> extends Apply2<F>, Pointed2<F> {}\n```\n\nAdded in v2.0.0\n\n## Applicative2C (interface)\n\n**Signature**\n\n```ts\nexport interface Applicative2C<F extends URIS2, E> extends Apply2C<F, E>, Pointed2C<F, E> {}\n```\n\nAdded in v2.0.0\n\n## Applicative3 (interface)\n\n**Signature**\n\n```ts\nexport interface Applicative3<F extends URIS3> extends Apply3<F>, Pointed3<F> {}\n```\n\nAdded in v2.0.0\n\n## Applicative3C (interface)\n\n**Signature**\n\n```ts\nexport interface Applicative3C<F extends URIS3, E> extends Apply3C<F, E>, Pointed3C<F, E> {}\n```\n\nAdded in v2.2.0\n\n## Applicative4 (interface)\n\n**Signature**\n\n```ts\nexport interface Applicative4<F extends URIS4> extends Apply4<F>, Pointed4<F> {}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## getApplicativeMonoid\n\nLift a monoid into 'F', the inner values are concatenated using the provided `Monoid`.\n\n**Signature**\n\n```ts\nexport declare function getApplicativeMonoid<F extends URIS4>(\n  F: Applicative4<F>\n): <A, S, R, E>(M: Monoid<A>) => Monoid<Kind4<F, S, R, E, A>>\nexport declare function getApplicativeMonoid<F extends URIS3>(\n  F: Applicative3<F>\n): <A, R, E>(M: Monoid<A>) => Monoid<Kind3<F, R, E, A>>\nexport declare function getApplicativeMonoid<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <A, R>(M: Monoid<A>) => Monoid<Kind3<F, R, E, A>>\nexport declare function getApplicativeMonoid<F extends URIS2>(\n  F: Applicative2<F>\n): <A, E>(M: Monoid<A>) => Monoid<Kind2<F, E, A>>\nexport declare function getApplicativeMonoid<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <A>(M: Monoid<A>) => Monoid<Kind2<F, E, A>>\nexport declare function getApplicativeMonoid<F extends URIS>(\n  F: Applicative1<F>\n): <A>(M: Monoid<A>) => Monoid<Kind<F, A>>\nexport declare function getApplicativeMonoid<F>(F: Applicative<F>): <A>(M: Monoid<A>) => Monoid<HKT<F, A>>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~ApplicativeComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeComposition11<F extends URIS, G extends URIS> extends FunctorComposition11<F, G> {\n  readonly of: <A>(a: A) => Kind<F, Kind<G, A>>\n  readonly ap: <A, B>(fgab: Kind<F, Kind<G, (a: A) => B>>, fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeComposition12C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeComposition12C<F extends URIS, G extends URIS2, E> extends FunctorComposition12C<F, G, E> {\n  readonly of: <A>(a: A) => Kind<F, Kind2<G, E, A>>\n  readonly ap: <A, B>(fgab: Kind<F, Kind2<G, E, (a: A) => B>>, fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeComposition12~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeComposition12<F extends URIS, G extends URIS2> extends FunctorComposition12<F, G> {\n  readonly of: <E, A>(a: A) => Kind<F, Kind2<G, E, A>>\n  readonly ap: <E, A, B>(\n    fgab: Kind<F, Kind2<G, E, (a: A) => B>>,\n    fga: Kind<F, Kind2<G, E, A>>\n  ) => Kind<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeComposition21~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeComposition21<F extends URIS2, G extends URIS> extends FunctorComposition21<F, G> {\n  readonly of: <E, A>(a: A) => Kind2<F, E, Kind<G, A>>\n  readonly ap: <E, A, B>(\n    fgab: Kind2<F, E, Kind<G, (a: A) => B>>,\n    fga: Kind2<F, E, Kind<G, A>>\n  ) => Kind2<F, E, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeComposition22C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeComposition22C<F extends URIS2, G extends URIS2, E> extends FunctorComposition22C<F, G, E> {\n  readonly of: <FE, A>(a: A) => Kind2<F, FE, Kind2<G, E, A>>\n  readonly ap: <FE, A, B>(\n    fgab: Kind2<F, FE, Kind2<G, E, (a: A) => B>>,\n    fga: Kind2<F, FE, Kind2<G, E, A>>\n  ) => Kind2<F, FE, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeComposition22~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeComposition22<F extends URIS2, G extends URIS2> extends FunctorComposition22<F, G> {\n  readonly of: <FE, GE, A>(a: A) => Kind2<F, FE, Kind2<G, GE, A>>\n  readonly ap: <FE, GE, A, B>(\n    fgab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>,\n    fga: Kind2<F, FE, Kind2<G, GE, A>>\n  ) => Kind2<F, FE, Kind2<G, GE, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeComposition2C1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeComposition2C1<F extends URIS2, G extends URIS, E> extends FunctorComposition2C1<F, G, E> {\n  readonly of: <A>(a: A) => Kind2<F, E, Kind<G, A>>\n  readonly ap: <A, B>(fgab: Kind2<F, E, Kind<G, (a: A) => B>>, fga: Kind2<F, E, Kind<G, A>>) => Kind2<F, E, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeCompositionHKT1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeCompositionHKT1<F, G extends URIS> extends FunctorCompositionHKT1<F, G> {\n  readonly of: <A>(a: A) => HKT<F, Kind<G, A>>\n  readonly ap: <A, B>(fgab: HKT<F, Kind<G, (a: A) => B>>, fga: HKT<F, Kind<G, A>>) => HKT<F, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeCompositionHKT2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeCompositionHKT2C<F, G extends URIS2, E> extends FunctorCompositionHKT2C<F, G, E> {\n  readonly of: <A>(a: A) => HKT<F, Kind2<G, E, A>>\n  readonly ap: <A, B>(fgab: HKT<F, Kind2<G, E, (a: A) => B>>, fga: HKT<F, Kind2<G, E, A>>) => HKT<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeCompositionHKT2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeCompositionHKT2<F, G extends URIS2> extends FunctorCompositionHKT2<F, G> {\n  readonly of: <E, A>(a: A) => HKT<F, Kind2<G, E, A>>\n  readonly ap: <E, A, B>(fgab: HKT<F, Kind2<G, E, (a: A) => B>>, fga: HKT<F, Kind2<G, E, A>>) => HKT<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ApplicativeComposition~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ApplicativeComposition<F, G> extends FunctorComposition<F, G> {\n  readonly of: <A>(a: A) => HKT<F, HKT<G, A>>\n  readonly ap: <A, B>(fgab: HKT<F, HKT<G, (a: A) => B>>, fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~getApplicativeComposition~~\n\nUse [`ap`](./Apply.ts.html#ap) instead.\n\n**Signature**\n\n```ts\nexport declare function getApplicativeComposition<F extends URIS2, G extends URIS2, E>(\n  F: Applicative2<F>,\n  G: Applicative2C<G, E>\n): ApplicativeComposition22C<F, G, E>\nexport declare function getApplicativeComposition<F extends URIS2, G extends URIS2>(\n  F: Applicative2<F>,\n  G: Applicative2<G>\n): ApplicativeComposition22<F, G>\nexport declare function getApplicativeComposition<F extends URIS2, G extends URIS2, E>(\n  F: Applicative2<F>,\n  G: Applicative2C<G, E>\n): ApplicativeComposition22C<F, G, E>\nexport declare function getApplicativeComposition<F extends URIS2, G extends URIS>(\n  F: Applicative2<F>,\n  G: Applicative1<G>\n): ApplicativeComposition21<F, G>\nexport declare function getApplicativeComposition<F extends URIS, G extends URIS2>(\n  F: Applicative1<F>,\n  G: Applicative2<G>\n): ApplicativeComposition12<F, G>\nexport declare function getApplicativeComposition<F extends URIS, G extends URIS2, E>(\n  F: Applicative1<F>,\n  G: Applicative2C<G, E>\n): ApplicativeComposition12C<F, G, E>\nexport declare function getApplicativeComposition<F extends URIS, G extends URIS>(\n  F: Applicative1<F>,\n  G: Applicative1<G>\n): ApplicativeComposition11<F, G>\nexport declare function getApplicativeComposition<F, G extends URIS2>(\n  F: Applicative<F>,\n  G: Applicative2<G>\n): ApplicativeCompositionHKT2<F, G>\nexport declare function getApplicativeComposition<F, G extends URIS2, E>(\n  F: Applicative<F>,\n  G: Applicative2C<G, E>\n): ApplicativeCompositionHKT2C<F, G, E>\nexport declare function getApplicativeComposition<F, G extends URIS>(\n  F: Applicative<F>,\n  G: Applicative1<G>\n): ApplicativeCompositionHKT1<F, G>\nexport declare function getApplicativeComposition<F, G>(\n  F: Applicative<F>,\n  G: Applicative<G>\n): ApplicativeComposition<F, G>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Apply.ts.md",
    "content": "---\ntitle: Apply.ts\nnav_order: 4\nparent: Modules\n---\n\n## Apply overview\n\nThe `Apply` class provides the `ap` which is used to apply a function to an argument under a type constructor.\n\n`Apply` can be used to lift functions of two or more arguments to work on values wrapped with the type constructor\n`f`.\n\nInstances must satisfy the following law in addition to the `Functor` laws:\n\n1. Associative composition: `F.ap(F.ap(F.map(fbc, bc => ab => a => bc(ab(a))), fab), fa) <-> F.ap(fbc, F.ap(fab, fa))`\n\nFormally, `Apply` represents a strong lax semi-monoidal endofunctor.\n\n**Example**\n\n```ts\nimport * as O from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\nconst f = (a: string) => (b: number) => (c: boolean) => a + String(b) + String(c)\nconst fa: O.Option<string> = O.some('s')\nconst fb: O.Option<number> = O.some(1)\nconst fc: O.Option<boolean> = O.some(true)\n\nassert.deepStrictEqual(\n  pipe(\n    // lift a function\n    O.some(f),\n    // apply the first argument\n    O.ap(fa),\n    // apply the second argument\n    O.ap(fb),\n    // apply the third argument\n    O.ap(fc)\n  ),\n  O.some('s1true')\n)\n```\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Apply (interface)](#apply-interface)\n  - [Apply1 (interface)](#apply1-interface)\n  - [Apply2 (interface)](#apply2-interface)\n  - [Apply2C (interface)](#apply2c-interface)\n  - [Apply3 (interface)](#apply3-interface)\n  - [Apply3C (interface)](#apply3c-interface)\n  - [Apply4 (interface)](#apply4-interface)\n- [utils](#utils)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apS](#aps)\n  - [apSecond](#apsecond)\n  - [getApplySemigroup](#getapplysemigroup)\n  - [sequenceS](#sequences)\n  - [sequenceT](#sequencet)\n\n---\n\n# model\n\n## Apply (interface)\n\n**Signature**\n\n```ts\nexport interface Apply<F> extends Functor<F> {\n  readonly ap: <A, B>(fab: HKT<F, (a: A) => B>, fa: HKT<F, A>) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Apply1 (interface)\n\n**Signature**\n\n```ts\nexport interface Apply1<F extends URIS> extends Functor1<F> {\n  readonly ap: <A, B>(fab: Kind<F, (a: A) => B>, fa: Kind<F, A>) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Apply2 (interface)\n\n**Signature**\n\n```ts\nexport interface Apply2<F extends URIS2> extends Functor2<F> {\n  readonly ap: <E, A, B>(fab: Kind2<F, E, (a: A) => B>, fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Apply2C (interface)\n\n**Signature**\n\n```ts\nexport interface Apply2C<F extends URIS2, E> extends Functor2C<F, E> {\n  readonly ap: <A, B>(fab: Kind2<F, E, (a: A) => B>, fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Apply3 (interface)\n\n**Signature**\n\n```ts\nexport interface Apply3<F extends URIS3> extends Functor3<F> {\n  readonly ap: <R, E, A, B>(fab: Kind3<F, R, E, (a: A) => B>, fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Apply3C (interface)\n\n**Signature**\n\n```ts\nexport interface Apply3C<F extends URIS3, E> extends Functor3C<F, E> {\n  readonly ap: <R, A, B>(fab: Kind3<F, R, E, (a: A) => B>, fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## Apply4 (interface)\n\n**Signature**\n\n```ts\nexport interface Apply4<F extends URIS4> extends Functor4<F> {\n  readonly ap: <S, R, E, A, B>(fab: Kind4<F, S, R, E, (a: A) => B>, fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ap\n\n`ap` composition.\n\n**Signature**\n\n```ts\nexport declare function ap<F extends URIS4, G extends URIS4>(\n  F: Apply4<F>,\n  G: Apply4<G>\n): <FS, FR, FE, GS, GR, GE, A>(\n  fa: Kind4<F, FS, FR, FE, Kind4<G, GS, GR, GE, A>>\n) => <B>(fab: Kind4<F, FS, FR, FE, Kind4<G, GS, GR, GE, (a: A) => B>>) => Kind4<F, FS, FR, FE, Kind4<G, GS, GR, GE, B>>\nexport declare function ap<F extends URIS4, G extends URIS3>(\n  F: Apply4<F>,\n  G: Apply3<G>\n): <S, FR, FE, GR, GE, A>(\n  fa: Kind4<F, S, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind4<F, S, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind4<F, S, FR, FE, Kind3<G, GR, GE, B>>\nexport declare function ap<F extends URIS4, G extends URIS3, GE>(\n  F: Apply4<F>,\n  G: Apply3C<G, GE>\n): <S, FR, FE, GR, A>(\n  fa: Kind4<F, S, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind4<F, S, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind4<F, S, FR, FE, Kind3<G, GR, GE, B>>\nexport declare function ap<F extends URIS4, G extends URIS2>(\n  F: Apply4<F>,\n  G: Apply2<G>\n): <S, R, FE, GE, A>(\n  fa: Kind4<F, S, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind4<F, S, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind4<F, S, R, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS4, G extends URIS2, GE>(\n  F: Apply4<F>,\n  G: Apply2C<G, GE>\n): <S, R, FE, A>(\n  fa: Kind4<F, S, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind4<F, S, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind4<F, S, R, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS4, G extends URIS>(\n  F: Apply4<F>,\n  G: Apply1<G>\n): <S, R, E, A>(\n  fa: Kind4<F, S, R, E, Kind<G, A>>\n) => <B>(fab: Kind4<F, S, R, E, Kind<G, (a: A) => B>>) => Kind4<F, S, R, E, Kind<G, B>>\nexport declare function ap<F extends URIS3, FE, G extends URIS4>(\n  F: Apply3C<F, FE>,\n  G: Apply4<G>\n): <FR, S, GR, GE, A>(\n  fa: Kind3<F, FR, FE, Kind4<G, S, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind4<G, S, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind4<G, S, GR, GE, B>>\nexport declare function ap<F extends URIS3, FE, G extends URIS3>(\n  F: Apply3C<F, FE>,\n  G: Apply3<G>\n): <FR, GR, GE, A>(\n  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>\nexport declare function ap<F extends URIS3, FE, G extends URIS3, GE>(\n  F: Apply3C<F, FE>,\n  G: Apply3C<G, GE>\n): <FR, GR, A>(\n  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>\nexport declare function ap<F extends URIS3, FE, G extends URIS2>(\n  F: Apply3C<F, FE>,\n  G: Apply2<G>\n): <R, GE, A>(\n  fa: Kind3<F, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS3, FE, G extends URIS2, GE>(\n  F: Apply3C<F, FE>,\n  G: Apply2C<G, GE>\n): <R, A>(\n  fa: Kind3<F, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS3, E, G extends URIS>(\n  F: Apply3C<F, E>,\n  G: Apply1<G>\n): <R, A>(\n  fa: Kind3<F, R, E, Kind<G, A>>\n) => <B>(fab: Kind3<F, R, E, Kind<G, (a: A) => B>>) => Kind3<F, R, E, Kind<G, B>>\nexport declare function ap<F extends URIS3, G extends URIS4>(\n  F: Apply3<F>,\n  G: Apply4<G>\n): <FR, FE, S, GR, GE, A>(\n  fa: Kind3<F, FR, FE, Kind4<G, S, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind4<G, S, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind4<G, S, GR, GE, B>>\nexport declare function ap<F extends URIS3, G extends URIS3>(\n  F: Apply3<F>,\n  G: Apply3<G>\n): <FR, FE, GR, GE, A>(\n  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>\nexport declare function ap<F extends URIS3, G extends URIS3, GE>(\n  F: Apply3<F>,\n  G: Apply3C<G, GE>\n): <FR, FE, GR, A>(\n  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>\nexport declare function ap<F extends URIS3, G extends URIS2>(\n  F: Apply3<F>,\n  G: Apply2<G>\n): <R, FE, GE, A>(\n  fa: Kind3<F, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS3, G extends URIS2, GE>(\n  F: Apply3<F>,\n  G: Apply2C<G, GE>\n): <R, FE, A>(\n  fa: Kind3<F, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS3, G extends URIS>(\n  F: Apply3<F>,\n  G: Apply1<G>\n): <R, E, A>(\n  fa: Kind3<F, R, E, Kind<G, A>>\n) => <B>(fab: Kind3<F, R, E, Kind<G, (a: A) => B>>) => Kind3<F, R, E, Kind<G, B>>\nexport declare function ap<F extends URIS2, FE, G extends URIS4>(\n  F: Apply2C<F, FE>,\n  G: Apply4<G>\n): <S, R, GE, A>(\n  fa: Kind2<F, FE, Kind4<G, S, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind4<G, S, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind4<G, S, R, GE, B>>\nexport declare function ap<F extends URIS2, FE, G extends URIS3>(\n  F: Apply2C<F, FE>,\n  G: Apply3<G>\n): <R, GE, A>(\n  fa: Kind2<F, FE, Kind3<G, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>\nexport declare function ap<F extends URIS2, FE, G extends URIS3, GE>(\n  F: Apply2C<F, FE>,\n  G: Apply3C<G, GE>\n): <R, A>(\n  fa: Kind2<F, FE, Kind3<G, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>\nexport declare function ap<F extends URIS2, FE, G extends URIS2>(\n  F: Apply2C<F, FE>,\n  G: Apply2<G>\n): <GE, A>(\n  fa: Kind2<F, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS2, FE, G extends URIS2, GE>(\n  F: Apply2C<F, FE>,\n  G: Apply2C<G, GE>\n): <A>(\n  fa: Kind2<F, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS2, E, G extends URIS>(\n  F: Apply2C<F, E>,\n  G: Apply1<G>\n): <A>(fa: Kind2<F, E, Kind<G, A>>) => <B>(fab: Kind2<F, E, Kind<G, (a: A) => B>>) => Kind2<F, E, Kind<G, B>>\nexport declare function ap<F extends URIS2, G extends URIS4>(\n  F: Apply2<F>,\n  G: Apply4<G>\n): <FE, S, R, GE, A>(\n  fa: Kind2<F, FE, Kind4<G, S, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind4<G, S, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind4<G, S, R, GE, B>>\nexport declare function ap<F extends URIS2, G extends URIS3>(\n  F: Apply2<F>,\n  G: Apply3<G>\n): <FE, R, GE, A>(\n  fa: Kind2<F, FE, Kind3<G, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>\nexport declare function ap<F extends URIS2, G extends URIS3, GE>(\n  F: Apply2<F>,\n  G: Apply3C<G, GE>\n): <FE, R, A>(\n  fa: Kind2<F, FE, Kind3<G, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>\nexport declare function ap<F extends URIS2, G extends URIS2>(\n  F: Apply2<F>,\n  G: Apply2<G>\n): <FE, GE, A>(\n  fa: Kind2<F, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS2, G extends URIS2, GE>(\n  F: Apply2<F>,\n  G: Apply2C<G, GE>\n): <FE, A>(\n  fa: Kind2<F, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>\nexport declare function ap<F extends URIS2, G extends URIS>(\n  F: Apply2<F>,\n  G: Apply1<G>\n): <E, A>(fa: Kind2<F, E, Kind<G, A>>) => <B>(fab: Kind2<F, E, Kind<G, (a: A) => B>>) => Kind2<F, E, Kind<G, B>>\nexport declare function ap<F extends URIS, G extends URIS4>(\n  F: Apply1<F>,\n  G: Apply4<G>\n): <S, R, E, A>(\n  fa: Kind<F, Kind4<G, S, R, E, A>>\n) => <B>(fab: Kind<F, Kind4<G, S, R, E, (a: A) => B>>) => Kind<F, Kind4<G, S, R, E, B>>\nexport declare function ap<F extends URIS, G extends URIS3>(\n  F: Apply1<F>,\n  G: Apply3<G>\n): <R, E, A>(\n  fa: Kind<F, Kind3<G, R, E, A>>\n) => <B>(fab: Kind<F, Kind3<G, R, E, (a: A) => B>>) => Kind<F, Kind3<G, R, E, B>>\nexport declare function ap<F extends URIS, G extends URIS3, E>(\n  F: Apply1<F>,\n  G: Apply3C<G, E>\n): <R, A>(\n  fa: Kind<F, Kind3<G, R, E, A>>\n) => <B>(fab: Kind<F, Kind3<G, R, E, (a: A) => B>>) => Kind<F, Kind3<G, R, E, B>>\nexport declare function ap<F extends URIS, G extends URIS2>(\n  F: Apply1<F>,\n  G: Apply2<G>\n): <E, A>(fa: Kind<F, Kind2<G, E, A>>) => <B>(fab: Kind<F, Kind2<G, E, (a: A) => B>>) => Kind<F, Kind2<G, E, B>>\nexport declare function ap<F extends URIS, G extends URIS2, E>(\n  F: Apply1<F>,\n  G: Apply2C<G, E>\n): <A>(fa: Kind<F, Kind2<G, E, A>>) => <B>(fab: Kind<F, Kind2<G, E, (a: A) => B>>) => Kind<F, Kind2<G, E, B>>\nexport declare function ap<F extends URIS, G extends URIS>(\n  F: Apply1<F>,\n  G: Apply1<G>\n): <A>(fa: Kind<F, Kind<G, A>>) => <B>(fab: Kind<F, Kind<G, (a: A) => B>>) => Kind<F, Kind<G, B>>\nexport declare function ap<F, G extends URIS4>(\n  F: Apply<F>,\n  G: Apply4<G>\n): <S, R, E, A>(\n  fa: HKT<F, Kind4<G, S, R, E, A>>\n) => <B>(fab: HKT<F, Kind4<G, S, R, E, (a: A) => B>>) => HKT<F, Kind4<G, S, R, E, B>>\nexport declare function ap<F, G extends URIS3>(\n  F: Apply<F>,\n  G: Apply3<G>\n): <R, E, A>(\n  fa: HKT<F, Kind3<G, R, E, A>>\n) => <B>(fab: HKT<F, Kind3<G, R, E, (a: A) => B>>) => HKT<F, Kind3<G, R, E, B>>\nexport declare function ap<F, G extends URIS3, E>(\n  F: Apply<F>,\n  G: Apply3C<G, E>\n): <R, A>(fa: HKT<F, Kind3<G, R, E, A>>) => <B>(fab: HKT<F, Kind3<G, R, E, (a: A) => B>>) => HKT<F, Kind3<G, R, E, B>>\nexport declare function ap<F, G extends URIS2>(\n  F: Apply<F>,\n  G: Apply2<G>\n): <E, A>(fa: HKT<F, Kind2<G, E, A>>) => <B>(fab: HKT<F, Kind2<G, E, (a: A) => B>>) => HKT<F, Kind2<G, E, B>>\nexport declare function ap<F, G extends URIS2, E>(\n  F: Apply<F>,\n  G: Apply2C<G, E>\n): <A>(fa: HKT<F, Kind2<G, E, A>>) => <B>(fab: HKT<F, Kind2<G, E, (a: A) => B>>) => HKT<F, Kind2<G, E, B>>\nexport declare function ap<F, G extends URIS>(\n  F: Apply<F>,\n  G: Apply1<G>\n): <A>(fa: HKT<F, Kind<G, A>>) => <B>(fab: HKT<F, Kind<G, (a: A) => B>>) => HKT<F, Kind<G, B>>\nexport declare function ap<F, G>(\n  F: Apply<F>,\n  G: Apply<G>\n): <A>(fa: HKT<F, HKT<G, A>>) => <B>(fab: HKT<F, HKT<G, (a: A) => B>>) => HKT<F, HKT<G, B>>\n```\n\nAdded in v2.10.0\n\n## apFirst\n\n**Signature**\n\n```ts\nexport declare function apFirst<F extends URIS4>(\n  A: Apply4<F>\n): <S, R, E, B>(second: Kind4<F, S, R, E, B>) => <A>(first: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\nexport declare function apFirst<F extends URIS3>(\n  A: Apply3<F>\n): <R, E, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\nexport declare function apFirst<F extends URIS3, E>(\n  A: Apply3C<F, E>\n): <R, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\nexport declare function apFirst<F extends URIS2>(\n  A: Apply2<F>\n): <E, B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, A>\nexport declare function apFirst<F extends URIS2, E>(\n  A: Apply2C<F, E>\n): <B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, A>\nexport declare function apFirst<F extends URIS>(\n  A: Apply1<F>\n): <B>(second: Kind<F, B>) => <A>(first: Kind<F, A>) => Kind<F, A>\nexport declare function apFirst<F>(A: Apply<F>): <B>(second: HKT<F, B>) => <A>(first: HKT<F, A>) => HKT<F, A>\n```\n\nAdded in v2.10.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare function apS<F extends URIS4>(\n  F: Apply4<F>\n): <N extends string, A, S, R, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind4<F, S, R, E, B>\n) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function apS<F extends URIS3>(\n  F: Apply3<F>\n): <N extends string, A, R, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind3<F, R, E, B>\n) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function apS<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <N extends string, A, R, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind3<F, R, E, B>\n) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function apS<F extends URIS2>(\n  F: Apply2<F>\n): <N extends string, A, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind2<F, E, B>\n) => (fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function apS<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind2<F, E, B>\n) => (fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function apS<F extends URIS>(\n  F: Apply1<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind<F, B>\n) => (fa: Kind<F, A>) => Kind<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function apS<F>(\n  F: Apply<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: HKT<F, B>\n) => (fa: HKT<F, A>) => HKT<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.10.0\n\n## apSecond\n\n**Signature**\n\n```ts\nexport declare function apSecond<F extends URIS4>(\n  A: Apply4<F>\n): <S, R, E, B>(second: Kind4<F, S, R, E, B>) => <A>(first: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport declare function apSecond<F extends URIS3>(\n  A: Apply3<F>\n): <R, E, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function apSecond<F extends URIS3, E>(\n  A: Apply3C<F, E>\n): <R, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function apSecond<F extends URIS2>(\n  A: Apply2<F>\n): <E, B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function apSecond<F extends URIS2, E>(\n  A: Apply2C<F, E>\n): <B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function apSecond<F extends URIS>(\n  A: Apply1<F>\n): <B>(second: Kind<F, B>) => <A>(first: Kind<F, A>) => Kind<F, B>\nexport declare function apSecond<F>(A: Apply<F>): <B>(second: HKT<F, B>) => <A>(first: HKT<F, A>) => HKT<F, B>\n```\n\nAdded in v2.10.0\n\n## getApplySemigroup\n\nLift a semigroup into 'F', the inner values are concatenated using the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare function getApplySemigroup<F extends URIS4>(\n  F: Apply4<F>\n): <A, S, R, E>(S: Semigroup<A>) => Semigroup<Kind4<F, S, R, E, A>>\nexport declare function getApplySemigroup<F extends URIS3>(\n  F: Apply3<F>\n): <A, R, E>(S: Semigroup<A>) => Semigroup<Kind3<F, R, E, A>>\nexport declare function getApplySemigroup<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <A, R>(S: Semigroup<A>) => Semigroup<Kind3<F, R, E, A>>\nexport declare function getApplySemigroup<F extends URIS2>(\n  F: Apply2<F>\n): <A, E>(S: Semigroup<A>) => Semigroup<Kind2<F, E, A>>\nexport declare function getApplySemigroup<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <A>(S: Semigroup<A>) => Semigroup<Kind2<F, E, A>>\nexport declare function getApplySemigroup<F extends URIS>(F: Apply1<F>): <A>(S: Semigroup<A>) => Semigroup<Kind<F, A>>\nexport declare function getApplySemigroup<F>(F: Apply<F>): <A>(S: Semigroup<A>) => Semigroup<HKT<F, A>>\n```\n\nAdded in v2.10.0\n\n## sequenceS\n\nLike `Apply.sequenceT` but works with structs instead of tuples.\n\n**Signature**\n\n```ts\nexport declare function sequenceS<F extends URIS4>(\n  F: Apply4<F>\n): <S, R, E, NER extends Record<string, Kind4<F, S, R, E, any>>>(\n  r: EnforceNonEmptyRecord<NER> & Record<string, Kind4<F, S, R, E, any>>\n) => Kind4<F, S, R, E, { [K in keyof NER]: [NER[K]] extends [Kind4<F, any, any, any, infer A>] ? A : never }>\nexport declare function sequenceS<F extends URIS3>(\n  F: Apply3<F>\n): <R, E, NER extends Record<string, Kind3<F, R, E, any>>>(\n  r: EnforceNonEmptyRecord<NER> & Record<string, Kind3<F, R, E, any>>\n) => Kind3<F, R, E, { [K in keyof NER]: [NER[K]] extends [Kind3<F, any, any, infer A>] ? A : never }>\nexport declare function sequenceS<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <R, NER extends Record<string, Kind3<F, R, E, any>>>(\n  r: EnforceNonEmptyRecord<NER> & Record<string, Kind3<F, R, E, any>>\n) => Kind3<F, R, E, { [K in keyof NER]: [NER[K]] extends [Kind3<F, any, any, infer A>] ? A : never }>\nexport declare function sequenceS<F extends URIS2>(\n  F: Apply2<F>\n): <E, NER extends Record<string, Kind2<F, E, any>>>(\n  r: EnforceNonEmptyRecord<NER> & Record<string, Kind2<F, E, any>>\n) => Kind2<F, E, { [K in keyof NER]: [NER[K]] extends [Kind2<F, any, infer A>] ? A : never }>\nexport declare function sequenceS<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <NER extends Record<string, Kind2<F, E, any>>>(\n  r: EnforceNonEmptyRecord<NER>\n) => Kind2<F, E, { [K in keyof NER]: [NER[K]] extends [Kind2<F, any, infer A>] ? A : never }>\nexport declare function sequenceS<F extends URIS>(\n  F: Apply1<F>\n): <NER extends Record<string, Kind<F, any>>>(\n  r: EnforceNonEmptyRecord<NER>\n) => Kind<F, { [K in keyof NER]: [NER[K]] extends [Kind<F, infer A>] ? A : never }>\nexport declare function sequenceS<F>(\n  F: Apply<F>\n): <NER extends Record<string, HKT<F, any>>>(\n  r: EnforceNonEmptyRecord<NER>\n) => HKT<F, { [K in keyof NER]: [NER[K]] extends [HKT<F, infer A>] ? A : never }>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { sequenceS } from 'fp-ts/Apply'\n\nconst ado = sequenceS(E.Apply)\n\nassert.deepStrictEqual(\n  ado({\n    a: E.right(1),\n    b: E.right(true),\n  }),\n  E.right({ a: 1, b: true })\n)\nassert.deepStrictEqual(\n  ado({\n    a: E.right(1),\n    b: E.left('error'),\n  }),\n  E.left('error')\n)\n```\n\nAdded in v2.0.0\n\n## sequenceT\n\nTuple sequencing, i.e., take a tuple of monadic actions and does them from left-to-right, returning the resulting tuple.\n\n**Signature**\n\n```ts\nexport declare function sequenceT<F extends URIS4>(\n  F: Apply4<F>\n): <S, R, E, T extends Array<Kind4<F, S, R, E, any>>>(\n  ...t: T & { readonly 0: Kind4<F, S, R, E, any> }\n) => Kind4<F, S, R, E, { [K in keyof T]: [T[K]] extends [Kind4<F, S, R, E, infer A>] ? A : never }>\nexport declare function sequenceT<F extends URIS3>(\n  F: Apply3<F>\n): <R, E, T extends Array<Kind3<F, R, E, any>>>(\n  ...t: T & { readonly 0: Kind3<F, R, E, any> }\n) => Kind3<F, R, E, { [K in keyof T]: [T[K]] extends [Kind3<F, R, E, infer A>] ? A : never }>\nexport declare function sequenceT<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <R, T extends Array<Kind3<F, R, E, any>>>(\n  ...t: T & { readonly 0: Kind3<F, R, E, any> }\n) => Kind3<F, R, E, { [K in keyof T]: [T[K]] extends [Kind3<F, R, E, infer A>] ? A : never }>\nexport declare function sequenceT<F extends URIS2>(\n  F: Apply2<F>\n): <E, T extends Array<Kind2<F, E, any>>>(\n  ...t: T & { readonly 0: Kind2<F, E, any> }\n) => Kind2<F, E, { [K in keyof T]: [T[K]] extends [Kind2<F, E, infer A>] ? A : never }>\nexport declare function sequenceT<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <T extends Array<Kind2<F, E, any>>>(\n  ...t: T & { readonly 0: Kind2<F, E, any> }\n) => Kind2<F, E, { [K in keyof T]: [T[K]] extends [Kind2<F, E, infer A>] ? A : never }>\nexport declare function sequenceT<F extends URIS>(\n  F: Apply1<F>\n): <T extends Array<Kind<F, any>>>(\n  ...t: T & { readonly 0: Kind<F, any> }\n) => Kind<F, { [K in keyof T]: [T[K]] extends [Kind<F, infer A>] ? A : never }>\nexport declare function sequenceT<F>(\n  F: Apply<F>\n): <T extends Array<HKT<F, any>>>(\n  ...t: T & { readonly 0: HKT<F, any> }\n) => HKT<F, { [K in keyof T]: [T[K]] extends [HKT<F, infer A>] ? A : never }>\n```\n\n**Example**\n\n```ts\nimport { sequenceT } from 'fp-ts/Apply'\nimport * as O from 'fp-ts/Option'\n\nconst sequenceTOption = sequenceT(O.Apply)\nassert.deepStrictEqual(sequenceTOption(O.some(1)), O.some([1]))\nassert.deepStrictEqual(sequenceTOption(O.some(1), O.some('2')), O.some([1, '2']))\nassert.deepStrictEqual(sequenceTOption(O.some(1), O.some('2'), O.none), O.none)\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Array.ts.md",
    "content": "---\ntitle: Array.ts\nnav_order: 5\nparent: Modules\n---\n\n## Array overview\n\nThe Array module provides tools for working with Typescript's Array<T> type in a functional way.\n\nIn functional jargon, this module provides a monadic interface over Typescript's Array<T>.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [makeBy](#makeby)\n  - [of](#of)\n  - [replicate](#replicate)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromOption](#fromoption)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [guard](#guard)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [filterMapWithIndex](#filtermapwithindex)\n  - [filterWithIndex](#filterwithindex)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [partitionMapWithIndex](#partitionmapwithindex)\n  - [partitionWithIndex](#partitionwithindex)\n  - [separate](#separate)\n  - [wilt](#wilt)\n  - [wither](#wither)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Alternative](#alternative)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [ChainRecBreadthFirst](#chainrecbreadthfirst)\n  - [ChainRecDepthFirst](#chainrecdepthfirst)\n  - [Compactable](#compactable)\n  - [Extend](#extend)\n  - [Filterable](#filterable)\n  - [FilterableWithIndex](#filterablewithindex)\n  - [Foldable](#foldable)\n  - [FoldableWithIndex](#foldablewithindex)\n  - [FromEither](#fromeither)\n  - [Functor](#functor)\n  - [FunctorWithIndex](#functorwithindex)\n  - [Monad](#monad)\n  - [Pointed](#pointed)\n  - [Traversable](#traversable)\n  - [TraversableWithIndex](#traversablewithindex)\n  - [Unfoldable](#unfoldable)\n  - [Witherable](#witherable)\n  - [Zero](#zero)\n  - [getDifferenceMagma](#getdifferencemagma)\n  - [getEq](#geteq)\n  - [getIntersectionSemigroup](#getintersectionsemigroup)\n  - [getMonoid](#getmonoid)\n  - [getOrd](#getord)\n  - [getSemigroup](#getsemigroup)\n  - [getShow](#getshow)\n  - [getUnionMonoid](#getunionmonoid)\n  - [getUnionSemigroup](#getunionsemigroup)\n- [legacy](#legacy)\n  - [chain](#chain)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromOptionK](#fromoptionk)\n  - [fromPredicate](#frompredicate)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n  - [mapWithIndex](#mapwithindex)\n- [pattern matching](#pattern-matching)\n  - [foldLeft](#foldleft)\n  - [foldRight](#foldright)\n  - [match](#match)\n  - [matchLeft](#matchleft)\n  - [matchLeftW](#matchleftw)\n  - [matchRight](#matchright)\n  - [matchRightW](#matchrightw)\n  - [matchW](#matchw)\n- [refinements](#refinements)\n  - [isEmpty](#isempty)\n  - [isNonEmpty](#isnonempty)\n- [sequencing](#sequencing)\n  - [chainFirst](#chainfirst)\n  - [chainRecBreadthFirst](#chainrecbreadthfirst)\n  - [chainRecDepthFirst](#chainrecdepthfirst)\n  - [chainWithIndex](#chainwithindex)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n  - [traverseWithIndex](#traversewithindex)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [unsafe](#unsafe)\n  - [unsafeDeleteAt](#unsafedeleteat)\n  - [unsafeInsertAt](#unsafeinsertat)\n  - [unsafeUpdateAt](#unsafeupdateat)\n- [utils](#utils)\n  - [Spanned (interface)](#spanned-interface)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [append](#append)\n  - [appendW](#appendw)\n  - [chop](#chop)\n  - [chunksOf](#chunksof)\n  - [comprehension](#comprehension)\n  - [concat](#concat)\n  - [concatW](#concatw)\n  - [copy](#copy)\n  - [deleteAt](#deleteat)\n  - [difference](#difference)\n  - [dropLeft](#dropleft)\n  - [dropLeftWhile](#dropleftwhile)\n  - [dropRight](#dropright)\n  - [duplicate](#duplicate)\n  - [elem](#elem)\n  - [every](#every)\n  - [exists](#exists)\n  - [extend](#extend)\n  - [filterE](#filtere)\n  - [findFirst](#findfirst)\n  - [findFirstMap](#findfirstmap)\n  - [findIndex](#findindex)\n  - [findLast](#findlast)\n  - [findLastIndex](#findlastindex)\n  - [findLastMap](#findlastmap)\n  - [head](#head)\n  - [init](#init)\n  - [insertAt](#insertat)\n  - [intercalate](#intercalate)\n  - [intersection](#intersection)\n  - [intersperse](#intersperse)\n  - [isOutOfBound](#isoutofbound)\n  - [last](#last)\n  - [lefts](#lefts)\n  - [lookup](#lookup)\n  - [modifyAt](#modifyat)\n  - [prepend](#prepend)\n  - [prependAll](#prependall)\n  - [prependW](#prependw)\n  - [reverse](#reverse)\n  - [rights](#rights)\n  - [rotate](#rotate)\n  - [scanLeft](#scanleft)\n  - [scanRight](#scanright)\n  - [size](#size)\n  - [some](#some)\n  - [sort](#sort)\n  - [sortBy](#sortby)\n  - [spanLeft](#spanleft)\n  - [splitAt](#splitat)\n  - [tail](#tail)\n  - [takeLeft](#takeleft)\n  - [takeLeftWhile](#takeleftwhile)\n  - [takeRight](#takeright)\n  - [unfold](#unfold)\n  - [union](#union)\n  - [uniq](#uniq)\n  - [unzip](#unzip)\n  - [updateAt](#updateat)\n  - [zero](#zero)\n  - [zip](#zip)\n  - [zipWith](#zipwith)\n- [zone of death](#zone-of-death)\n  - [~~array~~](#array)\n  - [~~cons~~](#cons)\n  - [~~empty~~](#empty)\n  - [~~prependToAll~~](#prependtoall)\n  - [~~range~~](#range)\n  - [~~snoc~~](#snoc)\n\n---\n\n# constructors\n\n## makeBy\n\nReturn a `Array` of length `n` with element `i` initialized with `f(i)`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const makeBy: <A>(n: number, f: (i: number) => A) => A[]\n```\n\n**Example**\n\n```ts\nimport { makeBy } from 'fp-ts/Array'\n\nconst double = (i: number): number => i * 2\nassert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8])\nassert.deepStrictEqual(makeBy(-3, double), [])\nassert.deepStrictEqual(makeBy(4.32164, double), [0, 2, 4, 6])\n```\n\nAdded in v2.0.0\n\n## of\n\nGiven an element of the base type, `of` builds an `Array` containing just that\nelement of the base type (this is useful for building a `Monad`).\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => A[]\n```\n\n**Example**\n\n```ts\nimport { of } from 'fp-ts/Array'\n\nassert.deepStrictEqual(of('a'), ['a'])\n```\n\nAdded in v2.0.0\n\n## replicate\n\nCreate a `Array` containing a value repeated the specified number of times.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const replicate: <A>(n: number, a: A) => A[]\n```\n\n**Example**\n\n```ts\nimport { replicate } from 'fp-ts/Array'\n\nassert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a'])\nassert.deepStrictEqual(replicate(-3, 'a'), [])\nassert.deepStrictEqual(replicate(2.985647, 'a'), ['a', 'a'])\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromEither\n\nCreate an array from an `Either`. The resulting array will contain the content of the\n`Either` if it is `Right` and it will be empty if the `Either` is `Left`.\n\n**Signature**\n\n```ts\nexport declare const fromEither: <A>(fa: Either<unknown, A>) => A[]\n```\n\n**Example**\n\n```ts\nimport { fromEither } from 'fp-ts/Array'\nimport { either } from 'fp-ts'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe(either.right('r'), fromEither), ['r'])\nassert.deepStrictEqual(pipe(either.left('l'), fromEither), [])\n```\n\nAdded in v2.11.0\n\n## fromOption\n\nCreate an array from an `Option`. The resulting array will contain the content of the\n`Option` if it is `Some` and it will be empty if the `Option` is `None`.\n\n**Signature**\n\n```ts\nexport declare const fromOption: <A>(fa: Option<A>) => A[]\n```\n\n**Example**\n\n```ts\nimport { fromOption } from 'fp-ts/Array'\nimport { option } from 'fp-ts'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe(option.some('a'), fromOption), ['a'])\nassert.deepStrictEqual(pipe(option.none, fromOption), [])\n```\n\nAdded in v2.11.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: {}[]\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: B[]\n) => (fa: A[]) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B[]\n) => (ma: A[]) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: A[]) => { readonly [K in N]: A }[]\n```\n\nAdded in v2.8.0\n\n## guard\n\n**Signature**\n\n```ts\nexport declare const guard: (b: boolean) => void[]\n```\n\nAdded in v2.11.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: A[]) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\nIn case of `Array` concatenates the inputs into a single array.\n\n**Signature**\n\n```ts\nexport declare const alt: <A>(that: LazyArg<A[]>) => (fa: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport * as A from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    A.alt(() => [4, 5])\n  ),\n  [1, 2, 3, 4, 5]\n)\n```\n\nAdded in v2.0.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <B>(that: LazyArg<B[]>) => <A>(fa: A[]) => (B | A)[]\n```\n\n**Example**\n\n```ts\nimport * as A from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    A.altW(() => ['a', 'b'])\n  ),\n  [1, 2, 3, 'a', 'b']\n)\n```\n\nAdded in v2.9.0\n\n# filtering\n\n## compact\n\nCompact an array of `Option`s discarding the `None` values and\nkeeping the `Some` values. It returns a new array containing the values of\nthe `Some` options.\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(fa: Option<A>[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { compact } from 'fp-ts/Array'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(compact([option.some('a'), option.none, option.some('b')]), ['a', 'b'])\n```\n\nAdded in v2.0.0\n\n## filter\n\nGiven an iterating function that is a `Predicate` or a `Refinement`,\n`filter` creates a new `Array` containing the elements of the original\n`Array` for which the iterating function is `true`.\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (as: A[]) => B[]\n  <A>(predicate: Predicate<A>): <B extends A>(bs: B[]) => B[]\n  <A>(predicate: Predicate<A>): (as: A[]) => A[]\n}\n```\n\n**Example**\n\n```ts\nimport { filter } from 'fp-ts/Array'\nimport { isString } from 'fp-ts/string'\n\nassert.deepStrictEqual(filter(isString)(['a', 1, {}, 'b', 5]), ['a', 'b'])\nassert.deepStrictEqual(filter((x: number) => x > 0)([-3, 1, -2, 5]), [1, 5])\n```\n\nAdded in v2.0.0\n\n## filterMap\n\nMaps an array with an iterating function that returns an `Option`\nand it keeps only the `Some` values discarding the `None`s.\n\n**Signature**\n\n```ts\nexport declare const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: A[]) => B[]\n```\n\n**Example**\n\n```ts\nimport { filterMap } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\nimport { option } from 'fp-ts'\n\nconst f = (s: string) => (s.length === 1 ? option.some(s.toUpperCase()) : option.none)\nassert.deepStrictEqual(pipe(['a', 'no', 'neither', 'b'], filterMap(f)), ['A', 'B'])\n```\n\nAdded in v2.0.0\n\n## filterMapWithIndex\n\nMaps an array with an iterating function that takes the index and the value of\neach element and returns an `Option`. It keeps only the `Some` values discarding\nthe `None`s.\n\nSame as [`filterMap`](#filterMap), but with an iterating function which takes also\nthe index as input.\n\n**Signature**\n\n```ts\nexport declare const filterMapWithIndex: <A, B>(f: (i: number, a: A) => Option<B>) => (fa: A[]) => B[]\n```\n\n**Example**\n\n```ts\nimport { filterMapWithIndex } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\nimport { option } from 'fp-ts'\n\nconst f = (i: number, s: string) => (i % 2 === 1 ? option.some(s.toUpperCase()) : option.none)\nassert.deepStrictEqual(pipe(['a', 'no', 'neither', 'b'], filterMapWithIndex(f)), ['NO', 'B'])\n```\n\nAdded in v2.0.0\n\n## filterWithIndex\n\nSame as [`filter`](#filter), but passing also the index to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const filterWithIndex: {\n  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (as: A[]) => B[]\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: B[]) => B[]\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: A[]) => A[]\n}\n```\n\n**Example**\n\n```ts\nimport { filterWithIndex } from 'fp-ts/Array'\n\nconst f = (index: number, x: number) => x > 0 && index <= 2\nassert.deepStrictEqual(filterWithIndex(f)([-3, 1, -2, 5]), [1])\n```\n\nAdded in v2.0.0\n\n## partition\n\nGiven an iterating function that is a `Predicate` or a `Refinement`,\n`partition` creates two new `Array`s: `right` containing the elements of the original\n`Array` for which the iterating function is `true`, `left` containing the elements\nfor which it is false.\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (as: A[]) => Separated<A[], B[]>\n  <A>(predicate: Predicate<A>): <B extends A>(bs: B[]) => Separated<B[], B[]>\n  <A>(predicate: Predicate<A>): (as: A[]) => Separated<A[], A[]>\n}\n```\n\n**Example**\n\n```ts\nimport { partition } from 'fp-ts/Array'\nimport { isString } from 'fp-ts/string'\n\nassert.deepStrictEqual(partition(isString)(['a', 1, {}, 'b', 5]), { left: [1, {}, 5], right: ['a', 'b'] })\nassert.deepStrictEqual(partition((x: number) => x > 0)([-3, 1, -2, 5]), { left: [-3, -2], right: [1, 5] })\n```\n\nAdded in v2.0.0\n\n## partitionMap\n\nGiven an iterating function that returns an `Either`,\n`partitionMap` applies the iterating function to each element and it creates two `Array`s:\n`right` containing the values of `Right` results, `left` containing the values of `Left` results.\n\n**Signature**\n\n```ts\nexport declare const partitionMap: <A, B, C>(f: (a: A) => Either<B, C>) => (fa: A[]) => Separated<B[], C[]>\n```\n\n**Example**\n\n```ts\nimport { partitionMap } from 'fp-ts/Array'\nimport { Either, left, right } from 'fp-ts/Either'\n\nconst upperIfString = <B>(x: B): Either<B, string> => (typeof x === 'string' ? right(x.toUpperCase()) : left(x))\nassert.deepStrictEqual(partitionMap(upperIfString)([-2, 'hello', 6, 7, 'world']), {\n  left: [-2, 6, 7],\n  right: ['HELLO', 'WORLD'],\n})\n```\n\nAdded in v2.0.0\n\n## partitionMapWithIndex\n\nSame as [`partitionMap`](#partitionMap), but passing also the index to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const partitionMapWithIndex: <A, B, C>(\n  f: (i: number, a: A) => Either<B, C>\n) => (fa: A[]) => Separated<B[], C[]>\n```\n\n**Example**\n\n```ts\nimport { partitionMapWithIndex } from 'fp-ts/Array'\nimport { Either, left, right } from 'fp-ts/Either'\n\nconst upperIfStringBefore3 = <B>(index: number, x: B): Either<B, string> =>\n  index < 3 && typeof x === 'string' ? right(x.toUpperCase()) : left(x)\nassert.deepStrictEqual(partitionMapWithIndex(upperIfStringBefore3)([-2, 'hello', 6, 7, 'world']), {\n  left: [-2, 6, 7, 'world'],\n  right: ['HELLO'],\n})\n```\n\nAdded in v2.0.0\n\n## partitionWithIndex\n\nSame as [`partition`](#partition), but passing also the index to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const partitionWithIndex: {\n  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (as: A[]) => Separated<A[], B[]>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: B[]) => Separated<B[], B[]>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: A[]) => Separated<A[], A[]>\n}\n```\n\n**Example**\n\n```ts\nimport { partitionWithIndex } from 'fp-ts/Array'\n\nassert.deepStrictEqual(partitionWithIndex((index, x: number) => index < 3 && x > 0)([-2, 5, 6, 7]), {\n  left: [-2, 7],\n  right: [5, 6],\n})\n```\n\nAdded in v2.0.0\n\n## separate\n\nSeparate an array of `Either`s into `Left`s and `Right`s, creating two new arrays:\none containing all the left values and one containing all the right values.\n\n**Signature**\n\n```ts\nexport declare const separate: <A, B>(fa: Either<A, B>[]) => Separated<A[], B[]>\n```\n\n**Example**\n\n```ts\nimport { separate } from 'fp-ts/Array'\nimport { either } from 'fp-ts'\n\nassert.deepStrictEqual(separate([either.right('r1'), either.left('l1'), either.right('r2')]), {\n  left: ['l1'],\n  right: ['r1', 'r2'],\n})\n```\n\nAdded in v2.0.0\n\n## wilt\n\n**Signature**\n\n```ts\nexport declare const wilt: PipeableWilt1<'Array'>\n```\n\nAdded in v2.6.5\n\n## wither\n\n**Signature**\n\n```ts\nexport declare const wither: PipeableWither1<'Array'>\n```\n\nAdded in v2.6.5\n\n# folding\n\n## foldMap\n\nMap and fold an `Array`.\nMap the `Array` passing each value to the iterating function.\nThen fold the results using the provided `Monoid`.\n\n**Signature**\n\n```ts\nexport declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: A[]) => M\n```\n\n**Example**\n\n```ts\nimport { foldMap } from 'fp-ts/Array'\n\nconst monoid = { concat: (a: string, b: string) => a + b, empty: '' }\nconst f = (s: string) => s.toUpperCase()\nassert.deepStrictEqual(foldMap(monoid)(f)(['a', 'b', 'c']), 'ABC')\n```\n\nAdded in v2.0.0\n\n## foldMapWithIndex\n\nSame as [`foldMap`](#foldMap) but passing also the index to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: number, a: A) => M) => (fa: A[]) => M\n```\n\n**Example**\n\n```ts\nimport { foldMapWithIndex } from 'fp-ts/Array'\n\nconst monoid = { concat: (a: string, b: string) => a + b, empty: '' }\nconst f = (index: number, s: string) => `${s.toUpperCase()}(${index})`\nassert.deepStrictEqual(foldMapWithIndex(monoid)(f)(['a', 'b', 'c']), 'A(0)B(1)C(2)')\n```\n\nAdded in v2.0.0\n\n## reduce\n\nReduces an `Array`.\n\n`reduce` executes the supplied iterating function on each element of the array,\nin order, passing in the element and the return value from the calculation on the preceding element.\n\nThe first time that the iterating function is called there is no \"return value of the\nprevious calculation\", the initial value is used in its place.\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: A[]) => B\n```\n\n**Example**\n\n```ts\nimport { reduce } from 'fp-ts/Array'\n\nassert.deepStrictEqual(reduce(5, (acc: number, cur: number) => acc * cur)([2, 3]), 5 * 2 * 3)\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\nSame as [`reduce`](#reduce) but applied from the end to the start.\n\n_Note_: the iterating function in this case takes the accumulator as the last argument.\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: A[]) => B\n```\n\n**Example**\n\n```ts\nimport { reduceRight } from 'fp-ts/Array'\n\nassert.deepStrictEqual(reduceRight('', (cur: string, acc: string) => acc + cur)(['a', 'b', 'c']), 'cba')\n```\n\nAdded in v2.0.0\n\n## reduceRightWithIndex\n\nSame as [`reduceRight`](#reduceRight) but passing also the index to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const reduceRightWithIndex: <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: A[]) => B\n```\n\n**Example**\n\n```ts\nimport { reduceRightWithIndex } from 'fp-ts/Array'\n\nconst f = (index: number, cur: unknown, acc: string) => acc + (typeof cur === 'string' ? cur.toUpperCase() + index : '')\nassert.deepStrictEqual(reduceRightWithIndex('', f)([2, 'a', 'b', null]), 'B2A1')\n```\n\nAdded in v2.0.0\n\n## reduceWithIndex\n\nSame as [`reduce`](#reduce) but passing also the index to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const reduceWithIndex: <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: A[]) => B\n```\n\n**Example**\n\n```ts\nimport { reduceWithIndex } from 'fp-ts/Array'\n\nconst f = (index: number, acc: string, cur: unknown) => acc + (typeof cur === 'string' ? cur.toUpperCase() + index : '')\nassert.deepStrictEqual(reduceWithIndex('', f)([2, 'a', 'b', null]), 'A1B2')\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt1<'Array'>\n```\n\nAdded in v2.7.0\n\n## Alternative\n\n**Signature**\n\n```ts\nexport declare const Alternative: Alternative1<'Array'>\n```\n\nAdded in v2.7.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative1<'Array'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply1<'Array'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: Chain1<'Array'>\n```\n\nAdded in v2.10.0\n\n## ChainRecBreadthFirst\n\n**Signature**\n\n```ts\nexport declare const ChainRecBreadthFirst: ChainRec1<'Array'>\n```\n\nAdded in v2.11.0\n\n## ChainRecDepthFirst\n\n**Signature**\n\n```ts\nexport declare const ChainRecDepthFirst: ChainRec1<'Array'>\n```\n\nAdded in v2.11.0\n\n## Compactable\n\n**Signature**\n\n```ts\nexport declare const Compactable: Compactable1<'Array'>\n```\n\nAdded in v2.7.0\n\n## Extend\n\n**Signature**\n\n```ts\nexport declare const Extend: Extend1<'Array'>\n```\n\nAdded in v2.7.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: Filterable1<'Array'>\n```\n\nAdded in v2.7.0\n\n## FilterableWithIndex\n\n**Signature**\n\n```ts\nexport declare const FilterableWithIndex: FilterableWithIndex1<'Array', number>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable1<'Array'>\n```\n\nAdded in v2.7.0\n\n## FoldableWithIndex\n\n**Signature**\n\n```ts\nexport declare const FoldableWithIndex: FoldableWithIndex1<'Array', number>\n```\n\nAdded in v2.7.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither1<'Array'>\n```\n\nAdded in v2.11.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'Array'>\n```\n\nAdded in v2.7.0\n\n## FunctorWithIndex\n\n**Signature**\n\n```ts\nexport declare const FunctorWithIndex: FunctorWithIndex1<'Array', number>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'Array'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'Array'>\n```\n\nAdded in v2.10.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable1<'Array'>\n```\n\nAdded in v2.7.0\n\n## TraversableWithIndex\n\n**Signature**\n\n```ts\nexport declare const TraversableWithIndex: TraversableWithIndex1<'Array', number>\n```\n\nAdded in v2.7.0\n\n## Unfoldable\n\n**Signature**\n\n```ts\nexport declare const Unfoldable: Unfoldable1<'Array'>\n```\n\nAdded in v2.7.0\n\n## Witherable\n\n**Signature**\n\n```ts\nexport declare const Witherable: Witherable1<'Array'>\n```\n\nAdded in v2.7.0\n\n## Zero\n\n**Signature**\n\n```ts\nexport declare const Zero: Zero1<'Array'>\n```\n\nAdded in v2.11.0\n\n## getDifferenceMagma\n\nGet a `Magma` for `Array` where the `concat` function is the differnce between\nthe first and the second array, i.e. the result contains all the elements of the\nfirst array for which their is no equal element in the second array according\nto the `Eq` provided.\n\n**Signature**\n\n```ts\nexport declare const getDifferenceMagma: <A>(E: Eq<A>) => Magma<A[]>\n```\n\n**Example**\n\n```ts\nimport { getDifferenceMagma } from 'fp-ts/Array'\nimport { Eq } from 'fp-ts/number'\n\nconst S = getDifferenceMagma<number>(Eq)\nassert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1])\n```\n\nAdded in v2.11.0\n\n## getEq\n\nDerives an `Eq` over the `Array` of a given element type from the `Eq` of that type. The derived `Eq` defines two\narrays as equal if all elements of both arrays are compared equal pairwise with the given `E`. In case of arrays of\ndifferent lengths, the result is non equality.\n\n**Signature**\n\n```ts\nexport declare const getEq: <A>(E: Eq<A>) => Eq<A[]>\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { getEq } from 'fp-ts/Array'\n\nconst E = getEq(S.Eq)\nassert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true)\nassert.strictEqual(E.equals(['a'], []), false)\n```\n\nAdded in v2.0.0\n\n## getIntersectionSemigroup\n\nGet a `Semigroup` based on the intersection of the elements of `Array`s.\nOnly elements present in the two arrays which are equal according to the\nprovided `Eq` are included in the result.\n\n**Signature**\n\n```ts\nexport declare const getIntersectionSemigroup: <A>(E: Eq<A>) => Semigroup<A[]>\n```\n\n**Example**\n\n```ts\nimport { getIntersectionSemigroup } from 'fp-ts/Array'\nimport { Eq } from 'fp-ts/number'\n\nconst S = getIntersectionSemigroup<number>(Eq)\nassert.deepStrictEqual(S.concat([1, 2], [2, 3]), [2])\n```\n\nAdded in v2.11.0\n\n## getMonoid\n\nReturns a `Monoid` for `Array<A>` based on the concatenation of `Array`s.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A = never>() => Monoid<A[]>\n```\n\n**Example**\n\n```ts\nimport { getMonoid } from 'fp-ts/Array'\n\nconst M = getMonoid<number>()\nassert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4])\n```\n\nAdded in v2.0.0\n\n## getOrd\n\nDerives an `Ord` over the `Array` of a given element type from the `Ord` of that type. The ordering between two such\narrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in\ncase of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have\nthe same length, the result is equality.\n\n**Signature**\n\n```ts\nexport declare const getOrd: <A>(O: Ord<A>) => Ord<A[]>\n```\n\n**Example**\n\n```ts\nimport { getOrd } from 'fp-ts/Array'\nimport * as S from 'fp-ts/string'\n\nconst O = getOrd(S.Ord)\nassert.strictEqual(O.compare(['b'], ['a']), 1)\nassert.strictEqual(O.compare(['a'], ['a']), 0)\nassert.strictEqual(O.compare(['a'], ['b']), -1)\n```\n\nAdded in v2.0.0\n\n## getSemigroup\n\nGet a `Semigroup` based on the concatenation of `Array`s.\nSee also [`getMonoid`](#getMonoid).\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A = never>() => Semigroup<A[]>\n```\n\n**Example**\n\n```ts\nimport { getSemigroup } from 'fp-ts/Array'\n\nconst S = getSemigroup<number>()\nassert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1, 2, 2, 3])\n```\n\nAdded in v2.10.0\n\n## getShow\n\n`getShow` makes a `Show` for an `Array<A>` from a `Show` for\nan `A`.\n\n**Signature**\n\n```ts\nexport declare const getShow: <A>(S: Show<A>) => Show<A[]>\n```\n\n**Example**\n\n```ts\nimport { getShow } from 'fp-ts/Array'\n\nconst numShow = { show: (n: number) => (n >= 0 ? `${n}` : `(${-n})`) }\nassert.deepStrictEqual(getShow(numShow).show([-2, -1, 0, 1]), '[(2), (1), 0, 1]')\n```\n\nAdded in v2.0.0\n\n## getUnionMonoid\n\nGet a `Monoid` based on the union of the elements of `Array`s.\nElements which equal according to the provided `Eq` are included\nonly once in the result.\n\n**Signature**\n\n```ts\nexport declare const getUnionMonoid: <A>(E: Eq<A>) => Monoid<A[]>\n```\n\n**Example**\n\n```ts\nimport { getUnionMonoid } from 'fp-ts/Array'\nimport { Eq } from 'fp-ts/number'\n\nconst M = getUnionMonoid<number>(Eq)\nassert.deepStrictEqual(M.concat([1, 2], [2, 3]), [1, 2, 3])\nassert.deepStrictEqual(M.empty, [])\n```\n\nAdded in v2.11.0\n\n## getUnionSemigroup\n\nGet a `Semigroup` based on the union of the elements of `Array`s.\nElements which equal according to the provided `Eq` are included\nonly once in the result.\nSee also [`getUnionMonoid`](#getUnionMonoid).\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <A>(E: Eq<A>) => Semigroup<A[]>\n```\n\n**Example**\n\n```ts\nimport { getUnionSemigroup } from 'fp-ts/Array'\nimport { Eq } from 'fp-ts/number'\n\nconst S = getUnionSemigroup<number>(Eq)\nassert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1, 2, 3])\n```\n\nAdded in v2.11.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => B[]) => (ma: A[]) => B[]\n```\n\nAdded in v2.0.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(f: (...a: A) => Either<E, B>) => (...a: A) => B[]\n```\n\nAdded in v2.11.0\n\n## fromOptionK\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => B[]\n```\n\nAdded in v2.11.0\n\n## fromPredicate\n\nCreate an array with one element, if the element satisfies the predicate, otherwise\nit returns an empty array.\n\n**Signature**\n\n```ts\nexport declare function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => Array<B>\nexport declare function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => Array<B>\nexport declare function fromPredicate<A>(predicate: Predicate<A>): (a: A) => Array<A>\n```\n\n**Example**\n\n```ts\nimport { fromPredicate } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\nimport { isString } from 'fp-ts/string'\n\nassert.deepStrictEqual(pipe('a', fromPredicate(isString)), ['a'])\nassert.deepStrictEqual(pipe(7, fromPredicate(isString)), [])\n\nassert.deepStrictEqual(\n  pipe(\n    7,\n    fromPredicate((x) => x > 0)\n  ),\n  [7]\n)\nassert.deepStrictEqual(\n  pipe(\n    -3,\n    fromPredicate((x) => x > 0)\n  ),\n  []\n)\n```\n\nAdded in v2.11.0\n\n# mapping\n\n## flap\n\nGiven an input an `Array` of functions, `flap` returns an `Array` containing\nthe results of applying each function to the given input.\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: ((a: A) => B)[]) => B[]\n```\n\n**Example**\n\n```ts\nimport { flap } from 'fp-ts/Array'\n\nconst funs = [(n: number) => `Double: ${n * 2}`, (n: number) => `Triple: ${n * 3}`, (n: number) => `Square: ${n * n}`]\nassert.deepStrictEqual(flap(4)(funs), ['Double: 8', 'Triple: 12', 'Square: 16'])\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: Array<A>) => Array<B>`.\nIn practice it applies the base function to each element of the array and collects the\nresults in a new array.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (fa: A[]) => B[]\n```\n\n**Example**\n\n```ts\nimport { map } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nconst f = (n: number) => n * 2\nassert.deepStrictEqual(pipe([1, 2, 3], map(f)), [2, 4, 6])\n```\n\nAdded in v2.0.0\n\n## mapWithIndex\n\nSame as [`map`](#map), but the iterating function takes both the index and the value\nof the element.\n\n**Signature**\n\n```ts\nexport declare const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (fa: A[]) => B[]\n```\n\n**Example**\n\n```ts\nimport { mapWithIndex } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nconst f = (i: number, s: string) => `${s} - ${i}`\nassert.deepStrictEqual(pipe(['a', 'b', 'c'], mapWithIndex(f)), ['a - 0', 'b - 1', 'c - 2'])\n```\n\nAdded in v2.0.0\n\n# pattern matching\n\n## foldLeft\n\nAlias of [`matchLeft`](#matchleft).\n\n**Signature**\n\n```ts\nexport declare const foldLeft: <A, B>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: A[]) => B) => (as: A[]) => B\n```\n\nAdded in v2.0.0\n\n## foldRight\n\nAlias of [`matchRight`](#matchright).\n\n**Signature**\n\n```ts\nexport declare const foldRight: <A, B>(onEmpty: LazyArg<B>, onNonEmpty: (init: A[], last: A) => B) => (as: A[]) => B\n```\n\nAdded in v2.0.0\n\n## match\n\nTakes an array, if the array is empty it returns the result of `onEmpty`, otherwise\nit passes the array to `onNonEmpty` and returns the result.\n\n**Signature**\n\n```ts\nexport declare const match: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (as: NEA.NonEmptyArray<A>) => B) => (as: A[]) => B\n```\n\n**Example**\n\n```ts\nimport { match } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nconst matcher = match(\n  () => 'No elements',\n  (as) => `Found ${as.length} element(s)`\n)\nassert.deepStrictEqual(pipe([1, 2, 3, 4], matcher), 'Found 4 element(s)')\nassert.deepStrictEqual(pipe([], matcher), 'No elements')\n```\n\nAdded in v2.11.0\n\n## matchLeft\n\nTakes an array, if the array is empty it returns the result of `onEmpty`, otherwise\nit passes the array to `onNonEmpty` broken into its first element and remaining elements.\n\n**Signature**\n\n```ts\nexport declare const matchLeft: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: A[]) => B) => (as: A[]) => B\n```\n\n**Example**\n\n```ts\nimport { matchLeft } from 'fp-ts/Array'\n\nconst len: <A>(as: Array<A>) => number = matchLeft(\n  () => 0,\n  (_, tail) => 1 + len(tail)\n)\nassert.strictEqual(len([1, 2, 3]), 3)\n```\n\nAdded in v2.10.0\n\n## matchLeftW\n\nLess strict version of [`matchLeft`](#matchleft). It will work when `onEmpty` and\n`onNonEmpty` have different return types.\n\n**Signature**\n\n```ts\nexport declare const matchLeftW: <B, A, C>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (head: A, tail: A[]) => C\n) => (as: A[]) => B | C\n```\n\n**Example**\n\n```ts\nimport { matchLeftW } from 'fp-ts/Array'\n\nconst f = matchLeftW(\n  () => 0,\n  (head: string, tail: string[]) => `Found \"${head}\" followed by ${tail.length} elements`\n)\nassert.strictEqual(f(['a', 'b', 'c']), 'Found \"a\" followed by 2 elements')\nassert.strictEqual(f([]), 0)\n```\n\nAdded in v2.11.0\n\n## matchRight\n\nTakes an array, if the array is empty it returns the result of `onEmpty`, otherwise\nit passes the array to `onNonEmpty` broken into its initial elements and the last element.\n\n**Signature**\n\n```ts\nexport declare const matchRight: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (init: A[], last: A) => B) => (as: A[]) => B\n```\n\n**Example**\n\n```ts\nimport { matchRight } from 'fp-ts/Array'\n\nconst len: <A>(as: Array<A>) => number = matchRight(\n  () => 0,\n  (head, _) => 1 + len(head)\n)\nassert.strictEqual(len([1, 2, 3]), 3)\n```\n\nAdded in v2.10.0\n\n## matchRightW\n\nLess strict version of [`matchRight`](#matchright). It will work when `onEmpty` and\n`onNonEmpty` have different return types.\n\n**Signature**\n\n```ts\nexport declare const matchRightW: <B, A, C>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (init: A[], last: A) => C\n) => (as: A[]) => B | C\n```\n\n**Example**\n\n```ts\nimport { matchRightW } from 'fp-ts/Array'\n\nconst f = matchRightW(\n  () => 0,\n  (head: string[], tail: string) => `Found ${head.length} elements folllowed by \"${tail}\"`\n)\nassert.strictEqual(f(['a', 'b', 'c']), 'Found 2 elements folllowed by \"c\"')\nassert.strictEqual(f([]), 0)\n```\n\nAdded in v2.11.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <B, A, C>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (as: NEA.NonEmptyArray<A>) => C\n) => (as: A[]) => B | C\n```\n\n**Example**\n\n```ts\nimport { matchW } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nconst matcherW = matchW(\n  () => 'No elements',\n  (as) => as.length\n)\nassert.deepStrictEqual(pipe([1, 2, 3, 4], matcherW), 4)\nassert.deepStrictEqual(pipe([], matcherW), 'No elements')\n```\n\nAdded in v2.11.0\n\n# refinements\n\n## isEmpty\n\nTest whether an array is empty\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <A>(as: A[]) => as is []\n```\n\n**Example**\n\n```ts\nimport { isEmpty } from 'fp-ts/Array'\n\nassert.strictEqual(isEmpty([]), true)\nassert.strictEqual(isEmpty(['a']), false)\n```\n\nAdded in v2.0.0\n\n## isNonEmpty\n\nTest whether an array is non empty narrowing down the type to `NonEmptyArray<A>`\n\n**Signature**\n\n```ts\nexport declare const isNonEmpty: <A>(as: A[]) => as is NEA.NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { isNonEmpty } from 'fp-ts/Array'\n\nassert.strictEqual(isNonEmpty([]), false)\nassert.strictEqual(isNonEmpty(['a']), true)\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## chainFirst\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => B[]) => (first: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport * as A from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    A.chainFirst(() => ['a', 'b'])\n  ),\n  [1, 1, 2, 2, 3, 3]\n)\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    A.chainFirst(() => [])\n  ),\n  []\n)\n```\n\nAdded in v2.0.0\n\n## chainRecBreadthFirst\n\n**Signature**\n\n```ts\nexport declare const chainRecBreadthFirst: <A, B>(f: (a: A) => Either<A, B>[]) => (a: A) => B[]\n```\n\nAdded in v2.11.0\n\n## chainRecDepthFirst\n\n**Signature**\n\n```ts\nexport declare const chainRecDepthFirst: <A, B>(f: (a: A) => Either<A, B>[]) => (a: A) => B[]\n```\n\nAdded in v2.11.0\n\n## chainWithIndex\n\nSame as [`chain`](#chain), but passing also the index to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const chainWithIndex: <A, B>(f: (i: number, a: A) => B[]) => (as: A[]) => B[]\n```\n\n**Example**\n\n```ts\nimport { chainWithIndex, replicate } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nconst f = (index: number, x: string) => replicate(2, `${x}${index}`)\nassert.deepStrictEqual(pipe(['a', 'b', 'c'], chainWithIndex(f)), ['a0', 'a0', 'b1', 'b1', 'c2', 'c2'])\n```\n\nAdded in v2.7.0\n\n## flatMap\n\nComposes computations in sequence, using the return value of one computation to\ndetermine the next computation.\n\nIn other words it takes a function `f` that produces an array from a single element of\nthe base type `A` and returns a new function which applies `f` to each element of the\ninput array (like [`map`](#map)) and, instead of returning an array of arrays, concatenates the\nresults into a single array (like [`flatten`](#flatten)).\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A, i: number) => B[]): (ma: A[]) => B[]\n  <A, B>(ma: A[], f: (a: A, i: number) => B[]): B[]\n}\n```\n\n**Example**\n\n```ts\nimport { flatMap, map, replicate } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nconst f = (n: number) => replicate(n, `${n}`)\nassert.deepStrictEqual(pipe([1, 2, 3], map(f)), [['1'], ['2', '2'], ['3', '3', '3']])\nassert.deepStrictEqual(pipe([1, 2, 3], flatMap(f)), ['1', '2', '2', '3', '3', '3'])\n```\n\nAdded in v2.14.0\n\n## flatten\n\nTakes an array of arrays of `A` and flattens them into an array of `A`\nby concatenating the elements of each array in order.\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: A[][]) => A[]\n```\n\n**Example**\n\n```ts\nimport { flatten } from 'fp-ts/Array'\n\nassert.deepStrictEqual(flatten([['a'], ['b', 'c'], ['d', 'e', 'f']]), ['a', 'b', 'c', 'd', 'e', 'f'])\n```\n\nAdded in v2.5.0\n\n## traverseWithIndex\n\nSame as [`traverse`](#traverse) but passing also the index to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const traverseWithIndex: PipeableTraverseWithIndex1<'Array', number>\n```\n\n**Example**\n\n```ts\nimport { traverseWithIndex } from 'fp-ts/Array'\nimport { Applicative, left, right } from 'fp-ts/Either'\n\nconst f = (index: number, x: unknown) =>\n  typeof x === 'string' ? right(x.toUpperCase() + index) : left(new Error('not a string'))\nassert.deepStrictEqual(traverseWithIndex(Applicative)(f)(['a', 'b']), right(['A0', 'B1']))\nassert.deepStrictEqual(traverseWithIndex(Applicative)(f)(['a', 5]), left(new Error('not a string')))\n```\n\nAdded in v2.6.3\n\n# traversing\n\n## sequence\n\n`sequence` takes an `Array` where elements are `HKT<A>` (higher kinded type) and,\nusing an applicative of that `HKT`, returns an `HKT` of `Array<A>`.\nE.g. it can turn an `Array<Either<Error, string>>` into an `Either<Error, Array<string>>`.\n\n`sequence` requires an `Applicative` of the `HKT` you are targeting, e.g. to turn an\n`Array<Either<E, A>>` into an `Either<E, Array<A>>`, it needs an\n`Applicative` for `Either`, to to turn an `Array<Option<A>>` into an `Option<Array<A>>`,\nit needs an `Applicative` for `Option`.\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence1<'Array'>\n```\n\n**Example**\n\n```ts\nimport { sequence } from 'fp-ts/Array'\nimport { Applicative, left, right } from 'fp-ts/Either'\n\nassert.deepStrictEqual(sequence(Applicative)([right('a'), right('b')]), right(['a', 'b']))\nassert.deepStrictEqual(\n  sequence(Applicative)([right('a'), left(new Error('not a string'))]),\n  left(new Error('not a string'))\n)\n```\n\nAdded in v2.6.3\n\n## traverse\n\nGiven an iterating function that returns a `HKT` (higher kinded type), `traverse`\napplies the iterating function to each element of the `Array` and then [`sequence`](#sequence)-s\nthe results using the provided `Applicative`.\n\nE.g. suppose you have an `Array` and you want to format each element with a function\nthat returns a result or an error as `f = (a: A) => Either<Error, B>`, using `traverse`\nyou can apply `f` to all elements and directly obtain as a result an `Either<Error,Array<B>>`\ni.e. an `Array<B>` if all the results are `B`, or an `Error` if some of the results\nare `Error`s.\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse1<'Array'>\n```\n\n**Example**\n\n```ts\nimport { traverse } from 'fp-ts/Array'\nimport { Applicative, left, right } from 'fp-ts/Either'\n\nconst f = (x: unknown) => (typeof x === 'string' ? right(x.toUpperCase()) : left(new Error('not a string')))\nassert.deepStrictEqual(traverse(Applicative)(f)(['a', 'b']), right(['A', 'B']))\nassert.deepStrictEqual(traverse(Applicative)(f)(['a', 5]), left(new Error('not a string')))\n```\n\nAdded in v2.6.3\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Array'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# unsafe\n\n## unsafeDeleteAt\n\n**Signature**\n\n```ts\nexport declare const unsafeDeleteAt: <A>(i: number, as: A[]) => A[]\n```\n\nAdded in v2.0.0\n\n## unsafeInsertAt\n\n**Signature**\n\n```ts\nexport declare const unsafeInsertAt: <A>(i: number, a: A, as: A[]) => NEA.NonEmptyArray<A>\n```\n\nAdded in v2.0.0\n\n## unsafeUpdateAt\n\n**Signature**\n\n```ts\nexport declare const unsafeUpdateAt: <A>(i: number, a: A, as: A[]) => A[]\n```\n\nAdded in v2.0.0\n\n# utils\n\n## Spanned (interface)\n\nType returned by [`spanLeft`](#spanLeft) composed of an `init` array and a `rest` array.\n\n**Signature**\n\n```ts\nexport interface Spanned<I, R> {\n  init: Array<I>\n  rest: Array<R>\n}\n```\n\nAdded in v2.10.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(fa: A[]) => <B>(fab: ((a: A) => B)[]) => B[]\n```\n\n**Example**\n\n```ts\nimport { ap, map, of } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\n// a curried function with 3 input parameteres\nconst f = (s1: string) => (n: number) => (s2: string) => s1 + n + s2\n\n// let's use `ap` to iterate `f` over an array for each input parameter\nassert.deepStrictEqual(pipe(['a', 'b'], map(f), ap([1, 2]), ap(['😀', '😫', '😎'])), [\n  'a1😀',\n  'a1😫',\n  'a1😎',\n  'a2😀',\n  'a2😫',\n  'a2😎',\n  'b1😀',\n  'b1😫',\n  'b1😎',\n  'b2😀',\n  'b2😫',\n  'b2😎',\n])\n\n// given Array implements the Applicative interface with the `of` method,\n// we can write exactly the same thing in a more symmetric way\n// using `of` on `f` and `ap` on each array in input\nassert.deepStrictEqual(\n  pipe(of(f), ap(['a', 'b']), ap([1, 2]), ap(['😀', '😫', '😎'])),\n  pipe(['a', 'b'], map(f), ap([1, 2]), ap(['😀', '😫', '😎']))\n)\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: B[]) => <A>(first: A[]) => A[]\n```\n\nAdded in v2.5.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: B[]) => <A>(first: A[]) => B[]\n```\n\nAdded in v2.5.0\n\n## append\n\nAppend an element to the end of a `Array`, creating a new `NonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const append: <A>(end: A) => (init: A[]) => NEA.NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { append } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2, 3], append(4)), [1, 2, 3, 4])\n```\n\nAdded in v2.10.0\n\n## appendW\n\nLess strict version of [`append`](#append).\n\n**Signature**\n\n```ts\nexport declare const appendW: <A, B>(end: B) => (init: A[]) => NEA.NonEmptyArray<A | B>\n```\n\n**Example**\n\n```ts\nimport { appendW } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2, 3], appendW('d')), [1, 2, 3, 'd'])\n```\n\nAdded in v2.11.0\n\n## chop\n\nA useful recursion pattern for processing an array to produce a new array, often used for \"chopping\" up the input\narray. Typically chop is called with some function that will consume an initial prefix of the array and produce a\nvalue and the rest of the array.\n\n**Signature**\n\n```ts\nexport declare const chop: <A, B>(f: (as: NEA.NonEmptyArray<A>) => [B, A[]]) => (as: A[]) => B[]\n```\n\n**Example**\n\n```ts\nimport { Eq } from 'fp-ts/Eq'\nimport * as A from 'fp-ts/Array'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nconst group = <A>(S: Eq<A>): ((as: Array<A>) => Array<Array<A>>) => {\n  return A.chop((as) => {\n    const { init, rest } = pipe(\n      as,\n      A.spanLeft((a: A) => S.equals(a, as[0]))\n    )\n    return [init, rest]\n  })\n}\nassert.deepStrictEqual(group(N.Eq)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]])\n```\n\nAdded in v2.0.0\n\n## chunksOf\n\nSplits an array into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\nthe array. 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 `xs`.\n\n**Signature**\n\n```ts\nexport declare const chunksOf: (n: number) => <A>(as: A[]) => NEA.NonEmptyArray<A>[]\n```\n\n**Example**\n\n```ts\nimport { chunksOf } from 'fp-ts/Array'\n\nassert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])\n```\n\nAdded in v2.0.0\n\n## comprehension\n\n`Array` comprehension.\n\n```\n[ f(x, y, ...) | x ← xs, y ← ys, ..., g(x, y, ...) ]\n```\n\n**Signature**\n\n```ts\nexport declare function comprehension<A, B, C, D, R>(\n  input: [Array<A>, Array<B>, Array<C>, Array<D>],\n  f: (a: A, b: B, c: C, d: D) => R,\n  g?: (a: A, b: B, c: C, d: D) => boolean\n): Array<R>\nexport declare function comprehension<A, B, C, R>(\n  input: [Array<A>, Array<B>, Array<C>],\n  f: (a: A, b: B, c: C) => R,\n  g?: (a: A, b: B, c: C) => boolean\n): Array<R>\nexport declare function comprehension<A, B, R>(\n  input: [Array<A>, Array<B>],\n  f: (a: A, b: B) => R,\n  g?: (a: A, b: B) => boolean\n): Array<R>\nexport declare function comprehension<A, R>(input: [Array<A>], f: (a: A) => R, g?: (a: A) => boolean): Array<R>\n```\n\n**Example**\n\n```ts\nimport { comprehension } from 'fp-ts/Array'\nimport { tuple } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  comprehension(\n    [\n      [1, 2, 3],\n      ['a', 'b'],\n    ],\n    tuple,\n    (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\nAdded in v2.0.0\n\n## concat\n\n**Signature**\n\n```ts\nexport declare const concat: <A>(second: A[]) => (first: A[]) => A[]\n```\n\nAdded in v2.11.0\n\n## concatW\n\n**Signature**\n\n```ts\nexport declare const concatW: <B>(second: B[]) => <A>(first: A[]) => (B | A)[]\n```\n\nAdded in v2.11.0\n\n## copy\n\nThis function takes an array and makes a new array containing the same elements.\n\n**Signature**\n\n```ts\nexport declare const copy: <A>(as: A[]) => A[]\n```\n\nAdded in v2.0.0\n\n## deleteAt\n\nDelete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds.\n\n**Signature**\n\n```ts\nexport declare const deleteAt: (i: number) => <A>(as: A[]) => Option<A[]>\n```\n\n**Example**\n\n```ts\nimport { deleteAt } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3]))\nassert.deepStrictEqual(deleteAt(1)([]), none)\n```\n\nAdded in v2.0.0\n\n## difference\n\nCreates an array of array values not included in the other given array using a `Eq` for equality\ncomparisons. The order and references of result values are determined by the first array.\n\n**Signature**\n\n```ts\nexport declare function difference<A>(E: Eq<A>): {\n  (xs: Array<A>): (ys: Array<A>) => Array<A>\n  (xs: Array<A>, ys: Array<A>): Array<A>\n}\n```\n\n**Example**\n\n```ts\nimport { difference } from 'fp-ts/Array'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2], difference(N.Eq)([2, 3])), [1])\n```\n\nAdded in v2.0.0\n\n## dropLeft\n\nCreates a new `Array` which is a copy of the input dropping a max number of elements from the start.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const dropLeft: (n: number) => <A>(as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { dropLeft } from 'fp-ts/Array'\n\nassert.deepStrictEqual(dropLeft(2)([1, 2, 3]), [3])\nassert.deepStrictEqual(dropLeft(5)([1, 2, 3]), [])\nassert.deepStrictEqual(dropLeft(0)([1, 2, 3]), [1, 2, 3])\nassert.deepStrictEqual(dropLeft(-2)([1, 2, 3]), [1, 2, 3])\n```\n\nAdded in v2.0.0\n\n## dropLeftWhile\n\nCreates a new `Array` which is a copy of the input dropping the longest initial subarray for\nwhich all element satisfy the specified predicate.\n\n**Signature**\n\n```ts\nexport declare function dropLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>\nexport declare function dropLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>\nexport declare function dropLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>\n```\n\n**Example**\n\n```ts\nimport { dropLeftWhile } from 'fp-ts/Array'\n\nassert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5])\n```\n\nAdded in v2.0.0\n\n## dropRight\n\nCreates a new `Array` which is a copy of the input dropping a max number of elements from the end.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const dropRight: (n: number) => <A>(as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { dropRight } from 'fp-ts/Array'\n\nassert.deepStrictEqual(dropRight(2)([1, 2, 3]), [1])\nassert.deepStrictEqual(dropRight(5)([1, 2, 3]), [])\nassert.deepStrictEqual(dropRight(0)([1, 2, 3]), [1, 2, 3])\nassert.deepStrictEqual(dropRight(-2)([1, 2, 3]), [1, 2, 3])\n```\n\nAdded in v2.0.0\n\n## duplicate\n\n`duplicate` returns an array containing the whole input `Array`,\nthen to the input `Array` dropping the first element, then to the input\n`Array` dropping the first two elements, etc.\n\n**Signature**\n\n```ts\nexport declare const duplicate: <A>(wa: A[]) => A[][]\n```\n\n**Example**\n\n```ts\nimport { duplicate } from 'fp-ts/Array'\n\nassert.deepStrictEqual(duplicate(['a', 'b', 'c']), [['a', 'b', 'c'], ['b', 'c'], ['c']])\n```\n\nAdded in v2.0.0\n\n## elem\n\nTest if a value is a member of an `Array`. Takes a `Eq<A>` as a single\nargument which returns the function to use to search for a value of type `A` in\nan `Array<A>`.\n\n**Signature**\n\n```ts\nexport declare const elem: <A>(E: Eq<A>) => { (a: A): (as: A[]) => boolean; (a: A, as: A[]): boolean }\n```\n\n**Example**\n\n```ts\nimport { elem } from 'fp-ts/Array'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(2)), true)\nassert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(0)), false)\n```\n\nAdded in v2.0.0\n\n## every\n\n`every` tells if the provided predicate holds true for every element in the `Array`.\n\n**Signature**\n\n```ts\nexport declare const every: {\n  <A, B extends A>(refinement: Refinement<A, B>): Refinement<A[], B[]>\n  <A>(predicate: Predicate<A>): Predicate<A[]>\n}\n```\n\n**Example**\n\n```ts\nimport { every } from 'fp-ts/Array'\n\nassert.equal(every((x: number) => x >= 0)([1, 2, 3]), true)\nassert.equal(every((x: number) => x >= 0)([-1, 2, 3]), false)\n```\n\nAdded in v2.9.0\n\n## exists\n\nAlias of [`some`](#some)\n\n**Signature**\n\n```ts\nexport declare const exists: <A>(predicate: Predicate<A>) => (as: A[]) => as is NEA.NonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## extend\n\nGiven an iterating function that takes `Array<A>` as input, `extend` returns\nan array containing the results of the iterating function applied to the whole input\n`Array`, then to the input `Array` without the first element, then to the input\n`Array` without the first two elements, etc.\n\n**Signature**\n\n```ts\nexport declare const extend: <A, B>(f: (as: A[]) => B) => (as: A[]) => B[]\n```\n\n**Example**\n\n```ts\nimport { extend } from 'fp-ts/Array'\n\nconst f = (a: string[]) => a.join(',')\nassert.deepStrictEqual(extend(f)(['a', 'b', 'c']), ['a,b,c', 'b,c', 'c'])\n```\n\nAdded in v2.0.0\n\n## filterE\n\nFilter values inside a context.\n\n**Signature**\n\n```ts\nexport declare const filterE: FilterE1<'Array'>\n```\n\nAdded in v2.11.0\n\n## findFirst\n\nFind the first element which satisfies a predicate (or a refinement) function.\nIt returns an `Option` containing the element or `None` if not found.\n\n**Signature**\n\n```ts\nexport declare function findFirst<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Option<B>\nexport declare function findFirst<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Option<B>\nexport declare function findFirst<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { findFirst } from 'fp-ts/Array'\nimport { some } from 'fp-ts/Option'\n\ntype X = {\n  readonly a: number\n  readonly b: number\n}\n\nassert.deepStrictEqual(\n  findFirst((x: X) => x.a === 1)([\n    { a: 1, b: 1 },\n    { a: 1, b: 2 },\n  ]),\n  some({ a: 1, b: 1 })\n)\n```\n\nAdded in v2.0.0\n\n## findFirstMap\n\nGiven a selector function which takes an element and returns an option,\nthis function applies the selector to each element of the array and\nreturns the first `Some` result. Otherwise it returns `None`.\n\n**Signature**\n\n```ts\nexport declare const findFirstMap: <A, B>(f: (a: A) => Option<B>) => (as: A[]) => Option<B>\n```\n\n**Example**\n\n```ts\nimport { findFirstMap } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\ninterface Person {\n  readonly name: string\n  readonly age: number\n}\n\nconst persons: Array<Person> = [\n  { name: 'John', age: 16 },\n  { name: 'Mary', age: 45 },\n  { name: 'Joey', age: 28 },\n]\n\nconst nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name))\nconst nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name))\nassert.deepStrictEqual(findFirstMap(nameOfPersonAbove18)(persons), some('Mary'))\nassert.deepStrictEqual(findFirstMap(nameOfPersonAbove70)(persons), none)\n```\n\nAdded in v2.0.0\n\n## findIndex\n\n`findIndex` returns an `Option` containing the first index for which a predicate holds.\nIt returns `None` if no element satisfies the predicate.\nSimilar to [`findFirst`](#findFirst) but returning the index instead of the element.\n\n**Signature**\n\n```ts\nexport declare const findIndex: <A>(predicate: Predicate<A>) => (as: A[]) => Option<number>\n```\n\n**Example**\n\n```ts\nimport { findIndex } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1))\nassert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none)\n```\n\nAdded in v2.0.0\n\n## findLast\n\nFind the last element which satisfies a predicate function.\nIt returns an `Option` containing the element or `None` if not found.\n\n**Signature**\n\n```ts\nexport declare function findLast<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Option<B>\nexport declare function findLast<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Option<B>\nexport declare function findLast<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { findLast } from 'fp-ts/Array'\nimport { some } from 'fp-ts/Option'\n\ntype X = {\n  readonly a: number\n  readonly b: number\n}\n\nassert.deepStrictEqual(\n  findLast((x: X) => x.a === 1)([\n    { a: 1, b: 1 },\n    { a: 1, b: 2 },\n  ]),\n  some({ a: 1, b: 2 })\n)\n```\n\nAdded in v2.0.0\n\n## findLastIndex\n\nReturns the index of the last element of the list which matches the predicate.\nIt returns an `Option` containing the index or `None` if not found.\n\n**Signature**\n\n```ts\nexport declare const findLastIndex: <A>(predicate: Predicate<A>) => (as: A[]) => Option<number>\n```\n\n**Example**\n\n```ts\nimport { findLastIndex } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\ninterface X {\n  readonly a: number\n  readonly b: number\n}\nconst xs: Array<X> = [\n  { a: 1, b: 0 },\n  { a: 1, b: 1 },\n]\nassert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 1)(xs), some(1))\nassert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 4)(xs), none)\n```\n\nAdded in v2.0.0\n\n## findLastMap\n\nGiven a selector function which takes an element and returns an option,\nthis function applies the selector to each element of the array starting from the\nend and returns the last `Some` result. Otherwise it returns `None`.\n\n**Signature**\n\n```ts\nexport declare const findLastMap: <A, B>(f: (a: A) => Option<B>) => (as: A[]) => Option<B>\n```\n\n**Example**\n\n```ts\nimport { findLastMap } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\ninterface Person {\n  readonly name: string\n  readonly age: number\n}\n\nconst persons: Array<Person> = [\n  { name: 'John', age: 16 },\n  { name: 'Mary', age: 45 },\n  { name: 'Joey', age: 28 },\n]\n\nconst nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name))\nconst nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name))\nassert.deepStrictEqual(findLastMap(nameOfPersonAbove18)(persons), some('Joey'))\nassert.deepStrictEqual(findLastMap(nameOfPersonAbove70)(persons), none)\n```\n\nAdded in v2.0.0\n\n## head\n\nGet the first element in an array, or `None` if the array is empty\n\n**Signature**\n\n```ts\nexport declare const head: <A>(as: A[]) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { head } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(head([1, 2, 3]), some(1))\nassert.deepStrictEqual(head([]), none)\n```\n\nAdded in v2.0.0\n\n## init\n\nGet all but the last element of an array, creating a new array, or `None` if the array is empty\n\n**Signature**\n\n```ts\nexport declare const init: <A>(as: A[]) => Option<A[]>\n```\n\n**Example**\n\n```ts\nimport { init } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(init([1, 2, 3]), some([1, 2]))\nassert.deepStrictEqual(init([]), none)\n```\n\nAdded in v2.0.0\n\n## insertAt\n\nInsert an element at the specified index, creating a new array,\nor returning `None` if the index is out of bounds.\n\n**Signature**\n\n```ts\nexport declare const insertAt: <A>(i: number, a: A) => (as: A[]) => Option<NEA.NonEmptyArray<A>>\n```\n\n**Example**\n\n```ts\nimport { insertAt } from 'fp-ts/Array'\nimport { some } from 'fp-ts/Option'\n\nassert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4]))\n```\n\nAdded in v2.0.0\n\n## intercalate\n\nPlaces an element in between members of an `Array`, then folds the results using the provided `Monoid`.\n\n**Signature**\n\n```ts\nexport declare const intercalate: <A>(M: Monoid<A>) => (middle: A) => (as: A[]) => A\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { intercalate } from 'fp-ts/Array'\n\nassert.deepStrictEqual(intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c')\n```\n\nAdded in v2.12.0\n\n## intersection\n\nCreates an array of unique values that are included in all given arrays using a `Eq` for equality\ncomparisons. The order and references of result values are determined by the first array.\n\n**Signature**\n\n```ts\nexport declare function intersection<A>(E: Eq<A>): {\n  (xs: Array<A>): (ys: Array<A>) => Array<A>\n  (xs: Array<A>, ys: Array<A>): Array<A>\n}\n```\n\n**Example**\n\n```ts\nimport { intersection } from 'fp-ts/Array'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2], intersection(N.Eq)([2, 3])), [2])\n```\n\nAdded in v2.0.0\n\n## intersperse\n\nCreates a new `Array` placing an element in between members of the input `Array`.\n\n**Signature**\n\n```ts\nexport declare const intersperse: <A>(middle: A) => (as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { intersperse } from 'fp-ts/Array'\n\nassert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])\n```\n\nAdded in v2.9.0\n\n## isOutOfBound\n\nTest whether an array contains a particular index\n\n**Signature**\n\n```ts\nexport declare const isOutOfBound: <A>(i: number, as: A[]) => boolean\n```\n\n**Example**\n\n```ts\nimport { isOutOfBound } from 'fp-ts/Array'\n\nassert.strictEqual(isOutOfBound(1, ['a', 'b', 'c']), false)\nassert.strictEqual(isOutOfBound(-1, ['a', 'b', 'c']), true)\nassert.strictEqual(isOutOfBound(3, ['a', 'b', 'c']), true)\n```\n\nAdded in v2.0.0\n\n## last\n\nGet the last element in an array, or `None` if the array is empty\n\n**Signature**\n\n```ts\nexport declare const last: <A>(as: A[]) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { last } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(last([1, 2, 3]), some(3))\nassert.deepStrictEqual(last([]), none)\n```\n\nAdded in v2.0.0\n\n## lefts\n\nTakes an `Array` of `Either` and produces a new `Array` containing\nthe values of all the `Left` elements in the same order.\n\n**Signature**\n\n```ts\nexport declare const lefts: <E, A>(as: Either<E, A>[]) => E[]\n```\n\n**Example**\n\n```ts\nimport { lefts } from 'fp-ts/Array'\nimport { left, right } from 'fp-ts/Either'\n\nassert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo'])\n```\n\nAdded in v2.0.0\n\n## lookup\n\nThis function provides a safe way to read a value at a particular index from an array.\nIt returns a `none` if the index is out of bounds, and a `some` of the element if the\nindex is valid.\n\n**Signature**\n\n```ts\nexport declare const lookup: { (i: number): <A>(as: A[]) => Option<A>; <A>(i: number, as: A[]): Option<A> }\n```\n\n**Example**\n\n```ts\nimport { lookup } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2))\nassert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none)\n```\n\nAdded in v2.0.0\n\n## modifyAt\n\nApply a function to the element at the specified index, creating a new array, or returning `None` if the index is out\nof bounds.\n\n**Signature**\n\n```ts\nexport declare const modifyAt: <A>(i: number, f: (a: A) => A) => (as: A[]) => Option<A[]>\n```\n\n**Example**\n\n```ts\nimport { modifyAt } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\nconst double = (x: number): number => x * 2\nassert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3]))\nassert.deepStrictEqual(modifyAt(1, double)([]), none)\n```\n\nAdded in v2.0.0\n\n## prepend\n\nPrepend an element to the front of a `Array`, creating a new `NonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const prepend: <A>(head: A) => (tail: A[]) => NEA.NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { prepend } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([2, 3, 4], prepend(1)), [1, 2, 3, 4])\n```\n\nAdded in v2.10.0\n\n## prependAll\n\nCreates a new `Array`, prepending an element to every member of the input `Array`.\n\n**Signature**\n\n```ts\nexport declare const prependAll: <A>(middle: A) => (as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { prependAll } from 'fp-ts/Array'\n\nassert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])\n```\n\nAdded in v2.10.0\n\n## prependW\n\nLess strict version of [`prepend`](#prepend).\n\n**Signature**\n\n```ts\nexport declare const prependW: <A, B>(head: B) => (tail: A[]) => NEA.NonEmptyArray<A | B>\n```\n\n**Example**\n\n```ts\nimport { prependW } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([2, 3, 4], prependW('a')), ['a', 2, 3, 4])\n```\n\nAdded in v2.11.0\n\n## reverse\n\nReverse an array, creating a new array\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { reverse } from 'fp-ts/Array'\n\nassert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1])\n```\n\nAdded in v2.0.0\n\n## rights\n\nTakes an `Array` of `Either` and produces a new `Array` containing\nthe values of all the `Right` elements in the same order.\n\n**Signature**\n\n```ts\nexport declare const rights: <E, A>(as: Either<E, A>[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { rights } from 'fp-ts/Array'\nimport { right, left } from 'fp-ts/Either'\n\nassert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2])\n```\n\nAdded in v2.0.0\n\n## rotate\n\nCreates a new `Array` rotating the input `Array` by `n` steps.\n\n**Signature**\n\n```ts\nexport declare const rotate: (n: number) => <A>(as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { rotate } from 'fp-ts/Array'\n\nassert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n```\n\nAdded in v2.0.0\n\n## scanLeft\n\nSame as `reduce` but it carries over the intermediate steps\n\n**Signature**\n\n```ts\nexport declare const scanLeft: <A, B>(b: B, f: (b: B, a: A) => B) => (as: A[]) => NEA.NonEmptyArray<B>\n```\n\n**Example**\n\n```ts\nimport { scanLeft } from 'fp-ts/Array'\n\nassert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4])\n```\n\nAdded in v2.0.0\n\n## scanRight\n\nFold an array from the right, keeping all intermediate results instead of only the final result\n\n**Signature**\n\n```ts\nexport declare const scanRight: <A, B>(b: B, f: (a: A, b: B) => B) => (as: A[]) => NEA.NonEmptyArray<B>\n```\n\n**Example**\n\n```ts\nimport { scanRight } from 'fp-ts/Array'\n\nassert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10])\n```\n\nAdded in v2.0.0\n\n## size\n\nCalculate the number of elements in a `Array`.\n\n**Signature**\n\n```ts\nexport declare const size: <A>(as: A[]) => number\n```\n\n**Example**\n\n```ts\nimport { size } from 'fp-ts/Array'\n\nassert.strictEqual(size(['a', 'b', 'c']), 3)\n```\n\nAdded in v2.10.0\n\n## some\n\n`some` tells if the provided predicate holds true at least for one element in the `Array`.\n\n**Signature**\n\n```ts\nexport declare const some: <A>(predicate: Predicate<A>) => (as: A[]) => as is NEA.NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { some } from 'fp-ts/Array'\n\nassert.equal(some((x: number) => x >= 0)([1, 2, 3]), true)\nassert.equal(some((x: number) => x >= 10)([1, 2, 3]), false)\n```\n\nAdded in v2.9.0\n\n## sort\n\nSort the elements of an array in increasing order, creating a new array\n\n**Signature**\n\n```ts\nexport declare const sort: <B>(O: Ord<B>) => <A extends B>(as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { sort } from 'fp-ts/Array'\nimport * as N from 'fp-ts/number'\n\nassert.deepStrictEqual(sort(N.Ord)([3, 2, 1]), [1, 2, 3])\n```\n\nAdded in v2.0.0\n\n## sortBy\n\nSort the elements of an array in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,\netc...\n\n**Signature**\n\n```ts\nexport declare const sortBy: <B>(ords: Ord<B>[]) => <A extends B>(as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { sortBy } from 'fp-ts/Array'\nimport { contramap } from 'fp-ts/Ord'\nimport * as S from 'fp-ts/string'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\ninterface Person {\n  readonly name: string\n  readonly age: number\n}\nconst byName = pipe(\n  S.Ord,\n  contramap((p: Person) => p.name)\n)\nconst byAge = pipe(\n  N.Ord,\n  contramap((p: Person) => p.age)\n)\n\nconst sortByNameByAge = sortBy([byName, byAge])\n\nconst persons = [\n  { name: 'a', age: 1 },\n  { name: 'b', age: 3 },\n  { name: 'c', age: 2 },\n  { name: 'b', age: 2 },\n]\nassert.deepStrictEqual(sortByNameByAge(persons), [\n  { name: 'a', age: 1 },\n  { name: 'b', age: 2 },\n  { name: 'b', age: 3 },\n  { name: 'c', age: 2 },\n])\n```\n\nAdded in v2.0.0\n\n## spanLeft\n\nSplit an array 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 function spanLeft<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Spanned<B, A>\nexport declare function spanLeft<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Spanned<B, B>\nexport declare function spanLeft<A>(predicate: Predicate<A>): (as: Array<A>) => Spanned<A, A>\n```\n\n**Example**\n\n```ts\nimport { spanLeft } from 'fp-ts/Array'\n\nconst isOdd = (n: number) => n % 2 === 1\nassert.deepStrictEqual(spanLeft(isOdd)([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] })\nassert.deepStrictEqual(spanLeft(isOdd)([0, 2, 4, 5]), { init: [], rest: [0, 2, 4, 5] })\nassert.deepStrictEqual(spanLeft(isOdd)([1, 3, 5]), { init: [1, 3, 5], rest: [] })\n```\n\nAdded in v2.0.0\n\n## splitAt\n\nSplits an `Array` into two pieces, the first piece has max `n` elements.\n\n**Signature**\n\n```ts\nexport declare const splitAt: (n: number) => <A>(as: A[]) => [A[], A[]]\n```\n\n**Example**\n\n```ts\nimport { splitAt } from 'fp-ts/Array'\n\nassert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [\n  [1, 2],\n  [3, 4, 5],\n])\n```\n\nAdded in v2.0.0\n\n## tail\n\nGet all but the first element of an array, creating a new array, or `None` if the array is empty\n\n**Signature**\n\n```ts\nexport declare const tail: <A>(as: A[]) => Option<A[]>\n```\n\n**Example**\n\n```ts\nimport { tail } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(tail([1, 2, 3]), some([2, 3]))\nassert.deepStrictEqual(tail([]), none)\n```\n\nAdded in v2.0.0\n\n## takeLeft\n\nKeep only a max number of elements from the start of an `Array`, creating a new `Array`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const takeLeft: (n: number) => <A>(as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { takeLeft } from 'fp-ts/Array'\n\nassert.deepStrictEqual(takeLeft(2)([1, 2, 3, 4, 5]), [1, 2])\nassert.deepStrictEqual(takeLeft(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\nassert.deepStrictEqual(takeLeft(0)([1, 2, 3, 4, 5]), [])\nassert.deepStrictEqual(takeLeft(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n```\n\nAdded in v2.0.0\n\n## takeLeftWhile\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 function takeLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>\nexport declare function takeLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>\nexport declare function takeLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>\n```\n\n**Example**\n\n```ts\nimport { takeLeftWhile } from 'fp-ts/Array'\n\nassert.deepStrictEqual(takeLeftWhile((n: number) => n % 2 === 0)([2, 4, 3, 6]), [2, 4])\n```\n\nAdded in v2.0.0\n\n## takeRight\n\nKeep only a max number of elements from the end of an `Array`, 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>(as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { takeRight } from 'fp-ts/Array'\n\nassert.deepStrictEqual(takeRight(2)([1, 2, 3, 4, 5]), [4, 5])\nassert.deepStrictEqual(takeRight(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\nassert.deepStrictEqual(takeRight(0)([1, 2, 3, 4, 5]), [])\nassert.deepStrictEqual(takeRight(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n```\n\nAdded in v2.0.0\n\n## unfold\n\n`unfold` takes a function `f` which returns an `Option` of a tuple containing an outcome\nvalue and an input for the following iteration.\n`unfold` applies `f` to the initial value `b` and then recursively to the second\nelement of the tuple contained in the returned `option` of the previous\ncalculation until `f` returns `Option.none`.\n\n**Signature**\n\n```ts\nexport declare const unfold: <A, B>(b: B, f: (b: B) => Option<readonly [A, B]>) => A[]\n```\n\n**Example**\n\n```ts\nimport { unfold } from 'fp-ts/Array'\nimport { option } from 'fp-ts'\n\nconst f = (n: number) => {\n  if (n <= 0) return option.none\n  const returnValue = n * 2\n  const inputForNextRound = n - 1\n  return option.some([returnValue, inputForNextRound] as const)\n}\nassert.deepStrictEqual(unfold(5, f), [10, 8, 6, 4, 2])\n```\n\nAdded in v2.6.6\n\n## union\n\nCreates an array of unique values, in order, from all given arrays using a `Eq` for equality comparisons\n\n**Signature**\n\n```ts\nexport declare function union<A>(E: Eq<A>): {\n  (xs: Array<A>): (ys: Array<A>) => Array<A>\n  (xs: Array<A>, ys: Array<A>): Array<A>\n}\n```\n\n**Example**\n\n```ts\nimport { union } from 'fp-ts/Array'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2], union(N.Eq)([2, 3])), [1, 2, 3])\n```\n\nAdded in v2.0.0\n\n## uniq\n\nCreates a new `Array` removing duplicate elements, keeping the first occurrence of an element,\nbased on a `Eq<A>`.\n\n**Signature**\n\n```ts\nexport declare const uniq: <A>(E: Eq<A>) => (as: A[]) => A[]\n```\n\n**Example**\n\n```ts\nimport { uniq } from 'fp-ts/Array'\nimport * as N from 'fp-ts/number'\n\nassert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])\n```\n\nAdded in v2.0.0\n\n## unzip\n\nThe function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays\n\n**Signature**\n\n```ts\nexport declare const unzip: <A, B>(as: [A, B][]) => [A[], B[]]\n```\n\n**Example**\n\n```ts\nimport { unzip } from 'fp-ts/Array'\n\nassert.deepStrictEqual(\n  unzip([\n    [1, 'a'],\n    [2, 'b'],\n    [3, 'c'],\n  ]),\n  [\n    [1, 2, 3],\n    ['a', 'b', 'c'],\n  ]\n)\n```\n\nAdded in v2.0.0\n\n## updateAt\n\nChange the element at the specified index, creating a new array,\nor returning `None` if the index is out of bounds.\n\n**Signature**\n\n```ts\nexport declare const updateAt: <A>(i: number, a: A) => (as: A[]) => Option<A[]>\n```\n\n**Example**\n\n```ts\nimport { updateAt } from 'fp-ts/Array'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3]))\nassert.deepStrictEqual(updateAt(1, 1)([]), none)\n```\n\nAdded in v2.0.0\n\n## zero\n\nMakes an empty `Array`, useful for building a [`Monoid`](#Monoid)\n\n**Signature**\n\n```ts\nexport declare const zero: <A>() => A[]\n```\n\nAdded in v2.7.0\n\n## zip\n\nTakes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the\nlonger array are discarded\n\n**Signature**\n\n```ts\nexport declare function zip<B>(bs: Array<B>): <A>(as: Array<A>) => Array<[A, B]>\nexport declare function zip<A, B>(as: Array<A>, bs: Array<B>): Array<[A, B]>\n```\n\n**Example**\n\n```ts\nimport { zip } from 'fp-ts/Array'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2, 3], zip(['a', 'b', 'c', 'd'])), [\n  [1, 'a'],\n  [2, 'b'],\n  [3, 'c'],\n])\n```\n\nAdded in v2.0.0\n\n## zipWith\n\nApply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one\ninput array is short, excess elements of the longer array are discarded.\n\n**Signature**\n\n```ts\nexport declare const zipWith: <A, B, C>(fa: A[], fb: B[], f: (a: A, b: B) => C) => C[]\n```\n\n**Example**\n\n```ts\nimport { zipWith } from 'fp-ts/Array'\n\nassert.deepStrictEqual(\n  zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n),\n  ['a1', 'b2', 'c3']\n)\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~array~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `A.Functor` instead of `A.array`\n(where `A` is from `import A from 'fp-ts/Array'`)\n\n**Signature**\n\n```ts\nexport declare const array: FunctorWithIndex1<'Array', number> &\n  Monad1<'Array'> &\n  Unfoldable1<'Array'> &\n  Alternative1<'Array'> &\n  Extend1<'Array'> &\n  FilterableWithIndex1<'Array', number> &\n  FoldableWithIndex1<'Array', number> &\n  TraversableWithIndex1<'Array', number> &\n  Witherable1<'Array'>\n```\n\nAdded in v2.0.0\n\n## ~~cons~~\n\nUse `prepend` instead.\n\n**Signature**\n\n```ts\nexport declare const cons: typeof NEA.cons\n```\n\nAdded in v2.0.0\n\n## ~~empty~~\n\nUse a new `[]` instead.\n\n**Signature**\n\n```ts\nexport declare const empty: never[]\n```\n\nAdded in v2.0.0\n\n## ~~prependToAll~~\n\nUse `prependAll` instead\n\n**Signature**\n\n```ts\nexport declare const prependToAll: <A>(middle: A) => (as: A[]) => A[]\n```\n\nAdded in v2.9.0\n\n## ~~range~~\n\nUse `NonEmptyArray` module instead.\n\n**Signature**\n\n```ts\nexport declare const range: (start: number, end: number) => NEA.NonEmptyArray<number>\n```\n\nAdded in v2.0.0\n\n## ~~snoc~~\n\nUse `append` instead.\n\n**Signature**\n\n```ts\nexport declare const snoc: <A>(init: A[], end: A) => NEA.NonEmptyArray<A>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Bifunctor.ts.md",
    "content": "---\ntitle: Bifunctor.ts\nnav_order: 6\nparent: Modules\n---\n\n## Bifunctor overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Bifunctor (interface)](#bifunctor-interface)\n  - [Bifunctor2 (interface)](#bifunctor2-interface)\n  - [Bifunctor2C (interface)](#bifunctor2c-interface)\n  - [Bifunctor3 (interface)](#bifunctor3-interface)\n  - [Bifunctor3C (interface)](#bifunctor3c-interface)\n  - [Bifunctor4 (interface)](#bifunctor4-interface)\n\n---\n\n# model\n\n## Bifunctor (interface)\n\n**Signature**\n\n```ts\nexport interface Bifunctor<F> {\n  readonly URI: F\n  readonly bimap: <E, A, G, B>(fea: HKT2<F, E, A>, f: (e: E) => G, g: (a: A) => B) => HKT2<F, G, B>\n  readonly mapLeft: <E, A, G>(fea: HKT2<F, E, A>, f: (e: E) => G) => HKT2<F, G, A>\n}\n```\n\nAdded in v2.0.0\n\n## Bifunctor2 (interface)\n\n**Signature**\n\n```ts\nexport interface Bifunctor2<F extends URIS2> {\n  readonly URI: F\n  readonly bimap: <E, A, G, B>(fea: Kind2<F, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind2<F, G, B>\n  readonly mapLeft: <E, A, G>(fea: Kind2<F, E, A>, f: (e: E) => G) => Kind2<F, G, A>\n}\n```\n\nAdded in v2.0.0\n\n## Bifunctor2C (interface)\n\n**Signature**\n\n```ts\nexport interface Bifunctor2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly bimap: <A, G, B>(fea: Kind2<F, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind2<F, G, B>\n  readonly mapLeft: <A, M>(fea: Kind2<F, E, A>, f: (e: E) => M) => Kind2<F, M, A>\n}\n```\n\nAdded in v2.0.0\n\n## Bifunctor3 (interface)\n\n**Signature**\n\n```ts\nexport interface Bifunctor3<F extends URIS3> {\n  readonly URI: F\n  readonly bimap: <R, E, A, G, B>(fea: Kind3<F, R, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind3<F, R, G, B>\n  readonly mapLeft: <R, E, A, G>(fea: Kind3<F, R, E, A>, f: (e: E) => G) => Kind3<F, R, G, A>\n}\n```\n\nAdded in v2.0.0\n\n## Bifunctor3C (interface)\n\n**Signature**\n\n```ts\nexport interface Bifunctor3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly bimap: <R, A, G, B>(fea: Kind3<F, R, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind3<F, R, G, B>\n  readonly mapLeft: <R, A, G>(fea: Kind3<F, R, E, A>, f: (e: E) => G) => Kind3<F, R, G, A>\n}\n```\n\nAdded in v2.2.0\n\n## Bifunctor4 (interface)\n\n**Signature**\n\n```ts\nexport interface Bifunctor4<F extends URIS4> {\n  readonly URI: F\n  readonly bimap: <S, R, E, A, G, B>(fea: Kind4<F, S, R, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind4<F, S, R, G, B>\n  readonly mapLeft: <S, R, E, A, G>(fea: Kind4<F, S, R, E, A>, f: (e: E) => G) => Kind4<F, S, R, G, A>\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/BooleanAlgebra.ts.md",
    "content": "---\ntitle: BooleanAlgebra.ts\nnav_order: 8\nparent: Modules\n---\n\n## BooleanAlgebra overview\n\nBoolean algebras are Heyting algebras with the additional constraint that the law of the excluded middle is true\n(equivalently, double-negation is true).\n\nInstances should satisfy the following laws in addition to the `HeytingAlgebra` laws:\n\n- Excluded middle: `a ∨ ¬a <-> 1`\n\nBoolean algebras generalize classical logic: one is equivalent to \"true\" and zero is equivalent to \"false\".\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [booleanAlgebraVoid](#booleanalgebravoid)\n- [model](#model)\n  - [BooleanAlgebra (interface)](#booleanalgebra-interface)\n- [utils](#utils)\n  - [reverse](#reverse)\n- [zone of death](#zone-of-death)\n  - [~~booleanAlgebraBoolean~~](#booleanalgebraboolean)\n  - [~~getDualBooleanAlgebra~~](#getdualbooleanalgebra)\n  - [~~getFunctionBooleanAlgebra~~](#getfunctionbooleanalgebra)\n\n---\n\n# instances\n\n## booleanAlgebraVoid\n\n**Signature**\n\n```ts\nexport declare const booleanAlgebraVoid: BooleanAlgebra<void>\n```\n\nAdded in v2.0.0\n\n# model\n\n## BooleanAlgebra (interface)\n\n**Signature**\n\n```ts\nexport interface BooleanAlgebra<A> extends HeytingAlgebra<A> {}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## reverse\n\nEvery boolean algebras has a dual algebra, which involves reversing one/zero as well as join/meet.\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(B: BooleanAlgebra<A>) => BooleanAlgebra<A>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~booleanAlgebraBoolean~~\n\nUse [`BooleanAlgebra`](./boolean.ts.html#booleanalgebra) instead.\n\n**Signature**\n\n```ts\nexport declare const booleanAlgebraBoolean: BooleanAlgebra<boolean>\n```\n\nAdded in v2.0.0\n\n## ~~getDualBooleanAlgebra~~\n\nUse [`reverse`](#reverse) instead.\n\n**Signature**\n\n```ts\nexport declare const getDualBooleanAlgebra: <A>(B: BooleanAlgebra<A>) => BooleanAlgebra<A>\n```\n\nAdded in v2.0.0\n\n## ~~getFunctionBooleanAlgebra~~\n\nUse [`getBooleanAlgebra`](./function.ts.html#getbooleanalgebra) instead.\n\n**Signature**\n\n```ts\nexport declare const getFunctionBooleanAlgebra: <B>(\n  B: BooleanAlgebra<B>\n) => <A = never>() => BooleanAlgebra<(a: A) => B>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Bounded.ts.md",
    "content": "---\ntitle: Bounded.ts\nnav_order: 9\nparent: Modules\n---\n\n## Bounded overview\n\nThe `Bounded` type class represents totally ordered types that have an upper and lower boundary.\n\nInstances should satisfy the following law in addition to the `Ord` laws:\n\n- Bounded: `bottom <= a <= top`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Bounded (interface)](#bounded-interface)\n- [utils](#utils)\n  - [clamp](#clamp)\n  - [reverse](#reverse)\n- [zone of death](#zone-of-death)\n  - [~~boundedNumber~~](#boundednumber)\n\n---\n\n# model\n\n## Bounded (interface)\n\n**Signature**\n\n```ts\nexport interface Bounded<A> extends Ord<A> {\n  readonly top: A\n  readonly bottom: A\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## clamp\n\nClamp a value between bottom and top values.\n\n**Signature**\n\n```ts\nexport declare const clamp: <A>(B: Bounded<A>) => (a: A) => A\n```\n\nAdded in v2.12.0\n\n## reverse\n\nReverses the Ord of a bound and swaps top and bottom values.\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(B: Bounded<A>) => Bounded<A>\n```\n\nAdded in v2.12.0\n\n# zone of death\n\n## ~~boundedNumber~~\n\nUse [`Bounded`](./number.ts.html#bounded) instead.\n\n**Signature**\n\n```ts\nexport declare const boundedNumber: Bounded<number>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/BoundedDistributiveLattice.ts.md",
    "content": "---\ntitle: BoundedDistributiveLattice.ts\nnav_order: 10\nparent: Modules\n---\n\n## BoundedDistributiveLattice overview\n\nA `BoundedDistributiveLattice` is a lattice that is both bounded and distributive\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [getMinMaxBoundedDistributiveLattice](#getminmaxboundeddistributivelattice)\n- [model](#model)\n  - [BoundedDistributiveLattice (interface)](#boundeddistributivelattice-interface)\n\n---\n\n# constructors\n\n## getMinMaxBoundedDistributiveLattice\n\n**Signature**\n\n```ts\nexport declare function getMinMaxBoundedDistributiveLattice<A>(\n  O: Ord<A>\n): (min: A, max: A) => BoundedDistributiveLattice<A>\n```\n\nAdded in v2.0.0\n\n# model\n\n## BoundedDistributiveLattice (interface)\n\n**Signature**\n\n```ts\nexport interface BoundedDistributiveLattice<A> extends BoundedLattice<A>, DistributiveLattice<A> {}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/BoundedJoinSemilattice.ts.md",
    "content": "---\ntitle: BoundedJoinSemilattice.ts\nnav_order: 11\nparent: Modules\n---\n\n## BoundedJoinSemilattice overview\n\nA `BoundedJoinSemilattice` must satisfy the following laws in addition to `JoinSemilattice` laws:\n\n- `a ∨ 0 <-> a`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [BoundedJoinSemilattice (interface)](#boundedjoinsemilattice-interface)\n\n---\n\n# model\n\n## BoundedJoinSemilattice (interface)\n\n**Signature**\n\n```ts\nexport interface BoundedJoinSemilattice<A> extends JoinSemilattice<A> {\n  readonly zero: A\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/BoundedLattice.ts.md",
    "content": "---\ntitle: BoundedLattice.ts\nnav_order: 12\nparent: Modules\n---\n\n## BoundedLattice overview\n\nA `BoundedLattice` must satisfy the following in addition to `BoundedMeetSemilattice` and `BoundedJoinSemilattice` laws:\n\n- Absorption law for meet: `a ∧ (a ∨ b) <-> a`\n- Absorption law for join: `a ∨ (a ∧ b) <-> a`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [BoundedLattice (interface)](#boundedlattice-interface)\n\n---\n\n# model\n\n## BoundedLattice (interface)\n\n**Signature**\n\n```ts\nexport interface BoundedLattice<A> extends BoundedJoinSemilattice<A>, BoundedMeetSemilattice<A> {}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/BoundedMeetSemilattice.ts.md",
    "content": "---\ntitle: BoundedMeetSemilattice.ts\nnav_order: 13\nparent: Modules\n---\n\n## BoundedMeetSemilattice overview\n\nA `BoundedMeetSemilattice` must satisfy the following laws in addition to `MeetSemilattice` laws:\n\n- `a ∧ 1 <-> a`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [BoundedMeetSemilattice (interface)](#boundedmeetsemilattice-interface)\n\n---\n\n# model\n\n## BoundedMeetSemilattice (interface)\n\n**Signature**\n\n```ts\nexport interface BoundedMeetSemilattice<A> extends MeetSemilattice<A> {\n  readonly one: A\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Category.ts.md",
    "content": "---\ntitle: Category.ts\nnav_order: 14\nparent: Modules\n---\n\n## Category overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Category (interface)](#category-interface)\n  - [Category2 (interface)](#category2-interface)\n  - [Category3 (interface)](#category3-interface)\n  - [Category4 (interface)](#category4-interface)\n\n---\n\n# model\n\n## Category (interface)\n\n**Signature**\n\n```ts\nexport interface Category<F> extends Semigroupoid<F> {\n  readonly id: <A>() => HKT2<F, A, A>\n}\n```\n\nAdded in v2.0.0\n\n## Category2 (interface)\n\n**Signature**\n\n```ts\nexport interface Category2<F extends URIS2> extends Semigroupoid2<F> {\n  readonly id: <A>() => Kind2<F, A, A>\n}\n```\n\nAdded in v2.0.0\n\n## Category3 (interface)\n\n**Signature**\n\n```ts\nexport interface Category3<F extends URIS3> extends Semigroupoid3<F> {\n  readonly id: <R, A>() => Kind3<F, R, A, A>\n}\n```\n\nAdded in v2.0.0\n\n## Category4 (interface)\n\n**Signature**\n\n```ts\nexport interface Category4<F extends URIS4> extends Semigroupoid4<F> {\n  readonly id: <S, R, A>() => Kind4<F, S, R, A, A>\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Chain.ts.md",
    "content": "---\ntitle: Chain.ts\nnav_order: 15\nparent: Modules\n---\n\n## Chain overview\n\nThe `Chain` type class extends the `Apply` type class with a `chain` operation which composes computations in\nsequence, using the return value of one computation to determine the next computation.\n\nInstances must satisfy the following law in addition to the `Apply` laws:\n\n1. Associativity: `F.chain(F.chain(fa, afb), bfc) <-> F.chain(fa, a => F.chain(afb(a), bfc))`\n\nNote. `Apply`'s `ap` can be derived: `(fab, fa) => F.chain(fab, f => F.map(fa, f))`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Chain (interface)](#chain-interface)\n  - [Chain1 (interface)](#chain1-interface)\n  - [Chain2 (interface)](#chain2-interface)\n  - [Chain2C (interface)](#chain2c-interface)\n  - [Chain3 (interface)](#chain3-interface)\n  - [Chain3C (interface)](#chain3c-interface)\n  - [Chain4 (interface)](#chain4-interface)\n- [utils](#utils)\n  - [bind](#bind)\n  - [chainFirst](#chainfirst)\n\n---\n\n# model\n\n## Chain (interface)\n\n**Signature**\n\n```ts\nexport interface Chain<F> extends Apply<F> {\n  readonly chain: <A, B>(fa: HKT<F, A>, f: (a: A) => HKT<F, B>) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Chain1 (interface)\n\n**Signature**\n\n```ts\nexport interface Chain1<F extends URIS> extends Apply1<F> {\n  readonly chain: <A, B>(fa: Kind<F, A>, f: (a: A) => Kind<F, B>) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Chain2 (interface)\n\n**Signature**\n\n```ts\nexport interface Chain2<F extends URIS2> extends Apply2<F> {\n  readonly chain: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => Kind2<F, E, B>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Chain2C (interface)\n\n**Signature**\n\n```ts\nexport interface Chain2C<F extends URIS2, E> extends Apply2C<F, E> {\n  readonly chain: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => Kind2<F, E, B>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Chain3 (interface)\n\n**Signature**\n\n```ts\nexport interface Chain3<F extends URIS3> extends Apply3<F> {\n  readonly chain: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Kind3<F, R, E, B>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Chain3C (interface)\n\n**Signature**\n\n```ts\nexport interface Chain3C<F extends URIS3, E> extends Apply3C<F, E> {\n  readonly chain: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Kind3<F, R, E, B>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## Chain4 (interface)\n\n**Signature**\n\n```ts\nexport interface Chain4<F extends URIS4> extends Apply4<F> {\n  readonly chain: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => Kind4<F, S, R, E, B>) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## bind\n\n**Signature**\n\n```ts\nexport declare function bind<M extends URIS4>(\n  M: Chain4<M>\n): <N extends string, A, S, R, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind4<M, S, R, E, B>\n) => (ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function bind<M extends URIS3>(\n  M: Chain3<M>\n): <N extends string, A, R, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind3<M, R, E, B>\n) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function bind<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <N extends string, A, R, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind3<M, R, E, B>\n) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function bind<M extends URIS2>(\n  M: Chain2<M>\n): <N extends string, A, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind2<M, E, B>\n) => (ma: Kind2<M, E, A>) => Kind2<M, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function bind<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind2<M, E, B>\n) => (ma: Kind2<M, E, A>) => Kind2<M, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function bind<M extends URIS>(\n  M: Chain1<M>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind<M, B>\n) => (ma: Kind<M, A>) => Kind<M, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport declare function bind<M>(\n  M: Chain<M>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => HKT<M, B>\n) => (ma: HKT<M, A>) => HKT<M, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.10.0\n\n## chainFirst\n\n**Signature**\n\n```ts\nexport declare function chainFirst<M extends URIS4>(\n  M: Chain4<M>\n): <A, S, R, E, _>(f: (a: A) => Kind4<M, S, R, E, _>) => (first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport declare function chainFirst<M extends URIS3>(\n  M: Chain3<M>\n): <A, R, E, _>(f: (a: A) => Kind3<M, R, E, _>) => (first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirst<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <A, R, _>(f: (a: A) => Kind3<M, R, E, _>) => (first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirst<M extends URIS2>(\n  M: Chain2<M>\n): <A, E, _>(f: (a: A) => Kind2<M, E, _>) => (first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport declare function chainFirst<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <A, _>(f: (a: A) => Kind2<M, E, _>) => (first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport declare function chainFirst<M extends URIS>(\n  M: Chain1<M>\n): <A, _>(f: (a: A) => Kind<M, _>) => (first: Kind<M, A>) => Kind<M, A>\nexport declare function chainFirst<M>(M: Chain<M>): <A, _>(f: (a: A) => HKT<M, _>) => (first: HKT<M, A>) => HKT<M, A>\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/ChainRec.ts.md",
    "content": "---\ntitle: ChainRec.ts\nnav_order: 16\nparent: Modules\n---\n\n## ChainRec overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [ChainRec (interface)](#chainrec-interface)\n  - [ChainRec1 (interface)](#chainrec1-interface)\n  - [ChainRec2 (interface)](#chainrec2-interface)\n  - [ChainRec2C (interface)](#chainrec2c-interface)\n  - [ChainRec3 (interface)](#chainrec3-interface)\n  - [ChainRec3C (interface)](#chainrec3c-interface)\n  - [ChainRec4 (interface)](#chainrec4-interface)\n- [utils](#utils)\n  - [tailRec](#tailrec)\n\n---\n\n# model\n\n## ChainRec (interface)\n\n**Signature**\n\n```ts\nexport interface ChainRec<F> extends Chain<F> {\n  readonly chainRec: <A, B>(a: A, f: (a: A) => HKT<F, Either<A, B>>) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ChainRec1 (interface)\n\n**Signature**\n\n```ts\nexport interface ChainRec1<F extends URIS> extends Chain1<F> {\n  readonly chainRec: <A, B>(a: A, f: (a: A) => Kind<F, Either<A, B>>) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ChainRec2 (interface)\n\n**Signature**\n\n```ts\nexport interface ChainRec2<F extends URIS2> extends Chain2<F> {\n  readonly chainRec: <E, A, B>(a: A, f: (a: A) => Kind2<F, E, Either<A, B>>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ChainRec2C (interface)\n\n**Signature**\n\n```ts\nexport interface ChainRec2C<F extends URIS2, E> extends Chain2C<F, E> {\n  readonly chainRec: <A, B>(a: A, f: (a: A) => Kind2<F, E, Either<A, B>>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ChainRec3 (interface)\n\n**Signature**\n\n```ts\nexport interface ChainRec3<F extends URIS3> extends Chain3<F> {\n  readonly chainRec: <R, E, A, B>(a: A, f: (a: A) => Kind3<F, R, E, Either<A, B>>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ChainRec3C (interface)\n\n**Signature**\n\n```ts\nexport interface ChainRec3C<F extends URIS3, E> extends Chain3C<F, E> {\n  readonly chainRec: <R, A, B>(a: A, f: (a: A) => Kind3<F, R, E, Either<A, B>>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.10.0\n\n## ChainRec4 (interface)\n\n**Signature**\n\n```ts\nexport interface ChainRec4<F extends URIS4> extends Chain4<F> {\n  readonly chainRec: <S, R, E, A, B>(a: A, f: (a: A) => Kind4<F, S, R, E, Either<A, B>>) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.10.0\n\n# utils\n\n## tailRec\n\n**Signature**\n\n```ts\nexport declare const tailRec: <A, B>(startWith: A, f: (a: A) => Either<A, B>) => B\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Choice.ts.md",
    "content": "---\ntitle: Choice.ts\nnav_order: 17\nparent: Modules\n---\n\n## Choice overview\n\nThe `Choice` class extends `Profunctor` with combinators for working with\nsum types.\n\n`left` and `right` lift values in a `Profunctor` to act on the `Left` and\n`Right` components of a sum, respectively.\n\nLooking at `Choice` through the intuition of inputs and outputs\nyields the following type signature:\n\n```purescript\nleft ::  forall input output a. p input output -> p (Either input a) (Either output a)\nright :: forall input output a. p input output -> p (Either a input) (Either a output)\n```\n\nIf we specialize the profunctor `p` to the `function` arrow, we get the following type\nsignatures:\n\n```purescript\nleft ::  forall input output a. (input -> output) -> (Either input a) -> (Either output a)\nright :: forall input output a. (input -> output) -> (Either a input) -> (Either a output)\n```\n\nWhen the `profunctor` is `Function` application, `left` allows you to map a function over the\nleft side of an `Either`, and `right` maps it over the right side (same as `map` would do).\n\nAdapted from https://github.com/purescript/purescript-profunctor/blob/master/src/Data/Profunctor/Choice.purs\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Choice (interface)](#choice-interface)\n  - [Choice2 (interface)](#choice2-interface)\n  - [Choice3 (interface)](#choice3-interface)\n  - [Choice4 (interface)](#choice4-interface)\n- [utils](#utils)\n  - [fanIn](#fanin)\n  - [split](#split)\n  - [~~fanin~~](#fanin)\n- [zone of death](#zone-of-death)\n  - [~~splitChoice~~](#splitchoice)\n\n---\n\n# model\n\n## Choice (interface)\n\n**Signature**\n\n```ts\nexport interface Choice<F> extends Profunctor<F> {\n  readonly left: <A, B, C>(pab: HKT2<F, A, B>) => HKT2<F, Either<A, C>, Either<B, C>>\n  readonly right: <A, B, C>(pbc: HKT2<F, B, C>) => HKT2<F, Either<A, B>, Either<A, C>>\n}\n```\n\nAdded in v2.0.0\n\n## Choice2 (interface)\n\n**Signature**\n\n```ts\nexport interface Choice2<F extends URIS2> extends Profunctor2<F> {\n  readonly left: <A, B, C>(pab: Kind2<F, A, B>) => Kind2<F, Either<A, C>, Either<B, C>>\n  readonly right: <A, B, C>(pbc: Kind2<F, B, C>) => Kind2<F, Either<A, B>, Either<A, C>>\n}\n```\n\nAdded in v2.0.0\n\n## Choice3 (interface)\n\n**Signature**\n\n```ts\nexport interface Choice3<F extends URIS3> extends Profunctor3<F> {\n  readonly left: <R, A, B, C>(pab: Kind3<F, R, A, B>) => Kind3<F, R, Either<A, C>, Either<B, C>>\n  readonly right: <R, A, B, C>(pbc: Kind3<F, R, B, C>) => Kind3<F, R, Either<A, B>, Either<A, C>>\n}\n```\n\nAdded in v2.0.0\n\n## Choice4 (interface)\n\n**Signature**\n\n```ts\nexport interface Choice4<F extends URIS4> extends Profunctor4<F> {\n  readonly left: <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, Either<A, C>, Either<B, C>>\n  readonly right: <S, R, A, B, C>(pbc: Kind4<F, S, R, B, C>) => Kind4<F, S, R, Either<A, B>, Either<A, C>>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## fanIn\n\nCompose a value which eliminates a sum from two values, each eliminating\none side of the sum.\n\nThis combinator is useful when assembling values from smaller components,\nbecause it provides a way to support two different types of input.\n\nSpecializing `fanIn` to function application would look like this:\n\n```purescript\nfanIn :: forall a b c d. (a -> c) -> (b -> c) -> Either a b -> c\n```\n\nWe take two functions, `f` and `g`, which both return the same type `c` and we transform them into a\nsingle function which takes an `Either` value with the parameter type of `f` on the left side and\nthe parameter type of `g` on the right side. The function then runs either `f` or `g`, depending on\nwhether the `Either` value is a `Left` or a `Right`.\nThis allows us to bundle two different computations which both have the same result type into one\nfunction which will run the appropriate computation based on the parameter supplied in the `Either` value.\n\n**Signature**\n\n```ts\nexport declare function fanIn<P extends URIS4>(\n  P: Choice4<P>,\n  C: Category4<P>\n): <S, R, A, B, C>(pac: Kind4<P, S, R, A, C>, pbc: Kind4<P, S, R, B, C>) => Kind4<P, S, R, Either<A, B>, C>\nexport declare function fanIn<P extends URIS3>(\n  P: Choice3<P>,\n  C: Category3<P>\n): <R, A, B, C>(pac: Kind3<P, R, A, C>, pbc: Kind3<P, R, B, C>) => Kind3<P, R, Either<A, B>, C>\nexport declare function fanIn<P extends URIS2>(\n  P: Choice2<P>,\n  C: Category2<P>\n): <A, B, C>(pac: Kind2<P, A, C>, pbc: Kind2<P, B, C>) => Kind2<P, Either<A, B>, C>\nexport declare function fanIn<P>(\n  P: Choice<P>,\n  C: Category<P>\n): <A, B, C>(pac: HKT2<P, A, C>, pbc: HKT2<P, B, C>) => HKT2<P, Either<A, B>, C>\n```\n\nAdded in v2.10.0\n\n## split\n\nCompose a value acting on a sum from two values, each acting on one of\nthe components of the sum.\n\nSpecializing `split` to function application would look like this:\n\n```purescript\nsplit :: forall a b c d. (a -> b) -> (c -> d) -> (Either a c) -> (Either b d)\n```\n\nWe take two functions, `f` and `g`, and we transform them into a single function which\ntakes an `Either`and maps `f` over the left side and `g` over the right side. Just like\n`bimap` would do for the `Bifunctor` instance of `Either`.\n\n**Signature**\n\n```ts\nexport declare function split<P extends URIS4>(\n  P: Choice4<P>,\n  C: Category4<P>\n): <S, R, A, B, C, D>(\n  pab: Kind4<P, S, R, A, B>,\n  pcd: Kind4<P, S, R, C, D>\n) => Kind4<P, S, R, Either<A, C>, Either<B, D>>\nexport declare function split<P extends URIS3>(\n  P: Choice3<P>,\n  C: Category3<P>\n): <R, A, B, C, D>(pab: Kind3<P, R, A, B>, pcd: Kind3<P, R, C, D>) => Kind3<P, R, Either<A, C>, Either<B, D>>\nexport declare function split<P extends URIS2>(\n  P: Choice2<P>,\n  C: Category2<P>\n): <A, B, C, D>(pab: Kind2<P, A, B>, pcd: Kind2<P, C, D>) => Kind2<P, Either<A, C>, Either<B, D>>\nexport declare function split<P>(\n  P: Choice<P>,\n  C: Category<P>\n): <A, B, C, D>(pab: HKT2<P, A, B>, pcd: HKT2<P, C, D>) => HKT2<P, Either<A, C>, Either<B, D>>\n```\n\nAdded in v2.10.0\n\n## ~~fanin~~\n\nUse [`fanIn`](#fanIn) instead.\n\n**Signature**\n\n```ts\nexport declare function fanin<F extends URIS3>(\n  F: Category3<F> & Choice3<F>\n): <R, A, B, C>(pac: Kind3<F, R, A, C>, pbc: Kind3<F, R, B, C>) => Kind3<F, R, Either<A, B>, C>\nexport declare function fanin<F extends URIS2>(\n  F: Category2<F> & Choice2<F>\n): <A, B, C>(pac: Kind2<F, A, C>, pbc: Kind2<F, B, C>) => Kind2<F, Either<A, B>, C>\nexport declare function fanin<F>(\n  F: Category<F> & Choice<F>\n): <A, B, C>(pac: HKT2<F, A, C>, pbc: HKT2<F, B, C>) => HKT2<F, Either<A, B>, C>\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~splitChoice~~\n\nUse [`split`](#split) instead.\n\n**Signature**\n\n```ts\nexport declare function splitChoice<F extends URIS3>(\n  F: Category3<F> & Choice3<F>\n): <R, A, B, C, D>(pab: Kind3<F, R, A, B>, pcd: Kind3<F, R, C, D>) => Kind3<F, R, Either<A, C>, Either<B, D>>\nexport declare function splitChoice<F extends URIS2>(\n  F: Category2<F> & Choice2<F>\n): <A, B, C, D>(pab: Kind2<F, A, B>, pcd: Kind2<F, C, D>) => Kind2<F, Either<A, C>, Either<B, D>>\nexport declare function splitChoice<F>(\n  F: Category<F> & Choice<F>\n): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, Either<A, C>, Either<B, D>>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Comonad.ts.md",
    "content": "---\ntitle: Comonad.ts\nnav_order: 18\nparent: Modules\n---\n\n## Comonad overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Comonad (interface)](#comonad-interface)\n  - [Comonad1 (interface)](#comonad1-interface)\n  - [Comonad2 (interface)](#comonad2-interface)\n  - [Comonad2C (interface)](#comonad2c-interface)\n  - [Comonad3 (interface)](#comonad3-interface)\n  - [Comonad3C (interface)](#comonad3c-interface)\n  - [Comonad4 (interface)](#comonad4-interface)\n\n---\n\n# model\n\n## Comonad (interface)\n\n**Signature**\n\n```ts\nexport interface Comonad<W> extends Extend<W> {\n  readonly extract: <A>(wa: HKT<W, A>) => A\n}\n```\n\nAdded in v2.0.0\n\n## Comonad1 (interface)\n\n**Signature**\n\n```ts\nexport interface Comonad1<W extends URIS> extends Extend1<W> {\n  readonly extract: <A>(wa: Kind<W, A>) => A\n}\n```\n\nAdded in v2.0.0\n\n## Comonad2 (interface)\n\n**Signature**\n\n```ts\nexport interface Comonad2<W extends URIS2> extends Extend2<W> {\n  readonly extract: <E, A>(wa: Kind2<W, E, A>) => A\n}\n```\n\nAdded in v2.0.0\n\n## Comonad2C (interface)\n\n**Signature**\n\n```ts\nexport interface Comonad2C<W extends URIS2, E> extends Extend2C<W, E> {\n  readonly extract: <A>(wa: Kind2<W, E, A>) => A\n}\n```\n\nAdded in v2.0.0\n\n## Comonad3 (interface)\n\n**Signature**\n\n```ts\nexport interface Comonad3<W extends URIS3> extends Extend3<W> {\n  readonly extract: <R, E, A>(wa: Kind3<W, R, E, A>) => A\n}\n```\n\nAdded in v2.0.0\n\n## Comonad3C (interface)\n\n**Signature**\n\n```ts\nexport interface Comonad3C<W extends URIS3, E> extends Extend3C<W, E> {\n  readonly extract: <R, A>(wa: Kind3<W, R, E, A>) => A\n}\n```\n\nAdded in v2.10.0\n\n## Comonad4 (interface)\n\n**Signature**\n\n```ts\nexport interface Comonad4<W extends URIS4> extends Extend4<W> {\n  readonly extract: <S, R, E, A>(wa: Kind4<W, S, R, E, A>) => A\n}\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/Compactable.ts.md",
    "content": "---\ntitle: Compactable.ts\nnav_order: 19\nparent: Modules\n---\n\n## Compactable overview\n\n`Compactable` represents data structures which can be _compacted_/_filtered_. This is a generalization of\n`catOptions` as a new function `compact`. `compact` has relations with `Functor`, `Applicative`,\n`Monad`, `Alternative`, and `Traversable` in that we can use these classes to provide the ability to\noperate on a data type by eliminating intermediate `None`s. This is useful for representing the filtering out of\nvalues, or failure.\n\nAdapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Compactable.purs\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Compactable (interface)](#compactable-interface)\n  - [Compactable1 (interface)](#compactable1-interface)\n  - [Compactable2 (interface)](#compactable2-interface)\n  - [Compactable2C (interface)](#compactable2c-interface)\n  - [Compactable3 (interface)](#compactable3-interface)\n  - [Compactable3C (interface)](#compactable3c-interface)\n  - [Compactable4 (interface)](#compactable4-interface)\n- [utils](#utils)\n  - [compact](#compact)\n  - [separate](#separate)\n  - [~~Separated~~ (interface)](#separated-interface)\n- [zone of death](#zone-of-death)\n  - [~~CompactableComposition11~~ (interface)](#compactablecomposition11-interface)\n  - [~~CompactableComposition12C~~ (interface)](#compactablecomposition12c-interface)\n  - [~~CompactableComposition12~~ (interface)](#compactablecomposition12-interface)\n  - [~~CompactableComposition21~~ (interface)](#compactablecomposition21-interface)\n  - [~~CompactableComposition22C~~ (interface)](#compactablecomposition22c-interface)\n  - [~~CompactableComposition22~~ (interface)](#compactablecomposition22-interface)\n  - [~~CompactableComposition23C~~ (interface)](#compactablecomposition23c-interface)\n  - [~~CompactableComposition23~~ (interface)](#compactablecomposition23-interface)\n  - [~~CompactableComposition2C1~~ (interface)](#compactablecomposition2c1-interface)\n  - [~~CompactableComposition~~ (interface)](#compactablecomposition-interface)\n  - [~~getCompactableComposition~~](#getcompactablecomposition)\n\n---\n\n# model\n\n## Compactable (interface)\n\n**Signature**\n\n```ts\nexport interface Compactable<F> {\n  readonly URI: F\n  /**\n   * Compacts a data structure unwrapping inner Option\n   */\n  readonly compact: <A>(fa: HKT<F, Option<A>>) => HKT<F, A>\n  /**\n   * Separates a data structure moving inner Left to the left side and inner Right to the right side of Separated\n   */\n  readonly separate: <A, B>(fa: HKT<F, Either<A, B>>) => S.Separated<HKT<F, A>, HKT<F, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Compactable1 (interface)\n\n**Signature**\n\n```ts\nexport interface Compactable1<F extends URIS> {\n  readonly URI: F\n  readonly compact: <A>(fa: Kind<F, Option<A>>) => Kind<F, A>\n  readonly separate: <A, B>(fa: Kind<F, Either<A, B>>) => S.Separated<Kind<F, A>, Kind<F, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Compactable2 (interface)\n\n**Signature**\n\n```ts\nexport interface Compactable2<F extends URIS2> {\n  readonly URI: F\n  readonly compact: <E, A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>\n  readonly separate: <E, A, B>(fa: Kind2<F, E, Either<A, B>>) => S.Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Compactable2C (interface)\n\n**Signature**\n\n```ts\nexport interface Compactable2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly compact: <A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>\n  readonly separate: <A, B>(fa: Kind2<F, E, Either<A, B>>) => S.Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Compactable3 (interface)\n\n**Signature**\n\n```ts\nexport interface Compactable3<F extends URIS3> {\n  readonly URI: F\n  readonly compact: <R, E, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>\n  readonly separate: <R, E, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => S.Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Compactable3C (interface)\n\n**Signature**\n\n```ts\nexport interface Compactable3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly compact: <R, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>\n  readonly separate: <R, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => S.Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n}\n```\n\nAdded in v2.2.0\n\n## Compactable4 (interface)\n\n**Signature**\n\n```ts\nexport interface Compactable4<F extends URIS4> {\n  readonly URI: F\n  readonly compact: <S, R, E, A>(fa: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, A>\n  readonly separate: <S, R, E, A, B>(\n    fa: Kind4<F, S, R, E, Either<A, B>>\n  ) => S.Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## compact\n\n`compact` composition.\n\n**Signature**\n\n```ts\nexport declare function compact<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Compactable2C<G, E>\n): <FE, A>(fa: Kind2<F, FE, Kind2<G, E, Option<A>>>) => Kind2<F, FE, Kind2<G, E, A>>\nexport declare function compact<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Compactable2C<G, E>\n): <A>(fa: Kind<F, Kind2<G, E, Option<A>>>) => Kind<F, Kind2<G, E, A>>\nexport declare function compact<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Compactable1<G>\n): <A>(fa: Kind<F, Kind<G, Option<A>>>) => Kind<F, Kind<G, A>>\nexport declare function compact<F, G>(\n  F: Functor<F>,\n  G: Compactable<G>\n): <A>(fa: HKT<F, HKT<G, Option<A>>>) => HKT<F, HKT<G, A>>\n```\n\nAdded in v2.10.0\n\n## separate\n\n`separate` composition.\n\n**Signature**\n\n```ts\nexport declare function separate<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  C: Compactable2C<G, E>,\n  G: Functor2<G>\n): <FE, A, B>(\n  fge: Kind2<F, FE, Kind2<G, E, Either<A, B>>>\n) => S.Separated<Kind2<F, FE, Kind2<G, E, A>>, Kind2<F, FE, Kind2<G, E, B>>>\nexport declare function separate<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  C: Compactable2C<G, E>,\n  G: Functor2<G>\n): <A, B>(fge: Kind<F, Kind2<G, E, Either<A, B>>>) => S.Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>\nexport declare function separate<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  C: Compactable1<G>,\n  G: Functor1<G>\n): <A, B>(fge: Kind<F, Kind<G, Either<A, B>>>) => S.Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, B>>>\nexport declare function separate<F, G>(\n  F: Functor<F>,\n  C: Compactable<G>,\n  G: Functor<G>\n): <A, B>(fge: HKT<F, HKT<G, Either<A, B>>>) => S.Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>>\n```\n\nAdded in v2.10.0\n\n## ~~Separated~~ (interface)\n\nUse [`Separated`](./Separated.ts.html#separated) instead.\n\n**Signature**\n\n```ts\nexport interface Separated<A, B> {\n  readonly left: A\n  readonly right: B\n}\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~CompactableComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition11<F extends URIS, G extends URIS> extends FunctorComposition11<F, G> {\n  readonly compact: <A>(fga: Kind<F, Kind<G, Option<A>>>) => Kind<F, Kind<G, A>>\n  readonly separate: <A, B>(fge: Kind<F, Kind<G, Either<A, B>>>) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, B>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~CompactableComposition12C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition12C<F extends URIS, G extends URIS2, E> extends FunctorComposition12C<F, G, E> {\n  readonly compact: <A>(fga: Kind<F, Kind2<G, E, Option<A>>>) => Kind<F, Kind2<G, E, A>>\n  readonly separate: <A, B>(\n    fge: Kind<F, Kind2<G, E, Either<A, B>>>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~CompactableComposition12~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition12<F extends URIS, G extends URIS2> extends FunctorComposition12<F, G> {\n  readonly compact: <E, A>(fga: Kind<F, Kind2<G, E, Option<A>>>) => Kind<F, Kind2<G, E, A>>\n  readonly separate: <E, A, B>(\n    fge: Kind<F, Kind2<G, E, Either<A, B>>>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~CompactableComposition21~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition21<F extends URIS2, G extends URIS> extends FunctorComposition21<F, G> {\n  readonly compact: <FE, A>(fga: Kind2<F, FE, Kind<G, Option<A>>>) => Kind2<F, FE, Kind<G, A>>\n  readonly separate: <FE, A, B>(\n    fge: Kind2<F, FE, Kind<G, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind<G, A>>, Kind2<F, FE, Kind<G, B>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~CompactableComposition22C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition22C<F extends URIS2, G extends URIS2, E> extends FunctorComposition22C<F, G, E> {\n  readonly compact: <FE, A>(fga: Kind2<F, FE, Kind2<G, E, Option<A>>>) => Kind2<F, FE, Kind2<G, E, A>>\n  readonly separate: <FE, A, B>(\n    fge: Kind2<F, FE, Kind2<G, E, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind2<G, E, A>>, Kind2<F, FE, Kind2<G, E, B>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~CompactableComposition22~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition22<F extends URIS2, G extends URIS2> extends FunctorComposition22<F, G> {\n  readonly compact: <FE, GE, A>(fga: Kind2<F, FE, Kind2<G, GE, Option<A>>>) => Kind2<F, FE, Kind2<G, GE, A>>\n  readonly separate: <FE, GE, A, B>(\n    fge: Kind2<F, FE, Kind2<G, GE, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind2<G, GE, A>>, Kind2<F, FE, Kind2<G, GE, B>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~CompactableComposition23C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition23C<F extends URIS2, G extends URIS3, E> extends FunctorComposition23C<F, G, E> {\n  readonly compact: <FE, R, A>(fga: Kind2<F, FE, Kind3<G, R, E, Option<A>>>) => Kind2<F, FE, Kind3<G, R, E, A>>\n  readonly separate: <FE, R, A, B>(\n    fge: Kind2<F, FE, Kind3<G, R, E, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind3<G, R, E, A>>, Kind2<F, FE, Kind3<G, R, E, B>>>\n}\n```\n\nAdded in v2.2.0\n\n## ~~CompactableComposition23~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition23<F extends URIS2, G extends URIS3> extends FunctorComposition23<F, G> {\n  readonly compact: <R, FE, GE, A>(fga: Kind2<F, FE, Kind3<G, R, GE, Option<A>>>) => Kind2<F, FE, Kind3<G, R, GE, A>>\n  readonly separate: <R, FE, GE, A, B>(\n    fge: Kind2<F, FE, Kind3<G, R, GE, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind3<G, R, GE, A>>, Kind2<F, FE, Kind3<G, R, GE, B>>>\n}\n```\n\nAdded in v2.2.0\n\n## ~~CompactableComposition2C1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition2C1<F extends URIS2, G extends URIS, E> extends FunctorComposition2C1<F, G, E> {\n  readonly compact: <A>(fga: Kind2<F, E, Kind<G, Option<A>>>) => Kind2<F, E, Kind<G, A>>\n  readonly separate: <A, B>(\n    fge: Kind2<F, E, Kind<G, Either<A, B>>>\n  ) => Separated<Kind2<F, E, Kind<G, A>>, Kind2<F, E, Kind<G, B>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~CompactableComposition~~ (interface)\n\n**Signature**\n\n```ts\nexport interface CompactableComposition<F, G> extends FunctorComposition<F, G> {\n  readonly compact: <A>(fga: HKT<F, HKT<G, Option<A>>>) => HKT<F, HKT<G, A>>\n  readonly separate: <A, B>(fge: HKT<F, HKT<G, Either<A, B>>>) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~getCompactableComposition~~\n\nUse [`compact`](#compact) and [`separate`](#separate) instead.\n\n**Signature**\n\n```ts\nexport declare function getCompactableComposition<F extends URIS2, G extends URIS3, E>(\n  F: Functor2<F>,\n  G: Compactable3C<G, E> & Functor3C<G, E>\n): CompactableComposition23C<F, G, E>\nexport declare function getCompactableComposition<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Compactable2C<G, E> & Functor2C<G, E>\n): CompactableComposition22C<F, G, E>\nexport declare function getCompactableComposition<F extends URIS2, G extends URIS2>(\n  F: Functor2<F>,\n  G: Compactable2<G> & Functor2<G>\n): CompactableComposition22<F, G>\nexport declare function getCompactableComposition<F extends URIS2, G extends URIS, E>(\n  F: Functor2C<F, E>,\n  G: Compactable1<G> & Functor1<G>\n): CompactableComposition2C1<F, G, E>\nexport declare function getCompactableComposition<F extends URIS2, G extends URIS>(\n  F: Functor2<F>,\n  G: Compactable1<G> & Functor1<G>\n): CompactableComposition21<F, G>\nexport declare function getCompactableComposition<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Compactable2C<G, E> & Functor2C<G, E>\n): CompactableComposition12<F, G>\nexport declare function getCompactableComposition<F extends URIS, G extends URIS2>(\n  F: Functor1<F>,\n  G: Compactable2<G> & Functor2<G>\n): CompactableComposition12<F, G>\nexport declare function getCompactableComposition<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Compactable1<G> & Functor1<G>\n): CompactableComposition11<F, G>\nexport declare function getCompactableComposition<F, G>(\n  F: Functor<F>,\n  G: Compactable<G> & Functor<G>\n): CompactableComposition<F, G>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Console.ts.md",
    "content": "---\ntitle: Console.ts\nnav_order: 20\nparent: Modules\n---\n\n## Console overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [utils](#utils)\n  - [error](#error)\n  - [info](#info)\n  - [log](#log)\n  - [warn](#warn)\n\n---\n\n# utils\n\n## error\n\n**Signature**\n\n```ts\nexport declare const error: <A>(a: A) => IO<void>\n```\n\nAdded in v2.0.0\n\n## info\n\n**Signature**\n\n```ts\nexport declare const info: <A>(a: A) => IO<void>\n```\n\nAdded in v2.0.0\n\n## log\n\n**Signature**\n\n```ts\nexport declare const log: <A>(a: A) => IO<void>\n```\n\nAdded in v2.0.0\n\n## warn\n\n**Signature**\n\n```ts\nexport declare const warn: <A>(a: A) => IO<void>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Const.ts.md",
    "content": "---\ntitle: Const.ts\nnav_order: 21\nparent: Modules\n---\n\n## Const overview\n\nThe `Const` type constructor, which wraps its first type argument and ignores its second.\nThat is, `Const<E, A>` is isomorphic to `E` for any `A`.\n\n`Const` has some useful instances. For example, the `Applicative` instance allows us to collect results using a `Monoid`\nwhile ignoring return values.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [make](#make)\n- [error handling](#error-handling)\n  - [mapLeft](#mapleft)\n- [instances](#instances)\n  - [Bifunctor](#bifunctor)\n  - [Contravariant](#contravariant)\n  - [Functor](#functor)\n  - [getApplicative](#getapplicative)\n  - [getApply](#getapply)\n  - [getBooleanAlgebra](#getbooleanalgebra)\n  - [getBounded](#getbounded)\n  - [getEq](#geteq)\n  - [getHeytingAlgebra](#getheytingalgebra)\n  - [getMonoid](#getmonoid)\n  - [getOrd](#getord)\n  - [getRing](#getring)\n  - [getSemigroup](#getsemigroup)\n  - [getSemiring](#getsemiring)\n  - [getShow](#getshow)\n- [mapping](#mapping)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Const (type alias)](#const-type-alias)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [contramap](#contramap)\n- [zone of death](#zone-of-death)\n  - [~~const\\_~~](#const_)\n\n---\n\n# constructors\n\n## make\n\n**Signature**\n\n```ts\nexport declare const make: <E, A = never>(e: E) => Const<E, A>\n```\n\nAdded in v2.0.0\n\n# error handling\n\n## mapLeft\n\nMap a function over the first type argument of a bifunctor.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Const<E, A>) => Const<G, A>\n```\n\nAdded in v2.6.2\n\n# instances\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor2<'Const'>\n```\n\nAdded in v2.7.0\n\n## Contravariant\n\n**Signature**\n\n```ts\nexport declare const Contravariant: Contravariant2<'Const'>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'Const'>\n```\n\nAdded in v2.7.0\n\n## getApplicative\n\n**Signature**\n\n```ts\nexport declare function getApplicative<E>(M: Monoid<E>): Applicative2C<URI, E>\n```\n\nAdded in v2.0.0\n\n## getApply\n\n**Signature**\n\n```ts\nexport declare function getApply<E>(S: Semigroup<E>): Apply2C<URI, E>\n```\n\nAdded in v2.0.0\n\n## getBooleanAlgebra\n\n**Signature**\n\n```ts\nexport declare const getBooleanAlgebra: <E, A>(H: BooleanAlgebra<E>) => BooleanAlgebra<Const<E, A>>\n```\n\nAdded in v2.6.0\n\n## getBounded\n\n**Signature**\n\n```ts\nexport declare const getBounded: <E, A>(B: Bounded<E>) => Bounded<Const<E, A>>\n```\n\nAdded in v2.6.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare const getEq: <E, A>(E: Eq<E>) => Eq<Const<E, A>>\n```\n\nAdded in v2.0.0\n\n## getHeytingAlgebra\n\n**Signature**\n\n```ts\nexport declare const getHeytingAlgebra: <E, A>(H: HeytingAlgebra<E>) => HeytingAlgebra<Const<E, A>>\n```\n\nAdded in v2.6.0\n\n## getMonoid\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <E, A>(M: Monoid<E>) => Monoid<Const<E, A>>\n```\n\nAdded in v2.6.0\n\n## getOrd\n\n**Signature**\n\n```ts\nexport declare const getOrd: <E, A>(O: Ord<E>) => Ord<Const<E, A>>\n```\n\nAdded in v2.6.0\n\n## getRing\n\n**Signature**\n\n```ts\nexport declare const getRing: <E, A>(S: Ring<E>) => Ring<Const<E, A>>\n```\n\nAdded in v2.6.0\n\n## getSemigroup\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <E, A>(S: Semigroup<E>) => Semigroup<Const<E, A>>\n```\n\nAdded in v2.6.0\n\n## getSemiring\n\n**Signature**\n\n```ts\nexport declare const getSemiring: <E, A>(S: Semiring<E>) => Semiring<Const<E, A>>\n```\n\nAdded in v2.6.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare function getShow<E, A>(S: Show<E>): Show<Const<E, A>>\n```\n\nAdded in v2.0.0\n\n# mapping\n\n## bimap\n\nMap a pair of functions over the two type arguments of the bifunctor.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Const<E, A>) => Const<G, B>\n```\n\nAdded in v2.6.2\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: Const<E, (a: A) => B>) => Const<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Const<E, A>) => Const<E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## Const (type alias)\n\n**Signature**\n\n```ts\nexport type Const<E, A> = E & { readonly _A: A }\n```\n\nAdded in v2.0.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Const'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## contramap\n\n**Signature**\n\n```ts\nexport declare const contramap: <A, B>(f: (b: B) => A) => <E>(fa: Const<E, A>) => Const<E, B>\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~const\\_~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `C.Functor` instead of `C.const_`\n(where `C` is from `import C from 'fp-ts/Const'`)\n\n**Signature**\n\n```ts\nexport declare const const_: Functor2<'Const'> & Contravariant2<'Const'> & Bifunctor2<'Const'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Contravariant.ts.md",
    "content": "---\ntitle: Contravariant.ts\nnav_order: 22\nparent: Modules\n---\n\n## Contravariant overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Contravariant (interface)](#contravariant-interface)\n  - [Contravariant1 (interface)](#contravariant1-interface)\n  - [Contravariant2 (interface)](#contravariant2-interface)\n  - [Contravariant2C (interface)](#contravariant2c-interface)\n  - [Contravariant3 (interface)](#contravariant3-interface)\n  - [Contravariant3C (interface)](#contravariant3c-interface)\n  - [Contravariant4 (interface)](#contravariant4-interface)\n\n---\n\n# model\n\n## Contravariant (interface)\n\n**Signature**\n\n```ts\nexport interface Contravariant<F> {\n  readonly URI: F\n  readonly contramap: <A, B>(fa: HKT<F, A>, f: (b: B) => A) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Contravariant1 (interface)\n\n**Signature**\n\n```ts\nexport interface Contravariant1<F extends URIS> {\n  readonly URI: F\n  readonly contramap: <A, B>(fa: Kind<F, A>, f: (b: B) => A) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Contravariant2 (interface)\n\n**Signature**\n\n```ts\nexport interface Contravariant2<F extends URIS2> {\n  readonly URI: F\n  readonly contramap: <E, A, B>(fa: Kind2<F, E, A>, f: (b: B) => A) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Contravariant2C (interface)\n\n**Signature**\n\n```ts\nexport interface Contravariant2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly contramap: <A, B>(fa: Kind2<F, E, A>, f: (b: B) => A) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Contravariant3 (interface)\n\n**Signature**\n\n```ts\nexport interface Contravariant3<F extends URIS3> {\n  readonly URI: F\n  readonly contramap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (b: B) => A) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Contravariant3C (interface)\n\n**Signature**\n\n```ts\nexport interface Contravariant3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly contramap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (b: B) => A) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## Contravariant4 (interface)\n\n**Signature**\n\n```ts\nexport interface Contravariant4<F extends URIS4> {\n  readonly URI: F\n  readonly contramap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (b: B) => A) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Date.ts.md",
    "content": "---\ntitle: Date.ts\nnav_order: 23\nparent: Modules\n---\n\n## Date overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [create](#create)\n- [instances](#instances)\n  - [Eq](#eq)\n  - [Ord](#ord)\n  - [eqDate](#eqdate)\n  - [eqMonth](#eqmonth)\n  - [eqYear](#eqyear)\n- [utils](#utils)\n  - [now](#now)\n\n---\n\n# constructors\n\n## create\n\nReturns the current `Date`\n\n**Signature**\n\n```ts\nexport declare const create: IO<Date>\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Eq\n\n**Signature**\n\n```ts\nexport declare const Eq: E.Eq<Date>\n```\n\nAdded in v2.10.0\n\n## Ord\n\n**Signature**\n\n```ts\nexport declare const Ord: O.Ord<Date>\n```\n\n**Example**\n\n```ts\nimport { Ord } from 'fp-ts/Date'\n\nassert.deepStrictEqual(Ord.compare(new Date(1, 1, 2020), new Date(1, 1, 2021)), -1)\n```\n\nAdded in v2.10.0\n\n## eqDate\n\n**Signature**\n\n```ts\nexport declare const eqDate: E.Eq<Date>\n```\n\nAdded in v2.6.0\n\n## eqMonth\n\n**Signature**\n\n```ts\nexport declare const eqMonth: E.Eq<Date>\n```\n\nAdded in v2.6.0\n\n## eqYear\n\n**Signature**\n\n```ts\nexport declare const eqYear: E.Eq<Date>\n```\n\nAdded in v2.6.0\n\n# utils\n\n## now\n\nReturns the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC\n\n**Signature**\n\n```ts\nexport declare const now: IO<number>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/DistributiveLattice.ts.md",
    "content": "---\ntitle: DistributiveLattice.ts\nnav_order: 24\nparent: Modules\n---\n\n## DistributiveLattice overview\n\nA `DistributiveLattice` must satisfy the following laws in addition to `Lattice` laws:\n\n- Distributivity for meet: `a ∨ (b ∧ c) <-> (a ∨ b) ∧ (a ∨ c)`\n- Distributivity for join: `a ∧ (b ∨ c) <-> (a ∧ b) ∨ (a ∧ c)`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [getMinMaxDistributiveLattice](#getminmaxdistributivelattice)\n- [model](#model)\n  - [DistributiveLattice (interface)](#distributivelattice-interface)\n\n---\n\n# constructors\n\n## getMinMaxDistributiveLattice\n\n**Signature**\n\n```ts\nexport declare function getMinMaxDistributiveLattice<A>(O: Ord<A>): DistributiveLattice<A>\n```\n\nAdded in v2.0.0\n\n# model\n\n## DistributiveLattice (interface)\n\n**Signature**\n\n```ts\nexport interface DistributiveLattice<A> extends Lattice<A> {}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Either.ts.md",
    "content": "---\ntitle: Either.ts\nnav_order: 25\nparent: Modules\n---\n\n## Either overview\n\n```ts\ntype Either<E, A> = Left<E> | Right<A>\n```\n\nRepresents a value of one of two possible types (a disjoint union).\n\nAn instance of `Either` is either an instance of `Left` or `Right`.\n\nA common use of `Either` is as an alternative to `Option` for dealing with possible missing values. In this usage,\n`None` is replaced with a `Left` which can contain useful information. `Right` takes the place of `Some`. Convention\ndictates that `Left` is used for failure and `Right` is used for success.\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\n\nconst double = (n: number): number => n * 2\n\nexport const imperative = (as: ReadonlyArray<number>): string => {\n  const head = (as: ReadonlyArray<number>): number => {\n    if (as.length === 0) {\n      throw new Error('empty array')\n    }\n    return as[0]\n  }\n  const inverse = (n: number): number => {\n    if (n === 0) {\n      throw new Error('cannot divide by zero')\n    }\n    return 1 / n\n  }\n  try {\n    return `Result is ${inverse(double(head(as)))}`\n  } catch (err: any) {\n    return `Error is ${err.message}`\n  }\n}\n\nexport const functional = (as: ReadonlyArray<number>): string => {\n  const head = <A>(as: ReadonlyArray<A>): E.Either<string, A> =>\n    as.length === 0 ? E.left('empty array') : E.right(as[0])\n  const inverse = (n: number): E.Either<string, number> => (n === 0 ? E.left('cannot divide by zero') : E.right(1 / n))\n  return pipe(\n    as,\n    head,\n    E.map(double),\n    E.flatMap(inverse),\n    E.match(\n      (err) => `Error is ${err}`, // onLeft handler\n      (head) => `Result is ${head}` // onRight handler\n    )\n  )\n}\n\nassert.deepStrictEqual(imperative([1, 2, 3]), functional([1, 2, 3]))\nassert.deepStrictEqual(imperative([]), functional([]))\nassert.deepStrictEqual(imperative([0]), functional([0]))\n```\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n- [constructors](#constructors)\n  - [left](#left)\n  - [of](#of)\n  - [right](#right)\n- [conversions](#conversions)\n  - [fromNullable](#fromnullable)\n  - [fromOption](#fromoption)\n  - [toUnion](#tounion)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [apSW](#apsw)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [bindW](#bindw)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n  - [getAltValidation](#getaltvalidation)\n  - [getApplicativeValidation](#getapplicativevalidation)\n  - [getOrElse](#getorelse)\n  - [getOrElseW](#getorelsew)\n  - [mapLeft](#mapleft)\n  - [orElse](#orelse)\n  - [orElseW](#orelsew)\n- [filtering](#filtering)\n  - [filterOrElse](#filterorelse)\n  - [filterOrElseW](#filterorelsew)\n  - [getCompactable](#getcompactable)\n  - [getFilterable](#getfilterable)\n  - [getWitherable](#getwitherable)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Bifunctor](#bifunctor)\n  - [Chain](#chain)\n  - [ChainRec](#chainrec)\n  - [Extend](#extend)\n  - [Foldable](#foldable)\n  - [FromEither](#fromeither)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadThrow](#monadthrow)\n  - [Pointed](#pointed)\n  - [Traversable](#traversable)\n  - [getEq](#geteq)\n  - [getSemigroup](#getsemigroup)\n  - [getShow](#getshow)\n- [interop](#interop)\n  - [tryCatch](#trycatch)\n  - [tryCatchK](#trycatchk)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n  - [chainFirstW](#chainfirstw)\n  - [chainNullableK](#chainnullablek)\n  - [chainOptionK](#chainoptionk)\n  - [chainOptionKW](#chainoptionkw)\n  - [chainW](#chainw)\n  - [fromNullableK](#fromnullablek)\n  - [fromOptionK](#fromoptionk)\n- [lifting](#lifting)\n  - [fromPredicate](#frompredicate)\n  - [liftNullable](#liftnullable)\n  - [liftOption](#liftoption)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Either (type alias)](#either-type-alias)\n  - [Left (interface)](#left-interface)\n  - [Right (interface)](#right-interface)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchW](#matchw)\n- [refinements](#refinements)\n  - [isLeft](#isleft)\n  - [isRight](#isright)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatMapOption](#flatmapoption)\n  - [flatten](#flatten)\n  - [flattenW](#flattenw)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [sequenceArray](#sequencearray)\n  - [traverse](#traverse)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apFirstW](#apfirstw)\n  - [apSecond](#apsecond)\n  - [apSecondW](#apsecondw)\n  - [apW](#apw)\n  - [duplicate](#duplicate)\n  - [elem](#elem)\n  - [exists](#exists)\n  - [extend](#extend)\n  - [swap](#swap)\n  - [throwError](#throwerror)\n  - [toError](#toerror)\n- [zone of death](#zone-of-death)\n  - [~~JsonArray~~ (interface)](#jsonarray-interface)\n  - [~~JsonRecord~~ (interface)](#jsonrecord-interface)\n  - [~~Json~~ (type alias)](#json-type-alias)\n  - [~~either~~](#either)\n  - [~~getApplyMonoid~~](#getapplymonoid)\n  - [~~getApplySemigroup~~](#getapplysemigroup)\n  - [~~getValidationMonoid~~](#getvalidationmonoid)\n  - [~~getValidationSemigroup~~](#getvalidationsemigroup)\n  - [~~getValidation~~](#getvalidation)\n  - [~~parseJSON~~](#parsejson)\n  - [~~stringifyJSON~~](#stringifyjson)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\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 v2.15.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 = never, A = never>(e: E) => Either<E, A>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <E = never, A = never>(a: A) => Either<E, A>\n```\n\nAdded in v2.7.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: <E = never, A = never>(a: A) => Either<E, A>\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromNullable\n\nTakes a 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: <E>(e: E) => <A>(a: A) => Either<E, NonNullable<A>>\n```\n\n**Example**\n\n```ts\nimport { fromNullable, left, right } from 'fp-ts/Either'\n\nconst parse = fromNullable('nully')\n\nassert.deepStrictEqual(parse(1), right(1))\nassert.deepStrictEqual(parse(null), left('nully'))\n```\n\nAdded in v2.0.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => Either<E, A>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as O from 'fp-ts/Option'\n\nassert.deepStrictEqual(\n  pipe(\n    O.some(1),\n    E.fromOption(() => 'error')\n  ),\n  E.right(1)\n)\nassert.deepStrictEqual(\n  pipe(\n    O.none,\n    E.fromOption(() => 'error')\n  ),\n  E.left('error')\n)\n```\n\nAdded in v2.0.0\n\n## toUnion\n\n**Signature**\n\n```ts\nexport declare const toUnion: <E, A>(fa: Either<E, A>) => E | A\n```\n\nAdded in v2.10.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: Either<never, {}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: Either<E, B>\n) => (fa: Either<E, A>) => Either<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## apSW\n\nLess strict version of [`apS`](#aps).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSW: <A, N extends string, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: Either<E2, B>\n) => <E1>(fa: Either<E1, A>) => Either<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Either<E, B>\n) => (ma: Either<E, A>) => Either<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <E, A>(fa: Either<E, A>) => Either<E, { readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## bindW\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bindW: <N extends string, A, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Either<E2, B>\n) => <E1>(fa: Either<E1, A>) => Either<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <E>(fa: Either<E, A>) => Either<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\nIn case of `Either` returns the left-most non-`Left` value (or the right-most `Left` value if both values are `Left`).\n\n| x        | y        | pipe(x, alt(() => y) |\n| -------- | -------- | -------------------- |\n| left(a)  | left(b)  | left(b)              |\n| left(a)  | right(2) | right(2)             |\n| right(1) | left(b)  | right(1)             |\n| right(1) | right(2) | right(1)             |\n\n**Signature**\n\n```ts\nexport declare const alt: <E, A>(that: LazyArg<Either<E, A>>) => (fa: Either<E, A>) => Either<E, A>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    E.left('a'),\n    E.alt(() => E.left('b'))\n  ),\n  E.left('b')\n)\nassert.deepStrictEqual(\n  pipe(\n    E.left('a'),\n    E.alt(() => E.right(2))\n  ),\n  E.right(2)\n)\nassert.deepStrictEqual(\n  pipe(\n    E.right(1),\n    E.alt(() => E.left('b'))\n  ),\n  E.right(1)\n)\nassert.deepStrictEqual(\n  pipe(\n    E.right(1),\n    E.alt(() => E.right(2))\n  ),\n  E.right(1)\n)\n```\n\nAdded in v2.0.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the error and the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <E2, B>(that: LazyArg<Either<E2, B>>) => <E1, A>(fa: Either<E1, A>) => Either<E2, B | A>\n```\n\nAdded in v2.9.0\n\n## getAltValidation\n\nThe default [`Alt`](#alt) instance returns the last error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const getAltValidation: <E>(SE: Semigroup<E>) => Alt2C<'Either', E>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as S from 'fp-ts/Semigroup'\nimport * as string from 'fp-ts/string'\n\nconst parseString = (u: unknown): E.Either<string, string> =>\n  typeof u === 'string' ? E.right(u) : E.left('not a string')\n\nconst parseNumber = (u: unknown): E.Either<string, number> =>\n  typeof u === 'number' ? E.right(u) : E.left('not a number')\n\nconst parse = (u: unknown): E.Either<string, string | number> =>\n  pipe(\n    parseString(u),\n    E.alt<string, string | number>(() => parseNumber(u))\n  )\n\nassert.deepStrictEqual(parse(true), E.left('not a number')) // <= last error\n\nconst Alt = E.getAltValidation(pipe(string.Semigroup, S.intercalate(', ')))\n\nconst parseAll = (u: unknown): E.Either<string, string | number> =>\n  Alt.alt<string | number>(parseString(u), () => parseNumber(u))\n\nassert.deepStrictEqual(parseAll(true), E.left('not a string, not a number')) // <= all errors\n```\n\nAdded in v2.7.0\n\n## getApplicativeValidation\n\nThe default [`Applicative`](#applicative) instance returns the first error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const getApplicativeValidation: <E>(SE: Semigroup<E>) => Applicative2C<'Either', E>\n```\n\n**Example**\n\n```ts\nimport * as A from 'fp-ts/Apply'\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as S from 'fp-ts/Semigroup'\nimport * as string from 'fp-ts/string'\n\nconst parseString = (u: unknown): E.Either<string, string> =>\n  typeof u === 'string' ? E.right(u) : E.left('not a string')\n\nconst parseNumber = (u: unknown): E.Either<string, number> =>\n  typeof u === 'number' ? E.right(u) : E.left('not a number')\n\ninterface Person {\n  readonly name: string\n  readonly age: number\n}\n\nconst parsePerson = (input: Record<string, unknown>): E.Either<string, Person> =>\n  pipe(E.Do, E.apS('name', parseString(input.name)), E.apS('age', parseNumber(input.age)))\n\nassert.deepStrictEqual(parsePerson({}), E.left('not a string')) // <= first error\n\nconst Applicative = E.getApplicativeValidation(pipe(string.Semigroup, S.intercalate(', ')))\n\nconst apS = A.apS(Applicative)\n\nconst parsePersonAll = (input: Record<string, unknown>): E.Either<string, Person> =>\n  pipe(E.Do, apS('name', parseString(input.name)), apS('age', parseNumber(input.age)))\n\nassert.deepStrictEqual(parsePersonAll({}), E.left('not a string, not a number')) // <= all errors\n```\n\nAdded in v2.7.0\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: <E, A>(onLeft: (e: E) => A) => (ma: Either<E, A>) => A\n```\n\n**Example**\n\n```ts\nimport { getOrElse, left, right } from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    right(1),\n    getOrElse(() => 0)\n  ),\n  1\n)\nassert.deepStrictEqual(\n  pipe(\n    left('error'),\n    getOrElse(() => 0)\n  ),\n  0\n)\n```\n\nAdded in v2.0.0\n\n## getOrElseW\n\nLess strict version of [`getOrElse`](#getorelse).\n\nThe `W` suffix (short for **W**idening) means that the handler return type will be merged.\n\n**Signature**\n\n```ts\nexport declare const getOrElseW: <E, B>(onLeft: (e: E) => B) => <A>(ma: Either<E, A>) => B | A\n```\n\nAdded in v2.6.0\n\n## mapLeft\n\nMap a function over the first type argument of a bifunctor.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Either<E, A>) => Either<G, A>\n```\n\nAdded in v2.0.0\n\n## orElse\n\nUseful for recovering from errors.\n\n**Signature**\n\n```ts\nexport declare const orElse: <E1, A, E2>(onLeft: (e: E1) => Either<E2, A>) => (ma: Either<E1, A>) => Either<E2, A>\n```\n\nAdded in v2.0.0\n\n## orElseW\n\nLess strict version of [`orElse`](#orelse).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const orElseW: <E1, E2, B>(\n  onLeft: (e: E1) => Either<E2, B>\n) => <A>(ma: Either<E1, A>) => Either<E2, B | A>\n```\n\nAdded in v2.10.0\n\n# filtering\n\n## filterOrElse\n\n**Signature**\n\n```ts\nexport declare const filterOrElse: {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (self: Either<E, A>) => Either<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(self: Either<E, B>) => Either<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (self: Either<E, A>) => Either<E, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    E.right(1),\n    E.filterOrElse(\n      (n) => n > 0,\n      () => 'error'\n    )\n  ),\n  E.right(1)\n)\nassert.deepStrictEqual(\n  pipe(\n    E.right(-1),\n    E.filterOrElse(\n      (n) => n > 0,\n      () => 'error'\n    )\n  ),\n  E.left('error')\n)\nassert.deepStrictEqual(\n  pipe(\n    E.left('a'),\n    E.filterOrElse(\n      (n) => n > 0,\n      () => 'error'\n    )\n  ),\n  E.left('a')\n)\n```\n\nAdded in v2.0.0\n\n## filterOrElseW\n\nLess strict version of [`filterOrElse`](#filterorelse).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(\n    ma: Either<E1, A>\n  ) => Either<E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>(mb: Either<E1, B>) => Either<E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: Either<E1, A>) => Either<E2 | E1, A>\n}\n```\n\nAdded in v2.9.0\n\n## getCompactable\n\nBuilds a `Compactable` instance for `Either` given `Monoid` for the left side.\n\n**Signature**\n\n```ts\nexport declare const getCompactable: <E>(M: Monoid<E>) => Compactable2C<'Either', E>\n```\n\nAdded in v2.10.0\n\n## getFilterable\n\nBuilds a `Filterable` instance for `Either` given `Monoid` for the left side\n\n**Signature**\n\n```ts\nexport declare const getFilterable: <E>(M: Monoid<E>) => Filterable2C<'Either', E>\n```\n\nAdded in v2.10.0\n\n## getWitherable\n\nBuilds `Witherable` instance for `Either` given `Monoid` for the left side\n\n**Signature**\n\n```ts\nexport declare const getWitherable: <E>(M: Monoid<E>) => Witherable2C<'Either', E>\n```\n\nAdded in v2.0.0\n\n# folding\n\n## foldMap\n\nMap each element of the structure to a monoid, and combine the results.\n\n**Signature**\n\n```ts\nexport declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: Either<E, A>) => M\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as E from 'fp-ts/Either'\nimport * as S from 'fp-ts/string'\n\nconst yell = (a: string) => `${a}!`\n\nassert.deepStrictEqual(pipe(E.right('a'), E.foldMap(S.Monoid)(yell)), 'a!')\n\nassert.deepStrictEqual(pipe(E.left('e'), E.foldMap(S.Monoid)(yell)), S.Monoid.empty)\n```\n\nAdded in v2.0.0\n\n## reduce\n\nLeft-associative fold of a structure.\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: Either<E, A>) => B\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as E from 'fp-ts/Either'\n\nconst startWith = 'prefix'\nconst concat = (a: string, b: string) => `${a}:${b}`\n\nassert.deepStrictEqual(pipe(E.right('a'), E.reduce(startWith, concat)), 'prefix:a')\n\nassert.deepStrictEqual(pipe(E.left('e'), E.reduce(startWith, concat)), 'prefix')\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\nRight-associative fold of a structure.\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: Either<E, A>) => B\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as E from 'fp-ts/Either'\n\nconst startWith = 'postfix'\nconst concat = (a: string, b: string) => `${a}:${b}`\n\nassert.deepStrictEqual(pipe(E.right('a'), E.reduceRight(startWith, concat)), 'a:postfix')\n\nassert.deepStrictEqual(pipe(E.left('e'), E.reduceRight(startWith, concat)), 'postfix')\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt2<'Either'>\n```\n\nAdded in v2.7.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative2<'Either'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply2<'Either'>\n```\n\nAdded in v2.10.0\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor2<'Either'>\n```\n\nAdded in v2.7.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain2<'Either'>\n```\n\nAdded in v2.10.0\n\n## ChainRec\n\n**Signature**\n\n```ts\nexport declare const ChainRec: ChainRec2<'Either'>\n```\n\nAdded in v2.7.0\n\n## Extend\n\n**Signature**\n\n```ts\nexport declare const Extend: Extend2<'Either'>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable2<'Either'>\n```\n\nAdded in v2.7.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither2<'Either'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'Either'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad2<'Either'>\n```\n\nAdded in v2.7.0\n\n## MonadThrow\n\n**Signature**\n\n```ts\nexport declare const MonadThrow: MonadThrow2<'Either'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed2<'Either'>\n```\n\nAdded in v2.10.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable2<'Either'>\n```\n\nAdded in v2.7.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare const getEq: <E, A>(EL: Eq<E>, EA: Eq<A>) => Eq<Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## getSemigroup\n\nSemigroup returning the left-most non-`Left` value. If both operands are `Right`s then the inner values are\nconcatenated using the provided `Semigroup`\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <E, A>(S: Semigroup<A>) => Semigroup<Either<E, A>>\n```\n\n**Example**\n\n```ts\nimport { getSemigroup, left, right } from 'fp-ts/Either'\nimport { SemigroupSum } from 'fp-ts/number'\n\nconst S = getSemigroup<string, number>(SemigroupSum)\nassert.deepStrictEqual(S.concat(left('a'), left('b')), left('a'))\nassert.deepStrictEqual(S.concat(left('a'), right(2)), right(2))\nassert.deepStrictEqual(S.concat(right(1), left('b')), right(1))\nassert.deepStrictEqual(S.concat(right(1), right(2)), right(3))\n```\n\nAdded in v2.0.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare const getShow: <E, A>(SE: Show<E>, SA: Show<A>) => Show<Either<E, A>>\n```\n\nAdded in v2.0.0\n\n# interop\n\n## tryCatch\n\nConstructs a new `Either` from a function that might throw.\n\nSee also [`tryCatchK`](#trycatchk).\n\n**Signature**\n\n```ts\nexport declare const tryCatch: <E, A>(f: LazyArg<A>, onThrow: (e: unknown) => E) => Either<E, A>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\n\nconst unsafeHead = <A>(as: ReadonlyArray<A>): A => {\n  if (as.length > 0) {\n    return as[0]\n  } else {\n    throw new Error('empty array')\n  }\n}\n\nconst head = <A>(as: ReadonlyArray<A>): E.Either<Error, A> =>\n  E.tryCatch(\n    () => unsafeHead(as),\n    (e) => (e instanceof Error ? e : new Error('unknown error'))\n  )\n\nassert.deepStrictEqual(head([]), E.left(new Error('empty array')))\nassert.deepStrictEqual(head([1, 2, 3]), E.right(1))\n```\n\nAdded in v2.0.0\n\n## tryCatchK\n\nConverts a function that may throw to one returning a `Either`.\n\n**Signature**\n\n```ts\nexport declare const tryCatchK: <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 v2.10.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Either<E, A>) => Either<E, B>\n```\n\nAdded in v2.0.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Either<E, A>) => Either<E, A>\n```\n\nAdded in v2.0.0\n\n## chainFirstW\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstW: <E2, A, B>(\n  f: (a: A) => Either<E2, B>\n) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, A>\n```\n\nAdded in v2.8.0\n\n## chainNullableK\n\nUse `flatMapNullable`.\n\n**Signature**\n\n```ts\nexport declare const chainNullableK: <E>(\n  e: E\n) => <A, B>(f: (a: A) => B | null | undefined) => (ma: Either<E, A>) => Either<E, NonNullable<B>>\n```\n\nAdded in v2.9.0\n\n## chainOptionK\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => (ma: Either<E, A>) => Either<E, B>\n```\n\nAdded in v2.11.0\n\n## chainOptionKW\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, B>\n```\n\nAdded in v2.13.2\n\n## chainW\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chainW: <E2, A, B>(f: (a: A) => Either<E2, B>) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, B>\n```\n\nAdded in v2.6.0\n\n## fromNullableK\n\nUse `liftNullable`.\n\n**Signature**\n\n```ts\nexport declare const fromNullableK: <E>(\n  e: E\n) => <A extends readonly unknown[], B>(f: (...a: A) => B | null | undefined) => (...a: A) => Either<E, NonNullable<B>>\n```\n\nAdded in v2.9.0\n\n## fromOptionK\n\nUse `liftOption`.\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => Either<E, B>\n```\n\nAdded in v2.10.0\n\n# lifting\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Either<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => Either<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Either<E, A>\n}\n```\n\n**Example**\n\n```ts\nimport { fromPredicate, left, right } from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    1,\n    fromPredicate(\n      (n) => n > 0,\n      () => 'error'\n    )\n  ),\n  right(1)\n)\nassert.deepStrictEqual(\n  pipe(\n    -1,\n    fromPredicate(\n      (n) => n > 0,\n      () => 'error'\n    )\n  ),\n  left('error')\n)\n```\n\nAdded in v2.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 v2.15.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 v2.15.0\n\n# mapping\n\n## as\n\nMaps the `Right` value of this `Either` to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <E, _>(self: Either<E, _>) => Either<E, A>\n  <E, _, A>(self: Either<E, _>, a: A): Either<E, A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the `Right` value of this `Either` to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <E, _>(self: Either<E, _>) => Either<E, void>\n```\n\nAdded in v2.16.0\n\n## bimap\n\nMap a pair of functions over the two type arguments of the bifunctor.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Either<E, A>) => Either<G, B>\n```\n\nAdded in v2.0.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: Either<E, (a: A) => B>) => Either<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Either<E, A>) => Either<E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## Either (type alias)\n\n**Signature**\n\n```ts\nexport type Either<E, A> = Left<E> | Right<A>\n```\n\nAdded in v2.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 v2.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 v2.0.0\n\n# pattern matching\n\n## fold\n\nAlias of [`match`](#match).\n\n**Signature**\n\n```ts\nexport declare const fold: <E, A, B>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Either<E, A>) => B\n```\n\nAdded in v2.0.0\n\n## foldW\n\nAlias of [`matchW`](#matchw).\n\n**Signature**\n\n```ts\nexport declare const foldW: <E, B, A, C>(onLeft: (e: E) => B, onRight: (a: A) => C) => (ma: Either<E, A>) => B | C\n```\n\nAdded in v2.10.0\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: <E, A, B>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Either<E, A>) => B\n```\n\n**Example**\n\n```ts\nimport { match, left, right } from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\n\nfunction onLeft(errors: Array<string>): string {\n  return `Errors: ${errors.join(', ')}`\n}\n\nfunction onRight(value: number): string {\n  return `Ok: ${value}`\n}\n\nassert.strictEqual(pipe(right(1), match(onLeft, onRight)), 'Ok: 1')\nassert.strictEqual(pipe(left(['error 1', 'error 2']), match(onLeft, onRight)), 'Errors: error 1, error 2')\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <E, B, A, C>(onLeft: (e: E) => B, onRight: (a: A) => C) => (ma: Either<E, A>) => B | C\n```\n\nAdded in v2.10.0\n\n# refinements\n\n## isLeft\n\nReturns `true` if the either is an instance of `Left`, `false` otherwise.\n\n**Signature**\n\n```ts\nexport declare const isLeft: <E>(ma: Either<E, unknown>) => ma is Left<E>\n```\n\nAdded in v2.0.0\n\n## isRight\n\nReturns `true` if the either is an instance of `Right`, `false` otherwise.\n\n**Signature**\n\n```ts\nexport declare const isRight: <A>(ma: Either<unknown, A>) => ma is Right<A>\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, E2, B>(f: (a: A) => Either<E2, B>): <E1>(ma: Either<E1, A>) => Either<E2 | E1, B>\n  <E1, A, E2, B>(ma: Either<E1, A>, f: (a: A) => Either<E2, B>): Either<E1 | E2, B>\n}\n```\n\nAdded in v2.14.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 v2.15.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 v2.15.0\n\n## flatten\n\nThe `flatten` function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level.\n\n**Signature**\n\n```ts\nexport declare const flatten: <E, A>(mma: Either<E, Either<E, A>>) => Either<E, A>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\n\nassert.deepStrictEqual(E.flatten(E.right(E.right('a'))), E.right('a'))\nassert.deepStrictEqual(E.flatten(E.right(E.left('e'))), E.left('e'))\nassert.deepStrictEqual(E.flatten(E.left('e')), E.left('e'))\n```\n\nAdded in v2.0.0\n\n## flattenW\n\nLess strict version of [`flatten`](#flatten).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const flattenW: <E1, E2, A>(mma: Either<E1, Either<E2, A>>) => Either<E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# traversing\n\n## sequence\n\nEvaluate each monadic action in the structure from left to right, and collect the results.\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence2<'Either'>\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as E from 'fp-ts/Either'\nimport * as O from 'fp-ts/Option'\n\nassert.deepStrictEqual(pipe(E.right(O.some('a')), E.sequence(O.Applicative)), O.some(E.right('a')))\n\nassert.deepStrictEqual(pipe(E.right(O.none), E.sequence(O.Applicative)), O.none)\n```\n\nAdded in v2.6.3\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <E, A>(as: readonly Either<E, A>[]) => Either<E, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverse\n\nMap each element of a structure to an action, evaluate these actions from left to right, and collect the results.\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse2<'Either'>\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport * as E from 'fp-ts/Either'\nimport * as O from 'fp-ts/Option'\n\nassert.deepStrictEqual(pipe(E.right(['a']), E.traverse(O.Applicative)(RA.head)), O.some(E.right('a')))\n\nassert.deepStrictEqual(pipe(E.right([]), E.traverse(O.Applicative)(RA.head)), O.none)\n```\n\nAdded in v2.6.3\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <E, A, B>(\n  f: (a: A) => Either<E, B>\n) => (as: readonly A[]) => Either<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <E, A, B>(\n  f: (index: number, a: A) => Either<E, B>\n) => (as: readonly A[]) => Either<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => Either<E, B>\n) => (as: readonly A[]) => Either<E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => Either<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => Either<E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Either'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: Either<never, readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <E, A>(fa: Either<E, A>) => <B>(fab: Either<E, (a: A) => B>) => Either<E, B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <E, B>(second: Either<E, B>) => <A>(first: Either<E, A>) => Either<E, A>\n```\n\nAdded in v2.0.0\n\n## apFirstW\n\nLess strict version of [`apFirst`](#apfirst)\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apFirstW: <E2, B>(second: Either<E2, B>) => <E1, A>(first: Either<E1, A>) => Either<E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <E, B>(second: Either<E, B>) => <A>(first: Either<E, A>) => Either<E, B>\n```\n\nAdded in v2.0.0\n\n## apSecondW\n\nLess strict version of [`apSecond`](#apsecond)\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSecondW: <E2, B>(second: Either<E2, B>) => <E1, A>(first: Either<E1, A>) => Either<E2 | E1, B>\n```\n\nAdded in v2.12.0\n\n## apW\n\nLess strict version of [`ap`](#ap).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apW: <E2, A>(fa: Either<E2, A>) => <E1, B>(fab: Either<E1, (a: A) => B>) => Either<E2 | E1, B>\n```\n\nAdded in v2.8.0\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <E, A>(ma: Either<E, A>) => Either<E, Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## elem\n\n**Signature**\n\n```ts\nexport declare function elem<A>(E: Eq<A>): {\n  (a: A): <E>(ma: Either<E, A>) => boolean\n  <E>(a: A, ma: Either<E, A>): boolean\n}\n```\n\nAdded in v2.0.0\n\n## exists\n\nReturns `false` if `Left` or returns the result of the application of the given predicate to the `Right` value.\n\n**Signature**\n\n```ts\nexport declare const exists: <A>(predicate: Predicate<A>) => (ma: Either<unknown, A>) => boolean\n```\n\n**Example**\n\n```ts\nimport { exists, left, right } from 'fp-ts/Either'\n\nconst gt2 = exists((n: number) => n > 2)\n\nassert.strictEqual(gt2(left('a')), false)\nassert.strictEqual(gt2(right(1)), false)\nassert.strictEqual(gt2(right(3)), true)\n```\n\nAdded in v2.0.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <E, A, B>(f: (wa: Either<E, A>) => B) => (wa: Either<E, A>) => Either<E, B>\n```\n\nAdded in v2.0.0\n\n## swap\n\nReturns a `Right` if is a `Left` (and vice versa).\n\n**Signature**\n\n```ts\nexport declare const swap: <E, A>(ma: Either<E, A>) => Either<A, E>\n```\n\nAdded in v2.0.0\n\n## throwError\n\n**Signature**\n\n```ts\nexport declare const throwError: <E, A>(e: E) => Either<E, A>\n```\n\nAdded in v2.6.3\n\n## toError\n\nDefault value for the `onError` argument of `tryCatch`\n\n**Signature**\n\n```ts\nexport declare function toError(e: unknown): Error\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~JsonArray~~ (interface)\n\nUse [`Json`](./Json.ts.html) module instead.\n\n**Signature**\n\n```ts\nexport interface JsonArray extends ReadonlyArray<Json> {}\n```\n\nAdded in v2.6.7\n\n## ~~JsonRecord~~ (interface)\n\nUse [`Json`](./Json.ts.html) module instead.\n\n**Signature**\n\n```ts\nexport interface JsonRecord {\n  readonly [key: string]: Json\n}\n```\n\nAdded in v2.6.7\n\n## ~~Json~~ (type alias)\n\nUse [`Json`](./Json.ts.html) module instead.\n\n**Signature**\n\n```ts\nexport type Json = boolean | number | string | null | JsonArray | JsonRecord\n```\n\nAdded in v2.6.7\n\n## ~~either~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `E.Functor` instead of `E.either`\n(where `E` is from `import E from 'fp-ts/Either'`)\n\n**Signature**\n\n```ts\nexport declare const either: Monad2<'Either'> &\n  Foldable2<'Either'> &\n  Traversable2<'Either'> &\n  Bifunctor2<'Either'> &\n  Alt2<'Either'> &\n  Extend2<'Either'> &\n  ChainRec2<'Either'> &\n  MonadThrow2<'Either'>\n```\n\nAdded in v2.0.0\n\n## ~~getApplyMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getApplySemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\nSemigroup returning the left-most `Left` value. If both operands are `Right`s then the inner values\nare concatenated using the provided `Semigroup`\n\n**Signature**\n\n```ts\nexport declare const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getValidationMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getValidationMonoid: <E, A>(SE: Semigroup<E>, MA: Monoid<A>) => Monoid<Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getValidationSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getValidationSemigroup: <E, A>(SE: Semigroup<E>, SA: Semigroup<A>) => Semigroup<Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getValidation~~\n\nUse [`getApplicativeValidation`](#getapplicativevalidation) and [`getAltValidation`](#getaltvalidation) instead.\n\n**Signature**\n\n```ts\nexport declare function getValidation<E>(\n  SE: Semigroup<E>\n): Monad2C<URI, E> &\n  Foldable2<URI> &\n  Traversable2<URI> &\n  Bifunctor2<URI> &\n  Alt2C<URI, E> &\n  Extend2<URI> &\n  ChainRec2C<URI, E> &\n  MonadThrow2C<URI, E>\n```\n\nAdded in v2.0.0\n\n## ~~parseJSON~~\n\nUse [`parse`](./Json.ts.html#parse) instead.\n\n**Signature**\n\n```ts\nexport declare function parseJSON<E>(s: string, onError: (reason: unknown) => E): Either<E, Json>\n```\n\nAdded in v2.0.0\n\n## ~~stringifyJSON~~\n\nUse [`stringify`](./Json.ts.html#stringify) instead.\n\n**Signature**\n\n```ts\nexport declare const stringifyJSON: <E>(u: unknown, onError: (reason: unknown) => E) => Either<E, string>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/EitherT.ts.md",
    "content": "---\ntitle: EitherT.ts\nnav_order: 26\nparent: Modules\n---\n\n## EitherT overview\n\nThe error monad transformer. It can be used to add error handling to other monads.\n\nThe `of` function yields a successful computation, while `chain` sequences two subcomputations, failing on the first error.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [error handling](#error-handling)\n  - [altValidation](#altvalidation)\n  - [orElseFirst](#orelsefirst)\n  - [orLeft](#orleft)\n- [pattern matching](#pattern-matching)\n  - [match](#match)\n- [utils](#utils)\n  - [alt](#alt)\n  - [ap](#ap)\n  - [bimap](#bimap)\n  - [chain](#chain)\n  - [chainNullableK](#chainnullablek)\n  - [fromNullable](#fromnullable)\n  - [fromNullableK](#fromnullablek)\n  - [getOrElse](#getorelse)\n  - [left](#left)\n  - [leftF](#leftf)\n  - [map](#map)\n  - [mapLeft](#mapleft)\n  - [matchE](#matche)\n  - [orElse](#orelse)\n  - [right](#right)\n  - [rightF](#rightf)\n  - [swap](#swap)\n  - [toUnion](#tounion)\n- [zone of death](#zone-of-death)\n  - [~~EitherM1~~ (interface)](#eitherm1-interface)\n  - [~~EitherM2~~ (interface)](#eitherm2-interface)\n  - [~~EitherM~~ (interface)](#eitherm-interface)\n  - [~~EitherT1~~ (type alias)](#eithert1-type-alias)\n  - [~~EitherT2~~ (type alias)](#eithert2-type-alias)\n  - [~~EitherT~~ (interface)](#eithert-interface)\n  - [~~getEitherM~~](#geteitherm)\n\n---\n\n# error handling\n\n## altValidation\n\n**Signature**\n\n```ts\nexport declare function altValidation<M extends URIS3, E>(\n  M: Monad3<M>,\n  S: Semigroup<E>\n): <R, ME, A>(\n  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>\n) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport declare function altValidation<M extends URIS3, ME, E>(\n  M: Monad3C<M, ME>,\n  S: Semigroup<E>\n): <R, A>(\n  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>\n) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport declare function altValidation<M extends URIS2, E>(\n  M: Monad2<M>,\n  S: Semigroup<E>\n): <ME, A>(\n  second: LazyArg<Kind2<M, ME, Either<E, A>>>\n) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport declare function altValidation<M extends URIS2, ME, E>(\n  M: Monad2C<M, ME>,\n  S: Semigroup<E>\n): <A>(second: LazyArg<Kind2<M, ME, Either<E, A>>>) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport declare function altValidation<M extends URIS, E>(\n  M: Monad1<M>,\n  S: Semigroup<E>\n): <A>(second: LazyArg<Kind<M, Either<E, A>>>) => (first: Kind<M, Either<E, A>>) => Kind<M, Either<E, A>>\nexport declare function altValidation<M, E>(\n  M: Monad<M>,\n  S: Semigroup<E>\n): <A>(second: LazyArg<HKT<M, Either<E, A>>>) => (first: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>>\n```\n\nAdded in v2.10.0\n\n## orElseFirst\n\n**Signature**\n\n```ts\nexport declare function orElseFirst<M extends URIS3>(\n  M: Monad3<M>\n): <E, R, ME, B>(\n  onLeft: (e: E) => Kind3<M, R, ME, Either<E, B>>\n) => <A>(ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport declare function orElseFirst<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <E, R, B>(\n  onLeft: (e: E) => Kind3<M, R, ME, Either<E, B>>\n) => <A>(ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport declare function orElseFirst<M extends URIS2>(\n  M: Monad2<M>\n): <E, ME, B>(\n  onLeft: (e: E) => Kind2<M, ME, Either<E, B>>\n) => <A>(ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport declare function orElseFirst<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E, B>(\n  onLeft: (e: E) => Kind2<M, ME, Either<E, B>>\n) => <A>(ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport declare function orElseFirst<M extends URIS>(\n  M: Monad1<M>\n): <E, B>(onLeft: (e: E) => Kind<M, Either<E, B>>) => <A>(ma: Kind<M, Either<E, A>>) => Kind<M, Either<E, A>>\nexport declare function orElseFirst<M>(\n  M: Monad<M>\n): <E, B>(onLeft: (e: E) => HKT<M, Either<E, B>>) => <A>(ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>>\n```\n\nAdded in v2.11.0\n\n## orLeft\n\n**Signature**\n\n```ts\nexport declare function orLeft<M extends URIS3>(\n  M: Monad3<M>\n): <E1, R, ME, E2>(\n  onLeft: (e: E1) => Kind3<M, R, ME, E2>\n) => <A>(fa: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>\nexport declare function orLeft<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <E1, R, E2>(\n  onLeft: (e: E1) => Kind3<M, R, ME, E2>\n) => <A>(fa: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>\nexport declare function orLeft<M extends URIS2>(\n  M: Monad2<M>\n): <E1, ME, E2>(\n  onLeft: (e: E1) => Kind2<M, ME, E2>\n) => <A>(fa: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>\nexport declare function orLeft<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E1, E2>(onLeft: (e: E1) => Kind2<M, ME, E2>) => <A>(fa: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>\nexport declare function orLeft<M extends URIS>(\n  M: Monad1<M>\n): <E1, E2>(onLeft: (e: E1) => Kind<M, E2>) => <A>(fa: Kind<M, Either<E1, A>>) => Kind<M, Either<E2, A>>\nexport declare function orLeft<M>(\n  M: Monad<M>\n): <E1, E2>(onLeft: (e: E1) => HKT<M, E2>) => <A>(fa: HKT<M, Either<E1, A>>) => HKT<M, Either<E2, A>>\n```\n\nAdded in v2.11.0\n\n# pattern matching\n\n## match\n\n**Signature**\n\n```ts\nexport declare function match<F extends URIS3>(\n  F: Functor3<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B\n) => <R, ME>(ma: Kind3<F, R, ME, Either<E, A>>) => Kind3<F, R, ME, B>\nexport declare function match<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => <R>(ma: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, B>\nexport declare function match<F extends URIS2>(\n  F: Functor2<F>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => <FE>(ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, B>\nexport declare function match<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, B>\nexport declare function match<F extends URIS>(\n  F: Functor1<F>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Kind<F, Either<E, A>>) => Kind<F, B>\nexport declare function match<F>(\n  F: Functor<F>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: HKT<F, Either<E, A>>) => HKT<F, B>\n```\n\nAdded in v2.11.0\n\n# utils\n\n## alt\n\n**Signature**\n\n```ts\nexport declare function alt<M extends URIS3>(\n  M: Monad3<M>\n): <R, ME, E, A>(\n  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>\n) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport declare function alt<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <R, E, A>(\n  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>\n) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport declare function alt<M extends URIS2>(\n  M: Monad2<M>\n): <ME, E, A>(\n  second: LazyArg<Kind2<M, ME, Either<E, A>>>\n) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport declare function alt<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E, A>(\n  second: LazyArg<Kind2<M, ME, Either<E, A>>>\n) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport declare function alt<M extends URIS>(\n  M: Monad1<M>\n): <E, A>(second: LazyArg<Kind<M, Either<E, A>>>) => (first: Kind<M, Either<E, A>>) => Kind<M, Either<E, A>>\nexport declare function alt<M>(\n  M: Monad<M>\n): <E, A>(second: LazyArg<HKT<M, Either<E, A>>>) => (first: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>>\n```\n\nAdded in v2.10.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare function ap<F extends URIS3>(\n  F: Apply3<F>\n): <R, FE, E, A>(\n  fa: Kind3<F, R, FE, Either<E, A>>\n) => <B>(fab: Kind3<F, R, FE, Either<E, (a: A) => B>>) => Kind3<F, R, FE, Either<E, B>>\nexport declare function ap<F extends URIS3, FE>(\n  F: Apply3C<F, FE>\n): <R, E, A>(\n  fa: Kind3<F, R, FE, Either<E, A>>\n) => <B>(fab: Kind3<F, R, FE, Either<E, (a: A) => B>>) => Kind3<F, R, FE, Either<E, B>>\nexport declare function ap<F extends URIS2>(\n  F: Apply2<F>\n): <FE, E, A>(\n  fa: Kind2<F, FE, Either<E, A>>\n) => <B>(fab: Kind2<F, FE, Either<E, (a: A) => B>>) => Kind2<F, FE, Either<E, B>>\nexport declare function ap<F extends URIS2, FE>(\n  F: Apply2C<F, FE>\n): <E, A>(\n  fa: Kind2<F, FE, Either<E, A>>\n) => <B>(fab: Kind2<F, FE, Either<E, (a: A) => B>>) => Kind2<F, FE, Either<E, B>>\nexport declare function ap<F extends URIS>(\n  F: Apply1<F>\n): <E, A>(fa: Kind<F, Either<E, A>>) => <B>(fab: Kind<F, Either<E, (a: A) => B>>) => Kind<F, Either<E, B>>\nexport declare function ap<F>(\n  F: Apply<F>\n): <E, A>(fa: HKT<F, Either<E, A>>) => <B>(fab: HKT<F, Either<E, (a: A) => B>>) => HKT<F, Either<E, B>>\n```\n\nAdded in v2.10.0\n\n## bimap\n\n**Signature**\n\n```ts\nexport declare function bimap<F extends URIS3>(\n  F: Functor3<F>\n): <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R, FE>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, B>>\nexport declare function bimap<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, B>>\nexport declare function bimap<F extends URIS2>(\n  F: Functor2<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <FE>(self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, B>>\nexport declare function bimap<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, B>>\nexport declare function bimap<F extends URIS>(\n  F: Functor1<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: Kind<F, Either<E, A>>) => Kind<F, Either<G, B>>\nexport declare function bimap<F>(\n  F: Functor<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: HKT<F, Either<E, A>>) => HKT<F, Either<G, B>>\n```\n\nAdded in v2.10.0\n\n## chain\n\n**Signature**\n\n```ts\nexport declare function chain<M extends URIS3>(\n  M: Monad3<M>\n): <A, R, ME, E, B>(\n  f: (a: A) => Kind3<M, R, ME, Either<E, B>>\n) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, B>>\nexport declare function chain<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <A, R, E, B>(\n  f: (a: A) => Kind3<M, R, ME, Either<E, B>>\n) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, B>>\nexport declare function chain<M extends URIS2>(\n  M: Monad2<M>\n): <A, ME, E, B>(\n  f: (a: A) => Kind2<M, ME, Either<E, B>>\n) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, B>>\nexport declare function chain<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <A, E, B>(f: (a: A) => Kind2<M, ME, Either<E, B>>) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, B>>\nexport declare function chain<M extends URIS>(\n  M: Monad1<M>\n): <A, E, B>(f: (a: A) => Kind<M, Either<E, B>>) => (ma: Kind<M, Either<E, A>>) => Kind<M, Either<E, B>>\nexport declare function chain<M>(\n  M: Monad<M>\n): <A, E, B>(f: (a: A) => HKT<M, Either<E, B>>) => (ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, B>>\n```\n\nAdded in v2.10.0\n\n## chainNullableK\n\n**Signature**\n\n```ts\nexport declare function chainNullableK<M extends URIS3>(\n  M: Monad3<M>\n): <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => <S, R>(ma: Kind3<M, S, R, Either<E, A>>) => Kind3<M, S, R, Either<E, NonNullable<B>>>\nexport declare function chainNullableK<M extends URIS3, R>(\n  M: Monad3C<M, R>\n): <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => <S>(ma: Kind3<M, S, R, Either<E, A>>) => Kind3<M, S, R, Either<E, NonNullable<B>>>\nexport declare function chainNullableK<M extends URIS2>(\n  M: Monad2<M>\n): <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => <R>(ma: Kind2<M, R, Either<E, A>>) => Kind2<M, R, Either<E, NonNullable<B>>>\nexport declare function chainNullableK<M extends URIS2, T>(\n  M: Monad2C<M, T>\n): <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => (ma: Kind2<M, T, Either<E, A>>) => Kind2<M, T, Either<E, NonNullable<B>>>\nexport declare function chainNullableK<M extends URIS>(\n  M: Monad1<M>\n): <E>(\n  e: E\n) => <A, B>(f: (a: A) => B | null | undefined) => (ma: Kind<M, Either<E, A>>) => Kind<M, Either<E, NonNullable<B>>>\nexport declare function chainNullableK<M>(\n  M: Monad<M>\n): <E>(\n  e: E\n) => <A, B>(f: (a: A) => B | null | undefined) => (ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, NonNullable<B>>>\n```\n\nAdded in v2.12.0\n\n## fromNullable\n\n**Signature**\n\n```ts\nexport declare function fromNullable<F extends URIS3>(\n  F: Pointed3<F>\n): <E>(e: E) => <A, S, R>(a: A) => Kind3<F, S, R, Either<E, NonNullable<A>>>\nexport declare function fromNullable<F extends URIS3, R>(\n  F: Pointed3C<F, R>\n): <E>(e: E) => <A, S>(a: A) => Kind3<F, S, R, Either<E, NonNullable<A>>>\nexport declare function fromNullable<F extends URIS2>(\n  F: Pointed2<F>\n): <E>(e: E) => <A, R>(a: A) => Kind2<F, R, Either<E, NonNullable<A>>>\nexport declare function fromNullable<F extends URIS2, R>(\n  F: Pointed2C<F, R>\n): <E>(e: E) => <A>(a: A) => Kind2<F, R, Either<E, NonNullable<A>>>\nexport declare function fromNullable<F extends URIS>(\n  F: Pointed1<F>\n): <E>(e: E) => <A>(a: A) => Kind<F, Either<E, NonNullable<A>>>\nexport declare function fromNullable<F>(F: Pointed<F>): <E>(e: E) => <A>(a: A) => HKT<F, Either<E, NonNullable<A>>>\n```\n\nAdded in v2.12.0\n\n## fromNullableK\n\n**Signature**\n\n```ts\nexport declare function fromNullableK<F extends URIS3>(\n  F: Pointed3<F>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <S, R>(...a: A) => Kind3<F, S, R, Either<E, NonNullable<B>>>\nexport declare function fromNullableK<F extends URIS3, R>(\n  F: Pointed3C<F, R>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <S>(...a: A) => Kind3<F, S, R, Either<E, NonNullable<B>>>\nexport declare function fromNullableK<F extends URIS2>(\n  F: Pointed2<F>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <R>(...a: A) => Kind2<F, R, Either<E, NonNullable<B>>>\nexport declare function fromNullableK<F extends URIS2, R>(\n  F: Pointed2C<F, R>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Kind2<F, R, Either<E, NonNullable<B>>>\nexport declare function fromNullableK<F extends URIS>(\n  F: Pointed1<F>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Kind<F, Either<E, NonNullable<B>>>\nexport declare function fromNullableK<F>(\n  F: Pointed<F>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => HKT<F, Either<E, NonNullable<B>>>\n```\n\nAdded in v2.12.0\n\n## getOrElse\n\n**Signature**\n\n```ts\nexport declare function getOrElse<M extends URIS3>(\n  M: Monad3<M>\n): <E, R, ME, A>(onLeft: (e: E) => Kind3<M, R, ME, A>) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, A>\nexport declare function getOrElse<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <E, R, A>(onLeft: (e: E) => Kind3<M, R, ME, A>) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, A>\nexport declare function getOrElse<M extends URIS2>(\n  M: Monad2<M>\n): <E, ME, A>(onLeft: (e: E) => Kind2<M, ME, A>) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, A>\nexport declare function getOrElse<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E, A>(onLeft: (e: E) => Kind2<M, ME, A>) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, A>\nexport declare function getOrElse<M extends URIS>(\n  M: Monad1<M>\n): <E, A>(onLeft: (e: E) => Kind<M, A>) => (ma: Kind<M, Either<E, A>>) => Kind<M, A>\nexport declare function getOrElse<M>(\n  M: Monad<M>\n): <E, A>(onLeft: (e: E) => HKT<M, A>) => (ma: HKT<M, Either<E, A>>) => HKT<M, A>\n```\n\nAdded in v2.10.0\n\n## left\n\n**Signature**\n\n```ts\nexport declare function left<F extends URIS3>(\n  F: Pointed3<F>\n): <E, R, FE, A = never>(e: E) => Kind3<F, R, FE, Either<E, A>>\nexport declare function left<F extends URIS3, FE>(\n  F: Pointed3C<F, FE>\n): <E, R, A = never>(e: E) => Kind3<F, R, FE, Either<E, A>>\nexport declare function left<F extends URIS2>(F: Pointed2<F>): <E, FE, A = never>(e: E) => Kind2<F, FE, Either<E, A>>\nexport declare function left<F extends URIS2, FE>(\n  F: Pointed2C<F, FE>\n): <E, A = never>(e: E) => Kind2<F, FE, Either<E, A>>\nexport declare function left<F extends URIS>(F: Pointed1<F>): <E, A = never>(e: E) => Kind<F, Either<E, A>>\nexport declare function left<F>(F: Pointed<F>): <E, A = never>(e: E) => HKT<F, Either<E, A>>\n```\n\nAdded in v2.10.0\n\n## leftF\n\n**Signature**\n\n```ts\nexport declare function leftF<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, Either<E, A>>\nexport declare function leftF<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, Either<E, A>>\nexport declare function leftF<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, Either<E, A>>\nexport declare function leftF<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, Either<E, A>>\nexport declare function leftF<F extends URIS>(F: Functor1<F>): <E, A = never>(fe: Kind<F, E>) => Kind<F, Either<E, A>>\nexport declare function leftF<F>(F: Functor<F>): <E, A = never>(fe: HKT<F, E>) => HKT<F, Either<E, A>>\n```\n\nAdded in v2.10.0\n\n## map\n\n**Signature**\n\n```ts\nexport declare function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, FE, E>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<E, B>>\nexport declare function map<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<E, B>>\nexport declare function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <FE, E>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<E, B>>\nexport declare function map<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<E, B>>\nexport declare function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind<F, Either<E, A>>) => Kind<F, Either<E, B>>\nexport declare function map<F>(\n  F: Functor<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, Either<E, A>>) => HKT<F, Either<E, B>>\n```\n\nAdded in v2.10.0\n\n## mapLeft\n\n**Signature**\n\n```ts\nexport declare function mapLeft<F extends URIS3>(\n  F: Functor3<F>\n): <E, G>(f: (e: E) => G) => <R, FE, A>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, A>>\nexport declare function mapLeft<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, G>(f: (e: E) => G) => <R, A>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, A>>\nexport declare function mapLeft<F extends URIS2>(\n  F: Functor2<F>\n): <E, G>(f: (e: E) => G) => <FE, A>(self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, A>>\nexport declare function mapLeft<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, G>(f: (e: E) => G) => <A>(self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, A>>\nexport declare function mapLeft<F extends URIS>(\n  F: Functor1<F>\n): <E, G>(f: (e: E) => G) => <A>(self: Kind<F, Either<E, A>>) => Kind<F, Either<G, A>>\nexport declare function mapLeft<F>(\n  F: Functor<F>\n): <E, G>(f: (e: E) => G) => <A>(self: HKT<F, Either<E, A>>) => HKT<F, Either<G, A>>\n```\n\nAdded in v2.10.0\n\n## matchE\n\n**Signature**\n\n```ts\nexport declare function matchE<M extends URIS3>(\n  M: Chain3<M>\n): <E, R, FE, B, A>(\n  onLeft: (e: E) => Kind3<M, R, FE, B>,\n  onRight: (a: A) => Kind3<M, R, FE, B>\n) => (ma: Kind3<M, R, FE, Either<E, A>>) => Kind3<M, R, FE, B>\nexport declare function matchE<M extends URIS3, FE>(\n  M: Chain3C<M, FE>\n): <E, R, B, A>(\n  onLeft: (e: E) => Kind3<M, R, FE, B>,\n  onRight: (a: A) => Kind3<M, R, FE, B>\n) => (ma: Kind3<M, R, FE, Either<E, A>>) => Kind3<M, R, FE, B>\nexport declare function matchE<M extends URIS2>(\n  M: Chain2<M>\n): <E, FE, B, A>(\n  onLeft: (e: E) => Kind2<M, FE, B>,\n  onRight: (a: A) => Kind2<M, FE, B>\n) => (ma: Kind2<M, FE, Either<E, A>>) => Kind2<M, FE, B>\nexport declare function matchE<M extends URIS2, FE>(\n  M: Chain2C<M, FE>\n): <E, B, A>(\n  onLeft: (e: E) => Kind2<M, FE, B>,\n  onRight: (a: A) => Kind2<M, FE, B>\n) => (ma: Kind2<M, FE, Either<E, A>>) => Kind2<M, FE, B>\nexport declare function matchE<M extends URIS>(\n  M: Chain1<M>\n): <E, B, A>(onLeft: (e: E) => Kind<M, B>, onRight: (a: A) => Kind<M, B>) => (ma: Kind<M, Either<E, A>>) => Kind<M, B>\nexport declare function matchE<M>(\n  M: Chain<M>\n): <E, B, A>(onLeft: (e: E) => HKT<M, B>, onRight: (a: A) => HKT<M, B>) => (ma: HKT<M, Either<E, A>>) => HKT<M, B>\n```\n\nAdded in v2.10.0\n\n## orElse\n\n**Signature**\n\n```ts\nexport declare function orElse<M extends URIS3>(\n  M: Monad3<M>\n): <E1, R, ME, E2, A>(\n  onLeft: (e: E1) => Kind3<M, R, ME, Either<E2, A>>\n) => (ma: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>\nexport declare function orElse<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <E1, R, E2, A>(\n  onLeft: (e: E1) => Kind3<M, R, ME, Either<E2, A>>\n) => (ma: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>\nexport declare function orElse<M extends URIS2>(\n  M: Monad2<M>\n): <E1, ME, E2, A>(\n  onLeft: (e: E1) => Kind2<M, ME, Either<E2, A>>\n) => (ma: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>\nexport declare function orElse<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E1, E2, A>(\n  onLeft: (e: E1) => Kind2<M, ME, Either<E2, A>>\n) => (ma: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>\nexport declare function orElse<M extends URIS>(\n  M: Monad1<M>\n): <E1, E2, A>(onLeft: (e: E1) => Kind<M, Either<E2, A>>) => (ma: Kind<M, Either<E1, A>>) => Kind<M, Either<E2, A>>\nexport declare function orElse<M>(\n  M: Monad<M>\n): <E1, E2, A>(onLeft: (e: E1) => HKT<M, Either<E2, A>>) => (ma: HKT<M, Either<E1, A>>) => HKT<M, Either<E2, A>>\n```\n\nAdded in v2.10.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare function right<F extends URIS3>(\n  F: Pointed3<F>\n): <A, R, FE, E = never>(a: A) => Kind3<F, R, FE, Either<E, A>>\nexport declare function right<F extends URIS3, FE>(\n  F: Pointed3C<F, FE>\n): <A, R, E = never>(a: A) => Kind3<F, R, FE, Either<E, A>>\nexport declare function right<F extends URIS2>(F: Pointed2<F>): <A, FE, E = never>(a: A) => Kind2<F, FE, Either<E, A>>\nexport declare function right<F extends URIS2, FE>(\n  F: Pointed2C<F, FE>\n): <A, E = never>(a: A) => Kind2<F, FE, Either<E, A>>\nexport declare function right<F extends URIS>(F: Pointed1<F>): <A, E = never>(a: A) => Kind<F, Either<E, A>>\nexport declare function right<F>(F: Pointed<F>): <A, E = never>(a: A) => HKT<F, Either<E, A>>\n```\n\nAdded in v2.10.0\n\n## rightF\n\n**Signature**\n\n```ts\nexport declare function rightF<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, Either<E, A>>\nexport declare function rightF<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, Either<E, A>>\nexport declare function rightF<F extends URIS2>(\n  F: Functor2<F>\n): <FE, A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, Either<E, A>>\nexport declare function rightF<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, Either<E, A>>\nexport declare function rightF<F extends URIS>(F: Functor1<F>): <A, E = never>(fa: Kind<F, A>) => Kind<F, Either<E, A>>\nexport declare function rightF<F>(F: Functor<F>): <A, E = never>(fa: HKT<F, A>) => HKT<F, Either<E, A>>\n```\n\nAdded in v2.10.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare function swap<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A>(ma: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<A, E>>\nexport declare function swap<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A>(ma: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<A, E>>\nexport declare function swap<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A>(ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<A, E>>\nexport declare function swap<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A>(ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<A, E>>\nexport declare function swap<F extends URIS>(F: Functor1<F>): <E, A>(ma: Kind<F, Either<E, A>>) => Kind<F, Either<A, E>>\nexport declare function swap<F>(F: Functor<F>): <E, A>(ma: HKT<F, Either<E, A>>) => HKT<F, Either<A, E>>\n```\n\nAdded in v2.10.0\n\n## toUnion\n\n**Signature**\n\n```ts\nexport declare function toUnion<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, E | A>\nexport declare function toUnion<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, E | A>\nexport declare function toUnion<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, E | A>\nexport declare function toUnion<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, E | A>\nexport declare function toUnion<F extends URIS>(F: Functor1<F>): <E, A>(fa: Kind<F, Either<E, A>>) => Kind<F, E | A>\nexport declare function toUnion<F>(F: Functor<F>): <E, A>(fa: HKT<F, Either<E, A>>) => HKT<F, E | A>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~EitherM1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface EitherM1<M extends URIS> extends ApplicativeComposition12<M, URI> {\n  readonly chain: <E, A, B>(ma: EitherT1<M, E, A>, f: (a: A) => EitherT1<M, E, B>) => EitherT1<M, E, B>\n  readonly alt: <E, A>(fa: EitherT1<M, E, A>, that: LazyArg<EitherT1<M, E, A>>) => EitherT1<M, E, A>\n  readonly bimap: <E, A, N, B>(ma: EitherT1<M, E, A>, f: (e: E) => N, g: (a: A) => B) => EitherT1<M, N, B>\n  readonly mapLeft: <E, A, N>(ma: EitherT1<M, E, A>, f: (e: E) => N) => EitherT1<M, N, A>\n  readonly fold: <E, A, R>(\n    ma: EitherT1<M, E, A>,\n    onLeft: (e: E) => Kind<M, R>,\n    onRight: (a: A) => Kind<M, R>\n  ) => Kind<M, R>\n  readonly getOrElse: <E, A>(ma: EitherT1<M, E, A>, onLeft: (e: E) => Kind<M, A>) => Kind<M, A>\n  readonly orElse: <E, A, N>(ma: EitherT1<M, E, A>, onLeft: (e: E) => EitherT1<M, N, A>) => EitherT1<M, N, A>\n  readonly swap: <E, A>(ma: EitherT1<M, E, A>) => EitherT1<M, A, E>\n  readonly rightM: <E, A>(ma: Kind<M, A>) => EitherT1<M, E, A>\n  readonly leftM: <E, A>(me: Kind<M, E>) => EitherT1<M, E, A>\n  readonly left: <E, A>(e: E) => EitherT1<M, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~EitherM2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface EitherM2<M extends URIS2> extends ApplicativeComposition22<M, URI> {\n  readonly chain: <R, E, A, B>(ma: EitherT2<M, R, E, A>, f: (a: A) => EitherT2<M, R, E, B>) => EitherT2<M, R, E, B>\n  readonly alt: <R, E, A>(fa: EitherT2<M, R, E, A>, that: LazyArg<EitherT2<M, R, E, A>>) => EitherT2<M, R, E, A>\n  readonly bimap: <R, E, A, N, B>(ma: EitherT2<M, R, E, A>, f: (e: E) => N, g: (a: A) => B) => EitherT2<M, R, N, B>\n  readonly mapLeft: <R, E, A, N>(ma: EitherT2<M, R, E, A>, f: (e: E) => N) => EitherT2<M, R, N, A>\n  readonly fold: <R, E, A, B>(\n    ma: EitherT2<M, R, E, A>,\n    onLeft: (e: E) => Kind2<M, R, B>,\n    onRight: (a: A) => Kind2<M, R, B>\n  ) => Kind2<M, R, B>\n  readonly getOrElse: <R, E, A>(ma: EitherT2<M, R, E, A>, onLeft: (e: E) => Kind2<M, R, A>) => Kind2<M, R, A>\n  readonly orElse: <R, E, A, F>(\n    ma: EitherT2<M, R, E, A>,\n    onLeft: (e: E) => EitherT2<M, R, F, A>\n  ) => EitherT2<M, R, F, A>\n  readonly swap: <R, E, A>(ma: EitherT2<M, R, E, A>) => EitherT2<M, R, A, E>\n  readonly rightM: <R, E, A>(ma: Kind2<M, R, A>) => EitherT2<M, R, E, A>\n  readonly leftM: <R, E, A>(me: Kind2<M, R, E>) => EitherT2<M, R, E, A>\n  readonly left: <R, E, A>(e: E) => EitherT2<M, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~EitherM~~ (interface)\n\n**Signature**\n\n```ts\nexport interface EitherM<M> extends ApplicativeCompositionHKT2<M, URI> {\n  readonly chain: <E, A, B>(ma: EitherT<M, E, A>, f: (a: A) => EitherT<M, E, B>) => EitherT<M, E, B>\n  readonly alt: <E, A>(fa: EitherT<M, E, A>, that: LazyArg<EitherT<M, E, A>>) => EitherT<M, E, A>\n  readonly bimap: <E, A, N, B>(ma: EitherT<M, E, A>, f: (e: E) => N, g: (a: A) => B) => EitherT<M, N, B>\n  readonly mapLeft: <E, A, N>(ma: EitherT<M, E, A>, f: (e: E) => N) => EitherT<M, N, A>\n  readonly fold: <E, A, R>(ma: EitherT<M, E, A>, onLeft: (e: E) => HKT<M, R>, onRight: (a: A) => HKT<M, R>) => HKT<M, R>\n  readonly getOrElse: <E, A>(ma: EitherT<M, E, A>, onLeft: (e: E) => HKT<M, A>) => HKT<M, A>\n  readonly orElse: <E, A, N>(ma: EitherT<M, E, A>, onLeft: (e: E) => EitherT<M, N, A>) => EitherT<M, N, A>\n  readonly swap: <E, A>(ma: EitherT<M, E, A>) => EitherT<M, A, E>\n  readonly rightM: <E, A>(ma: HKT<M, A>) => EitherT<M, E, A>\n  readonly leftM: <E, A>(me: HKT<M, E>) => EitherT<M, E, A>\n  readonly left: <E, A>(e: E) => EitherT<M, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~EitherT1~~ (type alias)\n\n**Signature**\n\n```ts\nexport type EitherT1<M extends URIS, E, A> = Kind<M, Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~EitherT2~~ (type alias)\n\n**Signature**\n\n```ts\nexport type EitherT2<M extends URIS2, R, E, A> = Kind2<M, R, Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~EitherT~~ (interface)\n\n**Signature**\n\n```ts\nexport interface EitherT<M, E, A> extends HKT<M, Either<E, A>> {}\n```\n\nAdded in v2.0.0\n\n## ~~getEitherM~~\n\n**Signature**\n\n```ts\nexport declare function getEitherM<M extends URIS2>(M: Monad2<M>): EitherM2<M>\nexport declare function getEitherM<M extends URIS>(M: Monad1<M>): EitherM1<M>\nexport declare function getEitherM<M>(M: Monad<M>): EitherM<M>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Endomorphism.ts.md",
    "content": "---\ntitle: Endomorphism.ts\nnav_order: 27\nparent: Modules\n---\n\n## Endomorphism overview\n\nAdded in v2.11.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [getMonoid](#getmonoid)\n  - [getSemigroup](#getsemigroup)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [Endomorphism (interface)](#endomorphism-interface)\n\n---\n\n# instances\n\n## getMonoid\n\nEndomorphism form a `Monoid` where the `empty` value is the `identity` function.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A = never>() => Monoid<Endomorphism<A>>\n```\n\nAdded in v2.11.0\n\n## getSemigroup\n\nEndomorphism form a `Semigroup` where the `concat` operation is the usual function composition.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A = never>() => Semigroup<Endomorphism<A>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Endomorphism'\n```\n\nAdded in v2.11.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.11.0\n\n# utils\n\n## Endomorphism (interface)\n\n**Signature**\n\n```ts\nexport interface Endomorphism<A> {\n  (a: A): A\n}\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/Eq.ts.md",
    "content": "---\ntitle: Eq.ts\nnav_order: 28\nparent: Modules\n---\n\n## Eq overview\n\nThe `Eq` type class represents types which support decidable equality.\n\nInstances must satisfy the following laws:\n\n1. Reflexivity: `E.equals(a, a) === true`\n2. Symmetry: `E.equals(a, b) === E.equals(b, a)`\n3. Transitivity: if `E.equals(a, b) === true` and `E.equals(b, c) === true`, then `E.equals(a, c) === true`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [fromEquals](#fromequals)\n- [instances](#instances)\n  - [Contravariant](#contravariant)\n  - [eqStrict](#eqstrict)\n  - [getMonoid](#getmonoid)\n  - [getSemigroup](#getsemigroup)\n- [model](#model)\n  - [Eq (interface)](#eq-interface)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [contramap](#contramap)\n  - [struct](#struct)\n  - [tuple](#tuple)\n- [zone of death](#zone-of-death)\n  - [~~eqBoolean~~](#eqboolean)\n  - [~~eqDate~~](#eqdate)\n  - [~~eqNumber~~](#eqnumber)\n  - [~~eqString~~](#eqstring)\n  - [~~eq~~](#eq)\n  - [~~getStructEq~~](#getstructeq)\n  - [~~getTupleEq~~](#gettupleeq)\n  - [~~strictEqual~~](#strictequal)\n\n---\n\n# constructors\n\n## fromEquals\n\n**Signature**\n\n```ts\nexport declare const fromEquals: <A>(equals: (x: A, y: A) => boolean) => Eq<A>\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Contravariant\n\n**Signature**\n\n```ts\nexport declare const Contravariant: Contravariant1<'Eq'>\n```\n\nAdded in v2.7.0\n\n## eqStrict\n\n**Signature**\n\n```ts\nexport declare const eqStrict: Eq<unknown>\n```\n\nAdded in v2.5.0\n\n## getMonoid\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A>() => Monoid<Eq<A>>\n```\n\nAdded in v2.6.0\n\n## getSemigroup\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A>() => Semigroup<Eq<A>>\n```\n\nAdded in v2.10.0\n\n# model\n\n## Eq (interface)\n\n**Signature**\n\n```ts\nexport interface Eq<A> {\n  readonly equals: (x: A, y: A) => boolean\n}\n```\n\nAdded in v2.0.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Eq'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## contramap\n\nA typical use case for `contramap` would be like, given some `User` type, to construct an `Eq<User>`.\n\nWe can do so with a function from `User -> X` where `X` is some value that we know how to compare\nfor equality (meaning we have an `Eq<X>`)\n\nFor example, given the following `User` type, we want to construct an `Eq<User>` that just looks at the `key` field\nfor each user (since it's known to be unique).\n\nIf we have a way of comparing `UUID`s for equality (`eqUUID: Eq<UUID>`) and we know how to go from `User -> UUID`,\nusing `contramap` we can do this\n\n**Signature**\n\n```ts\nexport declare const contramap: <A, B>(f: (b: B) => A) => (fa: Eq<A>) => Eq<B>\n```\n\n**Example**\n\n```ts\nimport { contramap, Eq } from 'fp-ts/Eq'\nimport { pipe } from 'fp-ts/function'\nimport * as S from 'fp-ts/string'\n\ntype UUID = string\n\ninterface User {\n  readonly key: UUID\n  readonly firstName: string\n  readonly lastName: string\n}\n\nconst eqUUID: Eq<UUID> = S.Eq\n\nconst eqUserByKey: Eq<User> = pipe(\n  eqUUID,\n  contramap((user) => user.key)\n)\n\nassert.deepStrictEqual(\n  eqUserByKey.equals({ key: 'k1', firstName: 'a1', lastName: 'b1' }, { key: 'k2', firstName: 'a1', lastName: 'b1' }),\n  false\n)\nassert.deepStrictEqual(\n  eqUserByKey.equals({ key: 'k1', firstName: 'a1', lastName: 'b1' }, { key: 'k1', firstName: 'a2', lastName: 'b1' }),\n  true\n)\n```\n\nAdded in v2.0.0\n\n## struct\n\n**Signature**\n\n```ts\nexport declare const struct: <A>(eqs: { [K in keyof A]: Eq<A[K]> }) => Eq<{ readonly [K in keyof A]: A[K] }>\n```\n\nAdded in v2.10.0\n\n## tuple\n\nGiven a tuple of `Eq`s returns a `Eq` for the tuple\n\n**Signature**\n\n```ts\nexport declare const tuple: <A extends readonly unknown[]>(...eqs: { [K in keyof A]: Eq<A[K]> }) => Eq<Readonly<A>>\n```\n\n**Example**\n\n```ts\nimport { tuple } from 'fp-ts/Eq'\nimport * as S from 'fp-ts/string'\nimport * as N from 'fp-ts/number'\nimport * as B from 'fp-ts/boolean'\n\nconst E = tuple(S.Eq, N.Eq, B.Eq)\nassert.strictEqual(E.equals(['a', 1, true], ['a', 1, true]), true)\nassert.strictEqual(E.equals(['a', 1, true], ['b', 1, true]), false)\nassert.strictEqual(E.equals(['a', 1, true], ['a', 2, true]), false)\nassert.strictEqual(E.equals(['a', 1, true], ['a', 1, false]), false)\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~eqBoolean~~\n\nUse [`Eq`](./boolean.ts.html#eq) instead.\n\n**Signature**\n\n```ts\nexport declare const eqBoolean: Eq<boolean>\n```\n\nAdded in v2.0.0\n\n## ~~eqDate~~\n\nUse [`Eq`](./Date.ts.html#eq) instead.\n\n**Signature**\n\n```ts\nexport declare const eqDate: Eq<Date>\n```\n\nAdded in v2.0.0\n\n## ~~eqNumber~~\n\nUse [`Eq`](./number.ts.html#eq) instead.\n\n**Signature**\n\n```ts\nexport declare const eqNumber: Eq<number>\n```\n\nAdded in v2.0.0\n\n## ~~eqString~~\n\nUse [`Eq`](./string.ts.html#eq) instead.\n\n**Signature**\n\n```ts\nexport declare const eqString: Eq<string>\n```\n\nAdded in v2.0.0\n\n## ~~eq~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Contravariant` instance, pass `E.Contravariant` instead of `E.eq`\n(where `E` is from `import E from 'fp-ts/Eq'`)\n\n**Signature**\n\n```ts\nexport declare const eq: Contravariant1<'Eq'>\n```\n\nAdded in v2.0.0\n\n## ~~getStructEq~~\n\nUse [`struct`](#struct) instead.\n\n**Signature**\n\n```ts\nexport declare const getStructEq: <O extends Readonly<Record<string, any>>>(eqs: { [K in keyof O]: Eq<O[K]> }) => Eq<O>\n```\n\nAdded in v2.0.0\n\n## ~~getTupleEq~~\n\nUse [`tuple`](#tuple) instead.\n\n**Signature**\n\n```ts\nexport declare const getTupleEq: <T extends readonly Eq<any>[]>(\n  ...eqs: T\n) => Eq<{ [K in keyof T]: T[K] extends Eq<infer A> ? A : never }>\n```\n\nAdded in v2.0.0\n\n## ~~strictEqual~~\n\nUse [`eqStrict`](#eqstrict) instead\n\n**Signature**\n\n```ts\nexport declare const strictEqual: <A>(a: A, b: A) => boolean\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Extend.ts.md",
    "content": "---\ntitle: Extend.ts\nnav_order: 29\nparent: Modules\n---\n\n## Extend overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Extend (interface)](#extend-interface)\n  - [Extend1 (interface)](#extend1-interface)\n  - [Extend2 (interface)](#extend2-interface)\n  - [Extend2C (interface)](#extend2c-interface)\n  - [Extend3 (interface)](#extend3-interface)\n  - [Extend3C (interface)](#extend3c-interface)\n  - [Extend4 (interface)](#extend4-interface)\n\n---\n\n# model\n\n## Extend (interface)\n\n**Signature**\n\n```ts\nexport interface Extend<W> extends Functor<W> {\n  readonly extend: <A, B>(wa: HKT<W, A>, f: (wa: HKT<W, A>) => B) => HKT<W, B>\n}\n```\n\nAdded in v2.0.0\n\n## Extend1 (interface)\n\n**Signature**\n\n```ts\nexport interface Extend1<W extends URIS> extends Functor1<W> {\n  readonly extend: <A, B>(wa: Kind<W, A>, f: (wa: Kind<W, A>) => B) => Kind<W, B>\n}\n```\n\nAdded in v2.0.0\n\n## Extend2 (interface)\n\n**Signature**\n\n```ts\nexport interface Extend2<W extends URIS2> extends Functor2<W> {\n  readonly extend: <E, A, B>(wa: Kind2<W, E, A>, f: (wa: Kind2<W, E, A>) => B) => Kind2<W, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Extend2C (interface)\n\n**Signature**\n\n```ts\nexport interface Extend2C<W extends URIS2, E> extends Functor2C<W, E> {\n  readonly extend: <A, B>(wa: Kind2<W, E, A>, f: (wa: Kind2<W, E, A>) => B) => Kind2<W, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Extend3 (interface)\n\n**Signature**\n\n```ts\nexport interface Extend3<W extends URIS3> extends Functor3<W> {\n  readonly extend: <R, E, A, B>(wa: Kind3<W, R, E, A>, f: (wa: Kind3<W, R, E, A>) => B) => Kind3<W, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Extend3C (interface)\n\n**Signature**\n\n```ts\nexport interface Extend3C<W extends URIS3, E> extends Functor3C<W, E> {\n  readonly extend: <R, A, B>(wa: Kind3<W, R, E, A>, f: (wa: Kind3<W, R, E, A>) => B) => Kind3<W, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## Extend4 (interface)\n\n**Signature**\n\n```ts\nexport interface Extend4<W extends URIS4> extends Functor4<W> {\n  readonly extend: <S, R, E, A, B>(wa: Kind4<W, S, R, E, A>, f: (wa: Kind4<W, S, R, E, A>) => B) => Kind4<W, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Field.ts.md",
    "content": "---\ntitle: Field.ts\nnav_order: 30\nparent: Modules\n---\n\n## Field overview\n\nAdapted from https://github.com/purescript/purescript-prelude/blob/master/src/Data/Field.purs\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Field (interface)](#field-interface)\n- [utils](#utils)\n  - [gcd](#gcd)\n  - [lcm](#lcm)\n- [zone of death](#zone-of-death)\n  - [~~fieldNumber~~](#fieldnumber)\n\n---\n\n# model\n\n## Field (interface)\n\n**Signature**\n\n```ts\nexport interface Field<A> extends Ring<A> {\n  readonly degree: (a: A) => number\n  readonly div: (x: A, y: A) => A\n  readonly mod: (x: A, y: A) => A\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## gcd\n\nThe _greatest common divisor_ of two values\n\n**Signature**\n\n```ts\nexport declare function gcd<A>(E: Eq<A>, field: Field<A>): (x: A, y: A) => A\n```\n\nAdded in v2.0.0\n\n## lcm\n\nThe _least common multiple_ of two values\n\n**Signature**\n\n```ts\nexport declare function lcm<A>(E: Eq<A>, F: Field<A>): (x: A, y: A) => A\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~fieldNumber~~\n\nUse [`Field`](./number.ts.html#field) instead.\n\n**Signature**\n\n```ts\nexport declare const fieldNumber: Field<number>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Filterable.ts.md",
    "content": "---\ntitle: Filterable.ts\nnav_order: 31\nparent: Modules\n---\n\n## Filterable overview\n\n`Filterable` represents data structures which can be _partitioned_/_filtered_.\n\nAdapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Filterable.purs\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Filterable (interface)](#filterable-interface)\n  - [Filterable1 (interface)](#filterable1-interface)\n  - [Filterable2 (interface)](#filterable2-interface)\n  - [Filterable2C (interface)](#filterable2c-interface)\n  - [Filterable3 (interface)](#filterable3-interface)\n  - [Filterable3C (interface)](#filterable3c-interface)\n  - [Filterable4 (interface)](#filterable4-interface)\n- [utils](#utils)\n  - [Filter (interface)](#filter-interface)\n  - [Filter1 (interface)](#filter1-interface)\n  - [Filter2 (interface)](#filter2-interface)\n  - [Filter2C (interface)](#filter2c-interface)\n  - [Filter3 (interface)](#filter3-interface)\n  - [Filter3C (interface)](#filter3c-interface)\n  - [Filter4 (interface)](#filter4-interface)\n  - [Partition (interface)](#partition-interface)\n  - [Partition1 (interface)](#partition1-interface)\n  - [Partition2 (interface)](#partition2-interface)\n  - [Partition2C (interface)](#partition2c-interface)\n  - [Partition3 (interface)](#partition3-interface)\n  - [Partition3C (interface)](#partition3c-interface)\n  - [Partition4 (interface)](#partition4-interface)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n- [zone of death](#zone-of-death)\n  - [~~FilterableComposition11~~ (interface)](#filterablecomposition11-interface)\n  - [~~FilterableComposition12C~~ (interface)](#filterablecomposition12c-interface)\n  - [~~FilterableComposition12~~ (interface)](#filterablecomposition12-interface)\n  - [~~FilterableComposition21~~ (interface)](#filterablecomposition21-interface)\n  - [~~FilterableComposition22C~~ (interface)](#filterablecomposition22c-interface)\n  - [~~FilterableComposition22~~ (interface)](#filterablecomposition22-interface)\n  - [~~FilterableComposition23C~~ (interface)](#filterablecomposition23c-interface)\n  - [~~FilterableComposition2C1~~ (interface)](#filterablecomposition2c1-interface)\n  - [~~FilterableComposition~~ (interface)](#filterablecomposition-interface)\n  - [~~getFilterableComposition~~](#getfilterablecomposition)\n\n---\n\n# model\n\n## Filterable (interface)\n\n**Signature**\n\n```ts\nexport interface Filterable<F> extends Functor<F>, Compactable<F> {\n  /**\n   * Partition a data structure based on an either predicate.\n   */\n  readonly partitionMap: <A, B, C>(fa: HKT<F, A>, f: (a: A) => Either<B, C>) => Separated<HKT<F, B>, HKT<F, C>>\n  /**\n   * Partition a data structure based on a boolean predicate.\n   */\n  readonly partition: Partition<F>\n  /**\n   * Map over a data structure and filter based on an option predicate.\n   */\n  readonly filterMap: <A, B>(fa: HKT<F, A>, f: (a: A) => Option<B>) => HKT<F, B>\n  /**\n   * Filter a data structure based on a boolean predicate.\n   */\n  readonly filter: Filter<F>\n}\n```\n\nAdded in v2.0.0\n\n## Filterable1 (interface)\n\n**Signature**\n\n```ts\nexport interface Filterable1<F extends URIS> extends Functor1<F>, Compactable1<F> {\n  readonly partitionMap: <A, B, C>(fa: Kind<F, A>, f: (a: A) => Either<B, C>) => Separated<Kind<F, B>, Kind<F, C>>\n  readonly partition: Partition1<F>\n  readonly filterMap: <A, B>(fa: Kind<F, A>, f: (a: A) => Option<B>) => Kind<F, B>\n  readonly filter: Filter1<F>\n}\n```\n\nAdded in v2.0.0\n\n## Filterable2 (interface)\n\n**Signature**\n\n```ts\nexport interface Filterable2<F extends URIS2> extends Functor2<F>, Compactable2<F> {\n  readonly partitionMap: <E, A, B, C>(\n    fa: Kind2<F, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n  readonly partition: Partition2<F>\n  readonly filterMap: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => Option<B>) => Kind2<F, E, B>\n  readonly filter: Filter2<F>\n}\n```\n\nAdded in v2.0.0\n\n## Filterable2C (interface)\n\n**Signature**\n\n```ts\nexport interface Filterable2C<F extends URIS2, E> extends Functor2C<F, E>, Compactable2C<F, E> {\n  readonly partitionMap: <A, B, C>(\n    fa: Kind2<F, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n  readonly partition: Partition2C<F, E>\n  readonly filterMap: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => Option<B>) => Kind2<F, E, B>\n  readonly filter: Filter2C<F, E>\n}\n```\n\nAdded in v2.0.0\n\n## Filterable3 (interface)\n\n**Signature**\n\n```ts\nexport interface Filterable3<F extends URIS3> extends Functor3<F>, Compactable3<F> {\n  readonly partitionMap: <R, E, A, B, C>(\n    fa: Kind3<F, R, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n  readonly partition: Partition3<F>\n  readonly filterMap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Option<B>) => Kind3<F, R, E, B>\n  readonly filter: Filter3<F>\n}\n```\n\nAdded in v2.0.0\n\n## Filterable3C (interface)\n\n**Signature**\n\n```ts\nexport interface Filterable3C<F extends URIS3, E> extends Functor3C<F, E>, Compactable3C<F, E> {\n  readonly partitionMap: <R, A, B, C>(\n    fa: Kind3<F, R, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n  readonly partition: Partition3C<F, E>\n  readonly filterMap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Option<B>) => Kind3<F, R, E, B>\n  readonly filter: Filter3C<F, E>\n}\n```\n\nAdded in v2.2.0\n\n## Filterable4 (interface)\n\n**Signature**\n\n```ts\nexport interface Filterable4<F extends URIS4> extends Functor4<F>, Compactable4<F> {\n  readonly partitionMap: <S, R, E, A, B, C>(\n    fa: Kind4<F, S, R, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\n  readonly partition: Partition4<F>\n  readonly filterMap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => Option<B>) => Kind4<F, S, R, E, B>\n  readonly filter: Filter4<F>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## Filter (interface)\n\n**Signature**\n\n```ts\nexport interface Filter<F> {\n  <A, B extends A>(fa: HKT<F, A>, refinement: Refinement<A, B>): HKT<F, B>\n  <A>(fa: HKT<F, A>, predicate: Predicate<A>): HKT<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## Filter1 (interface)\n\n**Signature**\n\n```ts\nexport interface Filter1<F extends URIS> {\n  <A, B extends A>(fa: Kind<F, A>, refinement: Refinement<A, B>): Kind<F, B>\n  <A>(fa: Kind<F, A>, predicate: Predicate<A>): Kind<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## Filter2 (interface)\n\n**Signature**\n\n```ts\nexport interface Filter2<F extends URIS2> {\n  <E, A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Kind2<F, E, B>\n  <E, A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Filter2C (interface)\n\n**Signature**\n\n```ts\nexport interface Filter2C<F extends URIS2, E> {\n  <A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Kind2<F, E, B>\n  <A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Filter3 (interface)\n\n**Signature**\n\n```ts\nexport interface Filter3<F extends URIS3> {\n  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Kind3<F, R, E, B>\n  <R, E, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Filter3C (interface)\n\n**Signature**\n\n```ts\nexport interface Filter3C<F extends URIS3, E> {\n  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Kind3<F, R, E, B>\n  <R, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.2.0\n\n## Filter4 (interface)\n\n**Signature**\n\n```ts\nexport interface Filter4<F extends URIS4> {\n  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinement: Refinement<A, B>): Kind4<F, S, R, E, B>\n  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicate: Predicate<A>): Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Partition (interface)\n\n**Signature**\n\n```ts\nexport interface Partition<F> {\n  <A, B extends A>(fa: HKT<F, A>, refinement: Refinement<A, B>): Separated<HKT<F, A>, HKT<F, B>>\n  <A>(fa: HKT<F, A>, predicate: Predicate<A>): Separated<HKT<F, A>, HKT<F, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Partition1 (interface)\n\n**Signature**\n\n```ts\nexport interface Partition1<F extends URIS> {\n  <A, B extends A>(fa: Kind<F, A>, refinement: Refinement<A, B>): Separated<Kind<F, A>, Kind<F, B>>\n  <A>(fa: Kind<F, A>, predicate: Predicate<A>): Separated<Kind<F, A>, Kind<F, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Partition2 (interface)\n\n**Signature**\n\n```ts\nexport interface Partition2<F extends URIS2> {\n  <E, A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <E, A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Partition2C (interface)\n\n**Signature**\n\n```ts\nexport interface Partition2C<F extends URIS2, E> {\n  <A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Partition3 (interface)\n\n**Signature**\n\n```ts\nexport interface Partition3<F extends URIS3> {\n  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, B>\n  >\n  <R, E, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Partition3C (interface)\n\n**Signature**\n\n```ts\nexport interface Partition3C<F extends URIS3, E> {\n  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, B>\n  >\n  <R, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\n```\n\nAdded in v2.2.0\n\n## Partition4 (interface)\n\n**Signature**\n\n```ts\nexport interface Partition4<F extends URIS4> {\n  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinement: Refinement<A, B>): Separated<\n    Kind4<F, S, R, E, A>,\n    Kind4<F, S, R, E, B>\n  >\n  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicate: Predicate<A>): Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## filter\n\n`filter` composition.\n\n**Signature**\n\n```ts\nexport declare function filter<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(fga: Kind2<F, R, Kind2<G, E, A>>) => Kind2<F, R, Kind2<G, E, B>>\n  <A>(predicate: Predicate<A>): <R, B extends A>(fgb: Kind2<F, R, Kind2<G, E, B>>) => Kind2<F, R, Kind2<G, E, B>>\n  <A>(predicate: Predicate<A>): <R>(fga: Kind2<F, R, Kind2<G, E, A>>) => Kind2<F, R, Kind2<G, E, A>>\n}\nexport declare function filter<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fgb: Kind<F, Kind2<G, E, B>>) => Kind<F, Kind2<G, E, B>>\n  <A>(predicate: Predicate<A>): (fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, A>>\n}\nexport declare function filter<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fgb: Kind<F, Kind<G, B>>) => Kind<F, Kind<G, B>>\n  <A>(predicate: Predicate<A>): (fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, A>>\n}\nexport declare function filter<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fgb: HKT<F, HKT<G, B>>) => HKT<F, HKT<G, B>>\n  <A>(predicate: Predicate<A>): (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, A>>\n}\n```\n\nAdded in v2.10.0\n\n## filterMap\n\n`filterMap` composition.\n\n**Signature**\n\n```ts\nexport declare function filterMap<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): <A, B>(f: (a: A) => Option<B>) => <FE>(fga: Kind2<F, FE, Kind2<G, E, A>>) => Kind2<F, FE, Kind2<G, E, B>>\nexport declare function filterMap<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): <A, B>(f: (a: A) => Option<B>) => (fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>\nexport declare function filterMap<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): <A, B>(f: (a: A) => Option<B>) => (fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\nexport declare function filterMap<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): <A, B>(f: (a: A) => Option<B>) => (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\n```\n\nAdded in v2.10.0\n\n## partition\n\n`partition` composition.\n\n**Signature**\n\n```ts\nexport declare function partition<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(\n    fga: Kind2<F, R, Kind2<G, E, A>>\n  ) => Separated<Kind2<F, R, Kind2<G, E, A>>, Kind2<F, R, Kind2<G, E, B>>>\n  <A>(predicate: Predicate<A>): <R, B extends A>(\n    fgb: Kind2<F, R, Kind2<G, E, B>>\n  ) => Separated<Kind2<F, R, Kind2<G, E, B>>, Kind2<F, R, Kind2<G, E, B>>>\n  <A>(predicate: Predicate<A>): <R>(\n    fga: Kind2<F, R, Kind2<G, E, A>>\n  ) => Separated<Kind2<F, R, Kind2<G, E, A>>, Kind2<F, R, Kind2<G, E, A>>>\n}\nexport declare function partition<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fga: Kind<F, Kind2<G, E, A>>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>\n  <A>(predicate: Predicate<A>): <B extends A>(\n    fgb: Kind<F, Kind2<G, E, B>>\n  ) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, B>>>\n  <A>(predicate: Predicate<A>): (\n    fga: Kind<F, Kind2<G, E, A>>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, A>>>\n}\nexport declare function partition<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fga: Kind<F, Kind<G, A>>\n  ) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, B>>>\n  <A>(predicate: Predicate<A>): <B extends A>(\n    fgb: Kind<F, Kind<G, B>>\n  ) => Separated<Kind<F, Kind<G, B>>, Kind<F, Kind<G, B>>>\n  <A>(predicate: Predicate<A>): (fga: Kind<F, Kind<G, A>>) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, A>>>\n}\nexport declare function partition<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fga: HKT<F, HKT<G, A>>\n  ) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>>\n  <A>(predicate: Predicate<A>): <B extends A>(fgb: HKT<F, HKT<G, B>>) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, B>>>\n  <A>(predicate: Predicate<A>): (fga: HKT<F, HKT<G, A>>) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, A>>>\n}\n```\n\nAdded in v2.10.0\n\n## partitionMap\n\n`partitionMap` composition.\n\n**Signature**\n\n```ts\nexport declare function partitionMap<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <FE>(fa: Kind2<F, FE, Kind2<G, E, A>>) => Separated<Kind2<F, FE, Kind2<G, E, B>>, Kind2<F, FE, Kind2<G, E, C>>>\nexport declare function partitionMap<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: Kind<F, Kind2<G, E, A>>) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, C>>>\nexport declare function partitionMap<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: Kind<F, Kind<G, A>>) => Separated<Kind<F, Kind<G, B>>, Kind<F, Kind<G, C>>>\nexport declare function partitionMap<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, HKT<G, A>>) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, C>>>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~FilterableComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableComposition11<F extends URIS, G extends URIS>\n  extends FunctorComposition11<F, G>,\n    CompactableComposition11<F, G> {\n  readonly partitionMap: <A, B, C>(\n    fa: Kind<F, Kind<G, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind<F, Kind<G, B>>, Kind<F, Kind<G, C>>>\n  readonly partition: <A>(\n    fa: Kind<F, Kind<G, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, A>>>\n  readonly filterMap: <A, B>(fa: Kind<F, Kind<G, A>>, f: (a: A) => Option<B>) => Kind<F, Kind<G, B>>\n  readonly filter: <A>(fa: Kind<F, Kind<G, A>>, predicate: Predicate<A>) => Kind<F, Kind<G, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FilterableComposition12C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableComposition12C<F extends URIS, G extends URIS2, E>\n  extends FunctorComposition12C<F, G, E>,\n    CompactableComposition12C<F, G, E> {\n  readonly partitionMap: <A, B, C>(\n    fa: Kind<F, Kind2<G, E, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, C>>>\n  readonly partition: <A>(\n    fa: Kind<F, Kind2<G, E, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, A>>>\n  readonly filterMap: <A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => Option<B>) => Kind<F, Kind2<G, E, B>>\n  readonly filter: <A>(fa: Kind<F, Kind2<G, E, A>>, predicate: Predicate<A>) => Kind<F, Kind2<G, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FilterableComposition12~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableComposition12<F extends URIS, G extends URIS2>\n  extends FunctorComposition12<F, G>,\n    CompactableComposition12<F, G> {\n  readonly partitionMap: <E, A, B, C>(\n    fa: Kind<F, Kind2<G, E, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, C>>>\n  readonly partition: <E, A>(\n    fa: Kind<F, Kind2<G, E, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, A>>>\n  readonly filterMap: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => Option<B>) => Kind<F, Kind2<G, E, B>>\n  readonly filter: <E, A>(fa: Kind<F, Kind2<G, E, A>>, predicate: Predicate<A>) => Kind<F, Kind2<G, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FilterableComposition21~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableComposition21<F extends URIS2, G extends URIS>\n  extends FunctorComposition21<F, G>,\n    CompactableComposition21<F, G> {\n  readonly partitionMap: <E, A, B, C>(\n    fa: Kind2<F, E, Kind<G, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, Kind<G, B>>, Kind2<F, E, Kind<G, C>>>\n  readonly partition: <E, A>(\n    fa: Kind2<F, E, Kind<G, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, E, Kind<G, A>>, Kind2<F, E, Kind<G, A>>>\n  readonly filterMap: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => Option<B>) => Kind2<F, E, Kind<G, B>>\n  readonly filter: <E, A>(fa: Kind2<F, E, Kind<G, A>>, predicate: Predicate<A>) => Kind2<F, E, Kind<G, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FilterableComposition22C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableComposition22C<F extends URIS2, G extends URIS2, E>\n  extends FunctorComposition22<F, G>,\n    CompactableComposition22<F, G> {\n  readonly partitionMap: <FE, A, B, C>(\n    fa: Kind2<F, FE, Kind2<G, E, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, FE, Kind2<G, E, B>>, Kind2<F, FE, Kind2<G, E, C>>>\n  readonly partition: <FE, A>(\n    fa: Kind2<F, FE, Kind2<G, E, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, FE, Kind2<G, E, A>>, Kind2<F, FE, Kind2<G, E, A>>>\n  readonly filterMap: <FE, A, B>(\n    fa: Kind2<F, FE, Kind2<G, E, A>>,\n    f: (a: A) => Option<B>\n  ) => Kind2<F, FE, Kind2<G, E, B>>\n  readonly filter: <FE, A>(fa: Kind2<F, FE, Kind2<G, E, A>>, predicate: Predicate<A>) => Kind2<F, FE, Kind2<G, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FilterableComposition22~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableComposition22<F extends URIS2, G extends URIS2>\n  extends FunctorComposition22<F, G>,\n    CompactableComposition22<F, G> {\n  readonly partitionMap: <FE, GE, A, B, C>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, FE, Kind2<G, GE, B>>, Kind2<F, FE, Kind2<G, GE, C>>>\n  readonly partition: <FE, GE, A>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, FE, Kind2<G, GE, A>>, Kind2<F, FE, Kind2<G, GE, A>>>\n  readonly filterMap: <FE, GE, A, B>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    f: (a: A) => Option<B>\n  ) => Kind2<F, FE, Kind2<G, GE, B>>\n  readonly filter: <FE, GE, A>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    predicate: Predicate<A>\n  ) => Kind2<F, FE, Kind2<G, GE, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FilterableComposition23C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableComposition23C<F extends URIS2, G extends URIS3, E>\n  extends FunctorComposition23<F, G>,\n    CompactableComposition23<F, G> {\n  readonly partitionMap: <R, FE, A, B, C>(\n    fa: Kind2<F, FE, Kind3<G, R, E, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, FE, Kind3<G, R, E, B>>, Kind2<F, FE, Kind3<G, R, E, C>>>\n  readonly partition: <R, FE, A>(\n    fa: Kind2<F, FE, Kind3<G, R, E, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, FE, Kind3<G, R, E, A>>, Kind2<F, FE, Kind3<G, R, E, A>>>\n  readonly filterMap: <R, FE, A, B>(\n    fa: Kind2<F, FE, Kind3<G, R, E, A>>,\n    f: (a: A) => Option<B>\n  ) => Kind2<F, FE, Kind3<G, R, E, B>>\n  readonly filter: <R, FE, A>(\n    fa: Kind2<F, FE, Kind3<G, R, E, A>>,\n    predicate: Predicate<A>\n  ) => Kind2<F, FE, Kind3<G, R, E, A>>\n}\n```\n\nAdded in v2.2.0\n\n## ~~FilterableComposition2C1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableComposition2C1<F extends URIS2, G extends URIS, E>\n  extends FunctorComposition21<F, G>,\n    CompactableComposition21<F, G> {\n  readonly partitionMap: <A, B, C>(\n    fa: Kind2<F, E, Kind<G, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, Kind<G, B>>, Kind2<F, E, Kind<G, C>>>\n  readonly partition: <A>(\n    fa: Kind2<F, E, Kind<G, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, E, Kind<G, A>>, Kind2<F, E, Kind<G, A>>>\n  readonly filterMap: <A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => Option<B>) => Kind2<F, E, Kind<G, B>>\n  readonly filter: <A>(fa: Kind2<F, E, Kind<G, A>>, predicate: Predicate<A>) => Kind2<F, E, Kind<G, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FilterableComposition~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableComposition<F, G> extends FunctorComposition<F, G>, CompactableComposition<F, G> {\n  readonly partitionMap: <A, B, C>(\n    fa: HKT<F, HKT<G, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, C>>>\n  readonly partition: <A>(\n    fa: HKT<F, HKT<G, A>>,\n    predicate: Predicate<A>\n  ) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, A>>>\n  readonly filterMap: <A, B>(fa: HKT<F, HKT<G, A>>, f: (a: A) => Option<B>) => HKT<F, HKT<G, B>>\n  readonly filter: <A>(fa: HKT<F, HKT<G, A>>, predicate: Predicate<A>) => HKT<F, HKT<G, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~getFilterableComposition~~\n\nUse\n\n- [`filter`](#filter)\n- [`filterMap`](#filtermap)\n- [`partition`](#partition)\n- [`partitionMap`](#partitionmap)\n\ninstead.\n\n**Signature**\n\n```ts\nexport declare function getFilterableComposition<F extends URIS2, G extends URIS3, E>(\n  F: Functor2<F>,\n  G: Filterable3C<G, E>\n): FilterableComposition23C<F, G, E>\nexport declare function getFilterableComposition<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): FilterableComposition22C<F, G, E>\nexport declare function getFilterableComposition<F extends URIS2, G extends URIS2>(\n  F: Functor2<F>,\n  G: Filterable2<G>\n): FilterableComposition22<F, G>\nexport declare function getFilterableComposition<F extends URIS2, G extends URIS, E>(\n  F: Functor2C<F, E>,\n  G: Filterable1<G>\n): FilterableComposition2C1<F, G, E>\nexport declare function getFilterableComposition<F extends URIS2, G extends URIS>(\n  F: Functor2<F>,\n  G: Filterable1<G>\n): FilterableComposition21<F, G>\nexport declare function getFilterableComposition<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): FilterableComposition12C<F, G, E>\nexport declare function getFilterableComposition<F extends URIS, G extends URIS2>(\n  F: Functor1<F>,\n  G: Filterable2<G>\n): FilterableComposition12<F, G>\nexport declare function getFilterableComposition<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): FilterableComposition11<F, G>\nexport declare function getFilterableComposition<F, G>(F: Functor<F>, G: Filterable<G>): FilterableComposition<F, G>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/FilterableWithIndex.ts.md",
    "content": "---\ntitle: FilterableWithIndex.ts\nnav_order: 32\nparent: Modules\n---\n\n## FilterableWithIndex overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [FilterableWithIndex (interface)](#filterablewithindex-interface)\n  - [FilterableWithIndex1 (interface)](#filterablewithindex1-interface)\n  - [FilterableWithIndex2 (interface)](#filterablewithindex2-interface)\n  - [FilterableWithIndex2C (interface)](#filterablewithindex2c-interface)\n  - [FilterableWithIndex3 (interface)](#filterablewithindex3-interface)\n  - [FilterableWithIndex3C (interface)](#filterablewithindex3c-interface)\n  - [FilterableWithIndex4 (interface)](#filterablewithindex4-interface)\n- [utils](#utils)\n  - [FilterWithIndex (interface)](#filterwithindex-interface)\n  - [FilterWithIndex1 (interface)](#filterwithindex1-interface)\n  - [FilterWithIndex2 (interface)](#filterwithindex2-interface)\n  - [FilterWithIndex2C (interface)](#filterwithindex2c-interface)\n  - [FilterWithIndex3 (interface)](#filterwithindex3-interface)\n  - [FilterWithIndex3C (interface)](#filterwithindex3c-interface)\n  - [FilterWithIndex4 (interface)](#filterwithindex4-interface)\n  - [PartitionWithIndex (interface)](#partitionwithindex-interface)\n  - [PartitionWithIndex1 (interface)](#partitionwithindex1-interface)\n  - [PartitionWithIndex2 (interface)](#partitionwithindex2-interface)\n  - [PartitionWithIndex2C (interface)](#partitionwithindex2c-interface)\n  - [PartitionWithIndex3 (interface)](#partitionwithindex3-interface)\n  - [PartitionWithIndex3C (interface)](#partitionwithindex3c-interface)\n  - [PartitionWithIndex4 (interface)](#partitionwithindex4-interface)\n  - [PredicateWithIndex (type alias)](#predicatewithindex-type-alias)\n  - [RefinementWithIndex (type alias)](#refinementwithindex-type-alias)\n\n---\n\n# model\n\n## FilterableWithIndex (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableWithIndex<F, I> extends FunctorWithIndex<F, I>, Filterable<F> {\n  readonly partitionMapWithIndex: <A, B, C>(\n    fa: HKT<F, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<HKT<F, B>, HKT<F, C>>\n  readonly partitionWithIndex: PartitionWithIndex<F, I>\n  readonly filterMapWithIndex: <A, B>(fa: HKT<F, A>, f: (i: I, a: A) => Option<B>) => HKT<F, B>\n  readonly filterWithIndex: FilterWithIndex<F, I>\n}\n```\n\nAdded in v2.0.0\n\n## FilterableWithIndex1 (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableWithIndex1<F extends URIS, I> extends FunctorWithIndex1<F, I>, Filterable1<F> {\n  readonly partitionMapWithIndex: <A, B, C>(\n    fa: Kind<F, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind<F, B>, Kind<F, C>>\n  readonly partitionWithIndex: PartitionWithIndex1<F, I>\n  readonly filterMapWithIndex: <A, B>(fa: Kind<F, A>, f: (i: I, a: A) => Option<B>) => Kind<F, B>\n  readonly filterWithIndex: FilterWithIndex1<F, I>\n}\n```\n\nAdded in v2.0.0\n\n## FilterableWithIndex2 (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableWithIndex2<F extends URIS2, I> extends FunctorWithIndex2<F, I>, Filterable2<F> {\n  readonly partitionMapWithIndex: <E, A, B, C>(\n    fa: Kind2<F, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex2<F, I>\n  readonly filterMapWithIndex: <E, A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => Option<B>) => Kind2<F, E, B>\n  readonly filterWithIndex: FilterWithIndex2<F, I>\n}\n```\n\nAdded in v2.0.0\n\n## FilterableWithIndex2C (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableWithIndex2C<F extends URIS2, I, E> extends FunctorWithIndex2C<F, I, E>, Filterable2C<F, E> {\n  readonly partitionMapWithIndex: <A, B, C>(\n    fa: Kind2<F, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex2C<F, I, E>\n  readonly filterMapWithIndex: <A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => Option<B>) => Kind2<F, E, B>\n  readonly filterWithIndex: FilterWithIndex2C<F, I, E>\n}\n```\n\nAdded in v2.0.0\n\n## FilterableWithIndex3 (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableWithIndex3<F extends URIS3, I> extends FunctorWithIndex3<F, I>, Filterable3<F> {\n  readonly partitionMapWithIndex: <R, E, A, B, C>(\n    fa: Kind3<F, R, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex3<F, I>\n  readonly filterMapWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => Option<B>) => Kind3<F, R, E, B>\n  readonly filterWithIndex: FilterWithIndex3<F, I>\n}\n```\n\nAdded in v2.0.0\n\n## FilterableWithIndex3C (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableWithIndex3C<F extends URIS3, I, E> extends FunctorWithIndex3C<F, I, E>, Filterable3C<F, E> {\n  readonly partitionMapWithIndex: <R, A, B, C>(\n    fa: Kind3<F, R, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex3C<F, I, E>\n  readonly filterMapWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => Option<B>) => Kind3<F, R, E, B>\n  readonly filterWithIndex: FilterWithIndex3C<F, I, E>\n}\n```\n\nAdded in v2.2.0\n\n## FilterableWithIndex4 (interface)\n\n**Signature**\n\n```ts\nexport interface FilterableWithIndex4<F extends URIS4, I> extends FunctorWithIndex4<F, I>, Filterable4<F> {\n  readonly partitionMapWithIndex: <S, R, E, A, B, C>(\n    fa: Kind4<F, S, R, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex4<F, I>\n  readonly filterMapWithIndex: <S, R, E, A, B>(\n    fa: Kind4<F, S, R, E, A>,\n    f: (i: I, a: A) => Option<B>\n  ) => Kind4<F, S, R, E, B>\n  readonly filterWithIndex: FilterWithIndex4<F, I>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## FilterWithIndex (interface)\n\n**Signature**\n\n```ts\nexport interface FilterWithIndex<F, I> {\n  <A, B extends A>(fa: HKT<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): HKT<F, B>\n  <A>(fa: HKT<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): HKT<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## FilterWithIndex1 (interface)\n\n**Signature**\n\n```ts\nexport interface FilterWithIndex1<F extends URIS, I> {\n  <A, B extends A>(fa: Kind<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind<F, B>\n  <A>(fa: Kind<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## FilterWithIndex2 (interface)\n\n**Signature**\n\n```ts\nexport interface FilterWithIndex2<F extends URIS2, I> {\n  <E, A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind2<F, E, B>\n  <E, A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## FilterWithIndex2C (interface)\n\n**Signature**\n\n```ts\nexport interface FilterWithIndex2C<F extends URIS2, I, E> {\n  <A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind2<F, E, B>\n  <A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## FilterWithIndex3 (interface)\n\n**Signature**\n\n```ts\nexport interface FilterWithIndex3<F extends URIS3, I> {\n  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind3<F, R, E, B>\n  <R, E, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## FilterWithIndex3C (interface)\n\n**Signature**\n\n```ts\nexport interface FilterWithIndex3C<F extends URIS3, I, E> {\n  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind3<F, R, E, B>\n  <R, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.2.0\n\n## FilterWithIndex4 (interface)\n\n**Signature**\n\n```ts\nexport interface FilterWithIndex4<F extends URIS4, I> {\n  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind4<\n    F,\n    S,\n    R,\n    E,\n    B\n  >\n  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## PartitionWithIndex (interface)\n\n**Signature**\n\n```ts\nexport interface PartitionWithIndex<F, I> {\n  <A, B extends A>(fa: HKT<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<HKT<F, A>, HKT<F, B>>\n  <A>(fa: HKT<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<HKT<F, A>, HKT<F, A>>\n}\n```\n\nAdded in v2.0.0\n\n## PartitionWithIndex1 (interface)\n\n**Signature**\n\n```ts\nexport interface PartitionWithIndex1<F extends URIS, I> {\n  <A, B extends A>(fa: Kind<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<Kind<F, A>, Kind<F, B>>\n  <A>(fa: Kind<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<Kind<F, A>, Kind<F, A>>\n}\n```\n\nAdded in v2.0.0\n\n## PartitionWithIndex2 (interface)\n\n**Signature**\n\n```ts\nexport interface PartitionWithIndex2<F extends URIS2, I> {\n  <E, A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind2<F, E, A>,\n    Kind2<F, E, B>\n  >\n  <E, A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## PartitionWithIndex2C (interface)\n\n**Signature**\n\n```ts\nexport interface PartitionWithIndex2C<F extends URIS2, I, E> {\n  <A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind2<F, E, A>,\n    Kind2<F, E, B>\n  >\n  <A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## PartitionWithIndex3 (interface)\n\n**Signature**\n\n```ts\nexport interface PartitionWithIndex3<F extends URIS3, I> {\n  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, B>\n  >\n  <R, E, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, A>\n  >\n}\n```\n\nAdded in v2.0.0\n\n## PartitionWithIndex3C (interface)\n\n**Signature**\n\n```ts\nexport interface PartitionWithIndex3C<F extends URIS3, I, E> {\n  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, B>\n  >\n  <R, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, A>\n  >\n}\n```\n\nAdded in v2.2.0\n\n## PartitionWithIndex4 (interface)\n\n**Signature**\n\n```ts\nexport interface PartitionWithIndex4<F extends URIS4, I> {\n  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind4<F, S, R, E, A>,\n    Kind4<F, S, R, E, B>\n  >\n  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<\n    Kind4<F, S, R, E, A>,\n    Kind4<F, S, R, E, A>\n  >\n}\n```\n\nAdded in v2.0.0\n\n## PredicateWithIndex (type alias)\n\n**Signature**\n\n```ts\nexport type PredicateWithIndex<I, A> = (i: I, a: A) => boolean\n```\n\nAdded in v2.0.0\n\n## RefinementWithIndex (type alias)\n\n**Signature**\n\n```ts\nexport type RefinementWithIndex<I, A, B extends A> = (i: I, a: A) => a is B\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Foldable.ts.md",
    "content": "---\ntitle: Foldable.ts\nnav_order: 33\nparent: Modules\n---\n\n## Foldable overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Foldable (interface)](#foldable-interface)\n  - [Foldable1 (interface)](#foldable1-interface)\n  - [Foldable2 (interface)](#foldable2-interface)\n  - [Foldable2C (interface)](#foldable2c-interface)\n  - [Foldable3 (interface)](#foldable3-interface)\n  - [Foldable3C (interface)](#foldable3c-interface)\n  - [Foldable4 (interface)](#foldable4-interface)\n- [utils](#utils)\n  - [foldMap](#foldmap)\n  - [intercalate](#intercalate)\n  - [reduce](#reduce)\n  - [reduceM](#reducem)\n  - [reduceRight](#reduceright)\n  - [toReadonlyArray](#toreadonlyarray)\n  - [traverse\\_](#traverse_)\n- [zone of death](#zone-of-death)\n  - [~~FoldableComposition11~~ (interface)](#foldablecomposition11-interface)\n  - [~~FoldableComposition12C~~ (interface)](#foldablecomposition12c-interface)\n  - [~~FoldableComposition12~~ (interface)](#foldablecomposition12-interface)\n  - [~~FoldableComposition21~~ (interface)](#foldablecomposition21-interface)\n  - [~~FoldableComposition22C~~ (interface)](#foldablecomposition22c-interface)\n  - [~~FoldableComposition22~~ (interface)](#foldablecomposition22-interface)\n  - [~~FoldableComposition2C1~~ (interface)](#foldablecomposition2c1-interface)\n  - [~~FoldableComposition~~ (interface)](#foldablecomposition-interface)\n  - [~~foldM~~](#foldm)\n  - [~~getFoldableComposition~~](#getfoldablecomposition)\n  - [~~toArray~~](#toarray)\n\n---\n\n# model\n\n## Foldable (interface)\n\n**Signature**\n\n```ts\nexport interface Foldable<F> {\n  readonly URI: F\n  readonly reduce: <A, B>(fa: HKT<F, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: HKT<F, A>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: HKT<F, A>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## Foldable1 (interface)\n\n**Signature**\n\n```ts\nexport interface Foldable1<F extends URIS> {\n  readonly URI: F\n  readonly reduce: <A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind<F, A>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind<F, A>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## Foldable2 (interface)\n\n**Signature**\n\n```ts\nexport interface Foldable2<F extends URIS2> {\n  readonly URI: F\n  readonly reduce: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <E, A>(fa: Kind2<F, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## Foldable2C (interface)\n\n**Signature**\n\n```ts\nexport interface Foldable2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly reduce: <A, B>(fa: Kind2<F, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind2<F, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind2<F, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## Foldable3 (interface)\n\n**Signature**\n\n```ts\nexport interface Foldable3<F extends URIS3> {\n  readonly URI: F\n  readonly reduce: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <R, E, A>(fa: Kind3<F, R, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## Foldable3C (interface)\n\n**Signature**\n\n```ts\nexport interface Foldable3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly reduce: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <R, A>(fa: Kind3<F, R, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.2.0\n\n## Foldable4 (interface)\n\n**Signature**\n\n```ts\nexport interface Foldable4<F extends URIS4> {\n  readonly URI: F\n  readonly reduce: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <S, R, E, A>(fa: Kind4<F, S, R, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## foldMap\n\n`foldMap` composition.\n\n**Signature**\n\n```ts\nexport declare function foldMap<F extends URIS, G extends URIS>(\n  F: Foldable1<F>,\n  G: Foldable1<G>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fga: Kind<F, Kind<G, A>>) => M\nexport declare function foldMap<F, G>(\n  F: Foldable<F>,\n  G: Foldable<G>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fga: HKT<F, HKT<G, A>>) => M\n```\n\nAdded in v2.10.0\n\n## intercalate\n\nFold a data structure, accumulating values in some `Monoid`, combining adjacent elements using the specified separator\n\n**Signature**\n\n```ts\nexport declare function intercalate<M, F extends URIS3>(\n  M: Monoid<M>,\n  F: Foldable3<F>\n): <R, E>(middle: M, fm: Kind3<F, R, E, M>) => M\nexport declare function intercalate<M, F extends URIS2>(\n  M: Monoid<M>,\n  F: Foldable2<F>\n): <E>(middle: M, fm: Kind2<F, E, M>) => M\nexport declare function intercalate<M, F extends URIS2, E>(\n  M: Monoid<M>,\n  F: Foldable2C<F, E>\n): (middle: M, fm: Kind2<F, E, M>) => M\nexport declare function intercalate<M, F extends URIS>(M: Monoid<M>, F: Foldable1<F>): (middle: M, fm: Kind<F, M>) => M\nexport declare function intercalate<M, F>(M: Monoid<M>, F: Foldable<F>): (middle: M, fm: HKT<F, M>) => M\n```\n\n**Example**\n\n```ts\nimport { intercalate } from 'fp-ts/Foldable'\nimport * as S from 'fp-ts/string'\nimport { make, Foldable } from 'fp-ts/Tree'\n\nconst t = make('a', [make('b', []), make('c', []), make('d', [])])\nassert.strictEqual(intercalate(S.Monoid, Foldable)('|', t), 'a|b|c|d')\n```\n\nAdded in v2.0.0\n\n## reduce\n\n`reduce` composition.\n\n**Signature**\n\n```ts\nexport declare function reduce<F extends URIS, G extends URIS>(\n  F: Foldable1<F>,\n  G: Foldable1<G>\n): <B, A>(b: B, f: (b: B, a: A) => B) => (fga: Kind<F, Kind<G, A>>) => B\nexport declare function reduce<F, G>(\n  F: Foldable<F>,\n  G: Foldable<G>\n): <B, A>(b: B, f: (b: B, a: A) => B) => (fga: HKT<F, HKT<G, A>>) => B\n```\n\nAdded in v2.10.0\n\n## reduceM\n\nSimilar to 'reduce', but the result is encapsulated in a monad.\n\nNote: this function is not generally stack-safe, e.g., for monads which build up thunks a la `IO`.\n\n**Signature**\n\n```ts\nexport declare function reduceM<M extends URIS3, F extends URIS>(\n  M: Monad3<M>,\n  F: Foldable1<F>\n): <B, A, R, E>(b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => (fa: Kind<F, A>) => Kind3<M, R, E, B>\nexport declare function reduceM<M extends URIS3, F extends URIS, E>(\n  M: Monad3C<M, E>,\n  F: Foldable1<F>\n): <B, A, R>(b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => (fa: Kind<F, A>) => Kind3<M, R, E, B>\nexport declare function reduceM<M extends URIS2, F extends URIS>(\n  M: Monad2<M>,\n  F: Foldable1<F>\n): <B, A, E>(b: B, f: (b: B, a: A) => Kind2<M, E, B>) => (fa: Kind<F, A>) => Kind2<M, E, B>\nexport declare function reduceM<M extends URIS2, F extends URIS, E>(\n  M: Monad2C<M, E>,\n  F: Foldable1<F>\n): <B, A>(b: B, f: (b: B, a: A) => Kind2<M, E, B>) => (fa: Kind<F, A>) => Kind2<M, E, B>\nexport declare function reduceM<M extends URIS, F extends URIS>(\n  M: Monad1<M>,\n  F: Foldable1<F>\n): <B, A>(b: B, f: (b: B, a: A) => Kind<M, B>) => (fa: Kind<F, A>) => Kind<M, B>\nexport declare function reduceM<M, F>(\n  M: Monad<M>,\n  F: Foldable<F>\n): <B, A>(b: B, f: (b: B, a: A) => HKT<M, B>) => (fa: HKT<F, A>) => HKT<M, B>\n```\n\n**Example**\n\n```ts\nimport { reduceM } from 'fp-ts/Foldable'\nimport { Monad, some } from 'fp-ts/Option'\nimport { make, Foldable } from 'fp-ts/Tree'\nimport { pipe } from 'fp-ts/function'\n\nconst t = make(1, [make(2, []), make(3, []), make(4, [])])\nassert.deepStrictEqual(\n  pipe(\n    t,\n    reduceM(Monad, Foldable)(0, (b, a) => (a > 2 ? some(b + a) : some(b)))\n  ),\n  some(7)\n)\n```\n\nAdded in v2.8.0\n\n## reduceRight\n\n`reduceRight` composition.\n\n**Signature**\n\n```ts\nexport declare function reduceRight<F extends URIS, G extends URIS>(\n  F: Foldable1<F>,\n  G: Foldable1<G>\n): <B, A>(b: B, f: (a: A, b: B) => B) => (fga: Kind<F, Kind<G, A>>) => B\nexport declare function reduceRight<F, G>(\n  F: Foldable<F>,\n  G: Foldable<G>\n): <B, A>(b: B, f: (a: A, b: B) => B) => (fga: HKT<F, HKT<G, A>>) => B\n```\n\nAdded in v2.10.0\n\n## toReadonlyArray\n\nTransforms a `Foldable` into a `toReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare function toReadonlyArray<F extends URIS4>(\n  F: Foldable4<F>\n): <S, R, E, A>(fa: Kind4<F, S, R, E, A>) => ReadonlyArray<A>\nexport declare function toReadonlyArray<F extends URIS3>(\n  F: Foldable3<F>\n): <R, E, A>(fa: Kind3<F, R, E, A>) => ReadonlyArray<A>\nexport declare function toReadonlyArray<F extends URIS3, E>(\n  F: Foldable3C<F, E>\n): <R, A>(fa: Kind3<F, R, E, A>) => ReadonlyArray<A>\nexport declare function toReadonlyArray<F extends URIS2>(\n  F: Foldable2<F>\n): <E, A>(fa: Kind2<F, E, A>) => ReadonlyArray<A>\nexport declare function toReadonlyArray<F extends URIS2, E>(\n  F: Foldable2C<F, E>\n): <A>(fa: Kind2<F, E, A>) => ReadonlyArray<A>\nexport declare function toReadonlyArray<F extends URIS>(F: Foldable1<F>): <A>(fa: Kind<F, A>) => ReadonlyArray<A>\nexport declare function toReadonlyArray<F>(F: Foldable<F>): <A>(fa: HKT<F, A>) => ReadonlyArray<A>\n```\n\n**Example**\n\n```ts\nimport { toReadonlyArray } from 'fp-ts/Foldable'\nimport { Foldable, make } from 'fp-ts/Tree'\n\nconst t = make(1, [make(2, []), make(3, []), make(4, [])])\nassert.deepStrictEqual(toReadonlyArray(Foldable)(t), [1, 2, 3, 4])\n```\n\nAdded in v2.10.0\n\n## traverse\\_\n\nTraverse a data structure, performing some effects encoded by an `Applicative` functor at each value, ignoring the\nfinal result.\n\n**Signature**\n\n```ts\nexport declare function traverse_<M extends URIS3, F extends URIS>(\n  M: Applicative3<M>,\n  F: Foldable1<F>\n): <R, E, A, B>(fa: Kind<F, A>, f: (a: A) => Kind3<M, R, E, B>) => Kind3<M, R, E, void>\nexport declare function traverse_<M extends URIS2, F extends URIS>(\n  M: Applicative2<M>,\n  F: Foldable1<F>\n): <E, A, B>(fa: Kind<F, A>, f: (a: A) => Kind2<M, E, B>) => Kind2<M, E, void>\nexport declare function traverse_<M extends URIS2, F extends URIS, E>(\n  M: Applicative2C<M, E>,\n  F: Foldable1<F>\n): <A, B>(fa: Kind<F, A>, f: (a: A) => Kind2<M, E, B>) => Kind2<M, E, void>\nexport declare function traverse_<M extends URIS, F extends URIS>(\n  M: Applicative1<M>,\n  F: Foldable1<F>\n): <A, B>(fa: Kind<F, A>, f: (a: A) => Kind<M, B>) => Kind<M, void>\nexport declare function traverse_<M, F>(\n  M: Applicative<M>,\n  F: Foldable<F>\n): <A, B>(fa: HKT<F, A>, f: (a: A) => HKT<M, B>) => HKT<M, void>\n```\n\n**Example**\n\n```ts\nimport { Foldable } from 'fp-ts/Array'\nimport { traverse_ } from 'fp-ts/Foldable'\nimport { Applicative } from 'fp-ts/IO'\n\nlet log = ''\nconst append = (s: string) => () => (log += s)\ntraverse_(Applicative, Foldable)(['a', 'b', 'c'], append)()\nassert.strictEqual(log, 'abc')\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~FoldableComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableComposition11<F extends URIS, G extends URIS> {\n  readonly reduce: <A, B>(fga: Kind<F, Kind<G, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind<F, Kind<G, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind<F, Kind<G, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableComposition12C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableComposition12C<F extends URIS, G extends URIS2, E> {\n  readonly reduce: <A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind<F, Kind2<G, E, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableComposition12~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableComposition12<F extends URIS, G extends URIS2> {\n  readonly reduce: <E, A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <E, A>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableComposition21~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableComposition21<F extends URIS2, G extends URIS> {\n  readonly reduce: <E, A, B>(fga: Kind2<F, E, Kind<G, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <E, A>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableComposition22C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableComposition22C<F extends URIS2, G extends URIS2, E> {\n  readonly reduce: <FE, A, B>(fga: Kind2<F, FE, Kind2<G, E, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <FE, A>(fa: Kind2<F, FE, Kind2<G, E, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <FE, A, B>(fa: Kind2<F, FE, Kind2<G, E, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableComposition22~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableComposition22<F extends URIS2, G extends URIS2> {\n  readonly reduce: <FE, GE, A, B>(fga: Kind2<F, FE, Kind2<G, GE, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <FE, GE, A>(fa: Kind2<F, FE, Kind2<G, GE, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <FE, GE, A, B>(fa: Kind2<F, FE, Kind2<G, GE, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableComposition2C1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableComposition2C1<F extends URIS2, G extends URIS, E> {\n  readonly reduce: <A, B>(fga: Kind2<F, E, Kind<G, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind2<F, E, Kind<G, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableComposition~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableComposition<F, G> {\n  readonly reduce: <A, B>(fga: HKT<F, HKT<G, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: HKT<F, HKT<G, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: HKT<F, HKT<G, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~foldM~~\n\nUse [`reduceM`](#reducem) instead\n\n**Signature**\n\n```ts\nexport declare function foldM<M extends URIS3, F extends URIS>(\n  M: Monad3<M>,\n  F: Foldable1<F>\n): <R, E, A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => Kind3<M, R, E, B>\nexport declare function foldM<M extends URIS3, F extends URIS, E>(\n  M: Monad3C<M, E>,\n  F: Foldable1<F>\n): <R, A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => Kind3<M, R, E, B>\nexport declare function foldM<M extends URIS2, F extends URIS>(\n  M: Monad2<M>,\n  F: Foldable1<F>\n): <E, A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind2<M, E, B>) => Kind2<M, E, B>\nexport declare function foldM<M extends URIS2, F extends URIS, E>(\n  M: Monad2C<M, E>,\n  F: Foldable1<F>\n): <A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind2<M, E, B>) => Kind2<M, E, B>\nexport declare function foldM<M extends URIS, F extends URIS>(\n  M: Monad1<M>,\n  F: Foldable1<F>\n): <A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind<M, B>) => Kind<M, B>\nexport declare function foldM<M, F>(\n  M: Monad<M>,\n  F: Foldable<F>\n): <A, B>(fa: HKT<F, A>, b: B, f: (b: B, a: A) => HKT<M, B>) => HKT<M, B>\n```\n\nAdded in v2.0.0\n\n## ~~getFoldableComposition~~\n\nUse\n\n- [reduce](#reduce)\n- [foldMap](#foldmap)\n- [reduceRight](#reduceright)\n\ninstead.\n\n**Signature**\n\n```ts\nexport declare function getFoldableComposition<F extends URIS2, G extends URIS2, E>(\n  F: Foldable2<F>,\n  G: Foldable2C<G, E>\n): FoldableComposition22C<F, G, E>\nexport declare function getFoldableComposition<F extends URIS2, G extends URIS2>(\n  F: Foldable2<F>,\n  G: Foldable2<G>\n): FoldableComposition22<F, G>\nexport declare function getFoldableComposition<F extends URIS2, G extends URIS, E>(\n  F: Foldable2C<F, E>,\n  G: Foldable1<G>\n): FoldableComposition2C1<F, G, E>\nexport declare function getFoldableComposition<F extends URIS2, G extends URIS>(\n  F: Foldable2<F>,\n  G: Foldable1<G>\n): FoldableComposition21<F, G>\nexport declare function getFoldableComposition<F extends URIS, G extends URIS2, E>(\n  F: Foldable1<F>,\n  G: Foldable2C<G, E>\n): FoldableComposition12C<F, G, E>\nexport declare function getFoldableComposition<F extends URIS, G extends URIS2>(\n  F: Foldable1<F>,\n  G: Foldable2<G>\n): FoldableComposition12<F, G>\nexport declare function getFoldableComposition<F extends URIS, G extends URIS>(\n  F: Foldable1<F>,\n  G: Foldable1<G>\n): FoldableComposition11<F, G>\nexport declare function getFoldableComposition<F, G>(F: Foldable<F>, G: Foldable<G>): FoldableComposition<F, G>\n```\n\nAdded in v2.0.0\n\n## ~~toArray~~\n\nUse [`toReadonlyArray`](#toreadonlyarray) instead\n\n**Signature**\n\n```ts\nexport declare const toArray: typeof toReadonlyArray\n```\n\nAdded in v2.8.0\n"
  },
  {
    "path": "docs/modules/FoldableWithIndex.ts.md",
    "content": "---\ntitle: FoldableWithIndex.ts\nnav_order: 34\nparent: Modules\n---\n\n## FoldableWithIndex overview\n\nA `Foldable` with an additional index.\nA `FoldableWithIndex` instance must be compatible with its `Foldable` instance\n\n```ts\nreduce(fa, b, f) = reduceWithIndex(fa, b, (_, b, a) => f(b, a))\nfoldMap(M)(fa, f) = foldMapWithIndex(M)(fa, (_, a) => f(a))\nreduceRight(fa, b, f) = reduceRightWithIndex(fa, b, (_, a, b) => f(a, b))\n```\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [FoldableWithIndex (interface)](#foldablewithindex-interface)\n  - [FoldableWithIndex1 (interface)](#foldablewithindex1-interface)\n  - [FoldableWithIndex2 (interface)](#foldablewithindex2-interface)\n  - [FoldableWithIndex2C (interface)](#foldablewithindex2c-interface)\n  - [FoldableWithIndex3 (interface)](#foldablewithindex3-interface)\n  - [FoldableWithIndex3C (interface)](#foldablewithindex3c-interface)\n  - [FoldableWithIndex4 (interface)](#foldablewithindex4-interface)\n- [utils](#utils)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n- [zone of death](#zone-of-death)\n  - [~~FoldableWithIndexComposition11~~ (interface)](#foldablewithindexcomposition11-interface)\n  - [~~FoldableWithIndexComposition12C~~ (interface)](#foldablewithindexcomposition12c-interface)\n  - [~~FoldableWithIndexComposition12~~ (interface)](#foldablewithindexcomposition12-interface)\n  - [~~FoldableWithIndexComposition21~~ (interface)](#foldablewithindexcomposition21-interface)\n  - [~~FoldableWithIndexComposition22C~~ (interface)](#foldablewithindexcomposition22c-interface)\n  - [~~FoldableWithIndexComposition22~~ (interface)](#foldablewithindexcomposition22-interface)\n  - [~~FoldableWithIndexComposition2C1~~ (interface)](#foldablewithindexcomposition2c1-interface)\n  - [~~FoldableWithIndexComposition~~ (interface)](#foldablewithindexcomposition-interface)\n  - [~~getFoldableWithIndexComposition~~](#getfoldablewithindexcomposition)\n\n---\n\n# model\n\n## FoldableWithIndex (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndex<F, I> extends Foldable<F> {\n  readonly reduceWithIndex: <A, B>(fa: HKT<F, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fa: HKT<F, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fa: HKT<F, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## FoldableWithIndex1 (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndex1<F extends URIS, I> extends Foldable1<F> {\n  readonly reduceWithIndex: <A, B>(fa: Kind<F, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fa: Kind<F, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fa: Kind<F, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## FoldableWithIndex2 (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndex2<F extends URIS2, I> extends Foldable2<F> {\n  readonly reduceWithIndex: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <E, A>(fa: Kind2<F, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## FoldableWithIndex2C (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndex2C<F extends URIS2, I, E> extends Foldable2C<F, E> {\n  readonly reduceWithIndex: <A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fa: Kind2<F, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## FoldableWithIndex3 (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndex3<F extends URIS3, I> extends Foldable3<F> {\n  readonly reduceWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <R, E, A>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## FoldableWithIndex3C (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndex3C<F extends URIS3, I, E> extends Foldable3C<F, E> {\n  readonly reduceWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <R, A>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.2.0\n\n## FoldableWithIndex4 (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndex4<F extends URIS4, I> extends Foldable4<F> {\n  readonly reduceWithIndex: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <S, R, E, A>(fa: Kind4<F, S, R, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## foldMapWithIndex\n\n`foldMapWithIndex` composition.\n\n**Signature**\n\n```ts\nexport declare function foldMapWithIndex<F extends URIS, I, G extends URIS, J>(\n  F: FoldableWithIndex1<F, I>,\n  G: FoldableWithIndex1<G, J>\n): <M>(M: Monoid<M>) => <A>(f: (ij: readonly [I, J], a: A) => M) => (fga: Kind<F, Kind<G, A>>) => M\nexport declare function foldMapWithIndex<F, I, G, J>(\n  F: FoldableWithIndex<F, I>,\n  G: FoldableWithIndex<G, J>\n): <M>(M: Monoid<M>) => <A>(f: (ij: readonly [I, J], a: A) => M) => (fga: HKT<F, HKT<G, A>>) => M\n```\n\nAdded in v2.10.0\n\n## reduceRightWithIndex\n\n`reduceRightWithIndex` composition.\n\n**Signature**\n\n```ts\nexport declare function reduceRightWithIndex<F extends URIS, I, G extends URIS, J>(\n  F: FoldableWithIndex1<F, I>,\n  G: FoldableWithIndex1<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], a: A, b: B) => B) => (fga: Kind<F, Kind<G, A>>) => B\nexport declare function reduceRightWithIndex<F, I, G, J>(\n  F: FoldableWithIndex<F, I>,\n  G: FoldableWithIndex<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], a: A, b: B) => B) => (fga: HKT<F, HKT<G, A>>) => B\n```\n\nAdded in v2.10.0\n\n## reduceWithIndex\n\n`reduceWithIndex` composition.\n\n**Signature**\n\n```ts\nexport declare function reduceWithIndex<F extends URIS, I, G extends URIS, J>(\n  F: FoldableWithIndex1<F, I>,\n  G: FoldableWithIndex1<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], b: B, a: A) => B) => (fga: Kind<F, Kind<G, A>>) => B\nexport declare function reduceWithIndex<F, I, G, J>(\n  F: FoldableWithIndex<F, I>,\n  G: FoldableWithIndex<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], b: B, a: A) => B) => (fga: HKT<F, HKT<G, A>>) => B\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~FoldableWithIndexComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndexComposition11<F extends URIS, FI, G extends URIS, GI>\n  extends FoldableComposition11<F, G> {\n  readonly reduceWithIndex: <A, B>(fga: Kind<F, Kind<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: Kind<F, Kind<G, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fga: Kind<F, Kind<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableWithIndexComposition12C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndexComposition12C<F extends URIS, FI, G extends URIS2, GI, E>\n  extends FoldableComposition12C<F, G, E> {\n  readonly reduceWithIndex: <A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableWithIndexComposition12~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndexComposition12<F extends URIS, FI, G extends URIS2, GI>\n  extends FoldableComposition12<F, G> {\n  readonly reduceWithIndex: <E, A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <E, A>(fga: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <E, A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableWithIndexComposition21~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndexComposition21<F extends URIS2, FI, G extends URIS, GI>\n  extends FoldableComposition21<F, G> {\n  readonly reduceWithIndex: <FE, A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(\n    M: Monoid<M>\n  ) => <FE, A>(fga: Kind2<F, FE, Kind<G, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <FE, A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableWithIndexComposition22C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndexComposition22C<F extends URIS2, FI, G extends URIS2, GI, E>\n  extends FoldableComposition22C<F, G, E> {\n  readonly reduceWithIndex: <FE, A, B>(fga: Kind2<F, FE, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(\n    M: Monoid<M>\n  ) => <FE, A>(fga: Kind2<F, FE, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <FE, A, B>(\n    fga: Kind2<F, FE, Kind2<G, E, A>>,\n    b: B,\n    f: (i: [FI, GI], a: A, b: B) => B\n  ) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableWithIndexComposition22~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndexComposition22<F extends URIS2, FI, G extends URIS2, GI>\n  extends FoldableComposition22<F, G> {\n  readonly reduceWithIndex: <FE, GE, A, B>(\n    fga: Kind2<F, FE, Kind2<G, GE, A>>,\n    b: B,\n    f: (i: [FI, GI], b: B, a: A) => B\n  ) => B\n  readonly foldMapWithIndex: <M>(\n    M: Monoid<M>\n  ) => <FE, GE, A>(fga: Kind2<F, FE, Kind2<G, GE, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <FE, GE, A, B>(\n    fga: Kind2<F, FE, Kind2<G, GE, A>>,\n    b: B,\n    f: (i: [FI, GI], a: A, b: B) => B\n  ) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableWithIndexComposition2C1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndexComposition2C1<F extends URIS2, FI, G extends URIS, GI, FE>\n  extends FoldableComposition2C1<F, G, FE> {\n  readonly reduceWithIndex: <A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: Kind2<F, FE, Kind<G, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~FoldableWithIndexComposition~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FoldableWithIndexComposition<F, FI, G, GI> extends FoldableComposition<F, G> {\n  readonly reduceWithIndex: <A, B>(fga: HKT<F, HKT<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: HKT<F, HKT<G, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fga: HKT<F, HKT<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~getFoldableWithIndexComposition~~\n\nUse\n\n- [reduceWithIndex](#reducewithindex)\n- [foldMapWithIndex](#foldmapwithindex)\n- [reduceRightWithIndex](#reducerightwithindex)\n\ninstead.\n\n**Signature**\n\n```ts\nexport declare function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI, E>(\n  F: FoldableWithIndex2<F, FI>,\n  G: FoldableWithIndex2C<G, GI, E>\n): FoldableWithIndexComposition22C<F, FI, G, GI, E>\nexport declare function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI>(\n  F: FoldableWithIndex2<F, FI>,\n  G: FoldableWithIndex2<G, GI>\n): FoldableWithIndexComposition22<F, FI, G, GI>\nexport declare function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS, GI, E>(\n  F: FoldableWithIndex2C<F, FI, E>,\n  G: FoldableWithIndex1<G, GI>\n): FoldableWithIndexComposition2C1<F, FI, G, GI, E>\nexport declare function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS, GI>(\n  F: FoldableWithIndex2<F, FI>,\n  G: FoldableWithIndex1<G, GI>\n): FoldableWithIndexComposition21<F, FI, G, GI>\nexport declare function getFoldableWithIndexComposition<F extends URIS, FI, G extends URIS2, GI>(\n  F: FoldableWithIndex1<F, FI>,\n  G: FoldableWithIndex2<G, GI>\n): FoldableWithIndexComposition12<F, FI, G, GI>\nexport declare function getFoldableWithIndexComposition<F extends URIS, FI, G extends URIS2, GI>(\n  F: FoldableWithIndex1<F, FI>,\n  G: FoldableWithIndex2<G, GI>\n): FoldableWithIndexComposition12<F, FI, G, GI>\nexport declare function getFoldableWithIndexComposition<F extends URIS, FI, G extends URIS, GI>(\n  F: FoldableWithIndex1<F, FI>,\n  G: FoldableWithIndex1<G, GI>\n): FoldableWithIndexComposition11<F, FI, G, GI>\nexport declare function getFoldableWithIndexComposition<F, FI, G, GI>(\n  F: FoldableWithIndex<F, FI>,\n  G: FoldableWithIndex<G, GI>\n): FoldableWithIndexComposition<F, FI, G, GI>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/FromEither.ts.md",
    "content": "---\ntitle: FromEither.ts\nnav_order: 35\nparent: Modules\n---\n\n## FromEither overview\n\nThe `FromEither` type class represents those data types which support errors.\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [fromOption](#fromoption)\n- [lifting](#lifting)\n  - [fromPredicate](#frompredicate)\n- [model](#model)\n  - [FromEither (interface)](#fromeither-interface)\n  - [FromEither1 (interface)](#fromeither1-interface)\n  - [FromEither2 (interface)](#fromeither2-interface)\n  - [FromEither2C (interface)](#fromeither2c-interface)\n  - [FromEither3 (interface)](#fromeither3-interface)\n  - [FromEither3C (interface)](#fromeither3c-interface)\n  - [FromEither4 (interface)](#fromeither4-interface)\n- [utils](#utils)\n  - [chainEitherK](#chaineitherk)\n  - [chainFirstEitherK](#chainfirsteitherk)\n  - [chainOptionK](#chainoptionk)\n  - [filterOrElse](#filterorelse)\n  - [fromEitherK](#fromeitherk)\n  - [fromOptionK](#fromoptionk)\n\n---\n\n# constructors\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare function fromOption<F extends URIS4>(\n  F: FromEither4<F>\n): <E>(onNone: LazyArg<E>) => <A, S, R>(fa: Option<A>) => Kind4<F, S, R, E, A>\nexport declare function fromOption<F extends URIS3>(\n  F: FromEither3<F>\n): <E>(onNone: LazyArg<E>) => <A, R>(fa: Option<A>) => Kind3<F, R, E, A>\nexport declare function fromOption<F extends URIS3, E>(\n  F: FromEither3C<F, E>\n): (onNone: LazyArg<E>) => <A, R>(fa: Option<A>) => Kind3<F, R, E, A>\nexport declare function fromOption<F extends URIS2>(\n  F: FromEither2<F>\n): <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => Kind2<F, E, A>\nexport declare function fromOption<F extends URIS2, E>(\n  F: FromEither2C<F, E>\n): (onNone: LazyArg<E>) => <A>(fa: Option<A>) => Kind2<F, E, A>\nexport declare function fromOption<F>(F: FromEither<F>): <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => HKT2<F, E, A>\n```\n\nAdded in v2.10.0\n\n# lifting\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare function fromPredicate<F extends URIS4>(\n  F: FromEither4<F>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(b: B) => Kind4<F, S, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, A>\n}\nexport declare function fromPredicate<F extends URIS3>(\n  F: FromEither3<F>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(b: B) => Kind3<F, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>\n}\nexport declare function fromPredicate<F extends URIS3, E>(\n  F: FromEither3C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(b: B) => Kind3<F, R, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>\n}\nexport declare function fromPredicate<F extends URIS2>(\n  F: FromEither2<F>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => Kind2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>\n}\nexport declare function fromPredicate<F extends URIS2, E>(\n  F: FromEither2C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => Kind2<F, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>\n}\nexport declare function fromPredicate<F>(F: FromEither<F>): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => HKT2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => HKT2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => HKT2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n# model\n\n## FromEither (interface)\n\n**Signature**\n\n```ts\nexport interface FromEither<F> {\n  readonly URI: F\n  readonly fromEither: <E, A>(e: Either<E, A>) => HKT2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromEither1 (interface)\n\n**Signature**\n\n```ts\nexport interface FromEither1<F extends URIS> {\n  readonly URI: F\n  readonly fromEither: <A>(fa: Either<unknown, A>) => Kind<F, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromEither2 (interface)\n\n**Signature**\n\n```ts\nexport interface FromEither2<F extends URIS2> {\n  readonly URI: F\n  readonly fromEither: <E, A>(fa: Either<E, A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromEither2C (interface)\n\n**Signature**\n\n```ts\nexport interface FromEither2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromEither: <A>(fa: Either<E, A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromEither3 (interface)\n\n**Signature**\n\n```ts\nexport interface FromEither3<F extends URIS3> {\n  readonly URI: F\n  readonly fromEither: <E, A, R>(fa: Either<E, A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromEither3C (interface)\n\n**Signature**\n\n```ts\nexport interface FromEither3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromEither: <A, R>(fa: Either<E, A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromEither4 (interface)\n\n**Signature**\n\n```ts\nexport interface FromEither4<F extends URIS4> {\n  readonly URI: F\n  readonly fromEither: <E, A, S, R>(fa: Either<E, A>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n# utils\n\n## chainEitherK\n\n**Signature**\n\n```ts\nexport declare function chainEitherK<M extends URIS4>(\n  F: FromEither4<M>,\n  M: Chain4<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => <S, R>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport declare function chainEitherK<M extends URIS3>(\n  F: FromEither3<M>,\n  M: Chain3<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport declare function chainEitherK<M extends URIS3, E>(\n  F: FromEither3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport declare function chainEitherK<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, B>\nexport declare function chainEitherK<M extends URIS2, E>(\n  F: FromEither2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, B>\nexport declare function chainEitherK<M extends URIS>(\n  F: FromEither1<M>,\n  M: Chain1<M>\n): <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Kind<M, A>) => Kind<M, B>\nexport declare function chainEitherK<M>(\n  F: FromEither<M>,\n  M: Chain<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: HKT2<M, E, A>) => HKT2<M, E, B>\n```\n\nAdded in v2.10.0\n\n## chainFirstEitherK\n\n**Signature**\n\n```ts\nexport declare function chainFirstEitherK<M extends URIS4>(\n  F: FromEither4<M>,\n  M: Chain4<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => <S, R>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport declare function chainFirstEitherK<M extends URIS3>(\n  F: FromEither3<M>,\n  M: Chain3<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirstEitherK<M extends URIS3, E>(\n  F: FromEither3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirstEitherK<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, A>\nexport declare function chainFirstEitherK<M extends URIS2, E>(\n  F: FromEither2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, A>\nexport declare function chainFirstEitherK<M extends URIS>(\n  F: FromEither1<M>,\n  M: Chain1<M>\n): <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Kind<M, A>) => Kind<M, A>\nexport declare function chainFirstEitherK<M>(\n  F: FromEither<M>,\n  M: Chain<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: HKT2<M, E, A>) => HKT2<M, E, A>\n```\n\nAdded in v2.12.0\n\n## chainOptionK\n\n**Signature**\n\n```ts\nexport declare function chainOptionK<F extends URIS4>(\n  F: FromEither4<F>,\n  M: Chain4<F>\n): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => <S, R>(ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport declare function chainOptionK<F extends URIS3>(\n  F: FromEither3<F>,\n  M: Chain3<F>\n): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function chainOptionK<F extends URIS3, E>(\n  F: FromEither3C<F, E>,\n  M: Chain3C<F, E>\n): (onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function chainOptionK<F extends URIS2>(\n  F: FromEither2<F>,\n  M: Chain2<F>\n): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function chainOptionK<F extends URIS2, E>(\n  F: FromEither2C<F, E>,\n  M: Chain2C<F, E>\n): (onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function chainOptionK<F>(\n  F: FromEither<F>,\n  M: Chain<F>\n): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: HKT2<F, E, A>) => HKT2<F, E, B>\n```\n\nAdded in v2.10.0\n\n## filterOrElse\n\n**Signature**\n\n```ts\nexport declare function filterOrElse<M extends URIS4>(\n  F: FromEither4<M>,\n  M: Chain4<M>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(\n    ma: Kind4<M, S, R, E, A>\n  ) => Kind4<M, S, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(\n    mb: Kind4<M, S, R, E, B>\n  ) => Kind4<M, S, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\n}\nexport declare function filterOrElse<M extends URIS3>(\n  F: FromEither3<M>,\n  M: Chain3<M>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n    ma: Kind3<M, R, E, A>\n  ) => Kind3<M, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(mb: Kind3<M, R, E, B>) => Kind3<M, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\n}\nexport declare function filterOrElse<M extends URIS3, E>(\n  F: FromEither3C<M, E>,\n  M: Chain3C<M, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(mb: Kind3<M, R, E, B>) => Kind3<M, R, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\n}\nexport declare function filterOrElse<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (self: Kind2<M, E, A>) => Kind2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(self: Kind2<M, E, B>) => Kind2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (self: Kind2<M, E, A>) => Kind2<M, E, A>\n}\nexport declare function filterOrElse<M extends URIS2, E>(\n  F: FromEither2C<M, E>,\n  M: Chain2C<M, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<M, E, A>) => Kind2<M, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: Kind2<M, E, B>) => Kind2<M, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<M, E, A>) => Kind2<M, E, A>\n}\nexport declare function filterOrElse<M extends URIS2>(\n  F: FromEither<M>,\n  M: Chain<M>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: HKT2<M, E, A>) => HKT2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: HKT2<M, E, B>) => HKT2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: HKT2<M, E, A>) => HKT2<M, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare function fromEitherK<F extends URIS4>(\n  F: FromEither4<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => <S, R>(...a: A) => Kind4<F, S, R, E, B>\nexport declare function fromEitherK<F extends URIS3>(\n  F: FromEither3<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromEitherK<F extends URIS3, E>(\n  F: FromEither3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Either<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromEitherK<F extends URIS2>(\n  F: FromEither2<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => (...a: A) => Kind2<F, E, B>\nexport declare function fromEitherK<F extends URIS2, E>(\n  F: FromEither2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Either<E, B>) => (...a: A) => Kind2<F, E, B>\nexport declare function fromEitherK<F extends URIS>(\n  F: FromEither1<F>\n): <E, A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Either<E, B>) => (...a: A) => Kind<F, B>\nexport declare function fromEitherK<F>(\n  F: FromEither<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => (...a: A) => HKT2<F, E, B>\n```\n\nAdded in v2.10.0\n\n## fromOptionK\n\n**Signature**\n\n```ts\nexport declare function fromOptionK<F extends URIS4>(\n  F: FromEither4<F>\n): <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <S, R>(...a: A) => Kind4<F, S, R, E, B>\nexport declare function fromOptionK<F extends URIS3>(\n  F: FromEither3<F>\n): <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromOptionK<F extends URIS3, E>(\n  F: FromEither3C<F, E>\n): (\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromOptionK<F extends URIS2>(\n  F: FromEither2<F>\n): <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind2<F, E, B>\nexport declare function fromOptionK<F extends URIS2, E>(\n  F: FromEither2C<F, E>\n): (\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind2<F, E, B>\nexport declare function fromOptionK<F>(\n  F: FromEither<F>\n): <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => HKT2<F, E, B>\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/FromIO.ts.md",
    "content": "---\ntitle: FromIO.ts\nnav_order: 36\nparent: Modules\n---\n\n## FromIO overview\n\nLift a computation from the `IO` monad\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [FromIO (interface)](#fromio-interface)\n  - [FromIO1 (interface)](#fromio1-interface)\n  - [FromIO2 (interface)](#fromio2-interface)\n  - [FromIO2C (interface)](#fromio2c-interface)\n  - [FromIO3 (interface)](#fromio3-interface)\n  - [FromIO3C (interface)](#fromio3c-interface)\n  - [FromIO4 (interface)](#fromio4-interface)\n- [utils](#utils)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainIOK](#chainiok)\n  - [fromIOK](#fromiok)\n\n---\n\n# model\n\n## FromIO (interface)\n\n**Signature**\n\n```ts\nexport interface FromIO<F> {\n  readonly URI: F\n  readonly fromIO: <A>(fa: IO<A>) => HKT<F, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromIO1 (interface)\n\n**Signature**\n\n```ts\nexport interface FromIO1<F extends URIS> {\n  readonly URI: F\n  readonly fromIO: <A>(fa: IO<A>) => Kind<F, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromIO2 (interface)\n\n**Signature**\n\n```ts\nexport interface FromIO2<F extends URIS2> {\n  readonly URI: F\n  readonly fromIO: <A, E>(fa: IO<A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromIO2C (interface)\n\n**Signature**\n\n```ts\nexport interface FromIO2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromIO: <A>(fa: IO<A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromIO3 (interface)\n\n**Signature**\n\n```ts\nexport interface FromIO3<F extends URIS3> {\n  readonly URI: F\n  readonly fromIO: <A, R, E>(fa: IO<A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromIO3C (interface)\n\n**Signature**\n\n```ts\nexport interface FromIO3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromIO: <A, R>(fa: IO<A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromIO4 (interface)\n\n**Signature**\n\n```ts\nexport interface FromIO4<F extends URIS4> {\n  readonly URI: F\n  readonly fromIO: <A, S, R, E>(fa: IO<A>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n# utils\n\n## chainFirstIOK\n\n**Signature**\n\n```ts\nexport declare function chainFirstIOK<M extends URIS4>(\n  F: FromIO4<M>,\n  M: Chain4<M>\n): <A, B>(f: (a: A) => IO<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport declare function chainFirstIOK<M extends URIS3>(\n  F: FromIO3<M>,\n  M: Chain3<M>\n): <A, B>(f: (a: A) => IO<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirstIOK<M extends URIS3, E>(\n  F: FromIO3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => IO<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirstIOK<M extends URIS2>(\n  F: FromIO2<M>,\n  M: Chain2<M>\n): <A, B>(f: (a: A) => IO<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport declare function chainFirstIOK<M extends URIS2, E>(\n  F: FromIO2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => IO<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport declare function chainFirstIOK<M extends URIS>(\n  F: FromIO1<M>,\n  M: Chain1<M>\n): <A, B>(f: (a: A) => IO<B>) => (first: Kind<M, A>) => Kind<M, A>\nexport declare function chainFirstIOK<M>(\n  F: FromIO<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => IO<B>) => (first: HKT<M, A>) => HKT<M, A>\n```\n\nAdded in v2.10.0\n\n## chainIOK\n\n**Signature**\n\n```ts\nexport declare function chainIOK<M extends URIS4>(\n  F: FromIO4<M>,\n  M: Chain4<M>\n): <A, B>(f: (a: A) => IO<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport declare function chainIOK<M extends URIS3>(\n  F: FromIO3<M>,\n  M: Chain3<M>\n): <A, B>(f: (a: A) => IO<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport declare function chainIOK<M extends URIS3, E>(\n  F: FromIO3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => IO<B>) => <R>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport declare function chainIOK<M extends URIS2>(\n  F: FromIO2<M>,\n  M: Chain2<M>\n): <A, B>(f: (a: A) => IO<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, B>\nexport declare function chainIOK<M extends URIS2, E>(\n  F: FromIO2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => IO<B>) => (first: Kind2<M, E, A>) => Kind2<M, E, B>\nexport declare function chainIOK<M extends URIS>(\n  F: FromIO1<M>,\n  M: Chain1<M>\n): <A, B>(f: (a: A) => IO<B>) => (first: Kind<M, A>) => Kind<M, B>\nexport declare function chainIOK<M>(\n  F: FromIO<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => IO<B>) => (first: HKT<M, A>) => HKT<M, B>\n```\n\nAdded in v2.10.0\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare function fromIOK<F extends URIS4>(\n  F: FromIO4<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <S, R, E>(...a: A) => Kind4<F, S, R, E, B>\nexport declare function fromIOK<F extends URIS3>(\n  F: FromIO3<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <R, E>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromIOK<F extends URIS3, E>(\n  F: FromIO3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromIOK<F extends URIS2>(\n  F: FromIO2<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <E>(...a: A) => Kind2<F, E, B>\nexport declare function fromIOK<F extends URIS2, E>(\n  F: FromIO2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => Kind2<F, E, B>\nexport declare function fromIOK<F extends URIS>(\n  F: FromIO1<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => Kind<F, B>\nexport declare function fromIOK<F>(\n  F: FromIO<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => HKT<F, B>\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/FromReader.ts.md",
    "content": "---\ntitle: FromReader.ts\nnav_order: 37\nparent: Modules\n---\n\n## FromReader overview\n\nLift a computation from the `Reader` monad.\n\nAdded in v2.11.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [ask](#ask)\n  - [asks](#asks)\n- [model](#model)\n  - [FromReader (interface)](#fromreader-interface)\n  - [FromReader2 (interface)](#fromreader2-interface)\n  - [FromReader3 (interface)](#fromreader3-interface)\n  - [FromReader3C (interface)](#fromreader3c-interface)\n  - [FromReader4 (interface)](#fromreader4-interface)\n- [utils](#utils)\n  - [chainFirstReaderK](#chainfirstreaderk)\n  - [chainReaderK](#chainreaderk)\n  - [fromReaderK](#fromreaderk)\n\n---\n\n# constructors\n\n## ask\n\n**Signature**\n\n```ts\nexport declare function ask<F extends URIS4>(F: FromReader4<F>): <S, R, E>() => Kind4<F, S, R, E, R>\nexport declare function ask<F extends URIS3>(F: FromReader3<F>): <R, E>() => Kind3<F, R, E, R>\nexport declare function ask<F extends URIS3, E>(F: FromReader3C<F, E>): <R>() => Kind3<F, R, E, R>\nexport declare function ask<F extends URIS2>(F: FromReader2<F>): <R>() => Kind2<F, R, R>\nexport declare function ask<F>(F: FromReader<F>): <R>() => HKT2<F, R, R>\n```\n\nAdded in v2.11.0\n\n## asks\n\n**Signature**\n\n```ts\nexport declare function asks<F extends URIS4>(F: FromReader4<F>): <R, A, S, E>(f: (r: R) => A) => Kind4<F, S, R, E, A>\nexport declare function asks<F extends URIS3>(F: FromReader3<F>): <R, A, E>(f: (r: R) => A) => Kind3<F, R, E, A>\nexport declare function asks<F extends URIS3, E>(F: FromReader3C<F, E>): <R, A>(f: (r: R) => A) => Kind3<F, R, E, A>\nexport declare function asks<F extends URIS2>(F: FromReader2<F>): <R, A>(f: (r: R) => A) => Kind2<F, R, A>\nexport declare function asks<F>(F: FromReader<F>): <R, A>(f: (r: R) => A) => HKT2<F, R, A>\n```\n\nAdded in v2.11.0\n\n# model\n\n## FromReader (interface)\n\n**Signature**\n\n```ts\nexport interface FromReader<F> {\n  readonly URI: F\n  readonly fromReader: <R, A>(fa: Reader<R, A>) => HKT2<F, R, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromReader2 (interface)\n\n**Signature**\n\n```ts\nexport interface FromReader2<F extends URIS2> {\n  readonly URI: F\n  readonly fromReader: <E, A>(fa: Reader<E, A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromReader3 (interface)\n\n**Signature**\n\n```ts\nexport interface FromReader3<F extends URIS3> {\n  readonly URI: F\n  readonly fromReader: <R, A, E>(fa: Reader<R, A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromReader3C (interface)\n\n**Signature**\n\n```ts\nexport interface FromReader3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromReader: <R, A>(fa: Reader<R, A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromReader4 (interface)\n\n**Signature**\n\n```ts\nexport interface FromReader4<F extends URIS4> {\n  readonly URI: F\n  readonly fromReader: <R, A, S, E>(fa: Reader<R, A>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n# utils\n\n## chainFirstReaderK\n\n**Signature**\n\n```ts\nexport declare function chainFirstReaderK<M extends URIS4>(\n  F: FromReader4<M>,\n  M: Chain4<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => <S, E>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport declare function chainFirstReaderK<M extends URIS3>(\n  F: FromReader3<M>,\n  M: Chain3<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => <E>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirstReaderK<M extends URIS3, E>(\n  F: FromReader3C<M, E>,\n  M: Chain3C<M, E>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirstReaderK<M extends URIS2>(\n  F: FromReader2<M>,\n  M: Chain2<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind2<M, R, A>) => Kind2<M, R, A>\nexport declare function chainFirstReaderK<M>(\n  F: FromReader<M>,\n  M: Chain<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: HKT2<M, R, A>) => HKT2<M, R, A>\n```\n\nAdded in v2.11.0\n\n## chainReaderK\n\n**Signature**\n\n```ts\nexport declare function chainReaderK<M extends URIS4>(\n  F: FromReader4<M>,\n  M: Chain4<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => <S, E>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport declare function chainReaderK<M extends URIS3>(\n  F: FromReader3<M>,\n  M: Chain3<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => <E>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport declare function chainReaderK<M extends URIS3, E>(\n  F: FromReader3C<M, E>,\n  M: Chain3C<M, E>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport declare function chainReaderK<M extends URIS2>(\n  F: FromReader2<M>,\n  M: Chain2<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind2<M, R, A>) => Kind2<M, R, B>\nexport declare function chainReaderK<M>(\n  F: FromReader<M>,\n  M: Chain<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: HKT2<M, R, A>) => HKT2<M, R, B>\n```\n\nAdded in v2.11.0\n\n## fromReaderK\n\n**Signature**\n\n```ts\nexport declare function fromReaderK<F extends URIS4>(\n  F: FromReader4<F>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => <S, E>(...a: A) => Kind4<F, S, R, E, B>\nexport declare function fromReaderK<F extends URIS3>(\n  F: FromReader3<F>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => <E>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromReaderK<F extends URIS3, E>(\n  F: FromReader3C<F, E>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => Kind3<F, R, E, B>\nexport declare function fromReaderK<F extends URIS2>(\n  F: FromReader2<F>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => Kind2<F, R, B>\nexport declare function fromReaderK<F>(\n  F: FromReader<F>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => HKT2<F, R, B>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/FromState.ts.md",
    "content": "---\ntitle: FromState.ts\nnav_order: 38\nparent: Modules\n---\n\n## FromState overview\n\nLift a computation from the `State` monad.\n\nAdded in v2.11.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [get](#get)\n  - [gets](#gets)\n  - [modify](#modify)\n  - [put](#put)\n- [model](#model)\n  - [FromState (interface)](#fromstate-interface)\n  - [FromState2 (interface)](#fromstate2-interface)\n  - [FromState3 (interface)](#fromstate3-interface)\n  - [FromState3C (interface)](#fromstate3c-interface)\n  - [FromState4 (interface)](#fromstate4-interface)\n- [utils](#utils)\n  - [chainStateK](#chainstatek)\n  - [fromStateK](#fromstatek)\n\n---\n\n# constructors\n\n## get\n\n**Signature**\n\n```ts\nexport declare function get<F extends URIS4>(F: FromState4<F>): <S, R, E>() => Kind4<F, S, R, E, S>\nexport declare function get<F extends URIS3>(F: FromState3<F>): <S, E>() => Kind3<F, S, E, S>\nexport declare function get<F extends URIS3, E>(F: FromState3C<F, E>): <S>() => Kind3<F, S, E, S>\nexport declare function get<F extends URIS2>(F: FromState2<F>): <S>() => Kind2<F, S, S>\nexport declare function get<F>(F: FromState<F>): <S>() => HKT2<F, S, S>\n```\n\nAdded in v2.11.0\n\n## gets\n\n**Signature**\n\n```ts\nexport declare function gets<F extends URIS4>(F: FromState4<F>): <S, R, E, A>(f: (s: S) => A) => Kind4<F, S, R, E, A>\nexport declare function gets<F extends URIS3>(F: FromState3<F>): <S, E, A>(f: (s: S) => A) => Kind3<F, S, E, A>\nexport declare function gets<F extends URIS3, E>(F: FromState3C<F, E>): <S, A>(f: (s: S) => A) => Kind3<F, S, E, A>\nexport declare function gets<F extends URIS2>(F: FromState2<F>): <S, A>(f: (s: S) => A) => Kind2<F, S, A>\nexport declare function gets<F>(F: FromState<F>): <S, A>(f: (s: S) => A) => HKT2<F, S, A>\n```\n\nAdded in v2.11.0\n\n## modify\n\n**Signature**\n\n```ts\nexport declare function modify<F extends URIS4>(\n  F: FromState4<F>\n): <S, R, E>(f: Endomorphism<S>) => Kind4<F, S, R, E, void>\nexport declare function modify<F extends URIS3>(F: FromState3<F>): <S, E>(f: Endomorphism<S>) => Kind3<F, S, E, void>\nexport declare function modify<F extends URIS3, E>(\n  F: FromState3C<F, E>\n): <S>(f: Endomorphism<S>) => Kind3<F, S, E, void>\nexport declare function modify<F extends URIS2>(F: FromState2<F>): <S>(f: Endomorphism<S>) => Kind2<F, S, void>\nexport declare function modify<F>(F: FromState<F>): <S>(f: Endomorphism<S>) => HKT2<F, S, void>\n```\n\nAdded in v2.11.0\n\n## put\n\n**Signature**\n\n```ts\nexport declare function put<F extends URIS4>(F: FromState4<F>): <S, R, E>(s: S) => Kind4<F, S, R, E, void>\nexport declare function put<F extends URIS3>(F: FromState3<F>): <S, E>(s: S) => Kind3<F, S, E, void>\nexport declare function put<F extends URIS3, E>(F: FromState3C<F, E>): <S>(s: S) => Kind3<F, S, E, void>\nexport declare function put<F extends URIS2>(F: FromState2<F>): <S>(s: S) => Kind2<F, S, void>\nexport declare function put<F>(F: FromState<F>): <S>(s: S) => HKT2<F, S, void>\n```\n\nAdded in v2.11.0\n\n# model\n\n## FromState (interface)\n\n**Signature**\n\n```ts\nexport interface FromState<F> {\n  readonly URI: F\n  readonly fromState: <S, A>(fa: State<S, A>) => HKT2<F, S, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromState2 (interface)\n\n**Signature**\n\n```ts\nexport interface FromState2<F extends URIS2> {\n  readonly URI: F\n  readonly fromState: <S, A>(fa: State<S, A>) => Kind2<F, S, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromState3 (interface)\n\n**Signature**\n\n```ts\nexport interface FromState3<F extends URIS3> {\n  readonly URI: F\n  readonly fromState: <S, A, E>(fa: State<S, A>) => Kind3<F, S, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromState3C (interface)\n\n**Signature**\n\n```ts\nexport interface FromState3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromState: <S, A>(fa: State<S, A>) => Kind3<F, S, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromState4 (interface)\n\n**Signature**\n\n```ts\nexport interface FromState4<F extends URIS4> {\n  readonly URI: F\n  readonly fromState: <S, A, R, E>(fa: State<S, A>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n# utils\n\n## chainStateK\n\n**Signature**\n\n```ts\nexport declare function chainStateK<M extends URIS4>(\n  F: FromState4<M>,\n  M: Chain4<M>\n): <A, S, B>(f: (a: A) => State<S, B>) => <R, E>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport declare function chainStateK<M extends URIS3>(\n  F: FromState3<M>,\n  M: Chain3<M>\n): <A, S, B>(f: (a: A) => State<S, B>) => <E>(ma: Kind3<M, S, E, A>) => Kind3<M, S, E, B>\nexport declare function chainStateK<M extends URIS2>(\n  F: FromState2<M>,\n  M: Chain2<M>\n): <A, S, B>(f: (a: A) => State<S, B>) => (ma: Kind2<M, S, A>) => Kind2<M, S, B>\nexport declare function chainStateK<M>(\n  F: FromState<M>,\n  M: Chain<M>\n): <A, S, B>(f: (a: A) => State<S, B>) => (ma: HKT2<M, S, A>) => HKT2<M, S, B>\n```\n\nAdded in v2.11.0\n\n## fromStateK\n\n**Signature**\n\n```ts\nexport declare function fromStateK<F extends URIS4>(\n  F: FromState4<F>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => <R, E>(...a: A) => Kind4<F, S, R, E, B>\nexport declare function fromStateK<F extends URIS3>(\n  F: FromState3<F>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => <E>(...a: A) => Kind3<F, S, E, B>\nexport declare function fromStateK<F extends URIS3, E>(\n  F: FromState3C<F, E>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => Kind3<F, S, E, B>\nexport declare function fromStateK<F extends URIS2>(\n  F: FromState2<F>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => Kind2<F, S, B>\nexport declare function fromStateK<F>(\n  F: FromState<F>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => HKT2<F, S, B>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/FromTask.ts.md",
    "content": "---\ntitle: FromTask.ts\nnav_order: 39\nparent: Modules\n---\n\n## FromTask overview\n\nLift a computation from the `Task` monad\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [FromTask (interface)](#fromtask-interface)\n  - [FromTask1 (interface)](#fromtask1-interface)\n  - [FromTask2 (interface)](#fromtask2-interface)\n  - [FromTask2C (interface)](#fromtask2c-interface)\n  - [FromTask3 (interface)](#fromtask3-interface)\n  - [FromTask3C (interface)](#fromtask3c-interface)\n  - [FromTask4 (interface)](#fromtask4-interface)\n- [utils](#utils)\n  - [chainFirstTaskK](#chainfirsttaskk)\n  - [chainTaskK](#chaintaskk)\n  - [fromTaskK](#fromtaskk)\n\n---\n\n# model\n\n## FromTask (interface)\n\n**Signature**\n\n```ts\nexport interface FromTask<F> extends FromIO<F> {\n  readonly fromTask: <A>(fa: Task<A>) => HKT<F, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromTask1 (interface)\n\n**Signature**\n\n```ts\nexport interface FromTask1<F extends URIS> extends FromIO1<F> {\n  readonly fromTask: <A>(fa: Task<A>) => Kind<F, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromTask2 (interface)\n\n**Signature**\n\n```ts\nexport interface FromTask2<F extends URIS2> extends FromIO2<F> {\n  readonly fromTask: <A, E>(fa: Task<A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromTask2C (interface)\n\n**Signature**\n\n```ts\nexport interface FromTask2C<F extends URIS2, E> extends FromIO2C<F, E> {\n  readonly fromTask: <A>(fa: Task<A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromTask3 (interface)\n\n**Signature**\n\n```ts\nexport interface FromTask3<F extends URIS3> extends FromIO3<F> {\n  readonly fromTask: <A, R, E>(fa: Task<A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromTask3C (interface)\n\n**Signature**\n\n```ts\nexport interface FromTask3C<F extends URIS3, E> extends FromIO3C<F, E> {\n  readonly fromTask: <A, R>(fa: Task<A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## FromTask4 (interface)\n\n**Signature**\n\n```ts\nexport interface FromTask4<F extends URIS4> extends FromIO4<F> {\n  readonly fromTask: <A, S, R, E>(fa: Task<A>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n# utils\n\n## chainFirstTaskK\n\n**Signature**\n\n```ts\nexport declare function chainFirstTaskK<M extends URIS4>(\n  F: FromTask4<M>,\n  M: Chain4<M>\n): <A, B>(f: (a: A) => Task<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport declare function chainFirstTaskK<M extends URIS3>(\n  F: FromTask3<M>,\n  M: Chain3<M>\n): <A, B>(f: (a: A) => Task<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirstTaskK<M extends URIS3, E>(\n  F: FromTask3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => Task<B>) => <R>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport declare function chainFirstTaskK<M extends URIS2>(\n  F: FromTask2<M>,\n  M: Chain2<M>\n): <A, B>(f: (a: A) => Task<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport declare function chainFirstTaskK<M extends URIS2, E>(\n  F: FromTask2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => Task<B>) => (first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport declare function chainFirstTaskK<M extends URIS>(\n  F: FromTask1<M>,\n  M: Chain1<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: Kind<M, A>) => Kind<M, A>\nexport declare function chainFirstTaskK<M>(\n  F: FromTask<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: HKT<M, A>) => HKT<M, A>\n```\n\nAdded in v2.10.0\n\n## chainTaskK\n\n**Signature**\n\n```ts\nexport declare function chainTaskK<M extends URIS4>(\n  F: FromTask4<M>,\n  M: Chain4<M>\n): <A, B>(f: (a: A) => Task<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport declare function chainTaskK<M extends URIS3>(\n  F: FromTask3<M>,\n  M: Chain3<M>\n): <A, B>(f: (a: A) => Task<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport declare function chainTaskK<M extends URIS3, E>(\n  F: FromTask3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => Task<B>) => <R>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport declare function chainTaskK<M extends URIS2>(\n  F: FromTask2<M>,\n  M: Chain2<M>\n): <A, B>(f: (a: A) => Task<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, B>\nexport declare function chainTaskK<M extends URIS2, E>(\n  F: FromTask2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => Task<B>) => (first: Kind2<M, E, A>) => Kind2<M, E, B>\nexport declare function chainTaskK<M extends URIS>(\n  F: FromTask1<M>,\n  M: Chain1<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: Kind<M, A>) => Kind<M, B>\nexport declare function chainTaskK<M>(\n  F: FromTask<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: HKT<M, A>) => HKT<M, B>\n```\n\nAdded in v2.10.0\n\n## fromTaskK\n\n**Signature**\n\n```ts\nexport declare function fromTaskK<F extends URIS4>(\n  F: FromTask4<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <S, R, E>(...a: A) => Kind4<F, S, R, E, B>\nexport declare function fromTaskK<F extends URIS3>(\n  F: FromTask3<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <R, E>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromTaskK<F extends URIS3, E>(\n  F: FromTask3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromTaskK<F extends URIS2>(\n  F: FromTask2<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <E>(...a: A) => Kind2<F, E, B>\nexport declare function fromTaskK<F extends URIS2, E>(\n  F: FromTask2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => Kind2<F, E, B>\nexport declare function fromTaskK<F extends URIS>(\n  F: FromTask1<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => Kind<F, B>\nexport declare function fromTaskK<F>(\n  F: FromTask<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => HKT<F, B>\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/FromThese.ts.md",
    "content": "---\ntitle: FromThese.ts\nnav_order: 40\nparent: Modules\n---\n\n## FromThese overview\n\nThe `FromThese` type class represents those data types which support errors and warnings.\n\nAdded in v2.11.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [FromThese (interface)](#fromthese-interface)\n  - [FromThese2 (interface)](#fromthese2-interface)\n  - [FromThese2C (interface)](#fromthese2c-interface)\n  - [FromThese3 (interface)](#fromthese3-interface)\n  - [FromThese3C (interface)](#fromthese3c-interface)\n  - [FromThese4 (interface)](#fromthese4-interface)\n- [utils](#utils)\n  - [fromTheseK](#fromthesek)\n\n---\n\n# model\n\n## FromThese (interface)\n\n**Signature**\n\n```ts\nexport interface FromThese<F> {\n  readonly URI: F\n  readonly fromThese: <E, A>(e: These<E, A>) => HKT2<F, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromThese2 (interface)\n\n**Signature**\n\n```ts\nexport interface FromThese2<F extends URIS2> {\n  readonly URI: F\n  readonly fromThese: <E, A>(fa: These<E, A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromThese2C (interface)\n\n**Signature**\n\n```ts\nexport interface FromThese2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromThese: <A>(fa: These<E, A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromThese3 (interface)\n\n**Signature**\n\n```ts\nexport interface FromThese3<F extends URIS3> {\n  readonly URI: F\n  readonly fromThese: <E, A, R>(fa: These<E, A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromThese3C (interface)\n\n**Signature**\n\n```ts\nexport interface FromThese3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromThese: <A, R>(fa: These<E, A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## FromThese4 (interface)\n\n**Signature**\n\n```ts\nexport interface FromThese4<F extends URIS4> {\n  readonly URI: F\n  readonly fromThese: <E, A, S, R>(fa: These<E, A>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n# utils\n\n## fromTheseK\n\n**Signature**\n\n```ts\nexport declare function fromTheseK<F extends URIS4>(\n  F: FromThese4<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => <S, R>(...a: A) => Kind4<F, S, R, E, B>\nexport declare function fromTheseK<F extends URIS3>(\n  F: FromThese3<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromTheseK<F extends URIS3, E>(\n  F: FromThese3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => These<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport declare function fromTheseK<F extends URIS2>(\n  F: FromThese2<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => (...a: A) => Kind2<F, E, B>\nexport declare function fromTheseK<F extends URIS2, E>(\n  F: FromThese2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => These<E, B>) => (...a: A) => Kind2<F, E, B>\nexport declare function fromTheseK<F>(\n  F: FromThese<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => (...a: A) => HKT2<F, E, B>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/Functor.ts.md",
    "content": "---\ntitle: Functor.ts\nnav_order: 42\nparent: Modules\n---\n\n## Functor overview\n\nA `Functor` is a type constructor which supports a mapping operation `map`.\n\n`map` can be used to turn functions `a -> b` into functions `f a -> f b` whose argument and return types use the type\nconstructor `f` to represent some computational context.\n\nInstances must satisfy the following laws:\n\n1. Identity: `F.map(fa, a => a) <-> fa`\n2. Composition: `F.map(fa, a => bc(ab(a))) <-> F.map(F.map(fa, ab), bc)`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [mapping](#mapping)\n  - [flap](#flap)\n- [model](#model)\n  - [Functor (interface)](#functor-interface)\n  - [Functor1 (interface)](#functor1-interface)\n  - [Functor2 (interface)](#functor2-interface)\n  - [Functor2C (interface)](#functor2c-interface)\n  - [Functor3 (interface)](#functor3-interface)\n  - [Functor3C (interface)](#functor3c-interface)\n  - [Functor4 (interface)](#functor4-interface)\n- [utils](#utils)\n  - [bindTo](#bindto)\n  - [let](#let)\n  - [let\\_](#let_)\n  - [map](#map)\n- [zone of death](#zone-of-death)\n  - [~~FunctorComposition11~~ (interface)](#functorcomposition11-interface)\n  - [~~FunctorComposition12C~~ (interface)](#functorcomposition12c-interface)\n  - [~~FunctorComposition12~~ (interface)](#functorcomposition12-interface)\n  - [~~FunctorComposition21~~ (interface)](#functorcomposition21-interface)\n  - [~~FunctorComposition22C~~ (interface)](#functorcomposition22c-interface)\n  - [~~FunctorComposition22~~ (interface)](#functorcomposition22-interface)\n  - [~~FunctorComposition23C~~ (interface)](#functorcomposition23c-interface)\n  - [~~FunctorComposition23~~ (interface)](#functorcomposition23-interface)\n  - [~~FunctorComposition2C1~~ (interface)](#functorcomposition2c1-interface)\n  - [~~FunctorCompositionHKT1~~ (interface)](#functorcompositionhkt1-interface)\n  - [~~FunctorCompositionHKT2C~~ (interface)](#functorcompositionhkt2c-interface)\n  - [~~FunctorCompositionHKT2~~ (interface)](#functorcompositionhkt2-interface)\n  - [~~FunctorComposition~~ (interface)](#functorcomposition-interface)\n  - [~~getFunctorComposition~~](#getfunctorcomposition)\n\n---\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare function flap<F extends URIS4>(\n  F: Functor4<F>\n): <A>(a: A) => <S, R, E, B>(fab: Kind4<F, S, R, E, (a: A) => B>) => Kind4<F, S, R, E, B>\nexport declare function flap<F extends URIS3>(\n  F: Functor3<F>\n): <A>(a: A) => <R, E, B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\nexport declare function flap<F extends URIS2>(\n  F: Functor2<F>\n): <A>(a: A) => <E, B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\nexport declare function flap<F extends URIS>(F: Functor1<F>): <A>(a: A) => <B>(fab: Kind<F, (a: A) => B>) => Kind<F, B>\nexport declare function flap<F>(F: Functor<F>): <A>(a: A) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B>\n```\n\nAdded in v2.10.0\n\n# model\n\n## Functor (interface)\n\n**Signature**\n\n```ts\nexport interface Functor<F> {\n  readonly URI: F\n  readonly map: <A, B>(fa: HKT<F, A>, f: (a: A) => B) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Functor1 (interface)\n\n**Signature**\n\n```ts\nexport interface Functor1<F extends URIS> {\n  readonly URI: F\n  readonly map: <A, B>(fa: Kind<F, A>, f: (a: A) => B) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Functor2 (interface)\n\n**Signature**\n\n```ts\nexport interface Functor2<F extends URIS2> {\n  readonly URI: F\n  readonly map: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Functor2C (interface)\n\n**Signature**\n\n```ts\nexport interface Functor2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly map: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Functor3 (interface)\n\n**Signature**\n\n```ts\nexport interface Functor3<F extends URIS3> {\n  readonly URI: F\n  readonly map: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Functor3C (interface)\n\n**Signature**\n\n```ts\nexport interface Functor3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly map: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## Functor4 (interface)\n\n**Signature**\n\n```ts\nexport interface Functor4<F extends URIS4> {\n  readonly URI: F\n  readonly map: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => B) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare function bindTo<F extends URIS4>(\n  F: Functor4<F>\n): <N extends string>(name: N) => <S, R, E, A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, { readonly [K in N]: A }>\nexport declare function bindTo<F extends URIS3>(\n  F: Functor3<F>\n): <N extends string>(name: N) => <R, E, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in N]: A }>\nexport declare function bindTo<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <N extends string>(name: N) => <R, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in N]: A }>\nexport declare function bindTo<F extends URIS2>(\n  F: Functor2<F>\n): <N extends string>(name: N) => <E, A>(fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in N]: A }>\nexport declare function bindTo<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <N extends string>(name: N) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in N]: A }>\nexport declare function bindTo<F extends URIS>(\n  F: Functor1<F>\n): <N extends string>(name: N) => <A>(fa: Kind<F, A>) => Kind<F, { readonly [K in N]: A }>\nexport declare function bindTo<F>(\n  F: Functor<F>\n): <N extends string>(name: N) => <A>(fa: HKT<F, A>) => HKT<F, { readonly [K in N]: A }>\n```\n\nAdded in v2.10.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: typeof let_\n```\n\nAdded in v2.13.0\n\n## let\\_\n\n**Signature**\n\n```ts\nfunction let_<F extends URIS4>(\n  F: Functor4<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <S, R, E>(\n  fa: Kind4<F, S, R, E, A>\n) => Kind4<F, S, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS3>(\n  F: Functor3<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS2>(\n  F: Functor2<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS>(\n  F: Functor1<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: Kind<F, A>) => Kind<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F>(\n  F: Functor<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: HKT<F, A>) => HKT<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n## map\n\n`map` composition.\n\n**Signature**\n\n```ts\nexport declare function map<F extends URIS3, G extends URIS>(\n  F: Functor3<F>,\n  G: Functor1<G>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, Kind<G, A>>) => Kind3<F, R, E, Kind<G, B>>\nexport declare function map<F extends URIS2, G extends URIS2>(\n  F: Functor2<F>,\n  G: Functor2<G>\n): <A, B>(f: (a: A) => B) => <EF, EG>(fa: Kind2<F, EF, Kind2<G, EG, A>>) => Kind2<F, EF, Kind2<G, EG, B>>\nexport declare function map<F extends URIS2, G extends URIS>(\n  F: Functor2<F>,\n  G: Functor1<G>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, Kind<G, A>>) => Kind2<F, E, Kind<G, B>>\nexport declare function map<F extends URIS, G extends URIS3>(\n  F: Functor1<F>,\n  G: Functor3<G>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind<F, Kind3<G, R, E, A>>) => Kind<F, Kind3<G, R, E, B>>\nexport declare function map<F extends URIS, G extends URIS2>(\n  F: Functor1<F>,\n  G: Functor2<G>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>\nexport declare function map<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Functor1<G>\n): <A, B>(f: (a: A) => B) => (fa: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\nexport declare function map<F, G extends URIS2>(\n  F: Functor<F>,\n  G: Functor2<G>\n): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, Kind2<G, E, A>>) => HKT<F, Kind2<G, E, B>>\nexport declare function map<F, G extends URIS>(\n  F: Functor<F>,\n  G: Functor1<G>\n): <A, B>(f: (a: A) => B) => (fa: HKT<F, Kind<G, A>>) => HKT<F, Kind<G, B>>\nexport declare function map<F, G>(\n  F: Functor<F>,\n  G: Functor<G>\n): <A, B>(f: (a: A) => B) => (fa: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~FunctorComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition11<F extends URIS, G extends URIS> {\n  readonly map: <A, B>(fa: Kind<F, Kind<G, A>>, f: (a: A) => B) => Kind<F, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorComposition12C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition12C<F extends URIS, G extends URIS2, E> {\n  readonly map: <A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => B) => Kind<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorComposition12~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition12<F extends URIS, G extends URIS2> {\n  readonly map: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => B) => Kind<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorComposition21~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition21<F extends URIS2, G extends URIS> {\n  readonly map: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => B) => Kind2<F, E, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorComposition22C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition22C<F extends URIS2, G extends URIS2, E> {\n  readonly map: <FE, A, B>(fa: Kind2<F, FE, Kind2<G, E, A>>, f: (a: A) => B) => Kind2<F, FE, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorComposition22~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition22<F extends URIS2, G extends URIS2> {\n  readonly map: <FE, GE, A, B>(fa: Kind2<F, FE, Kind2<G, GE, A>>, f: (a: A) => B) => Kind2<F, FE, Kind2<G, GE, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorComposition23C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition23C<F extends URIS2, G extends URIS3, E> {\n  readonly map: <FE, R, A, B>(fa: Kind2<F, FE, Kind3<G, R, E, A>>, f: (a: A) => B) => Kind2<F, FE, Kind3<G, R, E, B>>\n}\n```\n\nAdded in v2.2.0\n\n## ~~FunctorComposition23~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition23<F extends URIS2, G extends URIS3> {\n  readonly map: <FE, R, E, A, B>(fa: Kind2<F, FE, Kind3<G, R, E, A>>, f: (a: A) => B) => Kind2<F, FE, Kind3<G, R, E, B>>\n}\n```\n\nAdded in v2.2.0\n\n## ~~FunctorComposition2C1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition2C1<F extends URIS2, G extends URIS, E> {\n  readonly map: <A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => B) => Kind2<F, E, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorCompositionHKT1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorCompositionHKT1<F, G extends URIS> {\n  readonly map: <A, B>(fa: HKT<F, Kind<G, A>>, f: (a: A) => B) => HKT<F, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorCompositionHKT2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorCompositionHKT2C<F, G extends URIS2, E> {\n  readonly map: <A, B>(fa: HKT<F, Kind2<G, E, A>>, f: (a: A) => B) => HKT<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorCompositionHKT2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorCompositionHKT2<F, G extends URIS2> {\n  readonly map: <E, A, B>(fa: HKT<F, Kind2<G, E, A>>, f: (a: A) => B) => HKT<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorComposition~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorComposition<F, G> {\n  readonly map: <A, B>(fa: HKT<F, HKT<G, A>>, f: (a: A) => B) => HKT<F, HKT<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~getFunctorComposition~~\n\nUse [`map`](#map) instead.\n\n**Signature**\n\n```ts\nexport declare function getFunctorComposition<F extends URIS2, G extends URIS3, E>(\n  F: Functor2<F>,\n  G: Functor3C<G, E>\n): FunctorComposition23C<F, G, E>\nexport declare function getFunctorComposition<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Functor2C<G, E>\n): FunctorComposition22C<F, G, E>\nexport declare function getFunctorComposition<F extends URIS2, G extends URIS2>(\n  F: Functor2<F>,\n  G: Functor2<G>\n): FunctorComposition22<F, G>\nexport declare function getFunctorComposition<F extends URIS2, G extends URIS, E>(\n  F: Functor2C<F, E>,\n  G: Functor1<G>\n): FunctorComposition2C1<F, G, E>\nexport declare function getFunctorComposition<F extends URIS2, G extends URIS>(\n  F: Functor2<F>,\n  G: Functor1<G>\n): FunctorComposition21<F, G>\nexport declare function getFunctorComposition<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Functor2C<G, E>\n): FunctorComposition12C<F, G, E>\nexport declare function getFunctorComposition<F extends URIS, G extends URIS2>(\n  F: Functor1<F>,\n  G: Functor2<G>\n): FunctorComposition12<F, G>\nexport declare function getFunctorComposition<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Functor1<G>\n): FunctorComposition11<F, G>\nexport declare function getFunctorComposition<F, G>(F: Functor<F>, G: Functor<G>): FunctorComposition<F, G>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/FunctorWithIndex.ts.md",
    "content": "---\ntitle: FunctorWithIndex.ts\nnav_order: 43\nparent: Modules\n---\n\n## FunctorWithIndex overview\n\nA `FunctorWithIndex` is a type constructor which supports a mapping operation `mapWithIndex`.\n\n`mapWithIndex` can be used to turn functions `i -> a -> b` into functions `f a -> f b` whose argument and return types use the type\nconstructor `f` to represent some computational context.\n\nInstances must satisfy the following laws:\n\n1. Identity: `F.mapWithIndex(fa, (_i, a) => a) <-> fa`\n2. Composition: `F.mapWithIndex(fa, (_i, a) => bc(ab(a))) <-> F.mapWithIndex(F.mapWithIndex(fa, ab), bc)`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [FunctorWithIndex (interface)](#functorwithindex-interface)\n  - [FunctorWithIndex1 (interface)](#functorwithindex1-interface)\n  - [FunctorWithIndex2 (interface)](#functorwithindex2-interface)\n  - [FunctorWithIndex2C (interface)](#functorwithindex2c-interface)\n  - [FunctorWithIndex3 (interface)](#functorwithindex3-interface)\n  - [FunctorWithIndex3C (interface)](#functorwithindex3c-interface)\n  - [FunctorWithIndex4 (interface)](#functorwithindex4-interface)\n- [utils](#utils)\n  - [mapWithIndex](#mapwithindex)\n- [zone of death](#zone-of-death)\n  - [~~FunctorWithIndexComposition11~~ (interface)](#functorwithindexcomposition11-interface)\n  - [~~FunctorWithIndexComposition12C~~ (interface)](#functorwithindexcomposition12c-interface)\n  - [~~FunctorWithIndexComposition12~~ (interface)](#functorwithindexcomposition12-interface)\n  - [~~FunctorWithIndexComposition21~~ (interface)](#functorwithindexcomposition21-interface)\n  - [~~FunctorWithIndexComposition22C~~ (interface)](#functorwithindexcomposition22c-interface)\n  - [~~FunctorWithIndexComposition22~~ (interface)](#functorwithindexcomposition22-interface)\n  - [~~FunctorWithIndexComposition2C1~~ (interface)](#functorwithindexcomposition2c1-interface)\n  - [~~FunctorWithIndexComposition~~ (interface)](#functorwithindexcomposition-interface)\n  - [~~getFunctorWithIndexComposition~~](#getfunctorwithindexcomposition)\n\n---\n\n# model\n\n## FunctorWithIndex (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndex<F, I> extends Functor<F> {\n  readonly mapWithIndex: <A, B>(fa: HKT<F, A>, f: (i: I, a: A) => B) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## FunctorWithIndex1 (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndex1<F extends URIS, I> extends Functor1<F> {\n  readonly mapWithIndex: <A, B>(fa: Kind<F, A>, f: (i: I, a: A) => B) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## FunctorWithIndex2 (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndex2<F extends URIS2, I> extends Functor2<F> {\n  readonly mapWithIndex: <E, A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => B) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## FunctorWithIndex2C (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndex2C<F extends URIS2, I, E> extends Functor2C<F, E> {\n  readonly mapWithIndex: <A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => B) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## FunctorWithIndex3 (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndex3<F extends URIS3, I> extends Functor3<F> {\n  readonly mapWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => B) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## FunctorWithIndex3C (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndex3C<F extends URIS3, I, E> extends Functor3C<F, E> {\n  readonly mapWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => B) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## FunctorWithIndex4 (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndex4<F extends URIS4, I> extends Functor4<F> {\n  readonly mapWithIndex: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (i: I, a: A) => B) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## mapWithIndex\n\n`mapWithIndex` composition.\n\n**Signature**\n\n```ts\nexport declare function mapWithIndex<F extends URIS, I, G extends URIS, J>(\n  F: FunctorWithIndex1<F, I>,\n  G: FunctorWithIndex1<G, J>\n): <A, B>(f: (ij: readonly [I, J], a: A) => B) => (fa: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\nexport declare function mapWithIndex<F, I, G, J>(\n  F: FunctorWithIndex<F, I>,\n  G: FunctorWithIndex<G, J>\n): <A, B>(f: (ij: readonly [I, J], a: A) => B) => (fa: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~FunctorWithIndexComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndexComposition11<F extends URIS, FI, G extends URIS, GI>\n  extends FunctorComposition11<F, G> {\n  readonly mapWithIndex: <A, B>(fa: Kind<F, Kind<G, A>>, f: (i: [FI, GI], a: A) => B) => Kind<F, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorWithIndexComposition12C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndexComposition12C<F extends URIS, FI, G extends URIS2, GI, E>\n  extends FunctorComposition12C<F, G, E> {\n  readonly mapWithIndex: <A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => B) => Kind<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorWithIndexComposition12~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndexComposition12<F extends URIS, FI, G extends URIS2, GI>\n  extends FunctorComposition12<F, G> {\n  readonly mapWithIndex: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => B) => Kind<F, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorWithIndexComposition21~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndexComposition21<F extends URIS2, FI, G extends URIS, GI>\n  extends FunctorComposition21<F, G> {\n  readonly mapWithIndex: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (i: [FI, GI], a: A) => B) => Kind2<F, E, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorWithIndexComposition22C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndexComposition22C<F extends URIS2, FI, G extends URIS2, GI, E>\n  extends FunctorComposition22C<F, G, E> {\n  readonly mapWithIndex: <FE, A, B>(\n    fa: Kind2<F, FE, Kind2<G, E, A>>,\n    f: (i: [FI, GI], a: A) => B\n  ) => Kind2<F, FE, Kind2<G, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorWithIndexComposition22~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndexComposition22<F extends URIS2, FI, G extends URIS2, GI>\n  extends FunctorComposition22<F, G> {\n  readonly mapWithIndex: <FE, GE, A, B>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    f: (i: [FI, GI], a: A) => B\n  ) => Kind2<F, FE, Kind2<G, GE, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorWithIndexComposition2C1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndexComposition2C1<F extends URIS2, FI, G extends URIS, GI, E>\n  extends FunctorComposition2C1<F, G, E> {\n  readonly mapWithIndex: <A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (i: [FI, GI], a: A) => B) => Kind2<F, E, Kind<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~FunctorWithIndexComposition~~ (interface)\n\n**Signature**\n\n```ts\nexport interface FunctorWithIndexComposition<F, FI, G, GI> extends FunctorComposition<F, G> {\n  readonly mapWithIndex: <A, B>(fga: HKT<F, HKT<G, A>>, f: (i: [FI, GI], a: A) => B) => HKT<F, HKT<G, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~getFunctorWithIndexComposition~~\n\nUse [`mapWithIndex`](#mapwithindex) instead.\n\n**Signature**\n\n```ts\nexport declare function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI, E>(\n  F: FunctorWithIndex2<F, FI>,\n  G: FunctorWithIndex2C<G, FI, E>\n): FunctorWithIndexComposition22C<F, FI, G, GI, E>\nexport declare function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI>(\n  F: FunctorWithIndex2<F, FI>,\n  G: FunctorWithIndex2<G, FI>\n): FunctorWithIndexComposition22<F, FI, G, GI>\nexport declare function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS, GI, E>(\n  F: FunctorWithIndex2C<F, FI, E>,\n  G: FunctorWithIndex1<G, GI>\n): FunctorWithIndexComposition2C1<F, FI, G, GI, E>\nexport declare function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS, GI>(\n  F: FunctorWithIndex2<F, FI>,\n  G: FunctorWithIndex1<G, GI>\n): FunctorWithIndexComposition21<F, FI, G, GI>\nexport declare function getFunctorWithIndexComposition<F extends URIS, FI, G extends URIS2, GI, E>(\n  F: FunctorWithIndex1<F, FI>,\n  G: FunctorWithIndex2C<G, GI, E>\n): FunctorWithIndexComposition12C<F, FI, G, GI, E>\nexport declare function getFunctorWithIndexComposition<F extends URIS, FI, G extends URIS2, GI>(\n  F: FunctorWithIndex1<F, FI>,\n  G: FunctorWithIndex2<G, GI>\n): FunctorWithIndexComposition12<F, FI, G, GI>\nexport declare function getFunctorWithIndexComposition<F extends URIS, FI, G extends URIS, GI>(\n  F: FunctorWithIndex1<F, FI>,\n  G: FunctorWithIndex1<G, GI>\n): FunctorWithIndexComposition11<F, FI, G, GI>\nexport declare function getFunctorWithIndexComposition<F, FI, G, GI>(\n  F: FunctorWithIndex<F, FI>,\n  G: FunctorWithIndex<G, GI>\n): FunctorWithIndexComposition<F, FI, G, GI>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Group.ts.md",
    "content": "---\ntitle: Group.ts\nnav_order: 44\nparent: Modules\n---\n\n## Group overview\n\nA `Group` is a `Monoid` with inverses. Instances must satisfy the following law in addition to the monoid laws:\n\n- Inverse: `concat(inverse(a), a) <-> empty = concat(a, inverse(a))`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Group (interface)](#group-interface)\n\n---\n\n# model\n\n## Group (interface)\n\n**Signature**\n\n```ts\nexport interface Group<A> extends Monoid<A> {\n  readonly inverse: (a: A) => A\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/HKT.ts.md",
    "content": "---\ntitle: HKT.ts\nnav_order: 46\nparent: Modules\n---\n\n## HKT overview\n\nType defunctionalization (as describe in [Lightweight higher-kinded polymorphism](https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf))\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [utils](#utils)\n  - [HKT (interface)](#hkt-interface)\n  - [HKT2 (interface)](#hkt2-interface)\n  - [HKT3 (interface)](#hkt3-interface)\n  - [HKT4 (interface)](#hkt4-interface)\n  - [Kind (type alias)](#kind-type-alias)\n  - [Kind2 (type alias)](#kind2-type-alias)\n  - [Kind3 (type alias)](#kind3-type-alias)\n  - [Kind4 (type alias)](#kind4-type-alias)\n  - [URIS (type alias)](#uris-type-alias)\n  - [URIS2 (type alias)](#uris2-type-alias)\n  - [URIS3 (type alias)](#uris3-type-alias)\n  - [URIS4 (type alias)](#uris4-type-alias)\n  - [URItoKind (interface)](#uritokind-interface)\n  - [URItoKind2 (interface)](#uritokind2-interface)\n  - [URItoKind3 (interface)](#uritokind3-interface)\n  - [URItoKind4 (interface)](#uritokind4-interface)\n\n---\n\n# utils\n\n## HKT (interface)\n\n`* -> *` constructors\n\n**Signature**\n\n```ts\nexport interface HKT<URI, A> {\n  readonly _URI: URI\n  readonly _A: A\n}\n```\n\nAdded in v2.0.0\n\n## HKT2 (interface)\n\n`* -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport interface HKT2<URI, E, A> extends HKT<URI, A> {\n  readonly _E: E\n}\n```\n\nAdded in v2.0.0\n\n## HKT3 (interface)\n\n`* -> * -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport interface HKT3<URI, R, E, A> extends HKT2<URI, E, A> {\n  readonly _R: R\n}\n```\n\nAdded in v2.0.0\n\n## HKT4 (interface)\n\n`* -> * -> * -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport interface HKT4<URI, S, R, E, A> extends HKT3<URI, R, E, A> {\n  readonly _S: S\n}\n```\n\nAdded in v2.0.0\n\n## Kind (type alias)\n\n`* -> *` constructors\n\n**Signature**\n\n```ts\nexport type Kind<URI extends URIS, A> = URI extends URIS ? URItoKind<A>[URI] : any\n```\n\nAdded in v2.0.0\n\n## Kind2 (type alias)\n\n`* -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport type Kind2<URI extends URIS2, E, A> = URI extends URIS2 ? URItoKind2<E, A>[URI] : any\n```\n\nAdded in v2.0.0\n\n## Kind3 (type alias)\n\n`* -> * -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport type Kind3<URI extends URIS3, R, E, A> = URI extends URIS3 ? URItoKind3<R, E, A>[URI] : any\n```\n\nAdded in v2.0.0\n\n## Kind4 (type alias)\n\n`* -> * -> * -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport type Kind4<URI extends URIS4, S, R, E, A> = URI extends URIS4 ? URItoKind4<S, R, E, A>[URI] : any\n```\n\nAdded in v2.0.0\n\n## URIS (type alias)\n\n`* -> *` constructors\n\n**Signature**\n\n```ts\nexport type URIS = keyof URItoKind<any>\n```\n\nAdded in v2.0.0\n\n## URIS2 (type alias)\n\n`* -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport type URIS2 = keyof URItoKind2<any, any>\n```\n\nAdded in v2.0.0\n\n## URIS3 (type alias)\n\n`* -> * -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport type URIS3 = keyof URItoKind3<any, any, any>\n```\n\nAdded in v2.0.0\n\n## URIS4 (type alias)\n\n`* -> * -> * -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport type URIS4 = keyof URItoKind4<any, any, any, any>\n```\n\nAdded in v2.0.0\n\n## URItoKind (interface)\n\n`* -> *` constructors\n\n**Signature**\n\n```ts\nexport interface URItoKind<A> {}\n```\n\nAdded in v2.0.0\n\n## URItoKind2 (interface)\n\n`* -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport interface URItoKind2<E, A> {}\n```\n\nAdded in v2.0.0\n\n## URItoKind3 (interface)\n\n`* -> * -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport interface URItoKind3<R, E, A> {}\n```\n\nAdded in v2.0.0\n\n## URItoKind4 (interface)\n\n`* -> * -> * -> * -> *` constructors\n\n**Signature**\n\n```ts\nexport interface URItoKind4<S, R, E, A> {}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/HeytingAlgebra.ts.md",
    "content": "---\ntitle: HeytingAlgebra.ts\nnav_order: 45\nparent: Modules\n---\n\n## HeytingAlgebra overview\n\nHeyting algebras are bounded (distributive) lattices that are also equipped with an additional binary operation\n`implies` (also written as `→`). Heyting algebras also define a complement operation `not` (sometimes written as\n`¬a`)\n\nHowever, in Heyting algebras this operation is only a pseudo-complement, since Heyting algebras do not necessarily\nprovide the law of the excluded middle. This means that there is no guarantee that `a ∨ ¬a = 1`.\n\nHeyting algebras model intuitionistic logic. For a model of classical logic, see the boolean algebra type class\nimplemented as `BooleanAlgebra`.\n\nA `HeytingAlgebra` must satisfy the following laws in addition to `BoundedDistributiveLattice` laws:\n\n- Implication:\n  - `a → a <-> 1`\n  - `a ∧ (a → b) <-> a ∧ b`\n  - `b ∧ (a → b) <-> b`\n  - `a → (b ∧ c) <-> (a → b) ∧ (a → c)`\n- Complemented\n  - `¬a <-> a → 0`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [HeytingAlgebra (interface)](#heytingalgebra-interface)\n\n---\n\n# model\n\n## HeytingAlgebra (interface)\n\n**Signature**\n\n```ts\nexport interface HeytingAlgebra<A> extends BoundedDistributiveLattice<A> {\n  readonly implies: (x: A, y: A) => A\n  readonly not: (x: A) => A\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/IO.ts.md",
    "content": "---\ntitle: IO.ts\nnav_order: 50\nparent: Modules\n---\n\n## IO overview\n\n```ts\ninterface IO<A> {\n  (): A\n}\n```\n\n`IO<A>` represents a non-deterministic synchronous computation that can cause side effects, yields a value of\ntype `A` and **never fails**.\n\nIf you want to represent a synchronous computation that may fail, please see `IOEither`.\nIf you want to represent a synchronous computation that may yield nothing, please see `IOOption`.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n- [constructors](#constructors)\n  - [of](#of)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n- [instances](#instances)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [ChainRec](#chainrec)\n  - [FromIO](#fromio)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [Pointed](#pointed)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [IO (interface)](#io-interface)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n- [zone of death](#zone-of-death)\n  - [~~fromIO~~](#fromio)\n  - [~~getMonoid~~](#getmonoid)\n  - [~~getSemigroup~~](#getsemigroup)\n  - [~~io~~](#io)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <A, _>(self: IO<A>, f: (a: A) => IO<_>): IO<A>\n  <A, _>(f: (a: A) => IO<_>): (self: IO<A>) => IO<A>\n}\n```\n\nAdded in v2.15.0\n\n# constructors\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => IO<A>\n```\n\nAdded in v2.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: IO<{}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: IO<B>\n) => (fa: IO<A>) => IO<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => IO<B>\n) => (ma: IO<A>) => IO<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: IO<A>) => IO<{ readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: IO<A>) => IO<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# instances\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative1<'IO'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply1<'IO'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain1<'IO'>\n```\n\nAdded in v2.10.0\n\n## ChainRec\n\n**Signature**\n\n```ts\nexport declare const ChainRec: ChainRec1<'IO'>\n```\n\nAdded in v2.7.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO1<'IO'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'IO'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'IO'>\n```\n\nAdded in v2.7.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO1<'IO'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'IO'>\n```\n\nAdded in v2.10.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => IO<B>) => (ma: IO<A>) => IO<B>\n```\n\nAdded in v2.0.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => IO<B>) => (first: IO<A>) => IO<A>\n```\n\nAdded in v2.0.0\n\n# mapping\n\n## as\n\nMaps the value to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: { <A>(a: A): <_>(self: IO<_>) => IO<A>; <_, A>(self: IO<_>, a: A): IO<A> }\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the value to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <_>(self: IO<_>) => IO<void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: IO<(a: A) => B>) => IO<B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (fa: IO<A>) => IO<B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## IO (interface)\n\n**Signature**\n\n```ts\nexport interface IO<A> {\n  (): A\n}\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A) => IO<B>): (ma: IO<A>) => IO<B>\n  <A, B>(ma: IO<A>, f: (a: A) => IO<B>): IO<B>\n}\n```\n\nAdded in v2.14.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: IO<IO<A>>) => IO<A>\n```\n\nAdded in v2.0.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <A>(arr: readonly IO<A>[]) => IO<readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <A, B>(f: (a: A) => IO<B>) => (as: readonly A[]) => IO<readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => IO<B>\n) => (as: readonly A[]) => IO<readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => IO<B>\n) => (as: readonly A[]) => IO<readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => IO<B>\n) => (as: ReadonlyNonEmptyArray<A>) => IO<ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'IO'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: IO<readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(fa: IO<A>) => <B>(fab: IO<(a: A) => B>) => IO<B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: IO<B>) => <A>(first: IO<A>) => IO<A>\n```\n\nAdded in v2.0.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: IO<B>) => <A>(first: IO<A>) => IO<B>\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~fromIO~~\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A>(fa: IO<A>) => IO<A>\n```\n\nAdded in v2.7.0\n\n## ~~getMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A>(M: Monoid<A>) => Monoid<IO<A>>\n```\n\nAdded in v2.0.0\n\n## ~~getSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A>(S: Semigroup<A>) => Semigroup<IO<A>>\n```\n\nAdded in v2.0.0\n\n## ~~io~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `IO.Functor` instead of `IO.io`\n(where `IO` is from `import IO from 'fp-ts/IO'`)\n\n**Signature**\n\n```ts\nexport declare const io: Monad1<'IO'> & MonadIO1<'IO'> & ChainRec1<'IO'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/IOEither.ts.md",
    "content": "---\ntitle: IOEither.ts\nnav_order: 51\nparent: Modules\n---\n\n## IOEither overview\n\n`IOEither<E, A>` represents a synchronous computation that either yields a value of type `A` or fails yielding an\nerror of type `E`.\n\nIf you want to represent a synchronous computation that never fails, please see `IO`.\nIf you want to represent a synchronous computation that may yield nothing, please see `IOOption`.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapEither](#tapeither)\n  - [tapIO](#tapio)\n- [constructors](#constructors)\n  - [left](#left)\n  - [leftIO](#leftio)\n  - [of](#of)\n  - [right](#right)\n  - [rightIO](#rightio)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromIO](#fromio)\n  - [fromOption](#fromoption)\n  - [toUnion](#tounion)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [apSW](#apsw)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [bindW](#bindw)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n  - [getAltIOValidation](#getaltiovalidation)\n  - [getApplicativeIOValidation](#getapplicativeiovalidation)\n  - [getOrElse](#getorelse)\n  - [getOrElseW](#getorelsew)\n  - [mapBoth](#mapboth)\n  - [mapError](#maperror)\n  - [orElse](#orelse)\n  - [orElseFirstIOK](#orelsefirstiok)\n  - [orElseW](#orelsew)\n  - [orLeft](#orleft)\n  - [tapError](#taperror)\n- [filtering](#filtering)\n  - [filterOrElse](#filterorelse)\n  - [filterOrElseW](#filterorelsew)\n  - [getCompactable](#getcompactable)\n  - [getFilterable](#getfilterable)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [ApplicativePar](#applicativepar)\n  - [ApplicativeSeq](#applicativeseq)\n  - [ApplyPar](#applypar)\n  - [Bifunctor](#bifunctor)\n  - [Chain](#chain)\n  - [FromEither](#fromeither)\n  - [FromIO](#fromio)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [MonadThrow](#monadthrow)\n  - [Pointed](#pointed)\n- [interop](#interop)\n  - [tryCatch](#trycatch)\n  - [tryCatchK](#trycatchk)\n- [legacy](#legacy)\n  - [bimap](#bimap)\n  - [chain](#chain)\n  - [chainEitherK](#chaineitherk)\n  - [chainEitherKW](#chaineitherkw)\n  - [chainFirst](#chainfirst)\n  - [chainFirstEitherK](#chainfirsteitherk)\n  - [chainFirstEitherKW](#chainfirsteitherkw)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainFirstW](#chainfirstw)\n  - [chainIOK](#chainiok)\n  - [chainOptionK](#chainoptionk)\n  - [chainOptionKW](#chainoptionkw)\n  - [chainW](#chainw)\n  - [fromOptionK](#fromoptionk)\n  - [mapLeft](#mapleft)\n  - [orElseFirst](#orelsefirst)\n  - [orElseFirstW](#orelsefirstw)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromIOK](#fromiok)\n  - [fromPredicate](#frompredicate)\n  - [liftNullable](#liftnullable)\n  - [liftOption](#liftoption)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [IOEither (interface)](#ioeither-interface)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchE](#matche)\n  - [matchEW](#matchew)\n  - [matchW](#matchw)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapEither](#flatmapeither)\n  - [flatMapIO](#flatmapio)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatMapOption](#flatmapoption)\n  - [flatten](#flatten)\n  - [flattenW](#flattenw)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [sequenceSeqArray](#sequenceseqarray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyArrayWithIndexSeq](#traversereadonlyarraywithindexseq)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndexSeq](#traversereadonlynonemptyarraywithindexseq)\n  - [traverseSeqArray](#traverseseqarray)\n  - [traverseSeqArrayWithIndex](#traverseseqarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apFirstW](#apfirstw)\n  - [apSecond](#apsecond)\n  - [apSecondW](#apsecondw)\n  - [apW](#apw)\n  - [bracket](#bracket)\n  - [bracketW](#bracketw)\n  - [swap](#swap)\n  - [throwError](#throwerror)\n- [zone of death](#zone-of-death)\n  - [~~Applicative~~](#applicative)\n  - [~~getApplyMonoid~~](#getapplymonoid)\n  - [~~getApplySemigroup~~](#getapplysemigroup)\n  - [~~getIOValidation~~](#getiovalidation)\n  - [~~getSemigroup~~](#getsemigroup)\n  - [~~ioEither~~](#ioeither)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => IOEither<E2, _>): IOEither<E1 | E2, A>\n  <A, E2, _>(f: (a: A) => IOEither<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A>\n}\n```\n\nAdded in v2.15.0\n\n## tapEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapEither: {\n  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A>\n  <E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => E.Either<E2, _>): IOEither<E1 | E2, A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as IOE from 'fp-ts/IOEither'\nimport * as E from 'fp-ts/Either'\n\nconst compute = (value: string) =>\n  pipe(\n    IOE.of(value),\n    IOE.tapEither(() => (value.length > 0 ? E.right('ok') : E.left('error')))\n  )\n\nassert.deepStrictEqual(compute('')(), E.left('error'))\nassert.deepStrictEqual(compute('fp-ts')(), E.right('fp-ts'))\n```\n\nAdded in v2.16.0\n\n## tapIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapIO: {\n  <A, _>(f: (a: A) => I.IO<_>): <E>(self: IOEither<E, A>) => IOEither<E, A>\n  <E, A, _>(self: IOEither<E, A>, f: (a: A) => I.IO<_>): IOEither<E, A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as IOE from 'fp-ts/IOEither'\nimport * as E from 'fp-ts/Either'\nimport * as Console from 'fp-ts/Console'\n\nconst sayHello = (value: string) => Console.log(`Hello, ${value}`)\n\n// Will produce `Hello, fp-ts` to the stdout\nconst effectA = IOE.tapIO(IOE.of('fp-ts'), sayHello)\n\n// No output to the stdout\nconst effectB = pipe(IOE.left<string>('error'), IOE.tapIO(sayHello))\n\nassert.deepStrictEqual(effectA(), E.right('fp-ts'))\nassert.deepStrictEqual(effectB(), E.left('error'))\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## left\n\n**Signature**\n\n```ts\nexport declare const left: <E = never, A = never>(l: E) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## leftIO\n\n**Signature**\n\n```ts\nexport declare const leftIO: <E = never, A = never>(me: I.IO<E>) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <E = never, A = never>(a: A) => IOEither<E, A>\n```\n\nAdded in v2.8.5\n\n## right\n\n**Signature**\n\n```ts\nexport declare const right: <E = never, A = never>(a: A) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## rightIO\n\n**Signature**\n\n```ts\nexport declare const rightIO: <E = never, A = never>(ma: I.IO<A>) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <E, A>(fa: E.Either<E, A>) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A, E = never>(fa: I.IO<A>) => IOEither<E, A>\n```\n\nAdded in v2.7.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## toUnion\n\n**Signature**\n\n```ts\nexport declare const toUnion: <E, A>(fa: IOEither<E, A>) => I.IO<E | A>\n```\n\nAdded in v2.10.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: IOEither<never, {}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: IOEither<E, B>\n) => (fa: IOEither<E, A>) => IOEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## apSW\n\nLess strict version of [`apS`](#aps).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSW: <A, N extends string, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: IOEither<E2, B>\n) => <E1>(fa: IOEither<E1, A>) => IOEither<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => IOEither<E, B>\n) => (ma: IOEither<E, A>) => IOEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <E, A>(fa: IOEither<E, A>) => IOEither<E, { readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## bindW\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bindW: <N extends string, A, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => IOEither<E2, B>\n) => <E1>(fa: IOEither<E1, A>) => IOEither<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <E>(fa: IOEither<E, A>) => IOEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\n**Signature**\n\n```ts\nexport declare const alt: <E, A>(that: LazyArg<IOEither<E, A>>) => (fa: IOEither<E, A>) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the error and the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <E2, B>(\n  that: LazyArg<IOEither<E2, B>>\n) => <E1, A>(fa: IOEither<E1, A>) => IOEither<E2, B | A>\n```\n\nAdded in v2.9.0\n\n## getAltIOValidation\n\nThe default [`Alt`](#alt) instance returns the last error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\nSee [`getAltValidation`](./Either.ts.html#getaltvalidation).\n\n**Signature**\n\n```ts\nexport declare function getAltIOValidation<E>(S: Semigroup<E>): Alt2C<URI, E>\n```\n\nAdded in v2.7.0\n\n## getApplicativeIOValidation\n\nThe default [`ApplicativePar`](#applicativepar) instance returns the first error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\nSee [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation).\n\n**Signature**\n\n```ts\nexport declare function getApplicativeIOValidation<E>(S: Semigroup<E>): Applicative2C<URI, E>\n```\n\nAdded in v2.7.0\n\n## getOrElse\n\n**Signature**\n\n```ts\nexport declare const getOrElse: <E, A>(onLeft: (e: E) => I.IO<A>) => (ma: IOEither<E, A>) => I.IO<A>\n```\n\nAdded in v2.0.0\n\n## getOrElseW\n\nLess strict version of [`getOrElse`](#getorelse).\n\nThe `W` suffix (short for **W**idening) means that the handler return type will be merged.\n\n**Signature**\n\n```ts\nexport declare const getOrElseW: <E, B>(onLeft: (e: E) => I.IO<B>) => <A>(ma: IOEither<E, A>) => I.IO<B | A>\n```\n\nAdded in v2.6.0\n\n## mapBoth\n\nReturns a `IOEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`.\n\n**Signature**\n\n```ts\nexport declare const mapBoth: {\n  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): (self: IOEither<E, A>) => IOEither<G, B>\n  <E, A, G, B>(self: IOEither<E, A>, f: (e: E) => G, g: (a: A) => B): IOEither<G, B>\n}\n```\n\n**Example**\n\n```ts\nimport * as IOEither from 'fp-ts/IOEither'\nimport * as Either from 'fp-ts/Either'\n\nconst f = (s: string) => new Error(s)\nconst g = (n: number) => n * 2\n\nassert.deepStrictEqual(IOEither.mapBoth(IOEither.right(1), f, g)(), Either.right(2))\nassert.deepStrictEqual(IOEither.mapBoth(IOEither.left('err'), f, g)(), Either.left(new Error('err')))\n```\n\nAdded in v2.16.0\n\n## mapError\n\nReturns a `IOEither` with its error channel mapped using the specified function.\n\n**Signature**\n\n```ts\nexport declare const mapError: {\n  <E, G>(f: (e: E) => G): <A>(self: IOEither<E, A>) => IOEither<G, A>\n  <E, A, G>(self: IOEither<E, A>, f: (e: E) => G): IOEither<G, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as IOEither from 'fp-ts/IOEither'\nimport * as Either from 'fp-ts/Either'\n\nconst f = (s: string) => new Error(s)\n\nassert.deepStrictEqual(IOEither.mapError(IOEither.right(1), f)(), Either.right(1))\nassert.deepStrictEqual(IOEither.mapError(IOEither.left('err'), f)(), Either.left(new Error('err')))\n```\n\nAdded in v2.16.0\n\n## orElse\n\n**Signature**\n\n```ts\nexport declare const orElse: <E1, A, E2>(onLeft: (e: E1) => IOEither<E2, A>) => (ma: IOEither<E1, A>) => IOEither<E2, A>\n```\n\nAdded in v2.0.0\n\n## orElseFirstIOK\n\n**Signature**\n\n```ts\nexport declare const orElseFirstIOK: <E, B>(onLeft: (e: E) => I.IO<B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A>\n```\n\nAdded in v2.12.0\n\n## orElseW\n\nLess strict version of [`orElse`](#orelse).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const orElseW: <E1, E2, B>(\n  onLeft: (e: E1) => IOEither<E2, B>\n) => <A>(ma: IOEither<E1, A>) => IOEither<E2, B | A>\n```\n\nAdded in v2.10.0\n\n## orLeft\n\n**Signature**\n\n```ts\nexport declare const orLeft: <E1, E2>(onLeft: (e: E1) => I.IO<E2>) => <A>(fa: IOEither<E1, A>) => IOEither<E2, A>\n```\n\nAdded in v2.11.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) => IOEither<E2, _>): <A>(self: IOEither<E1, A>) => IOEither<E1 | E2, A>\n  <E1, A, E2, _>(self: IOEither<E1, A>, onLeft: (e: E1) => IOEither<E2, _>): IOEither<E1 | E2, A>\n}\n```\n\nAdded in v2.15.0\n\n# filtering\n\n## filterOrElse\n\n**Signature**\n\n```ts\nexport declare const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: IOEither<E, B>) => IOEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, A>\n}\n```\n\nAdded in v2.0.0\n\n## filterOrElseW\n\nLess strict version of [`filterOrElse`](#filterorelse).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(\n    ma: IOEither<E1, A>\n  ) => IOEither<E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>(\n    mb: IOEither<E1, B>\n  ) => IOEither<E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, A>\n}\n```\n\nAdded in v2.9.0\n\n## getCompactable\n\n**Signature**\n\n```ts\nexport declare const getCompactable: <E>(M: Monoid<E>) => Compactable2C<'IOEither', E>\n```\n\nAdded in v2.10.0\n\n## getFilterable\n\n**Signature**\n\n```ts\nexport declare function getFilterable<E>(M: Monoid<E>): Filterable2C<URI, E>\n```\n\nAdded in v2.1.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt2<'IOEither'>\n```\n\nAdded in v2.7.0\n\n## ApplicativePar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplicativePar: Applicative2<'IOEither'>\n```\n\nAdded in v2.8.4\n\n## ApplicativeSeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplicativeSeq: Applicative2<'IOEither'>\n```\n\nAdded in v2.8.4\n\n## ApplyPar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplyPar: Apply2<'IOEither'>\n```\n\nAdded in v2.10.0\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor2<'IOEither'>\n```\n\nAdded in v2.7.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain2<'IOEither'>\n```\n\nAdded in v2.10.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither2<'IOEither'>\n```\n\nAdded in v2.10.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO2<'IOEither'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'IOEither'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad2<'IOEither'>\n```\n\nAdded in v2.7.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO2<'IOEither'>\n```\n\nAdded in v2.7.0\n\n## MonadThrow\n\n**Signature**\n\n```ts\nexport declare const MonadThrow: MonadThrow2<'IOEither'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed2<'IOEither'>\n```\n\nAdded in v2.10.0\n\n# interop\n\n## tryCatch\n\nConstructs a new `IOEither` from a function that performs a side effect and might throw\n\nSee also [`tryCatchK`](#trycatchk).\n\n**Signature**\n\n```ts\nexport declare const tryCatch: <E, A>(f: LazyArg<A>, onThrow: (reason: unknown) => E) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## tryCatchK\n\nConverts a function that may throw to one returning a `IOEither`.\n\n**Signature**\n\n```ts\nexport declare const tryCatchK: <A extends readonly unknown[], B, E>(\n  f: (...a: A) => B,\n  onThrow: (reason: unknown) => E\n) => (...a: A) => IOEither<E, B>\n```\n\nAdded in v2.10.0\n\n# legacy\n\n## bimap\n\nAlias of `mapBoth`.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: IOEither<E, A>) => IOEither<G, B>\n```\n\nAdded in v2.0.0\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B>\n```\n\nAdded in v2.0.0\n\n## chainEitherK\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherK: <E, A, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B>\n```\n\nAdded in v2.4.0\n\n## chainEitherKW\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherKW: <E2, A, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## chainFirstEitherK\n\nAlias of `tapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherK: <A, E, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstEitherKW\n\nAlias of `tapEither`.\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstIOK\n\nAlias of `tapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, A>\n```\n\nAdded in v2.10.0\n\n## chainFirstW\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstW: <E2, A, B>(\n  f: (a: A) => IOEither<E2, B>\n) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, A>\n```\n\nAdded in v2.8.0\n\n## chainIOK\n\nAlias of `flatMapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, B>\n```\n\nAdded in v2.10.0\n\n## chainOptionK\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => (ma: IOEither<E, A>) => IOEither<E, B>\n```\n\nAdded in v2.10.0\n\n## chainOptionKW\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, B>\n```\n\nAdded in v2.13.2\n\n## chainW\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chainW: <E2, A, B>(\n  f: (a: A) => IOEither<E2, B>\n) => <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, B>\n```\n\nAdded in v2.6.0\n\n## fromOptionK\n\nUse `liftOption`.\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => IOEither<E, B>\n```\n\nAdded in v2.10.0\n\n## mapLeft\n\nAlias of `mapError`.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: IOEither<E, A>) => IOEither<G, A>\n```\n\nAdded in v2.0.0\n\n## orElseFirst\n\nAlias of `tapError`.\n\n**Signature**\n\n```ts\nexport declare const orElseFirst: <E, B>(onLeft: (e: E) => IOEither<E, B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A>\n```\n\nAdded in v2.11.0\n\n## orElseFirstW\n\nAlias of `tapError`.\n\n**Signature**\n\n```ts\nexport declare const orElseFirstW: <E1, E2, B>(\n  onLeft: (e: E1) => IOEither<E2, B>\n) => <A>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => E.Either<E, B>\n) => (...a: A) => IOEither<E, B>\n```\n\nAdded in v2.4.0\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(\n  f: (...a: A) => I.IO<B>\n) => <E = never>(...a: A) => IOEither<E, B>\n```\n\nAdded in v2.10.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => IOEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => IOEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => IOEither<E, A>\n}\n```\n\nAdded in v2.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) => IOEither<E, NonNullable<B>>\n```\n\nAdded in v2.15.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) => IOEither<E, B>\n```\n\nAdded in v2.15.0\n\n# mapping\n\n## as\n\nMaps the `Right` value of this `IOEither` to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <E, _>(self: IOEither<E, _>) => IOEither<E, A>\n  <E, _, A>(self: IOEither<E, _>, a: A): IOEither<E, A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the `Right` value of this `IOEither` to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <E, _>(self: IOEither<E, _>) => IOEither<E, void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: IOEither<E, (a: A) => B>) => IOEither<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: IOEither<E, A>) => IOEither<E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## IOEither (interface)\n\n**Signature**\n\n```ts\nexport interface IOEither<E, A> extends IO<Either<E, A>> {}\n```\n\nAdded in v2.0.0\n\n# pattern matching\n\n## fold\n\nAlias of [`matchE`](#matche).\n\n**Signature**\n\n```ts\nexport declare const fold: <E, A, B>(\n  onLeft: (e: E) => I.IO<B>,\n  onRight: (a: A) => I.IO<B>\n) => (ma: IOEither<E, A>) => I.IO<B>\n```\n\nAdded in v2.0.0\n\n## foldW\n\nAlias of [`matchEW`](#matchew).\n\n**Signature**\n\n```ts\nexport declare const foldW: <E, B, A, C>(\n  onLeft: (e: E) => I.IO<B>,\n  onRight: (a: A) => I.IO<C>\n) => (ma: IOEither<E, A>) => I.IO<B | C>\n```\n\nAdded in v2.10.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: IOEither<E, A>) => I.IO<B>\n```\n\nAdded in v2.10.0\n\n## matchE\n\nThe `E` suffix (short for **E**ffect) means that the handlers return an effect (`IO`).\n\n**Signature**\n\n```ts\nexport declare const matchE: <E, A, B>(\n  onLeft: (e: E) => I.IO<B>,\n  onRight: (a: A) => I.IO<B>\n) => (ma: IOEither<E, A>) => I.IO<B>\n```\n\nAdded in v2.10.0\n\n## matchEW\n\nLess strict version of [`matchE`](#matche).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchEW: <E, B, A, C>(\n  onLeft: (e: E) => I.IO<B>,\n  onRight: (a: A) => I.IO<C>\n) => (ma: IOEither<E, A>) => I.IO<B | C>\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <E, B, A, C>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C\n) => (ma: IOEither<E, A>) => I.IO<B | C>\n```\n\nAdded in v2.10.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, B>\n  <E1, A, E2, B>(ma: IOEither<E1, A>, f: (a: A) => IOEither<E2, B>): IOEither<E1 | E2, B>\n}\n```\n\nAdded in v2.14.0\n\n## flatMapEither\n\n**Signature**\n\n```ts\nexport declare const flatMapEither: {\n  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, B>\n  <E1, A, E2, B>(self: IOEither<E1, A>, f: (a: A) => E.Either<E2, B>): IOEither<E1 | E2, B>\n}\n```\n\nAdded in v2.15.0\n\n## flatMapIO\n\n**Signature**\n\n```ts\nexport declare const flatMapIO: {\n  <A, B>(f: (a: A) => I.IO<B>): <E>(self: IOEither<E, A>) => IOEither<E, B>\n  <E, A, B>(self: IOEither<E, A>, f: (a: A) => I.IO<B>): IOEither<E, B>\n}\n```\n\nAdded in v2.16.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: IOEither<E1, A>\n  ) => IOEither<E2 | E1, NonNullable<B>>\n  <E1, A, B, E2>(self: IOEither<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): IOEither<\n    E1 | E2,\n    NonNullable<B>\n  >\n}\n```\n\nAdded in v2.15.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: IOEither<E1, A>) => IOEither<E2 | E1, B>\n  <E1, A, B, E2>(self: IOEither<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): IOEither<E1 | E2, B>\n}\n```\n\nAdded in v2.15.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <E, A>(mma: IOEither<E, IOEither<E, A>>) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## flattenW\n\nLess strict version of [`flatten`](#flatten).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const flattenW: <E1, E2, A>(mma: IOEither<E1, IOEither<E2, A>>) => IOEither<E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <E, A>(arr: readonly IOEither<E, A>[]) => IOEither<E, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## sequenceSeqArray\n\nEquivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceSeqArray: <E, A>(arr: readonly IOEither<E, A>[]) => IOEither<E, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <A, E, B>(\n  f: (a: A) => IOEither<E, B>\n) => (as: readonly A[]) => IOEither<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n) => (as: readonly A[]) => IOEither<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n) => (as: readonly A[]) => IOEither<E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyArrayWithIndexSeq\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndexSeq: <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n) => (as: readonly A[]) => IOEither<E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => IOEither<E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndexSeq\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => IOEither<E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseSeqArray\n\nEquivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArray: <A, E, B>(\n  f: (a: A) => IOEither<E, B>\n) => (as: readonly A[]) => IOEither<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseSeqArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n) => (as: readonly A[]) => IOEither<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'IOEither'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: IOEither<never, readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <E, A>(fa: IOEither<E, A>) => <B>(fab: IOEither<E, (a: A) => B>) => IOEither<E, B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <E, B>(second: IOEither<E, B>) => <A>(first: IOEither<E, A>) => IOEither<E, A>\n```\n\nAdded in v2.0.0\n\n## apFirstW\n\nLess strict version of [`apFirst`](#apfirst).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apFirstW: <E2, B>(\n  second: IOEither<E2, B>\n) => <E1, A>(first: IOEither<E1, A>) => IOEither<E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <E, B>(second: IOEither<E, B>) => <A>(first: IOEither<E, A>) => IOEither<E, B>\n```\n\nAdded in v2.0.0\n\n## apSecondW\n\nLess strict version of [`apSecond`](#apsecond).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSecondW: <E2, B>(\n  second: IOEither<E2, B>\n) => <E1, A>(first: IOEither<E1, A>) => IOEither<E2 | E1, B>\n```\n\nAdded in v2.12.0\n\n## apW\n\nLess strict version of [`ap`](#ap).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apW: <E2, A>(\n  fa: IOEither<E2, A>\n) => <E1, B>(fab: IOEither<E1, (a: A) => B>) => IOEither<E2 | E1, B>\n```\n\nAdded in v2.8.0\n\n## bracket\n\nMake sure that a resource is cleaned up in the event of an exception (\\*). The release action is called regardless of\nwhether the body action throws (\\*) or returns.\n\n(\\*) i.e. returns a `Left`\n\n**Signature**\n\n```ts\nexport declare const bracket: <E, A, B>(\n  acquire: IOEither<E, A>,\n  use: (a: A) => IOEither<E, B>,\n  release: (a: A, e: E.Either<E, B>) => IOEither<E, void>\n) => IOEither<E, B>\n```\n\nAdded in v2.0.0\n\n## bracketW\n\nLess strict version of [`bracket`](#bracket).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bracketW: <E1, A, E2, B, E3>(\n  acquire: IOEither<E1, A>,\n  use: (a: A) => IOEither<E2, B>,\n  release: (a: A, e: E.Either<E2, B>) => IOEither<E3, void>\n) => IOEither<E1 | E2 | E3, B>\n```\n\nAdded in v2.12.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare const swap: <E, A>(ma: IOEither<E, A>) => IOEither<A, E>\n```\n\nAdded in v2.0.0\n\n## throwError\n\n**Signature**\n\n```ts\nexport declare const throwError: <E, A>(e: E) => IOEither<E, A>\n```\n\nAdded in v2.7.0\n\n# zone of death\n\n## ~~Applicative~~\n\nUse [`ApplicativePar`](#applicativepar) instead\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative2<'IOEither'>\n```\n\nAdded in v2.7.0\n\n## ~~getApplyMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<IOEither<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getApplySemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<IOEither<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getIOValidation~~\n\nUse [`getApplicativeIOValidation`](#getapplicativeiovalidation) and [`getAltIOValidation`](#getaltiovalidation).\n\n**Signature**\n\n```ts\nexport declare function getIOValidation<E>(\n  SE: Semigroup<E>\n): Monad2C<URI, E> & Bifunctor2<URI> & Alt2C<URI, E> & MonadIO2C<URI, E> & MonadThrow2C<URI, E>\n```\n\nAdded in v2.0.0\n\n## ~~getSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <E, A>(S: Semigroup<A>) => Semigroup<IOEither<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~ioEither~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `IOE.Functor` instead of `IOE.ioEither`\n(where `IOE` is from `import IOE from 'fp-ts/IOEither'`)\n\n**Signature**\n\n```ts\nexport declare const ioEither: Monad2<'IOEither'> &\n  Bifunctor2<'IOEither'> &\n  Alt2<'IOEither'> &\n  MonadIO2<'IOEither'> &\n  MonadThrow2<'IOEither'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/IOOption.ts.md",
    "content": "---\ntitle: IOOption.ts\nnav_order: 52\nparent: Modules\n---\n\n## IOOption overview\n\n`IOOption<A>` represents a synchronous computation that either yields a value of type `A` or nothing.\n\nIf you want to represent a synchronous computation that never fails, please see `IO`.\nIf you want to represent a synchronous computation that may fail, please see `IOEither`.\n\nAdded in v2.12.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapEither](#tapeither)\n  - [tapIO](#tapio)\n- [constructors](#constructors)\n  - [none](#none)\n  - [of](#of)\n  - [some](#some)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromIO](#fromio)\n  - [fromIOEither](#fromioeither)\n  - [fromNullable](#fromnullable)\n  - [fromOption](#fromoption)\n  - [toNullable](#tonullable)\n  - [toUndefined](#toundefined)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [guard](#guard)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n  - [getOrElse](#getorelse)\n  - [getOrElseW](#getorelsew)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [separate](#separate)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Alternative](#alternative)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [Compactable](#compactable)\n  - [Filterable](#filterable)\n  - [FromEither](#fromeither)\n  - [FromIO](#fromio)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [Pointed](#pointed)\n  - [Zero](#zero)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainEitherK](#chaineitherk)\n  - [chainFirst](#chainfirst)\n  - [chainFirstEitherK](#chainfirsteitherk)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainIOK](#chainiok)\n  - [chainNullableK](#chainnullablek)\n  - [chainOptionK](#chainoptionk)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromIOK](#fromiok)\n  - [fromNullableK](#fromnullablek)\n  - [fromOptionK](#fromoptionk)\n  - [fromPredicate](#frompredicate)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [IOOption (interface)](#iooption-interface)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [match](#match)\n  - [matchE](#matche)\n  - [matchEW](#matchew)\n  - [matchW](#matchw)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapEither](#flatmapeither)\n  - [flatMapIO](#flatmapio)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatMapOption](#flatmapoption)\n  - [flatten](#flatten)\n- [traversing](#traversing)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [zero](#zero)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <A, _>(self: IOOption<A>, f: (a: A) => IOOption<_>): IOOption<A>\n  <A, _>(f: (a: A) => IOOption<_>): (self: IOOption<A>) => IOOption<A>\n}\n```\n\nAdded in v2.15.0\n\n## tapEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapEither: {\n  <A, E, _>(f: (a: A) => Either<E, _>): (self: IOOption<A>) => IOOption<A>\n  <A, E, _>(self: IOOption<A>, f: (a: A) => Either<E, _>): IOOption<A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as IOO from 'fp-ts/IOOption'\nimport * as O from 'fp-ts/Option'\nimport * as E from 'fp-ts/Either'\n\nconst compute = (value: number) =>\n  pipe(\n    IOO.of(value),\n    IOO.tapEither((value) => (value > 0 ? E.right('ok') : E.left('error')))\n  )\n\nassert.deepStrictEqual(compute(1)(), O.of(1))\nassert.deepStrictEqual(compute(-1)(), O.none)\n```\n\nAdded in v2.16.0\n\n## tapIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapIO: {\n  <A, _>(f: (a: A) => I.IO<_>): (self: IOOption<A>) => IOOption<A>\n  <A, _>(self: IOOption<A>, f: (a: A) => I.IO<_>): IOOption<A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as IOO from 'fp-ts/IOOption'\nimport * as O from 'fp-ts/Option'\nimport * as Console from 'fp-ts/Console'\n\n// Will produce `Hello, fp-ts` to the stdout\nconst effectA = pipe(\n  IOO.of('fp-ts'),\n  IOO.tapIO((value) => Console.log(`Hello, ${value}`))\n)\n\n// No output to the stdout\nconst effectB = pipe(\n  IOO.none as IOO.IOOption<string>,\n  IOO.tapIO((value) => Console.log(`Hello, ${value}`))\n)\n\nasync function test() {\n  assert.deepStrictEqual(effectA(), O.of('fp-ts'))\n  assert.deepStrictEqual(effectB(), O.none)\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## none\n\n**Signature**\n\n```ts\nexport declare const none: IOOption<never>\n```\n\nAdded in v2.12.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## some\n\n**Signature**\n\n```ts\nexport declare const some: <A>(a: A) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n# conversions\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <A>(fa: Either<unknown, A>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A>(fa: I.IO<A>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## fromIOEither\n\n**Signature**\n\n```ts\nexport declare const fromIOEither: <A>(fa: IOEither<unknown, A>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## fromNullable\n\n**Signature**\n\n```ts\nexport declare const fromNullable: <A>(a: A) => IOOption<NonNullable<A>>\n```\n\nAdded in v2.12.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <A>(fa: O.Option<A>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## toNullable\n\n**Signature**\n\n```ts\nexport declare const toNullable: <A>(ma: IOOption<A>) => I.IO<A | null>\n```\n\nAdded in v2.12.0\n\n## toUndefined\n\n**Signature**\n\n```ts\nexport declare const toUndefined: <A>(ma: IOOption<A>) => I.IO<A | undefined>\n```\n\nAdded in v2.12.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: IOOption<{}>\n```\n\nAdded in v2.12.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: IOOption<B>\n) => (fa: IOOption<A>) => IOOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.12.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => IOOption<B>\n) => (ma: IOOption<A>) => IOOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.12.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: IOOption<A>) => IOOption<{ readonly [K in N]: A }>\n```\n\nAdded in v2.12.0\n\n## guard\n\n**Signature**\n\n```ts\nexport declare const guard: (b: boolean) => IOOption<void>\n```\n\nAdded in v2.12.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: IOOption<A>) => IOOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\n**Signature**\n\n```ts\nexport declare const alt: <A>(second: LazyArg<IOOption<A>>) => (first: IOOption<A>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <B>(second: LazyArg<IOOption<B>>) => <A>(first: IOOption<A>) => IOOption<B | A>\n```\n\nAdded in v2.12.0\n\n## getOrElse\n\n**Signature**\n\n```ts\nexport declare const getOrElse: <A>(onNone: LazyArg<I.IO<A>>) => (fa: IOOption<A>) => I.IO<A>\n```\n\nAdded in v2.12.0\n\n## getOrElseW\n\nLess strict version of [`getOrElse`](#getorelse).\n\nThe `W` suffix (short for **W**idening) means that the handler return type will be merged.\n\n**Signature**\n\n```ts\nexport declare const getOrElseW: <B>(onNone: LazyArg<I.IO<B>>) => <A>(ma: IOOption<A>) => I.IO<B | A>\n```\n\nAdded in v2.12.0\n\n# filtering\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(fa: IOOption<O.Option<A>>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fb: IOOption<A>) => IOOption<B>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: IOOption<B>) => IOOption<B>\n  <A>(predicate: Predicate<A>): (fa: IOOption<A>) => IOOption<A>\n}\n```\n\nAdded in v2.12.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => (fga: IOOption<A>) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fb: IOOption<A>) => Separated<IOOption<A>, IOOption<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: IOOption<B>) => Separated<IOOption<B>, IOOption<B>>\n  <A>(predicate: Predicate<A>): (fa: IOOption<A>) => Separated<IOOption<A>, IOOption<A>>\n}\n```\n\nAdded in v2.12.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: IOOption<A>) => Separated<IOOption<B>, IOOption<C>>\n```\n\nAdded in v2.12.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare const separate: <A, B>(fa: IOOption<Either<A, B>>) => Separated<IOOption<A>, IOOption<B>>\n```\n\nAdded in v2.12.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Alternative\n\n**Signature**\n\n```ts\nexport declare const Alternative: Alternative1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Compactable\n\n**Signature**\n\n```ts\nexport declare const Compactable: Compactable1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: Filterable1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n## Zero\n\n**Signature**\n\n```ts\nexport declare const Zero: Zero1<'IOOption'>\n```\n\nAdded in v2.12.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => IOOption<B>) => (ma: IOOption<A>) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## chainEitherK\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: IOOption<A>) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => IOOption<B>) => (first: IOOption<A>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## chainFirstEitherK\n\nAlias of `tapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: IOOption<A>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## chainFirstIOK\n\nAlias of `tapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => (first: IOOption<A>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## chainIOK\n\nAlias of `flatMapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => (first: IOOption<A>) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## chainNullableK\n\nAlias of `flatMapNullable`.\n\n**Signature**\n\n```ts\nexport declare const chainNullableK: <A, B>(\n  f: (a: A) => B | null | undefined\n) => (ma: IOOption<A>) => IOOption<NonNullable<B>>\n```\n\nAdded in v2.12.0\n\n## chainOptionK\n\nAlias of `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionK: <A, B>(f: (a: A) => O.Option<B>) => (ma: IOOption<A>) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(f: (...a: A) => I.IO<B>) => (...a: A) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## fromNullableK\n\n**Signature**\n\n```ts\nexport declare const fromNullableK: <A extends readonly unknown[], B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => IOOption<NonNullable<B>>\n```\n\nAdded in v2.12.0\n\n## fromOptionK\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <A extends readonly unknown[], B>(\n  f: (...a: A) => O.Option<B>\n) => (...a: A) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => IOOption<B>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => IOOption<B>\n  <A>(predicate: Predicate<A>): (a: A) => IOOption<A>\n}\n```\n\nAdded in v2.12.0\n\n# mapping\n\n## as\n\nMaps the `Some` value of this `IOOption` to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <_>(self: IOOption<_>) => IOOption<A>\n  <_, A>(self: IOOption<_>, a: A): IOOption<A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the `Some` value of this `IOOption` to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <_>(self: IOOption<_>) => IOOption<void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: IOOption<(a: A) => B>) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (fa: IOOption<A>) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n# model\n\n## IOOption (interface)\n\n**Signature**\n\n```ts\nexport interface IOOption<A> extends IO<Option<A>> {}\n```\n\nAdded in v2.12.0\n\n# pattern matching\n\n## fold\n\nAlias of [`matchE`](#matche).\n\n**Signature**\n\n```ts\nexport declare const fold: <B, A>(onNone: () => I.IO<B>, onSome: (a: A) => I.IO<B>) => (ma: IOOption<A>) => I.IO<B>\n```\n\nAdded in v2.12.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: IOOption<A>) => I.IO<B>\n```\n\nAdded in v2.12.0\n\n## matchE\n\nThe `E` suffix (short for **E**ffect) means that the handlers return an effect (`IO`).\n\n**Signature**\n\n```ts\nexport declare const matchE: <B, A>(onNone: () => I.IO<B>, onSome: (a: A) => I.IO<B>) => (ma: IOOption<A>) => I.IO<B>\n```\n\nAdded in v2.12.0\n\n## matchEW\n\nLess strict version of [`matchE`](#matche).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchEW: <B, C, A>(\n  onNone: () => I.IO<B>,\n  onSome: (a: A) => I.IO<C>\n) => (ma: IOOption<A>) => I.IO<B | C>\n```\n\nAdded in v2.12.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <B, A, C>(onNone: () => B, onSome: (a: A) => C) => (ma: IOOption<A>) => I.IO<B | C>\n```\n\nAdded in v2.12.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A) => IOOption<B>): (ma: IOOption<A>) => IOOption<B>\n  <A, B>(ma: IOOption<A>, f: (a: A) => IOOption<B>): IOOption<B>\n}\n```\n\nAdded in v2.14.0\n\n## flatMapEither\n\n**Signature**\n\n```ts\nexport declare const flatMapEither: {\n  <A, B, _>(f: (a: A) => Either<_, B>): (self: IOOption<A>) => IOOption<B>\n  <A, B, _>(self: IOOption<A>, f: (a: A) => Either<_, B>): IOOption<B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapIO\n\n**Signature**\n\n```ts\nexport declare const flatMapIO: {\n  <A, B>(f: (a: A) => I.IO<B>): (self: IOOption<A>) => IOOption<B>\n  <A, B>(self: IOOption<A>, f: (a: A) => I.IO<B>): IOOption<B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapNullable\n\n**Signature**\n\n```ts\nexport declare const flatMapNullable: {\n  <A, B>(f: (a: A) => B | null | undefined): (self: IOOption<A>) => IOOption<B>\n  <A, B>(self: IOOption<A>, f: (a: A) => B | null | undefined): IOOption<B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapOption\n\n**Signature**\n\n```ts\nexport declare const flatMapOption: {\n  <A, B>(f: (a: A) => O.Option<B>): (self: IOOption<A>) => IOOption<B>\n  <A, B>(self: IOOption<A>, f: (a: A) => O.Option<B>): IOOption<B>\n}\n```\n\nAdded in v2.16.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: IOOption<IOOption<A>>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n# traversing\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => IOOption<B>\n) => (as: readonly A[]) => IOOption<readonly B[]>\n```\n\nAdded in v2.12.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => IOOption<B>\n) => (as: ReadonlyNonEmptyArray<A>) => IOOption<ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.12.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'IOOption'\n```\n\nAdded in v2.12.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.12.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: IOOption<readonly []>\n```\n\nAdded in v2.12.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(fa: IOOption<A>) => <B>(fab: IOOption<(a: A) => B>) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: IOOption<B>) => <A>(first: IOOption<A>) => IOOption<A>\n```\n\nAdded in v2.12.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: IOOption<B>) => <A>(first: IOOption<A>) => IOOption<B>\n```\n\nAdded in v2.12.0\n\n## zero\n\n**Signature**\n\n```ts\nexport declare const zero: <A>() => IOOption<A>\n```\n\nAdded in v2.12.0\n"
  },
  {
    "path": "docs/modules/IORef.ts.md",
    "content": "---\ntitle: IORef.ts\nnav_order: 53\nparent: Modules\n---\n\n## IORef overview\n\nMutable references in the `IO` monad\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [newIORef](#newioref)\n- [model](#model)\n  - [IORef (class)](#ioref-class)\n    - [write (method)](#write-method)\n    - [modify (method)](#modify-method)\n    - [read (property)](#read-property)\n\n---\n\n# constructors\n\n## newIORef\n\n**Signature**\n\n```ts\nexport declare function newIORef<A>(a: A): IO<IORef<A>>\n```\n\nAdded in v2.0.0\n\n# model\n\n## IORef (class)\n\n**Signature**\n\n```ts\nexport declare class IORef<A> {\n  constructor(private value: A)\n}\n```\n\n**Example**\n\n```ts\nimport { flatMap } from 'fp-ts/IO'\nimport { newIORef } from 'fp-ts/IORef'\n\nassert.strictEqual(flatMap(newIORef(1), (ref) => flatMap(ref.write(2), () => ref.read))(), 2)\n```\n\nAdded in v2.0.0\n\n### write (method)\n\n**Signature**\n\n```ts\nwrite(a: A): IO<void>\n```\n\nAdded in v2.0.0\n\n### modify (method)\n\n**Signature**\n\n```ts\nmodify(f: (a: A) => A): IO<void>\n```\n\nAdded in v2.0.0\n\n### read (property)\n\n**Signature**\n\n```ts\nreadonly read: IO<A>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Identity.ts.md",
    "content": "---\ntitle: Identity.ts\nnav_order: 47\nparent: Modules\n---\n\n## Identity overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [Extract](#extract)\n  - [extract](#extract)\n- [combinators](#combinators)\n  - [tap](#tap)\n- [constructors](#constructors)\n  - [of](#of)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [ChainRec](#chainrec)\n  - [Comonad](#comonad)\n  - [Foldable](#foldable)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [Pointed](#pointed)\n  - [Traversable](#traversable)\n  - [getEq](#geteq)\n  - [getShow](#getshow)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Identity (type alias)](#identity-type-alias)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [duplicate](#duplicate)\n  - [extend](#extend)\n- [zone of death](#zone-of-death)\n  - [~~identity~~](#identity)\n\n---\n\n# Extract\n\n## extract\n\n**Signature**\n\n```ts\nexport declare const extract: <A>(wa: A) => A\n```\n\nAdded in v2.6.2\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: { <A, _>(self: A, f: (a: A) => _): A; <A, _>(f: (a: A) => _): (self: A) => A }\n```\n\nAdded in v2.16.7\n\n# constructors\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => A\n```\n\nAdded in v2.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: {}\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: B\n) => (fa: A) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (ma: A) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: A) => { readonly [K in N]: A }\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: A) => { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\n**Signature**\n\n```ts\nexport declare const alt: <A>(that: () => A) => (fa: A) => A\n```\n\nAdded in v2.0.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <B>(that: () => B) => <A>(fa: A) => B | A\n```\n\nAdded in v2.9.0\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: A) => M\n```\n\nAdded in v2.0.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: A) => B\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: A) => B\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt1<'Identity'>\n```\n\nAdded in v2.7.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative1<'Identity'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply1<'Identity'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: Chain1<'Identity'>\n```\n\nAdded in v2.10.0\n\n## ChainRec\n\n**Signature**\n\n```ts\nexport declare const ChainRec: ChainRec1<'Identity'>\n```\n\nAdded in v2.7.0\n\n## Comonad\n\n**Signature**\n\n```ts\nexport declare const Comonad: Comonad1<'Identity'>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable1<'Identity'>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'Identity'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'Identity'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'Identity'>\n```\n\nAdded in v2.10.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable1<'Identity'>\n```\n\nAdded in v2.7.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare const getEq: <A>(E: Eq<A>) => Eq<A>\n```\n\nAdded in v2.0.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare const getShow: <A>(S: Show<A>) => Show<A>\n```\n\nAdded in v2.0.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => B) => (ma: A) => B\n```\n\nAdded in v2.0.0\n\n## chainFirst\n\nAlias of `tap`\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => B) => (first: A) => A\n```\n\nAdded in v2.0.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: (a: A) => B) => B\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (fa: A) => B\n```\n\nAdded in v2.0.0\n\n# model\n\n## Identity (type alias)\n\n**Signature**\n\n```ts\nexport type Identity<A> = A\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: { <A, B>(f: (a: A) => B): (ma: A) => B; <A, B>(ma: A, f: (a: A) => B): B }\n```\n\nAdded in v2.14.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: A) => A\n```\n\nAdded in v2.0.0\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence1<'Identity'>\n```\n\nAdded in v2.6.3\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse1<'Identity'>\n```\n\nAdded in v2.6.3\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Identity'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(fa: A) => <B>(fab: (a: A) => B) => B\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: B) => <A>(first: A) => A\n```\n\nAdded in v2.0.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: B) => <A>(first: A) => B\n```\n\nAdded in v2.0.0\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <A>(ma: A) => A\n```\n\nAdded in v2.0.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <A, B>(f: (wa: A) => B) => (wa: A) => B\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~identity~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `I.Functor` instead of `I.identity`\n(where `I` is from `import I from 'fp-ts/Identity'`)\n\n**Signature**\n\n```ts\nexport declare const identity: Monad1<'Identity'> &\n  Foldable1<'Identity'> &\n  Traversable1<'Identity'> &\n  Alt1<'Identity'> &\n  Comonad1<'Identity'> &\n  ChainRec1<'Identity'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Invariant.ts.md",
    "content": "---\ntitle: Invariant.ts\nnav_order: 49\nparent: Modules\n---\n\n## Invariant overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Invariant (interface)](#invariant-interface)\n  - [Invariant1 (interface)](#invariant1-interface)\n  - [Invariant2 (interface)](#invariant2-interface)\n  - [Invariant2C (interface)](#invariant2c-interface)\n  - [Invariant3 (interface)](#invariant3-interface)\n  - [Invariant3C (interface)](#invariant3c-interface)\n  - [Invariant4 (interface)](#invariant4-interface)\n\n---\n\n# model\n\n## Invariant (interface)\n\n**Signature**\n\n```ts\nexport interface Invariant<F> {\n  readonly URI: F\n  readonly imap: <A, B>(fa: HKT<F, A>, f: (a: A) => B, g: (b: B) => A) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Invariant1 (interface)\n\n**Signature**\n\n```ts\nexport interface Invariant1<F extends URIS> {\n  readonly URI: F\n  readonly imap: <A, B>(fa: Kind<F, A>, f: (a: A) => B, g: (b: B) => A) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## Invariant2 (interface)\n\n**Signature**\n\n```ts\nexport interface Invariant2<F extends URIS2> {\n  readonly URI: F\n  readonly imap: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Invariant2C (interface)\n\n**Signature**\n\n```ts\nexport interface Invariant2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly imap: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Invariant3 (interface)\n\n**Signature**\n\n```ts\nexport interface Invariant3<F extends URIS3> {\n  readonly URI: F\n  readonly imap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## Invariant3C (interface)\n\n**Signature**\n\n```ts\nexport interface Invariant3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly imap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.4.2\n\n## Invariant4 (interface)\n\n**Signature**\n\n```ts\nexport interface Invariant4<F extends URIS4> {\n  readonly URI: F\n  readonly imap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.4.2\n"
  },
  {
    "path": "docs/modules/JoinSemilattice.ts.md",
    "content": "---\ntitle: JoinSemilattice.ts\nnav_order: 54\nparent: Modules\n---\n\n## JoinSemilattice overview\n\nA join-semilattice (or upper semilattice) is a semilattice whose operation is called `join`, and which can be thought\nof as a least upper bound.\n\nA `JoinSemilattice` must satisfy the following laws:\n\n- Associativity: `a ∨ (b ∨ c) <-> (a ∨ b) ∨ c`\n- Commutativity: `a ∨ b <-> b ∨ a`\n- Idempotency: `a ∨ a <-> a`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [JoinSemilattice (interface)](#joinsemilattice-interface)\n\n---\n\n# model\n\n## JoinSemilattice (interface)\n\n**Signature**\n\n```ts\nexport interface JoinSemilattice<A> {\n  readonly join: (x: A, y: A) => A\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Json.ts.md",
    "content": "---\ntitle: Json.ts\nnav_order: 55\nparent: Modules\n---\n\n## Json overview\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [utils](#utils)\n  - [Json (type alias)](#json-type-alias)\n  - [JsonArray (interface)](#jsonarray-interface)\n  - [JsonRecord (interface)](#jsonrecord-interface)\n  - [parse](#parse)\n  - [stringify](#stringify)\n\n---\n\n# utils\n\n## Json (type alias)\n\n**Signature**\n\n```ts\nexport type Json = boolean | number | string | null | JsonArray | JsonRecord\n```\n\nAdded in v2.10.0\n\n## JsonArray (interface)\n\n**Signature**\n\n```ts\nexport interface JsonArray extends ReadonlyArray<Json> {}\n```\n\nAdded in v2.10.0\n\n## JsonRecord (interface)\n\n**Signature**\n\n```ts\nexport interface JsonRecord {\n  readonly [key: string]: Json\n}\n```\n\nAdded in v2.10.0\n\n## parse\n\nConverts a JavaScript Object Notation (JSON) string into a `Json` type.\n\n**Signature**\n\n```ts\nexport declare const parse: (s: string) => Either<unknown, Json>\n```\n\n**Example**\n\n```ts\nimport * as J from 'fp-ts/Json'\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('{\"a\":1}', J.parse), E.right({ a: 1 }))\nassert.deepStrictEqual(\n  pipe('{\"a\":}', J.parse),\n  E.left(new SyntaxError(`Unexpected token '}', \"{\"a\":}\" is not valid JSON`))\n)\n```\n\nAdded in v2.10.0\n\n## stringify\n\nConverts a JavaScript value to a JavaScript Object Notation (JSON) string.\n\n**Signature**\n\n```ts\nexport declare const stringify: <A>(a: A) => Either<unknown, string>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport * as J from 'fp-ts/Json'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(J.stringify({ a: 1 }), E.right('{\"a\":1}'))\nconst circular: any = { ref: null }\ncircular.ref = circular\nassert.deepStrictEqual(\n  pipe(\n    J.stringify(circular),\n    E.mapLeft((e) => e instanceof Error && e.message.includes('Converting circular structure to JSON'))\n  ),\n  E.left(true)\n)\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/Lattice.ts.md",
    "content": "---\ntitle: Lattice.ts\nnav_order: 56\nparent: Modules\n---\n\n## Lattice overview\n\nA `Lattice` must satisfy the following in addition to `JoinSemilattice` and `MeetSemilattice` laws:\n\n- Absorbtion law for meet: `a ∧ (a ∨ b) <-> a`\n- Absorbtion law for join: `a ∨ (a ∧ b) <-> a`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Lattice (interface)](#lattice-interface)\n\n---\n\n# model\n\n## Lattice (interface)\n\n**Signature**\n\n```ts\nexport interface Lattice<A> extends JoinSemilattice<A>, MeetSemilattice<A> {}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Magma.ts.md",
    "content": "---\ntitle: Magma.ts\nnav_order: 57\nparent: Modules\n---\n\n## Magma overview\n\nA `Magma` is a pair `(A, concat)` in which `A` is a non-empty set and `concat` is a binary operation on `A`\n\nSee [Semigroup](https://gcanti.github.io/fp-ts/modules/Semigroup.ts.html) for some instances.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Magma (interface)](#magma-interface)\n- [utils](#utils)\n  - [concatAll](#concatall)\n  - [endo](#endo)\n  - [filterFirst](#filterfirst)\n  - [filterSecond](#filtersecond)\n  - [reverse](#reverse)\n\n---\n\n# model\n\n## Magma (interface)\n\n**Signature**\n\n```ts\nexport interface Magma<A> {\n  readonly concat: (x: A, y: A) => A\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## concatAll\n\nGiven a sequence of `as`, concat them and return the total.\n\nIf `as` is empty, return the provided `startWith` value.\n\n**Signature**\n\n```ts\nexport declare const concatAll: <A>(M: Magma<A>) => (startWith: A) => (as: readonly A[]) => A\n```\n\n**Example**\n\n```ts\nimport { concatAll } from 'fp-ts/Magma'\nimport * as N from 'fp-ts/number'\n\nconst subAll = concatAll(N.MagmaSub)(0)\n\nassert.deepStrictEqual(subAll([1, 2, 3]), -6)\n```\n\nAdded in v2.11.0\n\n## endo\n\n**Signature**\n\n```ts\nexport declare const endo: <A>(f: Endomorphism<A>) => (M: Magma<A>) => Magma<A>\n```\n\nAdded in v2.11.0\n\n## filterFirst\n\n**Signature**\n\n```ts\nexport declare const filterFirst: <A>(predicate: Predicate<A>) => (M: Magma<A>) => Magma<A>\n```\n\nAdded in v2.11.0\n\n## filterSecond\n\n**Signature**\n\n```ts\nexport declare const filterSecond: <A>(predicate: Predicate<A>) => (M: Magma<A>) => Magma<A>\n```\n\nAdded in v2.11.0\n\n## reverse\n\nThe dual of a `Magma`, obtained by swapping the arguments of `concat`.\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(M: Magma<A>) => Magma<A>\n```\n\n**Example**\n\n```ts\nimport { reverse, concatAll } from 'fp-ts/Magma'\nimport * as N from 'fp-ts/number'\n\nconst subAll = concatAll(reverse(N.MagmaSub))(0)\n\nassert.deepStrictEqual(subAll([1, 2, 3]), 2)\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/Map.ts.md",
    "content": "---\ntitle: Map.ts\nnav_order: 58\nparent: Modules\n---\n\n## Map overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [fromFoldable](#fromfoldable)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [getFilterableWithIndex](#getfilterablewithindex)\n  - [getWitherable](#getwitherable)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [separate](#separate)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [getFoldable](#getfoldable)\n  - [getFoldableWithIndex](#getfoldablewithindex)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n- [instances](#instances)\n  - [Compactable](#compactable)\n  - [Filterable](#filterable)\n  - [Functor](#functor)\n  - [getDifferenceMagma](#getdifferencemagma)\n  - [getEq](#geteq)\n  - [getIntersectionSemigroup](#getintersectionsemigroup)\n  - [getMonoid](#getmonoid)\n  - [getShow](#getshow)\n  - [getUnionMonoid](#getunionmonoid)\n  - [getUnionSemigroup](#getunionsemigroup)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n  - [mapWithIndex](#mapwithindex)\n- [traversing](#traversing)\n  - [getTraversableWithIndex](#gettraversablewithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [collect](#collect)\n  - [deleteAt](#deleteat)\n  - [difference](#difference)\n  - [elem](#elem)\n  - [filterMapWithIndex](#filtermapwithindex)\n  - [filterWithIndex](#filterwithindex)\n  - [intersection](#intersection)\n  - [isEmpty](#isempty)\n  - [isSubmap](#issubmap)\n  - [keys](#keys)\n  - [lookup](#lookup)\n  - [lookupWithKey](#lookupwithkey)\n  - [member](#member)\n  - [modifyAt](#modifyat)\n  - [partitionMapWithIndex](#partitionmapwithindex)\n  - [partitionWithIndex](#partitionwithindex)\n  - [pop](#pop)\n  - [singleton](#singleton)\n  - [size](#size)\n  - [toArray](#toarray)\n  - [toUnfoldable](#tounfoldable)\n  - [union](#union)\n  - [updateAt](#updateat)\n  - [upsertAt](#upsertat)\n  - [values](#values)\n- [zone of death](#zone-of-death)\n  - [~~empty~~](#empty)\n  - [~~insertAt~~](#insertat)\n  - [~~map\\_~~](#map_)\n\n---\n\n# constructors\n\n## fromFoldable\n\nCreate a map from a foldable collection of key/value pairs, using the\nspecified `Magma` to combine values for duplicate keys.\n\n**Signature**\n\n```ts\nexport declare function fromFoldable<F extends URIS3, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable3<F>\n): <R, E>(fka: Kind3<F, R, E, [K, A]>) => Map<K, A>\nexport declare function fromFoldable<F extends URIS2, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable2<F>\n): <E>(fka: Kind2<F, E, [K, A]>) => Map<K, A>\nexport declare function fromFoldable<F extends URIS, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable1<F>\n): (fka: Kind<F, [K, A]>) => Map<K, A>\nexport declare function fromFoldable<F, K, A>(E: Eq<K>, M: Magma<A>, F: Foldable<F>): (fka: HKT<F, [K, A]>) => Map<K, A>\n```\n\nAdded in v2.0.0\n\n# filtering\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <K, A>(fa: Map<K, O.Option<A>>) => Map<K, A>\n```\n\nAdded in v2.0.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: Map<K, A>) => Map<K, B>\n  <A>(predicate: Predicate<A>): <K, B extends A>(fb: Map<K, B>) => Map<K, B>\n  <A>(predicate: Predicate<A>): <K>(fa: Map<K, A>) => Map<K, A>\n}\n```\n\nAdded in v2.0.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => <K>(fa: Map<K, A>) => Map<K, B>\n```\n\nAdded in v2.0.0\n\n## getFilterableWithIndex\n\n**Signature**\n\n```ts\nexport declare function getFilterableWithIndex<K = never>(): FilterableWithIndex2C<URI, K, K>\n```\n\nAdded in v2.0.0\n\n## getWitherable\n\n**Signature**\n\n```ts\nexport declare function getWitherable<K>(O: Ord<K>): Witherable2C<URI, K> & TraversableWithIndex2C<URI, K, K>\n```\n\nAdded in v2.0.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: Map<K, A>) => Separated<Map<K, A>, Map<K, B>>\n  <A>(predicate: Predicate<A>): <K, B extends A>(fb: Map<K, B>) => Separated<Map<K, B>, Map<K, B>>\n  <A>(predicate: Predicate<A>): <K>(fa: Map<K, A>) => Separated<Map<K, A>, Map<K, A>>\n}\n```\n\nAdded in v2.0.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <K>(fa: Map<K, A>) => Separated<Map<K, B>, Map<K, C>>\n```\n\nAdded in v2.0.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare const separate: <K, A, B>(fa: Map<K, Either<A, B>>) => Separated<Map<K, A>, Map<K, B>>\n```\n\nAdded in v2.0.0\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <K>(O: Ord<K>) => <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (m: Map<K, A>) => M\n```\n\nAdded in v2.11.0\n\n## foldMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const foldMapWithIndex: <K>(\n  O: Ord<K>\n) => <M>(M: Monoid<M>) => <A>(f: (k: K, a: A) => M) => (m: Map<K, A>) => M\n```\n\nAdded in v2.11.0\n\n## getFoldable\n\n**Signature**\n\n```ts\nexport declare const getFoldable: <K>(O: Ord<K>) => Foldable2C<'Map', K>\n```\n\nAdded in v2.11.0\n\n## getFoldableWithIndex\n\n**Signature**\n\n```ts\nexport declare const getFoldableWithIndex: <K>(O: Ord<K>) => FoldableWithIndex2C<'Map', K, K>\n```\n\nAdded in v2.10.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <K>(O: Ord<K>) => <B, A>(b: B, f: (b: B, a: A) => B) => (m: Map<K, A>) => B\n```\n\nAdded in v2.11.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <K>(O: Ord<K>) => <B, A>(b: B, f: (a: A, b: B) => B) => (m: Map<K, A>) => B\n```\n\nAdded in v2.11.0\n\n## reduceRightWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceRightWithIndex: <K>(\n  O: Ord<K>\n) => <B, A>(b: B, f: (k: K, a: A, b: B) => B) => (m: Map<K, A>) => B\n```\n\nAdded in v2.11.0\n\n## reduceWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceWithIndex: <K>(O: Ord<K>) => <B, A>(b: B, f: (k: K, b: B, a: A) => B) => (m: Map<K, A>) => B\n```\n\nAdded in v2.11.0\n\n# instances\n\n## Compactable\n\n**Signature**\n\n```ts\nexport declare const Compactable: Compactable2<'Map'>\n```\n\nAdded in v2.7.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: Filterable2<'Map'>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'Map'>\n```\n\nAdded in v2.7.0\n\n## getDifferenceMagma\n\n**Signature**\n\n```ts\nexport declare const getDifferenceMagma: <K>(E: Eq<K>) => <A>() => Magma<Map<K, A>>\n```\n\nAdded in v2.11.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare const getEq: <K, A>(SK: Eq<K>, SA: Eq<A>) => Eq<Map<K, A>>\n```\n\nAdded in v2.0.0\n\n## getIntersectionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getIntersectionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<Map<K, A>>\n```\n\nAdded in v2.11.0\n\n## getMonoid\n\nGets `Monoid` instance for Maps given `Semigroup` instance for their values\n\n**Signature**\n\n```ts\nexport declare function getMonoid<K, A>(SK: Eq<K>, SA: Semigroup<A>): Monoid<Map<K, A>>\n```\n\nAdded in v2.0.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare const getShow: <K, A>(SK: Show<K>, SA: Show<A>) => Show<Map<K, A>>\n```\n\nAdded in v2.0.0\n\n## getUnionMonoid\n\n**Signature**\n\n```ts\nexport declare const getUnionMonoid: <K, A>(E: Eq<K>, S: Semigroup<A>) => Monoid<Map<K, A>>\n```\n\nAdded in v2.11.0\n\n## getUnionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<Map<K, A>>\n```\n\nAdded in v2.11.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: Map<E, (a: A) => B>) => Map<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <K>(fa: Map<K, A>) => Map<K, B>\n```\n\nAdded in v2.0.0\n\n## mapWithIndex\n\n**Signature**\n\n```ts\nexport declare const mapWithIndex: <K, A, B>(f: (k: K, a: A) => B) => (fa: Map<K, A>) => Map<K, B>\n```\n\nAdded in v2.7.1\n\n# traversing\n\n## getTraversableWithIndex\n\n**Signature**\n\n```ts\nexport declare const getTraversableWithIndex: <K>(O: Ord<K>) => TraversableWithIndex2C<'Map', K, K>\n```\n\nAdded in v2.10.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Map'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## collect\n\n**Signature**\n\n```ts\nexport declare function collect<K>(O: Ord<K>): <A, B>(f: (k: K, a: A) => B) => (m: Map<K, A>) => Array<B>\n```\n\nAdded in v2.0.0\n\n## deleteAt\n\nDelete a key and value from a map\n\n**Signature**\n\n```ts\nexport declare const deleteAt: <K>(E: Eq<K>) => (k: K) => <A>(m: Map<K, A>) => Map<K, A>\n```\n\nAdded in v2.0.0\n\n## difference\n\n**Signature**\n\n```ts\nexport declare const difference: <K>(E: Eq<K>) => <A>(_second: Map<K, A>) => (first: Map<K, A>) => Map<K, A>\n```\n\nAdded in v2.11.0\n\n## elem\n\nTest whether or not a value is a member of a map\n\n**Signature**\n\n```ts\nexport declare const elem: <A>(E: Eq<A>) => { (a: A): <K>(m: Map<K, A>) => boolean; <K>(a: A, m: Map<K, A>): boolean }\n```\n\nAdded in v2.0.0\n\n## filterMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const filterMapWithIndex: <K, A, B>(f: (k: K, a: A) => O.Option<B>) => (fa: Map<K, A>) => Map<K, B>\n```\n\nAdded in v2.10.0\n\n## filterWithIndex\n\n**Signature**\n\n```ts\nexport declare function filterWithIndex<K, A, B extends A>(p: (k: K, a: A) => a is B): (m: Map<K, A>) => Map<K, B>\nexport declare function filterWithIndex<K, A>(p: (k: K, a: A) => boolean): <B extends A>(m: Map<K, B>) => Map<K, B>\nexport declare function filterWithIndex<K, A>(p: (k: K, a: A) => boolean): (m: Map<K, A>) => Map<K, A>\n```\n\nAdded in v2.10.0\n\n## intersection\n\n**Signature**\n\n```ts\nexport declare const intersection: <K, A>(\n  E: Eq<K>,\n  M: Magma<A>\n) => (second: Map<K, A>) => (first: Map<K, A>) => Map<K, A>\n```\n\nAdded in v2.11.0\n\n## isEmpty\n\nTest whether or not a map is empty\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <K, A>(m: Map<K, A>) => boolean\n```\n\nAdded in v2.0.0\n\n## isSubmap\n\nTest whether or not one `Map` contains all of the keys and values contained in another `Map`\n\n**Signature**\n\n```ts\nexport declare const isSubmap: <K, A>(\n  SK: Eq<K>,\n  SA: Eq<A>\n) => { (that: Map<K, A>): (me: Map<K, A>) => boolean; (me: Map<K, A>, that: Map<K, A>): boolean }\n```\n\nAdded in v2.0.0\n\n## keys\n\nGet a sorted `Array` of the keys contained in a `Map`.\n\n**Signature**\n\n```ts\nexport declare const keys: <K>(O: Ord<K>) => <A>(m: Map<K, A>) => K[]\n```\n\nAdded in v2.0.0\n\n## lookup\n\nLookup the value for a key in a `Map`.\n\n**Signature**\n\n```ts\nexport declare const lookup: <K>(E: Eq<K>) => {\n  (k: K): <A>(m: Map<K, A>) => O.Option<A>\n  <A>(k: K, m: Map<K, A>): O.Option<A>\n}\n```\n\nAdded in v2.0.0\n\n## lookupWithKey\n\nLookup the value for a key in a `Map`.\nIf the result is a `Some`, the existing key is also returned.\n\n**Signature**\n\n```ts\nexport declare function lookupWithKey<K>(E: Eq<K>): {\n  (k: K): <A>(m: Map<K, A>) => Option<[K, A]>\n  <A>(k: K, m: Map<K, A>): Option<[K, A]>\n}\n```\n\nAdded in v2.0.0\n\n## member\n\nTest whether or not a key exists in a map\n\n**Signature**\n\n```ts\nexport declare const member: <K>(E: Eq<K>) => { (k: K): <A>(m: Map<K, A>) => boolean; <A>(k: K, m: Map<K, A>): boolean }\n```\n\nAdded in v2.0.0\n\n## modifyAt\n\n**Signature**\n\n```ts\nexport declare const modifyAt: <K>(E: Eq<K>) => <A>(k: K, f: (a: A) => A) => (m: Map<K, A>) => O.Option<Map<K, A>>\n```\n\nAdded in v2.0.0\n\n## partitionMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const partitionMapWithIndex: <K, A, B, C>(\n  f: (k: K, a: A) => Either<B, C>\n) => (fa: Map<K, A>) => Separated<Map<K, B>, Map<K, C>>\n```\n\nAdded in v2.10.0\n\n## partitionWithIndex\n\n**Signature**\n\n```ts\nexport declare function partitionWithIndex<K, A, B extends A>(\n  predicateWithIndex: (k: K, a: A) => a is B\n): (fa: Map<K, A>) => Separated<Map<K, A>, Map<K, B>>\nexport declare function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): <B extends A>(fb: Map<K, B>) => Separated<Map<K, B>, Map<K, B>>\nexport declare function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): (fa: Map<K, A>) => Separated<Map<K, A>, Map<K, A>>\n```\n\nAdded in v2.10.0\n\n## pop\n\nDelete a key and value from a map, returning the value as well as the subsequent map\n\n**Signature**\n\n```ts\nexport declare function pop<K>(E: Eq<K>): (k: K) => <A>(m: Map<K, A>) => Option<[A, Map<K, A>]>\n```\n\nAdded in v2.0.0\n\n## singleton\n\nCreate a map with one key/value pair\n\n**Signature**\n\n```ts\nexport declare const singleton: <K, A>(k: K, a: A) => Map<K, A>\n```\n\nAdded in v2.0.0\n\n## size\n\nCalculate the number of key/value pairs in a map\n\n**Signature**\n\n```ts\nexport declare const size: <K, A>(m: Map<K, A>) => number\n```\n\nAdded in v2.0.0\n\n## toArray\n\nGet a sorted `Array` of the key/value pairs contained in a `Map`.\n\n**Signature**\n\n```ts\nexport declare function toArray<K>(O: Ord<K>): <A>(m: Map<K, A>) => Array<[K, A]>\n```\n\nAdded in v2.0.0\n\n## toUnfoldable\n\nUnfolds a map into a list of key/value pairs\n\n**Signature**\n\n```ts\nexport declare function toUnfoldable<K, F extends URIS>(\n  ord: Ord<K>,\n  U: Unfoldable1<F>\n): <A>(d: Map<K, A>) => Kind<F, [K, A]>\nexport declare function toUnfoldable<K, F>(ord: Ord<K>, U: Unfoldable<F>): <A>(d: Map<K, A>) => HKT<F, [K, A]>\n```\n\nAdded in v2.0.0\n\n## union\n\n**Signature**\n\n```ts\nexport declare const union: <K, A>(E: Eq<K>, M: Magma<A>) => (second: Map<K, A>) => (first: Map<K, A>) => Map<K, A>\n```\n\nAdded in v2.11.0\n\n## updateAt\n\n**Signature**\n\n```ts\nexport declare const updateAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: Map<K, A>) => O.Option<Map<K, A>>\n```\n\nAdded in v2.0.0\n\n## upsertAt\n\nInsert or replace a key/value pair in a `Map`.\n\n**Signature**\n\n```ts\nexport declare const upsertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: Map<K, A>) => Map<K, A>\n```\n\nAdded in v2.0.0\n\n## values\n\nGet a sorted `Array` of the values contained in a `Map`.\n\n**Signature**\n\n```ts\nexport declare const values: <A>(O: Ord<A>) => <K>(m: Map<K, A>) => A[]\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~empty~~\n\nUse a `new Map()` instead.\n\n**Signature**\n\n```ts\nexport declare const empty: Map<never, never>\n```\n\nAdded in v2.0.0\n\n## ~~insertAt~~\n\nUse [`upsertAt`](#upsertat) instead.\n\n**Signature**\n\n```ts\nexport declare const insertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: Map<K, A>) => Map<K, A>\n```\n\nAdded in v2.0.0\n\n## ~~map\\_~~\n\nUse [`Filterable`](#filterable) instead.\n\n**Signature**\n\n```ts\nexport declare const map_: Filterable2<'Map'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/MeetSemilattice.ts.md",
    "content": "---\ntitle: MeetSemilattice.ts\nnav_order: 59\nparent: Modules\n---\n\n## MeetSemilattice overview\n\nA meet-semilattice (or lower semilattice) is a semilattice whose operation is called `meet`, and which can be thought\nof as a greatest lower bound.\n\nA `MeetSemilattice` must satisfy the following laws:\n\n- Associativity: `a ∧ (b ∧ c) <-> (a ∧ b) ∧ c`\n- Commutativity: `a ∧ b <-> b ∧ a`\n- Idempotency: `a ∧ a <-> a`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [MeetSemilattice (interface)](#meetsemilattice-interface)\n\n---\n\n# model\n\n## MeetSemilattice (interface)\n\n**Signature**\n\n```ts\nexport interface MeetSemilattice<A> {\n  readonly meet: (x: A, y: A) => A\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Monad.ts.md",
    "content": "---\ntitle: Monad.ts\nnav_order: 60\nparent: Modules\n---\n\n## Monad overview\n\nThe `Monad` type class combines the operations of the `Chain` and\n`Applicative` type classes. Therefore, `Monad` instances represent type\nconstructors which support sequential composition, and also lifting of\nfunctions of arbitrary arity.\n\nInstances must satisfy the following laws in addition to the `Applicative` and `Chain` laws:\n\n1. Left identity: `M.chain(M.of(a), f) <-> f(a)`\n2. Right identity: `M.chain(fa, M.of) <-> fa`\n\nNote. `Functor`'s `map` can be derived: `A.map = (fa, f) => A.chain(fa, a => A.of(f(a)))`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Monad (interface)](#monad-interface)\n  - [Monad1 (interface)](#monad1-interface)\n  - [Monad2 (interface)](#monad2-interface)\n  - [Monad2C (interface)](#monad2c-interface)\n  - [Monad3 (interface)](#monad3-interface)\n  - [Monad3C (interface)](#monad3c-interface)\n  - [Monad4 (interface)](#monad4-interface)\n\n---\n\n# model\n\n## Monad (interface)\n\n**Signature**\n\n```ts\nexport interface Monad<F> extends Applicative<F>, Chain<F> {}\n```\n\nAdded in v2.0.0\n\n## Monad1 (interface)\n\n**Signature**\n\n```ts\nexport interface Monad1<F extends URIS> extends Applicative1<F>, Chain1<F> {}\n```\n\nAdded in v2.0.0\n\n## Monad2 (interface)\n\n**Signature**\n\n```ts\nexport interface Monad2<M extends URIS2> extends Applicative2<M>, Chain2<M> {}\n```\n\nAdded in v2.0.0\n\n## Monad2C (interface)\n\n**Signature**\n\n```ts\nexport interface Monad2C<M extends URIS2, L> extends Applicative2C<M, L>, Chain2C<M, L> {}\n```\n\nAdded in v2.0.0\n\n## Monad3 (interface)\n\n**Signature**\n\n```ts\nexport interface Monad3<M extends URIS3> extends Applicative3<M>, Chain3<M> {}\n```\n\nAdded in v2.0.0\n\n## Monad3C (interface)\n\n**Signature**\n\n```ts\nexport interface Monad3C<M extends URIS3, E> extends Applicative3C<M, E>, Chain3C<M, E> {}\n```\n\nAdded in v2.2.0\n\n## Monad4 (interface)\n\n**Signature**\n\n```ts\nexport interface Monad4<M extends URIS4> extends Applicative4<M>, Chain4<M> {}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/MonadIO.ts.md",
    "content": "---\ntitle: MonadIO.ts\nnav_order: 61\nparent: Modules\n---\n\n## MonadIO overview\n\nLift a computation from the `IO` monad\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [MonadIO (interface)](#monadio-interface)\n  - [MonadIO1 (interface)](#monadio1-interface)\n  - [MonadIO2 (interface)](#monadio2-interface)\n  - [MonadIO2C (interface)](#monadio2c-interface)\n  - [MonadIO3 (interface)](#monadio3-interface)\n  - [MonadIO3C (interface)](#monadio3c-interface)\n  - [MonadIO4 (interface)](#monadio4-interface)\n\n---\n\n# model\n\n## MonadIO (interface)\n\n**Signature**\n\n```ts\nexport interface MonadIO<M> extends Monad<M>, FromIO<M> {}\n```\n\nAdded in v2.0.0\n\n## MonadIO1 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadIO1<M extends URIS> extends Monad1<M>, FromIO1<M> {}\n```\n\nAdded in v2.0.0\n\n## MonadIO2 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadIO2<M extends URIS2> extends Monad2<M>, FromIO2<M> {}\n```\n\nAdded in v2.0.0\n\n## MonadIO2C (interface)\n\n**Signature**\n\n```ts\nexport interface MonadIO2C<M extends URIS2, E> extends Monad2C<M, E>, FromIO2C<M, E> {}\n```\n\nAdded in v2.0.0\n\n## MonadIO3 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadIO3<M extends URIS3> extends Monad3<M>, FromIO3<M> {}\n```\n\nAdded in v2.0.0\n\n## MonadIO3C (interface)\n\n**Signature**\n\n```ts\nexport interface MonadIO3C<M extends URIS3, E> extends Monad3C<M, E>, FromIO3C<M, E> {}\n```\n\nAdded in v2.2.0\n\n## MonadIO4 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadIO4<M extends URIS4> extends Monad4<M>, FromIO4<M> {}\n```\n\nAdded in v2.4.4\n"
  },
  {
    "path": "docs/modules/MonadTask.ts.md",
    "content": "---\ntitle: MonadTask.ts\nnav_order: 62\nparent: Modules\n---\n\n## MonadTask overview\n\nLift a computation from the `Task` monad\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [MonadTask (interface)](#monadtask-interface)\n  - [MonadTask1 (interface)](#monadtask1-interface)\n  - [MonadTask2 (interface)](#monadtask2-interface)\n  - [MonadTask2C (interface)](#monadtask2c-interface)\n  - [MonadTask3 (interface)](#monadtask3-interface)\n  - [MonadTask3C (interface)](#monadtask3c-interface)\n  - [MonadTask4 (interface)](#monadtask4-interface)\n\n---\n\n# model\n\n## MonadTask (interface)\n\n**Signature**\n\n```ts\nexport interface MonadTask<M> extends MonadIO<M>, FromTask<M> {}\n```\n\nAdded in v2.0.0\n\n## MonadTask1 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadTask1<M extends URIS> extends MonadIO1<M>, FromTask1<M> {}\n```\n\nAdded in v2.0.0\n\n## MonadTask2 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadTask2<M extends URIS2> extends MonadIO2<M>, FromTask2<M> {}\n```\n\nAdded in v2.0.0\n\n## MonadTask2C (interface)\n\n**Signature**\n\n```ts\nexport interface MonadTask2C<M extends URIS2, E> extends MonadIO2C<M, E>, FromTask2C<M, E> {}\n```\n\nAdded in v2.0.0\n\n## MonadTask3 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadTask3<M extends URIS3> extends MonadIO3<M>, FromTask3<M> {}\n```\n\nAdded in v2.0.0\n\n## MonadTask3C (interface)\n\n**Signature**\n\n```ts\nexport interface MonadTask3C<M extends URIS3, E> extends MonadIO3C<M, E>, FromTask3C<M, E> {}\n```\n\nAdded in v2.2.0\n\n## MonadTask4 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadTask4<M extends URIS4> extends MonadIO4<M>, FromTask4<M> {}\n```\n\nAdded in v2.4.4\n"
  },
  {
    "path": "docs/modules/MonadThrow.ts.md",
    "content": "---\ntitle: MonadThrow.ts\nnav_order: 63\nparent: Modules\n---\n\n## MonadThrow overview\n\nThe `MonadThrow` type class represents those monads which support errors via\n`throwError`, where `throwError(e)` halts, yielding the error `e`.\n\nLaws:\n\n- Left zero: `M.chain(M.throwError(e), f) = M.throwError(e)`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [MonadThrow (interface)](#monadthrow-interface)\n  - [MonadThrow1 (interface)](#monadthrow1-interface)\n  - [MonadThrow2 (interface)](#monadthrow2-interface)\n  - [MonadThrow2C (interface)](#monadthrow2c-interface)\n  - [MonadThrow3 (interface)](#monadthrow3-interface)\n  - [MonadThrow3C (interface)](#monadthrow3c-interface)\n  - [MonadThrow4 (interface)](#monadthrow4-interface)\n\n---\n\n# model\n\n## MonadThrow (interface)\n\n**Signature**\n\n```ts\nexport interface MonadThrow<M> extends Monad<M> {\n  readonly throwError: <E, A>(e: E) => HKT<M, A>\n}\n```\n\nAdded in v2.0.0\n\n## MonadThrow1 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadThrow1<M extends URIS> extends Monad1<M> {\n  readonly throwError: <E, A>(e: E) => Kind<M, A>\n}\n```\n\nAdded in v2.0.0\n\n## MonadThrow2 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadThrow2<M extends URIS2> extends Monad2<M> {\n  readonly throwError: <E, A>(e: E) => Kind2<M, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## MonadThrow2C (interface)\n\n**Signature**\n\n```ts\nexport interface MonadThrow2C<M extends URIS2, E> extends Monad2C<M, E> {\n  readonly throwError: <A>(e: E) => Kind2<M, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## MonadThrow3 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadThrow3<M extends URIS3> extends Monad3<M> {\n  readonly throwError: <R, E, A>(e: E) => Kind3<M, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## MonadThrow3C (interface)\n\n**Signature**\n\n```ts\nexport interface MonadThrow3C<M extends URIS3, E> extends Monad3C<M, E> {\n  readonly throwError: <R, A>(e: E) => Kind3<M, R, E, A>\n}\n```\n\nAdded in v2.2.0\n\n## MonadThrow4 (interface)\n\n**Signature**\n\n```ts\nexport interface MonadThrow4<M extends URIS4> extends Monad4<M> {\n  readonly throwError: <S, R, E, A>(e: E) => Kind4<M, S, R, E, A>\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Monoid.ts.md",
    "content": "---\ntitle: Monoid.ts\nnav_order: 64\nparent: Modules\n---\n\n## Monoid overview\n\n`Monoid` extends the power of `Semigroup` by providing an additional `empty` value.\n\n```ts\ninterface Semigroup<A> {\n  readonly concat: (x: A, y: A) => A\n}\n\ninterface Monoid<A> extends Semigroup<A> {\n  readonly empty: A\n}\n```\n\nThis `empty` value should be an identity for the `concat` operation, which means the following equalities hold for any choice of `x`.\n\n```ts\nconcat(x, empty) = concat(empty, x) = x\n```\n\nMany types that form a `Semigroup` also form a `Monoid`, such as `number`s (with `0`) and `string`s (with `''`).\n\n```ts\nimport { Monoid } from 'fp-ts/Monoid'\n\nconst monoidString: Monoid<string> = {\n  concat: (x, y) => x + y,\n  empty: '',\n}\n```\n\n_Adapted from https://typelevel.org/cats_\n\nAdded in v2.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- [model](#model)\n  - [Monoid (interface)](#monoid-interface)\n- [utils](#utils)\n  - [concatAll](#concatall)\n  - [reverse](#reverse)\n  - [struct](#struct)\n  - [tuple](#tuple)\n- [zone of death](#zone-of-death)\n  - [~~fold~~](#fold)\n  - [~~getDualMonoid~~](#getdualmonoid)\n  - [~~getEndomorphismMonoid~~](#getendomorphismmonoid)\n  - [~~getFunctionMonoid~~](#getfunctionmonoid)\n  - [~~getJoinMonoid~~](#getjoinmonoid)\n  - [~~getMeetMonoid~~](#getmeetmonoid)\n  - [~~getStructMonoid~~](#getstructmonoid)\n  - [~~getTupleMonoid~~](#gettuplemonoid)\n  - [~~monoidAll~~](#monoidall)\n  - [~~monoidAny~~](#monoidany)\n  - [~~monoidProduct~~](#monoidproduct)\n  - [~~monoidString~~](#monoidstring)\n  - [~~monoidSum~~](#monoidsum)\n  - [~~monoidVoid~~](#monoidvoid)\n\n---\n\n# constructors\n\n## max\n\nGet a monoid where `concat` will return the maximum, based on the provided bounded order.\n\nThe `empty` value is the `bottom` value.\n\n**Signature**\n\n```ts\nexport declare const max: <A>(B: Bounded<A>) => Monoid<A>\n```\n\n**Example**\n\n```ts\nimport * as N from 'fp-ts/number'\nimport * as M from 'fp-ts/Monoid'\n\nconst M1 = M.max(N.Bounded)\n\nassert.deepStrictEqual(M1.concat(1, 2), 2)\n```\n\nAdded in v2.10.0\n\n## min\n\nGet a monoid where `concat` will return the minimum, based on the provided bounded order.\n\nThe `empty` value is the `top` value.\n\n**Signature**\n\n```ts\nexport declare const min: <A>(B: Bounded<A>) => Monoid<A>\n```\n\n**Example**\n\n```ts\nimport * as N from 'fp-ts/number'\nimport * as M from 'fp-ts/Monoid'\n\nconst M1 = M.min(N.Bounded)\n\nassert.deepStrictEqual(M1.concat(1, 2), 1)\n```\n\nAdded in v2.10.0\n\n# model\n\n## Monoid (interface)\n\n**Signature**\n\n```ts\nexport interface Monoid<A> extends Se.Semigroup<A> {\n  readonly empty: A\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## concatAll\n\nGiven a sequence of `as`, concat them and return the total.\n\nIf `as` is empty, return the monoid `empty` value.\n\n**Signature**\n\n```ts\nexport declare const concatAll: <A>(M: Monoid<A>) => (as: readonly A[]) => A\n```\n\n**Example**\n\n```ts\nimport { concatAll } from 'fp-ts/Monoid'\nimport * as N from 'fp-ts/number'\n\nassert.deepStrictEqual(concatAll(N.MonoidSum)([1, 2, 3]), 6)\nassert.deepStrictEqual(concatAll(N.MonoidSum)([]), 0)\n```\n\nAdded in v2.10.0\n\n## reverse\n\nThe dual of a `Monoid`, obtained by swapping the arguments of `concat`.\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(M: Monoid<A>) => Monoid<A>\n```\n\n**Example**\n\n```ts\nimport { reverse } from 'fp-ts/Monoid'\nimport * as S from 'fp-ts/string'\n\nassert.deepStrictEqual(reverse(S.Monoid).concat('a', 'b'), 'ba')\n```\n\nAdded in v2.10.0\n\n## struct\n\nGiven a struct of monoids returns a monoid for the struct.\n\n**Signature**\n\n```ts\nexport declare const struct: <A>(monoids: { [K in keyof A]: Monoid<A[K]> }) => Monoid<{ readonly [K in keyof A]: A[K] }>\n```\n\n**Example**\n\n```ts\nimport { struct } from 'fp-ts/Monoid'\nimport * as N from 'fp-ts/number'\n\ninterface Point {\n  readonly x: number\n  readonly y: number\n}\n\nconst M = struct<Point>({\n  x: N.MonoidSum,\n  y: N.MonoidSum,\n})\n\nassert.deepStrictEqual(M.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 })\n```\n\nAdded in v2.10.0\n\n## tuple\n\nGiven a tuple of monoids returns a monoid for the tuple.\n\n**Signature**\n\n```ts\nexport declare const tuple: <A extends readonly unknown[]>(\n  ...monoids: { [K in keyof A]: Monoid<A[K]> }\n) => Monoid<Readonly<A>>\n```\n\n**Example**\n\n```ts\nimport { tuple } from 'fp-ts/Monoid'\nimport * as B from 'fp-ts/boolean'\nimport * as N from 'fp-ts/number'\nimport * as S from 'fp-ts/string'\n\nconst M1 = tuple(S.Monoid, N.MonoidSum)\nassert.deepStrictEqual(M1.concat(['a', 1], ['b', 2]), ['ab', 3])\n\nconst M2 = tuple(S.Monoid, N.MonoidSum, B.MonoidAll)\nassert.deepStrictEqual(M2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~fold~~\n\nUse [`concatAll`](#concatall) instead.\n\n**Signature**\n\n```ts\nexport declare const fold: <A>(M: Monoid<A>) => (as: readonly A[]) => A\n```\n\nAdded in v2.0.0\n\n## ~~getDualMonoid~~\n\nUse [`reverse`](#reverse) instead.\n\n**Signature**\n\n```ts\nexport declare const getDualMonoid: <A>(M: Monoid<A>) => Monoid<A>\n```\n\nAdded in v2.0.0\n\n## ~~getEndomorphismMonoid~~\n\nUse [`getEndomorphismMonoid`](./function.ts.html#getendomorphismmonoid) instead.\n\n**Note**. The execution order in [`getEndomorphismMonoid`](./function.ts.html#getendomorphismmonoid) is reversed.\n\n**Signature**\n\n```ts\nexport declare const getEndomorphismMonoid: <A = never>() => Monoid<Endomorphism<A>>\n```\n\nAdded in v2.0.0\n\n## ~~getFunctionMonoid~~\n\nUse [`getMonoid`](./function.ts.html#getmonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getFunctionMonoid: <M>(M: Monoid<M>) => <A = never>() => Monoid<(a: A) => M>\n```\n\nAdded in v2.0.0\n\n## ~~getJoinMonoid~~\n\nUse [`max`](#max) instead.\n\n**Signature**\n\n```ts\nexport declare const getJoinMonoid: <A>(B: Bounded<A>) => Monoid<A>\n```\n\nAdded in v2.0.0\n\n## ~~getMeetMonoid~~\n\nUse [`min`](#min) instead.\n\n**Signature**\n\n```ts\nexport declare const getMeetMonoid: <A>(B: Bounded<A>) => Monoid<A>\n```\n\nAdded in v2.0.0\n\n## ~~getStructMonoid~~\n\nUse [`struct`](#struct) instead.\n\n**Signature**\n\n```ts\nexport declare const getStructMonoid: <O extends Readonly<Record<string, any>>>(monoids: {\n  [K in keyof O]: Monoid<O[K]>\n}) => Monoid<O>\n```\n\nAdded in v2.0.0\n\n## ~~getTupleMonoid~~\n\nUse [`tuple`](#tuple) instead.\n\n**Signature**\n\n```ts\nexport declare const getTupleMonoid: <T extends readonly Monoid<any>[]>(\n  ...monoids: T\n) => Monoid<{ [K in keyof T]: T[K] extends Se.Semigroup<infer A> ? A : never }>\n```\n\nAdded in v2.0.0\n\n## ~~monoidAll~~\n\nUse [`MonoidAll`](./boolean.ts.html#monoidall) instead.\n\n**Signature**\n\n```ts\nexport declare const monoidAll: Monoid<boolean>\n```\n\nAdded in v2.0.0\n\n## ~~monoidAny~~\n\nUse [`MonoidAny`](./boolean.ts.html#monoidany) instead.\n\n**Signature**\n\n```ts\nexport declare const monoidAny: Monoid<boolean>\n```\n\nAdded in v2.0.0\n\n## ~~monoidProduct~~\n\nUse [`MonoidProduct`](./number.ts.html#monoidproduct) instead.\n\n**Signature**\n\n```ts\nexport declare const monoidProduct: Monoid<number>\n```\n\nAdded in v2.0.0\n\n## ~~monoidString~~\n\nUse [`Monoid`](./string.ts.html#monoid) instead.\n\n**Signature**\n\n```ts\nexport declare const monoidString: Monoid<string>\n```\n\nAdded in v2.0.0\n\n## ~~monoidSum~~\n\nUse [`MonoidSum`](./number.ts.html#monoidsum) instead.\n\n**Signature**\n\n```ts\nexport declare const monoidSum: Monoid<number>\n```\n\nAdded in v2.0.0\n\n## ~~monoidVoid~~\n\nUse [`Monoid`](./void.ts.html#monoid) instead.\n\n**Signature**\n\n```ts\nexport declare const monoidVoid: Monoid<void>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/NaturalTransformation.ts.md",
    "content": "---\ntitle: NaturalTransformation.ts\nnav_order: 65\nparent: Modules\n---\n\n## NaturalTransformation overview\n\nA type for natural transformations.\n\nA natural transformation is a mapping between type constructors of kind `* -> *` where the mapping\noperation has no ability to manipulate the inner values.\n\nThe definition of a natural transformation in category theory states that `F` and `G` should be functors,\nbut the `Functor` constraint is not enforced here; that the types are of kind `* -> *` is enough for our purposes.\n\nAdded in v2.11.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [utils](#utils)\n  - [NaturalTransformation (interface)](#naturaltransformation-interface)\n  - [NaturalTransformation11 (interface)](#naturaltransformation11-interface)\n  - [NaturalTransformation12 (interface)](#naturaltransformation12-interface)\n  - [NaturalTransformation12C (interface)](#naturaltransformation12c-interface)\n  - [NaturalTransformation13 (interface)](#naturaltransformation13-interface)\n  - [NaturalTransformation13C (interface)](#naturaltransformation13c-interface)\n  - [NaturalTransformation14 (interface)](#naturaltransformation14-interface)\n  - [NaturalTransformation14C (interface)](#naturaltransformation14c-interface)\n  - [NaturalTransformation21 (interface)](#naturaltransformation21-interface)\n  - [NaturalTransformation22 (interface)](#naturaltransformation22-interface)\n  - [NaturalTransformation22C (interface)](#naturaltransformation22c-interface)\n  - [NaturalTransformation23 (interface)](#naturaltransformation23-interface)\n  - [NaturalTransformation23C (interface)](#naturaltransformation23c-interface)\n  - [NaturalTransformation23R (interface)](#naturaltransformation23r-interface)\n  - [NaturalTransformation23RC (interface)](#naturaltransformation23rc-interface)\n  - [NaturalTransformation24 (interface)](#naturaltransformation24-interface)\n  - [NaturalTransformation24R (interface)](#naturaltransformation24r-interface)\n  - [NaturalTransformation24S (interface)](#naturaltransformation24s-interface)\n  - [NaturalTransformation33 (interface)](#naturaltransformation33-interface)\n  - [NaturalTransformation34 (interface)](#naturaltransformation34-interface)\n\n---\n\n# utils\n\n## NaturalTransformation (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation<F, G> {\n  <A>(fa: HKT<F, A>): HKT<G, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation11 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation11<F extends URIS, G extends URIS> {\n  <A>(fa: Kind<F, A>): Kind<G, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation12 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation12<F extends URIS, G extends URIS2> {\n  <A, E>(fa: Kind<F, A>): Kind2<G, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation12C (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation12C<F extends URIS, G extends URIS2, E> {\n  <A>(fa: Kind<F, A>): Kind2<G, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation13 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation13<F extends URIS, G extends URIS3> {\n  <A, R, E>(fa: Kind<F, A>): Kind3<G, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation13C (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation13C<F extends URIS, G extends URIS3, E> {\n  <A, R>(fa: Kind<F, A>): Kind3<G, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation14 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation14<F extends URIS, G extends URIS4> {\n  <A, S, R, E>(fa: Kind<F, A>): Kind4<G, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation14C (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation14C<F extends URIS, G extends URIS4, E> {\n  <A, S, R>(fa: Kind<F, A>): Kind4<G, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation21 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation21<F extends URIS2, G extends URIS> {\n  <A>(fa: Kind2<F, unknown, A>): Kind<G, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation22 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation22<F extends URIS2, G extends URIS2> {\n  <E, A>(fa: Kind2<F, E, A>): Kind2<G, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation22C (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation22C<F extends URIS2, G extends URIS2, E> {\n  <A>(fa: Kind2<F, E, A>): Kind2<G, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation23 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation23<F extends URIS2, G extends URIS3> {\n  <E, A, R>(fa: Kind2<F, E, A>): Kind3<G, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation23C (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation23C<F extends URIS2, G extends URIS3, E> {\n  <A, R>(fa: Kind2<F, E, A>): Kind3<G, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation23R (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation23R<F extends URIS2, G extends URIS3> {\n  <R, A, E>(fa: Kind2<F, R, A>): Kind3<G, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation23RC (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation23RC<F extends URIS2, G extends URIS3, E> {\n  <R, A>(fa: Kind2<F, R, A>): Kind3<G, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation24 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation24<F extends URIS2, G extends URIS4> {\n  <E, A, S, R>(fa: Kind2<F, E, A>): Kind4<G, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation24R (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation24R<F extends URIS2, G extends URIS4> {\n  <R, A, S, E>(fa: Kind2<F, R, A>): Kind4<G, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation24S (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation24S<F extends URIS2, G extends URIS4> {\n  <S, A, R, E>(fa: Kind2<F, S, A>): Kind4<G, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation33 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation33<F extends URIS3, G extends URIS3> {\n  <R, E, A>(fa: Kind3<F, R, E, A>): Kind3<G, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## NaturalTransformation34 (interface)\n\n**Signature**\n\n```ts\nexport interface NaturalTransformation34<F extends URIS3, G extends URIS4> {\n  <R, E, A, S>(fa: Kind3<F, R, E, A>): Kind4<G, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/NonEmptyArray.ts.md",
    "content": "---\ntitle: NonEmptyArray.ts\nnav_order: 66\nparent: Modules\n---\n\n## NonEmptyArray overview\n\nData structure which represents non-empty arrays.\n\n```ts\nexport type NonEmptyArray<A> = Array<A> & {\n  0: A\n}\n```\n\nNote that you don't need any conversion, a `NonEmptyArray` is an `Array`,\nso all `Array`'s APIs can be used with a `NonEmptyArray` without further ado.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [makeBy](#makeby)\n  - [of](#of)\n  - [range](#range)\n  - [replicate](#replicate)\n- [conversions](#conversions)\n  - [fromArray](#fromarray)\n  - [fromReadonlyNonEmptyArray](#fromreadonlynonemptyarray)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [Comonad](#comonad)\n  - [Foldable](#foldable)\n  - [FoldableWithIndex](#foldablewithindex)\n  - [Functor](#functor)\n  - [FunctorWithIndex](#functorwithindex)\n  - [Monad](#monad)\n  - [Pointed](#pointed)\n  - [Traversable](#traversable)\n  - [TraversableWithIndex](#traversablewithindex)\n  - [getEq](#geteq)\n  - [getSemigroup](#getsemigroup)\n  - [getShow](#getshow)\n- [legacy](#legacy)\n  - [chain](#chain)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n  - [mapWithIndex](#mapwithindex)\n- [model](#model)\n  - [NonEmptyArray (interface)](#nonemptyarray-interface)\n- [pattern matching](#pattern-matching)\n  - [matchLeft](#matchleft)\n  - [matchRight](#matchright)\n- [sequencing](#sequencing)\n  - [chainFirst](#chainfirst)\n  - [chainWithIndex](#chainwithindex)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n  - [traverseWithIndex](#traversewithindex)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [chop](#chop)\n  - [chunksOf](#chunksof)\n  - [concat](#concat)\n  - [concatAll](#concatall)\n  - [concatW](#concatw)\n  - [copy](#copy)\n  - [duplicate](#duplicate)\n  - [extend](#extend)\n  - [extract](#extract)\n  - [getUnionSemigroup](#getunionsemigroup)\n  - [group](#group)\n  - [groupBy](#groupby)\n  - [head](#head)\n  - [init](#init)\n  - [insertAt](#insertat)\n  - [intercalate](#intercalate)\n  - [intersperse](#intersperse)\n  - [last](#last)\n  - [max](#max)\n  - [min](#min)\n  - [modifyAt](#modifyat)\n  - [modifyHead](#modifyhead)\n  - [modifyLast](#modifylast)\n  - [prependAll](#prependall)\n  - [reverse](#reverse)\n  - [rotate](#rotate)\n  - [sort](#sort)\n  - [sortBy](#sortby)\n  - [splitAt](#splitat)\n  - [tail](#tail)\n  - [unappend](#unappend)\n  - [union](#union)\n  - [uniq](#uniq)\n  - [unprepend](#unprepend)\n  - [unzip](#unzip)\n  - [updateAt](#updateat)\n  - [updateHead](#updatehead)\n  - [updateLast](#updatelast)\n  - [zip](#zip)\n  - [zipWith](#zipwith)\n- [zone of death](#zone-of-death)\n  - [~~cons~~](#cons)\n  - [~~filterWithIndex~~](#filterwithindex)\n  - [~~filter~~](#filter)\n  - [~~fold~~](#fold)\n  - [~~groupSort~~](#groupsort)\n  - [~~nonEmptyArray~~](#nonemptyarray)\n  - [~~prependToAll~~](#prependtoall)\n  - [~~snoc~~](#snoc)\n  - [~~uncons~~](#uncons)\n  - [~~unsnoc~~](#unsnoc)\n\n---\n\n# constructors\n\n## makeBy\n\nReturn a `NonEmptyArray` of length `n` with element `i` initialized with `f(i)`.\n\n**Note**. `n` is normalized to a natural number.\n\n**Signature**\n\n```ts\nexport declare const makeBy: <A>(f: (i: number) => A) => (n: number) => NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { makeBy } from 'fp-ts/NonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nconst double = (n: number): number => n * 2\nassert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8])\n```\n\nAdded in v2.11.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => NonEmptyArray<A>\n```\n\nAdded in v2.0.0\n\n## range\n\nCreate a `NonEmptyArray` containing a range of integers, including both endpoints.\n\n**Signature**\n\n```ts\nexport declare const range: (start: number, end: number) => NonEmptyArray<number>\n```\n\n**Example**\n\n```ts\nimport { range } from 'fp-ts/NonEmptyArray'\n\nassert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5])\n```\n\nAdded in v2.11.0\n\n## replicate\n\nCreate a `NonEmptyArray` containing a value repeated the specified number of times.\n\n**Note**. `n` is normalized to a natural number.\n\n**Signature**\n\n```ts\nexport declare const replicate: <A>(a: A) => (n: number) => RNEA.ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { replicate } from 'fp-ts/NonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a'])\n```\n\nAdded in v2.11.0\n\n# conversions\n\n## fromArray\n\nBuilds a `NonEmptyArray` from an `Array` returning `none` if `as` is an empty array\n\n**Signature**\n\n```ts\nexport declare const fromArray: <A>(as: A[]) => Option<NonEmptyArray<A>>\n```\n\nAdded in v2.0.0\n\n## fromReadonlyNonEmptyArray\n\n**Signature**\n\n```ts\nexport declare const fromReadonlyNonEmptyArray: <A>(as: RNEA.ReadonlyNonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.10.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: NonEmptyArray<{}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: NonEmptyArray<B>\n) => (fa: NonEmptyArray<A>) => NonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => NonEmptyArray<B>\n) => (ma: NonEmptyArray<A>) => NonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: NonEmptyArray<A>) => NonEmptyArray<{ readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: NonEmptyArray<A>) => NonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\nIn case of `NonEmptyArray` concatenates the inputs into a single array.\n\n**Signature**\n\n```ts\nexport declare const alt: <A>(that: LazyArg<NonEmptyArray<A>>) => (fa: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport * as NEA from 'fp-ts/NonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    NEA.alt(() => [4, 5])\n  ),\n  [1, 2, 3, 4, 5]\n)\n```\n\nAdded in v2.6.2\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <B>(that: LazyArg<NonEmptyArray<B>>) => <A>(as: NonEmptyArray<A>) => NonEmptyArray<B | A>\n```\n\n**Example**\n\n```ts\nimport * as NEA from 'fp-ts/NonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3] as NEA.NonEmptyArray<number>,\n    NEA.altW(() => ['a', 'b'])\n  ),\n  [1, 2, 3, 'a', 'b']\n)\n```\n\nAdded in v2.9.0\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <S>(S: Se.Semigroup<S>) => <A>(f: (a: A) => S) => (fa: NonEmptyArray<A>) => S\n```\n\nAdded in v2.0.0\n\n## foldMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const foldMapWithIndex: <S>(\n  S: Se.Semigroup<S>\n) => <A>(f: (i: number, a: A) => S) => (fa: NonEmptyArray<A>) => S\n```\n\nAdded in v2.0.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: NonEmptyArray<A>) => B\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: NonEmptyArray<A>) => B\n```\n\nAdded in v2.0.0\n\n## reduceRightWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceRightWithIndex: <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: NonEmptyArray<A>) => B\n```\n\nAdded in v2.0.0\n\n## reduceWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceWithIndex: <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: NonEmptyArray<A>) => B\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt1<'NonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative1<'NonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply1<'NonEmptyArray'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: Chain1<'NonEmptyArray'>\n```\n\nAdded in v2.10.0\n\n## Comonad\n\n**Signature**\n\n```ts\nexport declare const Comonad: Comonad1<'NonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable1<'NonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## FoldableWithIndex\n\n**Signature**\n\n```ts\nexport declare const FoldableWithIndex: FoldableWithIndex1<'NonEmptyArray', number>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'NonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## FunctorWithIndex\n\n**Signature**\n\n```ts\nexport declare const FunctorWithIndex: FunctorWithIndex1<'NonEmptyArray', number>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'NonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'NonEmptyArray'>\n```\n\nAdded in v2.10.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable1<'NonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## TraversableWithIndex\n\n**Signature**\n\n```ts\nexport declare const TraversableWithIndex: TraversableWithIndex1<'NonEmptyArray', number>\n```\n\nAdded in v2.7.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare const getEq: <A>(E: Eq<A>) => Eq<NonEmptyArray<A>>\n```\n\n**Example**\n\n```ts\nimport { getEq } from 'fp-ts/NonEmptyArray'\nimport * as N from 'fp-ts/number'\n\nconst E = getEq(N.Eq)\nassert.strictEqual(E.equals([1, 2], [1, 2]), true)\nassert.strictEqual(E.equals([1, 2], [1, 3]), false)\n```\n\nAdded in v2.0.0\n\n## getSemigroup\n\nBuilds a `Semigroup` instance for `NonEmptyArray`\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A = never>() => Se.Semigroup<NonEmptyArray<A>>\n```\n\nAdded in v2.0.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare const getShow: <A>(S: Show<A>) => Show<NonEmptyArray<A>>\n```\n\nAdded in v2.0.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => NonEmptyArray<B>) => (ma: NonEmptyArray<A>) => NonEmptyArray<B>\n```\n\nAdded in v2.0.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: NonEmptyArray<(a: A) => B>) => NonEmptyArray<B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (as: NonEmptyArray<A>) => NonEmptyArray<B>\n```\n\nAdded in v2.0.0\n\n## mapWithIndex\n\n**Signature**\n\n```ts\nexport declare const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (as: NonEmptyArray<A>) => NonEmptyArray<B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## NonEmptyArray (interface)\n\n**Signature**\n\n```ts\nexport interface NonEmptyArray<A> extends Array<A> {\n  0: A\n}\n```\n\nAdded in v2.0.0\n\n# pattern matching\n\n## matchLeft\n\nBreak an `Array` into its first element and remaining elements.\n\n**Signature**\n\n```ts\nexport declare const matchLeft: <A, B>(f: (head: A, tail: A[]) => B) => (as: NonEmptyArray<A>) => B\n```\n\nAdded in v2.11.0\n\n## matchRight\n\nBreak an `Array` into its initial elements and the last element.\n\n**Signature**\n\n```ts\nexport declare const matchRight: <A, B>(f: (init: A[], last: A) => B) => (as: NonEmptyArray<A>) => B\n```\n\nAdded in v2.11.0\n\n# sequencing\n\n## chainFirst\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => NonEmptyArray<B>) => (first: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## chainWithIndex\n\n**Signature**\n\n```ts\nexport declare const chainWithIndex: <A, B>(\n  f: (i: number, a: A) => NonEmptyArray<B>\n) => (as: NonEmptyArray<A>) => NonEmptyArray<B>\n```\n\nAdded in v2.10.0\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A, i: number) => NonEmptyArray<B>): (ma: NonEmptyArray<A>) => NonEmptyArray<B>\n  <A, B>(ma: NonEmptyArray<A>, f: (a: A, i: number) => NonEmptyArray<B>): NonEmptyArray<B>\n}\n```\n\n**Example**\n\n```ts\nimport * as NEA from 'fp-ts/NonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    NEA.flatMap((n) => [`a${n}`, `b${n}`])\n  ),\n  ['a1', 'b1', 'a2', 'b2', 'a3', 'b3']\n)\n```\n\nAdded in v2.14.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: NonEmptyArray<NonEmptyArray<A>>) => NonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## traverseWithIndex\n\n**Signature**\n\n```ts\nexport declare const traverseWithIndex: PipeableTraverseWithIndex1<'NonEmptyArray', number>\n```\n\nAdded in v2.6.3\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence1<'NonEmptyArray'>\n```\n\nAdded in v2.6.3\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse1<'NonEmptyArray'>\n```\n\nAdded in v2.6.3\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'NonEmptyArray'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ap\n\nApply a function to an argument under a type constructor.\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(as: NonEmptyArray<A>) => <B>(fab: NonEmptyArray<(a: A) => B>) => NonEmptyArray<B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: NonEmptyArray<B>) => <A>(first: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: NonEmptyArray<B>) => <A>(first: NonEmptyArray<A>) => NonEmptyArray<B>\n```\n\nAdded in v2.5.0\n\n## chop\n\n**Signature**\n\n```ts\nexport declare const chop: <A, B>(f: (as: NonEmptyArray<A>) => [B, A[]]) => (as: NonEmptyArray<A>) => NonEmptyArray<B>\n```\n\nAdded in v2.10.0\n\n## chunksOf\n\n**Signature**\n\n```ts\nexport declare const chunksOf: (n: number) => <A>(as: NonEmptyArray<A>) => NonEmptyArray<NonEmptyArray<A>>\n```\n\nAdded in v2.10.0\n\n## concat\n\n**Signature**\n\n```ts\nexport declare function concat<A>(second: NonEmptyArray<A>): (first: Array<A>) => NonEmptyArray<A>\nexport declare function concat<A>(second: Array<A>): (first: NonEmptyArray<A>) => NonEmptyArray<A>\nexport declare function concat<A>(first: Array<A>, second: NonEmptyArray<A>): NonEmptyArray<A>\nexport declare function concat<A>(first: NonEmptyArray<A>, second: Array<A>): NonEmptyArray<A>\n```\n\nAdded in v2.2.0\n\n## concatAll\n\n**Signature**\n\n```ts\nexport declare const concatAll: <A>(S: Se.Semigroup<A>) => (as: NonEmptyArray<A>) => A\n```\n\nAdded in v2.10.0\n\n## concatW\n\n**Signature**\n\n```ts\nexport declare function concatW<B>(second: NonEmptyArray<B>): <A>(first: Array<A>) => NonEmptyArray<A | B>\nexport declare function concatW<B>(second: Array<B>): <A>(first: NonEmptyArray<A>) => NonEmptyArray<A | B>\n```\n\nAdded in v2.11.0\n\n## copy\n\n**Signature**\n\n```ts\nexport declare const copy: <A>(as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.0.0\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <A>(ma: NonEmptyArray<A>) => NonEmptyArray<NonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <A, B>(f: (as: NonEmptyArray<A>) => B) => (as: NonEmptyArray<A>) => NonEmptyArray<B>\n```\n\nAdded in v2.0.0\n\n## extract\n\n**Signature**\n\n```ts\nexport declare const extract: <A>(wa: NonEmptyArray<A>) => A\n```\n\nAdded in v2.7.0\n\n## getUnionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <A>(E: Eq<A>) => Se.Semigroup<NonEmptyArray<A>>\n```\n\nAdded in v2.11.0\n\n## group\n\nGroup equal, consecutive elements of an array into non empty arrays.\n\n**Signature**\n\n```ts\nexport declare function group<B>(E: Eq<B>): {\n  <A extends B>(as: NonEmptyArray<A>): NonEmptyArray<NonEmptyArray<A>>\n  <A extends B>(as: Array<A>): Array<NonEmptyArray<A>>\n}\n```\n\n**Example**\n\n```ts\nimport { group } from 'fp-ts/NonEmptyArray'\nimport * as N from 'fp-ts/number'\n\nassert.deepStrictEqual(group(N.Ord)([1, 2, 1, 1]), [[1], [2], [1, 1]])\n```\n\nAdded in v2.0.0\n\n## groupBy\n\nSplits an array 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: <A>(f: (a: A) => string) => (as: A[]) => Record<string, NonEmptyArray<A>>\n```\n\n**Example**\n\n```ts\nimport { groupBy } from 'fp-ts/NonEmptyArray'\n\nassert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), {\n  '1': ['a', 'b'],\n  '2': ['ab'],\n})\n```\n\nAdded in v2.0.0\n\n## head\n\n**Signature**\n\n```ts\nexport declare const head: <A>(nea: NonEmptyArray<A>) => A\n```\n\nAdded in v2.0.0\n\n## init\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 init: <A>(as: NonEmptyArray<A>) => A[]\n```\n\n**Example**\n\n```ts\nimport { init } from 'fp-ts/NonEmptyArray'\n\nassert.deepStrictEqual(init([1, 2, 3]), [1, 2])\nassert.deepStrictEqual(init([1]), [])\n```\n\nAdded in v2.2.0\n\n## insertAt\n\n**Signature**\n\n```ts\nexport declare const insertAt: <A>(i: number, a: A) => (as: A[]) => Option<NonEmptyArray<A>>\n```\n\nAdded in v2.0.0\n\n## intercalate\n\nPlaces an element in between members of a `NonEmptyArray`, then folds the results using the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const intercalate: <A>(S: Se.Semigroup<A>) => (middle: A) => (as: NonEmptyArray<A>) => A\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { intercalate } from 'fp-ts/NonEmptyArray'\n\nassert.deepStrictEqual(intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c')\n```\n\nAdded in v2.12.0\n\n## intersperse\n\nPlaces an element in between members of an array\n\n**Signature**\n\n```ts\nexport declare const intersperse: <A>(middle: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { intersperse } from 'fp-ts/NonEmptyArray'\n\nassert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])\n```\n\nAdded in v2.9.0\n\n## last\n\n**Signature**\n\n```ts\nexport declare const last: <A>(nea: NonEmptyArray<A>) => A\n```\n\nAdded in v2.0.0\n\n## max\n\n**Signature**\n\n```ts\nexport declare const max: <A>(ord: Ord<A>) => (nea: NonEmptyArray<A>) => A\n```\n\nAdded in v2.0.0\n\n## min\n\n**Signature**\n\n```ts\nexport declare const min: <A>(ord: Ord<A>) => (nea: NonEmptyArray<A>) => A\n```\n\nAdded in v2.0.0\n\n## modifyAt\n\n**Signature**\n\n```ts\nexport declare const modifyAt: <A>(i: number, f: (a: A) => A) => (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>\n```\n\nAdded in v2.0.0\n\n## modifyHead\n\nApply a function to the head, creating a new `NonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const modifyHead: <A>(f: Endomorphism<A>) => (as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## modifyLast\n\nApply a function to the last element, creating a new `NonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const modifyLast: <A>(f: Endomorphism<A>) => (as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## prependAll\n\nPrepend an element to every member of an array\n\n**Signature**\n\n```ts\nexport declare const prependAll: <A>(middle: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { prependAll } from 'fp-ts/NonEmptyArray'\n\nassert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])\n```\n\nAdded in v2.10.0\n\n## reverse\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.0.0\n\n## rotate\n\nRotate a `NonEmptyArray` by `n` steps.\n\n**Signature**\n\n```ts\nexport declare const rotate: (n: number) => <A>(as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { rotate } from 'fp-ts/NonEmptyArray'\n\nassert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\nassert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n```\n\nAdded in v2.11.0\n\n## sort\n\n**Signature**\n\n```ts\nexport declare const sort: <B>(O: Ord<B>) => <A extends B>(as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.0.0\n\n## sortBy\n\nSort the elements of a `NonEmptyArray` in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,\netc...\n\n**Signature**\n\n```ts\nexport declare const sortBy: <B>(ords: Ord<B>[]) => <A extends B>(as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport * as NEA from 'fp-ts/NonEmptyArray'\nimport { contramap } from 'fp-ts/Ord'\nimport * as S from 'fp-ts/string'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\ninterface Person {\n  name: string\n  age: number\n}\n\nconst byName = pipe(\n  S.Ord,\n  contramap((p: Person) => p.name)\n)\n\nconst byAge = pipe(\n  N.Ord,\n  contramap((p: Person) => p.age)\n)\n\nconst sortByNameByAge = NEA.sortBy([byName, byAge])\n\nconst persons: NEA.NonEmptyArray<Person> = [\n  { name: 'a', age: 1 },\n  { name: 'b', age: 3 },\n  { name: 'c', age: 2 },\n  { name: 'b', age: 2 },\n]\n\nassert.deepStrictEqual(sortByNameByAge(persons), [\n  { name: 'a', age: 1 },\n  { name: 'b', age: 2 },\n  { name: 'b', age: 3 },\n  { name: 'c', age: 2 },\n])\n```\n\nAdded in v2.11.0\n\n## splitAt\n\nSplits a `NonEmptyArray` into two pieces, the first piece has max `n` elements.\n\n**Signature**\n\n```ts\nexport declare const splitAt: (n: number) => <A>(as: NonEmptyArray<A>) => [NonEmptyArray<A>, A[]]\n```\n\nAdded in v2.10.0\n\n## tail\n\n**Signature**\n\n```ts\nexport declare const tail: <A>(as: NonEmptyArray<A>) => A[]\n```\n\nAdded in v2.0.0\n\n## unappend\n\nReturn the tuple of the `init` and the `last`.\n\n**Signature**\n\n```ts\nexport declare const unappend: <A>(as: NonEmptyArray<A>) => [A[], A]\n```\n\n**Example**\n\n```ts\nimport { unappend } from 'fp-ts/NonEmptyArray'\n\nassert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4])\n```\n\nAdded in v2.9.0\n\n## union\n\n**Signature**\n\n```ts\nexport declare const union: <A>(E: Eq<A>) => (second: NonEmptyArray<A>) => (first: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## uniq\n\nRemove duplicates from a `NonEmptyArray`, keeping the first occurrence of an element.\n\n**Signature**\n\n```ts\nexport declare const uniq: <A>(E: Eq<A>) => (as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { uniq } from 'fp-ts/NonEmptyArray'\nimport * as N from 'fp-ts/number'\n\nassert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])\n```\n\nAdded in v2.11.0\n\n## unprepend\n\nReturn the tuple of the `head` and the `tail`.\n\n**Signature**\n\n```ts\nexport declare const unprepend: <A>(as: NonEmptyArray<A>) => [A, A[]]\n```\n\n**Example**\n\n```ts\nimport { unprepend } from 'fp-ts/NonEmptyArray'\n\nassert.deepStrictEqual(unprepend([1, 2, 3]), [1, [2, 3]])\n```\n\nAdded in v2.9.0\n\n## unzip\n\n**Signature**\n\n```ts\nexport declare const unzip: <A, B>(abs: NonEmptyArray<[A, B]>) => [NonEmptyArray<A>, NonEmptyArray<B>]\n```\n\nAdded in v2.5.1\n\n## updateAt\n\n**Signature**\n\n```ts\nexport declare const updateAt: <A>(i: number, a: A) => (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>\n```\n\nAdded in v2.0.0\n\n## updateHead\n\nChange the head, creating a new `NonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const updateHead: <A>(a: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## updateLast\n\nChange the last element, creating a new `NonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const updateLast: <A>(a: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## zip\n\n**Signature**\n\n```ts\nexport declare function zip<B>(bs: NonEmptyArray<B>): <A>(as: NonEmptyArray<A>) => NonEmptyArray<[A, B]>\nexport declare function zip<A, B>(as: NonEmptyArray<A>, bs: NonEmptyArray<B>): NonEmptyArray<[A, B]>\n```\n\nAdded in v2.5.1\n\n## zipWith\n\n**Signature**\n\n```ts\nexport declare const zipWith: <A, B, C>(\n  as: NonEmptyArray<A>,\n  bs: NonEmptyArray<B>,\n  f: (a: A, b: B) => C\n) => NonEmptyArray<C>\n```\n\nAdded in v2.5.1\n\n# zone of death\n\n## ~~cons~~\n\nUse [`prepend`](./Array.ts.html#prepend) instead.\n\n**Signature**\n\n```ts\nexport declare function cons<A>(head: A): (tail: Array<A>) => NonEmptyArray<A>\nexport declare function cons<A>(head: A, tail: Array<A>): NonEmptyArray<A>\n```\n\nAdded in v2.0.0\n\n## ~~filterWithIndex~~\n\nUse [`filterWithIndex`](./Array.ts.html#filterwithindex) instead.\n\n**Signature**\n\n```ts\nexport declare const filterWithIndex: <A>(\n  predicate: (i: number, a: A) => boolean\n) => (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>\n```\n\nAdded in v2.0.0\n\n## ~~filter~~\n\nUse [`filter`](./Array.ts.html#filter) instead.\n\n**Signature**\n\n```ts\nexport declare function filter<A, B extends A>(\n  refinement: Refinement<A, B>\n): (as: NonEmptyArray<A>) => Option<NonEmptyArray<B>>\nexport declare function filter<A>(\n  predicate: Predicate<A>\n): <B extends A>(bs: NonEmptyArray<B>) => Option<NonEmptyArray<B>>\nexport declare function filter<A>(predicate: Predicate<A>): (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>\n```\n\nAdded in v2.0.0\n\n## ~~fold~~\n\nUse [`concatAll`](#concatall) instead.\n\n**Signature**\n\n```ts\nexport declare const fold: <A>(S: Se.Semigroup<A>) => (fa: NonEmptyArray<A>) => A\n```\n\nAdded in v2.5.0\n\n## ~~groupSort~~\n\nThis is just `sort` followed by `group`.\n\n**Signature**\n\n```ts\nexport declare function groupSort<B>(O: Ord<B>): {\n  <A extends B>(as: NonEmptyArray<A>): NonEmptyArray<NonEmptyArray<A>>\n  <A extends B>(as: Array<A>): Array<NonEmptyArray<A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~nonEmptyArray~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `NEA.Functor` instead of `NEA.nonEmptyArray`\n(where `NEA` is from `import NEA from 'fp-ts/NonEmptyArray'`)\n\n**Signature**\n\n```ts\nexport declare const nonEmptyArray: Monad1<'NonEmptyArray'> &\n  Comonad1<'NonEmptyArray'> &\n  TraversableWithIndex1<'NonEmptyArray', number> &\n  FunctorWithIndex1<'NonEmptyArray', number> &\n  FoldableWithIndex1<'NonEmptyArray', number> &\n  Alt1<'NonEmptyArray'>\n```\n\nAdded in v2.0.0\n\n## ~~prependToAll~~\n\nUse [`prependAll`](#prependall) instead.\n\n**Signature**\n\n```ts\nexport declare const prependToAll: <A>(middle: A) => (as: NonEmptyArray<A>) => NonEmptyArray<A>\n```\n\nAdded in v2.9.0\n\n## ~~snoc~~\n\nUse [`append`](./Array.ts.html#append) instead.\n\n**Signature**\n\n```ts\nexport declare const snoc: <A>(init: A[], end: A) => NonEmptyArray<A>\n```\n\nAdded in v2.0.0\n\n## ~~uncons~~\n\nUse [`unprepend`](#unprepend) instead.\n\n**Signature**\n\n```ts\nexport declare const uncons: <A>(as: NonEmptyArray<A>) => [A, A[]]\n```\n\nAdded in v2.9.0\n\n## ~~unsnoc~~\n\nUse [`unappend`](#unappend) instead.\n\n**Signature**\n\n```ts\nexport declare const unsnoc: <A>(as: NonEmptyArray<A>) => [A[], A]\n```\n\nAdded in v2.9.0\n"
  },
  {
    "path": "docs/modules/Option.ts.md",
    "content": "---\ntitle: Option.ts\nnav_order: 68\nparent: Modules\n---\n\n## Option overview\n\n```ts\ntype Option<A> = None | Some<A>\n```\n\n`Option<A>` is a container for an optional value of type `A`. If the value of type `A` is present, the `Option<A>` is\nan instance of `Some<A>`, containing the present value of type `A`. If the value is absent, the `Option<A>` is an\ninstance of `None`.\n\nAn option could be looked at as a collection or foldable structure with either one or zero elements.\nAnother way to look at `Option` is: it represents the effect of a possibly failing computation.\n\n**Example**\n\n```ts\nimport * as O from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\nconst double = (n: number): number => n * 2\n\nexport const imperative = (as: ReadonlyArray<number>): string => {\n  const head = (as: ReadonlyArray<number>): number => {\n    if (as.length === 0) {\n      throw new Error()\n    }\n    return as[0]\n  }\n  const inverse = (n: number): number => {\n    if (n === 0) {\n      throw new Error()\n    }\n    return 1 / n\n  }\n  try {\n    return `Result is ${inverse(double(head(as)))}`\n  } catch (e) {\n    return 'no result'\n  }\n}\n\nexport const functional = (as: ReadonlyArray<number>): string => {\n  const head = <A>(as: ReadonlyArray<A>): O.Option<A> => (as.length === 0 ? O.none : O.some(as[0]))\n  const inverse = (n: number): O.Option<number> => (n === 0 ? O.none : O.some(1 / n))\n  return pipe(\n    as,\n    head,\n    O.map(double),\n    O.flatMap(inverse),\n    O.match(\n      () => 'no result', // onNone handler\n      (head) => `Result is ${head}` // onSome handler\n    )\n  )\n}\n\nassert.deepStrictEqual(imperative([1, 2, 3]), functional([1, 2, 3]))\nassert.deepStrictEqual(imperative([]), functional([]))\nassert.deepStrictEqual(imperative([0]), functional([0]))\n```\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapEither](#tapeither)\n- [constructors](#constructors)\n  - [getLeft](#getleft)\n  - [getRight](#getright)\n  - [none](#none)\n  - [of](#of)\n  - [some](#some)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromNullable](#fromnullable)\n  - [toNullable](#tonullable)\n  - [toUndefined](#toundefined)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [guard](#guard)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [getOrElse](#getorelse)\n  - [getOrElseW](#getorelsew)\n  - [orElse](#orelse)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [separate](#separate)\n  - [wilt](#wilt)\n  - [wither](#wither)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Alternative](#alternative)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [Compactable](#compactable)\n  - [Extend](#extend)\n  - [Filterable](#filterable)\n  - [Foldable](#foldable)\n  - [FromEither](#fromeither)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadThrow](#monadthrow)\n  - [Pointed](#pointed)\n  - [Traversable](#traversable)\n  - [Witherable](#witherable)\n  - [Zero](#zero)\n  - [getEq](#geteq)\n  - [getMonoid](#getmonoid)\n  - [getOrd](#getord)\n  - [getShow](#getshow)\n- [interop](#interop)\n  - [tryCatch](#trycatch)\n  - [tryCatchK](#trycatchk)\n- [legacy](#legacy)\n  - [alt](#alt)\n  - [altW](#altw)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n  - [chainFirstEitherK](#chainfirsteitherk)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromNullableK](#fromnullablek)\n  - [fromPredicate](#frompredicate)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [None (interface)](#none-interface)\n  - [Option (type alias)](#option-type-alias)\n  - [Some (interface)](#some-interface)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchW](#matchw)\n- [refinements](#refinements)\n  - [isNone](#isnone)\n  - [isSome](#issome)\n- [sequencing](#sequencing)\n  - [chainEitherK](#chaineitherk)\n  - [chainNullableK](#chainnullablek)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [sequenceArray](#sequencearray)\n  - [traverse](#traverse)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [duplicate](#duplicate)\n  - [elem](#elem)\n  - [exists](#exists)\n  - [extend](#extend)\n  - [throwError](#throwerror)\n  - [zero](#zero)\n- [zone of death](#zone-of-death)\n  - [~~getApplyMonoid~~](#getapplymonoid)\n  - [~~getApplySemigroup~~](#getapplysemigroup)\n  - [~~getFirstMonoid~~](#getfirstmonoid)\n  - [~~getLastMonoid~~](#getlastmonoid)\n  - [~~getRefinement~~](#getrefinement)\n  - [~~mapNullable~~](#mapnullable)\n  - [~~option~~](#option)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\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 v2.15.0\n\n## tapEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapEither: {\n  <A, E, _>(f: (a: A) => Either<E, _>): (self: Option<A>) => Option<A>\n  <A, E, _>(self: Option<A>, f: (a: A) => Either<E, _>): Option<A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as O from 'fp-ts/Option'\nimport * as E from 'fp-ts/Either'\n\nconst compute = (value: number) =>\n  pipe(\n    O.of(value),\n    O.tapEither((value) => (value > 0 ? E.right('ok') : E.left('error')))\n  )\n\nassert.deepStrictEqual(compute(1), O.of(1))\nassert.deepStrictEqual(compute(-42), O.none)\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## getLeft\n\nReturns the `Left` value of an `Either` if possible.\n\n**Signature**\n\n```ts\nexport declare const getLeft: <E, A>(ma: Either<E, A>) => Option<E>\n```\n\n**Example**\n\n```ts\nimport { getLeft, none, some } from 'fp-ts/Option'\nimport { right, left } from 'fp-ts/Either'\n\nassert.deepStrictEqual(getLeft(right(1)), none)\nassert.deepStrictEqual(getLeft(left('a')), some('a'))\n```\n\nAdded in v2.0.0\n\n## getRight\n\nReturns the `Right` value of an `Either` if possible.\n\n**Signature**\n\n```ts\nexport declare const getRight: <E, A>(ma: Either<E, A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { getRight, none, some } from 'fp-ts/Option'\nimport { right, left } from 'fp-ts/Either'\n\nassert.deepStrictEqual(getRight(right(1)), some(1))\nassert.deepStrictEqual(getRight(left('a')), none)\n```\n\nAdded in v2.0.0\n\n## none\n\n`None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.\n\n**Signature**\n\n```ts\nexport declare const none: Option<never>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => Option<A>\n```\n\nAdded in v2.7.0\n\n## some\n\nConstructs a `Some`. Represents an optional value that exists.\n\n**Signature**\n\n```ts\nexport declare const some: <A>(a: A) => Option<A>\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromEither\n\nTransforms an `Either` to an `Option` discarding the error.\n\nAlias of [getRight](#getright)\n\n**Signature**\n\n```ts\nexport declare const fromEither: <A>(fa: Either<unknown, A>) => Option<A>\n```\n\nAdded in v2.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>(a: A) => Option<NonNullable<A>>\n```\n\n**Example**\n\n```ts\nimport { none, some, fromNullable } from 'fp-ts/Option'\n\nassert.deepStrictEqual(fromNullable(undefined), none)\nassert.deepStrictEqual(fromNullable(null), none)\nassert.deepStrictEqual(fromNullable(1), some(1))\n```\n\nAdded in v2.0.0\n\n## toNullable\n\nExtracts the value out of the structure, if it exists. Otherwise returns `null`.\n\n**Signature**\n\n```ts\nexport declare const toNullable: <A>(ma: Option<A>) => A | null\n```\n\n**Example**\n\n```ts\nimport { some, none, toNullable } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\nassert.strictEqual(pipe(some(1), toNullable), 1)\nassert.strictEqual(pipe(none, toNullable), null)\n```\n\nAdded in v2.0.0\n\n## toUndefined\n\nExtracts the value out of the structure, if it exists. Otherwise returns `undefined`.\n\n**Signature**\n\n```ts\nexport declare const toUndefined: <A>(ma: Option<A>) => A | undefined\n```\n\n**Example**\n\n```ts\nimport { some, none, toUndefined } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\nassert.strictEqual(pipe(some(1), toUndefined), 1)\nassert.strictEqual(pipe(none, toUndefined), undefined)\n```\n\nAdded in v2.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: Option<{}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: Option<B>\n) => (fa: Option<A>) => Option<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Option<B>\n) => (ma: Option<A>) => Option<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: Option<A>) => Option<{ readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## guard\n\n**Signature**\n\n```ts\nexport declare const guard: (b: boolean) => Option<void>\n```\n\nAdded in v2.11.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: Option<A>) => Option<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## getOrElse\n\nExtracts the value out of the structure, if it exists. Otherwise returns the given default value\n\n**Signature**\n\n```ts\nexport declare const getOrElse: <A>(onNone: LazyArg<A>) => (ma: Option<A>) => A\n```\n\n**Example**\n\n```ts\nimport { some, none, getOrElse } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\nassert.strictEqual(\n  pipe(\n    some(1),\n    getOrElse(() => 0)\n  ),\n  1\n)\nassert.strictEqual(\n  pipe(\n    none,\n    getOrElse(() => 0)\n  ),\n  0\n)\n```\n\nAdded in v2.0.0\n\n## getOrElseW\n\nLess strict version of [`getOrElse`](#getorelse).\n\nThe `W` suffix (short for **W**idening) means that the handler return type will be merged.\n\n**Signature**\n\n```ts\nexport declare const getOrElseW: <B>(onNone: LazyArg<B>) => <A>(ma: Option<A>) => B | A\n```\n\nAdded in v2.6.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/Option'\n\nassert.deepStrictEqual(\n  O.orElse(O.none, () => O.none),\n  O.none\n)\nassert.deepStrictEqual(\n  O.orElse(O.some(1), () => O.none),\n  O.some(1)\n)\nassert.deepStrictEqual(\n  O.orElse(O.none, () => O.some('b')),\n  O.some('b')\n)\nassert.deepStrictEqual(\n  O.orElse(O.some(1), () => O.some('b')),\n  O.some(1)\n)\n```\n\nAdded in v2.16.0\n\n# filtering\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(fa: Option<Option<A>>) => Option<A>\n```\n\nAdded in v2.0.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Option<A>) => Option<B>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: Option<B>) => Option<B>\n  <A>(predicate: Predicate<A>): (fa: Option<A>) => Option<A>\n}\n```\n\nAdded in v2.0.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Option<A>) => Option<B>\n```\n\nAdded in v2.0.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Option<A>) => Separated<Option<A>, Option<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: Option<B>) => Separated<Option<B>, Option<B>>\n  <A>(predicate: Predicate<A>): (fa: Option<A>) => Separated<Option<A>, Option<A>>\n}\n```\n\nAdded in v2.0.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: Option<A>) => Separated<Option<B>, Option<C>>\n```\n\nAdded in v2.0.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare const separate: <A, B>(ma: Option<Either<A, B>>) => Separated<Option<A>, Option<B>>\n```\n\nAdded in v2.0.0\n\n## wilt\n\n**Signature**\n\n```ts\nexport declare const wilt: PipeableWilt1<'Option'>\n```\n\nAdded in v2.6.5\n\n## wither\n\n**Signature**\n\n```ts\nexport declare const wither: PipeableWither1<'Option'>\n```\n\nAdded in v2.6.5\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Option<A>) => M\n```\n\nAdded in v2.0.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Option<A>) => B\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Option<A>) => B\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Alternative\n\n**Signature**\n\n```ts\nexport declare const Alternative: Alternative1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply1<'Option'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain1<'Option'>\n```\n\nAdded in v2.10.0\n\n## Compactable\n\n**Signature**\n\n```ts\nexport declare const Compactable: Compactable1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Extend\n\n**Signature**\n\n```ts\nexport declare const Extend: Extend1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: Filterable1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable1<'Option'>\n```\n\nAdded in v2.7.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither1<'Option'>\n```\n\nAdded in v2.11.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'Option'>\n```\n\nAdded in v2.7.0\n\n## MonadThrow\n\n**Signature**\n\n```ts\nexport declare const MonadThrow: MonadThrow1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'Option'>\n```\n\nAdded in v2.10.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Witherable\n\n**Signature**\n\n```ts\nexport declare const Witherable: Witherable1<'Option'>\n```\n\nAdded in v2.7.0\n\n## Zero\n\n**Signature**\n\n```ts\nexport declare const Zero: Zero1<'Option'>\n```\n\nAdded in v2.11.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare const getEq: <A>(E: Eq<A>) => Eq<Option<A>>\n```\n\n**Example**\n\n```ts\nimport { none, some, getEq } from 'fp-ts/Option'\nimport * as N from 'fp-ts/number'\n\nconst E = getEq(N.Eq)\nassert.strictEqual(E.equals(none, none), true)\nassert.strictEqual(E.equals(none, some(1)), false)\nassert.strictEqual(E.equals(some(1), none), false)\nassert.strictEqual(E.equals(some(1), some(2)), false)\nassert.strictEqual(E.equals(some(1), some(1)), true)\n```\n\nAdded in v2.0.0\n\n## getMonoid\n\nMonoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are\nconcatenated using the provided `Semigroup`\n\n| x       | y       | concat(x, y)       |\n| ------- | ------- | ------------------ |\n| none    | none    | none               |\n| some(a) | none    | some(a)            |\n| none    | some(b) | some(b)            |\n| some(a) | some(b) | some(concat(a, b)) |\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A>(S: Semigroup<A>) => Monoid<Option<A>>\n```\n\n**Example**\n\n```ts\nimport { getMonoid, some, none } from 'fp-ts/Option'\nimport { SemigroupSum } from 'fp-ts/number'\n\nconst M = getMonoid(SemigroupSum)\nassert.deepStrictEqual(M.concat(none, none), none)\nassert.deepStrictEqual(M.concat(some(1), none), some(1))\nassert.deepStrictEqual(M.concat(none, some(1)), some(1))\nassert.deepStrictEqual(M.concat(some(1), some(2)), some(3))\n```\n\nAdded in v2.0.0\n\n## getOrd\n\nThe `Ord` instance allows `Option` values to be compared with\n`compare`, whenever there is an `Ord` 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 getOrd: <A>(O: Ord<A>) => Ord<Option<A>>\n```\n\n**Example**\n\n```ts\nimport { none, some, getOrd } from 'fp-ts/Option'\nimport * as N from 'fp-ts/number'\n\nconst O = getOrd(N.Ord)\nassert.strictEqual(O.compare(none, none), 0)\nassert.strictEqual(O.compare(none, some(1)), -1)\nassert.strictEqual(O.compare(some(1), none), 1)\nassert.strictEqual(O.compare(some(1), some(2)), -1)\nassert.strictEqual(O.compare(some(1), some(1)), 0)\n```\n\nAdded in v2.0.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare const getShow: <A>(S: Show<A>) => Show<Option<A>>\n```\n\nAdded in v2.0.0\n\n# interop\n\n## tryCatch\n\nTransforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a\n`Some`.\n\nSee also [`tryCatchK`](#trycatchk).\n\n**Signature**\n\n```ts\nexport declare const tryCatch: <A>(f: LazyArg<A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { none, some, tryCatch } from 'fp-ts/Option'\n\nassert.deepStrictEqual(\n  tryCatch(() => {\n    throw new Error()\n  }),\n  none\n)\nassert.deepStrictEqual(\n  tryCatch(() => 1),\n  some(1)\n)\n```\n\nAdded in v2.0.0\n\n## tryCatchK\n\nConverts a function that may throw to one returning a `Option`.\n\n**Signature**\n\n```ts\nexport declare const tryCatchK: <A extends readonly unknown[], B>(f: (...a: A) => B) => (...a: A) => Option<B>\n```\n\nAdded in v2.10.0\n\n# legacy\n\n## alt\n\nAlias of `orElse`.\n\n**Signature**\n\n```ts\nexport declare const alt: <A>(that: LazyArg<Option<A>>) => (fa: Option<A>) => Option<A>\n```\n\nAdded in v2.0.0\n\n## altW\n\nAlias of `orElse`.\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <B>(that: LazyArg<Option<B>>) => <A>(fa: Option<A>) => Option<B | A>\n```\n\nAdded in v2.9.0\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => Option<B>) => (ma: Option<A>) => Option<B>\n```\n\nAdded in v2.0.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => Option<B>) => (first: Option<A>) => Option<A>\n```\n\nAdded in v2.0.0\n\n## chainFirstEitherK\n\nAlias of `tapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Option<A>) => Option<A>\n```\n\nAdded in v2.12.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => Option<B>\n```\n\nAdded in v2.11.0\n\n## fromNullableK\n\nReturns a _smart constructor_ from a function that returns a nullable value.\n\n**Signature**\n\n```ts\nexport declare const fromNullableK: <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 { fromNullableK, none, some } from 'fp-ts/Option'\n\nconst f = (s: string): number | undefined => {\n  const n = parseFloat(s)\n  return isNaN(n) ? undefined : n\n}\n\nconst g = fromNullableK(f)\n\nassert.deepStrictEqual(g('1'), some(1))\nassert.deepStrictEqual(g('a'), none)\n```\n\nAdded in v2.9.0\n\n## fromPredicate\n\nReturns a _smart constructor_ based on the given predicate.\n\n**Signature**\n\n```ts\nexport declare function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => Option<B>\nexport declare function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => Option<B>\nexport declare function fromPredicate<A>(predicate: Predicate<A>): (a: A) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { none, some, fromPredicate } from 'fp-ts/Option'\n\nconst getOption = fromPredicate((n: number) => n >= 0)\n\nassert.deepStrictEqual(getOption(-1), none)\nassert.deepStrictEqual(getOption(1), some(1))\n```\n\nAdded in v2.0.0\n\n# mapping\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: { <A>(a: A): <_>(self: Option<_>) => Option<A>; <_, A>(self: Option<_>, a: A): Option<A> }\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the `Some` value of this `Option` to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <_>(self: Option<_>) => Option<void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: Option<(a: A) => B>) => Option<B>\n```\n\nAdded in v2.10.0\n\n## map\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (fa: Option<A>) => Option<B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## None (interface)\n\n**Signature**\n\n```ts\nexport interface None {\n  readonly _tag: 'None'\n}\n```\n\nAdded in v2.0.0\n\n## Option (type alias)\n\n**Signature**\n\n```ts\nexport type Option<A> = None | Some<A>\n```\n\nAdded in v2.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 v2.0.0\n\n# pattern matching\n\n## fold\n\nAlias of [`match`](#match).\n\n**Signature**\n\n```ts\nexport declare const fold: <A, B>(onNone: LazyArg<B>, onSome: (a: A) => B) => (ma: Option<A>) => B\n```\n\nAdded in v2.0.0\n\n## foldW\n\nAlias of [`matchW`](#matchw).\n\n**Signature**\n\n```ts\nexport declare const foldW: <B, A, C>(onNone: LazyArg<B>, onSome: (a: A) => C) => (ma: Option<A>) => B | C\n```\n\nAdded in v2.10.0\n\n## match\n\nTakes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is\nreturned, otherwise the function is applied to the value inside the `Some` and the result is returned.\n\n**Signature**\n\n```ts\nexport declare const match: <A, B>(onNone: LazyArg<B>, onSome: (a: A) => B) => (ma: Option<A>) => B\n```\n\n**Example**\n\n```ts\nimport { some, none, match } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\nassert.strictEqual(\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.strictEqual(\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 v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <B, A, C>(onNone: LazyArg<B>, onSome: (a: A) => C) => (ma: Option<A>) => B | C\n```\n\nAdded in v2.10.0\n\n# refinements\n\n## isNone\n\nReturns `true` if the option is `None`, `false` otherwise.\n\n**Signature**\n\n```ts\nexport declare const isNone: (fa: Option<unknown>) => fa is None\n```\n\n**Example**\n\n```ts\nimport { some, none, isNone } from 'fp-ts/Option'\n\nassert.strictEqual(isNone(some(1)), false)\nassert.strictEqual(isNone(none), true)\n```\n\nAdded in v2.0.0\n\n## isSome\n\nReturns `true` if the option is an instance of `Some`, `false` otherwise.\n\n**Signature**\n\n```ts\nexport declare const isSome: <A>(fa: Option<A>) => fa is Some<A>\n```\n\n**Example**\n\n```ts\nimport { some, none, isSome } from 'fp-ts/Option'\n\nassert.strictEqual(isSome(some(1)), true)\nassert.strictEqual(isSome(none), false)\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## chainEitherK\n\n**Signature**\n\n```ts\nexport declare const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Option<A>) => Option<B>\n```\n\nAdded in v2.11.0\n\n## chainNullableK\n\nThis is `chain` + `fromNullable`, useful when working with optional values.\n\n**Signature**\n\n```ts\nexport declare const chainNullableK: <A, B>(\n  f: (a: A) => B | null | undefined\n) => (ma: Option<A>) => Option<NonNullable<B>>\n```\n\n**Example**\n\n```ts\nimport { some, none, fromNullable, chainNullableK } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\ninterface Employee {\n  readonly company?: {\n    readonly address?: {\n      readonly street?: {\n        readonly name?: string\n      }\n    }\n  }\n}\n\nconst employee1: Employee = { company: { address: { street: { name: 'high street' } } } }\n\nassert.deepStrictEqual(\n  pipe(\n    fromNullable(employee1.company),\n    chainNullableK((company) => company.address),\n    chainNullableK((address) => address.street),\n    chainNullableK((street) => street.name)\n  ),\n  some('high street')\n)\n\nconst employee2: Employee = { company: { address: { street: {} } } }\n\nassert.deepStrictEqual(\n  pipe(\n    fromNullable(employee2.company),\n    chainNullableK((company) => company.address),\n    chainNullableK((address) => address.street),\n    chainNullableK((street) => street.name)\n  ),\n  none\n)\n```\n\nAdded in v2.9.0\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A) => Option<B>): (ma: Option<A>) => Option<B>\n  <A, B>(ma: Option<A>, f: (a: A) => Option<B>): Option<B>\n}\n```\n\nAdded in v2.14.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: Option<Option<A>>) => Option<A>\n```\n\nAdded in v2.0.0\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence1<'Option'>\n```\n\nAdded in v2.6.3\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <A>(arr: readonly Option<A>[]) => Option<readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse1<'Option'>\n```\n\nAdded in v2.6.3\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <A, B>(f: (a: A) => Option<B>) => (as: readonly A[]) => Option<readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Option<B>\n) => (as: readonly A[]) => Option<readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Option<B>\n) => (as: readonly A[]) => Option<readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Option<B>\n) => (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Option'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: Option<readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(fa: Option<A>) => <B>(fab: Option<(a: A) => B>) => Option<B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: Option<B>) => <A>(first: Option<A>) => Option<A>\n```\n\nAdded in v2.0.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: Option<B>) => <A>(first: Option<A>) => Option<B>\n```\n\nAdded in v2.0.0\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <A>(ma: Option<A>) => Option<Option<A>>\n```\n\nAdded in v2.0.0\n\n## elem\n\nReturns `true` if `ma` contains `a`\n\n**Signature**\n\n```ts\nexport declare function elem<A>(E: Eq<A>): {\n  (a: A): (ma: Option<A>) => boolean\n  (a: A, ma: Option<A>): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { some, none, elem } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\nimport * as N from 'fp-ts/number'\n\nassert.strictEqual(pipe(some(1), elem(N.Eq)(1)), true)\nassert.strictEqual(pipe(some(1), elem(N.Eq)(2)), false)\nassert.strictEqual(pipe(none, elem(N.Eq)(1)), false)\n```\n\nAdded in v2.0.0\n\n## exists\n\nReturns `true` if the predicate is satisfied by the wrapped value\n\n**Signature**\n\n```ts\nexport declare const exists: <A>(predicate: Predicate<A>) => (ma: Option<A>) => boolean\n```\n\n**Example**\n\n```ts\nimport { some, none, exists } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\nassert.strictEqual(\n  pipe(\n    some(1),\n    exists((n) => n > 0)\n  ),\n  true\n)\nassert.strictEqual(\n  pipe(\n    some(1),\n    exists((n) => n > 1)\n  ),\n  false\n)\nassert.strictEqual(\n  pipe(\n    none,\n    exists((n) => n > 0)\n  ),\n  false\n)\n```\n\nAdded in v2.0.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <A, B>(f: (wa: Option<A>) => B) => (wa: Option<A>) => Option<B>\n```\n\nAdded in v2.0.0\n\n## throwError\n\n**Signature**\n\n```ts\nexport declare const throwError: <E, A>(e: E) => Option<A>\n```\n\nAdded in v2.7.0\n\n## zero\n\n**Signature**\n\n```ts\nexport declare const zero: <A>() => Option<A>\n```\n\nAdded in v2.7.0\n\n# zone of death\n\n## ~~getApplyMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplyMonoid: <A>(M: Monoid<A>) => Monoid<Option<A>>\n```\n\nAdded in v2.0.0\n\n## ~~getApplySemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplySemigroup: <A>(S: Semigroup<A>) => Semigroup<Option<A>>\n```\n\nAdded in v2.0.0\n\n## ~~getFirstMonoid~~\n\nUse\n\n```ts\nimport { first } from 'fp-ts/Semigroup'\nimport { getMonoid } from 'fp-ts/Option'\n\ngetMonoid(first())\n```\n\ninstead.\n\nMonoid returning the left-most non-`None` value\n\n| x       | y       | concat(x, y) |\n| ------- | ------- | ------------ |\n| none    | none    | none         |\n| some(a) | none    | some(a)      |\n| none    | some(b) | some(b)      |\n| some(a) | some(b) | some(a)      |\n\n**Signature**\n\n```ts\nexport declare const getFirstMonoid: <A = never>() => Monoid<Option<A>>\n```\n\n**Example**\n\n```ts\nimport { getFirstMonoid, some, none } from 'fp-ts/Option'\n\nconst M = getFirstMonoid<number>()\nassert.deepStrictEqual(M.concat(none, none), none)\nassert.deepStrictEqual(M.concat(some(1), none), some(1))\nassert.deepStrictEqual(M.concat(none, some(2)), some(2))\nassert.deepStrictEqual(M.concat(some(1), some(2)), some(1))\n```\n\nAdded in v2.0.0\n\n## ~~getLastMonoid~~\n\nUse\n\n```ts\nimport { last } from 'fp-ts/Semigroup'\nimport { getMonoid } from 'fp-ts/Option'\n\ngetMonoid(last())\n```\n\ninstead.\n\nMonoid returning the right-most non-`None` value\n\n| x       | y       | concat(x, y) |\n| ------- | ------- | ------------ |\n| none    | none    | none         |\n| some(a) | none    | some(a)      |\n| none    | some(b) | some(b)      |\n| some(a) | some(b) | some(b)      |\n\n**Signature**\n\n```ts\nexport declare const getLastMonoid: <A = never>() => Monoid<Option<A>>\n```\n\n**Example**\n\n```ts\nimport { getLastMonoid, some, none } from 'fp-ts/Option'\n\nconst M = getLastMonoid<number>()\nassert.deepStrictEqual(M.concat(none, none), none)\nassert.deepStrictEqual(M.concat(some(1), none), some(1))\nassert.deepStrictEqual(M.concat(none, some(2)), some(2))\nassert.deepStrictEqual(M.concat(some(1), some(2)), some(2))\n```\n\nAdded in v2.0.0\n\n## ~~getRefinement~~\n\nUse `Refinement` module instead.\n\n**Signature**\n\n```ts\nexport declare function getRefinement<A, B extends A>(getOption: (a: A) => Option<B>): Refinement<A, B>\n```\n\nAdded in v2.0.0\n\n## ~~mapNullable~~\n\nUse [`chainNullableK`](#chainnullablek) instead.\n\n**Signature**\n\n```ts\nexport declare const mapNullable: <A, B>(f: (a: A) => B | null | undefined) => (ma: Option<A>) => Option<NonNullable<B>>\n```\n\nAdded in v2.0.0\n\n## ~~option~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `O.Functor` instead of `O.option`\n(where `O` is from `import O from 'fp-ts/Option'`)\n\n**Signature**\n\n```ts\nexport declare const option: Monad1<'Option'> &\n  Foldable1<'Option'> &\n  Alternative1<'Option'> &\n  Extend1<'Option'> &\n  Witherable1<'Option'> &\n  MonadThrow1<'Option'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/OptionT.ts.md",
    "content": "---\ntitle: OptionT.ts\nnav_order: 69\nparent: Modules\n---\n\n## OptionT overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [lifting](#lifting)\n  - [fromPredicate](#frompredicate)\n- [pattern matching](#pattern-matching)\n  - [match](#match)\n- [utils](#utils)\n  - [alt](#alt)\n  - [ap](#ap)\n  - [chain](#chain)\n  - [chainNullableK](#chainnullablek)\n  - [chainOptionK](#chainoptionk)\n  - [fromEither](#fromeither)\n  - [fromF](#fromf)\n  - [fromNullable](#fromnullable)\n  - [fromNullableK](#fromnullablek)\n  - [fromOptionK](#fromoptionk)\n  - [getOrElse](#getorelse)\n  - [map](#map)\n  - [matchE](#matche)\n  - [some](#some)\n  - [zero](#zero)\n- [zone of death](#zone-of-death)\n  - [~~OptionM1~~ (interface)](#optionm1-interface)\n  - [~~OptionM2C~~ (interface)](#optionm2c-interface)\n  - [~~OptionM2~~ (interface)](#optionm2-interface)\n  - [~~OptionM~~ (interface)](#optionm-interface)\n  - [~~OptionT1~~ (type alias)](#optiont1-type-alias)\n  - [~~OptionT2~~ (type alias)](#optiont2-type-alias)\n  - [~~OptionT~~ (interface)](#optiont-interface)\n  - [~~getOptionM~~](#getoptionm)\n\n---\n\n# lifting\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare function fromPredicate<F extends URIS4>(\n  F: Pointed4<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(a: A) => Kind4<F, S, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <S, R, E, B extends A>(b: B) => Kind4<F, S, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <S, R, E>(a: A) => Kind4<F, S, R, E, Option<A>>\n}\nexport declare function fromPredicate<F extends URIS3>(\n  F: Pointed3<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R, E>(a: A) => Kind3<F, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <R, E, B extends A>(b: B) => Kind3<F, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <R, E>(a: A) => Kind3<F, R, E, Option<A>>\n}\nexport declare function fromPredicate<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(a: A) => Kind3<F, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <R, B extends A>(b: B) => Kind3<F, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <R>(a: A) => Kind3<F, R, E, Option<A>>\n}\nexport declare function fromPredicate<F extends URIS2>(\n  F: Pointed2<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <E>(a: A) => Kind2<F, E, Option<B>>\n  <A>(predicate: Predicate<A>): <E, B extends A>(b: B) => Kind2<F, E, Option<B>>\n  <A>(predicate: Predicate<A>): <E>(a: A) => Kind2<F, E, Option<A>>\n}\nexport declare function fromPredicate<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => Kind2<F, E, Option<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => Kind2<F, E, Option<B>>\n  <A>(predicate: Predicate<A>): (a: A) => Kind2<F, E, Option<A>>\n}\nexport declare function fromPredicate<F extends URIS>(\n  F: Pointed1<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => Kind<F, Option<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => Kind<F, Option<B>>\n  <A>(predicate: Predicate<A>): (a: A) => Kind<F, Option<A>>\n}\nexport declare function fromPredicate<F>(F: Pointed<F>): {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => HKT<F, Option<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => HKT<F, Option<B>>\n  <A>(predicate: Predicate<A>): (a: A) => HKT<F, Option<A>>\n}\n```\n\nAdded in v2.10.0\n\n# pattern matching\n\n## match\n\n**Signature**\n\n```ts\nexport declare function match<F extends URIS4>(\n  F: Functor4<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => <S, R, E>(ma: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, B>\nexport declare function match<F extends URIS3>(\n  F: Functor3<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => <R, E>(ma: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, B>\nexport declare function match<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => <R>(ma: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, B>\nexport declare function match<F extends URIS2>(\n  F: Functor2<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => <E>(ma: Kind2<F, E, Option<A>>) => Kind2<F, E, B>\nexport declare function match<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: Kind2<F, E, Option<A>>) => Kind2<F, E, B>\nexport declare function match<F extends URIS>(\n  F: Functor1<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: Kind<F, Option<A>>) => Kind<F, B>\nexport declare function match<F>(\n  F: Functor<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: HKT<F, Option<A>>) => HKT<F, B>\n```\n\nAdded in v2.10.0\n\n# utils\n\n## alt\n\n**Signature**\n\n```ts\nexport declare function alt<M extends URIS4>(\n  M: Monad4<M>\n): <S, R, E, A>(\n  second: LazyArg<Kind4<M, S, R, E, Option<A>>>\n) => (first: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<A>>\nexport declare function alt<M extends URIS3>(\n  M: Monad3<M>\n): <R, E, A>(\n  second: LazyArg<Kind3<M, R, E, Option<A>>>\n) => (first: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<A>>\nexport declare function alt<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <R, A>(second: LazyArg<Kind3<M, R, E, Option<A>>>) => (first: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<A>>\nexport declare function alt<M extends URIS2>(\n  M: Monad2<M>\n): <E, A>(second: LazyArg<Kind2<M, E, Option<A>>>) => (first: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<A>>\nexport declare function alt<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A>(second: LazyArg<Kind2<M, E, Option<A>>>) => (first: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<A>>\nexport declare function alt<M extends URIS>(\n  M: Monad1<M>\n): <A>(second: LazyArg<Kind<M, Option<A>>>) => (first: Kind<M, Option<A>>) => Kind<M, Option<A>>\nexport declare function alt<M>(\n  M: Monad<M>\n): <A>(second: LazyArg<HKT<M, Option<A>>>) => (first: HKT<M, Option<A>>) => HKT<M, Option<A>>\n```\n\nAdded in v2.10.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare function ap<F extends URIS4>(\n  F: Apply4<F>\n): <S, R, E, A>(\n  fa: Kind4<F, S, R, E, Option<A>>\n) => <B>(fab: Kind4<F, S, R, E, Option<(a: A) => B>>) => Kind4<F, S, R, E, Option<B>>\nexport declare function ap<F extends URIS3>(\n  F: Apply3<F>\n): <R, E, A>(\n  fa: Kind3<F, R, E, Option<A>>\n) => <B>(fab: Kind3<F, R, E, Option<(a: A) => B>>) => Kind3<F, R, E, Option<B>>\nexport declare function ap<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <R, A>(fa: Kind3<F, R, E, Option<A>>) => <B>(fab: Kind3<F, R, E, Option<(a: A) => B>>) => Kind3<F, R, E, Option<B>>\nexport declare function ap<F extends URIS2>(\n  F: Apply2<F>\n): <E, A>(fa: Kind2<F, E, Option<A>>) => <B>(fab: Kind2<F, E, Option<(a: A) => B>>) => Kind2<F, E, Option<B>>\nexport declare function ap<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <A>(fa: Kind2<F, E, Option<A>>) => <B>(fab: Kind2<F, E, Option<(a: A) => B>>) => Kind2<F, E, Option<B>>\nexport declare function ap<F extends URIS>(\n  F: Apply1<F>\n): <A>(fa: Kind<F, Option<A>>) => <B>(fab: Kind<F, Option<(a: A) => B>>) => Kind<F, Option<B>>\nexport declare function ap<F>(\n  F: Apply<F>\n): <A>(fa: HKT<F, Option<A>>) => <B>(fab: HKT<F, Option<(a: A) => B>>) => HKT<F, Option<B>>\n```\n\nAdded in v2.10.0\n\n## chain\n\n**Signature**\n\n```ts\nexport declare function chain<M extends URIS4>(\n  M: Monad4<M>\n): <A, S, R, E, B>(\n  f: (a: A) => Kind4<M, S, R, E, Option<B>>\n) => (ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<B>>\nexport declare function chain<M extends URIS3>(\n  M: Monad3<M>\n): <A, R, E, B>(f: (a: A) => Kind3<M, R, E, Option<B>>) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>\nexport declare function chain<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <A, R, B>(f: (a: A) => Kind3<M, R, E, Option<B>>) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>\nexport declare function chain<M extends URIS2>(\n  M: Monad2<M>\n): <A, E, B>(f: (a: A) => Kind2<M, E, Option<B>>) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>\nexport declare function chain<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(f: (a: A) => Kind2<M, E, Option<B>>) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>\nexport declare function chain<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(f: (a: A) => Kind<M, Option<B>>) => (ma: Kind<M, Option<A>>) => Kind<M, Option<B>>\nexport declare function chain<M>(\n  M: Monad<M>\n): <A, B>(f: (a: A) => HKT<M, Option<B>>) => (ma: HKT<M, Option<A>>) => HKT<M, Option<B>>\n```\n\nAdded in v2.10.0\n\n## chainNullableK\n\n**Signature**\n\n```ts\nexport declare function chainNullableK<M extends URIS4>(\n  M: Monad4<M>\n): <A, B>(\n  f: (a: A) => B | null | undefined\n) => <S, R, E>(ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<NonNullable<B>>>\nexport declare function chainNullableK<M extends URIS3>(\n  M: Monad3<M>\n): <A, B>(\n  f: (a: A) => B | null | undefined\n) => <R, E>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<NonNullable<B>>>\nexport declare function chainNullableK<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <A, B>(\n  f: (a: A) => B | null | undefined\n) => <R>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<NonNullable<B>>>\nexport declare function chainNullableK<M extends URIS2>(\n  M: Monad2<M>\n): <A, B>(f: (a: A) => B | null | undefined) => <E>(ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<NonNullable<B>>>\nexport declare function chainNullableK<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(f: (a: A) => B | null | undefined) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<NonNullable<B>>>\nexport declare function chainNullableK<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(f: (a: A) => B | null | undefined) => (ma: Kind<M, Option<A>>) => Kind<M, Option<NonNullable<B>>>\nexport declare function chainNullableK<M>(\n  M: Monad<M>\n): <A, B>(f: (a: A) => B | null | undefined) => (ma: HKT<M, Option<A>>) => HKT<M, Option<NonNullable<B>>>\n```\n\nAdded in v2.10.0\n\n## chainOptionK\n\n**Signature**\n\n```ts\nexport declare function chainOptionK<M extends URIS4>(\n  M: Monad4<M>\n): <A, B>(f: (a: A) => Option<B>) => <S, R, E>(ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<B>>\nexport declare function chainOptionK<M extends URIS3>(\n  M: Monad3<M>\n): <A, B>(f: (a: A) => Option<B>) => <R, E>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>\nexport declare function chainOptionK<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <A, B>(f: (a: A) => Option<B>) => <R>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>\nexport declare function chainOptionK<M extends URIS2>(\n  M: Monad2<M>\n): <A, B>(f: (a: A) => Option<B>) => <E>(ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>\nexport declare function chainOptionK<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>\nexport declare function chainOptionK<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(f: (a: A) => Option<B>) => (ma: Kind<M, Option<A>>) => Kind<M, Option<B>>\nexport declare function chainOptionK<M>(\n  M: Monad<M>\n): <A, B>(f: (a: A) => Option<B>) => (ma: HKT<M, Option<A>>) => HKT<M, Option<B>>\n```\n\nAdded in v2.10.0\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare function fromEither<F extends URIS4>(\n  F: Pointed4<F>\n): <A, S, R, E>(e: Either<unknown, A>) => Kind4<F, S, R, E, Option<A>>\nexport declare function fromEither<F extends URIS3>(\n  F: Pointed3<F>\n): <A, R, E>(e: Either<unknown, A>) => Kind3<F, R, E, Option<A>>\nexport declare function fromEither<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): <A, R>(e: Either<unknown, A>) => Kind3<F, R, E, Option<A>>\nexport declare function fromEither<F extends URIS2>(\n  F: Pointed2<F>\n): <A, E>(e: Either<unknown, A>) => Kind2<F, E, Option<A>>\nexport declare function fromEither<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): <A>(e: Either<unknown, A>) => Kind2<F, E, Option<A>>\nexport declare function fromEither<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): <A>(e: Either<unknown, A>) => Kind2<F, E, Option<A>>\nexport declare function fromEither<F extends URIS>(F: Pointed1<F>): <A>(e: Either<unknown, A>) => Kind<F, Option<A>>\nexport declare function fromEither<F>(F: Pointed<F>): <A>(e: Either<unknown, A>) => HKT<F, Option<A>>\n```\n\nAdded in v2.10.0\n\n## fromF\n\n**Signature**\n\n```ts\nexport declare function fromF<F extends URIS4>(\n  F: Functor4<F>\n): <S, R, E, A>(ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, Option<A>>\nexport declare function fromF<F extends URIS3>(\n  F: Functor3<F>\n): <R, E, A>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, Option<A>>\nexport declare function fromF<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <R, A>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, Option<A>>\nexport declare function fromF<F extends URIS2>(F: Functor2<F>): <E, A>(ma: Kind2<F, E, A>) => Kind2<F, E, Option<A>>\nexport declare function fromF<F extends URIS2, E>(F: Functor2C<F, E>): <A>(ma: Kind2<F, E, A>) => Kind2<F, E, Option<A>>\nexport declare function fromF<F extends URIS>(F: Functor1<F>): <A>(ma: Kind<F, A>) => Kind<F, Option<A>>\nexport declare function fromF<F>(F: Functor<F>): <A>(ma: HKT<F, A>) => HKT<F, Option<A>>\n```\n\nAdded in v2.10.0\n\n## fromNullable\n\n**Signature**\n\n```ts\nexport declare function fromNullable<F extends URIS4>(\n  F: Pointed4<F>\n): <A, S, R, E>(a: A) => Kind4<F, S, R, E, Option<NonNullable<A>>>\nexport declare function fromNullable<F extends URIS3>(\n  F: Pointed3<F>\n): <A, R, E>(a: A) => Kind3<F, R, E, Option<NonNullable<A>>>\nexport declare function fromNullable<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): <A, R>(a: A) => Kind3<F, R, E, Option<NonNullable<A>>>\nexport declare function fromNullable<F extends URIS2>(\n  F: Pointed2<F>\n): <A, E>(a: A) => Kind2<F, E, Option<NonNullable<A>>>\nexport declare function fromNullable<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): <A>(a: A) => Kind2<F, E, Option<NonNullable<A>>>\nexport declare function fromNullable<F extends URIS>(F: Pointed1<F>): <A>(a: A) => Kind<F, Option<NonNullable<A>>>\nexport declare function fromNullable<F>(F: Pointed<F>): <A>(a: A) => HKT<F, Option<NonNullable<A>>>\n```\n\nAdded in v2.10.0\n\n## fromNullableK\n\n**Signature**\n\n```ts\nexport declare function fromNullableK<F extends URIS4>(\n  F: Pointed4<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <S, R, E>(...a: A) => Kind4<F, S, R, E, Option<NonNullable<B>>>\nexport declare function fromNullableK<F extends URIS3>(\n  F: Pointed3<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <R, E>(...a: A) => Kind3<F, R, E, Option<NonNullable<B>>>\nexport declare function fromNullableK<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <R>(...a: A) => Kind3<F, R, E, Option<NonNullable<B>>>\nexport declare function fromNullableK<F extends URIS2>(\n  F: Pointed2<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <E>(...a: A) => Kind2<F, E, Option<NonNullable<B>>>\nexport declare function fromNullableK<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Kind2<F, E, Option<NonNullable<B>>>\nexport declare function fromNullableK<F extends URIS>(\n  F: Pointed1<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Kind<F, Option<NonNullable<B>>>\nexport declare function fromNullableK<F>(\n  F: Pointed<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => HKT<F, Option<NonNullable<B>>>\n```\n\nAdded in v2.10.0\n\n## fromOptionK\n\n**Signature**\n\n```ts\nexport declare function fromOptionK<F extends URIS4>(\n  F: Pointed4<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Option<B>\n) => <S, R, E>(...a: A) => Kind4<F, S, R, E, Option<B>>\nexport declare function fromOptionK<F extends URIS3>(\n  F: Pointed3<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R, E>(...a: A) => Kind3<F, R, E, Option<B>>\nexport declare function fromOptionK<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R>(...a: A) => Kind3<F, R, E, Option<B>>\nexport declare function fromOptionK<F extends URIS2>(\n  F: Pointed2<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <E>(...a: A) => Kind2<F, E, Option<B>>\nexport declare function fromOptionK<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind2<F, E, Option<B>>\nexport declare function fromOptionK<F extends URIS>(\n  F: Pointed1<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind<F, Option<B>>\nexport declare function fromOptionK<F>(\n  F: Pointed<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => HKT<F, Option<B>>\n```\n\nAdded in v2.10.0\n\n## getOrElse\n\n**Signature**\n\n```ts\nexport declare function getOrElse<M extends URIS4>(\n  M: Monad4<M>\n): <S, R, E, A>(onNone: LazyArg<Kind4<M, S, R, E, A>>) => (fa: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, A>\nexport declare function getOrElse<M extends URIS3>(\n  M: Monad3<M>\n): <R, E, A>(onNone: LazyArg<Kind3<M, R, E, A>>) => (fa: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, A>\nexport declare function getOrElse<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <R, A>(onNone: LazyArg<Kind3<M, R, E, A>>) => (fa: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, A>\nexport declare function getOrElse<M extends URIS2>(\n  M: Monad2<M>\n): <E, A>(onNone: LazyArg<Kind2<M, E, A>>) => (fa: Kind2<M, E, Option<A>>) => Kind2<M, E, A>\nexport declare function getOrElse<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A>(onNone: LazyArg<Kind2<M, E, A>>) => (fa: Kind2<M, E, Option<A>>) => Kind2<M, E, A>\nexport declare function getOrElse<M extends URIS>(\n  M: Monad1<M>\n): <A>(onNone: LazyArg<Kind<M, A>>) => (fa: Kind<M, Option<A>>) => Kind<M, A>\nexport declare function getOrElse<M>(\n  M: Monad<M>\n): <A>(onNone: LazyArg<HKT<M, A>>) => (fa: HKT<M, Option<A>>) => HKT<M, A>\n```\n\nAdded in v2.10.0\n\n## map\n\n**Signature**\n\n```ts\nexport declare function map<F extends URIS4>(\n  F: Functor4<F>\n): <A, B>(f: (a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, Option<B>>\nexport declare function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, Option<B>>\nexport declare function map<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <A, B>(f: (a: A) => B) => <R>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, Option<B>>\nexport declare function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, Option<B>>\nexport declare function map<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <A, B>(f: (a: A) => B) => (fa: Kind2<F, E, Option<A>>) => Kind2<F, E, Option<B>>\nexport declare function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => (fa: Kind<F, Option<A>>) => Kind<F, Option<B>>\nexport declare function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, Option<A>>) => HKT<F, Option<B>>\n```\n\nAdded in v2.10.0\n\n## matchE\n\n**Signature**\n\n```ts\nexport declare function matchE<M extends URIS4>(\n  M: Chain4<M>\n): <S, R, E, B, A>(\n  onNone: () => Kind4<M, S, R, E, B>,\n  onSome: (a: A) => Kind4<M, S, R, E, B>\n) => (ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, B>\nexport declare function matchE<M extends URIS3>(\n  M: Chain3<M>\n): <R, E, B, A>(\n  onNone: () => Kind3<M, R, E, B>,\n  onSome: (a: A) => Kind3<M, R, E, B>\n) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, B>\nexport declare function matchE<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <R, B, A>(\n  onNone: () => Kind3<M, R, E, B>,\n  onSome: (a: A) => Kind3<M, R, E, B>\n) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, B>\nexport declare function matchE<M extends URIS2>(\n  M: Chain2<M>\n): <E, B, A>(\n  onNone: () => Kind2<M, E, B>,\n  onSome: (a: A) => Kind2<M, E, B>\n) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, B>\nexport declare function matchE<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <B, A>(\n  onNone: () => Kind2<M, E, B>,\n  onSome: (a: A) => Kind2<M, E, B>\n) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, B>\nexport declare function matchE<M extends URIS>(\n  M: Chain1<M>\n): <B, A>(onNone: () => Kind<M, B>, onSome: (a: A) => Kind<M, B>) => (ma: Kind<M, Option<A>>) => Kind<M, B>\nexport declare function matchE<M>(\n  M: Chain<M>\n): <B, A>(onNone: () => HKT<M, B>, onSome: (a: A) => HKT<M, B>) => (ma: HKT<M, Option<A>>) => HKT<M, B>\n```\n\nAdded in v2.10.0\n\n## some\n\n**Signature**\n\n```ts\nexport declare function some<F extends URIS4>(F: Pointed4<F>): <A, S, R, E>(a: A) => Kind4<F, S, R, E, Option<A>>\nexport declare function some<F extends URIS3>(F: Pointed3<F>): <A, R, E>(a: A) => Kind3<F, R, E, Option<A>>\nexport declare function some<F extends URIS3, E>(F: Pointed3C<F, E>): <A, R>(a: A) => Kind3<F, R, E, Option<A>>\nexport declare function some<F extends URIS2>(F: Pointed2<F>): <A, E>(a: A) => Kind2<F, E, Option<A>>\nexport declare function some<F extends URIS2, E>(F: Pointed2C<F, E>): <A>(a: A) => Kind2<F, E, Option<A>>\nexport declare function some<F extends URIS>(F: Pointed1<F>): <A>(a: A) => Kind<F, Option<A>>\nexport declare function some<F>(F: Pointed<F>): <A>(a: A) => HKT<F, Option<A>>\n```\n\nAdded in v2.10.0\n\n## zero\n\n**Signature**\n\n```ts\nexport declare function zero<F extends URIS4>(F: Pointed4<F>): <S, R, E, A>() => Kind4<F, S, R, E, Option<A>>\nexport declare function zero<F extends URIS3>(F: Pointed3<F>): <R, E, A>() => Kind3<F, R, E, Option<A>>\nexport declare function zero<F extends URIS3, E>(F: Pointed3C<F, E>): <R, A>() => Kind3<F, R, E, Option<A>>\nexport declare function zero<F extends URIS2>(F: Pointed2<F>): <E, A>() => Kind2<F, E, Option<A>>\nexport declare function zero<F extends URIS2, E>(F: Pointed2C<F, E>): <A>() => Kind2<F, E, Option<A>>\nexport declare function zero<F extends URIS>(F: Pointed1<F>): <A>() => Kind<F, Option<A>>\nexport declare function zero<F>(F: Pointed<F>): <A>() => HKT<F, Option<A>>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~OptionM1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface OptionM1<M extends URIS> extends ApplicativeComposition11<M, O.URI> {\n  readonly chain: <A, B>(ma: OptionT1<M, A>, f: (a: A) => OptionT1<M, B>) => OptionT1<M, B>\n  readonly alt: <A>(fa: OptionT1<M, A>, that: LazyArg<OptionT1<M, A>>) => OptionT1<M, A>\n  readonly fold: <A, R>(ma: OptionT1<M, A>, onNone: LazyArg<Kind<M, R>>, onSome: (a: A) => Kind<M, R>) => Kind<M, R>\n  readonly getOrElse: <A>(ma: OptionT1<M, A>, onNone: LazyArg<Kind<M, A>>) => Kind<M, A>\n  readonly fromM: <A>(ma: Kind<M, A>) => OptionT1<M, A>\n  readonly none: <A = never>() => OptionT1<M, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~OptionM2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface OptionM2C<M extends URIS2, E> extends ApplicativeComposition2C1<M, O.URI, E> {\n  readonly chain: <A, B>(ma: OptionT2<M, E, A>, f: (a: A) => OptionT2<M, E, B>) => OptionT2<M, E, B>\n  readonly alt: <A>(fa: OptionT2<M, E, A>, that: LazyArg<OptionT2<M, E, A>>) => OptionT2<M, E, A>\n  readonly fold: <A, R>(\n    ma: OptionT2<M, E, A>,\n    onNone: LazyArg<Kind2<M, E, R>>,\n    onSome: (a: A) => Kind2<M, E, R>\n  ) => Kind2<M, E, R>\n  readonly getOrElse: <A>(ma: OptionT2<M, E, A>, onNone: LazyArg<Kind2<M, E, A>>) => Kind2<M, E, A>\n  readonly fromM: <A>(ma: Kind2<M, E, A>) => OptionT2<M, E, A>\n  readonly none: <A = never>() => OptionT2<M, E, A>\n}\n```\n\nAdded in v2.2.0\n\n## ~~OptionM2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface OptionM2<M extends URIS2> extends ApplicativeComposition21<M, O.URI> {\n  readonly chain: <E, A, B>(ma: OptionT2<M, E, A>, f: (a: A) => OptionT2<M, E, B>) => OptionT2<M, E, B>\n  readonly alt: <E, A>(fa: OptionT2<M, E, A>, that: LazyArg<OptionT2<M, E, A>>) => OptionT2<M, E, A>\n  readonly fold: <E, A, R>(\n    ma: OptionT2<M, E, A>,\n    onNone: LazyArg<Kind2<M, E, R>>,\n    onSome: (a: A) => Kind2<M, E, R>\n  ) => Kind2<M, E, R>\n  readonly getOrElse: <E, A>(ma: OptionT2<M, E, A>, onNone: LazyArg<Kind2<M, E, A>>) => Kind2<M, E, A>\n  readonly fromM: <E, A>(ma: Kind2<M, E, A>) => OptionT2<M, E, A>\n  readonly none: <E = never, A = never>() => OptionT2<M, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~OptionM~~ (interface)\n\n**Signature**\n\n```ts\nexport interface OptionM<M> extends ApplicativeCompositionHKT1<M, O.URI> {\n  readonly chain: <A, B>(ma: OptionT<M, A>, f: (a: A) => OptionT<M, B>) => OptionT<M, B>\n  readonly alt: <A>(fa: OptionT<M, A>, that: LazyArg<OptionT<M, A>>) => OptionT<M, A>\n  readonly fold: <A, R>(ma: OptionT<M, A>, onNone: LazyArg<HKT<M, R>>, onSome: (a: A) => HKT<M, R>) => HKT<M, R>\n  readonly getOrElse: <A>(ma: OptionT<M, A>, onNone: LazyArg<HKT<M, A>>) => HKT<M, A>\n  readonly fromM: <A>(ma: HKT<M, A>) => OptionT<M, A>\n  readonly none: <A = never>() => OptionT<M, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~OptionT1~~ (type alias)\n\n**Signature**\n\n```ts\nexport type OptionT1<M extends URIS, A> = Kind<M, Option<A>>\n```\n\nAdded in v2.0.0\n\n## ~~OptionT2~~ (type alias)\n\n**Signature**\n\n```ts\nexport type OptionT2<M extends URIS2, E, A> = Kind2<M, E, Option<A>>\n```\n\nAdded in v2.0.0\n\n## ~~OptionT~~ (interface)\n\n**Signature**\n\n```ts\nexport interface OptionT<M, A> extends HKT<M, Option<A>> {}\n```\n\nAdded in v2.0.0\n\n## ~~getOptionM~~\n\n**Signature**\n\n```ts\nexport declare function getOptionM<M extends URIS2>(M: Monad2<M>): OptionM2<M>\nexport declare function getOptionM<M extends URIS2, E>(M: Monad2C<M, E>): OptionM2C<M, E>\nexport declare function getOptionM<M extends URIS>(M: Monad1<M>): OptionM1<M>\nexport declare function getOptionM<M>(M: Monad<M>): OptionM<M>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Ord.ts.md",
    "content": "---\ntitle: Ord.ts\nnav_order: 70\nparent: Modules\n---\n\n## Ord overview\n\nThe `Ord` type class represents types which support comparisons with a _total order_.\n\nInstances should satisfy the laws of total orderings:\n\n1. Reflexivity: `S.compare(a, a) <= 0`\n2. Antisymmetry: if `S.compare(a, b) <= 0` and `S.compare(b, a) <= 0` then `a <-> b`\n3. Transitivity: if `S.compare(a, b) <= 0` and `S.compare(b, c) <= 0` then `S.compare(a, c) <= 0`\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [fromCompare](#fromcompare)\n- [defaults](#defaults)\n  - [equalsDefault](#equalsdefault)\n- [instances](#instances)\n  - [Contravariant](#contravariant)\n  - [getMonoid](#getmonoid)\n  - [getSemigroup](#getsemigroup)\n- [model](#model)\n  - [Ord (interface)](#ord-interface)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [between](#between)\n  - [clamp](#clamp)\n  - [contramap](#contramap)\n  - [equals](#equals)\n  - [geq](#geq)\n  - [gt](#gt)\n  - [leq](#leq)\n  - [lt](#lt)\n  - [max](#max)\n  - [min](#min)\n  - [reverse](#reverse)\n  - [trivial](#trivial)\n  - [tuple](#tuple)\n- [zone of death](#zone-of-death)\n  - [~~getDualOrd~~](#getdualord)\n  - [~~getTupleOrd~~](#gettupleord)\n  - [~~ordBoolean~~](#ordboolean)\n  - [~~ordDate~~](#orddate)\n  - [~~ordNumber~~](#ordnumber)\n  - [~~ordString~~](#ordstring)\n  - [~~ord~~](#ord)\n\n---\n\n# constructors\n\n## fromCompare\n\n**Signature**\n\n```ts\nexport declare const fromCompare: <A>(compare: (first: A, second: A) => Ordering) => Ord<A>\n```\n\nAdded in v2.0.0\n\n# defaults\n\n## equalsDefault\n\n**Signature**\n\n```ts\nexport declare const equalsDefault: <A>(compare: (first: A, second: A) => Ordering) => (x: A, y: A) => boolean\n```\n\nAdded in v2.10.0\n\n# instances\n\n## Contravariant\n\n**Signature**\n\n```ts\nexport declare const Contravariant: Contravariant1<'Ord'>\n```\n\nAdded in v2.7.0\n\n## getMonoid\n\nReturns a `Monoid` such that:\n\n- its `concat(ord1, ord2)` operation will order first by `ord1`, and then by `ord2`\n- its `empty` value is an `Ord` that always considers compared elements equal\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A = never>() => Monoid<Ord<A>>\n```\n\n**Example**\n\n```ts\nimport { sort } from 'fp-ts/Array'\nimport { contramap, reverse, getMonoid } from 'fp-ts/Ord'\nimport * as S from 'fp-ts/string'\nimport * as B from 'fp-ts/boolean'\nimport { pipe } from 'fp-ts/function'\nimport { concatAll } from 'fp-ts/Monoid'\nimport * as N from 'fp-ts/number'\n\ninterface User {\n  readonly id: number\n  readonly name: string\n  readonly age: number\n  readonly rememberMe: boolean\n}\n\nconst byName = pipe(\n  S.Ord,\n  contramap((p: User) => p.name)\n)\n\nconst byAge = pipe(\n  N.Ord,\n  contramap((p: User) => p.age)\n)\n\nconst byRememberMe = pipe(\n  B.Ord,\n  contramap((p: User) => p.rememberMe)\n)\n\nconst M = getMonoid<User>()\n\nconst users: Array<User> = [\n  { id: 1, name: 'Guido', age: 47, rememberMe: false },\n  { id: 2, name: 'Guido', age: 46, rememberMe: true },\n  { id: 3, name: 'Giulio', age: 44, rememberMe: false },\n  { id: 4, name: 'Giulio', age: 44, rememberMe: true },\n]\n\n// sort by name, then by age, then by `rememberMe`\nconst O1 = concatAll(M)([byName, byAge, byRememberMe])\nassert.deepStrictEqual(sort(O1)(users), [\n  { id: 3, name: 'Giulio', age: 44, rememberMe: false },\n  { id: 4, name: 'Giulio', age: 44, rememberMe: true },\n  { id: 2, name: 'Guido', age: 46, rememberMe: true },\n  { id: 1, name: 'Guido', age: 47, rememberMe: false },\n])\n\n// now `rememberMe = true` first, then by name, then by age\nconst O2 = concatAll(M)([reverse(byRememberMe), byName, byAge])\nassert.deepStrictEqual(sort(O2)(users), [\n  { id: 4, name: 'Giulio', age: 44, rememberMe: true },\n  { id: 2, name: 'Guido', age: 46, rememberMe: true },\n  { id: 3, name: 'Giulio', age: 44, rememberMe: false },\n  { id: 1, name: 'Guido', age: 47, rememberMe: false },\n])\n```\n\nAdded in v2.4.0\n\n## getSemigroup\n\nA typical use case for the `Semigroup` instance of `Ord` is merging two or more orderings.\n\nFor example the following snippet builds an `Ord` for a type `User` which\nsorts by `created` date descending, and **then** `lastName`\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A = never>() => Semigroup<Ord<A>>\n```\n\n**Example**\n\n```ts\nimport * as D from 'fp-ts/Date'\nimport { pipe } from 'fp-ts/function'\nimport { contramap, getSemigroup, Ord, reverse } from 'fp-ts/Ord'\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport * as S from 'fp-ts/string'\n\ninterface User {\n  readonly id: string\n  readonly lastName: string\n  readonly created: Date\n}\n\nconst ordByLastName: Ord<User> = pipe(\n  S.Ord,\n  contramap((user) => user.lastName)\n)\n\nconst ordByCreated: Ord<User> = pipe(\n  D.Ord,\n  contramap((user) => user.created)\n)\n\nconst ordUserByCreatedDescThenLastName = getSemigroup<User>().concat(reverse(ordByCreated), ordByLastName)\n\nassert.deepStrictEqual(\n  RA.sort(ordUserByCreatedDescThenLastName)([\n    { id: 'c', lastName: 'd', created: new Date(1973, 10, 30) },\n    { id: 'a', lastName: 'b', created: new Date(1973, 10, 30) },\n    { id: 'e', lastName: 'f', created: new Date(1980, 10, 30) },\n  ]),\n  [\n    { id: 'e', lastName: 'f', created: new Date(1980, 10, 30) },\n    { id: 'a', lastName: 'b', created: new Date(1973, 10, 30) },\n    { id: 'c', lastName: 'd', created: new Date(1973, 10, 30) },\n  ]\n)\n```\n\nAdded in v2.0.0\n\n# model\n\n## Ord (interface)\n\n**Signature**\n\n```ts\nexport interface Ord<A> extends Eq<A> {\n  readonly compare: (first: A, second: A) => Ordering\n}\n```\n\nAdded in v2.0.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Ord'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.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: Ord<A>) => (low: A, hi: A) => (a: A) => boolean\n```\n\nAdded in v2.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: Ord<A>) => (low: A, hi: A) => (a: A) => A\n```\n\nAdded in v2.0.0\n\n## contramap\n\nA typical use case for `contramap` would be like, given some `User` type, to construct an `Ord<User>`.\n\nWe can do so with a function from `User -> X` where `X` is some value that we know how to compare\nfor ordering (meaning we have an `Ord<X>`)\n\nFor example, given the following `User` type, there are lots of possible choices for `X`,\nbut let's say we want to sort a list of users by `lastName`.\n\nIf we have a way of comparing `lastName`s for ordering (`ordLastName: Ord<string>`) and we know how to go from `User -> string`,\nusing `contramap` we can do this\n\n**Signature**\n\n```ts\nexport declare const contramap: <A, B>(f: (b: B) => A) => (fa: Ord<A>) => Ord<B>\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport { contramap, Ord } from 'fp-ts/Ord'\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport * as S from 'fp-ts/string'\n\ninterface User {\n  readonly firstName: string\n  readonly lastName: string\n}\n\nconst ordLastName: Ord<string> = S.Ord\n\nconst ordByLastName: Ord<User> = pipe(\n  ordLastName,\n  contramap((user) => user.lastName)\n)\n\nassert.deepStrictEqual(\n  RA.sort(ordByLastName)([\n    { firstName: 'a', lastName: 'd' },\n    { firstName: 'c', lastName: 'b' },\n  ]),\n  [\n    { firstName: 'c', lastName: 'b' },\n    { firstName: 'a', lastName: 'd' },\n  ]\n)\n```\n\nAdded in v2.0.0\n\n## equals\n\n**Signature**\n\n```ts\nexport declare const equals: <A>(O: Ord<A>) => (second: A) => (first: A) => boolean\n```\n\nAdded in v2.11.0\n\n## geq\n\nTest whether one value is _non-strictly greater than_ another\n\n**Signature**\n\n```ts\nexport declare const geq: <A>(O: Ord<A>) => (first: A, second: A) => boolean\n```\n\nAdded in v2.0.0\n\n## gt\n\nTest whether one value is _strictly greater than_ another\n\n**Signature**\n\n```ts\nexport declare const gt: <A>(O: Ord<A>) => (first: A, second: A) => boolean\n```\n\nAdded in v2.0.0\n\n## leq\n\nTest whether one value is _non-strictly less than_ another\n\n**Signature**\n\n```ts\nexport declare const leq: <A>(O: Ord<A>) => (first: A, second: A) => boolean\n```\n\nAdded in v2.0.0\n\n## lt\n\nTest whether one value is _strictly less than_ another\n\n**Signature**\n\n```ts\nexport declare const lt: <A>(O: Ord<A>) => (first: A, second: A) => boolean\n```\n\nAdded in v2.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: Ord<A>) => (first: A, second: A) => A\n```\n\nAdded in v2.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: Ord<A>) => (first: A, second: A) => A\n```\n\nAdded in v2.0.0\n\n## reverse\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(O: Ord<A>) => Ord<A>\n```\n\nAdded in v2.10.0\n\n## trivial\n\n**Signature**\n\n```ts\nexport declare const trivial: Ord<unknown>\n```\n\nAdded in v2.11.0\n\n## tuple\n\nGiven a tuple of `Ord`s returns an `Ord` for the tuple.\n\n**Signature**\n\n```ts\nexport declare const tuple: <A extends readonly unknown[]>(...ords: { [K in keyof A]: Ord<A[K]> }) => Ord<Readonly<A>>\n```\n\n**Example**\n\n```ts\nimport { tuple } from 'fp-ts/Ord'\nimport * as B from 'fp-ts/boolean'\nimport * as S from 'fp-ts/string'\nimport * as N from 'fp-ts/number'\n\nconst O = tuple(S.Ord, N.Ord, B.Ord)\nassert.strictEqual(O.compare(['a', 1, true], ['b', 2, true]), -1)\nassert.strictEqual(O.compare(['a', 1, true], ['a', 2, true]), -1)\nassert.strictEqual(O.compare(['a', 1, true], ['a', 1, false]), 1)\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~getDualOrd~~\n\nUse [`reverse`](#reverse) instead.\n\n**Signature**\n\n```ts\nexport declare const getDualOrd: <A>(O: Ord<A>) => Ord<A>\n```\n\nAdded in v2.0.0\n\n## ~~getTupleOrd~~\n\nUse [`tuple`](#tuple) instead.\n\n**Signature**\n\n```ts\nexport declare const getTupleOrd: <T extends readonly Ord<any>[]>(\n  ...ords: T\n) => Ord<{ [K in keyof T]: T[K] extends Ord<infer A> ? A : never }>\n```\n\nAdded in v2.0.0\n\n## ~~ordBoolean~~\n\nUse [`Ord`](./boolean.ts.html#ord) instead.\n\n**Signature**\n\n```ts\nexport declare const ordBoolean: Ord<boolean>\n```\n\nAdded in v2.0.0\n\n## ~~ordDate~~\n\nUse [`Ord`](./Date.ts.html#ord) instead.\n\n**Signature**\n\n```ts\nexport declare const ordDate: Ord<Date>\n```\n\nAdded in v2.0.0\n\n## ~~ordNumber~~\n\nUse [`Ord`](./number.ts.html#ord) instead.\n\n**Signature**\n\n```ts\nexport declare const ordNumber: Ord<number>\n```\n\nAdded in v2.0.0\n\n## ~~ordString~~\n\nUse [`Ord`](./string.ts.html#ord) instead.\n\n**Signature**\n\n```ts\nexport declare const ordString: Ord<string>\n```\n\nAdded in v2.0.0\n\n## ~~ord~~\n\nUse [`Contravariant`](#contravariant) instead.\n\n**Signature**\n\n```ts\nexport declare const ord: Contravariant1<'Ord'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Ordering.ts.md",
    "content": "---\ntitle: Ordering.ts\nnav_order: 71\nparent: Modules\n---\n\n## Ordering overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [Eq](#eq)\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  - [matchW](#matchw)\n- [utils](#utils)\n  - [reverse](#reverse)\n  - [sign](#sign)\n- [zone of death](#zone-of-death)\n  - [~~eqOrdering~~](#eqordering)\n  - [~~invert~~](#invert)\n  - [~~monoidOrdering~~](#monoidordering)\n  - [~~semigroupOrdering~~](#semigroupordering)\n\n---\n\n# instances\n\n## Eq\n\n**Signature**\n\n```ts\nexport declare const Eq: E.Eq<Ordering>\n```\n\nAdded in v2.10.0\n\n## Monoid\n\n**Signature**\n\n```ts\nexport declare const Monoid: M.Monoid<Ordering>\n```\n\nAdded in v2.10.0\n\n## Semigroup\n\n**Signature**\n\n```ts\nexport declare const Semigroup: S.Semigroup<Ordering>\n```\n\nAdded in v2.10.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 v2.0.0\n\n# pattern matching\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <A>(onLessThan: () => A, onEqual: () => A, onGreaterThan: () => A) => (o: Ordering) => A\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <A, B, C>(\n  onLessThan: () => A,\n  onEqual: () => B,\n  onGreaterThan: () => C\n) => (o: Ordering) => A | B | C\n```\n\nAdded in v2.12.0\n\n# utils\n\n## reverse\n\n**Signature**\n\n```ts\nexport declare const reverse: (o: Ordering) => Ordering\n```\n\nAdded in v2.10.0\n\n## sign\n\n**Signature**\n\n```ts\nexport declare const sign: (n: number) => Ordering\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~eqOrdering~~\n\nUse [`Eq`](#eq) instead\n\n**Signature**\n\n```ts\nexport declare const eqOrdering: E.Eq<Ordering>\n```\n\nAdded in v2.0.0\n\n## ~~invert~~\n\nUse [`reverse`](#reverse) instead.\n\n**Signature**\n\n```ts\nexport declare const invert: (o: Ordering) => Ordering\n```\n\nAdded in v2.0.0\n\n## ~~monoidOrdering~~\n\nUse [`Monoid`](#monoid) instead\n\n**Signature**\n\n```ts\nexport declare const monoidOrdering: M.Monoid<Ordering>\n```\n\nAdded in v2.4.0\n\n## ~~semigroupOrdering~~\n\nUse [`Semigroup`](#semigroup) instead\n\n**Signature**\n\n```ts\nexport declare const semigroupOrdering: S.Semigroup<Ordering>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Pointed.ts.md",
    "content": "---\ntitle: Pointed.ts\nnav_order: 73\nparent: Modules\n---\n\n## Pointed overview\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Pointed (interface)](#pointed-interface)\n  - [Pointed1 (interface)](#pointed1-interface)\n  - [Pointed2 (interface)](#pointed2-interface)\n  - [Pointed2C (interface)](#pointed2c-interface)\n  - [Pointed3 (interface)](#pointed3-interface)\n  - [Pointed3C (interface)](#pointed3c-interface)\n  - [Pointed4 (interface)](#pointed4-interface)\n\n---\n\n# model\n\n## Pointed (interface)\n\n**Signature**\n\n```ts\nexport interface Pointed<F> {\n  readonly URI: F\n  readonly of: <A>(a: A) => HKT<F, A>\n}\n```\n\nAdded in v2.10.0\n\n## Pointed1 (interface)\n\n**Signature**\n\n```ts\nexport interface Pointed1<F extends URIS> {\n  readonly URI: F\n  readonly of: <A>(a: A) => Kind<F, A>\n}\n```\n\nAdded in v2.10.0\n\n## Pointed2 (interface)\n\n**Signature**\n\n```ts\nexport interface Pointed2<F extends URIS2> {\n  readonly URI: F\n  readonly of: <E, A>(a: A) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## Pointed2C (interface)\n\n**Signature**\n\n```ts\nexport interface Pointed2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly of: <A>(a: A) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## Pointed3 (interface)\n\n**Signature**\n\n```ts\nexport interface Pointed3<F extends URIS3> {\n  readonly URI: F\n  readonly of: <R, E, A>(a: A) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## Pointed3C (interface)\n\n**Signature**\n\n```ts\nexport interface Pointed3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly of: <R, A>(a: A) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## Pointed4 (interface)\n\n**Signature**\n\n```ts\nexport interface Pointed4<F extends URIS4> {\n  readonly URI: F\n  readonly of: <S, R, E, A>(a: A) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/Predicate.ts.md",
    "content": "---\ntitle: Predicate.ts\nnav_order: 74\nparent: Modules\n---\n\n## Predicate overview\n\nAdded in v2.11.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [Contravariant](#contravariant)\n  - [getMonoidAll](#getmonoidall)\n  - [getMonoidAny](#getmonoidany)\n  - [getSemigroupAll](#getsemigroupall)\n  - [getSemigroupAny](#getsemigroupany)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [Predicate (interface)](#predicate-interface)\n  - [and](#and)\n  - [contramap](#contramap)\n  - [not](#not)\n  - [or](#or)\n\n---\n\n# instances\n\n## Contravariant\n\n**Signature**\n\n```ts\nexport declare const Contravariant: Contravariant1<'Predicate'>\n```\n\nAdded in v2.11.0\n\n## getMonoidAll\n\n**Signature**\n\n```ts\nexport declare const getMonoidAll: <A = never>() => Monoid<Predicate<A>>\n```\n\nAdded in v2.11.0\n\n## getMonoidAny\n\n**Signature**\n\n```ts\nexport declare const getMonoidAny: <A = never>() => Monoid<Predicate<A>>\n```\n\nAdded in v2.11.0\n\n## getSemigroupAll\n\n**Signature**\n\n```ts\nexport declare const getSemigroupAll: <A = never>() => Semigroup<Predicate<A>>\n```\n\nAdded in v2.11.0\n\n## getSemigroupAny\n\n**Signature**\n\n```ts\nexport declare const getSemigroupAny: <A = never>() => Semigroup<Predicate<A>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Predicate'\n```\n\nAdded in v2.11.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.11.0\n\n# utils\n\n## Predicate (interface)\n\n**Signature**\n\n```ts\nexport interface Predicate<A> {\n  (a: A): boolean\n}\n```\n\nAdded in v2.11.0\n\n## and\n\n**Signature**\n\n```ts\nexport declare const and: <A>(second: Predicate<A>) => (first: Predicate<A>) => Predicate<A>\n```\n\nAdded in v2.11.0\n\n## contramap\n\n**Signature**\n\n```ts\nexport declare const contramap: <B, A>(f: (b: B) => A) => (predicate: Predicate<A>) => Predicate<B>\n```\n\nAdded in v2.11.0\n\n## not\n\n**Signature**\n\n```ts\nexport declare const not: <A>(predicate: Predicate<A>) => Predicate<A>\n```\n\nAdded in v2.11.0\n\n## or\n\n**Signature**\n\n```ts\nexport declare const or: <A>(second: Predicate<A>) => (first: Predicate<A>) => Predicate<A>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/Profunctor.ts.md",
    "content": "---\ntitle: Profunctor.ts\nnav_order: 75\nparent: Modules\n---\n\n## Profunctor overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Profunctor (interface)](#profunctor-interface)\n  - [Profunctor2 (interface)](#profunctor2-interface)\n  - [Profunctor2C (interface)](#profunctor2c-interface)\n  - [Profunctor3 (interface)](#profunctor3-interface)\n  - [Profunctor3C (interface)](#profunctor3c-interface)\n  - [Profunctor4 (interface)](#profunctor4-interface)\n\n---\n\n# model\n\n## Profunctor (interface)\n\n**Signature**\n\n```ts\nexport interface Profunctor<F> {\n  readonly URI: F\n  readonly map: <E, A, B>(fa: HKT2<F, E, A>, f: (a: A) => B) => HKT<F, B>\n  readonly promap: <E, A, D, B>(fea: HKT2<F, E, A>, f: (d: D) => E, g: (a: A) => B) => HKT2<F, D, B>\n}\n```\n\nAdded in v2.0.0\n\n## Profunctor2 (interface)\n\n**Signature**\n\n```ts\nexport interface Profunctor2<F extends URIS2> extends Functor2<F> {\n  readonly promap: <E, A, D, B>(fea: Kind2<F, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind2<F, D, B>\n}\n```\n\nAdded in v2.0.0\n\n## Profunctor2C (interface)\n\n**Signature**\n\n```ts\nexport interface Profunctor2C<F extends URIS2, E> extends Functor2C<F, E> {\n  readonly promap: <A, D, B>(fea: Kind2<F, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind2<F, D, B>\n}\n```\n\nAdded in v2.0.0\n\n## Profunctor3 (interface)\n\n**Signature**\n\n```ts\nexport interface Profunctor3<F extends URIS3> extends Functor3<F> {\n  readonly promap: <R, E, A, D, B>(fea: Kind3<F, R, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind3<F, R, D, B>\n}\n```\n\nAdded in v2.0.0\n\n## Profunctor3C (interface)\n\n**Signature**\n\n```ts\nexport interface Profunctor3C<F extends URIS3, E> extends Functor3C<F, E> {\n  readonly promap: <R, A, D, B>(fea: Kind3<F, R, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind3<F, R, D, B>\n}\n```\n\nAdded in v2.2.0\n\n## Profunctor4 (interface)\n\n**Signature**\n\n```ts\nexport interface Profunctor4<F extends URIS4> extends Functor4<F> {\n  readonly promap: <S, R, E, A, D, B>(fea: Kind4<F, S, R, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind4<F, S, R, D, B>\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Random.ts.md",
    "content": "---\ntitle: Random.ts\nnav_order: 76\nparent: Modules\n---\n\n## Random overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [utils](#utils)\n  - [random](#random)\n  - [randomBool](#randombool)\n  - [randomElem](#randomelem)\n  - [randomInt](#randomint)\n  - [randomRange](#randomrange)\n\n---\n\n# utils\n\n## random\n\nReturns a random number between 0 (inclusive) and 1 (exclusive). This is a direct wrapper around JavaScript's\n`Math.random()`.\n\n**Signature**\n\n```ts\nexport declare const random: IO<number>\n```\n\nAdded in v2.0.0\n\n## randomBool\n\nReturns a random boolean value with an equal chance of being `true` or `false`\n\n**Signature**\n\n```ts\nexport declare const randomBool: IO<boolean>\n```\n\nAdded in v2.0.0\n\n## randomElem\n\nReturns a random element of a `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const randomElem: <A>(as: ReadonlyNonEmptyArray<A>) => IO<A>\n```\n\nAdded in v2.10.0\n\n## randomInt\n\nTakes a range specified by `low` (the first argument) and `high` (the second), and returns a random integer uniformly\ndistributed in the closed interval `[low, high]`. It is unspecified what happens if `low > high`, or if either of\n`low` or `high` is not an integer.\n\n**Signature**\n\n```ts\nexport declare function randomInt(low: number, high: number): IO<number>\n```\n\nAdded in v2.0.0\n\n## randomRange\n\nReturns a random number between a minimum value (inclusive) and a maximum value (exclusive). It is unspecified what\nhappens if `maximum < minimum`.\n\n**Signature**\n\n```ts\nexport declare function randomRange(min: number, max: number): IO<number>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Reader.ts.md",
    "content": "---\ntitle: Reader.ts\nnav_order: 77\nparent: Modules\n---\n\n## Reader overview\n\nThe `Reader` monad (also called the Environment monad). Represents a computation, which can read values from a shared environment,\npass values from function to function, and execute sub-computations in a modified environment.\nUsing `Reader` monad for such computations is often clearer and easier than using the `State` monad.\n\nIn this example the `Reader` monad provides access to variable bindings. `Bindings` are a map of `number` variables.\nThe variable count contains number of variables in the bindings. You can see how to run a `Reader` monad and retrieve\ndata from it, how to access the `Reader` data with `ask` and `asks`.\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as O from 'fp-ts/Option'\nimport * as R from 'fp-ts/Reader'\nimport * as RR from 'fp-ts/ReadonlyRecord'\n\ninterface Bindings extends RR.ReadonlyRecord<string, number> {}\n\n// The Reader monad, which implements this complicated check.\nconst isCountCorrect: R.Reader<Bindings, boolean> = pipe(\n  R.Do,\n  R.bind('count', () => R.asks(lookupVar('count'))),\n  R.bind('bindings', () => R.ask()),\n  R.map(({ count, bindings }) => count === RR.size(bindings))\n)\n\n// The selector function to use with 'asks'.\n// Returns value of the variable with specified name.\nconst lookupVar =\n  (name: string) =>\n  (bindings: Bindings): number =>\n    pipe(\n      bindings,\n      RR.lookup(name),\n      O.getOrElse(() => 0)\n    )\n\nconst sampleBindings: Bindings = { count: 3, a: 1, b: 2 }\n\nassert.deepStrictEqual(isCountCorrect(sampleBindings), true)\n```\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n- [constructors](#constructors)\n  - [ask](#ask)\n  - [asks](#asks)\n  - [asksReader](#asksreader)\n  - [asksReaderW](#asksreaderw)\n  - [id](#id)\n  - [of](#of)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [apSW](#apsw)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [bindW](#bindw)\n  - [let](#let)\n- [instances](#instances)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Category](#category)\n  - [Chain](#chain)\n  - [Choice](#choice)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [Pointed](#pointed)\n  - [Profunctor](#profunctor)\n  - [Strong](#strong)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n  - [chainFirstW](#chainfirstw)\n  - [chainW](#chainw)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Reader (interface)](#reader-interface)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n  - [flattenW](#flattenw)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apFirstW](#apfirstw)\n  - [apSecond](#apsecond)\n  - [apSecondW](#apsecondw)\n  - [apW](#apw)\n  - [compose](#compose)\n  - [first](#first)\n  - [left](#left)\n  - [local](#local)\n  - [promap](#promap)\n  - [right](#right)\n  - [second](#second)\n- [zone of death](#zone-of-death)\n  - [~~getMonoid~~](#getmonoid)\n  - [~~getSemigroup~~](#getsemigroup)\n  - [~~reader~~](#reader)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <R1, A, R2, _>(self: Reader<R1, A>, f: (a: A) => Reader<R2, _>): Reader<R1 & R2, A>\n  <A, R2, _>(f: (a: A) => Reader<R2, _>): <R1>(self: Reader<R1, A>) => Reader<R2 & R1, A>\n}\n```\n\nAdded in v2.15.0\n\n# constructors\n\n## ask\n\nReads the current context\n\n**Signature**\n\n```ts\nexport declare const ask: <R>() => Reader<R, R>\n```\n\nAdded in v2.0.0\n\n## asks\n\nProjects a value from the global context in a Reader\n\n**Signature**\n\n```ts\nexport declare const asks: <R, A>(f: (r: R) => A) => Reader<R, A>\n```\n\nAdded in v2.0.0\n\n## asksReader\n\nEffectfully accesses the environment.\n\n**Signature**\n\n```ts\nexport declare const asksReader: <R, A>(f: (r: R) => Reader<R, A>) => Reader<R, A>\n```\n\nAdded in v2.11.0\n\n## asksReaderW\n\nLess strict version of [`asksReader`](#asksreader).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const asksReaderW: <R1, R2, A>(f: (r1: R1) => Reader<R2, A>) => Reader<R1 & R2, A>\n```\n\nAdded in v2.11.0\n\n## id\n\n**Signature**\n\n```ts\nexport declare const id: <A>() => Reader<A, A>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <R = unknown, A = never>(a: A) => Reader<R, A>\n```\n\nAdded in v2.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: Reader<unknown, {}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: Reader<E, B>\n) => (fa: Reader<E, A>) => Reader<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## apSW\n\nLess strict version of [`apS`](#aps).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSW: <A, N extends string, R2, B>(\n  name: Exclude<N, keyof A>,\n  fb: Reader<R2, B>\n) => <R1>(fa: Reader<R1, A>) => Reader<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Reader<E, B>\n) => (ma: Reader<E, A>) => Reader<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <E, A>(fa: Reader<E, A>) => Reader<E, { readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## bindW\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bindW: <N extends string, A, R2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Reader<R2, B>\n) => <R1>(fa: Reader<R1, A>) => Reader<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <E>(fa: Reader<E, A>) => Reader<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# instances\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative2<'Reader'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply2<'Reader'>\n```\n\nAdded in v2.10.0\n\n## Category\n\n**Signature**\n\n```ts\nexport declare const Category: Category2<'Reader'>\n```\n\nAdded in v2.7.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain2<'Reader'>\n```\n\nAdded in v2.10.0\n\n## Choice\n\n**Signature**\n\n```ts\nexport declare const Choice: Choice2<'Reader'>\n```\n\nAdded in v2.8.3\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'Reader'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad2<'Reader'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed2<'Reader'>\n```\n\nAdded in v2.10.0\n\n## Profunctor\n\n**Signature**\n\n```ts\nexport declare const Profunctor: Profunctor2<'Reader'>\n```\n\nAdded in v2.7.0\n\n## Strong\n\n**Signature**\n\n```ts\nexport declare const Strong: Strong2<'Reader'>\n```\n\nAdded in v2.8.3\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Reader<R, A>) => Reader<R, B>\n```\n\nAdded in v2.0.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, R, B>(f: (a: A) => Reader<R, B>) => (first: Reader<R, A>) => Reader<R, A>\n```\n\nAdded in v2.0.0\n\n## chainFirstW\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstW: <R2, A, B>(\n  f: (a: A) => Reader<R2, B>\n) => <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, A>\n```\n\nAdded in v2.11.0\n\n## chainW\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chainW: <R2, A, B>(f: (a: A) => Reader<R2, B>) => <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, B>\n```\n\nAdded in v2.6.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: Reader<E, (a: A) => B>) => Reader<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, A>) => Reader<R, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## Reader (interface)\n\n**Signature**\n\n```ts\nexport interface Reader<R, A> {\n  (r: R): A\n}\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, R2, B>(f: (a: A) => Reader<R2, B>): <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, B>\n  <R1, A, R2, B>(ma: Reader<R1, A>, f: (a: A) => Reader<R2, B>): Reader<R1 & R2, B>\n}\n```\n\nAdded in v2.14.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <R, A>(mma: Reader<R, Reader<R, A>>) => Reader<R, A>\n```\n\nAdded in v2.0.0\n\n## flattenW\n\nLess strict version of [`flatten`](#flatten).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const flattenW: <R1, R2, A>(mma: Reader<R1, Reader<R2, A>>) => Reader<R1 & R2, A>\n```\n\nAdded in v2.11.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <R, A>(arr: readonly Reader<R, A>[]) => Reader<R, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <R, A, B>(\n  f: (a: A) => Reader<R, B>\n) => (as: readonly A[]) => Reader<R, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <R, A, B>(\n  f: (index: number, a: A) => Reader<R, B>\n) => (as: readonly A[]) => Reader<R, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, R, B>(\n  f: (index: number, a: A) => Reader<R, B>\n) => (as: readonly A[]) => Reader<R, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, B>(\n  f: (index: number, a: A) => Reader<R, B>\n) => (as: ReadonlyNonEmptyArray<A>) => Reader<R, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Reader'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: Reader<unknown, readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <R, A>(fa: Reader<R, A>) => <B>(fab: Reader<R, (a: A) => B>) => Reader<R, B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <E, B>(second: Reader<E, B>) => <A>(first: Reader<E, A>) => Reader<E, A>\n```\n\nAdded in v2.0.0\n\n## apFirstW\n\nLess strict version of [`apFirst`](#apfirst).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apFirstW: <R2, B>(second: Reader<R2, B>) => <R1, A>(first: Reader<R1, A>) => Reader<R1 & R2, A>\n```\n\nAdded in v2.12.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <E, B>(second: Reader<E, B>) => <A>(first: Reader<E, A>) => Reader<E, B>\n```\n\nAdded in v2.0.0\n\n## apSecondW\n\nLess strict version of [`apSecond`](#apsecond).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSecondW: <R2, B>(second: Reader<R2, B>) => <R1, A>(first: Reader<R1, A>) => Reader<R1 & R2, B>\n```\n\nAdded in v2.12.0\n\n## apW\n\nLess strict version of [`ap`](#ap).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apW: <R2, A>(fa: Reader<R2, A>) => <R1, B>(fab: Reader<R1, (a: A) => B>) => Reader<R1 & R2, B>\n```\n\nAdded in v2.8.0\n\n## compose\n\n**Signature**\n\n```ts\nexport declare const compose: <A, B>(ab: Reader<A, B>) => <C>(bc: Reader<B, C>) => Reader<A, C>\n```\n\nAdded in v2.0.0\n\n## first\n\n**Signature**\n\n```ts\nexport declare const first: <A, B, C>(pab: Reader<A, B>) => Reader<[A, C], [B, C]>\n```\n\nAdded in v2.10.0\n\n## left\n\n**Signature**\n\n```ts\nexport declare const left: <A, B, C>(pab: Reader<A, B>) => Reader<E.Either<A, C>, E.Either<B, C>>\n```\n\nAdded in v2.10.0\n\n## local\n\nChanges the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n`contramap`).\n\n**Signature**\n\n```ts\nexport declare const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: Reader<R1, A>) => Reader<R2, A>\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as R from 'fp-ts/Reader'\nimport * as string from 'fp-ts/string'\n\nconst calculateContentLen: R.Reader<string, number> = pipe(\n  R.Do,\n  R.bind('content', () => R.ask<string>()),\n  R.map(({ content }) => string.size(content))\n)\n\n// Calls calculateContentLen after adding a prefix to the Reader content.\nconst calculateModifiedContentLen: R.Reader<string, number> = pipe(\n  calculateContentLen,\n  R.local((s) => 'Prefix ' + s)\n)\n\nconst s = '12345'\n\nassert.deepStrictEqual(\n  \"Modified 's' length: \" + calculateModifiedContentLen(s) + '\\n' + \"Original 's' length: \" + calculateContentLen(s),\n  \"Modified 's' length: 12\\nOriginal 's' length: 5\"\n)\n```\n\nAdded in v2.0.0\n\n## promap\n\n**Signature**\n\n```ts\nexport declare const promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fea: Reader<E, A>) => Reader<D, B>\n```\n\nAdded in v2.0.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare const right: <A, B, C>(pbc: Reader<B, C>) => Reader<E.Either<A, B>, E.Either<A, C>>\n```\n\nAdded in v2.10.0\n\n## second\n\n**Signature**\n\n```ts\nexport declare const second: <A, B, C>(pab: Reader<B, C>) => Reader<[A, B], [A, C]>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~getMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <R, A>(M: Monoid<A>) => Monoid<Reader<R, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <R, A>(S: Semigroup<A>) => Semigroup<Reader<R, A>>\n```\n\nAdded in v2.0.0\n\n## ~~reader~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `R.Functor` instead of `R.reader`\n(where `R` is from `import R from 'fp-ts/Reader'`)\n\n**Signature**\n\n```ts\nexport declare const reader: Monad2<'Reader'> &\n  Profunctor2<'Reader'> &\n  Category2<'Reader'> &\n  Strong2<'Reader'> &\n  Choice2<'Reader'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/ReaderEither.ts.md",
    "content": "---\ntitle: ReaderEither.ts\nnav_order: 78\nparent: Modules\n---\n\n## ReaderEither overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapEither](#tapeither)\n  - [tapReader](#tapreader)\n- [constructors](#constructors)\n  - [ask](#ask)\n  - [asks](#asks)\n  - [asksReaderEither](#asksreadereither)\n  - [asksReaderEitherW](#asksreadereitherw)\n  - [left](#left)\n  - [leftReader](#leftreader)\n  - [of](#of)\n  - [right](#right)\n  - [rightReader](#rightreader)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromOption](#fromoption)\n  - [fromReader](#fromreader)\n  - [toUnion](#tounion)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [apSW](#apsw)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [bindW](#bindw)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n  - [getAltReaderValidation](#getaltreadervalidation)\n  - [getApplicativeReaderValidation](#getapplicativereadervalidation)\n  - [getOrElse](#getorelse)\n  - [getOrElseW](#getorelsew)\n  - [mapBoth](#mapboth)\n  - [mapError](#maperror)\n  - [orElse](#orelse)\n  - [orElseW](#orelsew)\n  - [orLeft](#orleft)\n  - [orLeftW](#orleftw)\n  - [tapError](#taperror)\n- [filtering](#filtering)\n  - [filterOrElse](#filterorelse)\n  - [filterOrElseW](#filterorelsew)\n  - [getCompactable](#getcompactable)\n  - [getFilterable](#getfilterable)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Bifunctor](#bifunctor)\n  - [Chain](#chain)\n  - [FromEither](#fromeither)\n  - [FromReader](#fromreader)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadThrow](#monadthrow)\n  - [Pointed](#pointed)\n- [legacy](#legacy)\n  - [bimap](#bimap)\n  - [chain](#chain)\n  - [chainEitherK](#chaineitherk)\n  - [chainEitherKW](#chaineitherkw)\n  - [chainFirst](#chainfirst)\n  - [chainFirstEitherK](#chainfirsteitherk)\n  - [chainFirstEitherKW](#chainfirsteitherkw)\n  - [chainFirstReaderK](#chainfirstreaderk)\n  - [chainFirstReaderKW](#chainfirstreaderkw)\n  - [chainFirstW](#chainfirstw)\n  - [chainOptionK](#chainoptionk)\n  - [chainOptionKW](#chainoptionkw)\n  - [chainReaderK](#chainreaderk)\n  - [chainReaderKW](#chainreaderkw)\n  - [chainW](#chainw)\n  - [fromOptionK](#fromoptionk)\n  - [mapLeft](#mapleft)\n  - [orElseFirst](#orelsefirst)\n  - [orElseFirstW](#orelsefirstw)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromPredicate](#frompredicate)\n  - [fromReaderK](#fromreaderk)\n  - [liftNullable](#liftnullable)\n  - [liftOption](#liftoption)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [ReaderEither (interface)](#readereither-interface)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchE](#matche)\n  - [matchEW](#matchew)\n  - [matchW](#matchw)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapEither](#flatmapeither)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatMapOption](#flatmapoption)\n  - [flatMapReader](#flatmapreader)\n  - [flatten](#flatten)\n  - [flattenW](#flattenw)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apFirstW](#apfirstw)\n  - [apSecond](#apsecond)\n  - [apSecondW](#apsecondw)\n  - [apW](#apw)\n  - [local](#local)\n  - [swap](#swap)\n  - [throwError](#throwerror)\n- [zone of death](#zone-of-death)\n  - [~~getApplyMonoid~~](#getapplymonoid)\n  - [~~getApplySemigroup~~](#getapplysemigroup)\n  - [~~getReaderValidation~~](#getreadervalidation)\n  - [~~getSemigroup~~](#getsemigroup)\n  - [~~readerEither~~](#readereither)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <R1, E1, A, R2, E2, _>(self: ReaderEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, _>): ReaderEither<\n    R1 & R2,\n    E1 | E2,\n    A\n  >\n  <A, R2, E2, _>(f: (a: A) => ReaderEither<R2, E2, _>): <R1, E1>(\n    self: ReaderEither<R1, E1, A>\n  ) => ReaderEither<R1 & R2, E2 | E1, A>\n}\n```\n\nAdded in v2.15.0\n\n## tapEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapEither: {\n  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <R1, E1>(self: ReaderEither<R1, E1, A>) => ReaderEither<R1, E2 | E1, A>\n  <R1, E1, A, E2, _>(self: ReaderEither<R1, E1, A>, f: (a: A) => E.Either<E2, _>): ReaderEither<R1, E1 | E2, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as RE from 'fp-ts/ReaderEither'\n\nconst checkString = (value: string) =>\n  pipe(\n    RE.ask<number>(),\n    RE.tapEither((minLength) => (value.length > minLength ? E.right('ok') : E.left('error')))\n  )\n\nassert.deepStrictEqual(checkString('')(1), E.left('error'))\nassert.deepStrictEqual(checkString('fp-ts')(2), E.right(2))\n```\n\nAdded in v2.16.0\n\n## tapReader\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapReader: {\n  <R2, A, E, _>(f: (a: A) => R.Reader<R2, _>): <R1>(self: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, A>\n  <R1, R2, E, A, _>(self: ReaderEither<R1, E, A>, f: (a: A) => R.Reader<R2, _>): ReaderEither<R1 & R2, E, A>\n}\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## ask\n\nReads the current context.\n\n**Signature**\n\n```ts\nexport declare const ask: <R, E = never>() => ReaderEither<R, E, R>\n```\n\nAdded in v2.0.0\n\n## asks\n\nProjects a value from the global context in a `ReaderEither`.\n\n**Signature**\n\n```ts\nexport declare const asks: <R, A, E = never>(f: (r: R) => A) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## asksReaderEither\n\nEffectfully accesses the environment.\n\n**Signature**\n\n```ts\nexport declare const asksReaderEither: <R, E, A>(f: (r: R) => ReaderEither<R, E, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## asksReaderEitherW\n\nLess strict version of [`asksReaderEither`](#asksreadereither).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const asksReaderEitherW: <R1, R2, E, A>(\n  f: (r1: R1) => ReaderEither<R2, E, A>\n) => ReaderEither<R1 & R2, E, A>\n```\n\nAdded in v2.11.0\n\n## left\n\n**Signature**\n\n```ts\nexport declare const left: <R, E = never, A = never>(e: E) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## leftReader\n\n**Signature**\n\n```ts\nexport declare const leftReader: <R, E = never, A = never>(me: R.Reader<R, E>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <R = unknown, E = never, A = never>(a: A) => ReaderEither<R, E, A>\n```\n\nAdded in v2.8.5\n\n## right\n\n**Signature**\n\n```ts\nexport declare const right: <R, E = never, A = never>(a: A) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## rightReader\n\n**Signature**\n\n```ts\nexport declare const rightReader: <R, E = never, A = never>(ma: R.Reader<R, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <E, A, R = unknown>(fa: E.Either<E, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <E>(onNone: LazyArg<E>) => <A, R = unknown>(fa: Option<A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromReader\n\n**Signature**\n\n```ts\nexport declare const fromReader: <R, A, E = never>(fa: R.Reader<R, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## toUnion\n\n**Signature**\n\n```ts\nexport declare const toUnion: <R, E, A>(fa: ReaderEither<R, E, A>) => R.Reader<R, E | A>\n```\n\nAdded in v2.10.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: ReaderEither<unknown, never, {}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, R, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderEither<R, E, B>\n) => (fa: ReaderEither<R, E, A>) => ReaderEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## apSW\n\nLess strict version of [`apS`](#aps).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSW: <A, N extends string, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderEither<R2, E2, B>\n) => <R1, E1>(\n  fa: ReaderEither<R1, E1, A>\n) => ReaderEither<R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, R, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderEither<R, E, B>\n) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(\n  name: N\n) => <R, E, A>(fa: ReaderEither<R, E, A>) => ReaderEither<R, E, { readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## bindW\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bindW: <N extends string, A, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(\n  fa: ReaderEither<R1, E1, A>\n) => ReaderEither<R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <R, E>(\n  fa: ReaderEither<R, E, A>\n) => ReaderEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\n**Signature**\n\n```ts\nexport declare const alt: <R, E, A>(\n  that: () => ReaderEither<R, E, A>\n) => (fa: ReaderEither<R, E, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <R2, E2, B>(\n  that: () => ReaderEither<R2, E2, B>\n) => <R1, E1, A>(fa: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2, B | A>\n```\n\nAdded in v2.9.0\n\n## getAltReaderValidation\n\nThe default [`Alt`](#alt) instance returns the last error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\nSee [`getAltValidation`](./Either.ts.html#getaltvalidation).\n\n**Signature**\n\n```ts\nexport declare function getAltReaderValidation<E>(S: Semigroup<E>): Alt3C<URI, E>\n```\n\nAdded in v2.7.0\n\n## getApplicativeReaderValidation\n\nThe default [`Applicative`](#applicative) instance returns the first error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\nSee [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation).\n\n**Signature**\n\n```ts\nexport declare function getApplicativeReaderValidation<E>(S: Semigroup<E>): Applicative3C<URI, E>\n```\n\nAdded in v2.7.0\n\n## getOrElse\n\n**Signature**\n\n```ts\nexport declare const getOrElse: <E, R, A>(\n  onLeft: (e: E) => R.Reader<R, A>\n) => (ma: ReaderEither<R, E, A>) => R.Reader<R, A>\n```\n\nAdded in v2.0.0\n\n## getOrElseW\n\nLess strict version of [`getOrElse`](#getorelse).\n\nThe `W` suffix (short for **W**idening) means that the handler return type will be merged.\n\n**Signature**\n\n```ts\nexport declare const getOrElseW: <R2, E, B>(\n  onLeft: (e: E) => R.Reader<R2, B>\n) => <R1, A>(ma: ReaderEither<R1, E, A>) => R.Reader<R1 & R2, B | A>\n```\n\nAdded in v2.6.0\n\n## mapBoth\n\nReturns a `ReaderEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`.\n\n**Signature**\n\n```ts\nexport declare const mapBoth: {\n  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): <R>(self: ReaderEither<R, E, A>) => ReaderEither<R, G, B>\n  <R, E, A, G, B>(self: ReaderEither<R, E, A>, f: (e: E) => G, g: (a: A) => B): ReaderEither<R, G, B>\n}\n```\n\n**Example**\n\n```ts\nimport * as ReaderEither from 'fp-ts/ReaderEither'\nimport * as Either from 'fp-ts/Either'\n\nconst f = (s: string) => new Error(s)\nconst g = (n: number) => n * 2\n\nassert.deepStrictEqual(ReaderEither.mapBoth(ReaderEither.right(1), f, g)({}), Either.right(2))\nassert.deepStrictEqual(ReaderEither.mapBoth(ReaderEither.left('err'), f, g)({}), Either.left(new Error('err')))\n```\n\nAdded in v2.16.0\n\n## mapError\n\nReturns a `ReaderEither` with its error channel mapped using the specified function.\n\n**Signature**\n\n```ts\nexport declare const mapError: {\n  <R, E, G>(f: (e: E) => G): <A>(self: ReaderEither<R, E, A>) => ReaderEither<R, G, A>\n  <R, E, A, G>(self: ReaderEither<R, E, A>, f: (e: E) => G): ReaderEither<R, G, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as ReaderEither from 'fp-ts/ReaderEither'\nimport * as Either from 'fp-ts/Either'\n\nconst f = (s: string) => new Error(s)\n\nassert.deepStrictEqual(ReaderEither.mapError(ReaderEither.right(1), f)({}), Either.right(1))\nassert.deepStrictEqual(ReaderEither.mapError(ReaderEither.left('err'), f)({}), Either.left(new Error('err')))\n```\n\nAdded in v2.16.0\n\n## orElse\n\n**Signature**\n\n```ts\nexport declare const orElse: <E1, R, E2, A>(\n  onLeft: (e: E1) => ReaderEither<R, E2, A>\n) => (ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2, A>\n```\n\nAdded in v2.0.0\n\n## orElseW\n\nLess strict version of [`orElse`](#orelse).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const orElseW: <E1, R1, E2, B>(\n  onLeft: (e: E1) => ReaderEither<R1, E2, B>\n) => <R2, A>(ma: ReaderEither<R2, E1, A>) => ReaderEither<R1 & R2, E2, B | A>\n```\n\nAdded in v2.10.0\n\n## orLeft\n\n**Signature**\n\n```ts\nexport declare const orLeft: <E1, R, E2>(\n  onLeft: (e: E1) => R.Reader<R, E2>\n) => <A>(fa: ReaderEither<R, E1, A>) => ReaderEither<R, E2, A>\n```\n\nAdded in v2.11.0\n\n## orLeftW\n\n**Signature**\n\n```ts\nexport declare const orLeftW: <E1, R2, E2>(\n  onLeft: (e: E1) => R.Reader<R2, E2>\n) => <R1, A>(fa: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2, A>\n```\n\nAdded in v2.16.6\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, R2, E2, _>(onLeft: (e: E1) => ReaderEither<R2, E2, _>): <R1, A>(\n    self: ReaderEither<R1, E1, A>\n  ) => ReaderEither<R1 & R2, E1 | E2, A>\n  <R1, E1, A, R2, E2, _>(self: ReaderEither<R1, E1, A>, onLeft: (e: E1) => ReaderEither<R2, E2, _>): ReaderEither<\n    R1 & R2,\n    E1 | E2,\n    A\n  >\n}\n```\n\nAdded in v2.15.0\n\n# filtering\n\n## filterOrElse\n\n**Signature**\n\n```ts\nexport declare const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n    ma: ReaderEither<R, E, A>\n  ) => ReaderEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(\n    mb: ReaderEither<R, E, B>\n  ) => ReaderEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## filterOrElseW\n\nLess strict version of [`filterOrElse`](#filterorelse).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <R, E1>(\n    ma: ReaderEither<R, E1, A>\n  ) => ReaderEither<R, E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1, B extends A>(\n    mb: ReaderEither<R, E1, B>\n  ) => ReaderEither<R, E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1>(\n    ma: ReaderEither<R, E1, A>\n  ) => ReaderEither<R, E2 | E1, A>\n}\n```\n\nAdded in v2.9.0\n\n## getCompactable\n\n**Signature**\n\n```ts\nexport declare const getCompactable: <E>(M: Monoid<E>) => Compactable3C<'ReaderEither', E>\n```\n\nAdded in v2.10.0\n\n## getFilterable\n\n**Signature**\n\n```ts\nexport declare function getFilterable<E>(M: Monoid<E>): Filterable3C<URI, E>\n```\n\nAdded in v2.10.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt3<'ReaderEither'>\n```\n\nAdded in v2.7.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative3<'ReaderEither'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply3<'ReaderEither'>\n```\n\nAdded in v2.10.0\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor3<'ReaderEither'>\n```\n\nAdded in v2.7.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain3<'ReaderEither'>\n```\n\nAdded in v2.10.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither3<'ReaderEither'>\n```\n\nAdded in v2.10.0\n\n## FromReader\n\n**Signature**\n\n```ts\nexport declare const FromReader: FromReader3<'ReaderEither'>\n```\n\nAdded in v2.11.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor3<'ReaderEither'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad3<'ReaderEither'>\n```\n\nAdded in v2.7.0\n\n## MonadThrow\n\n**Signature**\n\n```ts\nexport declare const MonadThrow: MonadThrow3<'ReaderEither'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed3<'ReaderEither'>\n```\n\nAdded in v2.10.0\n\n# legacy\n\n## bimap\n\nAlias of `mapBoth`.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R>(fa: ReaderEither<R, E, A>) => ReaderEither<R, G, B>\n```\n\nAdded in v2.0.0\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>\n```\n\nAdded in v2.0.0\n\n## chainEitherK\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherK: <E, A, B>(\n  f: (a: A) => E.Either<E, B>\n) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>\n```\n\nAdded in v2.4.0\n\n## chainEitherKW\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherKW: <E2, A, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## chainFirstEitherK\n\nAlias of `tapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherK: <A, E, B>(\n  f: (a: A) => E.Either<E, B>\n) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstEitherKW\n\nAlias of `tapEither`.\n\nLess strict version of [`chainFirstEitherK`](#chainfirsteitherk).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstReaderK\n\nAlias of `tapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderK: <A, R, B>(\n  f: (a: A) => R.Reader<R, B>\n) => <E>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstReaderKW\n\nAlias of `tapReader`.\n\nLess strict version of [`chainReaderK`](#chainreaderk).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2, E>(ma: ReaderEither<R2, E, A>) => ReaderEither<R1 & R2, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstW\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstW: <R2, E2, A, B>(\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2 | E1, A>\n```\n\nAdded in v2.8.0\n\n## chainOptionK\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>\n```\n\nAdded in v2.10.0\n\n## chainOptionKW\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2 | E1, B>\n```\n\nAdded in v2.13.2\n\n## chainReaderK\n\nAlias of `flatMapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderK: <A, R, B>(\n  f: (a: A) => R.Reader<R, B>\n) => <E>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B>\n```\n\nAdded in v2.11.0\n\n## chainReaderKW\n\nAlias of `flatMapReader`.\n\nLess strict version of [`chainReaderK`](#chainreaderk).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainReaderKW: <A, R2, B>(\n  f: (a: A) => R.Reader<R2, B>\n) => <R1, E>(ma: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, B>\n```\n\nAdded in v2.11.0\n\n## chainW\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chainW: <R2, E2, A, B>(\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.6.0\n\n## fromOptionK\n\nUse `liftOption`.\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => <R = unknown>(...a: A) => ReaderEither<R, E, B>\n```\n\nAdded in v2.10.0\n\n## mapLeft\n\nAlias of `mapError`.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: ReaderEither<R, E, A>) => ReaderEither<R, G, A>\n```\n\nAdded in v2.0.0\n\n## orElseFirst\n\nAlias of `tapError`.\n\n**Signature**\n\n```ts\nexport declare const orElseFirst: <E, R, B>(\n  onLeft: (e: E) => ReaderEither<R, E, B>\n) => <A>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## orElseFirstW\n\nAlias of `tapError`.\n\n**Signature**\n\n```ts\nexport declare const orElseFirstW: <E1, R2, E2, B>(\n  onLeft: (e: E1) => ReaderEither<R2, E2, B>\n) => <R1, A>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => E.Either<E, B>\n) => <R = unknown>(...a: A) => ReaderEither<R, E, B>\n```\n\nAdded in v2.4.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown, B extends A = A>(b: B) => ReaderEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderEither<R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## fromReaderK\n\n**Signature**\n\n```ts\nexport declare const fromReaderK: <A extends readonly unknown[], R, B>(\n  f: (...a: A) => R.Reader<R, B>\n) => <E = never>(...a: A) => ReaderEither<R, E, B>\n```\n\nAdded in v2.11.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) => <R>(...a: A) => ReaderEither<R, E, NonNullable<B>>\n```\n\nAdded in v2.15.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) => <R>(...a: A) => ReaderEither<R, E, B>\n```\n\nAdded in v2.15.0\n\n# mapping\n\n## as\n\nMaps the `Right` value of this `ReaderEither` to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <R, E, _>(self: ReaderEither<R, E, _>) => ReaderEither<R, E, A>\n  <R, E, _, A>(self: ReaderEither<R, E, _>, a: A): ReaderEither<R, E, A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the `Right` value of this `ReaderEither` to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <R, E, _>(self: ReaderEither<R, E, _>) => ReaderEither<R, E, void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <R, E, B>(fab: ReaderEither<R, E, (a: A) => B>) => ReaderEither<R, E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <R, E>(fa: ReaderEither<R, E, A>) => ReaderEither<R, E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## ReaderEither (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderEither<R, E, A> extends Reader<R, Either<E, A>> {}\n```\n\nAdded in v2.0.0\n\n# pattern matching\n\n## fold\n\nAlias of [`matchE`](#matche).\n\n**Signature**\n\n```ts\nexport declare const fold: <R, E, A, B>(\n  onLeft: (e: E) => R.Reader<R, B>,\n  onRight: (a: A) => R.Reader<R, B>\n) => (ma: ReaderEither<R, E, A>) => R.Reader<R, B>\n```\n\nAdded in v2.0.0\n\n## foldW\n\nAlias of [`matchEW`](#matchew).\n\n**Signature**\n\n```ts\nexport declare const foldW: <E, R2, B, A, R3, C>(\n  onLeft: (e: E) => R.Reader<R2, B>,\n  onRight: (a: A) => R.Reader<R3, C>\n) => <R1>(ma: ReaderEither<R1, E, A>) => R.Reader<R1 & R2 & R3, B | C>\n```\n\nAdded in v2.10.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B\n) => <R>(ma: ReaderEither<R, E, A>) => R.Reader<R, B>\n```\n\nAdded in v2.10.0\n\n## matchE\n\nThe `E` suffix (short for **E**ffect) means that the handlers return an effect (`Reader`).\n\n**Signature**\n\n```ts\nexport declare const matchE: <R, E, A, B>(\n  onLeft: (e: E) => R.Reader<R, B>,\n  onRight: (a: A) => R.Reader<R, B>\n) => (ma: ReaderEither<R, E, A>) => R.Reader<R, B>\n```\n\nAdded in v2.10.0\n\n## matchEW\n\nLess strict version of [`matchE`](#matche).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchEW: <E, R2, B, A, R3, C>(\n  onLeft: (e: E) => R.Reader<R2, B>,\n  onRight: (a: A) => R.Reader<R3, C>\n) => <R1>(ma: ReaderEither<R1, E, A>) => R.Reader<R1 & R2 & R3, B | C>\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <E, B, A, C>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C\n) => <R>(ma: R.Reader<R, E.Either<E, A>>) => R.Reader<R, B | C>\n```\n\nAdded in v2.10.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, R2, E2, B>(f: (a: A) => ReaderEither<R2, E2, B>): <R1, E1>(\n    ma: ReaderEither<R1, E1, A>\n  ) => ReaderEither<R1 & R2, E2 | E1, B>\n  <R1, E1, A, R2, E2, B>(ma: ReaderEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, B>): ReaderEither<\n    R1 & R2,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v2.14.0\n\n## flatMapEither\n\n**Signature**\n\n```ts\nexport declare const flatMapEither: {\n  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <R, E1>(self: ReaderEither<R, E1, A>) => ReaderEither<R, E2 | E1, B>\n  <R, E1, A, E2, B>(self: ReaderEither<R, E1, A>, f: (a: A) => E.Either<E2, B>): ReaderEither<R, E1 | E2, B>\n}\n```\n\nAdded in v2.15.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): <R, E1>(\n    self: ReaderEither<R, E1, A>\n  ) => ReaderEither<R, E2 | E1, NonNullable<B>>\n  <R, E1, A, B, E2>(\n    self: ReaderEither<R, E1, A>,\n    f: (a: A) => B | null | undefined,\n    onNullable: (a: A) => E2\n  ): ReaderEither<R, E1 | E2, NonNullable<B>>\n}\n```\n\nAdded in v2.15.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): <R, E1>(\n    self: ReaderEither<R, E1, A>\n  ) => ReaderEither<R, E2 | E1, B>\n  <R, E1, A, B, E2>(self: ReaderEither<R, E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): ReaderEither<\n    R,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v2.15.0\n\n## flatMapReader\n\n**Signature**\n\n```ts\nexport declare const flatMapReader: {\n  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <R1, E>(self: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, B>\n  <R1, E, A, R2, B>(self: ReaderEither<R1, E, A>, f: (a: A) => R.Reader<R2, B>): ReaderEither<R1 & R2, E, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <R, E, A>(mma: ReaderEither<R, E, ReaderEither<R, E, A>>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## flattenW\n\nLess strict version of [`flatten`](#flatten).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const flattenW: <R1, R2, E1, E2, A>(\n  mma: ReaderEither<R1, E1, ReaderEither<R2, E2, A>>\n) => ReaderEither<R1 & R2, E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <R, E, A>(arr: readonly ReaderEither<R, E, A>[]) => ReaderEither<R, E, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n) => (as: readonly A[]) => ReaderEither<R, E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <R, E, A, B>(\n  f: (index: number, a: A) => ReaderEither<R, E, B>\n) => (as: readonly A[]) => ReaderEither<R, E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, R, E, B>(\n  f: (index: number, a: A) => ReaderEither<R, E, B>\n) => (as: readonly A[]) => ReaderEither<R, E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, E, B>(\n  f: (index: number, a: A) => ReaderEither<R, E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => ReaderEither<R, E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReaderEither'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: ReaderEither<unknown, never, readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <R, E, A>(\n  fa: ReaderEither<R, E, A>\n) => <B>(fab: ReaderEither<R, E, (a: A) => B>) => ReaderEither<R, E, B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <R, E, B>(\n  second: ReaderEither<R, E, B>\n) => <A>(first: ReaderEither<R, E, A>) => ReaderEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## apFirstW\n\nLess strict version of [`apFirst`](#apfirst)\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apFirstW: <R2, E2, B>(\n  second: ReaderEither<R2, E2, B>\n) => <R1, E1, A>(first: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <R, E, B>(\n  second: ReaderEither<R, E, B>\n) => <A>(first: ReaderEither<R, E, A>) => ReaderEither<R, E, B>\n```\n\nAdded in v2.0.0\n\n## apSecondW\n\nLess strict version of [`apSecond`](#apsecond)\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSecondW: <R2, E2, B>(\n  second: ReaderEither<R2, E2, B>\n) => <R1, E1, A>(first: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.12.0\n\n## apW\n\nLess strict version of [`ap`](#ap).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apW: <R2, E2, A>(\n  fa: ReaderEither<R2, E2, A>\n) => <R1, E1, B>(fab: ReaderEither<R1, E1, (a: A) => B>) => ReaderEither<R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.8.0\n\n## local\n\nChanges the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n`contramap`).\n\n**Signature**\n\n```ts\nexport declare const local: <R2, R1>(f: (r2: R2) => R1) => <E, A>(ma: ReaderEither<R1, E, A>) => ReaderEither<R2, E, A>\n```\n\nAdded in v2.0.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare const swap: <R, E, A>(ma: ReaderEither<R, E, A>) => ReaderEither<R, A, E>\n```\n\nAdded in v2.0.0\n\n## throwError\n\n**Signature**\n\n```ts\nexport declare const throwError: <R, E, A>(e: E) => ReaderEither<R, E, A>\n```\n\nAdded in v2.7.0\n\n# zone of death\n\n## ~~getApplyMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplyMonoid: <R, E, A>(M: Monoid<A>) => Monoid<ReaderEither<R, E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getApplySemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplySemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderEither<R, E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getReaderValidation~~\n\nUse [`getApplicativeReaderValidation`](#getapplicativereadervalidation) and [`getAltReaderValidation`](#getaltreadervalidation) instead.\n\n**Signature**\n\n```ts\nexport declare function getReaderValidation<E>(\n  SE: Semigroup<E>\n): Monad3C<URI, E> & Bifunctor3<URI> & Alt3C<URI, E> & MonadThrow3C<URI, E>\n```\n\nAdded in v2.3.0\n\n## ~~getSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderEither<R, E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~readerEither~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RE.Functor` instead of `RE.readerEither`\n(where `R` is from `import R from 'fp-ts/ReaderEither'`)\n\n**Signature**\n\n```ts\nexport declare const readerEither: Monad3<'ReaderEither'> &\n  Bifunctor3<'ReaderEither'> &\n  Alt3<'ReaderEither'> &\n  MonadThrow3<'ReaderEither'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/ReaderIO.ts.md",
    "content": "---\ntitle: ReaderIO.ts\nnav_order: 79\nparent: Modules\n---\n\n## ReaderIO overview\n\nAdded in v2.13.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapIO](#tapio)\n  - [tapReader](#tapreader)\n- [constructors](#constructors)\n  - [ask](#ask)\n  - [asks](#asks)\n  - [asksReaderIO](#asksreaderio)\n  - [asksReaderIOW](#asksreaderiow)\n  - [of](#of)\n- [conversions](#conversions)\n  - [fromIO](#fromio)\n  - [fromReader](#fromreader)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [apSW](#apsw)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [bindW](#bindw)\n- [instances](#instances)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [FromIO](#fromio)\n  - [FromReader](#fromreader)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [Pointed](#pointed)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainFirstReaderK](#chainfirstreaderk)\n  - [chainFirstReaderKW](#chainfirstreaderkw)\n  - [chainFirstW](#chainfirstw)\n  - [chainIOK](#chainiok)\n  - [chainReaderK](#chainreaderk)\n  - [chainReaderKW](#chainreaderkw)\n  - [chainW](#chainw)\n- [lifting](#lifting)\n  - [fromIOK](#fromiok)\n  - [fromReaderK](#fromreaderk)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [ReaderIO (interface)](#readerio-interface)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapIO](#flatmapio)\n  - [flatMapReader](#flatmapreader)\n  - [flatten](#flatten)\n  - [flattenW](#flattenw)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [apW](#apw)\n  - [local](#local)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <R1, A, R2, _>(self: ReaderIO<R1, A>, f: (a: A) => ReaderIO<R2, _>): ReaderIO<R1 & R2, A>\n  <A, R2, _>(f: (a: A) => ReaderIO<R2, _>): <R1>(self: ReaderIO<R1, A>) => ReaderIO<R2 & R1, A>\n}\n```\n\nAdded in v2.15.0\n\n## tapIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapIO: {\n  <A, _>(f: (a: A) => I.IO<_>): <R>(self: ReaderIO<R, A>) => ReaderIO<R, A>\n  <R, A, _>(self: ReaderIO<R, A>, f: (a: A) => I.IO<_>): ReaderIO<R, A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as RIO from 'fp-ts/ReaderIO'\nimport * as Console from 'fp-ts/Console'\n\n// Will produce `Hello, fp-ts` to the stdout\nconst effect = pipe(\n  RIO.ask<string>(),\n  RIO.tapIO((value) => Console.log(`Hello, ${value}`))\n)\n\nasync function test() {\n  assert.deepStrictEqual(effect('fp-ts')(), 'fp-ts')\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## tapReader\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapReader: {\n  <R2, A, _>(f: (a: A) => R.Reader<R2, _>): <R1>(self: ReaderIO<R1, A>) => ReaderIO<R1 & R2, A>\n  <R1, A, R2, _>(self: ReaderIO<R1, A>, f: (a: A) => R.Reader<R2, _>): ReaderIO<R1 & R2, A>\n}\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## ask\n\nReads the current context.\n\n**Signature**\n\n```ts\nexport declare const ask: <R>() => ReaderIO<R, R>\n```\n\nAdded in v2.13.0\n\n## asks\n\nProjects a value from the global context in a `ReaderIO`.\n\n**Signature**\n\n```ts\nexport declare const asks: <R, A>(f: (r: R) => A) => ReaderIO<R, A>\n```\n\nAdded in v2.13.0\n\n## asksReaderIO\n\nEffectfully accesses the environment.\n\n**Signature**\n\n```ts\nexport declare const asksReaderIO: <R, A>(f: (r: R) => ReaderIO<R, A>) => ReaderIO<R, A>\n```\n\nAdded in v2.13.0\n\n## asksReaderIOW\n\nLess strict version of [`asksReaderIO`](#asksreaderio).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const asksReaderIOW: <R1, R2, A>(f: (r1: R1) => ReaderIO<R2, A>) => ReaderIO<R1 & R2, A>\n```\n\nAdded in v2.13.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <R = unknown, A = never>(a: A) => ReaderIO<R, A>\n```\n\nAdded in v2.13.0\n\n# conversions\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A, R = unknown>(fa: I.IO<A>) => ReaderIO<R, A>\n```\n\nAdded in v2.13.0\n\n## fromReader\n\n**Signature**\n\n```ts\nexport declare const fromReader: <R, A>(fa: R.Reader<R, A>) => ReaderIO<R, A>\n```\n\nAdded in v2.13.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: ReaderIO<unknown, {}>\n```\n\nAdded in v2.13.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderIO<E, B>\n) => (fa: ReaderIO<E, A>) => ReaderIO<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n## apSW\n\nLess strict version of [`apS`](#aps).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSW: <N extends string, A, R2, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderIO<R2, B>\n) => <R1>(fa: ReaderIO<R1, A>) => ReaderIO<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderIO<E, B>\n) => (ma: ReaderIO<E, A>) => ReaderIO<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <E, A>(fa: ReaderIO<E, A>) => ReaderIO<E, { readonly [K in N]: A }>\n```\n\nAdded in v2.13.0\n\n## bindW\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bindW: <N extends string, A, R2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderIO<R2, B>\n) => <R1>(fa: ReaderIO<R1, A>) => ReaderIO<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# instances\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative2<'ReaderIO'>\n```\n\nAdded in v2.13.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply2<'ReaderIO'>\n```\n\nAdded in v2.13.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain2<'ReaderIO'>\n```\n\nAdded in v2.13.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO2<'ReaderIO'>\n```\n\nAdded in v2.13.0\n\n## FromReader\n\n**Signature**\n\n```ts\nexport declare const FromReader: FromReader2<'ReaderIO'>\n```\n\nAdded in v2.13.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'ReaderIO'>\n```\n\nAdded in v2.13.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad2<'ReaderIO'>\n```\n\nAdded in v2.13.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO2<'ReaderIO'>\n```\n\nAdded in v2.13.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed2<'ReaderIO'>\n```\n\nAdded in v2.13.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, R, B>(f: (a: A) => ReaderIO<R, B>) => (ma: ReaderIO<R, A>) => ReaderIO<R, B>\n```\n\nAdded in v2.13.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, R, B>(f: (a: A) => ReaderIO<R, B>) => (first: ReaderIO<R, A>) => ReaderIO<R, A>\n```\n\nAdded in v2.13.0\n\n## chainFirstIOK\n\nAlias of `tapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: ReaderIO<E, A>) => ReaderIO<E, A>\n```\n\nAdded in v2.13.0\n\n## chainFirstReaderK\n\nAlias of `tapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderIO<R, A>) => ReaderIO<R, A>\n```\n\nAdded in v2.13.0\n\n## chainFirstReaderKW\n\nAlias of `tapReader`.\n\nLess strict version of [`chainFirstReaderK`](#chainfirstreaderk).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2>(ma: ReaderIO<R2, A>) => ReaderIO<R1 & R2, A>\n```\n\nAdded in v2.13.0\n\n## chainFirstW\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstW: <A, R2, B>(\n  f: (a: A) => ReaderIO<R2, B>\n) => <R1>(ma: ReaderIO<R1, A>) => ReaderIO<R1 & R2, A>\n```\n\nAdded in v2.13.0\n\n## chainIOK\n\nAlias of `flatMapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: ReaderIO<E, A>) => ReaderIO<E, B>\n```\n\nAdded in v2.13.0\n\n## chainReaderK\n\nAlias of `flatMapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderIO<R, A>) => ReaderIO<R, B>\n```\n\nAdded in v2.13.0\n\n## chainReaderKW\n\nAlias of `flatMapReader`.\n\nLess strict version of [`chainReaderK`](#chainreaderk).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2>(ma: ReaderIO<R2, A>) => ReaderIO<R1 & R2, B>\n```\n\nAdded in v2.13.0\n\n## chainW\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chainW: <A, R2, B>(\n  f: (a: A) => ReaderIO<R2, B>\n) => <R1>(ma: ReaderIO<R1, A>) => ReaderIO<R1 & R2, B>\n```\n\nAdded in v2.13.0\n\n# lifting\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(\n  f: (...a: A) => I.IO<B>\n) => <R = unknown>(...a: A) => ReaderIO<R, B>\n```\n\nAdded in v2.13.0\n\n## fromReaderK\n\n**Signature**\n\n```ts\nexport declare const fromReaderK: <A extends readonly unknown[], R, B>(\n  f: (...a: A) => R.Reader<R, B>\n) => (...a: A) => ReaderIO<R, B>\n```\n\nAdded in v2.13.0\n\n# mapping\n\n## as\n\nMaps the value to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <R, _>(self: ReaderIO<R, _>) => ReaderIO<R, A>\n  <R, _, A>(self: ReaderIO<R, _>, a: A): ReaderIO<R, A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the value to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <R, _>(self: ReaderIO<R, _>) => ReaderIO<R, void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: ReaderIO<E, (a: A) => B>) => ReaderIO<E, B>\n```\n\nAdded in v2.13.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <R>(fa: ReaderIO<R, A>) => ReaderIO<R, B>\n```\n\nAdded in v2.13.0\n\n# model\n\n## ReaderIO (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderIO<R, A> {\n  (r: R): I.IO<A>\n}\n```\n\nAdded in v2.13.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, R2, B>(f: (a: A) => ReaderIO<R2, B>): <R1>(ma: ReaderIO<R1, A>) => ReaderIO<R1 & R2, B>\n  <R1, A, R2, B>(ma: ReaderIO<R1, A>, f: (a: A) => ReaderIO<R2, B>): ReaderIO<R1 & R2, B>\n}\n```\n\nAdded in v2.14.0\n\n## flatMapIO\n\n**Signature**\n\n```ts\nexport declare const flatMapIO: {\n  <A, B>(f: (a: A) => I.IO<B>): <R>(self: ReaderIO<R, A>) => ReaderIO<R, B>\n  <R, A, B>(self: ReaderIO<R, A>, f: (a: A) => I.IO<B>): ReaderIO<R, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapReader\n\n**Signature**\n\n```ts\nexport declare const flatMapReader: {\n  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <R1>(self: ReaderIO<R1, A>) => ReaderIO<R1 & R2, B>\n  <R1, A, R2, B>(self: ReaderIO<R1, A>, f: (a: A) => R.Reader<R2, B>): ReaderIO<R1 & R2, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <R, A>(mma: ReaderIO<R, ReaderIO<R, A>>) => ReaderIO<R, A>\n```\n\nAdded in v2.13.0\n\n## flattenW\n\nLess strict version of [`flatten`](#flatten).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const flattenW: <R1, R2, A>(mma: ReaderIO<R1, ReaderIO<R2, A>>) => ReaderIO<R1 & R2, A>\n```\n\nAdded in v2.13.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <R, A>(arr: readonly ReaderIO<R, A>[]) => ReaderIO<R, readonly A[]>\n```\n\nAdded in v2.13.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <A, R, B>(\n  f: (a: A) => ReaderIO<R, B>\n) => (as: readonly A[]) => ReaderIO<R, readonly B[]>\n```\n\nAdded in v2.13.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <A, R, B>(\n  f: (index: number, a: A) => ReaderIO<R, B>\n) => (as: readonly A[]) => ReaderIO<R, readonly B[]>\n```\n\nAdded in v2.13.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, R, B>(\n  f: (index: number, a: A) => ReaderIO<R, B>\n) => (as: readonly A[]) => ReaderIO<R, readonly B[]>\n```\n\nAdded in v2.13.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, B>(\n  f: (index: number, a: A) => ReaderIO<R, B>\n) => (as: ReadonlyNonEmptyArray<A>) => ReaderIO<R, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.13.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReaderIO'\n```\n\nAdded in v2.13.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.13.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: ReaderIO<unknown, readonly []>\n```\n\nAdded in v2.13.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <R, A>(fa: ReaderIO<R, A>) => <B>(fab: ReaderIO<R, (a: A) => B>) => ReaderIO<R, B>\n```\n\nAdded in v2.13.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <E, B>(second: ReaderIO<E, B>) => <A>(first: ReaderIO<E, A>) => ReaderIO<E, A>\n```\n\nAdded in v2.13.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <E, B>(second: ReaderIO<E, B>) => <A>(first: ReaderIO<E, A>) => ReaderIO<E, B>\n```\n\nAdded in v2.13.0\n\n## apW\n\nLess strict version of [`ap`](#ap).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apW: <R2, A>(\n  fa: ReaderIO<R2, A>\n) => <R1, B>(fab: ReaderIO<R1, (a: A) => B>) => ReaderIO<R1 & R2, B>\n```\n\nAdded in v2.13.0\n\n## local\n\nChanges the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n`contramap`).\n\n**Signature**\n\n```ts\nexport declare const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderIO<R1, A>) => ReaderIO<R2, A>\n```\n\nAdded in v2.13.0\n"
  },
  {
    "path": "docs/modules/ReaderT.ts.md",
    "content": "---\ntitle: ReaderT.ts\nnav_order: 80\nparent: Modules\n---\n\n## ReaderT overview\n\nThe reader monad transformer, which adds a read-only environment to the given monad.\n\nThe `of` function ignores the environment, while `chain` passes the inherited environment to both subcomputations.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [fromNaturalTransformation](#fromnaturaltransformation)\n- [utils](#utils)\n  - [ap](#ap)\n  - [chain](#chain)\n  - [fromReader](#fromreader)\n  - [map](#map)\n  - [of](#of)\n- [zone of death](#zone-of-death)\n  - [~~ReaderM1~~ (interface)](#readerm1-interface)\n  - [~~ReaderM2C~~ (interface)](#readerm2c-interface)\n  - [~~ReaderM2~~ (interface)](#readerm2-interface)\n  - [~~ReaderM3~~ (interface)](#readerm3-interface)\n  - [~~ReaderM~~ (interface)](#readerm-interface)\n  - [~~ReaderT1~~ (interface)](#readert1-interface)\n  - [~~ReaderT2~~ (interface)](#readert2-interface)\n  - [~~ReaderT3~~ (interface)](#readert3-interface)\n  - [~~ReaderT~~ (interface)](#readert-interface)\n  - [~~getReaderM~~](#getreaderm)\n\n---\n\n# constructors\n\n## fromNaturalTransformation\n\n**Signature**\n\n```ts\nexport declare function fromNaturalTransformation<F extends URIS2, G extends URIS4>(\n  nt: NaturalTransformation24S<F, G>\n): <R, S, A, E>(f: (r: R) => Kind2<F, S, A>) => Reader<R, Kind4<G, S, R, E, A>>\nexport declare function fromNaturalTransformation<F extends URIS2, G extends URIS3>(\n  nt: NaturalTransformation23R<F, G>\n): <R, A, E>(f: (r: R) => Kind2<F, R, A>) => Reader<R, Kind3<G, R, E, A>>\nexport declare function fromNaturalTransformation<F extends URIS2, G extends URIS2>(\n  nt: NaturalTransformation22<F, G>\n): <R, E, A>(f: (r: R) => Kind2<F, E, A>) => Reader<R, Kind2<G, E, A>>\nexport declare function fromNaturalTransformation<F extends URIS, G extends URIS2>(\n  nt: NaturalTransformation12<F, G>\n): <R, A, E>(f: (r: R) => Kind<F, A>) => Reader<R, Kind2<G, E, A>>\nexport declare function fromNaturalTransformation<F extends URIS, G extends URIS>(\n  nt: NaturalTransformation11<F, G>\n): <R, A>(f: (r: R) => Kind<F, A>) => Reader<R, Kind<G, A>>\nexport declare function fromNaturalTransformation<F, G>(\n  nt: NaturalTransformation<F, G>\n): <R, A>(f: (r: R) => HKT<F, A>) => Reader<R, HKT<G, A>>\n```\n\nAdded in v2.11.0\n\n# utils\n\n## ap\n\n**Signature**\n\n```ts\nexport declare function ap<F extends URIS4>(\n  F: Apply4<F>\n): <R, S, FR, FE, A>(\n  fa: Reader<R, Kind4<F, S, FR, FE, A>>\n) => <B>(fab: Reader<R, Kind4<F, S, FR, FE, (a: A) => B>>) => Reader<R, Kind4<F, S, FR, FE, B>>\nexport declare function ap<F extends URIS3>(\n  F: Apply3<F>\n): <R, FR, FE, A>(\n  fa: Reader<R, Kind3<F, FR, FE, A>>\n) => <B>(fab: Reader<R, Kind3<F, FR, FE, (a: A) => B>>) => Reader<R, Kind3<F, FR, FE, B>>\nexport declare function ap<F extends URIS3, FE>(\n  F: Apply3C<F, FE>\n): <R, FR, A>(\n  fa: Reader<R, Kind3<F, FR, FE, A>>\n) => <B>(fab: Reader<R, Kind3<F, FR, FE, (a: A) => B>>) => Reader<R, Kind3<F, FR, FE, B>>\nexport declare function ap<F extends URIS2>(\n  F: Apply2<F>\n): <R, FE, A>(\n  fa: Reader<R, Kind2<F, FE, A>>\n) => <B>(fab: Reader<R, Kind2<F, FE, (a: A) => B>>) => Reader<R, Kind2<F, FE, B>>\nexport declare function ap<F extends URIS2, FE>(\n  F: Apply2C<F, FE>\n): <R, A>(\n  fa: Reader<R, Kind2<F, FE, A>>\n) => <B>(fab: Reader<R, Kind2<F, FE, (a: A) => B>>) => Reader<R, Kind2<F, FE, B>>\nexport declare function ap<F extends URIS>(\n  F: Apply1<F>\n): <R, A>(fa: Reader<R, Kind<F, A>>) => <B>(fab: Reader<R, Kind<F, (a: A) => B>>) => Reader<R, Kind<F, B>>\nexport declare function ap<F>(\n  F: Apply<F>\n): <R, A>(fa: Reader<R, HKT<F, A>>) => <B>(fab: Reader<R, HKT<F, (a: A) => B>>) => Reader<R, HKT<F, B>>\n```\n\nAdded in v2.10.0\n\n## chain\n\n**Signature**\n\n```ts\nexport declare function chain<M extends URIS4>(\n  M: Chain4<M>\n): <A, R, S, FR, FE, B>(\n  f: (a: A) => Reader<R, Kind4<M, S, FR, FE, B>>\n) => (ma: Reader<R, Kind4<M, S, FR, FE, A>>) => Reader<R, Kind4<M, S, FR, FE, B>>\nexport declare function chain<M extends URIS3>(\n  M: Chain3<M>\n): <A, R, FR, FE, B>(\n  f: (a: A) => Reader<R, Kind3<M, FR, FE, B>>\n) => (ma: Reader<R, Kind3<M, FR, FE, A>>) => Reader<R, Kind3<M, FR, FE, B>>\nexport declare function chain<M extends URIS3, FE>(\n  M: Chain3C<M, FE>\n): <A, R, FR, B>(\n  f: (a: A) => Reader<R, Kind3<M, FR, FE, B>>\n) => (ma: Reader<R, Kind3<M, FR, FE, A>>) => Reader<R, Kind3<M, FR, FE, B>>\nexport declare function chain<M extends URIS2>(\n  M: Chain2<M>\n): <A, R, FE, B>(\n  f: (a: A) => Reader<R, Kind2<M, FE, B>>\n) => (ma: Reader<R, Kind2<M, FE, A>>) => Reader<R, Kind2<M, FE, B>>\nexport declare function chain<M extends URIS2, FE>(\n  M: Chain2C<M, FE>\n): <A, R, B>(f: (a: A) => Reader<R, Kind2<M, FE, B>>) => (ma: Reader<R, Kind2<M, FE, A>>) => Reader<R, Kind2<M, FE, B>>\nexport declare function chain<M extends URIS>(\n  M: Chain1<M>\n): <A, R, B>(f: (a: A) => Reader<R, Kind<M, B>>) => (ma: Reader<R, Kind<M, A>>) => Reader<R, Kind<M, B>>\nexport declare function chain<M>(\n  M: Chain<M>\n): <A, R, B>(f: (a: A) => Reader<R, HKT<M, B>>) => (ma: Reader<R, HKT<M, A>>) => Reader<R, HKT<M, B>>\n```\n\nAdded in v2.10.0\n\n## fromReader\n\n**Signature**\n\n```ts\nexport declare function fromReader<F extends URIS4>(\n  F: Pointed4<F>\n): <R, A, S, FR, FE>(ma: Reader<R, A>) => Reader<R, Kind4<F, S, FR, FE, A>>\nexport declare function fromReader<F extends URIS3>(\n  F: Pointed3<F>\n): <R, A, FR, FE>(ma: Reader<R, A>) => Reader<R, Kind3<F, FR, FE, A>>\nexport declare function fromReader<F extends URIS3, FE>(\n  F: Pointed3C<F, FE>\n): <R, A, FR>(ma: Reader<R, A>) => Reader<R, Kind3<F, FR, FE, A>>\nexport declare function fromReader<F extends URIS2>(\n  F: Pointed2<F>\n): <R, A, FE>(ma: Reader<R, A>) => Reader<R, Kind2<F, FE, A>>\nexport declare function fromReader<F extends URIS2, FE>(\n  F: Pointed2C<F, FE>\n): <R, A>(ma: Reader<R, A>) => Reader<R, Kind2<F, FE, A>>\nexport declare function fromReader<F extends URIS>(F: Pointed1<F>): <R, A>(ma: Reader<R, A>) => Reader<R, Kind<F, A>>\nexport declare function fromReader<F>(F: Pointed<F>): <R, A>(ma: Reader<R, A>) => Reader<R, HKT<F, A>>\n```\n\nAdded in v2.10.0\n\n## map\n\n**Signature**\n\n```ts\nexport declare function map<F extends URIS4>(\n  F: Functor4<F>\n): <A, B>(f: (a: A) => B) => <R, S, FR, FE>(fa: Reader<R, Kind4<F, S, FR, FE, A>>) => Reader<R, Kind4<F, S, FR, FE, B>>\nexport declare function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, FR, FE>(fa: Reader<R, Kind3<F, FR, FE, A>>) => Reader<R, Kind3<F, FR, FE, B>>\nexport declare function map<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <A, B>(f: (a: A) => B) => <R, FR>(fa: Reader<R, Kind3<F, FR, FE, A>>) => Reader<R, Kind3<F, FR, FE, B>>\nexport declare function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <R, FE>(fa: Reader<R, Kind2<F, FE, A>>) => Reader<R, Kind2<F, FE, B>>\nexport declare function map<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, Kind2<F, FE, A>>) => Reader<R, Kind2<F, FE, B>>\nexport declare function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, Kind<F, A>>) => Reader<R, Kind<F, B>>\nexport declare function map<F>(\n  F: Functor<F>\n): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, HKT<F, A>>) => Reader<R, HKT<F, B>>\n```\n\nAdded in v2.10.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare function of<F extends URIS4>(\n  F: Pointed4<F>\n): <A, R, S, FR, FE>(a: A) => Reader<R, Kind4<F, S, FR, FE, A>>\nexport declare function of<F extends URIS3>(F: Pointed3<F>): <A, R, FR, FE>(a: A) => Reader<R, Kind3<F, FR, FE, A>>\nexport declare function of<F extends URIS3, FE>(F: Pointed3C<F, FE>): <A, R, FR>(a: A) => Reader<R, Kind3<F, FR, FE, A>>\nexport declare function of<F extends URIS2>(F: Pointed2<F>): <A, R, FE>(a: A) => Reader<R, Kind2<F, FE, A>>\nexport declare function of<F extends URIS2, FE>(F: Pointed2C<F, FE>): <A, R>(a: A) => Reader<R, Kind2<F, FE, A>>\nexport declare function of<F extends URIS>(F: Pointed1<F>): <A, R>(a: A) => Reader<R, Kind<F, A>>\nexport declare function of<F>(F: Pointed<F>): <A, R>(a: A) => Reader<R, HKT<F, A>>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~ReaderM1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderM1<M extends URIS> {\n  readonly map: <R, A, B>(ma: ReaderT1<M, R, A>, f: (a: A) => B) => ReaderT1<M, R, B>\n  readonly of: <R, A>(a: A) => ReaderT1<M, R, A>\n  readonly ap: <R, A, B>(mab: ReaderT1<M, R, (a: A) => B>, ma: ReaderT1<M, R, A>) => ReaderT1<M, R, B>\n  readonly chain: <R, A, B>(ma: ReaderT1<M, R, A>, f: (a: A) => ReaderT1<M, R, B>) => ReaderT1<M, R, B>\n  readonly ask: <R>() => ReaderT1<M, R, R>\n  readonly asks: <R, A>(f: (r: R) => A) => ReaderT1<M, R, A>\n  readonly local: <R1, A, R2>(ma: ReaderT1<M, R1, A>, f: (d: R2) => R1) => ReaderT1<M, R2, A>\n  readonly fromReader: <R, A>(ma: Reader<R, A>) => ReaderT1<M, R, A>\n  readonly fromM: <R, A>(ma: Kind<M, A>) => ReaderT1<M, R, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ReaderM2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderM2C<M extends URIS2, E> {\n  readonly map: <R, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => B) => ReaderT2<M, R, E, B>\n  readonly of: <R, A>(a: A) => ReaderT2<M, R, E, A>\n  readonly ap: <R, A, B>(mab: ReaderT2<M, R, E, (a: A) => B>, ma: ReaderT2<M, R, E, A>) => ReaderT2<M, R, E, B>\n  readonly chain: <R, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => ReaderT2<M, R, E, B>) => ReaderT2<M, R, E, B>\n  readonly ask: <R>() => ReaderT2<M, R, E, R>\n  readonly asks: <R, A>(f: (r: R) => A) => ReaderT2<M, R, E, A>\n  readonly local: <R1, A, R2>(ma: ReaderT2<M, R1, E, A>, f: (d: R2) => R1) => ReaderT2<M, R2, E, A>\n  readonly fromReader: <R, A>(ma: Reader<R, A>) => ReaderT2<M, R, E, A>\n  readonly fromM: <R, A>(ma: Kind2<M, E, A>) => ReaderT2<M, R, E, A>\n}\n```\n\nAdded in v2.2.0\n\n## ~~ReaderM2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderM2<M extends URIS2> {\n  readonly map: <R, E, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => B) => ReaderT2<M, R, E, B>\n  readonly of: <R, E, A>(a: A) => ReaderT2<M, R, E, A>\n  readonly ap: <R, E, A, B>(mab: ReaderT2<M, R, E, (a: A) => B>, ma: ReaderT2<M, R, E, A>) => ReaderT2<M, R, E, B>\n  readonly chain: <R, E, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => ReaderT2<M, R, E, B>) => ReaderT2<M, R, E, B>\n  readonly ask: <R, E>() => ReaderT2<M, R, E, R>\n  readonly asks: <R, E, A>(f: (r: R) => A) => ReaderT2<M, R, E, A>\n  readonly local: <R1, E, A, R2>(ma: ReaderT2<M, R1, E, A>, f: (d: R2) => R1) => ReaderT2<M, R2, E, A>\n  readonly fromReader: <R, E, A>(ma: Reader<R, A>) => ReaderT2<M, R, E, A>\n  readonly fromM: <R, E, A>(ma: Kind2<M, E, A>) => ReaderT2<M, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ReaderM3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderM3<M extends URIS3> {\n  readonly map: <R, U, E, A, B>(ma: ReaderT3<M, R, U, E, A>, f: (a: A) => B) => ReaderT3<M, R, U, E, B>\n  readonly of: <R, U, E, A>(a: A) => ReaderT3<M, R, U, E, A>\n  readonly ap: <R, U, E, A, B>(\n    mab: ReaderT3<M, R, U, E, (a: A) => B>,\n    ma: ReaderT3<M, R, U, E, A>\n  ) => ReaderT3<M, R, U, E, B>\n  readonly chain: <R, U, E, A, B>(\n    ma: ReaderT3<M, R, U, E, A>,\n    f: (a: A) => ReaderT3<M, R, U, E, B>\n  ) => ReaderT3<M, R, U, E, B>\n  readonly ask: <R, U, E>() => ReaderT3<M, R, U, E, R>\n  readonly asks: <R, U, E, A>(f: (r: R) => A) => ReaderT3<M, R, U, E, A>\n  readonly local: <R1, U, E, A, R2>(ma: ReaderT3<M, R1, U, E, A>, f: (d: R2) => R1) => ReaderT3<M, R2, U, E, A>\n  readonly fromReader: <R, U, E, A>(ma: Reader<R, A>) => ReaderT3<M, R, U, E, A>\n  readonly fromM: <R, U, E, A>(ma: Kind3<M, U, E, A>) => ReaderT3<M, R, U, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ReaderM~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderM<M> {\n  readonly map: <R, A, B>(ma: ReaderT<M, R, A>, f: (a: A) => B) => ReaderT<M, R, B>\n  readonly of: <R, A>(a: A) => ReaderT<M, R, A>\n  readonly ap: <R, A, B>(mab: ReaderT<M, R, (a: A) => B>, ma: ReaderT<M, R, A>) => ReaderT<M, R, B>\n  readonly chain: <R, A, B>(ma: ReaderT<M, R, A>, f: (a: A) => ReaderT<M, R, B>) => ReaderT<M, R, B>\n  readonly ask: <R>() => ReaderT<M, R, R>\n  readonly asks: <R, A>(f: (r: R) => A) => ReaderT<M, R, A>\n  readonly local: <R1, A, R2>(ma: ReaderT<M, R1, A>, f: (d: R2) => R1) => ReaderT<M, R2, A>\n  readonly fromReader: <R, A>(ma: Reader<R, A>) => ReaderT<M, R, A>\n  readonly fromM: <R, A>(ma: HKT<M, A>) => ReaderT<M, R, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ReaderT1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderT1<M extends URIS, R, A> {\n  (r: R): Kind<M, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ReaderT2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderT2<M extends URIS2, R, E, A> {\n  (r: R): Kind2<M, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ReaderT3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderT3<M extends URIS3, R, U, E, A> {\n  (r: R): Kind3<M, U, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ReaderT~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderT<M, R, A> {\n  (r: R): HKT<M, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~getReaderM~~\n\n**Signature**\n\n```ts\nexport declare function getReaderM<M extends URIS3>(M: Monad3<M>): ReaderM3<M>\nexport declare function getReaderM<M extends URIS2>(M: Monad2<M>): ReaderM2<M>\nexport declare function getReaderM<M extends URIS2, E>(M: Monad2C<M, E>): ReaderM2C<M, E>\nexport declare function getReaderM<M extends URIS>(M: Monad1<M>): ReaderM1<M>\nexport declare function getReaderM<M>(M: Monad<M>): ReaderM<M>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/ReaderTask.ts.md",
    "content": "---\ntitle: ReaderTask.ts\nnav_order: 81\nparent: Modules\n---\n\n## ReaderTask overview\n\nAdded in v2.3.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapIO](#tapio)\n  - [tapReader](#tapreader)\n  - [tapReaderIO](#tapreaderio)\n  - [tapTask](#taptask)\n- [constructors](#constructors)\n  - [ask](#ask)\n  - [asks](#asks)\n  - [asksReaderTask](#asksreadertask)\n  - [asksReaderTaskW](#asksreadertaskw)\n  - [of](#of)\n- [conversions](#conversions)\n  - [fromIO](#fromio)\n  - [fromReader](#fromreader)\n  - [fromReaderIO](#fromreaderio)\n  - [fromTask](#fromtask)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [apSW](#apsw)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [bindW](#bindw)\n  - [let](#let)\n- [instances](#instances)\n  - [ApplicativePar](#applicativepar)\n  - [ApplicativeSeq](#applicativeseq)\n  - [ApplyPar](#applypar)\n  - [ApplySeq](#applyseq)\n  - [Chain](#chain)\n  - [FromIO](#fromio)\n  - [FromReader](#fromreader)\n  - [FromTask](#fromtask)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [MonadTask](#monadtask)\n  - [Pointed](#pointed)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainFirstReaderIOK](#chainfirstreaderiok)\n  - [chainFirstReaderIOKW](#chainfirstreaderiokw)\n  - [chainFirstReaderK](#chainfirstreaderk)\n  - [chainFirstReaderKW](#chainfirstreaderkw)\n  - [chainFirstTaskK](#chainfirsttaskk)\n  - [chainFirstW](#chainfirstw)\n  - [chainIOK](#chainiok)\n  - [chainReaderIOK](#chainreaderiok)\n  - [chainReaderIOKW](#chainreaderiokw)\n  - [chainReaderK](#chainreaderk)\n  - [chainReaderKW](#chainreaderkw)\n  - [chainTaskK](#chaintaskk)\n  - [chainW](#chainw)\n- [lifting](#lifting)\n  - [fromIOK](#fromiok)\n  - [fromReaderIOK](#fromreaderiok)\n  - [fromReaderK](#fromreaderk)\n  - [fromTaskK](#fromtaskk)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [ReaderTask (interface)](#readertask-interface)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapIO](#flatmapio)\n  - [flatMapReader](#flatmapreader)\n  - [flatMapReaderIO](#flatmapreaderio)\n  - [flatMapTask](#flatmaptask)\n  - [flatten](#flatten)\n  - [flattenW](#flattenw)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyArrayWithIndexSeq](#traversereadonlyarraywithindexseq)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndexSeq](#traversereadonlynonemptyarraywithindexseq)\n  - [traverseSeqArray](#traverseseqarray)\n  - [traverseSeqArrayWithIndex](#traverseseqarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apFirstW](#apfirstw)\n  - [apSecond](#apsecond)\n  - [apSecondW](#apsecondw)\n  - [apW](#apw)\n  - [local](#local)\n- [zone of death](#zone-of-death)\n  - [~~getMonoid~~](#getmonoid)\n  - [~~getSemigroup~~](#getsemigroup)\n  - [~~readerTaskSeq~~](#readertaskseq)\n  - [~~readerTask~~](#readertask)\n  - [~~run~~](#run)\n  - [~~sequenceSeqArray~~](#sequenceseqarray)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <R1, A, R2, _>(self: ReaderTask<R1, A>, f: (a: A) => ReaderTask<R2, _>): ReaderTask<R1 & R2, A>\n  <A, R2, _>(f: (a: A) => ReaderTask<R2, _>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R2 & R1, A>\n}\n```\n\nAdded in v2.15.0\n\n## tapIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, A>\n  <R, A, _>(self: ReaderTask<R, A>, f: (a: A) => IO<_>): ReaderTask<R, A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as RT from 'fp-ts/ReaderTask'\nimport * as Console from 'fp-ts/Console'\n\n// Will produce `Hello, fp-ts` to the stdout\nconst effect = pipe(\n  RT.ask<string>(),\n  RT.tapIO((value) => Console.log(`Hello, ${value}`))\n)\n\nasync function test() {\n  assert.deepStrictEqual(await effect('fp-ts')(), 'fp-ts')\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## tapReader\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapReader: {\n  <R2, A, _>(f: (a: A) => R.Reader<R2, _>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>\n  <R1, R2, A, _>(self: ReaderTask<R1, A>, f: (a: A) => R.Reader<R2, _>): ReaderTask<R1 & R2, A>\n}\n```\n\nAdded in v2.16.0\n\n## tapReaderIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapReaderIO: {\n  <R2, A, _>(f: (a: A) => RIO.ReaderIO<R2, _>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>\n  <R1, R2, A, _>(self: ReaderTask<R1, A>, f: (a: A) => RIO.ReaderIO<R2, _>): ReaderTask<R1 & R2, A>\n}\n```\n\nAdded in v2.16.0\n\n## tapTask\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapTask: {\n  <A, _>(f: (a: A) => T.Task<_>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, A>\n  <R, A, _>(self: ReaderTask<R, A>, f: (a: A) => T.Task<_>): ReaderTask<R, A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as RT from 'fp-ts/ReaderTask'\nimport * as T from 'fp-ts/Task'\n\nconst effect = pipe(\n  RT.ask<number>(),\n  RT.tapTask((value) => T.of(value + 1))\n)\n\nasync function test() {\n  assert.deepStrictEqual(await effect(1)(), 1)\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## ask\n\nReads the current context.\n\n**Signature**\n\n```ts\nexport declare const ask: <R>() => ReaderTask<R, R>\n```\n\nAdded in v2.3.0\n\n## asks\n\nProjects a value from the global context in a `ReaderTask`.\n\n**Signature**\n\n```ts\nexport declare const asks: <R, A>(f: (r: R) => A) => ReaderTask<R, A>\n```\n\nAdded in v2.3.0\n\n## asksReaderTask\n\nEffectfully accesses the environment.\n\n**Signature**\n\n```ts\nexport declare const asksReaderTask: <R, A>(f: (r: R) => ReaderTask<R, A>) => ReaderTask<R, A>\n```\n\nAdded in v2.11.0\n\n## asksReaderTaskW\n\nLess strict version of [`asksReaderTask`](#asksreadertask).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const asksReaderTaskW: <R1, R2, A>(f: (r1: R1) => ReaderTask<R2, A>) => ReaderTask<R1 & R2, A>\n```\n\nAdded in v2.11.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <R = unknown, A = never>(a: A) => ReaderTask<R, A>\n```\n\nAdded in v2.3.0\n\n# conversions\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A, R = unknown>(fa: IO<A>) => ReaderTask<R, A>\n```\n\nAdded in v2.3.0\n\n## fromReader\n\n**Signature**\n\n```ts\nexport declare const fromReader: <R, A>(fa: R.Reader<R, A>) => ReaderTask<R, A>\n```\n\nAdded in v2.3.0\n\n## fromReaderIO\n\n**Signature**\n\n```ts\nexport declare const fromReaderIO: <R, A>(fa: RIO.ReaderIO<R, A>) => ReaderTask<R, A>\n```\n\nAdded in v2.13.0\n\n## fromTask\n\n**Signature**\n\n```ts\nexport declare const fromTask: <A, R = unknown>(fa: T.Task<A>) => ReaderTask<R, A>\n```\n\nAdded in v2.3.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: ReaderTask<unknown, {}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderTask<E, B>\n) => (fa: ReaderTask<E, A>) => ReaderTask<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## apSW\n\nLess strict version of [`apS`](#aps).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSW: <A, N extends string, R2, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderTask<R2, B>\n) => <R1>(fa: ReaderTask<R1, A>) => ReaderTask<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderTask<E, B>\n) => (ma: ReaderTask<E, A>) => ReaderTask<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <E, A>(fa: ReaderTask<E, A>) => ReaderTask<E, { readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## bindW\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bindW: <N extends string, A, R2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderTask<R2, B>\n) => <R1>(fa: ReaderTask<R1, A>) => ReaderTask<R1 & R2, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <E>(fa: ReaderTask<E, A>) => ReaderTask<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# instances\n\n## ApplicativePar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplicativePar: Applicative2<'ReaderTask'>\n```\n\nAdded in v2.7.0\n\n## ApplicativeSeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplicativeSeq: Applicative2<'ReaderTask'>\n```\n\nAdded in v2.7.0\n\n## ApplyPar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplyPar: Apply2<'ReaderTask'>\n```\n\nAdded in v2.10.0\n\n## ApplySeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplySeq: Apply2<'ReaderTask'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain2<'ReaderTask'>\n```\n\nAdded in v2.10.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO2<'ReaderTask'>\n```\n\nAdded in v2.10.0\n\n## FromReader\n\n**Signature**\n\n```ts\nexport declare const FromReader: FromReader2<'ReaderTask'>\n```\n\nAdded in v2.11.0\n\n## FromTask\n\n**Signature**\n\n```ts\nexport declare const FromTask: FromTask2<'ReaderTask'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'ReaderTask'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad2<'ReaderTask'>\n```\n\nAdded in v2.10.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO2<'ReaderTask'>\n```\n\nAdded in v2.10.0\n\n## MonadTask\n\n**Signature**\n\n```ts\nexport declare const MonadTask: MonadTask2<'ReaderTask'>\n```\n\nAdded in v2.10.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed2<'ReaderTask'>\n```\n\nAdded in v2.10.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, R, B>(f: (a: A) => ReaderTask<R, B>) => (ma: ReaderTask<R, A>) => ReaderTask<R, B>\n```\n\nAdded in v2.3.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, R, B>(\n  f: (a: A) => ReaderTask<R, B>\n) => (first: ReaderTask<R, A>) => ReaderTask<R, A>\n```\n\nAdded in v2.3.0\n\n## chainFirstIOK\n\nAlias of `tapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, A>\n```\n\nAdded in v2.10.0\n\n## chainFirstReaderIOK\n\nAlias of `tapReaderIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderIOK: <A, R, B>(\n  f: (a: A) => RIO.ReaderIO<R, B>\n) => (ma: ReaderTask<R, A>) => ReaderTask<R, A>\n```\n\nAdded in v2.13.0\n\n## chainFirstReaderIOKW\n\nAlias of `tapReaderIO`.\n\nLess strict version of [`chainFirstReaderIOK`](#chainfirstreaderiok).\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderIOKW: <A, R2, B>(\n  f: (a: A) => RIO.ReaderIO<R2, B>\n) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>\n```\n\nAdded in v2.13.0\n\n## chainFirstReaderK\n\nAlias of `tapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderK: <A, R, B>(\n  f: (a: A) => R.Reader<R, B>\n) => (ma: ReaderTask<R, A>) => ReaderTask<R, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstReaderKW\n\nAlias of `tapReader`.\n\nLess strict version of [`chainFirstReaderK`](#chainfirstreaderk).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2>(ma: ReaderTask<R2, A>) => ReaderTask<R1 & R2, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstTaskK\n\nAlias of `tapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, A>\n```\n\nAdded in v2.10.0\n\n## chainFirstW\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstW: <R2, A, B>(\n  f: (a: A) => ReaderTask<R2, B>\n) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>\n```\n\nAdded in v2.11.0\n\n## chainIOK\n\nAlias of `flatMapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainIOK: <A, B>(f: (a: A) => IO<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, B>\n```\n\nAdded in v2.4.0\n\n## chainReaderIOK\n\nAlias of `flatMapReaderIO`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderIOK: <A, R, B>(\n  f: (a: A) => RIO.ReaderIO<R, B>\n) => (ma: ReaderTask<R, A>) => ReaderTask<R, B>\n```\n\nAdded in v2.13.0\n\n## chainReaderIOKW\n\nAlias of `flatMapReaderIO`.\n\nLess strict version of [`chainReaderIOK`](#chainreaderiok).\n\n**Signature**\n\n```ts\nexport declare const chainReaderIOKW: <A, R2, B>(\n  f: (a: A) => RIO.ReaderIO<R2, B>\n) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>\n```\n\nAdded in v2.13.0\n\n## chainReaderK\n\nAlias of `flatMapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderTask<R, A>) => ReaderTask<R, B>\n```\n\nAdded in v2.11.0\n\n## chainReaderKW\n\nAlias of `flatMapReader`.\n\nLess strict version of [`chainReaderK`](#chainreaderk).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2>(ma: ReaderTask<R2, A>) => ReaderTask<R1 & R2, B>\n```\n\nAdded in v2.11.0\n\n## chainTaskK\n\nAlias of `flatMapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainTaskK: <A, B>(f: (a: A) => T.Task<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, B>\n```\n\nAdded in v2.4.0\n\n## chainW\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chainW: <R2, A, B>(\n  f: (a: A) => ReaderTask<R2, B>\n) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>\n```\n\nAdded in v2.6.7\n\n# lifting\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(\n  f: (...a: A) => IO<B>\n) => <R = unknown>(...a: A) => ReaderTask<R, B>\n```\n\nAdded in v2.4.0\n\n## fromReaderIOK\n\n**Signature**\n\n```ts\nexport declare const fromReaderIOK: <A extends readonly unknown[], R, B>(\n  f: (...a: A) => RIO.ReaderIO<R, B>\n) => (...a: A) => ReaderTask<R, B>\n```\n\nAdded in v2.13.0\n\n## fromReaderK\n\n**Signature**\n\n```ts\nexport declare const fromReaderK: <A extends readonly unknown[], R, B>(\n  f: (...a: A) => R.Reader<R, B>\n) => (...a: A) => ReaderTask<R, B>\n```\n\nAdded in v2.11.0\n\n## fromTaskK\n\n**Signature**\n\n```ts\nexport declare const fromTaskK: <A extends readonly unknown[], B>(\n  f: (...a: A) => T.Task<B>\n) => <R = unknown>(...a: A) => ReaderTask<R, B>\n```\n\nAdded in v2.4.0\n\n# mapping\n\n## as\n\nMaps the value to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <R, _>(self: ReaderTask<R, _>) => ReaderTask<R, A>\n  <R, _, A>(self: ReaderTask<R, _>, a: A): ReaderTask<R, A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the value to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <R, _>(self: ReaderTask<R, _>) => ReaderTask<R, void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: ReaderTask<E, (a: A) => B>) => ReaderTask<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <R>(fa: ReaderTask<R, A>) => ReaderTask<R, B>\n```\n\nAdded in v2.3.0\n\n# model\n\n## ReaderTask (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderTask<R, A> {\n  (r: R): Task<A>\n}\n```\n\nAdded in v2.3.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, R2, B>(f: (a: A) => ReaderTask<R2, B>): <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>\n  <R1, A, R2, B>(ma: ReaderTask<R1, A>, f: (a: A) => ReaderTask<R2, B>): ReaderTask<R1 & R2, B>\n}\n```\n\nAdded in v2.14.0\n\n## flatMapIO\n\n**Signature**\n\n```ts\nexport declare const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, B>\n  <R, A, B>(self: ReaderTask<R, A>, f: (a: A) => IO<B>): ReaderTask<R, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapReader\n\n**Signature**\n\n```ts\nexport declare const flatMapReader: {\n  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>\n  <R1, A, R2, B>(self: ReaderTask<R1, A>, f: (a: A) => R.Reader<R2, B>): ReaderTask<R1 & R2, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapReaderIO\n\n**Signature**\n\n```ts\nexport declare const flatMapReaderIO: {\n  <A, R2, B>(f: (a: A) => RIO.ReaderIO<R2, B>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>\n  <R1, A, R2, B>(self: ReaderTask<R1, A>, f: (a: A) => RIO.ReaderIO<R2, B>): ReaderTask<R1 & R2, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapTask\n\n**Signature**\n\n```ts\nexport declare const flatMapTask: {\n  <A, B>(f: (a: A) => T.Task<B>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, B>\n  <R, A, B>(self: ReaderTask<R, A>, f: (a: A) => T.Task<B>): ReaderTask<R, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <R, A>(mma: ReaderTask<R, ReaderTask<R, A>>) => ReaderTask<R, A>\n```\n\nAdded in v2.3.0\n\n## flattenW\n\nLess strict version of [`flatten`](#flatten).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const flattenW: <R1, R2, A>(mma: ReaderTask<R1, ReaderTask<R2, A>>) => ReaderTask<R1 & R2, A>\n```\n\nAdded in v2.11.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <R, A>(arr: readonly ReaderTask<R, A>[]) => ReaderTask<R, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <R, A, B>(\n  f: (a: A) => ReaderTask<R, B>\n) => (as: readonly A[]) => ReaderTask<R, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <R, A, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n) => (as: readonly A[]) => ReaderTask<R, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, R, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n) => (as: readonly A[]) => ReaderTask<R, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyArrayWithIndexSeq\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndexSeq: <R, A, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n) => (as: readonly A[]) => ReaderTask<R, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n) => (as: ReadonlyNonEmptyArray<A>) => ReaderTask<R, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndexSeq\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <R, A, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n) => (as: ReadonlyNonEmptyArray<A>) => ReaderTask<R, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseSeqArray\n\nEquivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArray: <R, A, B>(\n  f: (a: A) => ReaderTask<R, B>\n) => (as: readonly A[]) => ReaderTask<R, readonly B[]>\n```\n\nAdded in v2.10.0\n\n## traverseSeqArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArrayWithIndex: <R, A, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n) => (as: readonly A[]) => ReaderTask<R, readonly B[]>\n```\n\nAdded in v2.10.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReaderTask'\n```\n\nAdded in v2.3.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.3.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: ReaderTask<unknown, readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <R, A>(fa: ReaderTask<R, A>) => <B>(fab: ReaderTask<R, (a: A) => B>) => ReaderTask<R, B>\n```\n\nAdded in v2.3.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <E, B>(second: ReaderTask<E, B>) => <A>(first: ReaderTask<E, A>) => ReaderTask<E, A>\n```\n\nAdded in v2.3.0\n\n## apFirstW\n\nLess strict version of [`apFirst`](#apfirst).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apFirstW: <R2, B>(\n  second: ReaderTask<R2, B>\n) => <R1, A>(first: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>\n```\n\nAdded in v2.17.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <E, B>(second: ReaderTask<E, B>) => <A>(first: ReaderTask<E, A>) => ReaderTask<E, B>\n```\n\nAdded in v2.3.0\n\n## apSecondW\n\nLess strict version of [`apSecond`](#apsecond).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSecondW: <R2, B>(\n  second: ReaderTask<R2, B>\n) => <R1, A>(first: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>\n```\n\nAdded in v2.17.0\n\n## apW\n\nLess strict version of [`ap`](#ap).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apW: <R2, A>(\n  fa: ReaderTask<R2, A>\n) => <R1, B>(fab: ReaderTask<R1, (a: A) => B>) => ReaderTask<R1 & R2, B>\n```\n\nAdded in v2.8.0\n\n## local\n\nChanges the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n`contramap`).\n\n**Signature**\n\n```ts\nexport declare const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderTask<R1, A>) => ReaderTask<R2, A>\n```\n\nAdded in v2.3.0\n\n# zone of death\n\n## ~~getMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <R, A>(M: Monoid<A>) => Monoid<ReaderTask<R, A>>\n```\n\nAdded in v2.3.0\n\n## ~~getSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <R, A>(S: Semigroup<A>) => Semigroup<ReaderTask<R, A>>\n```\n\nAdded in v2.3.0\n\n## ~~readerTaskSeq~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RT.Functor` instead of `RT.readerTaskSeq`\n(where `RT` is from `import RT from 'fp-ts/ReaderTask'`)\n\n**Signature**\n\n```ts\nexport declare const readerTaskSeq: MonadTask2<'ReaderTask'>\n```\n\nAdded in v2.3.0\n\n## ~~readerTask~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RT.Functor` instead of `RT.readerTask`\n(where `RT` is from `import RT from 'fp-ts/ReaderTask'`)\n\n**Signature**\n\n```ts\nexport declare const readerTask: MonadTask2<'ReaderTask'>\n```\n\nAdded in v2.3.0\n\n## ~~run~~\n\n**Signature**\n\n```ts\nexport declare function run<R, A>(ma: ReaderTask<R, A>, r: R): Promise<A>\n```\n\nAdded in v2.4.0\n\n## ~~sequenceSeqArray~~\n\nUse `traverseReadonlyArrayWithIndexSeq` instead.\n\n**Signature**\n\n```ts\nexport declare const sequenceSeqArray: <R, A>(arr: readonly ReaderTask<R, A>[]) => ReaderTask<R, readonly A[]>\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/ReaderTaskEither.ts.md",
    "content": "---\ntitle: ReaderTaskEither.ts\nnav_order: 82\nparent: Modules\n---\n\n## ReaderTaskEither overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapEither](#tapeither)\n  - [tapIO](#tapio)\n  - [tapReader](#tapreader)\n  - [tapReaderEither](#tapreadereither)\n  - [tapReaderIO](#tapreaderio)\n  - [tapReaderTask](#tapreadertask)\n  - [tapTask](#taptask)\n  - [tapTaskEither](#taptaskeither)\n- [constructors](#constructors)\n  - [ask](#ask)\n  - [asks](#asks)\n  - [asksReaderTaskEither](#asksreadertaskeither)\n  - [asksReaderTaskEitherW](#asksreadertaskeitherw)\n  - [left](#left)\n  - [leftIO](#leftio)\n  - [leftReader](#leftreader)\n  - [leftReaderIO](#leftreaderio)\n  - [leftReaderTask](#leftreadertask)\n  - [leftTask](#lefttask)\n  - [of](#of)\n  - [right](#right)\n  - [rightIO](#rightio)\n  - [rightReader](#rightreader)\n  - [rightReaderIO](#rightreaderio)\n  - [rightReaderTask](#rightreadertask)\n  - [rightTask](#righttask)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromIO](#fromio)\n  - [fromIOEither](#fromioeither)\n  - [fromNullable](#fromnullable)\n  - [fromOption](#fromoption)\n  - [fromReader](#fromreader)\n  - [fromReaderEither](#fromreadereither)\n  - [fromTask](#fromtask)\n  - [fromTaskEither](#fromtaskeither)\n  - [toUnion](#tounion)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [apSW](#apsw)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [bindW](#bindw)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n  - [getAltReaderTaskValidation](#getaltreadertaskvalidation)\n  - [getApplicativeReaderTaskValidation](#getapplicativereadertaskvalidation)\n  - [getOrElse](#getorelse)\n  - [getOrElseW](#getorelsew)\n  - [mapBoth](#mapboth)\n  - [mapError](#maperror)\n  - [orElse](#orelse)\n  - [orElseW](#orelsew)\n  - [orLeft](#orleft)\n  - [orLeftW](#orleftw)\n  - [tapError](#taperror)\n- [filtering](#filtering)\n  - [filterOrElse](#filterorelse)\n  - [filterOrElseW](#filterorelsew)\n  - [getCompactable](#getcompactable)\n  - [getFilterable](#getfilterable)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [ApplicativePar](#applicativepar)\n  - [ApplicativeSeq](#applicativeseq)\n  - [ApplyPar](#applypar)\n  - [ApplySeq](#applyseq)\n  - [Bifunctor](#bifunctor)\n  - [Chain](#chain)\n  - [FromEither](#fromeither)\n  - [FromIO](#fromio)\n  - [FromReader](#fromreader)\n  - [FromTask](#fromtask)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [MonadTask](#monadtask)\n  - [MonadThrow](#monadthrow)\n  - [Pointed](#pointed)\n  - [~~getReaderTaskValidation~~](#getreadertaskvalidation)\n- [legacy](#legacy)\n  - [bimap](#bimap)\n  - [chain](#chain)\n  - [chainEitherK](#chaineitherk)\n  - [chainEitherKW](#chaineitherkw)\n  - [chainFirst](#chainfirst)\n  - [chainFirstEitherK](#chainfirsteitherk)\n  - [chainFirstEitherKW](#chainfirsteitherkw)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainFirstReaderEitherK](#chainfirstreadereitherk)\n  - [chainFirstReaderEitherKW](#chainfirstreadereitherkw)\n  - [chainFirstReaderIOK](#chainfirstreaderiok)\n  - [chainFirstReaderIOKW](#chainfirstreaderiokw)\n  - [chainFirstReaderK](#chainfirstreaderk)\n  - [chainFirstReaderKW](#chainfirstreaderkw)\n  - [chainFirstReaderTaskK](#chainfirstreadertaskk)\n  - [chainFirstReaderTaskKW](#chainfirstreadertaskkw)\n  - [chainFirstTaskEitherK](#chainfirsttaskeitherk)\n  - [chainFirstTaskEitherKW](#chainfirsttaskeitherkw)\n  - [chainFirstTaskK](#chainfirsttaskk)\n  - [chainFirstW](#chainfirstw)\n  - [chainIOEitherK](#chainioeitherk)\n  - [chainIOEitherKW](#chainioeitherkw)\n  - [chainIOK](#chainiok)\n  - [chainNullableK](#chainnullablek)\n  - [chainOptionK](#chainoptionk)\n  - [chainOptionKW](#chainoptionkw)\n  - [chainReaderEitherK](#chainreadereitherk)\n  - [chainReaderEitherKW](#chainreadereitherkw)\n  - [chainReaderIOK](#chainreaderiok)\n  - [chainReaderIOKW](#chainreaderiokw)\n  - [chainReaderK](#chainreaderk)\n  - [chainReaderKW](#chainreaderkw)\n  - [chainReaderTaskK](#chainreadertaskk)\n  - [chainReaderTaskKW](#chainreadertaskkw)\n  - [chainTaskEitherK](#chaintaskeitherk)\n  - [chainTaskEitherKW](#chaintaskeitherkw)\n  - [chainTaskK](#chaintaskk)\n  - [chainW](#chainw)\n  - [fromNullableK](#fromnullablek)\n  - [fromOptionK](#fromoptionk)\n  - [mapLeft](#mapleft)\n  - [orElseFirst](#orelsefirst)\n  - [orElseFirstW](#orelsefirstw)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromIOEitherK](#fromioeitherk)\n  - [fromIOK](#fromiok)\n  - [fromPredicate](#frompredicate)\n  - [fromReaderEitherK](#fromreadereitherk)\n  - [fromReaderIOK](#fromreaderiok)\n  - [fromReaderK](#fromreaderk)\n  - [fromReaderTaskK](#fromreadertaskk)\n  - [fromTaskEitherK](#fromtaskeitherk)\n  - [fromTaskK](#fromtaskk)\n  - [liftNullable](#liftnullable)\n  - [liftOption](#liftoption)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [ReaderTaskEither (interface)](#readertaskeither-interface)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchE](#matche)\n  - [matchEW](#matchew)\n  - [matchW](#matchw)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapEither](#flatmapeither)\n  - [flatMapIO](#flatmapio)\n  - [flatMapIOEither](#flatmapioeither)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatMapOption](#flatmapoption)\n  - [flatMapReader](#flatmapreader)\n  - [flatMapReaderEither](#flatmapreadereither)\n  - [flatMapReaderIO](#flatmapreaderio)\n  - [flatMapReaderTask](#flatmapreadertask)\n  - [flatMapTask](#flatmaptask)\n  - [flatMapTaskEither](#flatmaptaskeither)\n  - [flatten](#flatten)\n  - [flattenW](#flattenw)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [sequenceSeqArray](#sequenceseqarray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyArrayWithIndexSeq](#traversereadonlyarraywithindexseq)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndexSeq](#traversereadonlynonemptyarraywithindexseq)\n  - [traverseSeqArray](#traverseseqarray)\n  - [traverseSeqArrayWithIndex](#traverseseqarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apFirstW](#apfirstw)\n  - [apSecond](#apsecond)\n  - [apSecondW](#apsecondw)\n  - [apW](#apw)\n  - [bracket](#bracket)\n  - [bracketW](#bracketw)\n  - [local](#local)\n  - [swap](#swap)\n  - [throwError](#throwerror)\n- [zone of death](#zone-of-death)\n  - [~~getApplyMonoid~~](#getapplymonoid)\n  - [~~getApplySemigroup~~](#getapplysemigroup)\n  - [~~getSemigroup~~](#getsemigroup)\n  - [~~readerTaskEitherSeq~~](#readertaskeitherseq)\n  - [~~readerTaskEither~~](#readertaskeither)\n  - [~~run~~](#run)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <R1, E1, A, R2, E2, _>(self: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderTaskEither<R2, E2, _>): ReaderTaskEither<\n    R1 & R2,\n    E1 | E2,\n    A\n  >\n  <A, R2, E2, _>(f: (a: A) => ReaderTaskEither<R2, E2, _>): <R1, E1>(\n    self: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E2 | E1, A>\n}\n```\n\nAdded in v2.15.0\n\n## tapEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapEither: {\n  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <R, E1>(self: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, A>\n  <R, E1, A, E2, _>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => E.Either<E2, _>): ReaderTaskEither<R, E1 | E2, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as RTE from 'fp-ts/ReaderTaskEither'\n\nconst checkString = (value: string) =>\n  pipe(\n    RTE.ask<number>(),\n    RTE.tapEither((minLength) => (value.length > minLength ? E.right('ok') : E.left('error')))\n  )\n\nasync function test() {\n  assert.deepStrictEqual(await checkString('')(2)(), E.left('error'))\n  assert.deepStrictEqual(await checkString('fp-ts')(2)(), E.right(2))\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## tapIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n  <R, E, A, _>(self: ReaderTaskEither<R, E, A>, f: (a: A) => IO<_>): ReaderTaskEither<R, E, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as RTE from 'fp-ts/ReaderTaskEither'\nimport * as E from 'fp-ts/Either'\nimport * as Console from 'fp-ts/Console'\n\n// Will produce `Hello, fp-ts` to the stdout\nconst effect = RTE.tapIO(RTE.ask<string>(), (value) => Console.log(`Hello, ${value}`))\n\nasync function test() {\n  assert.deepStrictEqual(await effect('fp-ts')(), E.of('fp-ts'))\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## tapReader\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapReader: {\n  <A, R2, _>(f: (a: A) => R.Reader<R2, _>): <R1, E>(self: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A>\n  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => R.Reader<R2, _>): ReaderTaskEither<R1 & R2, E, A>\n}\n```\n\nAdded in v2.16.0\n\n## tapReaderEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapReaderEither: {\n  <A, R2, E2, _>(f: (a: A) => ReaderEither<R2, E2, _>): <R1, E1>(\n    self: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E2 | E1, A>\n  <R1, E1, A, R2, E2, _>(self: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, _>): ReaderTaskEither<\n    R1 & R2,\n    E1 | E2,\n    A\n  >\n}\n```\n\nAdded in v2.16.0\n\n## tapReaderIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapReaderIO: {\n  <A, R2, _>(f: (a: A) => RIO.ReaderIO<R2, _>): <R1, E>(\n    self: ReaderTaskEither<R1, E, A>\n  ) => ReaderTaskEither<R1 & R2, E, A>\n  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => RIO.ReaderIO<R2, _>): ReaderTaskEither<R1 & R2, E, A>\n}\n```\n\nAdded in v2.16.0\n\n## tapReaderTask\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapReaderTask: {\n  <A, R2, _>(f: (a: A) => RT.ReaderTask<R2, _>): <R1, E>(\n    self: ReaderTaskEither<R1, E, A>\n  ) => ReaderTaskEither<R1 & R2, E, A>\n  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => RT.ReaderTask<R2, _>): ReaderTaskEither<\n    R1 & R2,\n    E,\n    A\n  >\n}\n```\n\nAdded in v2.16.0\n\n## tapTask\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapTask: {\n  <A, _>(f: (a: A) => T.Task<_>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n  <R, E, A, _>(self: ReaderTaskEither<R, E, A>, f: (a: A) => T.Task<_>): ReaderTaskEither<R, E, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as RTE from 'fp-ts/ReaderTaskEither'\nimport * as E from 'fp-ts/Either'\nimport * as T from 'fp-ts/Task'\n\nconst effect = RTE.tapTask(RTE.ask<number>(), (value) => T.of(value + 1))\n\nasync function test() {\n  assert.deepStrictEqual(await effect(1)(), E.of(1))\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## tapTaskEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapTaskEither: {\n  <A, E2, _>(f: (a: A) => TE.TaskEither<E2, _>): <R, E1>(\n    self: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E2 | E1, A>\n  <R, E1, A, E2, _>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => TE.TaskEither<E2, _>): ReaderTaskEither<\n    R,\n    E1 | E2,\n    A\n  >\n}\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## ask\n\nReads the current context.\n\n**Signature**\n\n```ts\nexport declare const ask: <R, E = never>() => ReaderTaskEither<R, E, R>\n```\n\nAdded in v2.0.0\n\n## asks\n\nProjects a value from the global context in a `ReaderEither`.\n\n**Signature**\n\n```ts\nexport declare const asks: <R, A, E = never>(f: (r: R) => A) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## asksReaderTaskEither\n\nEffectfully accesses the environment.\n\n**Signature**\n\n```ts\nexport declare const asksReaderTaskEither: <R, E, A>(\n  f: (r: R) => ReaderTaskEither<R, E, A>\n) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## asksReaderTaskEitherW\n\nLess strict version of [`asksReaderTaskEither`](#asksreadertaskeither).\n\nThe `W` suffix (short for **W**idening) means that the environment types will be merged.\n\n**Signature**\n\n```ts\nexport declare const asksReaderTaskEitherW: <R1, R2, E, A>(\n  f: (r1: R1) => ReaderTaskEither<R2, E, A>\n) => ReaderTaskEither<R1 & R2, E, A>\n```\n\nAdded in v2.11.0\n\n## left\n\n**Signature**\n\n```ts\nexport declare const left: <R, E = never, A = never>(e: E) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## leftIO\n\n**Signature**\n\n```ts\nexport declare const leftIO: <R, E = never, A = never>(me: IO<E>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## leftReader\n\n**Signature**\n\n```ts\nexport declare const leftReader: <R, E = never, A = never>(me: R.Reader<R, E>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## leftReaderIO\n\n**Signature**\n\n```ts\nexport declare const leftReaderIO: <R, E = never, A = never>(me: RIO.ReaderIO<R, E>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.13.0\n\n## leftReaderTask\n\n**Signature**\n\n```ts\nexport declare const leftReaderTask: <R, E = never, A = never>(me: RT.ReaderTask<R, E>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.5.0\n\n## leftTask\n\n**Signature**\n\n```ts\nexport declare const leftTask: <R, E = never, A = never>(me: T.Task<E>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <R = unknown, E = never, A = never>(a: A) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.7.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare const right: <R, E = never, A = never>(a: A) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## rightIO\n\n**Signature**\n\n```ts\nexport declare const rightIO: <R, E = never, A = never>(ma: IO<A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## rightReader\n\n**Signature**\n\n```ts\nexport declare const rightReader: <R, E = never, A = never>(ma: R.Reader<R, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## rightReaderIO\n\n**Signature**\n\n```ts\nexport declare const rightReaderIO: <R, E = never, A = never>(ma: RIO.ReaderIO<R, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.13.0\n\n## rightReaderTask\n\n**Signature**\n\n```ts\nexport declare const rightReaderTask: <R, E = never, A = never>(ma: RT.ReaderTask<R, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.5.0\n\n## rightTask\n\n**Signature**\n\n```ts\nexport declare const rightTask: <R, E = never, A = never>(ma: T.Task<A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <E, A, R = unknown>(fa: E.Either<E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A, R = unknown, E = never>(fa: IO<A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromIOEither\n\n**Signature**\n\n```ts\nexport declare const fromIOEither: <E, A, R = unknown>(fa: IOEither<E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromNullable\n\n**Signature**\n\n```ts\nexport declare const fromNullable: <E>(e: E) => <R, A>(a: A) => ReaderTaskEither<R, E, NonNullable<A>>\n```\n\nAdded in v2.12.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <E>(onNone: LazyArg<E>) => <A, R = unknown>(fa: Option<A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromReader\n\n**Signature**\n\n```ts\nexport declare const fromReader: <R, A, E = never>(fa: R.Reader<R, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## fromReaderEither\n\n**Signature**\n\n```ts\nexport declare const fromReaderEither: <R, E, A>(fa: ReaderEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromTask\n\n**Signature**\n\n```ts\nexport declare const fromTask: <A, R = unknown, E = never>(fa: T.Task<A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromTaskEither\n\n**Signature**\n\n```ts\nexport declare const fromTaskEither: <E, A, R = unknown>(fa: TE.TaskEither<E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## toUnion\n\n**Signature**\n\n```ts\nexport declare const toUnion: <R, E, A>(fa: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, E | A>\n```\n\nAdded in v2.10.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: ReaderTaskEither<unknown, never, {}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, R, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderTaskEither<R, E, B>\n) => (\n  fa: ReaderTaskEither<R, E, A>\n) => ReaderTaskEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## apSW\n\nLess strict version of [`apS`](#aps).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSW: <A, N extends string, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderTaskEither<R2, E2, B>\n) => <R1, E1>(\n  fa: ReaderTaskEither<R1, E1, A>\n) => ReaderTaskEither<R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, R, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderTaskEither<R, E, B>\n) => (\n  ma: ReaderTaskEither<R, E, A>\n) => ReaderTaskEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(\n  name: N\n) => <R, E, A>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, { readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## bindW\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bindW: <N extends string, A, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderTaskEither<R2, E2, B>\n) => <R1, E1>(\n  fa: ReaderTaskEither<R1, E1, A>\n) => ReaderTaskEither<R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <R, E>(\n  fa: ReaderTaskEither<R, E, A>\n) => ReaderTaskEither<R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\n**Signature**\n\n```ts\nexport declare const alt: <R, E, A>(\n  that: () => ReaderTaskEither<R, E, A>\n) => (fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <R2, E2, B>(\n  that: () => ReaderTaskEither<R2, E2, B>\n) => <R1, E1, A>(fa: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2, B | A>\n```\n\nAdded in v2.9.0\n\n## getAltReaderTaskValidation\n\nThe default [`Alt`](#alt) instance returns the last error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\nSee [`getAltValidation`](./Either.ts.html#getaltvalidation).\n\n**Signature**\n\n```ts\nexport declare function getAltReaderTaskValidation<E>(S: Semigroup<E>): Alt3C<URI, E>\n```\n\nAdded in v2.7.0\n\n## getApplicativeReaderTaskValidation\n\nThe default [`ApplicativePar`](#applicativepar) instance returns the first error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\nSee [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation).\n\n**Signature**\n\n```ts\nexport declare function getApplicativeReaderTaskValidation<E>(A: Apply1<T.URI>, S: Semigroup<E>): Applicative3C<URI, E>\n```\n\nAdded in v2.7.0\n\n## getOrElse\n\n**Signature**\n\n```ts\nexport declare const getOrElse: <R, E, A>(\n  onLeft: (e: E) => RT.ReaderTask<R, A>\n) => (ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, A>\n```\n\nAdded in v2.0.0\n\n## getOrElseW\n\nLess strict version of [`getOrElse`](#getorelse).\n\nThe `W` suffix (short for **W**idening) means that the handler return type will be merged.\n\n**Signature**\n\n```ts\nexport declare const getOrElseW: <R2, E, B>(\n  onLeft: (e: E) => RT.ReaderTask<R2, B>\n) => <R1, A>(ma: ReaderTaskEither<R1, E, A>) => RT.ReaderTask<R1 & R2, B | A>\n```\n\nAdded in v2.6.0\n\n## mapBoth\n\nReturns a `ReaderTaskEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`.\n\n**Signature**\n\n```ts\nexport declare const mapBoth: {\n  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): <R>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, B>\n  <R, E, A, G, B>(self: ReaderTaskEither<R, E, A>, f: (e: E) => G, g: (a: A) => B): ReaderTaskEither<R, G, B>\n}\n```\n\n**Example**\n\n```ts\nimport * as ReaderTaskEither from 'fp-ts/ReaderTaskEither'\nimport * as Either from 'fp-ts/Either'\n\nconst f = (s: string) => new Error(s)\nconst g = (n: number) => n * 2\n\nasync function test() {\n  assert.deepStrictEqual(await ReaderTaskEither.mapBoth(ReaderTaskEither.right(1), f, g)({})(), Either.right(2))\n  assert.deepStrictEqual(\n    await ReaderTaskEither.mapBoth(ReaderTaskEither.left('err'), f, g)({})(),\n    Either.left(new Error('err'))\n  )\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## mapError\n\nReturns a `ReaderTaskEither` with its error channel mapped using the specified function.\n\n**Signature**\n\n```ts\nexport declare const mapError: {\n  <R, E, G>(f: (e: E) => G): <A>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, A>\n  <R, E, A, G>(self: ReaderTaskEither<R, E, A>, f: (e: E) => G): ReaderTaskEither<R, G, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as ReaderTaskEither from 'fp-ts/ReaderTaskEither'\nimport * as Either from 'fp-ts/Either'\n\nconst f = (s: string) => new Error(s)\n\nasync function test() {\n  assert.deepStrictEqual(await ReaderTaskEither.mapError(ReaderTaskEither.right(1), f)({})(), Either.right(1))\n  assert.deepStrictEqual(\n    await ReaderTaskEither.mapError(ReaderTaskEither.left('err'), f)({})(),\n    Either.left(new Error('err'))\n  )\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## orElse\n\n**Signature**\n\n```ts\nexport declare const orElse: <R, E1, A, E2>(\n  onLeft: (e: E1) => ReaderTaskEither<R, E2, A>\n) => (ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2, A>\n```\n\nAdded in v2.0.0\n\n## orElseW\n\nLess strict version of [`orElse`](#orelse).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const orElseW: <E1, R1, E2, B>(\n  onLeft: (e: E1) => ReaderTaskEither<R1, E2, B>\n) => <R2, A>(ma: ReaderTaskEither<R2, E1, A>) => ReaderTaskEither<R1 & R2, E2, B | A>\n```\n\nAdded in v2.10.0\n\n## orLeft\n\n**Signature**\n\n```ts\nexport declare const orLeft: <E1, R, E2>(\n  onLeft: (e: E1) => RT.ReaderTask<R, E2>\n) => <A>(fa: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2, A>\n```\n\nAdded in v2.11.0\n\n## orLeftW\n\n**Signature**\n\n```ts\nexport declare const orLeftW: <E1, R2, E2>(\n  onLeft: (e: E1) => RT.ReaderTask<R2, E2>\n) => <R1, A>(fa: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2, A>\n```\n\nAdded in v2.16.6\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, R2, E2, _>(onLeft: (e: E1) => ReaderTaskEither<R2, E2, _>): <R1, A>(\n    self: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E1 | E2, A>\n  <R1, E1, A, R2, E2, _>(\n    self: ReaderTaskEither<R1, E1, A>,\n    onLeft: (e: E1) => ReaderTaskEither<R2, E2, _>\n  ): ReaderTaskEither<R1 & R2, E1 | E2, A>\n}\n```\n\nAdded in v2.15.0\n\n# filtering\n\n## filterOrElse\n\n**Signature**\n\n```ts\nexport declare const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n    ma: ReaderTaskEither<R, E, A>\n  ) => ReaderTaskEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(\n    mb: ReaderTaskEither<R, E, B>\n  ) => ReaderTaskEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## filterOrElseW\n\nLess strict version of [`filterOrElse`](#filterorelse).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <R, E1>(\n    ma: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1, B extends A>(\n    mb: ReaderTaskEither<R, E1, B>\n  ) => ReaderTaskEither<R, E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1>(\n    ma: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E2 | E1, A>\n}\n```\n\nAdded in v2.9.0\n\n## getCompactable\n\n**Signature**\n\n```ts\nexport declare const getCompactable: <E>(M: Monoid<E>) => Compactable3C<'ReaderTaskEither', E>\n```\n\nAdded in v2.10.0\n\n## getFilterable\n\n**Signature**\n\n```ts\nexport declare function getFilterable<E>(M: Monoid<E>): Filterable3C<URI, E>\n```\n\nAdded in v2.10.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt3<'ReaderTaskEither'>\n```\n\nAdded in v2.7.0\n\n## ApplicativePar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplicativePar: Applicative3<'ReaderTaskEither'>\n```\n\nAdded in v2.7.0\n\n## ApplicativeSeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplicativeSeq: Applicative3<'ReaderTaskEither'>\n```\n\nAdded in v2.7.0\n\n## ApplyPar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplyPar: Apply3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## ApplySeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplySeq: Apply3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor3<'ReaderTaskEither'>\n```\n\nAdded in v2.7.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## FromReader\n\n**Signature**\n\n```ts\nexport declare const FromReader: FromReader3<'ReaderTaskEither'>\n```\n\nAdded in v2.11.0\n\n## FromTask\n\n**Signature**\n\n```ts\nexport declare const FromTask: FromTask3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor3<'ReaderTaskEither'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## MonadTask\n\n**Signature**\n\n```ts\nexport declare const MonadTask: MonadTask3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## MonadThrow\n\n**Signature**\n\n```ts\nexport declare const MonadThrow: MonadThrow3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed3<'ReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## ~~getReaderTaskValidation~~\n\nUse [`getApplicativeReaderTaskValidation`](#getapplicativereadertaskvalidation) and [`getAltReaderTaskValidation`](#getaltreadertaskvalidation) instead.\n\n**Signature**\n\n```ts\nexport declare function getReaderTaskValidation<E>(\n  SE: Semigroup<E>\n): Monad3C<URI, E> & Bifunctor3<URI> & Alt3C<URI, E> & MonadTask3C<URI, E> & MonadThrow3C<URI, E>\n```\n\nAdded in v2.3.0\n\n# legacy\n\n## bimap\n\nAlias of `mapBoth`.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, B>\n```\n\nAdded in v2.0.0\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <R, E, A, B>(\n  f: (a: A) => ReaderTaskEither<R, E, B>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.0.0\n\n## chainEitherK\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherK: <E, A, B>(\n  f: (a: A) => E.Either<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.4.0\n\n## chainEitherKW\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherKW: <E2, A, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <R, E, A, B>(\n  f: (a: A) => ReaderTaskEither<R, E, B>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## chainFirstEitherK\n\nAlias of `tapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherK: <A, E, B>(\n  f: (a: A) => E.Either<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstEitherKW\n\nAlias of `tapEither`.\n\nLess strict version of [`chainFirstEitherK`](#chainfirsteitherk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstIOK\n\nAlias of `tapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstIOK: <A, B>(\n  f: (a: A) => IO<B>\n) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.10.0\n\n## chainFirstReaderEitherK\n\nAlias of `tapReaderEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderEitherK: <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstReaderEitherKW\n\nAlias of `tapReaderEither`.\n\nLess strict version of [`chainFirstReaderEitherK`](#chainfirstreadereitherk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderEitherKW: <R2, E2, A, B>(\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstReaderIOK\n\nAlias of `tapReaderIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderIOK: <A, R, B>(\n  f: (a: A) => RIO.ReaderIO<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.13.0\n\n## chainFirstReaderIOKW\n\nAlias of `tapReaderIO`.\n\nLess strict version of [`chainFirstReaderIOK`](#chainfirstreaderiok).\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderIOKW: <A, R2, B>(\n  f: (a: A) => RIO.ReaderIO<R2, B>\n) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A>\n```\n\nAdded in v2.13.0\n\n## chainFirstReaderK\n\nAlias of `tapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderK: <A, R, B>(\n  f: (a: A) => R.Reader<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstReaderKW\n\nAlias of `tapReader`.\n\nLess strict version of [`chainFirstReaderK`](#chainfirstreaderk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2, E>(ma: ReaderTaskEither<R2, E, A>) => ReaderTaskEither<R1 & R2, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstReaderTaskK\n\nAlias of `tapReaderTask`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderTaskK: <A, R, B>(\n  f: (a: A) => RT.ReaderTask<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstReaderTaskKW\n\nAlias of `tapReaderTask`.\n\nLess strict version of [`chainFirstReaderTaskK`](#chainfirstreadertaskk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderTaskKW: <A, R2, B>(\n  f: (a: A) => RT.ReaderTask<R2, B>\n) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstTaskEitherK\n\nAlias of `tapTaskEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstTaskEitherK: <E, A, B>(\n  f: (a: A) => TE.TaskEither<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstTaskEitherKW\n\nAlias of `tapTaskEither`.\n\nLess strict version of [`chainFirstTaskEitherK`](#chainfirsttaskeitherk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstTaskEitherKW: <E2, A, B>(\n  f: (a: A) => TE.TaskEither<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstTaskK\n\nAlias of `tapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstTaskK: <A, B>(\n  f: (a: A) => T.Task<B>\n) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.10.0\n\n## chainFirstW\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstW: <R2, E2, A, B>(\n  f: (a: A) => ReaderTaskEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, A>\n```\n\nAdded in v2.8.0\n\n## chainIOEitherK\n\nAlias of `flatMapIOEither`.\n\n**Signature**\n\n```ts\nexport declare const chainIOEitherK: <E, A, B>(\n  f: (a: A) => IOEither<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.4.0\n\n## chainIOEitherKW\n\nAlias of `flatMapIOEither`.\n\nLess strict version of [`chainIOEitherK`](#chainioeitherk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainIOEitherKW: <E2, A, B>(\n  f: (a: A) => IOEither<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainIOK\n\nAlias of `flatMapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainIOK: <A, B>(\n  f: (a: A) => IO<B>\n) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.10.0\n\n## chainNullableK\n\nUse `flatMapNullable`.\n\n**Signature**\n\n```ts\nexport declare const chainNullableK: <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, NonNullable<B>>\n```\n\nAdded in v2.12.0\n\n## chainOptionK\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.10.0\n\n## chainOptionKW\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>\n```\n\nAdded in v2.13.2\n\n## chainReaderEitherK\n\nAlias of `flatMapReaderEither`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderEitherK: <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.11.0\n\n## chainReaderEitherKW\n\nAlias of `flatMapReaderEither`.\n\nLess strict version of [`chainReaderEitherK`](#chainreadereitherk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainReaderEitherKW: <R2, E2, A, B>(\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.11.0\n\n## chainReaderIOK\n\nAlias of `flatMapReaderIO`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderIOK: <A, R, B>(\n  f: (a: A) => RIO.ReaderIO<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.13.0\n\n## chainReaderIOKW\n\nAlias of `flatMapReaderIO`.\n\nLess strict version of [`chainReaderIOK`](#chainreaderiok).\n\n**Signature**\n\n```ts\nexport declare const chainReaderIOKW: <A, R2, B>(\n  f: (a: A) => RIO.ReaderIO<R2, B>\n) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B>\n```\n\nAdded in v2.13.0\n\n## chainReaderK\n\nAlias of `flatMapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderK: <A, R, B>(\n  f: (a: A) => R.Reader<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.11.0\n\n## chainReaderKW\n\nAlias of `flatMapReader`.\n\nLess strict version of [`chainReaderK`](#chainreaderk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2, E>(ma: ReaderTaskEither<R2, E, A>) => ReaderTaskEither<R1 & R2, E, B>\n```\n\nAdded in v2.11.0\n\n## chainReaderTaskK\n\nAlias of `flatMapReaderTask`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderTaskK: <A, R, B>(\n  f: (a: A) => RT.ReaderTask<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.11.0\n\n## chainReaderTaskKW\n\nAlias of `flatMapReaderTask`.\n\nLess strict version of [`chainReaderTaskK`](#chainreadertaskk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainReaderTaskKW: <A, R2, B>(\n  f: (a: A) => RT.ReaderTask<R2, B>\n) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B>\n```\n\nAdded in v2.11.0\n\n## chainTaskEitherK\n\nAlias of `flatMapTaskEither`.\n\n**Signature**\n\n```ts\nexport declare const chainTaskEitherK: <E, A, B>(\n  f: (a: A) => TE.TaskEither<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.4.0\n\n## chainTaskEitherKW\n\nAlias of `flatMapTaskEither`.\n\nLess strict version of [`chainTaskEitherK`](#chaintaskeitherk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainTaskEitherKW: <E2, A, B>(\n  f: (a: A) => TE.TaskEither<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainTaskK\n\nAlias of `flatMapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainTaskK: <A, B>(\n  f: (a: A) => T.Task<B>\n) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.10.0\n\n## chainW\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chainW: <R2, E2, A, B>(\n  f: (a: A) => ReaderTaskEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.6.0\n\n## fromNullableK\n\nUse `liftNullable`.\n\n**Signature**\n\n```ts\nexport declare const fromNullableK: <E>(\n  e: E\n) => <A extends readonly unknown[], B>(\n  f: (...a: A) => B | null | undefined\n) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, NonNullable<B>>\n```\n\nAdded in v2.12.0\n\n## fromOptionK\n\nUse `liftOption`.\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.10.0\n\n## mapLeft\n\nAlias of `mapError`.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(\n  f: (e: E) => G\n) => <R, A>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, A>\n```\n\nAdded in v2.0.0\n\n## orElseFirst\n\nAlias of `tapError`.\n\n**Signature**\n\n```ts\nexport declare const orElseFirst: <E, R, B>(\n  onLeft: (e: E) => ReaderTaskEither<R, E, B>\n) => <A>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.11.0\n\n## orElseFirstW\n\nAlias of `tapError`.\n\n**Signature**\n\n```ts\nexport declare const orElseFirstW: <E1, R2, E2, B>(\n  onLeft: (e: E1) => ReaderTaskEither<R2, E2, B>\n) => <R1, A>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => E.Either<E, B>\n) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.4.0\n\n## fromIOEitherK\n\n**Signature**\n\n```ts\nexport declare const fromIOEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => IOEither<E, B>\n) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.4.0\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(\n  f: (...a: A) => IO<B>\n) => <R = unknown, E = never>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.10.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R = unknown>(\n    a: A\n  ) => ReaderTaskEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown, B extends A = A>(\n    b: B\n  ) => ReaderTaskEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderTaskEither<R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## fromReaderEitherK\n\n**Signature**\n\n```ts\nexport declare const fromReaderEitherK: <R, E, A extends readonly unknown[], B>(\n  f: (...a: A) => ReaderEither<R, E, B>\n) => (...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.11.0\n\n## fromReaderIOK\n\n**Signature**\n\n```ts\nexport declare const fromReaderIOK: <A extends readonly unknown[], R, B>(\n  f: (...a: A) => RIO.ReaderIO<R, B>\n) => <E = never>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.13.0\n\n## fromReaderK\n\n**Signature**\n\n```ts\nexport declare const fromReaderK: <A extends readonly unknown[], R, B>(\n  f: (...a: A) => R.Reader<R, B>\n) => <E = never>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.11.0\n\n## fromReaderTaskK\n\n**Signature**\n\n```ts\nexport declare const fromReaderTaskK: <A extends readonly unknown[], R, B>(\n  f: (...a: A) => RT.ReaderTask<R, B>\n) => <E = never>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.11.0\n\n## fromTaskEitherK\n\n**Signature**\n\n```ts\nexport declare const fromTaskEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => TE.TaskEither<E, B>\n) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.4.0\n\n## fromTaskK\n\n**Signature**\n\n```ts\nexport declare const fromTaskK: <A extends readonly unknown[], B>(\n  f: (...a: A) => T.Task<B>\n) => <R = unknown, E = never>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.10.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) => <R>(...a: A) => ReaderTaskEither<R, E, NonNullable<B>>\n```\n\nAdded in v2.15.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) => <R>(...a: A) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.15.0\n\n# mapping\n\n## as\n\nMaps the `Right` value of this `ReaderTaskEither` to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <R, E, _>(self: ReaderTaskEither<R, E, _>) => ReaderTaskEither<R, E, A>\n  <R, E, _, A>(self: ReaderTaskEither<R, E, _>, a: A): ReaderTaskEither<R, E, A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the `Right` value of this `ReaderTaskEither` to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <R, E, _>(self: ReaderTaskEither<R, E, _>) => ReaderTaskEither<R, E, void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <R, E, B>(fab: ReaderTaskEither<R, E, (a: A) => B>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <R, E>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## ReaderTaskEither (interface)\n\n**Signature**\n\n```ts\nexport interface ReaderTaskEither<R, E, A> {\n  (r: R): TaskEither<E, A>\n}\n```\n\nAdded in v2.0.0\n\n# pattern matching\n\n## fold\n\nAlias of [`matchE`](#matche).\n\n**Signature**\n\n```ts\nexport declare const fold: <R, E, A, B>(\n  onLeft: (e: E) => RT.ReaderTask<R, B>,\n  onRight: (a: A) => RT.ReaderTask<R, B>\n) => (ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, B>\n```\n\nAdded in v2.0.0\n\n## foldW\n\nAlias of [`matchEW`](#matchew).\n\n**Signature**\n\n```ts\nexport declare const foldW: <E, R2, B, A, R3, C>(\n  onLeft: (e: E) => RT.ReaderTask<R2, B>,\n  onRight: (a: A) => RT.ReaderTask<R3, C>\n) => <R1>(ma: ReaderTaskEither<R1, E, A>) => RT.ReaderTask<R1 & R2 & R3, B | C>\n```\n\nAdded in v2.10.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B\n) => <R>(ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, B>\n```\n\nAdded in v2.10.0\n\n## matchE\n\nThe `E` suffix (short for **E**ffect) means that the handlers return an effect (`ReaderTask`).\n\n**Signature**\n\n```ts\nexport declare const matchE: <R, E, A, B>(\n  onLeft: (e: E) => RT.ReaderTask<R, B>,\n  onRight: (a: A) => RT.ReaderTask<R, B>\n) => (ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, B>\n```\n\nAdded in v2.10.0\n\n## matchEW\n\nLess strict version of [`matchE`](#matche).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchEW: <E, R2, B, A, R3, C>(\n  onLeft: (e: E) => RT.ReaderTask<R2, B>,\n  onRight: (a: A) => RT.ReaderTask<R3, C>\n) => <R1>(ma: ReaderTaskEither<R1, E, A>) => RT.ReaderTask<R1 & R2 & R3, B | C>\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <E, B, A, C>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C\n) => <R>(ma: ReaderTaskEither<R, E, A>) => RT.ReaderTask<R, B | C>\n```\n\nAdded in v2.10.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, R2, E2, B>(f: (a: A) => ReaderTaskEither<R2, E2, B>): <R1, E1>(\n    ma: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E2 | E1, B>\n  <R1, E1, A, R2, E2, B>(ma: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderTaskEither<R2, E2, B>): ReaderTaskEither<\n    R1 & R2,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v2.14.0\n\n## flatMapEither\n\n**Signature**\n\n```ts\nexport declare const flatMapEither: {\n  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <R, E1>(self: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>\n  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => E.Either<E2, B>): ReaderTaskEither<R, E1 | E2, B>\n}\n```\n\nAdded in v2.15.0\n\n## flatMapIO\n\n**Signature**\n\n```ts\nexport declare const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n  <R, E, A, B>(self: ReaderTaskEither<R, E, A>, f: (a: A) => IO<B>): ReaderTaskEither<R, E, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapIOEither\n\n**Signature**\n\n```ts\nexport declare const flatMapIOEither: {\n  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <R, E1>(self: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2 | E1, B>\n  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => IOEither<E2, B>): ReaderTaskEither<R, E1 | E2, B>\n}\n```\n\nAdded in v2.16.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): <R, E1>(\n    self: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E2 | E1, NonNullable<B>>\n  <R, E1, A, B, E2>(\n    self: ReaderTaskEither<R, E1, A>,\n    f: (a: A) => B | null | undefined,\n    onNullable: (a: A) => E2\n  ): ReaderTaskEither<R, E1 | E2, NonNullable<B>>\n}\n```\n\nAdded in v2.15.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): <R, E1>(\n    self: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E2 | E1, B>\n  <R, E1, A, B, E2>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): ReaderTaskEither<\n    R,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v2.15.0\n\n## flatMapReader\n\n**Signature**\n\n```ts\nexport declare const flatMapReader: {\n  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <R1, E>(self: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B>\n  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => R.Reader<R2, B>): ReaderTaskEither<R1 & R2, E, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapReaderEither\n\n**Signature**\n\n```ts\nexport declare const flatMapReaderEither: {\n  <A, R2, E2, B>(f: (a: A) => ReaderEither<R2, E2, B>): <R1, E1>(\n    self: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E2 | E1, B>\n  <R1, E1, A, R2, E2, B>(self: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, B>): ReaderTaskEither<\n    R1 & R2,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v2.16.0\n\n## flatMapReaderIO\n\n**Signature**\n\n```ts\nexport declare const flatMapReaderIO: {\n  <A, R2, B>(f: (a: A) => RIO.ReaderIO<R2, B>): <R1, E>(\n    self: ReaderTaskEither<R1, E, A>\n  ) => ReaderTaskEither<R1 & R2, E, B>\n  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => RIO.ReaderIO<R2, B>): ReaderTaskEither<R1 & R2, E, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapReaderTask\n\n**Signature**\n\n```ts\nexport declare const flatMapReaderTask: {\n  <A, R2, B>(f: (a: A) => RT.ReaderTask<R2, B>): <R1, E>(\n    self: ReaderTaskEither<R1, E, A>\n  ) => ReaderTaskEither<R1 & R2, E, B>\n  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => RT.ReaderTask<R2, B>): ReaderTaskEither<\n    R1 & R2,\n    E,\n    B\n  >\n}\n```\n\nAdded in v2.16.0\n\n## flatMapTask\n\n**Signature**\n\n```ts\nexport declare const flatMapTask: {\n  <A, B>(f: (a: A) => T.Task<B>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n  <R, E, A, B>(self: ReaderTaskEither<R, E, A>, f: (a: A) => T.Task<B>): ReaderTaskEither<R, E, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapTaskEither\n\n**Signature**\n\n```ts\nexport declare const flatMapTaskEither: {\n  <A, E2, B>(f: (a: A) => TE.TaskEither<E2, B>): <R, E1>(\n    self: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E2 | E1, B>\n  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => TE.TaskEither<E2, B>): ReaderTaskEither<\n    R,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v2.16.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <R, E, A>(\n  mma: ReaderTaskEither<R, E, ReaderTaskEither<R, E, A>>\n) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## flattenW\n\nLess strict version of [`flatten`](#flatten).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const flattenW: <R1, E1, R2, E2, A>(\n  mma: ReaderTaskEither<R1, E1, ReaderTaskEither<R2, E2, A>>\n) => ReaderTaskEither<R1 & R2, E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <R, E, A>(\n  arr: readonly ReaderTaskEither<R, E, A>[]\n) => ReaderTaskEither<R, E, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## sequenceSeqArray\n\nEquivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceSeqArray: <R, E, A>(\n  arr: readonly ReaderTaskEither<R, E, A>[]\n) => ReaderTaskEither<R, E, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <R, E, A, B>(\n  f: (a: A) => ReaderTaskEither<R, E, B>\n) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <R, E, A, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, R, E, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyArrayWithIndexSeq\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndexSeq: <A, R, E, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, R, E, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => ReaderTaskEither<R, E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndexSeq\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, R, E, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => ReaderTaskEither<R, E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseSeqArray\n\nEquivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArray: <R, E, A, B>(\n  f: (a: A) => ReaderTaskEither<R, E, B>\n) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseSeqArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArrayWithIndex: <R, E, A, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n) => (as: readonly A[]) => ReaderTaskEither<R, E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReaderTaskEither'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: ReaderTaskEither<unknown, never, readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <R, E, A>(\n  fa: ReaderTaskEither<R, E, A>\n) => <B>(fab: ReaderTaskEither<R, E, (a: A) => B>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <R, E, B>(\n  second: ReaderTaskEither<R, E, B>\n) => <A>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## apFirstW\n\nLess strict version of [`apFirst`](#apfirst).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apFirstW: <R2, E2, B>(\n  second: ReaderTaskEither<R2, E2, B>\n) => <R1, E1, A>(first: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <R, E, B>(\n  second: ReaderTaskEither<R, E, B>\n) => <A>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.0.0\n\n## apSecondW\n\nLess strict version of [`apSecond`](#apsecond).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSecondW: <R2, E2, B>(\n  second: ReaderTaskEither<R2, E2, B>\n) => <R1, E1, A>(first: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.12.0\n\n## apW\n\nLess strict version of [`ap`](#ap).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apW: <R2, E2, A>(\n  fa: ReaderTaskEither<R2, E2, A>\n) => <R1, E1, B>(fab: ReaderTaskEither<R1, E1, (a: A) => B>) => ReaderTaskEither<R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.8.0\n\n## bracket\n\nMake sure that a resource is cleaned up in the event of an exception (\\*). The release action is called regardless of\nwhether the body action throws (\\*) or returns.\n\n(\\*) i.e. returns a `Left`\n\n**Signature**\n\n```ts\nexport declare function bracket<R, E, A, B>(\n  acquire: ReaderTaskEither<R, E, A>,\n  use: (a: A) => ReaderTaskEither<R, E, B>,\n  release: (a: A, e: Either<E, B>) => ReaderTaskEither<R, E, void>\n): ReaderTaskEither<R, E, B>\n```\n\nAdded in v2.0.4\n\n## bracketW\n\nLess strict version of [`bracket`](#bracket).\n\n**Signature**\n\n```ts\nexport declare function bracketW<R1, E1, A, R2, E2, B, R3, E3>(\n  acquire: ReaderTaskEither<R1, E1, A>,\n  use: (a: A) => ReaderTaskEither<R2, E2, B>,\n  release: (a: A, e: Either<E2, B>) => ReaderTaskEither<R3, E3, void>\n): ReaderTaskEither<R1 & R2 & R3, E1 | E2 | E3, B>\n```\n\nAdded in v2.12.0\n\n## local\n\nChanges the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n`contramap`).\n\n**Signature**\n\n```ts\nexport declare const local: <R2, R1>(\n  f: (r2: R2) => R1\n) => <E, A>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R2, E, A>\n```\n\nAdded in v2.0.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare const swap: <R, E, A>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, A, E>\n```\n\nAdded in v2.0.0\n\n## throwError\n\n**Signature**\n\n```ts\nexport declare const throwError: <R, E, A>(e: E) => ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~getApplyMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplyMonoid: <R, E, A>(M: Monoid<A>) => Monoid<ReaderTaskEither<R, E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getApplySemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\nSemigroup returning the left-most `Left` value. If both operands are `Right`s then the inner values\nare concatenated using the provided `Semigroup`\n\n**Signature**\n\n```ts\nexport declare const getApplySemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderTaskEither<R, E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderTaskEither<R, E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~readerTaskEitherSeq~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RTE.Functor` instead of `RTE.readerTaskEitherSeq`\n(where `RTE` is from `import RTE from 'fp-ts/ReaderTaskEither'`)\n\n**Signature**\n\n```ts\nexport declare const readerTaskEitherSeq: Monad3<'ReaderTaskEither'> &\n  Bifunctor3<'ReaderTaskEither'> &\n  Alt3<'ReaderTaskEither'> &\n  MonadTask3<'ReaderTaskEither'> &\n  MonadThrow3<'ReaderTaskEither'>\n```\n\nAdded in v2.0.0\n\n## ~~readerTaskEither~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RTE.Functor` instead of `RTE.readerTaskEither`\n(where `RTE` is from `import RTE from 'fp-ts/ReaderTaskEither'`)\n\n**Signature**\n\n```ts\nexport declare const readerTaskEither: Monad3<'ReaderTaskEither'> &\n  Bifunctor3<'ReaderTaskEither'> &\n  Alt3<'ReaderTaskEither'> &\n  MonadTask3<'ReaderTaskEither'> &\n  MonadThrow3<'ReaderTaskEither'>\n```\n\nAdded in v2.0.0\n\n## ~~run~~\n\n**Signature**\n\n```ts\nexport declare function run<R, E, A>(ma: ReaderTaskEither<R, E, A>, r: R): Promise<Either<E, A>>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/ReadonlyArray.ts.md",
    "content": "---\ntitle: ReadonlyArray.ts\nnav_order: 83\nparent: Modules\n---\n\n## ReadonlyArray overview\n\nAdded in v2.5.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [makeBy](#makeby)\n  - [of](#of)\n  - [replicate](#replicate)\n- [conversions](#conversions)\n  - [fromArray](#fromarray)\n  - [fromEither](#fromeither)\n  - [fromOption](#fromoption)\n  - [toArray](#toarray)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [guard](#guard)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [filterMapWithIndex](#filtermapwithindex)\n  - [filterWithIndex](#filterwithindex)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [partitionMapWithIndex](#partitionmapwithindex)\n  - [partitionWithIndex](#partitionwithindex)\n  - [separate](#separate)\n  - [wilt](#wilt)\n  - [wither](#wither)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Alternative](#alternative)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [ChainRecBreadthFirst](#chainrecbreadthfirst)\n  - [ChainRecDepthFirst](#chainrecdepthfirst)\n  - [Compactable](#compactable)\n  - [Extend](#extend)\n  - [Filterable](#filterable)\n  - [FilterableWithIndex](#filterablewithindex)\n  - [Foldable](#foldable)\n  - [FoldableWithIndex](#foldablewithindex)\n  - [FromEither](#fromeither)\n  - [Functor](#functor)\n  - [FunctorWithIndex](#functorwithindex)\n  - [Monad](#monad)\n  - [Pointed](#pointed)\n  - [Traversable](#traversable)\n  - [TraversableWithIndex](#traversablewithindex)\n  - [Unfoldable](#unfoldable)\n  - [Witherable](#witherable)\n  - [Zero](#zero)\n  - [getDifferenceMagma](#getdifferencemagma)\n  - [getEq](#geteq)\n  - [getIntersectionSemigroup](#getintersectionsemigroup)\n  - [getMonoid](#getmonoid)\n  - [getOrd](#getord)\n  - [getSemigroup](#getsemigroup)\n  - [getShow](#getshow)\n  - [getUnionMonoid](#getunionmonoid)\n  - [getUnionSemigroup](#getunionsemigroup)\n- [legacy](#legacy)\n  - [chain](#chain)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromOptionK](#fromoptionk)\n  - [fromPredicate](#frompredicate)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n  - [mapWithIndex](#mapwithindex)\n- [pattern matching](#pattern-matching)\n  - [foldLeft](#foldleft)\n  - [foldRight](#foldright)\n  - [match](#match)\n  - [matchLeft](#matchleft)\n  - [matchLeftW](#matchleftw)\n  - [matchRight](#matchright)\n  - [matchRightW](#matchrightw)\n  - [matchW](#matchw)\n- [refinements](#refinements)\n  - [isEmpty](#isempty)\n  - [isNonEmpty](#isnonempty)\n- [sequencing](#sequencing)\n  - [chainFirst](#chainfirst)\n  - [chainRecBreadthFirst](#chainrecbreadthfirst)\n  - [chainRecDepthFirst](#chainrecdepthfirst)\n  - [chainWithIndex](#chainwithindex)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n  - [traverseWithIndex](#traversewithindex)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [unsafe](#unsafe)\n  - [unsafeDeleteAt](#unsafedeleteat)\n  - [unsafeInsertAt](#unsafeinsertat)\n  - [unsafeUpdateAt](#unsafeupdateat)\n- [utils](#utils)\n  - [Spanned (interface)](#spanned-interface)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [append](#append)\n  - [appendW](#appendw)\n  - [chop](#chop)\n  - [chunksOf](#chunksof)\n  - [comprehension](#comprehension)\n  - [concat](#concat)\n  - [concatW](#concatw)\n  - [deleteAt](#deleteat)\n  - [difference](#difference)\n  - [dropLeft](#dropleft)\n  - [dropLeftWhile](#dropleftwhile)\n  - [dropRight](#dropright)\n  - [duplicate](#duplicate)\n  - [elem](#elem)\n  - [empty](#empty)\n  - [every](#every)\n  - [exists](#exists)\n  - [extend](#extend)\n  - [filterE](#filtere)\n  - [findFirst](#findfirst)\n  - [findFirstMap](#findfirstmap)\n  - [findIndex](#findindex)\n  - [findLast](#findlast)\n  - [findLastIndex](#findlastindex)\n  - [findLastMap](#findlastmap)\n  - [head](#head)\n  - [init](#init)\n  - [insertAt](#insertat)\n  - [intercalate](#intercalate)\n  - [intersection](#intersection)\n  - [intersperse](#intersperse)\n  - [isOutOfBound](#isoutofbound)\n  - [last](#last)\n  - [lefts](#lefts)\n  - [lookup](#lookup)\n  - [modifyAt](#modifyat)\n  - [prepend](#prepend)\n  - [prependAll](#prependall)\n  - [prependW](#prependw)\n  - [reverse](#reverse)\n  - [rights](#rights)\n  - [rotate](#rotate)\n  - [scanLeft](#scanleft)\n  - [scanRight](#scanright)\n  - [size](#size)\n  - [some](#some)\n  - [sort](#sort)\n  - [sortBy](#sortby)\n  - [spanLeft](#spanleft)\n  - [splitAt](#splitat)\n  - [tail](#tail)\n  - [takeLeft](#takeleft)\n  - [takeLeftWhile](#takeleftwhile)\n  - [takeRight](#takeright)\n  - [unfold](#unfold)\n  - [union](#union)\n  - [uniq](#uniq)\n  - [unzip](#unzip)\n  - [updateAt](#updateat)\n  - [zero](#zero)\n  - [zip](#zip)\n  - [zipWith](#zipwith)\n- [zone of death](#zone-of-death)\n  - [~~cons~~](#cons)\n  - [~~prependToAll~~](#prependtoall)\n  - [~~range~~](#range)\n  - [~~readonlyArray~~](#readonlyarray)\n  - [~~snoc~~](#snoc)\n\n---\n\n# constructors\n\n## makeBy\n\nReturn a `ReadonlyArray` of length `n` with element `i` initialized with `f(i)`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const makeBy: <A>(n: number, f: (i: number) => A) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { makeBy } from 'fp-ts/ReadonlyArray'\n\nconst double = (n: number): number => n * 2\nassert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8])\n```\n\nAdded in v2.5.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => readonly A[]\n```\n\nAdded in v2.5.0\n\n## replicate\n\nCreate a `ReadonlyArray` containing a value repeated the specified number of times.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const replicate: <A>(n: number, a: A) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { replicate } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a'])\n```\n\nAdded in v2.5.0\n\n# conversions\n\n## fromArray\n\n**Signature**\n\n```ts\nexport declare const fromArray: <A>(as: A[]) => readonly A[]\n```\n\nAdded in v2.5.0\n\n## fromEither\n\nTransforms an `Either` to a `ReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const fromEither: <A>(fa: Either<unknown, A>) => readonly A[]\n```\n\nAdded in v2.11.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <A>(fa: Option<A>) => readonly A[]\n```\n\nAdded in v2.11.0\n\n## toArray\n\n**Signature**\n\n```ts\nexport declare const toArray: <A>(as: readonly A[]) => A[]\n```\n\nAdded in v2.5.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: readonly {}[]\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: readonly B[]\n) => (fa: readonly A[]) => readonly { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => readonly B[]\n) => (ma: readonly A[]) => readonly { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: readonly A[]) => readonly { readonly [K in N]: A }[]\n```\n\nAdded in v2.8.0\n\n## guard\n\n**Signature**\n\n```ts\nexport declare const guard: (b: boolean) => readonly void[]\n```\n\nAdded in v2.11.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: readonly A[]) => readonly { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }[]\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\nIn case of `ReadonlyArray` concatenates the inputs into a single array.\n\n**Signature**\n\n```ts\nexport declare const alt: <A>(that: LazyArg<readonly A[]>) => (fa: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    RA.alt(() => [4, 5])\n  ),\n  [1, 2, 3, 4, 5]\n)\n```\n\nAdded in v2.5.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <B>(that: LazyArg<readonly B[]>) => <A>(fa: readonly A[]) => readonly (B | A)[]\n```\n\n**Example**\n\n```ts\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    RA.altW(() => ['a', 'b'])\n  ),\n  [1, 2, 3, 'a', 'b']\n)\n```\n\nAdded in v2.9.0\n\n# filtering\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(fa: readonly Option<A>[]) => readonly A[]\n```\n\nAdded in v2.5.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (as: readonly A[]) => readonly B[]\n  <A>(predicate: Predicate<A>): <B extends A>(bs: readonly B[]) => readonly B[]\n  <A>(predicate: Predicate<A>): (as: readonly A[]) => readonly A[]\n}\n```\n\nAdded in v2.5.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: readonly A[]) => readonly B[]\n```\n\nAdded in v2.5.0\n\n## filterMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const filterMapWithIndex: <A, B>(f: (i: number, a: A) => Option<B>) => (fa: readonly A[]) => readonly B[]\n```\n\nAdded in v2.5.0\n\n## filterWithIndex\n\n**Signature**\n\n```ts\nexport declare const filterWithIndex: {\n  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (as: readonly A[]) => readonly B[]\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: readonly B[]) => readonly B[]\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: readonly A[]) => readonly A[]\n}\n```\n\nAdded in v2.5.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (as: readonly A[]) => Separated<readonly A[], readonly B[]>\n  <A>(predicate: Predicate<A>): <B extends A>(bs: readonly B[]) => Separated<readonly B[], readonly B[]>\n  <A>(predicate: Predicate<A>): (as: readonly A[]) => Separated<readonly A[], readonly A[]>\n}\n```\n\nAdded in v2.5.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: readonly A[]) => Separated<readonly B[], readonly C[]>\n```\n\nAdded in v2.5.0\n\n## partitionMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const partitionMapWithIndex: <A, B, C>(\n  f: (i: number, a: A) => Either<B, C>\n) => (fa: readonly A[]) => Separated<readonly B[], readonly C[]>\n```\n\nAdded in v2.5.0\n\n## partitionWithIndex\n\n**Signature**\n\n```ts\nexport declare const partitionWithIndex: {\n  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (\n    as: readonly A[]\n  ) => Separated<readonly A[], readonly B[]>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(\n    bs: readonly B[]\n  ) => Separated<readonly B[], readonly B[]>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: readonly A[]) => Separated<readonly A[], readonly A[]>\n}\n```\n\nAdded in v2.5.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare const separate: <A, B>(fa: readonly Either<A, B>[]) => Separated<readonly A[], readonly B[]>\n```\n\nAdded in v2.5.0\n\n## wilt\n\n**Signature**\n\n```ts\nexport declare const wilt: PipeableWilt1<'ReadonlyArray'>\n```\n\nAdded in v2.6.5\n\n## wither\n\n**Signature**\n\n```ts\nexport declare const wither: PipeableWither1<'ReadonlyArray'>\n```\n\nAdded in v2.6.5\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: readonly A[]) => M\n```\n\nAdded in v2.5.0\n\n## foldMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: number, a: A) => M) => (fa: readonly A[]) => M\n```\n\nAdded in v2.5.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: readonly A[]) => B\n```\n\nAdded in v2.5.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: readonly A[]) => B\n```\n\nAdded in v2.5.0\n\n## reduceRightWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceRightWithIndex: <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: readonly A[]) => B\n```\n\nAdded in v2.5.0\n\n## reduceWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceWithIndex: <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: readonly A[]) => B\n```\n\nAdded in v2.5.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## Alternative\n\n**Signature**\n\n```ts\nexport declare const Alternative: Alternative1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply1<'ReadonlyArray'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: Chain1<'ReadonlyArray'>\n```\n\nAdded in v2.10.0\n\n## ChainRecBreadthFirst\n\n**Signature**\n\n```ts\nexport declare const ChainRecBreadthFirst: ChainRec1<'ReadonlyArray'>\n```\n\nAdded in v2.11.0\n\n## ChainRecDepthFirst\n\n**Signature**\n\n```ts\nexport declare const ChainRecDepthFirst: ChainRec1<'ReadonlyArray'>\n```\n\nAdded in v2.11.0\n\n## Compactable\n\n**Signature**\n\n```ts\nexport declare const Compactable: Compactable1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## Extend\n\n**Signature**\n\n```ts\nexport declare const Extend: Extend1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: Filterable1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## FilterableWithIndex\n\n**Signature**\n\n```ts\nexport declare const FilterableWithIndex: FilterableWithIndex1<'ReadonlyArray', number>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## FoldableWithIndex\n\n**Signature**\n\n```ts\nexport declare const FoldableWithIndex: FoldableWithIndex1<'ReadonlyArray', number>\n```\n\nAdded in v2.7.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither1<'ReadonlyArray'>\n```\n\nAdded in v2.11.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## FunctorWithIndex\n\n**Signature**\n\n```ts\nexport declare const FunctorWithIndex: FunctorWithIndex1<'ReadonlyArray', number>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'ReadonlyArray'>\n```\n\nAdded in v2.10.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## TraversableWithIndex\n\n**Signature**\n\n```ts\nexport declare const TraversableWithIndex: TraversableWithIndex1<'ReadonlyArray', number>\n```\n\nAdded in v2.7.0\n\n## Unfoldable\n\n**Signature**\n\n```ts\nexport declare const Unfoldable: Unfoldable1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## Witherable\n\n**Signature**\n\n```ts\nexport declare const Witherable: Witherable1<'ReadonlyArray'>\n```\n\nAdded in v2.7.0\n\n## Zero\n\n**Signature**\n\n```ts\nexport declare const Zero: Zero1<'ReadonlyArray'>\n```\n\nAdded in v2.11.0\n\n## getDifferenceMagma\n\n**Signature**\n\n```ts\nexport declare const getDifferenceMagma: <A>(E: Eq<A>) => Magma<readonly A[]>\n```\n\nAdded in v2.11.0\n\n## getEq\n\nDerives an `Eq` over the `ReadonlyArray` of a given element type from the `Eq` of that type. The derived `Eq` defines two\narrays as equal if all elements of both arrays are compared equal pairwise with the given `E`. In case of arrays of\ndifferent lengths, the result is non equality.\n\n**Signature**\n\n```ts\nexport declare const getEq: <A>(E: Eq<A>) => Eq<readonly A[]>\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { getEq } from 'fp-ts/ReadonlyArray'\n\nconst E = getEq(S.Eq)\nassert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true)\nassert.strictEqual(E.equals(['a'], []), false)\n```\n\nAdded in v2.5.0\n\n## getIntersectionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getIntersectionSemigroup: <A>(E: Eq<A>) => Semigroup<readonly A[]>\n```\n\nAdded in v2.11.0\n\n## getMonoid\n\nReturns a `Monoid` for `ReadonlyArray<A>`.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A = never>() => Monoid<readonly A[]>\n```\n\n**Example**\n\n```ts\nimport { getMonoid } from 'fp-ts/ReadonlyArray'\n\nconst M = getMonoid<number>()\nassert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4])\n```\n\nAdded in v2.5.0\n\n## getOrd\n\nDerives an `Ord` over the `ReadonlyArray` of a given element type from the `Ord` of that type. The ordering between two such\narrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in\ncase of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have\nthe same length, the result is equality.\n\n**Signature**\n\n```ts\nexport declare const getOrd: <A>(O: Ord<A>) => Ord<readonly A[]>\n```\n\n**Example**\n\n```ts\nimport { getOrd } from 'fp-ts/ReadonlyArray'\nimport * as S from 'fp-ts/string'\n\nconst O = getOrd(S.Ord)\nassert.strictEqual(O.compare(['b'], ['a']), 1)\nassert.strictEqual(O.compare(['a'], ['a']), 0)\nassert.strictEqual(O.compare(['a'], ['b']), -1)\n```\n\nAdded in v2.5.0\n\n## getSemigroup\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A = never>() => Semigroup<readonly A[]>\n```\n\nAdded in v2.5.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare const getShow: <A>(S: Show<A>) => Show<readonly A[]>\n```\n\nAdded in v2.5.0\n\n## getUnionMonoid\n\n**Signature**\n\n```ts\nexport declare const getUnionMonoid: <A>(E: Eq<A>) => Monoid<readonly A[]>\n```\n\nAdded in v2.11.0\n\n## getUnionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <A>(E: Eq<A>) => Semigroup<readonly A[]>\n```\n\nAdded in v2.11.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => readonly B[]) => (ma: readonly A[]) => readonly B[]\n```\n\nAdded in v2.5.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => readonly B[]\n```\n\nAdded in v2.11.0\n\n## fromOptionK\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <A extends readonly unknown[], B>(\n  f: (...a: A) => Option<B>\n) => (...a: A) => readonly B[]\n```\n\nAdded in v2.11.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => ReadonlyArray<B>\nexport declare function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => ReadonlyArray<B>\nexport declare function fromPredicate<A>(predicate: Predicate<A>): (a: A) => ReadonlyArray<A>\n```\n\nAdded in v2.11.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: readonly ((a: A) => B)[]) => readonly B[]\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (fa: readonly A[]) => readonly B[]\n```\n\nAdded in v2.5.0\n\n## mapWithIndex\n\n**Signature**\n\n```ts\nexport declare const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (fa: readonly A[]) => readonly B[]\n```\n\nAdded in v2.5.0\n\n# pattern matching\n\n## foldLeft\n\nAlias of [`matchLeft`](#matchleft).\n\n**Signature**\n\n```ts\nexport declare const foldLeft: <A, B>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (head: A, tail: readonly A[]) => B\n) => (as: readonly A[]) => B\n```\n\nAdded in v2.5.0\n\n## foldRight\n\nAlias of [`matchRight`](#matchright).\n\n**Signature**\n\n```ts\nexport declare const foldRight: <A, B>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (init: readonly A[], last: A) => B\n) => (as: readonly A[]) => B\n```\n\nAdded in v2.5.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <B, A>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (as: RNEA.ReadonlyNonEmptyArray<A>) => B\n) => (as: readonly A[]) => B\n```\n\nAdded in v2.11.0\n\n## matchLeft\n\nBreak a `ReadonlyArray` into its first element and remaining elements.\n\n**Signature**\n\n```ts\nexport declare const matchLeft: <B, A>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (head: A, tail: readonly A[]) => B\n) => (as: readonly A[]) => B\n```\n\n**Example**\n\n```ts\nimport { matchLeft } from 'fp-ts/ReadonlyArray'\n\nconst len: <A>(as: ReadonlyArray<A>) => number = matchLeft(\n  () => 0,\n  (_, tail) => 1 + len(tail)\n)\nassert.strictEqual(len([1, 2, 3]), 3)\n```\n\nAdded in v2.10.0\n\n## matchLeftW\n\nLess strict version of [`matchLeft`](#matchleft).\n\n**Signature**\n\n```ts\nexport declare const matchLeftW: <B, A, C>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (head: A, tail: readonly A[]) => C\n) => (as: readonly A[]) => B | C\n```\n\nAdded in v2.11.0\n\n## matchRight\n\nBreak a `ReadonlyArray` into its initial elements and the last element.\n\n**Signature**\n\n```ts\nexport declare const matchRight: <B, A>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (init: readonly A[], last: A) => B\n) => (as: readonly A[]) => B\n```\n\nAdded in v2.10.0\n\n## matchRightW\n\nLess strict version of [`matchRight`](#matchright).\n\n**Signature**\n\n```ts\nexport declare const matchRightW: <B, A, C>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (init: readonly A[], last: A) => C\n) => (as: readonly A[]) => B | C\n```\n\nAdded in v2.11.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <B, A, C>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (as: RNEA.ReadonlyNonEmptyArray<A>) => C\n) => (as: readonly A[]) => B | C\n```\n\nAdded in v2.11.0\n\n# refinements\n\n## isEmpty\n\nTest whether a `ReadonlyArray` is empty.\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <A>(as: readonly A[]) => as is readonly []\n```\n\n**Example**\n\n```ts\nimport { isEmpty } from 'fp-ts/ReadonlyArray'\n\nassert.strictEqual(isEmpty([]), true)\n```\n\nAdded in v2.5.0\n\n## isNonEmpty\n\nTest whether a `ReadonlyArray` is non empty.\n\n**Signature**\n\n```ts\nexport declare const isNonEmpty: <A>(as: readonly A[]) => as is RNEA.ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n# sequencing\n\n## chainFirst\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => readonly B[]) => (first: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    RA.chainFirst(() => ['a', 'b'])\n  ),\n  [1, 1, 2, 2, 3, 3]\n)\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    RA.chainFirst(() => [])\n  ),\n  []\n)\n```\n\nAdded in v2.5.0\n\n## chainRecBreadthFirst\n\n**Signature**\n\n```ts\nexport declare const chainRecBreadthFirst: <A, B>(f: (a: A) => readonly Either<A, B>[]) => (a: A) => readonly B[]\n```\n\nAdded in v2.11.0\n\n## chainRecDepthFirst\n\n**Signature**\n\n```ts\nexport declare const chainRecDepthFirst: <A, B>(f: (a: A) => readonly Either<A, B>[]) => (a: A) => readonly B[]\n```\n\nAdded in v2.11.0\n\n## chainWithIndex\n\n**Signature**\n\n```ts\nexport declare const chainWithIndex: <A, B>(f: (i: number, a: A) => readonly B[]) => (as: readonly A[]) => readonly B[]\n```\n\nAdded in v2.7.0\n\n## flatMap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation.\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A, i: number) => readonly B[]): (ma: readonly A[]) => readonly B[]\n  <A, B>(ma: readonly A[], f: (a: A, i: number) => readonly B[]): readonly B[]\n}\n```\n\n**Example**\n\n```ts\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    RA.flatMap((n) => [`a${n}`, `b${n}`])\n  ),\n  ['a1', 'b1', 'a2', 'b2', 'a3', 'b3']\n)\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    RA.flatMap(() => [])\n  ),\n  []\n)\n```\n\nAdded in v2.14.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: readonly (readonly A[])[]) => readonly A[]\n```\n\nAdded in v2.5.0\n\n## traverseWithIndex\n\n**Signature**\n\n```ts\nexport declare const traverseWithIndex: PipeableTraverseWithIndex1<'ReadonlyArray', number>\n```\n\nAdded in v2.6.3\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence1<'ReadonlyArray'>\n```\n\nAdded in v2.6.3\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse1<'ReadonlyArray'>\n```\n\nAdded in v2.6.3\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReadonlyArray'\n```\n\nAdded in v2.5.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.5.0\n\n# unsafe\n\n## unsafeDeleteAt\n\n**Signature**\n\n```ts\nexport declare const unsafeDeleteAt: <A>(i: number, as: readonly A[]) => readonly A[]\n```\n\nAdded in v2.5.0\n\n## unsafeInsertAt\n\n**Signature**\n\n```ts\nexport declare const unsafeInsertAt: <A>(i: number, a: A, as: readonly A[]) => RNEA.ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## unsafeUpdateAt\n\n**Signature**\n\n```ts\nexport declare const unsafeUpdateAt: <A>(i: number, a: A, as: readonly A[]) => readonly A[]\n```\n\nAdded in v2.5.0\n\n# utils\n\n## Spanned (interface)\n\n**Signature**\n\n```ts\nexport interface Spanned<I, R> {\n  readonly init: ReadonlyArray<I>\n  readonly rest: ReadonlyArray<R>\n}\n```\n\nAdded in v2.5.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(fa: readonly A[]) => <B>(fab: readonly ((a: A) => B)[]) => readonly B[]\n```\n\nAdded in v2.5.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: readonly B[]) => <A>(first: readonly A[]) => readonly A[]\n```\n\nAdded in v2.5.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: readonly B[]) => <A>(first: readonly A[]) => readonly B[]\n```\n\nAdded in v2.5.0\n\n## append\n\nAppend an element to the end of a `ReadonlyArray`, creating a new `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const append: <A>(end: A) => (init: readonly A[]) => RNEA.ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { append } from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2, 3], append(4)), [1, 2, 3, 4])\n```\n\nAdded in v2.10.0\n\n## appendW\n\nLess strict version of [`append`](#append).\n\n**Signature**\n\n```ts\nexport declare const appendW: <B>(end: B) => <A>(init: readonly A[]) => RNEA.ReadonlyNonEmptyArray<B | A>\n```\n\nAdded in v2.11.0\n\n## chop\n\nA useful recursion pattern for processing a `ReadonlyArray` to produce a new `ReadonlyArray`, often used for \"chopping\" up the input\n`ReadonlyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `ReadonlyArray` and produce a\nvalue and the tail of the `ReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const chop: <A, B>(\n  f: (as: RNEA.ReadonlyNonEmptyArray<A>) => readonly [B, readonly A[]]\n) => (as: readonly A[]) => readonly B[]\n```\n\n**Example**\n\n```ts\nimport { Eq } from 'fp-ts/Eq'\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nconst group = <A>(S: Eq<A>): ((as: ReadonlyArray<A>) => ReadonlyArray<ReadonlyArray<A>>) => {\n  return RA.chop((as) => {\n    const { init, rest } = pipe(\n      as,\n      RA.spanLeft((a: A) => S.equals(a, as[0]))\n    )\n    return [init, rest]\n  })\n}\nassert.deepStrictEqual(group(N.Eq)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]])\n```\n\nAdded in v2.5.0\n\n## chunksOf\n\nSplits a `ReadonlyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\nthe `ReadonlyArray`. 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 `as`.\n\n**Signature**\n\n```ts\nexport declare const chunksOf: (n: number) => <A>(as: readonly A[]) => readonly RNEA.ReadonlyNonEmptyArray<A>[]\n```\n\n**Example**\n\n```ts\nimport { chunksOf } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])\n```\n\nAdded in v2.5.0\n\n## comprehension\n\n`ReadonlyArray` comprehension.\n\n```\n[ f(x, y, ...) | x ← xs, y ← ys, ..., g(x, y, ...) ]\n```\n\n**Signature**\n\n```ts\nexport declare function comprehension<A, B, C, D, R>(\n  input: readonly [ReadonlyArray<A>, ReadonlyArray<B>, ReadonlyArray<C>, ReadonlyArray<D>],\n  f: (a: A, b: B, c: C, d: D) => R,\n  g?: (a: A, b: B, c: C, d: D) => boolean\n): ReadonlyArray<R>\nexport declare function comprehension<A, B, C, R>(\n  input: readonly [ReadonlyArray<A>, ReadonlyArray<B>, ReadonlyArray<C>],\n  f: (a: A, b: B, c: C) => R,\n  g?: (a: A, b: B, c: C) => boolean\n): ReadonlyArray<R>\nexport declare function comprehension<A, B, R>(\n  input: readonly [ReadonlyArray<A>, ReadonlyArray<B>],\n  f: (a: A, b: B) => R,\n  g?: (a: A, b: B) => boolean\n): ReadonlyArray<R>\nexport declare function comprehension<A, R>(\n  input: readonly [ReadonlyArray<A>],\n  f: (a: A) => R,\n  g?: (a: A) => boolean\n): ReadonlyArray<R>\n```\n\n**Example**\n\n```ts\nimport { comprehension } from 'fp-ts/ReadonlyArray'\nimport { tuple } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  comprehension(\n    [\n      [1, 2, 3],\n      ['a', 'b'],\n    ],\n    tuple,\n    (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\nAdded in v2.5.0\n\n## concat\n\n**Signature**\n\n```ts\nexport declare const concat: <A>(second: readonly A[]) => (first: readonly A[]) => readonly A[]\n```\n\nAdded in v2.11.0\n\n## concatW\n\n**Signature**\n\n```ts\nexport declare const concatW: <B>(second: readonly B[]) => <A>(first: readonly A[]) => readonly (B | A)[]\n```\n\nAdded in v2.11.0\n\n## deleteAt\n\nDelete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds\n\n**Signature**\n\n```ts\nexport declare const deleteAt: (i: number) => <A>(as: readonly A[]) => Option<readonly A[]>\n```\n\n**Example**\n\n```ts\nimport { deleteAt } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3]))\nassert.deepStrictEqual(deleteAt(1)([]), none)\n```\n\nAdded in v2.5.0\n\n## difference\n\nCreates an array of array values not included in the other given array using a `Eq` for equality\ncomparisons. The order and references of result values are determined by the first array.\n\n**Signature**\n\n```ts\nexport declare function difference<A>(E: Eq<A>): {\n  (xs: ReadonlyArray<A>): (ys: ReadonlyArray<A>) => ReadonlyArray<A>\n  (xs: ReadonlyArray<A>, ys: ReadonlyArray<A>): ReadonlyArray<A>\n}\n```\n\n**Example**\n\n```ts\nimport { difference } from 'fp-ts/ReadonlyArray'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2], difference(N.Eq)([2, 3])), [1])\n```\n\nAdded in v2.5.0\n\n## dropLeft\n\nDrop a max number of elements from the start of an `ReadonlyArray`, creating a new `ReadonlyArray`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const dropLeft: (n: number) => <A>(as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nconst input: ReadonlyArray<number> = [1, 2, 3]\nassert.deepStrictEqual(pipe(input, RA.dropLeft(2)), [3])\nassert.strictEqual(pipe(input, RA.dropLeft(0)), input)\nassert.strictEqual(pipe(input, RA.dropLeft(-1)), input)\n```\n\nAdded in v2.5.0\n\n## dropLeftWhile\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 function dropLeftWhile<A, B extends A>(\n  refinement: Refinement<A, B>\n): (as: ReadonlyArray<A>) => ReadonlyArray<B>\nexport declare function dropLeftWhile<A>(\n  predicate: Predicate<A>\n): <B extends A>(bs: ReadonlyArray<B>) => ReadonlyArray<B>\nexport declare function dropLeftWhile<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => ReadonlyArray<A>\n```\n\n**Example**\n\n```ts\nimport { dropLeftWhile } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5])\n```\n\nAdded in v2.5.0\n\n## dropRight\n\nDrop a max number of elements from the end of an `ReadonlyArray`, creating a new `ReadonlyArray`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const dropRight: (n: number) => <A>(as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nconst input: ReadonlyArray<number> = [1, 2, 3]\nassert.deepStrictEqual(pipe(input, RA.dropRight(2)), [1])\nassert.strictEqual(pipe(input, RA.dropRight(0)), input)\nassert.strictEqual(pipe(input, RA.dropRight(-1)), input)\n```\n\nAdded in v2.5.0\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <A>(wa: readonly A[]) => readonly (readonly A[])[]\n```\n\nAdded in v2.5.0\n\n## elem\n\nTest if a value is a member of an array. Takes a `Eq<A>` as a single\nargument which returns the function to use to search for a value of type `A` in\nan array of type `ReadonlyArray<A>`.\n\n**Signature**\n\n```ts\nexport declare function elem<A>(E: Eq<A>): {\n  (a: A): (as: ReadonlyArray<A>) => boolean\n  (a: A, as: ReadonlyArray<A>): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { elem } from 'fp-ts/ReadonlyArray'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(2)), true)\nassert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(0)), false)\n```\n\nAdded in v2.5.0\n\n## empty\n\nAn empty array\n\n**Signature**\n\n```ts\nexport declare const empty: readonly never[]\n```\n\nAdded in v2.5.0\n\n## every\n\nCheck if a predicate holds true for every array 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\n**Example**\n\n```ts\nimport { every } from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nconst isPositive = (n: number): boolean => n > 0\n\nassert.deepStrictEqual(pipe([1, 2, 3], every(isPositive)), true)\nassert.deepStrictEqual(pipe([1, 2, -3], every(isPositive)), false)\n```\n\nAdded in v2.9.0\n\n## exists\n\nAlias of [`some`](#some)\n\n**Signature**\n\n```ts\nexport declare const exists: <A>(predicate: Predicate<A>) => (as: readonly A[]) => as is RNEA.ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <A, B>(f: (fa: readonly A[]) => B) => (wa: readonly A[]) => readonly B[]\n```\n\nAdded in v2.5.0\n\n## filterE\n\nFilter values inside a context.\n\n**Signature**\n\n```ts\nexport declare const filterE: FilterE1<'ReadonlyArray'>\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport * as T from 'fp-ts/Task'\n\nconst filterE = RA.filterE(T.ApplicativePar)\nasync function test() {\n  assert.deepStrictEqual(\n    await pipe(\n      [-1, 2, 3],\n      filterE((n) => T.of(n > 0))\n    )(),\n    [2, 3]\n  )\n}\ntest()\n```\n\nAdded in v2.11.0\n\n## findFirst\n\nFind the first element which satisfies a predicate (or a refinement) function\n\n**Signature**\n\n```ts\nexport declare function findFirst<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => Option<B>\nexport declare function findFirst<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Option<B>\nexport declare function findFirst<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { findFirst } from 'fp-ts/ReadonlyArray'\nimport { some } from 'fp-ts/Option'\n\ntype X = {\n  readonly a: number\n  readonly b: number\n}\n\nassert.deepStrictEqual(\n  findFirst((x: X) => x.a === 1)([\n    { a: 1, b: 1 },\n    { a: 1, b: 2 },\n  ]),\n  some({ a: 1, b: 1 })\n)\n```\n\nAdded in v2.5.0\n\n## findFirstMap\n\nFind the first element returned by an option based selector function\n\n**Signature**\n\n```ts\nexport declare const findFirstMap: <A, B>(f: (a: A) => Option<B>) => (as: readonly A[]) => Option<B>\n```\n\n**Example**\n\n```ts\nimport { findFirstMap } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\ninterface Person {\n  readonly name: string\n  readonly age?: number\n}\n\nconst persons: ReadonlyArray<Person> = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }]\n\n// returns the name of the first person that has an age\nassert.deepStrictEqual(findFirstMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Mary'))\n```\n\nAdded in v2.5.0\n\n## findIndex\n\nFind the first index for which a predicate holds\n\n**Signature**\n\n```ts\nexport declare const findIndex: <A>(predicate: Predicate<A>) => (as: readonly A[]) => Option<number>\n```\n\n**Example**\n\n```ts\nimport { findIndex } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1))\nassert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none)\n```\n\nAdded in v2.5.0\n\n## findLast\n\nFind the last element which satisfies a predicate function\n\n**Signature**\n\n```ts\nexport declare function findLast<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => Option<B>\nexport declare function findLast<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Option<B>\nexport declare function findLast<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { findLast } from 'fp-ts/ReadonlyArray'\nimport { some } from 'fp-ts/Option'\n\ntype X = {\n  readonly a: number\n  readonly b: number\n}\n\nassert.deepStrictEqual(\n  findLast((x: X) => x.a === 1)([\n    { a: 1, b: 1 },\n    { a: 1, b: 2 },\n  ]),\n  some({ a: 1, b: 2 })\n)\n```\n\nAdded in v2.5.0\n\n## findLastIndex\n\nReturns the index of the last element of the list which matches the predicate\n\n**Signature**\n\n```ts\nexport declare const findLastIndex: <A>(predicate: Predicate<A>) => (as: readonly A[]) => Option<number>\n```\n\n**Example**\n\n```ts\nimport { findLastIndex } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\ninterface X {\n  readonly a: number\n  readonly b: number\n}\nconst xs: ReadonlyArray<X> = [\n  { a: 1, b: 0 },\n  { a: 1, b: 1 },\n]\nassert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 1)(xs), some(1))\nassert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 4)(xs), none)\n```\n\nAdded in v2.5.0\n\n## findLastMap\n\nFind the last element returned by an option based selector function\n\n**Signature**\n\n```ts\nexport declare const findLastMap: <A, B>(f: (a: A) => Option<B>) => (as: readonly A[]) => Option<B>\n```\n\n**Example**\n\n```ts\nimport { findLastMap } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\ninterface Person {\n  readonly name: string\n  readonly age?: number\n}\n\nconst persons: ReadonlyArray<Person> = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }]\n\n// returns the name of the last person that has an age\nassert.deepStrictEqual(findLastMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Joey'))\n```\n\nAdded in v2.5.0\n\n## head\n\nGet the first element in an array, or `None` if the array is empty\n\n**Signature**\n\n```ts\nexport declare const head: <A>(as: readonly A[]) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { head } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(head([1, 2, 3]), some(1))\nassert.deepStrictEqual(head([]), none)\n```\n\nAdded in v2.5.0\n\n## init\n\nGet all but the last element of an array, creating a new array, or `None` if the array is empty\n\n**Signature**\n\n```ts\nexport declare const init: <A>(as: readonly A[]) => Option<readonly A[]>\n```\n\n**Example**\n\n```ts\nimport { init } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(init([1, 2, 3]), some([1, 2]))\nassert.deepStrictEqual(init([]), none)\n```\n\nAdded in v2.5.0\n\n## insertAt\n\nInsert an element at the specified index, creating a new array, or returning `None` if the index is out of bounds\n\n**Signature**\n\n```ts\nexport declare const insertAt: <A>(i: number, a: A) => (as: readonly A[]) => Option<RNEA.ReadonlyNonEmptyArray<A>>\n```\n\n**Example**\n\n```ts\nimport { insertAt } from 'fp-ts/ReadonlyArray'\nimport { some } from 'fp-ts/Option'\n\nassert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4]))\n```\n\nAdded in v2.5.0\n\n## intercalate\n\nPlaces an element in between members of a `ReadonlyArray`, then folds the results using the provided `Monoid`.\n\n**Signature**\n\n```ts\nexport declare const intercalate: <A>(M: Monoid<A>) => (middle: A) => (as: readonly A[]) => A\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { intercalate } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c')\n```\n\nAdded in v2.12.0\n\n## intersection\n\nCreates an array of unique values that are included in all given arrays using a `Eq` for equality\ncomparisons. The order and references of result values are determined by the first array.\n\n**Signature**\n\n```ts\nexport declare function intersection<A>(E: Eq<A>): {\n  (xs: ReadonlyArray<A>): (ys: ReadonlyArray<A>) => ReadonlyArray<A>\n  (xs: ReadonlyArray<A>, ys: ReadonlyArray<A>): ReadonlyArray<A>\n}\n```\n\n**Example**\n\n```ts\nimport { intersection } from 'fp-ts/ReadonlyArray'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2], intersection(N.Eq)([2, 3])), [2])\n```\n\nAdded in v2.5.0\n\n## intersperse\n\nPlaces an element in between members of an array\n\n**Signature**\n\n```ts\nexport declare const intersperse: <A>(middle: A) => (as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { intersperse } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])\n```\n\nAdded in v2.9.0\n\n## isOutOfBound\n\nTest whether an array contains a particular index\n\n**Signature**\n\n```ts\nexport declare const isOutOfBound: <A>(i: number, as: readonly A[]) => boolean\n```\n\nAdded in v2.5.0\n\n## last\n\nGet the last element in an array, or `None` if the array is empty\n\n**Signature**\n\n```ts\nexport declare const last: <A>(as: readonly A[]) => Option<A>\n```\n\n**Example**\n\n```ts\nimport { last } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(last([1, 2, 3]), some(3))\nassert.deepStrictEqual(last([]), none)\n```\n\nAdded in v2.5.0\n\n## lefts\n\nExtracts from an array of `Either` all the `Left` elements. All the `Left` elements are extracted in order\n\n**Signature**\n\n```ts\nexport declare const lefts: <E, A>(as: readonly Either<E, A>[]) => readonly E[]\n```\n\n**Example**\n\n```ts\nimport { lefts } from 'fp-ts/ReadonlyArray'\nimport { left, right } from 'fp-ts/Either'\n\nassert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo'])\n```\n\nAdded in v2.5.0\n\n## lookup\n\nThis function provides a safe way to read a value at a particular index from an array\n\n**Signature**\n\n```ts\nexport declare function lookup(i: number): <A>(as: ReadonlyArray<A>) => Option<A>\nexport declare function lookup<A>(i: number, as: ReadonlyArray<A>): Option<A>\n```\n\n**Example**\n\n```ts\nimport { lookup } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2))\nassert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none)\n```\n\nAdded in v2.5.0\n\n## modifyAt\n\nApply a function to the element at the specified index, creating a new array, or returning `None` if the index is out\nof bounds\n\n**Signature**\n\n```ts\nexport declare const modifyAt: <A>(i: number, f: (a: A) => A) => (as: readonly A[]) => Option<readonly A[]>\n```\n\n**Example**\n\n```ts\nimport { modifyAt } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\nconst double = (x: number): number => x * 2\nassert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3]))\nassert.deepStrictEqual(modifyAt(1, double)([]), none)\n```\n\nAdded in v2.5.0\n\n## prepend\n\nPrepend an element to the front of a `ReadonlyArray`, creating a new `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const prepend: <A>(head: A) => (tail: readonly A[]) => RNEA.ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { prepend } from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([2, 3, 4], prepend(1)), [1, 2, 3, 4])\n```\n\nAdded in v2.10.0\n\n## prependAll\n\nPrepend an element to every member of an array\n\n**Signature**\n\n```ts\nexport declare const prependAll: <A>(middle: A) => (as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { prependAll } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])\n```\n\nAdded in v2.10.0\n\n## prependW\n\nLess strict version of [`prepend`](#prepend).\n\n**Signature**\n\n```ts\nexport declare const prependW: <B>(head: B) => <A>(tail: readonly A[]) => RNEA.ReadonlyNonEmptyArray<B | A>\n```\n\nAdded in v2.11.0\n\n## reverse\n\nReverse an array, creating a new array\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { reverse } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1])\n```\n\nAdded in v2.5.0\n\n## rights\n\nExtracts from an array of `Either` all the `Right` elements. All the `Right` elements are extracted in order\n\n**Signature**\n\n```ts\nexport declare const rights: <E, A>(as: readonly Either<E, A>[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { rights } from 'fp-ts/ReadonlyArray'\nimport { right, left } from 'fp-ts/Either'\n\nassert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2])\n```\n\nAdded in v2.5.0\n\n## rotate\n\nRotate a `ReadonlyArray` by `n` steps.\n\n**Signature**\n\n```ts\nexport declare const rotate: (n: number) => <A>(as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { rotate } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n```\n\nAdded in v2.5.0\n\n## scanLeft\n\nSame as `reduce` but it carries over the intermediate steps.\n\n**Signature**\n\n```ts\nexport declare const scanLeft: <A, B>(b: B, f: (b: B, a: A) => B) => (as: readonly A[]) => RNEA.ReadonlyNonEmptyArray<B>\n```\n\n**Example**\n\n```ts\nimport { scanLeft } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4])\n```\n\nAdded in v2.5.0\n\n## scanRight\n\nFold an array from the right, keeping all intermediate results instead of only the final result\n\n**Signature**\n\n```ts\nexport declare const scanRight: <A, B>(\n  b: B,\n  f: (a: A, b: B) => B\n) => (as: readonly A[]) => RNEA.ReadonlyNonEmptyArray<B>\n```\n\n**Example**\n\n```ts\nimport { scanRight } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10])\n```\n\nAdded in v2.5.0\n\n## size\n\nCalculate the number of elements in a `ReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare const size: <A>(as: readonly A[]) => number\n```\n\nAdded in v2.10.0\n\n## some\n\nCheck if a predicate holds true for any array member.\n\n**Signature**\n\n```ts\nexport declare const some: <A>(predicate: Predicate<A>) => (as: readonly A[]) => as is RNEA.ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { some } from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nconst isPositive = (n: number): boolean => n > 0\n\nassert.deepStrictEqual(pipe([-1, -2, 3], some(isPositive)), true)\nassert.deepStrictEqual(pipe([-1, -2, -3], some(isPositive)), false)\n```\n\nAdded in v2.9.0\n\n## sort\n\nSort the elements of an array in increasing order, creating a new array\n\n**Signature**\n\n```ts\nexport declare const sort: <B>(O: Ord<B>) => <A extends B>(as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { sort } from 'fp-ts/ReadonlyArray'\nimport * as N from 'fp-ts/number'\n\nassert.deepStrictEqual(sort(N.Ord)([3, 2, 1]), [1, 2, 3])\n```\n\nAdded in v2.5.0\n\n## sortBy\n\nSort the elements of an array in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,\netc...\n\n**Signature**\n\n```ts\nexport declare const sortBy: <B>(ords: readonly Ord<B>[]) => <A extends B>(as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { sortBy } from 'fp-ts/ReadonlyArray'\nimport { contramap } from 'fp-ts/Ord'\nimport * as S from 'fp-ts/string'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\ninterface Person {\n  readonly name: string\n  readonly age: number\n}\nconst byName = pipe(\n  S.Ord,\n  contramap((p: Person) => p.name)\n)\nconst byAge = pipe(\n  N.Ord,\n  contramap((p: Person) => p.age)\n)\n\nconst sortByNameByAge = sortBy([byName, byAge])\n\nconst persons = [\n  { name: 'a', age: 1 },\n  { name: 'b', age: 3 },\n  { name: 'c', age: 2 },\n  { name: 'b', age: 2 },\n]\nassert.deepStrictEqual(sortByNameByAge(persons), [\n  { name: 'a', age: 1 },\n  { name: 'b', age: 2 },\n  { name: 'b', age: 3 },\n  { name: 'c', age: 2 },\n])\n```\n\nAdded in v2.5.0\n\n## spanLeft\n\nSplit an array 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 function spanLeft<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => Spanned<B, A>\nexport declare function spanLeft<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Spanned<B, B>\nexport declare function spanLeft<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Spanned<A, A>\n```\n\n**Example**\n\n```ts\nimport { spanLeft } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(spanLeft((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] })\n```\n\nAdded in v2.5.0\n\n## splitAt\n\nSplits a `ReadonlyArray` into two pieces, the first piece has max `n` elements.\n\n**Signature**\n\n```ts\nexport declare const splitAt: (n: number) => <A>(as: readonly A[]) => readonly [readonly A[], readonly A[]]\n```\n\n**Example**\n\n```ts\nimport { splitAt } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [\n  [1, 2],\n  [3, 4, 5],\n])\n```\n\nAdded in v2.5.0\n\n## tail\n\nGet all but the first element of an array, creating a new array, or `None` if the array is empty\n\n**Signature**\n\n```ts\nexport declare const tail: <A>(as: readonly A[]) => Option<readonly A[]>\n```\n\n**Example**\n\n```ts\nimport { tail } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(tail([1, 2, 3]), some([2, 3]))\nassert.deepStrictEqual(tail([]), none)\n```\n\nAdded in v2.5.0\n\n## takeLeft\n\nKeep only a max number of elements from the start of an `ReadonlyArray`, creating a new `ReadonlyArray`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const takeLeft: (n: number) => <A>(as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nconst input: ReadonlyArray<number> = [1, 2, 3]\nassert.deepStrictEqual(pipe(input, RA.takeLeft(2)), [1, 2])\n\n// out of bounds\nassert.strictEqual(pipe(input, RA.takeLeft(4)), input)\nassert.strictEqual(pipe(input, RA.takeLeft(-1)), input)\n```\n\nAdded in v2.5.0\n\n## takeLeftWhile\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 function takeLeftWhile<A, B extends A>(\n  refinement: Refinement<A, B>\n): (as: ReadonlyArray<A>) => ReadonlyArray<B>\nexport declare function takeLeftWhile<A>(\n  predicate: Predicate<A>\n): <B extends A>(bs: ReadonlyArray<B>) => ReadonlyArray<B>\nexport declare function takeLeftWhile<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => ReadonlyArray<A>\n```\n\n**Example**\n\n```ts\nimport { takeLeftWhile } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(takeLeftWhile((n: number) => n % 2 === 0)([2, 4, 3, 6]), [2, 4])\n```\n\nAdded in v2.5.0\n\n## takeRight\n\nKeep only a max number of elements from the end of an `ReadonlyArray`, creating a new `ReadonlyArray`.\n\n**Note**. `n` is normalized to a non negative integer.\n\n**Signature**\n\n```ts\nexport declare const takeRight: (n: number) => <A>(as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nconst input: ReadonlyArray<number> = [1, 2, 3]\nassert.deepStrictEqual(pipe(input, RA.takeRight(2)), [2, 3])\n\n// out of bounds\nassert.strictEqual(pipe(input, RA.takeRight(4)), input)\nassert.strictEqual(pipe(input, RA.takeRight(-1)), input)\n```\n\nAdded in v2.5.0\n\n## unfold\n\n**Signature**\n\n```ts\nexport declare const unfold: <A, B>(b: B, f: (b: B) => Option<readonly [A, B]>) => readonly A[]\n```\n\nAdded in v2.6.6\n\n## union\n\nCreates an array of unique values, in order, from all given arrays using a `Eq` for equality comparisons\n\n**Signature**\n\n```ts\nexport declare function union<A>(E: Eq<A>): {\n  (xs: ReadonlyArray<A>): (ys: ReadonlyArray<A>) => ReadonlyArray<A>\n  (xs: ReadonlyArray<A>, ys: ReadonlyArray<A>): ReadonlyArray<A>\n}\n```\n\n**Example**\n\n```ts\nimport { union } from 'fp-ts/ReadonlyArray'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2], union(N.Eq)([2, 3])), [1, 2, 3])\n```\n\nAdded in v2.5.0\n\n## uniq\n\nRemove duplicates from an array, keeping the first occurrence of an element.\n\n**Signature**\n\n```ts\nexport declare const uniq: <A>(E: Eq<A>) => (as: readonly A[]) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { uniq } from 'fp-ts/ReadonlyArray'\nimport * as N from 'fp-ts/number'\n\nassert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])\n```\n\nAdded in v2.5.0\n\n## unzip\n\nThe function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays\n\n**Signature**\n\n```ts\nexport declare const unzip: <A, B>(as: readonly (readonly [A, B])[]) => readonly [readonly A[], readonly B[]]\n```\n\n**Example**\n\n```ts\nimport { unzip } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(\n  unzip([\n    [1, 'a'],\n    [2, 'b'],\n    [3, 'c'],\n  ]),\n  [\n    [1, 2, 3],\n    ['a', 'b', 'c'],\n  ]\n)\n```\n\nAdded in v2.5.0\n\n## updateAt\n\nChange the element at the specified index, creating a new array, or returning `None` if the index is out of bounds\n\n**Signature**\n\n```ts\nexport declare const updateAt: <A>(i: number, a: A) => (as: readonly A[]) => Option<readonly A[]>\n```\n\n**Example**\n\n```ts\nimport { updateAt } from 'fp-ts/ReadonlyArray'\nimport { some, none } from 'fp-ts/Option'\n\nassert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3]))\nassert.deepStrictEqual(updateAt(1, 1)([]), none)\n```\n\nAdded in v2.5.0\n\n## zero\n\n**Signature**\n\n```ts\nexport declare const zero: <A>() => readonly A[]\n```\n\nAdded in v2.7.0\n\n## zip\n\nTakes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the\nlonger array are discarded\n\n**Signature**\n\n```ts\nexport declare function zip<B>(bs: ReadonlyArray<B>): <A>(as: ReadonlyArray<A>) => ReadonlyArray<readonly [A, B]>\nexport declare function zip<A, B>(as: ReadonlyArray<A>, bs: ReadonlyArray<B>): ReadonlyArray<readonly [A, B]>\n```\n\n**Example**\n\n```ts\nimport { zip } from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe([1, 2, 3], zip(['a', 'b', 'c', 'd'])), [\n  [1, 'a'],\n  [2, 'b'],\n  [3, 'c'],\n])\n```\n\nAdded in v2.5.0\n\n## zipWith\n\nApply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one\ninput array is short, excess elements of the longer array are discarded.\n\n**Signature**\n\n```ts\nexport declare const zipWith: <A, B, C>(fa: readonly A[], fb: readonly B[], f: (a: A, b: B) => C) => readonly C[]\n```\n\n**Example**\n\n```ts\nimport { zipWith } from 'fp-ts/ReadonlyArray'\n\nassert.deepStrictEqual(\n  zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n),\n  ['a1', 'b2', 'c3']\n)\n```\n\nAdded in v2.5.0\n\n# zone of death\n\n## ~~cons~~\n\nUse [`prepend`](#prepend) instead.\n\n**Signature**\n\n```ts\nexport declare const cons: typeof RNEA.cons\n```\n\nAdded in v2.5.0\n\n## ~~prependToAll~~\n\nUse [`prependAll`](#prependall) instead.\n\n**Signature**\n\n```ts\nexport declare const prependToAll: <A>(middle: A) => (as: readonly A[]) => readonly A[]\n```\n\nAdded in v2.9.0\n\n## ~~range~~\n\nUse `ReadonlyNonEmptyArray` module instead.\n\n**Signature**\n\n```ts\nexport declare const range: (start: number, end: number) => RNEA.ReadonlyNonEmptyArray<number>\n```\n\nAdded in v2.5.0\n\n## ~~readonlyArray~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RA.Functor` instead of `RA.readonlyArray`\n(where `RA` is from `import RA from 'fp-ts/ReadonlyArray'`)\n\n**Signature**\n\n```ts\nexport declare const readonlyArray: FunctorWithIndex1<'ReadonlyArray', number> &\n  Monad1<'ReadonlyArray'> &\n  Unfoldable1<'ReadonlyArray'> &\n  Alternative1<'ReadonlyArray'> &\n  Extend1<'ReadonlyArray'> &\n  FilterableWithIndex1<'ReadonlyArray', number> &\n  FoldableWithIndex1<'ReadonlyArray', number> &\n  TraversableWithIndex1<'ReadonlyArray', number> &\n  Witherable1<'ReadonlyArray'>\n```\n\nAdded in v2.5.0\n\n## ~~snoc~~\n\nUse [`append`](#append) instead.\n\n**Signature**\n\n```ts\nexport declare const snoc: <A>(init: readonly A[], end: A) => RNEA.ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n"
  },
  {
    "path": "docs/modules/ReadonlyMap.ts.md",
    "content": "---\ntitle: ReadonlyMap.ts\nnav_order: 84\nparent: Modules\n---\n\n## ReadonlyMap overview\n\nAdded in v2.5.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [fromFoldable](#fromfoldable)\n  - [singleton](#singleton)\n- [conversions](#conversions)\n  - [fromMap](#frommap)\n  - [toMap](#tomap)\n  - [toReadonlyArray](#toreadonlyarray)\n  - [toUnfoldable](#tounfoldable)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [getFilterableWithIndex](#getfilterablewithindex)\n  - [getWitherable](#getwitherable)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [separate](#separate)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [getFoldable](#getfoldable)\n  - [getFoldableWithIndex](#getfoldablewithindex)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n- [instances](#instances)\n  - [Compactable](#compactable)\n  - [Filterable](#filterable)\n  - [Functor](#functor)\n  - [getDifferenceMagma](#getdifferencemagma)\n  - [getEq](#geteq)\n  - [getFunctorWithIndex](#getfunctorwithindex)\n  - [getIntersectionSemigroup](#getintersectionsemigroup)\n  - [getMonoid](#getmonoid)\n  - [getShow](#getshow)\n  - [getUnionMonoid](#getunionmonoid)\n  - [getUnionSemigroup](#getunionsemigroup)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n  - [mapWithIndex](#mapwithindex)\n- [traversing](#traversing)\n  - [getTraversable](#gettraversable)\n  - [getTraversableWithIndex](#gettraversablewithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [collect](#collect)\n  - [deleteAt](#deleteat)\n  - [difference](#difference)\n  - [elem](#elem)\n  - [empty](#empty)\n  - [filterMapWithIndex](#filtermapwithindex)\n  - [filterWithIndex](#filterwithindex)\n  - [intersection](#intersection)\n  - [isEmpty](#isempty)\n  - [isSubmap](#issubmap)\n  - [keys](#keys)\n  - [lookup](#lookup)\n  - [lookupWithKey](#lookupwithkey)\n  - [member](#member)\n  - [modifyAt](#modifyat)\n  - [partitionMapWithIndex](#partitionmapwithindex)\n  - [partitionWithIndex](#partitionwithindex)\n  - [pop](#pop)\n  - [size](#size)\n  - [union](#union)\n  - [updateAt](#updateat)\n  - [upsertAt](#upsertat)\n  - [values](#values)\n- [zone of death](#zone-of-death)\n  - [~~insertAt~~](#insertat)\n  - [~~readonlyMap~~](#readonlymap)\n\n---\n\n# constructors\n\n## fromFoldable\n\nCreate a map from a foldable collection of key/value pairs, using the\nspecified `Magma` to combine values for duplicate keys.\n\n**Signature**\n\n```ts\nexport declare function fromFoldable<F extends URIS3, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable3<F>\n): <R, E>(fka: Kind3<F, R, E, readonly [K, A]>) => ReadonlyMap<K, A>\nexport declare function fromFoldable<F extends URIS2, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable2<F>\n): <E>(fka: Kind2<F, E, readonly [K, A]>) => ReadonlyMap<K, A>\nexport declare function fromFoldable<F extends URIS, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable1<F>\n): (fka: Kind<F, readonly [K, A]>) => ReadonlyMap<K, A>\nexport declare function fromFoldable<F, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable<F>\n): (fka: HKT<F, readonly [K, A]>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.5.0\n\n## singleton\n\nCreate a map with one key/value pair\n\n**Signature**\n\n```ts\nexport declare const singleton: <K, A>(k: K, a: A) => ReadonlyMap<K, A>\n```\n\nAdded in v2.5.0\n\n# conversions\n\n## fromMap\n\n**Signature**\n\n```ts\nexport declare const fromMap: <K, A>(m: Map<K, A>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.5.0\n\n## toMap\n\n**Signature**\n\n```ts\nexport declare function toMap<K, A>(m: ReadonlyMap<K, A>): Map<K, A>\n```\n\nAdded in v2.5.0\n\n## toReadonlyArray\n\nGet a sorted `ReadonlyArray` of the key/value pairs contained in a `ReadonlyMap`.\n\n**Signature**\n\n```ts\nexport declare const toReadonlyArray: <K>(O: Ord<K>) => <A>(m: ReadonlyMap<K, A>) => readonly (readonly [K, A])[]\n```\n\nAdded in v2.5.0\n\n## toUnfoldable\n\nUnfolds a map into a list of key/value pairs\n\n**Signature**\n\n```ts\nexport declare function toUnfoldable<K, F extends URIS>(\n  ord: Ord<K>,\n  U: Unfoldable1<F>\n): <A>(d: ReadonlyMap<K, A>) => Kind<F, readonly [K, A]>\nexport declare function toUnfoldable<K, F>(\n  ord: Ord<K>,\n  U: Unfoldable<F>\n): <A>(d: ReadonlyMap<K, A>) => HKT<F, readonly [K, A]>\n```\n\nAdded in v2.5.0\n\n# filtering\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <K, A>(fa: ReadonlyMap<K, O.Option<A>>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.5.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>\n  <A>(predicate: Predicate<A>): <K, B extends A>(fb: ReadonlyMap<K, B>) => ReadonlyMap<K, B>\n  <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\n}\n```\n\nAdded in v2.5.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>\n```\n\nAdded in v2.5.0\n\n## getFilterableWithIndex\n\n**Signature**\n\n```ts\nexport declare function getFilterableWithIndex<K = never>(): FilterableWithIndex2C<URI, K, K>\n```\n\nAdded in v2.5.0\n\n## getWitherable\n\n**Signature**\n\n```ts\nexport declare function getWitherable<K>(O: Ord<K>): Witherable2C<URI, K> & TraversableWithIndex2C<URI, K, K>\n```\n\nAdded in v2.5.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): <K>(\n    fa: ReadonlyMap<K, A>\n  ) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>\n  <A>(predicate: Predicate<A>): <K, B extends A>(\n    fb: ReadonlyMap<K, B>\n  ) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, B>>\n  <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>\n}\n```\n\nAdded in v2.5.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>>\n```\n\nAdded in v2.5.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare const separate: <K, A, B>(\n  fa: ReadonlyMap<K, Either<A, B>>\n) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>\n```\n\nAdded in v2.5.0\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <K>(O: Ord<K>) => <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (m: ReadonlyMap<K, A>) => M\n```\n\nAdded in v2.11.0\n\n## foldMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const foldMapWithIndex: <K>(\n  O: Ord<K>\n) => <M>(M: Monoid<M>) => <A>(f: (k: K, a: A) => M) => (m: ReadonlyMap<K, A>) => M\n```\n\nAdded in v2.11.0\n\n## getFoldable\n\n**Signature**\n\n```ts\nexport declare const getFoldable: <K>(O: Ord<K>) => Foldable2C<'ReadonlyMap', K>\n```\n\nAdded in v2.10.0\n\n## getFoldableWithIndex\n\n**Signature**\n\n```ts\nexport declare const getFoldableWithIndex: <K>(O: Ord<K>) => FoldableWithIndex2C<'ReadonlyMap', K, K>\n```\n\nAdded in v2.10.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <K>(O: Ord<K>) => <B, A>(b: B, f: (b: B, a: A) => B) => (m: ReadonlyMap<K, A>) => B\n```\n\nAdded in v2.11.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <K>(O: Ord<K>) => <B, A>(b: B, f: (a: A, b: B) => B) => (m: ReadonlyMap<K, A>) => B\n```\n\nAdded in v2.11.0\n\n## reduceRightWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceRightWithIndex: <K>(\n  O: Ord<K>\n) => <B, A>(b: B, f: (k: K, a: A, b: B) => B) => (m: ReadonlyMap<K, A>) => B\n```\n\nAdded in v2.11.0\n\n## reduceWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceWithIndex: <K>(\n  O: Ord<K>\n) => <B, A>(b: B, f: (k: K, b: B, a: A) => B) => (m: ReadonlyMap<K, A>) => B\n```\n\nAdded in v2.11.0\n\n# instances\n\n## Compactable\n\n**Signature**\n\n```ts\nexport declare const Compactable: Compactable2<'ReadonlyMap'>\n```\n\nAdded in v2.7.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: Filterable2<'ReadonlyMap'>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'ReadonlyMap'>\n```\n\nAdded in v2.7.0\n\n## getDifferenceMagma\n\n**Signature**\n\n```ts\nexport declare const getDifferenceMagma: <K>(E: Eq<K>) => <A>() => Magma<ReadonlyMap<K, A>>\n```\n\nAdded in v2.11.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare function getEq<K, A>(SK: Eq<K>, SA: Eq<A>): Eq<ReadonlyMap<K, A>>\n```\n\nAdded in v2.5.0\n\n## getFunctorWithIndex\n\n**Signature**\n\n```ts\nexport declare const getFunctorWithIndex: <K = never>() => FunctorWithIndex2C<'ReadonlyMap', K, K>\n```\n\nAdded in v2.10.0\n\n## getIntersectionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getIntersectionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<ReadonlyMap<K, A>>\n```\n\nAdded in v2.11.0\n\n## getMonoid\n\nGets `Monoid` instance for Maps given `Semigroup` instance for their values\n\n**Signature**\n\n```ts\nexport declare function getMonoid<K, A>(SK: Eq<K>, SA: Semigroup<A>): Monoid<ReadonlyMap<K, A>>\n```\n\nAdded in v2.5.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare function getShow<K, A>(SK: Show<K>, SA: Show<A>): Show<ReadonlyMap<K, A>>\n```\n\nAdded in v2.5.0\n\n## getUnionMonoid\n\n**Signature**\n\n```ts\nexport declare const getUnionMonoid: <K, A>(E: Eq<K>, S: Semigroup<A>) => Monoid<ReadonlyMap<K, A>>\n```\n\nAdded in v2.11.0\n\n## getUnionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <K, A>(E: Eq<K>, S: Semigroup<A>) => Semigroup<ReadonlyMap<K, A>>\n```\n\nAdded in v2.11.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: ReadonlyMap<E, (a: A) => B>) => ReadonlyMap<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>\n```\n\nAdded in v2.5.0\n\n## mapWithIndex\n\n**Signature**\n\n```ts\nexport declare const mapWithIndex: <K, A, B>(f: (k: K, a: A) => B) => (fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>\n```\n\nAdded in v2.7.1\n\n# traversing\n\n## getTraversable\n\n**Signature**\n\n```ts\nexport declare const getTraversable: <K>(O: Ord<K>) => Traversable2C<'ReadonlyMap', K>\n```\n\nAdded in v2.10.0\n\n## getTraversableWithIndex\n\n**Signature**\n\n```ts\nexport declare const getTraversableWithIndex: <K>(O: Ord<K>) => TraversableWithIndex2C<'ReadonlyMap', K, K>\n```\n\nAdded in v2.10.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReadonlyMap'\n```\n\nAdded in v2.5.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.5.0\n\n# utils\n\n## collect\n\n**Signature**\n\n```ts\nexport declare function collect<K>(\n  O: Ord<K>\n): <A, B>(f: (k: K, a: A) => B) => (m: ReadonlyMap<K, A>) => ReadonlyArray<B>\n```\n\nAdded in v2.5.0\n\n## deleteAt\n\nDelete a key and value from a map\n\n**Signature**\n\n```ts\nexport declare const deleteAt: <K>(E: Eq<K>) => (k: K) => <A>(m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.5.0\n\n## difference\n\n**Signature**\n\n```ts\nexport declare const difference: <K>(\n  E: Eq<K>\n) => <A>(_second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.11.0\n\n## elem\n\nTest whether or not a value is a member of a map\n\n**Signature**\n\n```ts\nexport declare function elem<A>(E: Eq<A>): {\n  (a: A): <K>(m: ReadonlyMap<K, A>) => boolean\n  <K>(a: A, m: ReadonlyMap<K, A>): boolean\n}\n```\n\nAdded in v2.5.0\n\n## empty\n\n**Signature**\n\n```ts\nexport declare const empty: ReadonlyMap<never, never>\n```\n\nAdded in v2.5.0\n\n## filterMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const filterMapWithIndex: <K, A, B>(\n  f: (k: K, a: A) => O.Option<B>\n) => (fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>\n```\n\nAdded in v2.10.0\n\n## filterWithIndex\n\n**Signature**\n\n```ts\nexport declare function filterWithIndex<K, A, B extends A>(\n  predicateWithIndex: (k: K, a: A) => a is B\n): (m: ReadonlyMap<K, A>) => ReadonlyMap<K, B>\nexport declare function filterWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): <B extends A>(m: ReadonlyMap<K, B>) => ReadonlyMap<K, B>\nexport declare function filterWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.10.0\n\n## intersection\n\n**Signature**\n\n```ts\nexport declare const intersection: <K, A>(\n  E: Eq<K>,\n  M: Magma<A>\n) => (second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.11.0\n\n## isEmpty\n\nTest whether or not a map is empty\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <K, A>(m: ReadonlyMap<K, A>) => boolean\n```\n\nAdded in v2.5.0\n\n## isSubmap\n\nTest whether or not one `Map` contains all of the keys and values contained in another `Map`\n\n**Signature**\n\n```ts\nexport declare function isSubmap<K, A>(\n  SK: Eq<K>,\n  SA: Eq<A>\n): {\n  (that: ReadonlyMap<K, A>): (me: ReadonlyMap<K, A>) => boolean\n  (me: ReadonlyMap<K, A>, that: ReadonlyMap<K, A>): boolean\n}\n```\n\nAdded in v2.5.0\n\n## keys\n\nGet a sorted `ReadonlyArray` of the keys contained in a `ReadonlyMap`.\n\n**Signature**\n\n```ts\nexport declare const keys: <K>(O: Ord<K>) => <A>(m: ReadonlyMap<K, A>) => readonly K[]\n```\n\nAdded in v2.5.0\n\n## lookup\n\nLookup the value for a key in a `Map`.\n\n**Signature**\n\n```ts\nexport declare function lookup<K>(E: Eq<K>): {\n  (k: K): <A>(m: ReadonlyMap<K, A>) => Option<A>\n  <A>(k: K, m: ReadonlyMap<K, A>): Option<A>\n}\n```\n\nAdded in v2.5.0\n\n## lookupWithKey\n\nLookup the value for a key in a `Map`.\nIf the result is a `Some`, the existing key is also returned.\n\n**Signature**\n\n```ts\nexport declare function lookupWithKey<K>(E: Eq<K>): {\n  (k: K): <A>(m: ReadonlyMap<K, A>) => Option<readonly [K, A]>\n  <A>(k: K, m: ReadonlyMap<K, A>): Option<readonly [K, A]>\n}\n```\n\nAdded in v2.5.0\n\n## member\n\nTest whether or not a key exists in a map\n\n**Signature**\n\n```ts\nexport declare function member<K>(E: Eq<K>): {\n  (k: K): <A>(m: ReadonlyMap<K, A>) => boolean\n  <A>(k: K, m: ReadonlyMap<K, A>): boolean\n}\n```\n\nAdded in v2.5.0\n\n## modifyAt\n\n**Signature**\n\n```ts\nexport declare const modifyAt: <K>(\n  E: Eq<K>\n) => <A>(k: K, f: (a: A) => A) => (m: ReadonlyMap<K, A>) => O.Option<ReadonlyMap<K, A>>\n```\n\nAdded in v2.5.0\n\n## partitionMapWithIndex\n\n**Signature**\n\n```ts\nexport declare const partitionMapWithIndex: <K, A, B, C>(\n  f: (k: K, a: A) => Either<B, C>\n) => (fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>>\n```\n\nAdded in v2.10.0\n\n## partitionWithIndex\n\n**Signature**\n\n```ts\nexport declare function partitionWithIndex<K, A, B extends A>(\n  predicateWithIndex: (k: K, a: A) => a is B\n): (m: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>\nexport declare function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): <B extends A>(m: ReadonlyMap<K, B>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, B>>\nexport declare function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): (m: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>\n```\n\nAdded in v2.10.0\n\n## pop\n\nDelete a key and value from a map, returning the value as well as the subsequent map\n\n**Signature**\n\n```ts\nexport declare function pop<K>(E: Eq<K>): (k: K) => <A>(m: ReadonlyMap<K, A>) => Option<readonly [A, ReadonlyMap<K, A>]>\n```\n\nAdded in v2.5.0\n\n## size\n\nCalculate the number of key/value pairs in a map\n\n**Signature**\n\n```ts\nexport declare const size: <K, A>(m: ReadonlyMap<K, A>) => number\n```\n\nAdded in v2.5.0\n\n## union\n\n**Signature**\n\n```ts\nexport declare const union: <K, A>(\n  E: Eq<K>,\n  M: Magma<A>\n) => (second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.11.0\n\n## updateAt\n\n**Signature**\n\n```ts\nexport declare const updateAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => O.Option<ReadonlyMap<K, A>>\n```\n\nAdded in v2.5.0\n\n## upsertAt\n\nInsert or replace a key/value pair in a `ReadonlyMap`.\n\n**Signature**\n\n```ts\nexport declare const upsertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.10.0\n\n## values\n\nGet a sorted `ReadonlyArray` of the values contained in a `ReadonlyMap`.\n\n**Signature**\n\n```ts\nexport declare const values: <A>(O: Ord<A>) => <K>(m: ReadonlyMap<K, A>) => readonly A[]\n```\n\nAdded in v2.5.0\n\n# zone of death\n\n## ~~insertAt~~\n\nUse [`upsertAt`](#upsertat) instead.\n\n**Signature**\n\n```ts\nexport declare const insertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\n```\n\nAdded in v2.5.0\n\n## ~~readonlyMap~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RM.Functor` instead of `RM.readonlyMap`\n(where `RM` is from `import RM from 'fp-ts/ReadonlyMap'`)\n\n**Signature**\n\n```ts\nexport declare const readonlyMap: Filterable2<'ReadonlyMap'>\n```\n\nAdded in v2.5.0\n"
  },
  {
    "path": "docs/modules/ReadonlyNonEmptyArray.ts.md",
    "content": "---\ntitle: ReadonlyNonEmptyArray.ts\nnav_order: 85\nparent: Modules\n---\n\n## ReadonlyNonEmptyArray overview\n\nData structure which represents non-empty readonly arrays.\n\n```ts\nexport type ReadonlyNonEmptyArray<A> = ReadonlyArray<A> & {\n  readonly 0: A\n}\n```\n\nNote that you don't need any conversion, a `ReadonlyNonEmptyArray` is a `ReadonlyArray`,\nso all `ReadonlyArray`'s APIs can be used with a `ReadonlyNonEmptyArray` without further ado.\n\nAdded in v2.5.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [Comonad](#comonad)\n  - [extract](#extract)\n- [constructors](#constructors)\n  - [makeBy](#makeby)\n  - [of](#of)\n  - [range](#range)\n  - [replicate](#replicate)\n- [conversions](#conversions)\n  - [fromArray](#fromarray)\n  - [fromReadonlyArray](#fromreadonlyarray)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [Comonad](#comonad-1)\n  - [Foldable](#foldable)\n  - [FoldableWithIndex](#foldablewithindex)\n  - [Functor](#functor)\n  - [FunctorWithIndex](#functorwithindex)\n  - [Monad](#monad)\n  - [Pointed](#pointed)\n  - [Traversable](#traversable)\n  - [TraversableWithIndex](#traversablewithindex)\n  - [getEq](#geteq)\n  - [getSemigroup](#getsemigroup)\n  - [getShow](#getshow)\n- [legacy](#legacy)\n  - [chain](#chain)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n  - [mapWithIndex](#mapwithindex)\n- [model](#model)\n  - [ReadonlyNonEmptyArray (type alias)](#readonlynonemptyarray-type-alias)\n- [pattern matching](#pattern-matching)\n  - [matchLeft](#matchleft)\n  - [matchRight](#matchright)\n- [sequencing](#sequencing)\n  - [chainFirst](#chainfirst)\n  - [chainWithIndex](#chainwithindex)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n  - [traverseWithIndex](#traversewithindex)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [chop](#chop)\n  - [chunksOf](#chunksof)\n  - [concat](#concat)\n  - [concatAll](#concatall)\n  - [concatW](#concatw)\n  - [duplicate](#duplicate)\n  - [extend](#extend)\n  - [getUnionSemigroup](#getunionsemigroup)\n  - [group](#group)\n  - [groupBy](#groupby)\n  - [head](#head)\n  - [init](#init)\n  - [intercalate](#intercalate)\n  - [intersperse](#intersperse)\n  - [last](#last)\n  - [max](#max)\n  - [min](#min)\n  - [modifyAt](#modifyat)\n  - [modifyHead](#modifyhead)\n  - [modifyLast](#modifylast)\n  - [prependAll](#prependall)\n  - [reverse](#reverse)\n  - [rotate](#rotate)\n  - [sort](#sort)\n  - [sortBy](#sortby)\n  - [splitAt](#splitat)\n  - [tail](#tail)\n  - [unappend](#unappend)\n  - [union](#union)\n  - [uniq](#uniq)\n  - [unprepend](#unprepend)\n  - [unzip](#unzip)\n  - [updateAt](#updateat)\n  - [updateHead](#updatehead)\n  - [updateLast](#updatelast)\n  - [zip](#zip)\n  - [zipWith](#zipwith)\n- [zone of death](#zone-of-death)\n  - [~~cons~~](#cons)\n  - [~~filterWithIndex~~](#filterwithindex)\n  - [~~filter~~](#filter)\n  - [~~fold~~](#fold)\n  - [~~groupSort~~](#groupsort)\n  - [~~insertAt~~](#insertat)\n  - [~~prependToAll~~](#prependtoall)\n  - [~~readonlyNonEmptyArray~~](#readonlynonemptyarray)\n  - [~~snoc~~](#snoc)\n  - [~~uncons~~](#uncons)\n  - [~~unsnoc~~](#unsnoc)\n\n---\n\n# Comonad\n\n## extract\n\n**Signature**\n\n```ts\nexport declare const extract: <A>(wa: ReadonlyNonEmptyArray<A>) => A\n```\n\nAdded in v2.6.3\n\n# constructors\n\n## makeBy\n\nReturn a `ReadonlyNonEmptyArray` of length `n` with element `i` initialized with `f(i)`.\n\n**Note**. `n` is normalized to a natural number.\n\n**Signature**\n\n```ts\nexport declare const makeBy: <A>(f: (i: number) => A) => (n: number) => ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { makeBy } from 'fp-ts/ReadonlyNonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nconst double = (n: number): number => n * 2\nassert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8])\n```\n\nAdded in v2.11.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## range\n\nCreate a `ReadonlyNonEmptyArray` containing a range of integers, including both endpoints.\n\n**Signature**\n\n```ts\nexport declare const range: (start: number, end: number) => ReadonlyNonEmptyArray<number>\n```\n\n**Example**\n\n```ts\nimport { range } from 'fp-ts/ReadonlyNonEmptyArray'\n\nassert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5])\n```\n\nAdded in v2.11.0\n\n## replicate\n\nCreate a `ReadonlyNonEmptyArray` containing a value repeated the specified number of times.\n\n**Note**. `n` is normalized to a natural number.\n\n**Signature**\n\n```ts\nexport declare const replicate: <A>(a: A) => (n: number) => ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { replicate } from 'fp-ts/ReadonlyNonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a'])\n```\n\nAdded in v2.11.0\n\n# conversions\n\n## fromArray\n\n**Signature**\n\n```ts\nexport declare const fromArray: <A>(as: A[]) => Option<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n## fromReadonlyArray\n\nReturn a `ReadonlyNonEmptyArray` from a `ReadonlyArray` returning `none` if the input is empty.\n\n**Signature**\n\n```ts\nexport declare const fromReadonlyArray: <A>(as: readonly A[]) => Option<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: ReadonlyNonEmptyArray<{}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReadonlyNonEmptyArray<B>\n) => (\n  fa: ReadonlyNonEmptyArray<A>\n) => ReadonlyNonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReadonlyNonEmptyArray<B>\n) => (\n  ma: ReadonlyNonEmptyArray<A>\n) => ReadonlyNonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(\n  name: N\n) => <A>(fa: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<{ readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (\n  fa: ReadonlyNonEmptyArray<A>\n) => ReadonlyNonEmptyArray<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\nIn case of `ReadonlyNonEmptyArray` concatenates the inputs into a single array.\n\n**Signature**\n\n```ts\nexport declare const alt: <A>(\n  that: LazyArg<ReadonlyNonEmptyArray<A>>\n) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    RNEA.alt(() => [4, 5])\n  ),\n  [1, 2, 3, 4, 5]\n)\n```\n\nAdded in v2.6.2\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <B>(\n  that: LazyArg<ReadonlyNonEmptyArray<B>>\n) => <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B | A>\n```\n\n**Example**\n\n```ts\nimport * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3] as RNEA.ReadonlyNonEmptyArray<number>,\n    RNEA.altW(() => ['a', 'b'])\n  ),\n  [1, 2, 3, 'a', 'b']\n)\n```\n\nAdded in v2.9.0\n\n# folding\n\n## foldMap\n\n**Note**. The constraint is relaxed: a `Semigroup` instead of a `Monoid`.\n\n**Signature**\n\n```ts\nexport declare const foldMap: <S>(S: Se.Semigroup<S>) => <A>(f: (a: A) => S) => (as: ReadonlyNonEmptyArray<A>) => S\n```\n\nAdded in v2.5.0\n\n## foldMapWithIndex\n\n**Note**. The constraint is relaxed: a `Semigroup` instead of a `Monoid`.\n\n**Signature**\n\n```ts\nexport declare const foldMapWithIndex: <S>(\n  S: Se.Semigroup<S>\n) => <A>(f: (i: number, a: A) => S) => (as: ReadonlyNonEmptyArray<A>) => S\n```\n\nAdded in v2.5.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (as: ReadonlyNonEmptyArray<A>) => B\n```\n\nAdded in v2.5.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (as: ReadonlyNonEmptyArray<A>) => B\n```\n\nAdded in v2.5.0\n\n## reduceRightWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceRightWithIndex: <A, B>(\n  b: B,\n  f: (i: number, a: A, b: B) => B\n) => (as: ReadonlyNonEmptyArray<A>) => B\n```\n\nAdded in v2.5.0\n\n## reduceWithIndex\n\n**Signature**\n\n```ts\nexport declare const reduceWithIndex: <A, B>(\n  b: B,\n  f: (i: number, b: B, a: A) => B\n) => (as: ReadonlyNonEmptyArray<A>) => B\n```\n\nAdded in v2.5.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: Chain1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.10.0\n\n## Comonad\n\n**Signature**\n\n```ts\nexport declare const Comonad: Comonad1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## FoldableWithIndex\n\n**Signature**\n\n```ts\nexport declare const FoldableWithIndex: FoldableWithIndex1<'ReadonlyNonEmptyArray', number>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## FunctorWithIndex\n\n**Signature**\n\n```ts\nexport declare const FunctorWithIndex: FunctorWithIndex1<'ReadonlyNonEmptyArray', number>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.10.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.7.0\n\n## TraversableWithIndex\n\n**Signature**\n\n```ts\nexport declare const TraversableWithIndex: TraversableWithIndex1<'ReadonlyNonEmptyArray', number>\n```\n\nAdded in v2.7.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare const getEq: <A>(E: Eq<A>) => Eq<ReadonlyNonEmptyArray<A>>\n```\n\n**Example**\n\n```ts\nimport { getEq } from 'fp-ts/ReadonlyNonEmptyArray'\nimport * as N from 'fp-ts/number'\n\nconst E = getEq(N.Eq)\nassert.strictEqual(E.equals([1, 2], [1, 2]), true)\nassert.strictEqual(E.equals([1, 2], [1, 3]), false)\n```\n\nAdded in v2.5.0\n\n## getSemigroup\n\nBuilds a `Semigroup` instance for `ReadonlyNonEmptyArray`\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A = never>() => Se.Semigroup<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare const getShow: <A>(S: Show<A>) => Show<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(\n  f: (a: A) => ReadonlyNonEmptyArray<B>\n) => (ma: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>\n```\n\nAdded in v2.5.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: ReadonlyNonEmptyArray<(a: A) => B>) => ReadonlyNonEmptyArray<B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>\n```\n\nAdded in v2.5.0\n\n## mapWithIndex\n\n**Signature**\n\n```ts\nexport declare const mapWithIndex: <A, B>(\n  f: (i: number, a: A) => B\n) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>\n```\n\nAdded in v2.5.0\n\n# model\n\n## ReadonlyNonEmptyArray (type alias)\n\n**Signature**\n\n```ts\nexport type ReadonlyNonEmptyArray<A> = ReadonlyArray<A> & {\n  readonly 0: A\n}\n```\n\nAdded in v2.5.0\n\n# pattern matching\n\n## matchLeft\n\nBreak a `ReadonlyArray` into its first element and remaining elements.\n\n**Signature**\n\n```ts\nexport declare const matchLeft: <A, B>(f: (head: A, tail: readonly A[]) => B) => (as: ReadonlyNonEmptyArray<A>) => B\n```\n\nAdded in v2.11.0\n\n## matchRight\n\nBreak a `ReadonlyArray` into its initial elements and the last element.\n\n**Signature**\n\n```ts\nexport declare const matchRight: <A, B>(f: (init: readonly A[], last: A) => B) => (as: ReadonlyNonEmptyArray<A>) => B\n```\n\nAdded in v2.11.0\n\n# sequencing\n\n## chainFirst\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(\n  f: (a: A) => ReadonlyNonEmptyArray<B>\n) => (first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    RA.chainFirst(() => ['a', 'b'])\n  ),\n  [1, 1, 2, 2, 3, 3]\n)\n```\n\nAdded in v2.5.0\n\n## chainWithIndex\n\n**Signature**\n\n```ts\nexport declare const chainWithIndex: <A, B>(\n  f: (i: number, a: A) => ReadonlyNonEmptyArray<B>\n) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>\n```\n\nAdded in v2.10.0\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A, i: number) => ReadonlyNonEmptyArray<B>): (ma: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>\n  <A, B>(ma: ReadonlyNonEmptyArray<A>, f: (a: A, i: number) => ReadonlyNonEmptyArray<B>): ReadonlyNonEmptyArray<B>\n}\n```\n\n**Example**\n\n```ts\nimport * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(\n  pipe(\n    [1, 2, 3],\n    RNEA.flatMap((n) => [`a${n}`, `b${n}`])\n  ),\n  ['a1', 'b1', 'a2', 'b2', 'a3', 'b3']\n)\n```\n\nAdded in v2.14.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## traverseWithIndex\n\n**Signature**\n\n```ts\nexport declare const traverseWithIndex: PipeableTraverseWithIndex1<'ReadonlyNonEmptyArray', number>\n```\n\nAdded in v2.6.3\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.6.3\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.6.3\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReadonlyNonEmptyArray'\n```\n\nAdded in v2.5.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.5.0\n\n# utils\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(\n  as: ReadonlyNonEmptyArray<A>\n) => <B>(fab: ReadonlyNonEmptyArray<(a: A) => B>) => ReadonlyNonEmptyArray<B>\n```\n\nAdded in v2.5.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(\n  second: ReadonlyNonEmptyArray<B>\n) => <A>(first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(\n  second: ReadonlyNonEmptyArray<B>\n) => <A>(first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>\n```\n\nAdded in v2.5.0\n\n## chop\n\nA useful recursion pattern for processing a `ReadonlyNonEmptyArray` to produce a new `ReadonlyNonEmptyArray`, often used for \"chopping\" up the input\n`ReadonlyNonEmptyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `ReadonlyNonEmptyArray` and produce a\nvalue and the tail of the `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const chop: <A, B>(\n  f: (as: ReadonlyNonEmptyArray<A>) => readonly [B, readonly A[]]\n) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>\n```\n\nAdded in v2.10.0\n\n## chunksOf\n\nSplits a `ReadonlyNonEmptyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\nthe `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const chunksOf: (\n  n: number\n) => <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.10.0\n\n## concat\n\n**Signature**\n\n```ts\nexport declare function concat<A>(\n  second: ReadonlyNonEmptyArray<A>\n): (first: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A>\nexport declare function concat<A>(\n  second: ReadonlyArray<A>\n): (first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\nexport declare function concat<A>(first: ReadonlyArray<A>, second: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A>\nexport declare function concat<A>(first: ReadonlyNonEmptyArray<A>, second: ReadonlyArray<A>): ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## concatAll\n\n**Signature**\n\n```ts\nexport declare const concatAll: <A>(S: Se.Semigroup<A>) => (as: ReadonlyNonEmptyArray<A>) => A\n```\n\nAdded in v2.10.0\n\n## concatW\n\n**Signature**\n\n```ts\nexport declare function concatW<B>(\n  second: ReadonlyNonEmptyArray<B>\n): <A>(first: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A | B>\nexport declare function concatW<B>(\n  second: ReadonlyArray<B>\n): <A>(first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A | B>\n```\n\nAdded in v2.11.0\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <A>(ma: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <A, B>(\n  f: (as: ReadonlyNonEmptyArray<A>) => B\n) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>\n```\n\nAdded in v2.5.0\n\n## getUnionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <A>(E: Eq<A>) => Se.Semigroup<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.11.0\n\n## group\n\nGroup equal, consecutive elements of a `ReadonlyArray` into `ReadonlyNonEmptyArray`s.\n\n**Signature**\n\n```ts\nexport declare function group<B>(E: Eq<B>): {\n  <A extends B>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>\n  <A extends B>(as: ReadonlyArray<A>): ReadonlyArray<ReadonlyNonEmptyArray<A>>\n}\n```\n\n**Example**\n\n```ts\nimport { group } from 'fp-ts/ReadonlyNonEmptyArray'\nimport * as N from 'fp-ts/number'\n\nassert.deepStrictEqual(group(N.Eq)([1, 2, 1, 1]), [[1], [2], [1, 1]])\n```\n\nAdded in v2.5.0\n\n## groupBy\n\nSplits an array 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: <A>(\n  f: (a: A) => string\n) => (as: readonly A[]) => Readonly<Record<string, ReadonlyNonEmptyArray<A>>>\n```\n\n**Example**\n\n```ts\nimport { groupBy } from 'fp-ts/ReadonlyNonEmptyArray'\n\nassert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), {\n  '1': ['a', 'b'],\n  '2': ['ab'],\n})\n```\n\nAdded in v2.5.0\n\n## head\n\n**Signature**\n\n```ts\nexport declare const head: <A>(as: ReadonlyNonEmptyArray<A>) => A\n```\n\nAdded in v2.5.0\n\n## init\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 init: <A>(as: ReadonlyNonEmptyArray<A>) => readonly A[]\n```\n\n**Example**\n\n```ts\nimport { init } from 'fp-ts/ReadonlyNonEmptyArray'\n\nassert.deepStrictEqual(init([1, 2, 3]), [1, 2])\nassert.deepStrictEqual(init([1]), [])\n```\n\nAdded in v2.5.0\n\n## intercalate\n\nPlaces an element in between members of a `ReadonlyNonEmptyArray`, then folds the results using the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const intercalate: <A>(S: Se.Semigroup<A>) => (middle: A) => (as: ReadonlyNonEmptyArray<A>) => A\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { intercalate } from 'fp-ts/ReadonlyNonEmptyArray'\n\nassert.deepStrictEqual(intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c')\n```\n\nAdded in v2.12.0\n\n## intersperse\n\nPlaces an element in between members of a `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const intersperse: <A>(middle: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { intersperse } from 'fp-ts/ReadonlyNonEmptyArray'\n\nassert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])\n```\n\nAdded in v2.9.0\n\n## last\n\n**Signature**\n\n```ts\nexport declare const last: <A>(as: ReadonlyNonEmptyArray<A>) => A\n```\n\nAdded in v2.5.0\n\n## max\n\n**Signature**\n\n```ts\nexport declare const max: <A>(O: Ord<A>) => (as: ReadonlyNonEmptyArray<A>) => A\n```\n\nAdded in v2.5.0\n\n## min\n\n**Signature**\n\n```ts\nexport declare const min: <A>(O: Ord<A>) => (as: ReadonlyNonEmptyArray<A>) => A\n```\n\nAdded in v2.5.0\n\n## modifyAt\n\n**Signature**\n\n```ts\nexport declare const modifyAt: <A>(\n  i: number,\n  f: (a: A) => A\n) => (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n## modifyHead\n\nApply a function to the head, creating a new `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const modifyHead: <A>(f: Endomorphism<A>) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## modifyLast\n\nApply a function to the last element, creating a new `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const modifyLast: <A>(f: Endomorphism<A>) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## prependAll\n\nPrepend an element to every member of a `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const prependAll: <A>(middle: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { prependAll } from 'fp-ts/ReadonlyNonEmptyArray'\n\nassert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])\n```\n\nAdded in v2.10.0\n\n## reverse\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## rotate\n\nRotate a `ReadonlyNonEmptyArray` by `n` steps.\n\n**Signature**\n\n```ts\nexport declare const rotate: (n: number) => <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { rotate } from 'fp-ts/ReadonlyNonEmptyArray'\n\nassert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\nassert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n```\n\nAdded in v2.11.0\n\n## sort\n\n**Signature**\n\n```ts\nexport declare const sort: <B>(O: Ord<B>) => <A extends B>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## sortBy\n\nSort the elements of a `ReadonlyNonEmptyArray` in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,\netc...\n\n**Signature**\n\n```ts\nexport declare const sortBy: <B>(\n  ords: readonly Ord<B>[]\n) => <A extends B>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'\nimport { contramap } from 'fp-ts/Ord'\nimport * as S from 'fp-ts/string'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\ninterface Person {\n  name: string\n  age: number\n}\n\nconst byName = pipe(\n  S.Ord,\n  contramap((p: Person) => p.name)\n)\n\nconst byAge = pipe(\n  N.Ord,\n  contramap((p: Person) => p.age)\n)\n\nconst sortByNameByAge = RNEA.sortBy([byName, byAge])\n\nconst persons: RNEA.ReadonlyNonEmptyArray<Person> = [\n  { name: 'a', age: 1 },\n  { name: 'b', age: 3 },\n  { name: 'c', age: 2 },\n  { name: 'b', age: 2 },\n]\n\nassert.deepStrictEqual(sortByNameByAge(persons), [\n  { name: 'a', age: 1 },\n  { name: 'b', age: 2 },\n  { name: 'b', age: 3 },\n  { name: 'c', age: 2 },\n])\n```\n\nAdded in v2.11.0\n\n## splitAt\n\nSplits a `ReadonlyNonEmptyArray` into two pieces, the first piece has max `n` elements.\n\n**Signature**\n\n```ts\nexport declare const splitAt: (\n  n: number\n) => <A>(as: ReadonlyNonEmptyArray<A>) => readonly [ReadonlyNonEmptyArray<A>, readonly A[]]\n```\n\nAdded in v2.10.0\n\n## tail\n\n**Signature**\n\n```ts\nexport declare const tail: <A>(as: ReadonlyNonEmptyArray<A>) => readonly A[]\n```\n\nAdded in v2.5.0\n\n## unappend\n\nReturn the tuple of the `init` and the `last`.\n\n**Signature**\n\n```ts\nexport declare const unappend: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [readonly A[], A]\n```\n\n**Example**\n\n```ts\nimport { unappend } from 'fp-ts/ReadonlyNonEmptyArray'\n\nassert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4])\n```\n\nAdded in v2.9.0\n\n## union\n\n**Signature**\n\n```ts\nexport declare const union: <A>(\n  E: Eq<A>\n) => (second: ReadonlyNonEmptyArray<A>) => (first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## uniq\n\nRemove duplicates from a `ReadonlyNonEmptyArray`, keeping the first occurrence of an element.\n\n**Signature**\n\n```ts\nexport declare const uniq: <A>(E: Eq<A>) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\n**Example**\n\n```ts\nimport { uniq } from 'fp-ts/ReadonlyNonEmptyArray'\nimport * as N from 'fp-ts/number'\n\nassert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])\n```\n\nAdded in v2.11.0\n\n## unprepend\n\nReturn the tuple of the `head` and the `tail`.\n\n**Signature**\n\n```ts\nexport declare const unprepend: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [A, readonly A[]]\n```\n\n**Example**\n\n```ts\nimport { unprepend } from 'fp-ts/ReadonlyNonEmptyArray'\n\nassert.deepStrictEqual(unprepend([1, 2, 3, 4]), [1, [2, 3, 4]])\n```\n\nAdded in v2.9.0\n\n## unzip\n\n**Signature**\n\n```ts\nexport declare const unzip: <A, B>(\n  abs: ReadonlyNonEmptyArray<readonly [A, B]>\n) => readonly [ReadonlyNonEmptyArray<A>, ReadonlyNonEmptyArray<B>]\n```\n\nAdded in v2.5.1\n\n## updateAt\n\n**Signature**\n\n```ts\nexport declare const updateAt: <A>(\n  i: number,\n  a: A\n) => (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n## updateHead\n\nChange the head, creating a new `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const updateHead: <A>(a: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## updateLast\n\nChange the last element, creating a new `ReadonlyNonEmptyArray`.\n\n**Signature**\n\n```ts\nexport declare const updateLast: <A>(a: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.11.0\n\n## zip\n\n**Signature**\n\n```ts\nexport declare function zip<B>(\n  bs: ReadonlyNonEmptyArray<B>\n): <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<readonly [A, B]>\nexport declare function zip<A, B>(\n  as: ReadonlyNonEmptyArray<A>,\n  bs: ReadonlyNonEmptyArray<B>\n): ReadonlyNonEmptyArray<readonly [A, B]>\n```\n\nAdded in v2.5.1\n\n## zipWith\n\n**Signature**\n\n```ts\nexport declare const zipWith: <A, B, C>(\n  as: ReadonlyNonEmptyArray<A>,\n  bs: ReadonlyNonEmptyArray<B>,\n  f: (a: A, b: B) => C\n) => ReadonlyNonEmptyArray<C>\n```\n\nAdded in v2.5.1\n\n# zone of death\n\n## ~~cons~~\n\nUse [`prepend`](./ReadonlyArray.ts.html#prepend) instead.\n\n**Signature**\n\n```ts\nexport declare function cons<A>(head: A): (tail: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A>\nexport declare function cons<A>(head: A, tail: ReadonlyArray<A>): ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## ~~filterWithIndex~~\n\nUse [`filterWithIndex`](./ReadonlyArray.ts.html#filterwithindex) instead.\n\n**Signature**\n\n```ts\nexport declare const filterWithIndex: <A>(\n  predicate: (i: number, a: A) => boolean\n) => (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n## ~~filter~~\n\nUse [`filter`](./ReadonlyArray.ts.html#filter) instead.\n\n**Signature**\n\n```ts\nexport declare function filter<A, B extends A>(\n  refinement: Refinement<A, B>\n): (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<B>>\nexport declare function filter<A>(\n  predicate: Predicate<A>\n): <B extends A>(bs: ReadonlyNonEmptyArray<B>) => Option<ReadonlyNonEmptyArray<B>>\nexport declare function filter<A>(\n  predicate: Predicate<A>\n): (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n## ~~fold~~\n\nUse [`concatAll`](#concatall) instead.\n\n**Signature**\n\n```ts\nexport declare const fold: <A>(S: Se.Semigroup<A>) => (as: ReadonlyNonEmptyArray<A>) => A\n```\n\nAdded in v2.5.0\n\n## ~~groupSort~~\n\nThis is just `sort` followed by `group`.\n\n**Signature**\n\n```ts\nexport declare function groupSort<B>(O: Ord<B>): {\n  <A extends B>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>\n  <A extends B>(as: ReadonlyArray<A>): ReadonlyArray<ReadonlyNonEmptyArray<A>>\n}\n```\n\nAdded in v2.5.0\n\n## ~~insertAt~~\n\nUse [`insertAt`](./ReadonlyArray.ts.html#insertat) instead.\n\n**Signature**\n\n```ts\nexport declare const insertAt: <A>(i: number, a: A) => (as: readonly A[]) => Option<ReadonlyNonEmptyArray<A>>\n```\n\nAdded in v2.5.0\n\n## ~~prependToAll~~\n\nUse [`prependAll`](#prependall) instead.\n\n**Signature**\n\n```ts\nexport declare const prependToAll: <A>(middle: A) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.9.0\n\n## ~~readonlyNonEmptyArray~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RNEA.Functor` instead of `RNEA.readonlyNonEmptyArray`\n(where `RNEA` is from `import RNEA from 'fp-ts/ReadonlyNonEmptyArray'`)\n\n**Signature**\n\n```ts\nexport declare const readonlyNonEmptyArray: Monad1<'ReadonlyNonEmptyArray'> &\n  Comonad1<'ReadonlyNonEmptyArray'> &\n  TraversableWithIndex1<'ReadonlyNonEmptyArray', number> &\n  FunctorWithIndex1<'ReadonlyNonEmptyArray', number> &\n  FoldableWithIndex1<'ReadonlyNonEmptyArray', number> &\n  Alt1<'ReadonlyNonEmptyArray'>\n```\n\nAdded in v2.5.0\n\n## ~~snoc~~\n\nUse [`append`](./ReadonlyArray.ts.html#append) instead.\n\n**Signature**\n\n```ts\nexport declare const snoc: <A>(init: readonly A[], end: A) => ReadonlyNonEmptyArray<A>\n```\n\nAdded in v2.5.0\n\n## ~~uncons~~\n\nUse [`unprepend`](#unprepend) instead.\n\n**Signature**\n\n```ts\nexport declare const uncons: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [A, readonly A[]]\n```\n\nAdded in v2.10.0\n\n## ~~unsnoc~~\n\nUse [`unappend`](#unappend) instead.\n\n**Signature**\n\n```ts\nexport declare const unsnoc: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [readonly A[], A]\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/ReadonlyRecord.ts.md",
    "content": "---\ntitle: ReadonlyRecord.ts\nnav_order: 86\nparent: Modules\n---\n\n## ReadonlyRecord overview\n\nThe `ReadonlyRecord.ts` module enables dealing in a functional way with\nTypescript's `Readonly<Record<K, T>>` type. That is similar to the\n`Record.ts` module, but for a record with all properties\ndeclared as `readonly`.\n\nAdded in v2.5.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [singleton](#singleton)\n- [conversions](#conversions)\n  - [fromEntries](#fromentries)\n  - [fromRecord](#fromrecord)\n  - [toEntries](#toentries)\n  - [toReadonlyArray](#toreadonlyarray)\n  - [toRecord](#torecord)\n  - [toUnfoldable](#tounfoldable)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [getWitherable](#getwitherable)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [separate](#separate)\n  - [wilt](#wilt)\n  - [wither](#wither)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [getFoldable](#getfoldable)\n  - [getFoldableWithIndex](#getfoldablewithindex)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [Compactable](#compactable)\n  - [Filterable](#filterable)\n  - [FilterableWithIndex](#filterablewithindex)\n  - [Functor](#functor)\n  - [FunctorWithIndex](#functorwithindex)\n  - [getDifferenceMagma](#getdifferencemagma)\n  - [getEq](#geteq)\n  - [getIntersectionSemigroup](#getintersectionsemigroup)\n  - [getMonoid](#getmonoid)\n  - [getShow](#getshow)\n  - [getUnionMonoid](#getunionmonoid)\n  - [getUnionSemigroup](#getunionsemigroup)\n- [mapping](#mapping)\n  - [flap](#flap)\n- [model](#model)\n  - [ReadonlyRecord (type alias)](#readonlyrecord-type-alias)\n- [traversing](#traversing)\n  - [getTraversable](#gettraversable)\n  - [getTraversableWithIndex](#gettraversablewithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [collect](#collect)\n  - [deleteAt](#deleteat)\n  - [difference](#difference)\n  - [elem](#elem)\n  - [empty](#empty)\n  - [every](#every)\n  - [filterMapWithIndex](#filtermapwithindex)\n  - [filterWithIndex](#filterwithindex)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [fromFoldable](#fromfoldable)\n  - [fromFoldableMap](#fromfoldablemap)\n  - [has](#has)\n  - [intersection](#intersection)\n  - [isEmpty](#isempty)\n  - [isSubrecord](#issubrecord)\n  - [keys](#keys)\n  - [lookup](#lookup)\n  - [map](#map)\n  - [mapWithIndex](#mapwithindex)\n  - [modifyAt](#modifyat)\n  - [partitionMapWithIndex](#partitionmapwithindex)\n  - [partitionWithIndex](#partitionwithindex)\n  - [pop](#pop)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n  - [sequence](#sequence)\n  - [size](#size)\n  - [some](#some)\n  - [traverse](#traverse)\n  - [traverseWithIndex](#traversewithindex)\n  - [union](#union)\n  - [updateAt](#updateat)\n  - [upsertAt](#upsertat)\n- [zone of death](#zone-of-death)\n  - [~~FoldableWithIndex~~](#foldablewithindex)\n  - [~~Foldable~~](#foldable)\n  - [~~TraversableWithIndex~~](#traversablewithindex)\n  - [~~Traversable~~](#traversable)\n  - [~~Witherable~~](#witherable)\n  - [~~hasOwnProperty (function)~~](#hasownproperty-function)\n  - [~~insertAt~~](#insertat)\n  - [~~readonlyRecord~~](#readonlyrecord)\n\n---\n\n# constructors\n\n## singleton\n\nCreate a `ReadonlyRecord` with one key/value pair.\n\n**Signature**\n\n```ts\nexport declare const singleton: <A>(k: string, a: A) => Readonly<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { singleton } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(singleton('a', 1), { a: 1 })\n```\n\nAdded in v2.5.0\n\n# conversions\n\n## fromEntries\n\nConverts a `ReadonlyArray` of `[key, value]` tuples into a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare const fromEntries: <A>(fa: readonly (readonly [string, A])[]) => Readonly<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { fromEntries } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(\n  fromEntries([\n    ['a', 1],\n    ['b', 2],\n    ['a', 3],\n  ]),\n  { b: 2, a: 3 }\n)\n```\n\nAdded in v2.12.0\n\n## fromRecord\n\nBuilds a `ReadonlyRecord` by copying a `Record`.\n\n**Signature**\n\n```ts\nexport declare const fromRecord: <K extends string, A>(r: Record<K, A>) => Readonly<Record<K, A>>\n```\n\n**Example**\n\n```ts\nimport { ReadonlyRecord, fromRecord } from 'fp-ts/ReadonlyRecord'\n\nconst x: Record<string, number> = { a: 1, b: 2 }\nconst y: ReadonlyRecord<string, number> = fromRecord(x)\nassert.deepStrictEqual(x, y)\n// `y.a = 5` gives compiler error\n```\n\nAdded in v2.5.0\n\n## toEntries\n\nAlias of [`toReadonlyArray`](#toreadonlyarray).\n\n**Signature**\n\n```ts\nexport declare const toEntries: <K extends string, A>(r: Readonly<Record<K, A>>) => readonly (readonly [K, A])[]\n```\n\n**Example**\n\n```ts\nimport { toEntries } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(toEntries({ b: 2, a: 1 }), [\n  ['a', 1],\n  ['b', 2],\n])\n```\n\nAdded in v2.12.0\n\n## toReadonlyArray\n\nGet a sorted `ReadonlyArray` of the key/value pairs contained in a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare const toReadonlyArray: <K extends string, A>(r: Readonly<Record<K, A>>) => readonly (readonly [K, A])[]\n```\n\n**Example**\n\n```ts\nimport { toReadonlyArray } from 'fp-ts/ReadonlyRecord'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(toReadonlyArray(x), [\n  ['a', 'foo'],\n  ['b', false],\n  ['c', 3],\n])\n```\n\nAdded in v2.5.0\n\n## toRecord\n\nBuilds a mutable `Record` from a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare const toRecord: <K extends string, A>(r: Readonly<Record<K, A>>) => Record<K, A>\n```\n\n**Example**\n\n```ts\nimport { ReadonlyRecord, toRecord } from 'fp-ts/ReadonlyRecord'\n\nconst x: ReadonlyRecord<string, number> = { a: 1, b: 2 }\nconst y: Record<string, number> = toRecord(x)\nassert.deepStrictEqual(x, y)\ny.a = 5 // it's ok, y is mutable\n```\n\nAdded in v2.5.0\n\n## toUnfoldable\n\nUnfolds a `ReadonlyRecord` into a list of key/value pairs.\n\nGiven an `Unfoldable` class type `U` such as `array` or `readonlyArray`,\nit uses the `unfold` function to create an instance of `U`,\nproviding an iterating function that iterates over each\nkey/value pair in the record sorted alphabetically by key.\n\n**Signature**\n\n```ts\nexport declare function toUnfoldable<F extends URIS>(\n  U: Unfoldable1<F>\n): <K extends string, A>(r: ReadonlyRecord<K, A>) => Kind<F, readonly [K, A]>\nexport declare function toUnfoldable<F>(\n  U: Unfoldable<F>\n): <K extends string, A>(r: ReadonlyRecord<K, A>) => HKT<F, readonly [K, A]>\n```\n\n**Example**\n\n```ts\nimport { array, readonlyArray } from 'fp-ts'\nimport { toUnfoldable } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(toUnfoldable(array)({ b: 2, a: 1 }), [\n  ['a', 1],\n  ['b', 2],\n])\nassert.deepStrictEqual(toUnfoldable(readonlyArray)({ b: 2, a: 1 }), [\n  ['a', 1],\n  ['b', 2],\n])\n```\n\nAdded in v2.5.0\n\n# filtering\n\n## compact\n\nCompact a `ReadonlyRecord` of `Option`s discarding the `None` values and\nkeeping the `Some` values.\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(r: Readonly<Record<string, Option<A>>>) => Readonly<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { compact } from 'fp-ts/ReadonlyRecord'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(compact({ a: option.some('foo'), b: option.none, c: option.some('bar') }), {\n  a: 'foo',\n  c: 'bar',\n})\n```\n\nAdded in v2.5.0\n\n## filter\n\nGiven a `Predicate`, it produces a new `ReadonlyRecord` keeping only the entries with a\nvalue that satisfies the provided predicate.\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Readonly<Record<string, A>>) => Readonly<Record<string, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: Readonly<Record<string, B>>) => Readonly<Record<string, B>>\n  <A>(predicate: Predicate<A>): (fa: Readonly<Record<string, A>>) => Readonly<Record<string, A>>\n}\n```\n\n**Example**\n\n```ts\nimport { filter } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(filter((s: string) => s.length < 4)({ a: 'foo', b: 'bar', c: 'verylong' }), {\n  a: 'foo',\n  b: 'bar',\n})\n```\n\nAdded in v2.5.0\n\n## filterMap\n\nMaps a `ReadonlyRecord` with an iterating function that returns an `Option`\nand it keeps only the `Some` values discarding the `None`s.\n\n**Signature**\n\n```ts\nexport declare const filterMap: <A, B>(\n  f: (a: A) => Option<B>\n) => (fa: Readonly<Record<string, A>>) => Readonly<Record<string, B>>\n```\n\n**Example**\n\n```ts\nimport { filterMap } from 'fp-ts/ReadonlyRecord'\nimport { option } from 'fp-ts'\n\nconst f = (s: string) => (s.length < 4 ? option.some(`${s} is short`) : option.none)\nassert.deepStrictEqual(filterMap(f)({ a: 'foo', b: 'bar', c: 'verylong' }), {\n  a: 'foo is short',\n  b: 'bar is short',\n})\n```\n\nAdded in v2.5.0\n\n## getWitherable\n\n**Signature**\n\n```ts\nexport declare const getWitherable: (O: Ord<string>) => Witherable1<URI>\n```\n\nAdded in v2.11.0\n\n## partition\n\nPartition a `ReadonlyRecord` into two parts according to a `Predicate`.\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fa: Readonly<Record<string, A>>\n  ) => Separated<Readonly<Record<string, A>>, Readonly<Record<string, B>>>\n  <A>(predicate: Predicate<A>): <B extends A>(\n    fb: Readonly<Record<string, B>>\n  ) => Separated<Readonly<Record<string, B>>, Readonly<Record<string, B>>>\n  <A>(predicate: Predicate<A>): (\n    fa: Readonly<Record<string, A>>\n  ) => Separated<Readonly<Record<string, A>>, Readonly<Record<string, A>>>\n}\n```\n\n**Example**\n\n```ts\nimport { partition } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(partition((s: string) => s.length < 4)({ a: 'foo', b: 'bar', c: 'verylong' }), {\n  left: {\n    c: 'verylong',\n  },\n  right: {\n    a: 'foo',\n    b: 'bar',\n  },\n})\n```\n\nAdded in v2.5.0\n\n## partitionMap\n\nMaps a `ReadonlyRecord` with a function returning an `Either` and\npartitions the resulting `ReadonlyRecord` into `Left`s and `Right`s.\n\n**Signature**\n\n```ts\nexport declare const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: Readonly<Record<string, A>>) => Separated<Readonly<Record<string, B>>, Readonly<Record<string, C>>>\n```\n\n**Example**\n\n```ts\nimport { partitionMap } from 'fp-ts/ReadonlyRecord'\nimport { either } from 'fp-ts'\n\nconst f = (s: string) => (s.length < 4 ? either.right(`${s} is short`) : either.left(`${s} is not short`))\nassert.deepStrictEqual(partitionMap(f)({ a: 'foo', b: 'bar', c: 'verylong' }), {\n  left: {\n    c: 'verylong is not short',\n  },\n  right: {\n    a: 'foo is short',\n    b: 'bar is short',\n  },\n})\n```\n\nAdded in v2.5.0\n\n## separate\n\nSeparate a `ReadonlyRecord` of `Either`s into `Left`s and `Right`s.\n\n**Signature**\n\n```ts\nexport declare const separate: <A, B>(\n  r: Readonly<Record<string, Either<A, B>>>\n) => Separated<Readonly<Record<string, A>>, Readonly<Record<string, B>>>\n```\n\n**Example**\n\n```ts\nimport { separate } from 'fp-ts/ReadonlyRecord'\nimport { either } from 'fp-ts'\n\nassert.deepStrictEqual(separate({ a: either.right('foo'), b: either.left('bar'), c: either.right('baz') }), {\n  right: {\n    a: 'foo',\n    c: 'baz',\n  },\n  left: {\n    b: 'bar',\n  },\n})\n```\n\nAdded in v2.5.0\n\n## wilt\n\n**Signature**\n\n```ts\nexport declare const wilt: PipeableWilt1<'ReadonlyRecord'>\n```\n\nAdded in v2.6.5\n\n## wither\n\n**Signature**\n\n```ts\nexport declare const wither: PipeableWither1<'ReadonlyRecord'>\n```\n\nAdded in v2.6.5\n\n# folding\n\n## foldMap\n\nMap and fold a `ReadonlyRecord`.\nMap the `ReadonlyRecord` passing each value to the iterating function.\nThen fold the results using the provided `Monoid`.\n\n**Signature**\n\n```ts\nexport declare function foldMap(\n  O: Ord<string>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: ReadonlyRecord<string, A>) => M\nexport declare function foldMap<M>(M: Monoid<M>): <A>(f: (a: A) => M) => (fa: ReadonlyRecord<string, A>) => M\n```\n\n**Example**\n\n```ts\nimport { foldMap } from 'fp-ts/ReadonlyRecord'\nimport { Ord } from 'fp-ts/string'\nimport { Monoid } from 'fp-ts/Monoid'\n\nconst m: Monoid<string> = { empty: '', concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) }\nconst f = (a: number) => `-${a}-`\nconst x = { c: 3, a: 1, b: 2 }\nassert.deepStrictEqual(foldMap(Ord)(m)(f)(x), '-1- -> -2- -> -3-')\n```\n\nAdded in v2.5.0\n\n## getFoldable\n\nProduces a `Foldable` instance for a `ReadonlyRecord`, using the\nprovided `Ord` to sort the `ReadonlyRecord`'s entries by key.\n\n**Signature**\n\n```ts\nexport declare const getFoldable: (O: Ord<string>) => Foldable1<URI>\n```\n\nAdded in v2.11.0\n\n## getFoldableWithIndex\n\nProduces a `FoldableWithIndex1` instance for a `ReadonlyRecord`, using the\nprovided `Ord` to sort the `ReadonlyRecord`'s entries by key.\n\n**Signature**\n\n```ts\nexport declare const getFoldableWithIndex: (O: Ord<string>) => FoldableWithIndex1<URI, string>\n```\n\nAdded in v2.11.0\n\n## reduce\n\nReduces a `ReadonlyRecord` passing each value to the iterating function.\nEntries are processed in order, sorted by key according to\nthe given `Ord`.\n\n**Signature**\n\n```ts\nexport declare function reduce(\n  O: Ord<string>\n): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: ReadonlyRecord<string, A>) => B\nexport declare function reduce<A, B>(b: B, f: (b: B, a: A) => B): (fa: ReadonlyRecord<string, A>) => B\n```\n\n**Example**\n\n```ts\nimport { reduce } from 'fp-ts/ReadonlyRecord'\nimport { Ord } from 'fp-ts/string'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(reduce(Ord)([] as string[], (b, a) => [...b, `-${a}-`])(x), ['-foo-', '-false-', '-3-'])\n```\n\nAdded in v2.5.0\n\n## reduceRight\n\nSame as `reduce` but entries are processed _from the right_,\ni.e. in reverse order, from the last to the first entry, according to\nthe given `Ord`.\n\n**Signature**\n\n```ts\nexport declare function reduceRight(\n  O: Ord<string>\n): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: ReadonlyRecord<string, A>) => B\nexport declare function reduceRight<A, B>(b: B, f: (a: A, b: B) => B): (fa: ReadonlyRecord<string, A>) => B\n```\n\n**Example**\n\n```ts\nimport { reduceRight } from 'fp-ts/ReadonlyRecord'\nimport { Ord } from 'fp-ts/string'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(reduceRight(Ord)([] as string[], (a, b) => [...b, `-${a}-`])(x), ['-3-', '-false-', '-foo-'])\n```\n\nAdded in v2.5.0\n\n# instances\n\n## Compactable\n\n**Signature**\n\n```ts\nexport declare const Compactable: Compactable1<'ReadonlyRecord'>\n```\n\nAdded in v2.7.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: Filterable1<'ReadonlyRecord'>\n```\n\nAdded in v2.7.0\n\n## FilterableWithIndex\n\n**Signature**\n\n```ts\nexport declare const FilterableWithIndex: FilterableWithIndex1<'ReadonlyRecord', string>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'ReadonlyRecord'>\n```\n\nAdded in v2.7.0\n\n## FunctorWithIndex\n\n**Signature**\n\n```ts\nexport declare const FunctorWithIndex: FunctorWithIndex1<'ReadonlyRecord', string>\n```\n\nAdded in v2.7.0\n\n## getDifferenceMagma\n\nProduces a `Magma` with a `concat` function that combines\ntwo `ReadonlyRecord`s by making the `difference`.\n\n**Signature**\n\n```ts\nexport declare const getDifferenceMagma: <A>() => Magma<Readonly<Record<string, A>>>\n```\n\n**Example**\n\n```ts\nimport { getDifferenceMagma, difference, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'\nimport { Magma } from 'fp-ts/Magma'\n\nconst r1 = { a: 3, c: 3 }\nconst r2 = { a: 1, b: 2 }\nconst m: Magma<ReadonlyRecord<string, number>> = getDifferenceMagma<number>()\nassert.deepStrictEqual(m.concat(r1, r2), difference(r2)(r1))\nassert.deepStrictEqual(m.concat(r1, r2), { c: 3, b: 2 })\n```\n\nAdded in v2.11.0\n\n## getEq\n\nGiven an `Eq` for the base type, it produces an `Eq`\nfor a `ReadonlyRecord` of that base type.\n\n**Signature**\n\n```ts\nexport declare function getEq<K extends string, A>(E: Eq<A>): Eq<ReadonlyRecord<K, A>>\n```\n\n**Example**\n\n```ts\nimport { getEq, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'\nimport { string } from 'fp-ts'\nimport { Eq } from 'fp-ts/Eq'\n\nconst eq: Eq<ReadonlyRecord<string, string>> = getEq(string.Eq)\nassert.deepStrictEqual(eq.equals({ a: 'foo' }, { b: 'bar' }), false)\nassert.deepStrictEqual(eq.equals({ a: 'foo' }, { a: 'foo' }), true)\n```\n\nAdded in v2.5.0\n\n## getIntersectionSemigroup\n\nGiven a `Semigroup` in the base type, it produces a `Semigroup`\nin the `ReadonlyRecord` of the base type.\nThe resulting `Semigroup` concatenates two `ReadonlyRecord`s by\n`intersection`.\n\n**Signature**\n\n```ts\nexport declare const getIntersectionSemigroup: <A>(S: Se.Semigroup<A>) => Se.Semigroup<Readonly<Record<string, A>>>\n```\n\n**Example**\n\n```ts\nimport { getIntersectionSemigroup, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'\nimport { Semigroup } from 'fp-ts/Semigroup'\n\nconst sNumber: Semigroup<number> = { concat: (x, y) => x - y }\nconst sReadonlyRecord: Semigroup<ReadonlyRecord<string, number>> = getIntersectionSemigroup(sNumber)\nassert.deepStrictEqual(sReadonlyRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { b: -1 })\n```\n\nAdded in v2.11.0\n\n## getMonoid\n\nReturns a `Monoid` instance for `ReadonlyRecord`s, given a `Semigroup`\ninstance for the base type.\nThe `Monoid` makes the union of two `ReadonlyRecord`s comining the\noverlapping entries with the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare function getMonoid<K extends string, A>(S: Semigroup<A>): Monoid<ReadonlyRecord<K, A>>\n```\n\n**Example**\n\n```ts\nimport { SemigroupSum } from 'fp-ts/number'\nimport { getMonoid } from 'fp-ts/ReadonlyRecord'\n\nconst M = getMonoid(SemigroupSum)\nassert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579, bar: 234, baz: 567 })\n```\n\nAdded in v2.5.0\n\n## getShow\n\nProduces a `Show` for a `ReadonlyRecord`, given a `Show` for the base type\n(a `Show` produces a human-readable representation of an instance).\n`ReadonlyRecord` entries are sorted by key with the provided `Ord`.\n\n**Signature**\n\n```ts\nexport declare function getShow(O: Ord<string>): <A>(S: Show<A>) => Show<ReadonlyRecord<string, A>>\nexport declare function getShow<A>(S: Show<A>): Show<ReadonlyRecord<string, A>>\n```\n\n**Example**\n\n```ts\nimport { getShow, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'\nimport { Show } from 'fp-ts/Show'\nimport { Ord } from 'fp-ts/string'\n\nconst sNumber: Show<number> = { show: (n: number) => `${n}` }\nconst sRecord: Show<ReadonlyRecord<string, number>> = getShow(Ord)(sNumber)\nassert.deepStrictEqual(sRecord.show({ b: 2, a: 1 }), '{ \"a\": 1, \"b\": 2 }')\n```\n\nAdded in v2.5.0\n\n## getUnionMonoid\n\nSame as `getMonoid`.\nReturns a `Monoid` instance for `ReadonlyRecord`s given a `Semigroup`\ninstance for the base type.\nThe `Monoid` makes the union of two `ReadonlyRecord`s combining the\nentries that have the same key with the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const getUnionMonoid: <A>(S: Se.Semigroup<A>) => Monoid<Readonly<Record<string, A>>>\n```\n\n**Example**\n\n```ts\nimport { SemigroupSum } from 'fp-ts/number'\nimport { getUnionMonoid } from 'fp-ts/ReadonlyRecord'\n\nconst M = getUnionMonoid(SemigroupSum)\nassert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579, bar: 234, baz: 567 })\n```\n\nAdded in v2.11.0\n\n## getUnionSemigroup\n\nGiven a `Semigroup` in the base type, it produces a `Semigroup`\nin the `ReadonlyRecord` of the base type.\nThe resulting `Semigroup` concatenates two `ReadonlyRecord`s by\n`union`.\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <A>(S: Se.Semigroup<A>) => Se.Semigroup<Readonly<Record<string, A>>>\n```\n\n**Example**\n\n```ts\nimport { getUnionSemigroup, ReadonlyRecord } from 'fp-ts/ReadonlyRecord'\nimport { Semigroup } from 'fp-ts/Semigroup'\n\nconst sNumber: Semigroup<number> = { concat: (x, y) => x - y }\nconst sReadonlyRecord: Semigroup<ReadonlyRecord<string, number>> = getUnionSemigroup(sNumber)\nassert.deepStrictEqual(sReadonlyRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { a: 1, b: -1, c: 4 })\n```\n\nAdded in v2.11.0\n\n# mapping\n\n## flap\n\nTakes a value and a `ReadonlyRecord` of functions and returns a\n`ReadonlyRecord` by applying each function to the input value.\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: Readonly<Record<string, (a: A) => B>>) => Readonly<Record<string, B>>\n```\n\n**Example**\n\n```ts\nimport { flap } from 'fp-ts/ReadonlyRecord'\n\nconst fab = { x: (n: number) => `${n} times 2`, y: (n: number) => `${n * 2}` }\nassert.deepStrictEqual(flap(3)(fab), {\n  x: '3 times 2',\n  y: '6',\n})\n```\n\nAdded in v2.10.0\n\n# model\n\n## ReadonlyRecord (type alias)\n\n**Signature**\n\n```ts\nexport type ReadonlyRecord<K extends string, T> = Readonly<Record<K, T>>\n```\n\nAdded in v2.5.0\n\n# traversing\n\n## getTraversable\n\nProduces a `Traversable` instance for a `ReadonlyRecord`, using the\nprovided `Ord` to sort the `ReadonlyRecord`'s entries by key.\n\n**Signature**\n\n```ts\nexport declare const getTraversable: (O: Ord<string>) => Traversable1<URI>\n```\n\nAdded in v2.11.0\n\n## getTraversableWithIndex\n\nProduces a `TraversableWithIndex` instance for a `ReadonlyRecord`, using the\nprovided `Ord` to sort the `ReadonlyRecord`'s entries by key.\n\n**Signature**\n\n```ts\nexport declare const getTraversableWithIndex: (O: Ord<string>) => TraversableWithIndex1<URI, string>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReadonlyRecord'\n```\n\nAdded in v2.5.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.5.0\n\n# utils\n\n## collect\n\nMap a `ReadonlyRecord` into an `ReadonlyArray`.\n\n**Signature**\n\n```ts\nexport declare function collect(\n  O: Ord<string>\n): <K extends string, A, B>(f: (k: K, a: A) => B) => (r: ReadonlyRecord<K, A>) => ReadonlyArray<B>\nexport declare function collect<K extends string, A, B>(\n  f: (k: K, a: A) => B\n): (r: ReadonlyRecord<K, A>) => ReadonlyArray<B>\n```\n\n**Example**\n\n```ts\nimport { collect } from 'fp-ts/ReadonlyRecord'\nimport { Ord } from 'fp-ts/string'\n\nconst f = <A>(k: string, a: A) => `${k.toUpperCase()}-${a}`\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(collect(Ord)(f)(x), ['A-foo', 'B-false', 'C-3'])\n```\n\nAdded in v2.5.0\n\n## deleteAt\n\nDelete a key and value from a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare function deleteAt<K extends string>(\n  k: K\n): <KS extends string, A>(r: ReadonlyRecord<KS, A>) => ReadonlyRecord<string extends K ? string : Exclude<KS, K>, A>\n```\n\n**Example**\n\n```ts\nimport { deleteAt } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(deleteAt('a')({ a: 1, b: 2 }), { b: 2 })\nassert.deepStrictEqual(deleteAt('c')({ a: 1, b: 2 }), { a: 1, b: 2 })\n```\n\nAdded in v2.5.0\n\n## difference\n\nDifference between two `ReadonlyRecord`s.\nTakes two `ReadonlyRecord`s and produces a `ReadonlyRecord` composed by the\nentries of the two inputs, removing the entries with the same\nkey in both inputs.\n\n**Signature**\n\n```ts\nexport declare const difference: <A>(\n  second: Readonly<Record<string, A>>\n) => (first: Readonly<Record<string, A>>) => Readonly<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { difference } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(difference({ a: 1 })({ a: 1, b: 2 }), { b: 2 })\nassert.deepStrictEqual(difference({ a: 3 })({ a: 1, b: 2 }), { b: 2 })\nassert.deepStrictEqual(difference({ a: 3, c: 3 })({ a: 1, b: 2 }), { b: 2, c: 3 })\n```\n\nAdded in v2.11.0\n\n## elem\n\nGiven an `Eq` checks if a `ReadonlyRecord` contains an entry with\nvalue equal to a provided value.\n\n**Signature**\n\n```ts\nexport declare function elem<A>(E: Eq<A>): {\n  (a: A): (fa: ReadonlyRecord<string, A>) => boolean\n  (a: A, fa: ReadonlyRecord<string, A>): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { elem } from 'fp-ts/ReadonlyRecord'\nimport { number } from 'fp-ts'\n\nassert.deepStrictEqual(elem(number.Eq)(123, { foo: 123, bar: 234 }), true)\nassert.deepStrictEqual(elem(number.Eq)(-7, { foo: 123, bar: 234 }), false)\n```\n\nAdded in v2.5.0\n\n## empty\n\n**Signature**\n\n```ts\nexport declare const empty: Readonly<Record<string, never>>\n```\n\nAdded in v2.5.0\n\n## every\n\nTest if every value in a `ReadonlyRecord` satisfies the predicate.\n\n**Signature**\n\n```ts\nexport declare function every<A, B extends A>(\n  refinement: Refinement<A, B>\n): Refinement<ReadonlyRecord<string, A>, ReadonlyRecord<string, B>>\nexport declare function every<A>(predicate: Predicate<A>): Predicate<ReadonlyRecord<string, A>>\n```\n\n**Example**\n\n```ts\nimport { every } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: 2 }), true)\nassert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: -1 }), false)\n```\n\nAdded in v2.5.0\n\n## filterMapWithIndex\n\nMaps a `ReadonlyRecord` with an iterating function that takes key and value and\nreturns an `Option`, keeping only the `Some` values and discarding `None`s.\n\n**Signature**\n\n```ts\nexport declare function filterMapWithIndex<K extends string, A, B>(\n  f: (key: K, a: A) => Option<B>\n): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<string, B>\n```\n\n**Example**\n\n```ts\nimport { filterMapWithIndex } from 'fp-ts/ReadonlyRecord'\nimport { option } from 'fp-ts'\n\nconst f = (key: string, a: number) => (a >= 0 ? option.some(`${key}${a}`) : option.none)\nassert.deepStrictEqual(filterMapWithIndex(f)({ a: -1, b: 2, c: 3 }), {\n  b: 'b2',\n  c: 'c3',\n})\n```\n\nAdded in v2.5.0\n\n## filterWithIndex\n\nProduce a new `ReadonlyRecord` keeping only the entries that satisfy\na predicate taking key and value as input.\n\n**Signature**\n\n```ts\nexport declare function filterWithIndex<K extends string, A, B extends A>(\n  refinementWithIndex: RefinementWithIndex<K, A, B>\n): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<string, B>\nexport declare function filterWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): <B extends A>(fb: ReadonlyRecord<K, B>) => ReadonlyRecord<string, B>\nexport declare function filterWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<string, A>\n```\n\n**Example**\n\n```ts\nimport { filterWithIndex } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(filterWithIndex((s: string, v: number) => s.length <= 1 && v > 0)({ a: 1, b: -2, ccc: 3 }), {\n  a: 1,\n})\n```\n\nAdded in v2.5.0\n\n## foldMapWithIndex\n\nMap and fold a `ReadonlyRecord`.\nMap the `ReadonlyRecord` passing each key/value pair to the iterating function.\nThen fold the results using the provided `Monoid`.\n\n**Signature**\n\n```ts\nexport declare function foldMapWithIndex(\n  O: Ord<string>\n): <M>(M: Monoid<M>) => <K extends string, A>(f: (k: K, a: A) => M) => (fa: ReadonlyRecord<K, A>) => M\nexport declare function foldMapWithIndex<M>(\n  M: Monoid<M>\n): <K extends string, A>(f: (k: K, a: A) => M) => (fa: ReadonlyRecord<K, A>) => M\n```\n\n**Example**\n\n```ts\nimport { foldMapWithIndex } from 'fp-ts/ReadonlyRecord'\nimport { Ord } from 'fp-ts/string'\nimport { Monoid } from 'fp-ts/Monoid'\n\nconst m: Monoid<string> = { empty: '', concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) }\nconst f = (k: string, a: number) => `${k}-${a}`\nconst x = { c: 3, a: 1, b: 2 }\nassert.deepStrictEqual(foldMapWithIndex(Ord)(m)(f)(x), 'a-1 -> b-2 -> c-3')\n```\n\nAdded in v2.5.0\n\n## fromFoldable\n\nCreate a `ReadonlyRecord` from a foldable collection of key/value pairs, using the\nspecified `Magma` to combine values for duplicate keys.\n\n**Signature**\n\n```ts\nexport declare function fromFoldable<F extends URIS3, A>(\n  M: Magma<A>,\n  F: Foldable3<F>\n): <R, E>(fka: Kind3<F, R, E, readonly [string, A]>) => ReadonlyRecord<string, A>\nexport declare function fromFoldable<F extends URIS2, A>(\n  M: Magma<A>,\n  F: Foldable2<F>\n): <E>(fka: Kind2<F, E, readonly [string, A]>) => ReadonlyRecord<string, A>\nexport declare function fromFoldable<F extends URIS, A>(\n  M: Magma<A>,\n  F: Foldable1<F>\n): (fka: Kind<F, readonly [string, A]>) => ReadonlyRecord<string, A>\nexport declare function fromFoldable<F, A>(\n  M: Magma<A>,\n  F: FoldableHKT<F>\n): (fka: HKT<F, readonly [string, A]>) => ReadonlyRecord<string, A>\n```\n\nAdded in v2.5.0\n\n## fromFoldableMap\n\nCreate a `ReadonlyRecord` from a foldable collection using the specified functions to:\n\n- map to key/value pairs\n- combine values for duplicate keys.\n\n**Signature**\n\n```ts\nexport declare function fromFoldableMap<F extends URIS3, B>(\n  M: Magma<B>,\n  F: Foldable3<F>\n): <R, E, A>(fa: Kind3<F, R, E, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>\nexport declare function fromFoldableMap<F extends URIS2, B>(\n  M: Magma<B>,\n  F: Foldable2<F>\n): <E, A>(fa: Kind2<F, E, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>\nexport declare function fromFoldableMap<F extends URIS, B>(\n  M: Magma<B>,\n  F: Foldable1<F>\n): <A>(fa: Kind<F, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>\nexport declare function fromFoldableMap<F, B>(\n  M: Magma<B>,\n  F: FoldableHKT<F>\n): <A>(fa: HKT<F, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>\n```\n\n**Example**\n\n```ts\nimport { last } from 'fp-ts/Semigroup'\nimport { Foldable, zip } from 'fp-ts/ReadonlyArray'\nimport { identity } from 'fp-ts/function'\nimport { ReadonlyRecord, fromFoldableMap } from 'fp-ts/ReadonlyRecord'\n\nexport const zipObject = <K extends string, A>(\n  keys: ReadonlyArray<K>,\n  values: ReadonlyArray<A>\n): ReadonlyRecord<K, A> => fromFoldableMap(last<A>(), Foldable)(zip(keys, values), identity)\n\nassert.deepStrictEqual(zipObject(['a', 'b'], [1, 2, 3]), { a: 1, b: 2 })\n\ninterface User {\n  readonly id: string\n  readonly name: string\n}\n\nconst users: ReadonlyArray<User> = [\n  { id: 'id1', name: 'name1' },\n  { id: 'id2', name: 'name2' },\n  { id: 'id1', name: 'name3' },\n]\n\nassert.deepStrictEqual(\n  fromFoldableMap(last<User>(), Foldable)(users, (user) => [user.id, user]),\n  {\n    id1: { id: 'id1', name: 'name3' },\n    id2: { id: 'id2', name: 'name2' },\n  }\n)\n```\n\nAdded in v2.5.0\n\n## has\n\nTest whether or not a key exists in a `ReadonlyRecord`.\n\nNote. This function is not pipeable because is a `Refinement`.\n\n**Signature**\n\n```ts\nexport declare const has: <K extends string>(k: string, r: Readonly<Record<K, unknown>>) => k is K\n```\n\n**Example**\n\n```ts\nimport { has } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(has('a', { a: 1, b: 2 }), true)\nassert.deepStrictEqual(has('c', { a: 1, b: 2 }), false)\n```\n\nAdded in v2.10.0\n\n## intersection\n\nIntersection of two `ReadonlyRecord`s.\nTakes two `ReadonlyRecord`s and produces a `ReadonlyRecord` combining only the\nentries of the two inputswith the same key.\nIt uses the `concat` function of the provided `Magma` to\ncombine the elements.\n\n**Signature**\n\n```ts\nexport declare const intersection: <A>(\n  M: Magma<A>\n) => (second: Readonly<Record<string, A>>) => (first: Readonly<Record<string, A>>) => Readonly<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { intersection } from 'fp-ts/ReadonlyRecord'\nimport { Magma } from 'fp-ts/Magma'\n\nconst m1: Magma<number> = { concat: (x: number, y: number) => x + y }\nassert.deepStrictEqual(intersection(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4 })\nconst m2: Magma<number> = { concat: (x: number) => x }\nassert.deepStrictEqual(intersection(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1 })\n```\n\nAdded in v2.11.0\n\n## isEmpty\n\nTest whether a `ReadonlyRecord` is empty.\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <A>(r: Readonly<Record<string, A>>) => boolean\n```\n\n**Example**\n\n```ts\nimport { isEmpty } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(isEmpty({}), true)\nassert.deepStrictEqual(isEmpty({ a: 3 }), false)\n```\n\nAdded in v2.5.0\n\n## isSubrecord\n\nTest whether one `ReadonlyRecord` contains all of the keys and values\ncontained in another `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare function isSubrecord<A>(E: Eq<A>): {\n  (that: ReadonlyRecord<string, A>): (me: ReadonlyRecord<string, A>) => boolean\n  (me: ReadonlyRecord<string, A>, that: ReadonlyRecord<string, A>): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { isSubrecord } from 'fp-ts/ReadonlyRecord'\nimport { string } from 'fp-ts'\n\nassert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', b: 'bar', c: 'baz' }), true)\nassert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', c: 'baz' }), true)\nassert.deepStrictEqual(\n  isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', b: 'not-bar', c: 'baz' }),\n  false\n)\nassert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar' })({ a: 'foo', b: 'bar', c: 'baz' }), false)\n```\n\nAdded in v2.5.0\n\n## keys\n\n**Signature**\n\n```ts\nexport declare const keys: <K extends string>(r: Readonly<Record<K, unknown>>) => readonly K[]\n```\n\nAdded in v2.5.0\n\n## lookup\n\nLookup the value for a key in a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare function lookup(k: string): <A>(r: ReadonlyRecord<string, A>) => Option<A>\nexport declare function lookup<A>(k: string, r: ReadonlyRecord<string, A>): Option<A>\n```\n\n**Example**\n\n```ts\nimport { lookup } from 'fp-ts/ReadonlyRecord'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(lookup('b')({ a: 'foo', b: 'bar' }), option.some('bar'))\nassert.deepStrictEqual(lookup('c')({ a: 'foo', b: 'bar' }), option.none)\n```\n\nAdded in v2.5.0\n\n## map\n\nMap a `ReadonlyRecord` passing the values to the iterating function.\n\n**Signature**\n\n```ts\nexport declare function map<A, B>(f: (a: A) => B): <K extends string>(fa: ReadonlyRecord<K, A>) => ReadonlyRecord<K, B>\n```\n\n**Example**\n\n```ts\nimport { map } from 'fp-ts/ReadonlyRecord'\n\nconst f = (n: number) => `-${n}-`\nassert.deepStrictEqual(map(f)({ a: 3, b: 5 }), { a: '-3-', b: '-5-' })\n```\n\nAdded in v2.5.0\n\n## mapWithIndex\n\nMap a `ReadonlyRecord` passing the keys to the iterating function.\n\n**Signature**\n\n```ts\nexport declare function mapWithIndex<K extends string, A, B>(\n  f: (k: K, a: A) => B\n): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<K, B>\n```\n\n**Example**\n\n```ts\nimport { mapWithIndex } from 'fp-ts/ReadonlyRecord'\n\nconst f = (k: string, n: number) => `${k.toUpperCase()}-${n}`\nassert.deepStrictEqual(mapWithIndex(f)({ a: 3, b: 5 }), { a: 'A-3', b: 'B-5' })\n```\n\nAdded in v2.5.0\n\n## modifyAt\n\nApplies a mapping function to one specific key/value pair in a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare const modifyAt: <A>(\n  k: string,\n  f: (a: A) => A\n) => <K extends string>(r: Readonly<Record<K, A>>) => Option<Readonly<Record<K, A>>>\n```\n\n**Example**\n\n```ts\nimport { modifyAt } from 'fp-ts/ReadonlyRecord'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(modifyAt('a', (x: number) => x * 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }))\nassert.deepStrictEqual(modifyAt('c', (x: number) => x * 3)({ a: 1, b: 2 }), option.none)\n```\n\nAdded in v2.5.0\n\n## partitionMapWithIndex\n\nMaps a `ReadonlyRecord` with a function returning an `Either` and\npartitions the resulting `ReadonlyRecord` into `Left`s and `Right`s.\n\n**Signature**\n\n```ts\nexport declare function partitionMapWithIndex<K extends string, A, B, C>(\n  f: (key: K, a: A) => Either<B, C>\n): (fa: ReadonlyRecord<K, A>) => Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, C>>\n```\n\n**Example**\n\n```ts\nimport { partitionMapWithIndex } from 'fp-ts/ReadonlyRecord'\nimport { either } from 'fp-ts'\n\nconst f = (key: string, a: number) =>\n  a >= 0 ? either.right(`${key} is >= 0 (${a})`) : either.left(`${key} is < 0 (${a})`)\nassert.deepStrictEqual(partitionMapWithIndex(f)({ a: -1, b: 2, c: 123 }), {\n  left: {\n    a: 'a is < 0 (-1)',\n  },\n  right: {\n    b: 'b is >= 0 (2)',\n    c: 'c is >= 0 (123)',\n  },\n})\n```\n\nAdded in v2.5.0\n\n## partitionWithIndex\n\nPartition a `ReadonlyRecord` into two parts according to a predicate\nthat takes a key and a value.\n\n**Signature**\n\n```ts\nexport declare function partitionWithIndex<K extends string, A, B extends A>(\n  refinementWithIndex: RefinementWithIndex<K, A, B>\n): (fa: ReadonlyRecord<K, A>) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, B>>\nexport declare function partitionWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): <B extends A>(fb: ReadonlyRecord<K, B>) => Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, B>>\nexport declare function partitionWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): (fa: ReadonlyRecord<K, A>) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, A>>\n```\n\n**Example**\n\n```ts\nimport { partitionWithIndex } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(\n  partitionWithIndex((key: string, a: number) => key.length <= 1 && a > 0)({ a: -1, b: 2, ccc: 7 }),\n  {\n    left: {\n      a: -1,\n      ccc: 7,\n    },\n    right: {\n      b: 2,\n    },\n  }\n)\n```\n\nAdded in v2.5.0\n\n## pop\n\nDelete a key and value from a `ReadonlyRecord`, returning the value as well as the subsequent `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare function pop<K extends string>(\n  k: K\n): <KS extends string, A>(\n  r: ReadonlyRecord<KS, A>\n) => Option<readonly [A, ReadonlyRecord<string extends K ? string : Exclude<KS, K>, A>]>\n```\n\n**Example**\n\n```ts\nimport { pop } from 'fp-ts/ReadonlyRecord'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(pop('a')({ a: 1, b: 2, c: 3 }), option.some([1, { b: 2, c: 3 }]))\nassert.deepStrictEqual(pop('x')({ a: 1, b: 2, c: 3 }), option.none)\n```\n\nAdded in v2.5.0\n\n## reduceRightWithIndex\n\nSame as `reduceWithIndex`, but reduce starting from the right\n(i.e. in reverse order, from the last to the first entry according to\nthe given `Ord`).\n\n**Signature**\n\n```ts\nexport declare function reduceRightWithIndex(\n  O: Ord<string>\n): <K extends string, A, B>(b: B, f: (k: K, a: A, b: B) => B) => (fa: ReadonlyRecord<K, A>) => B\nexport declare function reduceRightWithIndex<K extends string, A, B>(\n  b: B,\n  f: (k: K, a: A, b: B) => B\n): (fa: ReadonlyRecord<K, A>) => B\n```\n\n**Example**\n\n```ts\nimport { reduceRightWithIndex } from 'fp-ts/ReadonlyRecord'\nimport { Ord } from 'fp-ts/string'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(reduceRightWithIndex(Ord)([] as string[], (k, a, b) => [...b, `${k}-${a}`])(x), [\n  'c-3',\n  'b-false',\n  'a-foo',\n])\n```\n\nAdded in v2.5.0\n\n## reduceWithIndex\n\nReduces a `ReadonlyRecord` passing each key/value pair to the iterating function.\nEntries are processed in the order, sorted by key according to\nthe given `Ord`.\n\n**Signature**\n\n```ts\nexport declare function reduceWithIndex(\n  O: Ord<string>\n): <K extends string, A, B>(b: B, f: (k: K, b: B, a: A) => B) => (fa: ReadonlyRecord<K, A>) => B\nexport declare function reduceWithIndex<K extends string, A, B>(\n  b: B,\n  f: (k: K, b: B, a: A) => B\n): (fa: ReadonlyRecord<K, A>) => B\n```\n\n**Example**\n\n```ts\nimport { reduceWithIndex } from 'fp-ts/ReadonlyRecord'\nimport { Ord } from 'fp-ts/string'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(reduceWithIndex(Ord)([] as string[], (k, b, a) => [...b, `${k}-${a}`])(x), [\n  'a-foo',\n  'b-false',\n  'c-3',\n])\n```\n\nAdded in v2.5.0\n\n## sequence\n\n`ReadonlyRecord` sequencing,\ni.e., take a `ReadonlyRecord` in which elements are monads\nand return a monad of a `ReadonlyRecord` of the base types.\nThe following example for instance shows sequencing\na `ReadonlyRecord<string, Option<number>>`\ninto an `Option<ReadonlyRecord<string, number>>`.\n\n`sequence` in `ReadonlyRecord` is equivalent to `sequenceS` in `Apply.ts`.\n\n**Signature**\n\n```ts\nexport declare function sequence<F extends URIS3>(\n  F: Applicative3<F>\n): <K extends string, R, E, A>(ta: ReadonlyRecord<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, ReadonlyRecord<K, A>>\nexport declare function sequence<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <K extends string, R, A>(ta: ReadonlyRecord<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, ReadonlyRecord<K, A>>\nexport declare function sequence<F extends URIS2>(\n  F: Applicative2<F>\n): <K extends string, E, A>(ta: ReadonlyRecord<K, Kind2<F, E, A>>) => Kind2<F, E, ReadonlyRecord<K, A>>\nexport declare function sequence<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <K extends string, A>(ta: ReadonlyRecord<K, Kind2<F, E, A>>) => Kind2<F, E, ReadonlyRecord<K, A>>\nexport declare function sequence<F extends URIS>(\n  F: Applicative1<F>\n): <K extends string, A>(ta: ReadonlyRecord<K, Kind<F, A>>) => Kind<F, ReadonlyRecord<K, A>>\nexport declare function sequence<F>(\n  F: Applicative<F>\n): <K extends string, A>(ta: ReadonlyRecord<K, HKT<F, A>>) => HKT<F, ReadonlyRecord<K, A>>\n```\n\n**Example**\n\n```ts\nimport { sequence } from 'fp-ts/ReadonlyRecord'\nimport { option } from 'fp-ts'\nimport { sequenceS } from 'fp-ts/Apply'\n\nassert.deepStrictEqual(\n  sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),\n  option.some({ a: 1, b: 2 })\n)\nassert.deepStrictEqual(sequence(option.Applicative)({ a: option.some(1), b: option.none }), option.none)\nassert.deepStrictEqual(\n  sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),\n  sequenceS(option.Applicative)({ a: option.some(1), b: option.some(2) })\n)\n```\n\nAdded in v2.5.0\n\n## size\n\nCalculate the number of key/value pairs in a `ReadonlyRecord`,\n\n**Signature**\n\n```ts\nexport declare const size: <A>(r: Readonly<Record<string, A>>) => number\n```\n\n**Example**\n\n```ts\nimport { size } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(size({ a: true, b: 2, c: 'three' }), 3)\n```\n\nAdded in v2.5.0\n\n## some\n\nTest if at least one value in a `ReadonlyRecord` satisfies the predicate.\n\n**Signature**\n\n```ts\nexport declare function some<A>(predicate: (a: A) => boolean): (r: ReadonlyRecord<string, A>) => boolean\n```\n\n**Example**\n\n```ts\nimport { some } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(some((n: number) => n >= 0)({ a: 1, b: -2 }), true)\nassert.deepStrictEqual(some((n: number) => n >= 0)({ a: -1, b: -2 }), false)\n```\n\nAdded in v2.5.0\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare function traverse<F extends URIS4>(\n  F: Applicative4<F>\n): <S, R, E, A, B>(\n  f: (a: A) => Kind4<F, S, R, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind4<F, S, R, E, ReadonlyRecord<K, B>>\nexport declare function traverse<F extends URIS3>(\n  F: Applicative3<F>\n): <R, E, A, B>(\n  f: (a: A) => Kind3<F, R, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>\nexport declare function traverse<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <R, A, B>(\n  f: (a: A) => Kind3<F, R, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>\nexport declare function traverse<F extends URIS2>(\n  F: Applicative2<F>\n): <E, A, B>(\n  f: (a: A) => Kind2<F, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>\nexport declare function traverse<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <A, B>(\n  f: (a: A) => Kind2<F, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>\nexport declare function traverse<F extends URIS>(\n  F: Applicative1<F>\n): <A, B>(f: (a: A) => Kind<F, B>) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind<F, ReadonlyRecord<K, B>>\nexport declare function traverse<F>(\n  F: Applicative<F>\n): <A, B>(f: (a: A) => HKT<F, B>) => <K extends string>(ta: ReadonlyRecord<K, A>) => HKT<F, ReadonlyRecord<K, B>>\n```\n\nAdded in v2.5.0\n\n## traverseWithIndex\n\n**Signature**\n\n```ts\nexport declare function traverseWithIndex<F extends URIS4>(\n  F: Applicative4<F>\n): <K extends string, S, R, E, A, B>(\n  f: (k: K, a: A) => Kind4<F, S, R, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind4<F, S, R, E, ReadonlyRecord<K, B>>\nexport declare function traverseWithIndex<F extends URIS3>(\n  F: Applicative3<F>\n): <K extends string, R, E, A, B>(\n  f: (k: K, a: A) => Kind3<F, R, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>\nexport declare function traverseWithIndex<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <K extends string, R, A, B>(\n  f: (k: K, a: A) => Kind3<F, R, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>\nexport declare function traverseWithIndex<F extends URIS2>(\n  F: Applicative2<F>\n): <K extends string, E, A, B>(\n  f: (k: K, a: A) => Kind2<F, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>\nexport declare function traverseWithIndex<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <K extends string, A, B>(\n  f: (k: K, a: A) => Kind2<F, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>\nexport declare function traverseWithIndex<F extends URIS>(\n  F: Applicative1<F>\n): <K extends string, A, B>(\n  f: (k: K, a: A) => Kind<F, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind<F, ReadonlyRecord<K, B>>\nexport declare function traverseWithIndex<F>(\n  F: Applicative<F>\n): <K extends string, A, B>(f: (k: K, a: A) => HKT<F, B>) => (ta: ReadonlyRecord<K, A>) => HKT<F, ReadonlyRecord<K, B>>\n```\n\nAdded in v2.5.0\n\n## union\n\nUnion of two `ReadonlyRecord`s.\nTakes two `ReadonlyRecord`s and produces a `ReadonlyRecord` combining all the\nentries of the two inputs.\nIt uses the `concat` function of the provided `Magma` to\ncombine the elements with the same key.\n\n**Signature**\n\n```ts\nexport declare const union: <A>(\n  M: Magma<A>\n) => (second: Readonly<Record<string, A>>) => (first: Readonly<Record<string, A>>) => Readonly<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { union } from 'fp-ts/ReadonlyRecord'\nimport { Magma } from 'fp-ts/Magma'\n\nconst m1: Magma<number> = { concat: (x: number, y: number) => x + y }\nassert.deepStrictEqual(union(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4, b: 2, c: 3 })\nconst m2: Magma<number> = { concat: (x: number) => x }\nassert.deepStrictEqual(union(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 })\n```\n\nAdded in v2.11.0\n\n## updateAt\n\nReplace a key/value pair in a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare const updateAt: <A>(\n  k: string,\n  a: A\n) => <K extends string>(r: Readonly<Record<K, A>>) => Option<Readonly<Record<K, A>>>\n```\n\n**Example**\n\n```ts\nimport { updateAt } from 'fp-ts/ReadonlyRecord'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(updateAt('a', 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }))\nassert.deepStrictEqual(updateAt('c', 3)({ a: 1, b: 2 }), option.none)\n```\n\nAdded in v2.5.0\n\n## upsertAt\n\nInsert or replace a key/value pair in a `ReadonlyRecord`.\n\n**Signature**\n\n```ts\nexport declare const upsertAt: <A>(k: string, a: A) => (r: Readonly<Record<string, A>>) => Readonly<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { upsertAt } from 'fp-ts/ReadonlyRecord'\n\nassert.deepStrictEqual(upsertAt('a', 5)({ a: 1, b: 2 }), { a: 5, b: 2 })\nassert.deepStrictEqual(upsertAt('c', 5)({ a: 1, b: 2 }), { a: 1, b: 2, c: 5 })\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~FoldableWithIndex~~\n\nUse `getFoldableWithIndex` instead.\n\n**Signature**\n\n```ts\nexport declare const FoldableWithIndex: FoldableWithIndex1<'ReadonlyRecord', string>\n```\n\nAdded in v2.7.0\n\n## ~~Foldable~~\n\nUse `getFoldable` instead.\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable1<'ReadonlyRecord'>\n```\n\nAdded in v2.7.0\n\n## ~~TraversableWithIndex~~\n\nUse `getTraversableWithIndex` instead.\n\n**Signature**\n\n```ts\nexport declare const TraversableWithIndex: TraversableWithIndex1<'ReadonlyRecord', string>\n```\n\nAdded in v2.7.0\n\n## ~~Traversable~~\n\nUse `getTraversable` instead.\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable1<'ReadonlyRecord'>\n```\n\nAdded in v2.7.0\n\n## ~~Witherable~~\n\nUse `getWitherable` instead.\n\n**Signature**\n\n```ts\nexport declare const Witherable: Witherable1<'ReadonlyRecord'>\n```\n\nAdded in v2.7.0\n\n## ~~hasOwnProperty (function)~~\n\nUse [`has`](#has) instead.\n\n**Signature**\n\n```ts\nexport declare function hasOwnProperty<K extends string>(k: string, r: ReadonlyRecord<K, unknown>): k is K\n```\n\nAdded in v2.5.0\n\n## ~~insertAt~~\n\nUse [`upsertAt`](#upsertat) instead.\n\n**Signature**\n\n```ts\nexport declare const insertAt: <A>(k: string, a: A) => (r: Readonly<Record<string, A>>) => Readonly<Record<string, A>>\n```\n\nAdded in v2.5.0\n\n## ~~readonlyRecord~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RR.Functor` instead of `RR.readonlyRecord`\n(where `RR` is from `import RR from 'fp-ts/ReadonlyRecord'`)\n\n**Signature**\n\n```ts\nexport declare const readonlyRecord: FunctorWithIndex1<'ReadonlyRecord', string> &\n  FoldableWithIndex1<'ReadonlyRecord', string> &\n  FilterableWithIndex1<'ReadonlyRecord', string> &\n  TraversableWithIndex1<'ReadonlyRecord', string> &\n  Witherable1<'ReadonlyRecord'>\n```\n\nAdded in v2.5.0\n"
  },
  {
    "path": "docs/modules/ReadonlySet.ts.md",
    "content": "---\ntitle: ReadonlySet.ts\nnav_order: 87\nparent: Modules\n---\n\n## ReadonlySet overview\n\nAdded in v2.5.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [singleton](#singleton)\n- [conversions](#conversions)\n  - [fromReadonlyArray](#fromreadonlyarray)\n  - [fromSet](#fromset)\n  - [toReadonlyArray](#toreadonlyarray)\n  - [toSet](#toset)\n- [folding](#folding)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [getDifferenceMagma](#getdifferencemagma)\n  - [getEq](#geteq)\n  - [getIntersectionSemigroup](#getintersectionsemigroup)\n  - [getShow](#getshow)\n  - [getUnionMonoid](#getunionmonoid)\n  - [getUnionSemigroup](#getunionsemigroup)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [chain](#chain)\n  - [compact](#compact)\n  - [difference](#difference)\n  - [elem](#elem)\n  - [empty](#empty)\n  - [every](#every)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [foldMap](#foldmap)\n  - [insert](#insert)\n  - [intersection](#intersection)\n  - [isEmpty](#isempty)\n  - [isSubset](#issubset)\n  - [map](#map)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [reduce](#reduce)\n  - [remove](#remove)\n  - [separate](#separate)\n  - [size](#size)\n  - [some](#some)\n  - [toggle](#toggle)\n  - [union](#union)\n- [zone of death](#zone-of-death)\n  - [~~fromArray~~](#fromarray)\n\n---\n\n# constructors\n\n## singleton\n\nCreate a set with one element\n\n**Signature**\n\n```ts\nexport declare const singleton: <A>(a: A) => ReadonlySet<A>\n```\n\nAdded in v2.5.0\n\n# conversions\n\n## fromReadonlyArray\n\nCreate a `ReadonlySet` from a `ReadonlyArray`\n\n**Signature**\n\n```ts\nexport declare const fromReadonlyArray: <A>(E: Eq<A>) => (as: readonly A[]) => ReadonlySet<A>\n```\n\nAdded in v2.10.0\n\n## fromSet\n\n**Signature**\n\n```ts\nexport declare const fromSet: <A>(s: Set<A>) => ReadonlySet<A>\n```\n\nAdded in v2.5.0\n\n## toReadonlyArray\n\nGet a sorted `ReadonlyArray` of the values contained in a `ReadonlySet`.\n\n**Signature**\n\n```ts\nexport declare const toReadonlyArray: <A>(O: Ord<A>) => (set: ReadonlySet<A>) => readonly A[]\n```\n\nAdded in v2.5.0\n\n## toSet\n\n**Signature**\n\n```ts\nexport declare function toSet<A>(s: ReadonlySet<A>): Set<A>\n```\n\nAdded in v2.5.0\n\n# folding\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A>(O: Ord<A>) => <B>(b: B, f: (a: A, b: B) => B) => (fa: ReadonlySet<A>) => B\n```\n\nAdded in v2.11.0\n\n# instances\n\n## getDifferenceMagma\n\n**Signature**\n\n```ts\nexport declare const getDifferenceMagma: <A>(E: Eq<A>) => Magma<ReadonlySet<A>>\n```\n\nAdded in v2.11.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare function getEq<A>(E: Eq<A>): Eq<ReadonlySet<A>>\n```\n\nAdded in v2.5.0\n\n## getIntersectionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getIntersectionSemigroup: <A>(E: Eq<A>) => Semigroup<ReadonlySet<A>>\n```\n\nAdded in v2.5.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare function getShow<A>(S: Show<A>): Show<ReadonlySet<A>>\n```\n\nAdded in v2.5.0\n\n## getUnionMonoid\n\n**Signature**\n\n```ts\nexport declare const getUnionMonoid: <A>(E: Eq<A>) => Monoid<ReadonlySet<A>>\n```\n\nAdded in v2.5.0\n\n## getUnionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <A>(E: Eq<A>) => Semigroup<ReadonlySet<A>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReadonlySet'\n```\n\nAdded in v2.11.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.11.0\n\n# utils\n\n## chain\n\n**Signature**\n\n```ts\nexport declare function chain<B>(E: Eq<B>): <A>(f: (x: A) => ReadonlySet<B>) => (set: ReadonlySet<A>) => ReadonlySet<B>\n```\n\nAdded in v2.5.0\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(E: Eq<A>) => (fa: ReadonlySet<Option<A>>) => ReadonlySet<A>\n```\n\nAdded in v2.5.0\n\n## difference\n\nForm the set difference (`x` - `y`)\n\n**Signature**\n\n```ts\nexport declare function difference<A>(E: Eq<A>): {\n  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => ReadonlySet<A>\n  (me: ReadonlySet<A>, that: ReadonlySet<A>): ReadonlySet<A>\n}\n```\n\n**Example**\n\n```ts\nimport { difference } from 'fp-ts/ReadonlySet'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe(new Set([1, 2]), difference(N.Eq)(new Set([1, 3]))), new Set([2]))\n```\n\nAdded in v2.5.0\n\n## elem\n\nTest if a value is a member of a set\n\n**Signature**\n\n```ts\nexport declare function elem<A>(E: Eq<A>): {\n  (a: A): (set: ReadonlySet<A>) => boolean\n  (a: A, set: ReadonlySet<A>): boolean\n}\n```\n\nAdded in v2.5.0\n\n## empty\n\n**Signature**\n\n```ts\nexport declare const empty: ReadonlySet<never>\n```\n\nAdded in v2.5.0\n\n## every\n\n**Signature**\n\n```ts\nexport declare function every<A, B extends A>(refinement: Refinement<A, B>): Refinement<ReadonlySet<A>, ReadonlySet<B>>\nexport declare function every<A>(predicate: Predicate<A>): Predicate<ReadonlySet<A>>\n```\n\nAdded in v2.5.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare function filter<A, B extends A>(refinement: Refinement<A, B>): (set: ReadonlySet<A>) => ReadonlySet<B>\nexport declare function filter<A>(predicate: Predicate<A>): <B extends A>(set: ReadonlySet<B>) => ReadonlySet<B>\nexport declare function filter<A>(predicate: Predicate<A>): (set: ReadonlySet<A>) => ReadonlySet<A>\n```\n\nAdded in v2.5.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare function filterMap<B>(E: Eq<B>): <A>(f: (a: A) => Option<B>) => (fa: ReadonlySet<A>) => ReadonlySet<B>\n```\n\nAdded in v2.5.0\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare function foldMap<A, M>(O: Ord<A>, M: Monoid<M>): (f: (a: A) => M) => (fa: ReadonlySet<A>) => M\n```\n\nAdded in v2.5.0\n\n## insert\n\nInsert a value into a set\n\n**Signature**\n\n```ts\nexport declare function insert<A>(E: Eq<A>): (a: A) => (set: ReadonlySet<A>) => ReadonlySet<A>\n```\n\nAdded in v2.5.0\n\n## intersection\n\nThe set of elements which are in both the first and second set\n\n**Signature**\n\n```ts\nexport declare function intersection<A>(E: Eq<A>): {\n  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => ReadonlySet<A>\n  (me: ReadonlySet<A>, that: ReadonlySet<A>): ReadonlySet<A>\n}\n```\n\nAdded in v2.5.0\n\n## isEmpty\n\nTest whether a `ReadonlySet` is empty.\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <A>(set: ReadonlySet<A>) => boolean\n```\n\nAdded in v2.10.0\n\n## isSubset\n\n`true` if and only if every element in the first set is an element of the second set\n\n**Signature**\n\n```ts\nexport declare function isSubset<A>(E: Eq<A>): {\n  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => boolean\n  (me: ReadonlySet<A>, that: ReadonlySet<A>): boolean\n}\n```\n\nAdded in v2.5.0\n\n## map\n\nProjects a Set through a function\n\n**Signature**\n\n```ts\nexport declare function map<B>(E: Eq<B>): <A>(f: (x: A) => B) => (set: ReadonlySet<A>) => ReadonlySet<B>\n```\n\nAdded in v2.5.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare function partition<A, B extends A>(\n  refinement: Refinement<A, B>\n): (set: ReadonlySet<A>) => Separated<ReadonlySet<A>, ReadonlySet<B>>\nexport declare function partition<A>(\n  predicate: Predicate<A>\n): <B extends A>(set: ReadonlySet<B>) => Separated<ReadonlySet<B>, ReadonlySet<B>>\nexport declare function partition<A>(\n  predicate: Predicate<A>\n): (set: ReadonlySet<A>) => Separated<ReadonlySet<A>, ReadonlySet<A>>\n```\n\nAdded in v2.5.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare function partitionMap<B, C>(\n  EB: Eq<B>,\n  EC: Eq<C>\n): <A>(f: (a: A) => Either<B, C>) => (set: ReadonlySet<A>) => Separated<ReadonlySet<B>, ReadonlySet<C>>\n```\n\nAdded in v2.5.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare function reduce<A>(O: Ord<A>): <B>(b: B, f: (b: B, a: A) => B) => (fa: ReadonlySet<A>) => B\n```\n\nAdded in v2.5.0\n\n## remove\n\nDelete a value from a set\n\n**Signature**\n\n```ts\nexport declare const remove: <A>(E: Eq<A>) => (a: A) => (set: ReadonlySet<A>) => ReadonlySet<A>\n```\n\nAdded in v2.5.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare function separate<E, A>(\n  EE: Eq<E>,\n  EA: Eq<A>\n): (fa: ReadonlySet<Either<E, A>>) => Separated<ReadonlySet<E>, ReadonlySet<A>>\n```\n\nAdded in v2.5.0\n\n## size\n\nCalculate the number of elements in a `ReadonlySet`.\n\n**Signature**\n\n```ts\nexport declare const size: <A>(set: ReadonlySet<A>) => number\n```\n\nAdded in v2.10.0\n\n## some\n\n**Signature**\n\n```ts\nexport declare const some: <A>(predicate: Predicate<A>) => (set: ReadonlySet<A>) => boolean\n```\n\nAdded in v2.5.0\n\n## toggle\n\nChecks an element is a member of a set;\nIf yes, removes the value from the set\nIf no, inserts the value to the set\n\n**Signature**\n\n```ts\nexport declare const toggle: <A>(E: Eq<A>) => (a: A) => (set: ReadonlySet<A>) => ReadonlySet<A>\n```\n\nAdded in v2.10.0\n\n## union\n\nForm the union of two sets\n\n**Signature**\n\n```ts\nexport declare function union<A>(E: Eq<A>): {\n  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => ReadonlySet<A>\n  (me: ReadonlySet<A>, that: ReadonlySet<A>): ReadonlySet<A>\n}\n```\n\nAdded in v2.5.0\n\n# zone of death\n\n## ~~fromArray~~\n\nUse [`fromReadonlyArray`](#fromreadonlyarray) instead.\n\n**Signature**\n\n```ts\nexport declare const fromArray: <A>(E: Eq<A>) => (as: readonly A[]) => ReadonlySet<A>\n```\n\nAdded in v2.5.0\n"
  },
  {
    "path": "docs/modules/ReadonlyTuple.ts.md",
    "content": "---\ntitle: ReadonlyTuple.ts\nnav_order: 88\nparent: Modules\n---\n\n## ReadonlyTuple overview\n\nAdded in v2.5.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [Extract](#extract)\n  - [extract](#extract)\n- [error handling](#error-handling)\n  - [mapLeft](#mapleft)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [Bifunctor](#bifunctor)\n  - [Comonad](#comonad)\n  - [Foldable](#foldable)\n  - [Functor](#functor)\n  - [Semigroupoid](#semigroupoid)\n  - [Traversable](#traversable)\n  - [getApplicative](#getapplicative)\n  - [getApply](#getapply)\n  - [getChain](#getchain)\n  - [getChainRec](#getchainrec)\n  - [getMonad](#getmonad)\n- [mapping](#mapping)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [map](#map)\n  - [mapFst](#mapfst)\n  - [mapSnd](#mapsnd)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [compose](#compose)\n  - [duplicate](#duplicate)\n  - [extend](#extend)\n  - [fst](#fst)\n  - [snd](#snd)\n  - [swap](#swap)\n- [zone of death](#zone-of-death)\n  - [~~readonlyTuple~~](#readonlytuple)\n\n---\n\n# Extract\n\n## extract\n\n**Signature**\n\n```ts\nexport declare const extract: <E, A>(wa: readonly [A, E]) => A\n```\n\nAdded in v2.6.2\n\n# error handling\n\n## mapLeft\n\nAlias of [`mapSnd`](#mapsnd).\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: readonly [A, E]) => readonly [A, G]\n```\n\nAdded in v2.5.0\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: readonly [A, E]) => M\n```\n\nAdded in v2.5.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: readonly [A, E]) => B\n```\n\nAdded in v2.5.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: readonly [A, E]) => B\n```\n\nAdded in v2.5.0\n\n# instances\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor2<'ReadonlyTuple'>\n```\n\nAdded in v2.7.0\n\n## Comonad\n\n**Signature**\n\n```ts\nexport declare const Comonad: Comonad2<'ReadonlyTuple'>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable2<'ReadonlyTuple'>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'ReadonlyTuple'>\n```\n\nAdded in v2.7.0\n\n## Semigroupoid\n\n**Signature**\n\n```ts\nexport declare const Semigroupoid: Semigroupoid2<'ReadonlyTuple'>\n```\n\nAdded in v2.7.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable2<'ReadonlyTuple'>\n```\n\nAdded in v2.7.0\n\n## getApplicative\n\n**Signature**\n\n```ts\nexport declare function getApplicative<M>(M: Monoid<M>): Applicative2C<URI, M>\n```\n\nAdded in v2.5.0\n\n## getApply\n\n**Signature**\n\n```ts\nexport declare function getApply<S>(S: Semigroup<S>): Apply2C<URI, S>\n```\n\nAdded in v2.5.0\n\n## getChain\n\n**Signature**\n\n```ts\nexport declare function getChain<S>(S: Semigroup<S>): Chain2C<URI, S>\n```\n\nAdded in v2.5.0\n\n## getChainRec\n\n**Signature**\n\n```ts\nexport declare function getChainRec<M>(M: Monoid<M>): ChainRec2C<URI, M>\n```\n\nAdded in v2.5.0\n\n## getMonad\n\n**Signature**\n\n```ts\nexport declare function getMonad<M>(M: Monoid<M>): Monad2C<URI, M>\n```\n\nAdded in v2.5.0\n\n# mapping\n\n## bimap\n\nMap a pair of functions over the two type arguments of the bifunctor.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(\n  mapSnd: (e: E) => G,\n  mapFst: (a: A) => B\n) => (fa: readonly [A, E]) => readonly [B, G]\n```\n\nAdded in v2.5.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: readonly [(a: A) => B, E]) => readonly [B, E]\n```\n\nAdded in v2.10.0\n\n## map\n\nAlias of [`mapFst`](#mapfst).\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: readonly [A, E]) => readonly [B, E]\n```\n\nAdded in v2.5.0\n\n## mapFst\n\nMap a function over the first component of a `ReadonlyTuple`.\n\nThis is the `map` operation of the `Functor` instance.\n\n**Signature**\n\n```ts\nexport declare const mapFst: <A, B>(f: (a: A) => B) => <E>(fa: readonly [A, E]) => readonly [B, E]\n```\n\nAdded in v2.10.0\n\n## mapSnd\n\nMap a function over the second component of a `ReadonlyTuple`.\n\nThis is the `mapLeft` operation of the `Bifunctor` instance.\n\n**Signature**\n\n```ts\nexport declare const mapSnd: <E, G>(f: (e: E) => G) => <A>(fa: readonly [A, E]) => readonly [A, G]\n```\n\nAdded in v2.10.0\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence2<'ReadonlyTuple'>\n```\n\nAdded in v2.6.3\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse2<'ReadonlyTuple'>\n```\n\nAdded in v2.6.3\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'ReadonlyTuple'\n```\n\nAdded in v2.5.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.5.0\n\n# utils\n\n## compose\n\n**Signature**\n\n```ts\nexport declare const compose: <A, B>(ab: readonly [B, A]) => <C>(bc: readonly [C, B]) => readonly [C, A]\n```\n\nAdded in v2.5.0\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <E, A>(wa: readonly [A, E]) => readonly [readonly [A, E], E]\n```\n\nAdded in v2.5.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <E, A, B>(f: (wa: readonly [A, E]) => B) => (wa: readonly [A, E]) => readonly [B, E]\n```\n\nAdded in v2.5.0\n\n## fst\n\n**Signature**\n\n```ts\nexport declare function fst<A, E>(ea: readonly [A, E]): A\n```\n\nAdded in v2.5.0\n\n## snd\n\n**Signature**\n\n```ts\nexport declare function snd<A, E>(ea: readonly [A, E]): E\n```\n\nAdded in v2.5.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare const swap: <A, E>(ea: readonly [A, E]) => readonly [E, A]\n```\n\nAdded in v2.5.0\n\n# zone of death\n\n## ~~readonlyTuple~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `RT.Functor` instead of `RT.readonlyTuple`\n(where `RT` is from `import RT from 'fp-ts/ReadonlyTuple'`)\n\n**Signature**\n\n```ts\nexport declare const readonlyTuple: Semigroupoid2<'ReadonlyTuple'> &\n  Bifunctor2<'ReadonlyTuple'> &\n  Comonad2<'ReadonlyTuple'> &\n  Foldable2<'ReadonlyTuple'> &\n  Traversable2<'ReadonlyTuple'>\n```\n\nAdded in v2.5.0\n"
  },
  {
    "path": "docs/modules/Record.ts.md",
    "content": "---\ntitle: Record.ts\nnav_order: 89\nparent: Modules\n---\n\n## Record overview\n\nThe `Record` module enables dealing with Typescript's `Record<K, T>`\ntype in a functional way, basically treating it as a `Functor` in `T`.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [conversions](#conversions)\n  - [fromEntries](#fromentries)\n  - [toArray](#toarray)\n  - [toEntries](#toentries)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [getWitherable](#getwitherable)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [separate](#separate)\n  - [wilt](#wilt)\n  - [wither](#wither)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [getFoldable](#getfoldable)\n  - [getFoldableWithIndex](#getfoldablewithindex)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [Compactable](#compactable)\n  - [Filterable](#filterable)\n  - [FilterableWithIndex](#filterablewithindex)\n  - [Functor](#functor)\n  - [FunctorWithIndex](#functorwithindex)\n  - [getDifferenceMagma](#getdifferencemagma)\n  - [getEq](#geteq)\n  - [getIntersectionSemigroup](#getintersectionsemigroup)\n  - [getMonoid](#getmonoid)\n  - [getShow](#getshow)\n  - [getUnionMonoid](#getunionmonoid)\n  - [getUnionSemigroup](#getunionsemigroup)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n- [traversing](#traversing)\n  - [getTraversable](#gettraversable)\n  - [getTraversableWithIndex](#gettraversablewithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [collect](#collect)\n  - [deleteAt](#deleteat)\n  - [difference](#difference)\n  - [elem](#elem)\n  - [every](#every)\n  - [filterMapWithIndex](#filtermapwithindex)\n  - [filterWithIndex](#filterwithindex)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [fromFoldable](#fromfoldable)\n  - [fromFoldableMap](#fromfoldablemap)\n  - [has](#has)\n  - [intersection](#intersection)\n  - [isEmpty](#isempty)\n  - [isSubrecord](#issubrecord)\n  - [keys](#keys)\n  - [lookup](#lookup)\n  - [mapWithIndex](#mapwithindex)\n  - [modifyAt](#modifyat)\n  - [partitionMapWithIndex](#partitionmapwithindex)\n  - [partitionWithIndex](#partitionwithindex)\n  - [pop](#pop)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n  - [sequence](#sequence)\n  - [singleton](#singleton)\n  - [size](#size)\n  - [some](#some)\n  - [toUnfoldable](#tounfoldable)\n  - [traverse](#traverse)\n  - [traverseWithIndex](#traversewithindex)\n  - [union](#union)\n  - [updateAt](#updateat)\n  - [upsertAt](#upsertat)\n- [zone of death](#zone-of-death)\n  - [~~FoldableWithIndex~~](#foldablewithindex)\n  - [~~Foldable~~](#foldable)\n  - [~~TraversableWithIndex~~](#traversablewithindex)\n  - [~~Traversable~~](#traversable)\n  - [~~Witherable~~](#witherable)\n  - [~~empty~~](#empty)\n  - [~~hasOwnProperty (function)~~](#hasownproperty-function)\n  - [~~insertAt~~](#insertat)\n  - [~~record~~](#record)\n\n---\n\n# conversions\n\n## fromEntries\n\nConverts an `Array` of `[key, value]` tuples into a `Record`.\n\n**Signature**\n\n```ts\nexport declare const fromEntries: <A>(fa: [string, A][]) => Record<string, A>\n```\n\n**Example**\n\n```ts\nimport { fromEntries } from 'fp-ts/Record'\n\nassert.deepStrictEqual(\n  fromEntries([\n    ['a', 1],\n    ['b', 2],\n    ['a', 3],\n  ]),\n  { b: 2, a: 3 }\n)\n```\n\nAdded in v2.12.0\n\n## toArray\n\nGet a sorted `Array` of the key/value pairs contained in a `Record`.\nSorted alphabetically by key.\n\n**Signature**\n\n```ts\nexport declare const toArray: <K extends string, A>(r: Record<K, A>) => [K, A][]\n```\n\n**Example**\n\n```ts\nimport { toArray } from 'fp-ts/Record'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(toArray(x), [\n  ['a', 'foo'],\n  ['b', false],\n  ['c', 3],\n])\n```\n\nAdded in v2.0.0\n\n## toEntries\n\nAlias of [`toArray`](#toArray).\n\n**Signature**\n\n```ts\nexport declare const toEntries: <K extends string, A>(r: Record<K, A>) => [K, A][]\n```\n\n**Example**\n\n```ts\nimport { toEntries } from 'fp-ts/Record'\n\nassert.deepStrictEqual(toEntries({ b: 2, a: 1 }), [\n  ['a', 1],\n  ['b', 2],\n])\n```\n\nAdded in v2.12.0\n\n# filtering\n\n## compact\n\nCompact a `Record` of `Option`s discarding the `None` values and\nkeeping the `Some` values.\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(fa: Record<string, Option<A>>) => Record<string, A>\n```\n\n**Example**\n\n```ts\nimport { compact } from 'fp-ts/Record'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(compact({ a: option.some('foo'), b: option.none, c: option.some('bar') }), {\n  a: 'foo',\n  c: 'bar',\n})\n```\n\nAdded in v2.0.0\n\n## filter\n\nGiven a `Predicate`, it produces a new `Record` keeping only the entries with a\nvalue that satisfies the provided predicate.\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Record<string, A>) => Record<string, B>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: Record<string, B>) => Record<string, B>\n  <A>(predicate: Predicate<A>): (fa: Record<string, A>) => Record<string, A>\n}\n```\n\n**Example**\n\n```ts\nimport { filter } from 'fp-ts/Record'\n\nassert.deepStrictEqual(filter((s: string) => s.length < 4)({ a: 'foo', b: 'bar', c: 'verylong' }), {\n  a: 'foo',\n  b: 'bar',\n})\n```\n\nAdded in v2.0.0\n\n## filterMap\n\nMaps a `Record` with an iterating function that returns an `Option`\nand it keeps only the `Some` values discarding the `None`s.\n\n**Signature**\n\n```ts\nexport declare const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Record<string, A>) => Record<string, B>\n```\n\n**Example**\n\n```ts\nimport { filterMap } from 'fp-ts/Record'\nimport { option } from 'fp-ts'\n\nconst f = (s: string) => (s.length < 4 ? option.some(`${s} is short`) : option.none)\nassert.deepStrictEqual(filterMap(f)({ a: 'foo', b: 'bar', c: 'verylong' }), {\n  a: 'foo is short',\n  b: 'bar is short',\n})\n```\n\nAdded in v2.0.0\n\n## getWitherable\n\n**Signature**\n\n```ts\nexport declare const getWitherable: (O: Ord<string>) => Witherable1<URI>\n```\n\nAdded in v2.11.0\n\n## partition\n\nPartition a `Record` into two parts according to a `Predicate`.\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fa: Record<string, A>\n  ) => Separated<Record<string, A>, Record<string, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: Record<string, B>) => Separated<Record<string, B>, Record<string, B>>\n  <A>(predicate: Predicate<A>): (fa: Record<string, A>) => Separated<Record<string, A>, Record<string, A>>\n}\n```\n\n**Example**\n\n```ts\nimport { partition } from 'fp-ts/Record'\n\nassert.deepStrictEqual(partition((s: string) => s.length < 4)({ a: 'foo', b: 'bar', c: 'verylong' }), {\n  left: {\n    c: 'verylong',\n  },\n  right: {\n    a: 'foo',\n    b: 'bar',\n  },\n})\n```\n\nAdded in v2.0.0\n\n## partitionMap\n\nMaps a `Record` with a function returning an `Either` and\npartitions the resulting `Record` into `Left`s and `Right`s.\n\n**Signature**\n\n```ts\nexport declare const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: Record<string, A>) => Separated<Record<string, B>, Record<string, C>>\n```\n\n**Example**\n\n```ts\nimport { partitionMap } from 'fp-ts/Record'\nimport { either } from 'fp-ts'\n\nconst f = (s: string) => (s.length < 4 ? either.right(`${s} is short`) : either.left(`${s} is not short`))\nassert.deepStrictEqual(partitionMap(f)({ a: 'foo', b: 'bar', c: 'verylong' }), {\n  left: {\n    c: 'verylong is not short',\n  },\n  right: {\n    a: 'foo is short',\n    b: 'bar is short',\n  },\n})\n```\n\nAdded in v2.0.0\n\n## separate\n\nSeparate a `Record` of `Either`s into `Left`s and `Right`s.\n\n**Signature**\n\n```ts\nexport declare const separate: <A, B>(\n  fa: Record<string, Either<A, B>>\n) => Separated<Record<string, A>, Record<string, B>>\n```\n\n**Example**\n\n```ts\nimport { separate } from 'fp-ts/Record'\nimport { either } from 'fp-ts'\n\nassert.deepStrictEqual(separate({ a: either.right('foo'), b: either.left('bar'), c: either.right('baz') }), {\n  right: {\n    a: 'foo',\n    c: 'baz',\n  },\n  left: {\n    b: 'bar',\n  },\n})\n```\n\nAdded in v2.0.0\n\n## wilt\n\n**Signature**\n\n```ts\nexport declare const wilt: PipeableWilt1<'Record'>\n```\n\nAdded in v2.6.5\n\n## wither\n\n**Signature**\n\n```ts\nexport declare const wither: PipeableWither1<'Record'>\n```\n\nAdded in v2.6.5\n\n# folding\n\n## foldMap\n\nMap and fold a `Record`.\nMap the `Record` passing each value to the iterating function.\nThen fold the results using the provided `Monoid`.\n\n**Signature**\n\n```ts\nexport declare function foldMap(\n  O: Ord<string>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Record<string, A>) => M\nexport declare function foldMap<M>(M: Monoid<M>): <A>(f: (a: A) => M) => (fa: Record<string, A>) => M\n```\n\n**Example**\n\n```ts\nimport { foldMap } from 'fp-ts/Record'\nimport { Ord } from 'fp-ts/string'\nimport { Monoid } from 'fp-ts/Monoid'\n\nconst m: Monoid<string> = { empty: '', concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) }\nconst f = (a: number) => `-${a}-`\nconst x = { c: 3, a: 1, b: 2 }\nassert.deepStrictEqual(foldMap(Ord)(m)(f)(x), '-1- -> -2- -> -3-')\n```\n\nAdded in v2.0.0\n\n## getFoldable\n\nProduces a `Foldable` instance for a `Record`, using the\nprovided `Ord` to sort the `Record`'s entries by key.\n\n**Signature**\n\n```ts\nexport declare const getFoldable: (O: Ord<string>) => Foldable1<URI>\n```\n\nAdded in v2.11.0\n\n## getFoldableWithIndex\n\nProduces a `FoldableWithIndex1` instance for a `Record`, using the\nprovided `Ord` to sort the `Record`'s entries by key.\n\n**Signature**\n\n```ts\nexport declare const getFoldableWithIndex: (O: Ord<string>) => FoldableWithIndex1<URI, string>\n```\n\nAdded in v2.11.0\n\n## reduce\n\nReduces a `Record` passing each value to the iterating function.\nEntries are processed in order, sorted by key according to\nthe given `Ord`.\n\n**Signature**\n\n```ts\nexport declare function reduce(O: Ord<string>): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Record<string, A>) => B\nexport declare function reduce<A, B>(b: B, f: (b: B, a: A) => B): (fa: Record<string, A>) => B\n```\n\n**Example**\n\n```ts\nimport { reduce } from 'fp-ts/Record'\nimport { Ord } from 'fp-ts/string'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(reduce(Ord)([] as string[], (b, a) => [...b, `-${a}-`])(x), ['-foo-', '-false-', '-3-'])\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\nSame as `reduce` but entries are processed _from the right_,\ni.e. in reverse order, from the last to the first entry, according to\nthe given `Ord`.\n\n**Signature**\n\n```ts\nexport declare function reduceRight(O: Ord<string>): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Record<string, A>) => B\nexport declare function reduceRight<A, B>(b: B, f: (a: A, b: B) => B): (fa: Record<string, A>) => B\n```\n\n**Example**\n\n```ts\nimport { reduceRight } from 'fp-ts/Record'\nimport { Ord } from 'fp-ts/string'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(reduceRight(Ord)([] as string[], (a, b) => [...b, `-${a}-`])(x), ['-3-', '-false-', '-foo-'])\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Compactable\n\n**Signature**\n\n```ts\nexport declare const Compactable: Compactable1<'Record'>\n```\n\nAdded in v2.7.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: Filterable1<'Record'>\n```\n\nAdded in v2.7.0\n\n## FilterableWithIndex\n\n**Signature**\n\n```ts\nexport declare const FilterableWithIndex: FilterableWithIndex1<'Record', string>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'Record'>\n```\n\nAdded in v2.7.0\n\n## FunctorWithIndex\n\n**Signature**\n\n```ts\nexport declare const FunctorWithIndex: FunctorWithIndex1<'Record', string>\n```\n\nAdded in v2.7.0\n\n## getDifferenceMagma\n\nProduces a `Magma` with a `concat` function that combines\ntwo `Record`s by making the `difference`.\n\n**Signature**\n\n```ts\nexport declare const getDifferenceMagma: <A>() => Magma<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { getDifferenceMagma, difference } from 'fp-ts/Record'\nimport { Magma } from 'fp-ts/Magma'\n\nconst r1 = { a: 3, c: 3 }\nconst r2 = { a: 1, b: 2 }\nconst m: Magma<Record<string, number>> = getDifferenceMagma<number>()\nassert.deepStrictEqual(m.concat(r1, r2), difference(r2)(r1))\nassert.deepStrictEqual(m.concat(r1, r2), { c: 3, b: 2 })\n```\n\nAdded in v2.11.0\n\n## getEq\n\nGiven an `Eq` for the base type, it produces an `Eq`\nfor a `Record` of that base type.\n\n**Signature**\n\n```ts\nexport declare const getEq: <K extends string, A>(E: Eq<A>) => Eq<Record<K, A>>\n```\n\n**Example**\n\n```ts\nimport { getEq } from 'fp-ts/Record'\nimport { string } from 'fp-ts'\nimport { Eq } from 'fp-ts/Eq'\n\nconst eq: Eq<Record<string, string>> = getEq(string.Eq)\nassert.deepStrictEqual(eq.equals({ a: 'foo' }, { b: 'bar' }), false)\nassert.deepStrictEqual(eq.equals({ a: 'foo' }, { a: 'foo' }), true)\n```\n\nAdded in v2.0.0\n\n## getIntersectionSemigroup\n\nGiven a `Semigroup` in the base type, it produces a `Semigroup`\nin the `Record` of the base type.\nThe resulting `Semigroup` concatenates two `Record`s by\n`intersection`.\n\n**Signature**\n\n```ts\nexport declare const getIntersectionSemigroup: <A>(S: Se.Semigroup<A>) => Se.Semigroup<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { getIntersectionSemigroup } from 'fp-ts/Record'\nimport { Semigroup } from 'fp-ts/Semigroup'\n\nconst sNumber: Semigroup<number> = { concat: (x, y) => x - y }\nconst sRecord: Semigroup<Record<string, number>> = getIntersectionSemigroup(sNumber)\nassert.deepStrictEqual(sRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { b: -1 })\n```\n\nAdded in v2.11.0\n\n## getMonoid\n\nReturns a `Monoid` instance for `Record`s, given a `Semigroup`\ninstance for the base type.\nThe `Monoid` makes the union of two `Record`s comining the\noverlapping entries with the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <K extends string, A>(S: Se.Semigroup<A>) => Monoid<Record<K, A>>\n```\n\n**Example**\n\n```ts\nimport { SemigroupSum } from 'fp-ts/number'\nimport { getMonoid } from 'fp-ts/Record'\n\nconst M = getMonoid(SemigroupSum)\nassert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579, bar: 234, baz: 567 })\n```\n\nAdded in v2.0.0\n\n## getShow\n\nProduces a `Show` for a `Record`, given a `Show` for the base type\n(a `Show` produces a human-readable representation of an instance).\n`Record` entries are sorted by key with the provided `Ord`.\n\n**Signature**\n\n```ts\nexport declare function getShow(O: Ord<string>): <A>(S: Show<A>) => Show<Record<string, A>>\nexport declare function getShow<A>(S: Show<A>): Show<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { getShow } from 'fp-ts/Record'\nimport { Show } from 'fp-ts/Show'\nimport { Ord } from 'fp-ts/string'\n\nconst sNumber: Show<number> = { show: (n: number) => `${n}` }\nconst sRecord: Show<Record<string, number>> = getShow(Ord)(sNumber)\nassert.deepStrictEqual(sRecord.show({ b: 2, a: 1 }), '{ \"a\": 1, \"b\": 2 }')\n```\n\nAdded in v2.0.0\n\n## getUnionMonoid\n\nSame as `getMonoid`.\nReturns a `Monoid` instance for `Record`s given a `Semigroup`\ninstance for the base type.\nThe `Monoid` makes the union of two `Record`s combining the\nentries that have the same key with the provided `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare const getUnionMonoid: <A>(S: Se.Semigroup<A>) => Monoid<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { SemigroupSum } from 'fp-ts/number'\nimport { getUnionMonoid } from 'fp-ts/Record'\n\nconst M = getUnionMonoid(SemigroupSum)\nassert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579, bar: 234, baz: 567 })\n```\n\nAdded in v2.11.0\n\n## getUnionSemigroup\n\nGiven a `Semigroup` in the base type, it produces a `Semigroup`\nin the `Record` of the base type.\nThe resulting `Semigroup` concatenates two `Record`s by\n`union`.\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <A>(S: Se.Semigroup<A>) => Se.Semigroup<Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { getUnionSemigroup } from 'fp-ts/Record'\nimport { Semigroup } from 'fp-ts/Semigroup'\n\nconst sNumber: Semigroup<number> = { concat: (x, y) => x - y }\nconst sRecord: Semigroup<Record<string, number>> = getUnionSemigroup(sNumber)\nassert.deepStrictEqual(sRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { a: 1, b: -1, c: 4 })\n```\n\nAdded in v2.11.0\n\n# mapping\n\n## flap\n\nTakes a value and a `Record` of functions and returns a\n`Record` by applying each function to the input value.\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: Record<string, (a: A) => B>) => Record<string, B>\n```\n\n**Example**\n\n```ts\nimport { flap } from 'fp-ts/Record'\n\nconst fab = { x: (n: number) => `${n} times 2`, y: (n: number) => `${n * 2}` }\nassert.deepStrictEqual(flap(3)(fab), {\n  x: '3 times 2',\n  y: '6',\n})\n```\n\nAdded in v2.10.0\n\n## map\n\nMap a `Record` passing the values to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <K extends string>(fa: Record<K, A>) => Record<K, B>\n```\n\n**Example**\n\n```ts\nimport { map } from 'fp-ts/Record'\n\nconst f = (n: number) => `-${n}-`\nassert.deepStrictEqual(map(f)({ a: 3, b: 5 }), { a: '-3-', b: '-5-' })\n```\n\nAdded in v2.0.0\n\n# traversing\n\n## getTraversable\n\nProduces a `Traversable` instance for a `Record`, using the\nprovided `Ord` to sort the `Record`'s entries by key.\n\n**Signature**\n\n```ts\nexport declare const getTraversable: (O: Ord<string>) => Traversable1<URI>\n```\n\nAdded in v2.11.0\n\n## getTraversableWithIndex\n\nProduces a `TraversableWithIndex` instance for a `Record`, using the\nprovided `Ord` to sort the `Record`'s entries by key.\n\n**Signature**\n\n```ts\nexport declare const getTraversableWithIndex: (O: Ord<string>) => TraversableWithIndex1<URI, string>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Record'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## collect\n\nMap a `Record` into an `Array`.\nIt passes each key/value pair to the iterating function and collects\nthe results in an array, sorted alphabetically by the original key.\n\n**Signature**\n\n```ts\nexport declare function collect(\n  O: Ord<string>\n): <K extends string, A, B>(f: (k: K, a: A) => B) => (r: Record<K, A>) => Array<B>\nexport declare function collect<K extends string, A, B>(f: (k: K, a: A) => B): (r: Record<K, A>) => Array<B>\n```\n\n**Example**\n\n```ts\nimport { collect } from 'fp-ts/Record'\nimport { Ord } from 'fp-ts/string'\n\nconst f = <A>(k: string, a: A) => `${k.toUpperCase()}-${a}`\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(collect(Ord)(f)(x), ['A-foo', 'B-false', 'C-3'])\n```\n\nAdded in v2.0.0\n\n## deleteAt\n\nDelete a key and value from a `Record`.\n\n**Signature**\n\n```ts\nexport declare function deleteAt<K extends string>(\n  k: K\n): <KS extends string, A>(r: Record<KS, A>) => Record<string extends K ? string : Exclude<KS, K>, A>\n```\n\n**Example**\n\n```ts\nimport { deleteAt } from 'fp-ts/Record'\n\nassert.deepStrictEqual(deleteAt('a')({ a: 1, b: 2 }), { b: 2 })\nassert.deepStrictEqual(deleteAt('c')({ a: 1, b: 2 }), { a: 1, b: 2 })\n```\n\nAdded in v2.0.0\n\n## difference\n\nDifference between two `Record`s.\nTakes two `Record`s and produces a `Record` composed by the\nentries of the two inputs, removing the entries with the same\nkey in both inputs.\n\n**Signature**\n\n```ts\nexport declare const difference: <A>(second: Record<string, A>) => (first: Record<string, A>) => Record<string, A>\n```\n\n**Example**\n\n```ts\nimport { difference } from 'fp-ts/Record'\n\nassert.deepStrictEqual(difference({ a: 1 })({ a: 1, b: 2 }), { b: 2 })\nassert.deepStrictEqual(difference({ a: 3 })({ a: 1, b: 2 }), { b: 2 })\nassert.deepStrictEqual(difference({ a: 3, c: 3 })({ a: 1, b: 2 }), { b: 2, c: 3 })\n```\n\nAdded in v2.11.0\n\n## elem\n\nGiven an `Eq` checks if a `Record` contains an entry with\nvalue equal to a provided value.\n\n**Signature**\n\n```ts\nexport declare const elem: <A>(E: Eq<A>) => {\n  (a: A): (fa: Record<string, A>) => boolean\n  (a: A, fa: Record<string, A>): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { elem } from 'fp-ts/Record'\nimport { number } from 'fp-ts'\n\nassert.deepStrictEqual(elem(number.Eq)(123, { foo: 123, bar: 234 }), true)\nassert.deepStrictEqual(elem(number.Eq)(-7, { foo: 123, bar: 234 }), false)\n```\n\nAdded in v2.0.0\n\n## every\n\nTest if every value in a `Record` satisfies the predicate.\n\n**Signature**\n\n```ts\nexport declare const every: {\n  <A, B extends A>(refinement: Refinement<A, B>): Refinement<Record<string, A>, Record<string, B>>\n  <A>(predicate: Predicate<A>): Predicate<Record<string, A>>\n}\n```\n\n**Example**\n\n```ts\nimport { every } from 'fp-ts/Record'\n\nassert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: 2 }), true)\nassert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: -1 }), false)\n```\n\nAdded in v2.0.0\n\n## filterMapWithIndex\n\nMaps a `Record` with an iterating function that takes key and value and\nreturns an `Option`, keeping only the `Some` values and discarding `None`s.\n\n**Signature**\n\n```ts\nexport declare const filterMapWithIndex: <K extends string, A, B>(\n  f: (key: K, a: A) => Option<B>\n) => (fa: Record<K, A>) => Record<string, B>\n```\n\n**Example**\n\n```ts\nimport { filterMapWithIndex } from 'fp-ts/Record'\nimport { option } from 'fp-ts'\n\nconst f = (key: string, a: number) => (a >= 0 ? option.some(`${key}${a}`) : option.none)\nassert.deepStrictEqual(filterMapWithIndex(f)({ a: -1, b: 2, c: 3 }), {\n  b: 'b2',\n  c: 'c3',\n})\n```\n\nAdded in v2.0.0\n\n## filterWithIndex\n\nProduce a new `Record` keeping only the entries that satisfy\na predicate taking key and value as input.\n\n**Signature**\n\n```ts\nexport declare function filterWithIndex<K extends string, A, B extends A>(\n  refinementWithIndex: RefinementWithIndex<K, A, B>\n): (fa: Record<K, A>) => Record<string, B>\nexport declare function filterWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): <B extends A>(fb: Record<K, B>) => Record<string, B>\nexport declare function filterWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): (fa: Record<K, A>) => Record<string, A>\n```\n\n**Example**\n\n```ts\nimport { filterWithIndex } from 'fp-ts/Record'\n\nassert.deepStrictEqual(filterWithIndex((s: string, v: number) => s.length <= 1 && v > 0)({ a: 1, b: -2, ccc: 3 }), {\n  a: 1,\n})\n```\n\nAdded in v2.0.0\n\n## foldMapWithIndex\n\nMap and fold a `Record`.\nMap the `Record` passing each key/value pair to the iterating function.\nThen fold the results using the provided `Monoid`.\n\n**Signature**\n\n```ts\nexport declare function foldMapWithIndex(\n  O: Ord<string>\n): <M>(M: Monoid<M>) => <K extends string, A>(f: (k: K, a: A) => M) => (fa: Record<K, A>) => M\nexport declare function foldMapWithIndex<M>(\n  M: Monoid<M>\n): <K extends string, A>(f: (k: K, a: A) => M) => (fa: Record<K, A>) => M\n```\n\n**Example**\n\n```ts\nimport { foldMapWithIndex } from 'fp-ts/Record'\nimport { Ord } from 'fp-ts/string'\nimport { Monoid } from 'fp-ts/Monoid'\n\nconst m: Monoid<string> = { empty: '', concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) }\nconst f = (k: string, a: number) => `${k}-${a}`\nconst x = { c: 3, a: 1, b: 2 }\nassert.deepStrictEqual(foldMapWithIndex(Ord)(m)(f)(x), 'a-1 -> b-2 -> c-3')\n```\n\nAdded in v2.0.0\n\n## fromFoldable\n\nCreate a `Record` from a foldable collection of key/value pairs, using the\nspecified `Magma` to combine values for duplicate keys.\n\n**Signature**\n\n```ts\nexport declare function fromFoldable<F extends URIS3, A>(\n  M: Magma<A>,\n  F: Foldable3<F>\n): <R, E>(fka: Kind3<F, R, E, [string, A]>) => Record<string, A>\nexport declare function fromFoldable<F extends URIS2, A>(\n  M: Magma<A>,\n  F: Foldable2<F>\n): <E>(fka: Kind2<F, E, [string, A]>) => Record<string, A>\nexport declare function fromFoldable<F extends URIS, A>(\n  M: Magma<A>,\n  F: Foldable1<F>\n): (fka: Kind<F, [string, A]>) => Record<string, A>\nexport declare function fromFoldable<F, A>(\n  M: Magma<A>,\n  F: FoldableHKT<F>\n): (fka: HKT<F, [string, A]>) => Record<string, A>\n```\n\nAdded in v2.0.0\n\n## fromFoldableMap\n\nCreate a `Record` from a foldable collection using the specified functions to\n\n- map to key/value pairs\n- combine values for duplicate keys.\n\n**Signature**\n\n```ts\nexport declare function fromFoldableMap<F extends URIS3, B>(\n  M: Magma<B>,\n  F: Foldable3<F>\n): <R, E, A>(fa: Kind3<F, R, E, A>, f: (a: A) => [string, B]) => Record<string, B>\nexport declare function fromFoldableMap<F extends URIS2, B>(\n  M: Magma<B>,\n  F: Foldable2<F>\n): <E, A>(fa: Kind2<F, E, A>, f: (a: A) => [string, B]) => Record<string, B>\nexport declare function fromFoldableMap<F extends URIS, B>(\n  M: Magma<B>,\n  F: Foldable1<F>\n): <A>(fa: Kind<F, A>, f: (a: A) => [string, B]) => Record<string, B>\nexport declare function fromFoldableMap<F, B>(\n  M: Magma<B>,\n  F: FoldableHKT<F>\n): <A>(fa: HKT<F, A>, f: (a: A) => [string, B]) => Record<string, B>\n```\n\n**Example**\n\n```ts\nimport { last } from 'fp-ts/Semigroup'\nimport { Foldable, zip } from 'fp-ts/Array'\nimport { identity } from 'fp-ts/function'\nimport { fromFoldableMap } from 'fp-ts/Record'\n\nexport const zipObject = <K extends string, A>(keys: Array<K>, values: Array<A>): Record<K, A> =>\n  fromFoldableMap(last<A>(), Foldable)(zip(keys, values), identity)\n\nassert.deepStrictEqual(zipObject(['a', 'b'], [1, 2, 3]), { a: 1, b: 2 })\n\ninterface User {\n  readonly id: string\n  readonly name: string\n}\n\nconst users: Array<User> = [\n  { id: 'id1', name: 'name1' },\n  { id: 'id2', name: 'name2' },\n  { id: 'id1', name: 'name3' },\n]\n\nassert.deepStrictEqual(\n  fromFoldableMap(last<User>(), Foldable)(users, (user) => [user.id, user]),\n  {\n    id1: { id: 'id1', name: 'name3' },\n    id2: { id: 'id2', name: 'name2' },\n  }\n)\n```\n\nAdded in v2.0.0\n\n## has\n\nTest whether or not a key exists in a `Record`.\n\nNote. This function is not pipeable because is a `Refinement`.\n\n**Signature**\n\n```ts\nexport declare const has: <K extends string>(k: string, r: Record<K, unknown>) => k is K\n```\n\n**Example**\n\n```ts\nimport { has } from 'fp-ts/Record'\n\nassert.deepStrictEqual(has('a', { a: 1, b: 2 }), true)\nassert.deepStrictEqual(has('c', { a: 1, b: 2 }), false)\n```\n\nAdded in v2.10.0\n\n## intersection\n\nIntersection of two `Record`s.\nTakes two `Record`s and produces a `Record` combining only the\nentries of the two inputswith the same key.\nIt uses the `concat` function of the provided `Magma` to\ncombine the elements.\n\n**Signature**\n\n```ts\nexport declare const intersection: <A>(\n  M: Magma<A>\n) => (second: Record<string, A>) => (first: Record<string, A>) => Record<string, A>\n```\n\n**Example**\n\n```ts\nimport { intersection } from 'fp-ts/Record'\nimport { Magma } from 'fp-ts/Magma'\n\nconst m1: Magma<number> = { concat: (x: number, y: number) => x + y }\nassert.deepStrictEqual(intersection(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4 })\nconst m2: Magma<number> = { concat: (x: number) => x }\nassert.deepStrictEqual(intersection(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1 })\n```\n\nAdded in v2.11.0\n\n## isEmpty\n\nTest whether a `Record` is empty.\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <A>(r: Record<string, A>) => boolean\n```\n\n**Example**\n\n```ts\nimport { isEmpty } from 'fp-ts/Record'\n\nassert.deepStrictEqual(isEmpty({}), true)\nassert.deepStrictEqual(isEmpty({ a: 3 }), false)\n```\n\nAdded in v2.0.0\n\n## isSubrecord\n\nTest whether one `Record` contains all of the keys and values\ncontained in another `Record`.\n\n**Signature**\n\n```ts\nexport declare const isSubrecord: <A>(E: Eq<A>) => {\n  (that: Record<string, A>): (me: Record<string, A>) => boolean\n  (me: Record<string, A>, that: Record<string, A>): boolean\n}\n```\n\n**Example**\n\n```ts\nimport { isSubrecord } from 'fp-ts/Record'\nimport { string } from 'fp-ts'\n\nassert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', b: 'bar', c: 'baz' }), true)\nassert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', c: 'baz' }), true)\nassert.deepStrictEqual(\n  isSubrecord(string.Eq)({ a: 'foo', b: 'bar', c: 'baz' })({ a: 'foo', b: 'not-bar', c: 'baz' }),\n  false\n)\nassert.deepStrictEqual(isSubrecord(string.Eq)({ a: 'foo', b: 'bar' })({ a: 'foo', b: 'bar', c: 'baz' }), false)\n```\n\nAdded in v2.0.0\n\n## keys\n\nThe keys of a `Record`, sorted alphabetically.\n\n**Signature**\n\n```ts\nexport declare const keys: <K extends string>(r: Record<K, unknown>) => K[]\n```\n\n**Example**\n\n```ts\nimport { keys } from 'fp-ts/Record'\n\nassert.deepStrictEqual(keys({ c: 1, a: 2, b: 3 }), ['a', 'b', 'c'])\n```\n\nAdded in v2.0.0\n\n## lookup\n\nLookup the value for a key in a `Record`.\n\n**Signature**\n\n```ts\nexport declare const lookup: {\n  (k: string): <A>(r: Record<string, A>) => Option<A>\n  <A>(k: string, r: Record<string, A>): Option<A>\n}\n```\n\n**Example**\n\n```ts\nimport { lookup } from 'fp-ts/Record'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(lookup('b')({ a: 'foo', b: 'bar' }), option.some('bar'))\nassert.deepStrictEqual(lookup('c')({ a: 'foo', b: 'bar' }), option.none)\n```\n\nAdded in v2.0.0\n\n## mapWithIndex\n\nMap a `Record` passing the key/value pairs to the iterating function.\n\n**Signature**\n\n```ts\nexport declare const mapWithIndex: <K extends string, A, B>(f: (k: K, a: A) => B) => (fa: Record<K, A>) => Record<K, B>\n```\n\n**Example**\n\n```ts\nimport { mapWithIndex } from 'fp-ts/Record'\n\nconst f = (k: string, n: number) => `${k.toUpperCase()}-${n}`\nassert.deepStrictEqual(mapWithIndex(f)({ a: 3, b: 5 }), { a: 'A-3', b: 'B-5' })\n```\n\nAdded in v2.0.0\n\n## modifyAt\n\nApplies a mapping function to one spcific key/value pair in a `Record`.\n\n**Signature**\n\n```ts\nexport declare const modifyAt: <A>(\n  k: string,\n  f: (a: A) => A\n) => <K extends string>(r: Record<K, A>) => Option<Record<K, A>>\n```\n\n**Example**\n\n```ts\nimport { modifyAt } from 'fp-ts/Record'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(modifyAt('a', (x: number) => x * 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }))\nassert.deepStrictEqual(modifyAt('c', (x: number) => x * 3)({ a: 1, b: 2 }), option.none)\n```\n\nAdded in v2.0.0\n\n## partitionMapWithIndex\n\nMaps a `Record` with a function returning an `Either` and\npartitions the resulting `Record` into `Left`s and `Right`s.\n\n**Signature**\n\n```ts\nexport declare const partitionMapWithIndex: <K extends string, A, B, C>(\n  f: (key: K, a: A) => Either<B, C>\n) => (fa: Record<K, A>) => Separated<Record<string, B>, Record<string, C>>\n```\n\n**Example**\n\n```ts\nimport { partitionMapWithIndex } from 'fp-ts/Record'\nimport { either } from 'fp-ts'\n\nconst f = (key: string, a: number) =>\n  a >= 0 ? either.right(`${key} is >= 0 (${a})`) : either.left(`${key} is < 0 (${a})`)\nassert.deepStrictEqual(partitionMapWithIndex(f)({ a: -1, b: 2, c: 123 }), {\n  left: {\n    a: 'a is < 0 (-1)',\n  },\n  right: {\n    b: 'b is >= 0 (2)',\n    c: 'c is >= 0 (123)',\n  },\n})\n```\n\nAdded in v2.0.0\n\n## partitionWithIndex\n\nPartition a `Record` into two parts according to a predicate\nthat takes a key and a value.\n\n**Signature**\n\n```ts\nexport declare function partitionWithIndex<K extends string, A, B extends A>(\n  refinementWithIndex: RefinementWithIndex<K, A, B>\n): (fa: Record<K, A>) => Separated<Record<string, A>, Record<string, B>>\nexport declare function partitionWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): <B extends A>(fb: Record<K, B>) => Separated<Record<string, B>, Record<string, B>>\nexport declare function partitionWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): (fa: Record<K, A>) => Separated<Record<string, A>, Record<string, A>>\n```\n\n**Example**\n\n```ts\nimport { partitionWithIndex } from 'fp-ts/Record'\n\nassert.deepStrictEqual(\n  partitionWithIndex((key: string, a: number) => key.length <= 1 && a > 0)({ a: -1, b: 2, ccc: 7 }),\n  {\n    left: {\n      a: -1,\n      ccc: 7,\n    },\n    right: {\n      b: 2,\n    },\n  }\n)\n```\n\nAdded in v2.0.0\n\n## pop\n\nDelete a key and value from a `Record`, returning the value as well as the subsequent `Record`.\n\n**Signature**\n\n```ts\nexport declare function pop<K extends string>(\n  k: K\n): <KS extends string, A>(r: Record<KS, A>) => Option<[A, Record<string extends K ? string : Exclude<KS, K>, A>]>\n```\n\n**Example**\n\n```ts\nimport { pop } from 'fp-ts/Record'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(pop('a')({ a: 1, b: 2, c: 3 }), option.some([1, { b: 2, c: 3 }]))\nassert.deepStrictEqual(pop('x')({ a: 1, b: 2, c: 3 }), option.none)\n```\n\nAdded in v2.0.0\n\n## reduceRightWithIndex\n\nSame as `reduceWithIndex`, but reduce starting from the right\n(i.e. in reverse order, from the last to the first entry according to\nthe given `Ord`).\n\n**Signature**\n\n```ts\nexport declare function reduceRightWithIndex(\n  O: Ord<string>\n): <K extends string, A, B>(b: B, f: (k: K, a: A, b: B) => B) => (fa: Record<K, A>) => B\nexport declare function reduceRightWithIndex<K extends string, A, B>(\n  b: B,\n  f: (k: K, a: A, b: B) => B\n): (fa: Record<K, A>) => B\n```\n\n**Example**\n\n```ts\nimport { reduceRightWithIndex } from 'fp-ts/Record'\nimport { Ord } from 'fp-ts/string'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(reduceRightWithIndex(Ord)([] as string[], (k, a, b) => [...b, `${k}-${a}`])(x), [\n  'c-3',\n  'b-false',\n  'a-foo',\n])\n```\n\nAdded in v2.0.0\n\n## reduceWithIndex\n\nReduces a `Record` passing each key/value pair to the iterating function.\nEntries are processed in the order, sorted by key according to\nthe given `Ord`.\n\n**Signature**\n\n```ts\nexport declare function reduceWithIndex(\n  O: Ord<string>\n): <K extends string, A, B>(b: B, f: (k: K, b: B, a: A) => B) => (fa: Record<K, A>) => B\nexport declare function reduceWithIndex<K extends string, A, B>(\n  b: B,\n  f: (k: K, b: B, a: A) => B\n): (fa: Record<K, A>) => B\n```\n\n**Example**\n\n```ts\nimport { reduceWithIndex } from 'fp-ts/Record'\nimport { Ord } from 'fp-ts/string'\n\nconst x = { c: 3, a: 'foo', b: false }\nassert.deepStrictEqual(reduceWithIndex(Ord)([] as string[], (k, b, a) => [...b, `${k}-${a}`])(x), [\n  'a-foo',\n  'b-false',\n  'c-3',\n])\n```\n\nAdded in v2.0.0\n\n## sequence\n\n`Record` sequencing,\ni.e., take a `Record` in which elements are monads\nand return a monad of a `Record` of the base types.\nThe following example for instance shows sequencing\na `Record<string, Option<number>>`\ninto an `Option<Record<string, number>>`.\n\n`sequence` in `Record` is equivalent to `sequenceS` in `Apply.ts`.\n\n**Signature**\n\n```ts\nexport declare function sequence<F extends URIS3>(\n  F: Applicative3<F>\n): <K extends string, R, E, A>(ta: Record<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, Record<K, A>>\nexport declare function sequence<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <K extends string, R, A>(ta: Record<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, Record<K, A>>\nexport declare function sequence<F extends URIS2>(\n  F: Applicative2<F>\n): <K extends string, E, A>(ta: Record<K, Kind2<F, E, A>>) => Kind2<F, E, Record<K, A>>\nexport declare function sequence<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <K extends string, A>(ta: Record<K, Kind2<F, E, A>>) => Kind2<F, E, Record<K, A>>\nexport declare function sequence<F extends URIS>(\n  F: Applicative1<F>\n): <K extends string, A>(ta: Record<K, Kind<F, A>>) => Kind<F, Record<K, A>>\nexport declare function sequence<F>(\n  F: Applicative<F>\n): <K extends string, A>(ta: Record<K, HKT<F, A>>) => HKT<F, Record<K, A>>\n```\n\n**Example**\n\n```ts\nimport { sequence } from 'fp-ts/Record'\nimport { option } from 'fp-ts'\nimport { sequenceS } from 'fp-ts/Apply'\n\nassert.deepStrictEqual(\n  sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),\n  option.some({ a: 1, b: 2 })\n)\nassert.deepStrictEqual(sequence(option.Applicative)({ a: option.some(1), b: option.none }), option.none)\nassert.deepStrictEqual(\n  sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),\n  sequenceS(option.Applicative)({ a: option.some(1), b: option.some(2) })\n)\n```\n\nAdded in v2.0.0\n\n## singleton\n\nCreate a `Record` with one key/value pair.\n\n**Signature**\n\n```ts\nexport declare const singleton: <A>(k: string, a: A) => Record<string, A>\n```\n\n**Example**\n\n```ts\nimport { singleton } from 'fp-ts/Record'\n\nassert.deepStrictEqual(singleton('a', 1), { a: 1 })\n```\n\nAdded in v2.0.0\n\n## size\n\nCalculate the number of key/value pairs in a `Record`.\n\n**Signature**\n\n```ts\nexport declare const size: <A>(r: Record<string, A>) => number\n```\n\n**Example**\n\n```ts\nimport { size } from 'fp-ts/Record'\n\nassert.deepStrictEqual(size({ a: true, b: 2, c: 'three' }), 3)\n```\n\nAdded in v2.0.0\n\n## some\n\nTest if at least one value in a `Record` satisfies the predicate.\n\n**Signature**\n\n```ts\nexport declare const some: <A>(predicate: (a: A) => boolean) => (r: Record<string, A>) => boolean\n```\n\n**Example**\n\n```ts\nimport { some } from 'fp-ts/Record'\n\nassert.deepStrictEqual(some((n: number) => n >= 0)({ a: 1, b: -2 }), true)\nassert.deepStrictEqual(some((n: number) => n >= 0)({ a: -1, b: -2 }), false)\n```\n\nAdded in v2.0.0\n\n## toUnfoldable\n\nUnfolds a `Record` into a list of key/value pairs.\n\nGiven an `Unfoldable` class type `U` such as `array` or `readonlyArray`,\nit uses the `unfold` function to create an instance of `U`,\nproviding an iterating function that iterates over each\nkey/value pair in the record sorted alphabetically by key.\n\n**Signature**\n\n```ts\nexport declare function toUnfoldable<F extends URIS>(\n  U: Unfoldable1<F>\n): <K extends string, A>(r: Record<K, A>) => Kind<F, [K, A]>\nexport declare function toUnfoldable<F>(U: Unfoldable<F>): <K extends string, A>(r: Record<K, A>) => HKT<F, [K, A]>\n```\n\n**Example**\n\n```ts\nimport { array, readonlyArray } from 'fp-ts'\nimport { toUnfoldable } from 'fp-ts/Record'\n\nassert.deepStrictEqual(toUnfoldable(array)({ b: 2, a: 1 }), [\n  ['a', 1],\n  ['b', 2],\n])\nassert.deepStrictEqual(toUnfoldable(readonlyArray)({ b: 2, a: 1 }), [\n  ['a', 1],\n  ['b', 2],\n])\n```\n\nAdded in v2.0.0\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare function traverse<F extends URIS4>(\n  F: Applicative4<F>\n): <S, R, E, A, B>(\n  f: (a: A) => Kind4<F, S, R, E, B>\n) => <K extends string>(ta: Record<K, A>) => Kind4<F, S, R, E, Record<K, B>>\nexport declare function traverse<F extends URIS3>(\n  F: Applicative3<F>\n): <R, E, A, B>(f: (a: A) => Kind3<F, R, E, B>) => <K extends string>(ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>\nexport declare function traverse<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <R, A, B>(f: (a: A) => Kind3<F, R, E, B>) => <K extends string>(ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>\nexport declare function traverse<F extends URIS2>(\n  F: Applicative2<F>\n): <E, A, B>(f: (a: A) => Kind2<F, E, B>) => <K extends string>(ta: Record<K, A>) => Kind2<F, E, Record<K, B>>\nexport declare function traverse<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <A, B>(f: (a: A) => Kind2<F, E, B>) => <K extends string>(ta: Record<K, A>) => Kind2<F, E, Record<K, B>>\nexport declare function traverse<F extends URIS>(\n  F: Applicative1<F>\n): <A, B>(f: (a: A) => Kind<F, B>) => <K extends string>(ta: Record<K, A>) => Kind<F, Record<K, B>>\nexport declare function traverse<F>(\n  F: Applicative<F>\n): <A, B>(f: (a: A) => HKT<F, B>) => <K extends string>(ta: Record<K, A>) => HKT<F, Record<K, B>>\n```\n\nAdded in v2.0.0\n\n## traverseWithIndex\n\n**Signature**\n\n```ts\nexport declare function traverseWithIndex<F extends URIS4>(\n  F: Applicative4<F>\n): <K extends string, S, R, E, A, B>(\n  f: (k: K, a: A) => Kind4<F, S, R, E, B>\n) => (ta: Record<K, A>) => Kind4<F, S, R, E, Record<K, B>>\nexport declare function traverseWithIndex<F extends URIS3>(\n  F: Applicative3<F>\n): <K extends string, R, E, A, B>(\n  f: (k: K, a: A) => Kind3<F, R, E, B>\n) => (ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>\nexport declare function traverseWithIndex<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <K extends string, R, A, B>(\n  f: (k: K, a: A) => Kind3<F, R, E, B>\n) => (ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>\nexport declare function traverseWithIndex<F extends URIS2>(\n  F: Applicative2<F>\n): <K extends string, E, A, B>(f: (k: K, a: A) => Kind2<F, E, B>) => (ta: Record<K, A>) => Kind2<F, E, Record<K, B>>\nexport declare function traverseWithIndex<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <K extends string, A, B>(f: (k: K, a: A) => Kind2<F, E, B>) => (ta: Record<K, A>) => Kind2<F, E, Record<K, B>>\nexport declare function traverseWithIndex<F extends URIS>(\n  F: Applicative1<F>\n): <K extends string, A, B>(f: (k: K, a: A) => Kind<F, B>) => (ta: Record<K, A>) => Kind<F, Record<K, B>>\nexport declare function traverseWithIndex<F>(\n  F: Applicative<F>\n): <K extends string, A, B>(f: (k: K, a: A) => HKT<F, B>) => (ta: Record<K, A>) => HKT<F, Record<K, B>>\n```\n\nAdded in v2.0.0\n\n## union\n\nUnion of two `Record`s.\nTakes two `Record`s and produces a `Record` combining all the\nentries of the two inputs.\nIt uses the `concat` function of the provided `Magma` to\ncombine the elements with the same key.\n\n**Signature**\n\n```ts\nexport declare const union: <A>(\n  M: Magma<A>\n) => (second: Record<string, A>) => (first: Record<string, A>) => Record<string, A>\n```\n\n**Example**\n\n```ts\nimport { union } from 'fp-ts/Record'\nimport { Magma } from 'fp-ts/Magma'\n\nconst m1: Magma<number> = { concat: (x: number, y: number) => x + y }\nassert.deepStrictEqual(union(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4, b: 2, c: 3 })\nconst m2: Magma<number> = { concat: (x: number) => x }\nassert.deepStrictEqual(union(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 })\n```\n\nAdded in v2.11.0\n\n## updateAt\n\nReplace a key/value pair in a `Record`.\n\n**Signature**\n\n```ts\nexport declare const updateAt: <A>(k: string, a: A) => <K extends string>(r: Record<K, A>) => Option<Record<K, A>>\n```\n\n**Example**\n\n```ts\nimport { updateAt } from 'fp-ts/Record'\nimport { option } from 'fp-ts'\n\nassert.deepStrictEqual(updateAt('a', 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }))\nassert.deepStrictEqual(updateAt('c', 3)({ a: 1, b: 2 }), option.none)\n```\n\nAdded in v2.0.0\n\n## upsertAt\n\nInsert or replace a key/value pair in a `Record`.\n\n**Signature**\n\n```ts\nexport declare const upsertAt: <A>(k: string, a: A) => (r: Record<string, A>) => Record<string, A>\n```\n\n**Example**\n\n```ts\nimport { upsertAt } from 'fp-ts/Record'\n\nassert.deepStrictEqual(upsertAt('a', 5)({ a: 1, b: 2 }), { a: 5, b: 2 })\nassert.deepStrictEqual(upsertAt('c', 5)({ a: 1, b: 2 }), { a: 1, b: 2, c: 5 })\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~FoldableWithIndex~~\n\nUse `getFoldableWithIndex` instead.\n\n**Signature**\n\n```ts\nexport declare const FoldableWithIndex: FoldableWithIndex1<'Record', string>\n```\n\nAdded in v2.7.0\n\n## ~~Foldable~~\n\nUse `getFoldable` instead.\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable1<'Record'>\n```\n\nAdded in v2.7.0\n\n## ~~TraversableWithIndex~~\n\nUse the `getTraversableWithIndex` instead.\n\n**Signature**\n\n```ts\nexport declare const TraversableWithIndex: TraversableWithIndex1<'Record', string>\n```\n\nAdded in v2.7.0\n\n## ~~Traversable~~\n\nUse `getTraversable` instead.\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable1<'Record'>\n```\n\nAdded in v2.7.0\n\n## ~~Witherable~~\n\nUse `getWitherable` instead.\n\n**Signature**\n\n```ts\nexport declare const Witherable: Witherable1<'Record'>\n```\n\nAdded in v2.7.0\n\n## ~~empty~~\n\nUse a new `{}` instead.\n\n**Signature**\n\n```ts\nexport declare const empty: Record<string, never>\n```\n\nAdded in v2.0.0\n\n## ~~hasOwnProperty (function)~~\n\nUse [`has`](#has) instead.\n\n**Signature**\n\n```ts\nexport declare const hasOwnProperty: <K extends string>(k: string, r: Record<K, unknown>) => k is K\n```\n\nAdded in v2.0.0\n\n## ~~insertAt~~\n\nUse [`upsertAt`](#upsertat) instead.\n\n**Signature**\n\n```ts\nexport declare const insertAt: <A>(k: string, a: A) => (r: Record<string, A>) => Record<string, A>\n```\n\nAdded in v2.0.0\n\n## ~~record~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `R.Functor` instead of `R.record`\n(where `R` is from `import R from 'fp-ts/Record'`)\n\n**Signature**\n\n```ts\nexport declare const record: FunctorWithIndex1<'Record', string> &\n  FoldableWithIndex1<'Record', string> &\n  FilterableWithIndex1<'Record', string> &\n  TraversableWithIndex1<'Record', string> &\n  Witherable1<'Record'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Refinement.ts.md",
    "content": "---\ntitle: Refinement.ts\nnav_order: 90\nparent: Modules\n---\n\n## Refinement overview\n\nAdded in v2.11.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [id](#id)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromOptionK](#fromoptionk)\n- [utils](#utils)\n  - [Refinement (interface)](#refinement-interface)\n  - [and](#and)\n  - [compose](#compose)\n  - [not](#not)\n  - [or](#or)\n  - [zero](#zero)\n\n---\n\n# constructors\n\n## id\n\n**Signature**\n\n```ts\nexport declare const id: <A>() => Refinement<A, A>\n```\n\nAdded in v2.11.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <A, B extends A>(getEither: (a: A) => Either<unknown, B>) => Refinement<A, B>\n```\n\nAdded in v2.11.0\n\n## fromOptionK\n\nReturns a `Refinement` from a `Option` returning function.\nThis function ensures that a `Refinement` definition is type-safe.\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <A, B extends A>(getOption: (a: A) => Option<B>) => Refinement<A, B>\n```\n\nAdded in v2.11.0\n\n# utils\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 v2.11.0\n\n## and\n\n**Signature**\n\n```ts\nexport declare const and: <A, C extends A>(\n  second: Refinement<A, C>\n) => <B extends A>(first: Refinement<A, B>) => Refinement<A, B & C>\n```\n\nAdded in v2.11.0\n\n## compose\n\n**Signature**\n\n```ts\nexport declare const compose: <A, B extends A, C extends B>(\n  bc: Refinement<B, C>\n) => (ab: Refinement<A, B>) => Refinement<A, C>\n```\n\nAdded in v2.11.0\n\n## not\n\n**Signature**\n\n```ts\nexport declare const not: <A, B extends A>(refinement: Refinement<A, B>) => Refinement<A, Exclude<A, B>>\n```\n\nAdded in v2.11.0\n\n## or\n\n**Signature**\n\n```ts\nexport declare const or: <A, C extends A>(\n  second: Refinement<A, C>\n) => <B extends A>(first: Refinement<A, B>) => Refinement<A, C | B>\n```\n\nAdded in v2.11.0\n\n## zero\n\n**Signature**\n\n```ts\nexport declare const zero: <A, B extends A>() => Refinement<A, B>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/Ring.ts.md",
    "content": "---\ntitle: Ring.ts\nnav_order: 91\nparent: Modules\n---\n\n## Ring overview\n\nThe `Ring` class is for types that support addition, multiplication, and subtraction operations.\n\nInstances must satisfy the following law in addition to the `Semiring` laws:\n\n- Additive inverse: `a - a <-> (zero - a) + a <-> zero`\n\nAdapted from https://github.com/purescript/purescript-prelude/blob/master/src/Data/Ring.purs\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Ring (interface)](#ring-interface)\n- [utils](#utils)\n  - [negate](#negate)\n  - [tuple](#tuple)\n- [zone of death](#zone-of-death)\n  - [~~getFunctionRing~~](#getfunctionring)\n  - [~~getTupleRing~~](#gettuplering)\n\n---\n\n# model\n\n## Ring (interface)\n\n**Signature**\n\n```ts\nexport interface Ring<A> extends Semiring<A> {\n  readonly sub: (x: A, y: A) => A\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## negate\n\n`negate x` can be used as a shorthand for `zero - x`\n\n**Signature**\n\n```ts\nexport declare const negate: <A>(R: Ring<A>) => (a: A) => A\n```\n\nAdded in v2.0.0\n\n## tuple\n\nGiven a tuple of `Ring`s returns a `Ring` for the tuple\n\n**Signature**\n\n```ts\nexport declare const tuple: <A extends readonly unknown[]>(\n  ...rings: { [K in keyof A]: Ring<A[K]> }\n) => Ring<Readonly<A>>\n```\n\n**Example**\n\n```ts\nimport { tuple } from 'fp-ts/Ring'\nimport * as N from 'fp-ts/number'\n\nconst R = tuple(N.Field, N.Field, N.Field)\nassert.deepStrictEqual(R.add([1, 2, 3], [4, 5, 6]), [5, 7, 9])\nassert.deepStrictEqual(R.mul([1, 2, 3], [4, 5, 6]), [4, 10, 18])\nassert.deepStrictEqual(R.one, [1, 1, 1])\nassert.deepStrictEqual(R.sub([1, 2, 3], [4, 5, 6]), [-3, -3, -3])\nassert.deepStrictEqual(R.zero, [0, 0, 0])\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~getFunctionRing~~\n\nUse [`getRing`](./function.ts.html#getring) instead.\n\n**Signature**\n\n```ts\nexport declare const getFunctionRing: <A, B>(R: Ring<B>) => Ring<(a: A) => B>\n```\n\nAdded in v2.0.0\n\n## ~~getTupleRing~~\n\nUse [`tuple`](#tuple) instead.\n\n**Signature**\n\n```ts\nexport declare const getTupleRing: <T extends readonly Ring<any>[]>(\n  ...rings: T\n) => Ring<{ [K in keyof T]: T[K] extends Ring<infer A> ? A : never }>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Semigroup.ts.md",
    "content": "---\ntitle: Semigroup.ts\nnav_order: 92\nparent: Modules\n---\n\n## Semigroup overview\n\nIf a type `A` can form a `Semigroup` it has an **associative** binary operation.\n\n```ts\ninterface Semigroup<A> {\n  readonly concat: (x: A, y: A) => A\n}\n```\n\nAssociativity means the following equality must hold for any choice of `x`, `y`, and `z`.\n\n```ts\nconcat(x, concat(y, z)) = concat(concat(x, y), z)\n```\n\nA common example of a semigroup is the type `string` with the operation `+`.\n\n```ts\nimport { Semigroup } from 'fp-ts/Semigroup'\n\nconst semigroupString: Semigroup<string> = {\n  concat: (x, y) => x + y,\n}\n\nconst x = 'x'\nconst y = 'y'\nconst z = 'z'\n\nsemigroupString.concat(x, y) // 'xy'\n\nsemigroupString.concat(x, semigroupString.concat(y, z)) // 'xyz'\n\nsemigroupString.concat(semigroupString.concat(x, y), z) // 'xyz'\n```\n\n_Adapted from https://typelevel.org/cats_\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [constant](#constant)\n  - [max](#max)\n  - [min](#min)\n- [instances](#instances)\n  - [first](#first)\n  - [last](#last)\n- [model](#model)\n  - [Semigroup (interface)](#semigroup-interface)\n- [utils](#utils)\n  - [concatAll](#concatall)\n  - [intercalate](#intercalate)\n  - [reverse](#reverse)\n  - [struct](#struct)\n  - [tuple](#tuple)\n- [zone of death](#zone-of-death)\n  - [~~fold~~](#fold)\n  - [~~getDualSemigroup~~](#getdualsemigroup)\n  - [~~getFirstSemigroup~~](#getfirstsemigroup)\n  - [~~getFunctionSemigroup~~](#getfunctionsemigroup)\n  - [~~getIntercalateSemigroup~~](#getintercalatesemigroup)\n  - [~~getJoinSemigroup~~](#getjoinsemigroup)\n  - [~~getLastSemigroup~~](#getlastsemigroup)\n  - [~~getMeetSemigroup~~](#getmeetsemigroup)\n  - [~~getObjectSemigroup~~](#getobjectsemigroup)\n  - [~~getStructSemigroup~~](#getstructsemigroup)\n  - [~~getTupleSemigroup~~](#gettuplesemigroup)\n  - [~~semigroupAll~~](#semigroupall)\n  - [~~semigroupAny~~](#semigroupany)\n  - [~~semigroupProduct~~](#semigroupproduct)\n  - [~~semigroupString~~](#semigroupstring)\n  - [~~semigroupSum~~](#semigroupsum)\n  - [~~semigroupVoid~~](#semigroupvoid)\n\n---\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 v2.10.0\n\n## max\n\nGet a semigroup where `concat` will return the maximum, based on the provided order.\n\n**Signature**\n\n```ts\nexport declare const max: <A>(O: Or.Ord<A>) => Semigroup<A>\n```\n\n**Example**\n\n```ts\nimport * as N from 'fp-ts/number'\nimport * as S from 'fp-ts/Semigroup'\n\nconst S1 = S.max(N.Ord)\n\nassert.deepStrictEqual(S1.concat(1, 2), 2)\n```\n\nAdded in v2.10.0\n\n## min\n\nGet a semigroup where `concat` will return the minimum, based on the provided order.\n\n**Signature**\n\n```ts\nexport declare const min: <A>(O: Or.Ord<A>) => Semigroup<A>\n```\n\n**Example**\n\n```ts\nimport * as N from 'fp-ts/number'\nimport * as S from 'fp-ts/Semigroup'\n\nconst S1 = S.min(N.Ord)\n\nassert.deepStrictEqual(S1.concat(1, 2), 1)\n```\n\nAdded in v2.10.0\n\n# instances\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\n**Example**\n\n```ts\nimport * as S from 'fp-ts/Semigroup'\n\nassert.deepStrictEqual(S.first<number>().concat(1, 2), 1)\n```\n\nAdded in v2.10.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\n**Example**\n\n```ts\nimport * as S from 'fp-ts/Semigroup'\n\nassert.deepStrictEqual(S.last<number>().concat(1, 2), 2)\n```\n\nAdded in v2.10.0\n\n# model\n\n## Semigroup (interface)\n\n**Signature**\n\n```ts\nexport interface Semigroup<A> extends Magma<A> {}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## concatAll\n\nGiven a sequence of `as`, concat them and return the total.\n\nIf `as` is empty, return the provided `startWith` value.\n\n**Signature**\n\n```ts\nexport declare const concatAll: <A>(S: Semigroup<A>) => (startWith: A) => (as: readonly A[]) => A\n```\n\n**Example**\n\n```ts\nimport { concatAll } from 'fp-ts/Semigroup'\nimport * as N from 'fp-ts/number'\n\nconst sum = concatAll(N.SemigroupSum)(0)\n\nassert.deepStrictEqual(sum([1, 2, 3]), 6)\nassert.deepStrictEqual(sum([]), 0)\n```\n\nAdded in v2.10.0\n\n## intercalate\n\nBetween each pair of elements insert `middle`.\n\n**Signature**\n\n```ts\nexport declare const intercalate: <A>(middle: A) => (S: Semigroup<A>) => Semigroup<A>\n```\n\n**Example**\n\n```ts\nimport { intercalate } from 'fp-ts/Semigroup'\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nconst S1 = pipe(S.Semigroup, intercalate(' + '))\n\nassert.strictEqual(S1.concat('a', 'b'), 'a + b')\n```\n\nAdded in v2.10.0\n\n## reverse\n\nThe dual of a `Semigroup`, obtained by swapping the arguments of `concat`.\n\n**Signature**\n\n```ts\nexport declare const reverse: <A>(S: Semigroup<A>) => Semigroup<A>\n```\n\n**Example**\n\n```ts\nimport { reverse } from 'fp-ts/Semigroup'\nimport * as S from 'fp-ts/string'\n\nassert.deepStrictEqual(reverse(S.Semigroup).concat('a', 'b'), 'ba')\n```\n\nAdded in v2.10.0\n\n## struct\n\nGiven a struct of semigroups returns a semigroup for the struct.\n\n**Signature**\n\n```ts\nexport declare const struct: <A>(semigroups: { [K in keyof A]: Semigroup<A[K]> }) => Semigroup<{\n  readonly [K in keyof A]: A[K]\n}>\n```\n\n**Example**\n\n```ts\nimport { struct } from 'fp-ts/Semigroup'\nimport * as N from 'fp-ts/number'\n\ninterface Point {\n  readonly x: number\n  readonly y: number\n}\n\nconst S = struct<Point>({\n  x: N.SemigroupSum,\n  y: N.SemigroupSum,\n})\n\nassert.deepStrictEqual(S.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 })\n```\n\nAdded in v2.10.0\n\n## tuple\n\nGiven a tuple of semigroups returns a semigroup for the tuple.\n\n**Signature**\n\n```ts\nexport declare const tuple: <A extends readonly unknown[]>(\n  ...semigroups: { [K in keyof A]: Semigroup<A[K]> }\n) => Semigroup<Readonly<A>>\n```\n\n**Example**\n\n```ts\nimport { tuple } from 'fp-ts/Semigroup'\nimport * as B from 'fp-ts/boolean'\nimport * as N from 'fp-ts/number'\nimport * as S from 'fp-ts/string'\n\nconst S1 = tuple(S.Semigroup, N.SemigroupSum)\nassert.deepStrictEqual(S1.concat(['a', 1], ['b', 2]), ['ab', 3])\n\nconst S2 = tuple(S.Semigroup, N.SemigroupSum, B.SemigroupAll)\nassert.deepStrictEqual(S2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~fold~~\n\nUse [`concatAll`](#concatall) instead.\n\n**Signature**\n\n```ts\nexport declare function fold<A>(S: Semigroup<A>): {\n  (startWith: A): (as: ReadonlyArray<A>) => A\n  (startWith: A, as: ReadonlyArray<A>): A\n}\n```\n\nAdded in v2.0.0\n\n## ~~getDualSemigroup~~\n\nUse [`reverse`](#reverse) instead.\n\n**Signature**\n\n```ts\nexport declare const getDualSemigroup: <A>(S: Semigroup<A>) => Semigroup<A>\n```\n\nAdded in v2.0.0\n\n## ~~getFirstSemigroup~~\n\nUse [`first`](#first) instead.\n\n**Signature**\n\n```ts\nexport declare const getFirstSemigroup: <A = never>() => Semigroup<A>\n```\n\nAdded in v2.0.0\n\n## ~~getFunctionSemigroup~~\n\nUse [`getSemigroup`](./function.ts.html#getSemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getFunctionSemigroup: <S>(S: Semigroup<S>) => <A = never>() => Semigroup<(a: A) => S>\n```\n\nAdded in v2.0.0\n\n## ~~getIntercalateSemigroup~~\n\nUse [`intercalate`](#intercalate) instead.\n\n**Signature**\n\n```ts\nexport declare const getIntercalateSemigroup: <A>(middle: A) => (S: Semigroup<A>) => Semigroup<A>\n```\n\nAdded in v2.5.0\n\n## ~~getJoinSemigroup~~\n\nUse [`max`](#max) instead.\n\n**Signature**\n\n```ts\nexport declare const getJoinSemigroup: <A>(O: Or.Ord<A>) => Semigroup<A>\n```\n\nAdded in v2.0.0\n\n## ~~getLastSemigroup~~\n\nUse [`last`](#last) instead.\n\n**Signature**\n\n```ts\nexport declare const getLastSemigroup: <A = never>() => Semigroup<A>\n```\n\nAdded in v2.0.0\n\n## ~~getMeetSemigroup~~\n\nUse [`min`](#min) instead.\n\n**Signature**\n\n```ts\nexport declare const getMeetSemigroup: <A>(O: Or.Ord<A>) => Semigroup<A>\n```\n\nAdded in v2.0.0\n\n## ~~getObjectSemigroup~~\n\nUse [`getAssignSemigroup`](./struct.ts.html#getAssignSemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getObjectSemigroup: <A extends object = never>() => Semigroup<A>\n```\n\nAdded in v2.0.0\n\n## ~~getStructSemigroup~~\n\nUse [`struct`](#struct) instead.\n\n**Signature**\n\n```ts\nexport declare const getStructSemigroup: <O extends Readonly<Record<string, any>>>(semigroups: {\n  [K in keyof O]: Semigroup<O[K]>\n}) => Semigroup<O>\n```\n\nAdded in v2.0.0\n\n## ~~getTupleSemigroup~~\n\nUse [`tuple`](#tuple) instead.\n\n**Signature**\n\n```ts\nexport declare const getTupleSemigroup: <T extends readonly Semigroup<any>[]>(\n  ...semigroups: T\n) => Semigroup<{ [K in keyof T]: T[K] extends Semigroup<infer A> ? A : never }>\n```\n\nAdded in v2.0.0\n\n## ~~semigroupAll~~\n\nUse [`SemigroupAll`](./boolean.ts.html#SemigroupAll) instead.\n\n**Signature**\n\n```ts\nexport declare const semigroupAll: Semigroup<boolean>\n```\n\nAdded in v2.0.0\n\n## ~~semigroupAny~~\n\nUse [`SemigroupAny`](./boolean.ts.html#SemigroupAny) instead.\n\n**Signature**\n\n```ts\nexport declare const semigroupAny: Semigroup<boolean>\n```\n\nAdded in v2.0.0\n\n## ~~semigroupProduct~~\n\nUse [`SemigroupProduct`](./number.ts.html#SemigroupProduct) instead.\n\n**Signature**\n\n```ts\nexport declare const semigroupProduct: Semigroup<number>\n```\n\nAdded in v2.0.0\n\n## ~~semigroupString~~\n\nUse [`Semigroup`](./string.ts.html#Semigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const semigroupString: Semigroup<string>\n```\n\nAdded in v2.0.0\n\n## ~~semigroupSum~~\n\nUse [`SemigroupSum`](./number.ts.html#SemigroupSum) instead.\n\n**Signature**\n\n```ts\nexport declare const semigroupSum: Semigroup<number>\n```\n\nAdded in v2.0.0\n\n## ~~semigroupVoid~~\n\nUse `void` module instead.\n\n**Signature**\n\n```ts\nexport declare const semigroupVoid: Semigroup<void>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Semigroupoid.ts.md",
    "content": "---\ntitle: Semigroupoid.ts\nnav_order: 93\nparent: Modules\n---\n\n## Semigroupoid overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Semigroupoid (interface)](#semigroupoid-interface)\n  - [Semigroupoid2 (interface)](#semigroupoid2-interface)\n  - [Semigroupoid2C (interface)](#semigroupoid2c-interface)\n  - [Semigroupoid3 (interface)](#semigroupoid3-interface)\n  - [Semigroupoid3C (interface)](#semigroupoid3c-interface)\n  - [Semigroupoid4 (interface)](#semigroupoid4-interface)\n\n---\n\n# model\n\n## Semigroupoid (interface)\n\n**Signature**\n\n```ts\nexport interface Semigroupoid<F> {\n  readonly URI: F\n  readonly compose: <A, B, C>(bc: HKT2<F, B, C>, ab: HKT2<F, A, B>) => HKT2<F, A, C>\n}\n```\n\nAdded in v2.0.0\n\n## Semigroupoid2 (interface)\n\n**Signature**\n\n```ts\nexport interface Semigroupoid2<F extends URIS2> {\n  readonly URI: F\n  readonly compose: <A, B, C>(ab: Kind2<F, B, C>, la: Kind2<F, A, B>) => Kind2<F, A, C>\n}\n```\n\nAdded in v2.0.0\n\n## Semigroupoid2C (interface)\n\n**Signature**\n\n```ts\nexport interface Semigroupoid2C<F extends URIS2, A> {\n  readonly URI: F\n  readonly _E: A\n  readonly compose: <B, C>(ab: Kind2<F, B, C>, la: Kind2<F, A, B>) => Kind2<F, A, C>\n}\n```\n\nAdded in v2.0.0\n\n## Semigroupoid3 (interface)\n\n**Signature**\n\n```ts\nexport interface Semigroupoid3<F extends URIS3> {\n  readonly URI: F\n  readonly compose: <R, A, B, C>(ab: Kind3<F, R, B, C>, la: Kind3<F, R, A, B>) => Kind3<F, R, A, C>\n}\n```\n\nAdded in v2.0.0\n\n## Semigroupoid3C (interface)\n\n**Signature**\n\n```ts\nexport interface Semigroupoid3C<F extends URIS3, A> {\n  readonly URI: F\n  readonly _E: A\n  readonly compose: <R, B, C>(ab: Kind3<F, R, B, C>, la: Kind3<F, R, A, B>) => Kind3<F, R, A, C>\n}\n```\n\nAdded in v2.2.0\n\n## Semigroupoid4 (interface)\n\n**Signature**\n\n```ts\nexport interface Semigroupoid4<F extends URIS4> {\n  readonly URI: F\n  readonly compose: <S, R, A, B, C>(ab: Kind4<F, S, R, B, C>, la: Kind4<F, S, R, A, B>) => Kind4<F, S, R, A, C>\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Semiring.ts.md",
    "content": "---\ntitle: Semiring.ts\nnav_order: 94\nparent: Modules\n---\n\n## Semiring overview\n\nThe `Semiring` class is for types that support an addition and multiplication operation.\n\nInstances must satisfy the following laws:\n\n- Commutative monoid under addition:\n  - Associativity: `(a + b) + c <-> a + (b + c)`\n  - Identity: `zero + a = a + zero <-> a`\n  - Commutative: `a + b <-> b + a`\n- Monoid under multiplication:\n  - Associativity: `(a * b) * c <-> a * (b * c)`\n  - Identity: `one * a <-> a * one <-> a`\n- Multiplication distributes over addition:\n  - Left distributivity: `a * (b + c) <-> (a * b) + (a * c)`\n  - Right distributivity: `(a + b) * c <-> (a * c) + (b * c)`\n- Annihilation: `zero * a <-> a * zero <-> zero`\n\n**Note:** The `number` type is not fully law abiding members of this class hierarchy due to the potential\nfor arithmetic overflows, and the presence of `NaN` and `Infinity` values. The behaviour is\nunspecified in these cases.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Semiring (interface)](#semiring-interface)\n- [zone of death](#zone-of-death)\n  - [~~getFunctionSemiring~~](#getfunctionsemiring)\n\n---\n\n# model\n\n## Semiring (interface)\n\n**Signature**\n\n```ts\nexport interface Semiring<A> {\n  readonly add: (x: A, y: A) => A\n  readonly zero: A\n  readonly mul: (x: A, y: A) => A\n  readonly one: A\n}\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~getFunctionSemiring~~\n\nUse [`getSemiring`](./function.ts.html#getsemiring) instead.\n\n**Signature**\n\n```ts\nexport declare const getFunctionSemiring: <A, B>(S: Semiring<B>) => Semiring<(a: A) => B>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Separated.ts.md",
    "content": "---\ntitle: Separated.ts\nnav_order: 95\nparent: Modules\n---\n\n## Separated overview\n\n```ts\ninterface Separated<E, A> {\n  readonly left: E\n  readonly right: A\n}\n```\n\nRepresents a result of separating a whole into two parts.\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [separated](#separated)\n- [error handling](#error-handling)\n  - [mapLeft](#mapleft)\n- [instances](#instances)\n  - [Bifunctor](#bifunctor)\n  - [Functor](#functor)\n- [mapping](#mapping)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Separated (interface)](#separated-interface)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [left](#left)\n  - [right](#right)\n\n---\n\n# constructors\n\n## separated\n\n**Signature**\n\n```ts\nexport declare const separated: <E, A>(left: E, right: A) => Separated<E, A>\n```\n\nAdded in v2.10.0\n\n# error handling\n\n## mapLeft\n\nMap a function over the first type argument of a bifunctor.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Separated<E, A>) => Separated<G, A>\n```\n\nAdded in v2.10.0\n\n# instances\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor2<'Separated'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'Separated'>\n```\n\nAdded in v2.10.0\n\n# mapping\n\n## bimap\n\nMap a pair of functions over the two type arguments of the bifunctor.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Separated<E, A>) => Separated<G, B>\n```\n\nAdded in v2.10.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: Separated<E, (a: A) => B>) => Separated<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Separated<E, A>) => Separated<E, B>\n```\n\nAdded in v2.10.0\n\n# model\n\n## Separated (interface)\n\nA `Separated` type which holds `left` and `right` parts.\n\n**Signature**\n\n```ts\nexport interface Separated<E, A> {\n  readonly left: E\n  readonly right: A\n}\n```\n\nAdded in v2.10.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Separated'\n```\n\nAdded in v2.10.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.10.0\n\n# utils\n\n## left\n\n**Signature**\n\n```ts\nexport declare const left: <E, A>(s: Separated<E, A>) => E\n```\n\nAdded in v2.10.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare const right: <E, A>(s: Separated<E, A>) => A\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/Set.ts.md",
    "content": "---\ntitle: Set.ts\nnav_order: 96\nparent: Modules\n---\n\n## Set overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [singleton](#singleton)\n- [conversions](#conversions)\n  - [fromArray](#fromarray)\n  - [toArray](#toarray)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [getDifferenceMagma](#getdifferencemagma)\n  - [getEq](#geteq)\n  - [getIntersectionSemigroup](#getintersectionsemigroup)\n  - [getShow](#getshow)\n  - [getUnionMonoid](#getunionmonoid)\n  - [getUnionSemigroup](#getunionsemigroup)\n- [utils](#utils)\n  - [chain](#chain)\n  - [compact](#compact)\n  - [difference](#difference)\n  - [elem](#elem)\n  - [empty](#empty)\n  - [every](#every)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [insert](#insert)\n  - [intersection](#intersection)\n  - [isEmpty](#isempty)\n  - [isSubset](#issubset)\n  - [map](#map)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [remove](#remove)\n  - [separate](#separate)\n  - [size](#size)\n  - [some](#some)\n  - [toggle](#toggle)\n  - [union](#union)\n- [zone of death](#zone-of-death)\n  - [~~subset~~](#subset)\n\n---\n\n# constructors\n\n## singleton\n\nCreate a set with one element\n\n**Signature**\n\n```ts\nexport declare const singleton: <A>(a: A) => Set<A>\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromArray\n\nCreate a set from an array\n\n**Signature**\n\n```ts\nexport declare const fromArray: <A>(E: Eq<A>) => (as: A[]) => Set<A>\n```\n\nAdded in v2.0.0\n\n## toArray\n\nGet a sorted `Array` of the values contained in a `Set`.\n\n**Signature**\n\n```ts\nexport declare const toArray: <A>(O: Ord<A>) => (set: Set<A>) => A[]\n```\n\nAdded in v2.0.0\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <A, M>(O: Ord<A>, M: Monoid<M>) => (f: (a: A) => M) => (fa: Set<A>) => M\n```\n\nAdded in v2.0.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A>(O: Ord<A>) => <B>(b: B, f: (b: B, a: A) => B) => (fa: Set<A>) => B\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A>(O: Ord<A>) => <B>(b: B, f: (a: A, b: B) => B) => (fa: Set<A>) => B\n```\n\nAdded in v2.11.0\n\n# instances\n\n## getDifferenceMagma\n\n**Signature**\n\n```ts\nexport declare const getDifferenceMagma: <A>(E: Eq<A>) => Magma<Set<A>>\n```\n\nAdded in v2.11.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare const getEq: <A>(E: Eq<A>) => Eq<Set<A>>\n```\n\nAdded in v2.0.0\n\n## getIntersectionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getIntersectionSemigroup: <A>(E: Eq<A>) => Semigroup<Set<A>>\n```\n\nAdded in v2.0.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare const getShow: <A>(S: Show<A>) => Show<Set<A>>\n```\n\nAdded in v2.0.0\n\n## getUnionMonoid\n\n**Signature**\n\n```ts\nexport declare const getUnionMonoid: <A>(E: Eq<A>) => Monoid<Set<A>>\n```\n\nAdded in v2.0.0\n\n## getUnionSemigroup\n\n**Signature**\n\n```ts\nexport declare const getUnionSemigroup: <A>(E: Eq<A>) => Semigroup<Set<A>>\n```\n\nAdded in v2.11.0\n\n# utils\n\n## chain\n\nComposes computations in sequence, using the return value of one computation to determine the next computation.\n\n**Signature**\n\n```ts\nexport declare function chain<B>(E: Eq<B>): <A>(f: (x: A) => Set<B>) => (set: Set<A>) => Set<B>\n```\n\nAdded in v2.0.0\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(E: Eq<A>) => (fa: Set<Option<A>>) => Set<A>\n```\n\nAdded in v2.0.0\n\n## difference\n\nForm the set difference (`x` - `y`)\n\n**Signature**\n\n```ts\nexport declare function difference<A>(E: Eq<A>): {\n  (that: Set<A>): (me: Set<A>) => Set<A>\n  (me: Set<A>, that: Set<A>): Set<A>\n}\n```\n\n**Example**\n\n```ts\nimport { difference } from 'fp-ts/Set'\nimport * as N from 'fp-ts/number'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe(new Set([1, 2]), difference(N.Eq)(new Set([1, 3]))), new Set([2]))\n```\n\nAdded in v2.0.0\n\n## elem\n\nTest if a value is a member of a set\n\n**Signature**\n\n```ts\nexport declare const elem: <A>(E: Eq<A>) => { (a: A): (set: Set<A>) => boolean; (a: A, set: Set<A>): boolean }\n```\n\nAdded in v2.0.0\n\n## empty\n\n**Signature**\n\n```ts\nexport declare const empty: Set<never>\n```\n\nAdded in v2.0.0\n\n## every\n\n**Signature**\n\n```ts\nexport declare const every: {\n  <A, B extends A>(refinement: Refinement<A, B>): Refinement<Set<A>, Set<B>>\n  <A>(predicate: Predicate<A>): Predicate<Set<A>>\n}\n```\n\nAdded in v2.0.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare function filter<A, B extends A>(refinement: Refinement<A, B>): (set: Set<A>) => Set<B>\nexport declare function filter<A>(predicate: Predicate<A>): <B extends A>(set: Set<B>) => Set<B>\nexport declare function filter<A>(predicate: Predicate<A>): (set: Set<A>) => Set<A>\n```\n\nAdded in v2.0.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare function filterMap<B>(E: Eq<B>): <A>(f: (a: A) => Option<B>) => (fa: Set<A>) => Set<B>\n```\n\nAdded in v2.0.0\n\n## insert\n\nInsert a value into a set\n\n**Signature**\n\n```ts\nexport declare function insert<A>(E: Eq<A>): (a: A) => (set: Set<A>) => Set<A>\n```\n\nAdded in v2.0.0\n\n## intersection\n\nThe set of elements which are in both the first and second set\n\n**Signature**\n\n```ts\nexport declare function intersection<A>(E: Eq<A>): {\n  (that: Set<A>): (me: Set<A>) => Set<A>\n  (me: Set<A>, that: Set<A>): Set<A>\n}\n```\n\nAdded in v2.0.0\n\n## isEmpty\n\nTest whether a `Set` is empty.\n\n**Signature**\n\n```ts\nexport declare const isEmpty: <A>(set: Set<A>) => boolean\n```\n\nAdded in v2.10.0\n\n## isSubset\n\n**Signature**\n\n```ts\nexport declare const isSubset: <A>(E: Eq<A>) => (that: Set<A>) => (me: Set<A>) => boolean\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare function map<B>(E: Eq<B>): <A>(f: (x: A) => B) => (set: Set<A>) => Set<B>\n```\n\nAdded in v2.0.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare function partition<A, B extends A>(\n  refinement: Refinement<A, B>\n): (set: Set<A>) => Separated<Set<A>, Set<B>>\nexport declare function partition<A>(predicate: Predicate<A>): <B extends A>(set: Set<B>) => Separated<Set<B>, Set<B>>\nexport declare function partition<A>(predicate: Predicate<A>): (set: Set<A>) => Separated<Set<A>, Set<A>>\n```\n\nAdded in v2.0.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare function partitionMap<B, C>(\n  EB: Eq<B>,\n  EC: Eq<C>\n): <A>(f: (a: A) => Either<B, C>) => (set: Set<A>) => Separated<Set<B>, Set<C>>\n```\n\nAdded in v2.0.0\n\n## remove\n\nDelete a value from a set\n\n**Signature**\n\n```ts\nexport declare const remove: <A>(E: Eq<A>) => (a: A) => (set: Set<A>) => Set<A>\n```\n\nAdded in v2.0.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare function separate<E, A>(EE: Eq<E>, EA: Eq<A>): (fa: Set<Either<E, A>>) => Separated<Set<E>, Set<A>>\n```\n\nAdded in v2.0.0\n\n## size\n\nCalculate the number of elements in a `Set`.\n\n**Signature**\n\n```ts\nexport declare const size: <A>(set: Set<A>) => number\n```\n\nAdded in v2.10.0\n\n## some\n\n**Signature**\n\n```ts\nexport declare const some: <A>(predicate: Predicate<A>) => (set: Set<A>) => boolean\n```\n\nAdded in v2.0.0\n\n## toggle\n\nChecks an element is a member of a set;\nIf yes, removes the value from the set\nIf no, inserts the value to the set\n\n**Signature**\n\n```ts\nexport declare const toggle: <A>(E: Eq<A>) => (a: A) => (set: Set<A>) => Set<A>\n```\n\nAdded in v2.5.0\n\n## union\n\nForm the union of two sets\n\n**Signature**\n\n```ts\nexport declare function union<A>(E: Eq<A>): {\n  (that: Set<A>): (me: Set<A>) => Set<A>\n  (me: Set<A>, that: Set<A>): Set<A>\n}\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~subset~~\n\nUse [`isSubset`](#issubset) instead.\n\n**Signature**\n\n```ts\nexport declare const subset: <A>(E: Eq<A>) => {\n  (that: Set<A>): (me: Set<A>) => boolean\n  (me: Set<A>, that: Set<A>): boolean\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Show.ts.md",
    "content": "---\ntitle: Show.ts\nnav_order: 97\nparent: Modules\n---\n\n## Show overview\n\nThe `Show` type class represents those types which can be converted into\na human-readable `string` representation.\n\nWhile not required, it is recommended that for any expression `x`, the\nstring `show(x)` be executable TypeScript code which evaluates to the same\nvalue as the expression `x`.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Show (interface)](#show-interface)\n- [utils](#utils)\n  - [struct](#struct)\n  - [tuple](#tuple)\n- [zone of death](#zone-of-death)\n  - [~~getStructShow~~](#getstructshow)\n  - [~~getTupleShow~~](#gettupleshow)\n  - [~~showBoolean~~](#showboolean)\n  - [~~showNumber~~](#shownumber)\n  - [~~showString~~](#showstring)\n\n---\n\n# model\n\n## Show (interface)\n\n**Signature**\n\n```ts\nexport interface Show<A> {\n  readonly show: (a: A) => string\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## struct\n\n**Signature**\n\n```ts\nexport declare const struct: <A>(shows: { [K in keyof A]: Show<A[K]> }) => Show<{ readonly [K in keyof A]: A[K] }>\n```\n\nAdded in v2.10.0\n\n## tuple\n\n**Signature**\n\n```ts\nexport declare const tuple: <A extends readonly unknown[]>(\n  ...shows: { [K in keyof A]: Show<A[K]> }\n) => Show<Readonly<A>>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~getStructShow~~\n\nUse [`struct`](#struct) instead.\n\n**Signature**\n\n```ts\nexport declare const getStructShow: <O extends Readonly<Record<string, any>>>(shows: {\n  [K in keyof O]: Show<O[K]>\n}) => Show<O>\n```\n\nAdded in v2.0.0\n\n## ~~getTupleShow~~\n\nUse [`tuple`](#tuple) instead.\n\n**Signature**\n\n```ts\nexport declare const getTupleShow: <T extends readonly Show<any>[]>(\n  ...shows: T\n) => Show<{ [K in keyof T]: T[K] extends Show<infer A> ? A : never }>\n```\n\nAdded in v2.0.0\n\n## ~~showBoolean~~\n\nUse [`Show`](./boolean.ts.html#show) instead.\n\n**Signature**\n\n```ts\nexport declare const showBoolean: Show<boolean>\n```\n\nAdded in v2.0.0\n\n## ~~showNumber~~\n\nUse [`Show`](./number.ts.html#show) instead.\n\n**Signature**\n\n```ts\nexport declare const showNumber: Show<number>\n```\n\nAdded in v2.0.0\n\n## ~~showString~~\n\nUse [`Show`](./string.ts.html#show) instead.\n\n**Signature**\n\n```ts\nexport declare const showString: Show<string>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/State.ts.md",
    "content": "---\ntitle: State.ts\nnav_order: 98\nparent: Modules\n---\n\n## State overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n- [constructors](#constructors)\n  - [get](#get)\n  - [gets](#gets)\n  - [modify](#modify)\n  - [of](#of)\n  - [put](#put)\n- [instances](#instances)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [FromState](#fromstate)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [Pointed](#pointed)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [State (interface)](#state-interface)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apS](#aps)\n  - [apSecond](#apsecond)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [evaluate](#evaluate)\n  - [execute](#execute)\n  - [let](#let)\n- [zone of death](#zone-of-death)\n  - [~~evalState~~](#evalstate)\n  - [~~execState~~](#execstate)\n  - [~~state~~](#state)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <S, A, _>(self: State<S, A>, f: (a: A) => State<S, _>): State<S, A>\n  <A, S, _>(f: (a: A) => State<S, _>): (self: State<S, A>) => State<S, A>\n}\n```\n\nAdded in v2.15.0\n\n# constructors\n\n## get\n\nGet the current state\n\n**Signature**\n\n```ts\nexport declare const get: <S>() => State<S, S>\n```\n\nAdded in v2.0.0\n\n## gets\n\nGet a value which depends on the current state\n\n**Signature**\n\n```ts\nexport declare const gets: <S, A>(f: (s: S) => A) => State<S, A>\n```\n\nAdded in v2.0.0\n\n## modify\n\nModify the state by applying a function to the current state\n\n**Signature**\n\n```ts\nexport declare const modify: <S>(f: (s: S) => S) => State<S, void>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <S, A>(a: A) => State<S, A>\n```\n\nAdded in v2.0.0\n\n## put\n\nSet the state\n\n**Signature**\n\n```ts\nexport declare const put: <S>(s: S) => State<S, void>\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative2<'State'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply2<'State'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain2<'State'>\n```\n\nAdded in v2.10.0\n\n## FromState\n\n**Signature**\n\n```ts\nexport declare const FromState: FromState2<'State'>\n```\n\nAdded in v2.11.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'State'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad2<'State'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed2<'State'>\n```\n\nAdded in v2.10.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <S, A, B>(f: (a: A) => State<S, B>) => (ma: State<S, A>) => State<S, B>\n```\n\nAdded in v2.0.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <S, A, B>(f: (a: A) => State<S, B>) => (ma: State<S, A>) => State<S, A>\n```\n\nAdded in v2.0.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: State<E, (a: A) => B>) => State<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: State<E, A>) => State<E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## State (interface)\n\n**Signature**\n\n```ts\nexport interface State<S, A> {\n  (s: S): [A, S]\n}\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, S, B>(f: (a: A) => State<S, B>): (ma: State<S, A>) => State<S, B>\n  <S, A, B>(ma: State<S, A>, f: (a: A) => State<S, B>): State<S, B>\n}\n```\n\nAdded in v2.14.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <E, A>(mma: State<E, State<E, A>>) => State<E, A>\n```\n\nAdded in v2.0.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <S, A>(arr: readonly State<S, A>[]) => State<S, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <A, S, B>(f: (a: A) => State<S, B>) => (as: readonly A[]) => State<S, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <A, S, B>(\n  f: (index: number, a: A) => State<S, B>\n) => (as: readonly A[]) => State<S, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, S, B>(\n  f: (index: number, a: A) => State<S, B>\n) => (as: readonly A[]) => State<S, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, S, B>(\n  f: (index: number, a: A) => State<S, B>\n) => (as: ReadonlyNonEmptyArray<A>) => State<S, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'State'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <E, A>(fa: State<E, A>) => <B>(fab: State<E, (a: A) => B>) => State<E, B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <E, B>(second: State<E, B>) => <A>(first: State<E, A>) => State<E, A>\n```\n\nAdded in v2.0.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: State<E, B>\n) => (fa: State<E, A>) => State<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <E, B>(second: State<E, B>) => <A>(first: State<E, A>) => State<E, B>\n```\n\nAdded in v2.0.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => State<E, B>\n) => (ma: State<E, A>) => State<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <E, A>(fa: State<E, A>) => State<E, { readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## evaluate\n\nRun a computation in the `State` monad, discarding the final state\n\n**Signature**\n\n```ts\nexport declare const evaluate: <S>(s: S) => <A>(ma: State<S, A>) => A\n```\n\nAdded in v2.8.0\n\n## execute\n\nRun a computation in the `State` monad discarding the result\n\n**Signature**\n\n```ts\nexport declare const execute: <S>(s: S) => <A>(ma: State<S, A>) => S\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <E>(fa: State<E, A>) => State<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# zone of death\n\n## ~~evalState~~\n\nUse [`evaluate`](#evaluate) instead\n\n**Signature**\n\n```ts\nexport declare const evalState: <S, A>(ma: State<S, A>, s: S) => A\n```\n\nAdded in v2.0.0\n\n## ~~execState~~\n\nUse [`execute`](#execute) instead\n\n**Signature**\n\n```ts\nexport declare const execState: <S, A>(ma: State<S, A>, s: S) => S\n```\n\nAdded in v2.0.0\n\n## ~~state~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `S.Functor` instead of `S.state`\n(where `S` is from `import S from 'fp-ts/State'`)\n\n**Signature**\n\n```ts\nexport declare const state: Monad2<'State'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/StateReaderTaskEither.ts.md",
    "content": "---\ntitle: StateReaderTaskEither.ts\nnav_order: 99\nparent: Modules\n---\n\n## StateReaderTaskEither overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapEither](#tapeither)\n  - [tapIO](#tapio)\n  - [tapReader](#tapreader)\n  - [tapTask](#taptask)\n- [constructors](#constructors)\n  - [ask](#ask)\n  - [asks](#asks)\n  - [asksStateReaderTaskEither](#asksstatereadertaskeither)\n  - [asksStateReaderTaskEitherW](#asksstatereadertaskeitherw)\n  - [fromReaderTaskEither](#fromreadertaskeither)\n  - [get](#get)\n  - [gets](#gets)\n  - [left](#left)\n  - [leftIO](#leftio)\n  - [leftReader](#leftreader)\n  - [leftState](#leftstate)\n  - [leftTask](#lefttask)\n  - [modify](#modify)\n  - [of](#of)\n  - [put](#put)\n  - [right](#right)\n  - [rightIO](#rightio)\n  - [rightReader](#rightreader)\n  - [rightState](#rightstate)\n  - [rightTask](#righttask)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromIO](#fromio)\n  - [fromIOEither](#fromioeither)\n  - [fromOption](#fromoption)\n  - [fromReader](#fromreader)\n  - [fromReaderEither](#fromreadereither)\n  - [fromState](#fromstate)\n  - [fromTask](#fromtask)\n  - [fromTaskEither](#fromtaskeither)\n- [do notation](#do-notation)\n  - [apSW](#apsw)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n  - [mapLeft](#mapleft)\n- [filtering](#filtering)\n  - [filterOrElse](#filterorelse)\n  - [filterOrElseW](#filterorelsew)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Bifunctor](#bifunctor)\n  - [Chain](#chain)\n  - [FromEither](#fromeither)\n  - [FromIO](#fromio)\n  - [FromReader](#fromreader)\n  - [FromState](#fromstate)\n  - [FromTask](#fromtask)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [MonadTask](#monadtask)\n  - [MonadThrow](#monadthrow)\n  - [Pointed](#pointed)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainEitherK](#chaineitherk)\n  - [chainEitherKW](#chaineitherkw)\n  - [chainFirst](#chainfirst)\n  - [chainFirstEitherK](#chainfirsteitherk)\n  - [chainFirstEitherKW](#chainfirsteitherkw)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainFirstReaderK](#chainfirstreaderk)\n  - [chainFirstReaderKW](#chainfirstreaderkw)\n  - [chainFirstTaskK](#chainfirsttaskk)\n  - [chainFirstW](#chainfirstw)\n  - [chainIOEitherK](#chainioeitherk)\n  - [chainIOEitherKW](#chainioeitherkw)\n  - [chainIOK](#chainiok)\n  - [chainOptionK](#chainoptionk)\n  - [chainOptionKW](#chainoptionkw)\n  - [chainReaderK](#chainreaderk)\n  - [chainReaderKW](#chainreaderkw)\n  - [chainReaderTaskEitherK](#chainreadertaskeitherk)\n  - [chainReaderTaskEitherKW](#chainreadertaskeitherkw)\n  - [chainStateK](#chainstatek)\n  - [chainTaskEitherK](#chaintaskeitherk)\n  - [chainTaskEitherKW](#chaintaskeitherkw)\n  - [chainTaskK](#chaintaskk)\n  - [chainW](#chainw)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromIOEitherK](#fromioeitherk)\n  - [fromIOK](#fromiok)\n  - [fromOptionK](#fromoptionk)\n  - [fromPredicate](#frompredicate)\n  - [fromReaderK](#fromreaderk)\n  - [fromReaderTaskEitherK](#fromreadertaskeitherk)\n  - [fromStateK](#fromstatek)\n  - [fromTaskEitherK](#fromtaskeitherk)\n  - [fromTaskK](#fromtaskk)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [StateReaderTaskEither (interface)](#statereadertaskeither-interface)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapEither](#flatmapeither)\n  - [flatMapIO](#flatmapio)\n  - [flatMapIOEither](#flatmapioeither)\n  - [flatMapOption](#flatmapoption)\n  - [flatMapReader](#flatmapreader)\n  - [flatMapReaderTaskEither](#flatmapreadertaskeither)\n  - [flatMapState](#flatmapstate)\n  - [flatMapTask](#flatmaptask)\n  - [flatMapTaskEither](#flatmaptaskeither)\n  - [flatten](#flatten)\n  - [flattenW](#flattenw)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apFirstW](#apfirstw)\n  - [apS](#aps)\n  - [apSecond](#apsecond)\n  - [apSecondW](#apsecondw)\n  - [apW](#apw)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [bindW](#bindw)\n  - [evaluate](#evaluate)\n  - [execute](#execute)\n  - [let](#let)\n  - [local](#local)\n  - [throwError](#throwerror)\n- [zone of death](#zone-of-death)\n  - [~~evalState~~](#evalstate)\n  - [~~execState~~](#execstate)\n  - [~~run~~](#run)\n  - [~~stateReaderTaskEitherSeq~~](#statereadertaskeitherseq)\n  - [~~stateReaderTaskEither~~](#statereadertaskeither)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <S, R1, E1, A, R2, E2, _>(\n    self: StateReaderTaskEither<S, R1, E1, A>,\n    f: (a: A) => StateReaderTaskEither<S, R2, E2, _>\n  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, A>\n  <A, S, R2, E2, _>(f: (a: A) => StateReaderTaskEither<S, R2, E2, _>): <R1, E1>(\n    self: StateReaderTaskEither<S, R1, E1, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E2 | E1, A>\n}\n```\n\nAdded in v2.15.0\n\n## tapEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapEither: {\n  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <S, R1, E1>(\n    self: StateReaderTaskEither<S, R1, E1, A>\n  ) => StateReaderTaskEither<S, R1, E2 | E1, A>\n  <S, R1, E1, A, E2, _>(self: StateReaderTaskEither<S, R1, E1, A>, f: (a: A) => E.Either<E2, _>): StateReaderTaskEither<\n    S,\n    R1,\n    E1 | E2,\n    A\n  >\n}\n```\n\nAdded in v2.16.0\n\n## tapIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n  <S, R, E, A, _>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => IO<_>): StateReaderTaskEither<S, R, E, A>\n}\n```\n\nAdded in v2.16.0\n\n## tapReader\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapReader: {\n  <A, R2, _>(f: (a: A) => R.Reader<R2, _>): <S, R1, E>(\n    self: StateReaderTaskEither<S, R1, E, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E, A>\n  <S, R1, E, A, R2, _>(self: StateReaderTaskEither<S, R1, E, A>, f: (a: A) => R.Reader<R2, _>): StateReaderTaskEither<\n    S,\n    R1 & R2,\n    E,\n    A\n  >\n}\n```\n\nAdded in v2.16.0\n\n## tapTask\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapTask: {\n  <A, _>(f: (a: A) => Task<_>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n  <S, R, E, A, _>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => Task<_>): StateReaderTaskEither<S, R, E, A>\n}\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## ask\n\nReads the current context.\n\n**Signature**\n\n```ts\nexport declare const ask: <S, R, E = never>() => StateReaderTaskEither<S, R, E, R>\n```\n\nAdded in v2.11.0\n\n## asks\n\nProjects a value from the global context in a `ReaderEither`.\n\n**Signature**\n\n```ts\nexport declare const asks: <S, R, A, E = never>(f: (r: R) => A) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.11.0\n\n## asksStateReaderTaskEither\n\nEffectfully accesses the environment.\n\n**Signature**\n\n```ts\nexport declare const asksStateReaderTaskEither: <R, S, E, A>(\n  f: (r: R) => StateReaderTaskEither<S, R, E, A>\n) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.11.0\n\n## asksStateReaderTaskEitherW\n\nLess strict version of [`asksStateReaderTaskEither`](#asksstatereadertaskeither).\n\n**Signature**\n\n```ts\nexport declare const asksStateReaderTaskEitherW: <R1, S, R2, E, A>(\n  f: (r1: R1) => StateReaderTaskEither<S, R2, E, A>\n) => StateReaderTaskEither<S, R1 & R2, E, A>\n```\n\nAdded in v2.11.0\n\n## fromReaderTaskEither\n\n**Signature**\n\n```ts\nexport declare const fromReaderTaskEither: <R, E, A, S>(\n  fa: RTE.ReaderTaskEither<R, E, A>\n) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## get\n\nGet the current state\n\n**Signature**\n\n```ts\nexport declare const get: <S, R, E = never>() => StateReaderTaskEither<S, R, E, S>\n```\n\nAdded in v2.0.0\n\n## gets\n\nGet a value which depends on the current state\n\n**Signature**\n\n```ts\nexport declare const gets: <S, R, E = never, A = never>(f: (s: S) => A) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## left\n\n**Signature**\n\n```ts\nexport declare const left: <S, R, E, A = never>(e: E) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## leftIO\n\n**Signature**\n\n```ts\nexport declare function leftIO<S, R, E, A = never>(me: IO<E>): StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## leftReader\n\n**Signature**\n\n```ts\nexport declare function leftReader<S, R, E, A = never>(me: Reader<R, E>): StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## leftState\n\n**Signature**\n\n```ts\nexport declare const leftState: <S, R, E, A = never>(me: State<S, E>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## leftTask\n\n**Signature**\n\n```ts\nexport declare function leftTask<S, R, E, A = never>(me: Task<E>): StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## modify\n\nModify the state by applying a function to the current state\n\n**Signature**\n\n```ts\nexport declare const modify: <S, R, E = never>(f: Endomorphism<S>) => StateReaderTaskEither<S, R, E, void>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <S, R = unknown, E = never, A = never>(a: A) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.7.0\n\n## put\n\nSet the state\n\n**Signature**\n\n```ts\nexport declare const put: <S, R, E = never>(s: S) => StateReaderTaskEither<S, R, E, void>\n```\n\nAdded in v2.0.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare const right: <S, R, E = never, A = never>(a: A) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## rightIO\n\n**Signature**\n\n```ts\nexport declare function rightIO<S, R, E = never, A = never>(ma: IO<A>): StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## rightReader\n\n**Signature**\n\n```ts\nexport declare function rightReader<S, R, E = never, A = never>(ma: Reader<R, A>): StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## rightState\n\n**Signature**\n\n```ts\nexport declare const rightState: <S, R, E = never, A = never>(ma: State<S, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## rightTask\n\n**Signature**\n\n```ts\nexport declare function rightTask<S, R, E = never, A = never>(ma: Task<A>): StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <E, A, S, R = unknown>(fa: E.Either<E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A, S, R = unknown, E = never>(fa: IO<A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.7.0\n\n## fromIOEither\n\n**Signature**\n\n```ts\nexport declare const fromIOEither: <E, A, S, R = unknown>(fa: IOEither<E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <E>(\n  onNone: LazyArg<E>\n) => <A, S, R = unknown>(fa: Option<A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromReader\n\n**Signature**\n\n```ts\nexport declare const fromReader: <R, A, S, E = never>(fa: R.Reader<R, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.11.0\n\n## fromReaderEither\n\n**Signature**\n\n```ts\nexport declare const fromReaderEither: <R, E, A, S>(fa: ReaderEither<R, E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## fromState\n\n**Signature**\n\n```ts\nexport declare const fromState: <S, A, R = unknown, E = never>(fa: State<S, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.10.0\n\n## fromTask\n\n**Signature**\n\n```ts\nexport declare const fromTask: <A, S, R = unknown, E = never>(fa: Task<A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.7.0\n\n## fromTaskEither\n\n**Signature**\n\n```ts\nexport declare const fromTaskEither: <E, A, S, R = unknown>(fa: TaskEither<E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n# do notation\n\n## apSW\n\nLess strict version of [`apS`](#aps).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSW: <A, N extends string, S, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(\n  fa: StateReaderTaskEither<S, R1, E1, A>\n) => StateReaderTaskEither<S, R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\n**Signature**\n\n```ts\nexport declare const alt: <S, R, E, A>(\n  that: LazyArg<StateReaderTaskEither<S, R, E, A>>\n) => (fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.6.2\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <S, R2, E2, B>(\n  that: () => StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1, A>(fa: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2, B | A>\n```\n\nAdded in v2.9.0\n\n## mapLeft\n\nMap a function over the third type argument of a bifunctor.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(\n  f: (e: E) => G\n) => <S, R, A>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, G, A>\n```\n\nAdded in v2.6.2\n\n# filtering\n\n## filterOrElse\n\n**Signature**\n\n```ts\nexport declare const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(\n    ma: StateReaderTaskEither<S, R, E, A>\n  ) => StateReaderTaskEither<S, R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(\n    mb: StateReaderTaskEither<S, R, E, B>\n  ) => StateReaderTaskEither<S, R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(\n    ma: StateReaderTaskEither<S, R, E, A>\n  ) => StateReaderTaskEither<S, R, E, A>\n}\n```\n\nAdded in v2.4.4\n\n## filterOrElseW\n\nLess strict version of [`filterOrElse`](#filterorelse).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <S, R, E1>(\n    ma: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <S, R, E1, B extends A>(\n    mb: StateReaderTaskEither<S, R, E1, B>\n  ) => StateReaderTaskEither<S, R, E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <S, R, E1>(\n    ma: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E2 | E1, A>\n}\n```\n\nAdded in v2.9.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt4<'StateReaderTaskEither'>\n```\n\nAdded in v2.7.0\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative4<'StateReaderTaskEither'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor4<'StateReaderTaskEither'>\n```\n\nAdded in v2.7.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## FromReader\n\n**Signature**\n\n```ts\nexport declare const FromReader: FromReader4<'StateReaderTaskEither'>\n```\n\nAdded in v2.11.0\n\n## FromState\n\n**Signature**\n\n```ts\nexport declare const FromState: FromState4<'StateReaderTaskEither'>\n```\n\nAdded in v2.11.0\n\n## FromTask\n\n**Signature**\n\n```ts\nexport declare const FromTask: FromTask4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor4<'StateReaderTaskEither'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## MonadTask\n\n**Signature**\n\n```ts\nexport declare const MonadTask: MonadTask4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## MonadThrow\n\n**Signature**\n\n```ts\nexport declare const MonadThrow: MonadThrow4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed4<'StateReaderTaskEither'>\n```\n\nAdded in v2.10.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <S, R, E, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R, E, B>\n) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.0.0\n\n## chainEitherK\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherK: <E, A, B>(\n  f: (a: A) => E.Either<E, B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.4.0\n\n## chainEitherKW\n\nAlias of `flatMapEither`.\n\nLess strict version of [`chainEitherK`](#chaineitherk).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainEitherKW: <E2, A, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <S, R, E, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R, E, B>\n) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## chainFirstEitherK\n\nAlias of `tapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherK: <A, E, B>(\n  f: (a: A) => E.Either<E, B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstEitherKW\n\nAlias of `tapEither`.\n\nLess strict version of [`chainFirstEitherK`](#chainfirsteitherk).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstIOK\n\nAlias of `tapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstIOK: <A, B>(\n  f: (a: A) => IO<B>\n) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.10.0\n\n## chainFirstReaderK\n\nAlias of `tapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderK: <A, R, B>(\n  f: (a: A) => R.Reader<R, B>\n) => <S, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstReaderKW\n\nAlias of `tapReader`.\n\nLess strict version of [`chainFirstReaderK`](#chainFirstReaderK).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <S, R2, E>(ma: StateReaderTaskEither<S, R2, E, A>) => StateReaderTaskEither<S, R1 & R2, E, A>\n```\n\nAdded in v2.11.0\n\n## chainFirstTaskK\n\nAlias of `tapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstTaskK: <A, B>(\n  f: (a: A) => Task<B>\n) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.10.0\n\n## chainFirstW\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstW: <S, R2, E2, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(ma: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, A>\n```\n\nAdded in v2.8.0\n\n## chainIOEitherK\n\nAlias of `flatMapIOEither`.\n\n**Signature**\n\n```ts\nexport declare const chainIOEitherK: <E, A, B>(\n  f: (a: A) => IOEither<E, B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.4.0\n\n## chainIOEitherKW\n\nAlias of `flatMapIOEither`.\n\nLess strict version of [`chainIOEitherK`](#chainioeitherk).\n\n**Signature**\n\n```ts\nexport declare const chainIOEitherKW: <E2, A, B>(\n  f: (a: A) => IOEither<E2, B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainIOK\n\nAlias of `flatMapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainIOK: <A, B>(\n  f: (a: A) => IO<B>\n) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.10.0\n\n## chainOptionK\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(\n  f: (a: A) => Option<B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.10.0\n\n## chainOptionKW\n\nUse `flatMapOption`.\n\nLess strict version of [`chainOptionK`](#chainoptionk).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(\n  f: (a: A) => Option<B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>\n```\n\nAdded in v2.13.2\n\n## chainReaderK\n\nAlias of `flatMapReader`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderK: <A, R, B>(\n  f: (a: A) => R.Reader<R, B>\n) => <S, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.11.0\n\n## chainReaderKW\n\nAlias of `flatMapReader`.\n\nLess strict version of [`chainReaderK`](#chainReaderK).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <S, R2, E>(ma: StateReaderTaskEither<S, R2, E, A>) => StateReaderTaskEither<S, R1 & R2, E, B>\n```\n\nAdded in v2.11.0\n\n## chainReaderTaskEitherK\n\nAlias of `flatMapReaderTaskEither`.\n\n**Signature**\n\n```ts\nexport declare const chainReaderTaskEitherK: <R, E, A, B>(\n  f: (a: A) => RTE.ReaderTaskEither<R, E, B>\n) => <S>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.4.0\n\n## chainReaderTaskEitherKW\n\nAlias of `flatMapReaderTaskEither`.\n\nLess strict version of [`chainReaderTaskEitherK`](#chainreadertaskeitherk).\n\n**Signature**\n\n```ts\nexport declare const chainReaderTaskEitherKW: <R, E2, A, B>(\n  f: (a: A) => RTE.ReaderTaskEither<R, E2, B>\n) => <S, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainStateK\n\nAlias of `flatMapState`.\n\n**Signature**\n\n```ts\nexport declare const chainStateK: <A, S, B>(\n  f: (a: A) => State<S, B>\n) => <R, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.11.0\n\n## chainTaskEitherK\n\nAlias of `flatMapTaskEither`.\n\n**Signature**\n\n```ts\nexport declare const chainTaskEitherK: <E, A, B>(\n  f: (a: A) => TaskEither<E, B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.4.0\n\n## chainTaskEitherKW\n\nAlias of `flatMapTaskEither`.\n\nLess strict version of [`chainTaskEitherK`](#chaintaskeitherk).\n\n**Signature**\n\n```ts\nexport declare const chainTaskEitherKW: <E2, A, B>(\n  f: (a: A) => TaskEither<E2, B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainTaskK\n\nAlias of `flatMapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainTaskK: <A, B>(\n  f: (a: A) => Task<B>\n) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.10.0\n\n## chainW\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chainW: <S, R2, E2, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(ma: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.6.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => E.Either<E, B>\n) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.4.0\n\n## fromIOEitherK\n\n**Signature**\n\n```ts\nexport declare const fromIOEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => IOEither<E, B>\n) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.4.0\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(\n  f: (...a: A) => IO<B>\n) => <S, R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.10.0\n\n## fromOptionK\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends readonly unknown[], B>(\n  f: (...a: A) => Option<B>\n) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.10.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R = unknown>(\n    a: A\n  ) => StateReaderTaskEither<S, R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R = unknown, B extends A = A>(\n    b: B\n  ) => StateReaderTaskEither<S, R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R = unknown>(a: A) => StateReaderTaskEither<S, R, E, A>\n}\n```\n\nAdded in v2.4.4\n\n## fromReaderK\n\n**Signature**\n\n```ts\nexport declare const fromReaderK: <A extends readonly unknown[], R, B>(\n  f: (...a: A) => R.Reader<R, B>\n) => <S, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.11.0\n\n## fromReaderTaskEitherK\n\n**Signature**\n\n```ts\nexport declare const fromReaderTaskEitherK: <R, E, A extends readonly unknown[], B>(\n  f: (...a: A) => RTE.ReaderTaskEither<R, E, B>\n) => <S>(...a: A) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.4.0\n\n## fromStateK\n\n**Signature**\n\n```ts\nexport declare const fromStateK: <A extends readonly unknown[], S, B>(\n  f: (...a: A) => State<S, B>\n) => <R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.11.0\n\n## fromTaskEitherK\n\n**Signature**\n\n```ts\nexport declare const fromTaskEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => TaskEither<E, B>\n) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.4.0\n\n## fromTaskK\n\n**Signature**\n\n```ts\nexport declare const fromTaskK: <A extends readonly unknown[], B>(\n  f: (...a: A) => Task<B>\n) => <S, R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.10.0\n\n# mapping\n\n## as\n\nMaps the `Right` value of this `StateReaderTaskEither` to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <S, R, E, _>(self: StateReaderTaskEither<S, R, E, _>) => StateReaderTaskEither<S, R, E, A>\n  <S, R, E, _, A>(self: StateReaderTaskEither<S, R, E, _>, a: A): StateReaderTaskEither<S, R, E, A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the `Right` value of this `StateReaderTaskEither` to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <S, R, E, _>(\n  self: StateReaderTaskEither<S, R, E, _>\n) => StateReaderTaskEither<S, R, E, void>\n```\n\nAdded in v2.16.0\n\n## bimap\n\nMap a pair of functions over the two last type arguments of the bifunctor.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <S, R>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, G, B>\n```\n\nAdded in v2.6.2\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(\n  a: A\n) => <S, R, E, B>(fab: StateReaderTaskEither<S, R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(\n  f: (a: A) => B\n) => <S, R, E>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## StateReaderTaskEither (interface)\n\n**Signature**\n\n```ts\nexport interface StateReaderTaskEither<S, R, E, A> {\n  (s: S): ReaderTaskEither<R, E, [A, S]>\n}\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, S, R2, E2, B>(f: (a: A) => StateReaderTaskEither<S, R2, E2, B>): <R1, E1>(\n    ma: StateReaderTaskEither<S, R1, E1, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>\n  <S, R1, E1, A, R2, E2, B>(\n    ma: StateReaderTaskEither<S, R1, E1, A>,\n    f: (a: A) => StateReaderTaskEither<S, R2, E2, B>\n  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, B>\n}\n```\n\nAdded in v2.14.0\n\n## flatMapEither\n\n**Signature**\n\n```ts\nexport declare const flatMapEither: {\n  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <S, R, E1>(\n    self: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E2 | E1, B>\n  <S, R, E1, A, E2, B>(self: StateReaderTaskEither<S, R, E1, A>, f: (a: A) => E.Either<E2, B>): StateReaderTaskEither<\n    S,\n    R,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v2.16.0\n\n## flatMapIO\n\n**Signature**\n\n```ts\nexport declare const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n  <S, R, E, A, B>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => IO<B>): StateReaderTaskEither<S, R, E, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapIOEither\n\n**Signature**\n\n```ts\nexport declare const flatMapIOEither: {\n  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <S, R, E1>(\n    self: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E2 | E1, B>\n  <S, R, E1, A, E2, B>(self: StateReaderTaskEither<S, R, E1, A>, f: (a: A) => IOEither<E2, B>): StateReaderTaskEither<\n    S,\n    R,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v2.16.0\n\n## flatMapOption\n\n**Signature**\n\n```ts\nexport declare const flatMapOption: {\n  <A, E2, B>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <S, R, E1>(\n    self: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E2 | E1, B>\n  <S, R, E1, A, E2, B>(\n    self: StateReaderTaskEither<S, R, E1, A>,\n    f: (a: A) => Option<B>,\n    onNone: (a: A) => E2\n  ): StateReaderTaskEither<S, R, E1 | E2, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapReader\n\n**Signature**\n\n```ts\nexport declare const flatMapReader: {\n  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <S, R1, E>(\n    self: StateReaderTaskEither<S, R1, E, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E, B>\n  <S, R1, E, A, R2, B>(self: StateReaderTaskEither<S, R1, E, A>, f: (a: A) => R.Reader<R2, B>): StateReaderTaskEither<\n    S,\n    R1 & R2,\n    E,\n    B\n  >\n}\n```\n\nAdded in v2.16.0\n\n## flatMapReaderTaskEither\n\n**Signature**\n\n```ts\nexport declare const flatMapReaderTaskEither: {\n  <A, R2, E2, B>(f: (a: A) => RTE.ReaderTaskEither<R2, E2, B>): <S, R1, E1>(\n    self: StateReaderTaskEither<S, R1, E1, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>\n  <S, R1, E1, A, R2, E2, B>(\n    self: StateReaderTaskEither<S, R1, E1, A>,\n    f: (a: A) => RTE.ReaderTaskEither<R2, E2, B>\n  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapState\n\n**Signature**\n\n```ts\nexport declare const flatMapState: {\n  <S, A, B>(f: (a: A) => State<S, B>): <R, E>(\n    self: StateReaderTaskEither<S, R, E, A>\n  ) => StateReaderTaskEither<S, R, E, B>\n  <S, R, E, A, B>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => State<S, B>): StateReaderTaskEither<S, R, E, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapTask\n\n**Signature**\n\n```ts\nexport declare const flatMapTask: {\n  <A, B>(f: (a: A) => Task<B>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n  <S, R, E, A, B>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => Task<B>): StateReaderTaskEither<S, R, E, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapTaskEither\n\n**Signature**\n\n```ts\nexport declare const flatMapTaskEither: {\n  <A, E2, B>(f: (a: A) => TaskEither<E2, B>): <S, R, E1>(\n    self: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E2 | E1, B>\n  <S, R, E1, A, E2, B>(self: StateReaderTaskEither<S, R, E1, A>, f: (a: A) => TaskEither<E2, B>): StateReaderTaskEither<\n    S,\n    R,\n    E1 | E2,\n    B\n  >\n}\n```\n\nAdded in v2.16.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <S, R, E, A>(\n  mma: StateReaderTaskEither<S, R, E, StateReaderTaskEither<S, R, E, A>>\n) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## flattenW\n\nLess strict version of [`flatten`](#flatten).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const flattenW: <S, R1, E1, R2, E2, A>(\n  mma: StateReaderTaskEither<S, R1, E1, StateReaderTaskEither<S, R2, E2, A>>\n) => StateReaderTaskEither<S, R1 & R2, E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <S, R, E, A>(\n  arr: readonly StateReaderTaskEither<S, R, E, A>[]\n) => StateReaderTaskEither<S, R, E, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <S, R, E, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R, E, B>\n) => (as: readonly A[]) => StateReaderTaskEither<S, R, E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <S, R, E, A, B>(\n  f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>\n) => (as: readonly A[]) => StateReaderTaskEither<S, R, E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, S, R, E, B>(\n  f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>\n) => (as: readonly A[]) => StateReaderTaskEither<S, R, E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, S, R, E, B>(\n  f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => StateReaderTaskEither<S, R, E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'StateReaderTaskEither'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <S, R, E, A>(\n  fa: StateReaderTaskEither<S, R, E, A>\n) => <B>(fab: StateReaderTaskEither<S, R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <S, R, E, B>(\n  second: StateReaderTaskEither<S, R, E, B>\n) => <A>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.0.0\n\n## apFirstW\n\nLess strict version of [`apFirst`](#apfirst).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apFirstW: <S, R2, E2, A, B>(\n  second: StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(first: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, S, R, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: StateReaderTaskEither<S, R, E, B>\n) => (\n  fa: StateReaderTaskEither<S, R, E, A>\n) => StateReaderTaskEither<S, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <S, R, E, B>(\n  second: StateReaderTaskEither<S, R, E, B>\n) => <A>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n```\n\nAdded in v2.0.0\n\n## apSecondW\n\nLess strict version of [`apSecond`](#apsecond).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSecondW: <S, R2, E2, A, B>(\n  second: StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(first: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.12.0\n\n## apW\n\nLess strict version of [`ap`](#ap).\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apW: <S, R2, E2, A>(\n  fa: StateReaderTaskEither<S, R2, E2, A>\n) => <R1, E1, B>(fab: StateReaderTaskEither<S, R1, E1, (a: A) => B>) => StateReaderTaskEither<S, R1 & R2, E2 | E1, B>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, S, R, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => StateReaderTaskEither<S, R, E, B>\n) => (\n  ma: StateReaderTaskEither<S, R, E, A>\n) => StateReaderTaskEither<S, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(\n  name: N\n) => <S, R, E, A>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, { readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## bindW\n\nThe `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bindW: <N extends string, A, S, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(\n  fa: StateReaderTaskEither<S, R1, E1, A>\n) => StateReaderTaskEither<S, R1 & R2, E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## evaluate\n\nRun a computation in the `StateReaderTaskEither` monad, discarding the final state\n\n**Signature**\n\n```ts\nexport declare const evaluate: <S>(\n  s: S\n) => <R, E, A>(ma: StateReaderTaskEither<S, R, E, A>) => RTE.ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.8.0\n\n## execute\n\nRun a computation in the `StateReaderTaskEither` monad discarding the result\n\n**Signature**\n\n```ts\nexport declare const execute: <S>(\n  s: S\n) => <R, E, A>(ma: StateReaderTaskEither<S, R, E, A>) => RTE.ReaderTaskEither<R, E, S>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <S, R, E>(\n  fa: StateReaderTaskEither<S, R, E, A>\n) => StateReaderTaskEither<S, R, E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n## local\n\nChanges the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n`contramap`).\n\n**Signature**\n\n```ts\nexport declare const local: <R2, R1>(\n  f: (r2: R2) => R1\n) => <S, E, A>(ma: StateReaderTaskEither<S, R1, E, A>) => StateReaderTaskEither<S, R2, E, A>\n```\n\nAdded in v2.11.0\n\n## throwError\n\n**Signature**\n\n```ts\nexport declare const throwError: <S, R, E, A>(e: E) => StateReaderTaskEither<S, R, E, A>\n```\n\nAdded in v2.7.0\n\n# zone of death\n\n## ~~evalState~~\n\nUse [`evaluate`](#evaluate) instead\n\n**Signature**\n\n```ts\nexport declare const evalState: <S, R, E, A>(\n  ma: StateReaderTaskEither<S, R, E, A>,\n  s: S\n) => RTE.ReaderTaskEither<R, E, A>\n```\n\nAdded in v2.0.0\n\n## ~~execState~~\n\nUse [`execute`](#execute) instead\n\n**Signature**\n\n```ts\nexport declare const execState: <S, R, E, A>(\n  ma: StateReaderTaskEither<S, R, E, A>,\n  s: S\n) => RTE.ReaderTaskEither<R, E, S>\n```\n\nAdded in v2.0.0\n\n## ~~run~~\n\n**Signature**\n\n```ts\nexport declare function run<S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S, r: R): Promise<Either<E, [A, S]>>\n```\n\nAdded in v2.0.0\n\n## ~~stateReaderTaskEitherSeq~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `SRTE.Functor` instead of `SRTE.stateReaderTaskEitherSeq`\n(where `SRTE` is from `import SRTE from 'fp-ts/StateReaderTaskEither'`)\n\n**Signature**\n\n```ts\nexport declare const stateReaderTaskEitherSeq: Monad4<'StateReaderTaskEither'> &\n  Bifunctor4<'StateReaderTaskEither'> &\n  Alt4<'StateReaderTaskEither'> &\n  MonadTask4<'StateReaderTaskEither'> &\n  MonadThrow4<'StateReaderTaskEither'>\n```\n\nAdded in v2.0.0\n\n## ~~stateReaderTaskEither~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `SRTE.Functor` instead of `SRTE.stateReaderTaskEither`\n(where `SRTE` is from `import SRTE from 'fp-ts/StateReaderTaskEither'`)\n\n**Signature**\n\n```ts\nexport declare const stateReaderTaskEither: Monad4<'StateReaderTaskEither'> &\n  Bifunctor4<'StateReaderTaskEither'> &\n  Alt4<'StateReaderTaskEither'> &\n  MonadTask4<'StateReaderTaskEither'> &\n  MonadThrow4<'StateReaderTaskEither'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/StateT.ts.md",
    "content": "---\ntitle: StateT.ts\nnav_order: 100\nparent: Modules\n---\n\n## StateT overview\n\nThe state monad transformer. It can be used to add state to other monads.\n\nThe `of` function leaves the state unchanged, while `chain` uses the final state of the first computation\nas the initial state of the second.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [StateT (interface)](#statet-interface)\n  - [StateT1 (interface)](#statet1-interface)\n  - [StateT2 (interface)](#statet2-interface)\n  - [StateT3 (interface)](#statet3-interface)\n- [utils](#utils)\n  - [ap](#ap)\n  - [chain](#chain)\n  - [evaluate](#evaluate)\n  - [execute](#execute)\n  - [fromF](#fromf)\n  - [fromState](#fromstate)\n  - [map](#map)\n  - [of](#of)\n- [zone of death](#zone-of-death)\n  - [~~StateM1~~ (interface)](#statem1-interface)\n  - [~~StateM2C~~ (interface)](#statem2c-interface)\n  - [~~StateM2~~ (interface)](#statem2-interface)\n  - [~~StateM3C~~ (interface)](#statem3c-interface)\n  - [~~StateM3~~ (interface)](#statem3-interface)\n  - [~~StateM~~ (interface)](#statem-interface)\n  - [~~getStateM~~](#getstatem)\n\n---\n\n# model\n\n## StateT (interface)\n\n**Signature**\n\n```ts\nexport interface StateT<M, S, A> {\n  (s: S): HKT<M, [A, S]>\n}\n```\n\nAdded in v2.0.0\n\n## StateT1 (interface)\n\n**Signature**\n\n```ts\nexport interface StateT1<M extends URIS, S, A> {\n  (s: S): Kind<M, [A, S]>\n}\n```\n\nAdded in v2.0.0\n\n## StateT2 (interface)\n\n**Signature**\n\n```ts\nexport interface StateT2<M extends URIS2, S, E, A> {\n  (s: S): Kind2<M, E, [A, S]>\n}\n```\n\nAdded in v2.0.0\n\n## StateT3 (interface)\n\n**Signature**\n\n```ts\nexport interface StateT3<M extends URIS3, S, R, E, A> {\n  (s: S): Kind3<M, R, E, [A, S]>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ap\n\n**Signature**\n\n```ts\nexport declare function ap<M extends URIS3>(\n  M: Chain3<M>\n): <S, R, E, A>(fa: StateT3<M, S, R, E, A>) => <B>(fab: StateT3<M, S, R, E, (a: A) => B>) => StateT3<M, S, R, E, B>\nexport declare function ap<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <S, R, A>(fa: StateT3<M, S, R, E, A>) => <B>(fab: StateT3<M, S, R, E, (a: A) => B>) => StateT3<M, S, R, E, B>\nexport declare function ap<M extends URIS2>(\n  M: Chain2<M>\n): <S, E, A>(fa: StateT2<M, S, E, A>) => <B>(fab: StateT2<M, S, E, (a: A) => B>) => StateT2<M, S, E, B>\nexport declare function ap<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <S, A>(fa: StateT2<M, S, E, A>) => <B>(fab: StateT2<M, S, E, (a: A) => B>) => StateT2<M, S, E, B>\nexport declare function ap<M extends URIS>(\n  M: Chain1<M>\n): <S, A>(fa: StateT1<M, S, A>) => <B>(fab: StateT1<M, S, (a: A) => B>) => StateT1<M, S, B>\nexport declare function ap<M>(\n  M: Chain<M>\n): <S, A>(fa: StateT<M, S, A>) => <B>(fab: StateT<M, S, (a: A) => B>) => StateT<M, S, B>\n```\n\nAdded in v2.10.0\n\n## chain\n\n**Signature**\n\n```ts\nexport declare function chain<M extends URIS3>(\n  M: Chain3<M>\n): <A, S, R, E, B>(f: (a: A) => StateT3<M, S, R, E, B>) => (ma: StateT3<M, S, R, E, A>) => StateT3<M, S, R, E, B>\nexport declare function chain<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <A, S, R, B>(f: (a: A) => StateT3<M, S, R, E, B>) => (ma: StateT3<M, S, R, E, A>) => StateT3<M, S, R, E, B>\nexport declare function chain<M extends URIS2>(\n  M: Chain2<M>\n): <A, S, E, B>(f: (a: A) => StateT2<M, S, E, B>) => (ma: StateT2<M, S, E, A>) => StateT2<M, S, E, B>\nexport declare function chain<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <A, S, B>(f: (a: A) => StateT2<M, S, E, B>) => (ma: StateT2<M, S, E, A>) => StateT2<M, S, E, B>\nexport declare function chain<M extends URIS>(\n  M: Chain1<M>\n): <A, S, B>(f: (a: A) => StateT1<M, S, B>) => (ma: StateT1<M, S, A>) => StateT1<M, S, B>\nexport declare function chain<M>(\n  M: Chain<M>\n): <A, S, B>(f: (a: A) => StateT<M, S, B>) => (ma: StateT<M, S, A>) => StateT<M, S, B>\n```\n\nAdded in v2.10.0\n\n## evaluate\n\n**Signature**\n\n```ts\nexport declare function evaluate<F extends URIS3>(\n  F: Functor3<F>\n): <S>(s: S) => <R, E, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, A>\nexport declare function evaluate<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <S>(s: S) => <R, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, A>\nexport declare function evaluate<F extends URIS2>(\n  F: Functor2<F>\n): <S>(s: S) => <E, A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, A>\nexport declare function evaluate<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <S>(s: S) => <A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, A>\nexport declare function evaluate<F extends URIS>(F: Functor1<F>): <S>(s: S) => <A>(ma: StateT1<F, S, A>) => Kind<F, A>\nexport declare function evaluate<F>(F: Functor<F>): <S>(s: S) => <A>(ma: StateT<F, S, A>) => HKT<F, A>\n```\n\nAdded in v2.10.0\n\n## execute\n\n**Signature**\n\n```ts\nexport declare function execute<F extends URIS3>(\n  F: Functor3<F>\n): <S>(s: S) => <R, E, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, S>\nexport declare function execute<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <S>(s: S) => <R, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, S>\nexport declare function execute<F extends URIS2>(\n  F: Functor2<F>\n): <S>(s: S) => <E, A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, S>\nexport declare function execute<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <S>(s: S) => <A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, S>\nexport declare function execute<F extends URIS>(F: Functor1<F>): <S>(s: S) => <A>(ma: StateT1<F, S, A>) => Kind<F, S>\nexport declare function execute<F>(F: Functor<F>): <S>(s: S) => <A>(ma: StateT<F, S, A>) => HKT<F, S>\n```\n\nAdded in v2.10.0\n\n## fromF\n\n**Signature**\n\n```ts\nexport declare function fromF<F extends URIS3>(\n  F: Functor3<F>\n): <R, E, A, S>(ma: Kind3<F, R, E, A>) => StateT3<F, S, R, E, A>\nexport declare function fromF<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <R, A, S>(ma: Kind3<F, R, E, A>) => StateT3<F, S, R, E, A>\nexport declare function fromF<F extends URIS2>(F: Functor2<F>): <E, A, S>(ma: Kind2<F, E, A>) => StateT2<F, S, E, A>\nexport declare function fromF<F extends URIS2, E>(F: Functor2C<F, E>): <A, S>(ma: Kind2<F, E, A>) => StateT2<F, S, E, A>\nexport declare function fromF<F extends URIS>(F: Functor1<F>): <A, S>(ma: Kind<F, A>) => StateT1<F, S, A>\nexport declare function fromF<F>(F: Functor<F>): <A, S>(ma: HKT<F, A>) => StateT<F, S, A>\n```\n\nAdded in v2.10.0\n\n## fromState\n\n**Signature**\n\n```ts\nexport declare function fromState<F extends URIS3>(\n  F: Pointed3<F>\n): <S, A, R, E>(sa: State<S, A>) => StateT3<F, S, R, E, A>\nexport declare function fromState<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): <S, A, R>(sa: State<S, A>) => StateT3<F, S, R, E, A>\nexport declare function fromState<F extends URIS2>(F: Pointed2<F>): <S, A, E>(sa: State<S, A>) => StateT2<F, S, E, A>\nexport declare function fromState<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): <S, A>(sa: State<S, A>) => StateT2<F, S, E, A>\nexport declare function fromState<F extends URIS>(F: Pointed1<F>): <S, A>(sa: State<S, A>) => StateT1<F, S, A>\nexport declare function fromState<F>(F: Pointed<F>): <S, A>(sa: State<S, A>) => StateT<F, S, A>\n```\n\nAdded in v2.10.0\n\n## map\n\n**Signature**\n\n```ts\nexport declare function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <S, R, E>(fa: StateT3<F, S, R, E, A>) => StateT3<F, S, R, E, B>\nexport declare function map<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <A, B>(f: (a: A) => B) => <S, R>(fa: StateT3<F, S, R, E, A>) => StateT3<F, S, R, E, B>\nexport declare function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <S, E>(fa: StateT2<F, S, E, A>) => StateT2<F, S, E, B>\nexport declare function map<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <A, B>(f: (a: A) => B) => <S>(fa: StateT2<F, S, E, A>) => StateT2<F, S, E, B>\nexport declare function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => <S>(fa: StateT1<F, S, A>) => StateT1<F, S, B>\nexport declare function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <S>(fa: StateT<F, S, A>) => StateT<F, S, B>\n```\n\nAdded in v2.10.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare function of<F extends URIS3>(F: Pointed3<F>): <A, S, R, E>(a: A) => StateT3<F, S, R, E, A>\nexport declare function of<F extends URIS3, E>(F: Pointed3C<F, E>): <A, S, R>(a: A) => StateT3<F, S, R, E, A>\nexport declare function of<F extends URIS2>(F: Pointed2<F>): <A, S, E>(a: A) => StateT2<F, S, E, A>\nexport declare function of<F extends URIS2, E>(F: Pointed2C<F, E>): <A, S>(a: A) => StateT2<F, S, E, A>\nexport declare function of<F extends URIS>(F: Pointed1<F>): <A, S>(a: A) => StateT1<F, S, A>\nexport declare function of<F>(F: Pointed<F>): <A, S>(a: A) => StateT<F, S, A>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~StateM1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface StateM1<M extends URIS> {\n  readonly map: <S, A, B>(fa: StateT1<M, S, A>, f: (a: A) => B) => StateT1<M, S, B>\n  readonly of: <S, A>(a: A) => StateT1<M, S, A>\n  readonly ap: <S, A, B>(fab: StateT1<M, S, (a: A) => B>, fa: StateT1<M, S, A>) => StateT1<M, S, B>\n  readonly chain: <S, A, B>(fa: StateT1<M, S, A>, f: (a: A) => StateT1<M, S, B>) => StateT1<M, S, B>\n  readonly get: <S>() => StateT1<M, S, S>\n  readonly put: <S>(s: S) => StateT1<M, S, void>\n  readonly modify: <S>(f: (s: S) => S) => StateT1<M, S, void>\n  readonly gets: <S, A>(f: (s: S) => A) => StateT1<M, S, A>\n  readonly fromState: <S, A>(fa: State<S, A>) => StateT1<M, S, A>\n  readonly fromM: <S, A>(ma: Kind<M, A>) => StateT1<M, S, A>\n  readonly evalState: <S, A>(ma: StateT1<M, S, A>, s: S) => Kind<M, A>\n  readonly execState: <S, A>(ma: StateT1<M, S, A>, s: S) => Kind<M, S>\n}\n```\n\nAdded in v2.0.0\n\n## ~~StateM2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface StateM2C<M extends URIS2, E> {\n  readonly map: <S, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => B) => StateT2<M, S, E, B>\n  readonly of: <S, A>(a: A) => StateT2<M, S, E, A>\n  readonly ap: <S, A, B>(fab: StateT2<M, S, E, (a: A) => B>, fa: StateT2<M, S, E, A>) => StateT2<M, S, E, B>\n  readonly chain: <S, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => StateT2<M, S, E, B>) => StateT2<M, S, E, B>\n  readonly get: <S>() => StateT2<M, S, E, S>\n  readonly put: <S>(s: S) => StateT2<M, S, E, void>\n  readonly modify: <S>(f: (s: S) => S) => StateT2<M, S, E, void>\n  readonly gets: <S, A>(f: (s: S) => A) => StateT2<M, S, E, A>\n  readonly fromState: <S, A>(fa: State<S, A>) => StateT2<M, S, E, A>\n  readonly fromM: <S, A>(ma: Kind2<M, E, A>) => StateT2<M, S, E, A>\n  readonly evalState: <S, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, A>\n  readonly execState: <S, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, S>\n}\n```\n\nAdded in v2.5.4\n\n## ~~StateM2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface StateM2<M extends URIS2> {\n  readonly map: <S, E, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => B) => StateT2<M, S, E, B>\n  readonly of: <S, E, A>(a: A) => StateT2<M, S, E, A>\n  readonly ap: <S, E, A, B>(fab: StateT2<M, S, E, (a: A) => B>, fa: StateT2<M, S, E, A>) => StateT2<M, S, E, B>\n  readonly chain: <S, E, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => StateT2<M, S, E, B>) => StateT2<M, S, E, B>\n  readonly get: <E, S>() => StateT2<M, S, E, S>\n  readonly put: <E, S>(s: S) => StateT2<M, S, E, void>\n  readonly modify: <E, S>(f: (s: S) => S) => StateT2<M, S, E, void>\n  readonly gets: <S, E, A>(f: (s: S) => A) => StateT2<M, S, E, A>\n  readonly fromState: <S, E, A>(fa: State<S, A>) => StateT2<M, S, E, A>\n  readonly fromM: <S, E, A>(ma: Kind2<M, E, A>) => StateT2<M, S, E, A>\n  readonly evalState: <S, E, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, A>\n  readonly execState: <S, E, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, S>\n}\n```\n\nAdded in v2.0.0\n\n## ~~StateM3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface StateM3C<M extends URIS3, E> {\n  readonly map: <S, R, A, B>(fa: StateT3<M, S, R, E, A>, f: (a: A) => B) => StateT3<M, S, R, E, B>\n  readonly of: <S, R, A>(a: A) => StateT3<M, S, R, E, A>\n  readonly ap: <S, R, A, B>(fab: StateT3<M, S, R, E, (a: A) => B>, fa: StateT3<M, S, R, E, A>) => StateT3<M, S, R, E, B>\n  readonly chain: <S, R, A, B>(\n    fa: StateT3<M, S, R, E, A>,\n    f: (a: A) => StateT3<M, S, R, E, B>\n  ) => StateT3<M, S, R, E, B>\n  readonly get: <R, S>() => StateT3<M, S, R, E, S>\n  readonly put: <R, S>(s: S) => StateT3<M, S, R, E, void>\n  readonly modify: <R, S>(f: (s: S) => S) => StateT3<M, S, R, E, void>\n  readonly gets: <S, R, A>(f: (s: S) => A) => StateT3<M, S, R, E, A>\n  readonly fromState: <S, R, A>(fa: State<S, A>) => StateT3<M, S, R, E, A>\n  readonly fromM: <S, R, A>(ma: Kind3<M, R, E, A>) => StateT3<M, S, R, E, A>\n  readonly evalState: <S, R, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, A>\n  readonly execState: <S, R, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, S>\n}\n```\n\nAdded in v2.5.4\n\n## ~~StateM3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface StateM3<M extends URIS3> {\n  readonly map: <S, R, E, A, B>(fa: StateT3<M, S, R, E, A>, f: (a: A) => B) => StateT3<M, S, R, E, B>\n  readonly of: <S, R, E, A>(a: A) => StateT3<M, S, R, E, A>\n  readonly ap: <S, R, E, A, B>(\n    fab: StateT3<M, S, R, E, (a: A) => B>,\n    fa: StateT3<M, S, R, E, A>\n  ) => StateT3<M, S, R, E, B>\n  readonly chain: <S, R, E, A, B>(\n    fa: StateT3<M, S, R, E, A>,\n    f: (a: A) => StateT3<M, S, R, E, B>\n  ) => StateT3<M, S, R, E, B>\n  readonly get: <R, E, S>() => StateT3<M, S, R, E, S>\n  readonly put: <R, E, S>(s: S) => StateT3<M, S, R, E, void>\n  readonly modify: <R, E, S>(f: (s: S) => S) => StateT3<M, S, R, E, void>\n  readonly gets: <S, R, E, A>(f: (s: S) => A) => StateT3<M, S, R, E, A>\n  readonly fromState: <S, R, E, A>(fa: State<S, A>) => StateT3<M, S, R, E, A>\n  readonly fromM: <S, R, E, A>(ma: Kind3<M, R, E, A>) => StateT3<M, S, R, E, A>\n  readonly evalState: <S, R, E, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, A>\n  readonly execState: <S, R, E, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, S>\n}\n```\n\nAdded in v2.0.0\n\n## ~~StateM~~ (interface)\n\n**Signature**\n\n```ts\nexport interface StateM<M> {\n  readonly map: <S, A, B>(fa: StateT<M, S, A>, f: (a: A) => B) => StateT<M, S, B>\n  readonly of: <S, A>(a: A) => StateT<M, S, A>\n  readonly ap: <S, A, B>(fab: StateT<M, S, (a: A) => B>, fa: StateT<M, S, A>) => StateT<M, S, B>\n  readonly chain: <S, A, B>(fa: StateT<M, S, A>, f: (a: A) => StateT<M, S, B>) => StateT<M, S, B>\n  readonly get: <S>() => StateT<M, S, S>\n  readonly put: <S>(s: S) => StateT<M, S, void>\n  readonly modify: <S>(f: (s: S) => S) => StateT<M, S, void>\n  readonly gets: <S, A>(f: (s: S) => A) => StateT<M, S, A>\n  readonly fromState: <S, A>(fa: State<S, A>) => StateT<M, S, A>\n  readonly fromM: <S, A>(ma: HKT<M, A>) => StateT<M, S, A>\n  readonly evalState: <S, A>(ma: StateT<M, S, A>, s: S) => HKT<M, A>\n  readonly execState: <S, A>(ma: StateT<M, S, A>, s: S) => HKT<M, S>\n}\n```\n\nAdded in v2.0.0\n\n## ~~getStateM~~\n\n**Signature**\n\n```ts\nexport declare function getStateM<M extends URIS3>(M: Monad3<M>): StateM3<M>\nexport declare function getStateM<M extends URIS3, E>(M: Monad3C<M, E>): StateM3C<M, E>\nexport declare function getStateM<M extends URIS2>(M: Monad2<M>): StateM2<M>\nexport declare function getStateM<M extends URIS2, E>(M: Monad2C<M, E>): StateM2C<M, E>\nexport declare function getStateM<M extends URIS>(M: Monad1<M>): StateM1<M>\nexport declare function getStateM<M>(M: Monad<M>): StateM<M>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Store.ts.md",
    "content": "---\ntitle: Store.ts\nnav_order: 101\nparent: Modules\n---\n\n## Store overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [Extract](#extract)\n  - [extract](#extract)\n- [instances](#instances)\n  - [Comonad](#comonad)\n  - [Functor](#functor)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Store (interface)](#store-interface)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [duplicate](#duplicate)\n  - [experiment](#experiment)\n  - [extend](#extend)\n  - [peeks](#peeks)\n  - [seek](#seek)\n  - [seeks](#seeks)\n- [zone of death](#zone-of-death)\n  - [~~store~~](#store)\n\n---\n\n# Extract\n\n## extract\n\n**Signature**\n\n```ts\nexport declare const extract: <E, A>(wa: Store<E, A>) => A\n```\n\nAdded in v2.6.2\n\n# instances\n\n## Comonad\n\n**Signature**\n\n```ts\nexport declare const Comonad: Comonad2<'Store'>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'Store'>\n```\n\nAdded in v2.7.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: Store<E, (a: A) => B>) => Store<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Store<E, A>) => Store<E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## Store (interface)\n\n**Signature**\n\n```ts\nexport interface Store<S, A> {\n  readonly peek: (s: S) => A\n  readonly pos: S\n}\n```\n\nAdded in v2.0.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Store'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <E, A>(wa: Store<E, A>) => Store<E, Store<E, A>>\n```\n\nAdded in v2.0.0\n\n## experiment\n\nExtract a collection of values from positions which depend on the current position\n\n**Signature**\n\n```ts\nexport declare function experiment<F extends URIS3>(\n  F: Functor3<F>\n): <R, E, S>(f: (s: S) => Kind3<F, R, E, S>) => <A>(wa: Store<S, A>) => Kind3<F, R, E, A>\nexport declare function experiment<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <R, S>(f: (s: S) => Kind3<F, R, E, S>) => <A>(wa: Store<S, A>) => Kind3<F, R, E, A>\nexport declare function experiment<F extends URIS2>(\n  F: Functor2<F>\n): <E, S>(f: (s: S) => Kind2<F, E, S>) => <A>(wa: Store<S, A>) => Kind2<F, E, A>\nexport declare function experiment<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <S>(f: (s: S) => Kind2<F, E, S>) => <A>(wa: Store<S, A>) => Kind2<F, E, A>\nexport declare function experiment<F extends URIS>(\n  F: Functor1<F>\n): <S>(f: (s: S) => Kind<F, S>) => <A>(wa: Store<S, A>) => Kind<F, A>\nexport declare function experiment<F>(\n  F: FunctorHKT<F>\n): <S>(f: (s: S) => HKT<F, S>) => <A>(wa: Store<S, A>) => HKT<F, A>\n```\n\nAdded in v2.0.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <E, A, B>(f: (wa: Store<E, A>) => B) => (wa: Store<E, A>) => Store<E, B>\n```\n\nAdded in v2.0.0\n\n## peeks\n\nExtract a value from a position which depends on the current position\n\n**Signature**\n\n```ts\nexport declare function peeks<S>(f: Endomorphism<S>): <A>(wa: Store<S, A>) => A\n```\n\nAdded in v2.0.0\n\n## seek\n\nReposition the focus at the specified position\n\n**Signature**\n\n```ts\nexport declare function seek<S>(s: S): <A>(wa: Store<S, A>) => Store<S, A>\n```\n\nAdded in v2.0.0\n\n## seeks\n\nReposition the focus at the specified position, which depends on the current position\n\n**Signature**\n\n```ts\nexport declare function seeks<S>(f: Endomorphism<S>): <A>(wa: Store<S, A>) => Store<S, A>\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~store~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Comonad` instance, pass `S.Comonad` instead of `S.store`\n(where `S` is from `import S from 'fp-ts/Store'`)\n\n**Signature**\n\n```ts\nexport declare const store: Comonad2<'Store'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Strong.ts.md",
    "content": "---\ntitle: Strong.ts\nnav_order: 103\nparent: Modules\n---\n\n## Strong overview\n\nThe `Strong` class extends `Profunctor` with combinators for working with product types.\n\n`first` and `second` lift values in a `Profunctor` to act on the first and second components of a tuple,\nrespectively.\n\nAnother way to think about Strong is to piggyback on the intuition of\ninputs and outputs. Rewriting the type signature in this light then yields:\n\n```purescript\nfirst ::  forall input output a. p input output -> p (Tuple input a) (Tuple output a)\nsecond :: forall input output a. p input output -> p (Tuple a input) (Tuple a output)\n```\n\nIf we specialize the profunctor p to the function arrow, we get the following type\nsignatures, which may look a bit more familiar:\n\n```purescript\nfirst ::  forall input output a. (input -> output) -> (Tuple input a) -> (Tuple output a)\nsecond :: forall input output a. (input -> output) -> (Tuple a input) -> (Tuple a output)\n```\n\nSo, when the `profunctor` is `Function` application, `first` essentially applies your function\nto the first element of a tuple, and `second` applies it to the second element (same as `map` would do).\n\nAdapted from https://github.com/purescript/purescript-profunctor/blob/master/src/Data/Profunctor/Strong.purs\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Strong (interface)](#strong-interface)\n  - [Strong2 (interface)](#strong2-interface)\n  - [Strong3 (interface)](#strong3-interface)\n  - [Strong4 (interface)](#strong4-interface)\n- [utils](#utils)\n  - [fanOut](#fanout)\n  - [split](#split)\n- [zone of death](#zone-of-death)\n  - [~~fanout~~](#fanout)\n  - [~~splitStrong~~](#splitstrong)\n\n---\n\n# model\n\n## Strong (interface)\n\n**Signature**\n\n```ts\nexport interface Strong<F> extends Profunctor<F> {\n  readonly first: <A, B, C>(pab: HKT2<F, A, B>) => HKT2<F, [A, C], [B, C]>\n  readonly second: <A, B, C>(pab: HKT2<F, B, C>) => HKT2<F, [A, B], [A, C]>\n}\n```\n\nAdded in v2.0.0\n\n## Strong2 (interface)\n\n**Signature**\n\n```ts\nexport interface Strong2<F extends URIS2> extends Profunctor2<F> {\n  readonly first: <A, B, C>(pab: Kind2<F, A, B>) => Kind2<F, [A, C], [B, C]>\n  readonly second: <A, B, C>(pab: Kind2<F, B, C>) => Kind2<F, [A, B], [A, C]>\n}\n```\n\nAdded in v2.0.0\n\n## Strong3 (interface)\n\n**Signature**\n\n```ts\nexport interface Strong3<F extends URIS3> extends Profunctor3<F> {\n  readonly first: <R, A, B, C>(pab: Kind3<F, R, A, B>) => Kind3<F, R, [A, C], [B, C]>\n  readonly second: <R, A, B, C>(pab: Kind3<F, R, B, C>) => Kind3<F, R, [A, B], [A, C]>\n}\n```\n\nAdded in v2.0.0\n\n## Strong4 (interface)\n\n**Signature**\n\n```ts\nexport interface Strong4<F extends URIS4> extends Profunctor4<F> {\n  readonly first: <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, [A, C], [B, C]>\n  readonly second: <S, R, A, B, C>(pab: Kind4<F, S, R, B, C>) => Kind4<F, S, R, [A, B], [A, C]>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## fanOut\n\nCompose a value which introduces a tuple from two values, each introducing one side of the tuple.\n\nThis combinator is useful when assembling values from smaller components, because it provides a way to support two\ndifferent types of output.\n\nSpecializing `fanOut` to function application would look like this:\n\n```purescript\nfanOut :: forall a b c. (a -> b) -> (a -> c) -> (a -> (Tuple b c))\n```\n\nWe take two functions, `f` and `g`, with the same parameter type and we transform them into a single function which\ntakes one parameter and returns a tuple of the results of running `f` and `g` on the parameter, respectively. This\nallows us to run two parallel computations on the same input and return both results in a tuple.\n\n**Signature**\n\n```ts\nexport declare function fanOut<F extends URIS4>(\n  S: Strong4<F>,\n  C: Category4<F>\n): <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>, pac: Kind4<F, S, R, A, C>) => Kind4<F, S, R, A, [B, C]>\nexport declare function fanOut<F extends URIS3>(\n  S: Strong3<F>,\n  C: Category3<F>\n): <R, A, B, C>(pab: Kind3<F, R, A, B>, pac: Kind3<F, R, A, C>) => Kind3<F, R, A, [B, C]>\nexport declare function fanOut<F extends URIS2>(\n  S: Strong2<F>,\n  C: Category2<F>\n): <A, B, C>(pab: Kind2<F, A, B>, pac: Kind2<F, A, C>) => Kind2<F, A, [B, C]>\nexport declare function fanOut<F>(\n  S: Strong<F>,\n  C: Category<F>\n): <A, B, C>(pab: HKT2<F, A, B>, pac: HKT2<F, A, C>) => HKT2<F, A, [B, C]>\n```\n\nAdded in v2.10.0\n\n## split\n\nCompose a value acting on a tuple from two values, each acting on one of the components of the tuple.\n\nSpecializing `split` to function application would look like this:\n\n```purescript\nsplit :: forall a b c d. (a -> b) -> (c -> d) -> (Tuple a c) -> (Tuple b d)\n```\n\nWe take two functions, `f` and `g`, and we transform them into a single function which takes a tuple and maps `f`\nover the first element and `g` over the second. Just like `bi-map` would do for the `bi-functor` instance of tuple.\n\n**Signature**\n\n```ts\nexport declare function split<F extends URIS4>(\n  S: Strong4<F>,\n  C: Category4<F>\n): <S, R, A, B, C, D>(pab: Kind4<F, S, R, A, B>, pcd: Kind4<F, S, R, C, D>) => Kind4<F, S, R, [A, C], [B, D]>\nexport declare function split<F extends URIS3>(\n  S: Strong3<F>,\n  C: Category3<F>\n): <R, A, B, C, D>(pab: Kind3<F, R, A, B>, pcd: Kind3<F, R, C, D>) => Kind3<F, R, [A, C], [B, D]>\nexport declare function split<F extends URIS2>(\n  S: Strong2<F>,\n  C: Category2<F>\n): <A, B, C, D>(pab: Kind2<F, A, B>, pcd: Kind2<F, C, D>) => Kind2<F, [A, C], [B, D]>\nexport declare function split<F>(\n  S: Strong<F>,\n  C: Category<F>\n): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, [A, C], [B, D]>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~fanout~~\n\nUse [`fanOut`](#fanout) instead.\n\n**Signature**\n\n```ts\nexport declare function fanout<F extends URIS4>(\n  F: Category4<F> & Strong4<F>\n): <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>, pac: Kind4<F, S, R, A, C>) => Kind4<F, S, R, A, [B, C]>\nexport declare function fanout<F extends URIS3>(\n  F: Category3<F> & Strong3<F>\n): <R, A, B, C>(pab: Kind3<F, R, A, B>, pac: Kind3<F, R, A, C>) => Kind3<F, R, A, [B, C]>\nexport declare function fanout<F extends URIS2>(\n  F: Category2<F> & Strong2<F>\n): <A, B, C>(pab: Kind2<F, A, B>, pac: Kind2<F, A, C>) => Kind2<F, A, [B, C]>\nexport declare function fanout<F>(\n  F: Category<F> & Strong<F>\n): <A, B, C>(pab: HKT2<F, A, B>, pac: HKT2<F, A, C>) => HKT2<F, A, [B, C]>\n```\n\nAdded in v2.0.0\n\n## ~~splitStrong~~\n\nUse [`split`](#split) instead.\n\n**Signature**\n\n```ts\nexport declare function splitStrong<F extends URIS4>(\n  F: Category4<F> & Strong4<F>\n): <S, R, A, B, C, D>(pab: Kind4<F, S, R, A, B>, pcd: Kind4<F, S, R, C, D>) => Kind4<F, S, R, [A, C], [B, D]>\nexport declare function splitStrong<F extends URIS3>(\n  F: Category3<F> & Strong3<F>\n): <R, A, B, C, D>(pab: Kind3<F, R, A, B>, pcd: Kind3<F, R, C, D>) => Kind3<F, R, [A, C], [B, D]>\nexport declare function splitStrong<F extends URIS2>(\n  F: Category2<F> & Strong2<F>\n): <A, B, C, D>(pab: Kind2<F, A, B>, pcd: Kind2<F, C, D>) => Kind2<F, [A, C], [B, D]>\nexport declare function splitStrong<F>(\n  F: Category<F> & Strong<F>\n): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, [A, C], [B, D]>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Task.ts.md",
    "content": "---\ntitle: Task.ts\nnav_order: 105\nparent: Modules\n---\n\n## Task overview\n\n```ts\ninterface Task<A> {\n  (): Promise<A>\n}\n```\n\n`Task<A>` represents an asynchronous computation that yields a value of type `A` and **never fails**.\nIf you want to represent an asynchronous computation that may fail, please see `TaskEither`.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapIO](#tapio)\n- [constructors](#constructors)\n  - [of](#of)\n- [conversions](#conversions)\n  - [fromIO](#fromio)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n- [instances](#instances)\n  - [ApplicativePar](#applicativepar)\n  - [ApplicativeSeq](#applicativeseq)\n  - [ApplyPar](#applypar)\n  - [ApplySeq](#applyseq)\n  - [Chain](#chain)\n  - [FromIO](#fromio)\n  - [FromTask](#fromtask)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [MonadTask](#monadtask)\n  - [Pointed](#pointed)\n  - [getRaceMonoid](#getracemonoid)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainIOK](#chainiok)\n- [lifting](#lifting)\n  - [fromIOK](#fromiok)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Task (interface)](#task-interface)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapIO](#flatmapio)\n  - [flatten](#flatten)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [sequenceSeqArray](#sequenceseqarray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyArrayWithIndexSeq](#traversereadonlyarraywithindexseq)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndexSeq](#traversereadonlynonemptyarraywithindexseq)\n  - [traverseSeqArray](#traverseseqarray)\n  - [traverseSeqArrayWithIndex](#traverseseqarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [delay](#delay)\n  - [never](#never)\n- [zone of death](#zone-of-death)\n  - [~~fromTask~~](#fromtask)\n  - [~~getMonoid~~](#getmonoid)\n  - [~~getSemigroup~~](#getsemigroup)\n  - [~~taskSeq~~](#taskseq)\n  - [~~task~~](#task)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <A, _>(self: Task<A>, f: (a: A) => Task<_>): Task<A>\n  <A, _>(f: (a: A) => Task<_>): (self: Task<A>) => Task<A>\n}\n```\n\nAdded in v2.15.0\n\n## tapIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): (self: Task<A>) => Task<A>\n  <A, _>(self: Task<A>, f: (a: A) => IO<_>): Task<A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as T from 'fp-ts/Task'\nimport * as Console from 'fp-ts/Console'\n\n// Will produce `Hello, fp-ts` to the stdout\nconst effect = pipe(\n  T.of('fp-ts'),\n  T.tapIO((value) => Console.log(`Hello, ${value}`))\n)\n\nasync function test() {\n  assert.deepStrictEqual(await effect(), 'fp-ts')\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => Task<A>\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A>(fa: IO<A>) => Task<A>\n```\n\nAdded in v2.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: Task<{}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: Task<B>\n) => (fa: Task<A>) => Task<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Task<B>\n) => (ma: Task<A>) => Task<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: Task<A>) => Task<{ readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: Task<A>) => Task<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# instances\n\n## ApplicativePar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplicativePar: Applicative1<'Task'>\n```\n\nAdded in v2.7.0\n\n## ApplicativeSeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplicativeSeq: Applicative1<'Task'>\n```\n\nAdded in v2.7.0\n\n## ApplyPar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplyPar: Apply1<'Task'>\n```\n\nAdded in v2.10.0\n\n## ApplySeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplySeq: Apply1<'Task'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain1<'Task'>\n```\n\nAdded in v2.10.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO1<'Task'>\n```\n\nAdded in v2.10.0\n\n## FromTask\n\n**Signature**\n\n```ts\nexport declare const FromTask: FromTask1<'Task'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'Task'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'Task'>\n```\n\nAdded in v2.10.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO1<'Task'>\n```\n\nAdded in v2.10.0\n\n## MonadTask\n\n**Signature**\n\n```ts\nexport declare const MonadTask: MonadTask1<'Task'>\n```\n\nAdded in v2.10.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'Task'>\n```\n\nAdded in v2.10.0\n\n## getRaceMonoid\n\nMonoid returning the first completed task.\n\nNote: uses `Promise.race` internally.\n\n**Signature**\n\n```ts\nexport declare function getRaceMonoid<A = never>(): Monoid<Task<A>>\n```\n\n**Example**\n\n```ts\nimport * as T from 'fp-ts/Task'\n\nasync function test() {\n  const S = T.getRaceMonoid<string>()\n  const fa = T.delay(20)(T.of('a'))\n  const fb = T.delay(10)(T.of('b'))\n  assert.deepStrictEqual(await S.concat(fa, fb)(), 'b')\n}\n\ntest()\n```\n\nAdded in v2.0.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => Task<B>) => (ma: Task<A>) => Task<B>\n```\n\nAdded in v2.0.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => Task<B>) => (first: Task<A>) => Task<A>\n```\n\nAdded in v2.0.0\n\n## chainFirstIOK\n\nAlias of `tapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => (first: Task<A>) => Task<A>\n```\n\nAdded in v2.10.0\n\n## chainIOK\n\nAlias of `flatMapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainIOK: <A, B>(f: (a: A) => IO<B>) => (first: Task<A>) => Task<B>\n```\n\nAdded in v2.4.0\n\n# lifting\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(f: (...a: A) => IO<B>) => (...a: A) => Task<B>\n```\n\nAdded in v2.4.0\n\n# mapping\n\n## as\n\nMaps the value to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: { <A>(a: A): <_>(self: Task<_>) => Task<A>; <_, A>(self: Task<_>, a: A): Task<A> }\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the value to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <_>(self: Task<_>) => Task<void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: Task<(a: A) => B>) => Task<B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (fa: Task<A>) => Task<B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## Task (interface)\n\n**Signature**\n\n```ts\nexport interface Task<A> {\n  (): Promise<A>\n}\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A) => Task<B>): (ma: Task<A>) => Task<B>\n  <A, B>(ma: Task<A>, f: (a: A) => Task<B>): Task<B>\n}\n```\n\nAdded in v2.14.0\n\n## flatMapIO\n\n**Signature**\n\n```ts\nexport declare const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): (self: Task<A>) => Task<B>\n  <A, B>(self: Task<A>, f: (a: A) => IO<B>): Task<B>\n}\n```\n\nAdded in v2.16.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: Task<Task<A>>) => Task<A>\n```\n\nAdded in v2.0.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <A>(arr: readonly Task<A>[]) => Task<readonly A[]>\n```\n\nAdded in v2.9.0\n\n## sequenceSeqArray\n\nEquivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceSeqArray: <A>(arr: readonly Task<A>[]) => Task<readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <A, B>(f: (a: A) => Task<B>) => (as: readonly A[]) => Task<readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Task<B>\n) => (as: readonly A[]) => Task<readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Task<B>\n) => (as: readonly A[]) => Task<readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyArrayWithIndexSeq\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndexSeq: <A, B>(\n  f: (index: number, a: A) => Task<B>\n) => (as: readonly A[]) => Task<readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Task<B>\n) => (as: ReadonlyNonEmptyArray<A>) => Task<ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndexSeq\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, B>(\n  f: (index: number, a: A) => Task<B>\n) => (as: ReadonlyNonEmptyArray<A>) => Task<ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseSeqArray\n\nEquivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArray: <A, B>(f: (a: A) => Task<B>) => (as: readonly A[]) => Task<readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseSeqArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Task<B>\n) => (as: readonly A[]) => Task<readonly B[]>\n```\n\nAdded in v2.9.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Task'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: Task<readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(fa: Task<A>) => <B>(fab: Task<(a: A) => B>) => Task<B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: Task<B>) => <A>(first: Task<A>) => Task<A>\n```\n\nAdded in v2.0.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: Task<B>) => <A>(first: Task<A>) => Task<B>\n```\n\nAdded in v2.0.0\n\n## delay\n\nCreates a task that will complete after a time delay\n\n**Signature**\n\n```ts\nexport declare function delay(millis: number): <A>(ma: Task<A>) => Task<A>\n```\n\n**Example**\n\n```ts\nimport { sequenceT } from 'fp-ts/Apply'\nimport * as T from 'fp-ts/Task'\nimport { takeRight } from 'fp-ts/Array'\n\nasync function test() {\n  const log: Array<string> = []\n  const append = (message: string): T.Task<void> =>\n    T.fromIO(() => {\n      log.push(message)\n    })\n  const fa = append('a')\n  const fb = T.delay(20)(append('b'))\n  const fc = T.delay(10)(append('c'))\n  const fd = append('d')\n  await sequenceT(T.ApplyPar)(fa, fb, fc, fd)()\n  assert.deepStrictEqual(takeRight(2)(log), ['c', 'b'])\n}\n\ntest()\n```\n\nAdded in v2.0.0\n\n## never\n\nA `Task` that never completes.\n\n**Signature**\n\n```ts\nexport declare const never: Task<never>\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~fromTask~~\n\n**Signature**\n\n```ts\nexport declare const fromTask: <A>(fa: Task<A>) => Task<A>\n```\n\nAdded in v2.7.0\n\n## ~~getMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\nLift a monoid into 'Task', the inner values are concatenated using the provided `Monoid`.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <A>(M: Monoid<A>) => Monoid<Task<A>>\n```\n\nAdded in v2.0.0\n\n## ~~getSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <A>(S: Semigroup<A>) => Semigroup<Task<A>>\n```\n\nAdded in v2.0.0\n\n## ~~taskSeq~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.taskSeq`\n(where `T` is from `import T from 'fp-ts/Task'`)\n\n**Signature**\n\n```ts\nexport declare const taskSeq: Monad1<'Task'> & MonadTask1<'Task'>\n```\n\nAdded in v2.0.0\n\n## ~~task~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.task`\n(where `T` is from `import T from 'fp-ts/Task'`)\n\n**Signature**\n\n```ts\nexport declare const task: Monad1<'Task'> & MonadTask1<'Task'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/TaskEither.ts.md",
    "content": "---\ntitle: TaskEither.ts\nnav_order: 106\nparent: Modules\n---\n\n## TaskEither overview\n\n```ts\ninterface TaskEither<E, A> extends Task<Either<E, A>> {}\n```\n\n`TaskEither<E, A>` represents an asynchronous computation that either yields a value of type `A` or fails yielding an\nerror of type `E`. If you want to represent an asynchronous computation that never fails, please see `Task`.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapEither](#tapeither)\n  - [tapIO](#tapio)\n  - [tapTask](#taptask)\n- [constructors](#constructors)\n  - [left](#left)\n  - [leftIO](#leftio)\n  - [leftTask](#lefttask)\n  - [of](#of)\n  - [right](#right)\n  - [rightIO](#rightio)\n  - [rightTask](#righttask)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromIO](#fromio)\n  - [fromIOEither](#fromioeither)\n  - [fromNullable](#fromnullable)\n  - [fromOption](#fromoption)\n  - [fromTask](#fromtask)\n  - [fromTaskOption](#fromtaskoption)\n  - [toUnion](#tounion)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [apSW](#apsw)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [bindW](#bindw)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n  - [getAltTaskValidation](#getalttaskvalidation)\n  - [getApplicativeTaskValidation](#getapplicativetaskvalidation)\n  - [getOrElse](#getorelse)\n  - [getOrElseW](#getorelsew)\n  - [mapBoth](#mapboth)\n  - [mapError](#maperror)\n  - [orElse](#orelse)\n  - [orElseFirstIOK](#orelsefirstiok)\n  - [orElseFirstTaskK](#orelsefirsttaskk)\n  - [orElseW](#orelsew)\n  - [orLeft](#orleft)\n  - [tapError](#taperror)\n- [filtering](#filtering)\n  - [filterOrElse](#filterorelse)\n  - [filterOrElseW](#filterorelsew)\n  - [getCompactable](#getcompactable)\n  - [getFilterable](#getfilterable)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [ApplicativePar](#applicativepar)\n  - [ApplicativeSeq](#applicativeseq)\n  - [ApplyPar](#applypar)\n  - [ApplySeq](#applyseq)\n  - [Bifunctor](#bifunctor)\n  - [Chain](#chain)\n  - [FromEither](#fromeither)\n  - [FromIO](#fromio)\n  - [FromTask](#fromtask)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [MonadTask](#monadtask)\n  - [MonadThrow](#monadthrow)\n  - [Pointed](#pointed)\n- [interop](#interop)\n  - [taskify](#taskify)\n  - [tryCatch](#trycatch)\n  - [tryCatchK](#trycatchk)\n- [legacy](#legacy)\n  - [bimap](#bimap)\n  - [chain](#chain)\n  - [chainEitherK](#chaineitherk)\n  - [chainEitherKW](#chaineitherkw)\n  - [chainFirst](#chainfirst)\n  - [chainFirstEitherK](#chainfirsteitherk)\n  - [chainFirstEitherKW](#chainfirsteitherkw)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainFirstTaskK](#chainfirsttaskk)\n  - [chainFirstW](#chainfirstw)\n  - [chainIOEitherK](#chainioeitherk)\n  - [chainIOEitherKW](#chainioeitherkw)\n  - [chainIOK](#chainiok)\n  - [chainNullableK](#chainnullablek)\n  - [chainOptionK](#chainoptionk)\n  - [chainOptionKW](#chainoptionkw)\n  - [chainTaskK](#chaintaskk)\n  - [chainTaskOptionK](#chaintaskoptionk)\n  - [chainTaskOptionKW](#chaintaskoptionkw)\n  - [chainW](#chainw)\n  - [fromNullableK](#fromnullablek)\n  - [fromOptionK](#fromoptionk)\n  - [mapLeft](#mapleft)\n  - [orElseFirst](#orelsefirst)\n  - [orElseFirstW](#orelsefirstw)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromIOEitherK](#fromioeitherk)\n  - [fromIOK](#fromiok)\n  - [fromPredicate](#frompredicate)\n  - [fromTaskK](#fromtaskk)\n  - [fromTaskOptionK](#fromtaskoptionk)\n  - [liftNullable](#liftnullable)\n  - [liftOption](#liftoption)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [TaskEither (interface)](#taskeither-interface)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchE](#matche)\n  - [matchEW](#matchew)\n  - [matchW](#matchw)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatMapEither](#flatmapeither)\n  - [flatMapIO](#flatmapio)\n  - [flatMapIOEither](#flatmapioeither)\n  - [flatMapNullable](#flatmapnullable)\n  - [flatMapOption](#flatmapoption)\n  - [flatMapTask](#flatmaptask)\n  - [flatMapTaskOption](#flatmaptaskoption)\n  - [flatten](#flatten)\n  - [flattenW](#flattenw)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [sequenceSeqArray](#sequenceseqarray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyArrayWithIndexSeq](#traversereadonlyarraywithindexseq)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndexSeq](#traversereadonlynonemptyarraywithindexseq)\n  - [traverseSeqArray](#traverseseqarray)\n  - [traverseSeqArrayWithIndex](#traverseseqarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apFirstW](#apfirstw)\n  - [apSecond](#apsecond)\n  - [apSecondW](#apsecondw)\n  - [apW](#apw)\n  - [bracket](#bracket)\n  - [bracketW](#bracketw)\n  - [swap](#swap)\n  - [throwError](#throwerror)\n- [zone of death](#zone-of-death)\n  - [~~getApplyMonoid~~](#getapplymonoid)\n  - [~~getApplySemigroup~~](#getapplysemigroup)\n  - [~~getSemigroup~~](#getsemigroup)\n  - [~~getTaskValidation~~](#gettaskvalidation)\n  - [~~taskEitherSeq~~](#taskeitherseq)\n  - [~~taskEither~~](#taskeither)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <E1, A, E2, _>(self: TaskEither<E1, A>, f: (a: A) => TaskEither<E2, _>): TaskEither<E1 | E2, A>\n  <A, E2, _>(f: (a: A) => TaskEither<E2, _>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, A>\n}\n```\n\nAdded in v2.15.0\n\n## tapEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapEither: {\n  <A, E2, _>(f: (a: A) => E.Either<E2, _>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, A>\n  <E1, A, E2, _>(self: TaskEither<E1, A>, f: (a: A) => E.Either<E2, _>): TaskEither<E1 | E2, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as TE from 'fp-ts/TaskEither'\n\nconst checkString = (value: string) =>\n  pipe(\n    TE.of(value),\n    TE.tapEither(() => (value.length > 0 ? E.right('ok') : E.left('error')))\n  )\n\nasync function test() {\n  assert.deepStrictEqual(await checkString('')(), E.left('error'))\n  assert.deepStrictEqual(await checkString('fp-ts')(), E.right('fp-ts'))\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## tapIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <E>(self: TaskEither<E, A>) => TaskEither<E, A>\n  <E, A, _>(self: TaskEither<E, A>, f: (a: A) => IO<_>): TaskEither<E, A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as TE from 'fp-ts/TaskEither'\nimport * as E from 'fp-ts/Either'\nimport * as Console from 'fp-ts/Console'\n\n// Will produce `Hello, fp-ts` to the stdout\nconst effectA = TE.tapIO(TE.of(1), (value) => Console.log(`Hello, ${value}`))\n\n// No output to the stdout\nconst effectB = pipe(\n  TE.left('error'),\n  TE.tapIO((value) => Console.log(`Hello, ${value}`))\n)\n\nasync function test() {\n  assert.deepStrictEqual(await effectA(), E.of(1))\n  assert.deepStrictEqual(await effectB(), E.left('error'))\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## tapTask\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapTask: {\n  <A, _>(f: (a: A) => T.Task<_>): <E>(self: TaskEither<E, A>) => TaskEither<E, A>\n  <E, A, _>(self: TaskEither<E, A>, f: (a: A) => T.Task<_>): TaskEither<E, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as TE from 'fp-ts/TaskEither'\nimport * as T from 'fp-ts/Task'\nimport * as E from 'fp-ts/Either'\n\nconst effect = TE.tapIO(TE.of(1), (value) => T.of(value + 1))\n\nasync function test() {\n  assert.deepStrictEqual(await effect(), E.of(1))\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## left\n\n**Signature**\n\n```ts\nexport declare const left: <E = never, A = never>(e: E) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## leftIO\n\n**Signature**\n\n```ts\nexport declare const leftIO: <E = never, A = never>(me: IO<E>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## leftTask\n\n**Signature**\n\n```ts\nexport declare const leftTask: <E = never, A = never>(me: T.Task<E>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <E = never, A = never>(a: A) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare const right: <E = never, A = never>(a: A) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## rightIO\n\n**Signature**\n\n```ts\nexport declare const rightIO: <E = never, A = never>(ma: IO<A>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## rightTask\n\n**Signature**\n\n```ts\nexport declare const rightTask: <E = never, A = never>(ma: T.Task<A>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <E, A>(fa: E.Either<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A, E = never>(fa: IO<A>) => TaskEither<E, A>\n```\n\nAdded in v2.7.0\n\n## fromIOEither\n\n**Signature**\n\n```ts\nexport declare const fromIOEither: <E, A>(fa: IOEither<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## fromNullable\n\n**Signature**\n\n```ts\nexport declare const fromNullable: <E>(e: E) => <A>(a: A) => TaskEither<E, NonNullable<A>>\n```\n\nAdded in v2.12.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## fromTask\n\n**Signature**\n\n```ts\nexport declare const fromTask: <A, E = never>(fa: T.Task<A>) => TaskEither<E, A>\n```\n\nAdded in v2.7.0\n\n## fromTaskOption\n\n**Signature**\n\n```ts\nexport declare const fromTaskOption: <E>(onNone: LazyArg<E>) => <A>(fa: TaskOption<A>) => TaskEither<E, A>\n```\n\nAdded in v2.11.0\n\n## toUnion\n\n**Signature**\n\n```ts\nexport declare const toUnion: <E, A>(fa: TaskEither<E, A>) => T.Task<E | A>\n```\n\nAdded in v2.10.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: TaskEither<never, {}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: TaskEither<E, B>\n) => (fa: TaskEither<E, A>) => TaskEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## apSW\n\nLess strict version of [`apS`](#aps).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSW: <A, N extends string, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: TaskEither<E2, B>\n) => <E1>(fa: TaskEither<E1, A>) => TaskEither<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => TaskEither<E, B>\n) => (ma: TaskEither<E, A>) => TaskEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <E, A>(fa: TaskEither<E, A>) => TaskEither<E, { readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## bindW\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bindW: <N extends string, A, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => TaskEither<E2, B>\n) => <E1>(fa: TaskEither<E1, A>) => TaskEither<E2 | E1, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <E>(fa: TaskEither<E, A>) => TaskEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\nIdentifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\ntypes of kind `* -> *`.\n\nIn case of `TaskEither` returns `fa` if is a `Right` or the value returned by `that` otherwise.\n\nSee also [orElse](#orelse).\n\n**Signature**\n\n```ts\nexport declare const alt: <E, A>(that: LazyArg<TaskEither<E, A>>) => (fa: TaskEither<E, A>) => TaskEither<E, A>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as TE from 'fp-ts/TaskEither'\n\nasync function test() {\n  assert.deepStrictEqual(\n    await pipe(\n      TE.right(1),\n      TE.alt(() => TE.right(2))\n    )(),\n    E.right(1)\n  )\n  assert.deepStrictEqual(\n    await pipe(\n      TE.left('a'),\n      TE.alt(() => TE.right(2))\n    )(),\n    E.right(2)\n  )\n  assert.deepStrictEqual(\n    await pipe(\n      TE.left('a'),\n      TE.alt(() => TE.left('b'))\n    )(),\n    E.left('b')\n  )\n}\n\ntest()\n```\n\nAdded in v2.0.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the error and the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <E2, B>(\n  that: LazyArg<TaskEither<E2, B>>\n) => <E1, A>(fa: TaskEither<E1, A>) => TaskEither<E2, B | A>\n```\n\nAdded in v2.9.0\n\n## getAltTaskValidation\n\nThe default [`Alt`](#alt) instance returns the last error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\nSee [`getAltValidation`](./Either.ts.html#getaltvalidation).\n\n**Signature**\n\n```ts\nexport declare function getAltTaskValidation<E>(S: Semigroup<E>): Alt2C<URI, E>\n```\n\nAdded in v2.7.0\n\n## getApplicativeTaskValidation\n\nThe default [`ApplicativePar`](#applicativepar) instance returns the first error, if you want to\nget all errors you need to provide a way to concatenate them via a `Semigroup`.\n\n**Signature**\n\n```ts\nexport declare function getApplicativeTaskValidation<E>(A: Apply1<T.URI>, S: Semigroup<E>): Applicative2C<URI, E>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as RA from 'fp-ts/ReadonlyArray'\nimport * as S from 'fp-ts/Semigroup'\nimport * as string from 'fp-ts/string'\nimport * as T from 'fp-ts/Task'\nimport * as TE from 'fp-ts/TaskEither'\n\ninterface User {\n  readonly id: string\n  readonly name: string\n}\n\nconst remoteDatabase: ReadonlyArray<User> = [\n  { id: 'id1', name: 'John' },\n  { id: 'id2', name: 'Mary' },\n  { id: 'id3', name: 'Joey' },\n]\n\nconst fetchUser = (id: string): TE.TaskEither<string, User> =>\n  pipe(\n    remoteDatabase,\n    RA.findFirst((user) => user.id === id),\n    TE.fromOption(() => `${id} not found`)\n  )\n\nasync function test() {\n  assert.deepStrictEqual(\n    await pipe(['id4', 'id5'], RA.traverse(TE.ApplicativePar)(fetchUser))(),\n    E.left('id4 not found') // <= first error\n  )\n\n  const Applicative = TE.getApplicativeTaskValidation(T.ApplyPar, pipe(string.Semigroup, S.intercalate(', ')))\n\n  assert.deepStrictEqual(\n    await pipe(['id4', 'id5'], RA.traverse(Applicative)(fetchUser))(),\n    E.left('id4 not found, id5 not found') // <= all errors\n  )\n}\n\ntest()\n```\n\nAdded in v2.7.0\n\n## getOrElse\n\n**Signature**\n\n```ts\nexport declare const getOrElse: <E, A>(onLeft: (e: E) => T.Task<A>) => (ma: TaskEither<E, A>) => T.Task<A>\n```\n\nAdded in v2.0.0\n\n## getOrElseW\n\nLess strict version of [`getOrElse`](#getorelse).\n\nThe `W` suffix (short for **W**idening) means that the handler return type will be merged.\n\n**Signature**\n\n```ts\nexport declare const getOrElseW: <E, B>(onLeft: (e: E) => T.Task<B>) => <A>(ma: TaskEither<E, A>) => T.Task<B | A>\n```\n\nAdded in v2.6.0\n\n## mapBoth\n\nReturns a `TaskEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`.\n\n**Signature**\n\n```ts\nexport declare const mapBoth: {\n  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): (self: TaskEither<E, A>) => TaskEither<G, B>\n  <E, A, G, B>(self: TaskEither<E, A>, f: (e: E) => G, g: (a: A) => B): TaskEither<G, B>\n}\n```\n\n**Example**\n\n```ts\nimport * as TaskEither from 'fp-ts/TaskEither'\nimport * as Either from 'fp-ts/Either'\n\nconst f = (s: string) => new Error(s)\nconst g = (n: number) => n * 2\n\nasync function test() {\n  assert.deepStrictEqual(await TaskEither.mapBoth(TaskEither.right(1), f, g)(), Either.right(2))\n  assert.deepStrictEqual(await TaskEither.mapBoth(TaskEither.left('err'), f, g)(), Either.left(new Error('err')))\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## mapError\n\nReturns a `TaskEither` with its error channel mapped using the specified function.\n\n**Signature**\n\n```ts\nexport declare const mapError: {\n  <E, G>(f: (e: E) => G): <A>(self: TaskEither<E, A>) => TaskEither<G, A>\n  <E, A, G>(self: TaskEither<E, A>, f: (e: E) => G): TaskEither<G, A>\n}\n```\n\n**Example**\n\n```ts\nimport * as TaskEither from 'fp-ts/TaskEither'\nimport * as Either from 'fp-ts/Either'\n\nconst f = (s: string) => new Error(s)\n\nasync function test() {\n  assert.deepStrictEqual(await TaskEither.mapError(TaskEither.right(1), f)(), Either.right(1))\n  assert.deepStrictEqual(await TaskEither.mapError(TaskEither.left('err'), f)(), Either.left(new Error('err')))\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## orElse\n\nReturns `ma` if is a `Right` or the value returned by `onLeft` otherwise.\n\nSee also [alt](#alt).\n\n**Signature**\n\n```ts\nexport declare const orElse: <E1, A, E2>(\n  onLeft: (e: E1) => TaskEither<E2, A>\n) => (ma: TaskEither<E1, A>) => TaskEither<E2, A>\n```\n\n**Example**\n\n```ts\nimport * as E from 'fp-ts/Either'\nimport { pipe } from 'fp-ts/function'\nimport * as TE from 'fp-ts/TaskEither'\n\nasync function test() {\n  const errorHandler = TE.orElse((error: string) => TE.right(`recovering from ${error}...`))\n  assert.deepStrictEqual(await pipe(TE.right('ok'), errorHandler)(), E.right('ok'))\n  assert.deepStrictEqual(await pipe(TE.left('ko'), errorHandler)(), E.right('recovering from ko...'))\n}\n\ntest()\n```\n\nAdded in v2.0.0\n\n## orElseFirstIOK\n\n**Signature**\n\n```ts\nexport declare const orElseFirstIOK: <E, B>(onLeft: (e: E) => IO<B>) => <A>(ma: TaskEither<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.12.0\n\n## orElseFirstTaskK\n\n**Signature**\n\n```ts\nexport declare const orElseFirstTaskK: <E, B>(\n  onLeft: (e: E) => T.Task<B>\n) => <A>(ma: TaskEither<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.12.0\n\n## orElseW\n\nLess strict version of [`orElse`](#orelse).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const orElseW: <E1, E2, B>(\n  onLeft: (e: E1) => TaskEither<E2, B>\n) => <A>(ma: TaskEither<E1, A>) => TaskEither<E2, B | A>\n```\n\nAdded in v2.10.0\n\n## orLeft\n\n**Signature**\n\n```ts\nexport declare const orLeft: <E1, E2>(onLeft: (e: E1) => T.Task<E2>) => <A>(fa: TaskEither<E1, A>) => TaskEither<E2, A>\n```\n\nAdded in v2.11.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) => TaskEither<E2, _>): <A>(self: TaskEither<E1, A>) => TaskEither<E1 | E2, A>\n  <E1, A, E2, _>(self: TaskEither<E1, A>, onLeft: (e: E1) => TaskEither<E2, _>): TaskEither<E1 | E2, A>\n}\n```\n\nAdded in v2.15.0\n\n# filtering\n\n## filterOrElse\n\n**Signature**\n\n```ts\nexport declare const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: TaskEither<E, A>) => TaskEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: TaskEither<E, B>) => TaskEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: TaskEither<E, A>) => TaskEither<E, A>\n}\n```\n\nAdded in v2.0.0\n\n## filterOrElseW\n\nLess strict version of [`filterOrElse`](#filterorelse).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(\n    ma: TaskEither<E1, A>\n  ) => TaskEither<E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>(\n    mb: TaskEither<E1, B>\n  ) => TaskEither<E2 | E1, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, A>\n}\n```\n\nAdded in v2.9.0\n\n## getCompactable\n\n**Signature**\n\n```ts\nexport declare const getCompactable: <E>(M: Monoid<E>) => Compactable2C<'TaskEither', E>\n```\n\nAdded in v2.10.0\n\n## getFilterable\n\n**Signature**\n\n```ts\nexport declare function getFilterable<E>(M: Monoid<E>): Filterable2C<URI, E>\n```\n\nAdded in v2.1.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt2<'TaskEither'>\n```\n\nAdded in v2.7.0\n\n## ApplicativePar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplicativePar: Applicative2<'TaskEither'>\n```\n\nAdded in v2.7.0\n\n## ApplicativeSeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplicativeSeq: Applicative2<'TaskEither'>\n```\n\nAdded in v2.7.0\n\n## ApplyPar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplyPar: Apply2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## ApplySeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplySeq: Apply2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor2<'TaskEither'>\n```\n\nAdded in v2.7.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## FromTask\n\n**Signature**\n\n```ts\nexport declare const FromTask: FromTask2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'TaskEither'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## MonadTask\n\n**Signature**\n\n```ts\nexport declare const MonadTask: MonadTask2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## MonadThrow\n\n**Signature**\n\n```ts\nexport declare const MonadThrow: MonadThrow2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed2<'TaskEither'>\n```\n\nAdded in v2.10.0\n\n# interop\n\n## taskify\n\nConvert a node style callback function to one returning a `TaskEither`\n\n**Note**. If the function `f` admits multiple overloadings, `taskify` will pick last one. If you want a different\nbehaviour, add an explicit type annotation\n\n```ts\n// readFile admits multiple overloadings\n\n// const readFile: (a: string) => TaskEither<NodeJS.ErrnoException, Buffer>\nconst readFile = taskify(fs.readFile)\n\nconst readFile2: (filename: string, encoding: string) => TaskEither<NodeJS.ErrnoException, Buffer> = taskify(\n  fs.readFile\n)\n```\n\n**Signature**\n\n```ts\nexport declare function taskify<L, R>(f: (cb: (e: L | null | undefined, r?: R) => void) => void): () => TaskEither<L, R>\nexport declare function taskify<A, L, R>(\n  f: (a: A, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A) => TaskEither<L, R>\nexport declare function taskify<A, B, L, R>(\n  f: (a: A, b: B, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A, b: B) => TaskEither<L, R>\nexport declare function taskify<A, B, C, L, R>(\n  f: (a: A, b: B, c: C, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A, b: B, c: C) => TaskEither<L, R>\nexport declare function taskify<A, B, C, D, L, R>(\n  f: (a: A, b: B, c: C, d: D, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A, b: B, c: C, d: D) => TaskEither<L, R>\nexport declare function taskify<A, B, C, D, E, L, R>(\n  f: (a: A, b: B, c: C, d: D, e: E, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A, b: B, c: C, d: D, e: E) => TaskEither<L, R>\n```\n\n**Example**\n\n```ts\nimport { taskify } from 'fp-ts/TaskEither'\nimport * as fs from 'fs'\n\n// const stat: (a: string | Buffer) => TaskEither<NodeJS.ErrnoException, fs.Stats>\nconst stat = taskify(fs.stat)\nassert.strictEqual(stat.length, 0)\n```\n\nAdded in v2.0.0\n\n## tryCatch\n\nTransforms a `Promise` that may reject to a `Promise` that never rejects and returns an `Either` instead.\n\nSee also [`tryCatchK`](#trycatchk).\n\n**Signature**\n\n```ts\nexport declare const tryCatch: <E, A>(f: LazyArg<Promise<A>>, onRejected: (reason: unknown) => E) => TaskEither<E, A>\n```\n\n**Example**\n\n```ts\nimport { left, right } from 'fp-ts/Either'\nimport { tryCatch } from 'fp-ts/TaskEither'\n\ntryCatch(() => Promise.resolve(1), String)().then((result) => {\n  assert.deepStrictEqual(result, right(1))\n})\ntryCatch(() => Promise.reject('error'), String)().then((result) => {\n  assert.deepStrictEqual(result, left('error'))\n})\n```\n\nAdded in v2.0.0\n\n## tryCatchK\n\nConverts a function returning a `Promise` to one returning a `TaskEither`.\n\n**Signature**\n\n```ts\nexport declare const tryCatchK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => Promise<B>,\n  onRejected: (reason: unknown) => E\n) => (...a: A) => TaskEither<E, B>\n```\n\nAdded in v2.5.0\n\n# legacy\n\n## bimap\n\nAlias of `mapBoth`.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: TaskEither<E, A>) => TaskEither<G, B>\n```\n\nAdded in v2.0.0\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <E, A, B>(f: (a: A) => TaskEither<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, B>\n```\n\nAdded in v2.0.0\n\n## chainEitherK\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherK: <E, A, B>(f: (a: A) => E.Either<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, B>\n```\n\nAdded in v2.4.0\n\n## chainEitherKW\n\nAlias of `flatMapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainEitherKW: <E2, A, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <E, A, B>(f: (a: A) => TaskEither<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## chainFirstEitherK\n\nAlias of `tapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherK: <A, E, B>(\n  f: (a: A) => E.Either<E, B>\n) => (ma: TaskEither<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstEitherKW\n\nAlias of `tapEither`.\n\nLess strict version of [`chainFirstEitherK`](#chainfirsteitherk).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## chainFirstIOK\n\nAlias of `tapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.10.0\n\n## chainFirstTaskK\n\nAlias of `tapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.10.0\n\n## chainFirstW\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstW: <E2, A, B>(\n  f: (a: A) => TaskEither<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, A>\n```\n\nAdded in v2.8.0\n\n## chainIOEitherK\n\nAlias of `flatMapIOEither`.\n\n**Signature**\n\n```ts\nexport declare const chainIOEitherK: <E, A, B>(\n  f: (a: A) => IOEither<E, B>\n) => (ma: TaskEither<E, A>) => TaskEither<E, B>\n```\n\nAdded in v2.4.0\n\n## chainIOEitherKW\n\nAlias of `flatMapIOEither`.\n\nLess strict version of [`chainIOEitherK`](#chainioeitherk).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainIOEitherKW: <E2, A, B>(\n  f: (a: A) => IOEither<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n```\n\nAdded in v2.6.1\n\n## chainIOK\n\nAlias of `flatMapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainIOK: <A, B>(f: (a: A) => IO<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, B>\n```\n\nAdded in v2.10.0\n\n## chainNullableK\n\nUse `flatMapNullable`.\n\n**Signature**\n\n```ts\nexport declare const chainNullableK: <E>(\n  e: E\n) => <A, B>(f: (a: A) => B | null | undefined) => (ma: TaskEither<E, A>) => TaskEither<E, NonNullable<B>>\n```\n\nAdded in v2.12.0\n\n## chainOptionK\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => (ma: TaskEither<E, A>) => TaskEither<E, B>\n```\n\nAdded in v2.10.0\n\n## chainOptionKW\n\nUse `flatMapOption`.\n\n**Signature**\n\n```ts\nexport declare const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n```\n\nAdded in v2.13.2\n\n## chainTaskK\n\nAlias of `flatMapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainTaskK: <A, B>(f: (a: A) => T.Task<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, B>\n```\n\nAdded in v2.10.0\n\n## chainTaskOptionK\n\nUse `flatMapTaskOption`.\n\n**Signature**\n\n```ts\nexport declare const chainTaskOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => TaskOption<B>) => (ma: TaskEither<E, A>) => TaskEither<E, B>\n```\n\nAdded in v2.11.0\n\n## chainTaskOptionKW\n\nUse `flatMapTaskOption`.\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const chainTaskOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => TaskOption<B>) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n```\n\nAdded in v2.12.3\n\n## chainW\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chainW: <E2, A, B>(\n  f: (a: A) => TaskEither<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n```\n\nAdded in v2.6.0\n\n## fromNullableK\n\nUse `liftNullable`.\n\n**Signature**\n\n```ts\nexport declare const fromNullableK: <E>(\n  e: E\n) => <A extends readonly unknown[], B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => TaskEither<E, NonNullable<B>>\n```\n\nAdded in v2.12.0\n\n## fromOptionK\n\nUse `liftOption`.\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => TaskEither<E, B>\n```\n\nAdded in v2.10.0\n\n## mapLeft\n\nAlias of `mapError`.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: TaskEither<E, A>) => TaskEither<G, A>\n```\n\nAdded in v2.0.0\n\n## orElseFirst\n\nAlias of `tapError`.\n\n**Signature**\n\n```ts\nexport declare const orElseFirst: <E, B>(\n  onLeft: (e: E) => TaskEither<E, B>\n) => <A>(ma: TaskEither<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.11.0\n\n## orElseFirstW\n\nAlias of `tapError`.\n\n**Signature**\n\n```ts\nexport declare const orElseFirstW: <E1, E2, B>(\n  onLeft: (e: E1) => TaskEither<E2, B>\n) => <A>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => E.Either<E, B>\n) => (...a: A) => TaskEither<E, B>\n```\n\nAdded in v2.4.0\n\n## fromIOEitherK\n\n**Signature**\n\n```ts\nexport declare const fromIOEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => IOEither<E, B>\n) => (...a: A) => TaskEither<E, B>\n```\n\nAdded in v2.4.0\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(\n  f: (...a: A) => IO<B>\n) => <E = never>(...a: A) => TaskEither<E, B>\n```\n\nAdded in v2.10.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => TaskEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => TaskEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => TaskEither<E, A>\n}\n```\n\nAdded in v2.0.0\n\n## fromTaskK\n\n**Signature**\n\n```ts\nexport declare const fromTaskK: <A extends readonly unknown[], B>(\n  f: (...a: A) => T.Task<B>\n) => <E = never>(...a: A) => TaskEither<E, B>\n```\n\nAdded in v2.10.0\n\n## fromTaskOptionK\n\n**Signature**\n\n```ts\nexport declare const fromTaskOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends readonly unknown[], B>(f: (...a: A) => TaskOption<B>) => (...a: A) => TaskEither<E, B>\n```\n\nAdded in v2.11.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) => TaskEither<E, NonNullable<B>>\n```\n\nAdded in v2.15.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) => TaskEither<E, B>\n```\n\nAdded in v2.15.0\n\n# mapping\n\n## as\n\nMaps the `Right` value of this `TaskEither` to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <E, _>(self: TaskEither<E, _>) => TaskEither<E, A>\n  <E, _, A>(self: TaskEither<E, _>, a: A): TaskEither<E, A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the `Right` value of this `TaskEither` to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <E, _>(self: TaskEither<E, _>) => TaskEither<E, void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: TaskEither<E, (a: A) => B>) => TaskEither<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: TaskEither<E, A>) => TaskEither<E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## TaskEither (interface)\n\n**Signature**\n\n```ts\nexport interface TaskEither<E, A> extends Task<Either<E, A>> {}\n```\n\nAdded in v2.0.0\n\n# pattern matching\n\n## fold\n\nAlias of [`matchE`](#matche).\n\n**Signature**\n\n```ts\nexport declare const fold: <E, A, B>(\n  onLeft: (e: E) => T.Task<B>,\n  onRight: (a: A) => T.Task<B>\n) => (ma: TaskEither<E, A>) => T.Task<B>\n```\n\nAdded in v2.0.0\n\n## foldW\n\nAlias of [`matchEW`](#matchew).\n\n**Signature**\n\n```ts\nexport declare const foldW: <E, B, A, C>(\n  onLeft: (e: E) => T.Task<B>,\n  onRight: (a: A) => T.Task<C>\n) => (ma: TaskEither<E, A>) => T.Task<B | C>\n```\n\nAdded in v2.10.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: TaskEither<E, A>) => T.Task<B>\n```\n\nAdded in v2.10.0\n\n## matchE\n\nThe `E` suffix (short for **E**ffect) means that the handlers return an effect (`Task`).\n\n**Signature**\n\n```ts\nexport declare const matchE: <E, A, B>(\n  onLeft: (e: E) => T.Task<B>,\n  onRight: (a: A) => T.Task<B>\n) => (ma: TaskEither<E, A>) => T.Task<B>\n```\n\nAdded in v2.10.0\n\n## matchEW\n\nLess strict version of [`matchE`](#matche).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchEW: <E, B, A, C>(\n  onLeft: (e: E) => T.Task<B>,\n  onRight: (a: A) => T.Task<C>\n) => (ma: TaskEither<E, A>) => T.Task<B | C>\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <E, B, A, C>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C\n) => (ma: TaskEither<E, A>) => T.Task<B | C>\n```\n\nAdded in v2.10.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, E2, B>(f: (a: A) => TaskEither<E2, B>): <E1>(ma: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n  <E1, A, E2, B>(ma: TaskEither<E1, A>, f: (a: A) => TaskEither<E2, B>): TaskEither<E1 | E2, B>\n}\n```\n\nAdded in v2.14.0\n\n## flatMapEither\n\n**Signature**\n\n```ts\nexport declare const flatMapEither: {\n  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => E.Either<E2, B>): TaskEither<E1 | E2, B>\n}\n```\n\nAdded in v2.15.0\n\n## flatMapIO\n\n**Signature**\n\n```ts\nexport declare const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <E>(self: TaskEither<E, A>) => TaskEither<E, B>\n  <E, A, B>(self: TaskEither<E, A>, f: (a: A) => IO<B>): TaskEither<E, B>\n}\n```\n\nAdded in v2.15.0\n\n## flatMapIOEither\n\n**Signature**\n\n```ts\nexport declare const flatMapIOEither: {\n  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => IOEither<E2, B>): TaskEither<E1 | E2, B>\n}\n```\n\nAdded in v2.16.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: TaskEither<E1, A>\n  ) => TaskEither<E2 | E1, NonNullable<B>>\n  <E1, A, B, E2>(self: TaskEither<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): TaskEither<\n    E1 | E2,\n    NonNullable<B>\n  >\n}\n```\n\nAdded in v2.15.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: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n  <E1, A, B, E2>(self: TaskEither<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): TaskEither<E1 | E2, B>\n}\n```\n\nAdded in v2.15.0\n\n## flatMapTask\n\n**Signature**\n\n```ts\nexport declare const flatMapTask: {\n  <A, B>(f: (a: A) => T.Task<B>): <E>(self: TaskEither<E, A>) => TaskEither<E, B>\n  <E, A, B>(self: TaskEither<E, A>, f: (a: A) => T.Task<B>): TaskEither<E, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapTaskOption\n\n**Signature**\n\n```ts\nexport declare const flatMapTaskOption: {\n  <A, E2, B>(f: (a: A) => TaskOption<B>, onNone: (a: A) => E2): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => TaskOption<B>, onNone: (a: A) => E2): TaskEither<E1 | E2, B>\n}\n```\n\nAdded in v2.16.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <E, A>(mma: TaskEither<E, TaskEither<E, A>>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## flattenW\n\nLess strict version of [`flatten`](#flatten).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const flattenW: <E1, E2, A>(mma: TaskEither<E1, TaskEither<E2, A>>) => TaskEither<E1 | E2, A>\n```\n\nAdded in v2.11.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <A, E>(arr: readonly TaskEither<E, A>[]) => TaskEither<E, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## sequenceSeqArray\n\nEquivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceSeqArray: <A, E>(arr: readonly TaskEither<E, A>[]) => TaskEither<E, readonly A[]>\n```\n\nAdded in v2.9.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <A, B, E>(\n  f: (a: A) => TaskEither<E, B>\n) => (as: readonly A[]) => TaskEither<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <A, B, E>(\n  f: (index: number, a: A) => TaskEither<E, B>\n) => (as: readonly A[]) => TaskEither<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => TaskEither<E, B>\n) => (as: readonly A[]) => TaskEither<E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyArrayWithIndexSeq\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndexSeq: <A, E, B>(\n  f: (index: number, a: A) => TaskEither<E, B>\n) => (as: readonly A[]) => TaskEither<E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => TaskEither<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => TaskEither<E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndexSeq\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, E, B>(\n  f: (index: number, a: A) => TaskEither<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => TaskEither<E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseSeqArray\n\nEquivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArray: <A, B, E>(\n  f: (a: A) => TaskEither<E, B>\n) => (as: readonly A[]) => TaskEither<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n## traverseSeqArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArrayWithIndex: <A, B, E>(\n  f: (index: number, a: A) => TaskEither<E, B>\n) => (as: readonly A[]) => TaskEither<E, readonly B[]>\n```\n\nAdded in v2.9.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'TaskEither'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: TaskEither<never, readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <E, A>(fa: TaskEither<E, A>) => <B>(fab: TaskEither<E, (a: A) => B>) => TaskEither<E, B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <E, B>(second: TaskEither<E, B>) => <A>(first: TaskEither<E, A>) => TaskEither<E, A>\n```\n\nAdded in v2.0.0\n\n## apFirstW\n\nLess strict version of [`apFirst`](#apfirst).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apFirstW: <E2, B>(\n  second: TaskEither<E2, B>\n) => <E1, A>(first: TaskEither<E1, A>) => TaskEither<E2 | E1, A>\n```\n\nAdded in v2.12.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <E, B>(second: TaskEither<E, B>) => <A>(first: TaskEither<E, A>) => TaskEither<E, B>\n```\n\nAdded in v2.0.0\n\n## apSecondW\n\nLess strict version of [`apSecond`](#apsecond).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apSecondW: <E2, B>(\n  second: TaskEither<E2, B>\n) => <E1, A>(first: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n```\n\nAdded in v2.12.0\n\n## apW\n\nLess strict version of [`ap`](#ap).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const apW: <E2, A>(\n  fa: TaskEither<E2, A>\n) => <E1, B>(fab: TaskEither<E1, (a: A) => B>) => TaskEither<E2 | E1, B>\n```\n\nAdded in v2.8.0\n\n## bracket\n\nMake sure that a resource is cleaned up in the event of an exception (\\*). The release action is called regardless of\nwhether the body action throws (\\*) or returns.\n\n(\\*) i.e. returns a `Left`\n\n**Signature**\n\n```ts\nexport declare const bracket: <E, A, B>(\n  acquire: TaskEither<E, A>,\n  use: (a: A) => TaskEither<E, B>,\n  release: (a: A, e: E.Either<E, B>) => TaskEither<E, void>\n) => TaskEither<E, B>\n```\n\nAdded in v2.0.0\n\n## bracketW\n\nLess strict version of [`bracket`](#bracket).\n\nThe `W` suffix (short for **W**idening) means that the error types will be merged.\n\n**Signature**\n\n```ts\nexport declare const bracketW: <E1, A, E2, B, E3>(\n  acquire: TaskEither<E1, A>,\n  use: (a: A) => TaskEither<E2, B>,\n  release: (a: A, e: E.Either<E2, B>) => TaskEither<E3, void>\n) => TaskEither<E1 | E2 | E3, B>\n```\n\nAdded in v2.12.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare const swap: <E, A>(ma: TaskEither<E, A>) => TaskEither<A, E>\n```\n\nAdded in v2.0.0\n\n## throwError\n\n**Signature**\n\n```ts\nexport declare const throwError: <E, A>(e: E) => TaskEither<E, A>\n```\n\nAdded in v2.7.0\n\n# zone of death\n\n## ~~getApplyMonoid~~\n\nUse [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<TaskEither<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getApplySemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<TaskEither<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <E, A>(S: Semigroup<A>) => Semigroup<TaskEither<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~getTaskValidation~~\n\nUse [`getApplicativeTaskValidation`](#getapplicativetaskvalidation) and [`getAltTaskValidation`](#getalttaskvalidation) instead.\n\n**Signature**\n\n```ts\nexport declare function getTaskValidation<E>(\n  SE: Semigroup<E>\n): Monad2C<URI, E> & Bifunctor2<URI> & Alt2C<URI, E> & MonadTask2C<URI, E> & MonadThrow2C<URI, E>\n```\n\nAdded in v2.0.0\n\n## ~~taskEitherSeq~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `TE.Functor` instead of `TE.taskEitherSeq`\n(where `TE` is from `import TE from 'fp-ts/TaskEither'`)\n\n**Signature**\n\n```ts\nexport declare const taskEitherSeq: Monad2<'TaskEither'> &\n  Bifunctor2<'TaskEither'> &\n  Alt2<'TaskEither'> &\n  MonadTask2<'TaskEither'> &\n  MonadThrow2<'TaskEither'>\n```\n\nAdded in v2.0.0\n\n## ~~taskEither~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `TE.Functor` instead of `TE.taskEither`\n(where `TE` is from `import TE from 'fp-ts/TaskEither'`)\n\n**Signature**\n\n```ts\nexport declare const taskEither: Monad2<'TaskEither'> &\n  Bifunctor2<'TaskEither'> &\n  Alt2<'TaskEither'> &\n  MonadTask2<'TaskEither'> &\n  MonadThrow2<'TaskEither'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/TaskOption.ts.md",
    "content": "---\ntitle: TaskOption.ts\nnav_order: 107\nparent: Modules\n---\n\n## TaskOption overview\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [combinators](#combinators)\n  - [tap](#tap)\n  - [tapEither](#tapeither)\n  - [tapIO](#tapio)\n  - [tapTask](#taptask)\n- [constructors](#constructors)\n  - [none](#none)\n  - [of](#of)\n  - [some](#some)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromIO](#fromio)\n  - [fromNullable](#fromnullable)\n  - [fromOption](#fromoption)\n  - [fromTask](#fromtask)\n  - [fromTaskEither](#fromtaskeither)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [guard](#guard)\n  - [let](#let)\n- [error handling](#error-handling)\n  - [alt](#alt)\n  - [altW](#altw)\n  - [getOrElse](#getorelse)\n  - [getOrElseW](#getorelsew)\n- [filtering](#filtering)\n  - [compact](#compact)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [separate](#separate)\n- [instances](#instances)\n  - [Alt](#alt)\n  - [Alternative](#alternative)\n  - [ApplicativePar](#applicativepar)\n  - [ApplicativeSeq](#applicativeseq)\n  - [ApplyPar](#applypar)\n  - [ApplySeq](#applyseq)\n  - [Chain](#chain)\n  - [Compactable](#compactable)\n  - [Filterable](#filterable)\n  - [FromEither](#fromeither)\n  - [FromIO](#fromio)\n  - [FromTask](#fromtask)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [MonadIO](#monadio)\n  - [MonadTask](#monadtask)\n  - [Pointed](#pointed)\n  - [Zero](#zero)\n- [interop](#interop)\n  - [tryCatch](#trycatch)\n  - [tryCatchK](#trycatchk)\n- [legacy](#legacy)\n  - [chain](#chain)\n  - [chainFirst](#chainfirst)\n  - [chainFirstEitherK](#chainfirsteitherk)\n  - [chainFirstIOK](#chainfirstiok)\n  - [chainFirstTaskK](#chainfirsttaskk)\n  - [chainIOK](#chainiok)\n  - [chainTaskK](#chaintaskk)\n- [lifting](#lifting)\n  - [fromEitherK](#fromeitherk)\n  - [fromIOK](#fromiok)\n  - [fromNullableK](#fromnullablek)\n  - [fromOptionK](#fromoptionk)\n  - [fromPredicate](#frompredicate)\n  - [fromTaskK](#fromtaskk)\n- [mapping](#mapping)\n  - [as](#as)\n  - [asUnit](#asunit)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [TaskOption (interface)](#taskoption-interface)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchE](#matche)\n  - [matchEW](#matchew)\n  - [matchW](#matchw)\n- [sequencing](#sequencing)\n  - [chainEitherK](#chaineitherk)\n  - [chainNullableK](#chainnullablek)\n  - [chainOptionK](#chainoptionk)\n  - [flatMap](#flatmap)\n  - [flatMapIO](#flatmapio)\n  - [flatMapTask](#flatmaptask)\n  - [flatten](#flatten)\n- [traversing](#traversing)\n  - [sequenceArray](#sequencearray)\n  - [sequenceSeqArray](#sequenceseqarray)\n  - [traverseArray](#traversearray)\n  - [traverseArrayWithIndex](#traversearraywithindex)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyArrayWithIndexSeq](#traversereadonlyarraywithindexseq)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndexSeq](#traversereadonlynonemptyarraywithindexseq)\n  - [traverseSeqArray](#traverseseqarray)\n  - [traverseSeqArrayWithIndex](#traverseseqarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [zero](#zero)\n\n---\n\n# combinators\n\n## tap\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tap: {\n  <A, _>(self: TaskOption<A>, f: (a: A) => TaskOption<_>): TaskOption<A>\n  <A, _>(f: (a: A) => TaskOption<_>): (self: TaskOption<A>) => TaskOption<A>\n}\n```\n\nAdded in v2.15.0\n\n## tapEither\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapEither: {\n  <A, E, _>(f: (a: A) => Either<E, _>): (self: TaskOption<A>) => TaskOption<A>\n  <A, E, _>(self: TaskOption<A>, f: (a: A) => Either<E, _>): TaskOption<A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as TO from 'fp-ts/TaskOption'\nimport * as O from 'fp-ts/Option'\nimport * as E from 'fp-ts/Either'\n\nconst compute = (value: number) =>\n  pipe(\n    TO.of(value),\n    TO.tapEither((value) => (value > 0 ? E.right('ok') : E.left('error')))\n  )\n\nasync function test() {\n  assert.deepStrictEqual(await compute(1)(), O.of(1))\n  assert.deepStrictEqual(await compute(-1)(), O.none)\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## tapIO\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): (self: TaskOption<A>) => TaskOption<A>\n  <A, _>(self: TaskOption<A>, f: (a: A) => IO<_>): TaskOption<A>\n}\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport * as TO from 'fp-ts/TaskOption'\nimport * as O from 'fp-ts/Option'\nimport * as Console from 'fp-ts/Console'\n\n// Will produce `Hello, fp-ts` to the stdout\nconst effectA = TO.tapIO(TO.of(1), (value) => Console.log(`Hello, ${value}`))\n\n// No output to the stdout\nconst effectB = pipe(\n  TO.none as TO.TaskOption<string>,\n  TO.tapIO((value) => Console.log(`Hello, ${value}`))\n)\n\nasync function test() {\n  assert.deepStrictEqual(await effectA(), O.of(1))\n  assert.deepStrictEqual(await effectB(), O.none)\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n## tapTask\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const tapTask: {\n  <A, _>(f: (a: A) => T.Task<_>): (self: TaskOption<A>) => TaskOption<A>\n  <A, _>(self: TaskOption<A>, f: (a: A) => T.Task<_>): TaskOption<A>\n}\n```\n\n**Example**\n\n```ts\nimport * as TO from 'fp-ts/TaskOption'\nimport * as O from 'fp-ts/Option'\nimport * as T from 'fp-ts/Task'\n\nconst effect = TO.tapIO(TO.of(1), (value) => T.of(value + 1))\n\nasync function test() {\n  assert.deepStrictEqual(await effect(), O.of(1))\n}\n\ntest()\n```\n\nAdded in v2.16.0\n\n# constructors\n\n## none\n\n**Signature**\n\n```ts\nexport declare const none: TaskOption<never>\n```\n\nAdded in v2.10.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## some\n\n**Signature**\n\n```ts\nexport declare const some: <A>(a: A) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n# conversions\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <A>(fa: Either<unknown, A>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A>(fa: IO<A>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## fromNullable\n\n**Signature**\n\n```ts\nexport declare const fromNullable: <A>(a: A) => TaskOption<NonNullable<A>>\n```\n\nAdded in v2.10.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <A>(fa: O.Option<A>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## fromTask\n\n**Signature**\n\n```ts\nexport declare const fromTask: <A>(fa: T.Task<A>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## fromTaskEither\n\n**Signature**\n\n```ts\nexport declare const fromTaskEither: <A>(fa: TaskEither<unknown, A>) => TaskOption<A>\n```\n\nAdded in v2.11.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: TaskOption<{}>\n```\n\nAdded in v2.10.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: TaskOption<B>\n) => (fa: TaskOption<A>) => TaskOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.10.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => TaskOption<B>\n) => (ma: TaskOption<A>) => TaskOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.10.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: TaskOption<A>) => TaskOption<{ readonly [K in N]: A }>\n```\n\nAdded in v2.10.0\n\n## guard\n\n**Signature**\n\n```ts\nexport declare const guard: (b: boolean) => TaskOption<void>\n```\n\nAdded in v2.11.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: TaskOption<A>) => TaskOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# error handling\n\n## alt\n\n**Signature**\n\n```ts\nexport declare const alt: <A>(second: LazyArg<TaskOption<A>>) => (first: TaskOption<A>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## altW\n\nLess strict version of [`alt`](#alt).\n\nThe `W` suffix (short for **W**idening) means that the return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const altW: <B>(second: LazyArg<TaskOption<B>>) => <A>(first: TaskOption<A>) => TaskOption<B | A>\n```\n\nAdded in v2.10.0\n\n## getOrElse\n\n**Signature**\n\n```ts\nexport declare const getOrElse: <A>(onNone: LazyArg<T.Task<A>>) => (fa: TaskOption<A>) => T.Task<A>\n```\n\nAdded in v2.10.0\n\n## getOrElseW\n\nLess strict version of [`getOrElse`](#getorelse).\n\nThe `W` suffix (short for **W**idening) means that the handler return type will be merged.\n\n**Signature**\n\n```ts\nexport declare const getOrElseW: <B>(onNone: LazyArg<T.Task<B>>) => <A>(ma: TaskOption<A>) => T.Task<B | A>\n```\n\nAdded in v2.10.0\n\n# filtering\n\n## compact\n\n**Signature**\n\n```ts\nexport declare const compact: <A>(fa: TaskOption<O.Option<A>>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## filter\n\n**Signature**\n\n```ts\nexport declare const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fb: TaskOption<A>) => TaskOption<B>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: TaskOption<B>) => TaskOption<B>\n  <A>(predicate: Predicate<A>): (fa: TaskOption<A>) => TaskOption<A>\n}\n```\n\nAdded in v2.10.0\n\n## filterMap\n\n**Signature**\n\n```ts\nexport declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => (fga: TaskOption<A>) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n## partition\n\n**Signature**\n\n```ts\nexport declare const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fb: TaskOption<A>) => Separated<TaskOption<A>, TaskOption<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: TaskOption<B>) => Separated<TaskOption<B>, TaskOption<B>>\n  <A>(predicate: Predicate<A>): (fa: TaskOption<A>) => Separated<TaskOption<A>, TaskOption<A>>\n}\n```\n\nAdded in v2.10.0\n\n## partitionMap\n\n**Signature**\n\n```ts\nexport declare const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: TaskOption<A>) => Separated<TaskOption<B>, TaskOption<C>>\n```\n\nAdded in v2.10.0\n\n## separate\n\n**Signature**\n\n```ts\nexport declare const separate: <A, B>(fa: TaskOption<Either<A, B>>) => Separated<TaskOption<A>, TaskOption<B>>\n```\n\nAdded in v2.10.0\n\n# instances\n\n## Alt\n\n**Signature**\n\n```ts\nexport declare const Alt: Alt1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## Alternative\n\n**Signature**\n\n```ts\nexport declare const Alternative: Alternative1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## ApplicativePar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplicativePar: Applicative1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## ApplicativeSeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplicativeSeq: Applicative1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## ApplyPar\n\nRuns computations in parallel.\n\n**Signature**\n\n```ts\nexport declare const ApplyPar: Apply1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## ApplySeq\n\nRuns computations sequentially.\n\n**Signature**\n\n```ts\nexport declare const ApplySeq: Apply1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: chainable.Chain1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## Compactable\n\n**Signature**\n\n```ts\nexport declare const Compactable: Compactable1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## Filterable\n\n**Signature**\n\n```ts\nexport declare const Filterable: Filterable1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither1<'TaskOption'>\n```\n\nAdded in v2.11.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## FromTask\n\n**Signature**\n\n```ts\nexport declare const FromTask: FromTask1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## MonadIO\n\n**Signature**\n\n```ts\nexport declare const MonadIO: MonadIO1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## MonadTask\n\n**Signature**\n\n```ts\nexport declare const MonadTask: MonadTask1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'TaskOption'>\n```\n\nAdded in v2.10.0\n\n## Zero\n\n**Signature**\n\n```ts\nexport declare const Zero: Zero1<'TaskOption'>\n```\n\nAdded in v2.11.0\n\n# interop\n\n## tryCatch\n\nTransforms a `Promise` that may reject to a `Promise` that never rejects and returns an `Option` instead.\n\nSee also [`tryCatchK`](#trycatchk).\n\n**Signature**\n\n```ts\nexport declare const tryCatch: <A>(f: LazyArg<Promise<A>>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## tryCatchK\n\nConverts a function returning a `Promise` to one returning a `TaskOption`.\n\n**Signature**\n\n```ts\nexport declare const tryCatchK: <A extends readonly unknown[], B>(\n  f: (...a: A) => Promise<B>\n) => (...a: A) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => TaskOption<B>) => (ma: TaskOption<A>) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n## chainFirst\n\nAlias of `tap`.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => TaskOption<B>) => (first: TaskOption<A>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## chainFirstEitherK\n\nAlias of `tapEither`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: TaskOption<A>) => TaskOption<A>\n```\n\nAdded in v2.12.0\n\n## chainFirstIOK\n\nAlias of `tapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => (first: TaskOption<A>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## chainFirstTaskK\n\nAlias of `tapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => (first: TaskOption<A>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## chainIOK\n\nAlias of `flatMapIO`.\n\n**Signature**\n\n```ts\nexport declare const chainIOK: <A, B>(f: (a: A) => IO<B>) => (first: TaskOption<A>) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n## chainTaskK\n\nAlias of `flatMapTask`.\n\n**Signature**\n\n```ts\nexport declare const chainTaskK: <A, B>(f: (a: A) => T.Task<B>) => (first: TaskOption<A>) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n# lifting\n\n## fromEitherK\n\n**Signature**\n\n```ts\nexport declare const fromEitherK: <E, A extends readonly unknown[], B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => TaskOption<B>\n```\n\nAdded in v2.12.0\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(f: (...a: A) => IO<B>) => (...a: A) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n## fromNullableK\n\n**Signature**\n\n```ts\nexport declare const fromNullableK: <A extends readonly unknown[], B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => TaskOption<NonNullable<B>>\n```\n\nAdded in v2.10.0\n\n## fromOptionK\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <A extends readonly unknown[], B>(\n  f: (...a: A) => O.Option<B>\n) => (...a: A) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => TaskOption<B>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => TaskOption<B>\n  <A>(predicate: Predicate<A>): (a: A) => TaskOption<A>\n}\n```\n\nAdded in v2.10.0\n\n## fromTaskK\n\n**Signature**\n\n```ts\nexport declare const fromTaskK: <A extends readonly unknown[], B>(\n  f: (...a: A) => T.Task<B>\n) => (...a: A) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n# mapping\n\n## as\n\nMaps the `Some` value of this `TaskOption` to the specified constant value.\n\n**Signature**\n\n```ts\nexport declare const as: {\n  <A>(a: A): <_>(self: TaskOption<_>) => TaskOption<A>\n  <_, A>(self: TaskOption<_>, a: A): TaskOption<A>\n}\n```\n\nAdded in v2.16.0\n\n## asUnit\n\nMaps the `Some` value of this `TaskOption` to the void constant value.\n\n**Signature**\n\n```ts\nexport declare const asUnit: <_>(self: TaskOption<_>) => TaskOption<void>\n```\n\nAdded in v2.16.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: TaskOption<(a: A) => B>) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (fa: TaskOption<A>) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n# model\n\n## TaskOption (interface)\n\n**Signature**\n\n```ts\nexport interface TaskOption<A> extends Task<Option<A>> {}\n```\n\nAdded in v2.10.0\n\n# pattern matching\n\n## fold\n\nAlias of [`matchE`](#matche).\n\n**Signature**\n\n```ts\nexport declare const fold: <B, A>(\n  onNone: () => T.Task<B>,\n  onSome: (a: A) => T.Task<B>\n) => (ma: TaskOption<A>) => T.Task<B>\n```\n\nAdded in v2.10.0\n\n## foldW\n\nAlias of [`matchEW`](#matchew).\n\n**Signature**\n\n```ts\nexport declare const foldW: <B, C, A>(\n  onNone: () => T.Task<B>,\n  onSome: (a: A) => T.Task<C>\n) => (ma: TaskOption<A>) => T.Task<B | C>\n```\n\nAdded in v2.10.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: TaskOption<A>) => T.Task<B>\n```\n\nAdded in v2.10.0\n\n## matchE\n\nThe `E` suffix (short for **E**ffect) means that the handlers return an effect (`Task`).\n\n**Signature**\n\n```ts\nexport declare const matchE: <B, A>(\n  onNone: () => T.Task<B>,\n  onSome: (a: A) => T.Task<B>\n) => (ma: TaskOption<A>) => T.Task<B>\n```\n\nAdded in v2.10.0\n\n## matchEW\n\nLess strict version of [`matchE`](#matche).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchEW: <B, C, A>(\n  onNone: () => T.Task<B>,\n  onSome: (a: A) => T.Task<C>\n) => (ma: TaskOption<A>) => T.Task<B | C>\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <B, A, C>(onNone: () => B, onSome: (a: A) => C) => (ma: TaskOption<A>) => T.Task<B | C>\n```\n\nAdded in v2.10.0\n\n# sequencing\n\n## chainEitherK\n\n**Signature**\n\n```ts\nexport declare const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: TaskOption<A>) => TaskOption<B>\n```\n\nAdded in v2.12.0\n\n## chainNullableK\n\n**Signature**\n\n```ts\nexport declare const chainNullableK: <A, B>(\n  f: (a: A) => B | null | undefined\n) => (ma: TaskOption<A>) => TaskOption<NonNullable<B>>\n```\n\nAdded in v2.10.0\n\n## chainOptionK\n\n**Signature**\n\n```ts\nexport declare const chainOptionK: <A, B>(f: (a: A) => O.Option<B>) => (ma: TaskOption<A>) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A) => TaskOption<B>): (ma: TaskOption<A>) => TaskOption<B>\n  <A, B>(ma: TaskOption<A>, f: (a: A) => TaskOption<B>): TaskOption<B>\n}\n```\n\nAdded in v2.14.0\n\n## flatMapIO\n\n**Signature**\n\n```ts\nexport declare const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): (self: TaskOption<A>) => TaskOption<B>\n  <A, B>(self: TaskOption<A>, f: (a: A) => IO<B>): TaskOption<B>\n}\n```\n\nAdded in v2.16.0\n\n## flatMapTask\n\n**Signature**\n\n```ts\nexport declare const flatMapTask: {\n  <A, B>(f: (a: A) => T.Task<B>): (self: TaskOption<A>) => TaskOption<B>\n  <A, B>(self: TaskOption<A>, f: (a: A) => T.Task<B>): TaskOption<B>\n}\n```\n\nAdded in v2.16.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: TaskOption<TaskOption<A>>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n# traversing\n\n## sequenceArray\n\nEquivalent to `ReadonlyArray#sequence(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceArray: <A>(as: readonly TaskOption<A>[]) => TaskOption<readonly A[]>\n```\n\nAdded in v2.10.0\n\n## sequenceSeqArray\n\nEquivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const sequenceSeqArray: <A>(as: readonly TaskOption<A>[]) => TaskOption<readonly A[]>\n```\n\nAdded in v2.10.0\n\n## traverseArray\n\nEquivalent to `ReadonlyArray#traverse(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArray: <A, B>(f: (a: A) => TaskOption<B>) => (as: readonly A[]) => TaskOption<readonly B[]>\n```\n\nAdded in v2.10.0\n\n## traverseArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n\n**Signature**\n\n```ts\nexport declare const traverseArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n) => (as: readonly A[]) => TaskOption<readonly B[]>\n```\n\nAdded in v2.10.0\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n) => (as: readonly A[]) => TaskOption<readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyArrayWithIndexSeq\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndexSeq: <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n) => (as: readonly A[]) => TaskOption<readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n) => (as: ReadonlyNonEmptyArray<A>) => TaskOption<ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndexSeq\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n) => (as: ReadonlyNonEmptyArray<A>) => TaskOption<ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseSeqArray\n\nEquivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArray: <A, B>(\n  f: (a: A) => TaskOption<B>\n) => (as: readonly A[]) => TaskOption<readonly B[]>\n```\n\nAdded in v2.10.0\n\n## traverseSeqArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n\n**Signature**\n\n```ts\nexport declare const traverseSeqArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n) => (as: readonly A[]) => TaskOption<readonly B[]>\n```\n\nAdded in v2.10.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'TaskOption'\n```\n\nAdded in v2.10.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.10.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: TaskOption<readonly []>\n```\n\nAdded in v2.11.0\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(fa: TaskOption<A>) => <B>(fab: TaskOption<(a: A) => B>) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: TaskOption<B>) => <A>(first: TaskOption<A>) => TaskOption<A>\n```\n\nAdded in v2.10.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: TaskOption<B>) => <A>(first: TaskOption<A>) => TaskOption<B>\n```\n\nAdded in v2.10.0\n\n## zero\n\n**Signature**\n\n```ts\nexport declare const zero: <A>() => TaskOption<A>\n```\n\nAdded in v2.10.0\n"
  },
  {
    "path": "docs/modules/TaskThese.ts.md",
    "content": "---\ntitle: TaskThese.ts\nnav_order: 108\nparent: Modules\n---\n\n## TaskThese overview\n\nAdded in v2.4.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [both](#both)\n  - [left](#left)\n  - [leftIO](#leftio)\n  - [leftTask](#lefttask)\n  - [of](#of)\n  - [right](#right)\n  - [rightIO](#rightio)\n  - [rightTask](#righttask)\n- [conversions](#conversions)\n  - [fromEither](#fromeither)\n  - [fromIO](#fromio)\n  - [fromIOEither](#fromioeither)\n  - [fromOption](#fromoption)\n  - [fromTask](#fromtask)\n  - [fromThese](#fromthese)\n- [error handling](#error-handling)\n  - [mapLeft](#mapleft)\n- [instances](#instances)\n  - [Bifunctor](#bifunctor)\n  - [FromEither](#fromeither)\n  - [FromIO](#fromio)\n  - [FromTask](#fromtask)\n  - [FromThese](#fromthese)\n  - [Functor](#functor)\n  - [Pointed](#pointed)\n  - [getApplicative](#getapplicative)\n  - [getApply](#getapply)\n  - [getChain](#getchain)\n  - [getMonad](#getmonad)\n- [lifting](#lifting)\n  - [fromIOK](#fromiok)\n  - [fromOptionK](#fromoptionk)\n  - [fromPredicate](#frompredicate)\n  - [fromTaskK](#fromtaskk)\n  - [fromTheseK](#fromthesek)\n- [mapping](#mapping)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [TaskThese (interface)](#taskthese-interface)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchE](#matche)\n  - [matchEW](#matchew)\n  - [matchW](#matchw)\n- [traversing](#traversing)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyArrayWithIndexSeq](#traversereadonlyarraywithindexseq)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndexSeq](#traversereadonlynonemptyarraywithindexseq)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [swap](#swap)\n  - [toTuple2](#totuple2)\n- [zone of death](#zone-of-death)\n  - [~~bifunctorTaskThese~~](#bifunctortaskthese)\n  - [~~functorTaskThese~~](#functortaskthese)\n  - [~~getSemigroup~~](#getsemigroup)\n  - [~~taskThese~~](#taskthese)\n  - [~~toTuple~~](#totuple)\n\n---\n\n# constructors\n\n## both\n\n**Signature**\n\n```ts\nexport declare const both: <E, A>(e: E, a: A) => TaskThese<E, A>\n```\n\nAdded in v2.4.0\n\n## left\n\n**Signature**\n\n```ts\nexport declare const left: <E = never, A = never>(e: E) => TaskThese<E, A>\n```\n\nAdded in v2.4.0\n\n## leftIO\n\n**Signature**\n\n```ts\nexport declare const leftIO: <E = never, A = never>(me: IO<E>) => TaskThese<E, A>\n```\n\nAdded in v2.4.0\n\n## leftTask\n\n**Signature**\n\n```ts\nexport declare const leftTask: <E = never, A = never>(me: T.Task<E>) => TaskThese<E, A>\n```\n\nAdded in v2.4.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <E = never, A = never>(a: A) => TaskThese<E, A>\n```\n\nAdded in v2.7.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare const right: <E = never, A = never>(a: A) => TaskThese<E, A>\n```\n\nAdded in v2.4.0\n\n## rightIO\n\n**Signature**\n\n```ts\nexport declare const rightIO: <E = never, A = never>(ma: IO<A>) => TaskThese<E, A>\n```\n\nAdded in v2.4.0\n\n## rightTask\n\n**Signature**\n\n```ts\nexport declare const rightTask: <E = never, A = never>(ma: T.Task<A>) => TaskThese<E, A>\n```\n\nAdded in v2.4.0\n\n# conversions\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: <E, A>(fa: Either<E, A>) => TaskThese<E, A>\n```\n\nAdded in v2.10.0\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: <A, E = never>(fa: IO<A>) => TaskThese<E, A>\n```\n\nAdded in v2.7.0\n\n## fromIOEither\n\n**Signature**\n\n```ts\nexport declare const fromIOEither: <E, A>(fa: IOEither<E, A>) => TaskThese<E, A>\n```\n\nAdded in v2.4.0\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => TaskThese<E, A>\n```\n\nAdded in v2.10.0\n\n## fromTask\n\n**Signature**\n\n```ts\nexport declare const fromTask: <A, E = never>(fa: T.Task<A>) => TaskThese<E, A>\n```\n\nAdded in v2.7.0\n\n## fromThese\n\n**Signature**\n\n```ts\nexport declare const fromThese: <E, A>(fa: TH.These<E, A>) => TaskThese<E, A>\n```\n\nAdded in v2.11.0\n\n# error handling\n\n## mapLeft\n\nMap a function over the first type argument of a bifunctor.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: TaskThese<E, A>) => TaskThese<G, A>\n```\n\nAdded in v2.4.0\n\n# instances\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor2<'TaskThese'>\n```\n\nAdded in v2.10.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither2<'TaskThese'>\n```\n\nAdded in v2.10.0\n\n## FromIO\n\n**Signature**\n\n```ts\nexport declare const FromIO: FromIO2<'TaskThese'>\n```\n\nAdded in v2.10.0\n\n## FromTask\n\n**Signature**\n\n```ts\nexport declare const FromTask: FromTask2<'TaskThese'>\n```\n\nAdded in v2.10.0\n\n## FromThese\n\n**Signature**\n\n```ts\nexport declare const FromThese: FromThese2<'TaskThese'>\n```\n\nAdded in v2.11.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'TaskThese'>\n```\n\nAdded in v2.10.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed2<'TaskThese'>\n```\n\nAdded in v2.10.0\n\n## getApplicative\n\n**Signature**\n\n```ts\nexport declare function getApplicative<E>(A: Apply1<T.URI>, S: Semigroup<E>): Applicative2C<URI, E>\n```\n\nAdded in v2.7.0\n\n## getApply\n\n**Signature**\n\n```ts\nexport declare const getApply: <E>(A: Apply1<T.URI>, S: Semigroup<E>) => Apply2C<'TaskThese', E>\n```\n\nAdded in v2.10.0\n\n## getChain\n\n**Signature**\n\n```ts\nexport declare function getChain<E>(S: Semigroup<E>): Chain2C<URI, E>\n```\n\nAdded in v2.10.0\n\n## getMonad\n\n**Signature**\n\n```ts\nexport declare function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> & MonadTask2C<URI, E>\n```\n\nAdded in v2.4.0\n\n# lifting\n\n## fromIOK\n\n**Signature**\n\n```ts\nexport declare const fromIOK: <A extends readonly unknown[], B>(\n  f: (...a: A) => IO<B>\n) => <E = never>(...a: A) => TaskThese<E, B>\n```\n\nAdded in v2.10.0\n\n## fromOptionK\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => TaskThese<E, B>\n```\n\nAdded in v2.10.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => TaskThese<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => TaskThese<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => TaskThese<E, A>\n}\n```\n\nAdded in v2.10.0\n\n## fromTaskK\n\n**Signature**\n\n```ts\nexport declare const fromTaskK: <A extends readonly unknown[], B>(\n  f: (...a: A) => T.Task<B>\n) => <E = never>(...a: A) => TaskThese<E, B>\n```\n\nAdded in v2.10.0\n\n## fromTheseK\n\n**Signature**\n\n```ts\nexport declare const fromTheseK: <A extends readonly unknown[], E, B>(\n  f: (...a: A) => TH.These<E, B>\n) => (...a: A) => TaskThese<E, B>\n```\n\nAdded in v2.11.0\n\n# mapping\n\n## bimap\n\nMap a pair of functions over the two type arguments of the bifunctor.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: TaskThese<E, A>) => TaskThese<G, B>\n```\n\nAdded in v2.4.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: TaskThese<E, (a: A) => B>) => TaskThese<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: TaskThese<E, A>) => TaskThese<E, B>\n```\n\nAdded in v2.4.0\n\n# model\n\n## TaskThese (interface)\n\n**Signature**\n\n```ts\nexport interface TaskThese<E, A> extends Task<These<E, A>> {}\n```\n\nAdded in v2.4.0\n\n# pattern matching\n\n## fold\n\nAlias of [`matchE`](#matche).\n\n**Signature**\n\n```ts\nexport declare const fold: <E, B, A>(\n  onLeft: (e: E) => T.Task<B>,\n  onRight: (a: A) => T.Task<B>,\n  onBoth: (e: E, a: A) => T.Task<B>\n) => (fa: TaskThese<E, A>) => T.Task<B>\n```\n\nAdded in v2.4.0\n\n## foldW\n\nAlias of [`matchEW`](#matchew).\n\n**Signature**\n\n```ts\nexport declare const foldW: <E, B, A, C, D>(\n  onLeft: (e: E) => T.Task<B>,\n  onRight: (a: A) => T.Task<C>,\n  onBoth: (e: E, a: A) => T.Task<D>\n) => (fa: TaskThese<E, A>) => T.Task<B | C | D>\n```\n\nAdded in v2.10.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (fa: TaskThese<E, A>) => T.Task<B>\n```\n\nAdded in v2.10.0\n\n## matchE\n\nThe `E` suffix (short for **E**ffect) means that the handlers return an effect (`Task`).\n\n**Signature**\n\n```ts\nexport declare const matchE: <E, B, A>(\n  onLeft: (e: E) => T.Task<B>,\n  onRight: (a: A) => T.Task<B>,\n  onBoth: (e: E, a: A) => T.Task<B>\n) => (fa: TaskThese<E, A>) => T.Task<B>\n```\n\nAdded in v2.10.0\n\n## matchEW\n\nLess strict version of [`matchE`](#matche).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchEW: <E, B, A, C, D>(\n  onLeft: (e: E) => T.Task<B>,\n  onRight: (a: A) => T.Task<C>,\n  onBoth: (e: E, a: A) => T.Task<D>\n) => (fa: TaskThese<E, A>) => T.Task<B | C | D>\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <E, B, A, C, D>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C,\n  onBoth: (e: E, a: A) => D\n) => (ma: TaskThese<E, A>) => T.Task<B | C | D>\n```\n\nAdded in v2.10.0\n\n# traversing\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(getApplicative(T.ApplicativePar, S))`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <E>(\n  S: Semigroup<E>\n) => <A, B>(f: (index: number, a: A) => TaskThese<E, B>) => (as: readonly A[]) => TaskThese<E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyArrayWithIndexSeq\n\nEquivalent to `ReadonlyArray#traverseWithIndex(getApplicative(T.ApplicativeSeq, S))`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndexSeq: <E>(\n  S: Semigroup<E>\n) => <A, B>(f: (index: number, a: A) => TaskThese<E, B>) => (as: readonly A[]) => TaskThese<E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(T.ApplicativePar, S))`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <E>(\n  S: Semigroup<E>\n) => <A, B>(\n  f: (index: number, a: A) => TaskThese<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => TaskThese<E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndexSeq\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(T.ApplicativeSeq, S))`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <E>(\n  S: Semigroup<E>\n) => <A, B>(\n  f: (index: number, a: A) => TaskThese<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => TaskThese<E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'TaskThese'\n```\n\nAdded in v2.4.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.4.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: TaskThese<never, readonly []>\n```\n\nAdded in v2.11.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare const swap: <E, A>(fa: TaskThese<E, A>) => TaskThese<A, E>\n```\n\nAdded in v2.4.0\n\n## toTuple2\n\n**Signature**\n\n```ts\nexport declare const toTuple2: <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: TaskThese<E, A>) => T.Task<readonly [E, A]>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~bifunctorTaskThese~~\n\nUse [`Bifunctor`](#bifunctor) instead.\n\n**Signature**\n\n```ts\nexport declare const bifunctorTaskThese: Bifunctor2<'TaskThese'>\n```\n\nAdded in v2.7.0\n\n## ~~functorTaskThese~~\n\nUse [`Functor`](#functor) instead.\n\n**Signature**\n\n```ts\nexport declare const functorTaskThese: Functor2<'TaskThese'>\n```\n\nAdded in v2.7.0\n\n## ~~getSemigroup~~\n\nUse [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <E, A>(SE: Semigroup<E>, SA: Semigroup<A>) => Semigroup<TaskThese<E, A>>\n```\n\nAdded in v2.4.0\n\n## ~~taskThese~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `TT.Functor` instead of `TT.taskThese`\n(where `TT` is from `import TT from 'fp-ts/TaskThese'`)\n\n**Signature**\n\n```ts\nexport declare const taskThese: Functor2<'TaskThese'> & Bifunctor2<'TaskThese'>\n```\n\nAdded in v2.4.0\n\n## ~~toTuple~~\n\nUse [`toTuple2`](#totuple2) instead.\n\n**Signature**\n\n```ts\nexport declare const toTuple: <E, A>(e: E, a: A) => (fa: TaskThese<E, A>) => T.Task<[E, A]>\n```\n\nAdded in v2.4.0\n"
  },
  {
    "path": "docs/modules/These.ts.md",
    "content": "---\ntitle: These.ts\nnav_order: 109\nparent: Modules\n---\n\n## These overview\n\nA 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\n- You can think of a computation that has a non-fatal error.\n- You can think of a computation that went as far as it could before erroring.\n- 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\n(description adapted from https://package.elm-lang.org/packages/joneshf/elm-these)\n\nAdapted from https://github.com/purescript-contrib/purescript-these\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [both](#both)\n  - [left](#left)\n  - [leftOrBoth](#leftorboth)\n  - [of](#of)\n  - [right](#right)\n  - [rightOrBoth](#rightorboth)\n- [conversions](#conversions)\n  - [fromOption](#fromoption)\n  - [fromOptions](#fromoptions)\n  - [getLeft](#getleft)\n  - [getLeftOnly](#getleftonly)\n  - [getRight](#getright)\n  - [getRightOnly](#getrightonly)\n  - [toTuple2](#totuple2)\n- [error handling](#error-handling)\n  - [mapLeft](#mapleft)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [Bifunctor](#bifunctor)\n  - [Foldable](#foldable)\n  - [FromEither](#fromeither)\n  - [FromThese](#fromthese)\n  - [Functor](#functor)\n  - [Pointed](#pointed)\n  - [Traversable](#traversable)\n  - [getApplicative](#getapplicative)\n  - [getApply](#getapply)\n  - [getChain](#getchain)\n  - [getEq](#geteq)\n  - [getMonad](#getmonad)\n  - [getSemigroup](#getsemigroup)\n  - [getShow](#getshow)\n- [lifting](#lifting)\n  - [fromOptionK](#fromoptionk)\n  - [fromPredicate](#frompredicate)\n- [mapping](#mapping)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Both (interface)](#both-interface)\n  - [These (type alias)](#these-type-alias)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchW](#matchw)\n- [refinements](#refinements)\n  - [isBoth](#isboth)\n  - [isLeft](#isleft)\n  - [isRight](#isright)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n  - [traverseReadonlyArrayWithIndex](#traversereadonlyarraywithindex)\n  - [traverseReadonlyNonEmptyArrayWithIndex](#traversereadonlynonemptyarraywithindex)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ApT](#apt)\n  - [elem](#elem)\n  - [exists](#exists)\n  - [swap](#swap)\n- [zone of death](#zone-of-death)\n  - [~~these~~](#these)\n  - [~~toTuple~~](#totuple)\n\n---\n\n# constructors\n\n## both\n\n**Signature**\n\n```ts\nexport declare function both<E, A>(left: E, right: A): These<E, A>\n```\n\nAdded in v2.0.0\n\n## left\n\n**Signature**\n\n```ts\nexport declare function left<E = never, A = never>(left: E): These<E, A>\n```\n\nAdded in v2.0.0\n\n## leftOrBoth\n\n**Signature**\n\n```ts\nexport declare function leftOrBoth<E>(e: E): <A>(ma: Option<A>) => These<E, A>\n```\n\n**Example**\n\n```ts\nimport { leftOrBoth, left, both } from 'fp-ts/These'\nimport { none, some } from 'fp-ts/Option'\n\nassert.deepStrictEqual(leftOrBoth('a')(none), left('a'))\nassert.deepStrictEqual(leftOrBoth('a')(some(1)), both('a', 1))\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <E = never, A = never>(right: A) => These<E, A>\n```\n\nAdded in v2.0.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare function right<E = never, A = never>(right: A): These<E, A>\n```\n\nAdded in v2.0.0\n\n## rightOrBoth\n\n**Signature**\n\n```ts\nexport declare function rightOrBoth<A>(a: A): <E>(me: Option<E>) => These<E, A>\n```\n\n**Example**\n\n```ts\nimport { rightOrBoth, right, both } from 'fp-ts/These'\nimport { none, some } from 'fp-ts/Option'\n\nassert.deepStrictEqual(rightOrBoth(1)(none), right(1))\nassert.deepStrictEqual(rightOrBoth(1)(some('a')), both('a', 1))\n```\n\nAdded in v2.0.0\n\n# conversions\n\n## fromOption\n\n**Signature**\n\n```ts\nexport declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => These<E, A>\n```\n\nAdded in v2.10.0\n\n## fromOptions\n\nTakes a pair of `Option`s and attempts to create a `These` from them\n\n**Signature**\n\n```ts\nexport declare const fromOptions: <E, A>(fe: Option<E>, fa: Option<A>) => Option<These<E, A>>\n```\n\n**Example**\n\n```ts\nimport { fromOptions, left, right, both } from 'fp-ts/These'\nimport { none, some } from 'fp-ts/Option'\n\nassert.deepStrictEqual(fromOptions(none, none), none)\nassert.deepStrictEqual(fromOptions(some('a'), none), some(left('a')))\nassert.deepStrictEqual(fromOptions(none, some(1)), some(right(1)))\nassert.deepStrictEqual(fromOptions(some('a'), some(1)), some(both('a', 1)))\n```\n\nAdded in v2.0.0\n\n## getLeft\n\nReturns an `E` value if possible\n\n**Signature**\n\n```ts\nexport declare function getLeft<E, A>(fa: These<E, A>): Option<E>\n```\n\n**Example**\n\n```ts\nimport { getLeft, left, right, both } from 'fp-ts/These'\nimport { none, some } from 'fp-ts/Option'\n\nassert.deepStrictEqual(getLeft(left('a')), some('a'))\nassert.deepStrictEqual(getLeft(right(1)), none)\nassert.deepStrictEqual(getLeft(both('a', 1)), some('a'))\n```\n\nAdded in v2.0.0\n\n## getLeftOnly\n\nReturns the `E` value if and only if the value is constructed with `Left`\n\n**Signature**\n\n```ts\nexport declare function getLeftOnly<E, A>(fa: These<E, A>): Option<E>\n```\n\n**Example**\n\n```ts\nimport { getLeftOnly, left, right, both } from 'fp-ts/These'\nimport { none, some } from 'fp-ts/Option'\n\nassert.deepStrictEqual(getLeftOnly(left('a')), some('a'))\nassert.deepStrictEqual(getLeftOnly(right(1)), none)\nassert.deepStrictEqual(getLeftOnly(both('a', 1)), none)\n```\n\nAdded in v2.0.0\n\n## getRight\n\nReturns an `A` value if possible\n\n**Signature**\n\n```ts\nexport declare function getRight<E, A>(fa: These<E, A>): Option<A>\n```\n\n**Example**\n\n```ts\nimport { getRight, left, right, both } from 'fp-ts/These'\nimport { none, some } from 'fp-ts/Option'\n\nassert.deepStrictEqual(getRight(left('a')), none)\nassert.deepStrictEqual(getRight(right(1)), some(1))\nassert.deepStrictEqual(getRight(both('a', 1)), some(1))\n```\n\nAdded in v2.0.0\n\n## getRightOnly\n\nReturns the `A` value if and only if the value is constructed with `Right`\n\n**Signature**\n\n```ts\nexport declare function getRightOnly<E, A>(fa: These<E, A>): Option<A>\n```\n\n**Example**\n\n```ts\nimport { getRightOnly, left, right, both } from 'fp-ts/These'\nimport { none, some } from 'fp-ts/Option'\n\nassert.deepStrictEqual(getRightOnly(left('a')), none)\nassert.deepStrictEqual(getRightOnly(right(1)), some(1))\nassert.deepStrictEqual(getRightOnly(both('a', 1)), none)\n```\n\nAdded in v2.0.0\n\n## toTuple2\n\n**Signature**\n\n```ts\nexport declare const toTuple2: <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: These<E, A>) => readonly [E, A]\n```\n\n**Example**\n\n```ts\nimport { toTuple2, left, right, both } from 'fp-ts/These'\n\nassert.deepStrictEqual(\n  toTuple2(\n    () => 'a',\n    () => 1\n  )(left('b')),\n  ['b', 1]\n)\nassert.deepStrictEqual(\n  toTuple2(\n    () => 'a',\n    () => 1\n  )(right(2)),\n  ['a', 2]\n)\nassert.deepStrictEqual(\n  toTuple2(\n    () => 'a',\n    () => 1\n  )(both('b', 2)),\n  ['b', 2]\n)\n```\n\nAdded in v2.10.0\n\n# error handling\n\n## mapLeft\n\nMap a function over the first type argument of a bifunctor.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: These<E, A>) => These<G, A>\n```\n\nAdded in v2.0.0\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: These<E, A>) => M\n```\n\nAdded in v2.0.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: These<E, A>) => B\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: These<E, A>) => B\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor2<'These'>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable2<'These'>\n```\n\nAdded in v2.7.0\n\n## FromEither\n\n**Signature**\n\n```ts\nexport declare const FromEither: FromEither2<'These'>\n```\n\nAdded in v2.10.0\n\n## FromThese\n\n**Signature**\n\n```ts\nexport declare const FromThese: FromThese2<'These'>\n```\n\nAdded in v2.11.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'These'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed2<'These'>\n```\n\nAdded in v2.10.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable2<'These'>\n```\n\nAdded in v2.7.0\n\n## getApplicative\n\n**Signature**\n\n```ts\nexport declare function getApplicative<E>(S: Semigroup<E>): Applicative2C<URI, E>\n```\n\nAdded in v2.7.0\n\n## getApply\n\n**Signature**\n\n```ts\nexport declare const getApply: <E>(S: Semigroup<E>) => Apply2C<'These', E>\n```\n\nAdded in v2.10.0\n\n## getChain\n\n**Signature**\n\n```ts\nexport declare function getChain<E>(S: Semigroup<E>): Chain2C<URI, E>\n```\n\nAdded in v2.10.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare function getEq<E, A>(EE: Eq<E>, EA: Eq<A>): Eq<These<E, A>>\n```\n\nAdded in v2.0.0\n\n## getMonad\n\n**Signature**\n\n```ts\nexport declare function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> & MonadThrow2C<URI, E>\n```\n\nAdded in v2.0.0\n\n## getSemigroup\n\n**Signature**\n\n```ts\nexport declare function getSemigroup<E, A>(SE: Semigroup<E>, SA: Semigroup<A>): Semigroup<These<E, A>>\n```\n\nAdded in v2.0.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare function getShow<E, A>(SE: Show<E>, SA: Show<A>): Show<These<E, A>>\n```\n\nAdded in v2.0.0\n\n# lifting\n\n## fromOptionK\n\n**Signature**\n\n```ts\nexport declare const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends readonly unknown[], B>(f: (...a: A) => Option<B>) => (...a: A) => These<E, B>\n```\n\nAdded in v2.10.0\n\n## fromPredicate\n\n**Signature**\n\n```ts\nexport declare const fromPredicate: {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => These<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => These<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => These<E, A>\n}\n```\n\nAdded in v2.13.0\n\n# mapping\n\n## bimap\n\nMap a pair of functions over the two type arguments of the bifunctor.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: These<E, A>) => These<G, B>\n```\n\nAdded in v2.0.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: These<E, (a: A) => B>) => These<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: These<E, A>) => These<E, B>\n```\n\nAdded in v2.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 v2.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 v2.0.0\n\n# pattern matching\n\n## fold\n\nAlias of [`match`](#match).\n\n**Signature**\n\n```ts\nexport declare const fold: <E, A, B>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (fa: These<E, A>) => B\n```\n\nAdded in v2.0.0\n\n## foldW\n\nAlias of [`matchW`](#matchw).\n\n**Signature**\n\n```ts\nexport declare const foldW: <E, B, A, C, D>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C,\n  onBoth: (e: E, a: A) => D\n) => (fa: These<E, A>) => B | C | D\n```\n\nAdded in v2.10.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare const match: <E, A, B>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (fa: These<E, A>) => B\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <E, B, A, C, D>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C,\n  onBoth: (e: E, a: A) => D\n) => (fa: These<E, A>) => B | C | D\n```\n\nAdded in v2.10.0\n\n# refinements\n\n## isBoth\n\nReturns `true` if the these is an instance of `Both`, `false` otherwise\n\n**Signature**\n\n```ts\nexport declare function isBoth<E, A>(fa: These<E, A>): fa is Both<E, A>\n```\n\nAdded in v2.0.0\n\n## isLeft\n\nReturns `true` if the these is an instance of `Left`, `false` otherwise\n\n**Signature**\n\n```ts\nexport declare const isLeft: <E>(fa: These<E, unknown>) => fa is Left<E>\n```\n\nAdded in v2.0.0\n\n## isRight\n\nReturns `true` if the these is an instance of `Right`, `false` otherwise\n\n**Signature**\n\n```ts\nexport declare const isRight: <A>(fa: These<unknown, A>) => fa is Right<A>\n```\n\nAdded in v2.0.0\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence2<'These'>\n```\n\nAdded in v2.6.3\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse2<'These'>\n```\n\nAdded in v2.6.3\n\n## traverseReadonlyArrayWithIndex\n\nEquivalent to `ReadonlyArray#traverseWithIndex(getApplicative(S))`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyArrayWithIndex: <E>(\n  S: Semigroup<E>\n) => <A, B>(f: (index: number, a: A) => These<E, B>) => (as: readonly A[]) => These<E, readonly B[]>\n```\n\nAdded in v2.11.0\n\n## traverseReadonlyNonEmptyArrayWithIndex\n\nEquivalent to `ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(S))`.\n\n**Signature**\n\n```ts\nexport declare const traverseReadonlyNonEmptyArrayWithIndex: <E>(\n  S: Semigroup<E>\n) => <A, B>(\n  f: (index: number, a: A) => These<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => These<E, ReadonlyNonEmptyArray<B>>\n```\n\nAdded in v2.11.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'These'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ApT\n\n**Signature**\n\n```ts\nexport declare const ApT: These<never, readonly []>\n```\n\nAdded in v2.11.0\n\n## elem\n\n**Signature**\n\n```ts\nexport declare const elem: <A>(E: Eq<A>) => (a: A) => <E>(ma: These<E, A>) => boolean\n```\n\nAdded in v2.11.0\n\n## exists\n\n**Signature**\n\n```ts\nexport declare const exists: <A>(predicate: Predicate<A>) => (ma: These<unknown, A>) => boolean\n```\n\nAdded in v2.11.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare const swap: <E, A>(fa: These<E, A>) => These<A, E>\n```\n\nAdded in v2.4.0\n\n# zone of death\n\n## ~~these~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.these`\n(where `T` is from `import T from 'fp-ts/These'`)\n\n**Signature**\n\n```ts\nexport declare const these: Functor2<'These'> & Bifunctor2<'These'> & Foldable2<'These'> & Traversable2<'These'>\n```\n\nAdded in v2.0.0\n\n## ~~toTuple~~\n\nUse [`toTuple2`](#totuple2) instead.\n\n**Signature**\n\n```ts\nexport declare const toTuple: <E, A>(e: E, a: A) => (fa: These<E, A>) => [E, A]\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/TheseT.ts.md",
    "content": "---\ntitle: TheseT.ts\nnav_order: 110\nparent: Modules\n---\n\n## TheseT overview\n\nAdded in v2.4.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [utils](#utils)\n  - [ap](#ap)\n  - [bimap](#bimap)\n  - [both](#both)\n  - [chain](#chain)\n  - [left](#left)\n  - [leftF](#leftf)\n  - [map](#map)\n  - [mapLeft](#mapleft)\n  - [match](#match)\n  - [matchE](#matche)\n  - [right](#right)\n  - [rightF](#rightf)\n  - [swap](#swap)\n  - [toTuple2](#totuple2)\n- [zone of death](#zone-of-death)\n  - [~~TheseM1~~ (interface)](#thesem1-interface)\n  - [~~TheseM2~~ (interface)](#thesem2-interface)\n  - [~~TheseM~~ (interface)](#thesem-interface)\n  - [~~TheseT1~~ (type alias)](#theset1-type-alias)\n  - [~~TheseT2~~ (type alias)](#theset2-type-alias)\n  - [~~TheseT~~ (interface)](#theset-interface)\n  - [~~getTheseM~~](#getthesem)\n\n---\n\n# utils\n\n## ap\n\n**Signature**\n\n```ts\nexport declare function ap<F extends URIS3, E>(\n  F: Apply3<F>,\n  S: Semigroup<E>\n): <R, FE, A>(\n  fa: Kind3<F, R, FE, These<E, A>>\n) => <B>(fab: Kind3<F, R, FE, These<E, (a: A) => B>>) => Kind3<F, R, FE, These<E, B>>\nexport declare function ap<F extends URIS3, FE, E>(\n  F: Apply3C<F, FE>,\n  S: Semigroup<E>\n): <R, A>(\n  fa: Kind3<F, R, FE, These<E, A>>\n) => <B>(fab: Kind3<F, R, FE, These<E, (a: A) => B>>) => Kind3<F, R, FE, These<E, B>>\nexport declare function ap<F extends URIS2, E>(\n  F: Apply2<F>,\n  S: Semigroup<E>\n): <FE, A>(fa: Kind2<F, FE, These<E, A>>) => <B>(fab: Kind2<F, FE, These<E, (a: A) => B>>) => Kind2<F, FE, These<E, B>>\nexport declare function ap<F extends URIS2, FE, E>(\n  F: Apply2C<F, FE>,\n  S: Semigroup<E>\n): <A>(fa: Kind2<F, FE, These<E, A>>) => <B>(fab: Kind2<F, FE, These<E, (a: A) => B>>) => Kind2<F, FE, These<E, B>>\nexport declare function ap<F extends URIS, E>(\n  F: Apply1<F>,\n  S: Semigroup<E>\n): <A>(fa: Kind<F, These<E, A>>) => <B>(fab: Kind<F, These<E, (a: A) => B>>) => Kind<F, These<E, B>>\nexport declare function ap<F, E>(\n  F: Apply<F>,\n  S: Semigroup<E>\n): <A>(fa: HKT<F, These<E, A>>) => <B>(fab: HKT<F, These<E, (a: A) => B>>) => HKT<F, These<E, B>>\n```\n\nAdded in v2.10.0\n\n## bimap\n\n**Signature**\n\n```ts\nexport declare function bimap<F extends URIS3>(\n  F: Functor3<F>\n): <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R, FE>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, B>>\nexport declare function bimap<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, B>>\nexport declare function bimap<F extends URIS2>(\n  F: Functor2<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <FE>(fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, B>>\nexport declare function bimap<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, B>>\nexport declare function bimap<F extends URIS>(\n  F: Functor1<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind<F, These<E, A>>) => Kind<F, These<G, B>>\nexport declare function bimap<F>(\n  F: Functor<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: HKT<F, These<E, A>>) => HKT<F, These<G, B>>\n```\n\nAdded in v2.10.0\n\n## both\n\n**Signature**\n\n```ts\nexport declare function both<F extends URIS3>(F: Pointed3<F>): <E, A, S, R>(e: E, a: A) => Kind3<F, S, R, These<E, A>>\nexport declare function both<F extends URIS3, R>(F: Pointed3C<F, R>): <E, A>(e: E, a: A) => Kind3<F, R, R, These<E, A>>\nexport declare function both<F extends URIS2>(F: Pointed2<F>): <E, A, R>(e: E, a: A) => Kind2<F, R, These<E, A>>\nexport declare function both<F extends URIS2, R>(F: Pointed2C<F, R>): <E, A>(e: E, a: A) => Kind2<F, R, These<E, A>>\nexport declare function both<F extends URIS>(F: Pointed1<F>): <E, A>(e: E, a: A) => Kind<F, These<E, A>>\nexport declare function both<F>(F: Pointed<F>): <E, A = never>(e: E, a: A) => HKT<F, These<E, A>>\n```\n\nAdded in v2.10.0\n\n## chain\n\n**Signature**\n\n```ts\nexport declare function chain<M extends URIS3, E>(\n  M: Monad3<M>,\n  S: Semigroup<E>\n): <A, R, ME, B>(\n  f: (a: A) => Kind3<M, R, ME, These<E, B>>\n) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, These<E, B>>\nexport declare function chain<M extends URIS3, ME, E>(\n  M: Monad3C<M, ME>,\n  S: Semigroup<E>\n): <A, R, B>(\n  f: (a: A) => Kind3<M, R, ME, These<E, B>>\n) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, These<E, B>>\nexport declare function chain<M extends URIS2, E>(\n  M: Monad2<M>,\n  S: Semigroup<E>\n): <A, ME, B>(f: (a: A) => Kind2<M, ME, These<E, B>>) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, These<E, B>>\nexport declare function chain<M extends URIS2, ME, E>(\n  M: Monad2C<M, ME>,\n  S: Semigroup<E>\n): <A, B>(f: (a: A) => Kind2<M, ME, These<E, B>>) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, These<E, B>>\nexport declare function chain<M extends URIS, E>(\n  M: Monad1<M>,\n  S: Semigroup<E>\n): <A, B>(f: (a: A) => Kind<M, These<E, B>>) => (ma: Kind<M, These<E, A>>) => Kind<M, These<E, B>>\nexport declare function chain<M, E>(\n  M: Monad<M>,\n  S: Semigroup<E>\n): <A, B>(f: (a: A) => HKT<M, These<E, B>>) => (ma: HKT<M, These<E, A>>) => HKT<M, These<E, B>>\n```\n\nAdded in v2.10.0\n\n## left\n\n**Signature**\n\n```ts\nexport declare function left<F extends URIS3>(\n  F: Pointed3<F>\n): <E, R, FE, A = never>(e: E) => Kind3<F, R, FE, These<E, A>>\nexport declare function left<F extends URIS3, FE>(\n  F: Pointed3C<F, FE>\n): <E, R, A = never>(e: E) => Kind3<F, R, FE, These<E, A>>\nexport declare function left<F extends URIS2>(F: Pointed2<F>): <E, FE, A = never>(e: E) => Kind2<F, FE, These<E, A>>\nexport declare function left<F extends URIS2, FE>(\n  F: Pointed2C<F, FE>\n): <E, A = never>(e: E) => Kind2<F, FE, These<E, A>>\nexport declare function left<F extends URIS>(F: Pointed1<F>): <E, A = never>(e: E) => Kind<F, These<E, A>>\nexport declare function left<F>(F: Pointed<F>): <E, A = never>(e: E) => HKT<F, These<E, A>>\n```\n\nAdded in v2.10.0\n\n## leftF\n\n**Signature**\n\n```ts\nexport declare function leftF<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, These<E, A>>\nexport declare function leftF<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, These<E, A>>\nexport declare function leftF<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, These<E, A>>\nexport declare function leftF<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, These<E, A>>\nexport declare function leftF<F extends URIS>(F: Functor1<F>): <E, A = never>(fe: Kind<F, E>) => Kind<F, These<E, A>>\nexport declare function leftF<F>(F: Functor<F>): <E, A = never>(fe: HKT<F, E>) => HKT<F, These<E, A>>\n```\n\nAdded in v2.10.0\n\n## map\n\n**Signature**\n\n```ts\nexport declare function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, FE, E>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<E, B>>\nexport declare function map<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<E, B>>\nexport declare function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <FE, E>(fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<E, B>>\nexport declare function map<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<E, B>>\nexport declare function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind<F, These<E, A>>) => Kind<F, These<E, B>>\nexport declare function map<F>(\n  F: Functor<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, These<E, A>>) => HKT<F, These<E, B>>\n```\n\nAdded in v2.10.0\n\n## mapLeft\n\n**Signature**\n\n```ts\nexport declare function mapLeft<F extends URIS3>(\n  F: Functor3<F>\n): <E, G>(f: (e: E) => G) => <R, FE, A>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, A>>\nexport declare function mapLeft<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, G>(f: (e: E) => G) => <R, A>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, A>>\nexport declare function mapLeft<F extends URIS2>(\n  F: Functor2<F>\n): <E, G>(f: (e: E) => G) => <FE, A>(fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, A>>\nexport declare function mapLeft<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, G>(f: (e: E) => G) => <A>(fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, A>>\nexport declare function mapLeft<F extends URIS>(\n  F: Functor1<F>\n): <E, G>(f: (e: E) => G) => <A>(fea: Kind<F, These<E, A>>) => Kind<F, These<G, A>>\nexport declare function mapLeft<F>(\n  F: Functor<F>\n): <E, G>(f: (e: E) => G) => <A>(fea: HKT<F, These<E, A>>) => HKT<F, These<G, A>>\n```\n\nAdded in v2.10.0\n\n## match\n\n**Signature**\n\n```ts\nexport declare function match<F extends URIS3>(\n  F: Functor3<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => <S, R>(ma: Kind3<F, S, R, These<E, A>>) => Kind3<F, S, R, B>\nexport declare function match<F extends URIS3, R>(\n  F: Functor3C<F, R>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => <S>(ma: Kind3<F, S, R, These<E, A>>) => Kind3<F, S, R, B>\nexport declare function match<F extends URIS2>(\n  F: Functor2<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => <R>(ma: Kind2<F, R, These<E, A>>) => Kind2<F, R, B>\nexport declare function match<M extends URIS2, R>(\n  F: Functor2C<M, R>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (ma: Kind2<M, R, These<E, A>>) => Kind2<M, R, B>\nexport declare function match<F extends URIS>(\n  F: Functor1<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (ma: Kind<F, These<E, A>>) => Kind<F, B>\nexport declare function match<F>(\n  F: Functor<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (ma: HKT<F, These<E, A>>) => HKT<F, B>\n```\n\nAdded in v2.10.0\n\n## matchE\n\n**Signature**\n\n```ts\nexport declare function matchE<M extends URIS3>(\n  M: Chain3<M>\n): <E, R, ME, B, A>(\n  onLeft: (e: E) => Kind3<M, R, ME, B>,\n  onRight: (a: A) => Kind3<M, R, ME, B>,\n  onBoth: (e: E, a: A) => Kind3<M, R, ME, B>\n) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, B>\nexport declare function matchE<M extends URIS3, ME>(\n  M: Chain3C<M, ME>\n): <E, R, B, A>(\n  onLeft: (e: E) => Kind3<M, R, ME, B>,\n  onRight: (a: A) => Kind3<M, R, ME, B>,\n  onBoth: (e: E, a: A) => Kind3<M, R, ME, B>\n) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, B>\nexport declare function matchE<M extends URIS2>(\n  M: Chain2<M>\n): <E, ME, B, A>(\n  onLeft: (e: E) => Kind2<M, ME, B>,\n  onRight: (a: A) => Kind2<M, ME, B>,\n  onBoth: (e: E, a: A) => Kind2<M, ME, B>\n) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, B>\nexport declare function matchE<M extends URIS2, ME>(\n  M: Chain2C<M, ME>\n): <E, B, A>(\n  onLeft: (e: E) => Kind2<M, ME, B>,\n  onRight: (a: A) => Kind2<M, ME, B>,\n  onBoth: (e: E, a: A) => Kind2<M, ME, B>\n) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, B>\nexport declare function matchE<M extends URIS>(\n  M: Chain1<M>\n): <E, B, A>(\n  onLeft: (e: E) => Kind<M, B>,\n  onRight: (a: A) => Kind<M, B>,\n  onBoth: (e: E, a: A) => Kind<M, B>\n) => (ma: Kind<M, These<E, A>>) => Kind<M, B>\nexport declare function matchE<M>(\n  M: Chain<M>\n): <E, B, A>(\n  onLeft: (e: E) => HKT<M, B>,\n  onRight: (a: A) => HKT<M, B>,\n  onBoth: (e: E, a: A) => HKT<M, B>\n) => (ma: HKT<M, These<E, A>>) => HKT<M, B>\n```\n\nAdded in v2.10.0\n\n## right\n\n**Signature**\n\n```ts\nexport declare function right<F extends URIS3>(\n  F: Pointed3<F>\n): <A, R, FE, E = never>(a: A) => Kind3<F, R, FE, These<E, A>>\nexport declare function right<F extends URIS3, FE>(\n  F: Pointed3C<F, FE>\n): <A, R, E = never>(a: A) => Kind3<F, R, FE, These<E, A>>\nexport declare function right<F extends URIS2>(F: Pointed2<F>): <A, FE, E = never>(a: A) => Kind2<F, FE, These<E, A>>\nexport declare function right<F extends URIS2, FE>(\n  F: Pointed2C<F, FE>\n): <A, E = never>(a: A) => Kind2<F, FE, These<E, A>>\nexport declare function right<F extends URIS>(F: Pointed1<F>): <A, E = never>(a: A) => Kind<F, These<E, A>>\nexport declare function right<F>(F: Pointed<F>): <A, E = never>(a: A) => HKT<F, These<E, A>>\n```\n\nAdded in v2.10.0\n\n## rightF\n\n**Signature**\n\n```ts\nexport declare function rightF<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, These<E, A>>\nexport declare function rightF<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, These<E, A>>\nexport declare function rightF<F extends URIS2>(\n  F: Functor2<F>\n): <FE, A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, These<E, A>>\nexport declare function rightF<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, These<E, A>>\nexport declare function rightF<F extends URIS>(F: Functor1<F>): <A, E = never>(fa: Kind<F, A>) => Kind<F, These<E, A>>\nexport declare function rightF<F>(F: Functor<F>): <A, E = never>(fa: HKT<F, A>) => HKT<F, These<E, A>>\n```\n\nAdded in v2.10.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare function swap<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A>(ma: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<A, E>>\nexport declare function swap<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A>(ma: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<A, E>>\nexport declare function swap<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A>(ma: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<A, E>>\nexport declare function swap<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A>(ma: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<A, E>>\nexport declare function swap<F extends URIS>(F: Functor1<F>): <E, A>(ma: Kind<F, These<E, A>>) => Kind<F, These<A, E>>\nexport declare function swap<F>(F: Functor<F>): <E, A>(ma: HKT<F, These<E, A>>) => HKT<F, These<A, E>>\n```\n\nAdded in v2.10.0\n\n## toTuple2\n\n**Signature**\n\n```ts\nexport declare function toTuple2<F extends URIS3>(\n  F: Functor3<F>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => <R, FE>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, readonly [E, A]>\nexport declare function toTuple2<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => <R>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, readonly [E, A]>\nexport declare function toTuple2<F extends URIS2>(\n  F: Functor2<F>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => <FE>(fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, readonly [E, A]>\nexport declare function toTuple2<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, readonly [E, A]>\nexport declare function toTuple2<F extends URIS>(\n  F: Functor1<F>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: Kind<F, These<E, A>>) => Kind<F, readonly [E, A]>\nexport declare function toTuple2<F>(\n  F: Functor<F>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: HKT<F, These<E, A>>) => HKT<F, readonly [E, A]>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~TheseM1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface TheseM1<M extends URIS> {\n  readonly map: <E, A, B>(fa: TheseT1<M, E, A>, f: (a: A) => B) => TheseT1<M, E, B>\n  readonly bimap: <E, A, N, B>(fa: TheseT1<M, E, A>, f: (e: E) => N, g: (a: A) => B) => TheseT1<M, N, B>\n  readonly mapLeft: <E, A, N>(fa: TheseT1<M, E, A>, f: (e: E) => N) => TheseT1<M, N, A>\n  readonly fold: <E, A, R>(\n    fa: TheseT1<M, E, A>,\n    onLeft: (e: E) => Kind<M, R>,\n    onRight: (a: A) => Kind<M, R>,\n    onBoth: (e: E, a: A) => Kind<M, R>\n  ) => Kind<M, R>\n  readonly swap: <E, A>(fa: TheseT1<M, E, A>) => TheseT1<M, A, E>\n  readonly rightM: <E, A>(ma: Kind<M, A>) => TheseT1<M, E, A>\n  readonly leftM: <E, A>(me: Kind<M, E>) => TheseT1<M, E, A>\n  readonly left: <E, A>(e: E) => TheseT1<M, E, A>\n  readonly right: <E, A>(a: A) => TheseT1<M, E, A>\n  readonly both: <E, A>(e: E, a: A) => TheseT1<M, E, A>\n  readonly toTuple: <E, A>(fa: TheseT1<M, E, A>, e: E, a: A) => Kind<M, [E, A]>\n  readonly getMonad: <E>(S: Semigroup<E>) => {\n    readonly _E: E\n    readonly map: <A, B>(ma: TheseT1<M, E, A>, f: (a: A) => B) => TheseT1<M, E, B>\n    readonly of: <A>(a: A) => TheseT1<M, E, A>\n    readonly ap: <A, B>(mab: TheseT1<M, E, (a: A) => B>, ma: TheseT1<M, E, A>) => TheseT1<M, E, B>\n    readonly chain: <A, B>(ma: TheseT1<M, E, A>, f: (a: A) => TheseT1<M, E, B>) => TheseT1<M, E, B>\n  }\n}\n```\n\nAdded in v2.4.0\n\n## ~~TheseM2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface TheseM2<M extends URIS2> {\n  readonly map: <R, E, A, B>(fa: TheseT2<M, R, E, A>, f: (a: A) => B) => TheseT2<M, R, E, B>\n  readonly bimap: <R, E, A, N, B>(fa: TheseT2<M, R, E, A>, f: (e: E) => N, g: (a: A) => B) => TheseT2<M, R, N, B>\n  readonly mapLeft: <R, E, A, N>(fa: TheseT2<M, R, E, A>, f: (e: E) => N) => TheseT2<M, R, N, A>\n  readonly fold: <R, E, A, B>(\n    fa: TheseT2<M, R, E, A>,\n    onLeft: (e: E) => Kind2<M, R, B>,\n    onRight: (a: A) => Kind2<M, R, B>,\n    onBoth: (e: E, a: A) => Kind2<M, R, B>\n  ) => Kind2<M, R, B>\n  readonly swap: <R, E, A>(fa: TheseT2<M, R, E, A>) => TheseT2<M, R, A, E>\n  readonly rightM: <R, E, A>(ma: Kind2<M, R, A>) => TheseT2<M, R, E, A>\n  readonly leftM: <R, E, A>(me: Kind2<M, R, E>) => TheseT2<M, R, E, A>\n  readonly left: <R, E, A>(e: E) => TheseT2<M, R, E, A>\n  readonly right: <R, E, A>(a: A) => TheseT2<M, R, E, A>\n  readonly both: <R, E, A>(e: E, a: A) => TheseT2<M, R, E, A>\n  readonly toTuple: <R, E, A>(fa: TheseT2<M, R, E, A>, e: E, a: A) => Kind2<M, R, [E, A]>\n  readonly getMonad: <E>(S: Semigroup<E>) => {\n    readonly _E: E\n    readonly map: <R, A, B>(ma: TheseT2<M, R, E, A>, f: (a: A) => B) => TheseT2<M, R, E, B>\n    readonly of: <R, A>(a: A) => TheseT2<M, R, E, A>\n    readonly ap: <R, A, B>(mab: TheseT2<M, R, E, (a: A) => B>, ma: TheseT2<M, R, E, A>) => TheseT2<M, R, E, B>\n    readonly chain: <R, A, B>(ma: TheseT2<M, R, E, A>, f: (a: A) => TheseT2<M, R, E, B>) => TheseT2<M, R, E, B>\n  }\n}\n```\n\nAdded in v2.4.0\n\n## ~~TheseM~~ (interface)\n\n**Signature**\n\n```ts\nexport interface TheseM<M> {\n  readonly map: <E, A, B>(fa: TheseT<M, E, A>, f: (a: A) => B) => TheseT<M, E, B>\n  readonly bimap: <E, A, N, B>(fa: TheseT<M, E, A>, f: (e: E) => N, g: (a: A) => B) => TheseT<M, N, B>\n  readonly mapLeft: <E, A, N>(fa: TheseT<M, E, A>, f: (e: E) => N) => TheseT<M, N, A>\n  readonly fold: <E, A, R>(\n    fa: TheseT<M, E, A>,\n    onLeft: (e: E) => HKT<M, R>,\n    onRight: (a: A) => HKT<M, R>,\n    onBoth: (e: E, a: A) => HKT<M, R>\n  ) => HKT<M, R>\n  readonly swap: <E, A>(fa: TheseT<M, E, A>) => TheseT<M, A, E>\n  readonly rightM: <E, A>(ma: HKT<M, A>) => TheseT<M, E, A>\n  readonly leftM: <E, A>(me: HKT<M, E>) => TheseT<M, E, A>\n  readonly left: <E, A>(e: E) => TheseT<M, E, A>\n  readonly right: <E, A>(a: A) => TheseT<M, E, A>\n  readonly both: <E, A>(e: E, a: A) => TheseT<M, E, A>\n  readonly toTuple: <E, A>(fa: TheseT<M, E, A>, e: E, a: A) => HKT<M, [E, A]>\n  readonly getMonad: <E>(S: Semigroup<E>) => {\n    readonly _E: E\n    readonly map: <A, B>(ma: TheseT<M, E, A>, f: (a: A) => B) => TheseT<M, E, B>\n    readonly of: <A>(a: A) => TheseT<M, E, A>\n    readonly ap: <A, B>(mab: TheseT<M, E, (a: A) => B>, ma: TheseT<M, E, A>) => TheseT<M, E, B>\n    readonly chain: <A, B>(ma: TheseT<M, E, A>, f: (a: A) => TheseT<M, E, B>) => TheseT<M, E, B>\n  }\n}\n```\n\nAdded in v2.4.0\n\n## ~~TheseT1~~ (type alias)\n\n**Signature**\n\n```ts\nexport type TheseT1<M extends URIS, E, A> = Kind<M, These<E, A>>\n```\n\nAdded in v2.4.0\n\n## ~~TheseT2~~ (type alias)\n\n**Signature**\n\n```ts\nexport type TheseT2<M extends URIS2, R, E, A> = Kind2<M, R, These<E, A>>\n```\n\nAdded in v2.4.0\n\n## ~~TheseT~~ (interface)\n\n**Signature**\n\n```ts\nexport interface TheseT<M, E, A> extends HKT<M, These<E, A>> {}\n```\n\nAdded in v2.4.0\n\n## ~~getTheseM~~\n\n**Signature**\n\n```ts\nexport declare function getTheseM<M extends URIS2>(M: Monad2<M>): TheseM2<M>\nexport declare function getTheseM<M extends URIS>(M: Monad1<M>): TheseM1<M>\nexport declare function getTheseM<M>(M: Monad<M>): TheseM<M>\n```\n\nAdded in v2.4.0\n"
  },
  {
    "path": "docs/modules/Traced.ts.md",
    "content": "---\ntitle: Traced.ts\nnav_order: 111\nparent: Modules\n---\n\n## Traced overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [Functor](#functor)\n  - [getComonad](#getcomonad)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Traced (interface)](#traced-interface)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [censor](#censor)\n  - [listen](#listen)\n  - [listens](#listens)\n  - [tracks](#tracks)\n- [zone of death](#zone-of-death)\n  - [~~traced~~](#traced)\n\n---\n\n# instances\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'Traced'>\n```\n\nAdded in v2.7.0\n\n## getComonad\n\n**Signature**\n\n```ts\nexport declare function getComonad<P>(monoid: Monoid<P>): Comonad2C<URI, P>\n```\n\nAdded in v2.0.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: Traced<E, (a: A) => B>) => Traced<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Traced<E, A>) => Traced<E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## Traced (interface)\n\n**Signature**\n\n```ts\nexport interface Traced<P, A> {\n  (p: P): A\n}\n```\n\nAdded in v2.0.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Traced'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## censor\n\nApply a function to the current position\n\n**Signature**\n\n```ts\nexport declare function censor<P>(f: (p: P) => P): <A>(wa: Traced<P, A>) => Traced<P, A>\n```\n\nAdded in v2.0.0\n\n## listen\n\nGet the current position\n\n**Signature**\n\n```ts\nexport declare function listen<P, A>(wa: Traced<P, A>): Traced<P, [A, P]>\n```\n\nAdded in v2.0.0\n\n## listens\n\nGet a value which depends on the current position\n\n**Signature**\n\n```ts\nexport declare function listens<P, B>(f: (p: P) => B): <A>(wa: Traced<P, A>) => Traced<P, [A, B]>\n```\n\nAdded in v2.0.0\n\n## tracks\n\nExtracts a value at a relative position which depends on the current value.\n\n**Signature**\n\n```ts\nexport declare function tracks<P, A>(M: Monoid<P>, f: (a: A) => P): (wa: Traced<P, A>) => A\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~traced~~\n\nUse [`Functor`](#functor) instead.\n\n**Signature**\n\n```ts\nexport declare const traced: Functor2<'Traced'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Traversable.ts.md",
    "content": "---\ntitle: Traversable.ts\nnav_order: 112\nparent: Modules\n---\n\n## Traversable overview\n\n`Traversable` represents data structures which can be _traversed_ accumulating results and effects in some\n`Applicative` functor.\n\n- `traverse` runs an action for every element in a data structure, and accumulates the results.\n- `sequence` runs the actions _contained_ in a data structure, and accumulates the results.\n\nThe `traverse` and `sequence` functions should be compatible in the following sense:\n\n- `traverse(A)(xs, f) <-> sequence(A)(A.map(xs, f))`\n- `sequence(A)(xs) <-> traverse(A)(xs, identity)`\n\nwhere `A` is an `Applicative` instance\n\n`Traversable` instances should also be compatible with the corresponding `Foldable` instances, in the following sense:\n\n```ts\nimport { getApplicative, make } from 'fp-ts/Const'\n\nconst A = getApplicative(M)\n\nfoldMap(M)(xs, f) = traverse(A)(xs, (a) => make(f(a)))\n```\n\nwhere `M` is a `Monoid` instance\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Traversable (interface)](#traversable-interface)\n  - [Traversable1 (interface)](#traversable1-interface)\n  - [Traversable2 (interface)](#traversable2-interface)\n  - [Traversable2C (interface)](#traversable2c-interface)\n  - [Traversable3 (interface)](#traversable3-interface)\n- [utils](#utils)\n  - [PipeableTraverse1 (interface)](#pipeabletraverse1-interface)\n  - [PipeableTraverse2 (interface)](#pipeabletraverse2-interface)\n  - [Sequence (interface)](#sequence-interface)\n  - [Sequence1 (interface)](#sequence1-interface)\n  - [Sequence2 (interface)](#sequence2-interface)\n  - [Sequence2C (interface)](#sequence2c-interface)\n  - [Sequence3 (interface)](#sequence3-interface)\n  - [Traverse (interface)](#traverse-interface)\n  - [Traverse1 (interface)](#traverse1-interface)\n  - [Traverse2 (interface)](#traverse2-interface)\n  - [Traverse2C (interface)](#traverse2c-interface)\n  - [Traverse3 (interface)](#traverse3-interface)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n- [zone of death](#zone-of-death)\n  - [~~SequenceComposition11~~ (interface)](#sequencecomposition11-interface)\n  - [~~TraversableComposition11~~ (interface)](#traversablecomposition11-interface)\n  - [~~TraversableComposition~~ (interface)](#traversablecomposition-interface)\n  - [~~TraverseComposition11~~ (interface)](#traversecomposition11-interface)\n  - [~~getTraversableComposition~~](#gettraversablecomposition)\n\n---\n\n# model\n\n## Traversable (interface)\n\n**Signature**\n\n```ts\nexport interface Traversable<T> extends Functor<T>, Foldable<T> {\n  /**\n   * Runs an action for every element in a data structure and accumulates the results\n   */\n  readonly traverse: Traverse<T>\n  readonly sequence: Sequence<T>\n}\n```\n\nAdded in v2.0.0\n\n## Traversable1 (interface)\n\n**Signature**\n\n```ts\nexport interface Traversable1<T extends URIS> extends Functor1<T>, Foldable1<T> {\n  readonly traverse: Traverse1<T>\n  readonly sequence: Sequence1<T>\n}\n```\n\nAdded in v2.0.0\n\n## Traversable2 (interface)\n\n**Signature**\n\n```ts\nexport interface Traversable2<T extends URIS2> extends Functor2<T>, Foldable2<T> {\n  readonly traverse: Traverse2<T>\n  readonly sequence: Sequence2<T>\n}\n```\n\nAdded in v2.0.0\n\n## Traversable2C (interface)\n\n**Signature**\n\n```ts\nexport interface Traversable2C<T extends URIS2, TL> extends Functor2C<T, TL>, Foldable2C<T, TL> {\n  readonly traverse: Traverse2C<T, TL>\n  readonly sequence: Sequence2C<T, TL>\n}\n```\n\nAdded in v2.0.0\n\n## Traversable3 (interface)\n\n**Signature**\n\n```ts\nexport interface Traversable3<T extends URIS3> extends Functor3<T>, Foldable3<T> {\n  readonly traverse: Traverse3<T>\n  readonly sequence: Sequence3<T>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## PipeableTraverse1 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableTraverse1<T extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B>(\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => (ta: Kind<T, A>) => Kind3<F, FR, FE, Kind<T, B>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <A, FR, B>(\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => (ta: Kind<T, A>) => Kind3<F, FR, FE, Kind<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => (ta: Kind<T, A>) => Kind2<F, FE, Kind<T, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => (ta: Kind<T, A>) => Kind2<F, FE, Kind<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(f: (a: A) => Kind<F, B>) => (ta: Kind<T, A>) => Kind<F, Kind<T, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, B>) => (ta: Kind<T, A>) => HKT<F, Kind<T, B>>\n}\n```\n\nAdded in v2.6.3\n\n## PipeableTraverse2 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableTraverse2<T extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B>(\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind3<F, FR, FE, Kind2<T, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind<F, Kind2<T, TE, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, B>) => <TE>(ta: Kind2<T, TE, A>) => HKT<F, Kind2<T, TE, B>>\n}\n```\n\nAdded in v2.6.3\n\n## Sequence (interface)\n\n**Signature**\n\n```ts\nexport interface Sequence<T> {\n  <F extends URIS4>(F: Applicative4<F>): <S, R, E, A>(ta: HKT<T, Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, HKT<T, A>>\n  <F extends URIS3>(F: Applicative3<F>): <R, E, A>(ta: HKT<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, HKT<T, A>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <R, A>(ta: HKT<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, HKT<T, A>>\n  <F extends URIS2>(F: Applicative2<F>): <E, A>(ta: HKT<T, Kind2<F, E, A>>) => Kind2<F, E, HKT<T, A>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(ta: HKT<T, Kind2<F, E, A>>) => Kind2<F, E, HKT<T, A>>\n  <F extends URIS>(F: Applicative1<F>): <A>(ta: HKT<T, Kind<F, A>>) => Kind<F, HKT<T, A>>\n  <F>(F: Applicative<F>): <A>(ta: HKT<T, HKT<F, A>>) => HKT<F, HKT<T, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Sequence1 (interface)\n\n**Signature**\n\n```ts\nexport interface Sequence1<T extends URIS> {\n  <F extends URIS4>(F: Applicative4<F>): <S, R, E, A>(\n    ta: Kind<T, Kind4<F, S, R, E, A>>\n  ) => Kind4<F, S, R, E, Kind<T, A>>\n  <F extends URIS3>(F: Applicative3<F>): <R, E, A>(ta: Kind<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, Kind<T, A>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <R, A>(ta: Kind<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, Kind<T, A>>\n  <F extends URIS2>(F: Applicative2<F>): <E, A>(ta: Kind<T, Kind2<F, E, A>>) => Kind2<F, E, Kind<T, A>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(ta: Kind<T, Kind2<F, E, A>>) => Kind2<F, E, Kind<T, A>>\n  <F extends URIS>(F: Applicative1<F>): <A>(ta: Kind<T, Kind<F, A>>) => Kind<F, Kind<T, A>>\n  <F>(F: Applicative<F>): <A>(ta: Kind<T, HKT<F, A>>) => HKT<F, Kind<T, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Sequence2 (interface)\n\n**Signature**\n\n```ts\nexport interface Sequence2<T extends URIS2> {\n  <F extends URIS4>(F: Applicative4<F>): <TE, S, R, FE, A>(\n    ta: Kind2<T, TE, Kind4<F, S, R, FE, A>>\n  ) => Kind4<F, S, R, FE, Kind2<T, TE, A>>\n  <F extends URIS3>(F: Applicative3<F>): <TE, R, FE, A>(\n    ta: Kind2<T, TE, Kind3<F, R, FE, A>>\n  ) => Kind3<F, R, FE, Kind2<T, TE, A>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TE, R, A>(\n    ta: Kind2<T, TE, Kind3<F, R, FE, A>>\n  ) => Kind3<F, R, FE, Kind2<T, TE, A>>\n  <F extends URIS2>(F: Applicative2<F>): <TE, FE, A>(ta: Kind2<T, TE, Kind2<F, FE, A>>) => Kind2<F, FE, Kind2<T, TE, A>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <TE, A>(\n    ta: Kind2<T, TE, Kind2<F, FE, A>>\n  ) => Kind2<F, FE, Kind2<T, TE, A>>\n  <F extends URIS>(F: Applicative1<F>): <E, A>(ta: Kind2<T, E, Kind<F, A>>) => Kind<F, Kind2<T, E, A>>\n  <F>(F: Applicative<F>): <E, A>(ta: Kind2<T, E, HKT<F, A>>) => HKT<F, Kind2<T, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Sequence2C (interface)\n\n**Signature**\n\n```ts\nexport interface Sequence2C<T extends URIS2, E> {\n  <F extends URIS4>(F: Applicative4<F>): <S, R, FE, A>(\n    ta: Kind2<T, E, Kind4<F, S, R, FE, A>>\n  ) => Kind4<F, S, R, FE, Kind2<T, E, A>>\n  <F extends URIS3>(F: Applicative3<F>): <R, FE, A>(\n    ta: Kind2<T, E, Kind3<F, R, FE, A>>\n  ) => Kind3<F, R, FE, Kind2<T, E, A>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <R, A>(\n    ta: Kind2<T, E, Kind3<F, R, FE, A>>\n  ) => Kind3<F, R, FE, Kind2<T, E, A>>\n  <F extends URIS2>(F: Applicative2<F>): <FE, A>(ta: Kind2<T, E, Kind2<F, FE, A>>) => Kind2<F, FE, Kind2<T, E, A>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A>(ta: Kind2<T, E, Kind2<F, FE, A>>) => Kind2<F, FE, Kind2<T, E, A>>\n  <F extends URIS>(F: Applicative1<F>): <A>(ta: Kind2<T, E, Kind<F, A>>) => Kind<F, Kind2<T, E, A>>\n  <F>(F: Applicative<F>): <A>(ta: Kind2<T, E, HKT<F, A>>) => HKT<F, Kind2<T, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Sequence3 (interface)\n\n**Signature**\n\n```ts\nexport interface Sequence3<T extends URIS3> {\n  <F extends URIS4>(F: Applicative4<F>): <TR, TE, S, FR, FE, A>(\n    ta: Kind3<T, TR, TE, Kind4<F, S, FR, FE, A>>\n  ) => Kind4<F, S, FR, FE, Kind3<T, TR, TE, A>>\n  <F extends URIS3>(F: Applicative3<F>): <TR, TE, FR, FE, A>(\n    ta: Kind3<T, TR, TE, Kind3<F, FR, FE, A>>\n  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, A>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TR, TE, FR, A>(\n    ta: Kind3<T, TR, TE, Kind3<F, FR, FE, A>>\n  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, A>>\n  <F extends URIS2>(F: Applicative2<F>): <R, TE, FE, A>(\n    ta: Kind3<T, R, TE, Kind2<F, FE, A>>\n  ) => Kind2<F, FE, Kind3<T, R, TE, A>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, TE, A>(\n    ta: Kind3<T, R, TE, Kind2<F, FE, A>>\n  ) => Kind2<F, FE, Kind3<T, R, TE, A>>\n  <F extends URIS>(F: Applicative1<F>): <R, E, A>(ta: Kind3<T, R, E, Kind<F, A>>) => Kind<F, Kind3<T, R, E, A>>\n  <F>(F: Applicative<F>): <R, E, A>(ta: Kind3<T, R, E, HKT<F, A>>) => HKT<F, Kind3<T, R, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## Traverse (interface)\n\n**Signature**\n\n```ts\nexport interface Traverse<T> {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, E, B>(\n    ta: HKT<T, A>,\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => Kind4<F, S, R, E, HKT<T, B>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: HKT<T, A>,\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, HKT<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: HKT<T, A>,\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, HKT<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(ta: HKT<T, A>, f: (a: A) => Kind2<F, E, B>) => Kind2<F, E, HKT<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: HKT<T, A>,\n    f: (a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, HKT<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: HKT<T, A>, f: (a: A) => Kind<F, B>) => Kind<F, HKT<T, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: HKT<T, A>, f: (a: A) => HKT<F, B>) => HKT<F, HKT<T, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Traverse1 (interface)\n\n**Signature**\n\n```ts\nexport interface Traverse1<T extends URIS> {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, E, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => Kind4<F, S, R, E, Kind<T, B>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind<T, A>, f: (a: A) => Kind<F, B>) => Kind<F, Kind<T, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind<T, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind<T, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Traverse2 (interface)\n\n**Signature**\n\n```ts\nexport interface Traverse2<T extends URIS2> {\n  <F extends URIS4>(F: Applicative4<F>): <TE, A, S, R, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind4<F, S, R, FE, B>\n  ) => Kind4<F, S, R, FE, Kind2<T, TE, B>>\n  <F extends URIS3>(F: Applicative3<F>): <TE, A, R, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, TE, B>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TE, A, R, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <TE, A, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <TE, A, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <E, A, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind<F, B>\n  ) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <E, A, B>(ta: Kind2<T, E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Traverse2C (interface)\n\n**Signature**\n\n```ts\nexport interface Traverse2C<T extends URIS2, E> {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind4<F, S, R, FE, B>\n  ) => Kind4<F, S, R, FE, Kind2<T, E, B>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, E, B>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <A, R, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, E, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, E, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, E, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind2<T, E, A>, f: (a: A) => Kind<F, B>) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind2<T, E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Traverse3 (interface)\n\n**Signature**\n\n```ts\nexport interface Traverse3<T extends URIS3> {\n  <F extends URIS4>(F: Applicative4<F>): <TR, TE, A, S, FR, FE, B>(\n    ta: Kind3<T, TR, TE, A>,\n    f: (a: A) => Kind4<F, S, FR, FE, B>\n  ) => Kind4<F, S, FR, FE, Kind3<T, TR, TE, B>>\n  <F extends URIS3>(F: Applicative3<F>): <TR, TE, A, FR, FE, B>(\n    ta: Kind3<T, TR, TE, A>,\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, B>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TR, TE, A, FR, B>(\n    ta: Kind3<T, TR, TE, A>,\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <TR, A, TE, FE, B>(\n    ta: Kind3<T, TR, TE, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind3<T, TR, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, TE, A, B>(\n    ta: Kind3<T, R, TE, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind3<T, R, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <R, E, A, B>(\n    ta: Kind3<T, R, E, A>,\n    f: (a: A) => Kind<F, B>\n  ) => Kind<F, Kind3<T, R, E, B>>\n  <F>(F: Applicative<F>): <R, E, A, B>(ta: Kind3<T, R, E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind3<T, R, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## sequence\n\n`sequence` composition.\n\n**Signature**\n\n```ts\nexport declare function sequence<T extends URIS, G extends URIS2>(\n  T: Traversable1<T>,\n  G: Traversable2<G>\n): {\n  <F extends URIS4>(F: Applicative4<F>): <GE, S, R, FE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind4<F, S, R, FE, A>>>\n  ) => Kind4<F, S, R, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS3>(F: Applicative3<F>): <GE, R, FE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind3<F, R, FE, A>>>\n  ) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <GE, R, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind3<F, R, FE, A>>>\n  ) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS2>(F: Applicative2<F>): <GE, FE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind2<F, FE, A>>>\n  ) => Kind2<F, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <GE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind2<F, FE, A>>>\n  ) => Kind2<F, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS>(F: Applicative1<F>): <GE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind<F, A>>>\n  ) => Kind<F, Kind<T, Kind2<G, GE, A>>>\n  <F>(F: Applicative<F>): <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>>\n}\nexport declare function sequence<T extends URIS, G extends URIS>(\n  T: Traversable1<T>,\n  G: Traversable1<G>\n): {\n  <F extends URIS4>(F: Applicative4<F>): <S, R, E, A>(\n    tgfa: Kind<T, Kind<G, Kind4<F, S, R, E, A>>>\n  ) => Kind4<F, S, R, E, Kind<T, Kind<G, A>>>\n  <F extends URIS3>(F: Applicative3<F>): <R, E, A>(\n    tgfa: Kind<T, Kind<G, Kind3<F, R, E, A>>>\n  ) => Kind3<F, R, E, Kind<T, Kind<G, A>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <R, A>(\n    tgfa: Kind<T, Kind<G, Kind3<F, R, E, A>>>\n  ) => Kind3<F, R, E, Kind<T, Kind<G, A>>>\n  <F extends URIS2>(F: Applicative2<F>): <E, A>(\n    tgfa: Kind<T, Kind<G, Kind2<F, E, A>>>\n  ) => Kind2<F, E, Kind<T, Kind<G, A>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(\n    tgfa: Kind<T, Kind<G, Kind2<F, E, A>>>\n  ) => Kind2<F, E, Kind<T, Kind<G, A>>>\n  <F extends URIS>(F: Applicative1<F>): <A>(tgfa: Kind<T, Kind<G, Kind<F, A>>>) => Kind<F, Kind<T, Kind<G, A>>>\n  <F>(F: Applicative<F>): <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>>\n}\nexport declare function sequence<T, G>(\n  T: Traversable<T>,\n  G: Traversable<G>\n): <F>(F: Applicative<F>) => <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>>\n```\n\nAdded in v2.10.0\n\n## traverse\n\n`traverse` composition.\n\n**Signature**\n\n```ts\nexport declare function traverse<T extends URIS, G extends URIS2>(\n  T: Traversable1<T>,\n  G: Traversable2<G>\n): {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, FE, B>(\n    f: (a: A) => Kind4<F, S, R, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind4<F, S, R, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <A, R, B>(\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind2<F, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind2<F, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind<F, Kind<T, Kind2<G, GE, B>>>\n  <F>(F: Applicative<F>): <A, B>(\n    f: (a: A) => HKT<F, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => HKT<F, Kind<T, Kind2<G, GE, B>>>\n}\nexport declare function traverse<T extends URIS, G extends URIS>(\n  T: Traversable1<T>,\n  G: Traversable1<G>\n): {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, E, B>(\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind4<F, S, R, E, Kind<T, Kind<G, B>>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind3<F, R, E, Kind<T, Kind<G, B>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind3<F, R, E, Kind<T, Kind<G, B>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    f: (a: A) => Kind2<F, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind2<F, E, Kind<T, Kind<G, B>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    f: (a: A) => Kind2<F, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind2<F, E, Kind<T, Kind<G, B>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind<F, Kind<T, Kind<G, B>>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, B>) => (tga: Kind<T, Kind<G, A>>) => HKT<F, Kind<T, Kind<G, B>>>\n}\nexport declare function traverse<T, G>(\n  T: Traversable<T>,\n  G: Traversable<G>\n): <F>(F: Applicative<F>) => <A, B>(f: (a: A) => HKT<F, B>) => (tga: HKT<T, HKT<G, A>>) => HKT<F, HKT<T, HKT<G, B>>>\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~SequenceComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface SequenceComposition11<F extends URIS, G extends URIS> {\n  <H extends URIS3>(H: Applicative3<H>): <R, E, A>(\n    fga: Kind<F, Kind<G, Kind3<H, R, E, A>>>\n  ) => Kind3<H, R, E, Kind<F, Kind<G, A>>>\n  <H extends URIS2>(H: Applicative2<H>): <E, A>(\n    fga: Kind<F, Kind<G, Kind2<H, E, A>>>\n  ) => Kind2<H, E, Kind<F, Kind<G, A>>>\n  <H extends URIS2, E>(H: Applicative2C<H, E>): <A>(\n    fga: Kind<F, Kind<G, Kind2<H, E, A>>>\n  ) => Kind2<H, E, Kind<F, Kind<G, A>>>\n  <H extends URIS>(H: Applicative1<H>): <A>(fga: Kind<F, Kind<G, Kind<H, A>>>) => Kind<H, Kind<F, Kind<G, A>>>\n  <H>(H: Applicative<H>): <A>(fga: Kind<F, Kind<G, HKT<H, A>>>) => HKT<H, Kind<F, Kind<G, A>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~TraversableComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface TraversableComposition11<F extends URIS, G extends URIS>\n  extends FoldableComposition11<F, G>,\n    FunctorComposition11<F, G> {\n  readonly traverse: TraverseComposition11<F, G>\n  readonly sequence: SequenceComposition11<F, G>\n}\n```\n\nAdded in v2.0.0\n\n## ~~TraversableComposition~~ (interface)\n\n**Signature**\n\n```ts\nexport interface TraversableComposition<F, G> extends FoldableComposition<F, G>, FunctorComposition<F, G> {\n  readonly traverse: <H>(\n    H: Applicative<H>\n  ) => <A, B>(fga: HKT<F, HKT<G, A>>, f: (a: A) => HKT<H, B>) => HKT<H, HKT<F, HKT<G, B>>>\n  readonly sequence: <H>(H: Applicative<H>) => <A>(fga: HKT<F, HKT<G, HKT<H, A>>>) => HKT<H, HKT<F, HKT<G, A>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~TraverseComposition11~~ (interface)\n\n**Signature**\n\n```ts\nexport interface TraverseComposition11<F extends URIS, G extends URIS> {\n  <H extends URIS3>(H: Applicative3<H>): <R, E, A, B>(\n    fga: Kind<F, Kind<G, A>>,\n    f: (a: A) => Kind3<H, R, E, B>\n  ) => Kind3<H, R, E, Kind<F, Kind<G, B>>>\n  <H extends URIS2>(H: Applicative2<H>): <E, A, B>(\n    fga: Kind<F, Kind<G, A>>,\n    f: (a: A) => Kind2<H, E, B>\n  ) => Kind2<H, E, Kind<F, Kind<G, B>>>\n  <H extends URIS2, E>(H: Applicative2C<H, E>): <A, B>(\n    fga: Kind<F, Kind<G, A>>,\n    f: (a: A) => Kind2<H, E, B>\n  ) => Kind2<H, E, Kind<F, Kind<G, B>>>\n  <H extends URIS>(H: Applicative1<H>): <A, B>(\n    fga: Kind<F, Kind<G, A>>,\n    f: (a: A) => Kind<H, B>\n  ) => Kind<H, Kind<F, Kind<G, B>>>\n  <H>(H: Applicative<H>): <A, B>(fga: Kind<F, Kind<G, A>>, f: (a: A) => HKT<H, B>) => HKT<H, Kind<F, Kind<G, B>>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~getTraversableComposition~~\n\nUse\n\n- [`traverse`](#traverse)\n- [`sequence`](#sequence)\n\ninstead.\n\n**Signature**\n\n```ts\nexport declare function getTraversableComposition<F extends URIS, G extends URIS>(\n  F: Traversable1<F>,\n  G: Traversable1<G>\n): TraversableComposition11<F, G>\nexport declare function getTraversableComposition<F, G>(\n  F: Traversable<F>,\n  G: Traversable<G>\n): TraversableComposition<F, G>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/TraversableWithIndex.ts.md",
    "content": "---\ntitle: TraversableWithIndex.ts\nnav_order: 113\nparent: Modules\n---\n\n## TraversableWithIndex overview\n\nA `Traversable` with an additional index.\nA `TraversableWithIndex` instance must be compatible with its `Traversable` instance\n\n```ts\ntraverse(F)(ta, f) = traverseWithIndex(F)(ta, (_, a) => f(a))\n```\n\nwith its `FoldableWithIndex` instance\n\n```ts\nfoldMapWithIndex(M)(ta, f) = traverseWithIndex(getApplicative(M))(ta, (i, a) => new Const(f(i, a))).value\n```\n\nand with its `FunctorWithIndex` instance\n\n```purescript\nmapWithIndex(ta, f) = traverseWithIndex(identity)(ta, (i, a) => new Identity(f(i, a))).value\n```\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [utils](#utils)\n  - [PipeableTraverseWithIndex1 (interface)](#pipeabletraversewithindex1-interface)\n  - [PipeableTraverseWithIndex2 (interface)](#pipeabletraversewithindex2-interface)\n  - [TraversableWithIndex (interface)](#traversablewithindex-interface)\n  - [TraversableWithIndex1 (interface)](#traversablewithindex1-interface)\n  - [TraversableWithIndex2 (interface)](#traversablewithindex2-interface)\n  - [TraversableWithIndex2C (interface)](#traversablewithindex2c-interface)\n  - [TraverseWithIndex (interface)](#traversewithindex-interface)\n  - [TraverseWithIndex1 (interface)](#traversewithindex1-interface)\n  - [TraverseWithIndex2 (interface)](#traversewithindex2-interface)\n  - [TraverseWithIndex2C (interface)](#traversewithindex2c-interface)\n\n---\n\n# utils\n\n## PipeableTraverseWithIndex1 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableTraverseWithIndex1<T extends URIS, I> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => (ta: Kind<T, A>) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => (ta: Kind<T, A>) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => (ta: Kind<T, A>) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => (ta: Kind<T, A>) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(f: (i: I, a: A) => Kind<F, B>) => (ta: Kind<T, A>) => Kind<F, Kind<T, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (i: I, a: A) => HKT<F, B>) => (ta: Kind<T, A>) => HKT<F, Kind<T, B>>\n}\n```\n\nAdded in v2.6.3\n\n## PipeableTraverseWithIndex2 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableTraverseWithIndex2<T extends URIS2, I> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    f: (i: I, a: A) => Kind3<F, R, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind3<F, R, FE, Kind2<T, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (i: I, a: A) => Kind<F, B>\n  ) => <E>(ta: Kind2<T, E, A>) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (i: I, a: A) => HKT<F, B>) => <E>(ta: Kind2<T, E, A>) => HKT<F, Kind2<T, E, B>>\n}\n```\n\nAdded in v2.6.3\n\n## TraversableWithIndex (interface)\n\n**Signature**\n\n```ts\nexport interface TraversableWithIndex<T, I> extends FunctorWithIndex<T, I>, FoldableWithIndex<T, I>, Traversable<T> {\n  readonly traverseWithIndex: TraverseWithIndex<T, I>\n}\n```\n\nAdded in v2.0.0\n\n## TraversableWithIndex1 (interface)\n\n**Signature**\n\n```ts\nexport interface TraversableWithIndex1<T extends URIS, I>\n  extends FunctorWithIndex1<T, I>,\n    FoldableWithIndex1<T, I>,\n    Traversable1<T> {\n  readonly traverseWithIndex: TraverseWithIndex1<T, I>\n}\n```\n\nAdded in v2.0.0\n\n## TraversableWithIndex2 (interface)\n\n**Signature**\n\n```ts\nexport interface TraversableWithIndex2<T extends URIS2, I>\n  extends FunctorWithIndex2<T, I>,\n    FoldableWithIndex2<T, I>,\n    Traversable2<T> {\n  readonly traverseWithIndex: TraverseWithIndex2<T, I>\n}\n```\n\nAdded in v2.0.0\n\n## TraversableWithIndex2C (interface)\n\n**Signature**\n\n```ts\nexport interface TraversableWithIndex2C<T extends URIS2, I, E>\n  extends FunctorWithIndex2C<T, I, E>,\n    FoldableWithIndex2C<T, I, E>,\n    Traversable2C<T, E> {\n  readonly traverseWithIndex: TraverseWithIndex2C<T, I, E>\n}\n```\n\nAdded in v2.0.0\n\n## TraverseWithIndex (interface)\n\n**Signature**\n\n```ts\nexport interface TraverseWithIndex<T, I> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: HKT<T, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, HKT<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: HKT<T, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, HKT<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: HKT<T, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, HKT<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: HKT<T, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, HKT<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: HKT<T, A>, f: (i: I, a: A) => Kind<F, B>) => Kind<F, HKT<T, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: HKT<T, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, HKT<T, B>>\n}\n```\n\nAdded in v2.0.0\n\n## TraverseWithIndex1 (interface)\n\n**Signature**\n\n```ts\nexport interface TraverseWithIndex1<T extends URIS, I> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: Kind<T, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: Kind<T, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: Kind<T, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: Kind<T, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind<T, A>, f: (i: I, a: A) => Kind<F, B>) => Kind<F, Kind<T, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind<T, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, Kind<T, B>>\n}\n```\n\nAdded in v2.0.0\n\n## TraverseWithIndex2 (interface)\n\n**Signature**\n\n```ts\nexport interface TraverseWithIndex2<T extends URIS2, I> {\n  <F extends URIS3>(F: Applicative3<F>): <TE, A, R, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (i: I, a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <TE, A, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <TE, A, B>(\n    ta: Kind2<T, TE, A>,\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <E, A, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind<F, B>\n  ) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <E, A, B>(ta: Kind2<T, E, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## TraverseWithIndex2C (interface)\n\n**Signature**\n\n```ts\nexport interface TraverseWithIndex2C<T extends URIS2, I, E> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, E, B>>\n  <F extends URIS3>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind2<T, E, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, E, B>>\n  <F extends URIS2>(F: Applicative2C<F, E>): <A, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind2<T, E, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind<F, B>\n  ) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind2<T, E, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Tree.ts.md",
    "content": "---\ntitle: Tree.ts\nnav_order: 114\nparent: Modules\n---\n\n## Tree overview\n\nMulti-way trees (aka rose trees) and forests, where a forest is\n\n```ts\ntype Forest<A> = Array<Tree<A>>\n```\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [Extract](#extract)\n  - [extract](#extract)\n- [constructors](#constructors)\n  - [make](#make)\n  - [of](#of)\n  - [unfoldForest](#unfoldforest)\n  - [unfoldForestM](#unfoldforestm)\n  - [unfoldTree](#unfoldtree)\n  - [unfoldTreeM](#unfoldtreem)\n- [do notation](#do-notation)\n  - [Do](#do)\n  - [apS](#aps)\n  - [bind](#bind)\n  - [bindTo](#bindto)\n  - [let](#let)\n- [folding](#folding)\n  - [fold](#fold)\n  - [foldMap](#foldmap)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [Applicative](#applicative)\n  - [Apply](#apply)\n  - [Chain](#chain)\n  - [Comonad](#comonad)\n  - [Foldable](#foldable)\n  - [Functor](#functor)\n  - [Monad](#monad)\n  - [Pointed](#pointed)\n  - [Traversable](#traversable)\n  - [getEq](#geteq)\n  - [getShow](#getshow)\n- [legacy](#legacy)\n  - [chain](#chain)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Forest (type alias)](#forest-type-alias)\n  - [Tree (interface)](#tree-interface)\n- [sequencing](#sequencing)\n  - [flatMap](#flatmap)\n  - [flatten](#flatten)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [ap](#ap)\n  - [apFirst](#apfirst)\n  - [apSecond](#apsecond)\n  - [chainFirst](#chainfirst)\n  - [drawForest](#drawforest)\n  - [drawTree](#drawtree)\n  - [duplicate](#duplicate)\n  - [elem](#elem)\n  - [exists](#exists)\n  - [extend](#extend)\n- [zone of death](#zone-of-death)\n  - [~~tree~~](#tree)\n\n---\n\n# Extract\n\n## extract\n\n**Signature**\n\n```ts\nexport declare const extract: <A>(wa: Tree<A>) => A\n```\n\nAdded in v2.6.2\n\n# constructors\n\n## make\n\n**Signature**\n\n```ts\nexport declare function make<A>(value: A, forest: Forest<A> = []): Tree<A>\n```\n\nAdded in v2.0.0\n\n## of\n\n**Signature**\n\n```ts\nexport declare const of: <A>(a: A) => Tree<A>\n```\n\nAdded in v2.7.0\n\n## unfoldForest\n\nBuild a (possibly infinite) forest from a list of seed values in breadth-first order.\n\n**Signature**\n\n```ts\nexport declare function unfoldForest<A, B>(bs: Array<B>, f: (b: B) => [A, Array<B>]): Forest<A>\n```\n\nAdded in v2.0.0\n\n## unfoldForestM\n\nMonadic forest builder, in depth-first order\n\n**Signature**\n\n```ts\nexport declare function unfoldForestM<M extends URIS4>(\n  M: Monad4<M>\n): <S, R, E, A, B>(bs: Array<B>, f: (b: B) => Kind4<M, S, R, E, [A, Array<B>]>) => Kind4<M, S, R, E, Forest<A>>\nexport declare function unfoldForestM<M extends URIS3>(\n  M: Monad3<M>\n): <R, E, A, B>(bs: Array<B>, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Forest<A>>\nexport declare function unfoldForestM<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <R, A, B>(bs: Array<B>, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Forest<A>>\nexport declare function unfoldForestM<M extends URIS2>(\n  M: Monad2<M>\n): <R, E, B>(bs: Array<B>, f: (b: B) => Kind2<M, R, [E, Array<B>]>) => Kind2<M, R, Forest<E>>\nexport declare function unfoldForestM<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(bs: Array<B>, f: (b: B) => Kind2<M, E, [A, Array<B>]>) => Kind2<M, E, Forest<A>>\nexport declare function unfoldForestM<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(bs: Array<B>, f: (b: B) => Kind<M, [A, Array<B>]>) => Kind<M, Forest<A>>\nexport declare function unfoldForestM<M>(\n  M: MonadHKT<M>\n): <A, B>(bs: Array<B>, f: (b: B) => HKT<M, [A, Array<B>]>) => HKT<M, Forest<A>>\n```\n\nAdded in v2.0.0\n\n## unfoldTree\n\nBuild a (possibly infinite) tree from a seed value in breadth-first order.\n\n**Signature**\n\n```ts\nexport declare function unfoldTree<A, B>(b: B, f: (b: B) => [A, Array<B>]): Tree<A>\n```\n\nAdded in v2.0.0\n\n## unfoldTreeM\n\nMonadic tree builder, in depth-first order\n\n**Signature**\n\n```ts\nexport declare function unfoldTreeM<M extends URIS4>(\n  M: Monad4<M>\n): <S, R, E, A, B>(b: B, f: (b: B) => Kind4<M, S, R, E, [A, Array<B>]>) => Kind4<M, S, R, E, Tree<A>>\nexport declare function unfoldTreeM<M extends URIS3>(\n  M: Monad3<M>\n): <R, E, A, B>(b: B, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Tree<A>>\nexport declare function unfoldTreeM<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <R, A, B>(b: B, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Tree<A>>\nexport declare function unfoldTreeM<M extends URIS2>(\n  M: Monad2<M>\n): <E, A, B>(b: B, f: (b: B) => Kind2<M, E, [A, Array<B>]>) => Kind2<M, E, Tree<A>>\nexport declare function unfoldTreeM<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(b: B, f: (b: B) => Kind2<M, E, [A, Array<B>]>) => Kind2<M, E, Tree<A>>\nexport declare function unfoldTreeM<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(b: B, f: (b: B) => Kind<M, [A, Array<B>]>) => Kind<M, Tree<A>>\nexport declare function unfoldTreeM<M>(\n  M: MonadHKT<M>\n): <A, B>(b: B, f: (b: B) => HKT<M, [A, Array<B>]>) => HKT<M, Tree<A>>\n```\n\nAdded in v2.0.0\n\n# do notation\n\n## Do\n\n**Signature**\n\n```ts\nexport declare const Do: Tree<{}>\n```\n\nAdded in v2.9.0\n\n## apS\n\n**Signature**\n\n```ts\nexport declare const apS: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: Tree<B>\n) => (fa: Tree<A>) => Tree<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bind\n\n**Signature**\n\n```ts\nexport declare const bind: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Tree<B>\n) => (ma: Tree<A>) => Tree<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.8.0\n\n## bindTo\n\n**Signature**\n\n```ts\nexport declare const bindTo: <N>(name: N) => <A>(fa: Tree<A>) => Tree<{ readonly [K in N]: A }>\n```\n\nAdded in v2.8.0\n\n## let\n\n**Signature**\n\n```ts\nexport declare const let: <N, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: Tree<A>) => Tree<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>\n```\n\nAdded in v2.13.0\n\n# folding\n\n## fold\n\nFold a tree into a \"summary\" value in depth-first order.\n\nFor each node in the tree, apply `f` to the `value` and the result of applying `f` to each `forest`.\n\nThis is also known as the catamorphism on trees.\n\n**Signature**\n\n```ts\nexport declare function fold<A, B>(f: (a: A, bs: Array<B>) => B): (tree: Tree<A>) => B\n```\n\n**Example**\n\n```ts\nimport { fold, make } from 'fp-ts/Tree'\nimport { concatAll } from 'fp-ts/Monoid'\nimport { MonoidSum } from 'fp-ts/number'\n\nconst t = make(1, [make(2), make(3)])\n\nconst sum = concatAll(MonoidSum)\n\n// Sum the values in a tree:\nassert.deepStrictEqual(fold((a: number, bs: Array<number>) => a + sum(bs))(t), 6)\n\n// Find the maximum value in the tree:\nassert.deepStrictEqual(fold((a: number, bs: Array<number>) => bs.reduce((b, acc) => Math.max(b, acc), a))(t), 3)\n\n// Count the number of leaves in the tree:\nassert.deepStrictEqual(fold((_: number, bs: Array<number>) => (bs.length === 0 ? 1 : sum(bs)))(t), 2)\n```\n\nAdded in v2.6.0\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Tree<A>) => M\n```\n\nAdded in v2.0.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Tree<A>) => B\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Tree<A>) => B\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Applicative\n\n**Signature**\n\n```ts\nexport declare const Applicative: Applicative1<'Tree'>\n```\n\nAdded in v2.7.0\n\n## Apply\n\n**Signature**\n\n```ts\nexport declare const Apply: Apply1<'Tree'>\n```\n\nAdded in v2.10.0\n\n## Chain\n\n**Signature**\n\n```ts\nexport declare const Chain: Chain1<'Tree'>\n```\n\nAdded in v2.10.0\n\n## Comonad\n\n**Signature**\n\n```ts\nexport declare const Comonad: Comonad1<'Tree'>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable1<'Tree'>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor1<'Tree'>\n```\n\nAdded in v2.7.0\n\n## Monad\n\n**Signature**\n\n```ts\nexport declare const Monad: Monad1<'Tree'>\n```\n\nAdded in v2.7.0\n\n## Pointed\n\n**Signature**\n\n```ts\nexport declare const Pointed: Pointed1<'Tree'>\n```\n\nAdded in v2.10.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable1<'Tree'>\n```\n\nAdded in v2.7.0\n\n## getEq\n\n**Signature**\n\n```ts\nexport declare function getEq<A>(E: Eq<A>): Eq<Tree<A>>\n```\n\nAdded in v2.0.0\n\n## getShow\n\n**Signature**\n\n```ts\nexport declare function getShow<A>(S: Show<A>): Show<Tree<A>>\n```\n\nAdded in v2.0.0\n\n# legacy\n\n## chain\n\nAlias of `flatMap`.\n\n**Signature**\n\n```ts\nexport declare const chain: <A, B>(f: (a: A) => Tree<B>) => (ma: Tree<A>) => Tree<B>\n```\n\nAdded in v2.0.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <B>(fab: Tree<(a: A) => B>) => Tree<B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => (fa: Tree<A>) => Tree<B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## Forest (type alias)\n\n**Signature**\n\n```ts\nexport type Forest<A> = Array<Tree<A>>\n```\n\nAdded in v2.0.0\n\n## Tree (interface)\n\n**Signature**\n\n```ts\nexport interface Tree<A> {\n  readonly value: A\n  readonly forest: Forest<A>\n}\n```\n\nAdded in v2.0.0\n\n# sequencing\n\n## flatMap\n\n**Signature**\n\n```ts\nexport declare const flatMap: {\n  <A, B>(f: (a: A) => Tree<B>): (ma: Tree<A>) => Tree<B>\n  <A, B>(ma: Tree<A>, f: (a: A) => Tree<B>): Tree<B>\n}\n```\n\nAdded in v2.14.0\n\n## flatten\n\n**Signature**\n\n```ts\nexport declare const flatten: <A>(mma: Tree<Tree<A>>) => Tree<A>\n```\n\nAdded in v2.0.0\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence1<'Tree'>\n```\n\nAdded in v2.6.3\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse1<'Tree'>\n```\n\nAdded in v2.6.3\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Tree'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## ap\n\n**Signature**\n\n```ts\nexport declare const ap: <A>(fa: Tree<A>) => <B>(fab: Tree<(a: A) => B>) => Tree<B>\n```\n\nAdded in v2.0.0\n\n## apFirst\n\nCombine two effectful actions, keeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const apFirst: <B>(second: Tree<B>) => <A>(first: Tree<A>) => Tree<A>\n```\n\nAdded in v2.0.0\n\n## apSecond\n\nCombine two effectful actions, keeping only the result of the second.\n\n**Signature**\n\n```ts\nexport declare const apSecond: <B>(second: Tree<B>) => <A>(first: Tree<A>) => Tree<B>\n```\n\nAdded in v2.0.0\n\n## chainFirst\n\nComposes computations in sequence, using the return value of one computation to determine the next computation and\nkeeping only the result of the first.\n\n**Signature**\n\n```ts\nexport declare const chainFirst: <A, B>(f: (a: A) => Tree<B>) => (first: Tree<A>) => Tree<A>\n```\n\nAdded in v2.0.0\n\n## drawForest\n\nNeat 2-dimensional drawing of a forest\n\n**Signature**\n\n```ts\nexport declare function drawForest(forest: Forest<string>): string\n```\n\nAdded in v2.0.0\n\n## drawTree\n\nNeat 2-dimensional drawing of a tree\n\n**Signature**\n\n```ts\nexport declare function drawTree(tree: Tree<string>): string\n```\n\n**Example**\n\n```ts\nimport { make, drawTree } from 'fp-ts/Tree'\n\nconst fa = make('a', [make('b'), make('c'), make('d', [make('e'), make('f')])])\n\nassert.strictEqual(\n  drawTree(fa),\n  `a\n├─ b\n├─ c\n└─ d\n   ├─ e\n   └─ f`\n)\n```\n\nAdded in v2.0.0\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <A>(wa: Tree<A>) => Tree<Tree<A>>\n```\n\nAdded in v2.0.0\n\n## elem\n\n**Signature**\n\n```ts\nexport declare function elem<A>(E: Eq<A>): (a: A, fa: Tree<A>) => boolean\n```\n\nAdded in v2.0.0\n\n## exists\n\n**Signature**\n\n```ts\nexport declare const exists: <A>(predicate: Predicate<A>) => (ma: Tree<A>) => boolean\n```\n\nAdded in v2.11.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <A, B>(f: (wa: Tree<A>) => B) => (wa: Tree<A>) => Tree<B>\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~tree~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.tree`\n(where `T` is from `import T from 'fp-ts/Tree'`)\n\n**Signature**\n\n```ts\nexport declare const tree: Monad1<'Tree'> & Foldable1<'Tree'> & Traversable1<'Tree'> & Comonad1<'Tree'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Tuple.ts.md",
    "content": "---\ntitle: Tuple.ts\nnav_order: 115\nparent: Modules\n---\n\n## Tuple overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [Extract](#extract)\n  - [extract](#extract)\n- [folding](#folding)\n  - [foldMap](#foldmap)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n- [instances](#instances)\n  - [Bifunctor](#bifunctor)\n  - [Comonad](#comonad)\n  - [Foldable](#foldable)\n  - [Functor](#functor)\n  - [Semigroupoid](#semigroupoid)\n  - [Traversable](#traversable)\n  - [getApplicative](#getapplicative)\n  - [getApply](#getapply)\n  - [getChain](#getchain)\n  - [getChainRec](#getchainrec)\n  - [getMonad](#getmonad)\n- [mapping](#mapping)\n  - [bimap](#bimap)\n  - [flap](#flap)\n  - [mapFst](#mapfst)\n  - [mapSnd](#mapsnd)\n- [traversing](#traversing)\n  - [sequence](#sequence)\n  - [traverse](#traverse)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [compose](#compose)\n  - [duplicate](#duplicate)\n  - [extend](#extend)\n  - [fst](#fst)\n  - [snd](#snd)\n  - [swap](#swap)\n- [zone of death](#zone-of-death)\n  - [~~mapLeft~~](#mapleft)\n  - [~~map~~](#map)\n  - [~~tuple~~](#tuple)\n\n---\n\n# Extract\n\n## extract\n\n**Signature**\n\n```ts\nexport declare const extract: <E, A>(wa: [A, E]) => A\n```\n\nAdded in v2.6.2\n\n# folding\n\n## foldMap\n\n**Signature**\n\n```ts\nexport declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: [A, E]) => M\n```\n\nAdded in v2.0.0\n\n## reduce\n\n**Signature**\n\n```ts\nexport declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: [A, E]) => B\n```\n\nAdded in v2.0.0\n\n## reduceRight\n\n**Signature**\n\n```ts\nexport declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: [A, E]) => B\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Bifunctor\n\n**Signature**\n\n```ts\nexport declare const Bifunctor: Bifunctor2<'Tuple'>\n```\n\nAdded in v2.7.0\n\n## Comonad\n\n**Signature**\n\n```ts\nexport declare const Comonad: Comonad2<'Tuple'>\n```\n\nAdded in v2.7.0\n\n## Foldable\n\n**Signature**\n\n```ts\nexport declare const Foldable: Foldable2<'Tuple'>\n```\n\nAdded in v2.7.0\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'Tuple'>\n```\n\nAdded in v2.7.0\n\n## Semigroupoid\n\n**Signature**\n\n```ts\nexport declare const Semigroupoid: Semigroupoid2<'Tuple'>\n```\n\nAdded in v2.7.0\n\n## Traversable\n\n**Signature**\n\n```ts\nexport declare const Traversable: Traversable2<'Tuple'>\n```\n\nAdded in v2.7.0\n\n## getApplicative\n\n**Signature**\n\n```ts\nexport declare function getApplicative<M>(M: Monoid<M>): Applicative2C<URI, M>\n```\n\nAdded in v2.0.0\n\n## getApply\n\n**Signature**\n\n```ts\nexport declare function getApply<S>(S: Semigroup<S>): Apply2C<URI, S>\n```\n\nAdded in v2.0.0\n\n## getChain\n\n**Signature**\n\n```ts\nexport declare function getChain<S>(S: Semigroup<S>): Chain2C<URI, S>\n```\n\nAdded in v2.0.0\n\n## getChainRec\n\n**Signature**\n\n```ts\nexport declare function getChainRec<M>(M: Monoid<M>): ChainRec2C<URI, M>\n```\n\nAdded in v2.0.0\n\n## getMonad\n\n**Signature**\n\n```ts\nexport declare function getMonad<M>(M: Monoid<M>): Monad2C<URI, M>\n```\n\nAdded in v2.0.0\n\n# mapping\n\n## bimap\n\nMap a pair of functions over the two type arguments of the bifunctor.\n\n**Signature**\n\n```ts\nexport declare const bimap: <E, G, A, B>(mapSnd: (e: E) => G, mapFst: (a: A) => B) => (fa: [A, E]) => [B, G]\n```\n\nAdded in v2.0.0\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: [(a: A) => B, E]) => [B, E]\n```\n\nAdded in v2.10.0\n\n## mapFst\n\nMap a function over the first component of a `Tuple`.\n\nThis is the `map` operation of the `Functor` instance.\n\n**Signature**\n\n```ts\nexport declare const mapFst: <A, B>(f: (a: A) => B) => <E>(fa: [A, E]) => [B, E]\n```\n\nAdded in v2.0.0\n\n## mapSnd\n\nMap a function over the second component of a `Tuple`.\n\nThis is the `mapLeft` operation of the `Bifunctor` instance.\n\n**Signature**\n\n```ts\nexport declare const mapSnd: <E, G>(f: (e: E) => G) => <A>(fa: [A, E]) => [A, G]\n```\n\nAdded in v2.10.0\n\n# traversing\n\n## sequence\n\n**Signature**\n\n```ts\nexport declare const sequence: Sequence2<'Tuple'>\n```\n\nAdded in v2.6.3\n\n## traverse\n\n**Signature**\n\n```ts\nexport declare const traverse: PipeableTraverse2<'Tuple'>\n```\n\nAdded in v2.6.3\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Tuple'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## compose\n\n**Signature**\n\n```ts\nexport declare const compose: <A, B>(ab: [B, A]) => <C>(bc: [C, B]) => [C, A]\n```\n\nAdded in v2.0.0\n\n## duplicate\n\n**Signature**\n\n```ts\nexport declare const duplicate: <E, A>(wa: [A, E]) => [[A, E], E]\n```\n\nAdded in v2.0.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: <E, A, B>(f: (wa: [A, E]) => B) => (wa: [A, E]) => [B, E]\n```\n\nAdded in v2.0.0\n\n## fst\n\n**Signature**\n\n```ts\nexport declare const fst: <A, E>(ea: [A, E]) => A\n```\n\nAdded in v2.0.0\n\n## snd\n\n**Signature**\n\n```ts\nexport declare const snd: <A, E>(ea: [A, E]) => E\n```\n\nAdded in v2.0.0\n\n## swap\n\n**Signature**\n\n```ts\nexport declare const swap: <A, E>(ea: [A, E]) => [E, A]\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~mapLeft~~\n\nUse [`mapSnd`](#mapsnd) instead.\n\n**Signature**\n\n```ts\nexport declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: [A, E]) => [A, G]\n```\n\nAdded in v2.0.0\n\n## ~~map~~\n\nUse [`mapFst`](#mapfst) instead.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: [A, E]) => [B, E]\n```\n\nAdded in v2.0.0\n\n## ~~tuple~~\n\nThis instance is deprecated, use small, specific instances instead.\nFor example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.tuple`\n(where `T` is from `import T from 'fp-ts/Tuple'`)\n\n**Signature**\n\n```ts\nexport declare const tuple: Semigroupoid2<'Tuple'> &\n  Bifunctor2<'Tuple'> &\n  Comonad2<'Tuple'> &\n  Foldable2<'Tuple'> &\n  Traversable2<'Tuple'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Unfoldable.ts.md",
    "content": "---\ntitle: Unfoldable.ts\nnav_order: 116\nparent: Modules\n---\n\n## Unfoldable overview\n\nThis class identifies data structures which can be _unfolded_, generalizing `unfold` on arrays.\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [Unfoldable (interface)](#unfoldable-interface)\n  - [Unfoldable1 (interface)](#unfoldable1-interface)\n  - [Unfoldable2 (interface)](#unfoldable2-interface)\n  - [Unfoldable2C (interface)](#unfoldable2c-interface)\n  - [Unfoldable3 (interface)](#unfoldable3-interface)\n  - [Unfoldable3C (interface)](#unfoldable3c-interface)\n  - [Unfoldable4 (interface)](#unfoldable4-interface)\n\n---\n\n# model\n\n## Unfoldable (interface)\n\n**Signature**\n\n```ts\nexport interface Unfoldable<F> {\n  readonly URI: F\n  readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => HKT<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## Unfoldable1 (interface)\n\n**Signature**\n\n```ts\nexport interface Unfoldable1<F extends URIS> {\n  readonly URI: F\n  readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## Unfoldable2 (interface)\n\n**Signature**\n\n```ts\nexport interface Unfoldable2<F extends URIS2> {\n  readonly URI: F\n  readonly unfold: <E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Unfoldable2C (interface)\n\n**Signature**\n\n```ts\nexport interface Unfoldable2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Unfoldable3 (interface)\n\n**Signature**\n\n```ts\nexport interface Unfoldable3<F extends URIS3> {\n  readonly URI: F\n  readonly unfold: <R, E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## Unfoldable3C (interface)\n\n**Signature**\n\n```ts\nexport interface Unfoldable3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly unfold: <R, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.10.0\n\n## Unfoldable4 (interface)\n\n**Signature**\n\n```ts\nexport interface Unfoldable4<F extends URIS4> {\n  readonly URI: F\n  readonly unfold: <S, R, E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/ValidationT.ts.md",
    "content": "---\ntitle: ValidationT.ts\nnav_order: 117\nparent: Modules\n---\n\n## ValidationT overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [zone of death](#zone-of-death)\n  - [~~ValidationM1~~ (interface)](#validationm1-interface)\n  - [~~ValidationM2~~ (interface)](#validationm2-interface)\n  - [~~ValidationM~~ (interface)](#validationm-interface)\n  - [~~ValidationT1~~ (type alias)](#validationt1-type-alias)\n  - [~~ValidationT2~~ (type alias)](#validationt2-type-alias)\n  - [~~ValidationT~~ (interface)](#validationt-interface)\n  - [~~getValidationM~~](#getvalidationm)\n\n---\n\n# zone of death\n\n## ~~ValidationM1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ValidationM1<M extends URIS, E> extends ApplicativeComposition12C<M, E.URI, E> {\n  readonly chain: <A, B>(ma: ValidationT1<M, E, A>, f: (a: A) => ValidationT1<M, E, B>) => ValidationT1<M, E, B>\n\n  readonly alt: <A>(fa: ValidationT1<M, E, A>, that: LazyArg<ValidationT1<M, E, A>>) => ValidationT1<M, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ValidationM2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ValidationM2<M extends URIS2, E> extends ApplicativeComposition22C<M, E.URI, E> {\n  readonly chain: <R, A, B>(\n    ma: ValidationT2<M, R, E, A>,\n\n    f: (a: A) => ValidationT2<M, R, E, B>\n  ) => ValidationT2<M, R, E, B>\n\n  readonly alt: <R, A>(\n    fa: ValidationT2<M, R, E, A>,\n    that: LazyArg<ValidationT2<M, R, E, A>>\n  ) => ValidationT2<M, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ValidationM~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ValidationM<M, E> extends ApplicativeCompositionHKT2C<M, E.URI, E> {\n  readonly chain: <A, B>(ma: ValidationT<M, E, A>, f: (a: A) => ValidationT<M, E, B>) => ValidationT<M, E, B>\n\n  readonly alt: <A>(fa: ValidationT<M, E, A>, that: LazyArg<ValidationT<M, E, A>>) => ValidationT<M, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~ValidationT1~~ (type alias)\n\n**Signature**\n\n```ts\nexport type ValidationT1<M extends URIS, E, A> = Kind<M, Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~ValidationT2~~ (type alias)\n\n**Signature**\n\n```ts\nexport type ValidationT2<M extends URIS2, R, E, A> = Kind2<M, R, Either<E, A>>\n```\n\nAdded in v2.0.0\n\n## ~~ValidationT~~ (interface)\n\n**Signature**\n\n```ts\nexport interface ValidationT<M, E, A> extends HKT<M, Either<E, A>> {}\n```\n\nAdded in v2.0.0\n\n## ~~getValidationM~~\n\nUse `EitherT` instead.\n\n**Signature**\n\n```ts\nexport declare function getValidationM<E, M extends URIS2>(S: Semigroup<E>, M: Monad2<M>): ValidationM2<M, E>\nexport declare function getValidationM<E, M extends URIS>(S: Semigroup<E>, M: Monad1<M>): ValidationM1<M, E>\nexport declare function getValidationM<E, M>(S: Semigroup<E>, M: Monad<M>): ValidationM<M, E>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/Witherable.ts.md",
    "content": "---\ntitle: Witherable.ts\nnav_order: 119\nparent: Modules\n---\n\n## Witherable overview\n\n`Witherable` represents data structures which can be _partitioned_ with effects in some `Applicative` functor.\n\nAdapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Witherable.purs\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [defaults](#defaults)\n  - [wiltDefault](#wiltdefault)\n  - [witherDefault](#witherdefault)\n- [model](#model)\n  - [Witherable (interface)](#witherable-interface)\n  - [Witherable1 (interface)](#witherable1-interface)\n  - [Witherable2 (interface)](#witherable2-interface)\n  - [Witherable2C (interface)](#witherable2c-interface)\n  - [Witherable3 (interface)](#witherable3-interface)\n- [utils](#utils)\n  - [FilterE1 (interface)](#filtere1-interface)\n  - [PipeableWilt (interface)](#pipeablewilt-interface)\n  - [PipeableWilt1 (interface)](#pipeablewilt1-interface)\n  - [PipeableWilt2 (interface)](#pipeablewilt2-interface)\n  - [PipeableWilt2C (interface)](#pipeablewilt2c-interface)\n  - [PipeableWilt3 (interface)](#pipeablewilt3-interface)\n  - [PipeableWither (interface)](#pipeablewither-interface)\n  - [PipeableWither1 (interface)](#pipeablewither1-interface)\n  - [PipeableWither2 (interface)](#pipeablewither2-interface)\n  - [PipeableWither2C (interface)](#pipeablewither2c-interface)\n  - [PipeableWither3 (interface)](#pipeablewither3-interface)\n  - [Wilt (interface)](#wilt-interface)\n  - [Wilt1 (interface)](#wilt1-interface)\n  - [Wilt2 (interface)](#wilt2-interface)\n  - [Wilt2C (interface)](#wilt2c-interface)\n  - [Wilt3 (interface)](#wilt3-interface)\n  - [Wither (interface)](#wither-interface)\n  - [Wither1 (interface)](#wither1-interface)\n  - [Wither2 (interface)](#wither2-interface)\n  - [Wither2C (interface)](#wither2c-interface)\n  - [Wither3 (interface)](#wither3-interface)\n  - [filterE](#filtere)\n\n---\n\n# defaults\n\n## wiltDefault\n\nReturn a `wilt` implementation from `Traversable` and `Compactable`.\n\n**Signature**\n\n```ts\nexport declare function wiltDefault<W extends URIS2, E>(\n  T: Traversable2C<W, E>,\n  C: Compactable2<W>\n): Witherable2C<W, E>['wilt']\nexport declare function wiltDefault<W extends URIS2, E>(\n  T: Traversable2<W>,\n  C: Compactable2C<W, E>\n): Witherable2C<W, E>['wilt']\nexport declare function wiltDefault<W extends URIS>(T: Traversable1<W>, C: Compactable1<W>): Witherable1<W>['wilt']\nexport declare function wiltDefault<W>(T: Traversable<W>, C: Compactable<W>): Witherable<W>['wilt']\n```\n\nAdded in v2.11.0\n\n## witherDefault\n\nReturn a `wither` implementation from `Traversable` and `Compactable`.\n\n**Signature**\n\n```ts\nexport declare function witherDefault<W extends URIS2, E>(\n  T: Traversable2C<W, E>,\n  C: Compactable2<W>\n): Witherable2C<W, E>['wither']\nexport declare function witherDefault<W extends URIS2, E>(\n  T: Traversable2<W>,\n  C: Compactable2C<W, E>\n): Witherable2C<W, E>['wither']\nexport declare function witherDefault<W extends URIS>(T: Traversable1<W>, C: Compactable1<W>): Witherable1<W>['wither']\nexport declare function witherDefault<W>(T: Traversable<W>, C: Compactable<W>): Witherable<W>['wither']\n```\n\nAdded in v2.11.0\n\n# model\n\n## Witherable (interface)\n\n**Signature**\n\n```ts\nexport interface Witherable<T> extends Traversable<T>, Filterable<T> {\n  /**\n   * Partition a structure with effects\n   */\n  readonly wilt: Wilt<T>\n\n  /**\n   * Filter a structure  with effects\n   */\n  readonly wither: Wither<T>\n}\n```\n\nAdded in v2.0.0\n\n## Witherable1 (interface)\n\n**Signature**\n\n```ts\nexport interface Witherable1<T extends URIS> extends Traversable1<T>, Filterable1<T> {\n  readonly wilt: Wilt1<T>\n  readonly wither: Wither1<T>\n}\n```\n\nAdded in v2.0.0\n\n## Witherable2 (interface)\n\n**Signature**\n\n```ts\nexport interface Witherable2<T extends URIS2> extends Traversable2<T>, Filterable2<T> {\n  readonly wilt: Wilt2<T>\n  readonly wither: Wither2<T>\n}\n```\n\nAdded in v2.0.0\n\n## Witherable2C (interface)\n\n**Signature**\n\n```ts\nexport interface Witherable2C<T extends URIS2, TL> extends Traversable2C<T, TL>, Filterable2C<T, TL> {\n  readonly wilt: Wilt2C<T, TL>\n  readonly wither: Wither2C<T, TL>\n}\n```\n\nAdded in v2.0.0\n\n## Witherable3 (interface)\n\n**Signature**\n\n```ts\nexport interface Witherable3<T extends URIS3> extends Traversable3<T>, Filterable3<T> {\n  readonly wilt: Wilt3<T>\n  readonly wither: Wither3<T>\n}\n```\n\nAdded in v2.0.0\n\n# utils\n\n## FilterE1 (interface)\n\n**Signature**\n\n```ts\nexport interface FilterE1<G extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E>(\n    predicate: (a: A) => Kind3<F, R, E, boolean>\n  ) => (ga: Kind<G, A>) => Kind3<F, R, E, Kind<G, A>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R>(\n    predicate: (a: A) => Kind3<F, R, E, boolean>\n  ) => (ga: Kind<G, A>) => Kind3<F, R, E, Kind<G, A>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E>(\n    predicate: (a: A) => Kind2<F, E, boolean>\n  ) => (ga: Kind<G, A>) => Kind2<F, E, Kind<G, A>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(\n    predicate: (a: A) => Kind2<F, E, boolean>\n  ) => (ga: Kind<G, A>) => Kind2<F, E, Kind<G, A>>\n  <F extends URIS>(F: Applicative1<F>): <A>(\n    predicate: (a: A) => Kind<F, boolean>\n  ) => (ga: Kind<G, A>) => Kind<F, Kind<G, A>>\n  <F>(F: Applicative<F>): <A>(predicate: (a: A) => HKT<F, boolean>) => (ga: Kind<G, A>) => HKT<F, Kind<G, A>>\n}\n```\n\nAdded in v2.11.0\n\n## PipeableWilt (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWilt<W> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind<F, Separated<HKT<W, B>, HKT<W, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => (wa: HKT<W, A>) => HKT<F, Separated<HKT<W, B>, HKT<W, C>>>\n}\n```\n\nAdded in v2.6.5\n\n## PipeableWilt1 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWilt1<W extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind<F, Separated<Kind<W, B>, Kind<W, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => (wa: Kind<W, A>) => HKT<F, Separated<Kind<W, B>, Kind<W, C>>>\n}\n```\n\nAdded in v2.6.5\n\n## PipeableWilt2 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWilt2<W extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B, C>(\n    f: (a: A) => Kind3<F, R, FE, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => Kind3<F, R, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => Kind<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => HKT<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n}\n```\n\nAdded in v2.6.5\n\n## PipeableWilt2C (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWilt2C<W extends URIS2, WE> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B, C>(\n    f: (a: A) => Kind3<F, R, FE, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => Kind3<F, R, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => Kind<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => HKT<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n}\n```\n\nAdded in v2.6.5\n\n## PipeableWilt3 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWilt3<W extends URIS3> {\n  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B, C>(\n    f: (a: A) => Kind3<F, FR, FE, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind3<F, FR, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind2<F, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind2<F, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind<F, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => HKT<F, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n}\n```\n\nAdded in v2.6.5\n\n## PipeableWither (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWither<W> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => (ta: HKT<W, A>) => Kind3<F, R, E, HKT<W, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => (ta: HKT<W, A>) => Kind3<F, R, E, HKT<W, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => (ta: HKT<W, A>) => Kind2<F, E, HKT<W, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => (ta: HKT<W, A>) => Kind2<F, E, HKT<W, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(f: (a: A) => Kind<F, Option<B>>) => (ta: HKT<W, A>) => Kind<F, HKT<W, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => (ta: HKT<W, A>) => HKT<F, HKT<W, B>>\n}\n```\n\nAdded in v2.6.5\n\n## PipeableWither1 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWither1<W extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind3<F, R, E, Kind<W, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind3<F, R, E, Kind<W, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind2<F, E, Kind<W, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind2<F, E, Kind<W, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind<F, Kind<W, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => (ta: Kind<W, A>) => HKT<F, Kind<W, B>>\n}\n```\n\nAdded in v2.6.5\n\n## PipeableWither2 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWither2<W extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    f: (a: A) => Kind3<F, R, FE, Option<B>>\n  ) => <WE>(ta: Kind2<W, WE, A>) => Kind3<F, R, FE, Kind2<W, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => <WE>(ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => <WE>(ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, Option<B>>\n  ) => <WE>(ta: Kind2<W, WE, A>) => Kind<F, Kind2<W, WE, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => <WE>(ta: Kind2<W, WE, A>) => HKT<F, Kind2<W, WE, B>>\n}\n```\n\nAdded in v2.6.5\n\n## PipeableWither2C (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWither2C<W extends URIS2, WE> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    f: (a: A) => Kind3<F, R, FE, Option<B>>\n  ) => (ta: Kind2<W, WE, A>) => Kind3<F, R, FE, Kind2<W, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => (ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => (ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, Option<B>>\n  ) => (ta: Kind2<W, WE, A>) => Kind<F, Kind2<W, WE, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => (ta: Kind2<W, WE, A>) => HKT<F, Kind2<W, WE, B>>\n}\n```\n\nAdded in v2.6.5\n\n## PipeableWither3 (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableWither3<W extends URIS3> {\n  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B>(\n    f: (a: A) => Kind3<F, FR, FE, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind3<F, FR, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind2<F, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind2<F, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind<F, Kind3<W, WR, WE, B>>\n  <F>(F: Applicative<F>): <A, B>(\n    f: (a: A) => HKT<F, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => HKT<F, Kind3<W, WR, WE, B>>\n}\n```\n\nAdded in v2.6.5\n\n## Wilt (interface)\n\n**Signature**\n\n```ts\nexport interface Wilt<W> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<HKT<W, B>, HKT<W, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<HKT<W, B>, HKT<W, C>>>\n}\n```\n\nAdded in v2.0.0\n\n## Wilt1 (interface)\n\n**Signature**\n\n```ts\nexport interface Wilt1<W extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<Kind<W, B>, Kind<W, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<Kind<W, B>, Kind<W, C>>>\n}\n```\n\nAdded in v2.0.0\n\n## Wilt2 (interface)\n\n**Signature**\n\n```ts\nexport interface Wilt2<W extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <WE, A, R, FE, B, C>(\n    wa: Kind2<W, WE, A>,\n    f: (a: A) => Kind3<F, R, FE, Either<B, C>>\n  ) => Kind3<F, R, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <WE, A, FE, B, C>(\n    wa: Kind2<W, WE, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <WE, A, B, C>(\n    wa: Kind2<W, WE, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <E, A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F>(F: Applicative<F>): <E, A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n}\n```\n\nAdded in v2.0.0\n\n## Wilt2C (interface)\n\n**Signature**\n\n```ts\nexport interface Wilt2C<W extends URIS2, E> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind3<F, R, FE, Either<B, C>>\n  ) => Kind3<F, R, FE, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n}\n```\n\nAdded in v2.0.0\n\n## Wilt3 (interface)\n\n**Signature**\n\n```ts\nexport interface Wilt3<W extends URIS3> {\n  <F extends URIS3>(F: Applicative3<F>): <WR, WE, A, FR, FE, B, C>(\n    wa: Kind3<W, WR, WE, A>,\n    f: (a: A) => Kind3<F, FR, FE, Either<B, C>>\n  ) => Kind3<F, FR, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <R, WE, A, FE, B, C>(\n    wa: Kind3<W, R, WE, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind3<W, R, WE, B>, Kind3<W, R, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, WE, A, B, C>(\n    wa: Kind3<W, R, WE, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind3<W, R, WE, B>, Kind3<W, R, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <R, E, A, B, C>(\n    wa: Kind3<W, R, E, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<Kind3<W, R, E, B>, Kind3<W, R, E, C>>>\n  <F>(F: Applicative<F>): <R, E, A, B, C>(\n    wa: Kind3<W, R, E, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<Kind3<W, R, E, B>, Kind3<W, R, E, C>>>\n}\n```\n\nAdded in v2.0.0\n\n## Wither (interface)\n\n**Signature**\n\n```ts\nexport interface Wither<W> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: HKT<W, A>,\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => Kind3<F, R, E, HKT<W, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: HKT<W, A>,\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => Kind3<F, R, E, HKT<W, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: HKT<W, A>,\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => Kind2<F, E, HKT<W, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: HKT<W, A>,\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => Kind2<F, E, HKT<W, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: HKT<W, A>, f: (a: A) => Kind<F, Option<B>>) => Kind<F, HKT<W, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: HKT<W, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, HKT<W, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Wither1 (interface)\n\n**Signature**\n\n```ts\nexport interface Wither1<W extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: Kind<W, A>,\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => Kind3<F, R, E, Kind<W, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: Kind<W, A>,\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => Kind3<F, R, E, Kind<W, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: Kind<W, A>,\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => Kind2<F, E, Kind<W, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: Kind<W, A>,\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => Kind2<F, E, Kind<W, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind<W, A>, f: (a: A) => Kind<F, Option<B>>) => Kind<F, Kind<W, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind<W, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, Kind<W, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Wither2 (interface)\n\n**Signature**\n\n```ts\nexport interface Wither2<W extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <WE, A, R, FE, B>(\n    ta: Kind2<W, WE, A>,\n    f: (a: A) => Kind3<F, R, FE, Option<B>>\n  ) => Kind3<F, R, FE, Kind2<W, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <WE, A, FE, B>(\n    ta: Kind2<W, WE, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <WE, A, B>(\n    ta: Kind2<W, WE, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <E, A, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind<F, Option<B>>\n  ) => Kind<F, Kind2<W, E, B>>\n  <F>(F: Applicative<F>): <E, A, B>(ta: Kind2<W, E, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, Kind2<W, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Wither2C (interface)\n\n**Signature**\n\n```ts\nexport interface Wither2C<W extends URIS2, E> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind3<F, R, FE, Option<B>>\n  ) => Kind3<F, R, FE, Kind2<W, E, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind2<W, E, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind2<W, E, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind<F, Option<B>>\n  ) => Kind<F, Kind2<W, E, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind2<W, E, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, Kind2<W, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## Wither3 (interface)\n\n**Signature**\n\n```ts\nexport interface Wither3<W extends URIS3> {\n  <F extends URIS3>(F: Applicative3<F>): <WR, WE, A, FR, FE, B>(\n    ta: Kind3<W, WR, WE, A>,\n    f: (a: A) => Kind3<F, FR, FE, Option<B>>\n  ) => Kind3<F, FR, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <WR, WE, A, FE, B>(\n    ta: Kind3<W, WR, WE, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, WE, A, B>(\n    ta: Kind3<W, R, WE, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind3<W, R, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <R, E, A, B>(\n    ta: Kind3<W, R, E, A>,\n    f: (a: A) => Kind<F, Option<B>>\n  ) => Kind<F, Kind3<W, R, E, B>>\n  <F>(F: Applicative<F>): <R, E, A, B>(\n    ta: Kind3<W, R, E, A>,\n    f: (a: A) => HKT<F, Option<B>>\n  ) => HKT<F, Kind3<W, R, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## filterE\n\nFilter values inside a `F` context.\n\nSee `ReadonlyArray`'s `filterE` for an example of usage.\n\n**Signature**\n\n```ts\nexport declare function filterE<G extends URIS>(W: Witherable1<G>): FilterE1<G>\nexport declare function filterE<G>(\n  W: Witherable<G>\n): <F>(F: Applicative<F>) => <A>(predicate: (a: A) => HKT<F, boolean>) => (ga: HKT<G, A>) => HKT<F, HKT<G, A>>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/Writer.ts.md",
    "content": "---\ntitle: Writer.ts\nnav_order: 120\nparent: Modules\n---\n\n## Writer overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [constructors](#constructors)\n  - [tell](#tell)\n- [instances](#instances)\n  - [Functor](#functor)\n  - [getApplicative](#getapplicative)\n  - [getApply](#getapply)\n  - [getChain](#getchain)\n  - [getMonad](#getmonad)\n  - [getPointed](#getpointed)\n- [mapping](#mapping)\n  - [flap](#flap)\n  - [map](#map)\n- [model](#model)\n  - [Writer (interface)](#writer-interface)\n- [type lambdas](#type-lambdas)\n  - [URI](#uri)\n  - [URI (type alias)](#uri-type-alias)\n- [utils](#utils)\n  - [censor](#censor)\n  - [evaluate](#evaluate)\n  - [execute](#execute)\n  - [listen](#listen)\n  - [listens](#listens)\n  - [pass](#pass)\n- [zone of death](#zone-of-death)\n  - [~~evalWriter~~](#evalwriter)\n  - [~~execWriter~~](#execwriter)\n  - [~~writer~~](#writer)\n\n---\n\n# constructors\n\n## tell\n\nAppends a value to the accumulator\n\n**Signature**\n\n```ts\nexport declare const tell: <W>(w: W) => Writer<W, void>\n```\n\nAdded in v2.0.0\n\n# instances\n\n## Functor\n\n**Signature**\n\n```ts\nexport declare const Functor: Functor2<'Writer'>\n```\n\nAdded in v2.7.0\n\n## getApplicative\n\n**Signature**\n\n```ts\nexport declare const getApplicative: <W>(M: Monoid<W>) => Applicative2C<'Writer', W>\n```\n\nAdded in v2.10.0\n\n## getApply\n\n**Signature**\n\n```ts\nexport declare const getApply: <W>(S: Semigroup<W>) => Apply2C<'Writer', W>\n```\n\nAdded in v2.10.0\n\n## getChain\n\n**Signature**\n\n```ts\nexport declare function getChain<W>(S: Semigroup<W>): Chain2C<URI, W>\n```\n\nAdded in v2.10.0\n\n## getMonad\n\n**Signature**\n\n```ts\nexport declare function getMonad<W>(M: Monoid<W>): Monad2C<URI, W>\n```\n\nAdded in v2.0.0\n\n## getPointed\n\n**Signature**\n\n```ts\nexport declare const getPointed: <W>(M: Monoid<W>) => Pointed2C<'Writer', W>\n```\n\nAdded in v2.10.0\n\n# mapping\n\n## flap\n\n**Signature**\n\n```ts\nexport declare const flap: <A>(a: A) => <E, B>(fab: Writer<E, (a: A) => B>) => Writer<E, B>\n```\n\nAdded in v2.10.0\n\n## map\n\n`map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\nuse the type constructor `F` to represent some computational context.\n\n**Signature**\n\n```ts\nexport declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Writer<E, A>) => Writer<E, B>\n```\n\nAdded in v2.0.0\n\n# model\n\n## Writer (interface)\n\n**Signature**\n\n```ts\nexport interface Writer<W, A> {\n  (): [A, W]\n}\n```\n\nAdded in v2.0.0\n\n# type lambdas\n\n## URI\n\n**Signature**\n\n```ts\nexport declare const URI: 'Writer'\n```\n\nAdded in v2.0.0\n\n## URI (type alias)\n\n**Signature**\n\n```ts\nexport type URI = typeof URI\n```\n\nAdded in v2.0.0\n\n# utils\n\n## censor\n\nModify the final accumulator value by applying a function\n\n**Signature**\n\n```ts\nexport declare const censor: <W>(f: (w: W) => W) => <A>(fa: Writer<W, A>) => Writer<W, A>\n```\n\nAdded in v2.0.0\n\n## evaluate\n\n**Signature**\n\n```ts\nexport declare const evaluate: <W, A>(fa: Writer<W, A>) => A\n```\n\nAdded in v2.8.0\n\n## execute\n\n**Signature**\n\n```ts\nexport declare const execute: <W, A>(fa: Writer<W, A>) => W\n```\n\nAdded in v2.8.0\n\n## listen\n\nModifies the result to include the changes to the accumulator\n\n**Signature**\n\n```ts\nexport declare const listen: <W, A>(fa: Writer<W, A>) => Writer<W, [A, W]>\n```\n\nAdded in v2.0.0\n\n## listens\n\nProjects a value from modifications made to the accumulator during an action\n\n**Signature**\n\n```ts\nexport declare const listens: <W, B>(f: (w: W) => B) => <A>(fa: Writer<W, A>) => Writer<W, [A, B]>\n```\n\nAdded in v2.0.0\n\n## pass\n\nApplies the returned function to the accumulator\n\n**Signature**\n\n```ts\nexport declare const pass: <W, A>(fa: Writer<W, [A, (w: W) => W]>) => Writer<W, A>\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~evalWriter~~\n\nUse [`evaluate`](#evaluate) instead\n\n**Signature**\n\n```ts\nexport declare const evalWriter: <W, A>(fa: Writer<W, A>) => A\n```\n\nAdded in v2.0.0\n\n## ~~execWriter~~\n\nUse [`execute`](#execute) instead\n\n**Signature**\n\n```ts\nexport declare const execWriter: <W, A>(fa: Writer<W, A>) => W\n```\n\nAdded in v2.0.0\n\n## ~~writer~~\n\nUse [`Functor`](#functor) instead.\n\n**Signature**\n\n```ts\nexport declare const writer: Functor2<'Writer'>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/WriterT.ts.md",
    "content": "---\ntitle: WriterT.ts\nnav_order: 121\nparent: Modules\n---\n\n## WriterT overview\n\nAdded in v2.4.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [model](#model)\n  - [WriterT (interface)](#writert-interface)\n  - [WriterT1 (interface)](#writert1-interface)\n  - [WriterT2 (interface)](#writert2-interface)\n- [utils](#utils)\n  - [WriterM (interface)](#writerm-interface)\n  - [WriterM1 (interface)](#writerm1-interface)\n  - [WriterM2 (interface)](#writerm2-interface)\n  - [WriterM2C (interface)](#writerm2c-interface)\n  - [WriterM3 (interface)](#writerm3-interface)\n  - [WriterT3 (interface)](#writert3-interface)\n  - [getWriterM](#getwriterm)\n\n---\n\n# model\n\n## WriterT (interface)\n\n**Signature**\n\n```ts\nexport interface WriterT<M, W, A> {\n  (): HKT<M, [A, W]>\n}\n```\n\nAdded in v2.4.0\n\n## WriterT1 (interface)\n\n**Signature**\n\n```ts\nexport interface WriterT1<M extends URIS, W, A> {\n  (): Kind<M, [A, W]>\n}\n```\n\nAdded in v2.4.0\n\n## WriterT2 (interface)\n\n**Signature**\n\n```ts\nexport interface WriterT2<M extends URIS2, E, W, A> {\n  (): Kind2<M, E, [A, W]>\n}\n```\n\nAdded in v2.4.0\n\n# utils\n\n## WriterM (interface)\n\n**Signature**\n\n```ts\nexport interface WriterM<M> {\n  readonly map: <W, A, B>(fa: WriterT<M, W, A>, f: (a: A) => B) => WriterT<M, W, B>\n  readonly evalWriter: <W, A>(fa: WriterT<M, W, A>) => HKT<M, A>\n  readonly execWriter: <W, A>(fa: WriterT<M, W, A>) => HKT<M, W>\n  readonly tell: <W>(w: W) => WriterT<M, W, void>\n  readonly listen: <W, A>(fa: WriterT<M, W, A>) => WriterT<M, W, [A, W]>\n  readonly pass: <W, A>(fa: WriterT<M, W, [A, (w: W) => W]>) => WriterT<M, W, A>\n  readonly listens: <W, A, B>(fa: WriterT<M, W, A>, f: (w: W) => B) => WriterT<M, W, [A, B]>\n  readonly censor: <W, A>(fa: WriterT<M, W, A>, f: (w: W) => W) => WriterT<M, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <A, B>(ma: WriterT<M, W, A>, f: (a: A) => B) => WriterT<M, W, B>\n    readonly of: <A>(a: A) => WriterT<M, W, A>\n    readonly ap: <A, B>(mab: WriterT<M, W, (a: A) => B>, ma: WriterT<M, W, A>) => WriterT<M, W, B>\n    readonly chain: <A, B>(ma: WriterT<M, W, A>, f: (a: A) => WriterT<M, W, B>) => WriterT<M, W, B>\n  }\n}\n```\n\nAdded in v2.4.0\n\n## WriterM1 (interface)\n\n**Signature**\n\n```ts\nexport interface WriterM1<M extends URIS> {\n  readonly map: <W, A, B>(fa: WriterT1<M, W, A>, f: (a: A) => B) => WriterT1<M, W, B>\n  readonly evalWriter: <W, A>(fa: WriterT1<M, W, A>) => Kind<M, A>\n  readonly execWriter: <W, A>(fa: WriterT1<M, W, A>) => Kind<M, W>\n  readonly tell: <W>(w: W) => WriterT1<M, W, void>\n  readonly listen: <W, A>(fa: WriterT1<M, W, A>) => WriterT1<M, W, [A, W]>\n  readonly pass: <W, A>(fa: WriterT1<M, W, [A, (w: W) => W]>) => WriterT1<M, W, A>\n  readonly listens: <W, A, B>(fa: WriterT1<M, W, A>, f: (w: W) => B) => WriterT1<M, W, [A, B]>\n  readonly censor: <W, A>(fa: WriterT1<M, W, A>, f: (w: W) => W) => WriterT1<M, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <A, B>(ma: WriterT1<M, W, A>, f: (a: A) => B) => WriterT1<M, W, B>\n    readonly of: <A>(a: A) => WriterT1<M, W, A>\n    readonly ap: <A, B>(mab: WriterT1<M, W, (a: A) => B>, ma: WriterT1<M, W, A>) => WriterT1<M, W, B>\n    readonly chain: <A, B>(ma: WriterT1<M, W, A>, f: (a: A) => WriterT1<M, W, B>) => WriterT1<M, W, B>\n  }\n}\n```\n\nAdded in v2.4.0\n\n## WriterM2 (interface)\n\n**Signature**\n\n```ts\nexport interface WriterM2<M extends URIS2> {\n  readonly map: <E, W, A, B>(fa: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>\n  readonly evalWriter: <E, W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, A>\n  readonly execWriter: <E, W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, W>\n  readonly tell: <E, W>(w: W) => WriterT2<M, E, W, void>\n  readonly listen: <E, W, A>(fa: WriterT2<M, E, W, A>) => WriterT2<M, E, W, [A, W]>\n  readonly pass: <E, W, A>(fa: WriterT2<M, E, W, [A, (w: W) => W]>) => WriterT2<M, E, W, A>\n  readonly listens: <E, W, A, B>(fa: WriterT2<M, E, W, A>, f: (w: W) => B) => WriterT2<M, E, W, [A, B]>\n  readonly censor: <E, W, A>(fa: WriterT2<M, E, W, A>, f: (w: W) => W) => WriterT2<M, E, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <E, A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>\n    readonly of: <E, A>(a: A) => WriterT2<M, E, W, A>\n    readonly ap: <E, A, B>(mab: WriterT2<M, E, W, (a: A) => B>, ma: WriterT2<M, E, W, A>) => WriterT2<M, E, W, B>\n    readonly chain: <E, A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => WriterT2<M, E, W, B>) => WriterT2<M, E, W, B>\n  }\n}\n```\n\nAdded in v2.4.0\n\n## WriterM2C (interface)\n\n**Signature**\n\n```ts\nexport interface WriterM2C<M extends URIS2, E> {\n  readonly map: <W, A, B>(fa: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>\n  readonly evalWriter: <W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, A>\n  readonly execWriter: <W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, W>\n  readonly tell: <W>(w: W) => WriterT2<M, E, W, void>\n  readonly listen: <W, A>(fa: WriterT2<M, E, W, A>) => WriterT2<M, E, W, [A, W]>\n  readonly pass: <W, A>(fa: WriterT2<M, E, W, [A, (w: W) => W]>) => WriterT2<M, E, W, A>\n  readonly listens: <W, A, B>(fa: WriterT2<M, E, W, A>, f: (w: W) => B) => WriterT2<M, E, W, [A, B]>\n  readonly censor: <W, A>(fa: WriterT2<M, E, W, A>, f: (w: W) => W) => WriterT2<M, E, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>\n    readonly of: <A>(a: A) => WriterT2<M, E, W, A>\n    readonly ap: <A, B>(mab: WriterT2<M, E, W, (a: A) => B>, ma: WriterT2<M, E, W, A>) => WriterT2<M, E, W, B>\n    readonly chain: <A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => WriterT2<M, E, W, B>) => WriterT2<M, E, W, B>\n  }\n}\n```\n\nAdded in v2.4.0\n\n## WriterM3 (interface)\n\n**Signature**\n\n```ts\nexport interface WriterM3<M extends URIS3> {\n  readonly map: <R, E, W, A, B>(fa: WriterT3<M, R, E, W, A>, f: (a: A) => B) => WriterT3<M, R, E, W, B>\n  readonly evalWriter: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>) => Kind3<M, R, E, A>\n  readonly execWriter: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>) => Kind3<M, R, E, W>\n  readonly tell: <R, E, W>(w: W) => WriterT3<M, R, E, W, void>\n  readonly listen: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>) => WriterT3<M, R, E, W, [A, W]>\n  readonly pass: <R, E, W, A>(fa: WriterT3<M, R, E, W, [A, (w: W) => W]>) => WriterT3<M, R, E, W, A>\n  readonly listens: <R, E, W, A, B>(fa: WriterT3<M, R, E, W, A>, f: (w: W) => B) => WriterT3<M, R, E, W, [A, B]>\n  readonly censor: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>, f: (w: W) => W) => WriterT3<M, R, E, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <R, E, A, B>(ma: WriterT3<M, R, E, W, A>, f: (a: A) => B) => WriterT3<M, R, E, W, B>\n    readonly of: <R, E, A>(a: A) => WriterT3<M, R, E, W, A>\n    readonly ap: <R, E, A, B>(\n      mab: WriterT3<M, R, E, W, (a: A) => B>,\n      ma: WriterT3<M, R, E, W, A>\n    ) => WriterT3<M, R, E, W, B>\n    readonly chain: <R, E, A, B>(\n      ma: WriterT3<M, R, E, W, A>,\n      f: (a: A) => WriterT3<M, R, E, W, B>\n    ) => WriterT3<M, R, E, W, B>\n  }\n}\n```\n\nAdded in v2.4.0\n\n## WriterT3 (interface)\n\n**Signature**\n\n```ts\nexport interface WriterT3<M extends URIS3, R, E, W, A> {\n  (): Kind3<M, R, E, [A, W]>\n}\n```\n\nAdded in v2.4.0\n\n## getWriterM\n\n**Signature**\n\n```ts\nexport declare function getWriterM<M extends URIS3>(M: Monad3<M>): WriterM3<M>\nexport declare function getWriterM<M extends URIS2>(M: Monad2<M>): WriterM2<M>\nexport declare function getWriterM<M extends URIS2, E>(M: Monad2C<M, E>): WriterM2C<M, E>\nexport declare function getWriterM<M extends URIS>(M: Monad1<M>): WriterM1<M>\nexport declare function getWriterM<M>(M: Monad<M>): WriterM<M>\n```\n\nAdded in v2.4.0\n"
  },
  {
    "path": "docs/modules/Zero.ts.md",
    "content": "---\ntitle: Zero.ts\nnav_order: 122\nparent: Modules\n---\n\n## Zero overview\n\nAdded in v2.11.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [do notation](#do-notation)\n  - [guard](#guard)\n- [model](#model)\n  - [Zero (interface)](#zero-interface)\n  - [Zero1 (interface)](#zero1-interface)\n  - [Zero2 (interface)](#zero2-interface)\n  - [Zero2C (interface)](#zero2c-interface)\n  - [Zero3 (interface)](#zero3-interface)\n  - [Zero3C (interface)](#zero3c-interface)\n  - [Zero4 (interface)](#zero4-interface)\n\n---\n\n# do notation\n\n## guard\n\n**Signature**\n\n```ts\nexport declare function guard<F extends URIS4>(\n  F: Zero4<F>,\n  P: Pointed4<F>\n): <S, R, E>(b: boolean) => Kind4<F, S, R, E, void>\nexport declare function guard<F extends URIS3>(F: Zero3<F>, P: Pointed3<F>): <R, E>(b: boolean) => Kind3<F, R, E, void>\nexport declare function guard<F extends URIS3, E>(\n  F: Zero3C<F, E>,\n  P: Pointed3C<F, E>\n): <R>(b: boolean) => Kind3<F, R, E, void>\nexport declare function guard<F extends URIS2>(F: Zero2<F>, P: Pointed2<F>): <E>(b: boolean) => Kind2<F, E, void>\nexport declare function guard<F extends URIS2, E>(\n  F: Zero2C<F, E>,\n  P: Pointed2C<F, E>\n): (b: boolean) => Kind2<F, E, void>\nexport declare function guard<F extends URIS>(F: Zero1<F>, P: Pointed1<F>): (b: boolean) => Kind<F, void>\nexport declare function guard<F>(F: Zero<F>, P: Pointed<F>): (b: boolean) => HKT<F, void>\n```\n\nAdded in v2.11.0\n\n# model\n\n## Zero (interface)\n\n**Signature**\n\n```ts\nexport interface Zero<F> {\n  readonly URI: F\n  readonly zero: <A>() => HKT<F, A>\n}\n```\n\nAdded in v2.11.0\n\n## Zero1 (interface)\n\n**Signature**\n\n```ts\nexport interface Zero1<F extends URIS> {\n  readonly URI: F\n  readonly zero: <A>() => Kind<F, A>\n}\n```\n\nAdded in v2.11.0\n\n## Zero2 (interface)\n\n**Signature**\n\n```ts\nexport interface Zero2<F extends URIS2> {\n  readonly URI: F\n  readonly zero: <E, A>() => Kind2<F, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## Zero2C (interface)\n\n**Signature**\n\n```ts\nexport interface Zero2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly zero: <A>() => Kind2<F, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## Zero3 (interface)\n\n**Signature**\n\n```ts\nexport interface Zero3<F extends URIS3> {\n  readonly URI: F\n  readonly zero: <R, E, A>() => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## Zero3C (interface)\n\n**Signature**\n\n```ts\nexport interface Zero3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly zero: <R, A>() => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.11.0\n\n## Zero4 (interface)\n\n**Signature**\n\n```ts\nexport interface Zero4<F extends URIS4> {\n  readonly URI: F\n  readonly zero: <S, R, E, A>() => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/boolean.ts.md",
    "content": "---\ntitle: boolean.ts\nnav_order: 7\nparent: Modules\n---\n\n## boolean overview\n\nAdded in v2.2.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [BooleanAlgebra](#booleanalgebra)\n  - [Eq](#eq)\n  - [MonoidAll](#monoidall)\n  - [MonoidAny](#monoidany)\n  - [Ord](#ord)\n  - [SemigroupAll](#semigroupall)\n  - [SemigroupAny](#semigroupany)\n  - [Show](#show)\n- [pattern matching](#pattern-matching)\n  - [fold](#fold)\n  - [foldW](#foldw)\n  - [match](#match)\n  - [matchW](#matchw)\n- [refinements](#refinements)\n  - [isBoolean](#isboolean)\n\n---\n\n# instances\n\n## BooleanAlgebra\n\n**Signature**\n\n```ts\nexport declare const BooleanAlgebra: BA.BooleanAlgebra<boolean>\n```\n\nAdded in v2.10.0\n\n## Eq\n\n**Signature**\n\n```ts\nexport declare const Eq: E.Eq<boolean>\n```\n\nAdded in v2.10.0\n\n## MonoidAll\n\n`boolean` monoid under conjunction.\n\nThe `empty` value is `true`.\n\n**Signature**\n\n```ts\nexport declare const MonoidAll: Monoid<boolean>\n```\n\n**Example**\n\n```ts\nimport { MonoidAll } from 'fp-ts/boolean'\n\nassert.deepStrictEqual(MonoidAll.concat(true, true), true)\nassert.deepStrictEqual(MonoidAll.concat(true, false), false)\n```\n\nAdded in v2.10.0\n\n## MonoidAny\n\n`boolean` monoid under disjunction.\n\nThe `empty` value is `false`.\n\n**Signature**\n\n```ts\nexport declare const MonoidAny: Monoid<boolean>\n```\n\n**Example**\n\n```ts\nimport { MonoidAny } from 'fp-ts/boolean'\n\nassert.deepStrictEqual(MonoidAny.concat(true, true), true)\nassert.deepStrictEqual(MonoidAny.concat(true, false), true)\nassert.deepStrictEqual(MonoidAny.concat(false, false), false)\n```\n\nAdded in v2.10.0\n\n## Ord\n\n**Signature**\n\n```ts\nexport declare const Ord: O.Ord<boolean>\n```\n\nAdded in v2.10.0\n\n## SemigroupAll\n\n`boolean` semigroup under conjunction.\n\n**Signature**\n\n```ts\nexport declare const SemigroupAll: Semigroup<boolean>\n```\n\n**Example**\n\n```ts\nimport { SemigroupAll } from 'fp-ts/boolean'\n\nassert.deepStrictEqual(SemigroupAll.concat(true, true), true)\nassert.deepStrictEqual(SemigroupAll.concat(true, false), false)\n```\n\nAdded in v2.10.0\n\n## SemigroupAny\n\n`boolean` semigroup under disjunction.\n\n**Signature**\n\n```ts\nexport declare const SemigroupAny: Semigroup<boolean>\n```\n\n**Example**\n\n```ts\nimport { SemigroupAny } from 'fp-ts/boolean'\n\nassert.deepStrictEqual(SemigroupAny.concat(true, true), true)\nassert.deepStrictEqual(SemigroupAny.concat(true, false), true)\nassert.deepStrictEqual(SemigroupAny.concat(false, false), false)\n```\n\nAdded in v2.10.0\n\n## Show\n\n**Signature**\n\n```ts\nexport declare const Show: S.Show<boolean>\n```\n\nAdded in v2.10.0\n\n# pattern matching\n\n## fold\n\nAlias of [`match`](#match).\n\n**Signature**\n\n```ts\nexport declare const fold: <A>(onFalse: LazyArg<A>, onTrue: LazyArg<A>) => (value: boolean) => A\n```\n\nAdded in v2.2.0\n\n## foldW\n\nAlias of [`matchW`](#matchw).\n\n**Signature**\n\n```ts\nexport declare const foldW: <A, B>(onFalse: LazyArg<A>, onTrue: LazyArg<B>) => (value: boolean) => A | B\n```\n\nAdded in v2.10.0\n\n## match\n\nDefines the fold over a boolean value.\nTakes two thunks `onTrue`, `onFalse` and a `boolean` value.\nIf `value` is false, `onFalse()` is returned, otherwise `onTrue()`.\n\n**Signature**\n\n```ts\nexport declare const match: <A>(onFalse: LazyArg<A>, onTrue: LazyArg<A>) => (value: boolean) => A\n```\n\n**Example**\n\n```ts\nimport { some, map } from 'fp-ts/Option'\nimport { pipe } from 'fp-ts/function'\nimport { match } from 'fp-ts/boolean'\n\nassert.deepStrictEqual(\n  pipe(\n    some(true),\n    map(\n      match(\n        () => 'false',\n        () => 'true'\n      )\n    )\n  ),\n  some('true')\n)\n```\n\nAdded in v2.10.0\n\n## matchW\n\nLess strict version of [`match`](#match).\n\nThe `W` suffix (short for **W**idening) means that the handler return types will be merged.\n\n**Signature**\n\n```ts\nexport declare const matchW: <A, B>(onFalse: LazyArg<A>, onTrue: LazyArg<B>) => (value: boolean) => A | B\n```\n\nAdded in v2.10.0\n\n# refinements\n\n## isBoolean\n\n**Signature**\n\n```ts\nexport declare const isBoolean: Refinement<unknown, boolean>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/function.ts.md",
    "content": "---\ntitle: function.ts\nnav_order: 41\nparent: Modules\n---\n\n## function overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [getBooleanAlgebra](#getbooleanalgebra)\n  - [getMonoid](#getmonoid)\n  - [getRing](#getring)\n  - [getSemigroup](#getsemigroup)\n  - [getSemiring](#getsemiring)\n- [lagacy](#lagacy)\n  - [Lazy (interface)](#lazy-interface)\n- [utils](#utils)\n  - [FunctionN (interface)](#functionn-interface)\n  - [LazyArg (interface)](#lazyarg-interface)\n  - [SK](#sk)\n  - [absurd](#absurd)\n  - [apply](#apply)\n  - [constFalse](#constfalse)\n  - [constNull](#constnull)\n  - [constTrue](#consttrue)\n  - [constUndefined](#constundefined)\n  - [constVoid](#constvoid)\n  - [constant](#constant)\n  - [decrement](#decrement)\n  - [flip](#flip)\n  - [flow](#flow)\n  - [hole](#hole)\n  - [identity](#identity)\n  - [increment](#increment)\n  - [pipe](#pipe)\n  - [tuple](#tuple)\n  - [tupled](#tupled)\n  - [unsafeCoerce](#unsafecoerce)\n  - [untupled](#untupled)\n- [zone of death](#zone-of-death)\n  - [~~Endomorphism~~ (interface)](#endomorphism-interface)\n  - [~~Predicate~~ (interface)](#predicate-interface)\n  - [~~Refinement~~ (interface)](#refinement-interface)\n  - [~~getEndomorphismMonoid~~](#getendomorphismmonoid)\n  - [~~not~~](#not)\n\n---\n\n# instances\n\n## getBooleanAlgebra\n\n**Signature**\n\n```ts\nexport declare const getBooleanAlgebra: <B>(B: BooleanAlgebra<B>) => <A = never>() => BooleanAlgebra<(a: A) => B>\n```\n\nAdded in v2.10.0\n\n## getMonoid\n\nUnary functions form a monoid as long as you can provide a monoid for the codomain.\n\n**Signature**\n\n```ts\nexport declare const getMonoid: <M>(M: Monoid<M>) => <A = never>() => Monoid<(a: A) => M>\n```\n\n**Example**\n\n```ts\nimport { Predicate } from 'fp-ts/Predicate'\nimport { getMonoid } from 'fp-ts/function'\nimport * as B from 'fp-ts/boolean'\n\nconst f: Predicate<number> = (n) => n <= 2\nconst g: Predicate<number> = (n) => n >= 0\n\nconst M1 = getMonoid(B.MonoidAll)<number>()\n\nassert.deepStrictEqual(M1.concat(f, g)(1), true)\nassert.deepStrictEqual(M1.concat(f, g)(3), false)\n\nconst M2 = getMonoid(B.MonoidAny)<number>()\n\nassert.deepStrictEqual(M2.concat(f, g)(1), true)\nassert.deepStrictEqual(M2.concat(f, g)(3), true)\n```\n\nAdded in v2.10.0\n\n## getRing\n\n**Signature**\n\n```ts\nexport declare const getRing: <A, B>(R: Ring<B>) => Ring<(a: A) => B>\n```\n\nAdded in v2.10.0\n\n## getSemigroup\n\nUnary functions form a semigroup as long as you can provide a semigroup for the codomain.\n\n**Signature**\n\n```ts\nexport declare const getSemigroup: <S>(S: Semigroup<S>) => <A = never>() => Semigroup<(a: A) => S>\n```\n\n**Example**\n\n```ts\nimport { Predicate, getSemigroup } from 'fp-ts/function'\nimport * as B from 'fp-ts/boolean'\n\nconst f: Predicate<number> = (n) => n <= 2\nconst g: Predicate<number> = (n) => n >= 0\n\nconst S1 = getSemigroup(B.SemigroupAll)<number>()\n\nassert.deepStrictEqual(S1.concat(f, g)(1), true)\nassert.deepStrictEqual(S1.concat(f, g)(3), false)\n\nconst S2 = getSemigroup(B.SemigroupAny)<number>()\n\nassert.deepStrictEqual(S2.concat(f, g)(1), true)\nassert.deepStrictEqual(S2.concat(f, g)(3), true)\n```\n\nAdded in v2.10.0\n\n## getSemiring\n\n**Signature**\n\n```ts\nexport declare const getSemiring: <A, B>(S: Semiring<B>) => Semiring<(a: A) => B>\n```\n\nAdded in v2.10.0\n\n# lagacy\n\n## Lazy (interface)\n\nUse `LazyArg` instead.\n\n**Signature**\n\n```ts\nexport interface Lazy<A> {\n  (): A\n}\n```\n\nAdded in v2.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/function'\n\nexport const sum: FunctionN<[number, number], number> = (a, b) => a + b\n```\n\nAdded in v2.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\nAdded in v2.15.0\n\n## SK\n\n**Signature**\n\n```ts\nexport declare const SK: <A, B>(_: A, b: B) => B\n```\n\nAdded in v2.11.0\n\n## absurd\n\n**Signature**\n\n```ts\nexport declare function absurd<A>(_: never): A\n```\n\nAdded in v2.0.0\n\n## apply\n\n**Signature**\n\n```ts\nexport declare const apply: <A>(a: A) => <B>(f: (a: A) => B) => B\n```\n\nAdded in v2.11.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\nAdded in v2.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\nAdded in v2.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\nAdded in v2.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\nAdded in v2.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\nAdded in v2.0.0\n\n## constant\n\n**Signature**\n\n```ts\nexport declare function constant<A>(a: A): LazyArg<A>\n```\n\nAdded in v2.0.0\n\n## decrement\n\n**Signature**\n\n```ts\nexport declare function decrement(n: number): number\n```\n\nAdded in v2.0.0\n\n## flip\n\nFlips the arguments of a curried function.\n\n**Signature**\n\n```ts\nexport declare function flip<A, B, C>(f: (a: A) => (b: B) => C): (b: B) => (a: A) => C\nexport declare function flip<A, B, C>(f: (a: A, b: B) => C): (b: B, a: A) => C\n```\n\n**Example**\n\n```ts\nimport { flip } from 'fp-ts/function'\n\nconst f = (a: number) => (b: string) => a - b.length\n\nassert.strictEqual(flip(f)('aaa')(2), -1)\n```\n\nAdded in v2.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 [`pipe`](#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/function'\n\nconst len = (s: string): number => s.length\nconst double = (n: number): number => n * 2\n\nconst f = flow(len, double)\n\nassert.strictEqual(f('aaa'), 6)\n```\n\nAdded in v2.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 v2.7.0\n\n## identity\n\n**Signature**\n\n```ts\nexport declare function identity<A>(a: A): A\n```\n\nAdded in v2.0.0\n\n## increment\n\n**Signature**\n\n```ts\nexport declare function increment(n: number): number\n```\n\nAdded in v2.0.0\n\n## pipe\n\nPipes the value of an expression into a pipeline of functions.\n\nSee also [`flow`](#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/function'\n\nconst len = (s: string): number => s.length\nconst double = (n: number): number => n * 2\n\n// without pipe\nassert.strictEqual(double(len('aaa')), 6)\n\n// with pipe\nassert.strictEqual(pipe('aaa', len, double), 6)\n```\n\nAdded in v2.6.3\n\n## tuple\n\n**Signature**\n\n```ts\nexport declare function tuple<T extends ReadonlyArray<any>>(...t: T): T\n```\n\nAdded in v2.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 function tupled<A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => B\n```\n\n**Example**\n\n```ts\nimport { tupled } from 'fp-ts/function'\n\nconst add = tupled((x: number, y: number): number => x + y)\n\nassert.strictEqual(add([1, 2]), 3)\n```\n\nAdded in v2.4.0\n\n## unsafeCoerce\n\n**Signature**\n\n```ts\nexport declare const unsafeCoerce: <A, B>(a: A) => B\n```\n\nAdded in v2.0.0\n\n## untupled\n\nInverse function of `tupled`\n\n**Signature**\n\n```ts\nexport declare function untupled<A extends ReadonlyArray<unknown>, B>(f: (a: A) => B): (...a: A) => B\n```\n\nAdded in v2.4.0\n\n# zone of death\n\n## ~~Endomorphism~~ (interface)\n\nUse `Endomorphism` module instead.\n\n**Signature**\n\n```ts\nexport interface Endomorphism<A> {\n  (a: A): A\n}\n```\n\nAdded in v2.0.0\n\n## ~~Predicate~~ (interface)\n\nUse `Predicate` module instead.\n\n**Signature**\n\n```ts\nexport interface Predicate<A> {\n  (a: A): boolean\n}\n```\n\nAdded in v2.0.0\n\n## ~~Refinement~~ (interface)\n\nUse `Refinement` module instead.\n\n**Signature**\n\n```ts\nexport interface Refinement<A, B extends A> {\n  (a: A): a is B\n}\n```\n\nAdded in v2.0.0\n\n## ~~getEndomorphismMonoid~~\n\nUse `Endomorphism` module instead.\n\n**Signature**\n\n```ts\nexport declare const getEndomorphismMonoid: <A = never>() => Monoid<Endomorphism<A>>\n```\n\nAdded in v2.10.0\n\n## ~~not~~\n\nUse `Predicate` module instead.\n\n**Signature**\n\n```ts\nexport declare function not<A>(predicate: Predicate<A>): Predicate<A>\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/index.md",
    "content": "---\ntitle: Modules\npermalink: /modules/\nnav_order: 4\nhas_children: true\nhas_toc: true\n---\n\n# Modules\n\nThis section provides technical reference material for the functions, data types, and type classes provided by `fp-ts`.\n"
  },
  {
    "path": "docs/modules/index.ts.md",
    "content": "---\ntitle: index.ts\nnav_order: 48\nparent: Modules\n---\n\n## index overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [data types](#data-types)\n  - [array](#array)\n  - [const](#const)\n  - [either](#either)\n  - [endomorphism](#endomorphism)\n  - [identity](#identity)\n  - [io](#io)\n  - [ioEither](#ioeither)\n  - [ioOption](#iooption)\n  - [map](#map)\n  - [nonEmptyArray](#nonemptyarray)\n  - [option](#option)\n  - [predicate](#predicate)\n  - [reader](#reader)\n  - [readerEither](#readereither)\n  - [readerIO](#readerio)\n  - [readerTask](#readertask)\n  - [readerTaskEither](#readertaskeither)\n  - [readonlyArray](#readonlyarray)\n  - [readonlyMap](#readonlymap)\n  - [readonlyNonEmptyArray](#readonlynonemptyarray)\n  - [readonlyRecord](#readonlyrecord)\n  - [readonlySet](#readonlyset)\n  - [readonlyTuple](#readonlytuple)\n  - [record](#record)\n  - [refinement](#refinement)\n  - [separated](#separated)\n  - [set](#set)\n  - [state](#state)\n  - [stateReaderTaskEither](#statereadertaskeither)\n  - [store](#store)\n  - [task](#task)\n  - [taskEither](#taskeither)\n  - [taskOption](#taskoption)\n  - [taskThese](#taskthese)\n  - [these](#these)\n  - [traced](#traced)\n  - [tree](#tree)\n  - [tuple](#tuple)\n  - [validationT](#validationt)\n  - [writer](#writer)\n- [model](#model)\n  - [alt](#alt)\n  - [alternative](#alternative)\n  - [applicative](#applicative)\n  - [apply](#apply)\n  - [bifunctor](#bifunctor)\n  - [booleanAlgebra](#booleanalgebra)\n  - [bounded](#bounded)\n  - [boundedDistributiveLattice](#boundeddistributivelattice)\n  - [boundedJoinSemilattice](#boundedjoinsemilattice)\n  - [boundedLattice](#boundedlattice)\n  - [boundedMeetSemilattice](#boundedmeetsemilattice)\n  - [category](#category)\n  - [chain](#chain)\n  - [chainRec](#chainrec)\n  - [choice](#choice)\n  - [comonad](#comonad)\n  - [compactable](#compactable)\n  - [contravariant](#contravariant)\n  - [distributiveLattice](#distributivelattice)\n  - [eq](#eq)\n  - [extend](#extend)\n  - [field](#field)\n  - [filterable](#filterable)\n  - [filterableWithIndex](#filterablewithindex)\n  - [foldable](#foldable)\n  - [foldableWithIndex](#foldablewithindex)\n  - [fromEither](#fromeither)\n  - [fromIO](#fromio)\n  - [fromReader](#fromreader)\n  - [fromState](#fromstate)\n  - [fromTask](#fromtask)\n  - [fromThese](#fromthese)\n  - [functor](#functor)\n  - [functorWithIndex](#functorwithindex)\n  - [group](#group)\n  - [heytingAlgebra](#heytingalgebra)\n  - [invariant](#invariant)\n  - [joinSemilattice](#joinsemilattice)\n  - [lattice](#lattice)\n  - [magma](#magma)\n  - [meetSemilattice](#meetsemilattice)\n  - [monad](#monad)\n  - [monadIO](#monadio)\n  - [monadTask](#monadtask)\n  - [monadThrow](#monadthrow)\n  - [monoid](#monoid)\n  - [ord](#ord)\n  - [pointed](#pointed)\n  - [profunctor](#profunctor)\n  - [ring](#ring)\n  - [semigroup](#semigroup)\n  - [semigroupoid](#semigroupoid)\n  - [semiring](#semiring)\n  - [show](#show)\n  - [strong](#strong)\n  - [traversable](#traversable)\n  - [traversableWithIndex](#traversablewithindex)\n  - [unfoldable](#unfoldable)\n  - [witherable](#witherable)\n  - [zero](#zero)\n- [monad transformers](#monad-transformers)\n  - [eitherT](#eithert)\n  - [optionT](#optiont)\n  - [readerT](#readert)\n  - [stateT](#statet)\n  - [theseT](#theset)\n  - [writerT](#writert)\n- [utils](#utils)\n  - [boolean](#boolean)\n  - [console](#console)\n  - [date](#date)\n  - [function](#function)\n  - [hkt](#hkt)\n  - [ioRef](#ioref)\n  - [json](#json)\n  - [naturalTransformation](#naturaltransformation)\n  - [number](#number)\n  - [ordering](#ordering)\n  - [pipeable](#pipeable)\n  - [random](#random)\n  - [string](#string)\n  - [struct](#struct)\n- [zone of death](#zone-of-death)\n  - [~~void~~](#void)\n\n---\n\n# data types\n\n## array\n\n**Signature**\n\n```ts\nexport declare const array: typeof array\n```\n\nAdded in v2.0.0\n\n## const\n\n**Signature**\n\n```ts\nexport declare const const: typeof const_\n```\n\nAdded in v2.0.0\n\n## either\n\n**Signature**\n\n```ts\nexport declare const either: typeof either\n```\n\nAdded in v2.0.0\n\n## endomorphism\n\n**Signature**\n\n```ts\nexport declare const endomorphism: typeof endomorphism\n```\n\nAdded in v2.11.0\n\n## identity\n\n**Signature**\n\n```ts\nexport declare const identity: typeof identity\n```\n\nAdded in v2.0.0\n\n## io\n\n**Signature**\n\n```ts\nexport declare const io: typeof io\n```\n\nAdded in v2.0.0\n\n## ioEither\n\n**Signature**\n\n```ts\nexport declare const ioEither: typeof ioEither\n```\n\nAdded in v2.0.0\n\n## ioOption\n\n**Signature**\n\n```ts\nexport declare const ioOption: typeof ioOption\n```\n\nAdded in v2.12.0\n\n## map\n\n**Signature**\n\n```ts\nexport declare const map: typeof map\n```\n\nAdded in v2.0.0\n\n## nonEmptyArray\n\n**Signature**\n\n```ts\nexport declare const nonEmptyArray: typeof nonEmptyArray\n```\n\nAdded in v2.0.0\n\n## option\n\n**Signature**\n\n```ts\nexport declare const option: typeof option\n```\n\nAdded in v2.0.0\n\n## predicate\n\n**Signature**\n\n```ts\nexport declare const predicate: typeof predicate\n```\n\nAdded in v2.11.0\n\n## reader\n\n**Signature**\n\n```ts\nexport declare const reader: typeof reader\n```\n\nAdded in v2.0.0\n\n## readerEither\n\n**Signature**\n\n```ts\nexport declare const readerEither: typeof readerEither\n```\n\nAdded in v2.0.0\n\n## readerIO\n\n**Signature**\n\n```ts\nexport declare const readerIO: typeof readerIO\n```\n\nAdded in v2.0.0\n\n## readerTask\n\n**Signature**\n\n```ts\nexport declare const readerTask: typeof readerTask\n```\n\nAdded in v2.3.0\n\n## readerTaskEither\n\n**Signature**\n\n```ts\nexport declare const readerTaskEither: typeof readerTaskEither\n```\n\nAdded in v2.0.0\n\n## readonlyArray\n\n**Signature**\n\n```ts\nexport declare const readonlyArray: typeof readonlyArray\n```\n\nAdded in v2.5.0\n\n## readonlyMap\n\n**Signature**\n\n```ts\nexport declare const readonlyMap: typeof readonlyMap\n```\n\nAdded in v2.5.0\n\n## readonlyNonEmptyArray\n\n**Signature**\n\n```ts\nexport declare const readonlyNonEmptyArray: typeof readonlyNonEmptyArray\n```\n\nAdded in v2.5.0\n\n## readonlyRecord\n\n**Signature**\n\n```ts\nexport declare const readonlyRecord: typeof readonlyRecord\n```\n\nAdded in v2.5.0\n\n## readonlySet\n\n**Signature**\n\n```ts\nexport declare const readonlySet: typeof readonlySet\n```\n\nAdded in v2.5.0\n\n## readonlyTuple\n\n**Signature**\n\n```ts\nexport declare const readonlyTuple: typeof readonlyTuple\n```\n\nAdded in v2.5.0\n\n## record\n\n**Signature**\n\n```ts\nexport declare const record: typeof record\n```\n\nAdded in v2.0.0\n\n## refinement\n\n**Signature**\n\n```ts\nexport declare const refinement: typeof refinement\n```\n\nAdded in v2.11.0\n\n## separated\n\n**Signature**\n\n```ts\nexport declare const separated: typeof separated\n```\n\nAdded in v2.10.0\n\n## set\n\n**Signature**\n\n```ts\nexport declare const set: typeof set\n```\n\nAdded in v2.0.0\n\n## state\n\n**Signature**\n\n```ts\nexport declare const state: typeof state\n```\n\nAdded in v2.0.0\n\n## stateReaderTaskEither\n\n**Signature**\n\n```ts\nexport declare const stateReaderTaskEither: typeof stateReaderTaskEither\n```\n\nAdded in v2.0.0\n\n## store\n\n**Signature**\n\n```ts\nexport declare const store: typeof store\n```\n\nAdded in v2.0.0\n\n## task\n\n**Signature**\n\n```ts\nexport declare const task: typeof task\n```\n\nAdded in v2.0.0\n\n## taskEither\n\n**Signature**\n\n```ts\nexport declare const taskEither: typeof taskEither\n```\n\nAdded in v2.0.0\n\n## taskOption\n\n**Signature**\n\n```ts\nexport declare const taskOption: typeof taskOption\n```\n\nAdded in v2.10.0\n\n## taskThese\n\n**Signature**\n\n```ts\nexport declare const taskThese: typeof taskThese\n```\n\nAdded in v2.4.0\n\n## these\n\n**Signature**\n\n```ts\nexport declare const these: typeof these\n```\n\nAdded in v2.0.0\n\n## traced\n\n**Signature**\n\n```ts\nexport declare const traced: typeof traced\n```\n\nAdded in v2.0.0\n\n## tree\n\n**Signature**\n\n```ts\nexport declare const tree: typeof tree\n```\n\nAdded in v2.0.0\n\n## tuple\n\n**Signature**\n\n```ts\nexport declare const tuple: typeof tuple\n```\n\nAdded in v2.0.0\n\n## validationT\n\n**Signature**\n\n```ts\nexport declare const validationT: typeof validationT\n```\n\nAdded in v2.0.0\n\n## writer\n\n**Signature**\n\n```ts\nexport declare const writer: typeof writer\n```\n\nAdded in v2.0.0\n\n# model\n\n## alt\n\n**Signature**\n\n```ts\nexport declare const alt: typeof alt\n```\n\nAdded in v2.0.0\n\n## alternative\n\n**Signature**\n\n```ts\nexport declare const alternative: typeof alternative\n```\n\nAdded in v2.0.0\n\n## applicative\n\n**Signature**\n\n```ts\nexport declare const applicative: typeof applicative\n```\n\nAdded in v2.0.0\n\n## apply\n\n**Signature**\n\n```ts\nexport declare const apply: typeof apply\n```\n\nAdded in v2.0.0\n\n## bifunctor\n\n**Signature**\n\n```ts\nexport declare const bifunctor: typeof bifunctor\n```\n\nAdded in v2.0.0\n\n## booleanAlgebra\n\n**Signature**\n\n```ts\nexport declare const booleanAlgebra: typeof booleanAlgebra\n```\n\nAdded in v2.0.0\n\n## bounded\n\n**Signature**\n\n```ts\nexport declare const bounded: typeof bounded\n```\n\nAdded in v2.0.0\n\n## boundedDistributiveLattice\n\n**Signature**\n\n```ts\nexport declare const boundedDistributiveLattice: typeof boundedDistributiveLattice\n```\n\nAdded in v2.0.0\n\n## boundedJoinSemilattice\n\n**Signature**\n\n```ts\nexport declare const boundedJoinSemilattice: typeof boundedJoinSemilattice\n```\n\nAdded in v2.0.0\n\n## boundedLattice\n\n**Signature**\n\n```ts\nexport declare const boundedLattice: typeof boundedLattice\n```\n\nAdded in v2.0.0\n\n## boundedMeetSemilattice\n\n**Signature**\n\n```ts\nexport declare const boundedMeetSemilattice: typeof boundedMeetSemilattice\n```\n\nAdded in v2.0.0\n\n## category\n\n**Signature**\n\n```ts\nexport declare const category: typeof category\n```\n\nAdded in v2.0.0\n\n## chain\n\n**Signature**\n\n```ts\nexport declare const chain: typeof chain\n```\n\nAdded in v2.0.0\n\n## chainRec\n\n**Signature**\n\n```ts\nexport declare const chainRec: typeof chainRec\n```\n\nAdded in v2.0.0\n\n## choice\n\n**Signature**\n\n```ts\nexport declare const choice: typeof choice\n```\n\nAdded in v2.0.0\n\n## comonad\n\n**Signature**\n\n```ts\nexport declare const comonad: typeof comonad\n```\n\nAdded in v2.0.0\n\n## compactable\n\n**Signature**\n\n```ts\nexport declare const compactable: typeof compactable\n```\n\nAdded in v2.0.0\n\n## contravariant\n\n**Signature**\n\n```ts\nexport declare const contravariant: typeof contravariant\n```\n\nAdded in v2.0.0\n\n## distributiveLattice\n\n**Signature**\n\n```ts\nexport declare const distributiveLattice: typeof distributiveLattice\n```\n\nAdded in v2.0.0\n\n## eq\n\n**Signature**\n\n```ts\nexport declare const eq: typeof eq\n```\n\nAdded in v2.0.0\n\n## extend\n\n**Signature**\n\n```ts\nexport declare const extend: typeof extend\n```\n\nAdded in v2.0.0\n\n## field\n\n**Signature**\n\n```ts\nexport declare const field: typeof field\n```\n\nAdded in v2.0.0\n\n## filterable\n\n**Signature**\n\n```ts\nexport declare const filterable: typeof filterable\n```\n\nAdded in v2.0.0\n\n## filterableWithIndex\n\n**Signature**\n\n```ts\nexport declare const filterableWithIndex: typeof filterableWithIndex\n```\n\nAdded in v2.0.0\n\n## foldable\n\n**Signature**\n\n```ts\nexport declare const foldable: typeof foldable\n```\n\nAdded in v2.0.0\n\n## foldableWithIndex\n\n**Signature**\n\n```ts\nexport declare const foldableWithIndex: typeof foldableWithIndex\n```\n\nAdded in v2.0.0\n\n## fromEither\n\n**Signature**\n\n```ts\nexport declare const fromEither: typeof fromEither\n```\n\nAdded in v2.10.0\n\n## fromIO\n\n**Signature**\n\n```ts\nexport declare const fromIO: typeof fromIO\n```\n\nAdded in v2.10.0\n\n## fromReader\n\n**Signature**\n\n```ts\nexport declare const fromReader: typeof fromReader\n```\n\nAdded in v2.11.0\n\n## fromState\n\n**Signature**\n\n```ts\nexport declare const fromState: typeof fromState\n```\n\nAdded in v2.11.0\n\n## fromTask\n\n**Signature**\n\n```ts\nexport declare const fromTask: typeof fromTask\n```\n\nAdded in v2.10.0\n\n## fromThese\n\n**Signature**\n\n```ts\nexport declare const fromThese: typeof fromThese\n```\n\nAdded in v2.11.0\n\n## functor\n\n**Signature**\n\n```ts\nexport declare const functor: typeof functor\n```\n\nAdded in v2.0.0\n\n## functorWithIndex\n\n**Signature**\n\n```ts\nexport declare const functorWithIndex: typeof functorWithIndex\n```\n\nAdded in v2.0.0\n\n## group\n\n**Signature**\n\n```ts\nexport declare const group: typeof group\n```\n\nAdded in v2.0.0\n\n## heytingAlgebra\n\n**Signature**\n\n```ts\nexport declare const heytingAlgebra: typeof heytingAlgebra\n```\n\nAdded in v2.0.0\n\n## invariant\n\n**Signature**\n\n```ts\nexport declare const invariant: typeof invariant\n```\n\nAdded in v2.0.0\n\n## joinSemilattice\n\n**Signature**\n\n```ts\nexport declare const joinSemilattice: typeof joinSemilattice\n```\n\nAdded in v2.0.0\n\n## lattice\n\n**Signature**\n\n```ts\nexport declare const lattice: typeof lattice\n```\n\nAdded in v2.0.0\n\n## magma\n\n**Signature**\n\n```ts\nexport declare const magma: typeof magma\n```\n\nAdded in v2.0.0\n\n## meetSemilattice\n\n**Signature**\n\n```ts\nexport declare const meetSemilattice: typeof meetSemilattice\n```\n\nAdded in v2.0.0\n\n## monad\n\n**Signature**\n\n```ts\nexport declare const monad: typeof monad\n```\n\nAdded in v2.0.0\n\n## monadIO\n\n**Signature**\n\n```ts\nexport declare const monadIO: typeof monadIO\n```\n\nAdded in v2.0.0\n\n## monadTask\n\n**Signature**\n\n```ts\nexport declare const monadTask: typeof monadTask\n```\n\nAdded in v2.0.0\n\n## monadThrow\n\n**Signature**\n\n```ts\nexport declare const monadThrow: typeof monadThrow\n```\n\nAdded in v2.0.0\n\n## monoid\n\n**Signature**\n\n```ts\nexport declare const monoid: typeof monoid\n```\n\nAdded in v2.0.0\n\n## ord\n\n**Signature**\n\n```ts\nexport declare const ord: typeof ord\n```\n\nAdded in v2.0.0\n\n## pointed\n\n**Signature**\n\n```ts\nexport declare const pointed: typeof pointed\n```\n\nAdded in v2.10.0\n\n## profunctor\n\n**Signature**\n\n```ts\nexport declare const profunctor: typeof profunctor\n```\n\nAdded in v2.0.0\n\n## ring\n\n**Signature**\n\n```ts\nexport declare const ring: typeof ring\n```\n\nAdded in v2.0.0\n\n## semigroup\n\n**Signature**\n\n```ts\nexport declare const semigroup: typeof semigroup\n```\n\nAdded in v2.0.0\n\n## semigroupoid\n\n**Signature**\n\n```ts\nexport declare const semigroupoid: typeof semigroupoid\n```\n\nAdded in v2.0.0\n\n## semiring\n\n**Signature**\n\n```ts\nexport declare const semiring: typeof semiring\n```\n\nAdded in v2.0.0\n\n## show\n\n**Signature**\n\n```ts\nexport declare const show: typeof show\n```\n\nAdded in v2.0.0\n\n## strong\n\n**Signature**\n\n```ts\nexport declare const strong: typeof strong\n```\n\nAdded in v2.0.0\n\n## traversable\n\n**Signature**\n\n```ts\nexport declare const traversable: typeof traversable\n```\n\nAdded in v2.0.0\n\n## traversableWithIndex\n\n**Signature**\n\n```ts\nexport declare const traversableWithIndex: typeof traversableWithIndex\n```\n\nAdded in v2.0.0\n\n## unfoldable\n\n**Signature**\n\n```ts\nexport declare const unfoldable: typeof unfoldable\n```\n\nAdded in v2.0.0\n\n## witherable\n\n**Signature**\n\n```ts\nexport declare const witherable: typeof witherable\n```\n\nAdded in v2.0.0\n\n## zero\n\n**Signature**\n\n```ts\nexport declare const zero: typeof zero\n```\n\nAdded in v2.11.0\n\n# monad transformers\n\n## eitherT\n\n**Signature**\n\n```ts\nexport declare const eitherT: typeof eitherT\n```\n\nAdded in v2.0.0\n\n## optionT\n\n**Signature**\n\n```ts\nexport declare const optionT: typeof optionT\n```\n\nAdded in v2.0.0\n\n## readerT\n\n**Signature**\n\n```ts\nexport declare const readerT: typeof readerT\n```\n\nAdded in v2.0.0\n\n## stateT\n\n**Signature**\n\n```ts\nexport declare const stateT: typeof stateT\n```\n\nAdded in v2.0.0\n\n## theseT\n\n**Signature**\n\n```ts\nexport declare const theseT: typeof theseT\n```\n\nAdded in v2.4.0\n\n## writerT\n\n**Signature**\n\n```ts\nexport declare const writerT: typeof writerT\n```\n\nAdded in v2.4.0\n\n# utils\n\n## boolean\n\n**Signature**\n\n```ts\nexport declare const boolean: typeof boolean\n```\n\nAdded in v2.2.0\n\n## console\n\n**Signature**\n\n```ts\nexport declare const console: typeof console\n```\n\nAdded in v2.0.0\n\n## date\n\n**Signature**\n\n```ts\nexport declare const date: typeof date\n```\n\nAdded in v2.0.0\n\n## function\n\n**Signature**\n\n```ts\nexport declare const function: typeof function_\n```\n\nAdded in v2.0.0\n\n## hkt\n\n**Signature**\n\n```ts\nexport declare const hkt: typeof hkt\n```\n\nAdded in v2.0.0\n\n## ioRef\n\n**Signature**\n\n```ts\nexport declare const ioRef: typeof ioRef\n```\n\nAdded in v2.0.0\n\n## json\n\n**Signature**\n\n```ts\nexport declare const json: typeof json\n```\n\nAdded in v2.10.0\n\n## naturalTransformation\n\n**Signature**\n\n```ts\nexport declare const naturalTransformation: typeof naturalTransformation\n```\n\nAdded in v2.11.0\n\n## number\n\n**Signature**\n\n```ts\nexport declare const number: typeof number\n```\n\nAdded in v2.10.0\n\n## ordering\n\n**Signature**\n\n```ts\nexport declare const ordering: typeof ordering\n```\n\nAdded in v2.0.0\n\n## pipeable\n\n**Signature**\n\n```ts\nexport declare const pipeable: typeof pipeable\n```\n\nAdded in v2.0.0\n\n## random\n\n**Signature**\n\n```ts\nexport declare const random: typeof random\n```\n\nAdded in v2.0.0\n\n## string\n\n**Signature**\n\n```ts\nexport declare const string: typeof string\n```\n\nAdded in v2.10.0\n\n## struct\n\n**Signature**\n\n```ts\nexport declare const struct: typeof struct\n```\n\nAdded in v2.10.0\n\n# zone of death\n\n## ~~void~~\n\n**Signature**\n\n```ts\nexport declare const void: typeof void_\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/number.ts.md",
    "content": "---\ntitle: number.ts\nnav_order: 67\nparent: Modules\n---\n\n## number overview\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [Bounded](#bounded)\n  - [Eq](#eq)\n  - [Field](#field)\n  - [MagmaSub](#magmasub)\n  - [MonoidProduct](#monoidproduct)\n  - [MonoidSum](#monoidsum)\n  - [Ord](#ord)\n  - [SemigroupProduct](#semigroupproduct)\n  - [SemigroupSum](#semigroupsum)\n  - [Show](#show)\n- [refinements](#refinements)\n  - [isNumber](#isnumber)\n\n---\n\n# instances\n\n## Bounded\n\n**Signature**\n\n```ts\nexport declare const Bounded: B.Bounded<number>\n```\n\nAdded in v2.10.0\n\n## Eq\n\n**Signature**\n\n```ts\nexport declare const Eq: E.Eq<number>\n```\n\nAdded in v2.10.0\n\n## Field\n\n**Signature**\n\n```ts\nexport declare const Field: F.Field<number>\n```\n\nAdded in v2.10.0\n\n## MagmaSub\n\n**Signature**\n\n```ts\nexport declare const MagmaSub: Magma<number>\n```\n\nAdded in v2.11.0\n\n## MonoidProduct\n\n`number` monoid under multiplication.\n\nThe `empty` value is `1`.\n\n**Signature**\n\n```ts\nexport declare const MonoidProduct: Monoid<number>\n```\n\n**Example**\n\n```ts\nimport { MonoidProduct } from 'fp-ts/number'\n\nassert.deepStrictEqual(MonoidProduct.concat(2, MonoidProduct.empty), 2)\n```\n\nAdded in v2.10.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<number>\n```\n\n**Example**\n\n```ts\nimport { MonoidSum } from 'fp-ts/number'\n\nassert.deepStrictEqual(MonoidSum.concat(2, MonoidSum.empty), 2)\n```\n\nAdded in v2.10.0\n\n## Ord\n\n**Signature**\n\n```ts\nexport declare const Ord: O.Ord<number>\n```\n\nAdded in v2.10.0\n\n## SemigroupProduct\n\n`number` semigroup under multiplication.\n\n**Signature**\n\n```ts\nexport declare const SemigroupProduct: Semigroup<number>\n```\n\n**Example**\n\n```ts\nimport { SemigroupProduct } from 'fp-ts/number'\n\nassert.deepStrictEqual(SemigroupProduct.concat(2, 3), 6)\n```\n\nAdded in v2.10.0\n\n## SemigroupSum\n\n`number` semigroup under addition.\n\n**Signature**\n\n```ts\nexport declare const SemigroupSum: Semigroup<number>\n```\n\n**Example**\n\n```ts\nimport { SemigroupSum } from 'fp-ts/number'\n\nassert.deepStrictEqual(SemigroupSum.concat(2, 3), 5)\n```\n\nAdded in v2.10.0\n\n## Show\n\n**Signature**\n\n```ts\nexport declare const Show: S.Show<number>\n```\n\nAdded in v2.10.0\n\n# refinements\n\n## isNumber\n\n**Signature**\n\n```ts\nexport declare const isNumber: Refinement<unknown, number>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/pipeable.ts.md",
    "content": "---\ntitle: pipeable.ts\nnav_order: 72\nparent: Modules\n---\n\n## pipeable overview\n\nAdded in v2.0.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [pipeable helper](#pipeable-helper)\n  - [alt](#alt)\n  - [ap](#ap)\n  - [bimap](#bimap)\n  - [chain](#chain)\n  - [compose](#compose)\n  - [contramap](#contramap)\n  - [extend](#extend)\n  - [filter](#filter)\n  - [filterMap](#filtermap)\n  - [filterMapWithIndex](#filtermapwithindex)\n  - [filterWithIndex](#filterwithindex)\n  - [foldMap](#foldmap)\n  - [foldMapWithIndex](#foldmapwithindex)\n  - [map](#map)\n  - [mapLeft](#mapleft)\n  - [mapWithIndex](#mapwithindex)\n  - [partition](#partition)\n  - [partitionMap](#partitionmap)\n  - [partitionMapWithIndex](#partitionmapwithindex)\n  - [partitionWithIndex](#partitionwithindex)\n  - [promap](#promap)\n  - [reduce](#reduce)\n  - [reduceRight](#reduceright)\n  - [reduceRightWithIndex](#reducerightwithindex)\n  - [reduceWithIndex](#reducewithindex)\n- [utils](#utils)\n  - [~~PipeableAlt3C~~ (interface)](#pipeablealt3c-interface)\n  - [~~PipeableApply3C~~ (interface)](#pipeableapply3c-interface)\n  - [~~PipeableBifunctor3C~~ (interface)](#pipeablebifunctor3c-interface)\n  - [~~PipeableChain3C~~ (interface)](#pipeablechain3c-interface)\n  - [~~PipeableCompactable3C~~ (interface)](#pipeablecompactable3c-interface)\n  - [~~PipeableContravariant3C~~ (interface)](#pipeablecontravariant3c-interface)\n  - [~~PipeableExtend3C~~ (interface)](#pipeableextend3c-interface)\n  - [~~PipeableFilterable3C~~ (interface)](#pipeablefilterable3c-interface)\n  - [~~PipeableFilterableWithIndex3C~~ (interface)](#pipeablefilterablewithindex3c-interface)\n  - [~~PipeableFoldable3C~~ (interface)](#pipeablefoldable3c-interface)\n  - [~~PipeableFoldableWithIndex3C~~ (interface)](#pipeablefoldablewithindex3c-interface)\n  - [~~PipeableFunctor3C~~ (interface)](#pipeablefunctor3c-interface)\n  - [~~PipeableFunctorWithIndex3C~~ (interface)](#pipeablefunctorwithindex3c-interface)\n  - [~~PipeableMonadThrow3C~~ (interface)](#pipeablemonadthrow3c-interface)\n  - [~~PipeableProfunctor3C~~ (interface)](#pipeableprofunctor3c-interface)\n  - [~~PipeableSemigroupoid3C~~ (interface)](#pipeablesemigroupoid3c-interface)\n  - [~~pipe~~](#pipe)\n- [zone of death](#zone-of-death)\n  - [~~PipeableAlt1~~ (interface)](#pipeablealt1-interface)\n  - [~~PipeableAlt2C~~ (interface)](#pipeablealt2c-interface)\n  - [~~PipeableAlt2~~ (interface)](#pipeablealt2-interface)\n  - [~~PipeableAlt3~~ (interface)](#pipeablealt3-interface)\n  - [~~PipeableAlt4~~ (interface)](#pipeablealt4-interface)\n  - [~~PipeableAlt~~ (interface)](#pipeablealt-interface)\n  - [~~PipeableApply1~~ (interface)](#pipeableapply1-interface)\n  - [~~PipeableApply2C~~ (interface)](#pipeableapply2c-interface)\n  - [~~PipeableApply2~~ (interface)](#pipeableapply2-interface)\n  - [~~PipeableApply3~~ (interface)](#pipeableapply3-interface)\n  - [~~PipeableApply4~~ (interface)](#pipeableapply4-interface)\n  - [~~PipeableApply~~ (interface)](#pipeableapply-interface)\n  - [~~PipeableBifunctor2~~ (interface)](#pipeablebifunctor2-interface)\n  - [~~PipeableBifunctor3~~ (interface)](#pipeablebifunctor3-interface)\n  - [~~PipeableBifunctor4~~ (interface)](#pipeablebifunctor4-interface)\n  - [~~PipeableBifunctor~~ (interface)](#pipeablebifunctor-interface)\n  - [~~PipeableChain1~~ (interface)](#pipeablechain1-interface)\n  - [~~PipeableChain2C~~ (interface)](#pipeablechain2c-interface)\n  - [~~PipeableChain2~~ (interface)](#pipeablechain2-interface)\n  - [~~PipeableChain3~~ (interface)](#pipeablechain3-interface)\n  - [~~PipeableChain4~~ (interface)](#pipeablechain4-interface)\n  - [~~PipeableChain~~ (interface)](#pipeablechain-interface)\n  - [~~PipeableCompactable1~~ (interface)](#pipeablecompactable1-interface)\n  - [~~PipeableCompactable2C~~ (interface)](#pipeablecompactable2c-interface)\n  - [~~PipeableCompactable2~~ (interface)](#pipeablecompactable2-interface)\n  - [~~PipeableCompactable3~~ (interface)](#pipeablecompactable3-interface)\n  - [~~PipeableCompactable4~~ (interface)](#pipeablecompactable4-interface)\n  - [~~PipeableCompactable~~ (interface)](#pipeablecompactable-interface)\n  - [~~PipeableContravariant1~~ (interface)](#pipeablecontravariant1-interface)\n  - [~~PipeableContravariant2C~~ (interface)](#pipeablecontravariant2c-interface)\n  - [~~PipeableContravariant2~~ (interface)](#pipeablecontravariant2-interface)\n  - [~~PipeableContravariant3~~ (interface)](#pipeablecontravariant3-interface)\n  - [~~PipeableContravariant4~~ (interface)](#pipeablecontravariant4-interface)\n  - [~~PipeableContravariant~~ (interface)](#pipeablecontravariant-interface)\n  - [~~PipeableExtend1~~ (interface)](#pipeableextend1-interface)\n  - [~~PipeableExtend2C~~ (interface)](#pipeableextend2c-interface)\n  - [~~PipeableExtend2~~ (interface)](#pipeableextend2-interface)\n  - [~~PipeableExtend3~~ (interface)](#pipeableextend3-interface)\n  - [~~PipeableExtend4~~ (interface)](#pipeableextend4-interface)\n  - [~~PipeableExtend~~ (interface)](#pipeableextend-interface)\n  - [~~PipeableFilterable1~~ (interface)](#pipeablefilterable1-interface)\n  - [~~PipeableFilterable2C~~ (interface)](#pipeablefilterable2c-interface)\n  - [~~PipeableFilterable2~~ (interface)](#pipeablefilterable2-interface)\n  - [~~PipeableFilterable3~~ (interface)](#pipeablefilterable3-interface)\n  - [~~PipeableFilterable4~~ (interface)](#pipeablefilterable4-interface)\n  - [~~PipeableFilterableWithIndex1~~ (interface)](#pipeablefilterablewithindex1-interface)\n  - [~~PipeableFilterableWithIndex2C~~ (interface)](#pipeablefilterablewithindex2c-interface)\n  - [~~PipeableFilterableWithIndex2~~ (interface)](#pipeablefilterablewithindex2-interface)\n  - [~~PipeableFilterableWithIndex3~~ (interface)](#pipeablefilterablewithindex3-interface)\n  - [~~PipeableFilterableWithIndex4~~ (interface)](#pipeablefilterablewithindex4-interface)\n  - [~~PipeableFilterableWithIndex~~ (interface)](#pipeablefilterablewithindex-interface)\n  - [~~PipeableFilterable~~ (interface)](#pipeablefilterable-interface)\n  - [~~PipeableFoldable1~~ (interface)](#pipeablefoldable1-interface)\n  - [~~PipeableFoldable2C~~ (interface)](#pipeablefoldable2c-interface)\n  - [~~PipeableFoldable2~~ (interface)](#pipeablefoldable2-interface)\n  - [~~PipeableFoldable3~~ (interface)](#pipeablefoldable3-interface)\n  - [~~PipeableFoldable4~~ (interface)](#pipeablefoldable4-interface)\n  - [~~PipeableFoldableWithIndex1~~ (interface)](#pipeablefoldablewithindex1-interface)\n  - [~~PipeableFoldableWithIndex2C~~ (interface)](#pipeablefoldablewithindex2c-interface)\n  - [~~PipeableFoldableWithIndex2~~ (interface)](#pipeablefoldablewithindex2-interface)\n  - [~~PipeableFoldableWithIndex3~~ (interface)](#pipeablefoldablewithindex3-interface)\n  - [~~PipeableFoldableWithIndex4~~ (interface)](#pipeablefoldablewithindex4-interface)\n  - [~~PipeableFoldableWithIndex~~ (interface)](#pipeablefoldablewithindex-interface)\n  - [~~PipeableFoldable~~ (interface)](#pipeablefoldable-interface)\n  - [~~PipeableFunctor1~~ (interface)](#pipeablefunctor1-interface)\n  - [~~PipeableFunctor2C~~ (interface)](#pipeablefunctor2c-interface)\n  - [~~PipeableFunctor2~~ (interface)](#pipeablefunctor2-interface)\n  - [~~PipeableFunctor3~~ (interface)](#pipeablefunctor3-interface)\n  - [~~PipeableFunctor4~~ (interface)](#pipeablefunctor4-interface)\n  - [~~PipeableFunctorWithIndex1~~ (interface)](#pipeablefunctorwithindex1-interface)\n  - [~~PipeableFunctorWithIndex2C~~ (interface)](#pipeablefunctorwithindex2c-interface)\n  - [~~PipeableFunctorWithIndex2~~ (interface)](#pipeablefunctorwithindex2-interface)\n  - [~~PipeableFunctorWithIndex3~~ (interface)](#pipeablefunctorwithindex3-interface)\n  - [~~PipeableFunctorWithIndex4~~ (interface)](#pipeablefunctorwithindex4-interface)\n  - [~~PipeableFunctorWithIndex~~ (interface)](#pipeablefunctorwithindex-interface)\n  - [~~PipeableFunctor~~ (interface)](#pipeablefunctor-interface)\n  - [~~PipeableMonadThrow1~~ (interface)](#pipeablemonadthrow1-interface)\n  - [~~PipeableMonadThrow2C~~ (interface)](#pipeablemonadthrow2c-interface)\n  - [~~PipeableMonadThrow2~~ (interface)](#pipeablemonadthrow2-interface)\n  - [~~PipeableMonadThrow3~~ (interface)](#pipeablemonadthrow3-interface)\n  - [~~PipeableMonadThrow4~~ (interface)](#pipeablemonadthrow4-interface)\n  - [~~PipeableMonadThrow~~ (interface)](#pipeablemonadthrow-interface)\n  - [~~PipeableProfunctor2C~~ (interface)](#pipeableprofunctor2c-interface)\n  - [~~PipeableProfunctor2~~ (interface)](#pipeableprofunctor2-interface)\n  - [~~PipeableProfunctor3~~ (interface)](#pipeableprofunctor3-interface)\n  - [~~PipeableProfunctor4~~ (interface)](#pipeableprofunctor4-interface)\n  - [~~PipeableProfunctor~~ (interface)](#pipeableprofunctor-interface)\n  - [~~PipeableSemigroupoid2C~~ (interface)](#pipeablesemigroupoid2c-interface)\n  - [~~PipeableSemigroupoid2~~ (interface)](#pipeablesemigroupoid2-interface)\n  - [~~PipeableSemigroupoid3~~ (interface)](#pipeablesemigroupoid3-interface)\n  - [~~PipeableSemigroupoid4~~ (interface)](#pipeablesemigroupoid4-interface)\n  - [~~PipeableSemigroupoid~~ (interface)](#pipeablesemigroupoid-interface)\n  - [~~pipeable~~](#pipeable)\n\n---\n\n# pipeable helper\n\n## alt\n\nReturns a pipeable `alt`\n\n**Signature**\n\n```ts\nexport declare function alt<F extends URIS4>(\n  F: Alt4<F>\n): <S, R, E, A>(that: LazyArg<Kind4<F, S, R, E, A>>) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\nexport declare function alt<F extends URIS3>(\n  F: Alt3<F>\n): <R, E, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\nexport declare function alt<F extends URIS3, E>(\n  F: Alt3C<F, E>\n): <R, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\nexport declare function alt<F extends URIS2>(\n  F: Alt2<F>\n): <E, A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>\nexport declare function alt<F extends URIS2, E>(\n  F: Alt2C<F, E>\n): <A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>\nexport declare function alt<F extends URIS>(\n  F: Alt1<F>\n): <A>(that: LazyArg<Kind<F, A>>) => (fa: Kind<F, A>) => Kind<F, A>\nexport declare function alt<F>(F: Alt<F>): <A>(that: LazyArg<HKT<F, A>>) => (fa: HKT<F, A>) => HKT<F, A>\n```\n\nAdded in v2.13.0\n\n## ap\n\nReturns a pipeable `ap`\n\n**Signature**\n\n```ts\nexport declare function ap<F extends URIS4>(\n  F: Apply4<F>\n): <S, R, E, A>(fa: Kind4<F, S, R, E, A>) => <B>(fab: Kind4<F, S, R, E, (a: A) => B>) => Kind4<F, S, R, E, B>\nexport declare function ap<F extends URIS3>(\n  F: Apply3<F>\n): <R, E, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\nexport declare function ap<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <R, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\nexport declare function ap<F extends URIS2>(\n  F: Apply2<F>\n): <E, A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\nexport declare function ap<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\nexport declare function ap<F extends URIS>(\n  F: Apply1<F>\n): <A>(fa: Kind<F, A>) => <B>(fab: Kind<F, (a: A) => B>) => Kind<F, B>\nexport declare function ap<F>(F: Apply<F>): <A>(fa: HKT<F, A>) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B>\n```\n\nAdded in v2.13.0\n\n## bimap\n\nReturns a pipeable `bimap`\n\n**Signature**\n\n```ts\nexport declare function bimap<F extends URIS4>(\n  F: Bifunctor4<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <S, R>(fea: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, B>\nexport declare function bimap<F extends URIS3>(\n  F: Bifunctor3<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, B>\nexport declare function bimap<F extends URIS3, E>(\n  F: Bifunctor3C<F, E>\n): <G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, B>\nexport declare function bimap<F extends URIS2>(\n  F: Bifunctor2<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind2<F, E, A>) => Kind2<F, G, B>\nexport declare function bimap<F extends URIS2, E>(\n  F: Bifunctor2C<F, E>\n): <G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind2<F, E, A>) => Kind2<F, G, B>\nexport declare function bimap<F>(\n  F: Bifunctor<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: HKT2<F, E, A>) => HKT2<F, G, B>\n```\n\nAdded in v2.13.0\n\n## chain\n\nReturns a pipeable `chain`\n\n**Signature**\n\n```ts\nexport declare function chain<F extends URIS4>(\n  F: Chain4<F>\n): <A, S, R, E, B>(f: (a: A) => Kind4<F, S, R, E, B>) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport declare function chain<F extends URIS3>(\n  F: Chain3<F>\n): <A, R, E, B>(f: (a: A) => Kind3<F, R, E, B>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function chain<F extends URIS3, E>(\n  F: Chain3C<F, E>\n): <A, R, B>(f: (a: A) => Kind3<F, R, E, B>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function chain<F extends URIS2>(\n  F: Chain2<F>\n): <A, E, B>(f: (a: A) => Kind2<F, E, B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function chain<F extends URIS2, E>(\n  F: Chain2C<F, E>\n): <A, B>(f: (a: A) => Kind2<F, E, B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function chain<F extends URIS>(\n  F: Chain1<F>\n): <A, B>(f: (a: A) => Kind<F, B>) => (fa: Kind<F, A>) => Kind<F, B>\nexport declare function chain<F>(F: Chain<F>): <A, B>(f: (a: A) => HKT<F, B>) => (fa: HKT<F, A>) => HKT<F, B>\n```\n\nAdded in v2.13.0\n\n## compose\n\nReturns a pipeable `compose`\n\n**Signature**\n\n```ts\nexport declare function compose<F extends URIS4>(\n  F: Semigroupoid4<F>\n): <S, R, E, A>(ea: Kind4<F, S, R, E, A>) => <B>(ab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, E, B>\nexport declare function compose<F extends URIS3>(\n  F: Semigroupoid3<F>\n): <R, E, A>(ea: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>\nexport declare function compose<F extends URIS3, E>(\n  F: Semigroupoid3C<F, E>\n): <R, A>(ea: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>\nexport declare function compose<F extends URIS2>(\n  F: Semigroupoid2<F>\n): <E, A>(ea: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>\nexport declare function compose<F extends URIS2, E>(\n  F: Semigroupoid2C<F, E>\n): <A>(ea: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>\nexport declare function compose<F>(\n  F: Semigroupoid<F>\n): <E, A>(ea: HKT2<F, E, A>) => <B>(ab: HKT2<F, A, B>) => HKT2<F, E, B>\n```\n\nAdded in v2.13.0\n\n## contramap\n\nReturns a pipeable `contramap`\n\n**Signature**\n\n```ts\nexport declare function contramap<F extends URIS4>(\n  F: Contravariant4<F>\n): <A, B>(f: (b: B) => A) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport declare function contramap<F extends URIS3>(\n  F: Contravariant3<F>\n): <A, B>(f: (b: B) => A) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function contramap<F extends URIS3, E>(\n  F: Contravariant3C<F, E>\n): <A, B>(f: (b: B) => A) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function contramap<F extends URIS2>(\n  F: Contravariant2<F>\n): <A, B>(f: (b: B) => A) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function contramap<F extends URIS2, E>(\n  F: Contravariant2C<F, E>\n): <A, B>(f: (b: B) => A) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function contramap<F extends URIS>(\n  F: Contravariant1<F>\n): <A, B>(f: (b: B) => A) => (fa: Kind<F, A>) => Kind<F, B>\nexport declare function contramap<F>(F: Contravariant<F>): <A, B>(f: (b: B) => A) => (fa: HKT<F, A>) => HKT<F, B>\n```\n\nAdded in v2.13.0\n\n## extend\n\nReturns a pipeable `extend`\n\n**Signature**\n\n```ts\nexport declare function extend<F extends URIS4>(\n  F: Extend4<F>\n): <S, R, E, A, B>(f: (wa: Kind4<F, S, R, E, A>) => B) => (wa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport declare function extend<F extends URIS3>(\n  F: Extend3<F>\n): <R, E, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function extend<F extends URIS3, E>(\n  F: Extend3C<F, E>\n): <R, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function extend<F extends URIS2>(\n  F: Extend2<F>\n): <E, A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function extend<F extends URIS2, E>(\n  F: Extend2C<F, E>\n): <A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function extend<F extends URIS>(\n  F: Extend1<F>\n): <A, B>(f: (wa: Kind<F, A>) => B) => (wa: Kind<F, A>) => Kind<F, B>\nexport declare function extend<F>(F: Extend<F>): <A, B>(f: (wa: HKT<F, A>) => B) => (wa: HKT<F, A>) => HKT<F, B>\n```\n\nAdded in v2.13.0\n\n## filter\n\nReturns a pipeable `filter`\n\n**Signature**\n\n```ts\nexport declare function filter<F extends URIS4>(\n  F: Filterable4<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n  <A>(predicate: Predicate<A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n}\nexport declare function filter<F extends URIS3>(\n  F: Filterable3<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\nexport declare function filter<F extends URIS3, E>(\n  F: Filterable3C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\nexport declare function filter<F extends URIS2>(\n  F: Filterable2<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\nexport declare function filter<F extends URIS2, E>(\n  F: Filterable2C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\nexport declare function filter<F extends URIS>(\n  F: Filterable1<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Kind<F, B>\n  <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Kind<F, A>\n}\nexport declare function filter<F>(F: Filterable<F>): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => HKT<F, B>\n  <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => HKT<F, A>\n}\n```\n\nAdded in v2.13.0\n\n## filterMap\n\nReturns a pipeable `filterMap`\n\n**Signature**\n\n```ts\nexport declare function filterMap<F extends URIS4>(\n  F: Filterable4<F>\n): <A, B>(f: (a: A) => Option<B>) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport declare function filterMap<F extends URIS3>(\n  F: Filterable3<F>\n): <A, B>(f: (a: A) => Option<B>) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function filterMap<F extends URIS3, E>(\n  F: Filterable3C<F, E>\n): <A, B>(f: (a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function filterMap<F extends URIS2>(\n  F: Filterable2<F>\n): <A, B>(f: (a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function filterMap<F extends URIS2, E>(\n  F: Filterable2C<F, E>\n): <A, B>(f: (a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function filterMap<F extends URIS>(\n  F: Filterable1<F>\n): <A, B>(f: (a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>\nexport declare function filterMap<F>(F: Filterable<F>): <A, B>(f: (a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>\n```\n\nAdded in v2.13.0\n\n## filterMapWithIndex\n\nReturns a pipeable `filterMapWithIndex`\n\n**Signature**\n\n```ts\nexport declare function filterMapWithIndex<F extends URIS4, I>(\n  F: FilterableWithIndex4<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport declare function filterMapWithIndex<F extends URIS3, I>(\n  F: FilterableWithIndex3<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function filterMapWithIndex<F extends URIS3, I, E>(\n  F: FilterableWithIndex3C<F, I, E>\n): <A, B>(f: (i: I, a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function filterMapWithIndex<F extends URIS2, I>(\n  F: FilterableWithIndex2<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function filterMapWithIndex<F extends URIS2, I, E>(\n  F: FilterableWithIndex2C<F, I, E>\n): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function filterMapWithIndex<F extends URIS, I>(\n  F: FilterableWithIndex1<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>\nexport declare function filterMapWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>\n```\n\nAdded in v2.13.0\n\n## filterWithIndex\n\nReturns a pipeable `filterWithIndex`\n\n**Signature**\n\n```ts\nexport declare function filterWithIndex<F extends URIS4, I>(\n  F: FilterableWithIndex4<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Kind4<F, S, R, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n}\nexport declare function filterWithIndex<F extends URIS3, I>(\n  F: FilterableWithIndex3<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\nexport declare function filterWithIndex<F extends URIS3, I, E>(\n  F: FilterableWithIndex3C<F, I, E>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\nexport declare function filterWithIndex<F extends URIS2, I>(\n  F: FilterableWithIndex2<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\nexport declare function filterWithIndex<F extends URIS2, E, I>(\n  F: FilterableWithIndex2C<F, I, E>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\nexport declare function filterWithIndex<F extends URIS, I>(\n  F: FilterableWithIndex1<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: Kind<F, A>) => Kind<F, B>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Kind<F, A>\n}\nexport declare function filterWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: HKT<F, A>) => HKT<F, B>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => HKT<F, A>\n}\n```\n\nAdded in v2.13.0\n\n## foldMap\n\nReturns a pipeable `foldMap`\n\n**Signature**\n\n```ts\nexport declare function foldMap<F extends URIS4>(\n  F: Foldable4<F>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M\nexport declare function foldMap<F extends URIS3>(\n  F: Foldable3<F>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M\nexport declare function foldMap<F extends URIS3, E>(\n  F: Foldable3C<F, E>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M\nexport declare function foldMap<F extends URIS2>(\n  F: Foldable2<F>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: Kind2<F, E, A>) => M\nexport declare function foldMap<F extends URIS2, E>(\n  F: Foldable2C<F, E>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind2<F, E, A>) => M\nexport declare function foldMap<F extends URIS>(\n  F: Foldable1<F>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind<F, A>) => M\nexport declare function foldMap<F>(F: Foldable<F>): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: HKT<F, A>) => M\n```\n\nAdded in v2.13.0\n\n## foldMapWithIndex\n\nReturns a pipeable `foldMapWithIndex`\n\n**Signature**\n\n```ts\nexport declare function foldMapWithIndex<F extends URIS4, I>(\n  F: FoldableWithIndex4<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M\nexport declare function foldMapWithIndex<F extends URIS3, I>(\n  F: FoldableWithIndex3<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M\nexport declare function foldMapWithIndex<F extends URIS3, I, E>(\n  F: FoldableWithIndex3C<F, I, E>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M\nexport declare function foldMapWithIndex<F extends URIS2, I>(\n  F: FoldableWithIndex2<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <E>(fa: Kind2<F, E, A>) => M\nexport declare function foldMapWithIndex<F extends URIS2, I, E>(\n  F: FoldableWithIndex2C<F, I, E>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind2<F, E, A>) => M\nexport declare function foldMapWithIndex<F extends URIS, I>(\n  F: FoldableWithIndex1<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind<F, A>) => M\nexport declare function foldMapWithIndex<F, I>(\n  F: FoldableWithIndex<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: HKT<F, A>) => M\n```\n\nAdded in v2.13.0\n\n## map\n\nReturns a pipeable `map`\n\n**Signature**\n\n```ts\nexport declare function map<F extends URIS4>(\n  F: Functor4<F>\n): <A, B>(f: (a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport declare function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function map<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <A, B>(f: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function map<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <A, B>(f: (a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function map<F extends URIS>(F: Functor1<F>): <A, B>(f: (a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>\nexport declare function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>\n```\n\nAdded in v2.13.0\n\n## mapLeft\n\nReturns a pipeable `mapLeft`\n\n**Signature**\n\n```ts\nexport declare function mapLeft<F extends URIS4>(\n  F: Bifunctor4<F>\n): <E, G>(f: (e: E) => G) => <S, R, A>(fea: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, A>\nexport declare function mapLeft<F extends URIS3>(\n  F: Bifunctor3<F>\n): <E, G>(f: (e: E) => G) => <R, A>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, A>\nexport declare function mapLeft<F extends URIS3, E>(\n  F: Bifunctor3C<F, E>\n): <E, G>(f: (e: E) => G) => <R, A>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, A>\nexport declare function mapLeft<F extends URIS2>(\n  F: Bifunctor2<F>\n): <E, G>(f: (e: E) => G) => <A>(fea: Kind2<F, E, A>) => Kind2<F, G, A>\nexport declare function mapLeft<F extends URIS2, E>(\n  F: Bifunctor2C<F, E>\n): <E, G>(f: (e: E) => G) => <A>(fea: Kind2<F, E, A>) => Kind2<F, G, A>\nexport declare function mapLeft<F>(F: Bifunctor<F>): <E, G>(f: (e: E) => G) => <A>(fea: HKT2<F, E, A>) => HKT2<F, G, A>\n```\n\nAdded in v2.13.0\n\n## mapWithIndex\n\nReturns a pipeable `mapWithIndex`\n\n**Signature**\n\n```ts\nexport declare function mapWithIndex<F extends URIS4, I>(\n  F: FunctorWithIndex4<F, I>\n): <A, B>(f: (i: I, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport declare function mapWithIndex<F extends URIS3, I>(\n  F: FunctorWithIndex3<F, I>\n): <A, B>(f: (i: I, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function mapWithIndex<F extends URIS3, I, E>(\n  F: FunctorWithIndex3C<F, I, E>\n): <A, B>(f: (i: I, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport declare function mapWithIndex<F extends URIS2, I>(\n  F: FunctorWithIndex2<F, I>\n): <A, B>(f: (i: I, a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function mapWithIndex<F extends URIS2, I, E>(\n  F: FunctorWithIndex2C<F, I, E>\n): <A, B>(f: (i: I, a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport declare function mapWithIndex<F extends URIS, I>(\n  F: FunctorWithIndex1<F, I>\n): <A, B>(f: (i: I, a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>\nexport declare function mapWithIndex<F, I>(\n  F: FunctorWithIndex<F, I>\n): <A, B>(f: (i: I, a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>\n```\n\nAdded in v2.13.0\n\n## partition\n\nReturns a pipeable `partition`\n\n**Signature**\n\n```ts\nexport declare function partition<F extends URIS4>(\n  F: Filterable4<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n  <A>(predicate: Predicate<A>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n}\nexport declare function partition<F extends URIS3>(\n  F: Filterable3<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R, E>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n  <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\nexport declare function partition<F extends URIS3, E>(\n  F: Filterable3C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n  <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\nexport declare function partition<F extends URIS2>(\n  F: Filterable2<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\nexport declare function partition<F extends URIS2, E>(\n  F: Filterable2C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\nexport declare function partition<F extends URIS>(\n  F: Filterable1<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, B>>\n  <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>\n}\nexport declare function partition<F>(F: Filterable<F>): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, B>>\n  <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>\n}\n```\n\nAdded in v2.13.0\n\n## partitionMap\n\nReturns a pipeable `partitionMap`\n\n**Signature**\n\n```ts\nexport declare function partitionMap<F extends URIS4>(\n  F: Filterable4<F>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\nexport declare function partitionMap<F extends URIS3>(\n  F: Filterable3<F>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\nexport declare function partitionMap<F extends URIS3, E>(\n  F: Filterable3C<F, E>\n): <A, B, C>(f: (a: A) => Either<B, C>) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\nexport declare function partitionMap<F extends URIS2>(\n  F: Filterable2<F>\n): <A, B, C>(f: (a: A) => Either<B, C>) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\nexport declare function partitionMap<F extends URIS2, E>(\n  F: Filterable2C<F, E>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\nexport declare function partitionMap<F extends URIS>(\n  F: Filterable1<F>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>\nexport declare function partitionMap<F>(\n  F: Filterable<F>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>\n```\n\nAdded in v2.13.0\n\n## partitionMapWithIndex\n\nReturns a pipeable `partitionMapWithIndex`\n\n**Signature**\n\n```ts\nexport declare function partitionMapWithIndex<F extends URIS4, I>(\n  F: FilterableWithIndex4<F, I>\n): <A, B, C>(\n  f: (i: I, a: A) => Either<B, C>\n) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\nexport declare function partitionMapWithIndex<F extends URIS3, I>(\n  F: FilterableWithIndex3<F, I>\n): <A, B, C>(\n  f: (i: I, a: A) => Either<B, C>\n) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\nexport declare function partitionMapWithIndex<F extends URIS3, I, E>(\n  F: FilterableWithIndex3C<F, I, E>\n): <A, B, C>(\n  f: (i: I, a: A) => Either<B, C>\n) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\nexport declare function partitionMapWithIndex<F extends URIS2, I>(\n  F: FilterableWithIndex2<F, I>\n): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\nexport declare function partitionMapWithIndex<F extends URIS2, I, E>(\n  F: FilterableWithIndex2C<F, I, E>\n): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\nexport declare function partitionMapWithIndex<F extends URIS, I>(\n  F: FilterableWithIndex1<F, I>\n): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>\nexport declare function partitionMapWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>\n```\n\nAdded in v2.13.0\n\n## partitionWithIndex\n\nReturns a pipeable `partitionWithIndex`\n\n**Signature**\n\n```ts\nexport declare function partitionWithIndex<F extends URIS4, I>(\n  F: FilterableWithIndex4<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n}\nexport declare function partitionWithIndex<F extends URIS3, I>(\n  F: FilterableWithIndex3<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R, E>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): <R, E>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\nexport declare function partitionWithIndex<F extends URIS3, I, E>(\n  F: FilterableWithIndex3C<F, I, E>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): <R>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\nexport declare function partitionWithIndex<F extends URIS2, I>(\n  F: FilterableWithIndex2<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <E>(\n    fa: Kind2<F, E, A>\n  ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\nexport declare function partitionWithIndex<F extends URIS2, I, E>(\n  F: FilterableWithIndex2C<F, I, E>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (\n    fa: Kind2<F, E, A>\n  ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\nexport declare function partitionWithIndex<F extends URIS, I>(\n  F: FilterableWithIndex1<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>\n}\nexport declare function partitionWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>\n}\n```\n\nAdded in v2.13.0\n\n## promap\n\nReturns a pipeable `promap`\n\n**Signature**\n\n```ts\nexport declare function promap<F extends URIS4>(\n  F: Profunctor4<F>\n): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => <S, R>(fbc: Kind4<F, S, R, E, A>) => Kind4<F, S, R, D, B>\nexport declare function promap<F extends URIS3>(\n  F: Profunctor3<F>\n): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => <R>(fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>\nexport declare function promap<F extends URIS3, E>(\n  F: Profunctor3C<F, E>\n): <A, D, B>(f: (d: D) => E, g: (a: A) => B) => <R>(fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>\nexport declare function promap<F extends URIS2>(\n  F: Profunctor2<F>\n): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>\nexport declare function promap<F extends URIS2, E>(\n  F: Profunctor2C<F, E>\n): <A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>\nexport declare function promap<F>(\n  F: Profunctor<F>\n): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: HKT2<F, E, A>) => HKT2<F, D, B>\n```\n\nAdded in v2.13.0\n\n## reduce\n\nReturns a pipeable `reduce`\n\n**Signature**\n\n```ts\nexport declare function reduce<F extends URIS4>(\n  F: Foldable4<F>\n): <A, B>(b: B, f: (b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\nexport declare function reduce<F extends URIS3>(\n  F: Foldable3<F>\n): <A, B>(b: B, f: (b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\nexport declare function reduce<F extends URIS3, E>(\n  F: Foldable3C<F, E>\n): <A, B>(b: B, f: (b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B\nexport declare function reduce<F extends URIS2>(\n  F: Foldable2<F>\n): <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B\nexport declare function reduce<F extends URIS2, E>(\n  F: Foldable2C<F, E>\n): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B\nexport declare function reduce<F extends URIS>(\n  F: Foldable1<F>\n): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind<F, A>) => B\nexport declare function reduce<F>(F: Foldable<F>): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: HKT<F, A>) => B\n```\n\nAdded in v2.13.0\n\n## reduceRight\n\nReturns a pipeable `reduceRight`\n\n**Signature**\n\n```ts\nexport declare function reduceRight<F extends URIS4>(\n  F: Foldable4<F>\n): <A, B>(b: B, f: (a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\nexport declare function reduceRight<F extends URIS3>(\n  F: Foldable3<F>\n): <A, B>(b: B, f: (a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\nexport declare function reduceRight<F extends URIS3, E>(\n  F: Foldable3C<F, E>\n): <A, B>(b: B, f: (a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B\nexport declare function reduceRight<F extends URIS2>(\n  F: Foldable2<F>\n): <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B\nexport declare function reduceRight<F extends URIS2, E>(\n  F: Foldable2C<F, E>\n): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B\nexport declare function reduceRight<F extends URIS>(\n  F: Foldable1<F>\n): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind<F, A>) => B\nexport declare function reduceRight<F>(F: Foldable<F>): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: HKT<F, A>) => B\n```\n\nAdded in v2.13.0\n\n## reduceRightWithIndex\n\nReturns a pipeable `reduceRightWithIndex`\n\n**Signature**\n\n```ts\nexport declare function reduceRightWithIndex<F extends URIS4, I>(\n  F: FoldableWithIndex4<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\nexport declare function reduceRightWithIndex<F extends URIS3, I>(\n  F: FoldableWithIndex3<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\nexport declare function reduceRightWithIndex<F extends URIS3, I, E>(\n  F: FoldableWithIndex3C<F, I, E>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B\nexport declare function reduceRightWithIndex<F extends URIS2, I>(\n  F: FoldableWithIndex2<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B\nexport declare function reduceRightWithIndex<F extends URIS2, I, E>(\n  F: FoldableWithIndex2C<F, I, E>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B\nexport declare function reduceRightWithIndex<F extends URIS, I>(\n  F: FoldableWithIndex1<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind<F, A>) => B\nexport declare function reduceRightWithIndex<F, I>(\n  F: FoldableWithIndex<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: HKT<F, A>) => B\n```\n\nAdded in v2.13.0\n\n## reduceWithIndex\n\nReturns a pipeable `reduceWithIndex`\n\n**Signature**\n\n```ts\nexport declare function reduceWithIndex<F extends URIS4, I>(\n  F: FoldableWithIndex4<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\nexport declare function reduceWithIndex<F extends URIS3, I>(\n  F: FoldableWithIndex3<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\nexport declare function reduceWithIndex<F extends URIS3, I, E>(\n  F: FoldableWithIndex3C<F, I, E>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B\nexport declare function reduceWithIndex<F extends URIS2, I>(\n  F: FoldableWithIndex2<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B\nexport declare function reduceWithIndex<F extends URIS2, I, E>(\n  F: FoldableWithIndex2C<F, I, E>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B\nexport declare function reduceWithIndex<F extends URIS, I>(\n  F: FoldableWithIndex1<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind<F, A>) => B\nexport declare function reduceWithIndex<F, I>(\n  F: FoldableWithIndex<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: HKT<F, A>) => B\n```\n\nAdded in v2.13.0\n\n# utils\n\n## ~~PipeableAlt3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableAlt3C<F extends URIS3, E> {\n  readonly alt: <R, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableApply3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableApply3C<F extends URIS3, E> extends PipeableFunctor3C<F, E> {\n  readonly ap: <R, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\n  readonly apFirst: <R, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly apSecond: <R, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableBifunctor3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableBifunctor3C<F extends URIS3, E> {\n  readonly bimap: <G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, B>\n  readonly mapLeft: <G>(f: (e: E) => G) => <R, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, A>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableChain3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableChain3C<F extends URIS3, E> extends PipeableApply3C<F, E> {\n  readonly chain: <R, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  readonly chainFirst: <R, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly flatten: <R, A>(mma: Kind3<F, R, E, Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableCompactable3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableCompactable3C<F extends URIS3, E> {\n  readonly compact: <R, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>\n  readonly separate: <R, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableContravariant3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableContravariant3C<F extends URIS3, E> {\n  readonly contramap: <A, B>(f: (b: B) => A) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableExtend3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableExtend3C<F extends URIS3, E> extends PipeableFunctor3C<F, E> {\n  readonly extend: <R, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  readonly duplicate: <R, A>(wa: Kind3<F, R, E, A>) => Kind3<F, R, E, Kind3<F, R, E, A>>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableFilterable3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterable3C<F extends URIS3, E> extends PipeableCompactable3C<F, E> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n    <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): <R>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n    <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableFilterableWithIndex3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterableWithIndex3C<F extends URIS3, I, E> extends PipeableFilterable3C<F, E> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableFoldable3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldable3C<F extends URIS3, E> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableFoldableWithIndex3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldableWithIndex3C<F extends URIS3, I, E> extends PipeableFoldable3C<F, E> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableFunctor3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctor3C<F extends URIS3, E> {\n  readonly map: <A, B>(f: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableFunctorWithIndex3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctorWithIndex3C<F extends URIS3, I, E> extends PipeableFunctor3C<F, E> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableMonadThrow3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableMonadThrow3C<F extends URIS3, E> {\n  readonly fromOption: (onNone: LazyArg<E>) => <R, A>(ma: Option<A>) => Kind3<F, R, E, A>\n  readonly fromEither: <R, A>(ma: Either<E, A>) => Kind3<F, R, E, A>\n  readonly fromPredicate: {\n    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <U>(a: A) => Kind3<F, U, E, B>\n    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>\n  }\n  readonly filterOrElse: {\n    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n      ma: Kind3<F, R, E, A>\n    ) => Kind3<F, R, E, B>\n    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableProfunctor3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableProfunctor3C<F extends URIS3, E> extends PipeableFunctor3C<F, E> {\n  readonly promap: <R, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>\n}\n```\n\nAdded in v2.2.0\n\n## ~~PipeableSemigroupoid3C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableSemigroupoid3C<F extends URIS3, E> {\n  readonly compose: <R, A>(la: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.2.0\n\n## ~~pipe~~\n\nUse [`pipe`](https://gcanti.github.io/fp-ts/modules/function.ts.html#pipe) from `function` module instead.\n\n**Signature**\n\n```ts\nexport declare const pipe: typeof pipeFromFunctionModule\n```\n\nAdded in v2.0.0\n\n# zone of death\n\n## ~~PipeableAlt1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableAlt1<F extends URIS> {\n  readonly alt: <A>(that: LazyArg<Kind<F, A>>) => (fa: Kind<F, A>) => Kind<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableAlt2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableAlt2C<F extends URIS2, E> {\n  readonly alt: <A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableAlt2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableAlt2<F extends URIS2> {\n  readonly alt: <E, A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableAlt3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableAlt3<F extends URIS3> {\n  readonly alt: <R, E, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableAlt4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableAlt4<F extends URIS4> {\n  readonly alt: <S, R, E, A>(that: LazyArg<Kind4<F, S, R, E, A>>) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableAlt~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableAlt<F> {\n  readonly alt: <A>(that: LazyArg<HKT<F, A>>) => (fa: HKT<F, A>) => HKT<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableApply1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableApply1<F extends URIS> extends PipeableFunctor1<F> {\n  readonly ap: <A>(fa: Kind<F, A>) => <B>(fab: Kind<F, (a: A) => B>) => Kind<F, B>\n  readonly apFirst: <B>(fb: Kind<F, B>) => <A>(fa: Kind<F, A>) => Kind<F, A>\n  readonly apSecond: <B>(fb: Kind<F, B>) => <A>(fa: Kind<F, A>) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableApply2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableApply2C<F extends URIS2, E> extends PipeableFunctor2C<F, E> {\n  readonly ap: <A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\n  readonly apFirst: <B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  readonly apSecond: <B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableApply2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableApply2<F extends URIS2> extends PipeableFunctor2<F> {\n  readonly ap: <E, A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\n  readonly apFirst: <E, B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  readonly apSecond: <E, B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableApply3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableApply3<F extends URIS3> extends PipeableFunctor3<F> {\n  readonly ap: <R, E, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\n  readonly apFirst: <R, E, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly apSecond: <R, E, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableApply4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableApply4<F extends URIS4> extends PipeableFunctor4<F> {\n  readonly ap: <S, R, E, A>(\n    fa: Kind4<F, S, R, E, A>\n  ) => <B>(fab: Kind4<F, S, R, E, (a: A) => B>) => Kind4<F, S, R, E, B>\n  readonly apFirst: <S, R, E, B>(fb: Kind4<F, S, R, E, B>) => <A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  readonly apSecond: <S, R, E, B>(fb: Kind4<F, S, R, E, B>) => <A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableApply~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableApply<F> extends PipeableFunctor<F> {\n  readonly ap: <A>(fa: HKT<F, A>) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B>\n  readonly apFirst: <B>(fb: HKT<F, B>) => <A>(fa: HKT<F, A>) => HKT<F, A>\n  readonly apSecond: <B>(fb: HKT<F, B>) => <A>(fa: HKT<F, A>) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableBifunctor2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableBifunctor2<F extends URIS2> {\n  readonly bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, G, B>\n  readonly mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Kind2<F, E, A>) => Kind2<F, G, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableBifunctor3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableBifunctor3<F extends URIS3> {\n  readonly bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, B>\n  readonly mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableBifunctor4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableBifunctor4<F extends URIS4> {\n  readonly bimap: <E, G, A, B>(\n    f: (e: E) => G,\n    g: (a: A) => B\n  ) => <S, R>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, B>\n  readonly mapLeft: <E, G>(f: (e: E) => G) => <S, R, A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableBifunctor~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableBifunctor<F> {\n  readonly bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: HKT2<F, E, A>) => HKT2<F, G, B>\n  readonly mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: HKT2<F, E, A>) => HKT2<F, G, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableChain1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableChain1<F extends URIS> extends PipeableApply1<F> {\n  readonly chain: <A, B>(f: (a: A) => Kind<F, B>) => (ma: Kind<F, A>) => Kind<F, B>\n  readonly chainFirst: <A, B>(f: (a: A) => Kind<F, B>) => (ma: Kind<F, A>) => Kind<F, A>\n  readonly flatten: <A>(mma: Kind<F, Kind<F, A>>) => Kind<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableChain2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableChain2C<F extends URIS2, E> extends PipeableApply2C<F, E> {\n  readonly chain: <A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly chainFirst: <A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, A>\n  readonly flatten: <A>(mma: Kind2<F, E, Kind2<F, E, A>>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableChain2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableChain2<F extends URIS2> extends PipeableApply2<F> {\n  readonly chain: <E, A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly chainFirst: <E, A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, A>\n  readonly flatten: <E, A>(mma: Kind2<F, E, Kind2<F, E, A>>) => Kind2<F, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableChain3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableChain3<F extends URIS3> extends PipeableApply3<F> {\n  readonly chain: <R, E, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  readonly chainFirst: <R, E, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly flatten: <R, E, A>(mma: Kind3<F, R, E, Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableChain4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableChain4<F extends URIS4> extends PipeableApply4<F> {\n  readonly chain: <S, R, E, A, B>(\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => (ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n  readonly chainFirst: <S, R, E, A, B>(\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => (ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  readonly flatten: <S, R, E, A>(mma: Kind4<F, S, R, E, Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableChain~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableChain<F> extends PipeableApply<F> {\n  readonly chain: <A, B>(f: (a: A) => HKT<F, B>) => (ma: HKT<F, A>) => HKT<F, B>\n  readonly chainFirst: <A, B>(f: (a: A) => HKT<F, B>) => (ma: HKT<F, A>) => HKT<F, A>\n  readonly flatten: <A>(mma: HKT<F, HKT<F, A>>) => HKT<F, A>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableCompactable1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableCompactable1<F extends URIS> {\n  readonly compact: <A>(fa: Kind<F, Option<A>>) => Kind<F, A>\n  readonly separate: <A, B>(fa: Kind<F, Either<A, B>>) => Separated<Kind<F, A>, Kind<F, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableCompactable2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableCompactable2C<F extends URIS2, E> {\n  readonly compact: <A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>\n  readonly separate: <A, B>(fa: Kind2<F, E, Either<A, B>>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableCompactable2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableCompactable2<F extends URIS2> {\n  readonly compact: <E, A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>\n  readonly separate: <E, A, B>(fa: Kind2<F, E, Either<A, B>>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableCompactable3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableCompactable3<F extends URIS3> {\n  readonly compact: <R, E, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>\n  readonly separate: <R, E, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableCompactable4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableCompactable4<F extends URIS4> {\n  readonly compact: <S, R, E, A>(fa: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, A>\n  readonly separate: <S, R, E, A, B>(\n    fa: Kind4<F, S, R, E, Either<A, B>>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableCompactable~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableCompactable<F> {\n  readonly compact: <A>(fa: HKT<F, Option<A>>) => HKT<F, A>\n  readonly separate: <A, B>(fa: HKT<F, Either<A, B>>) => Separated<HKT<F, A>, HKT<F, B>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableContravariant1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableContravariant1<F extends URIS> {\n  readonly contramap: <A, B>(f: (b: B) => A) => (fa: Kind<F, A>) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableContravariant2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableContravariant2C<F extends URIS2, E> {\n  readonly contramap: <A, B>(f: (b: B) => A) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableContravariant2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableContravariant2<F extends URIS2> {\n  readonly contramap: <A, B>(f: (b: B) => A) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableContravariant3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableContravariant3<F extends URIS3> {\n  readonly contramap: <A, B>(f: (b: B) => A) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableContravariant4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableContravariant4<F extends URIS4> {\n  readonly contramap: <A, B>(f: (b: B) => A) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableContravariant~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableContravariant<F> {\n  readonly contramap: <A, B>(f: (b: B) => A) => (fa: HKT<F, A>) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableExtend1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableExtend1<F extends URIS> extends PipeableFunctor1<F> {\n  readonly extend: <A, B>(f: (wa: Kind<F, A>) => B) => (wa: Kind<F, A>) => Kind<F, B>\n  readonly duplicate: <A>(wa: Kind<F, A>) => Kind<F, Kind<F, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableExtend2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableExtend2C<F extends URIS2, E> extends PipeableFunctor2C<F, E> {\n  readonly extend: <A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly duplicate: <A>(wa: Kind2<F, E, A>) => Kind2<F, E, Kind2<F, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableExtend2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableExtend2<F extends URIS2> extends PipeableFunctor2<F> {\n  readonly extend: <E, A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly duplicate: <E, A>(wa: Kind2<F, E, A>) => Kind2<F, E, Kind2<F, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableExtend3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableExtend3<F extends URIS3> extends PipeableFunctor3<F> {\n  readonly extend: <R, E, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  readonly duplicate: <R, E, A>(wa: Kind3<F, R, E, A>) => Kind3<F, R, E, Kind3<F, R, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableExtend4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableExtend4<F extends URIS4> extends PipeableFunctor4<F> {\n  readonly extend: <S, R, E, A, B>(\n    f: (wa: Kind4<F, S, R, E, A>) => B\n  ) => (wa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n  readonly duplicate: <S, R, E, A>(wa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, Kind4<F, S, R, E, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableExtend~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableExtend<F> extends PipeableFunctor<F> {\n  readonly extend: <A, B>(f: (wa: HKT<F, A>) => B) => (wa: HKT<F, A>) => HKT<F, B>\n  readonly duplicate: <A>(wa: HKT<F, A>) => HKT<F, HKT<F, A>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterable1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterable1<F extends URIS> extends PipeableCompactable1<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Kind<F, B>\n    <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Kind<F, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, B>>\n    <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>\n  }\n  readonly partitionMap: <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterable2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterable2C<F extends URIS2, E> extends PipeableCompactable2C<F, E> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n    <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterable2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterable2<F extends URIS2> extends PipeableCompactable2<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n    <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterable3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterable3<F extends URIS3> extends PipeableCompactable3<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n    <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): <R, E>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n    <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterable4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterable4<F extends URIS4> extends PipeableCompactable4<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n    <A>(predicate: Predicate<A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n    <A>(predicate: Predicate<A>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterableWithIndex1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterableWithIndex1<F extends URIS, I> extends PipeableFilterable1<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (fa: Kind<F, A>) => Kind<F, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Kind<F, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (\n      fa: Kind<F, A>\n    ) => Separated<Kind<F, A>, Kind<F, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterableWithIndex2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterableWithIndex2C<F extends URIS2, I, E> extends PipeableFilterable2C<F, E> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (\n      fa: Kind2<F, E, A>\n    ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterableWithIndex2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterableWithIndex2<F extends URIS2, I> extends PipeableFilterable2<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <E>(\n      fa: Kind2<F, E, A>\n    ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <E>(\n      fa: Kind2<F, E, A>\n    ) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterableWithIndex3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterableWithIndex3<F extends URIS3, I> extends PipeableFilterable3<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R, E>(\n      fa: Kind3<F, R, E, A>\n    ) => Kind3<F, R, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(\n    f: (i: I, a: A) => Option<B>\n  ) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R, E>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R, E>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterableWithIndex4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterableWithIndex4<F extends URIS4, I> extends PipeableFilterable4<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Kind4<F, S, R, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(\n    f: (i: I, a: A) => Option<B>\n  ) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterableWithIndex~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterableWithIndex<F, I> extends PipeableFilterable<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (fa: HKT<F, A>) => HKT<F, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => HKT<F, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (\n      fa: HKT<F, A>\n    ) => Separated<HKT<F, A>, HKT<F, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFilterable~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFilterable<F> extends PipeableCompactable<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => HKT<F, B>\n    <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => HKT<F, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, B>>\n    <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>\n  }\n  readonly partitionMap: <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldable1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldable1<F extends URIS> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind<F, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind<F, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind<F, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldable2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldable2C<F extends URIS2, E> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind2<F, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldable2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldable2<F extends URIS2> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: Kind2<F, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldable3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldable3<F extends URIS3> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldable4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldable4<F extends URIS4> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldableWithIndex1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldableWithIndex1<F extends URIS, I> extends PipeableFoldable1<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind<F, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind<F, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind<F, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldableWithIndex2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldableWithIndex2C<F extends URIS2, I, E> extends PipeableFoldable2C<F, E> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind2<F, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldableWithIndex2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldableWithIndex2<F extends URIS2, I> extends PipeableFoldable2<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <E>(fa: Kind2<F, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldableWithIndex3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldableWithIndex3<F extends URIS3, I> extends PipeableFoldable3<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldableWithIndex4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldableWithIndex4<F extends URIS4, I> extends PipeableFoldable4<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldableWithIndex~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldableWithIndex<F, I> extends PipeableFoldable<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: HKT<F, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: HKT<F, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: HKT<F, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFoldable~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFoldable<F> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: HKT<F, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: HKT<F, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: HKT<F, A>) => B\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctor1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctor1<F extends URIS> {\n  readonly map: <A, B>(f: (a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctor2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctor2C<F extends URIS2, E> {\n  readonly map: <A, B>(f: (a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctor2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctor2<F extends URIS2> {\n  readonly map: <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctor3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctor3<F extends URIS3> {\n  readonly map: <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctor4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctor4<F extends URIS4> {\n  readonly map: <A, B>(f: (a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctorWithIndex1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctorWithIndex1<F extends URIS, I> extends PipeableFunctor1<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctorWithIndex2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctorWithIndex2C<F extends URIS2, I, E> extends PipeableFunctor2C<F, E> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctorWithIndex2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctorWithIndex2<F extends URIS2, I> extends PipeableFunctor2<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctorWithIndex3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctorWithIndex3<F extends URIS3, I> extends PipeableFunctor3<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctorWithIndex4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctorWithIndex4<F extends URIS4, I> extends PipeableFunctor4<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctorWithIndex~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctorWithIndex<F, I> extends PipeableFunctor<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableFunctor~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableFunctor<F> {\n  readonly map: <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableMonadThrow1~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableMonadThrow1<F extends URIS> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => Kind<F, A>\n  readonly fromEither: <E, A>(ma: Either<E, A>) => Kind<F, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind<F, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind<F, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind<F, A>) => Kind<F, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind<F, A>) => Kind<F, A>\n  }\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableMonadThrow2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableMonadThrow2C<F extends URIS2, E> {\n  readonly fromOption: (onNone: LazyArg<E>) => <A>(ma: Option<A>) => Kind2<F, E, A>\n  readonly fromEither: <A>(ma: Either<E, A>) => Kind2<F, E, A>\n  readonly fromPredicate: {\n    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>\n    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>\n  }\n  readonly filterOrElse: {\n    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableMonadThrow2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableMonadThrow2<F extends URIS2> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => Kind2<F, E, A>\n  readonly fromEither: <E, A>(ma: Either<E, A>) => Kind2<F, E, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableMonadThrow3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableMonadThrow3<F extends URIS3> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <R, A>(ma: Option<A>) => Kind3<F, R, E, A>\n  readonly fromEither: <R, E, A>(ma: Either<E, A>) => Kind3<F, R, E, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <U>(a: A) => Kind3<F, U, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n      ma: Kind3<F, R, E, A>\n    ) => Kind3<F, R, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableMonadThrow4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableMonadThrow4<F extends URIS4> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <S, R, A>(ma: Option<A>) => Kind4<F, S, R, E, A>\n  readonly fromEither: <S, R, E, A>(ma: Either<E, A>) => Kind4<F, S, R, E, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(\n      ma: Kind4<F, S, R, E, A>\n    ) => Kind4<F, S, R, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  }\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableMonadThrow~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableMonadThrow<F> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => HKT<F, A>\n  readonly fromEither: <E, A>(ma: Either<E, A>) => HKT<F, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => HKT<F, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => HKT<F, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: HKT<F, A>) => HKT<F, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: HKT<F, A>) => HKT<F, A>\n  }\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableProfunctor2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableProfunctor2C<F extends URIS2, E> extends PipeableFunctor2C<F, E> {\n  readonly promap: <A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableProfunctor2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableProfunctor2<F extends URIS2> extends PipeableFunctor2<F> {\n  readonly promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableProfunctor3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableProfunctor3<F extends URIS3> extends PipeableFunctor3<F> {\n  readonly promap: <R, E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableProfunctor4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableProfunctor4<F extends URIS4> extends PipeableFunctor4<F> {\n  readonly promap: <S, R, E, A, D, B>(\n    f: (d: D) => E,\n    g: (a: A) => B\n  ) => (fbc: Kind4<F, S, R, E, A>) => Kind4<F, S, R, D, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableProfunctor~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableProfunctor<F> {\n  readonly promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: HKT2<F, E, A>) => HKT2<F, D, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableSemigroupoid2C~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableSemigroupoid2C<F extends URIS2, E> {\n  readonly compose: <A>(la: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableSemigroupoid2~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableSemigroupoid2<F extends URIS2> {\n  readonly compose: <E, A>(la: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableSemigroupoid3~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableSemigroupoid3<F extends URIS3> {\n  readonly compose: <R, E, A>(la: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableSemigroupoid4~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableSemigroupoid4<F extends URIS4> {\n  readonly compose: <S, R, E, A>(la: Kind4<F, S, R, E, A>) => <B>(ab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~PipeableSemigroupoid~~ (interface)\n\n**Signature**\n\n```ts\nexport interface PipeableSemigroupoid<F> {\n  readonly compose: <E, A>(la: HKT2<F, E, A>) => <B>(ab: HKT2<F, A, B>) => HKT2<F, E, B>\n}\n```\n\nAdded in v2.0.0\n\n## ~~pipeable~~\n\n**Signature**\n\n```ts\nexport declare function pipeable<F extends URIS4, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain4<F>\n  ? PipeableChain4<F>\n  : I extends Apply4<F>\n  ? PipeableApply4<F>\n  : I extends Functor4<F>\n  ? PipeableFunctor4<F>\n  : {}) &\n  (I extends Contravariant4<F> ? PipeableContravariant4<F> : {}) &\n  (I extends FunctorWithIndex4<F, infer Ix> ? PipeableFunctorWithIndex4<F, Ix> : {}) &\n  (I extends Bifunctor4<F> ? PipeableBifunctor4<F> : {}) &\n  (I extends Extend4<F> ? PipeableExtend4<F> : {}) &\n  (I extends FoldableWithIndex4<F, infer Ix>\n    ? PipeableFoldableWithIndex4<F, Ix>\n    : I extends Foldable4<F>\n    ? PipeableFoldable4<F>\n    : {}) &\n  (I extends Alt4<F> ? PipeableAlt4<F> : {}) &\n  (I extends FilterableWithIndex4<F, infer Ix>\n    ? PipeableFilterableWithIndex4<F, Ix>\n    : I extends Filterable4<F>\n    ? PipeableFilterable4<F>\n    : I extends Compactable4<F>\n    ? PipeableCompactable4<F>\n    : {}) &\n  (I extends Profunctor4<F> ? PipeableProfunctor4<F> : {}) &\n  (I extends Semigroupoid4<F> ? PipeableSemigroupoid4<F> : {}) &\n  (I extends MonadThrow4<F> ? PipeableMonadThrow4<F> : {})\nexport declare function pipeable<F extends URIS3, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain3<F>\n  ? PipeableChain3<F>\n  : I extends Apply3<F>\n  ? PipeableApply3<F>\n  : I extends Functor3<F>\n  ? PipeableFunctor3<F>\n  : {}) &\n  (I extends Contravariant3<F> ? PipeableContravariant3<F> : {}) &\n  (I extends FunctorWithIndex3<F, infer Ix> ? PipeableFunctorWithIndex3<F, Ix> : {}) &\n  (I extends Bifunctor3<F> ? PipeableBifunctor3<F> : {}) &\n  (I extends Extend3<F> ? PipeableExtend3<F> : {}) &\n  (I extends FoldableWithIndex3<F, infer Ix>\n    ? PipeableFoldableWithIndex3<F, Ix>\n    : I extends Foldable3<F>\n    ? PipeableFoldable3<F>\n    : {}) &\n  (I extends Alt3<F> ? PipeableAlt3<F> : {}) &\n  (I extends FilterableWithIndex3<F, infer Ix>\n    ? PipeableFilterableWithIndex3<F, Ix>\n    : I extends Filterable3<F>\n    ? PipeableFilterable3<F>\n    : I extends Compactable3<F>\n    ? PipeableCompactable3<F>\n    : {}) &\n  (I extends Profunctor3<F> ? PipeableProfunctor3<F> : {}) &\n  (I extends Semigroupoid3<F> ? PipeableSemigroupoid3<F> : {}) &\n  (I extends MonadThrow3<F> ? PipeableMonadThrow3<F> : {})\nexport declare function pipeable<F extends URIS3, I, E>(\n  I: { readonly URI: F } & I\n): (I extends Chain3C<F, E>\n  ? PipeableChain3C<F, E>\n  : I extends Apply3C<F, E>\n  ? PipeableApply3C<F, E>\n  : I extends Functor3C<F, E>\n  ? PipeableFunctor3C<F, E>\n  : {}) &\n  (I extends Contravariant3C<F, E> ? PipeableContravariant3C<F, E> : {}) &\n  (I extends FunctorWithIndex3C<F, infer Ix, E> ? PipeableFunctorWithIndex3C<F, Ix, E> : {}) &\n  (I extends Bifunctor3C<F, E> ? PipeableBifunctor3C<F, E> : {}) &\n  (I extends Extend3C<F, E> ? PipeableExtend3C<F, E> : {}) &\n  (I extends FoldableWithIndex3C<F, infer Ix, E>\n    ? PipeableFoldableWithIndex3C<F, Ix, E>\n    : I extends Foldable3C<F, E>\n    ? PipeableFoldable3C<F, E>\n    : {}) &\n  (I extends Alt3C<F, E> ? PipeableAlt3C<F, E> : {}) &\n  (I extends FilterableWithIndex3C<F, infer Ix, E>\n    ? PipeableFilterableWithIndex3C<F, Ix, E>\n    : I extends Filterable3C<F, E>\n    ? PipeableFilterable3C<F, E>\n    : I extends Compactable3C<F, E>\n    ? PipeableCompactable3C<F, E>\n    : {}) &\n  (I extends Profunctor3C<F, E> ? PipeableProfunctor3C<F, E> : {}) &\n  (I extends Semigroupoid3C<F, E> ? PipeableSemigroupoid3C<F, E> : {}) &\n  (I extends MonadThrow3C<F, E> ? PipeableMonadThrow3C<F, E> : {})\nexport declare function pipeable<F extends URIS2, I, E>(\n  I: { readonly URI: F; readonly _E: E } & I\n): (I extends Chain2C<F, E>\n  ? PipeableChain2C<F, E>\n  : I extends Apply2C<F, E>\n  ? PipeableApply2C<F, E>\n  : I extends Functor2C<F, E>\n  ? PipeableFunctor2C<F, E>\n  : {}) &\n  (I extends Contravariant2C<F, E> ? PipeableContravariant2C<F, E> : {}) &\n  (I extends FunctorWithIndex2C<F, infer Ix, E> ? PipeableFunctorWithIndex2C<F, Ix, E> : {}) &\n  (I extends Extend2C<F, E> ? PipeableExtend2C<F, E> : {}) &\n  (I extends FoldableWithIndex2C<F, infer Ix, E>\n    ? PipeableFoldableWithIndex2C<F, Ix, E>\n    : I extends Foldable2C<F, E>\n    ? PipeableFoldable2C<F, E>\n    : {}) &\n  (I extends Alt2C<F, E> ? PipeableAlt2C<F, E> : {}) &\n  (I extends FilterableWithIndex2C<F, infer Ix, E>\n    ? PipeableFilterableWithIndex2C<F, Ix, E>\n    : I extends Filterable2C<F, E>\n    ? PipeableFilterable2C<F, E>\n    : I extends Compactable2C<F, E>\n    ? PipeableCompactable2C<F, E>\n    : {}) &\n  (I extends Profunctor2C<F, E> ? PipeableProfunctor2C<F, E> : {}) &\n  (I extends Semigroupoid2C<F, E> ? PipeableSemigroupoid2C<F, E> : {}) &\n  (I extends MonadThrow2C<F, E> ? PipeableMonadThrow2C<F, E> : {})\nexport declare function pipeable<F extends URIS2, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain2<F>\n  ? PipeableChain2<F>\n  : I extends Apply2<F>\n  ? PipeableApply2<F>\n  : I extends Functor2<F>\n  ? PipeableFunctor2<F>\n  : {}) &\n  (I extends Contravariant2<F> ? PipeableContravariant2<F> : {}) &\n  (I extends FunctorWithIndex2<F, infer Ix> ? PipeableFunctorWithIndex2<F, Ix> : {}) &\n  (I extends Bifunctor2<F> ? PipeableBifunctor2<F> : {}) &\n  (I extends Extend2<F> ? PipeableExtend2<F> : {}) &\n  (I extends FoldableWithIndex2<F, infer Ix>\n    ? PipeableFoldableWithIndex2<F, Ix>\n    : I extends Foldable2<F>\n    ? PipeableFoldable2<F>\n    : {}) &\n  (I extends Alt2<F> ? PipeableAlt2<F> : {}) &\n  (I extends FilterableWithIndex2<F, infer Ix>\n    ? PipeableFilterableWithIndex2<F, Ix>\n    : I extends Filterable2<F>\n    ? PipeableFilterable2<F>\n    : I extends Compactable2<F>\n    ? PipeableCompactable2<F>\n    : {}) &\n  (I extends Profunctor2<F> ? PipeableProfunctor2<F> : {}) &\n  (I extends Semigroupoid2<F> ? PipeableSemigroupoid2<F> : {}) &\n  (I extends MonadThrow2<F> ? PipeableMonadThrow2<F> : {})\nexport declare function pipeable<F extends URIS, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain1<F>\n  ? PipeableChain1<F>\n  : I extends Apply1<F>\n  ? PipeableApply1<F>\n  : I extends Functor1<F>\n  ? PipeableFunctor1<F>\n  : {}) &\n  (I extends Contravariant1<F> ? PipeableContravariant1<F> : {}) &\n  (I extends FunctorWithIndex1<F, infer Ix> ? PipeableFunctorWithIndex1<F, Ix> : {}) &\n  (I extends Extend1<F> ? PipeableExtend1<F> : {}) &\n  (I extends FoldableWithIndex1<F, infer Ix>\n    ? PipeableFoldableWithIndex1<F, Ix>\n    : I extends Foldable1<F>\n    ? PipeableFoldable1<F>\n    : {}) &\n  (I extends Alt1<F> ? PipeableAlt1<F> : {}) &\n  (I extends FilterableWithIndex1<F, infer Ix>\n    ? PipeableFilterableWithIndex1<F, Ix>\n    : I extends Filterable1<F>\n    ? PipeableFilterable1<F>\n    : I extends Compactable1<F>\n    ? PipeableCompactable1<F>\n    : {}) &\n  (I extends MonadThrow1<F> ? PipeableMonadThrow1<F> : {})\nexport declare function pipeable<F, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain<F>\n  ? PipeableChain<F>\n  : I extends Apply<F>\n  ? PipeableApply<F>\n  : I extends Functor<F>\n  ? PipeableFunctor<F>\n  : {}) &\n  (I extends Contravariant<F> ? PipeableContravariant<F> : {}) &\n  (I extends FunctorWithIndex<F, infer Ix> ? PipeableFunctorWithIndex<F, Ix> : {}) &\n  (I extends Bifunctor<F> ? PipeableBifunctor<F> : {}) &\n  (I extends Extend<F> ? PipeableExtend<F> : {}) &\n  (I extends FoldableWithIndex<F, infer Ix>\n    ? PipeableFoldableWithIndex<F, Ix>\n    : I extends Foldable<F>\n    ? PipeableFoldable<F>\n    : {}) &\n  (I extends Alt<F> ? PipeableAlt<F> : {}) &\n  (I extends FilterableWithIndex<F, infer Ix>\n    ? PipeableFilterableWithIndex<F, Ix>\n    : I extends Filterable<F>\n    ? PipeableFilterable<F>\n    : I extends Compactable<F>\n    ? PipeableCompactable<F>\n    : {}) &\n  (I extends Profunctor<F> ? PipeableProfunctor<F> : {}) &\n  (I extends Semigroupoid<F> ? PipeableSemigroupoid<F> : {}) &\n  (I extends MonadThrow<F> ? PipeableMonadThrow<F> : {})\n```\n\nAdded in v2.0.0\n"
  },
  {
    "path": "docs/modules/string.ts.md",
    "content": "---\ntitle: string.ts\nnav_order: 102\nparent: Modules\n---\n\n## string overview\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [Eq](#eq)\n  - [Monoid](#monoid)\n  - [Ord](#ord)\n  - [Semigroup](#semigroup)\n  - [Show](#show)\n- [refinements](#refinements)\n  - [isString](#isstring)\n- [utils](#utils)\n  - [empty](#empty)\n  - [endsWith](#endswith)\n  - [includes](#includes)\n  - [isEmpty](#isempty)\n  - [replace](#replace)\n  - [size](#size)\n  - [slice](#slice)\n  - [split](#split)\n  - [startsWith](#startswith)\n  - [toLowerCase](#tolowercase)\n  - [toUpperCase](#touppercase)\n  - [trim](#trim)\n  - [trimLeft](#trimleft)\n  - [trimRight](#trimright)\n\n---\n\n# instances\n\n## Eq\n\n**Signature**\n\n```ts\nexport declare const Eq: E.Eq<string>\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\n\nassert.deepStrictEqual(S.Eq.equals('a', 'a'), true)\nassert.deepStrictEqual(S.Eq.equals('a', 'b'), false)\n```\n\nAdded in v2.10.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: M.Monoid<string>\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\n\nassert.deepStrictEqual(S.Monoid.concat('a', 'b'), 'ab')\nassert.deepStrictEqual(S.Monoid.concat('a', S.Monoid.empty), 'a')\n```\n\nAdded in v2.10.0\n\n## Ord\n\n**Signature**\n\n```ts\nexport declare const Ord: O.Ord<string>\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\n\nassert.deepStrictEqual(S.Ord.compare('a', 'a'), 0)\nassert.deepStrictEqual(S.Ord.compare('a', 'b'), -1)\nassert.deepStrictEqual(S.Ord.compare('b', 'a'), 1)\n```\n\nAdded in v2.10.0\n\n## Semigroup\n\n`string` semigroup under concatenation.\n\n**Signature**\n\n```ts\nexport declare const Semigroup: S.Semigroup<string>\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\n\nassert.deepStrictEqual(S.Semigroup.concat('a', 'b'), 'ab')\n```\n\nAdded in v2.10.0\n\n## Show\n\n**Signature**\n\n```ts\nexport declare const Show: Sh.Show<string>\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\n\nassert.deepStrictEqual(S.Show.show('a'), '\"a\"')\n```\n\nAdded in v2.10.0\n\n# refinements\n\n## isString\n\n**Signature**\n\n```ts\nexport declare const isString: Refinement<unknown, string>\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\n\nassert.deepStrictEqual(S.isString('a'), true)\nassert.deepStrictEqual(S.isString(1), false)\n```\n\nAdded in v2.11.0\n\n# utils\n\n## empty\n\nAn empty `string`.\n\n**Signature**\n\n```ts\nexport declare const empty: ''\n```\n\nAdded in v2.10.0\n\n## endsWith\n\n**Signature**\n\n```ts\nexport declare const endsWith: (searchString: string, position?: number | undefined) => (s: string) => boolean\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('abc', S.endsWith('c')), true)\nassert.deepStrictEqual(pipe('ab', S.endsWith('c')), false)\n```\n\nAdded in v2.11.0\n\n## includes\n\n**Signature**\n\n```ts\nexport declare const includes: (searchString: string, position?: number | undefined) => (s: string) => boolean\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('abc', S.includes('b')), true)\nassert.deepStrictEqual(pipe('abc', S.includes('d')), false)\n```\n\nAdded in v2.11.0\n\n## isEmpty\n\nTest whether a `string` is empty.\n\n**Signature**\n\n```ts\nexport declare const isEmpty: (s: string) => boolean\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('', S.isEmpty), true)\nassert.deepStrictEqual(pipe('a', S.isEmpty), false)\n```\n\nAdded in v2.10.0\n\n## replace\n\n**Signature**\n\n```ts\nexport declare const replace: (searchValue: string | RegExp, replaceValue: string) => (s: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('abc', S.replace('b', 'd')), 'adc')\n```\n\nAdded in v2.11.0\n\n## size\n\nCalculate the number of characters in a `string`.\n\n**Signature**\n\n```ts\nexport declare const size: (s: string) => number\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('abc', S.size), 3)\n```\n\nAdded in v2.10.0\n\n## slice\n\n**Signature**\n\n```ts\nexport declare const slice: (start: number, end: number) => (s: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('abcd', S.slice(1, 3)), 'bc')\n```\n\nAdded in v2.11.0\n\n## split\n\n**Signature**\n\n```ts\nexport declare const split: (separator: string | RegExp) => (s: string) => ReadonlyNonEmptyArray<string>\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('abc', S.split('')), ['a', 'b', 'c'])\nassert.deepStrictEqual(pipe('', S.split('')), [''])\n```\n\nAdded in v2.11.0\n\n## startsWith\n\n**Signature**\n\n```ts\nexport declare const startsWith: (searchString: string, position?: number | undefined) => (s: string) => boolean\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('abc', S.startsWith('a')), true)\nassert.deepStrictEqual(pipe('bc', S.startsWith('a')), false)\n```\n\nAdded in v2.11.0\n\n## toLowerCase\n\n**Signature**\n\n```ts\nexport declare const toLowerCase: (s: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('A', S.toLowerCase), 'a')\n```\n\nAdded in v2.11.0\n\n## toUpperCase\n\n**Signature**\n\n```ts\nexport declare const toUpperCase: (s: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe('a', S.toUpperCase), 'A')\n```\n\nAdded in v2.11.0\n\n## trim\n\n**Signature**\n\n```ts\nexport declare const trim: (s: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe(' a ', S.trim), 'a')\n```\n\nAdded in v2.11.0\n\n## trimLeft\n\n**Signature**\n\n```ts\nexport declare const trimLeft: (s: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe(' a ', S.trimLeft), 'a ')\n```\n\nAdded in v2.11.0\n\n## trimRight\n\n**Signature**\n\n```ts\nexport declare const trimRight: (s: string) => string\n```\n\n**Example**\n\n```ts\nimport * as S from 'fp-ts/string'\nimport { pipe } from 'fp-ts/function'\n\nassert.deepStrictEqual(pipe(' a ', S.trimRight), ' a')\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/struct.ts.md",
    "content": "---\ntitle: struct.ts\nnav_order: 104\nparent: Modules\n---\n\n## struct overview\n\nAdded in v2.10.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [getAssignSemigroup](#getassignsemigroup)\n- [utils](#utils)\n  - [evolve](#evolve)\n\n---\n\n# instances\n\n## getAssignSemigroup\n\nReturn a semigroup which works like `Object.assign`.\n\n**Signature**\n\n```ts\nexport declare const getAssignSemigroup: <A extends object = never>() => Semigroup<A>\n```\n\n**Example**\n\n```ts\nimport { getAssignSemigroup } from 'fp-ts/struct'\n\ninterface Person {\n  readonly name: string\n  readonly age: number\n}\n\nconst S = getAssignSemigroup<Person>()\nassert.deepStrictEqual(S.concat({ name: 'name', age: 23 }, { name: 'name', age: 24 }), { name: 'name', age: 24 })\n```\n\nAdded in v2.10.0\n\n# utils\n\n## evolve\n\nCreates a new object by recursively evolving a shallow copy of `a`, according to the `transformation` functions.\n\n**Signature**\n\n```ts\nexport declare const evolve: <A, F extends { [K in keyof A]: (a: A[K]) => unknown }>(\n  transformations: F\n) => (a: A) => { [K in keyof F]: ReturnType<F[K]> }\n```\n\n**Example**\n\n```ts\nimport { pipe } from 'fp-ts/function'\nimport { evolve } from 'fp-ts/struct'\n\nassert.deepStrictEqual(\n  pipe(\n    { a: 'a', b: 1 },\n    evolve({\n      a: (a) => a.length,\n      b: (b) => b * 2,\n    })\n  ),\n  { a: 1, b: 2 }\n)\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs/modules/void.ts.md",
    "content": "---\ntitle: void.ts\nnav_order: 118\nparent: Modules\n---\n\n## void overview\n\nAdded in v2.11.0\n\n---\n\n<h2 class=\"text-delta\">Table of contents</h2>\n\n- [instances](#instances)\n  - [Monoid](#monoid)\n  - [Semigroup](#semigroup)\n\n---\n\n# instances\n\n## Monoid\n\n**Signature**\n\n```ts\nexport declare const Monoid: M.Monoid<void>\n```\n\nAdded in v2.11.0\n\n## Semigroup\n\n**Signature**\n\n```ts\nexport declare const Semigroup: Se.Semigroup<void>\n```\n\nAdded in v2.11.0\n"
  },
  {
    "path": "docs-ts.json",
    "content": "{\n  \"exclude\": [\"src/internal.ts\"]\n}\n"
  },
  {
    "path": "dtslint/Applicative.ts",
    "content": "import * as _ from '../src/Applicative'\nimport * as E from '../src/Either'\nimport * as R from '../src/Reader'\nimport * as S from '../src/Semigroup'\n\n//\n// getApplicativeComposition\n//\n\nconst applicativeValidation = E.getValidation(S.semigroupString)\n\n_.getApplicativeComposition(R.reader, applicativeValidation).map // $ExpectType <FE, A, B>(fa: Reader<FE, Either<string, A>>, f: (a: A) => B) => Reader<FE, Either<string, B>>\n"
  },
  {
    "path": "dtslint/Apply.ts",
    "content": "import * as _ from '../src/Apply'\nimport * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as Fu from '../src/Functor'\nimport { Kind, URIS } from '../src/HKT'\nimport * as RTE from '../src/ReaderTaskEither'\n\n//\n// apS\n//\n\nexport const apS =\n  <F extends URIS>(F: _.Apply1<F>) =>\n  (s: Kind<F, string>, n: Kind<F, number>): Kind<F, { s: string; n: number }> => {\n    const apS = _.apS(F)\n    const bindTo = Fu.bindTo(F)\n    return pipe(s, bindTo('s'), apS('n', n))\n  }\n\n//\n// sequenceS\n//\n\n// TODO: broken in typescript@4.2.3\n// export const sequenceS = <F extends URIS>(F: _.Apply1<F>) => (\n//   s: Kind<F, string>,\n//   n: Kind<F, number>\n// ): Kind<F, { s: string; n: number }> => _.sequenceS(F)({ s, n })\n\ndeclare const sequenceS1: E.Either<string, number>\ndeclare const sequenceS2: E.Either<string, string>\ndeclare const sequenceS3: E.Either<string, boolean>\ndeclare const sequenceS4: E.Either<boolean, void>\n\nconst sequenceSf1 = _.sequenceS(E.either)\n\n// @ts-expect-error\nsequenceSf1({})\n// @ts-expect-error\nsequenceSf1({ sequenceS1, sequenceS4 })\n\nsequenceSf1({ sequenceS1, sequenceS2, sequenceS3 }) // $ExpectType Either<string, { sequenceS1: number; sequenceS2: string; sequenceS3: boolean; }>\n\nconst sequenceSf2 = _.sequenceS(RTE.readerTaskEither)\ndeclare const sequenceS5: RTE.ReaderTaskEither<{ a: number }, string, number>\ndeclare const sequenceS6: RTE.ReaderTaskEither<{ a: number }, string, string>\ndeclare const sequenceS7: RTE.ReaderTaskEither<{ a: number }, string, boolean>\ndeclare const sequenceS8: RTE.ReaderTaskEither<{ a: number }, boolean, void>\ndeclare const sequenceS9: RTE.ReaderTaskEither<{ a: string }, string, void>\n\n// @ts-expect-error\nsequenceSf2({ sequenceS5, sequenceS8 })\n// @ts-expect-error\nsequenceSf2({ sequenceS5, sequenceS9 })\n\nsequenceSf2({ sequenceS5, sequenceS6, sequenceS7 }) // $ExpectType ReaderTaskEither<{ a: number; }, string, { sequenceS5: number; sequenceS6: string; sequenceS7: boolean; }>\n\n//\n// sequenceT\n//\n\n// TODO: broken in typescript@4.2.3\n// export const sequenceT = <F extends URIS>(F: _.Apply1<F>) => (\n//   s: Kind<F, string>,\n//   n: Kind<F, number>\n// ): Kind<F, [string, number]> => _.sequenceT(F)(s, n)\n\nconst sequenceTf1 = _.sequenceT(E.either)\n\n// @ts-expect-error\nsequenceTf1([])\n// @ts-expect-error\nsequenceTf1(sequenceS1, sequenceS4)\n\nsequenceTf1(sequenceS1, sequenceS2, sequenceS3) // $ExpectType Either<string, [number, string, boolean]>\n\nconst sequenceTf2 = _.sequenceT(RTE.readerTaskEither)\n\n// @ts-expect-error\nsequenceTf2(sequenceS5, sequenceS8)\n// @ts-expect-error\nsequenceTf2(sequenceS5, sequenceS9)\n\nsequenceTf2(sequenceS5, sequenceS6, sequenceS7) // $ExpectType ReaderTaskEither<{ a: number; }, string, [number, string, boolean]>\n"
  },
  {
    "path": "dtslint/Array.ts",
    "content": "import * as _ from '../src/Array'\nimport * as E from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as N from '../src/number'\nimport { Ord } from '../src/Ord'\n\ndeclare const us: Array<unknown>\ndeclare const ns: Array<number>\ndeclare const ss: Array<string>\ndeclare const tns: Array<[number, string]>\n\n// prepend\n\npipe(ss, _.prepend('a')) // $ExpectType NonEmptyArray<string>\npipe(ss, _.prependW(1)) // $ExpectType NonEmptyArray<string | number>\n\n// append\n\npipe(ss, _.append('a')) // $ExpectType NonEmptyArray<string>\npipe(ss, _.appendW(1)) // $ExpectType NonEmptyArray<string | number>\n\n//\n// zip\n//\n\n_.zip(ns, ss) // $ExpectType [number, string][]\n\n//\n// zipWith\n//\n\n_.zipWith(ns, ss, (n, s) => [n, s] as const) // $ExpectType (readonly [number, string])[]\n\n//\n// unzip\n//\n\n_.unzip(tns) // $ExpectType [number[], string[]]\npipe(tns, _.unzip) // $ExpectType [number[], string[]]\n\n//\n// spanLeft\n//\n\n// $ExpectType Spanned<number, unknown>\npipe(\n  us,\n  _.spanLeft((u: unknown): u is number => typeof u === 'number')\n)\n\n//\n// lookup\n//\n\n_.lookup(0, [1, 2, 3]) // $ExpectType Option<number>\n_.lookup(0) // $ExpectType <A>(as: A[]) => Option<A>\n\n//\n// elem\n//\n\n_.elem(N.Eq)(1, [1, 2, 3]) // $ExpectType boolean\n_.elem(N.Eq)(1) // $ExpectType (as: number[]) => boolean\n\n//\n// difference\n//\n\n_.difference(N.Eq)([1, 2], [3, 4]) // $ExpectType number[]\n_.difference(N.Eq)([3, 4]) // $ExpectType (ys: number[]) => number[]\n\n//\n// intersection\n//\n\n_.intersection(N.Eq)([1, 2], [3, 4]) // $ExpectType number[]\n_.intersection(N.Eq)([3, 4]) // $ExpectType (ys: number[]) => number[]\n\n//\n// union\n//\n\n_.union(N.Eq)([1, 2], [3, 4]) // $ExpectType number[]\n_.union(N.Eq)([3, 4]) // $ExpectType (ys: number[]) => number[]\n\n//\n// zip\n//\n\n_.zip([1, 2], ['a', 'b']) // $ExpectType [number, string][]\n_.zip(['a', 'b']) // $ExpectType <A>(as: A[]) => [A, string][]\n\n//\n// cons\n//\n\n_.cons(0, [1, 2]) // $ExpectType NonEmptyArray<number>\n_.cons(0) // $ExpectType (tail: number[]) => NonEmptyArray<number>\n\n//\n// sort\n//\n\ndeclare const ord1: Ord<{ readonly a: string }>\ninterface X1 {\n  readonly a: string\n  readonly b: number\n}\ndeclare const x1s: Array<X1>\n\n_.sort(ord1)(x1s) // $ExpectType X1[]\npipe(x1s, _.sort(ord1)) // $ExpectType X1[]\n\n//\n// sortBy\n//\n\ndeclare const ord2: Ord<X1>\ndeclare const ord3: Ord<X1>\ninterface X2 {\n  readonly a: string\n  readonly b: number\n  readonly c: boolean\n}\ndeclare const x2s: Array<X2>\n\n_.sortBy([ord2, ord3])(x2s) // $ExpectType X2[]\npipe(x2s, _.sortBy([ord2, ord3])) // $ExpectType X2[]\n\n//\n// Do\n//\n\n// $ExpectType { readonly a1: number; readonly a2: string; }[]\npipe(\n  _.Do,\n  _.bind('a1', () => _.of(1)),\n  _.bind('a2', () => _.of('b'))\n)\n\n//\n// some\n//\n\n// $ExpectType Either<number[], NonEmptyArray<number>>\npipe(\n  ns,\n  E.fromPredicate(\n    _.some((n) => n > 0),\n    identity\n  )\n)\n\n// -------------------------------------------------------------------------------------\n// Predicate-based APIs\n// -------------------------------------------------------------------------------------\n\ndeclare const prns: Array<number>\ndeclare const prsns: Array<string | number>\ndeclare const isString: (u: unknown) => u is string\ndeclare const isNumber: (sn: string | number) => sn is number\ndeclare const predicate: (sn: string | number) => boolean\ndeclare const isStringWithIndex: (i: number, u: unknown) => u is string\ndeclare const isNumberWithIndex: (i: number, sn: string | number) => sn is number\ndeclare const predicateWithIndex: (i: number, sn: string | number) => boolean\n\n//\n// filter\n//\n\n// $ExpectType string[]\npipe(prsns, _.filter(isString))\n// $ExpectType number[]\npipe(prns, _.filter(predicate))\n// $ExpectType number[]\npipe(\n  prns,\n  _.filter(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// filterWithIndex\n//\n\n// $ExpectType string[]\npipe(prsns, _.filterWithIndex(isStringWithIndex))\n// $ExpectType number[]\npipe(prns, _.filterWithIndex(predicateWithIndex))\n// $ExpectType number[]\npipe(\n  prns,\n  _.filterWithIndex(\n    (\n      _i, // $ExpectType number\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partition\n//\n\n// $ExpectType Separated<unknown[], string[]>\npipe(prsns, _.partition(isString))\n// $ExpectType Separated<number[], number[]>\npipe(prns, _.partition(predicate))\n// $ExpectType Separated<(string | number)[], number[]>\npipe(prsns, _.partition(isNumber))\n// $ExpectType Separated<number[], number[]>\npipe(\n  prns,\n  _.partition(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partitionWithIndex\n//\n\n// $ExpectType Separated<unknown[], string[]>\npipe(prsns, _.partitionWithIndex(isStringWithIndex))\n// $ExpectType Separated<number[], number[]>\npipe(prns, _.partitionWithIndex(predicateWithIndex))\n// $ExpectType Separated<(string | number)[], number[]>\npipe(prsns, _.partitionWithIndex(isNumberWithIndex))\n// $ExpectType Separated<number[], number[]>\npipe(\n  prns,\n  _.partitionWithIndex(\n    (\n      _i, // $ExpectType number\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// takeLeftWhile\n//\n\n// $ExpectType string[]\npipe(prsns, _.takeLeftWhile(isString))\n// $ExpectType number[]\npipe(prns, _.takeLeftWhile(predicate))\n\n//\n// dropLeftWhile\n//\n\n// $ExpectType string[]\npipe(prsns, _.dropLeftWhile(isString))\n// $ExpectType number[]\npipe(prns, _.dropLeftWhile(predicate))\n\n//\n// spanLeft\n//\n\n// $ExpectType Spanned<string, unknown>\npipe(prsns, _.spanLeft(isString))\n// $ExpectType Spanned<number, number>\npipe(prns, _.spanLeft(predicate))\n\n//\n// findFirst\n//\n\n// $ExpectType Option<string>\npipe(prsns, _.findFirst(isString))\n// $ExpectType Option<number>\npipe(prns, _.findFirst(predicate))\n\n//\n// findLast\n//\n\n// $ExpectType Option<string>\npipe(prsns, _.findLast(isString))\n// $ExpectType Option<number>\npipe(prns, _.findLast(predicate))\n\n//\n// isEmpty\n//\n\n// $ExpectType Either<string[], []>\npipe(\n  ss,\n  E.fromPredicate(_.isEmpty, (as) => as)\n)\n"
  },
  {
    "path": "dtslint/Console.ts",
    "content": "import * as _ from '../src/Console'\nimport { flow, pipe } from '../src/function'\nimport * as TE from '../src/TaskEither'\n\n// $ExpectType TaskEither<never, string>\npipe(TE.right('a'), TE.chainFirst(flow(_.error, TE.fromIO)))\n\n// $ExpectType TaskEither<never, string>\npipe(TE.right('a'), TE.chainFirst(flow(_.info, TE.fromIO)))\n\n// $ExpectType TaskEither<never, string>\npipe(TE.right('a'), TE.chainFirst(flow(_.log, TE.fromIO)))\n\n// $ExpectType TaskEither<never, string>\npipe(TE.right('a'), TE.chainFirst(flow(_.warn, TE.fromIO)))\n"
  },
  {
    "path": "dtslint/Const.ts",
    "content": "import * as _ from '../src/Const'\n\n//\n// contramap\n//\n\n_.const_.contramap(_.make<boolean>(true), (s: string) => s.length) // $ExpectType Const<boolean, string>\n"
  },
  {
    "path": "dtslint/Either.ts",
    "content": "import * as _ from '../src/Either'\nimport { flow, identity, pipe } from '../src/function'\nimport * as RA from '../src/ReadonlyArray'\n\n//\n// getOrElseW\n//\n\n// $ExpectType string | null\npipe(\n  _.right('a'),\n  _.getOrElseW(() => null)\n)\n\n//\n// chainW\n//\n\n// $ExpectType Either<string | number, number>\npipe(\n  _.right<string, string>('a'),\n  _.chainW(() => _.right<number, number>(1))\n)\n\n//\n// fromNullable\n//\n\ninterface D {\n  foo: number | undefined\n}\ndeclare const f: <K extends keyof D>(key: K) => D[K]\n\n// $ExpectType Either<string, number>\nflow(f, _.fromNullable('error'))('foo')\n\n//\n// do notation\n//\n\n// $ExpectType Either<string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<string, number>(1),\n  _.bindTo('a1'),\n  _.bind('a2', () => _.right('b')),\n  _.bindW('a3', () => _.right<number, boolean>(true))\n)\n\n//\n// pipeable sequence S\n//\n\n// $ExpectType Either<string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<string, number>(1),\n  _.bindTo('a1'),\n  _.apS('a2', _.right('b')),\n  _.apSW('a3', _.right<number, boolean>(true))\n)\n\n//\n// Do\n//\n\n// $ExpectType Either<string, { readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of<string, number>(1)),\n  _.bind('a2', () => _.of<string, string>('b'))\n)\n\n//\n// filterOrElseW\n//\n\n// $ExpectType Either<\"a1\" | \"a2\", number>\npipe(\n  _.left<'a1', number>('a1'),\n  _.filterOrElseW(\n    (result) => result > 0,\n    () => 'a2' as const\n  )\n)\n\n//\n// stringifyJSON\n//\n\n// $ExpectType Either<unknown, string>\npipe(\n  _.right('a'),\n  _.chainFirst((s) => _.stringifyJSON(s, identity))\n)\n\n// -------------------------------------------------------------------------------------\n// Predicate-based APIs\n// -------------------------------------------------------------------------------------\n\ndeclare const n: number\ndeclare const sn: string | number\ndeclare const en: _.Either<boolean, number>\ndeclare const esn: _.Either<boolean, string | number>\ndeclare const isString: (u: unknown) => u is string\ndeclare const predicate: (sn: string | number) => boolean\n\n//\n// fromPredicate\n//\n\n// $ExpectType Either<boolean, string>\npipe(\n  sn,\n  _.fromPredicate(isString, () => false)\n)\n// $ExpectType Either<boolean, number>\npipe(\n  n,\n  _.fromPredicate(predicate, () => false)\n)\n// $ExpectType Either<boolean, number>\npipe(\n  n,\n  _.fromPredicate(\n    (\n      _n // $ExpectType number\n    ) => true,\n    () => false\n  )\n)\n\n//\n// filterOrElse\n//\n\n// $ExpectType Either<boolean, string>\npipe(\n  esn,\n  _.filterOrElse(isString, () => false)\n)\n// $ExpectType Either<boolean, number>\npipe(\n  en,\n  _.filterOrElse(predicate, () => false)\n)\n// $ExpectType Either<boolean, number>\npipe(\n  en,\n  _.filterOrElse(\n    (\n      _n // $ExpectType number\n    ) => true,\n    () => false\n  )\n)\n\n//\n// exists\n//\n\ndeclare const es: Array<_.Either<string, number>>\npipe(es, RA.filter(_.exists((n) => n > 0)))\n"
  },
  {
    "path": "dtslint/Eq.ts",
    "content": "import * as B from '../src/boolean'\nimport * as _ from '../src/Eq'\nimport * as N from '../src/number'\nimport * as S from '../src/string'\n\n//\n// struct\n//\n\n// $ExpectType Eq<{ readonly a: string; readonly b: number; readonly c: boolean; }>\n_.struct({ a: S.Eq, b: N.Eq, c: B.Eq })\n\n//\n// tuple\n//\n\n// $ExpectType Eq<readonly [string, number, boolean]>\n_.tuple(S.Eq, N.Eq, B.Eq)\n\n//\n// getTupleEq\n//\n\n_.getTupleEq(_.eqString, _.eqNumber, _.eqBoolean) // $ExpectType Eq<[string, number, boolean]>\n"
  },
  {
    "path": "dtslint/Functor.ts",
    "content": "import * as E from '../src/Either'\nimport * as _ from '../src/Functor'\nimport * as RTE from '../src/ReaderTaskEither'\nimport * as RA from '../src/ReadonlyArray'\n\n// $ExpectType <A, B>(f: (a: A) => B) => (fa: readonly (readonly A[])[]) => readonly (readonly B[])[]\nexport const F11 = _.map(RA.Functor, RA.Functor)\n\n// $ExpectType <A, B>(f: (a: A) => B) => <E>(fa: readonly Either<E, A>[]) => readonly Either<E, B>[]\nexport const F12 = _.map(RA.Functor, E.Functor)\n\n// $ExpectType <A, B>(f: (a: A) => B) => <R, E>(fa: readonly ReaderTaskEither<R, E, A>[]) => readonly ReaderTaskEither<R, E, B>[]\nexport const F13 = _.map(RA.Functor, RTE.Functor)\n\n// $ExpectType <A, B>(f: (a: A) => B) => <E>(fa: Either<E, readonly A[]>) => Either<E, readonly B[]>\nexport const F21 = _.map(E.Functor, RA.Functor)\n\n// $ExpectType <A, B>(f: (a: A) => B) => <EF, EG>(fa: Either<EF, Either<EG, A>>) => Either<EF, Either<EG, B>>\nexport const F22 = _.map(E.Functor, E.Functor)\n\n// $ExpectType <A, B>(f: (a: A) => B) => <R, E>(fa: ReaderTaskEither<R, E, readonly A[]>) => ReaderTaskEither<R, E, readonly B[]>\nexport const F31 = _.map(RTE.Functor, RA.Functor)\n"
  },
  {
    "path": "dtslint/IO.ts",
    "content": "import { pipe } from '../src/function'\nimport * as _ from '../src/IO'\n\n//\n// Do\n//\n\n// $ExpectType IO<{ readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of(1)),\n  _.bind('a2', () => _.of('b'))\n)\n"
  },
  {
    "path": "dtslint/IOEither.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as IO from '../src/IO'\nimport * as _ from '../src/IOEither'\n\n//\n// getOrElseW\n//\n\n// $ExpectType IO<string | null>\npipe(\n  _.right('a'),\n  _.getOrElseW(() => IO.of(null))\n)\n\n//\n// orElse\n//\n\n// $ExpectType IOEither<number, never>\npipe(\n  _.left('a'),\n  _.orElse((a) => _.left(a.length))\n)\n\n//\n// orElseW\n//\n\n// $ExpectType IOEither<never, string | number>\npipe(\n  _.left<string, string>('a'),\n  _.orElseW((a) => _.right(a.length))\n)\n\n//\n// orElseFirst\n//\n\n// $ExpectType IOEither<string, never>\npipe(\n  _.left('a'),\n  _.orElseFirst((a) => _.right(a.length))\n)\n\n//\n// orElseFirstW\n//\n\n// $ExpectType IOEither<string | number, never>\npipe(\n  _.left('a'),\n  _.orElseFirstW((a) => _.left(a.length))\n)\n\n//\n// orElseFirstIOK\n//\n\n// $ExpectType IOEither<string, never>\npipe(\n  _.left('a'),\n  _.orElseFirstIOK((a) => IO.of(a.length))\n)\n\n//\n// orLeft\n//\n\n// $ExpectType IOEither<number, never>\npipe(\n  _.left('a'),\n  _.orLeft((a) => IO.of(a.length))\n)\n\n//\n// chainW\n//\n\n// $ExpectType IOEither<string | number, number>\npipe(\n  _.right<string, string>('a'),\n  _.chainW(() => _.right<number, number>(1))\n)\n\n//\n// chainEitherKW\n//\n\n// $ExpectType IOEither<string | number, number>\npipe(\n  _.right<string, string>('a'),\n  _.chainEitherKW(() => E.right<number, number>(1))\n)\n\n//\n// do notation\n//\n\n// $ExpectType IOEither<string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<string, number>(1),\n  _.bindTo('a1'),\n  _.bind('a2', () => _.right('b')),\n  _.bindW('a3', () => _.right<number, boolean>(true))\n)\n\n//\n// pipeable sequence S\n//\n\n// $ExpectType IOEither<string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<string, number>(1),\n  _.bindTo('a1'),\n  _.apS('a2', _.right('b')),\n  _.apSW('a3', _.right<number, boolean>(true))\n)\n\n//\n// Do\n//\n\n// $ExpectType IOEither<string, { readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of<string, number>(1)),\n  _.bind('a2', () => _.of<string, string>('b'))\n)\n\n//\n// filterOrElseW\n//\n\n// $ExpectType IOEither<\"a1\" | \"a2\", number>\npipe(\n  _.left<'a1', number>('a1'),\n  _.filterOrElseW(\n    (result) => result > 0,\n    () => 'a2' as const\n  )\n)\n"
  },
  {
    "path": "dtslint/Identity.ts",
    "content": "import { pipe } from '../src/function'\nimport * as _ from '../src/Identity'\n\n//\n// Do\n//\n\n// $ExpectType { readonly a1: number; readonly a2: string; }\npipe(\n  _.Do,\n  _.bind('a1', () => _.of(1)),\n  _.bind('a2', () => _.of('b'))\n)\n"
  },
  {
    "path": "dtslint/Json.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as _ from '../src/Json'\n\n//\n// stringify\n//\n\n// @ts-expect-error\n_.stringify<_.Json>(undefined)\n// @ts-expect-error\n_.stringify<_.Json>(() => {\n  return\n})\n// @ts-expect-error\n_.stringify<_.Json>(Symbol())\n// @ts-expect-error\n_.stringify<_.Json>({ a: undefined })\n// @ts-expect-error\n_.stringify<_.Json>({ ...{ a: undefined } })\n\n// tslint:disable-next-line: interface-over-type-literal\ninterface AB {\n  readonly a: string\n  readonly b: number\n}\n\nconst ab: AB = { a: 'a', b: 1 }\n\nconst abs: ReadonlyArray<AB> = [{ a: 'a', b: 1 }]\n\n_.stringify({ a: 'a', b: 1 })\n_.stringify(ab)\n_.stringify({ ...ab })\n_.stringify([{ a: 'a', b: 1 }])\n_.stringify(abs)\n_.stringify([...abs])\n\n// $ExpectType Either<unknown, string>\npipe(E.right('a'), E.chainFirst(_.stringify))\n"
  },
  {
    "path": "dtslint/Map.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as _ from '../src/Map'\nimport * as N from '../src/number'\nimport * as S from '../src/string'\n\n//\n// member\n//\n\n_.member(S.Eq)('a', new Map()) // $ExpectType boolean\n_.member(S.Eq)('a') // $ExpectType <A>(m: Map<string, A>) => boolean\n\n//\n// elem\n//\n\n_.elem(S.Eq)('a', new Map()) // $ExpectType boolean\n_.elem(S.Eq)('a') // $ExpectType <K>(m: Map<K, string>) => boolean\n\n//\n// lookup\n//\n\n_.lookup(S.Eq)('a', new Map([['a', 1]])) // $ExpectType Option<number>\n_.lookup(S.Eq)('a') // $ExpectType <A>(m: Map<string, A>) => Option<A>\n\n//\n// lookupWithKey\n//\n\n_.lookupWithKey(S.Eq)('a', new Map([['a', 1]])) // $ExpectType Option<[string, number]>\n_.lookupWithKey(S.Eq)('a') // $ExpectType <A>(m: Map<string, A>) => Option<[string, A]>\n\n//\n// isSubmap\n//\n\n_.isSubmap(S.Eq, N.Eq)(new Map([['a', 1]]), new Map([['a', 1]])) // $ExpectType boolean\n_.isSubmap(S.Eq, N.Eq)(new Map([['a', 1]])) // $ExpectType (me: Map<string, number>) => boolean\n\n// -------------------------------------------------------------------------------------\n// Predicate-based APIs\n// -------------------------------------------------------------------------------------\n\ndeclare const prns: Map<string, number>\ndeclare const prsns: Map<string, string | number>\ndeclare const isString: (u: unknown) => u is string\ndeclare const isNumber: (sn: string | number) => sn is number\ndeclare const predicate: (sn: string | number) => boolean\ndeclare const isStringWithIndex: (k: string, u: unknown) => u is string\ndeclare const isNumberWithIndex: (k: string, sn: string | number) => sn is number\ndeclare const predicateWithIndex: (k: string, sn: string | number) => boolean\n\n//\n// filter\n//\n\n// $ExpectType Map<string, string>\npipe(prsns, _.filter(isString))\n// $ExpectType Map<string, number>\npipe(prns, _.filter(predicate))\n// $ExpectType Map<string, number>\npipe(\n  prns,\n  _.filter(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// filterWithIndex\n//\n\n// $ExpectType Map<string, string>\npipe(prsns, _.filterWithIndex(isStringWithIndex))\n// $ExpectType Map<string, number>\npipe(prns, _.filterWithIndex(predicateWithIndex))\n// $ExpectType Map<string, number>\npipe(\n  prns,\n  _.filterWithIndex(\n    (\n      _k, // $ExpectType string\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partition\n//\n\n// $ExpectType Separated<Map<string, unknown>, Map<string, string>>\npipe(prsns, _.partition(isString))\n// $ExpectType Separated<Map<string, number>, Map<string, number>>\npipe(prns, _.partition(predicate))\n// $ExpectType Separated<Map<string, string | number>, Map<string, number>>\npipe(prsns, _.partition(isNumber))\n// $ExpectType Separated<Map<string, number>, Map<string, number>>\npipe(\n  prns,\n  _.partition(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partitionWithIndex\n//\n\n// $ExpectType Separated<Map<string, unknown>, Map<string, string>>\npipe(prsns, _.partitionWithIndex(isStringWithIndex))\n// $ExpectType Separated<Map<string, number>, Map<string, number>>\npipe(prns, _.partitionWithIndex(predicateWithIndex))\n// $ExpectType Separated<Map<string, string | number>, Map<string, number>>\npipe(prsns, _.partitionWithIndex(isNumberWithIndex))\n// $ExpectType Separated<Map<string, number>, Map<string, number>>\npipe(\n  prns,\n  _.partitionWithIndex(\n    (\n      _k, // $ExpectType string\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// isEmpty\n//\n\n// $ExpectType Either<Map<string, number>, Map<string, number>>\npipe(\n  prns,\n  E.fromPredicate(_.isEmpty, (as) => as)\n)\n"
  },
  {
    "path": "dtslint/Monoid.ts",
    "content": "import * as B from '../src/boolean'\nimport * as _ from '../src/Monoid'\nimport * as N from '../src/number'\nimport * as S from '../src/string'\n\n//\n// struct\n//\n\n// $ExpectType Monoid<{ readonly a: string; readonly b: number; readonly c: boolean; }>\n_.struct({ a: S.Monoid, b: N.MonoidSum, c: B.MonoidAll })\n\n//\n// tuple\n//\n\n// $ExpectType Monoid<readonly [string, number, boolean]>\n_.tuple(S.Monoid, N.MonoidSum, B.MonoidAll)\n\n//\n// getTupleMonoid\n//\n\n_.getTupleMonoid(_.monoidString, _.monoidSum, _.monoidAll) // $ExpectType Monoid<[string, number, boolean]>\n"
  },
  {
    "path": "dtslint/NonEmptyArray.ts",
    "content": "import { pipe } from '../src/function'\nimport * as _ from '../src/NonEmptyArray'\nimport { Ord } from '../src/Ord'\n\ndeclare const as: Array<string>\ndeclare const neas: _.NonEmptyArray<string>\ndeclare const nens: _.NonEmptyArray<number>\ndeclare const netns: _.NonEmptyArray<[number, string]>\n\n//\n// zip\n//\n\n_.zip(nens, neas) // $ExpectType NonEmptyArray<[number, string]>\n_.zip(neas) // $ExpectType <A>(as: NonEmptyArray<A>) => NonEmptyArray<[A, string]>\n\n//\n// zipWith\n//\n\n_.zipWith(nens, neas, (n, s) => [n, s] as const) // $ExpectType NonEmptyArray<readonly [number, string]>\n\n//\n// unzip\n//\n\n_.unzip(netns) // $ExpectType [NonEmptyArray<number>, NonEmptyArray<string>]\npipe(netns, _.unzip) // $ExpectType [NonEmptyArray<number>, NonEmptyArray<string>]\n\n//\n// cons\n//\n\n_.cons(1, []) // $ExpectType NonEmptyArray<1>\n_.cons(1, [2, 3]) // $ExpectType NonEmptyArray<number>\n\n//\n// sort\n//\n\ndeclare const ordSubX: Ord<{ readonly a: string }>\ninterface X {\n  readonly a: string\n  readonly b: number\n}\n\ndeclare const xs: Array<X>\ndeclare const nexs: _.NonEmptyArray<X>\n\n_.sort(ordSubX)(nexs) // $ExpectType NonEmptyArray<X>\npipe(nexs, _.sort(ordSubX)) // $ExpectType NonEmptyArray<X>\n\n//\n// group\n//\n\n_.group(ordSubX)(xs) // $ExpectType NonEmptyArray<X>[]\npipe(xs, _.group<X>(ordSubX)) // $ExpectType NonEmptyArray<X>[]\n_.group(ordSubX)(nexs) // $ExpectType NonEmptyArray<NonEmptyArray<X>>\n// TODO pipe(nexs, _.group<X>(ordSubX)) // $ExpectType NonEmptyArray<NonEmptyArray<X>>\n\n//\n// groupSort\n//\n\n_.groupSort(ordSubX)(xs) // $ExpectType NonEmptyArray<X>[]\npipe(xs, _.groupSort<X>(ordSubX)) // $ExpectType NonEmptyArray<X>[]\n_.groupSort(ordSubX)(nexs) // $ExpectType NonEmptyArray<NonEmptyArray<X>>\n// TODO pipe(nexs, _.groupSort<X>(ordSubX)) // $ExpectType NonEmptyArray<NonEmptyArray<X>>\n\n//\n// groupBy\n//\n\n_.groupBy((x: { readonly a: string }) => x.a)(xs) // $ExpectType Record<string, NonEmptyArray<{ readonly a: string; }>>\n// $ExpectType Record<string, NonEmptyArray<X>>\npipe(\n  xs,\n  _.groupBy((x) => x.a)\n)\n\n//\n// Do\n//\n\n// $ExpectType NonEmptyArray<{ readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of(1)),\n  _.bind('a2', () => _.of('b'))\n)\n\n//\n// filter\n//\n\ndeclare const isNumber1: (sn: string | number) => sn is number\ndeclare const isNumber2: (sn: unknown) => sn is number\ndeclare const neasn: _.NonEmptyArray<string | number>\n\n// $ExpectType Option<NonEmptyArray<number>>\npipe(neasn, _.filter(isNumber1))\n// $ExpectType Option<NonEmptyArray<number>>\n_.filter(isNumber1)(neasn)\n// $ExpectType Option<NonEmptyArray<number>>\npipe(neasn, _.filter(isNumber2))\n// $ExpectType Option<NonEmptyArray<number>>\n_.filter(isNumber2)(neasn)\n\n//\n// concat\n//\n\n_.concat(as, neas) // $ExpectType NonEmptyArray<string>\n_.concat(neas, as) // $ExpectType NonEmptyArray<string>\n_.concat(neas)(as) // $ExpectType NonEmptyArray<string>\n_.concat(as)(neas) // $ExpectType NonEmptyArray<string>\n"
  },
  {
    "path": "dtslint/Option.ts",
    "content": "import { flow, pipe } from '../src/function'\nimport * as _ from '../src/Option'\n\n//\n// getOrElseW\n//\n\n// $ExpectType string | null\npipe(\n  _.some('a'),\n  _.getOrElseW(() => null)\n)\n\n//\n// fromNullable\n//\n\ndeclare const x: number | null | undefined\n_.fromNullable(x) // $ExpectType Option<number>\n\ninterface D {\n  foo: number | undefined\n}\ndeclare const f: <K extends keyof D>(key: K) => D[K]\n// $ExpectType Option<number>\nflow(f, _.fromNullable)('foo')\n\n//\n// Do\n//\n\n// $ExpectType Option<{ readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of(1)),\n  _.bind('a2', () => _.of('b'))\n)\n\n// -------------------------------------------------------------------------------------\n// Predicate-based APIs\n// -------------------------------------------------------------------------------------\n\ndeclare const n: number\ndeclare const sn: string | number\ndeclare const on: _.Option<number>\ndeclare const osn: _.Option<string | number>\ndeclare const isString: (u: unknown) => u is string\ndeclare const isNumber: (sn: string | number) => sn is number\ndeclare const predicate: (sn: string | number) => boolean\n\n//\n// filter\n//\n\n// $ExpectType Option<string>\npipe(osn, _.filter(isString))\n// $ExpectType Option<number>\npipe(on, _.filter(predicate))\n// $ExpectType Option<number>\npipe(\n  on,\n  _.filter(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partition\n//\n\n// $ExpectType Separated<Option<unknown>, Option<string>>\npipe(osn, _.partition(isString))\n// $ExpectType Separated<Option<number>, Option<number>>\npipe(on, _.partition(predicate))\n// $ExpectType Separated<Option<string | number>, Option<number>>\npipe(osn, _.partition(isNumber))\n// $ExpectType Separated<Option<number>, Option<number>>\npipe(\n  on,\n  _.partition(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// fromPredicate\n//\n\n// $ExpectType Option<string>\npipe(sn, _.fromPredicate(isString))\n// $ExpectType Option<number>\npipe(n, _.fromPredicate(predicate))\n// $ExpectType Option<number>\npipe(\n  n,\n  _.fromPredicate(\n    (\n      _n // $ExpectType number\n    ) => true\n  )\n)\n"
  },
  {
    "path": "dtslint/Ord.ts",
    "content": "import * as B from '../src/boolean'\nimport * as N from '../src/number'\nimport * as _ from '../src/Ord'\nimport * as S from '../src/string'\n\n//\n// tuple\n//\n\n// $ExpectType Ord<readonly [string, number, boolean]>\n_.tuple(S.Ord, N.Ord, B.Ord)\n\n//\n// getTupleOrd\n//\n\n_.getTupleOrd(_.ordString, _.ordNumber, _.ordBoolean) // $ExpectType Ord<[string, number, boolean]>\n"
  },
  {
    "path": "dtslint/Reader.ts",
    "content": "import { pipe } from '../src/function'\nimport * as _ from '../src/Reader'\n\n//\n// chainW\n//\n\n// $ExpectType Reader<{ a: string; } & { b: number; }, number>\npipe(\n  _.of<{ a: string }, string>('a'),\n  _.chainW(() => _.of<{ b: number }, number>(1))\n)\n\n//\n// Do\n//\n\n// $ExpectType Reader<string, { readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of<string, number>(1)),\n  _.bind('a2', () => _.of<string, string>('b'))\n)\n"
  },
  {
    "path": "dtslint/ReaderEither.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as R from '../src/Reader'\nimport * as _ from '../src/ReaderEither'\n\n//\n// getOrElseW\n//\n\n// $ExpectType Reader<{ a: string; } & { b: number; }, string | null>\npipe(\n  _.right<{ a: string }, string, string>('a'),\n  _.getOrElseW(() => R.of<{ b: number }, null>(null))\n)\n\n//\n// orElse\n//\n\n// $ExpectType ReaderEither<{ a: string; }, number, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orElse((a) => _.left(a.length))\n)\n\n//\n// orElseW\n//\n\n// $ExpectType ReaderEither<{ b: number; } & { a: string; }, never, string | number>\npipe(\n  _.left<{ a: string }, string, string>('a'),\n  _.orElseW((a) => _.right<{ b: number }, never, string | number>(a.length))\n)\n\n//\n// orElseFirst\n//\n\n// $ExpectType ReaderEither<{ a: string; }, string, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orElseFirst((a) => _.right(a.length))\n)\n\n//\n// orElseFirstW\n//\n\n// $ExpectType ReaderEither<{ a: string; }, string | number, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orElseFirstW((a) => _.left(a.length))\n)\n\n//\n// orLeft\n//\n\n// $ExpectType ReaderEither<{ a: string; }, number, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orLeft((a) => R.of(a.length))\n)\n\n//\n// orLeftW\n//\n\n// $ExpectType ReaderEither<{ a: string; } & { b: string; }, number, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orLeftW((a) => R.of<{ b: string }, number>(a.length))\n)\n\n//\n// chainW\n//\n\n// $ExpectType ReaderEither<{ a: string; } & { b: number; }, string | number, number>\npipe(\n  _.right<{ a: string }, string, string>('a'),\n  _.chainW(() => _.right<{ b: number }, number, number>(1))\n)\n\n//\n// chainEitherKW\n//\n\n// $ExpectType ReaderEither<string, string | number, number>\npipe(\n  _.right<string, string, string>('a'),\n  _.chainEitherKW(() => E.right<number, number>(1))\n)\n\n//\n// do notation\n//\n\n// $ExpectType ReaderEither<{ readonly a: number; } & { readonly b: string; }, string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<{ readonly a: number }, string, number>(1),\n  _.bindTo('a1'),\n  _.bind('a2', () => _.right('b')),\n  _.bindW('a3', () => _.right<{ readonly b: string }, number, boolean>(true))\n)\n\n//\n// pipeable sequence S\n//\n\n// $ExpectType ReaderEither<{ readonly a: number; } & { readonly b: string; }, string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<{ readonly a: number }, string, number>(1),\n  _.bindTo('a1'),\n  _.apS('a2', _.right('b')),\n  _.apSW('a3', _.right<{ readonly b: string }, number, boolean>(true))\n)\n\n//\n// Do\n//\n\n// $ExpectType ReaderEither<unknown, string, { readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of<unknown, string, number>(1)),\n  _.bind('a2', () => _.of<unknown, string, string>('b'))\n)\n\n//\n// filterOrElseW\n//\n\n// $ExpectType ReaderEither<{ c: boolean; }, \"a1\" | \"a2\", number>\npipe(\n  _.left<{ c: boolean }, 'a1', number>('a1'),\n  _.filterOrElseW(\n    (result) => result > 0,\n    () => 'a2' as const\n  )\n)\n"
  },
  {
    "path": "dtslint/ReaderT.ts",
    "content": "import * as _ from '../src/ReaderT'\nimport * as RTE from '../src/ReaderTaskEither'\nimport * as SRTE from '../src/StateReaderTaskEither'\nimport * as TE from '../src/TaskEither'\nimport * as TTH from '../src/TaskThese'\n\n// $ExpectType <R, E, A>(f: (r: R) => Either<E, A>) => Reader<R, TaskEither<E, A>>\n_.fromNaturalTransformation<'Either', 'TaskEither'>(TE.fromEither)\n\n// $ExpectType <R, A, E>(f: (r: R) => IO<A>) => Reader<R, TaskEither<E, A>>\n_.fromNaturalTransformation<'IO', 'TaskEither'>(TE.fromIO)\n\n// $ExpectType <R, A, E>(f: (r: R) => Reader<R, A>) => Reader<R, ReaderTaskEither<R, E, A>>\n_.fromNaturalTransformation<'Reader', 'ReaderTaskEither'>(RTE.fromReader)\n\n// $ExpectType <R, S, A, E>(f: (r: R) => State<S, A>) => Reader<R, StateReaderTaskEither<S, R, E, A>>\n_.fromNaturalTransformation<'State', 'StateReaderTaskEither'>(SRTE.fromState)\n\n// $ExpectType <R, A, E>(f: (r: R) => Task<A>) => Reader<R, TaskEither<E, A>>\n_.fromNaturalTransformation<'Task', 'TaskEither'>(TE.fromTask)\n\n// $ExpectType <R, E, A>(f: (r: R) => These<E, A>) => Reader<R, TaskThese<E, A>>\n_.fromNaturalTransformation<'These', 'TaskThese'>(TTH.fromThese)\n"
  },
  {
    "path": "dtslint/ReaderTask.ts",
    "content": "import { pipe } from '../src/function'\nimport * as RIO from '../src/ReaderIO'\nimport * as _ from '../src/ReaderTask'\n\ninterface R1 {\n  foo: string\n}\n\ninterface R2 {\n  bar: string\n}\n\n//\n// fromReaderIO\n//\n\n// $ExpectType ReaderTask<R1, boolean>\n_.fromReaderIO(RIO.of<R1, boolean>(true))\n\n//\n// fromReaderIOK\n//\n\n// $ExpectType (a: boolean) => ReaderTask<R1, boolean>\n_.fromReaderIOK((a: boolean) => RIO.of<R1, boolean>(a))\n\n//\n// chainReaderIOKW\n//\n\n// $ExpectType ReaderTask<R1 & R2, boolean>\npipe(\n  _.of<R1, number>(1),\n  _.chainReaderIOKW(() => RIO.of<R2, boolean>(true))\n)\n\n//\n// chainReaderIOK\n//\n\n// $ExpectType ReaderTask<R1, number>\npipe(\n  _.of<R1, number>(1),\n  _.chainReaderIOK(() => RIO.of(1))\n)\n\npipe(\n  // @ts-expect-error\n  _.of<R1, number>(1),\n  _.chainReaderIOK(() => RIO.of<R2, boolean>(true))\n)\n\n//\n// chainFirstReaderIOKW\n//\n\n// $ExpectType ReaderTask<R1 & R2, number>\npipe(\n  _.of<R1, number>(1),\n  _.chainFirstReaderIOKW(() => RIO.of<R2, boolean>(true))\n)\n\n//\n// chainFirstReaderIOK\n//\n\n// $ExpectType ReaderTask<R1, number>\npipe(\n  _.of<R1, number>(1),\n  _.chainFirstReaderIOK(() => RIO.of(true))\n)\n\npipe(\n  // @ts-expect-error\n  _.of<R1, number>(1),\n  _.chainFirstReaderIOK(() => RIO.of<R2, boolean>(true))\n)\n\n//\n// Do\n//\n\n// $ExpectType ReaderTask<unknown, { readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of<unknown, number>(1)),\n  _.bind('a2', () => _.of<unknown, string>('b'))\n)\n"
  },
  {
    "path": "dtslint/ReaderTaskEither.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as IOE from '../src/IOEither'\nimport * as RIO from '../src/ReaderIO'\nimport * as RT from '../src/ReaderTask'\nimport * as _ from '../src/ReaderTaskEither'\nimport * as TE from '../src/TaskEither'\n\n//\n// rightReaderIO\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, never, boolean>\n_.rightReaderIO(RIO.of<{ a: string }, boolean>(true))\n\n//\n// leftReaderIO\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, boolean, never>\n_.leftReaderIO(RIO.of<{ a: string }, boolean>(true))\n\n//\n// getOrElseW\n//\n\n// $ExpectType ReaderTask<{ a: string; } & { b: number; }, string | null>\npipe(\n  _.right<{ a: string }, string, string>('a'),\n  _.getOrElseW(() => RT.of<{ b: number }, null>(null))\n)\n\n//\n// orElse\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, number, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orElse((a) => _.left(a.length))\n)\n\n//\n// orElseW\n//\n\n// $ExpectType ReaderTaskEither<{ b: number; } & { a: string; }, never, string | number>\npipe(\n  _.left<{ a: string }, string, string>('a'),\n  _.orElseW((a) => _.right<{ b: number }, never, string | number>(a.length))\n)\n\n//\n// orElseFirst\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, string, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orElseFirst((a) => _.right(a.length))\n)\n\n//\n// orElseFirstW\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, string | number, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orElseFirstW((a) => _.left(a.length))\n)\n\n//\n// orLeft\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, number, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orLeft((a) => RT.of(a.length))\n)\n\n//\n// orLeftW\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; } & { b: string; }, number, never>\npipe(\n  _.left<{ a: string }, string, never>('a'),\n  _.orLeftW((a) => RT.of<{ b: string }, number>(a.length))\n)\n\n//\n// chainW\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; } & { b: number; }, string | number, number>\npipe(\n  _.right<{ a: string }, string, string>('a'),\n  _.chainW(() => _.right<{ b: number }, number, number>(1))\n)\n\n//\n// chainEitherKW\n//\n\n// $ExpectType ReaderTaskEither<string, string | number, number>\npipe(\n  _.right<string, string, string>('a'),\n  _.chainEitherKW(() => E.right<number, number>(1))\n)\n\n//\n// chainTaskEitherKW\n//\n\n// $ExpectType ReaderTaskEither<string, string | number, number>\npipe(\n  _.right<string, string, string>('a'),\n  _.chainTaskEitherKW(() => TE.right<number, number>(1))\n)\n\n//\n// chainIOEitherKW\n//\n\n// $ExpectType ReaderTaskEither<string, string | number, number>\npipe(\n  _.right<string, string, string>('a'),\n  _.chainIOEitherKW(() => IOE.right<number, number>(1))\n)\n\n//\n// fromReaderIOK\n//\n\n// $ExpectType <E = never>(a: boolean) => ReaderTaskEither<{ a: string; }, E, boolean>\n_.fromReaderIOK((a: boolean) => RIO.of<{ a: string }, boolean>(a))\n\n//\n// chainReaderIOKW\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; } & { b: number; }, string, boolean>\npipe(\n  _.right<{ a: string }, string, number>(1),\n  _.chainReaderIOKW(() => RIO.of<{ b: number }, boolean>(true))\n)\n\n//\n// chainReaderIOK\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, string, number>\npipe(\n  _.right<{ a: string }, string, number>(1),\n  _.chainReaderIOK(() => RIO.of(1))\n)\n\npipe(\n  _.right<{ a: string }, string, number>(1),\n  // @ts-expect-error\n  _.chainReaderIOK(() => RIO.of<{ b: number }, boolean>(true))\n)\n\n//\n// chainFirstReaderIOKW\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; } & { b: number; }, string, number>\npipe(\n  _.right<{ a: string }, string, number>(1),\n  _.chainFirstReaderIOKW(() => RIO.of<{ b: number }, boolean>(true))\n)\n\n//\n// chainFirstReaderIOK\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, string, number>\npipe(\n  _.right<{ a: string }, string, number>(1),\n  _.chainFirstReaderIOK(() => RIO.of(true))\n)\n\npipe(\n  _.right<{ a: string }, string, number>(1),\n  // @ts-expect-error\n  _.chainFirstReaderIOK(() => RIO.of<{ b: number }, boolean>(true))\n)\n\n//\n// rightReaderIO\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, never, boolean>\n_.rightReaderIO(RIO.of<{ a: string }, boolean>(true))\n\n//\n// leftReaderIO\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, boolean, never>\n_.leftReaderIO(RIO.of<{ a: string }, boolean>(true))\n\n//\n// fromReaderIOK\n//\n\n// $ExpectType <E = never>(a: boolean) => ReaderTaskEither<{ a: string; }, E, boolean>\n_.fromReaderIOK((a: boolean) => RIO.of<{ a: string }, boolean>(a))\n\n//\n// chainReaderIOKW\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; } & { b: number; }, string, boolean>\npipe(\n  _.right<{ a: string }, string, number>(1),\n  _.chainReaderIOKW(() => RIO.of<{ b: number }, boolean>(true))\n)\n\n//\n// chainReaderIOK\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, string, number>\npipe(\n  _.right<{ a: string }, string, number>(1),\n  _.chainReaderIOK(() => RIO.of(1))\n)\n\npipe(\n  _.right<{ a: string }, string, number>(1),\n  // @ts-expect-error\n  _.chainReaderIOK(() => RIO.of<{ b: number }, boolean>(true))\n)\n\n//\n// chainFirstReaderIOKW\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; } & { b: number; }, string, number>\npipe(\n  _.right<{ a: string }, string, number>(1),\n  _.chainFirstReaderIOKW(() => RIO.of<{ b: number }, boolean>(true))\n)\n\n//\n// chainFirstReaderIOK\n//\n\n// $ExpectType ReaderTaskEither<{ a: string; }, string, number>\npipe(\n  _.right<{ a: string }, string, number>(1),\n  _.chainFirstReaderIOK(() => RIO.of(true))\n)\n\npipe(\n  _.right<{ a: string }, string, number>(1),\n  // @ts-expect-error\n  _.chainFirstReaderIOK(() => RIO.of<{ b: number }, boolean>(true))\n)\n\n//\n// do notation\n//\n\n// $ExpectType ReaderTaskEither<{ readonly a: number; } & { readonly b: string; }, string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<{ readonly a: number }, string, number>(1),\n  _.bindTo('a1'),\n  _.bind('a2', () => _.right('b')),\n  _.bindW('a3', () => _.right<{ readonly b: string }, number, boolean>(true))\n)\n\n//\n// pipeable sequence S\n//\n\n// $ExpectType ReaderTaskEither<{ readonly a: number; } & { readonly b: string; }, string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<{ readonly a: number }, string, number>(1),\n  _.bindTo('a1'),\n  _.apS('a2', _.right('b')),\n  _.apSW('a3', _.right<{ readonly b: string }, number, boolean>(true))\n)\n\n//\n// Do\n//\n\n// $ExpectType ReaderTaskEither<unknown, string, { readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of<unknown, string, number>(1)),\n  _.bind('a2', () => _.of<unknown, string, string>('b'))\n)\n\n//\n// filterOrElseW\n//\n\n// $ExpectType ReaderTaskEither<{ c: boolean; }, \"a1\" | \"a2\", number>\npipe(\n  _.left<{ c: boolean }, 'a1', number>('a1'),\n  _.filterOrElseW(\n    (result) => result > 0,\n    () => 'a2' as const\n  )\n)\n"
  },
  {
    "path": "dtslint/ReadonlyArray.ts",
    "content": "import * as E from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as N from '../src/number'\nimport { Ord } from '../src/Ord'\nimport * as _ from '../src/ReadonlyArray'\n\ndeclare const rus: ReadonlyArray<unknown>\ndeclare const rns: ReadonlyArray<number>\ndeclare const rss: ReadonlyArray<string>\ndeclare const rtns: ReadonlyArray<readonly [number, string]>\n\n// prepend\n\npipe(rss, _.prepend('a')) // $ExpectType ReadonlyNonEmptyArray<string>\npipe(rss, _.prependW(1)) // $ExpectType ReadonlyNonEmptyArray<string | number>\n\n// append\n\npipe(rss, _.append('a')) // $ExpectType ReadonlyNonEmptyArray<string>\npipe(rss, _.appendW(1)) // $ExpectType ReadonlyNonEmptyArray<string | number>\n\n//\n// zip\n//\n\n_.zip(rns, rss) // $ExpectType readonly (readonly [number, string])[]\n\n//\n// zipWith\n//\n\n_.zipWith(rns, rss, (n, s) => [n, s] as const) // $ExpectType readonly (readonly [number, string])[]\n\n//\n// unzip\n//\n\n_.unzip(rtns) // $ExpectType readonly [readonly number[], readonly string[]]\npipe(rtns, _.unzip) // $ExpectType readonly [readonly number[], readonly string[]]\n\n//\n// spanLeft\n//\n\n// $ExpectType Spanned<number, unknown>\npipe(\n  rus,\n  _.spanLeft((u: unknown): u is number => typeof u === 'number')\n)\n\n//\n// lookup\n//\n\n_.lookup(0, [1, 2, 3]) // $ExpectType Option<number>\n_.lookup(0) // $ExpectType <A>(as: readonly A[]) => Option<A>\n\n//\n// elem\n//\n\n_.elem(N.Eq)(1, [1, 2, 3]) // $ExpectType boolean\n_.elem(N.Eq)(1) // $ExpectType (as: readonly number[]) => boolean\n\n//\n// difference\n//\n\n_.difference(N.Eq)([1, 2], [3, 4]) // $ExpectType readonly number[]\n_.difference(N.Eq)([3, 4]) // $ExpectType (ys: readonly number[]) => readonly number[]\n\n//\n// intersection\n//\n\n_.intersection(N.Eq)([1, 2], [3, 4]) // $ExpectType readonly number[]\n_.intersection(N.Eq)([3, 4]) // $ExpectType (ys: readonly number[]) => readonly number[]\n\n//\n// union\n//\n\n_.union(N.Eq)([1, 2], [3, 4]) // $ExpectType readonly number[]\n_.union(N.Eq)([3, 4]) // $ExpectType (ys: readonly number[]) => readonly number[]\n\n//\n// zip\n//\n\n_.zip([1, 2], ['a', 'b']) // $ExpectType readonly (readonly [number, string])[]\n_.zip(['a', 'b']) // $ExpectType <A>(as: readonly A[]) => readonly (readonly [A, string])[]\n\n//\n// cons\n//\n\n_.cons(0, [1, 2]) // $ExpectType ReadonlyNonEmptyArray<number>\n_.cons(0) // $ExpectType (tail: readonly number[]) => ReadonlyNonEmptyArray<number>\n\n//\n// sort\n//\n\ndeclare const ord1: Ord<{ readonly a: string }>\ninterface X1 {\n  readonly a: string\n  readonly b: number\n}\ndeclare const x1s: ReadonlyArray<X1>\n\n_.sort(ord1)(x1s) // $ExpectType ReadonlyArray<X1>\npipe(x1s, _.sort(ord1)) // $ExpectType ReadonlyArray<X1>\n\n//\n// sortBy\n//\n\ndeclare const ord2: Ord<X1>\ndeclare const ord3: Ord<X1>\ninterface X2 {\n  readonly a: string\n  readonly b: number\n  readonly c: boolean\n}\ndeclare const x2s: ReadonlyArray<X2>\n\n_.sortBy([ord2, ord3])(x2s) // $ExpectType ReadonlyArray<X2>\npipe(x2s, _.sortBy([ord2, ord3])) // $ExpectType ReadonlyArray<X2>\n\n//\n// Do\n//\n\n// $ExpectType readonly { readonly a1: number; readonly a2: string; }[]\npipe(\n  _.Do,\n  _.bind('a1', () => _.of(1)),\n  _.bind('a2', () => _.of('b'))\n)\n\n//\n// some\n//\n\n// $ExpectType Either<readonly number[], ReadonlyNonEmptyArray<number>>\npipe(\n  rns,\n  E.fromPredicate(\n    _.some((n) => n > 0),\n    identity\n  )\n)\n\n// -------------------------------------------------------------------------------------\n// Predicate-based APIs\n// -------------------------------------------------------------------------------------\n\ndeclare const prns: ReadonlyArray<number>\ndeclare const prsns: ReadonlyArray<string | number>\ndeclare const isString: (u: unknown) => u is string\ndeclare const isNumber: (sn: string | number) => sn is number\ndeclare const predicate: (sn: string | number) => boolean\ndeclare const isStringWithIndex: (i: number, u: unknown) => u is string\ndeclare const isNumberWithIndex: (i: number, sn: string | number) => sn is number\ndeclare const predicateWithIndex: (i: number, sn: string | number) => boolean\n\n//\n// filter\n//\n\n// $ExpectType readonly string[]\npipe(prsns, _.filter(isString))\n// $ExpectType readonly number[]\npipe(prns, _.filter(predicate))\n// $ExpectType readonly number[]\npipe(\n  prns,\n  _.filter(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n// #1484\nconst isPositive = E.exists((n: number) => n > 0)\ndeclare const eithers: ReadonlyArray<E.Either<string, number>>\npipe(eithers, _.filter(E.isRight), _.filter(isPositive))\n\ninterface Registered {\n  readonly type: 'Registered'\n  readonly username: string\n}\ninterface Unregistered {\n  readonly type: 'Unregistered'\n}\n\ntype User = Registered | Unregistered\n\ndeclare const users: ReadonlyArray<User>\ndeclare const isRegistered: (u: User) => u is Registered\ndeclare const p: (u: User) => boolean\n\nconst registereds = _.filter(isRegistered)(users)\n_.filter(p)(registereds) // $ExpectType readonly Registered[]\n\ninterface Test {\n  test: string\n}\ndeclare const arrayOfTest: Array<Test>\nconst isFoo = <T extends Test>(t: T) => t.test === 'foo'\npipe(arrayOfTest, _.filter(isFoo)) // $ExpectType readonly Test[]\n\n//\n// filterWithIndex\n//\n\n// $ExpectType readonly string[]\npipe(prsns, _.filterWithIndex(isStringWithIndex))\n// $ExpectType readonly number[]\npipe(prns, _.filterWithIndex(predicateWithIndex))\n// $ExpectType readonly number[]\npipe(\n  prns,\n  _.filterWithIndex(\n    (\n      _i, // $ExpectType number\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partition\n//\n\n// $ExpectType Separated<readonly unknown[], readonly string[]>\npipe(prsns, _.partition(isString))\n// $ExpectType Separated<readonly number[], readonly number[]>\npipe(prns, _.partition(predicate))\n// $ExpectType Separated<readonly (string | number)[], readonly number[]>\npipe(prsns, _.partition(isNumber))\n// $ExpectType Separated<readonly number[], readonly number[]>\npipe(\n  rns,\n  _.partition(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partitionWithIndex\n//\n\n// $ExpectType Separated<readonly unknown[], readonly string[]>\npipe(prsns, _.partitionWithIndex(isStringWithIndex))\n// $ExpectType Separated<readonly number[], readonly number[]>\npipe(prns, _.partitionWithIndex(predicateWithIndex))\n// $ExpectType Separated<readonly (string | number)[], readonly number[]>\npipe(prsns, _.partitionWithIndex(isNumberWithIndex))\n// $ExpectType Separated<readonly number[], readonly number[]>\npipe(\n  prns,\n  _.partitionWithIndex(\n    (\n      _i, // $ExpectType number\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// takeLeftWhile\n//\n\n// $ExpectType readonly string[]\npipe(prsns, _.takeLeftWhile(isString))\n// $ExpectType readonly number[]\npipe(prns, _.takeLeftWhile(predicate))\n\n//\n// dropLeftWhile\n//\n\n// $ExpectType readonly string[]\npipe(prsns, _.dropLeftWhile(isString))\n// $ExpectType readonly number[]\npipe(prns, _.dropLeftWhile(predicate))\n\n//\n// spanLeft\n//\n\n// $ExpectType Spanned<string, unknown>\npipe(prsns, _.spanLeft(isString))\n// $ExpectType Spanned<number, number>\npipe(prns, _.spanLeft(predicate))\n\n//\n// findFirst\n//\n\n// $ExpectType Option<string>\npipe(prsns, _.findFirst(isString))\n// $ExpectType Option<number>\npipe(prns, _.findFirst(predicate))\n\n//\n// findLast\n//\n\n// $ExpectType Option<string>\npipe(prsns, _.findLast(isString))\n// $ExpectType Option<number>\npipe(prns, _.findLast(predicate))\n\n//\n// isEmpty\n//\n\n// $ExpectType Either<readonly string[], readonly []>\npipe(\n  rss,\n  E.fromPredicate(_.isEmpty, (as) => as)\n)\n"
  },
  {
    "path": "dtslint/ReadonlyMap.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as _ from '../src/ReadonlyMap'\nimport * as S from '../src/string'\n\n//\n// member\n//\n\n_.member(S.Eq)('a', new Map()) // $ExpectType boolean\n_.member(S.Eq)('a') // $ExpectType <A>(m: ReadonlyMap<string, A>) => boolean\n\n//\n// elem\n//\n\n_.elem(S.Eq)('a', new Map()) // $ExpectType boolean\n_.elem(S.Eq)('a') // $ExpectType <K>(m: ReadonlyMap<K, string>) => boolean\n\n//\n// lookup\n//\n\n_.lookup(S.Eq)('a', new Map([['a', 1]])) // $ExpectType Option<number>\n_.lookup(S.Eq)('a') // $ExpectType <A>(m: ReadonlyMap<string, A>) => Option<A>\n\n//\n// lookupWithKey\n//\n\n_.lookupWithKey(S.Eq)('a', new Map([['a', 1]])) // $ExpectType Option<readonly [string, number]>\n_.lookupWithKey(S.Eq)('a') // $ExpectType <A>(m: ReadonlyMap<string, A>) => Option<readonly [string, A]>\n\n//\n// isSubmap\n//\n\n_.isSubmap(S.Eq, N.Eq)(new Map([['a', 1]]), new Map([['a', 1]])) // $ExpectType boolean\n_.isSubmap(S.Eq, N.Eq)(new Map([['a', 1]])) // $ExpectType (me: ReadonlyMap<string, number>) => boolean\n\n// -------------------------------------------------------------------------------------\n// Predicate-based APIs\n// -------------------------------------------------------------------------------------\n\ndeclare const prns: ReadonlyMap<string, number>\ndeclare const prsns: ReadonlyMap<string, string | number>\ndeclare const isString: (u: unknown) => u is string\ndeclare const isNumber: (sn: string | number) => sn is number\ndeclare const predicate: (sn: string | number) => boolean\ndeclare const isStringWithIndex: (k: string, u: unknown) => u is string\ndeclare const isNumberWithIndex: (k: string, sn: string | number) => sn is number\ndeclare const predicateWithIndex: (k: string, sn: string | number) => boolean\n\n//\n// filter\n//\n\n// $ExpectType ReadonlyMap<string, string>\npipe(prsns, _.filter(isString))\n// $ExpectType ReadonlyMap<string, number>\npipe(prns, _.filter(predicate))\n// $ExpectType ReadonlyMap<string, number>\npipe(\n  prns,\n  _.filter(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// filterWithIndex\n//\n\n// $ExpectType ReadonlyMap<string, string>\npipe(prsns, _.filterWithIndex(isStringWithIndex))\n// $ExpectType ReadonlyMap<string, number>\npipe(prns, _.filterWithIndex(predicateWithIndex))\n// $ExpectType ReadonlyMap<string, number>\npipe(\n  prns,\n  _.filterWithIndex(\n    (\n      _k, // $ExpectType string\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partition\n//\n\n// $ExpectType Separated<ReadonlyMap<string, unknown>, ReadonlyMap<string, string>>\npipe(prsns, _.partition(isString))\n// $ExpectType Separated<ReadonlyMap<string, number>, ReadonlyMap<string, number>>\npipe(prns, _.partition(predicate))\n// $ExpectType Separated<ReadonlyMap<string, string | number>, ReadonlyMap<string, number>>\npipe(prsns, _.partition(isNumber))\n// $ExpectType Separated<ReadonlyMap<string, number>, ReadonlyMap<string, number>>\npipe(\n  prns,\n  _.partition(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partitionWithIndex\n//\n\n// $ExpectType Separated<ReadonlyMap<string, unknown>, ReadonlyMap<string, string>>\npipe(prsns, _.partitionWithIndex(isStringWithIndex))\n// $ExpectType Separated<ReadonlyMap<string, number>, ReadonlyMap<string, number>>\npipe(prns, _.partitionWithIndex(predicateWithIndex))\n// $ExpectType Separated<ReadonlyMap<string, string | number>, ReadonlyMap<string, number>>\npipe(prsns, _.partitionWithIndex(isNumberWithIndex))\n// $ExpectType Separated<ReadonlyMap<string, number>, ReadonlyMap<string, number>>\npipe(\n  prns,\n  _.partitionWithIndex(\n    (\n      _k, // $ExpectType string\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// isEmpty\n//\n\n// $ExpectType Either<ReadonlyMap<string, number>, ReadonlyMap<string, number>>\npipe(\n  prns,\n  E.fromPredicate(_.isEmpty, (as) => as)\n)\n"
  },
  {
    "path": "dtslint/ReadonlyNonEmptyArray.ts",
    "content": "import { pipe } from '../src/function'\nimport { Ord } from '../src/Ord'\nimport * as _ from '../src/ReadonlyNonEmptyArray'\n\ndeclare const ras: ReadonlyArray<string>\ndeclare const rneas: _.ReadonlyNonEmptyArray<string>\ndeclare const rnens: _.ReadonlyNonEmptyArray<number>\ndeclare const rnetns: _.ReadonlyNonEmptyArray<[number, string]>\n\n//\n// zip\n//\n\n_.zip(rnens, rneas) // $ExpectType ReadonlyNonEmptyArray<readonly [number, string]>\n_.zip(rneas) // $ExpectType <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<readonly [A, string]>\n\n//\n// zipWith\n//\n\n_.zipWith(rnens, rneas, (n, s) => [n, s] as const) // $ExpectType ReadonlyNonEmptyArray<readonly [number, string]>\n\n//\n// unzip\n//\n\n_.unzip(rnetns) // $ExpectType readonly [ReadonlyNonEmptyArray<number>, ReadonlyNonEmptyArray<string>]\npipe(rnetns, _.unzip) // $ExpectType readonly [ReadonlyNonEmptyArray<number>, ReadonlyNonEmptyArray<string>]\n\n//\n// cons\n//\n\n_.cons(1, []) // $ExpectType ReadonlyNonEmptyArray<1>\n_.cons(1, [2, 3]) // $ExpectType ReadonlyNonEmptyArray<number>\n\n//\n// sort\n//\n\ndeclare const ordSubX: Ord<{ readonly a: string }>\ninterface X {\n  readonly a: string\n  readonly b: number\n}\n\ndeclare const xs: ReadonlyArray<X>\ndeclare const nexs: _.ReadonlyNonEmptyArray<X>\n\n_.sort(ordSubX)(nexs) // $ExpectType ReadonlyNonEmptyArray<X>\npipe(nexs, _.sort(ordSubX)) // $ExpectType ReadonlyNonEmptyArray<X>\n\n//\n// group\n//\n\n_.group(ordSubX)(nexs) // $ExpectType ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<X>>\npipe(xs, _.group<X>(ordSubX)) // $ExpectType ReadonlyArray<ReadonlyNonEmptyArray<X>>\n_.group(ordSubX)(nexs) // $ExpectType ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<X>>\n// TODO pipe(nexs, _.group<X>(ordSubX)) // $ExpectType ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<X>>\n\n//\n// groupSort\n//\n\n_.groupSort(ordSubX)(nexs) // $ExpectType ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<X>>\npipe(xs, _.groupSort<X>(ordSubX)) // $ExpectType ReadonlyArray<ReadonlyNonEmptyArray<X>>\n_.groupSort(ordSubX)(nexs) // $ExpectType ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<X>>\n// TODO pipe(nexs, _.groupSort<X>(ordSubX)) // $ExpectType ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<X>>\n\n//\n// groupBy\n//\n\n_.groupBy((x: { readonly a: string }) => x.a)(xs) // $ExpectType Readonly<Record<string, ReadonlyNonEmptyArray<{ readonly a: string; }>>>\n// $ExpectType Readonly<Record<string, ReadonlyNonEmptyArray<X>>>\npipe(\n  xs,\n  _.groupBy((x) => x.a)\n)\n\n//\n// Do\n//\n\n// $ExpectType ReadonlyNonEmptyArray<{ readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of(1)),\n  _.bind('a2', () => _.of('b'))\n)\n\n//\n// filter\n//\n\ndeclare const isNumber1: (sn: string | number) => sn is number\ndeclare const isNumber2: (sn: unknown) => sn is number\ndeclare const neasn: _.ReadonlyNonEmptyArray<string | number>\n\n// $ExpectType Option<ReadonlyNonEmptyArray<number>>\npipe(neasn, _.filter(isNumber1))\n// $ExpectType Option<ReadonlyNonEmptyArray<number>>\n_.filter(isNumber1)(neasn)\n// $ExpectType Option<ReadonlyNonEmptyArray<number>>\npipe(neasn, _.filter(isNumber2))\n// $ExpectType Option<ReadonlyNonEmptyArray<number>>\n_.filter(isNumber2)(neasn)\n\n//\n// concat\n//\n\n_.concat(ras, rneas) // $ExpectType ReadonlyNonEmptyArray<string>\n_.concat(rneas, ras) // $ExpectType ReadonlyNonEmptyArray<string>\n_.concat(rneas)(ras) // $ExpectType ReadonlyNonEmptyArray<string>\n_.concat(ras)(rneas) // $ExpectType ReadonlyNonEmptyArray<string>\n"
  },
  {
    "path": "dtslint/ReadonlyRecord.ts",
    "content": "import * as E from '../src/Either'\nimport { Foldable } from '../src/Foldable'\nimport { identity, pipe } from '../src/function'\nimport { HKT } from '../src/HKT'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport * as _ from '../src/ReadonlyRecord'\nimport { getFirstSemigroup } from '../src/Semigroup'\nimport * as S from '../src/string'\n\ndeclare const do1: { [key: string]: O.Option<number> }\ndeclare const ro1: Readonly<Record<'a1' | 'a2', O.Option<number>>>\ndeclare const stringKey: string\ndeclare const d1: { [key: string]: number }\ndeclare const recordString: Readonly<Record<string, number>>\ndeclare const r1: Readonly<Record<'a1' | 'a2', number>>\nconst l1 = { a: 1 }\n\ndeclare const keyString: string\n\n//\n// hasOwnProperty\n//\n\n// eslint-disable-next-line no-prototype-builtins\nif (_.hasOwnProperty(keyString, d1)) {\n  keyString // $ExpectType string\n}\n// eslint-disable-next-line no-prototype-builtins\nif (_.hasOwnProperty(keyString, recordString)) {\n  keyString // $ExpectType string\n}\n// eslint-disable-next-line no-prototype-builtins\nif (_.hasOwnProperty(keyString, r1)) {\n  keyString // $ExpectType \"a1\" | \"a2\"\n}\n\n//\n// updateAt\n//\n\npipe(d1, _.updateAt('a1', 3)) // $ExpectType Option<Readonly<Record<string, number>>>\npipe(recordString, _.updateAt('a', 3)) // $ExpectType Option<Readonly<Record<string, number>>>\npipe(r1, _.updateAt('a1', 3)) // $ExpectType Option<Readonly<Record<\"a1\" | \"a2\", number>>>\n\n//\n// modifyAt\n//\n\npipe(d1, _.modifyAt('a1', identity)) // $ExpectType Option<Readonly<Record<string, number>>>\npipe(recordString, _.modifyAt('a', identity)) // $ExpectType Option<Readonly<Record<string, number>>>\npipe(r1, _.modifyAt('a1', identity)) // $ExpectType Option<Readonly<Record<\"a1\" | \"a2\", number>>>\n\n//\n// pop\n//\n\n_.pop('a1')(r1) // $ExpectType Option<readonly [number, Readonly<Record<\"a2\", number>>]>\n_.pop('a1')(d1) // $ExpectType Option<readonly [number, Readonly<Record<string, number>>]>\n_.pop(stringKey)(r1) // $ExpectType Option<readonly [number, Readonly<Record<string, number>>]>\n\n//\n// collect\n//\n\n_.collect((_k: 'a', n: number) => n)({ a: 1 }) // $ExpectType readonly number[]\n_.collect((_k: 'a', n: number) => n)(l1) // $ExpectType readonly number[]\n_.collect((_k, n: number) => n)(d1) // $ExpectType readonly number[]\n_.collect((_k: 'a1' | 'a2', n: number) => n)(r1) // $ExpectType readonly number[]\n\n_.collect(S.Ord)((_k: 'a', n: number) => n)({ a: 1 }) // $ExpectType readonly number[]\n_.collect(S.Ord)((_k: 'a', n: number) => n)(l1) // $ExpectType readonly number[]\n_.collect(S.Ord)((_k, n: number) => n)(d1) // $ExpectType readonly number[]\n_.collect(S.Ord)((_k: 'a1' | 'a2', n: number) => n)(r1) // $ExpectType readonly number[]\n\n//\n// insertAt\n//\n\n_.insertAt('b', 0)(d1) // $ExpectType Readonly<Record<string, number>>\n_.insertAt(stringKey, 0)(r1) // $ExpectType Readonly<Record<string, number>>\n\n//\n// deleteAt\n//\n\n_.deleteAt('a')({ a: 1 }) // $ExpectType Readonly<Record<never, number>>\n_.deleteAt('b')({ a: 1 }) // $ExpectType Readonly<Record<\"a\", number>>\n_.deleteAt('a')(l1) // $ExpectType Readonly<Record<never, number>>\n_.deleteAt('b')(l1) // $ExpectType Readonly<Record<\"a\", number>>\n_.deleteAt('b')(d1) // $ExpectType Readonly<Record<string, number>>\n_.deleteAt('c')(r1) // $ExpectType Readonly<Record<\"a1\" | \"a2\", number>>\n_.deleteAt('a1')(r1) // $ExpectType Readonly<Record<\"a2\", number>>\n_.deleteAt(stringKey)(r1) // $ExpectType Readonly<Record<string, number>>\n\n//\n// mapWithIndex\n//\n\n_.mapWithIndex((_k: 'a', n: number) => n > 2)({ a: 1 }) // $ExpectType Readonly<Record<\"a\", boolean>>\n_.mapWithIndex((_k: 'a', n: number) => n > 2)(l1) // $ExpectType Readonly<Record<\"a\", boolean>>\n_.mapWithIndex((_k: string, n: number) => n > 2)(d1) // $ExpectType Readonly<Record<string, boolean>>\n_.mapWithIndex((_k: 'a1' | 'a2', n: number) => n > 2)(r1) // $ExpectType Readonly<Record<\"a1\" | \"a2\", boolean>>\n\n// $ExpectType Readonly<Record<string, boolean>>\npipe(\n  d1,\n  _.mapWithIndex(\n    (\n      _key, // $ExpectType string\n      value // $ExpectType number\n    ) => value > 0\n  )\n)\n\n// $ExpectType Readonly<Record<\"a1\" | \"a2\", boolean>>\npipe(\n  r1,\n  _.mapWithIndex(\n    (\n      _key, // $ExpectType \"a1\" | \"a2\"\n      value // $ExpectType number\n    ) => value > 0\n  )\n)\n\n//\n// map\n//\n\n_.map((n: number) => n > 2)({ a: 1 }) // $ExpectType Readonly<Record<\"a\", boolean>>\n_.map((n: number) => n > 2)(l1) // $ExpectType Readonly<Record<\"a\", boolean>>\n_.map((n: number) => n > 2)(d1) // $ExpectType Readonly<Record<string, boolean>>\n_.map((n: number) => n > 2)(r1) // $ExpectType Readonly<Record<\"a1\" | \"a2\", boolean>>\n\nconst constStruct = { a: 1, b: 2 } as const\n\nfunction mapToBoolean(): { [K in keyof typeof constStruct]: boolean } {\n  return pipe(\n    constStruct,\n    _.map(() => true)\n  )\n}\n\n// $ExpectType { readonly a: boolean; readonly b: boolean; }\nmapToBoolean()\n\n//\n// reduceWithIndex\n//\n\n_.reduceWithIndex(S.Ord)('', (k: string, _n) => k)(d1) // $ExpectType string\n_.reduceWithIndex(S.Ord)('', (k: 'a1' | 'a2', _n) => k)(r1) // $ExpectType string\n\n_.reduceWithIndex('', (k: string, _n) => k)(d1) // $ExpectType string\n_.reduceWithIndex('', (k: 'a1' | 'a2', _n) => k)(r1) // $ExpectType string\n\n_.foldMapWithIndex(S.Ord)(S.Monoid)((k: string, _n) => k)(d1) // $ExpectType string\n_.foldMapWithIndex(S.Ord)(S.Monoid)((k: 'a1' | 'a2', _n) => k)(r1) // $ExpectType string\n\n_.foldMapWithIndex(S.Monoid)((k: string, _n) => k)(d1) // $ExpectType string\n_.foldMapWithIndex(S.Monoid)((k: 'a1' | 'a2', _n) => k)(r1) // $ExpectType string\n\n_.reduceRightWithIndex(S.Ord)('', (k: string, _n, _b) => k)(d1) // $ExpectType string\n_.reduceRightWithIndex(S.Ord)('', (k: 'a1' | 'a2', _n, _b) => k)(r1) // $ExpectType string\n\n_.reduceRightWithIndex('', (k: string, _n, _b) => k)(d1) // $ExpectType string\n_.reduceRightWithIndex('', (k: 'a1' | 'a2', _n, _b) => k)(r1) // $ExpectType string\n\n_.singleton('a', 1) // $ExpectType Readonly<Record<string, number>>\n\n_.traverseWithIndex(O.option)((_k, n: number) => O.some(n))(d1) // $ExpectType Option<Readonly<Record<string, number>>>\n_.traverseWithIndex(O.option)((_k: 'a1' | 'a2', n: number) => O.some(n))(r1) // $ExpectType Option<Readonly<Record<\"a1\" | \"a2\", number>>>\n\n_.traverse(O.option)((n: number) => O.some(n))(d1) // $ExpectType Option<Readonly<Record<string, number>>>\n_.traverse(O.option)((n: number) => O.some(n))(r1) // $ExpectType Option<Readonly<Record<\"a1\" | \"a2\", number>>>\n\n_.sequence(O.option)(do1) // $ExpectType Option<Readonly<Record<string, number>>>\n_.sequence(O.option)(ro1) // $ExpectType Option<Readonly<Record<\"a1\" | \"a2\", number>>>\n\n_.readonlyRecord.compact(do1) // $ExpectType Readonly<Record<string, number>>\n\n_.partitionMapWithIndex((_k: string, n: number): E.Either<string, number> => E.right(n))(d1) // $ExpectType Separated<Readonly<Record<string, string>>, Readonly<Record<string, number>>>\n_.partitionMapWithIndex((_k: 'a1' | 'a2', n: number): E.Either<string, number> => E.right(n))(r1) // $ExpectType Separated<Readonly<Record<string, string>>, Readonly<Record<string, number>>>\n\n_.partitionWithIndex((_k: string, n: number) => n > 2)(d1) // $ExpectType Separated<Readonly<Record<string, number>>, Readonly<Record<string, number>>>\n_.partitionWithIndex((_k: 'a1' | 'a2', n: number) => n > 2)(r1) // $ExpectType Separated<Readonly<Record<string, number>>, Readonly<Record<string, number>>>\n\n_.filterMapWithIndex((_k: string, n: number) => O.some(n))(d1) // $ExpectType Readonly<Record<string, number>>\n_.filterMapWithIndex((_k: 'a1' | 'a2', n: number) => O.some(n))(r1) // $ExpectType Readonly<Record<string, number>>\n\n_.filterWithIndex((_k: string, n: number) => n > 2)(d1) // $ExpectType Readonly<Record<string, number>>\n_.filterWithIndex((_k: 'a1' | 'a2', n: number) => n > 2)(r1) // $ExpectType Readonly<Record<string, number>>\n\ndeclare const arr1: Array<[string, number]>\ndeclare const arr2: Array<['a' | 'b', number]>\n\n_.fromFoldable(getFirstSemigroup<number>(), RA.Foldable)(arr1) // $ExpectType Readonly<Record<string, number>>\n_.fromFoldable(getFirstSemigroup<number>(), RA.Foldable)(arr2) // $ExpectType Readonly<Record<string, number>>\n\ntype Keys = 'key1' | 'key2'\n_.getMonoid(N.SemigroupSum) // $ExpectType Monoid<Readonly<Record<string, number>>>\n_.getMonoid<Keys, number>(N.SemigroupSum) // $ExpectType Monoid<Readonly<Record<Keys, number>>>\n\n_.getEq<Keys, number>(N.Eq) // $ExpectType Eq<Readonly<Record<Keys, number>>>\n_.getEq(N.Eq) // $ExpectType Eq<Readonly<Record<string, number>>>\n\n_.toUnfoldable(RA.Unfoldable)({ a: 1 }) // $ExpectType readonly (readonly [\"a\", number])[]\n_.toUnfoldable(RA.Unfoldable)({ a1: 1, a2: 2 }) // $ExpectType readonly (readonly [\"a1\" | \"a2\", number])[]\n\ndeclare const fromFoldableF1: Foldable<'Test'>\ndeclare const fromFoldableInput1: HKT<'Test', ['a' | 'b', number]>\n_.fromFoldable(getFirstSemigroup<number>(), fromFoldableF1)(fromFoldableInput1) // $ExpectType Readonly<Record<string, number>>\n\n//\n// isSubrecord\n//\n\n_.isSubrecord(N.Eq)(recordString, recordString) // $ExpectType boolean\n_.isSubrecord(N.Eq)(recordString) // $ExpectType (me: Readonly<Record<string, number>>) => boolean\n\n//\n// lookup\n//\n\n_.lookup('a', recordString) // $ExpectType Option<number>\n_.lookup('a') // $ExpectType <A>(r: Readonly<Record<string, A>>) => Option<A>\n\n//\n// elem\n//\n\n_.elem(N.Eq)(1, recordString) // $ExpectType boolean\n_.elem(N.Eq)(1) // $ExpectType (fa: Readonly<Record<string, number>>) => boolean\n\n//\n// reduce\n//\n\npipe(\n  r1,\n  _.reduce(1, (acc, n) => acc + n)\n)\npipe(\n  r1,\n  _.reduce(S.Ord)(1, (acc, n) => acc + n)\n)\n"
  },
  {
    "path": "dtslint/ReadonlySet.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as _ from '../src/ReadonlySet'\n\ndeclare const me: ReadonlySet<number>\n\n//\n// isSubset\n//\n\n_.isSubset(N.Eq)(me, me) // $ExpectType boolean\n_.isSubset(N.Eq)(me) // $ExpectType (me: ReadonlySet<number>) => boolean\n\n//\n// elem\n//\n\n_.elem(N.Eq)(1, me) // $ExpectType boolean\n_.elem(N.Eq)(1) // $ExpectType (set: ReadonlySet<number>) => boolean\n\n//\n// union\n//\n\n_.union(N.Eq)(me, me) // $ExpectType ReadonlySet<number>\n_.union(N.Eq)(me) // $ExpectType (me: ReadonlySet<number>) => ReadonlySet<number>\n\n//\n// intersection\n//\n\n_.intersection(N.Eq)(me, me) // $ExpectType ReadonlySet<number>\n_.intersection(N.Eq)(me) // $ExpectType (me: ReadonlySet<number>) => ReadonlySet<number>\n\n//\n// difference\n//\n\n_.difference(N.Eq)(me, me) // $ExpectType ReadonlySet<number>\n_.difference(N.Eq)(me) // $ExpectType (me: ReadonlySet<number>) => ReadonlySet<number>\n\n// -------------------------------------------------------------------------------------\n// Predicate-based APIs\n// -------------------------------------------------------------------------------------\n\ndeclare const prns: ReadonlySet<number>\ndeclare const prsns: ReadonlySet<string | number>\ndeclare const isString: (u: unknown) => u is string\ndeclare const isNumber: (sn: string | number) => sn is number\ndeclare const predicate: (sn: string | number) => boolean\n\n//\n// filter\n//\n\n// $ExpectType ReadonlySet<string>\npipe(prsns, _.filter(isString))\n// $ExpectType ReadonlySet<number>\npipe(prns, _.filter(predicate))\n// $ExpectType ReadonlySet<number>\npipe(\n  prns,\n  _.filter(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partition\n//\n\n// $ExpectType Separated<ReadonlySet<unknown>, ReadonlySet<string>>\npipe(prsns, _.partition(isString))\n// $ExpectType Separated<ReadonlySet<number>, ReadonlySet<number>>\npipe(prns, _.partition(predicate))\n// $ExpectType Separated<ReadonlySet<string | number>, ReadonlySet<number>>\npipe(prsns, _.partition(isNumber))\n// $ExpectType Separated<ReadonlySet<number>, ReadonlySet<number>>\npipe(\n  prns,\n  _.partition(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// isEmpty\n//\n\n// $ExpectType Either<ReadonlySet<number>, ReadonlySet<number>>\npipe(\n  me,\n  E.fromPredicate(_.isEmpty, (as) => as)\n)\n"
  },
  {
    "path": "dtslint/Record.ts",
    "content": "import * as A from '../src/Array'\nimport * as E from '../src/Either'\nimport { Foldable } from '../src/Foldable'\nimport { identity, pipe } from '../src/function'\nimport { HKT } from '../src/HKT'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as _ from '../src/Record'\nimport { getFirstSemigroup } from '../src/Semigroup'\nimport * as S from '../src/string'\n\ndeclare const do1: { [key: string]: O.Option<number> }\ndeclare const ro1: Record<'a1' | 'a2', O.Option<number>>\ndeclare const stringKey: string\ndeclare const d1: { [key: string]: number }\ndeclare const recordString: Record<string, number>\ndeclare const r1: Record<'a1' | 'a2', number>\nconst l1 = { a: 1 }\n\ndeclare const keyString: string\n\n//\n// hasOwnProperty\n//\n\n// eslint-disable-next-line no-prototype-builtins\nif (_.hasOwnProperty(keyString, d1)) {\n  keyString // $ExpectType string\n}\n// eslint-disable-next-line no-prototype-builtins\nif (_.hasOwnProperty(keyString, recordString)) {\n  keyString // $ExpectType string\n}\n// eslint-disable-next-line no-prototype-builtins\nif (_.hasOwnProperty(keyString, r1)) {\n  keyString // $ExpectType \"a1\" | \"a2\"\n}\n\n//\n// updateAt\n//\n\npipe(d1, _.updateAt('a1', 3)) // $ExpectType Option<Record<string, number>>\npipe(recordString, _.updateAt('a', 3)) // $ExpectType Option<Record<string, number>>\npipe(r1, _.updateAt('a1', 3)) // $ExpectType Option<Record<\"a1\" | \"a2\", number>>\n\n//\n// modifyAt\n//\n\npipe(d1, _.modifyAt('a1', identity)) // $ExpectType Option<Record<string, number>>\npipe(recordString, _.modifyAt('a', identity)) // $ExpectType Option<Record<string, number>>\npipe(r1, _.modifyAt('a1', identity)) // $ExpectType Option<Record<\"a1\" | \"a2\", number>>\n\n//\n// pop\n//\n\n_.pop('a1')(r1) // $ExpectType Option<[number, Record<\"a2\", number>]>\n_.pop('a1')(d1) // $ExpectType Option<[number, Record<string, number>]>\n_.pop(stringKey)(r1) // $ExpectType Option<[number, Record<string, number>]>\n\n//\n// collect\n//\n\n_.collect((_k: 'a', n: number) => n)({ a: 1 }) // $ExpectType number[]\n_.collect((_k: 'a', n: number) => n)(l1) // $ExpectType number[]\n_.collect((_k, n: number) => n)(d1) // $ExpectType number[]\n_.collect((_k: 'a1' | 'a2', n: number) => n)(r1) // $ExpectType number[]\n\n_.collect(S.Ord)((_k: 'a', n: number) => n)({ a: 1 }) // $ExpectType number[]\n_.collect(S.Ord)((_k: 'a', n: number) => n)(l1) // $ExpectType number[]\n_.collect(S.Ord)((_k, n: number) => n)(d1) // $ExpectType number[]\n_.collect(S.Ord)((_k: 'a1' | 'a2', n: number) => n)(r1) // $ExpectType number[]\n\n//\n// toArray\n//\n\n_.toArray({ a: 1 }) // $ExpectType [\"a\", number][]\n_.toArray(l1) // $ExpectType [\"a\", number][]\n_.toArray(d1) // $ExpectType [string, number][]\n_.toArray(r1) // $ExpectType [\"a1\" | \"a2\", number][]\n\n//\n// insertAt\n//\n\n_.insertAt('b', 0)(d1) // $ExpectType Record<string, number>\n_.insertAt(stringKey, 0)(r1) // $ExpectType Record<string, number>\n\n//\n// deleteAt\n//\n\n_.deleteAt('a')({ a: 1 }) // $ExpectType Record<never, number>\n_.deleteAt('b')({ a: 1 }) // $ExpectType Record<\"a\", number>\n_.deleteAt('a')(l1) // $ExpectType Record<never, number>\n_.deleteAt('b')(l1) // $ExpectType Record<\"a\", number>\n_.deleteAt('b')(d1) // $ExpectType Record<string, number>\n_.deleteAt('c')(r1) // $ExpectType Record<\"a1\" | \"a2\", number>\n_.deleteAt('a1')(r1) // $ExpectType Record<\"a2\", number>\n_.deleteAt(stringKey)(r1) // $ExpectType Record<string, number>\n\n//\n// mapWithIndex\n//\n\n_.mapWithIndex((_k: 'a', n: number) => n > 2)({ a: 1 }) // $ExpectType Record<\"a\", boolean>\n_.mapWithIndex((_k: 'a', n: number) => n > 2)(l1) // $ExpectType Record<\"a\", boolean>\n_.mapWithIndex((_k: string, n: number) => n > 2)(d1) // $ExpectType Record<string, boolean>\n_.mapWithIndex((_k: 'a1' | 'a2', n: number) => n > 2)(r1) // $ExpectType Record<\"a1\" | \"a2\", boolean>\n\n//\n// map\n//\n\n_.map((n: number) => n > 2)({ a: 1 }) // $ExpectType Record<\"a\", boolean>\n_.map((n: number) => n > 2)(l1) // $ExpectType Record<\"a\", boolean>\n_.map((n: number) => n > 2)(d1) // $ExpectType Record<string, boolean>\n_.map((n: number) => n > 2)(r1) // $ExpectType Record<\"a1\" | \"a2\", boolean>\n\n//\n// reduceWithIndex\n//\n\n_.reduceWithIndex(S.Ord)('', (k: string, _n) => k)(d1) // $ExpectType string\n_.reduceWithIndex(S.Ord)('', (k: 'a1' | 'a2', _n) => k)(r1) // $ExpectType string\n\n_.reduceWithIndex('', (k: string, _n) => k)(d1) // $ExpectType string\n_.reduceWithIndex('', (k: 'a1' | 'a2', _n) => k)(r1) // $ExpectType string\n\n_.foldMapWithIndex(S.Ord)(S.Monoid)((k: string, _n) => k)(d1) // $ExpectType string\n_.foldMapWithIndex(S.Ord)(S.Monoid)((k: 'a1' | 'a2', _n) => k)(r1) // $ExpectType string\n\n_.foldMapWithIndex(S.Monoid)((k: string, _n) => k)(d1) // $ExpectType string\n_.foldMapWithIndex(S.Monoid)((k: 'a1' | 'a2', _n) => k)(r1) // $ExpectType string\n\n_.reduceRightWithIndex(S.Ord)('', (k: string, _n, _b) => k)(d1) // $ExpectType string\n_.reduceRightWithIndex(S.Ord)('', (k: 'a1' | 'a2', _n, _b) => k)(r1) // $ExpectType string\n\n_.reduceRightWithIndex('', (k: string, _n, _b) => k)(d1) // $ExpectType string\n_.reduceRightWithIndex('', (k: 'a1' | 'a2', _n, _b) => k)(r1) // $ExpectType string\n\n_.singleton('a', 1) // $ExpectType Record<string, number>\n\n_.traverseWithIndex(O.option)((_k, n: number) => O.some(n))(d1) // $ExpectType Option<Record<string, number>>\n_.traverseWithIndex(O.option)((_k: 'a1' | 'a2', n: number) => O.some(n))(r1) // $ExpectType Option<Record<\"a1\" | \"a2\", number>>\n\n_.traverse(O.option)((n: number) => O.some(n))(d1) // $ExpectType Option<Record<string, number>>\n_.traverse(O.option)((n: number) => O.some(n))(r1) // $ExpectType Option<Record<\"a1\" | \"a2\", number>>\n\n_.sequence(O.option)(do1) // $ExpectType Option<Record<string, number>>\n_.sequence(O.option)(ro1) // $ExpectType Option<Record<\"a1\" | \"a2\", number>>\n\n_.record.compact(do1) // $ExpectType Record<string, number>\n\n_.partitionMapWithIndex((_k: string, n: number): E.Either<string, number> => E.right(n))(d1) // $ExpectType Separated<Record<string, string>, Record<string, number>>\n_.partitionMapWithIndex((_k: 'a1' | 'a2', n: number): E.Either<string, number> => E.right(n))(r1) // $ExpectType Separated<Record<string, string>, Record<string, number>>\n\n_.partitionWithIndex((_k: string, n: number) => n > 2)(d1) // $ExpectType Separated<Record<string, number>, Record<string, number>>\n_.partitionWithIndex((_k: 'a1' | 'a2', n: number) => n > 2)(r1) // $ExpectType Separated<Record<string, number>, Record<string, number>>\n\n_.filterMapWithIndex((_k: string, n: number) => O.some(n))(d1) // $ExpectType Record<string, number>\n_.filterMapWithIndex((_k: 'a1' | 'a2', n: number) => O.some(n))(r1) // $ExpectType Record<string, number>\n\n_.filterWithIndex((_k: string, n: number) => n > 2)(d1) // $ExpectType Record<string, number>\n_.filterWithIndex((_k: 'a1' | 'a2', n: number) => n > 2)(r1) // $ExpectType Record<string, number>\n\ndeclare const arr1: Array<[string, number]>\ndeclare const arr2: Array<['a' | 'b', number]>\n\n_.fromFoldable(getFirstSemigroup<number>(), A.array)(arr1) // $ExpectType Record<string, number>\n_.fromFoldable(getFirstSemigroup<number>(), A.array)(arr2) // $ExpectType Record<string, number>\n\ntype Keys = 'key1' | 'key2'\n_.getMonoid(N.SemigroupSum) // $ExpectType Monoid<Record<string, number>>\n_.getMonoid<Keys, number>(N.SemigroupSum) // $ExpectType Monoid<Record<Keys, number>>\n\n_.getEq<Keys, number>(N.Eq) // $ExpectType Eq<Record<Keys, number>>\n_.getEq(N.Eq) // $ExpectType Eq<Record<string, number>>\n\n_.toUnfoldable(A.array)({ a: 1 }) // $ExpectType [\"a\", number][]\n_.toUnfoldable(A.array)({ a1: 1, a2: 2 }) // $ExpectType [\"a1\" | \"a2\", number][]\n\ndeclare const fromFoldableF1: Foldable<'Test'>\ndeclare const fromFoldableInput1: HKT<'Test', ['a' | 'b', number]>\n_.fromFoldable(getFirstSemigroup<number>(), fromFoldableF1)(fromFoldableInput1) // $ExpectType Record<string, number>\n\n//\n// isSubrecord\n//\n\n_.isSubrecord(N.Eq)(recordString, recordString) // $ExpectType boolean\n_.isSubrecord(N.Eq)(recordString) // $ExpectType (me: Record<string, number>) => boolean\n\n//\n// lookup\n//\n\n_.lookup('a', recordString) // $ExpectType Option<number>\n_.lookup('a') // $ExpectType <A>(r: Record<string, A>) => Option<A>\n\n//\n// elem\n//\n\n_.elem(N.Eq)(1, recordString) // $ExpectType boolean\n_.elem(N.Eq)(1) // $ExpectType (fa: Record<string, number>) => boolean\n\n//\n// reduce\n//\n\npipe(\n  r1,\n  _.reduce(1, (acc, n) => acc + n)\n)\npipe(\n  r1,\n  _.reduce(S.Ord)(1, (acc, n) => acc + n)\n)\n"
  },
  {
    "path": "dtslint/Ring.ts",
    "content": "import * as N from '../src/number'\nimport * as _ from '../src/Ring'\n\n//\n// tuple\n//\n\n// $ExpectType Ring<readonly [number, number, number]>\n_.tuple(N.Field, N.Field, N.Field)\n\n//\n// getTupleRing\n//\n\n_.getTupleRing(N.Field, N.Field, N.Field) // $ExpectType Ring<[number, number, number]>\n"
  },
  {
    "path": "dtslint/Semigroup.ts",
    "content": "import * as B from '../src/boolean'\nimport * as N from '../src/number'\nimport * as _ from '../src/Semigroup'\nimport * as S from '../src/string'\n\n//\n// struct\n//\n\n// $ExpectType Semigroup<{ readonly a: string; readonly b: number; readonly c: boolean; }>\n_.struct({ a: S.Semigroup, b: N.SemigroupSum, c: B.SemigroupAll })\n\n//\n// tuple\n//\n\n// $ExpectType Semigroup<readonly [string, number, boolean]>\n_.tuple(S.Semigroup, N.SemigroupSum, B.SemigroupAll)\n\n//\n// getTupleSemigroup\n//\n\n_.getTupleSemigroup(_.semigroupString, _.semigroupSum, _.semigroupAll) // $ExpectType Semigroup<[string, number, boolean]>\n\n//\n// fold\n//\n\n_.fold(_.semigroupString)('', ['a']) // $ExpectType string\n_.fold(_.semigroupString)('') // $ExpectType (as: readonly string[]) => string\n"
  },
  {
    "path": "dtslint/Set.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as _ from '../src/Set'\n\ndeclare const me: Set<number>\n\n//\n// subset\n//\n\n_.subset(N.Eq)(me, me) // $ExpectType boolean\n_.subset(N.Eq)(me) // $ExpectType (me: Set<number>) => boolean\n\n//\n// elem\n//\n\n_.elem(N.Eq)(1, me) // $ExpectType boolean\n_.elem(N.Eq)(1) // $ExpectType (set: Set<number>) => boolean\n\n//\n// union\n//\n\n_.union(N.Eq)(me, me) // $ExpectType Set<number>\n_.union(N.Eq)(me) // $ExpectType (me: Set<number>) => Set<number>\n\n//\n// intersection\n//\n\n_.intersection(N.Eq)(me, me) // $ExpectType Set<number>\n_.intersection(N.Eq)(me) // $ExpectType (me: Set<number>) => Set<number>\n\n//\n// difference\n//\n\n_.difference(N.Eq)(me, me) // $ExpectType Set<number>\n_.difference(N.Eq)(me) // $ExpectType (me: Set<number>) => Set<number>\n\n// -------------------------------------------------------------------------------------\n// Predicate-based APIs\n// -------------------------------------------------------------------------------------\n\ndeclare const prns: Set<number>\ndeclare const prsns: Set<string | number>\ndeclare const isString: (u: unknown) => u is string\ndeclare const isNumber: (sn: string | number) => sn is number\ndeclare const predicate: (sn: string | number) => boolean\n\n//\n// filter\n//\n\n// $ExpectType Set<string>\npipe(prsns, _.filter(isString))\n// $ExpectType Set<number>\npipe(prns, _.filter(predicate))\n// $ExpectType Set<number>\npipe(\n  prns,\n  _.filter(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partition\n//\n\n// $ExpectType Separated<Set<unknown>, Set<string>>\npipe(prsns, _.partition(isString))\n// $ExpectType Separated<Set<number>, Set<number>>\npipe(prns, _.partition(predicate))\n// $ExpectType Separated<Set<string | number>, Set<number>>\npipe(prsns, _.partition(isNumber))\n// $ExpectType Separated<Set<number>, Set<number>>\npipe(\n  prns,\n  _.partition(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// isEmpty\n//\n\n// $ExpectType Either<Set<number>, Set<number>>\npipe(\n  me,\n  E.fromPredicate(_.isEmpty, (as) => as)\n)\n"
  },
  {
    "path": "dtslint/Show.ts",
    "content": "import * as B from '../src/boolean'\nimport * as N from '../src/number'\nimport * as _ from '../src/Show'\nimport * as S from '../src/string'\n\n//\n// struct\n//\n\n// $ExpectType Show<{ readonly a: string; readonly b: number; readonly c: boolean; }>\n_.struct({ a: S.Show, b: N.Show, c: B.Show })\n\n//\n// tuple\n//\n\n// $ExpectType Show<readonly [string, number, boolean]>\n_.tuple(S.Show, N.Show, B.Show)\n"
  },
  {
    "path": "dtslint/StateReaderTaskEither.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as IOE from '../src/IOEither'\nimport * as RTE from '../src/ReaderTaskEither'\nimport * as _ from '../src/StateReaderTaskEither'\nimport * as TE from '../src/TaskEither'\n\n//\n// chainW\n//\n\n// $ExpectType StateReaderTaskEither<boolean, { a: string; } & { b: number; }, string | number, number>\npipe(\n  _.right<boolean, { a: string }, string, string>('a'),\n  _.chainW(() => _.right<boolean, { b: number }, number, number>(1))\n)\n\n//\n// chainEitherKW\n//\n\n// $ExpectType StateReaderTaskEither<string, string, string | number, number>\npipe(\n  _.right<string, string, string, string>('a'),\n  _.chainEitherKW(() => E.right<number, number>(1))\n)\n\n//\n// chainTaskEitherKW\n//\n\n// $ExpectType StateReaderTaskEither<string, string, string | number, number>\npipe(\n  _.right<string, string, string, string>('a'),\n  _.chainTaskEitherKW(() => TE.right<number, number>(1))\n)\n\n//\n// chainReaderTaskEitherKW\n//\n\n// $ExpectType StateReaderTaskEither<string, string, string | number, number>\npipe(\n  _.right<string, string, string, string>('a'),\n  _.chainReaderTaskEitherKW(() => RTE.right<string, number, number>(1))\n)\n\n//\n// chainIOEitherKW\n//\n\n// $ExpectType StateReaderTaskEither<string, string, string | number, number>\npipe(\n  _.right<string, string, string, string>('a'),\n  _.chainIOEitherKW(() => IOE.right<number, number>(1))\n)\n\n//\n// do notation\n//\n\n// $ExpectType StateReaderTaskEither<void, { readonly a: number; } & { readonly b: string; }, string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<void, { readonly a: number }, string, number>(1),\n  _.bindTo('a1'),\n  _.bind('a2', () => _.right('b')),\n  _.bindW('a3', () => _.right<void, { readonly b: string }, number, boolean>(true))\n)\n\n//\n// pipeable sequence S\n//\n\n// $ExpectType StateReaderTaskEither<void, { readonly a: number; } & { readonly b: string; }, string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<void, { readonly a: number }, string, number>(1),\n  _.bindTo('a1'),\n  _.apS('a2', _.right('b')),\n  _.apSW('a3', _.right<void, { readonly b: string }, number, boolean>(true))\n)\n\n//\n// filterOrElseW\n//\n\n// $ExpectType StateReaderTaskEither<{ d: Date; }, { c: boolean; }, \"a1\" | \"a2\", number>\npipe(\n  _.left<{ d: Date }, { c: boolean }, 'a1', number>('a1'),\n  _.filterOrElseW(\n    (result) => result > 0,\n    () => 'a2' as const\n  )\n)\n"
  },
  {
    "path": "dtslint/Task.ts",
    "content": "import { pipe } from '../src/function'\nimport * as _ from '../src/Task'\n\n//\n// Do\n//\n\n// $ExpectType Task<{ readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of(1)),\n  _.bind('a2', () => _.of('b'))\n)\n"
  },
  {
    "path": "dtslint/TaskEither.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as IO from '../src/IO'\nimport * as IOE from '../src/IOEither'\nimport * as T from '../src/Task'\nimport * as _ from '../src/TaskEither'\nimport * as TO from '../src/TaskOption'\n\n//\n// getOrElseW\n//\n\n// $ExpectType Task<string | null>\npipe(\n  _.right('a'),\n  _.getOrElseW(() => T.of(null))\n)\n\n//\n// orElse\n//\n\n// $ExpectType TaskEither<number, never>\npipe(\n  _.left('a'),\n  _.orElse((a) => _.left(a.length))\n)\n\n//\n// orElseW\n//\n\n// $ExpectType TaskEither<never, string | number>\npipe(\n  _.left<string, string>('a'),\n  _.orElseW((a) => _.right(a.length))\n)\n\n//\n// orElseFirst\n//\n\n// $ExpectType TaskEither<string, never>\npipe(\n  _.left('a'),\n  _.orElseFirst((a) => _.right(a.length))\n)\n\n//\n// orElseFirstW\n//\n\n// $ExpectType TaskEither<string | number, never>\npipe(\n  _.left('a'),\n  _.orElseFirstW((a) => _.left(a.length))\n)\n\n//\n// orElseFirstIOK\n//\n\n// $ExpectType TaskEither<string, never>\npipe(\n  _.left('a'),\n  _.orElseFirstIOK((a) => IO.of(a.length))\n)\n\n//\n// orElseFirstTaskK\n//\n\n// $ExpectType TaskEither<string, never>\npipe(\n  _.left('a'),\n  _.orElseFirstTaskK((a) => T.of(a.length))\n)\n\n//\n// orLeft\n//\n\n// $ExpectType TaskEither<number, never>\npipe(\n  _.left('a'),\n  _.orLeft((a) => T.of(a.length))\n)\n\n//\n// chainW\n//\n\n// $ExpectType TaskEither<string | number, number>\npipe(\n  _.right<string, string>('a'),\n  _.chainW(() => _.right<number, number>(1))\n)\n\n//\n// chainEitherKW\n//\n\n// $ExpectType TaskEither<string | number, number>\npipe(\n  _.right<string, string>('a'),\n  _.chainEitherKW(() => E.right<number, number>(1))\n)\n\n//\n// chainIOEitherKW\n//\n\n// $ExpectType TaskEither<string | number, number>\npipe(\n  _.right<string, string>('a'),\n  _.chainIOEitherKW(() => IOE.right<number, number>(1))\n)\n\n//\n// fromTaskOption\n//\n\n// $ExpectType TaskEither<string, number>\npipe(\n  TO.some(1),\n  _.fromTaskOption(() => 'a')\n)\n\n//\n// taskify\n//\n\ndeclare function apiForTaskify(path: string, callback: (err: Error | null | undefined, result?: string) => void): void\n\n_.taskify(apiForTaskify) // $ExpectType (a: string) => TaskEither<Error, string>\n\n//\n// do notation\n//\n\n// $ExpectType TaskEither<string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<string, number>(1),\n  _.bindTo('a1'),\n  _.bind('a2', () => _.right('b')),\n  _.bindW('a3', () => _.right<number, boolean>(true))\n)\n\n//\n// pipeable sequence S\n//\n\n// $ExpectType TaskEither<string | number, { readonly a1: number; readonly a2: string; readonly a3: boolean; }>\npipe(\n  _.right<string, number>(1),\n  _.bindTo('a1'),\n  _.apS('a2', _.right('b')),\n  _.apSW('a3', _.right<number, boolean>(true))\n)\n\n//\n// Do\n//\n\n// $ExpectType TaskEither<string, { readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of<string, number>(1)),\n  _.bind('a2', () => _.of<string, string>('b'))\n)\n\n//\n// filterOrElseW\n//\n\n// $ExpectType TaskEither<\"a1\" | \"a2\", number>\npipe(\n  _.left<'a1', number>('a1'),\n  _.filterOrElseW(\n    (result) => result > 0,\n    () => 'a2' as const\n  )\n)\n"
  },
  {
    "path": "dtslint/TaskOption.ts",
    "content": "import { pipe } from '../src/function'\nimport * as TE from '../src/TaskEither'\nimport * as _ from '../src/TaskOption'\n\ndeclare const tesn: TE.TaskEither<string, number>\n\n//\n// fromTaskEither\n//\n\npipe(tesn, _.fromTaskEither) // $ExpectType TaskOption<number>\n\n// -------------------------------------------------------------------------------------\n// Predicate-based APIs\n// -------------------------------------------------------------------------------------\n\ndeclare const n: number\ndeclare const sn: string | number\ndeclare const on: _.TaskOption<number>\ndeclare const osn: _.TaskOption<string | number>\ndeclare const isString: (u: unknown) => u is string\ndeclare const isNumber: (sn: string | number) => sn is number\ndeclare const predicate: (sn: string | number) => boolean\n\n//\n// filter\n//\n\n// $ExpectType TaskOption<string>\npipe(osn, _.filter(isString))\n// $ExpectType TaskOption<number>\npipe(on, _.filter(predicate))\n// $ExpectType TaskOption<number>\npipe(\n  on,\n  _.filter(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// partition\n//\n\n// $ExpectType Separated<TaskOption<unknown>, TaskOption<string>>\npipe(osn, _.partition(isString))\n// $ExpectType Separated<TaskOption<number>, TaskOption<number>>\npipe(on, _.partition(predicate))\n// $ExpectType Separated<TaskOption<string | number>, TaskOption<number>>\npipe(osn, _.partition(isNumber))\n// $ExpectType Separated<TaskOption<number>, TaskOption<number>>\npipe(\n  on,\n  _.partition(\n    (\n      _x // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// fromPredicate\n//\n\n// $ExpectType TaskOption<string>\npipe(sn, _.fromPredicate(isString))\n// $ExpectType TaskOption<number>\npipe(n, _.fromPredicate(predicate))\n// $ExpectType TaskOption<number>\npipe(\n  n,\n  _.fromPredicate(\n    (\n      _n // $ExpectType number\n    ) => true\n  )\n)\n\n//\n// filterOrElse\n//\n"
  },
  {
    "path": "dtslint/Traversable.ts",
    "content": "import * as E from '../src/Either'\nimport * as RA from '../src/ReadonlyArray'\nimport * as TE from '../src/TaskEither'\nimport * as _ from '../src/Traversable'\n\n//\n// traversable\n//\n\n// $ExpectType <A, FE, B>(f: (a: A) => TaskEither<FE, B>) => <GE>(tga: readonly Either<GE, A>[]) => TaskEither<FE, readonly Either<GE, B>[]>\n_.traverse(RA.Traversable, E.Traversable)(TE.ApplicativePar)\n\n//\n// traversable\n//\n\n// $ExpectType <GE, FE, A>(tgfa: readonly Either<GE, TaskEither<FE, A>>[]) => TaskEither<FE, readonly Either<GE, A>[]>\n_.sequence(RA.Traversable, E.Traversable)(TE.ApplicativePar)\n"
  },
  {
    "path": "dtslint/Tree.ts",
    "content": "import { pipe } from '../src/function'\nimport * as _ from '../src/Tree'\n\n//\n// Do\n//\n\n// $ExpectType Tree<{ readonly a1: number; readonly a2: string; }>\npipe(\n  _.Do,\n  _.bind('a1', () => _.of(1)),\n  _.bind('a2', () => _.of('b'))\n)\n"
  },
  {
    "path": "dtslint/constrained.ts",
    "content": "import { Alt2C, Alt3C } from '../src/Alt'\nimport { Alternative2C, Alternative3C } from '../src/Alternative'\nimport { Applicative2C, Applicative3C } from '../src/Applicative'\nimport { Apply2C, Apply3C } from '../src/Apply'\nimport { Bifunctor2C, Bifunctor3C } from '../src/Bifunctor'\nimport { Chain2C, Chain3C } from '../src/Chain'\nimport { ChainRec2C, ChainRec3C } from '../src/ChainRec'\nimport { Comonad2C, Comonad3C } from '../src/Comonad'\nimport { Compactable2C, Compactable3C } from '../src/Compactable'\nimport { Contravariant2C, Contravariant3C } from '../src/Contravariant'\nimport { Extend2C, Extend3C } from '../src/Extend'\nimport { Filterable2C, Filterable3C } from '../src/Filterable'\nimport { FilterableWithIndex2C } from '../src/FilterableWithIndex'\nimport { Foldable2C, Foldable3C } from '../src/Foldable'\nimport { FoldableWithIndex2C, FoldableWithIndex3C } from '../src/FoldableWithIndex'\nimport { FromEither2C, FromEither3C } from '../src/FromEither'\nimport { FromIO2C, FromIO3C } from '../src/FromIO'\nimport { FromTask2C, FromTask3C } from '../src/FromTask'\nimport { Functor2C, Functor3C } from '../src/Functor'\nimport { FunctorWithIndex2C, FunctorWithIndex3C } from '../src/FunctorWithIndex'\nimport { Invariant2C, Invariant3C } from '../src/Invariant'\nimport { Monad2C, Monad3C } from '../src/Monad'\nimport { Pointed2C, Pointed3C } from '../src/Pointed'\nimport { Profunctor2C, Profunctor3C } from '../src/Profunctor'\nimport { Traversable2C } from '../src/Traversable'\nimport { TraversableWithIndex2C } from '../src/TraversableWithIndex'\nimport { Unfoldable2C, Unfoldable3C } from '../src/Unfoldable'\nimport { Witherable2C } from '../src/Witherable'\n\n// $ExpectType string\nexport type _1 = Alt2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _2 = Alt3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _3 = Alternative2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _4 = Alternative3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _5 = Applicative2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _6 = Applicative3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _7 = Apply2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _8 = Apply3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _9 = Bifunctor2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _10 = Bifunctor3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _11 = Comonad2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _12 = Comonad3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _13 = Compactable2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _14 = Compactable3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _15 = Contravariant2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _16 = Contravariant3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _17 = Extend2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _18 = Extend3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _19 = Filterable2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _20 = Filterable3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _21 = FilterableWithIndex2C<'Either', number, string>['_E']\n\n// $ExpectType string\nexport type _22 = Foldable2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _23 = Foldable3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _24 = FoldableWithIndex2C<'Either', number, string>['_E']\n\n// $ExpectType string\nexport type _25 = FoldableWithIndex3C<'ReaderEither', number, string>['_E']\n\n// $ExpectType string\nexport type _26 = FromEither2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _27 = FromEither3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _28 = FromIO2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _29 = FromIO3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _30 = FromTask2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _31 = FromTask3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _32 = Functor2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _33 = Functor3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _34 = FunctorWithIndex2C<'Either', number, string>['_E']\n\n// $ExpectType string\nexport type _35 = FunctorWithIndex3C<'ReaderEither', number, string>['_E']\n\n// $ExpectType string\nexport type _36 = Invariant2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _37 = Invariant3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _38 = Monad2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _39 = Monad3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _40 = Pointed2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _41 = Pointed3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _42 = Profunctor2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _43 = Profunctor3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _44 = Traversable2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _45 = TraversableWithIndex2C<'Either', number, string>['_E']\n\n// $ExpectType string\nexport type _46 = Unfoldable2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _47 = Unfoldable3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _48 = Witherable2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _49 = Chain2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _50 = Chain3C<'ReaderEither', string>['_E']\n\n// $ExpectType string\nexport type _51 = ChainRec2C<'Either', string>['_E']\n\n// $ExpectType string\nexport type _52 = ChainRec3C<'ReaderEither', string>['_E']\n"
  },
  {
    "path": "dtslint/function.ts",
    "content": "import * as _ from '../src/function'\nimport * as RA from '../src/ReadonlyArray'\n\n//\n// flip\n//\n\n// should handle generics\n_.flip(RA.snoc) // $ExpectType <A>(b: A, a: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A>\n\n//\n// tuple\n//\n\n_.tuple() // $ExpectType []\n_.tuple(1) // $ExpectType [number]\n_.tuple(1, 'a') // $ExpectType [number, string]\n_.tuple(1, 'a', true) // $ExpectType [number, string, boolean]\n\n// $ExpectType <A>(init: ReadonlyArray<A>, end: A) => Option<A>\n_.flow(RA.snoc, RA.head)\n\n//\n// tupled\n//\n\n_.tupled(RA.insertAt)([0, 'a']) // $ExpectType (as: ReadonlyArray<string>) => Option<ReadonlyNonEmptyArray<string>>\n\n//\n// untupled\n//\n\n_.untupled(_.tupled(RA.insertAt)) // $ExpectType <A>(i: number, a: A) => (as: ReadonlyArray<A>) => Option<ReadonlyNonEmptyArray<A>>\n"
  },
  {
    "path": "dtslint/index.d.ts",
    "content": ""
  },
  {
    "path": "dtslint/index.ts",
    "content": "import * as _ from '../src/HKT'\nimport * as T from '../src/Task'\n\n// issue #536\nexport function testIssue536<F extends _.URIS, G extends _.URIS, A>(x: _.Kind<F, A>): _.Kind<G, A> {\n  // @ts-expect-error\n  return x\n}\n\nexport const testURI = <F extends _.URIS>(ma: T.Task<number>): _.Kind<F, number> => {\n  // @ts-expect-error\n  return ma\n}\n\n// @ts-expect-error\nexport type HKT1 = _.Kind<'a', string>\n\nexport type Tuple<E, A> = readonly [A, E]\n"
  },
  {
    "path": "dtslint/pipeable.ts",
    "content": "import { Chain3C } from '../src/Chain'\nimport * as Eq from '../src/Eq'\nimport * as O from '../src/Option'\nimport * as P from '../src/pipeable'\nimport * as R from '../src/Reader'\nimport * as RTE from '../src/ReaderTaskEither'\nimport * as RA from '../src/ReadonlyArray'\nimport * as RT from '../src/ReadonlyTuple'\nimport * as SRTE from '../src/StateReaderTaskEither'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as TE from '../src/TaskEither'\nimport * as TH from '../src/These'\n\nconst TEApplicative = TE.getApplicativeTaskValidation(T.ApplyPar, S.Semigroup)\nconst TEAlt = TE.getAltTaskValidation(S.Semigroup)\nconst RTEApplicative = RTE.getApplicativeReaderTaskValidation(T.ApplyPar, S.Semigroup)\nconst RTEAlt = RTE.getAltReaderTaskValidation(S.Semigroup)\n\n//\n// map\n//\n\n// $ExpectType <A, B>(f: (a: A) => B) => (fa: Task<A>) => Task<B>\nP.map(T.Functor)\n\n// $ExpectType <A, B>(f: (a: A) => B) => <E>(fa: TaskEither<E, A>) => TaskEither<E, B>\nP.map(TE.Functor)\n\n// $ExpectType <A, B>(f: (a: A) => B) => (fa: TaskEither<string, A>) => TaskEither<string, B>\nP.map(TEApplicative)\n\n// $ExpectType <A, B>(f: (a: A) => B) => <R, E>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\nP.map(RTE.Functor)\n\n// $ExpectType <A, B>(f: (a: A) => B) => <R>(fa: ReaderTaskEither<R, string, A>) => ReaderTaskEither<R, string, B>\nP.map(RTEApplicative)\n\n// $ExpectType <A, B>(f: (a: A) => B) => <S, R, E>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\nP.map(SRTE.Functor)\n\n//\n// mapWithIndex\n//\n\n// $ExpectType <A, B>(f: (i: number, a: A) => B) => (fa: readonly A[]) => readonly B[]\nP.mapWithIndex(RA.FunctorWithIndex)\n\n//\n// contramap\n//\n\n// $ExpectType <A, B>(f: (b: B) => A) => (fa: Eq<A>) => Eq<B>\nP.contramap(Eq.Contravariant)\n\n//\n// ap\n//\n\n// $ExpectType <A>(fa: Task<A>) => <B>(fab: Task<(a: A) => B>) => Task<B>\nP.ap(T.ApplyPar)\n\n// $ExpectType <E, A>(fa: TaskEither<E, A>) => <B>(fab: TaskEither<E, (a: A) => B>) => TaskEither<E, B>\nP.ap(TE.ApplyPar)\n\n// $ExpectType <A>(fa: TaskEither<string, A>) => <B>(fab: TaskEither<string, (a: A) => B>) => TaskEither<string, B>\nP.ap(TEApplicative)\n\n// $ExpectType <R, E, A>(fa: ReaderTaskEither<R, E, A>) => <B>(fab: ReaderTaskEither<R, E, (a: A) => B>) => ReaderTaskEither<R, E, B>\nP.ap(RTE.ApplyPar)\n\n// $ExpectType <R, A>(fa: ReaderTaskEither<R, string, A>) => <B>(fab: ReaderTaskEither<R, string, (a: A) => B>) => ReaderTaskEither<R, string, B>\nP.ap(RTEApplicative)\n\n// $ExpectType <S, R, E, A>(fa: StateReaderTaskEither<S, R, E, A>) => <B>(fab: StateReaderTaskEither<S, R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B>\nP.ap(SRTE.Apply)\n\n//\n// chain\n//\n\n// $ExpectType <A, B>(f: (a: A) => Task<B>) => (fa: Task<A>) => Task<B>\nP.chain(T.Chain)\n\n// $ExpectType <A, E, B>(f: (a: A) => TaskEither<E, B>) => (fa: TaskEither<E, A>) => TaskEither<E, B>\nP.chain(TE.Chain)\n\nconst THChain = TH.getChain(S.Semigroup)\n\n// $ExpectType <A, B>(f: (a: A) => These<string, B>) => (fa: These<string, A>) => These<string, B>\nP.chain(THChain)\n\n// $ExpectType <A, R, E, B>(f: (a: A) => ReaderTaskEither<R, E, B>) => (fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\nP.chain(RTE.Chain)\n\ndeclare const Chain3C: Chain3C<RTE.URI, string>\n// $ExpectType <A, R, B>(f: (a: A) => ReaderTaskEither<R, string, B>) => (fa: ReaderTaskEither<R, string, A>) => ReaderTaskEither<R, string, B>\nP.chain(Chain3C)\n\n// $ExpectType <A, S, R, E, B>(f: (a: A) => StateReaderTaskEither<S, R, E, B>) => (fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\nP.chain(SRTE.Chain)\n\n//\n// bimap\n//\n\n// $ExpectType <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: These<E, A>) => These<G, B>\nP.bimap(TH.Bifunctor)\n\n//\n// mapLeft\n//\n\n// $ExpectType <E, G>(f: (e: E) => G) => <A>(fea: These<E, A>) => These<G, A>\nP.mapLeft(TH.Bifunctor)\n\n//\n// extend\n//\n\n// $ExpectType <A, B>(f: (wa: readonly A[]) => B) => (wa: readonly A[]) => readonly B[]\nP.extend(RA.Extend)\n\n//\n// reduce\n//\n\n// $ExpectType <A, B>(b: B, f: (b: B, a: A) => B) => (fa: readonly A[]) => B\nP.reduce(RA.Foldable)\n\n//\n// foldMap\n//\n\n// $ExpectType <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: readonly A[]) => M\nP.foldMap(RA.Foldable)\n\n//\n// reduceRight\n//\n\n// $ExpectType <A, B>(b: B, f: (a: A, b: B) => B) => (fa: readonly A[]) => B\nP.reduceRight(RA.Foldable)\n\n//\n// reduceWithIndex\n//\n\n// $ExpectType <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: readonly A[]) => B\nP.reduceWithIndex(RA.FoldableWithIndex)\n\n//\n// foldMapWithIndex\n//\n\n// $ExpectType <M>(M: Monoid<M>) => <A>(f: (i: number, a: A) => M) => (fa: readonly A[]) => M\nP.foldMapWithIndex(RA.FoldableWithIndex)\n\n//\n// reduceRightWithIndex\n//\n\n// $ExpectType <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: readonly A[]) => B\nP.reduceRightWithIndex(RA.FoldableWithIndex)\n\n//\n// alt\n//\n\n// $ExpectType <A>(that: LazyArg<Option<A>>) => (fa: Option<A>) => Option<A>\nP.alt(O.Alt)\n\n// $ExpectType <E, A>(that: LazyArg<TaskEither<E, A>>) => (fa: TaskEither<E, A>) => TaskEither<E, A>\nP.alt(TE.Alt)\n\n// $ExpectType <A>(that: LazyArg<TaskEither<string, A>>) => (fa: TaskEither<string, A>) => TaskEither<string, A>\nP.alt(TEAlt)\n\n// $ExpectType <R, E, A>(that: LazyArg<ReaderTaskEither<R, E, A>>) => (fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\nP.alt(RTE.Alt)\n\n// $ExpectType <R, A>(that: LazyArg<ReaderTaskEither<R, string, A>>) => (fa: ReaderTaskEither<R, string, A>) => ReaderTaskEither<R, string, A>\nP.alt(RTEAlt)\n\n// $ExpectType <S, R, E, A>(that: LazyArg<StateReaderTaskEither<S, R, E, A>>) => (fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\nP.alt(SRTE.Alt)\n\n//\n// filter\n//\n\n// $ExpectType { <A, B extends A>(refinement: Refinement<A, B>): (fa: readonly A[]) => readonly B[]; <A>(predicate: Predicate<A>): (fa: readonly A[]) => readonly A[]; }\nP.filter(RA.Filterable)\n\n//\n// filterMap\n//\n\n// $ExpectType <A, B>(f: (a: A) => Option<B>) => (fa: readonly A[]) => readonly B[]\nP.filterMap(RA.Filterable)\n\n//\n// partition\n//\n\n// $ExpectType { <A, B extends A>(refinement: Refinement<A, B>): (fa: readonly A[]) => Separated<readonly A[], readonly B[]>; <A>(predicate: Predicate<A>): (fa: readonly A[]) => Separated<readonly A[], readonly A[]>; }\nP.partition(RA.Filterable)\n\n//\n// partitionMap\n//\n\n// $ExpectType <A, B, C>(f: (a: A) => Either<B, C>) => (fa: readonly A[]) => Separated<readonly B[], readonly C[]>\nP.partitionMap(RA.Filterable)\n\n//\n// filterWithIndex\n//\n\n// $ExpectType { <A, B extends A>(refinement: RefinementWithIndex<number, A, B>): (fa: readonly A[]) => readonly B[]; <A>(predicate: PredicateWithIndex<number, A>): (fa: readonly A[]) => readonly A[]; }\nP.filterWithIndex(RA.FilterableWithIndex)\n\n//\n// filterMapWithIndex\n//\n\n// $ExpectType <A, B>(f: (i: number, a: A) => Option<B>) => (fa: readonly A[]) => readonly B[]\nP.filterMapWithIndex(RA.FilterableWithIndex)\n\n//\n// partitionWithIndex\n//\n\n// $ExpectType { <A, B extends A>(refinement: RefinementWithIndex<number, A, B>): (fa: readonly A[]) => Separated<readonly A[], readonly B[]>; <A>(predicate: PredicateWithIndex<number, A>): (fa: readonly A[]) => Separated<readonly A[], readonly A[]>; }\nP.partitionWithIndex(RA.FilterableWithIndex)\n\n//\n// partitionMapWithIndex\n//\n\n// $ExpectType <A, B, C>(f: (i: number, a: A) => Either<B, C>) => (fa: readonly A[]) => Separated<readonly B[], readonly C[]>\nP.partitionMapWithIndex(RA.FilterableWithIndex)\n\n//\n// promap\n//\n\n// $ExpectType <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Reader<E, A>) => Reader<D, B>\nP.promap(R.Profunctor)\n\n//\n// compose\n//\n\n// $ExpectType <E, A>(ea: readonly [A, E]) => <B>(ab: readonly [B, A]) => readonly [B, E]\nP.compose(RT.Semigroupoid)\n"
  },
  {
    "path": "dtslint/tsconfig.json",
    "content": "{\n  \"extends\": \"../tsconfig.json\",\n  \"include\": [\".\"],\n  \"compilerOptions\": {\n    \"incremental\": false,\n    \"composite\": false,\n    \"noUnusedLocals\": false\n  }\n}\n"
  },
  {
    "path": "examples/fp-ts-to-the-max-I.ts",
    "content": "import { createInterface } from 'readline'\n\nimport { log } from '../src/Console'\nimport { flow, pipe } from '../src/function'\nimport * as O from '../src/Option'\nimport { randomInt } from '../src/Random'\nimport * as T from '../src/Task'\n\n//\n// helpers\n//\n\n// read from standard input\nconst getStrLn: T.Task<string> = () =>\n  new Promise((resolve) => {\n    const rl = createInterface({\n      input: process.stdin,\n      output: process.stdout\n    })\n    rl.question('> ', (answer) => {\n      rl.close()\n      resolve(answer)\n    })\n  })\n\n// write to standard output\nconst putStrLn = flow(log, T.fromIO)\n\n// ask something and get the answer\nfunction ask(question: string): T.Task<string> {\n  return pipe(\n    putStrLn(question),\n    T.flatMap(() => getStrLn)\n  )\n}\n\n// get a random int between 1 and 5\nconst random = T.fromIO(randomInt(1, 5))\n\n// parse a string to an integer\nfunction parse(s: string): O.Option<number> {\n  const i = +s\n  return isNaN(i) || i % 1 !== 0 ? O.none : O.some(i)\n}\n\n//\n// game\n//\n\nfunction shouldContinue(name: string): T.Task<boolean> {\n  return pipe(\n    ask(`Do you want to continue, ${name} (y/n)?`),\n    T.flatMap((answer) => {\n      switch (answer.toLowerCase()) {\n        case 'y':\n          return T.of(true)\n        case 'n':\n          return T.of(false)\n        default:\n          return shouldContinue(name)\n      }\n    })\n  )\n}\n\nfunction gameLoop(name: string): T.Task<void> {\n  return pipe(\n    T.Do,\n    T.apS('secret', random),\n    T.apS('guess', ask(`Dear ${name}, please guess a number from 1 to 5`)),\n    T.flatMap(({ secret, guess }) =>\n      pipe(\n        parse(guess),\n        O.fold(\n          () => putStrLn('You did not enter an integer!'),\n          (x) =>\n            x === secret\n              ? putStrLn(`You guessed right, ${name}!`)\n              : putStrLn(`You guessed wrong, ${name}! The number was: ${secret}`)\n        )\n      )\n    ),\n    T.flatMap(() => shouldContinue(name)),\n    T.flatMap((b) => (b ? gameLoop(name) : T.of(undefined)))\n  )\n}\n\nconst main: T.Task<void> = pipe(\n  ask('What is your name?'),\n  T.tap((name) => putStrLn(`Hello, ${name} welcome to the game!`)),\n  T.flatMap(gameLoop)\n)\n\n// tslint:disable-next-line: no-floating-promises\nmain()\n"
  },
  {
    "path": "examples/fp-ts-to-the-max-II.ts",
    "content": "import * as assert from 'assert'\nimport { createInterface } from 'readline'\n\nimport { apS as apS_ } from '../src/Apply'\nimport { chainFirst as chainFirst_ } from '../src/Chain'\nimport { log } from '../src/Console'\nimport { flow, pipe } from '../src/function'\nimport { Kind, URIS } from '../src/HKT'\nimport { Monad1 } from '../src/Monad'\nimport * as O from '../src/Option'\nimport { randomInt } from '../src/Random'\nimport { append, dropLeft } from '../src/ReadonlyArray'\nimport * as S from '../src/State'\nimport * as T from '../src/Task'\n\n//\n// type classes\n//\n\ninterface Program<F extends URIS> extends Monad1<F> {\n  readonly finish: <A>(a: A) => Kind<F, A>\n}\n\ninterface Console<F extends URIS> {\n  readonly putStrLn: (message: string) => Kind<F, void>\n  readonly getStrLn: Kind<F, string>\n}\n\ninterface Random<F extends URIS> {\n  readonly nextInt: (upper: number) => Kind<F, number>\n}\n\ninterface Main<F extends URIS> extends Program<F>, Console<F>, Random<F> {}\n\n//\n// instances\n//\n\nconst programTask: Program<T.URI> = {\n  ...T.Monad,\n  finish: T.of\n}\n\n// read from standard input\nconst getStrLn: T.Task<string> = () =>\n  new Promise((resolve) => {\n    const rl = createInterface({\n      input: process.stdin,\n      output: process.stdout\n    })\n    rl.question('> ', (answer) => {\n      rl.close()\n      resolve(answer)\n    })\n  })\n\n// write to standard output\nconst putStrLn = flow(log, T.fromIO)\n\nconst consoleTask: Console<T.URI> = {\n  putStrLn,\n  getStrLn\n}\n\nconst randomTask: Random<T.URI> = {\n  nextInt: (upper) => T.fromIO(randomInt(1, upper))\n}\n\n//\n// game\n//\n\n// parse a string to an integer\nfunction parse(s: string): O.Option<number> {\n  const i = +s\n  return isNaN(i) || i % 1 !== 0 ? O.none : O.some(i)\n}\n\nfunction main<F extends URIS>(F: Main<F>): Kind<F, void> {\n  const flatMap =\n    <A, B>(f: (a: A) => Kind<F, B>) =>\n    (ma: Kind<F, A>): Kind<F, B> =>\n      F.chain(ma, f)\n  const Do: Kind<F, {}> = F.of({})\n  const apS = apS_(F)\n  const tap = chainFirst_(F)\n\n  // ask something and get the answer\n  const ask = (question: string): Kind<F, string> =>\n    pipe(\n      F.putStrLn(question),\n      flatMap(() => F.getStrLn)\n    )\n\n  const shouldContinue = (name: string): Kind<F, boolean> => {\n    return pipe(\n      ask(`Do you want to continue, ${name} (y/n)?`),\n      flatMap((answer) => {\n        switch (answer.toLowerCase()) {\n          case 'y':\n            return F.of<boolean>(true)\n          case 'n':\n            return F.of<boolean>(false)\n          default:\n            return shouldContinue(name)\n        }\n      })\n    )\n  }\n\n  const gameLoop = (name: string): Kind<F, void> => {\n    return pipe(\n      Do,\n      apS('secret', F.nextInt(5)),\n      apS('guess', ask(`Dear ${name}, please guess a number from 1 to 5`)),\n      flatMap(({ secret, guess }) =>\n        pipe(\n          parse(guess),\n          O.fold(\n            () => F.putStrLn('You did not enter an integer!'),\n            (x) =>\n              x === secret\n                ? F.putStrLn(`You guessed right, ${name}!`)\n                : F.putStrLn(`You guessed wrong, ${name}! The number was: ${secret}`)\n          )\n        )\n      ),\n      flatMap(() => shouldContinue(name)),\n      flatMap((b) => (b ? gameLoop(name) : F.of<void>(undefined)))\n    )\n  }\n\n  return pipe(\n    ask('What is your name?'),\n    tap((name) => F.putStrLn(`Hello, ${name} welcome to the game!`)),\n    flatMap(gameLoop)\n  )\n}\n\nexport const mainTask = main({\n  ...programTask,\n  ...consoleTask,\n  ...randomTask\n})\n\n// tslint:disable-next-line: no-floating-promises\n// mainTask()\n\n//\n// tests\n//\n\nclass TestData {\n  constructor(\n    readonly input: ReadonlyArray<string>,\n    readonly output: ReadonlyArray<string>,\n    readonly nums: ReadonlyArray<number>\n  ) {}\n  putStrLn(message: string): [void, TestData] {\n    return [undefined, new TestData(this.input, pipe(this.output, append(message)), this.nums)]\n  }\n  getStrLn(): [string, TestData] {\n    return [this.input[0], new TestData(dropLeft(1)(this.input), this.output, this.nums)]\n  }\n  nextInt(_upper: number): [number, TestData] {\n    return [this.nums[0], new TestData(this.input, this.output, dropLeft(1)(this.nums))]\n  }\n}\n\nconst URI = 'Test'\n\ntype URI = typeof URI\n\ndeclare module '../src/HKT' {\n  interface URItoKind<A> {\n    readonly Test: Test<A>\n  }\n}\n\ninterface Test<A> extends S.State<TestData, A> {}\n\nconst of =\n  <A>(a: A): Test<A> =>\n  (data) =>\n    [a, data]\n\nconst programTest: Program<URI> = {\n  ...S.Monad,\n  URI,\n  finish: of\n}\n\nconst consoleTest: Console<URI> = {\n  putStrLn: (message) => (data) => data.putStrLn(message),\n  getStrLn: (data) => data.getStrLn()\n}\n\nconst randomTest: Random<URI> = {\n  nextInt: (upper) => (data) => {\n    return data.nextInt(upper)\n  }\n}\n\nconst mainTestTask = main({\n  ...programTest,\n  ...consoleTest,\n  ...randomTest\n})\n\nconst testExample = new TestData(['Giulio', '1', 'n'], [], [1])\n\nassert.deepStrictEqual(mainTestTask(testExample), [\n  undefined,\n  new TestData(\n    [],\n    [\n      'What is your name?',\n      'Hello, Giulio welcome to the game!',\n      'Dear Giulio, please guess a number from 1 to 5',\n      'You guessed right, Giulio!',\n      'Do you want to continue, Giulio (y/n)?'\n    ],\n    []\n  )\n])\n"
  },
  {
    "path": "examples/tsconfig.json",
    "content": "{\n  \"extends\": \"../tsconfig.json\",\n  \"compilerOptions\": {\n    \"noEmit\": true\n  },\n  \"include\": [\"./**/*\"]\n}\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"fp-ts\",\n  \"version\": \"2.16.11\",\n  \"description\": \"Functional programming in TypeScript\",\n  \"main\": \"./lib/index.js\",\n  \"module\": \"./es6/index.js\",\n  \"typings\": \"lib/index.d.ts\",\n  \"sideEffects\": false,\n  \"scripts\": {\n    \"lint\": \"eslint \\\"src/**/*.ts\\\" \\\"test/**/*.ts\\\" \\\"scripts/**/*.ts\\\"\",\n    \"lint-fix\": \"eslint --fix \\\"src/**/*.ts\\\" \\\"test/**/*.ts\\\" \\\"scripts/**/*.ts\\\"\",\n    \"prettier\": \"prettier --list-different \\\"./{src,test,examples,scripts}/**/*.ts\\\"\",\n    \"fix-prettier\": \"prettier --write \\\"./{src,test,examples,scripts}/**/*.ts\\\"\",\n    \"test\": \"npm run lint && npm run prettier && npm run dtslint && npm run vitest && npm run docs\",\n    \"clean\": \"rimraf ./dist\",\n    \"prebuild\": \"npm run clean\",\n    \"build\": \"tsc -p ./tsconfig.build.json && tsc -p ./tsconfig.build-es6.json && ts-node scripts/build\",\n    \"postbuild\": \"prettier --loglevel=silent --write \\\"./dist/**/*.ts\\\"\",\n    \"prepublishOnly\": \"ts-node scripts/pre-publish\",\n    \"mocha\": \"mocha -r ts-node/register test/*.ts\",\n    \"dtslint\": \"dtslint dtslint\",\n    \"docs\": \"docs-ts\",\n    \"prerelease\": \"npm run build\",\n    \"release\": \"ts-node scripts/release\",\n    \"dpdm\": \"dpdm --warning=false --tree=false --exit-code circular:1 -T src/index.ts\",\n    \"vitest\": \"vitest run\",\n    \"coverage\": \"vitest run --coverage\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/gcanti/fp-ts.git\"\n  },\n  \"author\": \"Giulio Canti <giulio.canti@gmail.com>\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/gcanti/fp-ts/issues\"\n  },\n  \"homepage\": \"https://github.com/gcanti/fp-ts\",\n  \"devDependencies\": {\n    \"@effect/dtslint\": \"^0.1.0\",\n    \"@effect/language-service\": \"^0.0.19\",\n    \"@types/benchmark\": \"^1.0.31\",\n    \"@types/chai\": \"^3.5.2\",\n    \"@types/glob\": \"^7.1.3\",\n    \"@types/node\": \"^20.14.10\",\n    \"@typescript-eslint/eslint-plugin\": \"^5.59.0\",\n    \"@typescript-eslint/parser\": \"^5.59.0\",\n    \"@vitest/coverage-istanbul\": \"^1.6.0\",\n    \"benchmark\": \"2.1.4\",\n    \"docs-ts\": \"^0.8.0\",\n    \"eslint\": \"^8.38.0\",\n    \"eslint-plugin-deprecation\": \"^1.4.1\",\n    \"eslint-plugin-import\": \"^2.27.5\",\n    \"eslint-plugin-simple-import-sort\": \"^10.0.0\",\n    \"fast-check\": \"^3.1.3\",\n    \"glob\": \"^7.1.6\",\n    \"mocha\": \"^5.2.0\",\n    \"prettier\": \"^2.7.1\",\n    \"rimraf\": \"2.6.2\",\n    \"ts-node\": \"^8.0.2\",\n    \"tslint\": \"5.11.0\",\n    \"typescript\": \"^5.5.2\",\n    \"vitest\": \"^1.6.0\"\n  },\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}\n"
  },
  {
    "path": "perf/Either/sequenceArray.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/Either'\nimport { pipe } from '../../src/function'\n\n/*\nA.sequence(_.Applicative) x 993 ops/sec ±0.39% (88 runs sampled)\n_.sequenceArray x 164,033 ops/sec ±3.53% (87 runs sampled)\nFastest is _.sequenceArray\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000), RNEA.map(_.of))\n\nsuite\n  .add('A.sequence(_.Applicative)', function () {\n    pipe(as, RNEA.sequence(_.Applicative))\n  })\n  .add('_.sequenceArray', function () {\n    // tslint:disable-next-line: deprecation\n    pipe(as, _.sequenceArray)\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/IO/sequenceArray.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/IO'\nimport { pipe } from '../../src/function'\n\n/*\nA.sequence(_.Applicative) x 17,253 ops/sec ±0.28% (88 runs sampled)\n_.sequenceArray x 21,475,613 ops/sec ±1.19% (88 runs sampled)\nFastest is _.sequenceArray\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000), RNEA.map(_.of))\n\nsuite\n  .add('A.sequence(_.Applicative)', function () {\n    pipe(as, RNEA.sequence(_.Applicative))\n  })\n  .add('_.sequenceArray', function () {\n    // tslint:disable-next-line: deprecation\n    pipe(as, _.sequenceArray)\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/Option/sequenceArray.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/Option'\nimport { pipe } from '../../src/function'\n\n/*\nA.sequence(_.Applicative) x 261 ops/sec ±9.68% (60 runs sampled)\n_.sequenceArray x 58,110 ops/sec ±7.58% (71 runs sampled)\nFastest is _.sequenceArray\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000), RNEA.map(_.of))\n\nsuite\n  .add('A.sequence(_.Applicative)', function () {\n    return pipe(as, RNEA.sequence(_.Applicative))\n  })\n  .add('_.sequenceArray', function () {\n    // tslint:disable-next-line: deprecation\n    return pipe(as, _.sequenceArray)\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/ReaderTask/traverseReadonlyArrayWithIndexSeq.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/ReaderTask'\nimport { pipe } from '../../src/function'\n\n/*\nA.traverseWithIndex(_.ApplicativeSeq) x 247 ops/sec ±4.98% (36 runs sampled)\n_.traverseSeqArrayWithIndex x 1,901 ops/sec ±10.34% (66 runs sampled)\nFastest is _.traverseSeqArrayWithIndex\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000))\n\nsuite\n  .add('A.traverseWithIndex(_.ApplicativeSeq)', function () {\n    return pipe(\n      as,\n      RNEA.traverseWithIndex(_.ApplicativeSeq)((_i, a) => _.of(a))\n    )(undefined)()\n  })\n  .add('_.traverseReadonlyArrayWithIndexSeq', function () {\n    return pipe(\n      as,\n      _.traverseReadonlyArrayWithIndexSeq((_i, a) => _.of(a))\n    )(undefined)()\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/ReaderTaskEither/traverseReadonlyArrayWithIndexSeq.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/ReaderTaskEither'\nimport { pipe } from '../../src/function'\n\n/*\nA.traverseWithIndex(_.ApplicativeSeq) x 200 ops/sec ±6.32% (44 runs sampled)\n_.traverseSeqArrayWithIndex x 4,132 ops/sec ±8.65% (67 runs sampled)\nFastest is _.traverseSeqArrayWithIndex\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000))\n\nsuite\n  .add('A.traverseWithIndex(_.ApplicativeSeq)', function () {\n    return pipe(\n      as,\n      RNEA.traverseWithIndex(_.ApplicativeSeq)((_i, a) => _.of(a))\n    )(undefined)()\n  })\n  .add('_.traverseReadonlyArrayWithIndexSeq', function () {\n    return pipe(\n      as,\n      _.traverseReadonlyArrayWithIndexSeq((_i, a) => _.of(a))\n    )(undefined)()\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/ReadonlyNonEmptyArray.ts/reverse.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as _ from '../../src/ReadonlyNonEmptyArray'\n\n/*\nsnoc x 11,443,076 ops/sec ±1.78% (85 runs sampled)\nsnoc2 x 40,554,861 ops/sec ±1.52% (84 runs sampled)\n*/\n\nconst suite = new Benchmark.Suite()\n\nexport const reverse2 = <A>(as: _.ReadonlyNonEmptyArray<A>): _.ReadonlyNonEmptyArray<A> => as.slice().reverse() as any\n\nsuite\n  .add('reverse', function () {\n    _.reverse([1, 2, 3, 4])\n  })\n  .add('reverse2', function () {\n    reverse2([1, 2, 3, 4])\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/StateReaderTaskEither/sequenceArray.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/StateReaderTaskEither'\nimport { pipe } from '../../src/function'\n\n/*\nA.sequence(_.Applicative) x 5,930 ops/sec ±0.39% (90 runs sampled)\n_.sequenceArray x 21,057,757 ops/sec ±0.84% (88 runs sampled)\nFastest is _.sequenceArray\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000), RNEA.map(_.of))\n\nsuite\n  .add('A.sequence(_.Applicative)', function () {\n    pipe(as, RNEA.sequence(_.Applicative))\n  })\n  .add('_.sequenceArray', function () {\n    // tslint:disable-next-line: deprecation\n    pipe(as, _.sequenceArray)\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/Task/sequenceArray.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/Task'\nimport { pipe } from '../../src/function'\n\n/*\nA.sequence(_.ApplicativePar) x 390 ops/sec ±13.15% (44 runs sampled)\n_.sequenceArray x 3,460 ops/sec ±7.30% (57 runs sampled)\nFastest is _.sequenceArray\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000), RNEA.map(_.of))\n\nsuite\n  .add('A.sequence(_.ApplicativePar)', function () {\n    return pipe(as, RNEA.sequence(_.ApplicativePar))()\n  })\n  .add('_.sequenceArray', function () {\n    // tslint:disable-next-line: deprecation\n    return pipe(as, _.sequenceArray)()\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/Task/stack.ts",
    "content": "import * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/Task'\nimport { pipe } from '../../src/function'\n\nconst as = RNEA.range(0, 100000)\n\n// tslint:disable-next-line: no-floating-promises\npipe(\n  as,\n  // tslint:disable-next-line: deprecation\n  _.traverseSeqArrayWithIndex((_i, a) => _.of(a))\n  // tslint:disable-next-line: no-console\n)().then((as) => console.log(as.length))\n"
  },
  {
    "path": "perf/Task/traverseReadonlyArrayWithIndexSeq.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/Task'\nimport { pipe } from '../../src/function'\n\n/*\nA.traverseWithIndex(_.ApplicativeSeq) x 310 ops/sec ±10.89% (31 runs sampled)\n_.traverseSeqArrayWithIndex x 1,324 ops/sec ±6.92% (20 runs sampled)\nFastest is _.traverseSeqArrayWithIndex\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000))\n\nsuite\n  .add('A.traverseWithIndex(_.ApplicativeSeq)', function () {\n    return pipe(\n      as,\n      RNEA.traverseWithIndex(_.ApplicativeSeq)((_i, a) => _.of(a))\n    )()\n  })\n  .add('_.traverseReadonlyArrayWithIndexSeq', function () {\n    return pipe(\n      as,\n      _.traverseReadonlyArrayWithIndexSeq((_i, a) => _.of(a))\n    )()\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/TaskEither/traverseReadonlyArrayWithIndexSeq.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/TaskEither'\nimport { pipe } from '../../src/function'\n\n/*\nA.traverseWithIndex(_.ApplicativeSeq) x 309 ops/sec ±8.49% (67 runs sampled)\n_.traverseSeqArrayWithIndex x 1,502 ops/sec ±4.20% (20 runs sampled)\nFastest is _.traverseSeqArrayWithIndex\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000))\n\nsuite\n  .add('A.traverseWithIndex(_.ApplicativeSeq)', function () {\n    return pipe(\n      as,\n      RNEA.traverseWithIndex(_.ApplicativeSeq)((_i, a) => _.of(a))\n    )()\n  })\n  .add('_.traverseReadonlyArrayWithIndexSeq', function () {\n    return pipe(\n      as,\n      _.traverseReadonlyArrayWithIndexSeq((_i, a) => _.of(a))\n    )()\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/TaskOption/traverseReadonlyArrayWithIndexSeq.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/TaskOption'\nimport { pipe } from '../../src/function'\n\n/*\nA.traverseWithIndex(_.ApplicativeSeq) x 309 ops/sec ±8.49% (67 runs sampled)\n_.traverseSeqArrayWithIndex x 1,502 ops/sec ±4.20% (20 runs sampled)\nFastest is _.traverseSeqArrayWithIndex\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000))\n\nsuite\n  .add('A.traverseWithIndex(_.ApplicativeSeq)', function () {\n    return pipe(\n      as,\n      RNEA.traverseWithIndex(_.ApplicativeSeq)((_i, a) => _.of(a))\n    )()\n  })\n  .add('_.traverseReadonlyArrayWithIndexSeq', function () {\n    return pipe(\n      as,\n      _.traverseReadonlyArrayWithIndexSeq((_i, a) => _.of(a))\n    )()\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/TaskOption.ts/traverseReadonlyArrayWithIndexSeq.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport * as RNEA from '../../src/ReadonlyNonEmptyArray'\nimport * as _ from '../../src/TaskOption'\nimport { pipe } from '../../src/function'\n\n/*\nA.traverseWithIndex(_.ApplicativeSeq) x 309 ops/sec ±8.49% (67 runs sampled)\n_.traverseSeqArrayWithIndex x 1,502 ops/sec ±4.20% (20 runs sampled)\nFastest is _.traverseSeqArrayWithIndex\n*/\n\nconst suite = new Benchmark.Suite()\n\nconst as = pipe(RNEA.range(0, 1000))\n\nsuite\n  .add('A.traverseWithIndex(_.ApplicativeSeq)', function () {\n    return pipe(\n      as,\n      RNEA.traverseWithIndex(_.ApplicativeSeq)((_i, a) => _.of(a))\n    )()\n  })\n  .add('_.traverseReadonlyArrayWithIndexSeq', function () {\n    return pipe(\n      as,\n      _.traverseReadonlyArrayWithIndexSeq((_i, a) => _.of(a))\n    )()\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/function/flow.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport { flow } from '../../src/function'\n\nconst suite = new Benchmark.Suite()\n\nexport function flow2(...fns: ReadonlyArray<Function>): Function {\n  const len = fns.length\n  return function (this: any, ...x: ReadonlyArray<any>) {\n    let y = fns[0].apply(this, x)\n    for (let i = 1; i < len; i++) {\n      y = fns[i].call(this, y)\n    }\n    return y\n  }\n}\n\nconst f = (n: number) => n + 1\nconst g = (n: number) => n * 2\n\nsuite\n  .add('flow2', function (this: unknown) {\n    flow2(f, g, f, g, f, g, f, g, f)(2)\n  })\n  .add('flow', function (this: unknown) {\n    flow(f, g, f, g, f, g, f, g, f)(2)\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "perf/function/pipe.ts",
    "content": "import * as Benchmark from 'benchmark'\nimport { pipe } from '../../src/function'\n\nconst suite = new Benchmark.Suite()\n\nexport function pipe2(a: unknown, ...fns: ReadonlyArray<Function>): unknown {\n  let out: unknown = a\n  for (let i = 0; i < fns.length; i++) {\n    out = fns[i](out)\n  }\n  return out\n}\n\nconst f = (n: number) => n + 1\nconst g = (n: number) => n * 2\n\nsuite\n  .add('pipe2', function (this: unknown) {\n    pipe2(2, f, g, f, g, f, g, f, g, f)\n  })\n  .add('pipe', function (this: unknown) {\n    pipe(2, f, g, f, g, f, g, f, g, f)\n  })\n  .on('cycle', function (event: any) {\n    // tslint:disable-next-line: no-console\n    console.log(String(event.target))\n  })\n  .on('complete', function (this: any) {\n    // tslint:disable-next-line: no-console\n    console.log('Fastest is ' + this.filter('fastest').map('name'))\n  })\n  .run({ async: true })\n"
  },
  {
    "path": "scripts/FileSystem.ts",
    "content": "import * as fs from 'fs'\nimport G from 'glob'\n\nimport { flow } from '../src/function'\nimport * as TE from '../src/TaskEither'\n\nexport interface FileSystem {\n  readonly readFile: (path: string) => TE.TaskEither<Error, string>\n  readonly writeFile: (path: string, content: string) => TE.TaskEither<Error, void>\n  readonly copyFile: (from: string, to: string) => TE.TaskEither<Error, void>\n  readonly glob: (pattern: string) => TE.TaskEither<Error, ReadonlyArray<string>>\n  readonly mkdir: (path: string) => TE.TaskEither<Error, void>\n  readonly moveFile: (from: string, to: string) => TE.TaskEither<Error, void>\n}\n\nconst readFile = TE.taskify<fs.PathLike, { readonly encoding: 'utf8' }, NodeJS.ErrnoException, string>(fs.readFile)\nconst writeFile = TE.taskify<fs.PathLike, string, NodeJS.ErrnoException, void>(fs.writeFile)\nconst copyFile = TE.taskify<fs.PathLike, fs.PathLike, NodeJS.ErrnoException, void>(fs.copyFile)\nconst glob = TE.taskify<string, Error, ReadonlyArray<string>>(G)\nconst mkdirTE = TE.taskify(fs.mkdir)\nconst moveFile = TE.taskify<fs.PathLike, fs.PathLike, NodeJS.ErrnoException, void>(fs.rename)\n\nexport const fileSystem: FileSystem = {\n  readFile: (path) => readFile(path, { encoding: 'utf8' }),\n  writeFile,\n  copyFile,\n  glob,\n  mkdir: flow(\n    mkdirTE,\n    TE.map(() => undefined)\n  ),\n  moveFile\n}\n"
  },
  {
    "path": "scripts/build.ts",
    "content": "import * as path from 'path'\n\nimport * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as J from '../src/Json'\nimport * as RTE from '../src/ReaderTaskEither'\nimport * as TE from '../src/TaskEither'\nimport { FileSystem, fileSystem } from './FileSystem'\nimport { run } from './run'\n\ninterface Build<A> extends RTE.ReaderTaskEither<FileSystem, Error, A> {}\n\nconst OUTPUT_FOLDER = 'dist'\nconst PKG = 'package.json'\n\nexport const copyPackageJson: Build<void> = (C) =>\n  pipe(\n    C.readFile(PKG),\n    TE.flatMap((s) => TE.fromEither(pipe(J.parse(s), E.mapLeft(E.toError)))),\n    TE.map((json) => {\n      const clone = Object.assign({}, json as any)\n\n      delete clone.scripts\n      delete clone.files\n      delete clone.devDependencies\n\n      return clone\n    }),\n    TE.flatMap((json) => C.writeFile(path.join(OUTPUT_FOLDER, PKG), JSON.stringify(json, null, 2)))\n  )\n\nexport const FILES: ReadonlyArray<string> = ['CHANGELOG.md', 'LICENSE', 'README.md']\n\nexport const copyFiles: Build<ReadonlyArray<void>> = (C) =>\n  pipe(\n    FILES,\n    TE.traverseReadonlyArrayWithIndex((_, from) => C.copyFile(from, path.resolve(OUTPUT_FOLDER, from)))\n  )\n\nexport const makeModules: Build<void> = (C) => {\n  const makeSingleModuleC = makeSingleModule(C)\n  return pipe(\n    C.glob(`${OUTPUT_FOLDER}/lib/*.js`),\n    TE.map(getModules),\n    TE.flatMap(TE.traverseReadonlyArrayWithIndex((_, a) => makeSingleModuleC(a))),\n    TE.map(() => undefined)\n  )\n}\n\nfunction getModules(paths: ReadonlyArray<string>): ReadonlyArray<string> {\n  return paths.map((filePath) => path.basename(filePath, '.js')).filter((x) => x !== 'index')\n}\n\nfunction makeSingleModule(C: FileSystem): (module: string) => TE.TaskEither<Error, void> {\n  return (m) =>\n    pipe(\n      C.mkdir(path.join(OUTPUT_FOLDER, m)),\n      TE.flatMap(() => makePkgJson(m)),\n      TE.flatMap((data) => C.writeFile(path.join(OUTPUT_FOLDER, m, 'package.json'), data))\n    )\n}\n\nfunction makePkgJson(module: string): TE.TaskEither<Error, string> {\n  return pipe(\n    JSON.stringify(\n      {\n        main: `../lib/${module}.js`,\n        module: `../es6/${module}.js`,\n        typings: module === 'HKT' ? `../HKT.d.ts` : `../lib/${module}.d.ts`,\n        sideEffects: false\n      },\n      null,\n      2\n    ),\n    TE.right\n  )\n}\n\nconst fixHKT = (folder: string): Build<void> =>\n  pipe(\n    (C: FileSystem) => C.mkdir(path.join(OUTPUT_FOLDER, folder, 'HKT')),\n    RTE.flatMap(\n      (): Build<void> => (C) =>\n        C.writeFile(\n          path.join(OUTPUT_FOLDER, folder, 'HKT', 'package.json'),\n          JSON.stringify({ typings: '../../HKT.d.ts' }, null, 2)\n        )\n    ),\n    RTE.flatMap(\n      (): Build<void> => (C) =>\n        C.moveFile(path.join(OUTPUT_FOLDER, folder, 'HKT.js'), path.join(OUTPUT_FOLDER, folder, 'HKT', 'index.js'))\n    ),\n    RTE.flatMap(\n      (): Build<void> => (C) =>\n        C.moveFile(path.join(OUTPUT_FOLDER, folder, 'HKT.d.ts'), path.join(OUTPUT_FOLDER, 'HKT.d.ts'))\n    )\n  )\n\nconst main: Build<void> = pipe(\n  copyPackageJson,\n  RTE.flatMap(() => copyFiles),\n  RTE.flatMap(() => makeModules),\n  RTE.flatMap(() => fixHKT('es6')),\n  RTE.flatMap(() => fixHKT('lib'))\n)\n\nrun(\n  main({\n    ...fileSystem\n  })\n)\n"
  },
  {
    "path": "scripts/linter.ts",
    "content": "import * as glob from 'glob'\nimport * as path from 'path'\nimport * as ast from 'ts-morph'\n\nimport { pipe } from '../src/function'\nimport * as M from '../src/Monoid'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport * as string from '../src/string'\n\n// -------------------------------------------------------------------------------------\n// domain\n// -------------------------------------------------------------------------------------\n\nexport interface Overloadings {\n  readonly _tag: 'Overloadings'\n  readonly signatures: ReadonlyArray<Signature>\n}\n\nexport interface TypeParameter {\n  readonly name: string\n  readonly constraint: O.Option<Type>\n}\n\nexport interface Parameter {\n  readonly name: string\n  readonly type: Type\n}\n\nexport interface Signature {\n  readonly _tag: 'Signature'\n  readonly typeParameters: ReadonlyArray<TypeParameter>\n  readonly parameters: ReadonlyArray<Parameter>\n  readonly returnType: Type\n}\n\nexport interface TypeReference {\n  readonly _tag: 'TypeReference'\n  readonly name: string\n  readonly typeArguments: ReadonlyArray<Type>\n}\n\nexport interface InferType {\n  readonly _tag: 'InferType'\n  readonly typeParameter: Type\n}\n\nexport interface Token {\n  readonly _tag: 'Token'\n}\n\nexport interface TypeOperator {\n  readonly _tag: 'TypeOperator'\n  readonly type: Type\n}\n\nexport interface MappedType {\n  readonly _tag: 'MappedType'\n  readonly typeParameter: Type\n  readonly type: O.Option<Type>\n}\n\nexport interface UnionType {\n  readonly _tag: 'UnionType'\n  readonly members: ReadonlyArray<Type>\n}\n\nexport interface TypeParameterDeclaration {\n  readonly _tag: 'TypeParameterDeclaration'\n  readonly name: string\n  readonly constraint: O.Option<Type>\n}\n\nexport interface ConditionalType {\n  readonly _tag: 'ConditionalType'\n  readonly checkType: Type\n  readonly extendsType: Type\n  readonly trueType: Type\n  readonly falseType: Type\n}\n\nexport interface IndexedAccessType {\n  readonly _tag: 'IndexedAccessType'\n  readonly objectType: Type\n  readonly indexType: Type\n}\n\nexport interface TupleType {\n  readonly _tag: 'TupleType'\n  readonly elements: ReadonlyArray<Type>\n}\n\nexport interface RestType {\n  readonly _tag: 'RestType'\n  readonly type: Type\n}\n\nexport interface LiteralType {\n  readonly _tag: 'LiteralType'\n}\n\nexport interface IntersectionType {\n  readonly _tag: 'IntersectionType'\n  readonly members: ReadonlyArray<Type>\n}\n\nexport type Type =\n  | Signature\n  | Overloadings\n  | TypeReference\n  | Token\n  | TypeOperator\n  | MappedType\n  | TypeParameterDeclaration\n  | UnionType\n  | ConditionalType\n  | IndexedAccessType\n  | TupleType\n  | RestType\n  | LiteralType\n  | IntersectionType\n  | InferType\n\nexport interface FunctionDeclaration {\n  readonly name: string\n  readonly overloadings: ReadonlyArray<Signature>\n}\n\nexport interface File {\n  readonly name: string\n  readonly functions: ReadonlyArray<FunctionDeclaration>\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\nexport const signature = (input: {\n  readonly typeParameters: ReadonlyArray<TypeParameter>\n  readonly parameters: ReadonlyArray<Parameter>\n  readonly returnType: Type\n}): Signature => ({\n  _tag: 'Signature',\n  typeParameters: input.typeParameters,\n  parameters: input.parameters,\n  returnType: input.returnType\n})\n\n// -------------------------------------------------------------------------------------\n// parsers\n// -------------------------------------------------------------------------------------\n\nconst ensureReadonlyArray = <A>(as: ReadonlyArray<A> | undefined): ReadonlyArray<A> => (as ? as : RA.empty)\n\nexport function parseType(\n  node: ast.ts.TypeNode | ast.ts.TypeParameterDeclaration | ast.ts.CallSignatureDeclaration\n): Type {\n  if (ast.ts.isTypeReferenceNode(node)) {\n    return {\n      _tag: 'TypeReference',\n      name: node.typeName.getText(),\n      typeArguments: pipe(node.typeArguments, ensureReadonlyArray, RA.map(parseType))\n    }\n  }\n  if (ast.ts.isFunctionTypeNode(node) || ast.ts.isCallSignatureDeclaration(node)) {\n    if (node.type === undefined) {\n      throw new Error(`(parseType) not sure what to do with ${node.getText()}`)\n    }\n    return signature({\n      typeParameters: pipe(node.typeParameters, ensureReadonlyArray, RA.map(parseTypeParameter)),\n      parameters: pipe(node.parameters, RA.map(parseParameterDeclaration)),\n      returnType: parseType(node.type)\n    })\n  }\n  if (ast.ts.isToken(node)) {\n    return { _tag: 'Token' }\n  }\n  if (ast.ts.isTypeOperatorNode(node)) {\n    return { _tag: 'TypeOperator', type: parseType(node.type) }\n  }\n  if (ast.ts.isMappedTypeNode(node)) {\n    return {\n      _tag: 'MappedType',\n      typeParameter: parseType(node.typeParameter),\n      type: pipe(node.type, O.fromNullable, O.map(parseType))\n    }\n  }\n  if (ast.ts.isUnionTypeNode(node)) {\n    return { _tag: 'UnionType', members: pipe(node.types, RA.map(parseType)) }\n  }\n  if (ast.ts.isTypeParameterDeclaration(node)) {\n    return {\n      _tag: 'TypeParameterDeclaration',\n      name: node.name.getText(),\n      constraint: pipe(node.constraint, O.fromNullable, O.map(parseType))\n    }\n  }\n  if (ast.ts.isConditionalTypeNode(node)) {\n    return {\n      _tag: 'ConditionalType',\n      checkType: parseType(node.checkType),\n      extendsType: parseType(node.extendsType),\n      trueType: parseType(node.trueType),\n      falseType: parseType(node.falseType)\n    }\n  }\n  if (ast.ts.isIndexedAccessTypeNode(node)) {\n    return { _tag: 'IndexedAccessType', objectType: parseType(node.objectType), indexType: parseType(node.indexType) }\n  }\n  if (ast.ts.isTupleTypeNode(node)) {\n    return { _tag: 'TupleType', elements: pipe(node.elements, RA.map(parseType)) }\n  }\n  if (ast.ts.isRestTypeNode(node)) {\n    return { _tag: 'RestType', type: parseType(node.type) }\n  }\n  if (ast.ts.isLiteralTypeNode(node)) {\n    return { _tag: 'LiteralType' }\n  }\n  if (ast.ts.isTypeLiteralNode(node)) {\n    const members = node.members.filter(ast.ts.isCallSignatureDeclaration)\n    const signatures = pipe(members, RA.map(parseType)) as ReadonlyArray<Signature>\n    return { _tag: 'Overloadings', signatures }\n  }\n  if (ast.ts.isNamedTupleMember(node)) {\n    return parseType(node.type)\n  }\n  if (ast.ts.isTypePredicateNode(node)) {\n    if (node.type === undefined) {\n      throw new Error(`(parseType) not sure what to do with ${node.getText()}`)\n    }\n    return parseType(node.type)\n  }\n  if (ast.ts.isIntersectionTypeNode(node)) {\n    return { _tag: 'IntersectionType', members: pipe(node.types, RA.map(parseType)) }\n  }\n  if (ast.ts.isParenthesizedTypeNode(node)) {\n    return parseType(node.type)\n  }\n  if (ast.ts.isInferTypeNode(node)) {\n    return { _tag: 'InferType', typeParameter: parseType(node.typeParameter) }\n  }\n  throw new Error(`(parseType) not sure what to do with ${node.getText()}`)\n}\n\nexport const parseTypeParameter = (tp: ast.ts.TypeParameterDeclaration): TypeParameter => {\n  return {\n    name: tp.name.getText(),\n    constraint: pipe(tp.constraint, O.fromNullable, O.map(parseType))\n  }\n}\n\nexport const parseParameterDeclaration = (pd: ast.ts.ParameterDeclaration): Parameter => {\n  if (pd.type === undefined) {\n    throw new Error(`(parseParameterDeclaration) not sure what to do with ${pd.getText()} in ${pd.parent.getText()}`)\n  }\n  return {\n    name: pd.name.getText(),\n    type: parseType(pd.type)\n  }\n}\n\nexport const parseSignature = (\n  node: ast.ts.FunctionDeclaration | ast.ts.CallSignatureDeclaration | ast.ts.FunctionTypeNode\n): Signature => {\n  if (node.type === undefined) {\n    throw new Error(`(parseSignature) not sure what to do with ${node.getText()}`)\n  }\n  return signature({\n    typeParameters: pipe(node.typeParameters, ensureReadonlyArray, RA.map(parseTypeParameter)),\n    parameters: pipe(node.parameters, RA.map(parseParameterDeclaration)),\n    returnType: parseType(node.type)\n  })\n}\n\nexport const parseFunctionDeclaration = (fd: ast.FunctionDeclaration): FunctionDeclaration => {\n  const name = fd.getName()!\n  return {\n    name,\n    overloadings: pipe(\n      [...fd.getOverloads(), fd],\n      RA.map((fd) => parseSignature(fd.compilerNode))\n    )\n  }\n}\n\nexport const parseInterface = (i: ast.InterfaceDeclaration): ReadonlyArray<FunctionDeclaration> => {\n  const name = i.getName()\n  const members = i.compilerNode.members\n  // CallSignatureDeclaration\n  const csds = pipe(members, RA.filter(ast.ts.isCallSignatureDeclaration), RA.map(parseSignature))\n  const csdsfd = pipe(\n    csds,\n    RA.match<ReadonlyArray<FunctionDeclaration>, Signature>(\n      () => RA.empty,\n      (signatures) => [{ name, overloadings: signatures }]\n    )\n  )\n  // PropertySignature\n  const pss: ReadonlyArray<FunctionDeclaration> = pipe(\n    members,\n    RA.filter(ast.ts.isPropertySignature),\n    RA.filterMap((ps) => {\n      const type = parseType(ps.type!)\n      switch (type._tag) {\n        case 'Overloadings':\n          return O.some({ name: `${name}/${ps.name.getText()}`, overloadings: type.signatures })\n        case 'Signature':\n          return O.some({ name: `${name}/${ps.name.getText()}`, overloadings: [type] })\n        case 'TypeReference':\n        case 'LiteralType':\n        case 'Token':\n          return O.none\n      }\n      throw new Error(`(parseInterface (interface: ${name})) not sure what to do with ${type._tag}`)\n    })\n  )\n  return pipe(csdsfd, RA.concat(pss))\n}\n\nexport const parseArrowFunction = (node: ast.ts.ArrowFunction): ReadonlyArray<Signature> => {\n  return pipe(\n    node.type,\n    O.fromNullable,\n    O.match(\n      () => {\n        // example: export const makeBy = <A>(f: (i: number) => A) => (n: number): ReadonlyArray<A> => (n <= 0 ? empty : RNEA.makeBy(f)(n))\n        const body = node.body\n        if (ast.ts.isArrowFunction(body)) {\n          return pipe(\n            parseArrowFunction(body),\n            RA.map((returnType) => {\n              return signature({\n                typeParameters: pipe(node.typeParameters, ensureReadonlyArray, RA.map(parseTypeParameter)),\n                parameters: pipe(node.parameters, RA.map(parseParameterDeclaration)),\n                returnType\n              })\n            })\n          )\n        }\n        throw new Error(`(parseArrowFunction not sure what to do with ${body.getText()}`)\n      },\n      (returnType) => {\n        // example: export const replicate = <A>(a: A): ((n: number) => ReadonlyArray<A>) => makeBy(() => a)\n        return [\n          signature({\n            typeParameters: pipe(node.typeParameters, ensureReadonlyArray, RA.map(parseTypeParameter)),\n            parameters: pipe(node.parameters, RA.map(parseParameterDeclaration)),\n            returnType: parseType(returnType)\n          })\n        ]\n      }\n    )\n  )\n}\n\nexport const parseVariableDeclaration = (vd: ast.VariableDeclaration): ReadonlyArray<FunctionDeclaration> => {\n  const compilerNode = vd.compilerNode\n  const type = compilerNode.type\n  const name = compilerNode.name.getText()\n  const initializer = compilerNode.initializer\n  if (initializer === undefined) {\n    return RA.empty\n  }\n  if (type !== undefined) {\n    if (ast.ts.isTypeReferenceNode(type)) {\n      // example: export const fromOption: NaturalTransformation11<OURI, URI> = (ma) => (_.isNone(ma) ? empty : [ma.value])\n      return RA.empty\n    }\n    if (ast.ts.isIndexedAccessTypeNode(type)) {\n      // example: export const fromEither: FromEither1<URI>['fromEither'] = (e) => (_.isLeft(e) ? empty : [e.right])\n      return RA.empty\n    }\n    if (ast.ts.isFunctionTypeNode(type)) {\n      // example: export const zip: <B>(bs: ReadonlyArray<B>) => <A>(as: ReadonlyArray<A>) => ReadonlyArray<readonly [A, B]> = (bs) => zipWith(bs, (a, b) => [a, b])\n      return [{ name, overloadings: [parseSignature(type)] }]\n    }\n    if (ast.ts.isTypeLiteralNode(type)) {\n      const members = type.members.filter(ast.ts.isCallSignatureDeclaration)\n      const overloadings = pipe(members, RA.map(parseType)) as ReadonlyArray<Signature>\n      return [{ name, overloadings }]\n    }\n    if (ast.ts.isIntersectionTypeNode(type)) {\n      return RA.empty\n    }\n    if (ast.ts.isTypeOperatorNode(type)) {\n      return RA.empty\n    }\n    if (ast.ts.isTypeQueryNode(type)) {\n      return RA.empty\n    }\n    throw new Error(`(parseVariableDeclaration) not sure what to do with ${vd.getFullText()}`)\n  }\n  if (ast.ts.isArrowFunction(initializer)) {\n    return [{ name, overloadings: parseArrowFunction(initializer) }]\n  }\n  return RA.empty\n}\n\nexport const parseFile = (src: ast.SourceFile): File => {\n  const name = path.basename(src.getFilePath())\n  const functions = pipe(\n    src.getFunctions(),\n    RA.filter((fd) => fd.isExported()),\n    RA.map(parseFunctionDeclaration),\n    RA.concat(pipe(src.getInterfaces(), RA.flatMap(parseInterface))),\n    RA.concat(\n      pipe(\n        src.getVariableDeclarations(),\n        RA.filter((vd) => vd.isExported()),\n        RA.flatMap(parseVariableDeclaration)\n      )\n    )\n  )\n  return {\n    name,\n    functions\n  }\n}\n\n// -------------------------------------------------------------------------------------\n// linters\n// -------------------------------------------------------------------------------------\n\nexport interface Lint {\n  readonly path: string\n  readonly typeParameters: ReadonlyArray<string>\n  readonly typeArguments: ReadonlyArray<string>\n}\n\nexport const lint = (\n  path: string,\n  typeParameters: ReadonlyArray<string>,\n  typeArguments: ReadonlyArray<string>\n): Lint => ({ path, typeParameters, typeArguments })\n\nconst LintMonoid: M.Monoid<Lint> = M.struct({\n  path: string.Monoid,\n  typeParameters: RA.getMonoid(),\n  typeArguments: RA.getMonoid()\n})\n\nexport const append =\n  (bs: ReadonlyArray<Lint>) =>\n  (a: Lint): ReadonlyArray<Lint> => {\n    return pipe(\n      bs,\n      RA.match(\n        () => [a],\n        RA.map((b) => LintMonoid.concat(a, b))\n      )\n    )\n  }\n\nexport const getTypeParameters = (type: Type): ReadonlyArray<string> => {\n  switch (type._tag) {\n    case 'TypeReference':\n      return RA.empty\n  }\n  throw new Error(`(getTypeParameters) not sure what to do with ${type._tag}`)\n}\n\nexport const getTypeArguments = (type: Type): ReadonlyArray<string> => {\n  switch (type._tag) {\n    case 'TypeReference':\n      return pipe(\n        type.typeArguments,\n        RA.match(\n          () => [type.name],\n          (types) => pipe([type.name], RA.concat(pipe(types, RA.flatMap(getTypeArguments))))\n        )\n      )\n    case 'Signature': {\n      const typeParameters = pipe(\n        type.typeParameters,\n        RA.flatMap((tp) =>\n          pipe(\n            tp.constraint,\n            O.map((t) => pipe(getTypeArguments(t), RA.prepend(tp.name))),\n            O.getOrElse<ReadonlyArray<string>>(() => [tp.name])\n          )\n        )\n      )\n      const typeArguments = pipe(\n        type.parameters,\n        RA.flatMap((p) => getTypeArguments(p.type))\n      )\n      return pipe(typeParameters, RA.concat(typeArguments), RA.concat(getTypeArguments(type.returnType)))\n    }\n    case 'TypeOperator':\n    case 'RestType':\n      return getTypeArguments(type.type)\n    case 'MappedType':\n      return pipe(\n        type.type,\n        O.map(getTypeArguments),\n        O.getOrElse<ReadonlyArray<string>>(() => RA.empty)\n      )\n    case 'ConditionalType':\n      return pipe(\n        getTypeArguments(type.checkType),\n        RA.concat(getTypeArguments(type.extendsType)),\n        RA.concat(getTypeArguments(type.trueType)),\n        RA.concat(getTypeArguments(type.falseType))\n      )\n    case 'IndexedAccessType':\n      return pipe(getTypeArguments(type.objectType), RA.concat(getTypeArguments(type.indexType)))\n    case 'TupleType':\n      return pipe(type.elements, RA.flatMap(getTypeArguments))\n    case 'LiteralType':\n    case 'Token':\n      return RA.empty\n    case 'UnionType':\n    case 'IntersectionType':\n      return pipe(type.members, RA.flatMap(getTypeArguments))\n    case 'Overloadings':\n      return pipe(type.signatures, RA.flatMap(getTypeArguments))\n    case 'InferType':\n      return getTypeArguments(type.typeParameter)\n    case 'TypeParameterDeclaration':\n      return pipe(\n        type.constraint,\n        O.map(getTypeArguments),\n        O.getOrElse<ReadonlyArray<string>>(() => RA.empty)\n      )\n  }\n  // throw new Error(`(getTypeArguments) not sure what to do with ${type._tag}`)\n}\n\nexport const lintType = (type: Type, path: string = string.empty): ReadonlyArray<Lint> => {\n  switch (type._tag) {\n    case 'TypeReference':\n      return [pipe(lint(path, getTypeParameters(type), getTypeArguments(type)))]\n    case 'Signature':\n      return lintSignature(path, type)\n    case 'Overloadings':\n      return pipe(\n        type.signatures,\n        RA.flatMap((t, i) => lintType(t, `/${String(i)}`))\n      )\n    case 'TypeOperator':\n      return lintType(type.type, path)\n    case 'TupleType':\n      return pipe(\n        type.elements,\n        RA.flatMap((t) => lintType(t, path))\n      )\n    case 'IndexedAccessType':\n      return pipe(lintType(type.objectType, path), RA.concat(lintType(type.indexType, path)))\n    case 'LiteralType':\n    case 'Token':\n      return RA.empty\n    case 'UnionType':\n    case 'IntersectionType':\n      return pipe(\n        type.members,\n        RA.flatMap((t) => lintType(t, path))\n      )\n    case 'ConditionalType':\n      return pipe(\n        lintType(type.checkType),\n        RA.concat(lintType(type.extendsType)),\n        RA.concat(lintType(type.trueType)),\n        RA.concat(lintType(type.falseType))\n      )\n    case 'MappedType':\n      return pipe(\n        type.type,\n        O.map(lintType),\n        O.getOrElse<ReadonlyArray<Lint>>(() => RA.empty)\n      )\n  }\n  throw new Error(`(lintType) not sure what to do with ${type._tag}`)\n}\n\nexport const lintSignature = (path: string, s: Signature): ReadonlyArray<Lint> => {\n  return pipe(\n    lint(\n      path,\n      pipe(\n        s.typeParameters,\n        RA.map((tp) => tp.name)\n      ),\n      pipe(\n        s.parameters,\n        RA.flatMap((p) => getTypeArguments(p.type))\n      )\n    ),\n    append(lintType(s.returnType))\n  )\n}\n\nexport const lintFunction = (filename: string, fd: FunctionDeclaration): ReadonlyArray<Lint> => {\n  return pipe(\n    fd.overloadings,\n    RA.flatMap((s, i) => lintSignature(`${filename}/${fd.name}/${i}`, s))\n  )\n}\n\nexport const lintFile = (file: File): ReadonlyArray<Lint> => {\n  const functions = file.functions\n  return pipe(\n    functions,\n    RA.flatMap((f) => lintFunction(file.name, f))\n  )\n}\n\nconst eq = RA.getEq(string.Eq)\nconst intersection = RA.intersection(string.Eq)\nconst uniq = RA.uniq(string.Eq)\n\nexport const check = (lints: ReadonlyArray<Lint>): ReadonlyArray<string> => {\n  return pipe(\n    lints,\n    RA.map((l) => ({\n      path: l.path,\n      typeParameters: l.typeParameters,\n      typeArguments: pipe(l.typeArguments, intersection(l.typeParameters), uniq)\n    }))\n  )\n    .filter((l) => !eq.equals(l.typeParameters, l.typeArguments))\n    .map(\n      (l) => `Type Parameter Order Error in ${l.path}: ${l.typeParameters.join(', ')} !== ${l.typeArguments.join(', ')}`\n    )\n}\n\n// -------------------------------------------------------------------------------------\n// main\n// -------------------------------------------------------------------------------------\n\nexport const compilerOptions: ast.ProjectOptions['compilerOptions'] = {\n  strict: true\n}\n\nexport const project = new ast.Project({\n  compilerOptions\n})\n\nexport const paths = glob.sync('src/**/*.ts')\npaths.forEach((path) => project.addSourceFileAtPath(path))\nconst files = pipe(project.getSourceFiles(), RA.map(parseFile))\nconst checks = pipe(\n  files,\n  RA.flatMap((f) => check(lintFile(f)))\n)\nif (checks.length > 0) {\n  // tslint:disable-next-line: no-console\n  console.log(JSON.stringify(checks, null, 2))\n}\n\n// project.addSourceFileAtPath('src/Bounded.ts')\n// export const file = parseFile(project.getSourceFiles()[0])\n// console.log(JSON.stringify(check(lintFile(file)), null, 2))\n"
  },
  {
    "path": "scripts/pre-publish.ts",
    "content": "import { left } from '../src/TaskEither'\nimport { run } from './run'\n\nconst main = left(new Error('\"npm publish\" can not be run from root, run \"npm run release\" instead'))\n\nrun(main)\n"
  },
  {
    "path": "scripts/release.ts",
    "content": "import * as child_process from 'child_process'\n\nimport { left, right } from '../src/Either'\nimport * as TE from '../src/TaskEither'\nimport { run } from './run'\n\nconst DIST = 'dist'\n\nconst exec =\n  (cmd: string, args?: child_process.ExecOptions): TE.TaskEither<Error, void> =>\n  () =>\n    new Promise((resolve) => {\n      child_process.exec(cmd, args, (err) => {\n        if (err !== null) {\n          return resolve(left(err))\n        }\n\n        return resolve(right(undefined))\n      })\n    })\n\nexport const main = exec('npm publish', {\n  cwd: DIST\n})\n\nrun(main)\n"
  },
  {
    "path": "scripts/run.ts",
    "content": "import { fold } from '../src/Either'\nimport { TaskEither } from '../src/TaskEither'\n\nexport function run<A>(eff: TaskEither<Error, A>): void {\n  eff()\n    .then(\n      fold(\n        (e) => {\n          throw e\n        },\n        (_) => {\n          process.exitCode = 0\n        }\n      )\n    )\n    .catch((e) => {\n      console.error(e) // tslint:disable-line no-console\n\n      process.exitCode = 1\n    })\n}\n"
  },
  {
    "path": "src/Alt.ts",
    "content": "/**\n * The `Alt` type class identifies an associative operation on a type constructor.  It is similar to `Semigroup`, except\n * that it applies to types of kind `* -> *`, like `Array` or `Option`, rather than concrete types like `string` or\n * `number`.\n *\n * `Alt` instances are required to satisfy the following laws:\n *\n * 1. Associativity: `A.alt(A.alt(fa, ga), ha) <-> A.alt(fa, A.alt(ga, ha))`\n * 2. Distributivity: `A.map(A.alt(fa, ga), ab) <-> A.alt(A.map(fa, ab), A.map(ga, ab))`\n *\n * @since 2.0.0\n */\nimport { LazyArg } from './function'\nimport { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C, Functor4 } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alt<F> extends Functor<F> {\n  readonly alt: <A>(fa: HKT<F, A>, that: LazyArg<HKT<F, A>>) => HKT<F, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alt1<F extends URIS> extends Functor1<F> {\n  readonly alt: <A>(fa: Kind<F, A>, that: LazyArg<Kind<F, A>>) => Kind<F, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alt2<F extends URIS2> extends Functor2<F> {\n  readonly alt: <E, A>(fa: Kind2<F, E, A>, that: LazyArg<Kind2<F, E, A>>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alt2C<F extends URIS2, E> extends Functor2C<F, E> {\n  readonly alt: <A>(fa: Kind2<F, E, A>, that: LazyArg<Kind2<F, E, A>>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alt3<F extends URIS3> extends Functor3<F> {\n  readonly alt: <R, E, A>(fa: Kind3<F, R, E, A>, that: LazyArg<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Alt3C<F extends URIS3, E> extends Functor3C<F, E> {\n  readonly alt: <R, A>(fa: Kind3<F, R, E, A>, that: LazyArg<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alt4<F extends URIS4> extends Functor4<F> {\n  readonly alt: <S, R, E, A>(fa: Kind4<F, S, R, E, A>, that: LazyArg<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport function altAll<F extends URIS4>(\n  F: Alt4<F>\n): <S, R, E, A>(startWith: Kind4<F, S, R, E, A>) => (as: ReadonlyArray<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>\nexport function altAll<F extends URIS3>(\n  F: Alt3<F>\n): <R, E, A>(startWith: Kind3<F, R, E, A>) => (as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\nexport function altAll<F extends URIS3, E>(\n  F: Alt3C<F, E>\n): <R, A>(startWith: Kind3<F, R, E, A>) => (as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\nexport function altAll<F extends URIS2>(\n  F: Alt2<F>\n): <E, A>(startWith: Kind2<F, E, A>) => (as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>\nexport function altAll<F extends URIS2, E>(\n  F: Alt2C<F, E>\n): <A>(startWith: Kind2<F, E, A>) => (as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>\nexport function altAll<F extends URIS>(\n  F: Alt1<F>\n): <A>(startWith: Kind<F, A>) => (as: ReadonlyArray<Kind<F, A>>) => Kind<F, A>\nexport function altAll<F>(F: Alt<F>): <A>(startWith: HKT<F, A>) => (as: ReadonlyArray<HKT<F, A>>) => HKT<F, A>\nexport function altAll<F>(F: Alt<F>): <A>(startWith: HKT<F, A>) => (as: ReadonlyArray<HKT<F, A>>) => HKT<F, A> {\n  return (startWith) => (as) => as.reduce((acc, a) => F.alt(acc, () => a), startWith)\n}\n"
  },
  {
    "path": "src/Alternative.ts",
    "content": "/**\n * The `Alternative` type class extends the `Alt` type class with a value that should be the left and right identity for `alt`.\n *\n * It is similar to `Monoid`, except that it applies to types of kind `* -> *`, like `Array` or `Option`, rather than\n * concrete types like `string` or `number`.\n *\n * `Alternative` instances should satisfy the following laws:\n *\n * 1. Left identity: `A.alt(zero, fa) <-> fa`\n * 2. Right identity: `A.alt(fa, zero) <-> fa`\n * 3. Annihilation: `A.map(zero, f) <-> zero`\n * 4. Distributivity: `A.ap(A.alt(fab, gab), fa) <-> A.alt(A.ap(fab, fa), A.ap(gab, fa))`\n * 5. Annihilation: `A.ap(zero, fa) <-> zero`\n *\n * @since 2.0.0\n */\nimport { Alt, Alt1, Alt2, Alt2C, Alt3, Alt3C, Alt4, altAll as altAll_ } from './Alt'\nimport {\n  Applicative,\n  Applicative1,\n  Applicative2,\n  Applicative2C,\n  Applicative3,\n  Applicative3C,\n  Applicative4\n} from './Applicative'\nimport { getApplySemigroup } from './Apply'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Monoid } from './Monoid'\nimport { Semigroup } from './Semigroup'\nimport { Zero, Zero1, Zero2, Zero2C, Zero3, Zero3C, Zero4 } from './Zero'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alternative<F> extends Applicative<F>, Alt<F>, Zero<F> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alternative1<F extends URIS> extends Applicative1<F>, Alt1<F>, Zero1<F> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alternative2<F extends URIS2> extends Applicative2<F>, Alt2<F>, Zero2<F> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alternative2C<F extends URIS2, E> extends Applicative2C<F, E>, Alt2C<F, E>, Zero2C<F, E> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Alternative3<F extends URIS3> extends Applicative3<F>, Alt3<F>, Zero3<F> {}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Alternative3C<F extends URIS3, E> extends Applicative3C<F, E>, Alt3C<F, E>, Zero3C<F, E> {}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Alternative4<F extends URIS4> extends Applicative4<F>, Alt4<F>, Zero4<F> {}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport function altAll<F extends URIS4>(\n  F: Alternative4<F>\n): <S, R, E, A>(as: ReadonlyArray<Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>\nexport function altAll<F extends URIS3>(\n  F: Alternative3<F>\n): <R, E, A>(as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\nexport function altAll<F extends URIS3, E>(\n  F: Alternative3C<F, E>\n): <R, A>(as: ReadonlyArray<Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\nexport function altAll<F extends URIS2>(F: Alternative2<F>): <E, A>(as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>\nexport function altAll<F extends URIS2, E>(\n  F: Alternative2C<F, E>\n): <A>(as: ReadonlyArray<Kind2<F, E, A>>) => Kind2<F, E, A>\nexport function altAll<F extends URIS>(F: Alternative1<F>): <A>(as: ReadonlyArray<Kind<F, A>>) => Kind<F, A>\nexport function altAll<F>(F: Alternative<F>): <A>(as: ReadonlyArray<HKT<F, A>>) => HKT<F, A>\nexport function altAll<F>(F: Alternative<F>): <A>(as: ReadonlyArray<HKT<F, A>>) => HKT<F, A> {\n  return altAll_(F)(F.zero())\n}\n\n/**\n * Lift a semigroup into a monoid alternative 'F', the inner values are concatenated using the provided `Semigroup`.\n * @since 2.13.0\n */\nexport function getAlternativeMonoid<F extends URIS4>(\n  F: Alternative4<F>\n): <A, S, R, E>(S: Semigroup<A>) => Monoid<Kind4<F, S, R, E, A>>\nexport function getAlternativeMonoid<F extends URIS3>(\n  F: Alternative3<F>\n): <A, R, E>(S: Semigroup<A>) => Monoid<Kind3<F, R, E, A>>\nexport function getAlternativeMonoid<F extends URIS3, E>(\n  F: Alternative3C<F, E>\n): <A, R>(S: Semigroup<A>) => Monoid<Kind3<F, R, E, A>>\nexport function getAlternativeMonoid<F extends URIS2>(\n  F: Alternative2<F>\n): <A, E>(S: Semigroup<A>) => Monoid<Kind2<F, E, A>>\nexport function getAlternativeMonoid<F extends URIS2, E>(\n  F: Alternative2C<F, E>\n): <A>(S: Semigroup<A>) => Monoid<Kind2<F, E, A>>\nexport function getAlternativeMonoid<F extends URIS>(F: Alternative1<F>): <A>(S: Semigroup<A>) => Monoid<Kind<F, A>>\nexport function getAlternativeMonoid<F>(F: Alternative<F>): <A>(S: Semigroup<A>) => Monoid<HKT<F, A>>\nexport function getAlternativeMonoid<F>(F: Alternative<F>): <A>(S: Semigroup<A>) => Monoid<HKT<F, A>> {\n  const f = getApplySemigroup(F)\n  return <A>(S: Semigroup<A>) => {\n    const SF = f(S)\n    return {\n      concat: (first: HKT<F, A>, second: HKT<F, A>) =>\n        F.alt(SF.concat(first, second), () => F.alt(first, () => second)),\n      empty: F.zero()\n    }\n  }\n}\n"
  },
  {
    "path": "src/Applicative.ts",
    "content": "/**\n * The `Applicative` type class extends the `Apply` type class with a `of` function, which can be used to create values\n * of type `f a` from values of type `a`.\n *\n * Where `Apply` provides the ability to lift functions of two or more arguments to functions whose arguments are\n * wrapped using `f`, and `Functor` provides the ability to lift functions of one argument, `pure` can be seen as the\n * function which lifts functions of _zero_ arguments. That is, `Applicative` functors support a lifting operation for\n * any number of function arguments.\n *\n * Instances must satisfy the following laws in addition to the `Apply` laws:\n *\n * 1. Identity: `A.ap(A.of(a => a), fa) <-> fa`\n * 2. Homomorphism: `A.ap(A.of(ab), A.of(a)) <-> A.of(ab(a))`\n * 3. Interchange: `A.ap(fab, A.of(a)) <-> A.ap(A.of(ab => ab(a)), fab)`\n *\n * Note. `Functor`'s `map` can be derived: `A.map(x, f) = A.ap(A.of(f), x)`\n *\n * @since 2.0.0\n */\nimport { ap, Apply, Apply1, Apply2, Apply2C, Apply3, Apply3C, Apply4, getApplySemigroup } from './Apply'\nimport { pipe } from './function'\nimport {\n  FunctorComposition,\n  FunctorComposition2C1,\n  FunctorComposition11,\n  FunctorComposition12,\n  FunctorComposition12C,\n  FunctorComposition21,\n  FunctorComposition22,\n  FunctorComposition22C,\n  FunctorCompositionHKT1,\n  FunctorCompositionHKT2,\n  FunctorCompositionHKT2C,\n  getFunctorComposition\n} from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Monoid } from './Monoid'\nimport { Pointed, Pointed1, Pointed2, Pointed2C, Pointed3, Pointed3C, Pointed4 } from './Pointed'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Applicative<F> extends Apply<F>, Pointed<F> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Applicative1<F extends URIS> extends Apply1<F>, Pointed1<F> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Applicative2<F extends URIS2> extends Apply2<F>, Pointed2<F> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Applicative2C<F extends URIS2, E> extends Apply2C<F, E>, Pointed2C<F, E> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Applicative3<F extends URIS3> extends Apply3<F>, Pointed3<F> {}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Applicative3C<F extends URIS3, E> extends Apply3C<F, E>, Pointed3C<F, E> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Applicative4<F extends URIS4> extends Apply4<F>, Pointed4<F> {}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Lift a monoid into 'F', the inner values are concatenated using the provided `Monoid`.\n *\n * @since 2.10.0\n */\nexport function getApplicativeMonoid<F extends URIS4>(\n  F: Applicative4<F>\n): <A, S, R, E>(M: Monoid<A>) => Monoid<Kind4<F, S, R, E, A>>\nexport function getApplicativeMonoid<F extends URIS3>(\n  F: Applicative3<F>\n): <A, R, E>(M: Monoid<A>) => Monoid<Kind3<F, R, E, A>>\nexport function getApplicativeMonoid<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <A, R>(M: Monoid<A>) => Monoid<Kind3<F, R, E, A>>\nexport function getApplicativeMonoid<F extends URIS2>(\n  F: Applicative2<F>\n): <A, E>(M: Monoid<A>) => Monoid<Kind2<F, E, A>>\nexport function getApplicativeMonoid<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <A>(M: Monoid<A>) => Monoid<Kind2<F, E, A>>\nexport function getApplicativeMonoid<F extends URIS>(F: Applicative1<F>): <A>(M: Monoid<A>) => Monoid<Kind<F, A>>\nexport function getApplicativeMonoid<F>(F: Applicative<F>): <A>(M: Monoid<A>) => Monoid<HKT<F, A>>\nexport function getApplicativeMonoid<F>(F: Applicative<F>): <A>(M: Monoid<A>) => Monoid<HKT<F, A>> {\n  const f = getApplySemigroup(F)\n  return <A>(M: Monoid<A>) => ({\n    concat: f(M).concat,\n    empty: F.of(M.empty)\n  })\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeComposition<F, G> extends FunctorComposition<F, G> {\n  readonly of: <A>(a: A) => HKT<F, HKT<G, A>>\n  readonly ap: <A, B>(fgab: HKT<F, HKT<G, (a: A) => B>>, fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeCompositionHKT1<F, G extends URIS> extends FunctorCompositionHKT1<F, G> {\n  readonly of: <A>(a: A) => HKT<F, Kind<G, A>>\n  readonly ap: <A, B>(fgab: HKT<F, Kind<G, (a: A) => B>>, fga: HKT<F, Kind<G, A>>) => HKT<F, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeCompositionHKT2<F, G extends URIS2> extends FunctorCompositionHKT2<F, G> {\n  readonly of: <E, A>(a: A) => HKT<F, Kind2<G, E, A>>\n  readonly ap: <E, A, B>(fgab: HKT<F, Kind2<G, E, (a: A) => B>>, fga: HKT<F, Kind2<G, E, A>>) => HKT<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeCompositionHKT2C<F, G extends URIS2, E> extends FunctorCompositionHKT2C<F, G, E> {\n  readonly of: <A>(a: A) => HKT<F, Kind2<G, E, A>>\n  readonly ap: <A, B>(fgab: HKT<F, Kind2<G, E, (a: A) => B>>, fga: HKT<F, Kind2<G, E, A>>) => HKT<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeComposition11<F extends URIS, G extends URIS> extends FunctorComposition11<F, G> {\n  readonly of: <A>(a: A) => Kind<F, Kind<G, A>>\n  readonly ap: <A, B>(fgab: Kind<F, Kind<G, (a: A) => B>>, fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeComposition12<F extends URIS, G extends URIS2> extends FunctorComposition12<F, G> {\n  readonly of: <E, A>(a: A) => Kind<F, Kind2<G, E, A>>\n  readonly ap: <E, A, B>(\n    fgab: Kind<F, Kind2<G, E, (a: A) => B>>,\n    fga: Kind<F, Kind2<G, E, A>>\n  ) => Kind<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeComposition12C<F extends URIS, G extends URIS2, E> extends FunctorComposition12C<F, G, E> {\n  readonly of: <A>(a: A) => Kind<F, Kind2<G, E, A>>\n  readonly ap: <A, B>(fgab: Kind<F, Kind2<G, E, (a: A) => B>>, fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeComposition21<F extends URIS2, G extends URIS> extends FunctorComposition21<F, G> {\n  readonly of: <E, A>(a: A) => Kind2<F, E, Kind<G, A>>\n  readonly ap: <E, A, B>(\n    fgab: Kind2<F, E, Kind<G, (a: A) => B>>,\n    fga: Kind2<F, E, Kind<G, A>>\n  ) => Kind2<F, E, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeComposition2C1<F extends URIS2, G extends URIS, E> extends FunctorComposition2C1<F, G, E> {\n  readonly of: <A>(a: A) => Kind2<F, E, Kind<G, A>>\n  readonly ap: <A, B>(fgab: Kind2<F, E, Kind<G, (a: A) => B>>, fga: Kind2<F, E, Kind<G, A>>) => Kind2<F, E, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeComposition22<F extends URIS2, G extends URIS2> extends FunctorComposition22<F, G> {\n  readonly of: <FE, GE, A>(a: A) => Kind2<F, FE, Kind2<G, GE, A>>\n  readonly ap: <FE, GE, A, B>(\n    fgab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>,\n    fga: Kind2<F, FE, Kind2<G, GE, A>>\n  ) => Kind2<F, FE, Kind2<G, GE, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ApplicativeComposition22C<F extends URIS2, G extends URIS2, E> extends FunctorComposition22C<F, G, E> {\n  readonly of: <FE, A>(a: A) => Kind2<F, FE, Kind2<G, E, A>>\n  readonly ap: <FE, A, B>(\n    fgab: Kind2<F, FE, Kind2<G, E, (a: A) => B>>,\n    fga: Kind2<F, FE, Kind2<G, E, A>>\n  ) => Kind2<F, FE, Kind2<G, E, B>>\n}\n\n/**\n * Use [`ap`](./Apply.ts.html#ap) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getApplicativeComposition<F extends URIS2, G extends URIS2, E>(\n  F: Applicative2<F>,\n  G: Applicative2C<G, E>\n): ApplicativeComposition22C<F, G, E>\n/** @deprecated */\nexport function getApplicativeComposition<F extends URIS2, G extends URIS2>(\n  F: Applicative2<F>,\n  G: Applicative2<G>\n): ApplicativeComposition22<F, G>\n/** @deprecated */\nexport function getApplicativeComposition<F extends URIS2, G extends URIS2, E>(\n  F: Applicative2<F>,\n  G: Applicative2C<G, E>\n): ApplicativeComposition22C<F, G, E>\n/** @deprecated */\nexport function getApplicativeComposition<F extends URIS2, G extends URIS>(\n  F: Applicative2<F>,\n  G: Applicative1<G>\n): ApplicativeComposition21<F, G>\n/** @deprecated */\nexport function getApplicativeComposition<F extends URIS, G extends URIS2>(\n  F: Applicative1<F>,\n  G: Applicative2<G>\n): ApplicativeComposition12<F, G>\n/** @deprecated */\nexport function getApplicativeComposition<F extends URIS, G extends URIS2, E>(\n  F: Applicative1<F>,\n  G: Applicative2C<G, E>\n): ApplicativeComposition12C<F, G, E>\n/** @deprecated */\nexport function getApplicativeComposition<F extends URIS, G extends URIS>(\n  F: Applicative1<F>,\n  G: Applicative1<G>\n): ApplicativeComposition11<F, G>\n/** @deprecated */\nexport function getApplicativeComposition<F, G extends URIS2>(\n  F: Applicative<F>,\n  G: Applicative2<G>\n): ApplicativeCompositionHKT2<F, G>\n/** @deprecated */\nexport function getApplicativeComposition<F, G extends URIS2, E>(\n  F: Applicative<F>,\n  G: Applicative2C<G, E>\n): ApplicativeCompositionHKT2C<F, G, E>\n/** @deprecated */\nexport function getApplicativeComposition<F, G extends URIS>(\n  F: Applicative<F>,\n  G: Applicative1<G>\n): ApplicativeCompositionHKT1<F, G>\n/** @deprecated */\nexport function getApplicativeComposition<F, G>(F: Applicative<F>, G: Applicative<G>): ApplicativeComposition<F, G>\n/** @deprecated */\nexport function getApplicativeComposition<F, G>(F: Applicative<F>, G: Applicative<G>): ApplicativeComposition<F, G> {\n  const map = getFunctorComposition(F, G).map\n  const _ap = ap(F, G)\n  return {\n    map,\n    of: (a) => F.of(G.of(a)),\n    ap: (fgab, fga) => pipe(fgab, _ap(fga))\n  }\n}\n"
  },
  {
    "path": "src/Apply.ts",
    "content": "/**\n * The `Apply` class provides the `ap` which is used to apply a function to an argument under a type constructor.\n *\n * `Apply` can be used to lift functions of two or more arguments to work on values wrapped with the type constructor\n * `f`.\n *\n * Instances must satisfy the following law in addition to the `Functor` laws:\n *\n * 1. Associative composition: `F.ap(F.ap(F.map(fbc, bc => ab => a => bc(ab(a))), fab), fa) <-> F.ap(fbc, F.ap(fab, fa))`\n *\n * Formally, `Apply` represents a strong lax semi-monoidal endofunctor.\n *\n * @example\n * import * as O from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * const f = (a: string) => (b: number) => (c: boolean) => a + String(b) + String(c)\n * const fa: O.Option<string> = O.some('s')\n * const fb: O.Option<number> = O.some(1)\n * const fc: O.Option<boolean> = O.some(true)\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     // lift a function\n *     O.some(f),\n *     // apply the first argument\n *     O.ap(fa),\n *     // apply the second argument\n *     O.ap(fb),\n *     // apply the third argument\n *     O.ap(fc)\n *   ),\n *   O.some('s1true')\n * )\n *\n * @since 2.0.0\n */\nimport { tuple } from './function'\nimport { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C, Functor4 } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport * as _ from './internal'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Apply<F> extends Functor<F> {\n  readonly ap: <A, B>(fab: HKT<F, (a: A) => B>, fa: HKT<F, A>) => HKT<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Apply1<F extends URIS> extends Functor1<F> {\n  readonly ap: <A, B>(fab: Kind<F, (a: A) => B>, fa: Kind<F, A>) => Kind<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Apply2<F extends URIS2> extends Functor2<F> {\n  readonly ap: <E, A, B>(fab: Kind2<F, E, (a: A) => B>, fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Apply2C<F extends URIS2, E> extends Functor2C<F, E> {\n  readonly ap: <A, B>(fab: Kind2<F, E, (a: A) => B>, fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Apply3<F extends URIS3> extends Functor3<F> {\n  readonly ap: <R, E, A, B>(fab: Kind3<F, R, E, (a: A) => B>, fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Apply3C<F extends URIS3, E> extends Functor3C<F, E> {\n  readonly ap: <R, A, B>(fab: Kind3<F, R, E, (a: A) => B>, fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Apply4<F extends URIS4> extends Functor4<F> {\n  readonly ap: <S, R, E, A, B>(fab: Kind4<F, S, R, E, (a: A) => B>, fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * `ap` composition.\n *\n * @since 2.10.0\n */\nexport function ap<F extends URIS4, G extends URIS4>(\n  F: Apply4<F>,\n  G: Apply4<G>\n): <FS, FR, FE, GS, GR, GE, A>(\n  fa: Kind4<F, FS, FR, FE, Kind4<G, GS, GR, GE, A>>\n) => <B>(fab: Kind4<F, FS, FR, FE, Kind4<G, GS, GR, GE, (a: A) => B>>) => Kind4<F, FS, FR, FE, Kind4<G, GS, GR, GE, B>>\nexport function ap<F extends URIS4, G extends URIS3>(\n  F: Apply4<F>,\n  G: Apply3<G>\n): <S, FR, FE, GR, GE, A>(\n  fa: Kind4<F, S, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind4<F, S, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind4<F, S, FR, FE, Kind3<G, GR, GE, B>>\nexport function ap<F extends URIS4, G extends URIS3, GE>(\n  F: Apply4<F>,\n  G: Apply3C<G, GE>\n): <S, FR, FE, GR, A>(\n  fa: Kind4<F, S, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind4<F, S, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind4<F, S, FR, FE, Kind3<G, GR, GE, B>>\nexport function ap<F extends URIS4, G extends URIS2>(\n  F: Apply4<F>,\n  G: Apply2<G>\n): <S, R, FE, GE, A>(\n  fa: Kind4<F, S, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind4<F, S, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind4<F, S, R, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS4, G extends URIS2, GE>(\n  F: Apply4<F>,\n  G: Apply2C<G, GE>\n): <S, R, FE, A>(\n  fa: Kind4<F, S, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind4<F, S, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind4<F, S, R, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS4, G extends URIS>(\n  F: Apply4<F>,\n  G: Apply1<G>\n): <S, R, E, A>(\n  fa: Kind4<F, S, R, E, Kind<G, A>>\n) => <B>(fab: Kind4<F, S, R, E, Kind<G, (a: A) => B>>) => Kind4<F, S, R, E, Kind<G, B>>\nexport function ap<F extends URIS3, FE, G extends URIS4>(\n  F: Apply3C<F, FE>,\n  G: Apply4<G>\n): <FR, S, GR, GE, A>(\n  fa: Kind3<F, FR, FE, Kind4<G, S, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind4<G, S, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind4<G, S, GR, GE, B>>\nexport function ap<F extends URIS3, FE, G extends URIS3>(\n  F: Apply3C<F, FE>,\n  G: Apply3<G>\n): <FR, GR, GE, A>(\n  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>\nexport function ap<F extends URIS3, FE, G extends URIS3, GE>(\n  F: Apply3C<F, FE>,\n  G: Apply3C<G, GE>\n): <FR, GR, A>(\n  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>\nexport function ap<F extends URIS3, FE, G extends URIS2>(\n  F: Apply3C<F, FE>,\n  G: Apply2<G>\n): <R, GE, A>(\n  fa: Kind3<F, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS3, FE, G extends URIS2, GE>(\n  F: Apply3C<F, FE>,\n  G: Apply2C<G, GE>\n): <R, A>(\n  fa: Kind3<F, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS3, E, G extends URIS>(\n  F: Apply3C<F, E>,\n  G: Apply1<G>\n): <R, A>(\n  fa: Kind3<F, R, E, Kind<G, A>>\n) => <B>(fab: Kind3<F, R, E, Kind<G, (a: A) => B>>) => Kind3<F, R, E, Kind<G, B>>\nexport function ap<F extends URIS3, G extends URIS4>(\n  F: Apply3<F>,\n  G: Apply4<G>\n): <FR, FE, S, GR, GE, A>(\n  fa: Kind3<F, FR, FE, Kind4<G, S, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind4<G, S, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind4<G, S, GR, GE, B>>\nexport function ap<F extends URIS3, G extends URIS3>(\n  F: Apply3<F>,\n  G: Apply3<G>\n): <FR, FE, GR, GE, A>(\n  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>\nexport function ap<F extends URIS3, G extends URIS3, GE>(\n  F: Apply3<F>,\n  G: Apply3C<G, GE>\n): <FR, FE, GR, A>(\n  fa: Kind3<F, FR, FE, Kind3<G, GR, GE, A>>\n) => <B>(fab: Kind3<F, FR, FE, Kind3<G, GR, GE, (a: A) => B>>) => Kind3<F, FR, FE, Kind3<G, GR, GE, B>>\nexport function ap<F extends URIS3, G extends URIS2>(\n  F: Apply3<F>,\n  G: Apply2<G>\n): <R, FE, GE, A>(\n  fa: Kind3<F, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS3, G extends URIS2, GE>(\n  F: Apply3<F>,\n  G: Apply2C<G, GE>\n): <R, FE, A>(\n  fa: Kind3<F, R, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind3<F, R, FE, Kind2<G, GE, (a: A) => B>>) => Kind3<F, R, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS3, G extends URIS>(\n  F: Apply3<F>,\n  G: Apply1<G>\n): <R, E, A>(\n  fa: Kind3<F, R, E, Kind<G, A>>\n) => <B>(fab: Kind3<F, R, E, Kind<G, (a: A) => B>>) => Kind3<F, R, E, Kind<G, B>>\nexport function ap<F extends URIS2, FE, G extends URIS4>(\n  F: Apply2C<F, FE>,\n  G: Apply4<G>\n): <S, R, GE, A>(\n  fa: Kind2<F, FE, Kind4<G, S, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind4<G, S, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind4<G, S, R, GE, B>>\nexport function ap<F extends URIS2, FE, G extends URIS3>(\n  F: Apply2C<F, FE>,\n  G: Apply3<G>\n): <R, GE, A>(\n  fa: Kind2<F, FE, Kind3<G, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>\nexport function ap<F extends URIS2, FE, G extends URIS3, GE>(\n  F: Apply2C<F, FE>,\n  G: Apply3C<G, GE>\n): <R, A>(\n  fa: Kind2<F, FE, Kind3<G, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>\nexport function ap<F extends URIS2, FE, G extends URIS2>(\n  F: Apply2C<F, FE>,\n  G: Apply2<G>\n): <GE, A>(\n  fa: Kind2<F, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS2, FE, G extends URIS2, GE>(\n  F: Apply2C<F, FE>,\n  G: Apply2C<G, GE>\n): <A>(\n  fa: Kind2<F, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS2, E, G extends URIS>(\n  F: Apply2C<F, E>,\n  G: Apply1<G>\n): <A>(fa: Kind2<F, E, Kind<G, A>>) => <B>(fab: Kind2<F, E, Kind<G, (a: A) => B>>) => Kind2<F, E, Kind<G, B>>\nexport function ap<F extends URIS2, G extends URIS4>(\n  F: Apply2<F>,\n  G: Apply4<G>\n): <FE, S, R, GE, A>(\n  fa: Kind2<F, FE, Kind4<G, S, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind4<G, S, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind4<G, S, R, GE, B>>\nexport function ap<F extends URIS2, G extends URIS3>(\n  F: Apply2<F>,\n  G: Apply3<G>\n): <FE, R, GE, A>(\n  fa: Kind2<F, FE, Kind3<G, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>\nexport function ap<F extends URIS2, G extends URIS3, GE>(\n  F: Apply2<F>,\n  G: Apply3C<G, GE>\n): <FE, R, A>(\n  fa: Kind2<F, FE, Kind3<G, R, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind3<G, R, GE, (a: A) => B>>) => Kind2<F, FE, Kind3<G, R, GE, B>>\nexport function ap<F extends URIS2, G extends URIS2>(\n  F: Apply2<F>,\n  G: Apply2<G>\n): <FE, GE, A>(\n  fa: Kind2<F, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS2, G extends URIS2, GE>(\n  F: Apply2<F>,\n  G: Apply2C<G, GE>\n): <FE, A>(\n  fa: Kind2<F, FE, Kind2<G, GE, A>>\n) => <B>(fab: Kind2<F, FE, Kind2<G, GE, (a: A) => B>>) => Kind2<F, FE, Kind2<G, GE, B>>\nexport function ap<F extends URIS2, G extends URIS>(\n  F: Apply2<F>,\n  G: Apply1<G>\n): <E, A>(fa: Kind2<F, E, Kind<G, A>>) => <B>(fab: Kind2<F, E, Kind<G, (a: A) => B>>) => Kind2<F, E, Kind<G, B>>\nexport function ap<F extends URIS, G extends URIS4>(\n  F: Apply1<F>,\n  G: Apply4<G>\n): <S, R, E, A>(\n  fa: Kind<F, Kind4<G, S, R, E, A>>\n) => <B>(fab: Kind<F, Kind4<G, S, R, E, (a: A) => B>>) => Kind<F, Kind4<G, S, R, E, B>>\nexport function ap<F extends URIS, G extends URIS3>(\n  F: Apply1<F>,\n  G: Apply3<G>\n): <R, E, A>(\n  fa: Kind<F, Kind3<G, R, E, A>>\n) => <B>(fab: Kind<F, Kind3<G, R, E, (a: A) => B>>) => Kind<F, Kind3<G, R, E, B>>\nexport function ap<F extends URIS, G extends URIS3, E>(\n  F: Apply1<F>,\n  G: Apply3C<G, E>\n): <R, A>(\n  fa: Kind<F, Kind3<G, R, E, A>>\n) => <B>(fab: Kind<F, Kind3<G, R, E, (a: A) => B>>) => Kind<F, Kind3<G, R, E, B>>\nexport function ap<F extends URIS, G extends URIS2>(\n  F: Apply1<F>,\n  G: Apply2<G>\n): <E, A>(fa: Kind<F, Kind2<G, E, A>>) => <B>(fab: Kind<F, Kind2<G, E, (a: A) => B>>) => Kind<F, Kind2<G, E, B>>\nexport function ap<F extends URIS, G extends URIS2, E>(\n  F: Apply1<F>,\n  G: Apply2C<G, E>\n): <A>(fa: Kind<F, Kind2<G, E, A>>) => <B>(fab: Kind<F, Kind2<G, E, (a: A) => B>>) => Kind<F, Kind2<G, E, B>>\nexport function ap<F extends URIS, G extends URIS>(\n  F: Apply1<F>,\n  G: Apply1<G>\n): <A>(fa: Kind<F, Kind<G, A>>) => <B>(fab: Kind<F, Kind<G, (a: A) => B>>) => Kind<F, Kind<G, B>>\nexport function ap<F, G extends URIS4>(\n  F: Apply<F>,\n  G: Apply4<G>\n): <S, R, E, A>(\n  fa: HKT<F, Kind4<G, S, R, E, A>>\n) => <B>(fab: HKT<F, Kind4<G, S, R, E, (a: A) => B>>) => HKT<F, Kind4<G, S, R, E, B>>\nexport function ap<F, G extends URIS3>(\n  F: Apply<F>,\n  G: Apply3<G>\n): <R, E, A>(\n  fa: HKT<F, Kind3<G, R, E, A>>\n) => <B>(fab: HKT<F, Kind3<G, R, E, (a: A) => B>>) => HKT<F, Kind3<G, R, E, B>>\nexport function ap<F, G extends URIS3, E>(\n  F: Apply<F>,\n  G: Apply3C<G, E>\n): <R, A>(fa: HKT<F, Kind3<G, R, E, A>>) => <B>(fab: HKT<F, Kind3<G, R, E, (a: A) => B>>) => HKT<F, Kind3<G, R, E, B>>\nexport function ap<F, G extends URIS2>(\n  F: Apply<F>,\n  G: Apply2<G>\n): <E, A>(fa: HKT<F, Kind2<G, E, A>>) => <B>(fab: HKT<F, Kind2<G, E, (a: A) => B>>) => HKT<F, Kind2<G, E, B>>\nexport function ap<F, G extends URIS2, E>(\n  F: Apply<F>,\n  G: Apply2C<G, E>\n): <A>(fa: HKT<F, Kind2<G, E, A>>) => <B>(fab: HKT<F, Kind2<G, E, (a: A) => B>>) => HKT<F, Kind2<G, E, B>>\nexport function ap<F, G extends URIS>(\n  F: Apply<F>,\n  G: Apply1<G>\n): <A>(fa: HKT<F, Kind<G, A>>) => <B>(fab: HKT<F, Kind<G, (a: A) => B>>) => HKT<F, Kind<G, B>>\nexport function ap<F, G>(\n  F: Apply<F>,\n  G: Apply<G>\n): <A>(fa: HKT<F, HKT<G, A>>) => <B>(fab: HKT<F, HKT<G, (a: A) => B>>) => HKT<F, HKT<G, B>>\nexport function ap<F, G>(\n  F: Apply<F>,\n  G: Apply<G>\n): <A>(fa: HKT<F, HKT<G, A>>) => <B>(fab: HKT<F, HKT<G, (a: A) => B>>) => HKT<F, HKT<G, B>> {\n  return <A>(fa: HKT<F, HKT<G, A>>) =>\n    <B>(fab: HKT<F, HKT<G, (a: A) => B>>): HKT<F, HKT<G, B>> =>\n      F.ap(\n        F.map(fab, (gab) => (ga: HKT<G, A>) => G.ap(gab, ga)),\n        fa\n      )\n}\n\n/**\n * @since 2.10.0\n */\nexport function apFirst<F extends URIS4>(\n  A: Apply4<F>\n): <S, R, E, B>(second: Kind4<F, S, R, E, B>) => <A>(first: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\nexport function apFirst<F extends URIS3>(\n  A: Apply3<F>\n): <R, E, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\nexport function apFirst<F extends URIS3, E>(\n  A: Apply3C<F, E>\n): <R, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\nexport function apFirst<F extends URIS2>(\n  A: Apply2<F>\n): <E, B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, A>\nexport function apFirst<F extends URIS2, E>(\n  A: Apply2C<F, E>\n): <B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, A>\nexport function apFirst<F extends URIS>(A: Apply1<F>): <B>(second: Kind<F, B>) => <A>(first: Kind<F, A>) => Kind<F, A>\nexport function apFirst<F>(A: Apply<F>): <B>(second: HKT<F, B>) => <A>(first: HKT<F, A>) => HKT<F, A>\nexport function apFirst<F>(A: Apply<F>): <B>(second: HKT<F, B>) => <A>(first: HKT<F, A>) => HKT<F, A> {\n  return (second) => (first) =>\n    A.ap(\n      A.map(first, (a) => () => a),\n      second\n    )\n}\n\n/**\n * @since 2.10.0\n */\nexport function apSecond<F extends URIS4>(\n  A: Apply4<F>\n): <S, R, E, B>(second: Kind4<F, S, R, E, B>) => <A>(first: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport function apSecond<F extends URIS3>(\n  A: Apply3<F>\n): <R, E, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function apSecond<F extends URIS3, E>(\n  A: Apply3C<F, E>\n): <R, B>(second: Kind3<F, R, E, B>) => <A>(first: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function apSecond<F extends URIS2>(\n  A: Apply2<F>\n): <E, B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function apSecond<F extends URIS2, E>(\n  A: Apply2C<F, E>\n): <B>(second: Kind2<F, E, B>) => <A>(first: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function apSecond<F extends URIS>(A: Apply1<F>): <B>(second: Kind<F, B>) => <A>(first: Kind<F, A>) => Kind<F, B>\nexport function apSecond<F>(A: Apply<F>): <B>(second: HKT<F, B>) => <A>(first: HKT<F, A>) => HKT<F, B>\nexport function apSecond<F>(A: Apply<F>): <B>(second: HKT<F, B>) => <A>(first: HKT<F, A>) => HKT<F, B> {\n  return <B>(second: HKT<F, B>) =>\n    (first) =>\n      A.ap(\n        A.map(first, () => (b: B) => b),\n        second\n      )\n}\n\n/**\n * @since 2.10.0\n */\nexport function apS<F extends URIS4>(\n  F: Apply4<F>\n): <N extends string, A, S, R, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind4<F, S, R, E, B>\n) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function apS<F extends URIS3>(\n  F: Apply3<F>\n): <N extends string, A, R, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind3<F, R, E, B>\n) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function apS<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <N extends string, A, R, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind3<F, R, E, B>\n) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function apS<F extends URIS2>(\n  F: Apply2<F>\n): <N extends string, A, E, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind2<F, E, B>\n) => (fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function apS<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind2<F, E, B>\n) => (fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function apS<F extends URIS>(\n  F: Apply1<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: Kind<F, B>\n) => (fa: Kind<F, A>) => Kind<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function apS<F>(\n  F: Apply<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: HKT<F, B>\n) => (fa: HKT<F, A>) => HKT<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function apS<F>(\n  F: Apply<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  fb: HKT<F, B>\n) => (fa: HKT<F, A>) => HKT<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> {\n  return <B>(name: string, fb: HKT<F, B>) =>\n    (fa) =>\n      F.ap(\n        F.map(fa, (a) => (b: B) => Object.assign({}, a, { [name]: b }) as any),\n        fb\n      )\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Lift a semigroup into 'F', the inner values are concatenated using the provided `Semigroup`.\n *\n * @since 2.10.0\n */\nexport function getApplySemigroup<F extends URIS4>(\n  F: Apply4<F>\n): <A, S, R, E>(S: Semigroup<A>) => Semigroup<Kind4<F, S, R, E, A>>\nexport function getApplySemigroup<F extends URIS3>(\n  F: Apply3<F>\n): <A, R, E>(S: Semigroup<A>) => Semigroup<Kind3<F, R, E, A>>\nexport function getApplySemigroup<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <A, R>(S: Semigroup<A>) => Semigroup<Kind3<F, R, E, A>>\nexport function getApplySemigroup<F extends URIS2>(F: Apply2<F>): <A, E>(S: Semigroup<A>) => Semigroup<Kind2<F, E, A>>\nexport function getApplySemigroup<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <A>(S: Semigroup<A>) => Semigroup<Kind2<F, E, A>>\nexport function getApplySemigroup<F extends URIS>(F: Apply1<F>): <A>(S: Semigroup<A>) => Semigroup<Kind<F, A>>\nexport function getApplySemigroup<F>(F: Apply<F>): <A>(S: Semigroup<A>) => Semigroup<HKT<F, A>>\nexport function getApplySemigroup<F>(F: Apply<F>): <A>(S: Semigroup<A>) => Semigroup<HKT<F, A>> {\n  return <A>(S: Semigroup<A>) => ({\n    concat: (first: HKT<F, A>, second: HKT<F, A>) =>\n      F.ap(\n        F.map(first, (x: A) => (y: A) => S.concat(x, y)),\n        second\n      )\n  })\n}\n\nfunction curried(f: Function, n: number, acc: ReadonlyArray<unknown>) {\n  return function (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) : curried(f, n - 1, combined)\n  }\n}\n\nconst tupleConstructors: Record<number, (a: unknown) => any> = {\n  1: (a) => [a],\n  2: (a) => (b: any) => [a, b],\n  3: (a) => (b: any) => (c: any) => [a, b, c],\n  4: (a) => (b: any) => (c: any) => (d: any) => [a, b, c, d],\n  5: (a) => (b: any) => (c: any) => (d: any) => (e: any) => [a, b, c, d, e]\n}\n\nfunction getTupleConstructor(len: number): (a: unknown) => any {\n  if (!_.has.call(tupleConstructors, len)) {\n    tupleConstructors[len] = curried(tuple, len - 1, [])\n  }\n  return tupleConstructors[len]\n}\n\n/**\n * Tuple sequencing, i.e., take a tuple of monadic actions and does them from left-to-right, returning the resulting tuple.\n *\n * @example\n * import { sequenceT } from 'fp-ts/Apply'\n * import * as O from 'fp-ts/Option'\n *\n * const sequenceTOption = sequenceT(O.Apply)\n * assert.deepStrictEqual(sequenceTOption(O.some(1)), O.some([1]))\n * assert.deepStrictEqual(sequenceTOption(O.some(1), O.some('2')), O.some([1, '2']))\n * assert.deepStrictEqual(sequenceTOption(O.some(1), O.some('2'), O.none), O.none)\n *\n * @since 2.0.0\n */\nexport function sequenceT<F extends URIS4>(\n  F: Apply4<F>\n): <S, R, E, T extends Array<Kind4<F, S, R, E, any>>>(\n  ...t: T & { readonly 0: Kind4<F, S, R, E, any> }\n) => Kind4<F, S, R, E, { [K in keyof T]: [T[K]] extends [Kind4<F, S, R, E, infer A>] ? A : never }>\nexport function sequenceT<F extends URIS3>(\n  F: Apply3<F>\n): <R, E, T extends Array<Kind3<F, R, E, any>>>(\n  ...t: T & { readonly 0: Kind3<F, R, E, any> }\n) => Kind3<F, R, E, { [K in keyof T]: [T[K]] extends [Kind3<F, R, E, infer A>] ? A : never }>\nexport function sequenceT<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <R, T extends Array<Kind3<F, R, E, any>>>(\n  ...t: T & { readonly 0: Kind3<F, R, E, any> }\n) => Kind3<F, R, E, { [K in keyof T]: [T[K]] extends [Kind3<F, R, E, infer A>] ? A : never }>\nexport function sequenceT<F extends URIS2>(\n  F: Apply2<F>\n): <E, T extends Array<Kind2<F, E, any>>>(\n  ...t: T & { readonly 0: Kind2<F, E, any> }\n) => Kind2<F, E, { [K in keyof T]: [T[K]] extends [Kind2<F, E, infer A>] ? A : never }>\nexport function sequenceT<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <T extends Array<Kind2<F, E, any>>>(\n  ...t: T & { readonly 0: Kind2<F, E, any> }\n) => Kind2<F, E, { [K in keyof T]: [T[K]] extends [Kind2<F, E, infer A>] ? A : never }>\nexport function sequenceT<F extends URIS>(\n  F: Apply1<F>\n): <T extends Array<Kind<F, any>>>(\n  ...t: T & { readonly 0: Kind<F, any> }\n) => Kind<F, { [K in keyof T]: [T[K]] extends [Kind<F, infer A>] ? A : never }>\nexport function sequenceT<F>(\n  F: Apply<F>\n): <T extends Array<HKT<F, any>>>(\n  ...t: T & { readonly 0: HKT<F, any> }\n) => HKT<F, { [K in keyof T]: [T[K]] extends [HKT<F, infer A>] ? A : never }>\nexport function sequenceT<F>(F: Apply<F>): any {\n  return <A>(...args: Array<HKT<F, A>>) => {\n    const len = args.length\n    const f = getTupleConstructor(len)\n    let fas = F.map(args[0], f)\n    for (let i = 1; i < len; i++) {\n      fas = F.ap(fas, args[i])\n    }\n    return fas\n  }\n}\n\ntype EnforceNonEmptyRecord<R> = keyof R extends never ? never : R\n\nfunction getRecordConstructor(keys: ReadonlyArray<string>) {\n  const len = keys.length\n  switch (len) {\n    case 1:\n      return (a: any) => ({ [keys[0]]: a })\n    case 2:\n      return (a: any) => (b: any) => ({ [keys[0]]: a, [keys[1]]: b })\n    case 3:\n      return (a: any) => (b: any) => (c: any) => ({ [keys[0]]: a, [keys[1]]: b, [keys[2]]: c })\n    case 4:\n      return (a: any) => (b: any) => (c: any) => (d: any) => ({\n        [keys[0]]: a,\n        [keys[1]]: b,\n        [keys[2]]: c,\n        [keys[3]]: d\n      })\n    case 5:\n      return (a: any) => (b: any) => (c: any) => (d: any) => (e: any) => ({\n        [keys[0]]: a,\n        [keys[1]]: b,\n        [keys[2]]: c,\n        [keys[3]]: d,\n        [keys[4]]: e\n      })\n    default:\n      return curried(\n        (...args: ReadonlyArray<unknown>) => {\n          const r: Record<string, unknown> = {}\n          for (let i = 0; i < len; i++) {\n            r[keys[i]] = args[i]\n          }\n          return r\n        },\n        len - 1,\n        []\n      )\n  }\n}\n\n/**\n * Like `Apply.sequenceT` but works with structs instead of tuples.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { sequenceS } from 'fp-ts/Apply'\n *\n * const ado = sequenceS(E.Apply)\n *\n * assert.deepStrictEqual(\n *   ado({\n *     a: E.right(1),\n *     b: E.right(true)\n *   }),\n *   E.right({ a: 1, b: true })\n * )\n * assert.deepStrictEqual(\n *   ado({\n *     a: E.right(1),\n *     b: E.left('error')\n *   }),\n *   E.left('error')\n * )\n *\n * @since 2.0.0\n */\nexport function sequenceS<F extends URIS4>(\n  F: Apply4<F>\n): <S, R, E, NER extends Record<string, Kind4<F, S, R, E, any>>>(\n  r: EnforceNonEmptyRecord<NER> & Record<string, Kind4<F, S, R, E, any>>\n) => Kind4<F, S, R, E, { [K in keyof NER]: [NER[K]] extends [Kind4<F, any, any, any, infer A>] ? A : never }>\nexport function sequenceS<F extends URIS3>(\n  F: Apply3<F>\n): <R, E, NER extends Record<string, Kind3<F, R, E, any>>>(\n  r: EnforceNonEmptyRecord<NER> & Record<string, Kind3<F, R, E, any>>\n) => Kind3<F, R, E, { [K in keyof NER]: [NER[K]] extends [Kind3<F, any, any, infer A>] ? A : never }>\nexport function sequenceS<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <R, NER extends Record<string, Kind3<F, R, E, any>>>(\n  r: EnforceNonEmptyRecord<NER> & Record<string, Kind3<F, R, E, any>>\n) => Kind3<F, R, E, { [K in keyof NER]: [NER[K]] extends [Kind3<F, any, any, infer A>] ? A : never }>\nexport function sequenceS<F extends URIS2>(\n  F: Apply2<F>\n): <E, NER extends Record<string, Kind2<F, E, any>>>(\n  r: EnforceNonEmptyRecord<NER> & Record<string, Kind2<F, E, any>>\n) => Kind2<F, E, { [K in keyof NER]: [NER[K]] extends [Kind2<F, any, infer A>] ? A : never }>\nexport function sequenceS<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <NER extends Record<string, Kind2<F, E, any>>>(\n  r: EnforceNonEmptyRecord<NER>\n) => Kind2<F, E, { [K in keyof NER]: [NER[K]] extends [Kind2<F, any, infer A>] ? A : never }>\nexport function sequenceS<F extends URIS>(\n  F: Apply1<F>\n): <NER extends Record<string, Kind<F, any>>>(\n  r: EnforceNonEmptyRecord<NER>\n) => Kind<F, { [K in keyof NER]: [NER[K]] extends [Kind<F, infer A>] ? A : never }>\nexport function sequenceS<F>(\n  F: Apply<F>\n): <NER extends Record<string, HKT<F, any>>>(\n  r: EnforceNonEmptyRecord<NER>\n) => HKT<F, { [K in keyof NER]: [NER[K]] extends [HKT<F, infer A>] ? A : never }>\nexport function sequenceS<F>(F: Apply<F>): (r: Record<string, HKT<F, any>>) => HKT<F, Record<string, any>> {\n  return (r) => {\n    const keys = Object.keys(r)\n    const len = keys.length\n    const f = getRecordConstructor(keys)\n    let fr = F.map(r[keys[0]], f)\n    for (let i = 1; i < len; i++) {\n      fr = F.ap(fr, r[keys[i]])\n    }\n    return fr\n  }\n}\n"
  },
  {
    "path": "src/Array.ts",
    "content": "/**\n * The Array module provides tools for working with Typescript's Array<T> type in a functional way.\n *\n * In functional jargon, this module provides a monadic interface over Typescript's Array<T>.\n *\n * @since 2.0.0\n */\nimport { Alt1 } from './Alt'\nimport { Alternative1 } from './Alternative'\nimport { Applicative as ApplicativeHKT, Applicative1 } from './Applicative'\nimport { apFirst as apFirst_, Apply1, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport { bind as bind_, Chain1, chainFirst as chainFirst_ } from './Chain'\nimport { ChainRec1 } from './ChainRec'\nimport { Compactable1 } from './Compactable'\nimport { Either } from './Either'\nimport { Eq } from './Eq'\nimport { Extend1 } from './Extend'\nimport { Filterable1 } from './Filterable'\nimport { FilterableWithIndex1, PredicateWithIndex, RefinementWithIndex } from './FilterableWithIndex'\nimport { Foldable1 } from './Foldable'\nimport { FoldableWithIndex1 } from './FoldableWithIndex'\nimport { FromEither1, fromEitherK as fromEitherK_ } from './FromEither'\nimport { dual, identity, LazyArg, pipe } from './function'\nimport { bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport { FunctorWithIndex1 } from './FunctorWithIndex'\nimport { HKT } from './HKT'\nimport * as _ from './internal'\nimport { Magma } from './Magma'\nimport { Monad1 } from './Monad'\nimport { Monoid } from './Monoid'\nimport * as NEA from './NonEmptyArray'\nimport { Option } from './Option'\nimport { Ord } from './Ord'\nimport { Pointed1 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport * as RA from './ReadonlyArray'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport { Separated, separated } from './Separated'\nimport { Show } from './Show'\nimport { PipeableTraverse1, Traversable1 } from './Traversable'\nimport { PipeableTraverseWithIndex1, TraversableWithIndex1 } from './TraversableWithIndex'\nimport { Unfoldable1 } from './Unfoldable'\nimport {\n  filterE as filterE_,\n  PipeableWilt1,\n  PipeableWither1,\n  wiltDefault,\n  Witherable1,\n  witherDefault\n} from './Witherable'\nimport { guard as guard_, Zero1 } from './Zero'\n\nimport NonEmptyArray = NEA.NonEmptyArray\n\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n\n/**\n * Test whether an array is empty\n *\n * @example\n * import { isEmpty } from 'fp-ts/Array'\n *\n * assert.strictEqual(isEmpty([]), true)\n * assert.strictEqual(isEmpty(['a']), false)\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isEmpty = <A>(as: Array<A>): as is [] => as.length === 0\n\n/**\n * Test whether an array is non empty narrowing down the type to `NonEmptyArray<A>`\n *\n * @example\n * import { isNonEmpty } from 'fp-ts/Array'\n *\n * assert.strictEqual(isNonEmpty([]), false)\n * assert.strictEqual(isNonEmpty(['a']), true)\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isNonEmpty: <A>(as: Array<A>) => as is NonEmptyArray<A> = NEA.isNonEmpty\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Prepend an element to the front of a `Array`, creating a new `NonEmptyArray`.\n *\n * @example\n * import { prepend } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([2, 3, 4], prepend(1)), [1, 2, 3, 4])\n *\n * @since 2.10.0\n */\nexport const prepend: <A>(head: A) => (tail: Array<A>) => NEA.NonEmptyArray<A> = NEA.prepend\n\n/**\n * Less strict version of [`prepend`](#prepend).\n *\n * @example\n * import { prependW } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([2, 3, 4], prependW(\"a\")), [\"a\", 2, 3, 4]);\n *\n * @since 2.11.0\n */\nexport const prependW: <A, B>(head: B) => (tail: Array<A>) => NEA.NonEmptyArray<A | B> = NEA.prependW\n\n/**\n * Append an element to the end of a `Array`, creating a new `NonEmptyArray`.\n *\n * @example\n * import { append } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2, 3], append(4)), [1, 2, 3, 4])\n *\n * @since 2.10.0\n */\nexport const append: <A>(end: A) => (init: Array<A>) => NEA.NonEmptyArray<A> = NEA.append\n\n/**\n * Less strict version of [`append`](#append).\n *\n * @example\n * import { appendW } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2, 3], appendW(\"d\")), [1, 2, 3, \"d\"]);\n *\n * @since 2.11.0\n */\nexport const appendW: <A, B>(end: B) => (init: Array<A>) => NEA.NonEmptyArray<A | B> = NEA.appendW\n\n/**\n * Return a `Array` of length `n` with element `i` initialized with `f(i)`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import { makeBy } from 'fp-ts/Array'\n *\n * const double = (i: number): number => i * 2\n * assert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8])\n * assert.deepStrictEqual(makeBy(-3, double), [])\n * assert.deepStrictEqual(makeBy(4.32164, double), [0, 2, 4, 6])\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const makeBy = <A>(n: number, f: (i: number) => A): Array<A> => (n <= 0 ? [] : NEA.makeBy(f)(n))\n\n/**\n * Create a `Array` containing a value repeated the specified number of times.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import { replicate } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a'])\n * assert.deepStrictEqual(replicate(-3, 'a'), [])\n * assert.deepStrictEqual(replicate(2.985647, 'a'), ['a', 'a'])\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const replicate = <A>(n: number, a: A): Array<A> => makeBy(n, () => a)\n\n/**\n * Create an array with one element, if the element satisfies the predicate, otherwise\n * it returns an empty array.\n *\n * @example\n * import { fromPredicate } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n * import { isString } from \"fp-ts/string\";\n *\n * assert.deepStrictEqual(pipe(\"a\", fromPredicate(isString)), [\"a\"]);\n * assert.deepStrictEqual(pipe(7, fromPredicate(isString)), []);\n *\n * assert.deepStrictEqual(pipe(7, fromPredicate((x)=> x > 0)), [7]);\n * assert.deepStrictEqual(pipe(-3, fromPredicate((x)=> x > 0)), []);\n *\n * @category lifting\n * @since 2.11.0\n */\nexport function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => Array<B>\nexport function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => Array<B>\nexport function fromPredicate<A>(predicate: Predicate<A>): (a: A) => Array<A>\nexport function fromPredicate<A>(predicate: Predicate<A>): (a: A) => Array<A> {\n  return (a) => (predicate(a) ? [a] : [])\n}\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * Create an array from an `Option`. The resulting array will contain the content of the\n * `Option` if it is `Some` and it will be empty if the `Option` is `None`.\n *\n * @example\n * import { fromOption } from 'fp-ts/Array'\n * import { option } from \"fp-ts\";\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe(option.some(\"a\"), fromOption),[\"a\"])\n * assert.deepStrictEqual(pipe(option.none, fromOption),[])\n *\n * @category conversions\n * @since 2.11.0\n */\nexport const fromOption: <A>(fa: Option<A>) => Array<A> = (ma) => (_.isNone(ma) ? [] : [ma.value])\n\n/**\n * Create an array from an `Either`. The resulting array will contain the content of the\n * `Either` if it is `Right` and it will be empty if the `Either` is `Left`.\n *\n * @example\n * import { fromEither } from 'fp-ts/Array'\n * import { either } from \"fp-ts\";\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe(either.right(\"r\"), fromEither), [\"r\"]);\n * assert.deepStrictEqual(pipe(either.left(\"l\"), fromEither), []);\n *\n * @category conversions\n * @since 2.11.0\n */\nexport const fromEither: <A>(fa: Either<unknown, A>) => Array<A> = (e) => (_.isLeft(e) ? [] : [e.right])\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @example\n * import { matchW } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * const matcherW = matchW(\n *   () => \"No elements\",\n *   (as) => as.length\n * );\n * assert.deepStrictEqual(pipe([1, 2, 3, 4], matcherW), 4);\n * assert.deepStrictEqual(pipe([], matcherW), \"No elements\");\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchW =\n  <B, A, C>(onEmpty: LazyArg<B>, onNonEmpty: (as: NonEmptyArray<A>) => C) =>\n  (as: Array<A>): B | C =>\n    isNonEmpty(as) ? onNonEmpty(as) : onEmpty()\n\n/**\n * Takes an array, if the array is empty it returns the result of `onEmpty`, otherwise\n * it passes the array to `onNonEmpty` and returns the result.\n *\n * @example\n * import { match } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * const matcher = match(\n *   () => \"No elements\",\n *   (as) => `Found ${as.length} element(s)`\n * );\n * assert.deepStrictEqual(pipe([1, 2, 3, 4], matcher), \"Found 4 element(s)\");\n * assert.deepStrictEqual(pipe([], matcher), \"No elements\");\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const match: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (as: NonEmptyArray<A>) => B) => (as: Array<A>) => B = matchW\n\n/**\n * Less strict version of [`matchLeft`](#matchleft). It will work when `onEmpty` and\n * `onNonEmpty` have different return types.\n *\n * @example\n * import { matchLeftW } from 'fp-ts/Array'\n *\n * const f = matchLeftW(\n *   () => 0,\n *   (head: string, tail: string[]) => `Found \"${head}\" followed by ${tail.length} elements`\n * );\n * assert.strictEqual(f([\"a\", \"b\", \"c\"]), 'Found \"a\" followed by 2 elements');\n * assert.strictEqual(f([]), 0);\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchLeftW =\n  <B, A, C>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: Array<A>) => C) =>\n  (as: Array<A>): B | C =>\n    isNonEmpty(as) ? onNonEmpty(NEA.head(as), NEA.tail(as)) : onEmpty()\n\n/**\n * Takes an array, if the array is empty it returns the result of `onEmpty`, otherwise\n * it passes the array to `onNonEmpty` broken into its first element and remaining elements.\n *\n * @example\n * import { matchLeft } from 'fp-ts/Array'\n *\n * const len: <A>(as: Array<A>) => number = matchLeft(() => 0, (_, tail) => 1 + len(tail))\n * assert.strictEqual(len([1, 2, 3]), 3)\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchLeft: <B, A>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: Array<A>) => B) => (as: Array<A>) => B =\n  matchLeftW\n\n/**\n * Alias of [`matchLeft`](#matchleft).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const foldLeft: <A, B>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: Array<A>) => B) => (as: Array<A>) => B =\n  matchLeft\n\n/**\n * Less strict version of [`matchRight`](#matchright). It will work when `onEmpty` and\n * `onNonEmpty` have different return types.\n *\n * @example\n * import { matchRightW } from 'fp-ts/Array'\n *\n * const f = matchRightW(\n *   () => 0,\n *   (head: string[], tail: string) => `Found ${head.length} elements folllowed by \"${tail}\"`\n * );\n * assert.strictEqual(f([\"a\", \"b\", \"c\"]), 'Found 2 elements folllowed by \"c\"');\n * assert.strictEqual(f([]), 0);\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchRightW =\n  <B, A, C>(onEmpty: LazyArg<B>, onNonEmpty: (init: Array<A>, last: A) => C) =>\n  (as: Array<A>): B | C =>\n    isNonEmpty(as) ? onNonEmpty(NEA.init(as), NEA.last(as)) : onEmpty()\n\n/**\n * Takes an array, if the array is empty it returns the result of `onEmpty`, otherwise\n * it passes the array to `onNonEmpty` broken  into its initial elements and the last element.\n *\n * @example\n * import { matchRight } from 'fp-ts/Array'\n *\n * const len: <A>(as: Array<A>) => number = matchRight(\n *   () => 0,\n *   (head, _) => 1 + len(head)\n * );\n * assert.strictEqual(len([1, 2, 3]), 3);\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchRight: <B, A>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (init: Array<A>, last: A) => B\n) => (as: Array<A>) => B = matchRightW\n\n/**\n * Alias of [`matchRight`](#matchright).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const foldRight: <A, B>(onEmpty: LazyArg<B>, onNonEmpty: (init: Array<A>, last: A) => B) => (as: Array<A>) => B =\n  matchRight\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Same as [`chain`](#chain), but passing also the index to the iterating function.\n *\n * @example\n * import { chainWithIndex, replicate } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * const f = (index: number, x: string) => replicate(2, `${x}${index}`);\n * assert.deepStrictEqual(pipe([\"a\", \"b\", \"c\"], chainWithIndex(f)), [\"a0\", \"a0\", \"b1\", \"b1\", \"c2\", \"c2\"]);\n *\n * @category sequencing\n * @since 2.7.0\n */\nexport const chainWithIndex =\n  <A, B>(f: (i: number, a: A) => Array<B>) =>\n  (as: Array<A>): Array<B> => {\n    const out: Array<B> = []\n    for (let i = 0; i < as.length; i++) {\n      const bs = f(i, as[i])\n      for (let j = 0; j < bs.length; j++) {\n        out.push(bs[j])\n      }\n    }\n    return out\n  }\n\n/**\n * Same as `reduce` but it carries over the intermediate steps\n *\n * @example\n * import { scanLeft } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4])\n *\n * @since 2.0.0\n */\nexport const scanLeft =\n  <A, B>(b: B, f: (b: B, a: A) => B) =>\n  (as: Array<A>): NonEmptyArray<B> => {\n    const len = as.length\n    const out = new Array(len + 1) as NonEmptyArray<B>\n    out[0] = b\n    for (let i = 0; i < len; i++) {\n      out[i + 1] = f(out[i], as[i])\n    }\n    return out\n  }\n\n/**\n * Fold an array from the right, keeping all intermediate results instead of only the final result\n *\n * @example\n * import { scanRight } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10])\n *\n * @since 2.0.0\n */\nexport const scanRight =\n  <A, B>(b: B, f: (a: A, b: B) => B) =>\n  (as: Array<A>): NonEmptyArray<B> => {\n    const len = as.length\n    const out = new Array(len + 1) as NonEmptyArray<B>\n    out[len] = b\n    for (let i = len - 1; i >= 0; i--) {\n      out[i] = f(as[i], out[i + 1])\n    }\n    return out\n  }\n\n/**\n * Calculate the number of elements in a `Array`.\n *\n * @example\n * import { size } from 'fp-ts/Array'\n *\n * assert.strictEqual(size([\"a\",\"b\",\"c\"]),3)\n *\n * @since 2.10.0\n */\nexport const size = <A>(as: Array<A>): number => as.length\n\n/**\n * Test whether an array contains a particular index\n *\n * @example\n * import { isOutOfBound } from 'fp-ts/Array'\n *\n * assert.strictEqual(isOutOfBound(1,[\"a\",\"b\",\"c\"]),false)\n * assert.strictEqual(isOutOfBound(-1,[\"a\",\"b\",\"c\"]),true)\n * assert.strictEqual(isOutOfBound(3,[\"a\",\"b\",\"c\"]),true)\n *\n * @since 2.0.0\n */\nexport const isOutOfBound: <A>(i: number, as: Array<A>) => boolean = NEA.isOutOfBound\n\n// TODO: remove non-curried overloading in v3\n/**\n * This function provides a safe way to read a value at a particular index from an array.\n * It returns a `none` if the index is out of bounds, and a `some` of the element if the\n * index is valid.\n *\n * @example\n * import { lookup } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2))\n * assert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none)\n *\n * @since 2.0.0\n */\nexport const lookup: {\n  (i: number): <A>(as: Array<A>) => Option<A>\n  <A>(i: number, as: Array<A>): Option<A>\n} = RA.lookup\n\n/**\n * Get the first element in an array, or `None` if the array is empty\n *\n * @example\n * import { head } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(head([1, 2, 3]), some(1))\n * assert.deepStrictEqual(head([]), none)\n *\n * @since 2.0.0\n */\nexport const head: <A>(as: Array<A>) => Option<A> = RA.head\n\n/**\n * Get the last element in an array, or `None` if the array is empty\n *\n * @example\n * import { last } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(last([1, 2, 3]), some(3))\n * assert.deepStrictEqual(last([]), none)\n *\n * @since 2.0.0\n */\nexport const last: <A>(as: Array<A>) => Option<A> = RA.last\n\n/**\n * Get all but the first element of an array, creating a new array, or `None` if the array is empty\n *\n * @example\n * import { tail } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(tail([1, 2, 3]), some([2, 3]))\n * assert.deepStrictEqual(tail([]), none)\n *\n * @since 2.0.0\n */\nexport const tail = <A>(as: Array<A>): Option<Array<A>> => (isNonEmpty(as) ? _.some(NEA.tail(as)) : _.none)\n\n/**\n * Get all but the last element of an array, creating a new array, or `None` if the array is empty\n *\n * @example\n * import { init } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(init([1, 2, 3]), some([1, 2]))\n * assert.deepStrictEqual(init([]), none)\n *\n * @since 2.0.0\n */\nexport const init = <A>(as: Array<A>): Option<Array<A>> => (isNonEmpty(as) ? _.some(NEA.init(as)) : _.none)\n\n/**\n * Keep only a max number of elements from the start of an `Array`, creating a new `Array`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import { takeLeft } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(takeLeft(2)([1, 2, 3, 4, 5]), [1, 2]);\n * assert.deepStrictEqual(takeLeft(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]);\n * assert.deepStrictEqual(takeLeft(0)([1, 2, 3, 4, 5]), []);\n * assert.deepStrictEqual(takeLeft(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]);\n *\n * @since 2.0.0\n */\nexport const takeLeft =\n  (n: number) =>\n  <A>(as: Array<A>): Array<A> =>\n    isOutOfBound(n, as) ? copy(as) : as.slice(0, n)\n\n/**\n * Keep only a max number of elements from the end of an `Array`, creating a new `Array`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import { takeRight } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(takeRight(2)([1, 2, 3, 4, 5]), [4, 5]);\n * assert.deepStrictEqual(takeRight(7)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]);\n * assert.deepStrictEqual(takeRight(0)([1, 2, 3, 4, 5]), []);\n * assert.deepStrictEqual(takeRight(-1)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]);\n *\n * @since 2.0.0\n */\nexport const takeRight =\n  (n: number) =>\n  <A>(as: Array<A>): Array<A> =>\n    isOutOfBound(n, as) ? copy(as) : n === 0 ? [] : as.slice(-n)\n\n/**\n * Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new array\n *\n * @example\n * import { takeLeftWhile } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(takeLeftWhile((n: number) => n % 2 === 0)([2, 4, 3, 6]), [2, 4])\n *\n * @since 2.0.0\n */\nexport function takeLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>\nexport function takeLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>\nexport function takeLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>\nexport function takeLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A> {\n  return (as: Array<A>) => {\n    const out: Array<A> = []\n    for (const a of as) {\n      if (!predicate(a)) {\n        break\n      }\n      out.push(a)\n    }\n    return out\n  }\n}\n\nconst spanLeftIndex = <A>(as: Array<A>, predicate: Predicate<A>): number => {\n  const l = as.length\n  let i = 0\n  for (; i < l; i++) {\n    if (!predicate(as[i])) {\n      break\n    }\n  }\n  return i\n}\n\n/**\n * Type returned by [`spanLeft`](#spanLeft) composed of an `init` array and a `rest` array.\n *\n * @since 2.10.0\n */\nexport interface Spanned<I, R> {\n  init: Array<I>\n  rest: Array<R>\n}\n\n/**\n * Split an array into two parts:\n * 1. the longest initial subarray for which all elements satisfy the specified predicate\n * 2. the remaining elements\n *\n * @example\n * import { spanLeft } from 'fp-ts/Array'\n *\n * const isOdd = (n: number) => n % 2 === 1;\n * assert.deepStrictEqual(spanLeft(isOdd)([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] });\n * assert.deepStrictEqual(spanLeft(isOdd)([0, 2, 4, 5]), { init: [], rest: [0, 2, 4, 5] });\n * assert.deepStrictEqual(spanLeft(isOdd)([1, 3, 5]), { init: [1, 3, 5], rest: [] });\n *\n * @since 2.0.0\n */\nexport function spanLeft<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Spanned<B, A>\nexport function spanLeft<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Spanned<B, B>\nexport function spanLeft<A>(predicate: Predicate<A>): (as: Array<A>) => Spanned<A, A>\nexport function spanLeft<A>(predicate: Predicate<A>): (as: Array<A>) => Spanned<A, A> {\n  return (as) => {\n    const [init, rest] = splitAt(spanLeftIndex(as, predicate))(as)\n    return { init, rest }\n  }\n}\n\n/**\n * Creates a new `Array` which is a copy of the input dropping a max number of elements from the start.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import { dropLeft } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(dropLeft(2)([1, 2, 3]), [3]);\n * assert.deepStrictEqual(dropLeft(5)([1, 2, 3]), []);\n * assert.deepStrictEqual(dropLeft(0)([1, 2, 3]), [1, 2, 3]);\n * assert.deepStrictEqual(dropLeft(-2)([1, 2, 3]), [1, 2, 3]);\n *\n * @since 2.0.0\n */\nexport const dropLeft =\n  (n: number) =>\n  <A>(as: Array<A>): Array<A> =>\n    n <= 0 || isEmpty(as) ? copy(as) : n >= as.length ? [] : as.slice(n, as.length)\n\n/**\n * Creates a new `Array` which is a copy of the input dropping a max number of elements from the end.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import { dropRight } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(dropRight(2)([1, 2, 3]), [1]);\n * assert.deepStrictEqual(dropRight(5)([1, 2, 3]), []);\n * assert.deepStrictEqual(dropRight(0)([1, 2, 3]), [1, 2, 3]);\n * assert.deepStrictEqual(dropRight(-2)([1, 2, 3]), [1, 2, 3]);\n *\n * @since 2.0.0\n */\nexport const dropRight =\n  (n: number) =>\n  <A>(as: Array<A>): Array<A> =>\n    n <= 0 || isEmpty(as) ? copy(as) : n >= as.length ? [] : as.slice(0, as.length - n)\n\n/**\n * Creates a new `Array` which is a copy of the input dropping the longest initial subarray for\n * which all element satisfy the specified predicate.\n *\n * @example\n * import { dropLeftWhile } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5])\n *\n * @since 2.0.0\n */\nexport function dropLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>\nexport function dropLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>\nexport function dropLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>\nexport function dropLeftWhile<A>(predicate: Predicate<A>): (as: Array<A>) => Array<A> {\n  return (as) => as.slice(spanLeftIndex(as, predicate))\n}\n\n/**\n * `findIndex` returns an `Option` containing the first index for which a predicate holds.\n * It returns `None` if no element satisfies the predicate.\n * Similar to [`findFirst`](#findFirst) but returning the index instead of the element.\n *\n * @example\n * import { findIndex } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1))\n * assert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none)\n *\n * @since 2.0.0\n */\nexport const findIndex: <A>(predicate: Predicate<A>) => (as: Array<A>) => Option<number> = RA.findIndex\n\n/**\n * Find the first element which satisfies a predicate (or a refinement) function.\n * It returns an `Option` containing the element or `None` if not found.\n *\n * @example\n * import { findFirst } from 'fp-ts/Array'\n * import { some } from 'fp-ts/Option'\n *\n * type X = {\n *   readonly a: number\n *   readonly b: number\n * }\n *\n * assert.deepStrictEqual(findFirst((x: X) => x.a === 1)([{ a: 1, b: 1 }, { a: 1, b: 2 }]), some({ a: 1, b: 1 }))\n *\n * @since 2.0.0\n */\nexport function findFirst<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Option<B>\nexport function findFirst<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Option<B>\nexport function findFirst<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A>\nexport function findFirst<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A> {\n  return RA.findFirst(predicate)\n}\n\n/**\n * Given a selector function which takes an element and returns an option,\n * this function applies the selector to each element of the array and\n * returns the first `Some` result. Otherwise it returns `None`.\n *\n * @example\n * import { findFirstMap } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * interface Person {\n *   readonly name: string;\n *   readonly age: number;\n * }\n *\n * const persons: Array<Person> = [\n *   { name: \"John\", age: 16 },\n *   { name: \"Mary\", age: 45 },\n *   { name: \"Joey\", age: 28 },\n * ];\n *\n * const nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name));\n * const nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name));\n * assert.deepStrictEqual(findFirstMap(nameOfPersonAbove18)(persons), some(\"Mary\"));\n * assert.deepStrictEqual(findFirstMap(nameOfPersonAbove70)(persons), none);\n *\n * @since 2.0.0\n */\nexport const findFirstMap: <A, B>(f: (a: A) => Option<B>) => (as: Array<A>) => Option<B> = RA.findFirstMap\n\n/**\n * Find the last element which satisfies a predicate function.\n * It returns an `Option` containing the element or `None` if not found.\n *\n * @example\n * import { findLast } from 'fp-ts/Array'\n * import { some } from 'fp-ts/Option'\n *\n * type X = {\n *   readonly a: number\n *   readonly b: number\n * }\n *\n * assert.deepStrictEqual(findLast((x: X) => x.a === 1)([{ a: 1, b: 1 }, { a: 1, b: 2 }]), some({ a: 1, b: 2 }))\n *\n * @since 2.0.0\n */\nexport function findLast<A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Option<B>\nexport function findLast<A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Option<B>\nexport function findLast<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A>\nexport function findLast<A>(predicate: Predicate<A>): (as: Array<A>) => Option<A> {\n  return RA.findLast(predicate)\n}\n\n/**\n * Given a selector function which takes an element and returns an option,\n * this function applies the selector to each element of the array starting from the\n * end and returns the last `Some` result. Otherwise it returns `None`.\n *\n * @example\n * import { findLastMap } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * interface Person {\n *   readonly name: string;\n *   readonly age: number;\n * }\n *\n * const persons: Array<Person> = [\n *   { name: \"John\", age: 16 },\n *   { name: \"Mary\", age: 45 },\n *   { name: \"Joey\", age: 28 },\n * ];\n *\n * const nameOfPersonAbove18 = (p: Person) => (p.age <= 18 ? none : some(p.name));\n * const nameOfPersonAbove70 = (p: Person) => (p.age <= 70 ? none : some(p.name));\n * assert.deepStrictEqual(findLastMap(nameOfPersonAbove18)(persons), some(\"Joey\"));\n * assert.deepStrictEqual(findLastMap(nameOfPersonAbove70)(persons), none);\n *\n * @since 2.0.0\n */\nexport const findLastMap: <A, B>(f: (a: A) => Option<B>) => (as: Array<A>) => Option<B> = RA.findLastMap\n\n/**\n * Returns the index of the last element of the list which matches the predicate.\n * It returns an `Option` containing the index or `None` if not found.\n *\n * @example\n * import { findLastIndex } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * interface X {\n *   readonly a: number\n *   readonly b: number\n * }\n * const xs: Array<X> = [{ a: 1, b: 0 }, { a: 1, b: 1 }]\n * assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 1)(xs), some(1))\n * assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 4)(xs), none)\n *\n * @since 2.0.0\n */\nexport const findLastIndex: <A>(predicate: Predicate<A>) => (as: Array<A>) => Option<number> = RA.findLastIndex\n\n/**\n * This function takes an array and makes a new array containing the same elements.\n *\n * @since 2.0.0\n */\nexport const copy = <A>(as: Array<A>): Array<A> => as.slice()\n\n/**\n * Insert an element at the specified index, creating a new array,\n * or returning `None` if the index is out of bounds.\n *\n * @example\n * import { insertAt } from 'fp-ts/Array'\n * import { some } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4]))\n *\n * @since 2.0.0\n */\nexport const insertAt =\n  <A>(i: number, a: A) =>\n  (as: Array<A>): Option<NonEmptyArray<A>> =>\n    i < 0 || i > as.length ? _.none : _.some(unsafeInsertAt(i, a, as))\n\n/**\n * Change the element at the specified index, creating a new array,\n * or returning `None` if the index is out of bounds.\n *\n * @example\n * import { updateAt } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3]))\n * assert.deepStrictEqual(updateAt(1, 1)([]), none)\n *\n * @since 2.0.0\n */\nexport const updateAt = <A>(i: number, a: A): ((as: Array<A>) => Option<Array<A>>) => modifyAt(i, () => a)\n\n/**\n * Delete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds.\n *\n * @example\n * import { deleteAt } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3]))\n * assert.deepStrictEqual(deleteAt(1)([]), none)\n *\n * @since 2.0.0\n */\nexport const deleteAt =\n  (i: number) =>\n  <A>(as: Array<A>): Option<Array<A>> =>\n    isOutOfBound(i, as) ? _.none : _.some(unsafeDeleteAt(i, as))\n\n/**\n * Apply a function to the element at the specified index, creating a new array, or returning `None` if the index is out\n * of bounds.\n *\n * @example\n * import { modifyAt } from 'fp-ts/Array'\n * import { some, none } from 'fp-ts/Option'\n *\n * const double = (x: number): number => x * 2\n * assert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3]))\n * assert.deepStrictEqual(modifyAt(1, double)([]), none)\n *\n * @since 2.0.0\n */\nexport const modifyAt =\n  <A>(i: number, f: (a: A) => A) =>\n  (as: Array<A>): Option<Array<A>> =>\n    isOutOfBound(i, as) ? _.none : _.some(unsafeUpdateAt(i, f(as[i]), as))\n\n/**\n * Reverse an array, creating a new array\n *\n * @example\n * import { reverse } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1])\n *\n * @since 2.0.0\n */\nexport const reverse = <A>(as: Array<A>): Array<A> => (isEmpty(as) ? [] : as.slice().reverse())\n\n/**\n * Takes an `Array` of `Either` and produces a new `Array` containing\n * the values of all the `Right` elements in the same order.\n *\n * @example\n * import { rights } from 'fp-ts/Array'\n * import { right, left } from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2])\n *\n * @since 2.0.0\n */\nexport const rights = <E, A>(as: Array<Either<E, A>>): Array<A> => {\n  const r: Array<A> = []\n  for (let i = 0; i < as.length; i++) {\n    const a = as[i]\n    if (a._tag === 'Right') {\n      r.push(a.right)\n    }\n  }\n  return r\n}\n\n/**\n * Takes an `Array` of `Either` and produces a new `Array` containing\n * the values of all the `Left` elements in the same order.\n *\n * @example\n * import { lefts } from 'fp-ts/Array'\n * import { left, right } from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo'])\n *\n * @since 2.0.0\n */\nexport const lefts = <E, A>(as: Array<Either<E, A>>): Array<E> => {\n  const r: Array<E> = []\n  for (let i = 0; i < as.length; i++) {\n    const a = as[i]\n    if (a._tag === 'Left') {\n      r.push(a.left)\n    }\n  }\n  return r\n}\n\n/**\n * Sort the elements of an array in increasing order, creating a new array\n *\n * @example\n * import { sort } from 'fp-ts/Array'\n * import * as N from 'fp-ts/number'\n *\n * assert.deepStrictEqual(sort(N.Ord)([3, 2, 1]), [1, 2, 3])\n *\n * @since 2.0.0\n */\nexport const sort =\n  <B>(O: Ord<B>) =>\n  <A extends B>(as: Array<A>): Array<A> =>\n    as.length <= 1 ? copy(as) : as.slice().sort(O.compare)\n\n/**\n * Apply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one\n * input array is short, excess elements of the longer array are discarded.\n *\n * @example\n * import { zipWith } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n), ['a1', 'b2', 'c3'])\n *\n * @since 2.0.0\n */\nexport const zipWith = <A, B, C>(fa: Array<A>, fb: Array<B>, f: (a: A, b: B) => C): Array<C> => {\n  const fc: Array<C> = []\n  const len = Math.min(fa.length, fb.length)\n  for (let i = 0; i < len; i++) {\n    fc[i] = f(fa[i], fb[i])\n  }\n  return fc\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Takes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the\n * longer array are discarded\n *\n * @example\n * import { zip } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2, 3], zip(['a', 'b', 'c', 'd'])), [[1, 'a'], [2, 'b'], [3, 'c']])\n *\n * @since 2.0.0\n */\nexport function zip<B>(bs: Array<B>): <A>(as: Array<A>) => Array<[A, B]>\nexport function zip<A, B>(as: Array<A>, bs: Array<B>): Array<[A, B]>\nexport function zip<A, B>(as: Array<A>, bs?: Array<B>): Array<[A, B]> | ((bs: Array<B>) => Array<[B, A]>) {\n  if (bs === undefined) {\n    return (bs) => zip(bs, as)\n  }\n  return zipWith(as, bs, (a, b) => [a, b])\n}\n\n/**\n * The function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays\n *\n * @example\n * import { unzip } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(unzip([[1, 'a'], [2, 'b'], [3, 'c']]), [[1, 2, 3], ['a', 'b', 'c']])\n *\n * @since 2.0.0\n */\nexport const unzip = <A, B>(as: Array<[A, B]>): [Array<A>, Array<B>] => {\n  const fa: Array<A> = []\n  const fb: Array<B> = []\n  for (let i = 0; i < as.length; i++) {\n    fa[i] = as[i][0]\n    fb[i] = as[i][1]\n  }\n  return [fa, fb]\n}\n\n/**\n * Creates a new `Array`, prepending an element to every member of the input `Array`.\n *\n * @example\n * import { prependAll } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])\n *\n * @since 2.10.0\n */\nexport const prependAll = <A>(middle: A): ((as: Array<A>) => Array<A>) => {\n  const f = NEA.prependAll(middle)\n  return (as) => (isNonEmpty(as) ? f(as) : [])\n}\n\n/**\n * Creates a new `Array` placing an element in between members of the input `Array`.\n *\n * @example\n * import { intersperse } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])\n *\n * @since 2.9.0\n */\nexport const intersperse = <A>(middle: A): ((as: Array<A>) => Array<A>) => {\n  const f = NEA.intersperse(middle)\n  return (as) => (isNonEmpty(as) ? f(as) : copy(as))\n}\n\n/**\n * Creates a new `Array` rotating the input `Array` by `n` steps.\n *\n * @example\n * import { rotate } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n *\n * @since 2.0.0\n */\nexport const rotate = (n: number): (<A>(as: Array<A>) => Array<A>) => {\n  const f = NEA.rotate(n)\n  return (as) => (isNonEmpty(as) ? f(as) : copy(as))\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test if a value is a member of an `Array`. Takes a `Eq<A>` as a single\n * argument which returns the function to use to search for a value of type `A` in\n * an `Array<A>`.\n *\n * @example\n * import { elem } from 'fp-ts/Array'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(2)), true)\n * assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(0)), false)\n *\n * @since 2.0.0\n */\nexport const elem: <A>(E: Eq<A>) => {\n  (a: A): (as: Array<A>) => boolean\n  (a: A, as: Array<A>): boolean\n} = RA.elem\n\n/**\n * Creates a new `Array` removing duplicate elements, keeping the first occurrence of an element,\n * based on a `Eq<A>`.\n *\n * @example\n * import { uniq } from 'fp-ts/Array'\n * import * as N from 'fp-ts/number'\n *\n * assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])\n *\n * @since 2.0.0\n */\nexport const uniq = <A>(E: Eq<A>): ((as: Array<A>) => Array<A>) => {\n  const f = NEA.uniq(E)\n  return (as) => (isNonEmpty(as) ? f(as) : copy(as))\n}\n\n/**\n * Sort the elements of an array in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,\n * etc...\n *\n * @example\n * import { sortBy } from 'fp-ts/Array'\n * import { contramap } from 'fp-ts/Ord'\n * import * as S from 'fp-ts/string'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * interface Person {\n *   readonly name: string\n *   readonly age: number\n * }\n * const byName = pipe(S.Ord, contramap((p: Person) => p.name))\n * const byAge = pipe(N.Ord, contramap((p: Person) => p.age))\n *\n * const sortByNameByAge = sortBy([byName, byAge])\n *\n * const persons = [{ name: 'a', age: 1 }, { name: 'b', age: 3 }, { name: 'c', age: 2 }, { name: 'b', age: 2 }]\n * assert.deepStrictEqual(sortByNameByAge(persons), [\n *   { name: 'a', age: 1 },\n *   { name: 'b', age: 2 },\n *   { name: 'b', age: 3 },\n *   { name: 'c', age: 2 }\n * ])\n *\n * @since 2.0.0\n */\nexport const sortBy = <B>(ords: Array<Ord<B>>): (<A extends B>(as: Array<A>) => Array<A>) => {\n  const f = NEA.sortBy(ords)\n  return (as) => (isNonEmpty(as) ? f(as) : copy(as))\n}\n\n/**\n * A useful recursion pattern for processing an array to produce a new array, often used for \"chopping\" up the input\n * array. Typically chop is called with some function that will consume an initial prefix of the array and produce a\n * value and the rest of the array.\n *\n * @example\n * import { Eq } from 'fp-ts/Eq'\n * import * as A from 'fp-ts/Array'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * const group = <A>(S: Eq<A>): ((as: Array<A>) => Array<Array<A>>) => {\n *   return A.chop(as => {\n *     const { init, rest } = pipe(as, A.spanLeft((a: A) => S.equals(a, as[0])))\n *     return [init, rest]\n *   })\n * }\n * assert.deepStrictEqual(group(N.Eq)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]])\n *\n * @since 2.0.0\n */\nexport const chop = <A, B>(f: (as: NonEmptyArray<A>) => [B, Array<A>]): ((as: Array<A>) => Array<B>) => {\n  const g = NEA.chop(f)\n  return (as) => (isNonEmpty(as) ? g(as) : [])\n}\n\n/**\n * Splits an `Array` into two pieces, the first piece has max `n` elements.\n *\n * @example\n * import { splitAt } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4, 5]])\n *\n * @since 2.0.0\n */\nexport const splitAt =\n  (n: number) =>\n  <A>(as: Array<A>): [Array<A>, Array<A>] =>\n    n >= 1 && isNonEmpty(as) ? NEA.splitAt(n)(as) : isEmpty(as) ? [copy(as), []] : [[], copy(as)]\n\n/**\n * Splits an array into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\n * the array. 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 `xs`.\n *\n * @example\n * import { chunksOf } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])\n *\n * @since 2.0.0\n */\nexport const chunksOf = (n: number): (<A>(as: Array<A>) => Array<NonEmptyArray<A>>) => {\n  const f = NEA.chunksOf(n)\n  return (as) => (isNonEmpty(as) ? f(as) : [])\n}\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromOptionK =\n  <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) =>\n  (...a: A): Array<B> =>\n    fromOption(f(...a))\n\n/**\n * `Array` comprehension.\n *\n * ```\n * [ f(x, y, ...) | x ← xs, y ← ys, ..., g(x, y, ...) ]\n * ```\n *\n * @example\n * import { comprehension } from 'fp-ts/Array'\n * import { tuple } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(comprehension([[1, 2, 3], ['a', 'b']], tuple, (a, b) => (a + b.length) % 2 === 0), [\n *   [1, 'a'],\n *   [1, 'b'],\n *   [3, 'a'],\n *   [3, 'b']\n * ])\n *\n * @since 2.0.0\n */\nexport function comprehension<A, B, C, D, R>(\n  input: [Array<A>, Array<B>, Array<C>, Array<D>],\n  f: (a: A, b: B, c: C, d: D) => R,\n  g?: (a: A, b: B, c: C, d: D) => boolean\n): Array<R>\nexport function comprehension<A, B, C, R>(\n  input: [Array<A>, Array<B>, Array<C>],\n  f: (a: A, b: B, c: C) => R,\n  g?: (a: A, b: B, c: C) => boolean\n): Array<R>\nexport function comprehension<A, B, R>(\n  input: [Array<A>, Array<B>],\n  f: (a: A, b: B) => R,\n  g?: (a: A, b: B) => boolean\n): Array<R>\nexport function comprehension<A, R>(input: [Array<A>], f: (a: A) => R, g?: (a: A) => boolean): Array<R>\nexport function comprehension<A, R>(\n  input: Array<Array<A>>,\n  f: (...xs: Array<A>) => R,\n  g: (...xs: Array<A>) => boolean = () => true\n): Array<R> {\n  const go = (scope: Array<A>, input: Array<Array<A>>): Array<R> =>\n    isNonEmpty(input)\n      ? flatMap(NEA.head(input), (a) => go(pipe(scope, append(a)), NEA.tail(input)))\n      : g(...scope)\n      ? [f(...scope)]\n      : []\n  return go([], input)\n}\n\n/**\n * @since 2.11.0\n */\nexport const concatW =\n  <B>(second: Array<B>) =>\n  <A>(first: Array<A>): Array<A | B> =>\n    isEmpty(first) ? copy(second) : isEmpty(second) ? copy(first) : (first as Array<A | B>).concat(second)\n\n/**\n * @since 2.11.0\n */\nexport const concat: <A>(second: Array<A>) => (first: Array<A>) => Array<A> = concatW\n\n// TODO: remove non-curried overloading in v3\n/**\n * Creates an array of unique values, in order, from all given arrays using a `Eq` for equality comparisons\n *\n * @example\n * import { union } from 'fp-ts/Array'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2], union(N.Eq)([2, 3])), [1, 2, 3])\n *\n * @since 2.0.0\n */\nexport function union<A>(E: Eq<A>): {\n  (xs: Array<A>): (ys: Array<A>) => Array<A>\n  (xs: Array<A>, ys: Array<A>): Array<A>\n}\nexport function union<A>(E: Eq<A>): (xs: Array<A>, ys?: Array<A>) => Array<A> | ((ys: Array<A>) => Array<A>) {\n  const unionE = NEA.union(E)\n  return (first, second?) => {\n    if (second === undefined) {\n      const unionE = union(E)\n      return (second) => unionE(second, first)\n    }\n    return isNonEmpty(first) && isNonEmpty(second)\n      ? unionE(second)(first)\n      : isNonEmpty(first)\n      ? copy(first)\n      : copy(second)\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Creates an array of unique values that are included in all given arrays using a `Eq` for equality\n * comparisons. The order and references of result values are determined by the first array.\n *\n * @example\n * import { intersection } from 'fp-ts/Array'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2], intersection(N.Eq)([2, 3])), [2])\n *\n * @since 2.0.0\n */\nexport function intersection<A>(E: Eq<A>): {\n  (xs: Array<A>): (ys: Array<A>) => Array<A>\n  (xs: Array<A>, ys: Array<A>): Array<A>\n}\nexport function intersection<A>(E: Eq<A>): (xs: Array<A>, ys?: Array<A>) => Array<A> | ((ys: Array<A>) => Array<A>) {\n  const elemE = elem(E)\n  return (xs, ys?) => {\n    if (ys === undefined) {\n      const intersectionE = intersection(E)\n      return (ys) => intersectionE(ys, xs)\n    }\n    return xs.filter((a) => elemE(a, ys))\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Creates an array of array values not included in the other given array using a `Eq` for equality\n * comparisons. The order and references of result values are determined by the first array.\n *\n * @example\n * import { difference } from 'fp-ts/Array'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2], difference(N.Eq)([2, 3])), [1])\n *\n * @since 2.0.0\n */\nexport function difference<A>(E: Eq<A>): {\n  (xs: Array<A>): (ys: Array<A>) => Array<A>\n  (xs: Array<A>, ys: Array<A>): Array<A>\n}\nexport function difference<A>(E: Eq<A>): (xs: Array<A>, ys?: Array<A>) => Array<A> | ((ys: Array<A>) => Array<A>) {\n  const elemE = elem(E)\n  return (xs, ys?) => {\n    if (ys === undefined) {\n      const differenceE = difference(E)\n      return (ys) => differenceE(ys, xs)\n    }\n    return xs.filter((a) => !elemE(a, ys))\n  }\n}\n\nconst _map: Monad1<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _mapWithIndex: FunctorWithIndex1<URI, number>['mapWithIndex'] = (fa, f) => pipe(fa, mapWithIndex(f))\nconst _ap: Apply1<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n/* istanbul ignore next */\nconst _filter: Filterable1<URI>['filter'] = <A>(fa: Array<A>, predicate: Predicate<A>) => pipe(fa, filter(predicate))\n/* istanbul ignore next */\nconst _filterMap: Filterable1<URI>['filterMap'] = (fa, f) => pipe(fa, filterMap(f))\n/* istanbul ignore next */\nconst _partition: Filterable1<URI>['partition'] = <A>(fa: Array<A>, predicate: Predicate<A>) =>\n  pipe(fa, partition(predicate))\n/* istanbul ignore next */\nconst _partitionMap: Filterable1<URI>['partitionMap'] = (fa, f) => pipe(fa, partitionMap(f))\n/* istanbul ignore next */\nconst _partitionWithIndex: FilterableWithIndex1<URI, number>['partitionWithIndex'] = <A>(\n  fa: Array<A>,\n  predicateWithIndex: (i: number, a: A) => boolean\n) => pipe(fa, partitionWithIndex(predicateWithIndex))\n/* istanbul ignore next */\nconst _partitionMapWithIndex: FilterableWithIndex1<URI, number>['partitionMapWithIndex'] = <A, B, C>(\n  fa: Array<A>,\n  f: (i: number, a: A) => Either<B, C>\n) => pipe(fa, partitionMapWithIndex(f))\n/* istanbul ignore next */\nconst _alt: Alt1<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\nconst _reduce: Foldable1<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\n/* istanbul ignore next */\nconst _foldMap: Foldable1<URI>['foldMap'] = (M) => {\n  const foldMapM = foldMap(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\n/* istanbul ignore next */\nconst _reduceRight: Foldable1<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\n/* istanbul ignore next */\nconst _reduceWithIndex: FoldableWithIndex1<URI, number>['reduceWithIndex'] = (fa, b, f) =>\n  pipe(fa, reduceWithIndex(b, f))\n/* istanbul ignore next */\nconst _foldMapWithIndex: FoldableWithIndex1<URI, number>['foldMapWithIndex'] = (M) => {\n  const foldMapWithIndexM = foldMapWithIndex(M)\n  return (fa, f) => pipe(fa, foldMapWithIndexM(f))\n}\n/* istanbul ignore next */\nconst _reduceRightWithIndex: FoldableWithIndex1<URI, number>['reduceRightWithIndex'] = (fa, b, f) =>\n  pipe(fa, reduceRightWithIndex(b, f))\n/* istanbul ignore next */\nconst _filterMapWithIndex: FilterableWithIndex1<URI, number>['filterMapWithIndex'] = <A, B>(\n  fa: Array<A>,\n  f: (i: number, a: A) => Option<B>\n) => pipe(fa, filterMapWithIndex(f))\n/* istanbul ignore next */\nconst _filterWithIndex: FilterableWithIndex1<URI, number>['filterWithIndex'] = <A>(\n  fa: Array<A>,\n  predicateWithIndex: (i: number, a: A) => boolean\n) => pipe(fa, filterWithIndex(predicateWithIndex))\n/* istanbul ignore next */\nconst _extend: Extend1<URI>['extend'] = (fa, f) => pipe(fa, extend(f))\n/* istanbul ignore next */\nconst _traverse: Traversable1<URI>['traverse'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: Array<A>, f: (a: A) => HKT<F, B>) => HKT<F, Array<B>>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\n/* istanbul ignore next */\nconst _traverseWithIndex: TraversableWithIndex1<URI, number>['traverseWithIndex'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: Array<A>, f: (i: number, a: A) => HKT<F, B>) => HKT<F, Array<B>>) => {\n  const traverseWithIndexF = traverseWithIndex(F)\n  return (ta, f) => pipe(ta, traverseWithIndexF(f))\n}\nconst _chainRecDepthFirst: ChainRec1<URI>['chainRec'] = RA._chainRecDepthFirst as any\nconst _chainRecBreadthFirst: ChainRec1<URI>['chainRec'] = RA._chainRecBreadthFirst as any\n\n/**\n * Given an element of the base type, `of` builds an `Array` containing just that\n * element of the base type (this is useful for building a `Monad`).\n *\n * @example\n * import { of } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(of(\"a\"), [\"a\"]);\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const of: <A>(a: A) => Array<A> = NEA.of\n\n/**\n * Makes an empty `Array`, useful for building a [`Monoid`](#Monoid)\n *\n * @since 2.7.0\n */\nexport const zero: <A>() => Array<A> = () => []\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: Array<A>) => Array<B>`.\n * In practice it applies the base function to each element of the array and collects the\n * results in a new array.\n *\n * @example\n * import { map } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * const f = (n: number) => n * 2;\n * assert.deepStrictEqual(pipe([1, 2, 3], map(f)), [2, 4, 6]);\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => (fa: Array<A>) => Array<B> = (f) => (fa) => fa.map((a) => f(a))\n\n/**\n * @example\n * import { ap, map, of } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * // a curried function with 3 input parameteres\n * const f = (s1: string) => (n: number) => (s2: string) => s1 + n + s2;\n *\n * // let's use `ap` to iterate `f` over an array for each input parameter\n * assert.deepStrictEqual(pipe([\"a\", \"b\"], map(f), ap([1, 2]), ap([\"😀\", \"😫\", \"😎\"])), [\n *   \"a1😀\", \"a1😫\", \"a1😎\",\n *   \"a2😀\", \"a2😫\", \"a2😎\",\n *   \"b1😀\", \"b1😫\", \"b1😎\",\n *   \"b2😀\", \"b2😫\", \"b2😎\",\n * ]);\n *\n * // given Array implements the Applicative interface with the `of` method,\n * // we can write exactly the same thing in a more symmetric way\n * // using `of` on `f` and `ap` on each array in input\n * assert.deepStrictEqual(\n *   pipe(of(f), ap([\"a\", \"b\"]), ap([1, 2]), ap([\"😀\", \"😫\", \"😎\"])),\n *   pipe([\"a\", \"b\"], map(f), ap([1, 2]), ap([\"😀\", \"😫\", \"😎\"]))\n * );\n *\n * @since 2.0.0\n */\nexport const ap: <A>(fa: Array<A>) => <B>(fab: Array<(a: A) => B>) => Array<B> = (fa) =>\n  flatMap((f) => pipe(fa, map(f)))\n\n/**\n * Composes computations in sequence, using the return value of one computation to\n * determine the next computation.\n *\n * In other words it takes a function `f` that produces an array from a single element of\n * the base type `A` and returns a new function which applies `f` to each element of the\n * input array (like [`map`](#map)) and, instead of returning an array of arrays, concatenates the\n * results into a single array (like [`flatten`](#flatten)).\n *\n * @example\n * import { flatMap, map, replicate } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * const f = (n: number) => replicate(n, `${n}`);\n * assert.deepStrictEqual(pipe([1, 2, 3], map(f)), [[\"1\"], [\"2\", \"2\"], [\"3\", \"3\", \"3\"]]);\n * assert.deepStrictEqual(pipe([1, 2, 3], flatMap(f)), [\"1\", \"2\", \"2\", \"3\", \"3\", \"3\"]);\n *\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A, i: number) => Array<B>): (ma: Array<A>) => Array<B>\n  <A, B>(ma: Array<A>, f: (a: A, i: number) => Array<B>): Array<B>\n} = /*#__PURE__*/ dual(\n  2,\n  <A, B>(ma: Array<A>, f: (a: A, i: number) => Array<B>): Array<B> =>\n    pipe(\n      ma,\n      chainWithIndex((i, a) => f(a, i))\n    )\n)\n\n/**\n * Takes an array of arrays of `A` and flattens them into an array of `A`\n * by concatenating the elements of each array in order.\n *\n * @example\n * import { flatten } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(flatten([[\"a\"], [\"b\", \"c\"], [\"d\", \"e\", \"f\"]]), [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]);\n *\n * @category sequencing\n * @since 2.5.0\n */\nexport const flatten: <A>(mma: Array<Array<A>>) => Array<A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * Same as [`map`](#map), but the iterating function takes both the index and the value\n * of the element.\n *\n * @example\n * import { mapWithIndex } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * const f = (i: number, s: string) => `${s} - ${i}`;\n * assert.deepStrictEqual(pipe([\"a\", \"b\", \"c\"], mapWithIndex(f)), [\"a - 0\", \"b - 1\", \"c - 2\"]);\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (fa: Array<A>) => Array<B> = (f) => (fa) =>\n  fa.map((a, i) => f(i, a))\n\n/**\n * Maps an array with an iterating function that takes the index and the value of\n * each element and returns an `Option`. It keeps only the `Some` values discarding\n * the `None`s.\n *\n * Same as [`filterMap`](#filterMap), but with an iterating function which takes also\n * the index as input.\n *\n * @example\n * import { filterMapWithIndex } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n * import { option } from \"fp-ts\";\n *\n * const f = (i: number, s: string) => (i % 2 === 1 ? option.some(s.toUpperCase()) : option.none);\n * assert.deepStrictEqual(pipe([\"a\", \"no\", \"neither\", \"b\"], filterMapWithIndex(f)), [\"NO\", \"B\"]);\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const filterMapWithIndex =\n  <A, B>(f: (i: number, a: A) => Option<B>) =>\n  (fa: Array<A>): Array<B> => {\n    const out: Array<B> = []\n    for (let i = 0; i < fa.length; i++) {\n      const optionB = f(i, fa[i])\n      if (_.isSome(optionB)) {\n        out.push(optionB.value)\n      }\n    }\n    return out\n  }\n\n/**\n * Maps an array with an iterating function that returns an `Option`\n * and it keeps only the `Some` values discarding the `None`s.\n *\n * @example\n * import { filterMap } from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n * import { option } from \"fp-ts\";\n *\n * const f = (s: string) => s.length === 1 ? option.some(s.toUpperCase()) : option.none;\n * assert.deepStrictEqual(pipe([\"a\", \"no\", \"neither\", \"b\"], filterMap(f)), [\"A\", \"B\"]);\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Array<A>) => Array<B> = (f) =>\n  filterMapWithIndex((_, a) => f(a))\n\n/**\n * Compact an array of `Option`s discarding the `None` values and\n * keeping the `Some` values. It returns a new array containing the values of\n * the `Some` options.\n *\n * @example\n * import { compact } from 'fp-ts/Array'\n * import { option } from \"fp-ts\";\n *\n * assert.deepStrictEqual(compact([option.some(\"a\"), option.none, option.some(\"b\")]), [\"a\", \"b\"]);\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const compact: <A>(fa: Array<Option<A>>) => Array<A> = /*#__PURE__*/ filterMap(identity)\n\n/**\n * Separate an array of `Either`s into `Left`s and `Right`s, creating two new arrays:\n * one containing all the left values and one containing all the right values.\n *\n * @example\n * import { separate } from 'fp-ts/Array'\n * import { either } from \"fp-ts\";\n *\n * assert.deepStrictEqual(separate([either.right(\"r1\"), either.left(\"l1\"), either.right(\"r2\")]), {\n *   left: [\"l1\"],\n *   right: [\"r1\", \"r2\"],\n * });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const separate = <A, B>(fa: Array<Either<A, B>>): Separated<Array<A>, Array<B>> => {\n  const left: Array<A> = []\n  const right: Array<B> = []\n  for (const e of fa) {\n    if (e._tag === 'Left') {\n      left.push(e.left)\n    } else {\n      right.push(e.right)\n    }\n  }\n  return separated(left, right)\n}\n\n/**\n * Given an iterating function that is a `Predicate` or a `Refinement`,\n * `filter` creates a new `Array` containing the elements of the original\n * `Array` for which the iterating function is `true`.\n *\n * @example\n * import { filter } from 'fp-ts/Array'\n * import { isString } from \"fp-ts/string\";\n *\n * assert.deepStrictEqual(filter(isString)([\"a\", 1, {}, \"b\", 5]), [\"a\", \"b\"]);\n * assert.deepStrictEqual(filter((x:number) => x > 0)([-3, 1, -2, 5]), [1, 5]);\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Array<B>\n  <A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Array<B>\n  <A>(predicate: Predicate<A>): (as: Array<A>) => Array<A>\n} =\n  <A>(predicate: Predicate<A>) =>\n  (as: Array<A>) =>\n    as.filter(predicate)\n\n/**\n * Given an iterating function that is a `Predicate` or a `Refinement`,\n * `partition` creates two new `Array`s: `right` containing the elements of the original\n * `Array` for which the iterating function is `true`, `left` containing the elements\n * for which it is false.\n *\n * @example\n * import { partition } from 'fp-ts/Array'\n * import { isString } from \"fp-ts/string\";\n *\n * assert.deepStrictEqual(partition(isString)([\"a\", 1, {}, \"b\", 5]), { left: [1, {}, 5], right: [\"a\", \"b\"] });\n * assert.deepStrictEqual(partition((x: number) => x > 0)([-3, 1, -2, 5]), { left: [-3, -2], right: [1, 5] });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (as: Array<A>) => Separated<Array<A>, Array<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(bs: Array<B>) => Separated<Array<B>, Array<B>>\n  <A>(predicate: Predicate<A>): (as: Array<A>) => Separated<Array<A>, Array<A>>\n} = <A>(predicate: Predicate<A>): ((as: Array<A>) => Separated<Array<A>, Array<A>>) =>\n  partitionWithIndex((_, a) => predicate(a))\n\n/**\n * Same as [`partition`](#partition), but passing also the index to the iterating function.\n *\n * @example\n * import { partitionWithIndex } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(partitionWithIndex((index, x: number) => index < 3 && x > 0)([-2, 5, 6, 7]), {\n *   left: [-2, 7],\n *   right: [5, 6],\n * });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const partitionWithIndex: {\n  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (\n    as: Array<A>\n  ) => Separated<Array<A>, Array<B>>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: Array<B>) => Separated<Array<B>, Array<B>>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: Array<A>) => Separated<Array<A>, Array<A>>\n} =\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>) =>\n  (as: Array<A>): Separated<Array<A>, Array<A>> => {\n    const left: Array<A> = []\n    const right: Array<A> = []\n    for (let i = 0; i < as.length; i++) {\n      const b = as[i]\n      if (predicateWithIndex(i, b)) {\n        right.push(b)\n      } else {\n        left.push(b)\n      }\n    }\n    return separated(left, right)\n  }\n\n/**\n * Given an iterating function that returns an `Either`,\n * `partitionMap` applies the iterating function to each element and it creates two `Array`s:\n * `right` containing the values of `Right` results, `left` containing the values of `Left` results.\n *\n * @example\n * import { partitionMap } from 'fp-ts/Array'\n * import { Either, left, right } from \"fp-ts/Either\";\n *\n * const upperIfString = <B>(x: B): Either<B, string> =>\n *   typeof x === \"string\" ? right(x.toUpperCase()) : left(x);\n * assert.deepStrictEqual(partitionMap(upperIfString)([-2, \"hello\", 6, 7, \"world\"]), {\n *   left: [-2, 6, 7],\n *   right: [ 'HELLO', 'WORLD' ],\n * });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const partitionMap: <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Array<A>) => Separated<Array<B>, Array<C>> = (\n  f\n) => partitionMapWithIndex((_, a) => f(a))\n\n/**\n * Same as [`partitionMap`](#partitionMap), but passing also the index to the iterating function.\n *\n * @example\n * import { partitionMapWithIndex } from 'fp-ts/Array'\n * import { Either, left, right } from \"fp-ts/Either\";\n *\n * const upperIfStringBefore3 = <B>(index: number, x: B): Either<B, string> =>\n *   index < 3 && typeof x === \"string\" ? right(x.toUpperCase()) : left(x);\n * assert.deepStrictEqual(partitionMapWithIndex(upperIfStringBefore3)([-2, \"hello\", 6, 7, \"world\"]), {\n *   left: [-2, 6, 7, \"world\"],\n *   right: [\"HELLO\"],\n * });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const partitionMapWithIndex =\n  <A, B, C>(f: (i: number, a: A) => Either<B, C>) =>\n  (fa: Array<A>): Separated<Array<B>, Array<C>> => {\n    const left: Array<B> = []\n    const right: Array<C> = []\n    for (let i = 0; i < fa.length; i++) {\n      const e = f(i, fa[i])\n      if (e._tag === 'Left') {\n        left.push(e.left)\n      } else {\n        right.push(e.right)\n      }\n    }\n    return separated(left, right)\n  }\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @example\n * import * as A from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     A.altW(() => ['a', 'b'])\n *   ),\n *   [1, 2, 3, 'a', 'b']\n * )\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW =\n  <B>(that: LazyArg<Array<B>>) =>\n  <A>(fa: Array<A>): Array<A | B> =>\n    (fa as Array<A | B>).concat(that())\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * In case of `Array` concatenates the inputs into a single array.\n *\n * @example\n * import * as A from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     A.alt(() => [4, 5])\n *   ),\n *   [1, 2, 3, 4, 5]\n * )\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const alt: <A>(that: LazyArg<Array<A>>) => (fa: Array<A>) => Array<A> = altW\n\n/**\n * Same as [`filter`](#filter), but passing also the index to the iterating function.\n *\n * @example\n * import { filterWithIndex } from 'fp-ts/Array';\n *\n * const f = (index: number, x: number) => x > 0 && index <= 2;\n * assert.deepStrictEqual(filterWithIndex(f)([-3, 1, -2, 5]), [1]);\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const filterWithIndex: {\n  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (as: Array<A>) => Array<B>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: Array<B>) => Array<B>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: Array<A>) => Array<A>\n} =\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>) =>\n  (as: Array<A>): Array<A> =>\n    as.filter((b, i) => predicateWithIndex(i, b))\n\n/**\n * Given an iterating function that takes `Array<A>` as input, `extend` returns\n * an array containing the results of the iterating function applied to the whole input\n * `Array`, then to the input `Array` without the first element, then to the input\n * `Array` without the first two elements, etc.\n *\n * @example\n * import { extend } from 'fp-ts/Array'\n *\n * const f = (a: string[]) => a.join(\",\");\n * assert.deepStrictEqual(extend(f)([\"a\", \"b\", \"c\"]), [\"a,b,c\", \"b,c\", \"c\"]);\n *\n * @since 2.0.0\n */\nexport const extend: <A, B>(f: (as: Array<A>) => B) => (as: Array<A>) => Array<B> = (f) => (wa) =>\n  wa.map((_, i) => f(wa.slice(i)))\n\n/**\n * `duplicate` returns an array containing the whole input `Array`,\n * then to the input `Array` dropping the first element, then to the input\n * `Array` dropping the first two elements, etc.\n *\n * @example\n * import { duplicate } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(duplicate([\"a\", \"b\", \"c\"]), [[\"a\", \"b\", \"c\"], [\"b\", \"c\"], [\"c\"]]);\n *\n * @since 2.0.0\n */\nexport const duplicate: <A>(wa: Array<A>) => Array<Array<A>> = /*#__PURE__*/ extend(identity)\n\n/**\n * Map and fold an `Array`.\n * Map the `Array` passing each value to the iterating function.\n * Then fold the results using the provided `Monoid`.\n *\n * @example\n * import { foldMap } from 'fp-ts/Array'\n *\n * const monoid = { concat: (a: string, b: string) => a + b, empty: \"\" };\n * const f = (s: string) => s.toUpperCase()\n * assert.deepStrictEqual(foldMap(monoid)(f)([\"a\", \"b\", \"c\"]), \"ABC\");\n *\n * @category folding\n * @since 2.0.0\n */\nexport const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Array<A>) => M = RA.foldMap\n\n/**\n * Same as [`foldMap`](#foldMap) but passing also the index to the iterating function.\n *\n * @example\n * import { foldMapWithIndex } from 'fp-ts/Array'\n *\n * const monoid = { concat: (a: string, b: string) => a + b, empty: \"\" };\n * const f = (index:number, s: string) => `${s.toUpperCase()}(${index})`\n * assert.deepStrictEqual(foldMapWithIndex(monoid)(f)([\"a\", \"b\", \"c\"]), \"A(0)B(1)C(2)\");\n *\n * @category folding\n * @since 2.0.0\n */\nexport const foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: number, a: A) => M) => (fa: Array<A>) => M =\n  RA.foldMapWithIndex\n\n/**\n * Reduces an `Array`.\n *\n * `reduce` executes the supplied iterating function on each element of the array,\n * in order, passing in the element and the return value from the calculation on the preceding element.\n *\n * The first time that the iterating function is called there is no \"return value of the\n * previous calculation\", the initial value is used in its place.\n *\n * @example\n * import { reduce } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(reduce(5, (acc: number, cur: number) => acc * cur)([2, 3]), 5 * 2 * 3);\n *\n * @category folding\n * @since 2.0.0\n */\nexport const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Array<A>) => B = RA.reduce\n\n/**\n * Same as [`reduce`](#reduce) but passing also the index to the iterating function.\n *\n * @example\n * import { reduceWithIndex } from 'fp-ts/Array'\n *\n * const f = (index: number, acc: string, cur: unknown) =>\n *   acc + (typeof cur === \"string\" ? cur.toUpperCase() + index : \"\");\n * assert.deepStrictEqual(reduceWithIndex(\"\", f)([2, \"a\", \"b\", null]), \"A1B2\");\n *\n * @category folding\n * @since 2.0.0\n */\nexport const reduceWithIndex: <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: Array<A>) => B = RA.reduceWithIndex\n\n/**\n * Same as [`reduce`](#reduce) but applied from the end to the start.\n *\n * *Note*: the iterating function in this case takes the accumulator as the last argument.\n *\n * @example\n * import { reduceRight } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(reduceRight(\"\", (cur: string, acc: string) => acc + cur)([\"a\", \"b\", \"c\"]), \"cba\");\n *\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Array<A>) => B = RA.reduceRight\n\n/**\n * Same as [`reduceRight`](#reduceRight) but passing also the index to the iterating function.\n *\n * @example\n * import { reduceRightWithIndex } from 'fp-ts/Array'\n *\n * const f = (index: number, cur: unknown, acc: string) =>\n *   acc + (typeof cur === \"string\" ? cur.toUpperCase() + index : \"\");\n * assert.deepStrictEqual(reduceRightWithIndex(\"\", f)([2, \"a\", \"b\", null]), \"B2A1\");\n *\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRightWithIndex: <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: Array<A>) => B =\n  RA.reduceRightWithIndex\n\n/**\n * Given an iterating function that returns a `HKT` (higher kinded type), `traverse`\n * applies the iterating function to each element of the `Array` and then [`sequence`](#sequence)-s\n * the results using the provided `Applicative`.\n *\n * E.g. suppose you have an `Array` and you want to format each element with a function\n * that returns a result or an error as `f = (a: A) => Either<Error, B>`, using `traverse`\n * you can apply `f` to all elements and directly obtain as a result an `Either<Error,Array<B>>`\n * i.e. an `Array<B>` if all the results are `B`, or an `Error` if some of the results\n * are `Error`s.\n *\n * @example\n * import { traverse } from 'fp-ts/Array'\n * import { Applicative, left, right } from \"fp-ts/Either\";\n *\n * const f = (x: unknown) =>\n *   typeof x === \"string\" ? right(x.toUpperCase()) : left(new Error(\"not a string\"));\n * assert.deepStrictEqual(traverse(Applicative)(f)([\"a\", \"b\"]), right([\"A\", \"B\"]));\n * assert.deepStrictEqual(traverse(Applicative)(f)([\"a\", 5]), left(new Error(\"not a string\")));\n *\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(f: (a: A) => HKT<F, B>) => (ta: Array<A>) => HKT<F, Array<B>>) => {\n  const traverseWithIndexF = traverseWithIndex(F)\n  return (f) => traverseWithIndexF((_, a) => f(a))\n}\n\n/**\n * `sequence` takes an `Array` where elements are `HKT<A>` (higher kinded type) and,\n * using an applicative of that `HKT`, returns an `HKT` of `Array<A>`.\n * E.g. it can turn an `Array<Either<Error, string>>` into an `Either<Error, Array<string>>`.\n *\n * `sequence` requires an `Applicative` of the `HKT` you are targeting, e.g. to turn an\n * `Array<Either<E, A>>` into an `Either<E, Array<A>>`, it needs an\n * `Applicative` for `Either`, to to turn an `Array<Option<A>>` into an `Option<Array<A>>`,\n * it needs an `Applicative` for `Option`.\n *\n * @example\n * import { sequence } from 'fp-ts/Array'\n * import { Applicative, left, right } from \"fp-ts/Either\";\n *\n * assert.deepStrictEqual(sequence(Applicative)([right(\"a\"), right(\"b\")]), right([\"a\", \"b\"]));\n * assert.deepStrictEqual(\n *   sequence(Applicative)([right(\"a\"), left(new Error(\"not a string\"))]),\n *   left(new Error(\"not a string\"))\n * );\n *\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable1<URI>['sequence'] =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A>(ta: Array<HKT<F, A>>): HKT<F, Array<A>> => {\n    return _reduce(ta, F.of(zero()), (fas, fa) =>\n      F.ap(\n        F.map(fas, (as) => (a: A) => pipe(as, append(a))),\n        fa\n      )\n    )\n  }\n\n/**\n * Same as [`traverse`](#traverse) but passing also the index to the iterating function.\n *\n * @example\n * import { traverseWithIndex } from 'fp-ts/Array'\n * import { Applicative, left, right } from \"fp-ts/Either\";\n *\n * const f = (index:number, x:unknown) =>\n *   typeof x === \"string\" ? right(x.toUpperCase() + index) : left(new Error(\"not a string\"));\n * assert.deepStrictEqual(traverseWithIndex(Applicative)(f)([\"a\", \"b\"]), right([\"A0\", \"B1\"]));\n * assert.deepStrictEqual(traverseWithIndex(Applicative)(f)([\"a\", 5]), left(new Error(\"not a string\")));\n *\n * @category sequencing\n * @since 2.6.3\n */\nexport const traverseWithIndex: PipeableTraverseWithIndex1<URI, number> =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A, B>(f: (i: number, a: A) => HKT<F, B>): ((ta: Array<A>) => HKT<F, Array<B>>) =>\n    reduceWithIndex(F.of(zero()), (i, fbs, a) =>\n      F.ap(\n        F.map(fbs, (bs) => (b: B) => pipe(bs, append(b))),\n        f(i, a)\n      )\n    )\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wither: PipeableWither1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(f: (a: A) => HKT<F, Option<B>>) => (fa: Array<A>) => HKT<F, Array<B>>) => {\n  const _witherF = _wither(F)\n  return (f) => (fa) => _witherF(fa, f)\n}\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wilt: PipeableWilt1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B, C>(f: (a: A) => HKT<F, Either<B, C>>) => (fa: Array<A>) => HKT<F, Separated<Array<B>, Array<C>>>) => {\n  const _wiltF = _wilt(F)\n  return (f) => (fa) => _wiltF(fa, f)\n}\n\n/**\n * `unfold` takes a function `f` which returns an `Option` of a tuple containing an outcome\n * value and an input for the following iteration.\n * `unfold` applies `f` to the initial value `b` and then recursively to the second\n * element of the tuple contained in the returned `option` of the previous\n * calculation until `f` returns `Option.none`.\n *\n * @example\n * import { unfold } from 'fp-ts/Array'\n * import { option } from 'fp-ts'\n *\n * const f = (n: number) => {\n *   if (n <= 0) return option.none;\n *   const returnValue = n * 2;\n *   const inputForNextRound = n - 1;\n *   return option.some([returnValue, inputForNextRound] as const);\n * };\n * assert.deepStrictEqual(unfold(5, f), [10, 8, 6, 4, 2]);\n *\n * @since 2.6.6\n */\nexport const unfold = <A, B>(b: B, f: (b: B) => Option<readonly [A, B]>): Array<A> => {\n  const out: Array<A> = []\n  let bb: B = b\n  // eslint-disable-next-line no-constant-condition\n  while (true) {\n    const mt = f(bb)\n    if (_.isSome(mt)) {\n      const [a, b] = mt.value\n      out.push(a)\n      bb = b\n    } else {\n      break\n    }\n  }\n  return out\n}\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Array'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Array<A>\n  }\n}\n\n/**\n * `getShow` makes a `Show` for an `Array<A>` from a `Show` for\n * an `A`.\n *\n * @example\n * import { getShow } from 'fp-ts/Array'\n *\n * const numShow = { show: (n: number) => (n >= 0 ? `${n}` : `(${-n})`) };\n * assert.deepStrictEqual(getShow(numShow).show([-2, -1, 0, 1]), \"[(2), (1), 0, 1]\");\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getShow: <A>(S: Show<A>) => Show<Array<A>> = RA.getShow\n\n/**\n * Get a `Semigroup` based on the concatenation of `Array`s.\n * See also [`getMonoid`](#getMonoid).\n *\n * @example\n * import { getSemigroup } from 'fp-ts/Array'\n *\n * const S = getSemigroup<number>();\n * assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1, 2, 2, 3]);\n *\n * @category instances\n * @since 2.10.0\n */\nexport const getSemigroup = <A = never>(): Semigroup<Array<A>> => ({\n  concat: (first, second) => first.concat(second)\n})\n\n/**\n * Returns a `Monoid` for `Array<A>` based on the concatenation of `Array`s.\n *\n * @example\n * import { getMonoid } from 'fp-ts/Array'\n *\n * const M = getMonoid<number>()\n * assert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4])\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getMonoid = <A = never>(): Monoid<Array<A>> => ({\n  concat: getSemigroup<A>().concat,\n  empty: []\n})\n\n/**\n * Derives an `Eq` over the `Array` of a given element type from the `Eq` of that type. The derived `Eq` defines two\n * arrays as equal if all elements of both arrays are compared equal pairwise with the given `E`. In case of arrays of\n * different lengths, the result is non equality.\n *\n * @example\n * import * as S from 'fp-ts/string'\n * import { getEq } from 'fp-ts/Array'\n *\n * const E = getEq(S.Eq)\n * assert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true)\n * assert.strictEqual(E.equals(['a'], []), false)\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getEq: <A>(E: Eq<A>) => Eq<Array<A>> = RA.getEq\n\n/**\n * Derives an `Ord` over the `Array` of a given element type from the `Ord` of that type. The ordering between two such\n * arrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in\n * case of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have\n * the same length, the result is equality.\n *\n * @example\n * import { getOrd } from 'fp-ts/Array'\n * import * as S from 'fp-ts/string'\n *\n * const O = getOrd(S.Ord)\n * assert.strictEqual(O.compare(['b'], ['a']), 1)\n * assert.strictEqual(O.compare(['a'], ['a']), 0)\n * assert.strictEqual(O.compare(['a'], ['b']), -1)\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getOrd: <A>(O: Ord<A>) => Ord<Array<A>> = RA.getOrd\n\n/**\n * Get a `Semigroup` based on the union of the elements of `Array`s.\n * Elements which equal according to the provided `Eq` are included\n * only once in the result.\n * See also [`getUnionMonoid`](#getUnionMonoid).\n *\n * @example\n * import { getUnionSemigroup } from 'fp-ts/Array';\n * import { Eq } from 'fp-ts/number';\n *\n * const S = getUnionSemigroup<number>(Eq);\n * assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1, 2, 3]);\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <A>(E: Eq<A>): Semigroup<Array<A>> => {\n  const unionE = union(E)\n  return {\n    concat: (first, second) => unionE(second)(first)\n  }\n}\n\n/**\n * Get a `Monoid` based on the union of the elements of `Array`s.\n * Elements which equal according to the provided `Eq` are included\n * only once in the result.\n *\n * @example\n * import { getUnionMonoid } from 'fp-ts/Array'\n * import { Eq } from 'fp-ts/number';\n *\n * const M = getUnionMonoid<number>(Eq);\n * assert.deepStrictEqual(M.concat([1, 2], [2, 3]), [1, 2, 3]);\n * assert.deepStrictEqual(M.empty,[]);\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionMonoid = <A>(E: Eq<A>): Monoid<Array<A>> => ({\n  concat: getUnionSemigroup(E).concat,\n  empty: []\n})\n\n/**\n * Get a `Semigroup` based on the intersection of the elements of `Array`s.\n * Only elements present in the two arrays which are equal according to the\n * provided `Eq` are included in the result.\n *\n * @example\n * import { getIntersectionSemigroup } from 'fp-ts/Array'\n * import { Eq } from 'fp-ts/number';\n *\n * const S = getIntersectionSemigroup<number>(Eq);\n * assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [2]);\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getIntersectionSemigroup = <A>(E: Eq<A>): Semigroup<Array<A>> => {\n  const intersectionE = intersection(E)\n  return {\n    concat: (first, second) => intersectionE(second)(first)\n  }\n}\n\n/**\n * Get a `Magma` for `Array` where the `concat` function is the differnce between\n * the first and the second array, i.e. the result contains all the elements of the\n * first array for which their is no equal element in the second array according\n * to the `Eq` provided.\n *\n *\n * @example\n * import { getDifferenceMagma } from 'fp-ts/Array'\n * import { Eq } from 'fp-ts/number';\n *\n * const S = getDifferenceMagma<number>(Eq);\n * assert.deepStrictEqual(S.concat([1, 2], [2, 3]), [1]);\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getDifferenceMagma = <A>(E: Eq<A>): Magma<Array<A>> => {\n  const differenceE = difference(E)\n  return {\n    concat: (first, second) => differenceE(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Given an input an `Array` of functions, `flap` returns an `Array` containing\n * the results of applying each function to the given input.\n *\n * @example\n * import { flap } from 'fp-ts/Array'\n *\n * const funs = [\n *   (n: number) => `Double: ${n * 2}`,\n *   (n: number) => `Triple: ${n * 3}`,\n *   (n: number) => `Square: ${n * n}`,\n * ];\n * assert.deepStrictEqual(flap(4)(funs), ['Double: 8', 'Triple: 12', 'Square: 16']);\n *\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FunctorWithIndex: FunctorWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.5.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.5.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as A from 'fp-ts/Array'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     A.chainFirst(() => ['a', 'b'])\n *   ),\n *   [1, 1, 2, 2, 3, 3]\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     A.chainFirst(() => [])\n *   ),\n *   []\n * )\n *\n * @category sequencing\n * @since 2.0.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => Array<B>) => (first: Array<A>) => Array<A> =\n  /*#__PURE__*/ chainFirst_(Chain)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Unfoldable: Unfoldable1<URI> = {\n  URI,\n  unfold\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt1<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const Zero: Zero1<URI> = {\n  URI,\n  zero\n}\n\n/**\n * @category do notation\n * @since 2.11.0\n */\nexport const guard = /*#__PURE__*/ guard_(Zero, Pointed)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alternative: Alternative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  alt: _alt,\n  zero\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Extend: Extend1<URI> = {\n  URI,\n  map: _map,\n  extend: _extend\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Compactable: Compactable1<URI> = {\n  URI,\n  compact,\n  separate\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Filterable: Filterable1<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FilterableWithIndex: FilterableWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  partitionMapWithIndex: _partitionMapWithIndex,\n  partitionWithIndex: _partitionWithIndex,\n  filterMapWithIndex: _filterMapWithIndex,\n  filterWithIndex: _filterWithIndex\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable1<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FoldableWithIndex: FoldableWithIndex1<URI, number> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable1<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const TraversableWithIndex: TraversableWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex,\n  traverse: _traverse,\n  sequence,\n  traverseWithIndex: _traverseWithIndex\n}\n\nconst _wither: Witherable1<URI>['wither'] = /*#__PURE__*/ witherDefault(Traversable, Compactable)\nconst _wilt: Witherable1<URI>['wilt'] = /*#__PURE__*/ wiltDefault(Traversable, Compactable)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Witherable: Witherable1<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  wither: _wither,\n  wilt: _wilt\n}\n\n/**\n * @category sequencing\n * @since 2.11.0\n */\nexport const chainRecDepthFirst: <A, B>(f: (a: A) => Array<Either<A, B>>) => (a: A) => Array<B> =\n  RA.chainRecDepthFirst as any\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const ChainRecDepthFirst: ChainRec1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap,\n  chainRec: _chainRecDepthFirst\n}\n\n/**\n * @category sequencing\n * @since 2.11.0\n */\nexport const chainRecBreadthFirst: <A, B>(f: (a: A) => Array<Either<A, B>>) => (a: A) => Array<B> =\n  RA.chainRecBreadthFirst as any\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const ChainRecBreadthFirst: ChainRec1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap,\n  chainRec: _chainRecBreadthFirst\n}\n\n/**\n * Filter values inside a context.\n *\n * @since 2.11.0\n */\nexport const filterE = /*#__PURE__*/ filterE_(Witherable)\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromEither: FromEither1<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => Array<B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n// -------------------------------------------------------------------------------------\n// unsafe\n// -------------------------------------------------------------------------------------\n\n/**\n * @category unsafe\n * @since 2.0.0\n */\nexport const unsafeInsertAt: <A>(i: number, a: A, as: Array<A>) => NonEmptyArray<A> = NEA.unsafeInsertAt\n\n/**\n * @category unsafe\n * @since 2.0.0\n */\nexport const unsafeUpdateAt = <A>(i: number, a: A, as: Array<A>): Array<A> =>\n  isNonEmpty(as) ? NEA.unsafeUpdateAt(i, a, as) : []\n\n/**\n * @category unsafe\n * @since 2.0.0\n */\nexport const unsafeDeleteAt = <A>(i: number, as: Array<A>): Array<A> => {\n  const xs = as.slice()\n  xs.splice(i, 1)\n  return xs\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * `every` tells if the provided predicate holds true for every element in the `Array`.\n *\n * @example\n * import { every } from 'fp-ts/Array'\n *\n * assert.equal(every((x: number) => x >= 0)([1, 2, 3]), true);\n * assert.equal(every((x: number) => x >= 0)([-1, 2, 3]), false);\n *\n * @since 2.9.0\n */\nexport const every: {\n  <A, B extends A>(refinement: Refinement<A, B>): Refinement<Array<A>, Array<B>>\n  <A>(predicate: Predicate<A>): Predicate<Array<A>>\n} = RA.every as any\n\n/**\n * `some` tells if the provided predicate holds true at least for one element in the `Array`.\n *\n * @example\n * import { some } from 'fp-ts/Array'\n *\n * assert.equal(some((x: number) => x >= 0)([1, 2, 3]), true);\n * assert.equal(some((x: number) => x >= 10)([1, 2, 3]), false);\n *\n * @since 2.9.0\n */\nexport const some =\n  <A>(predicate: Predicate<A>) =>\n  (as: Array<A>): as is NonEmptyArray<A> =>\n    as.some(predicate)\n\n/**\n * Alias of [`some`](#some)\n *\n * @since 2.11.0\n */\nexport const exists: <A>(predicate: Predicate<A>) => (as: Array<A>) => as is NEA.NonEmptyArray<A> = some\n\n/**\n * Places an element in between members of an `Array`, then folds the results using the provided `Monoid`.\n *\n * @example\n * import * as S from 'fp-ts/string'\n * import { intercalate } from 'fp-ts/Array'\n *\n * assert.deepStrictEqual(intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c')\n *\n * @since 2.12.0\n */\nexport const intercalate: <A>(M: Monoid<A>) => (middle: A) => (as: Array<A>) => A = RA.intercalate\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: Array<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ bind_(Chain)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <A, B>(f: (a: A) => Array<B>) => (ma: Array<A>) => Array<B> = flatMap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use `NonEmptyArray` module instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const range = NEA.range\n\n/**\n * Use a new `[]` instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const empty: Array<never> = []\n\n/**\n * Use `prepend` instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const cons = NEA.cons\n\n/**\n * Use `append` instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const snoc = NEA.snoc\n\n/**\n * Use `prependAll` instead\n *\n * @category zone of death\n * @since 2.9.0\n * @deprecated\n */\nexport const prependToAll = prependAll\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `A.Functor` instead of `A.array`\n * (where `A` is from `import A from 'fp-ts/Array'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const array: FunctorWithIndex1<URI, number> &\n  Monad1<URI> &\n  Unfoldable1<URI> &\n  Alternative1<URI> &\n  Extend1<URI> &\n  FilterableWithIndex1<URI, number> &\n  FoldableWithIndex1<URI, number> &\n  TraversableWithIndex1<URI, number> &\n  Witherable1<URI> = {\n  URI,\n  compact,\n  separate,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  mapWithIndex: _mapWithIndex,\n  partitionMapWithIndex: _partitionMapWithIndex,\n  partitionWithIndex: _partitionWithIndex,\n  filterMapWithIndex: _filterMapWithIndex,\n  filterWithIndex: _filterWithIndex,\n  alt: _alt,\n  zero,\n  unfold,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex,\n  traverseWithIndex: _traverseWithIndex,\n  extend: _extend,\n  wither: _wither,\n  wilt: _wilt\n}\n"
  },
  {
    "path": "src/Bifunctor.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { HKT2, Kind2, Kind3, Kind4, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Bifunctor<F> {\n  readonly URI: F\n  readonly bimap: <E, A, G, B>(fea: HKT2<F, E, A>, f: (e: E) => G, g: (a: A) => B) => HKT2<F, G, B>\n  readonly mapLeft: <E, A, G>(fea: HKT2<F, E, A>, f: (e: E) => G) => HKT2<F, G, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Bifunctor2<F extends URIS2> {\n  readonly URI: F\n  readonly bimap: <E, A, G, B>(fea: Kind2<F, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind2<F, G, B>\n  readonly mapLeft: <E, A, G>(fea: Kind2<F, E, A>, f: (e: E) => G) => Kind2<F, G, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Bifunctor2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly bimap: <A, G, B>(fea: Kind2<F, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind2<F, G, B>\n  readonly mapLeft: <A, M>(fea: Kind2<F, E, A>, f: (e: E) => M) => Kind2<F, M, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Bifunctor3<F extends URIS3> {\n  readonly URI: F\n  readonly bimap: <R, E, A, G, B>(fea: Kind3<F, R, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind3<F, R, G, B>\n  readonly mapLeft: <R, E, A, G>(fea: Kind3<F, R, E, A>, f: (e: E) => G) => Kind3<F, R, G, A>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Bifunctor3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly bimap: <R, A, G, B>(fea: Kind3<F, R, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind3<F, R, G, B>\n  readonly mapLeft: <R, A, G>(fea: Kind3<F, R, E, A>, f: (e: E) => G) => Kind3<F, R, G, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Bifunctor4<F extends URIS4> {\n  readonly URI: F\n  readonly bimap: <S, R, E, A, G, B>(fea: Kind4<F, S, R, E, A>, f: (e: E) => G, g: (a: A) => B) => Kind4<F, S, R, G, B>\n  readonly mapLeft: <S, R, E, A, G>(fea: Kind4<F, S, R, E, A>, f: (e: E) => G) => Kind4<F, S, R, G, A>\n}\n"
  },
  {
    "path": "src/BooleanAlgebra.ts",
    "content": "/**\n * Boolean algebras are Heyting algebras with the additional constraint that the law of the excluded middle is true\n * (equivalently, double-negation is true).\n *\n * Instances should satisfy the following laws in addition to the `HeytingAlgebra` laws:\n *\n * - Excluded middle: `a ∨ ¬a <-> 1`\n *\n * Boolean algebras generalize classical logic: one is equivalent to \"true\" and zero is equivalent to \"false\".\n *\n * @since 2.0.0\n */\nimport { getBooleanAlgebra } from './function'\nimport { HeytingAlgebra } from './HeytingAlgebra'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface BooleanAlgebra<A> extends HeytingAlgebra<A> {}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Every boolean algebras has a dual algebra, which involves reversing one/zero as well as join/meet.\n *\n * @since 2.10.0\n */\nexport const reverse = <A>(B: BooleanAlgebra<A>): BooleanAlgebra<A> => ({\n  meet: (x, y) => B.join(x, y),\n  join: (x, y) => B.meet(x, y),\n  zero: B.one,\n  one: B.zero,\n  implies: (x, y) => B.join(B.not(x), y),\n  not: B.not\n})\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const booleanAlgebraVoid: BooleanAlgebra<void> = {\n  meet: () => undefined,\n  join: () => undefined,\n  zero: undefined,\n  one: undefined,\n  implies: () => undefined,\n  not: () => undefined\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`reverse`](#reverse) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getDualBooleanAlgebra = reverse\n\n/**\n * Use [`BooleanAlgebra`](./boolean.ts.html#booleanalgebra) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const booleanAlgebraBoolean: BooleanAlgebra<boolean> = {\n  meet: (x, y) => x && y,\n  join: (x, y) => x || y,\n  zero: false,\n  one: true,\n  implies: (x, y) => !x || y,\n  not: (x) => !x\n}\n\n/**\n * Use [`getBooleanAlgebra`](./function.ts.html#getbooleanalgebra) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getFunctionBooleanAlgebra: <B>(B: BooleanAlgebra<B>) => <A = never>() => BooleanAlgebra<(a: A) => B> =\n  getBooleanAlgebra\n"
  },
  {
    "path": "src/Bounded.ts",
    "content": "/**\n * The `Bounded` type class represents totally ordered types that have an upper and lower boundary.\n *\n * Instances should satisfy the following law in addition to the `Ord` laws:\n *\n * - Bounded: `bottom <= a <= top`\n *\n * @since 2.0.0\n */\nimport * as O from './Ord'\n\nimport Ord = O.Ord\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Bounded<A> extends Ord<A> {\n  readonly top: A\n  readonly bottom: A\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Clamp a value between bottom and top values.\n *\n * @category utils\n * @since 2.12.0\n */\nexport const clamp = <A>(B: Bounded<A>): ((a: A) => A) => O.clamp(B)(B.bottom, B.top)\n\n/**\n * Reverses the Ord of a bound and swaps top and bottom values.\n *\n * @category utils\n * @since 2.12.0\n */\nexport const reverse = <A>(B: Bounded<A>): Bounded<A> => {\n  const R = O.reverse(B)\n  return {\n    equals: R.equals,\n    compare: R.compare,\n    top: B.bottom,\n    bottom: B.top\n  }\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`Bounded`](./number.ts.html#bounded) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const boundedNumber: Bounded<number> = {\n  equals: O.ordNumber.equals,\n  compare: O.ordNumber.compare,\n  top: Infinity,\n  bottom: -Infinity\n}\n"
  },
  {
    "path": "src/BoundedDistributiveLattice.ts",
    "content": "/**\n * A `BoundedDistributiveLattice` is a lattice that is both bounded and distributive\n *\n * @since 2.0.0\n */\nimport { BoundedLattice } from './BoundedLattice'\nimport { DistributiveLattice, getMinMaxDistributiveLattice } from './DistributiveLattice'\nimport { Ord } from './Ord'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface BoundedDistributiveLattice<A> extends BoundedLattice<A>, DistributiveLattice<A> {}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function getMinMaxBoundedDistributiveLattice<A>(O: Ord<A>): (min: A, max: A) => BoundedDistributiveLattice<A> {\n  const L = getMinMaxDistributiveLattice(O)\n  return (min, max) => ({\n    join: L.join,\n    meet: L.meet,\n    zero: min,\n    one: max\n  })\n}\n"
  },
  {
    "path": "src/BoundedJoinSemilattice.ts",
    "content": "/**\n * A `BoundedJoinSemilattice` must satisfy the following laws in addition to `JoinSemilattice` laws:\n *\n * - `a ∨ 0 <-> a`\n *\n * @since 2.0.0\n */\nimport { JoinSemilattice } from './JoinSemilattice'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface BoundedJoinSemilattice<A> extends JoinSemilattice<A> {\n  readonly zero: A\n}\n"
  },
  {
    "path": "src/BoundedLattice.ts",
    "content": "/**\n * A `BoundedLattice` must satisfy the following in addition to `BoundedMeetSemilattice` and `BoundedJoinSemilattice` laws:\n *\n * - Absorption law for meet: `a ∧ (a ∨ b) <-> a`\n * - Absorption law for join: `a ∨ (a ∧ b) <-> a`\n *\n * @since 2.0.0\n */\nimport { BoundedJoinSemilattice } from './BoundedJoinSemilattice'\nimport { BoundedMeetSemilattice } from './BoundedMeetSemilattice'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface BoundedLattice<A> extends BoundedJoinSemilattice<A>, BoundedMeetSemilattice<A> {}\n"
  },
  {
    "path": "src/BoundedMeetSemilattice.ts",
    "content": "/**\n * A `BoundedMeetSemilattice` must satisfy the following laws in addition to `MeetSemilattice` laws:\n *\n * - `a ∧ 1 <-> a`\n *\n * @since 2.0.0\n */\nimport { MeetSemilattice } from './MeetSemilattice'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface BoundedMeetSemilattice<A> extends MeetSemilattice<A> {\n  readonly one: A\n}\n"
  },
  {
    "path": "src/Category.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { HKT2, Kind2, Kind3, Kind4, URIS2, URIS3, URIS4 } from './HKT'\nimport { Semigroupoid, Semigroupoid2, Semigroupoid3, Semigroupoid4 } from './Semigroupoid'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Category<F> extends Semigroupoid<F> {\n  readonly id: <A>() => HKT2<F, A, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Category2<F extends URIS2> extends Semigroupoid2<F> {\n  readonly id: <A>() => Kind2<F, A, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Category3<F extends URIS3> extends Semigroupoid3<F> {\n  readonly id: <R, A>() => Kind3<F, R, A, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Category4<F extends URIS4> extends Semigroupoid4<F> {\n  readonly id: <S, R, A>() => Kind4<F, S, R, A, A>\n}\n"
  },
  {
    "path": "src/Chain.ts",
    "content": "/**\n * The `Chain` type class extends the `Apply` type class with a `chain` operation which composes computations in\n * sequence, using the return value of one computation to determine the next computation.\n *\n * Instances must satisfy the following law in addition to the `Apply` laws:\n *\n * 1. Associativity: `F.chain(F.chain(fa, afb), bfc) <-> F.chain(fa, a => F.chain(afb(a), bfc))`\n *\n * Note. `Apply`'s `ap` can be derived: `(fab, fa) => F.chain(fab, f => F.map(fa, f))`\n *\n * @since 2.0.0\n */\nimport { Apply, Apply1, Apply2, Apply2C, Apply3, Apply3C, Apply4 } from './Apply'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Chain<F> extends Apply<F> {\n  readonly chain: <A, B>(fa: HKT<F, A>, f: (a: A) => HKT<F, B>) => HKT<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Chain1<F extends URIS> extends Apply1<F> {\n  readonly chain: <A, B>(fa: Kind<F, A>, f: (a: A) => Kind<F, B>) => Kind<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Chain2<F extends URIS2> extends Apply2<F> {\n  readonly chain: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => Kind2<F, E, B>) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Chain2C<F extends URIS2, E> extends Apply2C<F, E> {\n  readonly chain: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => Kind2<F, E, B>) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Chain3<F extends URIS3> extends Apply3<F> {\n  readonly chain: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Kind3<F, R, E, B>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Chain3C<F extends URIS3, E> extends Apply3C<F, E> {\n  readonly chain: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Kind3<F, R, E, B>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Chain4<F extends URIS4> extends Apply4<F> {\n  readonly chain: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => Kind4<F, S, R, E, B>) => Kind4<F, S, R, E, B>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function chainFirst<M extends URIS4>(\n  M: Chain4<M>\n): <A, S, R, E, _>(f: (a: A) => Kind4<M, S, R, E, _>) => (first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport function chainFirst<M extends URIS3>(\n  M: Chain3<M>\n): <A, R, E, _>(f: (a: A) => Kind3<M, R, E, _>) => (first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirst<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <A, R, _>(f: (a: A) => Kind3<M, R, E, _>) => (first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirst<M extends URIS2>(\n  M: Chain2<M>\n): <A, E, _>(f: (a: A) => Kind2<M, E, _>) => (first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport function chainFirst<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <A, _>(f: (a: A) => Kind2<M, E, _>) => (first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport function chainFirst<M extends URIS>(\n  M: Chain1<M>\n): <A, _>(f: (a: A) => Kind<M, _>) => (first: Kind<M, A>) => Kind<M, A>\nexport function chainFirst<M>(M: Chain<M>): <A, _>(f: (a: A) => HKT<M, _>) => (first: HKT<M, A>) => HKT<M, A>\nexport function chainFirst<M>(M: Chain<M>): <A, _>(f: (a: A) => HKT<M, _>) => (first: HKT<M, A>) => HKT<M, A> {\n  const tapM = tap(M)\n  return (f) => (first) => tapM(first, f)\n}\n\n/** @internal */\nexport function tap<M extends URIS4>(\n  M: Chain4<M>\n): <S, R1, E1, A, R2, E2, _>(\n  first: Kind4<M, S, R1, E1, A>,\n  f: (a: A) => Kind4<M, S, R2, E2, _>\n) => Kind4<M, S, R1 & R2, E1 | E2, A>\n/** @internal */\nexport function tap<M extends URIS3>(\n  M: Chain3<M>\n): <R1, E1, A, R2, E2, _>(first: Kind3<M, R1, E1, A>, f: (a: A) => Kind3<M, R2, E2, _>) => Kind3<M, R1 & R2, E1 | E2, A>\n/** @internal */\nexport function tap<M extends URIS2>(\n  M: Chain2<M>\n): <E1, A, E2, _>(first: Kind2<M, E1, A>, f: (a: A) => Kind2<M, E2, _>) => Kind2<M, E1 | E2, A>\n/** @internal */\nexport function tap<M extends URIS>(M: Chain1<M>): <A, _>(first: Kind<M, A>, f: (a: A) => Kind<M, _>) => Kind<M, A>\n/** @internal */\nexport function tap<M>(M: Chain<M>): <A, _>(first: HKT<M, A>, f: (a: A) => HKT<M, _>) => HKT<M, A>\n/** @internal */\nexport function tap<M>(M: Chain<M>): <A, _>(first: HKT<M, A>, f: (a: A) => HKT<M, _>) => HKT<M, A> {\n  return (first, f) => M.chain(first, (a) => M.map(f(a), () => a))\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function bind<M extends URIS4>(\n  M: Chain4<M>\n): <N extends string, A, S, R, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind4<M, S, R, E, B>\n) => (ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function bind<M extends URIS3>(\n  M: Chain3<M>\n): <N extends string, A, R, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind3<M, R, E, B>\n) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function bind<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <N extends string, A, R, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind3<M, R, E, B>\n) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function bind<M extends URIS2>(\n  M: Chain2<M>\n): <N extends string, A, E, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind2<M, E, B>\n) => (ma: Kind2<M, E, A>) => Kind2<M, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function bind<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind2<M, E, B>\n) => (ma: Kind2<M, E, A>) => Kind2<M, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function bind<M extends URIS>(\n  M: Chain1<M>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Kind<M, B>\n) => (ma: Kind<M, A>) => Kind<M, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function bind<M>(\n  M: Chain<M>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => HKT<M, B>\n) => (ma: HKT<M, A>) => HKT<M, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nexport function bind<M>(\n  M: Chain<M>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => HKT<M, B>\n) => (ma: HKT<M, A>) => HKT<M, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> {\n  return (name, f) => (ma) => M.chain(ma, (a) => M.map(f(a), (b) => Object.assign({}, a, { [name]: b }) as any))\n}\n"
  },
  {
    "path": "src/ChainRec.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C, Chain4 } from './Chain'\nimport { Either } from './Either'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface ChainRec<F> extends Chain<F> {\n  readonly chainRec: <A, B>(a: A, f: (a: A) => HKT<F, Either<A, B>>) => HKT<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface ChainRec1<F extends URIS> extends Chain1<F> {\n  readonly chainRec: <A, B>(a: A, f: (a: A) => Kind<F, Either<A, B>>) => Kind<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface ChainRec2<F extends URIS2> extends Chain2<F> {\n  readonly chainRec: <E, A, B>(a: A, f: (a: A) => Kind2<F, E, Either<A, B>>) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface ChainRec2C<F extends URIS2, E> extends Chain2C<F, E> {\n  readonly chainRec: <A, B>(a: A, f: (a: A) => Kind2<F, E, Either<A, B>>) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface ChainRec3<F extends URIS3> extends Chain3<F> {\n  readonly chainRec: <R, E, A, B>(a: A, f: (a: A) => Kind3<F, R, E, Either<A, B>>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface ChainRec3C<F extends URIS3, E> extends Chain3C<F, E> {\n  readonly chainRec: <R, A, B>(a: A, f: (a: A) => Kind3<F, R, E, Either<A, B>>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface ChainRec4<F extends URIS4> extends Chain4<F> {\n  readonly chainRec: <S, R, E, A, B>(a: A, f: (a: A) => Kind4<F, S, R, E, Either<A, B>>) => Kind4<F, S, R, E, B>\n}\n\n/**\n * @since 2.0.0\n */\nexport const tailRec = <A, B>(startWith: A, f: (a: A) => Either<A, B>): B => {\n  let ab = f(startWith)\n  while (ab._tag === 'Left') {\n    ab = f(ab.left)\n  }\n  return ab.right\n}\n"
  },
  {
    "path": "src/Choice.ts",
    "content": "/**\n * The `Choice` class extends `Profunctor` with combinators for working with\n * sum types.\n *\n * `left` and `right` lift values in a `Profunctor` to act on the `Left` and\n * `Right` components of a sum, respectively.\n *\n * Looking at `Choice` through the intuition of inputs and outputs\n * yields the following type signature:\n *\n * ```purescript\n * left ::  forall input output a. p input output -> p (Either input a) (Either output a)\n * right :: forall input output a. p input output -> p (Either a input) (Either a output)\n * ```\n *\n * If we specialize the profunctor `p` to the `function` arrow, we get the following type\n * signatures:\n *\n * ```purescript\n * left ::  forall input output a. (input -> output) -> (Either input a) -> (Either output a)\n * right :: forall input output a. (input -> output) -> (Either a input) -> (Either a output)\n * ```\n *\n * When the `profunctor` is `Function` application, `left` allows you to map a function over the\n * left side of an `Either`, and `right` maps it over the right side (same as `map` would do).\n *\n * Adapted from https://github.com/purescript/purescript-profunctor/blob/master/src/Data/Profunctor/Choice.purs\n *\n * @since 2.0.0\n */\nimport { Category, Category2, Category3, Category4 } from './Category'\nimport { Either } from './Either'\nimport { identity } from './function'\nimport { HKT2, Kind2, Kind3, Kind4, URIS2, URIS3, URIS4 } from './HKT'\nimport { Profunctor, Profunctor2, Profunctor3, Profunctor4 } from './Profunctor'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Choice<F> extends Profunctor<F> {\n  readonly left: <A, B, C>(pab: HKT2<F, A, B>) => HKT2<F, Either<A, C>, Either<B, C>>\n  readonly right: <A, B, C>(pbc: HKT2<F, B, C>) => HKT2<F, Either<A, B>, Either<A, C>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Choice2<F extends URIS2> extends Profunctor2<F> {\n  readonly left: <A, B, C>(pab: Kind2<F, A, B>) => Kind2<F, Either<A, C>, Either<B, C>>\n  readonly right: <A, B, C>(pbc: Kind2<F, B, C>) => Kind2<F, Either<A, B>, Either<A, C>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Choice3<F extends URIS3> extends Profunctor3<F> {\n  readonly left: <R, A, B, C>(pab: Kind3<F, R, A, B>) => Kind3<F, R, Either<A, C>, Either<B, C>>\n  readonly right: <R, A, B, C>(pbc: Kind3<F, R, B, C>) => Kind3<F, R, Either<A, B>, Either<A, C>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Choice4<F extends URIS4> extends Profunctor4<F> {\n  readonly left: <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, Either<A, C>, Either<B, C>>\n  readonly right: <S, R, A, B, C>(pbc: Kind4<F, S, R, B, C>) => Kind4<F, S, R, Either<A, B>, Either<A, C>>\n}\n\n/**\n * Compose a value acting on a sum from two values, each acting on one of\n * the components of the sum.\n *\n * Specializing `split` to function application would look like this:\n *\n * ```purescript\n * split :: forall a b c d. (a -> b) -> (c -> d) -> (Either a c) -> (Either b d)\n * ```\n *\n * We take two functions, `f` and `g`, and we transform them into a single function which\n * takes an `Either`and maps `f` over the left side and `g` over the right side.  Just like\n * `bimap` would do for the `Bifunctor` instance of `Either`.\n *\n * @since 2.10.0\n */\nexport function split<P extends URIS4>(\n  P: Choice4<P>,\n  C: Category4<P>\n): <S, R, A, B, C, D>(\n  pab: Kind4<P, S, R, A, B>,\n  pcd: Kind4<P, S, R, C, D>\n) => Kind4<P, S, R, Either<A, C>, Either<B, D>>\nexport function split<P extends URIS3>(\n  P: Choice3<P>,\n  C: Category3<P>\n): <R, A, B, C, D>(pab: Kind3<P, R, A, B>, pcd: Kind3<P, R, C, D>) => Kind3<P, R, Either<A, C>, Either<B, D>>\nexport function split<P extends URIS2>(\n  P: Choice2<P>,\n  C: Category2<P>\n): <A, B, C, D>(pab: Kind2<P, A, B>, pcd: Kind2<P, C, D>) => Kind2<P, Either<A, C>, Either<B, D>>\nexport function split<P>(\n  P: Choice<P>,\n  C: Category<P>\n): <A, B, C, D>(pab: HKT2<P, A, B>, pcd: HKT2<P, C, D>) => HKT2<P, Either<A, C>, Either<B, D>>\nexport function split<P>(\n  P: Choice<P>,\n  C: Category<P>\n): <A, B, C, D>(pab: HKT2<P, A, B>, pcd: HKT2<P, C, D>) => HKT2<P, Either<A, C>, Either<B, D>> {\n  return <A, B, C, D>(pab: HKT2<P, A, B>, pcd: HKT2<P, C, D>) => C.compose(P.right<B, C, D>(pcd), P.left<A, B, C>(pab))\n}\n\n/**\n * Compose a value which eliminates a sum from two values, each eliminating\n * one side of the sum.\n *\n * This combinator is useful when assembling values from smaller components,\n * because it provides a way to support two different types of input.\n *\n * Specializing `fanIn` to function application would look like this:\n *\n * ```purescript\n * fanIn :: forall a b c d. (a -> c) -> (b -> c) -> Either a b -> c\n * ```\n *\n * We take two functions, `f` and `g`, which both return the same type `c` and we transform them into a\n * single function which takes an `Either` value with the parameter type of `f` on the left side and\n * the parameter type of `g` on the right side. The function then runs either `f` or `g`, depending on\n * whether the `Either` value is a `Left` or a `Right`.\n * This allows us to bundle two different computations which both have the same result type into one\n * function which will run the appropriate computation based on the parameter supplied in the `Either` value.\n *\n * @since 2.10.0\n */\nexport function fanIn<P extends URIS4>(\n  P: Choice4<P>,\n  C: Category4<P>\n): <S, R, A, B, C>(pac: Kind4<P, S, R, A, C>, pbc: Kind4<P, S, R, B, C>) => Kind4<P, S, R, Either<A, B>, C>\nexport function fanIn<P extends URIS3>(\n  P: Choice3<P>,\n  C: Category3<P>\n): <R, A, B, C>(pac: Kind3<P, R, A, C>, pbc: Kind3<P, R, B, C>) => Kind3<P, R, Either<A, B>, C>\nexport function fanIn<P extends URIS2>(\n  P: Choice2<P>,\n  C: Category2<P>\n): <A, B, C>(pac: Kind2<P, A, C>, pbc: Kind2<P, B, C>) => Kind2<P, Either<A, B>, C>\nexport function fanIn<P>(\n  P: Choice<P>,\n  C: Category<P>\n): <A, B, C>(pac: HKT2<P, A, C>, pbc: HKT2<P, B, C>) => HKT2<P, Either<A, B>, C>\nexport function fanIn<P>(\n  P: Choice<P>,\n  C: Category<P>\n): <A, B, C>(pac: HKT2<P, A, C>, pbc: HKT2<P, B, C>) => HKT2<P, Either<A, B>, C> {\n  const splitPC = split(P, C)\n  return <A, B, C>(pac: HKT2<P, A, C>, pbc: HKT2<P, B, C>): HKT2<P, Either<A, B>, C> =>\n    C.compose(\n      P.promap(C.id<C>(), (cc: Either<C, C>) => (cc._tag === 'Left' ? cc.left : cc.right), identity),\n      splitPC(pac, pbc)\n    )\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`split`](#split) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function splitChoice<F extends URIS3>(\n  F: Category3<F> & Choice3<F>\n): <R, A, B, C, D>(pab: Kind3<F, R, A, B>, pcd: Kind3<F, R, C, D>) => Kind3<F, R, Either<A, C>, Either<B, D>>\n/** @deprecated */\nexport function splitChoice<F extends URIS2>(\n  F: Category2<F> & Choice2<F>\n): <A, B, C, D>(pab: Kind2<F, A, B>, pcd: Kind2<F, C, D>) => Kind2<F, Either<A, C>, Either<B, D>>\n/** @deprecated */\nexport function splitChoice<F>(\n  F: Category<F> & Choice<F>\n): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, Either<A, C>, Either<B, D>>\nexport function splitChoice<F>(\n  F: Category<F> & Choice<F>\n): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, Either<A, C>, Either<B, D>> {\n  return split(F, F)\n}\n\n/**\n * Use [`fanIn`](#fanIn) instead.\n *\n * @since 2.0.0\n * @deprecated\n */\nexport function fanin<F extends URIS3>(\n  F: Category3<F> & Choice3<F>\n): <R, A, B, C>(pac: Kind3<F, R, A, C>, pbc: Kind3<F, R, B, C>) => Kind3<F, R, Either<A, B>, C>\n/** @deprecated */\nexport function fanin<F extends URIS2>(\n  F: Category2<F> & Choice2<F>\n): <A, B, C>(pac: Kind2<F, A, C>, pbc: Kind2<F, B, C>) => Kind2<F, Either<A, B>, C>\n/** @deprecated */\nexport function fanin<F>(\n  F: Category<F> & Choice<F>\n): <A, B, C>(pac: HKT2<F, A, C>, pbc: HKT2<F, B, C>) => HKT2<F, Either<A, B>, C>\nexport function fanin<F>(\n  F: Category<F> & Choice<F>\n): <A, B, C>(pac: HKT2<F, A, C>, pbc: HKT2<F, B, C>) => HKT2<F, Either<A, B>, C> {\n  return fanIn(F, F)\n}\n"
  },
  {
    "path": "src/Comonad.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Extend, Extend1, Extend2, Extend2C, Extend3, Extend3C, Extend4 } from './Extend'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Comonad<W> extends Extend<W> {\n  readonly extract: <A>(wa: HKT<W, A>) => A\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Comonad1<W extends URIS> extends Extend1<W> {\n  readonly extract: <A>(wa: Kind<W, A>) => A\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Comonad2<W extends URIS2> extends Extend2<W> {\n  readonly extract: <E, A>(wa: Kind2<W, E, A>) => A\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Comonad2C<W extends URIS2, E> extends Extend2C<W, E> {\n  readonly extract: <A>(wa: Kind2<W, E, A>) => A\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Comonad3<W extends URIS3> extends Extend3<W> {\n  readonly extract: <R, E, A>(wa: Kind3<W, R, E, A>) => A\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Comonad3C<W extends URIS3, E> extends Extend3C<W, E> {\n  readonly extract: <R, A>(wa: Kind3<W, R, E, A>) => A\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Comonad4<W extends URIS4> extends Extend4<W> {\n  readonly extract: <S, R, E, A>(wa: Kind4<W, S, R, E, A>) => A\n}\n"
  },
  {
    "path": "src/Compactable.ts",
    "content": "/**\n * `Compactable` represents data structures which can be _compacted_/_filtered_. This is a generalization of\n * `catOptions` as a new function `compact`. `compact` has relations with `Functor`, `Applicative`,\n * `Monad`, `Alternative`, and `Traversable` in that we can use these classes to provide the ability to\n * operate on a data type by eliminating intermediate `None`s. This is useful for representing the filtering out of\n * values, or failure.\n *\n * Adapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Compactable.purs\n *\n * @since 2.0.0\n */\nimport { Either } from './Either'\nimport { pipe } from './function'\nimport {\n  Functor,\n  Functor1,\n  Functor2,\n  Functor2C,\n  Functor3C,\n  FunctorComposition,\n  FunctorComposition2C1,\n  FunctorComposition11,\n  FunctorComposition12,\n  FunctorComposition12C,\n  FunctorComposition21,\n  FunctorComposition22,\n  FunctorComposition22C,\n  FunctorComposition23,\n  FunctorComposition23C,\n  getFunctorComposition,\n  map\n} from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { getLeft, getRight, Option } from './Option'\nimport * as S from './Separated'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Compactable<F> {\n  readonly URI: F\n  /**\n   * Compacts a data structure unwrapping inner Option\n   */\n  readonly compact: <A>(fa: HKT<F, Option<A>>) => HKT<F, A>\n  /**\n   * Separates a data structure moving inner Left to the left side and inner Right to the right side of Separated\n   */\n  readonly separate: <A, B>(fa: HKT<F, Either<A, B>>) => S.Separated<HKT<F, A>, HKT<F, B>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Compactable1<F extends URIS> {\n  readonly URI: F\n  readonly compact: <A>(fa: Kind<F, Option<A>>) => Kind<F, A>\n  readonly separate: <A, B>(fa: Kind<F, Either<A, B>>) => S.Separated<Kind<F, A>, Kind<F, B>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Compactable2<F extends URIS2> {\n  readonly URI: F\n  readonly compact: <E, A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>\n  readonly separate: <E, A, B>(fa: Kind2<F, E, Either<A, B>>) => S.Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Compactable2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly compact: <A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>\n  readonly separate: <A, B>(fa: Kind2<F, E, Either<A, B>>) => S.Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Compactable3<F extends URIS3> {\n  readonly URI: F\n  readonly compact: <R, E, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>\n  readonly separate: <R, E, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => S.Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Compactable3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly compact: <R, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>\n  readonly separate: <R, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => S.Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Compactable4<F extends URIS4> {\n  readonly URI: F\n  readonly compact: <S, R, E, A>(fa: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, A>\n  readonly separate: <S, R, E, A, B>(\n    fa: Kind4<F, S, R, E, Either<A, B>>\n  ) => S.Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * `compact` composition.\n *\n * @since 2.10.0\n */\nexport function compact<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Compactable2C<G, E>\n): <FE, A>(fa: Kind2<F, FE, Kind2<G, E, Option<A>>>) => Kind2<F, FE, Kind2<G, E, A>>\nexport function compact<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Compactable2C<G, E>\n): <A>(fa: Kind<F, Kind2<G, E, Option<A>>>) => Kind<F, Kind2<G, E, A>>\nexport function compact<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Compactable1<G>\n): <A>(fa: Kind<F, Kind<G, Option<A>>>) => Kind<F, Kind<G, A>>\nexport function compact<F, G>(F: Functor<F>, G: Compactable<G>): <A>(fa: HKT<F, HKT<G, Option<A>>>) => HKT<F, HKT<G, A>>\nexport function compact<F, G>(\n  F: Functor<F>,\n  G: Compactable<G>\n): <A>(fa: HKT<F, HKT<G, Option<A>>>) => HKT<F, HKT<G, A>> {\n  return (fga) => F.map(fga, G.compact)\n}\n\n/**\n * `separate` composition.\n *\n * @since 2.10.0\n */\nexport function separate<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  C: Compactable2C<G, E>,\n  G: Functor2<G>\n): <FE, A, B>(\n  fge: Kind2<F, FE, Kind2<G, E, Either<A, B>>>\n) => S.Separated<Kind2<F, FE, Kind2<G, E, A>>, Kind2<F, FE, Kind2<G, E, B>>>\nexport function separate<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  C: Compactable2C<G, E>,\n  G: Functor2<G>\n): <A, B>(fge: Kind<F, Kind2<G, E, Either<A, B>>>) => S.Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>\nexport function separate<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  C: Compactable1<G>,\n  G: Functor1<G>\n): <A, B>(fge: Kind<F, Kind<G, Either<A, B>>>) => S.Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, B>>>\nexport function separate<F, G>(\n  F: Functor<F>,\n  C: Compactable<G>,\n  G: Functor<G>\n): <A, B>(fge: HKT<F, HKT<G, Either<A, B>>>) => S.Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>>\nexport function separate<F, G>(\n  F: Functor<F>,\n  C: Compactable<G>,\n  G: Functor<G>\n): <A, B>(fge: HKT<F, HKT<G, Either<A, B>>>) => S.Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>> {\n  const _compact = compact(F, C)\n  const _map = map(F, G)\n  return (fge) => S.separated(_compact(pipe(fge, _map(getLeft))), _compact(pipe(fge, _map(getRight))))\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface CompactableComposition<F, G> extends FunctorComposition<F, G> {\n  readonly compact: <A>(fga: HKT<F, HKT<G, Option<A>>>) => HKT<F, HKT<G, A>>\n  readonly separate: <A, B>(fge: HKT<F, HKT<G, Either<A, B>>>) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface CompactableComposition11<F extends URIS, G extends URIS> extends FunctorComposition11<F, G> {\n  readonly compact: <A>(fga: Kind<F, Kind<G, Option<A>>>) => Kind<F, Kind<G, A>>\n  readonly separate: <A, B>(fge: Kind<F, Kind<G, Either<A, B>>>) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface CompactableComposition12<F extends URIS, G extends URIS2> extends FunctorComposition12<F, G> {\n  readonly compact: <E, A>(fga: Kind<F, Kind2<G, E, Option<A>>>) => Kind<F, Kind2<G, E, A>>\n  readonly separate: <E, A, B>(\n    fge: Kind<F, Kind2<G, E, Either<A, B>>>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface CompactableComposition12C<F extends URIS, G extends URIS2, E> extends FunctorComposition12C<F, G, E> {\n  readonly compact: <A>(fga: Kind<F, Kind2<G, E, Option<A>>>) => Kind<F, Kind2<G, E, A>>\n  readonly separate: <A, B>(\n    fge: Kind<F, Kind2<G, E, Either<A, B>>>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface CompactableComposition21<F extends URIS2, G extends URIS> extends FunctorComposition21<F, G> {\n  readonly compact: <FE, A>(fga: Kind2<F, FE, Kind<G, Option<A>>>) => Kind2<F, FE, Kind<G, A>>\n  readonly separate: <FE, A, B>(\n    fge: Kind2<F, FE, Kind<G, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind<G, A>>, Kind2<F, FE, Kind<G, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface CompactableComposition2C1<F extends URIS2, G extends URIS, E> extends FunctorComposition2C1<F, G, E> {\n  readonly compact: <A>(fga: Kind2<F, E, Kind<G, Option<A>>>) => Kind2<F, E, Kind<G, A>>\n  readonly separate: <A, B>(\n    fge: Kind2<F, E, Kind<G, Either<A, B>>>\n  ) => Separated<Kind2<F, E, Kind<G, A>>, Kind2<F, E, Kind<G, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface CompactableComposition22<F extends URIS2, G extends URIS2> extends FunctorComposition22<F, G> {\n  readonly compact: <FE, GE, A>(fga: Kind2<F, FE, Kind2<G, GE, Option<A>>>) => Kind2<F, FE, Kind2<G, GE, A>>\n  readonly separate: <FE, GE, A, B>(\n    fge: Kind2<F, FE, Kind2<G, GE, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind2<G, GE, A>>, Kind2<F, FE, Kind2<G, GE, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface CompactableComposition22C<F extends URIS2, G extends URIS2, E> extends FunctorComposition22C<F, G, E> {\n  readonly compact: <FE, A>(fga: Kind2<F, FE, Kind2<G, E, Option<A>>>) => Kind2<F, FE, Kind2<G, E, A>>\n  readonly separate: <FE, A, B>(\n    fge: Kind2<F, FE, Kind2<G, E, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind2<G, E, A>>, Kind2<F, FE, Kind2<G, E, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.2.0\n * @deprecated\n */\nexport interface CompactableComposition23<F extends URIS2, G extends URIS3> extends FunctorComposition23<F, G> {\n  readonly compact: <R, FE, GE, A>(fga: Kind2<F, FE, Kind3<G, R, GE, Option<A>>>) => Kind2<F, FE, Kind3<G, R, GE, A>>\n  readonly separate: <R, FE, GE, A, B>(\n    fge: Kind2<F, FE, Kind3<G, R, GE, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind3<G, R, GE, A>>, Kind2<F, FE, Kind3<G, R, GE, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.2.0\n * @deprecated\n */\nexport interface CompactableComposition23C<F extends URIS2, G extends URIS3, E> extends FunctorComposition23C<F, G, E> {\n  readonly compact: <FE, R, A>(fga: Kind2<F, FE, Kind3<G, R, E, Option<A>>>) => Kind2<F, FE, Kind3<G, R, E, A>>\n  readonly separate: <FE, R, A, B>(\n    fge: Kind2<F, FE, Kind3<G, R, E, Either<A, B>>>\n  ) => Separated<Kind2<F, FE, Kind3<G, R, E, A>>, Kind2<F, FE, Kind3<G, R, E, B>>>\n}\n\n/**\n * Use [`compact`](#compact) and [`separate`](#separate) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getCompactableComposition<F extends URIS2, G extends URIS3, E>(\n  F: Functor2<F>,\n  G: Compactable3C<G, E> & Functor3C<G, E>\n): CompactableComposition23C<F, G, E>\n/** @deprecated */\nexport function getCompactableComposition<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Compactable2C<G, E> & Functor2C<G, E>\n): CompactableComposition22C<F, G, E>\n/** @deprecated */\nexport function getCompactableComposition<F extends URIS2, G extends URIS2>(\n  F: Functor2<F>,\n  G: Compactable2<G> & Functor2<G>\n): CompactableComposition22<F, G>\n/** @deprecated */\nexport function getCompactableComposition<F extends URIS2, G extends URIS, E>(\n  F: Functor2C<F, E>,\n  G: Compactable1<G> & Functor1<G>\n): CompactableComposition2C1<F, G, E>\n/** @deprecated */\nexport function getCompactableComposition<F extends URIS2, G extends URIS>(\n  F: Functor2<F>,\n  G: Compactable1<G> & Functor1<G>\n): CompactableComposition21<F, G>\n/** @deprecated */\nexport function getCompactableComposition<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Compactable2C<G, E> & Functor2C<G, E>\n): CompactableComposition12<F, G>\n/** @deprecated */\nexport function getCompactableComposition<F extends URIS, G extends URIS2>(\n  F: Functor1<F>,\n  G: Compactable2<G> & Functor2<G>\n): CompactableComposition12<F, G>\n/** @deprecated */\nexport function getCompactableComposition<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Compactable1<G> & Functor1<G>\n): CompactableComposition11<F, G>\n/** @deprecated */\nexport function getCompactableComposition<F, G>(\n  F: Functor<F>,\n  G: Compactable<G> & Functor<G>\n): CompactableComposition<F, G>\n/** @deprecated */\nexport function getCompactableComposition<F, G>(\n  F: Functor<F>,\n  G: Compactable<G> & Functor<G>\n): CompactableComposition<F, G> {\n  const map = getFunctorComposition(F, G).map\n  return {\n    map,\n    compact: compact(F, G),\n    separate: separate(F, G, G)\n  }\n}\n\n/**\n * Use [`Separated`](./Separated.ts.html#separated) instead.\n *\n * @since 2.0.0\n * @deprecated\n */\nexport interface Separated<A, B> {\n  readonly left: A\n  readonly right: B\n}\n"
  },
  {
    "path": "src/Console.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { IO } from './IO'\n\n/**\n * @since 2.0.0\n */\nexport const log =\n  <A>(a: A): IO<void> =>\n  () =>\n    console.log(a)\n\n/**\n * @since 2.0.0\n */\nexport const warn =\n  <A>(a: A): IO<void> =>\n  () =>\n    console.warn(a)\n\n/**\n * @since 2.0.0\n */\nexport const error =\n  <A>(a: A): IO<void> =>\n  () =>\n    console.error(a)\n\n/**\n * @since 2.0.0\n */\nexport const info =\n  <A>(a: A): IO<void> =>\n  () =>\n    console.info(a)\n"
  },
  {
    "path": "src/Const.ts",
    "content": "/**\n * The `Const` type constructor, which wraps its first type argument and ignores its second.\n * That is, `Const<E, A>` is isomorphic to `E` for any `A`.\n *\n * `Const` has some useful instances. For example, the `Applicative` instance allows us to collect results using a `Monoid`\n * while ignoring return values.\n *\n * @since 2.0.0\n */\nimport { Applicative2C } from './Applicative'\nimport { Apply2C } from './Apply'\nimport { Bifunctor2 } from './Bifunctor'\nimport { BooleanAlgebra } from './BooleanAlgebra'\nimport { Bounded } from './Bounded'\nimport { Contravariant2 } from './Contravariant'\nimport { Eq } from './Eq'\nimport { identity, pipe, unsafeCoerce } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\nimport { HeytingAlgebra } from './HeytingAlgebra'\nimport { Monoid } from './Monoid'\nimport { Ord } from './Ord'\nimport { Ring } from './Ring'\nimport { Semigroup } from './Semigroup'\nimport { Semiring } from './Semiring'\nimport { Show } from './Show'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport type Const<E, A> = E & { readonly _A: A }\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const make: <E, A = never>(e: E) => Const<E, A> = unsafeCoerce\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getShow<E, A>(S: Show<E>): Show<Const<E, A>> {\n  return {\n    show: (c) => `make(${S.show(c)})`\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getEq: <E, A>(E: Eq<E>) => Eq<Const<E, A>> = identity\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const getOrd: <E, A>(O: Ord<E>) => Ord<Const<E, A>> = identity\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const getBounded: <E, A>(B: Bounded<E>) => Bounded<Const<E, A>> = identity as any\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const getSemigroup: <E, A>(S: Semigroup<E>) => Semigroup<Const<E, A>> = identity as any\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const getMonoid: <E, A>(M: Monoid<E>) => Monoid<Const<E, A>> = identity as any\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const getSemiring: <E, A>(S: Semiring<E>) => Semiring<Const<E, A>> = identity as any\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const getRing: <E, A>(S: Ring<E>) => Ring<Const<E, A>> = identity as any\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const getHeytingAlgebra: <E, A>(H: HeytingAlgebra<E>) => HeytingAlgebra<Const<E, A>> = identity as any\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const getBooleanAlgebra: <E, A>(H: BooleanAlgebra<E>) => BooleanAlgebra<Const<E, A>> = identity as any\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getApply<E>(S: Semigroup<E>): Apply2C<URI, E> {\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: (fab, fa) => make(S.concat(fab, fa))\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getApplicative<E>(M: Monoid<E>): Applicative2C<URI, E> {\n  const A = getApply(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: A.map,\n    ap: A.ap,\n    of: () => make(M.empty)\n  }\n}\n\nconst _contramap: Contravariant2<URI>['contramap'] = (fa, f) => pipe(fa, contramap(f))\n/* istanbul ignore next */\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _bimap: Bifunctor2<URI>['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g))\n/* istanbul ignore next */\nconst _mapLeft: Bifunctor2<URI>['mapLeft'] = (fa, f) => pipe(fa, mapLeft(f))\n\n/**\n * @since 2.0.0\n */\nexport const contramap: <A, B>(f: (b: B) => A) => <E>(fa: Const<E, A>) => Const<E, B> = () => unsafeCoerce\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: Const<E, A>) => Const<E, B> = () => unsafeCoerce\n\n/**\n * Map a pair of functions over the two type arguments of the bifunctor.\n *\n * @category mapping\n * @since 2.6.2\n */\nexport const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Const<E, A>) => Const<G, B> = (f) => (fa) =>\n  make(f(fa))\n\n/**\n * Map a function over the first type argument of a bifunctor.\n *\n * @category error handling\n * @since 2.6.2\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Const<E, A>) => Const<G, A> = (f) => (fa) => make(f(fa))\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Const'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: Const<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Contravariant: Contravariant2<URI> = {\n  URI,\n  contramap: _contramap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor2<URI> = {\n  URI,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `C.Functor` instead of `C.const_`\n * (where `C` is from `import C from 'fp-ts/Const'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const const_: Functor2<URI> & Contravariant2<URI> & Bifunctor2<URI> = {\n  URI,\n  map: _map,\n  contramap: _contramap,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n"
  },
  {
    "path": "src/Contravariant.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Contravariant<F> {\n  readonly URI: F\n  readonly contramap: <A, B>(fa: HKT<F, A>, f: (b: B) => A) => HKT<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Contravariant1<F extends URIS> {\n  readonly URI: F\n  readonly contramap: <A, B>(fa: Kind<F, A>, f: (b: B) => A) => Kind<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Contravariant2<F extends URIS2> {\n  readonly URI: F\n  readonly contramap: <E, A, B>(fa: Kind2<F, E, A>, f: (b: B) => A) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Contravariant2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly contramap: <A, B>(fa: Kind2<F, E, A>, f: (b: B) => A) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Contravariant3<F extends URIS3> {\n  readonly URI: F\n  readonly contramap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (b: B) => A) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Contravariant3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly contramap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (b: B) => A) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Contravariant4<F extends URIS4> {\n  readonly URI: F\n  readonly contramap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (b: B) => A) => Kind4<F, S, R, E, B>\n}\n"
  },
  {
    "path": "src/Date.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport * as E from './Eq'\nimport { pipe } from './function'\nimport { IO } from './IO'\nimport * as N from './number'\nimport * as O from './Ord'\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Eq: E.Eq<Date> = {\n  equals: (first, second) => first.valueOf() === second.valueOf()\n}\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const eqDate: E.Eq<Date> = {\n  equals: (x, y) => x.getDate() === y.getDate()\n}\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const eqMonth: E.Eq<Date> = {\n  equals: (x, y) => x.getMonth() === y.getMonth()\n}\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const eqYear: E.Eq<Date> = {\n  equals: (x, y) => x.getFullYear() === y.getFullYear()\n}\n\n/**\n * @example\n * import { Ord } from 'fp-ts/Date'\n *\n * assert.deepStrictEqual(Ord.compare(new Date(1, 1, 2020), new Date(1, 1, 2021)), -1)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const Ord: O.Ord<Date> = /*#__PURE__*/ pipe(\n  N.Ord,\n  /*#__PURE__*/ O.contramap((date) => date.valueOf())\n)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Returns the current `Date`\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const create: IO<Date> = () => new Date()\n\n/**\n * Returns the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC\n *\n * @since 2.0.0\n */\nexport const now: IO<number> = () => new Date().getTime()\n"
  },
  {
    "path": "src/DistributiveLattice.ts",
    "content": "/**\n * A `DistributiveLattice` must satisfy the following laws in addition to `Lattice` laws:\n *\n * - Distributivity for meet: `a ∨ (b ∧ c) <-> (a ∨ b) ∧ (a ∨ c)`\n * - Distributivity for join: `a ∧ (b ∨ c) <-> (a ∧ b) ∨ (a ∧ c)`\n *\n * @since 2.0.0\n */\nimport { Lattice } from './Lattice'\nimport { max, min, Ord } from './Ord'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface DistributiveLattice<A> extends Lattice<A> {}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function getMinMaxDistributiveLattice<A>(O: Ord<A>): DistributiveLattice<A> {\n  return {\n    meet: min(O),\n    join: max(O)\n  }\n}\n"
  },
  {
    "path": "src/Either.ts",
    "content": "/**\n * ```ts\n * type Either<E, A> = Left<E> | Right<A>\n * ```\n *\n * Represents a value of one of two possible types (a disjoint union).\n *\n * An instance of `Either` is either an instance of `Left` or `Right`.\n *\n * A common use of `Either` is as an alternative to `Option` for dealing with possible missing values. In this usage,\n * `None` is replaced with a `Left` which can contain useful information. `Right` takes the place of `Some`. Convention\n * dictates that `Left` is used for failure and `Right` is used for success.\n *\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * const double = (n: number): number => n * 2\n *\n * export const imperative = (as: ReadonlyArray<number>): string => {\n *   const head = (as: ReadonlyArray<number>): number => {\n *     if (as.length === 0) {\n *       throw new Error('empty array')\n *     }\n *     return as[0]\n *   }\n *   const inverse = (n: number): number => {\n *     if (n === 0) {\n *       throw new Error('cannot divide by zero')\n *     }\n *     return 1 / n\n *   }\n *   try {\n *     return `Result is ${inverse(double(head(as)))}`\n *   } catch (err: any) {\n *     return `Error is ${err.message}`\n *   }\n * }\n *\n * export const functional = (as: ReadonlyArray<number>): string => {\n *   const head = <A>(as: ReadonlyArray<A>): E.Either<string, A> =>\n *     as.length === 0 ? E.left('empty array') : E.right(as[0])\n *   const inverse = (n: number): E.Either<string, number> =>\n *     n === 0 ? E.left('cannot divide by zero') : E.right(1 / n)\n *   return pipe(\n *     as,\n *     head,\n *     E.map(double),\n *     E.flatMap(inverse),\n *     E.match(\n *       (err) => `Error is ${err}`, // onLeft handler\n *       (head) => `Result is ${head}` // onRight handler\n *     )\n *   )\n * }\n *\n * assert.deepStrictEqual(imperative([1, 2, 3]), functional([1, 2, 3]))\n * assert.deepStrictEqual(imperative([]), functional([]))\n * assert.deepStrictEqual(imperative([0]), functional([0]))\n *\n * @since 2.0.0\n */\nimport { Alt2, Alt2C } from './Alt'\nimport { Applicative as ApplicativeHKT, Applicative2, Applicative2C, getApplicativeMonoid } from './Applicative'\nimport {\n  apFirst as apFirst_,\n  Apply2,\n  apS as apS_,\n  apSecond as apSecond_,\n  getApplySemigroup as getApplySemigroup_\n} from './Apply'\nimport { Bifunctor2 } from './Bifunctor'\nimport * as chainable from './Chain'\nimport { ChainRec2, ChainRec2C, tailRec } from './ChainRec'\nimport { Compactable2C } from './Compactable'\nimport { Eq } from './Eq'\nimport { Extend2 } from './Extend'\nimport { Filterable2C } from './Filterable'\nimport { Foldable2 } from './Foldable'\nimport {\n  chainOptionK as chainOptionK_,\n  filterOrElse as filterOrElse_,\n  FromEither2,\n  fromOption as fromOption_,\n  fromOptionK as fromOptionK_,\n  fromPredicate as fromPredicate_\n} from './FromEither'\nimport { dual, flow, identity, LazyArg, pipe } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor2, let as let__ } from './Functor'\nimport { HKT } from './HKT'\nimport * as _ from './internal'\nimport { Monad2, Monad2C } from './Monad'\nimport { MonadThrow2, MonadThrow2C } from './MonadThrow'\nimport { Monoid } from './Monoid'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Option } from './Option'\nimport { Pointed2 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport { Separated, separated } from './Separated'\nimport { Show } from './Show'\nimport { PipeableTraverse2, Traversable2 } from './Traversable'\nimport { wiltDefault, Witherable2C, witherDefault } from './Witherable'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Left<E> {\n  readonly _tag: 'Left'\n  readonly left: E\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Right<A> {\n  readonly _tag: 'Right'\n  readonly right: A\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport type Either<E, A> = Left<E> | Right<A>\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\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 2.0.0\n */\nexport const left: <E = never, A = never>(e: E) => Either<E, A> = _.left\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 2.0.0\n */\nexport const right: <E = never, A = never>(a: A) => Either<E, A> = _.right\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, E2, B>(f: (a: A) => Either<E2, B>): <E1>(ma: Either<E1, A>) => Either<E1 | E2, B>\n  <E1, A, E2, B>(ma: Either<E1, A>, f: (a: A) => Either<E2, B>): Either<E1 | E2, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <E1, A, E2, B>(ma: Either<E1, A>, f: (a: A) => Either<E2, B>): Either<E1 | E2, B> => (isLeft(ma) ? ma : f(ma.right))\n)\n\nconst _map: Monad2<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _ap: Monad2<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n/* istanbul ignore next */\nconst _reduce: Foldable2<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\n/* istanbul ignore next */\nconst _foldMap: Foldable2<URI>['foldMap'] = (M) => (fa, f) => {\n  const foldMapM = foldMap(M)\n  return pipe(fa, foldMapM(f))\n}\n/* istanbul ignore next */\nconst _reduceRight: Foldable2<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\nconst _traverse = <F>(\n  F: ApplicativeHKT<F>\n): (<E, A, B>(ta: Either<E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Either<E, B>>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\nconst _bimap: Bifunctor2<URI>['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g))\nconst _mapLeft: Bifunctor2<URI>['mapLeft'] = (fa, f) => pipe(fa, mapLeft(f))\n/* istanbul ignore next */\nconst _alt: Alt2<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n/* istanbul ignore next */\nconst _extend: Extend2<URI>['extend'] = (wa, f) => pipe(wa, extend(f))\nconst _chainRec: ChainRec2<URI>['chainRec'] = (a, f) =>\n  tailRec(f(a), (e) =>\n    isLeft(e) ? right(left(e.left)) : isLeft(e.right) ? left(f(e.right.left)) : right(right(e.right.right))\n  )\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Either'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: Either<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getShow = <E, A>(SE: Show<E>, SA: Show<A>): Show<Either<E, A>> => ({\n  show: (ma) => (isLeft(ma) ? `left(${SE.show(ma.left)})` : `right(${SA.show(ma.right)})`)\n})\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getEq = <E, A>(EL: Eq<E>, EA: Eq<A>): Eq<Either<E, A>> => ({\n  equals: (x, y) =>\n    x === y || (isLeft(x) ? isLeft(y) && EL.equals(x.left, y.left) : isRight(y) && EA.equals(x.right, y.right))\n})\n\n/**\n * Semigroup returning the left-most non-`Left` value. If both operands are `Right`s then the inner values are\n * concatenated using the provided `Semigroup`\n *\n * @example\n * import { getSemigroup, left, right } from 'fp-ts/Either'\n * import { SemigroupSum } from 'fp-ts/number'\n *\n * const S = getSemigroup<string, number>(SemigroupSum)\n * assert.deepStrictEqual(S.concat(left('a'), left('b')), left('a'))\n * assert.deepStrictEqual(S.concat(left('a'), right(2)), right(2))\n * assert.deepStrictEqual(S.concat(right(1), left('b')), right(1))\n * assert.deepStrictEqual(S.concat(right(1), right(2)), right(3))\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getSemigroup = <E, A>(S: Semigroup<A>): Semigroup<Either<E, A>> => ({\n  concat: (x, y) => (isLeft(y) ? x : isLeft(x) ? y : right(S.concat(x.right, y.right)))\n})\n\n/**\n * Builds a `Compactable` instance for `Either` given `Monoid` for the left side.\n *\n * @category filtering\n * @since 2.10.0\n */\nexport const getCompactable = <E>(M: Monoid<E>): Compactable2C<URI, E> => {\n  const empty = left(M.empty)\n  return {\n    URI,\n    _E: undefined as any,\n    compact: (ma) => (isLeft(ma) ? ma : ma.right._tag === 'None' ? empty : right(ma.right.value)),\n    separate: (ma) =>\n      isLeft(ma)\n        ? separated(ma, ma)\n        : isLeft(ma.right)\n        ? separated(right(ma.right.left), empty)\n        : separated(empty, right(ma.right.right))\n  }\n}\n\n/**\n * Builds a `Filterable` instance for `Either` given `Monoid` for the left side\n *\n * @category filtering\n * @since 2.10.0\n */\nexport const getFilterable = <E>(M: Monoid<E>): Filterable2C<URI, E> => {\n  const empty = left(M.empty)\n\n  const { compact, separate } = getCompactable(M)\n\n  const filter = <A>(ma: Either<E, A>, predicate: Predicate<A>): Either<E, A> =>\n    isLeft(ma) ? ma : predicate(ma.right) ? ma : empty\n\n  const partition = <A>(ma: Either<E, A>, p: Predicate<A>): Separated<Either<E, A>, Either<E, A>> => {\n    return isLeft(ma)\n      ? separated(ma, ma)\n      : p(ma.right)\n      ? separated(empty, right(ma.right))\n      : separated(right(ma.right), empty)\n  }\n\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    compact,\n    separate,\n    filter,\n    filterMap: (ma, f) => {\n      if (isLeft(ma)) {\n        return ma\n      }\n      const ob = f(ma.right)\n      return ob._tag === 'None' ? empty : right(ob.value)\n    },\n    partition,\n    partitionMap: (ma, f) => {\n      if (isLeft(ma)) {\n        return separated(ma, ma)\n      }\n      const e = f(ma.right)\n      return isLeft(e) ? separated(right(e.left), empty) : separated(empty, right(e.right))\n    }\n  }\n}\n\n/**\n * Builds `Witherable` instance for `Either` given `Monoid` for the left side\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const getWitherable = <E>(M: Monoid<E>): Witherable2C<URI, E> => {\n  const F_ = getFilterable(M)\n  const C = getCompactable(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    compact: F_.compact,\n    separate: F_.separate,\n    filter: F_.filter,\n    filterMap: F_.filterMap,\n    partition: F_.partition,\n    partitionMap: F_.partitionMap,\n    traverse: _traverse,\n    sequence,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight,\n    wither: witherDefault(Traversable, C),\n    wilt: wiltDefault(Traversable, C)\n  }\n}\n\n/**\n * The default [`Applicative`](#applicative) instance returns the first error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * @example\n * import * as A from 'fp-ts/Apply'\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as S from 'fp-ts/Semigroup'\n * import * as string from 'fp-ts/string'\n *\n * const parseString = (u: unknown): E.Either<string, string> =>\n *   typeof u === 'string' ? E.right(u) : E.left('not a string')\n *\n * const parseNumber = (u: unknown): E.Either<string, number> =>\n *   typeof u === 'number' ? E.right(u) : E.left('not a number')\n *\n * interface Person {\n *   readonly name: string\n *   readonly age: number\n * }\n *\n * const parsePerson = (\n *   input: Record<string, unknown>\n * ): E.Either<string, Person> =>\n *   pipe(\n *     E.Do,\n *     E.apS('name', parseString(input.name)),\n *     E.apS('age', parseNumber(input.age))\n *   )\n *\n * assert.deepStrictEqual(parsePerson({}), E.left('not a string')) // <= first error\n *\n * const Applicative = E.getApplicativeValidation(\n *   pipe(string.Semigroup, S.intercalate(', '))\n * )\n *\n * const apS = A.apS(Applicative)\n *\n * const parsePersonAll = (\n *   input: Record<string, unknown>\n * ): E.Either<string, Person> =>\n *   pipe(\n *     E.Do,\n *     apS('name', parseString(input.name)),\n *     apS('age', parseNumber(input.age))\n *   )\n *\n * assert.deepStrictEqual(parsePersonAll({}), E.left('not a string, not a number')) // <= all errors\n *\n * @category error handling\n * @since 2.7.0\n */\nexport const getApplicativeValidation = <E>(SE: Semigroup<E>): Applicative2C<URI, E> => ({\n  URI,\n  _E: undefined as any,\n  map: _map,\n  ap: (fab, fa) =>\n    isLeft(fab)\n      ? isLeft(fa)\n        ? left(SE.concat(fab.left, fa.left))\n        : fab\n      : isLeft(fa)\n      ? fa\n      : right(fab.right(fa.right)),\n  of\n})\n\n/**\n * The default [`Alt`](#alt) instance returns the last error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as S from 'fp-ts/Semigroup'\n * import * as string from 'fp-ts/string'\n *\n * const parseString = (u: unknown): E.Either<string, string> =>\n *   typeof u === 'string' ? E.right(u) : E.left('not a string')\n *\n * const parseNumber = (u: unknown): E.Either<string, number> =>\n *   typeof u === 'number' ? E.right(u) : E.left('not a number')\n *\n * const parse = (u: unknown): E.Either<string, string | number> =>\n *   pipe(\n *     parseString(u),\n *     E.alt<string, string | number>(() => parseNumber(u))\n *   )\n *\n * assert.deepStrictEqual(parse(true), E.left('not a number')) // <= last error\n *\n * const Alt = E.getAltValidation(pipe(string.Semigroup, S.intercalate(', ')))\n *\n * const parseAll = (u: unknown): E.Either<string, string | number> =>\n *   Alt.alt<string | number>(parseString(u), () => parseNumber(u))\n *\n * assert.deepStrictEqual(parseAll(true), E.left('not a string, not a number')) // <= all errors\n *\n * @category error handling\n * @since 2.7.0\n */\nexport const getAltValidation = <E>(SE: Semigroup<E>): Alt2C<URI, E> => ({\n  URI,\n  _E: undefined as any,\n  map: _map,\n  alt: (me, that) => {\n    if (isRight(me)) {\n      return me\n    }\n    const ea = that()\n    return isLeft(ea) ? left(SE.concat(me.left, ea.left)) : ea\n  }\n})\n\n/**\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: Either<E, A>) => Either<E, B> = (f) => (fa) =>\n  isLeft(fa) ? fa : right(f(fa.right))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the `Right` value of this `Either` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <E, _>(self: Either<E, _>) => Either<E, A>\n  <E, _, A>(self: Either<E, _>, a: A): Either<E, A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the `Right` value of this `Either` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <E, _>(self: Either<E, _>) => Either<E, void> = asUnit_(Functor)\n\n/**\n * @category constructors\n * @since 2.7.0\n */\nexport const of: <E = never, A = never>(a: A) => Either<E, A> = right\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed2<URI> = {\n  URI,\n  of\n}\n\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.8.0\n */\nexport const apW: <E2, A>(fa: Either<E2, A>) => <E1, B>(fab: Either<E1, (a: A) => B>) => Either<E1 | E2, B> =\n  (fa) => (fab) =>\n    isLeft(fab) ? fab : isLeft(fa) ? fa : right(fab.right(fa.right))\n\n/**\n * @since 2.0.0\n */\nexport const ap: <E, A>(fa: Either<E, A>) => <B>(fab: Either<E, (a: A) => B>) => Either<E, B> = apW\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * Left-associative fold of a structure.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as E from 'fp-ts/Either'\n *\n * const startWith = 'prefix'\n * const concat = (a: string, b: string) => `${a}:${b}`\n *\n * assert.deepStrictEqual(\n *   pipe(E.right('a'), E.reduce(startWith, concat)),\n *   'prefix:a'\n * )\n *\n * assert.deepStrictEqual(\n *   pipe(E.left('e'), E.reduce(startWith, concat)),\n *   'prefix'\n * )\n *\n * @category folding\n * @since 2.0.0\n */\nexport const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: Either<E, A>) => B = (b, f) => (fa) =>\n  isLeft(fa) ? b : f(b, fa.right)\n\n/**\n * Map each element of the structure to a monoid, and combine the results.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as E from 'fp-ts/Either'\n * import * as S from 'fp-ts/string'\n *\n * const yell = (a: string) => `${a}!`\n *\n * assert.deepStrictEqual(\n *   pipe(E.right('a'), E.foldMap(S.Monoid)(yell)),\n *   'a!'\n * )\n *\n * assert.deepStrictEqual(\n *   pipe(E.left('e'), E.foldMap(S.Monoid)(yell)),\n *   S.Monoid.empty\n * )\n *\n * @category folding\n * @since 2.0.0\n */\nexport const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: Either<E, A>) => M = (M) => (f) => (fa) =>\n  isLeft(fa) ? M.empty : f(fa.right)\n\n/**\n * Right-associative fold of a structure.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as E from 'fp-ts/Either'\n *\n * const startWith = 'postfix'\n * const concat = (a: string, b: string) => `${a}:${b}`\n *\n * assert.deepStrictEqual(\n *   pipe(E.right('a'), E.reduceRight(startWith, concat)),\n *   'a:postfix'\n * )\n *\n * assert.deepStrictEqual(\n *   pipe(E.left('e'), E.reduceRight(startWith, concat)),\n *   'postfix'\n * )\n *\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: Either<E, A>) => B = (b, f) => (fa) =>\n  isLeft(fa) ? b : f(fa.right, b)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable2<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import * as E from 'fp-ts/Either'\n * import * as O from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(\n *   pipe(E.right(['a']), E.traverse(O.Applicative)(RA.head)),\n *   O.some(E.right('a'))\n *  )\n *\n * assert.deepStrictEqual(\n *   pipe(E.right([]), E.traverse(O.Applicative)(RA.head)),\n *   O.none\n * )\n *\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse2<URI> =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A, B>(f: (a: A) => HKT<F, B>) =>\n  <E>(ta: Either<E, A>): HKT<F, Either<E, B>> =>\n    isLeft(ta) ? F.of(left(ta.left)) : F.map<B, Either<E, B>>(f(ta.right), right)\n\n/**\n * Evaluate each monadic action in the structure from left to right, and collect the results.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as E from 'fp-ts/Either'\n * import * as O from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(\n *   pipe(E.right(O.some('a')), E.sequence(O.Applicative)),\n *   O.some(E.right('a'))\n *  )\n *\n * assert.deepStrictEqual(\n *   pipe(E.right(O.none), E.sequence(O.Applicative)),\n *   O.none\n * )\n *\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable2<URI>['sequence'] =\n  <F>(F: ApplicativeHKT<F>) =>\n  <E, A>(ma: Either<E, HKT<F, A>>): HKT<F, Either<E, A>> => {\n    return isLeft(ma) ? F.of(left(ma.left)) : F.map<A, Either<E, A>>(ma.right, right)\n  }\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable2<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n/**\n * Map a pair of functions over the two type arguments of the bifunctor.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Either<E, A>) => Either<G, B> =\n  (f, g) => (fa) =>\n    isLeft(fa) ? left(f(fa.left)) : right(g(fa.right))\n\n/**\n * Map a function over the first type argument of a bifunctor.\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Either<E, A>) => Either<G, A> = (f) => (fa) =>\n  isLeft(fa) ? left(f(fa.left)) : fa\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor2<URI> = {\n  URI,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the error and the return types will be merged.\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW: <E2, B>(that: LazyArg<Either<E2, B>>) => <E1, A>(fa: Either<E1, A>) => Either<E2, A | B> =\n  (that) => (fa) =>\n    isLeft(fa) ? that() : fa\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * In case of `Either` returns the left-most non-`Left` value (or the right-most `Left` value if both values are `Left`).\n *\n * | x        | y        | pipe(x, alt(() => y) |\n * | -------- | -------- | -------------------- |\n * | left(a)  | left(b)  | left(b)              |\n * | left(a)  | right(2) | right(2)             |\n * | right(1) | left(b)  | right(1)             |\n * | right(1) | right(2) | right(1)             |\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     E.left('a'),\n *     E.alt(() => E.left('b'))\n *   ),\n *   E.left('b')\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.left('a'),\n *     E.alt(() => E.right(2))\n *   ),\n *   E.right(2)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.right(1),\n *     E.alt(() => E.left('b'))\n *   ),\n *   E.right(1)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.right(1),\n *     E.alt(() => E.right(2))\n *   ),\n *   E.right(1)\n * )\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const alt: <E, A>(that: LazyArg<Either<E, A>>) => (fa: Either<E, A>) => Either<E, A> = altW\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt2<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @since 2.0.0\n */\nexport const extend: <E, A, B>(f: (wa: Either<E, A>) => B) => (wa: Either<E, A>) => Either<E, B> = (f) => (wa) =>\n  isLeft(wa) ? wa : right(f(wa))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Extend: Extend2<URI> = {\n  URI,\n  map: _map,\n  extend: _extend\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const ChainRec: ChainRec2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap,\n  chainRec: _chainRec\n}\n\n/**\n * @since 2.6.3\n */\nexport const throwError: MonadThrow2<URI>['throwError'] = left\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const MonadThrow: MonadThrow2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  throwError\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromEither: FromEither2<URI> = {\n  URI,\n  fromEither: identity\n}\n\n/**\n * @example\n * import { fromPredicate, left, right } from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     1,\n *     fromPredicate(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   right(1)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     -1,\n *     fromPredicate(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   left('error')\n * )\n *\n * @category lifting\n * @since 2.0.0\n */\nexport const fromPredicate: {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Either<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => Either<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Either<E, A>\n} = /*#__PURE__*/ fromPredicate_(FromEither)\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as O from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     O.some(1),\n *     E.fromOption(() => 'error')\n *   ),\n *   E.right(1)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     O.none,\n *     E.fromOption(() => 'error')\n *   ),\n *   E.left('error')\n * )\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => Either<E, A> =\n  /*#__PURE__*/ fromOption_(FromEither)\n\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n\n/**\n * Returns `true` if the either is an instance of `Left`, `false` otherwise.\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isLeft: <E>(ma: Either<E, unknown>) => ma is Left<E> = _.isLeft\n\n/**\n * Returns `true` if the either is an instance of `Right`, `false` otherwise.\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isRight: <A>(ma: Either<unknown, A>) => ma is Right<A> = _.isRight\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW =\n  <E, B, A, C>(onLeft: (e: E) => B, onRight: (a: A) => C) =>\n  (ma: Either<E, A>): B | C =>\n    isLeft(ma) ? onLeft(ma.left) : onRight(ma.right)\n\n/**\n * Alias of [`matchW`](#matchw).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchW\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 { match, left, right } from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * function onLeft(errors: Array<string>): string {\n *   return `Errors: ${errors.join(', ')}`\n * }\n *\n * function onRight(value: number): string {\n *   return `Ok: ${value}`\n * }\n *\n * assert.strictEqual(\n *   pipe(\n *     right(1),\n *     match(onLeft, onRight)\n *   ),\n *   'Ok: 1'\n * )\n * assert.strictEqual(\n *   pipe(\n *     left(['error 1', 'error 2']),\n *     match(onLeft, onRight)\n *   ),\n *   'Errors: error 1, error 2'\n * )\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <E, A, B>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Either<E, A>) => B = matchW\n\n/**\n * Alias of [`match`](#match).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const fold: <E, A, B>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Either<E, A>) => B = match\n\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.6.0\n */\nexport const getOrElseW =\n  <E, B>(onLeft: (e: E) => B) =>\n  <A>(ma: Either<E, A>): A | B =>\n    isLeft(ma) ? onLeft(ma.left) : ma.right\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 { getOrElse, left, right } from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     right(1),\n *     getOrElse(() => 0)\n *   ),\n *   1\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     left('error'),\n *     getOrElse(() => 0)\n *   ),\n *   0\n * )\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const getOrElse: <E, A>(onLeft: (e: E) => A) => (ma: Either<E, A>) => A = getOrElseW\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Less strict version of [`apFirst`](#apfirst)\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apFirstW: <E2, B>(second: Either<E2, B>) => <E1, A>(first: Either<E1, A>) => Either<E1 | E2, A> =\n  apFirst as any\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * Less strict version of [`apSecond`](#apsecond)\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apSecondW: <E2, B>(second: Either<E2, B>) => <E1, A>(first: Either<E1, A>) => Either<E1 | E2, B> =\n  apSecond as any\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.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} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport const flattenW: <E1, E2, A>(mma: Either<E1, Either<E2, A>>) => Either<E1 | E2, A> =\n  /*#__PURE__*/ flatMap(identity)\n\n/**\n * The `flatten` function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(E.flatten(E.right(E.right('a'))), E.right('a'))\n * assert.deepStrictEqual(E.flatten(E.right(E.left('e'))), E.left('e'))\n * assert.deepStrictEqual(E.flatten(E.left('e')), E.left('e'))\n *\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <E, A>(mma: Either<E, Either<E, A>>) => Either<E, A> = flattenW\n\n/**\n * @since 2.0.0\n */\nexport const duplicate: <E, A>(ma: Either<E, A>) => Either<E, Either<E, A>> = /*#__PURE__*/ extend(identity)\n\n/**\n * Use `liftOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Either<E, B> =\n  /*#__PURE__*/ fromOptionK_(FromEither)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => (ma: Either<E, A>) => Either<E, B> = /*#__PURE__*/ chainOptionK_(\n  FromEither,\n  Chain\n)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.13.2\n */\nexport const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: Either<E1, A>) => Either<E1 | E2, B> = chainOptionK as any\n\n/** @internal */\ninterface EitherTypeLambda extends _.TypeLambda {\n  readonly type: Either<this['Out1'], this['Target']>\n}\n\n/** @internal */\nconst _FromEither: _.FromEither<EitherTypeLambda> = {\n  fromEither: FromEither.fromEither\n}\n\n/**\n * @category lifting\n * @since 2.15.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>> = /*#__PURE__*/ _.liftNullable(_FromEither)\n\n/**\n * @category lifting\n * @since 2.15.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> = /*#__PURE__*/ _.liftOption(_FromEither)\n\n/** @internal */\nconst _FlatMap: _.FlatMap<EitherTypeLambda> = {\n  flatMap\n}\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport 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} = /*#__PURE__*/ _.flatMapNullable(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport 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} = /*#__PURE__*/ _.flatMapOption(_FromEither, _FlatMap)\n\n/**\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     E.right(1),\n *     E.filterOrElse(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   E.right(1)\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.right(-1),\n *     E.filterOrElse(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   E.left('error')\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     E.left('a'),\n *     E.filterOrElse(\n *       (n) => n > 0,\n *       () => 'error'\n *     )\n *   ),\n *   E.left('a')\n * )\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const filterOrElse: {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (self: Either<E, A>) => Either<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(self: Either<E, B>) => Either<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (self: Either<E, A>) => Either<E, A>\n} = /*#__PURE__*/ filterOrElse_(FromEither, Chain)\n\n/**\n * Less strict version of [`filterOrElse`](#filterorelse).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category filtering\n * @since 2.9.0\n */\nexport const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(\n    ma: Either<E1, A>\n  ) => Either<E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>(mb: Either<E1, B>) => Either<E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: Either<E1, A>) => Either<E1 | E2, A>\n} = filterOrElse\n\n/**\n * Returns a `Right` if is a `Left` (and vice versa).\n *\n * @since 2.0.0\n */\nexport const swap = <E, A>(ma: Either<E, A>): Either<A, E> => (isLeft(ma) ? right(ma.left) : left(ma.right))\n\n/**\n * Less strict version of [`orElse`](#orelse).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport const orElseW =\n  <E1, E2, B>(onLeft: (e: E1) => Either<E2, B>) =>\n  <A>(ma: Either<E1, A>): Either<E2, A | B> =>\n    isLeft(ma) ? onLeft(ma.left) : ma\n\n/**\n * Useful for recovering from errors.\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const orElse: <E1, A, E2>(onLeft: (e: E1) => Either<E2, A>) => (ma: Either<E1, A>) => Either<E2, A> = orElseW\n\n/**\n * Takes a 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 { fromNullable, left, right } from 'fp-ts/Either'\n *\n * const parse = fromNullable('nully')\n *\n * assert.deepStrictEqual(parse(1), right(1))\n * assert.deepStrictEqual(parse(null), left('nully'))\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const fromNullable =\n  <E>(e: E) =>\n  <A>(a: A): Either<E, NonNullable<A>> =>\n    a == null ? left(e) : right(a as NonNullable<A>)\n\n/**\n * Constructs a new `Either` from a function that might throw.\n *\n * See also [`tryCatchK`](#trycatchk).\n *\n * @example\n * import * as E from 'fp-ts/Either'\n *\n * const unsafeHead = <A>(as: ReadonlyArray<A>): A => {\n *   if (as.length > 0) {\n *     return as[0]\n *   } else {\n *     throw new Error('empty array')\n *   }\n * }\n *\n * const head = <A>(as: ReadonlyArray<A>): E.Either<Error, A> =>\n *   E.tryCatch(() => unsafeHead(as), e => (e instanceof Error ? e : new Error('unknown error')))\n *\n * assert.deepStrictEqual(head([]), E.left(new Error('empty array')))\n * assert.deepStrictEqual(head([1, 2, 3]), E.right(1))\n *\n * @category interop\n * @since 2.0.0\n */\nexport const tryCatch = <E, A>(f: LazyArg<A>, onThrow: (e: unknown) => E): Either<E, A> => {\n  try {\n    return right(f())\n  } catch (e) {\n    return left(onThrow(e))\n  }\n}\n\n/**\n * Converts a function that may throw to one returning a `Either`.\n *\n * @category interop\n * @since 2.10.0\n */\nexport const tryCatchK =\n  <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    tryCatch(() => f(...a), onThrow)\n\n/**\n * Use `liftNullable`.\n *\n * @category legacy\n * @since 2.9.0\n */\nexport const fromNullableK = <E>(\n  e: E\n): (<A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Either<E, NonNullable<B>>) => {\n  const from = fromNullable(e)\n  return (f) => flow(f, from)\n}\n\n/**\n * Use `flatMapNullable`.\n *\n * @category legacy\n * @since 2.9.0\n */\nexport const chainNullableK = <E>(\n  e: E\n): (<A, B>(f: (a: A) => B | null | undefined) => (ma: Either<E, A>) => Either<E, NonNullable<B>>) => {\n  const from = fromNullableK(e)\n  return (f) => flatMap(from(f))\n}\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const toUnion: <E, A>(fa: Either<E, A>) => E | A = /*#__PURE__*/ foldW(identity, identity)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Default value for the `onError` argument of `tryCatch`\n *\n * @since 2.0.0\n */\nexport function toError(e: unknown): Error {\n  try {\n    return e instanceof Error ? e : new Error(String(e))\n  } catch (error) {\n    return new Error()\n  }\n}\n\n/**\n * @since 2.0.0\n */\nexport function elem<A>(E: Eq<A>): {\n  (a: A): <E>(ma: Either<E, A>) => boolean\n  <E>(a: A, ma: Either<E, A>): boolean\n}\nexport function elem<A>(E: Eq<A>): <E>(a: A, ma?: Either<E, A>) => boolean | ((ma: Either<E, A>) => boolean) {\n  return (a, ma?) => {\n    if (ma === undefined) {\n      const elemE = elem(E)\n      return (ma) => elemE(a, ma)\n    }\n    return isLeft(ma) ? false : E.equals(a, ma.right)\n  }\n}\n\n/**\n * Returns `false` if `Left` or returns the result of the application of the given predicate to the `Right` value.\n *\n * @example\n * import { exists, left, right } from 'fp-ts/Either'\n *\n * const gt2 = exists((n: number) => n > 2)\n *\n * assert.strictEqual(gt2(left('a')), false)\n * assert.strictEqual(gt2(right(1)), false)\n * assert.strictEqual(gt2(right(3)), true)\n *\n * @since 2.0.0\n */\nexport const exists =\n  <A>(predicate: Predicate<A>) =>\n  (ma: Either<unknown, A>): boolean =>\n    isLeft(ma) ? false : predicate(ma.right)\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: Either<never, {}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const bindW: <N extends string, A, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Either<E2, B>\n) => <E1>(fa: Either<E1, A>) => Either<E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  bind as any\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const apSW: <A, N extends string, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: Either<E2, B>\n) => <E1>(fa: Either<E1, A>) => Either<E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  apS as any\n\n/**\n * @since 2.11.0\n */\nexport const ApT: Either<never, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex =\n  <A, E, B>(f: (index: number, a: A) => Either<E, B>) =>\n  (as: ReadonlyNonEmptyArray<A>): Either<E, ReadonlyNonEmptyArray<B>> => {\n    const e = f(0, _.head(as))\n    if (isLeft(e)) {\n      return e\n    }\n    const out: NonEmptyArray<B> = [e.right]\n    for (let i = 1; i < as.length; i++) {\n      const e = f(i, as[i])\n      if (isLeft(e)) {\n        return e\n      }\n      out.push(e.right)\n    }\n    return right(out)\n  }\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, E, B>(\n  f: (index: number, a: A) => Either<E, B>\n): ((as: ReadonlyArray<A>) => Either<E, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <E, A, B>(\n  f: (index: number, a: A) => Either<E, B>\n) => (as: ReadonlyArray<A>) => Either<E, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <E, A, B>(\n  f: (a: A) => Either<E, B>\n): ((as: ReadonlyArray<A>) => Either<E, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <E, A>(as: ReadonlyArray<Either<E, A>>) => Either<E, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.0\n */\nexport const chainW: <E2, A, B>(f: (a: A) => Either<E2, B>) => <E1>(ma: Either<E1, A>) => Either<E2 | E1, B> = flatMap\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Either<E, A>) => Either<E, B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Either<E, A>) => Either<E, A> = tap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.8.0\n */\nexport const chainFirstW: <E2, A, B>(f: (a: A) => Either<E2, B>) => <E1>(ma: Either<E1, A>) => Either<E1 | E2, A> = tap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`Json`](./Json.ts.html) module instead.\n *\n * @category zone of death\n * @since 2.6.7\n * @deprecated\n */\nexport type Json = boolean | number | string | null | JsonArray | JsonRecord\n\n/**\n * Use [`Json`](./Json.ts.html) module instead.\n *\n * @category zone of death\n * @since 2.6.7\n * @deprecated\n */\nexport interface JsonRecord {\n  readonly [key: string]: Json\n}\n\n/**\n * Use [`Json`](./Json.ts.html) module instead.\n *\n * @category zone of death\n * @since 2.6.7\n * @deprecated\n */\nexport interface JsonArray extends ReadonlyArray<Json> {}\n\n/**\n * Use [`parse`](./Json.ts.html#parse) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function parseJSON<E>(s: string, onError: (reason: unknown) => E): Either<E, Json> {\n  return tryCatch(() => JSON.parse(s), onError)\n}\n\n/**\n * Use [`stringify`](./Json.ts.html#stringify) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const stringifyJSON = <E>(u: unknown, onError: (reason: unknown) => E): Either<E, string> =>\n  tryCatch(() => {\n    const s = JSON.stringify(u)\n    if (typeof s !== 'string') {\n      throw new Error('Converting unsupported structure to JSON')\n    }\n    return s\n  }, onError)\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `E.Functor` instead of `E.either`\n * (where `E` is from `import E from 'fp-ts/Either'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const either: Monad2<URI> &\n  Foldable2<URI> &\n  Traversable2<URI> &\n  Bifunctor2<URI> &\n  Alt2<URI> &\n  Extend2<URI> &\n  ChainRec2<URI> &\n  MonadThrow2<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  bimap: _bimap,\n  mapLeft: _mapLeft,\n  alt: _alt,\n  extend: _extend,\n  chainRec: _chainRec,\n  throwError: throwError\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * Semigroup returning the left-most `Left` value. If both operands are `Right`s then the inner values\n * are concatenated using the provided `Semigroup`\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<Either<E, A>> =\n  /*#__PURE__*/ getApplySemigroup_(Apply)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<Either<E, A>> =\n  /*#__PURE__*/ getApplicativeMonoid(Applicative)\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getValidationSemigroup = <E, A>(SE: Semigroup<E>, SA: Semigroup<A>): Semigroup<Either<E, A>> =>\n  getApplySemigroup_(getApplicativeValidation(SE))(SA)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getValidationMonoid = <E, A>(SE: Semigroup<E>, MA: Monoid<A>): Monoid<Either<E, A>> =>\n  getApplicativeMonoid(getApplicativeValidation(SE))(MA)\n\n/**\n * Use [`getApplicativeValidation`](#getapplicativevalidation) and [`getAltValidation`](#getaltvalidation) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getValidation<E>(\n  SE: Semigroup<E>\n): Monad2C<URI, E> &\n  Foldable2<URI> &\n  Traversable2<URI> &\n  Bifunctor2<URI> &\n  Alt2C<URI, E> &\n  Extend2<URI> &\n  ChainRec2C<URI, E> &\n  MonadThrow2C<URI, E> {\n  const ap = getApplicativeValidation(SE).ap\n  const alt = getAltValidation(SE).alt\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    of,\n    chain: flatMap,\n    bimap: _bimap,\n    mapLeft: _mapLeft,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight,\n    extend: _extend,\n    traverse: _traverse,\n    sequence,\n    chainRec: _chainRec,\n    throwError,\n    ap,\n    alt\n  }\n}\n"
  },
  {
    "path": "src/EitherT.ts",
    "content": "/**\n * The error monad transformer. It can be used to add error handling to other monads.\n *\n * The `of` function yields a successful computation, while `chain` sequences two subcomputations, failing on the first error.\n *\n * @since 2.0.0\n */\nimport { ApplicativeComposition12, ApplicativeComposition22, ApplicativeCompositionHKT2 } from './Applicative'\nimport { ap as ap_, Apply, Apply1, Apply2, Apply2C, Apply3, Apply3C } from './Apply'\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C } from './Chain'\nimport * as E from './Either'\nimport { flow, LazyArg, pipe } from './function'\nimport { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C, map as map_ } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'\nimport { Monad, Monad1, Monad2, Monad2C, Monad3, Monad3C } from './Monad'\nimport { Pointed, Pointed1, Pointed2, Pointed2C, Pointed3, Pointed3C } from './Pointed'\nimport { Semigroup } from './Semigroup'\n\nimport Either = E.Either\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function right<F extends URIS3>(F: Pointed3<F>): <A, R, FE, E = never>(a: A) => Kind3<F, R, FE, Either<E, A>>\nexport function right<F extends URIS3, FE>(\n  F: Pointed3C<F, FE>\n): <A, R, E = never>(a: A) => Kind3<F, R, FE, Either<E, A>>\nexport function right<F extends URIS2>(F: Pointed2<F>): <A, FE, E = never>(a: A) => Kind2<F, FE, Either<E, A>>\nexport function right<F extends URIS2, FE>(F: Pointed2C<F, FE>): <A, E = never>(a: A) => Kind2<F, FE, Either<E, A>>\nexport function right<F extends URIS>(F: Pointed1<F>): <A, E = never>(a: A) => Kind<F, Either<E, A>>\nexport function right<F>(F: Pointed<F>): <A, E = never>(a: A) => HKT<F, Either<E, A>>\nexport function right<F>(F: Pointed<F>): <A, E = never>(a: A) => HKT<F, Either<E, A>> {\n  return flow(E.right, F.of)\n}\n\n/**\n * @since 2.10.0\n */\nexport function left<F extends URIS3>(F: Pointed3<F>): <E, R, FE, A = never>(e: E) => Kind3<F, R, FE, Either<E, A>>\nexport function left<F extends URIS3, FE>(F: Pointed3C<F, FE>): <E, R, A = never>(e: E) => Kind3<F, R, FE, Either<E, A>>\nexport function left<F extends URIS2>(F: Pointed2<F>): <E, FE, A = never>(e: E) => Kind2<F, FE, Either<E, A>>\nexport function left<F extends URIS2, FE>(F: Pointed2C<F, FE>): <E, A = never>(e: E) => Kind2<F, FE, Either<E, A>>\nexport function left<F extends URIS>(F: Pointed1<F>): <E, A = never>(e: E) => Kind<F, Either<E, A>>\nexport function left<F>(F: Pointed<F>): <E, A = never>(e: E) => HKT<F, Either<E, A>>\nexport function left<F>(F: Pointed<F>): <E, A = never>(e: E) => HKT<F, Either<E, A>> {\n  return flow(E.left, F.of)\n}\n\n/**\n * @since 2.10.0\n */\nexport function rightF<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, Either<E, A>>\nexport function rightF<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, Either<E, A>>\nexport function rightF<F extends URIS2>(\n  F: Functor2<F>\n): <FE, A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, Either<E, A>>\nexport function rightF<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, Either<E, A>>\nexport function rightF<F extends URIS>(F: Functor1<F>): <A, E = never>(fa: Kind<F, A>) => Kind<F, Either<E, A>>\nexport function rightF<F>(F: Functor<F>): <A, E = never>(fa: HKT<F, A>) => HKT<F, Either<E, A>>\nexport function rightF<F>(F: Functor<F>): <A, E = never>(fa: HKT<F, A>) => HKT<F, Either<E, A>> {\n  return (fa) => F.map(fa, E.right)\n}\n\n/**\n * @since 2.10.0\n */\nexport function leftF<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, Either<E, A>>\nexport function leftF<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, Either<E, A>>\nexport function leftF<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, Either<E, A>>\nexport function leftF<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, Either<E, A>>\nexport function leftF<F extends URIS>(F: Functor1<F>): <E, A = never>(fe: Kind<F, E>) => Kind<F, Either<E, A>>\nexport function leftF<F>(F: Functor<F>): <E, A = never>(fe: HKT<F, E>) => HKT<F, Either<E, A>>\nexport function leftF<F>(F: Functor<F>): <E, A = never>(fe: HKT<F, E>) => HKT<F, Either<E, A>> {\n  return (fe) => F.map(fe, E.left)\n}\n\n/**\n * @since 2.12.0\n */\nexport function fromNullable<F extends URIS3>(\n  F: Pointed3<F>\n): <E>(e: E) => <A, S, R>(a: A) => Kind3<F, S, R, Either<E, NonNullable<A>>>\nexport function fromNullable<F extends URIS3, R>(\n  F: Pointed3C<F, R>\n): <E>(e: E) => <A, S>(a: A) => Kind3<F, S, R, Either<E, NonNullable<A>>>\nexport function fromNullable<F extends URIS2>(\n  F: Pointed2<F>\n): <E>(e: E) => <A, R>(a: A) => Kind2<F, R, Either<E, NonNullable<A>>>\nexport function fromNullable<F extends URIS2, R>(\n  F: Pointed2C<F, R>\n): <E>(e: E) => <A>(a: A) => Kind2<F, R, Either<E, NonNullable<A>>>\nexport function fromNullable<F extends URIS>(\n  F: Pointed1<F>\n): <E>(e: E) => <A>(a: A) => Kind<F, Either<E, NonNullable<A>>>\nexport function fromNullable<F>(F: Pointed<F>): <E>(e: E) => <A>(a: A) => HKT<F, Either<E, NonNullable<A>>>\nexport function fromNullable<F>(F: Pointed<F>): <E>(e: E) => <A>(a: A) => HKT<F, Either<E, NonNullable<A>>> {\n  return (e) => flow(E.fromNullable(e), F.of)\n}\n\n/**\n * @since 2.12.0\n */\nexport function fromNullableK<F extends URIS3>(\n  F: Pointed3<F>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <S, R>(...a: A) => Kind3<F, S, R, Either<E, NonNullable<B>>>\nexport function fromNullableK<F extends URIS3, R>(\n  F: Pointed3C<F, R>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <S>(...a: A) => Kind3<F, S, R, Either<E, NonNullable<B>>>\nexport function fromNullableK<F extends URIS2>(\n  F: Pointed2<F>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <R>(...a: A) => Kind2<F, R, Either<E, NonNullable<B>>>\nexport function fromNullableK<F extends URIS2, R>(\n  F: Pointed2C<F, R>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Kind2<F, R, Either<E, NonNullable<B>>>\nexport function fromNullableK<F extends URIS>(\n  F: Pointed1<F>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Kind<F, Either<E, NonNullable<B>>>\nexport function fromNullableK<F>(\n  F: Pointed<F>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => HKT<F, Either<E, NonNullable<B>>>\nexport function fromNullableK<F>(\n  F: Pointed<F>\n): <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => HKT<F, Either<E, NonNullable<B>>> {\n  const fromNullableF = fromNullable(F)\n  return (e) => {\n    const fromNullableFE = fromNullableF(e)\n    return (f) => flow(f, fromNullableFE)\n  }\n}\n\n/**\n * @since 2.12.0\n */\nexport function chainNullableK<M extends URIS3>(\n  M: Monad3<M>\n): <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => <S, R>(ma: Kind3<M, S, R, Either<E, A>>) => Kind3<M, S, R, Either<E, NonNullable<B>>>\nexport function chainNullableK<M extends URIS3, R>(\n  M: Monad3C<M, R>\n): <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => <S>(ma: Kind3<M, S, R, Either<E, A>>) => Kind3<M, S, R, Either<E, NonNullable<B>>>\nexport function chainNullableK<M extends URIS2>(\n  M: Monad2<M>\n): <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => <R>(ma: Kind2<M, R, Either<E, A>>) => Kind2<M, R, Either<E, NonNullable<B>>>\nexport function chainNullableK<M extends URIS2, T>(\n  M: Monad2C<M, T>\n): <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => (ma: Kind2<M, T, Either<E, A>>) => Kind2<M, T, Either<E, NonNullable<B>>>\nexport function chainNullableK<M extends URIS>(\n  M: Monad1<M>\n): <E>(\n  e: E\n) => <A, B>(f: (a: A) => B | null | undefined) => (ma: Kind<M, Either<E, A>>) => Kind<M, Either<E, NonNullable<B>>>\nexport function chainNullableK<M>(\n  M: Monad<M>\n): <E>(\n  e: E\n) => <A, B>(f: (a: A) => B | null | undefined) => (ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, NonNullable<B>>>\nexport function chainNullableK<M>(\n  M: Monad<M>\n): <E>(\n  e: E\n) => <A, B>(f: (a: A) => B | null | undefined) => (ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, NonNullable<B>>> {\n  const chainM = chain(M)\n  const fromNullableKM = fromNullableK(M)\n  return (e) => {\n    const fromNullableKMe = fromNullableKM(e)\n    return (f) => chainM(fromNullableKMe(f))\n  }\n}\n\n/**\n * @since 2.10.0\n */\nexport function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, FE, E>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<E, B>>\nexport function map<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<E, B>>\nexport function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <FE, E>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<E, B>>\nexport function map<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<E, B>>\nexport function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind<F, Either<E, A>>) => Kind<F, Either<E, B>>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, Either<E, A>>) => HKT<F, Either<E, B>>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, Either<E, A>>) => HKT<F, Either<E, B>> {\n  return map_(F, E.Functor)\n}\n\n/**\n * @since 2.10.0\n */\nexport function ap<F extends URIS3>(\n  F: Apply3<F>\n): <R, FE, E, A>(\n  fa: Kind3<F, R, FE, Either<E, A>>\n) => <B>(fab: Kind3<F, R, FE, Either<E, (a: A) => B>>) => Kind3<F, R, FE, Either<E, B>>\nexport function ap<F extends URIS3, FE>(\n  F: Apply3C<F, FE>\n): <R, E, A>(\n  fa: Kind3<F, R, FE, Either<E, A>>\n) => <B>(fab: Kind3<F, R, FE, Either<E, (a: A) => B>>) => Kind3<F, R, FE, Either<E, B>>\nexport function ap<F extends URIS2>(\n  F: Apply2<F>\n): <FE, E, A>(\n  fa: Kind2<F, FE, Either<E, A>>\n) => <B>(fab: Kind2<F, FE, Either<E, (a: A) => B>>) => Kind2<F, FE, Either<E, B>>\nexport function ap<F extends URIS2, FE>(\n  F: Apply2C<F, FE>\n): <E, A>(\n  fa: Kind2<F, FE, Either<E, A>>\n) => <B>(fab: Kind2<F, FE, Either<E, (a: A) => B>>) => Kind2<F, FE, Either<E, B>>\nexport function ap<F extends URIS>(\n  F: Apply1<F>\n): <E, A>(fa: Kind<F, Either<E, A>>) => <B>(fab: Kind<F, Either<E, (a: A) => B>>) => Kind<F, Either<E, B>>\nexport function ap<F>(\n  F: Apply<F>\n): <E, A>(fa: HKT<F, Either<E, A>>) => <B>(fab: HKT<F, Either<E, (a: A) => B>>) => HKT<F, Either<E, B>>\nexport function ap<F>(\n  F: Apply<F>\n): <E, A>(fa: HKT<F, Either<E, A>>) => <B>(fab: HKT<F, Either<E, (a: A) => B>>) => HKT<F, Either<E, B>> {\n  return ap_(F, E.Apply)\n}\n\n/**\n * @since 2.10.0\n */\nexport function chain<M extends URIS3>(\n  M: Monad3<M>\n): <A, R, ME, E, B>(\n  f: (a: A) => Kind3<M, R, ME, Either<E, B>>\n) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, B>>\nexport function chain<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <A, R, E, B>(\n  f: (a: A) => Kind3<M, R, ME, Either<E, B>>\n) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, B>>\nexport function chain<M extends URIS2>(\n  M: Monad2<M>\n): <A, ME, E, B>(\n  f: (a: A) => Kind2<M, ME, Either<E, B>>\n) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, B>>\nexport function chain<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <A, E, B>(f: (a: A) => Kind2<M, ME, Either<E, B>>) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, B>>\nexport function chain<M extends URIS>(\n  M: Monad1<M>\n): <A, E, B>(f: (a: A) => Kind<M, Either<E, B>>) => (ma: Kind<M, Either<E, A>>) => Kind<M, Either<E, B>>\nexport function chain<M>(\n  M: Monad<M>\n): <A, E, B>(f: (a: A) => HKT<M, Either<E, B>>) => (ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, B>>\nexport function chain<M>(\n  M: Monad<M>\n): <A, E, B>(f: (a: A) => HKT<M, Either<E, B>>) => (ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, B>> {\n  const flatMapM = flatMap(M)\n  return (f) => (ma) => flatMapM(ma, f)\n}\n\n/** @internal */\nexport function flatMap<M extends URIS2>(\n  M: Monad2<M>\n): <ME, E, A, B>(ma: Kind2<M, ME, Either<E, A>>, f: (a: A) => Kind2<M, ME, Either<E, B>>) => Kind2<M, ME, Either<E, B>>\n/** @internal */\nexport function flatMap<M extends URIS>(\n  M: Monad1<M>\n): <E, A, B>(ma: Kind<M, Either<E, A>>, f: (a: A) => Kind<M, Either<E, B>>) => Kind<M, Either<E, B>>\n/** @internal */\nexport function flatMap<M>(\n  M: Monad<M>\n): <E, A, B>(ma: HKT<M, Either<E, A>>, f: (a: A) => HKT<M, Either<E, B>>) => HKT<M, Either<E, B>>\n/** @internal */\nexport function flatMap<M>(\n  M: Monad<M>\n): <E, A, B>(ma: HKT<M, Either<E, A>>, f: (a: A) => HKT<M, Either<E, B>>) => HKT<M, Either<E, B>> {\n  return (ma, f) => M.chain(ma, (e) => (E.isLeft(e) ? M.of(e) : f(e.right)))\n}\n\n/**\n * @since 2.10.0\n */\nexport function alt<M extends URIS3>(\n  M: Monad3<M>\n): <R, ME, E, A>(\n  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>\n) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport function alt<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <R, E, A>(\n  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>\n) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport function alt<M extends URIS2>(\n  M: Monad2<M>\n): <ME, E, A>(\n  second: LazyArg<Kind2<M, ME, Either<E, A>>>\n) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport function alt<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E, A>(\n  second: LazyArg<Kind2<M, ME, Either<E, A>>>\n) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport function alt<M extends URIS>(\n  M: Monad1<M>\n): <E, A>(second: LazyArg<Kind<M, Either<E, A>>>) => (first: Kind<M, Either<E, A>>) => Kind<M, Either<E, A>>\nexport function alt<M>(\n  M: Monad<M>\n): <E, A>(second: LazyArg<HKT<M, Either<E, A>>>) => (first: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>>\nexport function alt<M>(\n  M: Monad<M>\n): <E, A>(second: LazyArg<HKT<M, Either<E, A>>>) => (first: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>> {\n  return (second) => (first) => M.chain(first, (e) => (E.isLeft(e) ? second() : M.of(e)))\n}\n\n/**\n * @since 2.10.0\n */\nexport function bimap<F extends URIS3>(\n  F: Functor3<F>\n): <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R, FE>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, B>>\nexport function bimap<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, B>>\nexport function bimap<F extends URIS2>(\n  F: Functor2<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <FE>(self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, B>>\nexport function bimap<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, B>>\nexport function bimap<F extends URIS>(\n  F: Functor1<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: Kind<F, Either<E, A>>) => Kind<F, Either<G, B>>\nexport function bimap<F>(\n  F: Functor<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: HKT<F, Either<E, A>>) => HKT<F, Either<G, B>>\nexport function bimap<F>(\n  F: Functor<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (self: HKT<F, Either<E, A>>) => HKT<F, Either<G, B>> {\n  const mapBothF = mapBoth(F)\n  return (f, g) => (self) => mapBothF(self, f, g)\n}\n\n/** @internal */\nexport function mapBoth<F extends URIS2>(\n  F: Functor2<F>\n): <R, E, A, G, B>(self: Kind2<F, R, Either<E, A>>, f: (e: E) => G, g: (a: A) => B) => Kind2<F, R, Either<G, B>>\n/** @internal */\nexport function mapBoth<F extends URIS>(\n  F: Functor1<F>\n): <E, A, G, B>(self: Kind<F, Either<E, A>>, f: (e: E) => G, g: (a: A) => B) => Kind<F, Either<G, B>>\n/** @internal */\nexport function mapBoth<F>(\n  F: Functor<F>\n): <E, A, G, B>(self: HKT<F, Either<E, A>>, f: (e: E) => G, g: (a: A) => B) => HKT<F, Either<G, B>>\n/** @internal */\nexport function mapBoth<F>(\n  F: Functor<F>\n): <E, A, G, B>(self: HKT<F, Either<E, A>>, f: (e: E) => G, g: (a: A) => B) => HKT<F, Either<G, B>> {\n  return (self, f, g) => F.map(self, E.bimap(f, g))\n}\n\n/**\n * @since 2.10.0\n */\nexport function mapLeft<F extends URIS3>(\n  F: Functor3<F>\n): <E, G>(f: (e: E) => G) => <R, FE, A>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, A>>\nexport function mapLeft<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, G>(f: (e: E) => G) => <R, A>(self: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<G, A>>\nexport function mapLeft<F extends URIS2>(\n  F: Functor2<F>\n): <E, G>(f: (e: E) => G) => <FE, A>(self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, A>>\nexport function mapLeft<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, G>(f: (e: E) => G) => <A>(self: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<G, A>>\nexport function mapLeft<F extends URIS>(\n  F: Functor1<F>\n): <E, G>(f: (e: E) => G) => <A>(self: Kind<F, Either<E, A>>) => Kind<F, Either<G, A>>\nexport function mapLeft<F>(\n  F: Functor<F>\n): <E, G>(f: (e: E) => G) => <A>(self: HKT<F, Either<E, A>>) => HKT<F, Either<G, A>>\nexport function mapLeft<F>(\n  F: Functor<F>\n): <E, G>(f: (e: E) => G) => <A>(self: HKT<F, Either<E, A>>) => HKT<F, Either<G, A>> {\n  const mapErrorF = mapError(F)\n  return (f) => (self) => mapErrorF(self, f)\n}\n\n/** @internal */\nexport function mapError<F extends URIS2>(\n  F: Functor2<F>\n): <R, E, A, G>(self: Kind2<F, R, Either<E, A>>, f: (e: E) => G) => Kind2<F, R, Either<G, A>>\n/** @internal */\nexport function mapError<F extends URIS>(\n  F: Functor1<F>\n): <E, A, G>(self: Kind<F, Either<E, A>>, f: (e: E) => G) => Kind<F, Either<G, A>>\n/** @internal */\nexport function mapError<F>(\n  F: Functor<F>\n): <E, A, G>(self: HKT<F, Either<E, A>>, f: (e: E) => G) => HKT<F, Either<G, A>>\n/** @internal */\nexport function mapError<F>(\n  F: Functor<F>\n): <E, A, G>(self: HKT<F, Either<E, A>>, f: (e: E) => G) => HKT<F, Either<G, A>> {\n  return (self, f) => F.map(self, E.mapLeft(f))\n}\n\n/**\n * @category error handling\n * @since 2.10.0\n */\nexport function altValidation<M extends URIS3, E>(\n  M: Monad3<M>,\n  S: Semigroup<E>\n): <R, ME, A>(\n  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>\n) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport function altValidation<M extends URIS3, ME, E>(\n  M: Monad3C<M, ME>,\n  S: Semigroup<E>\n): <R, A>(\n  second: LazyArg<Kind3<M, R, ME, Either<E, A>>>\n) => (first: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport function altValidation<M extends URIS2, E>(\n  M: Monad2<M>,\n  S: Semigroup<E>\n): <ME, A>(\n  second: LazyArg<Kind2<M, ME, Either<E, A>>>\n) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport function altValidation<M extends URIS2, ME, E>(\n  M: Monad2C<M, ME>,\n  S: Semigroup<E>\n): <A>(second: LazyArg<Kind2<M, ME, Either<E, A>>>) => (first: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport function altValidation<M extends URIS, E>(\n  M: Monad1<M>,\n  S: Semigroup<E>\n): <A>(second: LazyArg<Kind<M, Either<E, A>>>) => (first: Kind<M, Either<E, A>>) => Kind<M, Either<E, A>>\nexport function altValidation<M, E>(\n  M: Monad<M>,\n  S: Semigroup<E>\n): <A>(second: LazyArg<HKT<M, Either<E, A>>>) => (first: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>>\nexport function altValidation<M, E>(\n  M: Monad<M>,\n  S: Semigroup<E>\n): <A>(second: LazyArg<HKT<M, Either<E, A>>>) => (first: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>> {\n  return (second) => (first) =>\n    M.chain(\n      first,\n      E.match(\n        (e1) =>\n          M.map(\n            second(),\n            E.mapLeft((e2) => S.concat(e1, e2))\n          ),\n        right(M)\n      )\n    )\n}\n\n/**\n * @category pattern matching\n * @since 2.11.0\n */\nexport function match<F extends URIS3>(\n  F: Functor3<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B\n) => <R, ME>(ma: Kind3<F, R, ME, Either<E, A>>) => Kind3<F, R, ME, B>\nexport function match<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => <R>(ma: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, B>\nexport function match<F extends URIS2>(\n  F: Functor2<F>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => <FE>(ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, B>\nexport function match<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, B>\nexport function match<F extends URIS>(\n  F: Functor1<F>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: Kind<F, Either<E, A>>) => Kind<F, B>\nexport function match<F>(\n  F: Functor<F>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: HKT<F, Either<E, A>>) => HKT<F, B>\nexport function match<F>(\n  F: Functor<F>\n): <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: HKT<F, Either<E, A>>) => HKT<F, B> {\n  return (onLeft, onRight) => (ma) => F.map(ma, E.match(onLeft, onRight))\n}\n\n/**\n * @since 2.10.0\n */\nexport function matchE<M extends URIS3>(\n  M: Chain3<M>\n): <E, R, FE, B, A>(\n  onLeft: (e: E) => Kind3<M, R, FE, B>,\n  onRight: (a: A) => Kind3<M, R, FE, B>\n) => (ma: Kind3<M, R, FE, Either<E, A>>) => Kind3<M, R, FE, B>\nexport function matchE<M extends URIS3, FE>(\n  M: Chain3C<M, FE>\n): <E, R, B, A>(\n  onLeft: (e: E) => Kind3<M, R, FE, B>,\n  onRight: (a: A) => Kind3<M, R, FE, B>\n) => (ma: Kind3<M, R, FE, Either<E, A>>) => Kind3<M, R, FE, B>\nexport function matchE<M extends URIS2>(\n  M: Chain2<M>\n): <E, FE, B, A>(\n  onLeft: (e: E) => Kind2<M, FE, B>,\n  onRight: (a: A) => Kind2<M, FE, B>\n) => (ma: Kind2<M, FE, Either<E, A>>) => Kind2<M, FE, B>\nexport function matchE<M extends URIS2, FE>(\n  M: Chain2C<M, FE>\n): <E, B, A>(\n  onLeft: (e: E) => Kind2<M, FE, B>,\n  onRight: (a: A) => Kind2<M, FE, B>\n) => (ma: Kind2<M, FE, Either<E, A>>) => Kind2<M, FE, B>\nexport function matchE<M extends URIS>(\n  M: Chain1<M>\n): <E, B, A>(onLeft: (e: E) => Kind<M, B>, onRight: (a: A) => Kind<M, B>) => (ma: Kind<M, Either<E, A>>) => Kind<M, B>\nexport function matchE<M>(\n  M: Chain<M>\n): <E, B, A>(onLeft: (e: E) => HKT<M, B>, onRight: (a: A) => HKT<M, B>) => (ma: HKT<M, Either<E, A>>) => HKT<M, B>\nexport function matchE<M>(\n  M: Chain<M>\n): <E, B, A>(onLeft: (e: E) => HKT<M, B>, onRight: (a: A) => HKT<M, B>) => (ma: HKT<M, Either<E, A>>) => HKT<M, B> {\n  return (onLeft, onRight) => (ma) => M.chain(ma, E.match(onLeft, onRight))\n}\n\n/**\n * @since 2.10.0\n */\nexport function getOrElse<M extends URIS3>(\n  M: Monad3<M>\n): <E, R, ME, A>(onLeft: (e: E) => Kind3<M, R, ME, A>) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, A>\nexport function getOrElse<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <E, R, A>(onLeft: (e: E) => Kind3<M, R, ME, A>) => (ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, A>\nexport function getOrElse<M extends URIS2>(\n  M: Monad2<M>\n): <E, ME, A>(onLeft: (e: E) => Kind2<M, ME, A>) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, A>\nexport function getOrElse<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E, A>(onLeft: (e: E) => Kind2<M, ME, A>) => (ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, A>\nexport function getOrElse<M extends URIS>(\n  M: Monad1<M>\n): <E, A>(onLeft: (e: E) => Kind<M, A>) => (ma: Kind<M, Either<E, A>>) => Kind<M, A>\nexport function getOrElse<M>(\n  M: Monad<M>\n): <E, A>(onLeft: (e: E) => HKT<M, A>) => (ma: HKT<M, Either<E, A>>) => HKT<M, A>\nexport function getOrElse<M>(\n  M: Monad<M>\n): <E, A>(onLeft: (e: E) => HKT<M, A>) => (ma: HKT<M, Either<E, A>>) => HKT<M, A> {\n  return (onLeft) => (ma) => M.chain(ma, E.match(onLeft, M.of))\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function orElse<M extends URIS3>(\n  M: Monad3<M>\n): <E1, R, ME, E2, A>(\n  onLeft: (e: E1) => Kind3<M, R, ME, Either<E2, A>>\n) => (ma: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>\nexport function orElse<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <E1, R, E2, A>(\n  onLeft: (e: E1) => Kind3<M, R, ME, Either<E2, A>>\n) => (ma: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>\nexport function orElse<M extends URIS2>(\n  M: Monad2<M>\n): <E1, ME, E2, A>(\n  onLeft: (e: E1) => Kind2<M, ME, Either<E2, A>>\n) => (ma: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>\nexport function orElse<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E1, E2, A>(\n  onLeft: (e: E1) => Kind2<M, ME, Either<E2, A>>\n) => (ma: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>\nexport function orElse<M extends URIS>(\n  M: Monad1<M>\n): <E1, E2, A>(onLeft: (e: E1) => Kind<M, Either<E2, A>>) => (ma: Kind<M, Either<E1, A>>) => Kind<M, Either<E2, A>>\nexport function orElse<M>(\n  M: Monad<M>\n): <E1, E2, A>(onLeft: (e: E1) => HKT<M, Either<E2, A>>) => (ma: HKT<M, Either<E1, A>>) => HKT<M, Either<E2, A>>\nexport function orElse<M>(\n  M: Monad<M>\n): <E1, E2, A>(onLeft: (e: E1) => HKT<M, Either<E2, A>>) => (ma: HKT<M, Either<E1, A>>) => HKT<M, Either<E2, A>> {\n  return (onLeft) => (ma) => M.chain(ma, (e) => (E.isLeft(e) ? onLeft(e.left) : M.of(e)))\n}\n\n/**\n * @category error handling\n * @since 2.11.0\n */\nexport function orElseFirst<M extends URIS3>(\n  M: Monad3<M>\n): <E, R, ME, B>(\n  onLeft: (e: E) => Kind3<M, R, ME, Either<E, B>>\n) => <A>(ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport function orElseFirst<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <E, R, B>(\n  onLeft: (e: E) => Kind3<M, R, ME, Either<E, B>>\n) => <A>(ma: Kind3<M, R, ME, Either<E, A>>) => Kind3<M, R, ME, Either<E, A>>\nexport function orElseFirst<M extends URIS2>(\n  M: Monad2<M>\n): <E, ME, B>(\n  onLeft: (e: E) => Kind2<M, ME, Either<E, B>>\n) => <A>(ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport function orElseFirst<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E, B>(\n  onLeft: (e: E) => Kind2<M, ME, Either<E, B>>\n) => <A>(ma: Kind2<M, ME, Either<E, A>>) => Kind2<M, ME, Either<E, A>>\nexport function orElseFirst<M extends URIS>(\n  M: Monad1<M>\n): <E, B>(onLeft: (e: E) => Kind<M, Either<E, B>>) => <A>(ma: Kind<M, Either<E, A>>) => Kind<M, Either<E, A>>\nexport function orElseFirst<M>(\n  M: Monad<M>\n): <E, B>(onLeft: (e: E) => HKT<M, Either<E, B>>) => <A>(ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>>\nexport function orElseFirst<M>(\n  M: Monad<M>\n): <E, B>(onLeft: (e: E) => HKT<M, Either<E, B>>) => <A>(ma: HKT<M, Either<E, A>>) => HKT<M, Either<E, A>> {\n  const tapErrorM = tapError(M)\n  return (onLeft) => (ma) => tapErrorM(ma, onLeft)\n}\n\n/** @internal */\nexport function tapError<M extends URIS2>(\n  M: Monad2<M>\n): <R, E, A, B>(ma: Kind2<M, R, Either<E, A>>, onLeft: (e: E) => Kind2<M, R, Either<E, B>>) => Kind2<M, R, Either<E, A>>\n/** @internal */\nexport function tapError<M extends URIS>(\n  M: Monad1<M>\n): <E, A, B>(ma: Kind<M, Either<E, A>>, onLeft: (e: E) => Kind<M, Either<E, B>>) => Kind<M, Either<E, A>>\n/** @internal */\nexport function tapError<M>(\n  M: Monad<M>\n): <E, A, B>(ma: HKT<M, Either<E, A>>, onLeft: (e: E) => HKT<M, Either<E, B>>) => HKT<M, Either<E, A>>\n/** @internal */\nexport function tapError<M>(\n  M: Monad<M>\n): <E, A, B>(ma: HKT<M, Either<E, A>>, onLeft: (e: E) => HKT<M, Either<E, B>>) => HKT<M, Either<E, A>> {\n  const orElseM = orElse(M)\n  return (ma, onLeft) =>\n    pipe(\n      ma,\n      orElseM((e) => M.map(onLeft(e), (eb) => (E.isLeft(eb) ? eb : E.left(e))))\n    )\n}\n\n/**\n * @category error handling\n * @since 2.11.0\n */\nexport function orLeft<M extends URIS3>(\n  M: Monad3<M>\n): <E1, R, ME, E2>(\n  onLeft: (e: E1) => Kind3<M, R, ME, E2>\n) => <A>(fa: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>\nexport function orLeft<M extends URIS3, ME>(\n  M: Monad3C<M, ME>\n): <E1, R, E2>(\n  onLeft: (e: E1) => Kind3<M, R, ME, E2>\n) => <A>(fa: Kind3<M, R, ME, Either<E1, A>>) => Kind3<M, R, ME, Either<E2, A>>\nexport function orLeft<M extends URIS2>(\n  M: Monad2<M>\n): <E1, ME, E2>(\n  onLeft: (e: E1) => Kind2<M, ME, E2>\n) => <A>(fa: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>\nexport function orLeft<M extends URIS2, ME>(\n  M: Monad2C<M, ME>\n): <E1, E2>(onLeft: (e: E1) => Kind2<M, ME, E2>) => <A>(fa: Kind2<M, ME, Either<E1, A>>) => Kind2<M, ME, Either<E2, A>>\nexport function orLeft<M extends URIS>(\n  M: Monad1<M>\n): <E1, E2>(onLeft: (e: E1) => Kind<M, E2>) => <A>(fa: Kind<M, Either<E1, A>>) => Kind<M, Either<E2, A>>\nexport function orLeft<M>(\n  M: Monad<M>\n): <E1, E2>(onLeft: (e: E1) => HKT<M, E2>) => <A>(fa: HKT<M, Either<E1, A>>) => HKT<M, Either<E2, A>>\nexport function orLeft<M>(\n  M: Monad<M>\n): <E1, E2>(onLeft: (e: E1) => HKT<M, E2>) => <A>(fa: HKT<M, Either<E1, A>>) => HKT<M, Either<E2, A>> {\n  return (onLeft) => (ma) =>\n    M.chain(\n      ma,\n      E.match(\n        (e) => M.map(onLeft(e), E.left),\n        (a) => M.of(E.right(a))\n      )\n    )\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function swap<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A>(ma: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<A, E>>\nexport function swap<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A>(ma: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, Either<A, E>>\nexport function swap<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A>(ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<A, E>>\nexport function swap<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A>(ma: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, Either<A, E>>\nexport function swap<F extends URIS>(F: Functor1<F>): <E, A>(ma: Kind<F, Either<E, A>>) => Kind<F, Either<A, E>>\nexport function swap<F>(F: Functor<F>): <E, A>(ma: HKT<F, Either<E, A>>) => HKT<F, Either<A, E>>\nexport function swap<F>(F: Functor<F>): <E, A>(ma: HKT<F, Either<E, A>>) => HKT<F, Either<A, E>> {\n  return (ma) => F.map(ma, E.swap)\n}\n\n/**\n * @since 2.10.0\n */\nexport function toUnion<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, E | A>\nexport function toUnion<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A>(fa: Kind3<F, R, FE, Either<E, A>>) => Kind3<F, R, FE, E | A>\nexport function toUnion<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, E | A>\nexport function toUnion<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A>(fa: Kind2<F, FE, Either<E, A>>) => Kind2<F, FE, E | A>\nexport function toUnion<F extends URIS>(F: Functor1<F>): <E, A>(fa: Kind<F, Either<E, A>>) => Kind<F, E | A>\nexport function toUnion<F>(F: Functor<F>): <E, A>(fa: HKT<F, Either<E, A>>) => HKT<F, E | A>\nexport function toUnion<F>(F: Functor<F>): <E, A>(fa: HKT<F, Either<E, A>>) => HKT<F, E | A> {\n  return (fa) => F.map(fa, E.toUnion)\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n// eslint-disable-next-line import/first\nimport URI = E.URI\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface EitherT<M, E, A> extends HKT<M, Either<E, A>> {}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface EitherM<M> extends ApplicativeCompositionHKT2<M, URI> {\n  readonly chain: <E, A, B>(ma: EitherT<M, E, A>, f: (a: A) => EitherT<M, E, B>) => EitherT<M, E, B>\n  readonly alt: <E, A>(fa: EitherT<M, E, A>, that: LazyArg<EitherT<M, E, A>>) => EitherT<M, E, A>\n  readonly bimap: <E, A, N, B>(ma: EitherT<M, E, A>, f: (e: E) => N, g: (a: A) => B) => EitherT<M, N, B>\n  readonly mapLeft: <E, A, N>(ma: EitherT<M, E, A>, f: (e: E) => N) => EitherT<M, N, A>\n  readonly fold: <E, A, R>(ma: EitherT<M, E, A>, onLeft: (e: E) => HKT<M, R>, onRight: (a: A) => HKT<M, R>) => HKT<M, R>\n  readonly getOrElse: <E, A>(ma: EitherT<M, E, A>, onLeft: (e: E) => HKT<M, A>) => HKT<M, A>\n  readonly orElse: <E, A, N>(ma: EitherT<M, E, A>, onLeft: (e: E) => EitherT<M, N, A>) => EitherT<M, N, A>\n  readonly swap: <E, A>(ma: EitherT<M, E, A>) => EitherT<M, A, E>\n  readonly rightM: <E, A>(ma: HKT<M, A>) => EitherT<M, E, A>\n  readonly leftM: <E, A>(me: HKT<M, E>) => EitherT<M, E, A>\n  readonly left: <E, A>(e: E) => EitherT<M, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport type EitherT1<M extends URIS, E, A> = Kind<M, Either<E, A>>\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface EitherM1<M extends URIS> extends ApplicativeComposition12<M, URI> {\n  readonly chain: <E, A, B>(ma: EitherT1<M, E, A>, f: (a: A) => EitherT1<M, E, B>) => EitherT1<M, E, B>\n  readonly alt: <E, A>(fa: EitherT1<M, E, A>, that: LazyArg<EitherT1<M, E, A>>) => EitherT1<M, E, A>\n  readonly bimap: <E, A, N, B>(ma: EitherT1<M, E, A>, f: (e: E) => N, g: (a: A) => B) => EitherT1<M, N, B>\n  readonly mapLeft: <E, A, N>(ma: EitherT1<M, E, A>, f: (e: E) => N) => EitherT1<M, N, A>\n  readonly fold: <E, A, R>(\n    ma: EitherT1<M, E, A>,\n    onLeft: (e: E) => Kind<M, R>,\n    onRight: (a: A) => Kind<M, R>\n  ) => Kind<M, R>\n  readonly getOrElse: <E, A>(ma: EitherT1<M, E, A>, onLeft: (e: E) => Kind<M, A>) => Kind<M, A>\n  readonly orElse: <E, A, N>(ma: EitherT1<M, E, A>, onLeft: (e: E) => EitherT1<M, N, A>) => EitherT1<M, N, A>\n  readonly swap: <E, A>(ma: EitherT1<M, E, A>) => EitherT1<M, A, E>\n  readonly rightM: <E, A>(ma: Kind<M, A>) => EitherT1<M, E, A>\n  readonly leftM: <E, A>(me: Kind<M, E>) => EitherT1<M, E, A>\n  readonly left: <E, A>(e: E) => EitherT1<M, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport type EitherT2<M extends URIS2, R, E, A> = Kind2<M, R, Either<E, A>>\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface EitherM2<M extends URIS2> extends ApplicativeComposition22<M, URI> {\n  readonly chain: <R, E, A, B>(ma: EitherT2<M, R, E, A>, f: (a: A) => EitherT2<M, R, E, B>) => EitherT2<M, R, E, B>\n  readonly alt: <R, E, A>(fa: EitherT2<M, R, E, A>, that: LazyArg<EitherT2<M, R, E, A>>) => EitherT2<M, R, E, A>\n  readonly bimap: <R, E, A, N, B>(ma: EitherT2<M, R, E, A>, f: (e: E) => N, g: (a: A) => B) => EitherT2<M, R, N, B>\n  readonly mapLeft: <R, E, A, N>(ma: EitherT2<M, R, E, A>, f: (e: E) => N) => EitherT2<M, R, N, A>\n  readonly fold: <R, E, A, B>(\n    ma: EitherT2<M, R, E, A>,\n    onLeft: (e: E) => Kind2<M, R, B>,\n    onRight: (a: A) => Kind2<M, R, B>\n  ) => Kind2<M, R, B>\n  readonly getOrElse: <R, E, A>(ma: EitherT2<M, R, E, A>, onLeft: (e: E) => Kind2<M, R, A>) => Kind2<M, R, A>\n  readonly orElse: <R, E, A, F>(\n    ma: EitherT2<M, R, E, A>,\n    onLeft: (e: E) => EitherT2<M, R, F, A>\n  ) => EitherT2<M, R, F, A>\n  readonly swap: <R, E, A>(ma: EitherT2<M, R, E, A>) => EitherT2<M, R, A, E>\n  readonly rightM: <R, E, A>(ma: Kind2<M, R, A>) => EitherT2<M, R, E, A>\n  readonly leftM: <R, E, A>(me: Kind2<M, R, E>) => EitherT2<M, R, E, A>\n  readonly left: <R, E, A>(e: E) => EitherT2<M, R, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getEitherM<M extends URIS2>(M: Monad2<M>): EitherM2<M>\n/** @deprecated  */\nexport function getEitherM<M extends URIS>(M: Monad1<M>): EitherM1<M>\n/** @deprecated  */\nexport function getEitherM<M>(M: Monad<M>): EitherM<M>\n/** @deprecated  */\n/* istanbul ignore next */\nexport function getEitherM<M>(M: Monad<M>): EitherM<M> {\n  const _ap = ap(M)\n  const _map = map(M)\n  const _chain = chain(M)\n  const _alt = alt(M)\n  const _bimap = bimap(M)\n  const _mapLeft = mapLeft(M)\n  const _fold = matchE(M)\n  const _getOrElse = getOrElse(M)\n  const _orElse = orElse(M)\n\n  return {\n    map: (fa, f) => pipe(fa, _map(f)),\n    ap: (fab, fa) => pipe(fab, _ap(fa)),\n    of: right(M),\n    chain: (ma, f) => pipe(ma, _chain(f)),\n    alt: (fa, that) => pipe(fa, _alt(that)),\n    bimap: (fea, f, g) => pipe(fea, _bimap(f, g)),\n    mapLeft: (fea, f) => pipe(fea, _mapLeft(f)),\n    fold: (fa, onLeft, onRight) => pipe(fa, _fold(onLeft, onRight)),\n    getOrElse: (fa, onLeft) => pipe(fa, _getOrElse(onLeft)),\n    orElse: (fa, f) => pipe(fa, _orElse(f)),\n    swap: swap(M),\n    rightM: rightF(M),\n    leftM: leftF(M),\n    left: left(M)\n  }\n}\n"
  },
  {
    "path": "src/Endomorphism.ts",
    "content": "/**\n * @since 2.11.0\n */\n\nimport { flow, identity } from './function'\nimport { Monoid } from './Monoid'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport interface Endomorphism<A> {\n  (a: A): A\n}\n\n/**\n * @category type lambdas\n * @since 2.11.0\n */\nexport const URI = 'Endomorphism'\n\n/**\n * @category type lambdas\n * @since 2.11.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Endomorphism<A>\n  }\n}\n\n/**\n * Endomorphism form a `Semigroup` where the `concat` operation is the usual function composition.\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getSemigroup = <A = never>(): Semigroup<Endomorphism<A>> => ({\n  concat: (first, second) => flow(first, second)\n})\n\n/**\n * Endomorphism form a `Monoid` where the `empty` value is the `identity` function.\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getMonoid = <A = never>(): Monoid<Endomorphism<A>> => ({\n  concat: getSemigroup<A>().concat,\n  empty: identity\n})\n"
  },
  {
    "path": "src/Eq.ts",
    "content": "/**\n * The `Eq` type class represents types which support decidable equality.\n *\n * Instances must satisfy the following laws:\n *\n * 1. Reflexivity: `E.equals(a, a) === true`\n * 2. Symmetry: `E.equals(a, b) === E.equals(b, a)`\n * 3. Transitivity: if `E.equals(a, b) === true` and `E.equals(b, c) === true`, then `E.equals(a, c) === true`\n *\n * @since 2.0.0\n */\nimport { Contravariant1 } from './Contravariant'\nimport { pipe } from './function'\nimport { Monoid } from './Monoid'\nimport { ReadonlyRecord } from './ReadonlyRecord'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Eq<A> {\n  readonly equals: (x: A, y: A) => boolean\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const fromEquals = <A>(equals: Eq<A>['equals']): Eq<A> => ({\n  equals: (x, y) => x === y || equals(x, y)\n})\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport const struct = <A>(eqs: { [K in keyof A]: Eq<A[K]> }): Eq<{ readonly [K in keyof A]: A[K] }> =>\n  fromEquals((first, second) => {\n    for (const key in eqs) {\n      if (!eqs[key].equals(first[key], second[key])) {\n        return false\n      }\n    }\n    return true\n  })\n\n/**\n * Given a tuple of `Eq`s returns a `Eq` for the tuple\n *\n * @example\n * import { tuple } from 'fp-ts/Eq'\n * import * as S from 'fp-ts/string'\n * import * as N from 'fp-ts/number'\n * import * as B from 'fp-ts/boolean'\n *\n * const E = tuple(S.Eq, N.Eq, B.Eq)\n * assert.strictEqual(E.equals(['a', 1, true], ['a', 1, true]), true)\n * assert.strictEqual(E.equals(['a', 1, true], ['b', 1, true]), false)\n * assert.strictEqual(E.equals(['a', 1, true], ['a', 2, true]), false)\n * assert.strictEqual(E.equals(['a', 1, true], ['a', 1, false]), false)\n *\n * @since 2.10.0\n */\nexport const tuple = <A extends ReadonlyArray<unknown>>(...eqs: { [K in keyof A]: Eq<A[K]> }): Eq<Readonly<A>> =>\n  fromEquals((first, second) => eqs.every((E, i) => E.equals(first[i], second[i])))\n\n/* istanbul ignore next */\nconst contramap_: <A, B>(fa: Eq<A>, f: (b: B) => A) => Eq<B> = (fa, f) => pipe(fa, contramap(f))\n\n/**\n * A typical use case for `contramap` would be like, given some `User` type, to construct an `Eq<User>`.\n *\n * We can do so with a function from `User -> X` where `X` is some value that we know how to compare\n * for equality (meaning we have an `Eq<X>`)\n *\n * For example, given the following `User` type, we want to construct an `Eq<User>` that just looks at the `key` field\n * for each user (since it's known to be unique).\n *\n * If we have a way of comparing `UUID`s for equality (`eqUUID: Eq<UUID>`) and we know how to go from `User -> UUID`,\n * using `contramap` we can do this\n *\n * @example\n * import { contramap, Eq } from 'fp-ts/Eq'\n * import { pipe } from 'fp-ts/function'\n * import * as S from 'fp-ts/string'\n *\n * type UUID = string\n *\n * interface User {\n *   readonly key: UUID\n *   readonly firstName: string\n *   readonly lastName: string\n * }\n *\n * const eqUUID: Eq<UUID> = S.Eq\n *\n * const eqUserByKey: Eq<User> = pipe(\n *   eqUUID,\n *   contramap((user) => user.key)\n * )\n *\n * assert.deepStrictEqual(\n *   eqUserByKey.equals(\n *     { key: 'k1', firstName: 'a1', lastName: 'b1' },\n *     { key: 'k2', firstName: 'a1', lastName: 'b1' }\n *   ),\n *   false\n * )\n * assert.deepStrictEqual(\n *   eqUserByKey.equals(\n *     { key: 'k1', firstName: 'a1', lastName: 'b1' },\n *     { key: 'k1', firstName: 'a2', lastName: 'b1' }\n *   ),\n *   true\n * )\n *\n * @since 2.0.0\n */\nexport const contramap: <A, B>(f: (b: B) => A) => (fa: Eq<A>) => Eq<B> = (f) => (fa) =>\n  fromEquals((x, y) => fa.equals(f(x), f(y)))\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Eq'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Eq<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport const eqStrict: Eq<unknown> = {\n  equals: (a, b) => a === b\n}\n\nconst empty: Eq<unknown> = {\n  equals: () => true\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getSemigroup = <A>(): Semigroup<Eq<A>> => ({\n  concat: (x, y) => fromEquals((a, b) => x.equals(a, b) && y.equals(a, b))\n})\n\n/**\n * @category instances\n * @since 2.6.0\n */\nexport const getMonoid = <A>(): Monoid<Eq<A>> => ({\n  concat: getSemigroup<A>().concat,\n  empty\n})\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Contravariant: Contravariant1<URI> = {\n  URI,\n  contramap: contramap_\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`tuple`](#tuple) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getTupleEq: <T extends ReadonlyArray<Eq<any>>>(\n  ...eqs: T\n) => Eq<{ [K in keyof T]: T[K] extends Eq<infer A> ? A : never }> = tuple\n\n/**\n * Use [`struct`](#struct) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getStructEq: <O extends ReadonlyRecord<string, any>>(eqs: { [K in keyof O]: Eq<O[K]> }) => Eq<O> = struct\n\n/**\n * Use [`eqStrict`](#eqstrict) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const strictEqual: <A>(a: A, b: A) => boolean = eqStrict.equals\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Contravariant` instance, pass `E.Contravariant` instead of `E.eq`\n * (where `E` is from `import E from 'fp-ts/Eq'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const eq: Contravariant1<URI> = Contravariant\n\n/**\n * Use [`Eq`](./boolean.ts.html#eq) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const eqBoolean: Eq<boolean> = eqStrict\n\n/**\n * Use [`Eq`](./string.ts.html#eq) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const eqString: Eq<string> = eqStrict\n\n/**\n * Use [`Eq`](./number.ts.html#eq) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const eqNumber: Eq<number> = eqStrict\n\n/**\n * Use [`Eq`](./Date.ts.html#eq) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const eqDate: Eq<Date> = {\n  equals: (first, second) => first.valueOf() === second.valueOf()\n}\n"
  },
  {
    "path": "src/Extend.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C, Functor4 } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Extend<W> extends Functor<W> {\n  readonly extend: <A, B>(wa: HKT<W, A>, f: (wa: HKT<W, A>) => B) => HKT<W, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Extend1<W extends URIS> extends Functor1<W> {\n  readonly extend: <A, B>(wa: Kind<W, A>, f: (wa: Kind<W, A>) => B) => Kind<W, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Extend2<W extends URIS2> extends Functor2<W> {\n  readonly extend: <E, A, B>(wa: Kind2<W, E, A>, f: (wa: Kind2<W, E, A>) => B) => Kind2<W, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Extend2C<W extends URIS2, E> extends Functor2C<W, E> {\n  readonly extend: <A, B>(wa: Kind2<W, E, A>, f: (wa: Kind2<W, E, A>) => B) => Kind2<W, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Extend3<W extends URIS3> extends Functor3<W> {\n  readonly extend: <R, E, A, B>(wa: Kind3<W, R, E, A>, f: (wa: Kind3<W, R, E, A>) => B) => Kind3<W, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Extend3C<W extends URIS3, E> extends Functor3C<W, E> {\n  readonly extend: <R, A, B>(wa: Kind3<W, R, E, A>, f: (wa: Kind3<W, R, E, A>) => B) => Kind3<W, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Extend4<W extends URIS4> extends Functor4<W> {\n  readonly extend: <S, R, E, A, B>(wa: Kind4<W, S, R, E, A>, f: (wa: Kind4<W, S, R, E, A>) => B) => Kind4<W, S, R, E, B>\n}\n"
  },
  {
    "path": "src/Field.ts",
    "content": "/**\n * Adapted from https://github.com/purescript/purescript-prelude/blob/master/src/Data/Field.purs\n *\n * @since 2.0.0\n */\nimport { Eq } from './Eq'\nimport { Ring } from './Ring'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Field<A> extends Ring<A> {\n  readonly degree: (a: A) => number\n  readonly div: (x: A, y: A) => A\n  readonly mod: (x: A, y: A) => A\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * The *greatest common divisor* of two values\n *\n * @since 2.0.0\n */\nexport function gcd<A>(E: Eq<A>, field: Field<A>): (x: A, y: A) => A {\n  const zero = field.zero\n  const f = (x: A, y: A): A => (E.equals(y, zero) ? x : f(y, field.mod(x, y)))\n  return f\n}\n\n/**\n * The *least common multiple* of two values\n *\n * @since 2.0.0\n */\nexport function lcm<A>(E: Eq<A>, F: Field<A>): (x: A, y: A) => A {\n  const zero = F.zero\n  const gcdSF = gcd(E, F)\n  return (x, y) => (E.equals(x, zero) || E.equals(y, zero) ? zero : F.div(F.mul(x, y), gcdSF(x, y)))\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`Field`](./number.ts.html#field) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const fieldNumber: Field<number> = {\n  add: (x, y) => x + y,\n  zero: 0,\n  mul: (x, y) => x * y,\n  one: 1,\n  sub: (x, y) => x - y,\n  degree: (_) => 1,\n  div: (x, y) => x / y,\n  mod: (x, y) => x % y\n}\n"
  },
  {
    "path": "src/Filterable.ts",
    "content": "/**\n * `Filterable` represents data structures which can be _partitioned_/_filtered_.\n *\n * Adapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Filterable.purs\n *\n * @since 2.0.0\n */\nimport {\n  compact,\n  Compactable,\n  Compactable1,\n  Compactable2,\n  Compactable2C,\n  Compactable3,\n  Compactable3C,\n  Compactable4,\n  CompactableComposition,\n  CompactableComposition11,\n  CompactableComposition12,\n  CompactableComposition12C,\n  CompactableComposition21,\n  CompactableComposition22,\n  CompactableComposition23,\n  separate\n} from './Compactable'\nimport { Either } from './Either'\nimport { pipe } from './function'\nimport {\n  Functor,\n  Functor1,\n  Functor2,\n  Functor2C,\n  Functor3,\n  Functor3C,\n  Functor4,\n  FunctorComposition,\n  FunctorComposition11,\n  FunctorComposition12,\n  FunctorComposition12C,\n  FunctorComposition21,\n  FunctorComposition22,\n  FunctorComposition23,\n  getFunctorComposition\n} from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { getLeft, getRight, Option } from './Option'\nimport { not, Predicate } from './Predicate'\nimport { Refinement } from './Refinement'\nimport { Separated, separated } from './Separated'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.0.0\n */\nexport interface Filter<F> {\n  <A, B extends A>(fa: HKT<F, A>, refinement: Refinement<A, B>): HKT<F, B>\n  <A>(fa: HKT<F, A>, predicate: Predicate<A>): HKT<F, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Partition<F> {\n  <A, B extends A>(fa: HKT<F, A>, refinement: Refinement<A, B>): Separated<HKT<F, A>, HKT<F, B>>\n  <A>(fa: HKT<F, A>, predicate: Predicate<A>): Separated<HKT<F, A>, HKT<F, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Filterable<F> extends Functor<F>, Compactable<F> {\n  /**\n   * Partition a data structure based on an either predicate.\n   */\n  readonly partitionMap: <A, B, C>(fa: HKT<F, A>, f: (a: A) => Either<B, C>) => Separated<HKT<F, B>, HKT<F, C>>\n  /**\n   * Partition a data structure based on a boolean predicate.\n   */\n  readonly partition: Partition<F>\n  /**\n   * Map over a data structure and filter based on an option predicate.\n   */\n  readonly filterMap: <A, B>(fa: HKT<F, A>, f: (a: A) => Option<B>) => HKT<F, B>\n  /**\n   * Filter a data structure based on a boolean predicate.\n   */\n  readonly filter: Filter<F>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Filter1<F extends URIS> {\n  <A, B extends A>(fa: Kind<F, A>, refinement: Refinement<A, B>): Kind<F, B>\n  <A>(fa: Kind<F, A>, predicate: Predicate<A>): Kind<F, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Partition1<F extends URIS> {\n  <A, B extends A>(fa: Kind<F, A>, refinement: Refinement<A, B>): Separated<Kind<F, A>, Kind<F, B>>\n  <A>(fa: Kind<F, A>, predicate: Predicate<A>): Separated<Kind<F, A>, Kind<F, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Filterable1<F extends URIS> extends Functor1<F>, Compactable1<F> {\n  readonly partitionMap: <A, B, C>(fa: Kind<F, A>, f: (a: A) => Either<B, C>) => Separated<Kind<F, B>, Kind<F, C>>\n  readonly partition: Partition1<F>\n  readonly filterMap: <A, B>(fa: Kind<F, A>, f: (a: A) => Option<B>) => Kind<F, B>\n  readonly filter: Filter1<F>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Filter2<F extends URIS2> {\n  <E, A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Kind2<F, E, B>\n  <E, A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Kind2<F, E, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Partition2<F extends URIS2> {\n  <E, A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <E, A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Filterable2<F extends URIS2> extends Functor2<F>, Compactable2<F> {\n  readonly partitionMap: <E, A, B, C>(\n    fa: Kind2<F, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n  readonly partition: Partition2<F>\n  readonly filterMap: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => Option<B>) => Kind2<F, E, B>\n  readonly filter: Filter2<F>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Filter2C<F extends URIS2, E> {\n  <A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Kind2<F, E, B>\n  <A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Kind2<F, E, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Partition2C<F extends URIS2, E> {\n  <A, B extends A>(fa: Kind2<F, E, A>, refinement: Refinement<A, B>): Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(fa: Kind2<F, E, A>, predicate: Predicate<A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Filterable2C<F extends URIS2, E> extends Functor2C<F, E>, Compactable2C<F, E> {\n  readonly partitionMap: <A, B, C>(\n    fa: Kind2<F, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n  readonly partition: Partition2C<F, E>\n  readonly filterMap: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => Option<B>) => Kind2<F, E, B>\n  readonly filter: Filter2C<F, E>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Filter3<F extends URIS3> {\n  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Kind3<F, R, E, B>\n  <R, E, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Kind3<F, R, E, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Partition3<F extends URIS3> {\n  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, B>\n  >\n  <R, E, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Filterable3<F extends URIS3> extends Functor3<F>, Compactable3<F> {\n  readonly partitionMap: <R, E, A, B, C>(\n    fa: Kind3<F, R, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n  readonly partition: Partition3<F>\n  readonly filterMap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Option<B>) => Kind3<F, R, E, B>\n  readonly filter: Filter3<F>\n}\n\n/**\n * @since 2.2.0\n */\nexport interface Filter3C<F extends URIS3, E> {\n  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Kind3<F, R, E, B>\n  <R, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Kind3<F, R, E, A>\n}\n\n/**\n * @since 2.2.0\n */\nexport interface Partition3C<F extends URIS3, E> {\n  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinement: Refinement<A, B>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, B>\n  >\n  <R, A>(fa: Kind3<F, R, E, A>, predicate: Predicate<A>): Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Filterable3C<F extends URIS3, E> extends Functor3C<F, E>, Compactable3C<F, E> {\n  readonly partitionMap: <R, A, B, C>(\n    fa: Kind3<F, R, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n  readonly partition: Partition3C<F, E>\n  readonly filterMap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => Option<B>) => Kind3<F, R, E, B>\n  readonly filter: Filter3C<F, E>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Filter4<F extends URIS4> {\n  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinement: Refinement<A, B>): Kind4<F, S, R, E, B>\n  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicate: Predicate<A>): Kind4<F, S, R, E, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Partition4<F extends URIS4> {\n  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinement: Refinement<A, B>): Separated<\n    Kind4<F, S, R, E, A>,\n    Kind4<F, S, R, E, B>\n  >\n  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicate: Predicate<A>): Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Filterable4<F extends URIS4> extends Functor4<F>, Compactable4<F> {\n  readonly partitionMap: <S, R, E, A, B, C>(\n    fa: Kind4<F, S, R, E, A>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\n  readonly partition: Partition4<F>\n  readonly filterMap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => Option<B>) => Kind4<F, S, R, E, B>\n  readonly filter: Filter4<F>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * `filter` composition.\n *\n * @since 2.10.0\n */\nexport function filter<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(fga: Kind2<F, R, Kind2<G, E, A>>) => Kind2<F, R, Kind2<G, E, B>>\n  <A>(predicate: Predicate<A>): <R, B extends A>(fgb: Kind2<F, R, Kind2<G, E, B>>) => Kind2<F, R, Kind2<G, E, B>>\n  <A>(predicate: Predicate<A>): <R>(fga: Kind2<F, R, Kind2<G, E, A>>) => Kind2<F, R, Kind2<G, E, A>>\n}\nexport function filter<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fgb: Kind<F, Kind2<G, E, B>>) => Kind<F, Kind2<G, E, B>>\n  <A>(predicate: Predicate<A>): (fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, A>>\n}\nexport function filter<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fgb: Kind<F, Kind<G, B>>) => Kind<F, Kind<G, B>>\n  <A>(predicate: Predicate<A>): (fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, A>>\n}\nexport function filter<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fgb: HKT<F, HKT<G, B>>) => HKT<F, HKT<G, B>>\n  <A>(predicate: Predicate<A>): (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, A>>\n}\nexport function filter<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): <A>(predicate: Predicate<A>) => (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, A>> {\n  return (predicate) => (fga) => F.map(fga, (ga) => G.filter(ga, predicate))\n}\n\n/**\n * `filterMap` composition.\n *\n * @since 2.10.0\n */\nexport function filterMap<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): <A, B>(f: (a: A) => Option<B>) => <FE>(fga: Kind2<F, FE, Kind2<G, E, A>>) => Kind2<F, FE, Kind2<G, E, B>>\nexport function filterMap<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): <A, B>(f: (a: A) => Option<B>) => (fga: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>\nexport function filterMap<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): <A, B>(f: (a: A) => Option<B>) => (fga: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\nexport function filterMap<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): <A, B>(f: (a: A) => Option<B>) => (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\nexport function filterMap<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): <A, B>(f: (a: A) => Option<B>) => (fga: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>> {\n  return (f) => (fga) => F.map(fga, (ga) => G.filterMap(ga, f))\n}\n\n/**\n * `partition` composition.\n *\n * @since 2.10.0\n */\nexport function partition<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(\n    fga: Kind2<F, R, Kind2<G, E, A>>\n  ) => Separated<Kind2<F, R, Kind2<G, E, A>>, Kind2<F, R, Kind2<G, E, B>>>\n  <A>(predicate: Predicate<A>): <R, B extends A>(\n    fgb: Kind2<F, R, Kind2<G, E, B>>\n  ) => Separated<Kind2<F, R, Kind2<G, E, B>>, Kind2<F, R, Kind2<G, E, B>>>\n  <A>(predicate: Predicate<A>): <R>(\n    fga: Kind2<F, R, Kind2<G, E, A>>\n  ) => Separated<Kind2<F, R, Kind2<G, E, A>>, Kind2<F, R, Kind2<G, E, A>>>\n}\nexport function partition<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fga: Kind<F, Kind2<G, E, A>>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, B>>>\n  <A>(predicate: Predicate<A>): <B extends A>(\n    fgb: Kind<F, Kind2<G, E, B>>\n  ) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, B>>>\n  <A>(predicate: Predicate<A>): (\n    fga: Kind<F, Kind2<G, E, A>>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, A>>>\n}\nexport function partition<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fga: Kind<F, Kind<G, A>>\n  ) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, B>>>\n  <A>(predicate: Predicate<A>): <B extends A>(\n    fgb: Kind<F, Kind<G, B>>\n  ) => Separated<Kind<F, Kind<G, B>>, Kind<F, Kind<G, B>>>\n  <A>(predicate: Predicate<A>): (fga: Kind<F, Kind<G, A>>) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, A>>>\n}\nexport function partition<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fga: HKT<F, HKT<G, A>>\n  ) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, B>>>\n  <A>(predicate: Predicate<A>): <B extends A>(fgb: HKT<F, HKT<G, B>>) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, B>>>\n  <A>(predicate: Predicate<A>): (fga: HKT<F, HKT<G, A>>) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, A>>>\n}\nexport function partition<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): <A>(predicate: Predicate<A>) => (fga: HKT<F, HKT<G, A>>) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, A>>> {\n  const _filter = filter(F, G)\n  return (predicate) => {\n    const left = _filter(not(predicate))\n    const right = _filter(predicate)\n    return (fgb) => separated(left(fgb), right(fgb))\n  }\n}\n\n/**\n * `partitionMap` composition.\n *\n * @since 2.10.0\n */\nexport function partitionMap<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <FE>(fa: Kind2<F, FE, Kind2<G, E, A>>) => Separated<Kind2<F, FE, Kind2<G, E, B>>, Kind2<F, FE, Kind2<G, E, C>>>\nexport function partitionMap<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: Kind<F, Kind2<G, E, A>>) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, C>>>\nexport function partitionMap<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: Kind<F, Kind<G, A>>) => Separated<Kind<F, Kind<G, B>>, Kind<F, Kind<G, C>>>\nexport function partitionMap<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, HKT<G, A>>) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, C>>>\nexport function partitionMap<F, G>(\n  F: Functor<F>,\n  G: Filterable<G>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, HKT<G, A>>) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, C>>> {\n  const _filterMap = filterMap(F, G)\n  return (f) => (fga) =>\n    separated(\n      pipe(\n        fga,\n        _filterMap((a) => getLeft(f(a)))\n      ),\n      pipe(\n        fga,\n        _filterMap((a) => getRight(f(a)))\n      )\n    )\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FilterableComposition<F, G> extends FunctorComposition<F, G>, CompactableComposition<F, G> {\n  readonly partitionMap: <A, B, C>(\n    fa: HKT<F, HKT<G, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<HKT<F, HKT<G, B>>, HKT<F, HKT<G, C>>>\n  readonly partition: <A>(\n    fa: HKT<F, HKT<G, A>>,\n    predicate: Predicate<A>\n  ) => Separated<HKT<F, HKT<G, A>>, HKT<F, HKT<G, A>>>\n  readonly filterMap: <A, B>(fa: HKT<F, HKT<G, A>>, f: (a: A) => Option<B>) => HKT<F, HKT<G, B>>\n  readonly filter: <A>(fa: HKT<F, HKT<G, A>>, predicate: Predicate<A>) => HKT<F, HKT<G, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FilterableComposition11<F extends URIS, G extends URIS>\n  extends FunctorComposition11<F, G>,\n    CompactableComposition11<F, G> {\n  readonly partitionMap: <A, B, C>(\n    fa: Kind<F, Kind<G, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind<F, Kind<G, B>>, Kind<F, Kind<G, C>>>\n  readonly partition: <A>(\n    fa: Kind<F, Kind<G, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind<F, Kind<G, A>>, Kind<F, Kind<G, A>>>\n  readonly filterMap: <A, B>(fa: Kind<F, Kind<G, A>>, f: (a: A) => Option<B>) => Kind<F, Kind<G, B>>\n  readonly filter: <A>(fa: Kind<F, Kind<G, A>>, predicate: Predicate<A>) => Kind<F, Kind<G, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FilterableComposition12<F extends URIS, G extends URIS2>\n  extends FunctorComposition12<F, G>,\n    CompactableComposition12<F, G> {\n  readonly partitionMap: <E, A, B, C>(\n    fa: Kind<F, Kind2<G, E, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, C>>>\n  readonly partition: <E, A>(\n    fa: Kind<F, Kind2<G, E, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, A>>>\n  readonly filterMap: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => Option<B>) => Kind<F, Kind2<G, E, B>>\n  readonly filter: <E, A>(fa: Kind<F, Kind2<G, E, A>>, predicate: Predicate<A>) => Kind<F, Kind2<G, E, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FilterableComposition12C<F extends URIS, G extends URIS2, E>\n  extends FunctorComposition12C<F, G, E>,\n    CompactableComposition12C<F, G, E> {\n  readonly partitionMap: <A, B, C>(\n    fa: Kind<F, Kind2<G, E, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind<F, Kind2<G, E, B>>, Kind<F, Kind2<G, E, C>>>\n  readonly partition: <A>(\n    fa: Kind<F, Kind2<G, E, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind<F, Kind2<G, E, A>>, Kind<F, Kind2<G, E, A>>>\n  readonly filterMap: <A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => Option<B>) => Kind<F, Kind2<G, E, B>>\n  readonly filter: <A>(fa: Kind<F, Kind2<G, E, A>>, predicate: Predicate<A>) => Kind<F, Kind2<G, E, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FilterableComposition21<F extends URIS2, G extends URIS>\n  extends FunctorComposition21<F, G>,\n    CompactableComposition21<F, G> {\n  readonly partitionMap: <E, A, B, C>(\n    fa: Kind2<F, E, Kind<G, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, Kind<G, B>>, Kind2<F, E, Kind<G, C>>>\n  readonly partition: <E, A>(\n    fa: Kind2<F, E, Kind<G, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, E, Kind<G, A>>, Kind2<F, E, Kind<G, A>>>\n  readonly filterMap: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => Option<B>) => Kind2<F, E, Kind<G, B>>\n  readonly filter: <E, A>(fa: Kind2<F, E, Kind<G, A>>, predicate: Predicate<A>) => Kind2<F, E, Kind<G, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FilterableComposition2C1<F extends URIS2, G extends URIS, E>\n  extends FunctorComposition21<F, G>,\n    CompactableComposition21<F, G> {\n  readonly partitionMap: <A, B, C>(\n    fa: Kind2<F, E, Kind<G, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, Kind<G, B>>, Kind2<F, E, Kind<G, C>>>\n  readonly partition: <A>(\n    fa: Kind2<F, E, Kind<G, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, E, Kind<G, A>>, Kind2<F, E, Kind<G, A>>>\n  readonly filterMap: <A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => Option<B>) => Kind2<F, E, Kind<G, B>>\n  readonly filter: <A>(fa: Kind2<F, E, Kind<G, A>>, predicate: Predicate<A>) => Kind2<F, E, Kind<G, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FilterableComposition22<F extends URIS2, G extends URIS2>\n  extends FunctorComposition22<F, G>,\n    CompactableComposition22<F, G> {\n  readonly partitionMap: <FE, GE, A, B, C>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, FE, Kind2<G, GE, B>>, Kind2<F, FE, Kind2<G, GE, C>>>\n  readonly partition: <FE, GE, A>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, FE, Kind2<G, GE, A>>, Kind2<F, FE, Kind2<G, GE, A>>>\n  readonly filterMap: <FE, GE, A, B>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    f: (a: A) => Option<B>\n  ) => Kind2<F, FE, Kind2<G, GE, B>>\n  readonly filter: <FE, GE, A>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    predicate: Predicate<A>\n  ) => Kind2<F, FE, Kind2<G, GE, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FilterableComposition22C<F extends URIS2, G extends URIS2, E>\n  extends FunctorComposition22<F, G>,\n    CompactableComposition22<F, G> {\n  readonly partitionMap: <FE, A, B, C>(\n    fa: Kind2<F, FE, Kind2<G, E, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, FE, Kind2<G, E, B>>, Kind2<F, FE, Kind2<G, E, C>>>\n  readonly partition: <FE, A>(\n    fa: Kind2<F, FE, Kind2<G, E, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, FE, Kind2<G, E, A>>, Kind2<F, FE, Kind2<G, E, A>>>\n  readonly filterMap: <FE, A, B>(\n    fa: Kind2<F, FE, Kind2<G, E, A>>,\n    f: (a: A) => Option<B>\n  ) => Kind2<F, FE, Kind2<G, E, B>>\n  readonly filter: <FE, A>(fa: Kind2<F, FE, Kind2<G, E, A>>, predicate: Predicate<A>) => Kind2<F, FE, Kind2<G, E, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.2.0\n * @deprecated\n */\nexport interface FilterableComposition23C<F extends URIS2, G extends URIS3, E>\n  extends FunctorComposition23<F, G>,\n    CompactableComposition23<F, G> {\n  readonly partitionMap: <R, FE, A, B, C>(\n    fa: Kind2<F, FE, Kind3<G, R, E, A>>,\n    f: (a: A) => Either<B, C>\n  ) => Separated<Kind2<F, FE, Kind3<G, R, E, B>>, Kind2<F, FE, Kind3<G, R, E, C>>>\n  readonly partition: <R, FE, A>(\n    fa: Kind2<F, FE, Kind3<G, R, E, A>>,\n    predicate: Predicate<A>\n  ) => Separated<Kind2<F, FE, Kind3<G, R, E, A>>, Kind2<F, FE, Kind3<G, R, E, A>>>\n  readonly filterMap: <R, FE, A, B>(\n    fa: Kind2<F, FE, Kind3<G, R, E, A>>,\n    f: (a: A) => Option<B>\n  ) => Kind2<F, FE, Kind3<G, R, E, B>>\n  readonly filter: <R, FE, A>(\n    fa: Kind2<F, FE, Kind3<G, R, E, A>>,\n    predicate: Predicate<A>\n  ) => Kind2<F, FE, Kind3<G, R, E, A>>\n}\n\n/**\n * Use\n *\n * - [`filter`](#filter)\n * - [`filterMap`](#filtermap)\n * - [`partition`](#partition)\n * - [`partitionMap`](#partitionmap)\n *\n * instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getFilterableComposition<F extends URIS2, G extends URIS3, E>(\n  F: Functor2<F>,\n  G: Filterable3C<G, E>\n): FilterableComposition23C<F, G, E>\n/** @deprecated */\nexport function getFilterableComposition<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Filterable2C<G, E>\n): FilterableComposition22C<F, G, E>\n/** @deprecated */\nexport function getFilterableComposition<F extends URIS2, G extends URIS2>(\n  F: Functor2<F>,\n  G: Filterable2<G>\n): FilterableComposition22<F, G>\n/** @deprecated */\nexport function getFilterableComposition<F extends URIS2, G extends URIS, E>(\n  F: Functor2C<F, E>,\n  G: Filterable1<G>\n): FilterableComposition2C1<F, G, E>\n/** @deprecated */\nexport function getFilterableComposition<F extends URIS2, G extends URIS>(\n  F: Functor2<F>,\n  G: Filterable1<G>\n): FilterableComposition21<F, G>\n/** @deprecated */\nexport function getFilterableComposition<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Filterable2C<G, E>\n): FilterableComposition12C<F, G, E>\n/** @deprecated */\nexport function getFilterableComposition<F extends URIS, G extends URIS2>(\n  F: Functor1<F>,\n  G: Filterable2<G>\n): FilterableComposition12<F, G>\n/** @deprecated */\nexport function getFilterableComposition<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Filterable1<G>\n): FilterableComposition11<F, G>\n/** @deprecated */\nexport function getFilterableComposition<F, G>(F: Functor<F>, G: Filterable<G>): FilterableComposition<F, G>\n/** @deprecated */\nexport function getFilterableComposition<F, G>(F: Functor<F>, G: Filterable<G>): FilterableComposition<F, G> {\n  const map = getFunctorComposition(F, G).map\n  const _compact = compact(F, G)\n  const _separate = separate(F, G, G)\n  const _filter = filter(F, G)\n  const _filterMap = filterMap(F, G)\n  const _partition = partition(F, G)\n  const _partitionMap = partitionMap(F, G)\n  return {\n    map,\n    compact: _compact,\n    separate: _separate,\n    filter: (fga, f) => pipe(fga, _filter(f)),\n    filterMap: (fga, f) => pipe(fga, _filterMap(f)),\n    partition: (fga, p) => pipe(fga, _partition(p)),\n    partitionMap: (fga, f) => pipe(fga, _partitionMap(f))\n  }\n}\n"
  },
  {
    "path": "src/FilterableWithIndex.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Either } from './Either'\nimport {\n  Filterable,\n  Filterable1,\n  Filterable2,\n  Filterable2C,\n  Filterable3,\n  Filterable3C,\n  Filterable4\n} from './Filterable'\nimport {\n  FunctorWithIndex,\n  FunctorWithIndex1,\n  FunctorWithIndex2,\n  FunctorWithIndex2C,\n  FunctorWithIndex3,\n  FunctorWithIndex3C,\n  FunctorWithIndex4\n} from './FunctorWithIndex'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Option } from './Option'\nimport { Separated } from './Separated'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.0.0\n */\nexport type RefinementWithIndex<I, A, B extends A> = (i: I, a: A) => a is B\n\n/**\n * @since 2.0.0\n */\nexport type PredicateWithIndex<I, A> = (i: I, a: A) => boolean\n\n/**\n * @since 2.0.0\n */\nexport interface FilterWithIndex<F, I> {\n  <A, B extends A>(fa: HKT<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): HKT<F, B>\n  <A>(fa: HKT<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): HKT<F, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface PartitionWithIndex<F, I> {\n  <A, B extends A>(fa: HKT<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<HKT<F, A>, HKT<F, B>>\n  <A>(fa: HKT<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<HKT<F, A>, HKT<F, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FilterableWithIndex<F, I> extends FunctorWithIndex<F, I>, Filterable<F> {\n  readonly partitionMapWithIndex: <A, B, C>(\n    fa: HKT<F, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<HKT<F, B>, HKT<F, C>>\n  readonly partitionWithIndex: PartitionWithIndex<F, I>\n  readonly filterMapWithIndex: <A, B>(fa: HKT<F, A>, f: (i: I, a: A) => Option<B>) => HKT<F, B>\n  readonly filterWithIndex: FilterWithIndex<F, I>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface FilterWithIndex1<F extends URIS, I> {\n  <A, B extends A>(fa: Kind<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind<F, B>\n  <A>(fa: Kind<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind<F, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface PartitionWithIndex1<F extends URIS, I> {\n  <A, B extends A>(fa: Kind<F, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<Kind<F, A>, Kind<F, B>>\n  <A>(fa: Kind<F, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<Kind<F, A>, Kind<F, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FilterableWithIndex1<F extends URIS, I> extends FunctorWithIndex1<F, I>, Filterable1<F> {\n  readonly partitionMapWithIndex: <A, B, C>(\n    fa: Kind<F, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind<F, B>, Kind<F, C>>\n  readonly partitionWithIndex: PartitionWithIndex1<F, I>\n  readonly filterMapWithIndex: <A, B>(fa: Kind<F, A>, f: (i: I, a: A) => Option<B>) => Kind<F, B>\n  readonly filterWithIndex: FilterWithIndex1<F, I>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface FilterWithIndex2<F extends URIS2, I> {\n  <E, A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind2<F, E, B>\n  <E, A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind2<F, E, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface PartitionWithIndex2<F extends URIS2, I> {\n  <E, A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind2<F, E, A>,\n    Kind2<F, E, B>\n  >\n  <E, A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FilterableWithIndex2<F extends URIS2, I> extends FunctorWithIndex2<F, I>, Filterable2<F> {\n  readonly partitionMapWithIndex: <E, A, B, C>(\n    fa: Kind2<F, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex2<F, I>\n  readonly filterMapWithIndex: <E, A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => Option<B>) => Kind2<F, E, B>\n  readonly filterWithIndex: FilterWithIndex2<F, I>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface FilterWithIndex2C<F extends URIS2, I, E> {\n  <A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind2<F, E, B>\n  <A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind2<F, E, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface PartitionWithIndex2C<F extends URIS2, I, E> {\n  <A, B extends A>(fa: Kind2<F, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind2<F, E, A>,\n    Kind2<F, E, B>\n  >\n  <A>(fa: Kind2<F, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FilterableWithIndex2C<F extends URIS2, I, E> extends FunctorWithIndex2C<F, I, E>, Filterable2C<F, E> {\n  readonly partitionMapWithIndex: <A, B, C>(\n    fa: Kind2<F, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex2C<F, I, E>\n  readonly filterMapWithIndex: <A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => Option<B>) => Kind2<F, E, B>\n  readonly filterWithIndex: FilterWithIndex2C<F, I, E>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface FilterWithIndex3<F extends URIS3, I> {\n  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind3<F, R, E, B>\n  <R, E, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind3<F, R, E, A>\n}\n\n/**\n * @since 2.2.0\n */\nexport interface FilterWithIndex3C<F extends URIS3, I, E> {\n  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind3<F, R, E, B>\n  <R, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface FilterableWithIndex3C<F extends URIS3, I, E> extends FunctorWithIndex3C<F, I, E>, Filterable3C<F, E> {\n  readonly partitionMapWithIndex: <R, A, B, C>(\n    fa: Kind3<F, R, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex3C<F, I, E>\n  readonly filterMapWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => Option<B>) => Kind3<F, R, E, B>\n  readonly filterWithIndex: FilterWithIndex3C<F, I, E>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface PartitionWithIndex3<F extends URIS3, I> {\n  <R, E, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, B>\n  >\n  <R, E, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, A>\n  >\n}\n\n/**\n * @since 2.2.0\n */\nexport interface PartitionWithIndex3C<F extends URIS3, I, E> {\n  <R, A, B extends A>(fa: Kind3<F, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, B>\n  >\n  <R, A>(fa: Kind3<F, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<\n    Kind3<F, R, E, A>,\n    Kind3<F, R, E, A>\n  >\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FilterableWithIndex3<F extends URIS3, I> extends FunctorWithIndex3<F, I>, Filterable3<F> {\n  readonly partitionMapWithIndex: <R, E, A, B, C>(\n    fa: Kind3<F, R, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex3<F, I>\n  readonly filterMapWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => Option<B>) => Kind3<F, R, E, B>\n  readonly filterWithIndex: FilterWithIndex3<F, I>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface FilterWithIndex4<F extends URIS4, I> {\n  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Kind4<\n    F,\n    S,\n    R,\n    E,\n    B\n  >\n  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Kind4<F, S, R, E, A>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface PartitionWithIndex4<F extends URIS4, I> {\n  <S, R, E, A, B extends A>(fa: Kind4<F, S, R, E, A>, refinementWithIndex: RefinementWithIndex<I, A, B>): Separated<\n    Kind4<F, S, R, E, A>,\n    Kind4<F, S, R, E, B>\n  >\n  <S, R, E, A>(fa: Kind4<F, S, R, E, A>, predicateWithIndex: PredicateWithIndex<I, A>): Separated<\n    Kind4<F, S, R, E, A>,\n    Kind4<F, S, R, E, A>\n  >\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FilterableWithIndex4<F extends URIS4, I> extends FunctorWithIndex4<F, I>, Filterable4<F> {\n  readonly partitionMapWithIndex: <S, R, E, A, B, C>(\n    fa: Kind4<F, S, R, E, A>,\n    f: (i: I, a: A) => Either<B, C>\n  ) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\n  readonly partitionWithIndex: PartitionWithIndex4<F, I>\n  readonly filterMapWithIndex: <S, R, E, A, B>(\n    fa: Kind4<F, S, R, E, A>,\n    f: (i: I, a: A) => Option<B>\n  ) => Kind4<F, S, R, E, B>\n  readonly filterWithIndex: FilterWithIndex4<F, I>\n}\n"
  },
  {
    "path": "src/Foldable.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Applicative, Applicative1, Applicative2, Applicative2C, Applicative3 } from './Applicative'\nimport { constant, pipe } from './function'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Monad, Monad1, Monad2, Monad2C, Monad3, Monad3C } from './Monad'\nimport { Monoid } from './Monoid'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Foldable<F> {\n  readonly URI: F\n  readonly reduce: <A, B>(fa: HKT<F, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: HKT<F, A>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: HKT<F, A>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Foldable1<F extends URIS> {\n  readonly URI: F\n  readonly reduce: <A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind<F, A>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind<F, A>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Foldable2<F extends URIS2> {\n  readonly URI: F\n  readonly reduce: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <E, A>(fa: Kind2<F, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Foldable2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly reduce: <A, B>(fa: Kind2<F, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind2<F, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind2<F, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Foldable3<F extends URIS3> {\n  readonly URI: F\n  readonly reduce: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <R, E, A>(fa: Kind3<F, R, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Foldable3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly reduce: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <R, A>(fa: Kind3<F, R, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Foldable4<F extends URIS4> {\n  readonly URI: F\n  readonly reduce: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <S, R, E, A>(fa: Kind4<F, S, R, E, A>, f: (a: A) => M) => M\n  readonly reduceRight: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (a: A, b: B) => B) => B\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * `reduce` composition.\n *\n * @since 2.10.0\n */\nexport function reduce<F extends URIS, G extends URIS>(\n  F: Foldable1<F>,\n  G: Foldable1<G>\n): <B, A>(b: B, f: (b: B, a: A) => B) => (fga: Kind<F, Kind<G, A>>) => B\nexport function reduce<F, G>(\n  F: Foldable<F>,\n  G: Foldable<G>\n): <B, A>(b: B, f: (b: B, a: A) => B) => (fga: HKT<F, HKT<G, A>>) => B\nexport function reduce<F, G>(\n  F: Foldable<F>,\n  G: Foldable<G>\n): <B, A>(b: B, f: (b: B, a: A) => B) => (fga: HKT<F, HKT<G, A>>) => B {\n  return (b, f) => (fga) => F.reduce(fga, b, (b, ga) => G.reduce(ga, b, f))\n}\n\n/**\n * `foldMap` composition.\n *\n * @since 2.10.0\n */\nexport function foldMap<F extends URIS, G extends URIS>(\n  F: Foldable1<F>,\n  G: Foldable1<G>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fga: Kind<F, Kind<G, A>>) => M\nexport function foldMap<F, G>(\n  F: Foldable<F>,\n  G: Foldable<G>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fga: HKT<F, HKT<G, A>>) => M\nexport function foldMap<F, G>(\n  F: Foldable<F>,\n  G: Foldable<G>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fga: HKT<F, HKT<G, A>>) => M {\n  return (M) => {\n    const foldMapF = F.foldMap(M)\n    const foldMapG = G.foldMap(M)\n    return (f) => (fga) => foldMapF(fga, (ga) => foldMapG(ga, f))\n  }\n}\n\n/**\n * `reduceRight` composition.\n *\n * @since 2.10.0\n */\nexport function reduceRight<F extends URIS, G extends URIS>(\n  F: Foldable1<F>,\n  G: Foldable1<G>\n): <B, A>(b: B, f: (a: A, b: B) => B) => (fga: Kind<F, Kind<G, A>>) => B\nexport function reduceRight<F, G>(\n  F: Foldable<F>,\n  G: Foldable<G>\n): <B, A>(b: B, f: (a: A, b: B) => B) => (fga: HKT<F, HKT<G, A>>) => B\nexport function reduceRight<F, G>(\n  F: Foldable<F>,\n  G: Foldable<G>\n): <B, A>(b: B, f: (a: A, b: B) => B) => (fga: HKT<F, HKT<G, A>>) => B {\n  return (b, f) => (fga) => F.reduceRight(fga, b, (ga, b) => G.reduceRight(ga, b, f))\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Similar to 'reduce', but the result is encapsulated in a monad.\n *\n * Note: this function is not generally stack-safe, e.g., for monads which build up thunks a la `IO`.\n *\n * @example\n * import { reduceM } from 'fp-ts/Foldable'\n * import { Monad, some } from 'fp-ts/Option'\n * import { make, Foldable } from 'fp-ts/Tree'\n * import { pipe } from 'fp-ts/function'\n *\n * const t = make(1, [make(2, []), make(3, []), make(4, [])])\n * assert.deepStrictEqual(pipe(t, reduceM(Monad, Foldable)(0, (b, a) => (a > 2 ? some(b + a) : some(b)))), some(7))\n *\n * @since 2.8.0\n */\nexport function reduceM<M extends URIS3, F extends URIS>(\n  M: Monad3<M>,\n  F: Foldable1<F>\n): <B, A, R, E>(b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => (fa: Kind<F, A>) => Kind3<M, R, E, B>\nexport function reduceM<M extends URIS3, F extends URIS, E>(\n  M: Monad3C<M, E>,\n  F: Foldable1<F>\n): <B, A, R>(b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => (fa: Kind<F, A>) => Kind3<M, R, E, B>\nexport function reduceM<M extends URIS2, F extends URIS>(\n  M: Monad2<M>,\n  F: Foldable1<F>\n): <B, A, E>(b: B, f: (b: B, a: A) => Kind2<M, E, B>) => (fa: Kind<F, A>) => Kind2<M, E, B>\nexport function reduceM<M extends URIS2, F extends URIS, E>(\n  M: Monad2C<M, E>,\n  F: Foldable1<F>\n): <B, A>(b: B, f: (b: B, a: A) => Kind2<M, E, B>) => (fa: Kind<F, A>) => Kind2<M, E, B>\nexport function reduceM<M extends URIS, F extends URIS>(\n  M: Monad1<M>,\n  F: Foldable1<F>\n): <B, A>(b: B, f: (b: B, a: A) => Kind<M, B>) => (fa: Kind<F, A>) => Kind<M, B>\nexport function reduceM<M, F>(\n  M: Monad<M>,\n  F: Foldable<F>\n): <B, A>(b: B, f: (b: B, a: A) => HKT<M, B>) => (fa: HKT<F, A>) => HKT<M, B>\nexport function reduceM<M, F>(\n  M: Monad<M>,\n  F: Foldable<F>\n): <B, A>(b: B, f: (b: B, a: A) => HKT<M, B>) => (fa: HKT<F, A>) => HKT<M, B> {\n  return (b, f) => (fa) => F.reduce(fa, M.of(b), (mb, a) => M.chain(mb, (b) => f(b, a)))\n}\n\n// TODO: curry in v3\n/**\n * Fold a data structure, accumulating values in some `Monoid`, combining adjacent elements using the specified separator\n *\n * @example\n * import { intercalate } from 'fp-ts/Foldable'\n * import * as S from 'fp-ts/string'\n * import { make, Foldable } from 'fp-ts/Tree'\n *\n * const t = make('a', [make('b', []), make('c', []), make('d', [])])\n * assert.strictEqual(intercalate(S.Monoid, Foldable)('|', t), 'a|b|c|d')\n *\n * @since 2.0.0\n */\nexport function intercalate<M, F extends URIS3>(\n  M: Monoid<M>,\n  F: Foldable3<F>\n): <R, E>(middle: M, fm: Kind3<F, R, E, M>) => M\nexport function intercalate<M, F extends URIS2>(M: Monoid<M>, F: Foldable2<F>): <E>(middle: M, fm: Kind2<F, E, M>) => M\nexport function intercalate<M, F extends URIS2, E>(\n  M: Monoid<M>,\n  F: Foldable2C<F, E>\n): (middle: M, fm: Kind2<F, E, M>) => M\nexport function intercalate<M, F extends URIS>(M: Monoid<M>, F: Foldable1<F>): (middle: M, fm: Kind<F, M>) => M\nexport function intercalate<M, F>(M: Monoid<M>, F: Foldable<F>): (middle: M, fm: HKT<F, M>) => M\nexport function intercalate<M, F>(M: Monoid<M>, F: Foldable<F>): (middle: M, fm: HKT<F, M>) => M {\n  interface Acc<M> {\n    readonly init: boolean\n    readonly acc: M\n  }\n  return (middle, fm) => {\n    const go = ({ init, acc }: Acc<M>, x: M): Acc<M> =>\n      init ? { init: false, acc: x } : { init: false, acc: M.concat(M.concat(acc, middle), x) }\n    return F.reduce(fm, { init: true, acc: M.empty }, go).acc\n  }\n}\n\n/**\n * Transforms a `Foldable` into a `toReadonlyArray`.\n *\n * @example\n * import { toReadonlyArray } from 'fp-ts/Foldable'\n * import { Foldable, make } from 'fp-ts/Tree'\n *\n * const t = make(1, [make(2, []), make(3, []), make(4, [])])\n * assert.deepStrictEqual(toReadonlyArray(Foldable)(t), [1, 2, 3, 4])\n *\n * @since 2.10.0\n */\nexport function toReadonlyArray<F extends URIS4>(\n  F: Foldable4<F>\n): <S, R, E, A>(fa: Kind4<F, S, R, E, A>) => ReadonlyArray<A>\nexport function toReadonlyArray<F extends URIS3>(F: Foldable3<F>): <R, E, A>(fa: Kind3<F, R, E, A>) => ReadonlyArray<A>\nexport function toReadonlyArray<F extends URIS3, E>(\n  F: Foldable3C<F, E>\n): <R, A>(fa: Kind3<F, R, E, A>) => ReadonlyArray<A>\nexport function toReadonlyArray<F extends URIS2>(F: Foldable2<F>): <E, A>(fa: Kind2<F, E, A>) => ReadonlyArray<A>\nexport function toReadonlyArray<F extends URIS2, E>(F: Foldable2C<F, E>): <A>(fa: Kind2<F, E, A>) => ReadonlyArray<A>\nexport function toReadonlyArray<F extends URIS>(F: Foldable1<F>): <A>(fa: Kind<F, A>) => ReadonlyArray<A>\nexport function toReadonlyArray<F>(F: Foldable<F>): <A>(fa: HKT<F, A>) => ReadonlyArray<A>\nexport function toReadonlyArray<F>(F: Foldable<F>): <A>(fa: HKT<F, A>) => ReadonlyArray<A> {\n  return <A>(fa: HKT<F, A>) =>\n    F.reduce(fa, [], (acc: Array<A>, a) => {\n      acc.push(a)\n      return acc\n    })\n}\n\n/**\n * Traverse a data structure, performing some effects encoded by an `Applicative` functor at each value, ignoring the\n * final result.\n *\n * @example\n * import { Foldable } from 'fp-ts/Array'\n * import { traverse_ } from 'fp-ts/Foldable'\n * import { Applicative } from 'fp-ts/IO'\n *\n * let log = ''\n * const append = (s: string) => () => (log += s)\n * traverse_(Applicative, Foldable)(['a', 'b', 'c'], append)()\n * assert.strictEqual(log, 'abc')\n *\n * @since 2.0.0\n */\nexport function traverse_<M extends URIS3, F extends URIS>(\n  M: Applicative3<M>,\n  F: Foldable1<F>\n): <R, E, A, B>(fa: Kind<F, A>, f: (a: A) => Kind3<M, R, E, B>) => Kind3<M, R, E, void>\nexport function traverse_<M extends URIS2, F extends URIS>(\n  M: Applicative2<M>,\n  F: Foldable1<F>\n): <E, A, B>(fa: Kind<F, A>, f: (a: A) => Kind2<M, E, B>) => Kind2<M, E, void>\nexport function traverse_<M extends URIS2, F extends URIS, E>(\n  M: Applicative2C<M, E>,\n  F: Foldable1<F>\n): <A, B>(fa: Kind<F, A>, f: (a: A) => Kind2<M, E, B>) => Kind2<M, E, void>\nexport function traverse_<M extends URIS, F extends URIS>(\n  M: Applicative1<M>,\n  F: Foldable1<F>\n): <A, B>(fa: Kind<F, A>, f: (a: A) => Kind<M, B>) => Kind<M, void>\nexport function traverse_<M, F>(\n  M: Applicative<M>,\n  F: Foldable<F>\n): <A, B>(fa: HKT<F, A>, f: (a: A) => HKT<M, B>) => HKT<M, void>\nexport function traverse_<M, F>(\n  M: Applicative<M>,\n  F: Foldable<F>\n): <A, B>(fa: HKT<F, A>, f: (a: A) => HKT<M, B>) => HKT<M, void> {\n  const applyFirst = <B>(mu: HKT<M, void>, mb: HKT<M, B>): HKT<M, void> => M.ap(M.map(mu, constant), mb)\n  const mu: HKT<M, void> = M.of(undefined)\n  return (fa, f) => F.reduce(fa, mu, (mu, a) => applyFirst(mu, f(a)))\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`reduceM`](#reducem) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function foldM<M extends URIS3, F extends URIS>(\n  M: Monad3<M>,\n  F: Foldable1<F>\n): <R, E, A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => Kind3<M, R, E, B>\n/** @deprecated */\nexport function foldM<M extends URIS3, F extends URIS, E>(\n  M: Monad3C<M, E>,\n  F: Foldable1<F>\n): <R, A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind3<M, R, E, B>) => Kind3<M, R, E, B>\n/** @deprecated */\nexport function foldM<M extends URIS2, F extends URIS>(\n  M: Monad2<M>,\n  F: Foldable1<F>\n): <E, A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind2<M, E, B>) => Kind2<M, E, B>\n/** @deprecated */\nexport function foldM<M extends URIS2, F extends URIS, E>(\n  M: Monad2C<M, E>,\n  F: Foldable1<F>\n): <A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind2<M, E, B>) => Kind2<M, E, B>\n/** @deprecated */\nexport function foldM<M extends URIS, F extends URIS>(\n  M: Monad1<M>,\n  F: Foldable1<F>\n): <A, B>(fa: Kind<F, A>, b: B, f: (b: B, a: A) => Kind<M, B>) => Kind<M, B>\n/** @deprecated */\nexport function foldM<M, F>(\n  M: Monad<M>,\n  F: Foldable<F>\n): <A, B>(fa: HKT<F, A>, b: B, f: (b: B, a: A) => HKT<M, B>) => HKT<M, B>\nexport function foldM<M, F>(\n  M: Monad<M>,\n  F: Foldable<F>\n): <A, B>(fa: HKT<F, A>, b: B, f: (b: B, a: A) => HKT<M, B>) => HKT<M, B> {\n  return (fa, b, f) => F.reduce(fa, M.of(b), (mb, a) => M.chain(mb, (b) => f(b, a)))\n}\n\n/**\n * Use [`toReadonlyArray`](#toreadonlyarray) instead\n *\n * @category zone of death\n * @since 2.8.0\n * @deprecated\n */\nexport const toArray = toReadonlyArray\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableComposition<F, G> {\n  readonly reduce: <A, B>(fga: HKT<F, HKT<G, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: HKT<F, HKT<G, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: HKT<F, HKT<G, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableComposition11<F extends URIS, G extends URIS> {\n  readonly reduce: <A, B>(fga: Kind<F, Kind<G, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind<F, Kind<G, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind<F, Kind<G, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableComposition12<F extends URIS, G extends URIS2> {\n  readonly reduce: <E, A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <E, A>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableComposition12C<F extends URIS, G extends URIS2, E> {\n  readonly reduce: <A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind<F, Kind2<G, E, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableComposition21<F extends URIS2, G extends URIS> {\n  readonly reduce: <E, A, B>(fga: Kind2<F, E, Kind<G, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <E, A>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableComposition2C1<F extends URIS2, G extends URIS, E> {\n  readonly reduce: <A, B>(fga: Kind2<F, E, Kind<G, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <A, B>(fa: Kind2<F, E, Kind<G, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableComposition22<F extends URIS2, G extends URIS2> {\n  readonly reduce: <FE, GE, A, B>(fga: Kind2<F, FE, Kind2<G, GE, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <FE, GE, A>(fa: Kind2<F, FE, Kind2<G, GE, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <FE, GE, A, B>(fa: Kind2<F, FE, Kind2<G, GE, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableComposition22C<F extends URIS2, G extends URIS2, E> {\n  readonly reduce: <FE, A, B>(fga: Kind2<F, FE, Kind2<G, E, A>>, b: B, f: (b: B, a: A) => B) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <FE, A>(fa: Kind2<F, FE, Kind2<G, E, A>>, f: (a: A) => M) => M\n  readonly reduceRight: <FE, A, B>(fa: Kind2<F, FE, Kind2<G, E, A>>, b: B, f: (a: A, b: B) => B) => B\n}\n\n/**\n * Use\n *\n * - [reduce](#reduce)\n * - [foldMap](#foldmap)\n * - [reduceRight](#reduceright)\n *\n * instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getFoldableComposition<F extends URIS2, G extends URIS2, E>(\n  F: Foldable2<F>,\n  G: Foldable2C<G, E>\n): FoldableComposition22C<F, G, E>\n/** @deprecated */\nexport function getFoldableComposition<F extends URIS2, G extends URIS2>(\n  F: Foldable2<F>,\n  G: Foldable2<G>\n): FoldableComposition22<F, G>\n/** @deprecated */\nexport function getFoldableComposition<F extends URIS2, G extends URIS, E>(\n  F: Foldable2C<F, E>,\n  G: Foldable1<G>\n): FoldableComposition2C1<F, G, E>\n/** @deprecated */\nexport function getFoldableComposition<F extends URIS2, G extends URIS>(\n  F: Foldable2<F>,\n  G: Foldable1<G>\n): FoldableComposition21<F, G>\n/** @deprecated */\nexport function getFoldableComposition<F extends URIS, G extends URIS2, E>(\n  F: Foldable1<F>,\n  G: Foldable2C<G, E>\n): FoldableComposition12C<F, G, E>\n/** @deprecated */\nexport function getFoldableComposition<F extends URIS, G extends URIS2>(\n  F: Foldable1<F>,\n  G: Foldable2<G>\n): FoldableComposition12<F, G>\n/** @deprecated */\nexport function getFoldableComposition<F extends URIS, G extends URIS>(\n  F: Foldable1<F>,\n  G: Foldable1<G>\n): FoldableComposition11<F, G>\n/** @deprecated */\nexport function getFoldableComposition<F, G>(F: Foldable<F>, G: Foldable<G>): FoldableComposition<F, G>\n/** @deprecated */\nexport function getFoldableComposition<F, G>(F: Foldable<F>, G: Foldable<G>): FoldableComposition<F, G> {\n  const _reduce = reduce(F, G)\n  const _foldMap = foldMap(F, G)\n  const _reduceRight = reduceRight(F, G)\n  return {\n    reduce: (fga, b, f) => pipe(fga, _reduce(b, f)),\n    foldMap: (M) => {\n      const foldMapM = _foldMap(M)\n      return (fga, f) => pipe(fga, foldMapM(f))\n    },\n    reduceRight: (fga, b, f) => pipe(fga, _reduceRight(b, f))\n  }\n}\n"
  },
  {
    "path": "src/FoldableWithIndex.ts",
    "content": "/**\n * A `Foldable` with an additional index.\n * A `FoldableWithIndex` instance must be compatible with its `Foldable` instance\n *\n * ```ts\n * reduce(fa, b, f) = reduceWithIndex(fa, b, (_, b, a) => f(b, a))\n * foldMap(M)(fa, f) = foldMapWithIndex(M)(fa, (_, a) => f(a))\n * reduceRight(fa, b, f) = reduceRightWithIndex(fa, b, (_, a, b) => f(a, b))\n * ```\n *\n * @since 2.0.0\n */\nimport {\n  Foldable,\n  Foldable1,\n  Foldable2,\n  Foldable2C,\n  Foldable3,\n  Foldable3C,\n  Foldable4,\n  FoldableComposition,\n  FoldableComposition2C1,\n  FoldableComposition11,\n  FoldableComposition12,\n  FoldableComposition12C,\n  FoldableComposition21,\n  FoldableComposition22,\n  FoldableComposition22C,\n  getFoldableComposition\n} from './Foldable'\nimport { pipe } from './function'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Monoid } from './Monoid'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FoldableWithIndex<F, I> extends Foldable<F> {\n  readonly reduceWithIndex: <A, B>(fa: HKT<F, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fa: HKT<F, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fa: HKT<F, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FoldableWithIndex1<F extends URIS, I> extends Foldable1<F> {\n  readonly reduceWithIndex: <A, B>(fa: Kind<F, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fa: Kind<F, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fa: Kind<F, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FoldableWithIndex2<F extends URIS2, I> extends Foldable2<F> {\n  readonly reduceWithIndex: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <E, A>(fa: Kind2<F, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <E, A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FoldableWithIndex2C<F extends URIS2, I, E> extends Foldable2C<F, E> {\n  readonly reduceWithIndex: <A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fa: Kind2<F, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fa: Kind2<F, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FoldableWithIndex3<F extends URIS3, I> extends Foldable3<F> {\n  readonly reduceWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <R, E, A>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface FoldableWithIndex3C<F extends URIS3, I, E> extends Foldable3C<F, E> {\n  readonly reduceWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <R, A>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FoldableWithIndex4<F extends URIS4, I> extends Foldable4<F> {\n  readonly reduceWithIndex: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (i: I, b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <S, R, E, A>(fa: Kind4<F, S, R, E, A>, f: (i: I, a: A) => M) => M\n  readonly reduceRightWithIndex: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, b: B, f: (i: I, a: A, b: B) => B) => B\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * `reduceWithIndex` composition.\n *\n * @since 2.10.0\n */\nexport function reduceWithIndex<F extends URIS, I, G extends URIS, J>(\n  F: FoldableWithIndex1<F, I>,\n  G: FoldableWithIndex1<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], b: B, a: A) => B) => (fga: Kind<F, Kind<G, A>>) => B\nexport function reduceWithIndex<F, I, G, J>(\n  F: FoldableWithIndex<F, I>,\n  G: FoldableWithIndex<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], b: B, a: A) => B) => (fga: HKT<F, HKT<G, A>>) => B\nexport function reduceWithIndex<F, I, G, J>(\n  F: FoldableWithIndex<F, I>,\n  G: FoldableWithIndex<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], b: B, a: A) => B) => (fga: HKT<F, HKT<G, A>>) => B {\n  return (b, f) => (fga) =>\n    F.reduceWithIndex(fga, b, (i, b, ga) => G.reduceWithIndex(ga, b, (j, b, a) => f([i, j], b, a)))\n}\n\n/**\n * `foldMapWithIndex` composition.\n *\n * @since 2.10.0\n */\nexport function foldMapWithIndex<F extends URIS, I, G extends URIS, J>(\n  F: FoldableWithIndex1<F, I>,\n  G: FoldableWithIndex1<G, J>\n): <M>(M: Monoid<M>) => <A>(f: (ij: readonly [I, J], a: A) => M) => (fga: Kind<F, Kind<G, A>>) => M\nexport function foldMapWithIndex<F, I, G, J>(\n  F: FoldableWithIndex<F, I>,\n  G: FoldableWithIndex<G, J>\n): <M>(M: Monoid<M>) => <A>(f: (ij: readonly [I, J], a: A) => M) => (fga: HKT<F, HKT<G, A>>) => M\nexport function foldMapWithIndex<F, I, G, J>(\n  F: FoldableWithIndex<F, I>,\n  G: FoldableWithIndex<G, J>\n): <M>(M: Monoid<M>) => <A>(f: (ij: readonly [I, J], a: A) => M) => (fga: HKT<F, HKT<G, A>>) => M {\n  return (M) => {\n    const foldMapWithIndexF = F.foldMapWithIndex(M)\n    const foldMapWithIndexG = G.foldMapWithIndex(M)\n    return (f) => (fga) => foldMapWithIndexF(fga, (i, ga) => foldMapWithIndexG(ga, (j, a) => f([i, j], a)))\n  }\n}\n\n/**\n * `reduceRightWithIndex` composition.\n *\n * @since 2.10.0\n */\nexport function reduceRightWithIndex<F extends URIS, I, G extends URIS, J>(\n  F: FoldableWithIndex1<F, I>,\n  G: FoldableWithIndex1<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], a: A, b: B) => B) => (fga: Kind<F, Kind<G, A>>) => B\nexport function reduceRightWithIndex<F, I, G, J>(\n  F: FoldableWithIndex<F, I>,\n  G: FoldableWithIndex<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], a: A, b: B) => B) => (fga: HKT<F, HKT<G, A>>) => B\nexport function reduceRightWithIndex<F, I, G, J>(\n  F: FoldableWithIndex<F, I>,\n  G: FoldableWithIndex<G, J>\n): <B, A>(b: B, f: (ij: readonly [I, J], a: A, b: B) => B) => (fga: HKT<F, HKT<G, A>>) => B {\n  return (b, f) => (fga) =>\n    F.reduceRightWithIndex(fga, b, (i, ga, b) => G.reduceRightWithIndex(ga, b, (j, a, b) => f([i, j], a, b)))\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableWithIndexComposition<F, FI, G, GI> extends FoldableComposition<F, G> {\n  readonly reduceWithIndex: <A, B>(fga: HKT<F, HKT<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: HKT<F, HKT<G, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fga: HKT<F, HKT<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableWithIndexComposition11<F extends URIS, FI, G extends URIS, GI>\n  extends FoldableComposition11<F, G> {\n  readonly reduceWithIndex: <A, B>(fga: Kind<F, Kind<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: Kind<F, Kind<G, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fga: Kind<F, Kind<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableWithIndexComposition12<F extends URIS, FI, G extends URIS2, GI>\n  extends FoldableComposition12<F, G> {\n  readonly reduceWithIndex: <E, A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <E, A>(fga: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <E, A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableWithIndexComposition12C<F extends URIS, FI, G extends URIS2, GI, E>\n  extends FoldableComposition12C<F, G, E> {\n  readonly reduceWithIndex: <A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fga: Kind<F, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableWithIndexComposition21<F extends URIS2, FI, G extends URIS, GI>\n  extends FoldableComposition21<F, G> {\n  readonly reduceWithIndex: <FE, A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(\n    M: Monoid<M>\n  ) => <FE, A>(fga: Kind2<F, FE, Kind<G, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <FE, A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableWithIndexComposition2C1<F extends URIS2, FI, G extends URIS, GI, FE>\n  extends FoldableComposition2C1<F, G, FE> {\n  readonly reduceWithIndex: <A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(fga: Kind2<F, FE, Kind<G, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <A, B>(fga: Kind2<F, FE, Kind<G, A>>, b: B, f: (i: [FI, GI], a: A, b: B) => B) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableWithIndexComposition22<F extends URIS2, FI, G extends URIS2, GI>\n  extends FoldableComposition22<F, G> {\n  readonly reduceWithIndex: <FE, GE, A, B>(\n    fga: Kind2<F, FE, Kind2<G, GE, A>>,\n    b: B,\n    f: (i: [FI, GI], b: B, a: A) => B\n  ) => B\n  readonly foldMapWithIndex: <M>(\n    M: Monoid<M>\n  ) => <FE, GE, A>(fga: Kind2<F, FE, Kind2<G, GE, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <FE, GE, A, B>(\n    fga: Kind2<F, FE, Kind2<G, GE, A>>,\n    b: B,\n    f: (i: [FI, GI], a: A, b: B) => B\n  ) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FoldableWithIndexComposition22C<F extends URIS2, FI, G extends URIS2, GI, E>\n  extends FoldableComposition22C<F, G, E> {\n  readonly reduceWithIndex: <FE, A, B>(fga: Kind2<F, FE, Kind2<G, E, A>>, b: B, f: (i: [FI, GI], b: B, a: A) => B) => B\n  readonly foldMapWithIndex: <M>(\n    M: Monoid<M>\n  ) => <FE, A>(fga: Kind2<F, FE, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => M) => M\n  readonly reduceRightWithIndex: <FE, A, B>(\n    fga: Kind2<F, FE, Kind2<G, E, A>>,\n    b: B,\n    f: (i: [FI, GI], a: A, b: B) => B\n  ) => B\n}\n\n/**\n * Use\n *\n * - [reduceWithIndex](#reducewithindex)\n * - [foldMapWithIndex](#foldmapwithindex)\n * - [reduceRightWithIndex](#reducerightwithindex)\n *\n * instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI, E>(\n  F: FoldableWithIndex2<F, FI>,\n  G: FoldableWithIndex2C<G, GI, E>\n): FoldableWithIndexComposition22C<F, FI, G, GI, E>\n/** @deprecated */\nexport function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI>(\n  F: FoldableWithIndex2<F, FI>,\n  G: FoldableWithIndex2<G, GI>\n): FoldableWithIndexComposition22<F, FI, G, GI>\n/** @deprecated */\nexport function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS, GI, E>(\n  F: FoldableWithIndex2C<F, FI, E>,\n  G: FoldableWithIndex1<G, GI>\n): FoldableWithIndexComposition2C1<F, FI, G, GI, E>\n/** @deprecated */\nexport function getFoldableWithIndexComposition<F extends URIS2, FI, G extends URIS, GI>(\n  F: FoldableWithIndex2<F, FI>,\n  G: FoldableWithIndex1<G, GI>\n): FoldableWithIndexComposition21<F, FI, G, GI>\n/** @deprecated */\nexport function getFoldableWithIndexComposition<F extends URIS, FI, G extends URIS2, GI>(\n  F: FoldableWithIndex1<F, FI>,\n  G: FoldableWithIndex2<G, GI>\n): FoldableWithIndexComposition12<F, FI, G, GI>\n/** @deprecated */\nexport function getFoldableWithIndexComposition<F extends URIS, FI, G extends URIS2, GI>(\n  F: FoldableWithIndex1<F, FI>,\n  G: FoldableWithIndex2<G, GI>\n): FoldableWithIndexComposition12<F, FI, G, GI>\n/** @deprecated */\nexport function getFoldableWithIndexComposition<F extends URIS, FI, G extends URIS, GI>(\n  F: FoldableWithIndex1<F, FI>,\n  G: FoldableWithIndex1<G, GI>\n): FoldableWithIndexComposition11<F, FI, G, GI>\n/** @deprecated */\nexport function getFoldableWithIndexComposition<F, FI, G, GI>(\n  F: FoldableWithIndex<F, FI>,\n  G: FoldableWithIndex<G, GI>\n): FoldableWithIndexComposition<F, FI, G, GI>\n/** @deprecated */\nexport function getFoldableWithIndexComposition<F, FI, G, GI>(\n  F: FoldableWithIndex<F, FI>,\n  G: FoldableWithIndex<G, GI>\n): FoldableWithIndexComposition<F, FI, G, GI> {\n  const FC = getFoldableComposition(F, G)\n  const _reduceWithIndex = reduceWithIndex(F, G)\n  const _foldMapWithIndex = foldMapWithIndex(F, G)\n  const _reduceRightWithIndex = reduceRightWithIndex(F, G)\n  return {\n    reduce: FC.reduce,\n    foldMap: FC.foldMap,\n    reduceRight: FC.reduceRight,\n    reduceWithIndex: (fga, b, f: any) => pipe(fga, _reduceWithIndex(b, f)),\n    foldMapWithIndex: (M) => {\n      const foldMapWithIndexM = _foldMapWithIndex(M)\n      return (fga, f: any) => pipe(fga, foldMapWithIndexM(f))\n    },\n    reduceRightWithIndex: (fga, b, f: any) => pipe(fga, _reduceRightWithIndex(b, f))\n  }\n}\n"
  },
  {
    "path": "src/FromEither.ts",
    "content": "/**\n * The `FromEither` type class represents those data types which support errors.\n *\n * @since 2.10.0\n */\n\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C, Chain4, tap } from './Chain'\nimport { Either } from './Either'\nimport { flow, LazyArg } from './function'\nimport { HKT2, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport * as _ from './internal'\nimport { Option } from './Option'\nimport { Predicate } from './Predicate'\nimport { Refinement } from './Refinement'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromEither<F> {\n  readonly URI: F\n  readonly fromEither: <E, A>(e: Either<E, A>) => HKT2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromEither1<F extends URIS> {\n  readonly URI: F\n  readonly fromEither: <A>(fa: Either<unknown, A>) => Kind<F, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromEither2<F extends URIS2> {\n  readonly URI: F\n  readonly fromEither: <E, A>(fa: Either<E, A>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromEither2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromEither: <A>(fa: Either<E, A>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromEither3<F extends URIS3> {\n  readonly URI: F\n  readonly fromEither: <E, A, R>(fa: Either<E, A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromEither3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromEither: <A, R>(fa: Either<E, A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromEither4<F extends URIS4> {\n  readonly URI: F\n  readonly fromEither: <E, A, S, R>(fa: Either<E, A>) => Kind4<F, S, R, E, A>\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.10.0\n */\nexport function fromOption<F extends URIS4>(\n  F: FromEither4<F>\n): <E>(onNone: LazyArg<E>) => <A, S, R>(fa: Option<A>) => Kind4<F, S, R, E, A>\nexport function fromOption<F extends URIS3>(\n  F: FromEither3<F>\n): <E>(onNone: LazyArg<E>) => <A, R>(fa: Option<A>) => Kind3<F, R, E, A>\nexport function fromOption<F extends URIS3, E>(\n  F: FromEither3C<F, E>\n): (onNone: LazyArg<E>) => <A, R>(fa: Option<A>) => Kind3<F, R, E, A>\nexport function fromOption<F extends URIS2>(\n  F: FromEither2<F>\n): <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => Kind2<F, E, A>\nexport function fromOption<F extends URIS2, E>(\n  F: FromEither2C<F, E>\n): (onNone: LazyArg<E>) => <A>(fa: Option<A>) => Kind2<F, E, A>\nexport function fromOption<F>(F: FromEither<F>): <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => HKT2<F, E, A>\nexport function fromOption<F>(F: FromEither<F>): <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => HKT2<F, E, A> {\n  return (onNone) => (ma) => F.fromEither(_.isNone(ma) ? _.left(onNone()) : _.right(ma.value))\n}\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport function fromPredicate<F extends URIS4>(\n  F: FromEither4<F>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(b: B) => Kind4<F, S, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, A>\n}\nexport function fromPredicate<F extends URIS3>(\n  F: FromEither3<F>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(b: B) => Kind3<F, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>\n}\nexport function fromPredicate<F extends URIS3, E>(\n  F: FromEither3C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(b: B) => Kind3<F, R, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>\n}\nexport function fromPredicate<F extends URIS2>(\n  F: FromEither2<F>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => Kind2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>\n}\nexport function fromPredicate<F extends URIS2, E>(\n  F: FromEither2C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => Kind2<F, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>\n}\nexport function fromPredicate<F>(F: FromEither<F>): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => HKT2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => HKT2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => HKT2<F, E, A>\n}\nexport function fromPredicate<F>(F: FromEither<F>): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => HKT2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => HKT2<F, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => HKT2<F, E, A>\n} {\n  return <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E) =>\n    (a: A) =>\n      F.fromEither(predicate(a) ? _.right(a) : _.left(onFalse(a)))\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function fromOptionK<F extends URIS4>(\n  F: FromEither4<F>\n): <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <S, R>(...a: A) => Kind4<F, S, R, E, B>\nexport function fromOptionK<F extends URIS3>(\n  F: FromEither3<F>\n): <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport function fromOptionK<F extends URIS3, E>(\n  F: FromEither3C<F, E>\n): (\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport function fromOptionK<F extends URIS2>(\n  F: FromEither2<F>\n): <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind2<F, E, B>\nexport function fromOptionK<F extends URIS2, E>(\n  F: FromEither2C<F, E>\n): (\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind2<F, E, B>\nexport function fromOptionK<F>(\n  F: FromEither<F>\n): <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => HKT2<F, E, B>\nexport function fromOptionK<F>(\n  F: FromEither<F>\n): <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => HKT2<F, E, B> {\n  const fromOptionF = fromOption(F)\n  return (onNone) => {\n    const from = fromOptionF(onNone)\n    return (f) => flow(f, from)\n  }\n}\n\n/**\n * @since 2.10.0\n */\nexport function chainOptionK<F extends URIS4>(\n  F: FromEither4<F>,\n  M: Chain4<F>\n): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => <S, R>(ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport function chainOptionK<F extends URIS3>(\n  F: FromEither3<F>,\n  M: Chain3<F>\n): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function chainOptionK<F extends URIS3, E>(\n  F: FromEither3C<F, E>,\n  M: Chain3C<F, E>\n): (onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function chainOptionK<F extends URIS2>(\n  F: FromEither2<F>,\n  M: Chain2<F>\n): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function chainOptionK<F extends URIS2, E>(\n  F: FromEither2C<F, E>,\n  M: Chain2C<F, E>\n): (onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function chainOptionK<F>(\n  F: FromEither<F>,\n  M: Chain<F>\n): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: HKT2<F, E, A>) => HKT2<F, E, B>\nexport function chainOptionK<F extends URIS2>(\n  F: FromEither2<F>,\n  M: Chain2<F>\n): <E>(onNone: LazyArg<E>) => <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B> {\n  const fromOptionKF = fromOptionK(F)\n  return (onNone) => {\n    const from = fromOptionKF(onNone)\n    return (f) => (ma) => M.chain(ma, from(f))\n  }\n}\n\n/**\n * @since 2.10.0\n */\nexport function fromEitherK<F extends URIS4>(\n  F: FromEither4<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => <S, R>(...a: A) => Kind4<F, S, R, E, B>\nexport function fromEitherK<F extends URIS3>(\n  F: FromEither3<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport function fromEitherK<F extends URIS3, E>(\n  F: FromEither3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Either<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport function fromEitherK<F extends URIS2>(\n  F: FromEither2<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => (...a: A) => Kind2<F, E, B>\nexport function fromEitherK<F extends URIS2, E>(\n  F: FromEither2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Either<E, B>) => (...a: A) => Kind2<F, E, B>\nexport function fromEitherK<F extends URIS>(\n  F: FromEither1<F>\n): <E, A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Either<E, B>) => (...a: A) => Kind<F, B>\nexport function fromEitherK<F>(\n  F: FromEither<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => (...a: A) => HKT2<F, E, B>\nexport function fromEitherK<F>(\n  F: FromEither<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => Either<E, B>) => (...a: A) => HKT2<F, E, B> {\n  return (f) => flow(f, F.fromEither)\n}\n\n/**\n * @since 2.10.0\n */\nexport function chainEitherK<M extends URIS4>(\n  F: FromEither4<M>,\n  M: Chain4<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => <S, R>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport function chainEitherK<M extends URIS3>(\n  F: FromEither3<M>,\n  M: Chain3<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport function chainEitherK<M extends URIS3, E>(\n  F: FromEither3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport function chainEitherK<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, B>\nexport function chainEitherK<M extends URIS2, E>(\n  F: FromEither2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, B>\nexport function chainEitherK<M extends URIS>(\n  F: FromEither1<M>,\n  M: Chain1<M>\n): <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Kind<M, A>) => Kind<M, B>\nexport function chainEitherK<M>(\n  F: FromEither<M>,\n  M: Chain<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: HKT2<M, E, A>) => HKT2<M, E, B>\nexport function chainEitherK<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, B> {\n  const fromEitherKF = fromEitherK(F)\n  return (f) => (ma) => M.chain(ma, fromEitherKF(f))\n}\n\n/**\n * @since 2.12.0\n */\nexport function chainFirstEitherK<M extends URIS4>(\n  F: FromEither4<M>,\n  M: Chain4<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => <S, R>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport function chainFirstEitherK<M extends URIS3>(\n  F: FromEither3<M>,\n  M: Chain3<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirstEitherK<M extends URIS3, E>(\n  F: FromEither3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => Either<E, B>) => <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirstEitherK<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, A>\nexport function chainFirstEitherK<M extends URIS2, E>(\n  F: FromEither2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, A>\nexport function chainFirstEitherK<M extends URIS>(\n  F: FromEither1<M>,\n  M: Chain1<M>\n): <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Kind<M, A>) => Kind<M, A>\nexport function chainFirstEitherK<M>(\n  F: FromEither<M>,\n  M: Chain<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: HKT2<M, E, A>) => HKT2<M, E, A>\nexport function chainFirstEitherK<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): <A, E, B>(f: (a: A) => Either<E, B>) => (ma: Kind2<M, E, A>) => Kind2<M, E, A> {\n  const tapEitherM = tapEither(F, M)\n  return (f) => (ma) => tapEitherM(ma, f)\n}\n\n/**\n * @since 2.10.0\n */\nexport function filterOrElse<M extends URIS4>(\n  F: FromEither4<M>,\n  M: Chain4<M>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(\n    ma: Kind4<M, S, R, E, A>\n  ) => Kind4<M, S, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(\n    mb: Kind4<M, S, R, E, B>\n  ) => Kind4<M, S, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\n}\nexport function filterOrElse<M extends URIS3>(\n  F: FromEither3<M>,\n  M: Chain3<M>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n    ma: Kind3<M, R, E, A>\n  ) => Kind3<M, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(mb: Kind3<M, R, E, B>) => Kind3<M, R, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\n}\nexport function filterOrElse<M extends URIS3, E>(\n  F: FromEither3C<M, E>,\n  M: Chain3C<M, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(mb: Kind3<M, R, E, B>) => Kind3<M, R, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\n}\nexport function filterOrElse<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (self: Kind2<M, E, A>) => Kind2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(self: Kind2<M, E, B>) => Kind2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (self: Kind2<M, E, A>) => Kind2<M, E, A>\n}\nexport function filterOrElse<M extends URIS2, E>(\n  F: FromEither2C<M, E>,\n  M: Chain2C<M, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<M, E, A>) => Kind2<M, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: Kind2<M, E, B>) => Kind2<M, E, B>\n  <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<M, E, A>) => Kind2<M, E, A>\n}\nexport function filterOrElse<M extends URIS2>(\n  F: FromEither<M>,\n  M: Chain<M>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: HKT2<M, E, A>) => HKT2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: HKT2<M, E, B>) => HKT2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: HKT2<M, E, A>) => HKT2<M, E, A>\n}\nexport function filterOrElse<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<M, E, A>) => Kind2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: Kind2<M, E, B>) => Kind2<M, E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<M, E, A>) => Kind2<M, E, A>\n} {\n  return <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E) =>\n    (ma: Kind2<M, E, A>): Kind2<M, E, A> =>\n      M.chain(ma, (a) => F.fromEither(predicate(a) ? _.right(a) : _.left(onFalse(a))))\n}\n\n/** @internal */\nexport function tapEither<M extends URIS4>(\n  F: FromEither4<M>,\n  M: Chain4<M>\n): <A, E, B, S, R>(self: Kind4<M, S, R, E, A>, f: (a: A) => Either<E, B>) => Kind4<M, S, R, E, A>\n/** @internal */\nexport function tapEither<M extends URIS3>(\n  F: FromEither3<M>,\n  M: Chain3<M>\n): <A, E, B, R>(self: Kind3<M, R, E, A>, f: (a: A) => Either<E, B>) => Kind3<M, R, E, A>\n/** @internal */\nexport function tapEither<M extends URIS3, E>(\n  F: FromEither3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B, R>(self: Kind3<M, R, E, A>, f: (a: A) => Either<E, B>) => Kind3<M, R, E, A>\n/** @internal */\nexport function tapEither<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): <A, E, B>(self: Kind2<M, E, A>, f: (a: A) => Either<E, B>) => Kind2<M, E, A>\n/** @internal */\nexport function tapEither<M extends URIS2, E>(\n  F: FromEither2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(self: Kind2<M, E, A>, f: (a: A) => Either<E, B>) => Kind2<M, E, A>\n/** @internal */\nexport function tapEither<M extends URIS>(\n  F: FromEither1<M>,\n  M: Chain1<M>\n): <E, A, B>(self: Kind<M, A>, f: (a: A) => Either<E, B>) => Kind<M, A>\n/** @internal */\nexport function tapEither<M>(\n  F: FromEither<M>,\n  M: Chain<M>\n): <A, E, B>(self: HKT2<M, E, A>, f: (a: A) => Either<E, B>) => HKT2<M, E, A>\n/** @internal */\nexport function tapEither<M extends URIS2>(\n  F: FromEither2<M>,\n  M: Chain2<M>\n): <A, E, B>(self: Kind2<M, E, A>, f: (a: A) => Either<E, B>) => Kind2<M, E, A> {\n  const fromEither = fromEitherK(F)\n  const tapM = tap(M)\n  return (self, f) => tapM(self, fromEither(f))\n}\n"
  },
  {
    "path": "src/FromIO.ts",
    "content": "/**\n * Lift a computation from the `IO` monad\n *\n * @since 2.10.0\n */\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C, Chain4, tap } from './Chain'\nimport { flow } from './function'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { IO } from './IO'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromIO<F> {\n  readonly URI: F\n  readonly fromIO: <A>(fa: IO<A>) => HKT<F, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromIO1<F extends URIS> {\n  readonly URI: F\n  readonly fromIO: <A>(fa: IO<A>) => Kind<F, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromIO2<F extends URIS2> {\n  readonly URI: F\n  readonly fromIO: <A, E>(fa: IO<A>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromIO2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromIO: <A>(fa: IO<A>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromIO3<F extends URIS3> {\n  readonly URI: F\n  readonly fromIO: <A, R, E>(fa: IO<A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromIO3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromIO: <A, R>(fa: IO<A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromIO4<F extends URIS4> {\n  readonly URI: F\n  readonly fromIO: <A, S, R, E>(fa: IO<A>) => Kind4<F, S, R, E, A>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function fromIOK<F extends URIS4>(\n  F: FromIO4<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <S, R, E>(...a: A) => Kind4<F, S, R, E, B>\nexport function fromIOK<F extends URIS3>(\n  F: FromIO3<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <R, E>(...a: A) => Kind3<F, R, E, B>\nexport function fromIOK<F extends URIS3, E>(\n  F: FromIO3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport function fromIOK<F extends URIS2>(\n  F: FromIO2<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => <E>(...a: A) => Kind2<F, E, B>\nexport function fromIOK<F extends URIS2, E>(\n  F: FromIO2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => Kind2<F, E, B>\nexport function fromIOK<F extends URIS>(\n  F: FromIO1<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => Kind<F, B>\nexport function fromIOK<F>(\n  F: FromIO<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => HKT<F, B>\nexport function fromIOK<F>(\n  F: FromIO<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => HKT<F, B> {\n  return (f) => flow(f, F.fromIO)\n}\n\n/**\n * @since 2.10.0\n */\nexport function chainIOK<M extends URIS4>(\n  F: FromIO4<M>,\n  M: Chain4<M>\n): <A, B>(f: (a: A) => IO<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport function chainIOK<M extends URIS3>(\n  F: FromIO3<M>,\n  M: Chain3<M>\n): <A, B>(f: (a: A) => IO<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport function chainIOK<M extends URIS3, E>(\n  F: FromIO3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => IO<B>) => <R>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport function chainIOK<M extends URIS2>(\n  F: FromIO2<M>,\n  M: Chain2<M>\n): <A, B>(f: (a: A) => IO<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, B>\nexport function chainIOK<M extends URIS2, E>(\n  F: FromIO2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => IO<B>) => (first: Kind2<M, E, A>) => Kind2<M, E, B>\nexport function chainIOK<M extends URIS>(\n  F: FromIO1<M>,\n  M: Chain1<M>\n): <A, B>(f: (a: A) => IO<B>) => (first: Kind<M, A>) => Kind<M, B>\nexport function chainIOK<M>(F: FromIO<M>, M: Chain<M>): <A, B>(f: (a: A) => IO<B>) => (first: HKT<M, A>) => HKT<M, B>\nexport function chainIOK<M>(F: FromIO<M>, M: Chain<M>): <A, B>(f: (a: A) => IO<B>) => (first: HKT<M, A>) => HKT<M, B> {\n  return (f) => {\n    const g = flow(f, F.fromIO)\n    return (first) => M.chain(first, g)\n  }\n}\n\n/**\n * @since 2.10.0\n */\nexport function chainFirstIOK<M extends URIS4>(\n  F: FromIO4<M>,\n  M: Chain4<M>\n): <A, B>(f: (a: A) => IO<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport function chainFirstIOK<M extends URIS3>(\n  F: FromIO3<M>,\n  M: Chain3<M>\n): <A, B>(f: (a: A) => IO<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirstIOK<M extends URIS3, E>(\n  F: FromIO3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => IO<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirstIOK<M extends URIS2>(\n  F: FromIO2<M>,\n  M: Chain2<M>\n): <A, B>(f: (a: A) => IO<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport function chainFirstIOK<M extends URIS2, E>(\n  F: FromIO2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => IO<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport function chainFirstIOK<M extends URIS>(\n  F: FromIO1<M>,\n  M: Chain1<M>\n): <A, B>(f: (a: A) => IO<B>) => (first: Kind<M, A>) => Kind<M, A>\nexport function chainFirstIOK<M>(\n  F: FromIO<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => IO<B>) => (first: HKT<M, A>) => HKT<M, A>\nexport function chainFirstIOK<M>(\n  F: FromIO<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => IO<B>) => (first: HKT<M, A>) => HKT<M, A> {\n  const tapIOM = tapIO(F, M)\n  return (f) => (first) => tapIOM(first, f)\n}\n\n/** @internal */\nexport function tapIO<M extends URIS4>(\n  F: FromIO4<M>,\n  M: Chain4<M>\n): <A, B, S, R, E>(self: Kind4<M, S, R, E, A>, f: (a: A) => IO<B>) => Kind4<M, S, R, E, A>\n/** @internal */\nexport function tapIO<M extends URIS3>(\n  F: FromIO3<M>,\n  M: Chain3<M>\n): <A, B, R, E>(self: Kind3<M, R, E, A>, f: (a: A) => IO<B>) => Kind3<M, R, E, A>\n/** @internal */\nexport function tapIO<M extends URIS3, E>(\n  F: FromIO3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B, R, E>(self: Kind3<M, R, E, A>, f: (a: A) => IO<B>) => Kind3<M, R, E, A>\n/** @internal */\nexport function tapIO<M extends URIS2>(\n  F: FromIO2<M>,\n  M: Chain2<M>\n): <A, B, E>(self: Kind2<M, E, A>, f: (a: A) => IO<B>) => Kind2<M, E, A>\n/** @internal */\nexport function tapIO<M extends URIS2, E>(\n  F: FromIO2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B, E>(self: Kind2<M, E, A>, f: (a: A) => IO<B>) => Kind2<M, E, A>\n/** @internal */\nexport function tapIO<M extends URIS>(\n  F: FromIO1<M>,\n  M: Chain1<M>\n): <A, B>(self: Kind<M, A>, f: (a: A) => IO<B>) => Kind<M, A>\n/** @internal */\nexport function tapIO<M>(F: FromIO<M>, M: Chain<M>): <A, B>(self: HKT<M, A>, f: (a: A) => IO<B>) => HKT<M, A>\n/** @internal */\nexport function tapIO<M>(F: FromIO<M>, M: Chain<M>): <A, B>(self: HKT<M, A>, f: (a: A) => IO<B>) => HKT<M, A> {\n  const chainFirstM = tap(M)\n  return (self, f) => chainFirstM(self, flow(f, F.fromIO))\n}\n"
  },
  {
    "path": "src/FromReader.ts",
    "content": "/**\n * Lift a computation from the `Reader` monad.\n *\n * @since 2.11.0\n */\nimport { Chain, Chain2, Chain3, Chain3C, Chain4, tap } from './Chain'\nimport { flow } from './function'\nimport { HKT2, Kind2, Kind3, Kind4, URIS2, URIS3, URIS4 } from './HKT'\nimport * as R from './Reader'\n\nimport Reader = R.Reader\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromReader<F> {\n  readonly URI: F\n  readonly fromReader: <R, A>(fa: Reader<R, A>) => HKT2<F, R, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromReader2<F extends URIS2> {\n  readonly URI: F\n  readonly fromReader: <E, A>(fa: Reader<E, A>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromReader3<F extends URIS3> {\n  readonly URI: F\n  readonly fromReader: <R, A, E>(fa: Reader<R, A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromReader3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromReader: <R, A>(fa: Reader<R, A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromReader4<F extends URIS4> {\n  readonly URI: F\n  readonly fromReader: <R, A, S, E>(fa: Reader<R, A>) => Kind4<F, S, R, E, A>\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.11.0\n */\nexport function ask<F extends URIS4>(F: FromReader4<F>): <S, R, E>() => Kind4<F, S, R, E, R>\nexport function ask<F extends URIS3>(F: FromReader3<F>): <R, E>() => Kind3<F, R, E, R>\nexport function ask<F extends URIS3, E>(F: FromReader3C<F, E>): <R>() => Kind3<F, R, E, R>\nexport function ask<F extends URIS2>(F: FromReader2<F>): <R>() => Kind2<F, R, R>\nexport function ask<F>(F: FromReader<F>): <R>() => HKT2<F, R, R>\nexport function ask<F>(F: FromReader<F>): <R>() => HKT2<F, R, R> {\n  return () => F.fromReader(R.ask())\n}\n\n/**\n * @category constructors\n * @since 2.11.0\n */\nexport function asks<F extends URIS4>(F: FromReader4<F>): <R, A, S, E>(f: (r: R) => A) => Kind4<F, S, R, E, A>\nexport function asks<F extends URIS3>(F: FromReader3<F>): <R, A, E>(f: (r: R) => A) => Kind3<F, R, E, A>\nexport function asks<F extends URIS3, E>(F: FromReader3C<F, E>): <R, A>(f: (r: R) => A) => Kind3<F, R, E, A>\nexport function asks<F extends URIS2>(F: FromReader2<F>): <R, A>(f: (r: R) => A) => Kind2<F, R, A>\nexport function asks<F>(F: FromReader<F>): <R, A>(f: (r: R) => A) => HKT2<F, R, A>\nexport function asks<F>(F: FromReader<F>): <R, A>(f: (r: R) => A) => HKT2<F, R, A> {\n  return F.fromReader\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport function fromReaderK<F extends URIS4>(\n  F: FromReader4<F>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => <S, E>(...a: A) => Kind4<F, S, R, E, B>\nexport function fromReaderK<F extends URIS3>(\n  F: FromReader3<F>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => <E>(...a: A) => Kind3<F, R, E, B>\nexport function fromReaderK<F extends URIS3, E>(\n  F: FromReader3C<F, E>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => Kind3<F, R, E, B>\nexport function fromReaderK<F extends URIS2>(\n  F: FromReader2<F>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => Kind2<F, R, B>\nexport function fromReaderK<F>(\n  F: FromReader<F>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => HKT2<F, R, B>\nexport function fromReaderK<F>(\n  F: FromReader<F>\n): <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => Reader<R, B>) => (...a: A) => HKT2<F, R, B> {\n  return (f) => flow(f, F.fromReader)\n}\n\n/**\n * @since 2.11.0\n */\nexport function chainReaderK<M extends URIS4>(\n  F: FromReader4<M>,\n  M: Chain4<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => <S, E>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport function chainReaderK<M extends URIS3>(\n  F: FromReader3<M>,\n  M: Chain3<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => <E>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport function chainReaderK<M extends URIS3, E>(\n  F: FromReader3C<M, E>,\n  M: Chain3C<M, E>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport function chainReaderK<M extends URIS2>(\n  F: FromReader2<M>,\n  M: Chain2<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind2<M, R, A>) => Kind2<M, R, B>\nexport function chainReaderK<M>(\n  F: FromReader<M>,\n  M: Chain<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: HKT2<M, R, A>) => HKT2<M, R, B>\nexport function chainReaderK<M extends URIS2>(\n  F: FromReader2<M>,\n  M: Chain2<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind2<M, R, A>) => Kind2<M, R, B> {\n  const fromReaderKF = fromReaderK(F)\n  return (f) => (ma) => M.chain(ma, fromReaderKF(f))\n}\n\n/**\n * @since 2.11.0\n */\nexport function chainFirstReaderK<M extends URIS4>(\n  F: FromReader4<M>,\n  M: Chain4<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => <S, E>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport function chainFirstReaderK<M extends URIS3>(\n  F: FromReader3<M>,\n  M: Chain3<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => <E>(ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirstReaderK<M extends URIS3, E>(\n  F: FromReader3C<M, E>,\n  M: Chain3C<M, E>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirstReaderK<M extends URIS2>(\n  F: FromReader2<M>,\n  M: Chain2<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind2<M, R, A>) => Kind2<M, R, A>\nexport function chainFirstReaderK<M>(\n  F: FromReader<M>,\n  M: Chain<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: HKT2<M, R, A>) => HKT2<M, R, A>\nexport function chainFirstReaderK<M extends URIS2>(\n  F: FromReader2<M>,\n  M: Chain2<M>\n): <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Kind2<M, R, A>) => Kind2<M, R, A> {\n  const tapM = tapReader(F, M)\n  return (f) => (self) => tapM(self, f)\n}\n\n/** @internal */\nexport function tapReader<M extends URIS4>(\n  F: FromReader4<M>,\n  M: Chain4<M>\n): <A, S, R, E, B>(self: Kind4<M, S, R, E, A>, f: (a: A) => Reader<R, B>) => Kind4<M, S, R, E, A>\n/** @internal */\nexport function tapReader<M extends URIS3>(\n  F: FromReader3<M>,\n  M: Chain3<M>\n): <A, R, E, B>(self: Kind3<M, R, E, A>, f: (a: A) => Reader<R, B>) => Kind3<M, R, E, A>\n/** @internal */\nexport function tapReader<M extends URIS3, E>(\n  F: FromReader3C<M, E>,\n  M: Chain3C<M, E>\n): <A, R, E, B>(self: Kind3<M, R, E, A>, f: (a: A) => Reader<R, B>) => Kind3<M, R, E, A>\n/** @internal */\nexport function tapReader<M extends URIS2>(\n  F: FromReader2<M>,\n  M: Chain2<M>\n): <A, R, E, B>(self: Kind2<M, E, A>, f: (a: A) => Reader<R, B>) => Kind2<M, E, A>\nexport function tapReader<M extends URIS2>(\n  F: FromReader<M>,\n  M: Chain<M>\n): <A, R, B>(self: HKT2<M, R, A>, f: (a: A) => Reader<R, B>) => HKT2<M, R, A>\n/** @internal */\nexport function tapReader<M extends URIS2>(\n  F: FromReader2<M>,\n  M: Chain2<M>\n): <A, R, B>(self: Kind2<M, R, A>, f: (a: A) => Reader<R, B>) => Kind2<M, R, A> {\n  const tapM = tap(M)\n  return (self, f) => tapM(self, flow(f, F.fromReader))\n}\n"
  },
  {
    "path": "src/FromState.ts",
    "content": "/**\n * Lift a computation from the `State` monad.\n *\n * @since 2.11.0\n */\nimport { Chain, Chain2, Chain3, Chain4 } from './Chain'\nimport { Endomorphism } from './Endomorphism'\nimport { flow } from './function'\nimport { HKT2, Kind2, Kind3, Kind4, URIS2, URIS3, URIS4 } from './HKT'\nimport * as S from './State'\n\nimport State = S.State\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromState<F> {\n  readonly URI: F\n  readonly fromState: <S, A>(fa: State<S, A>) => HKT2<F, S, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromState2<F extends URIS2> {\n  readonly URI: F\n  readonly fromState: <S, A>(fa: State<S, A>) => Kind2<F, S, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromState3<F extends URIS3> {\n  readonly URI: F\n  readonly fromState: <S, A, E>(fa: State<S, A>) => Kind3<F, S, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromState3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromState: <S, A>(fa: State<S, A>) => Kind3<F, S, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromState4<F extends URIS4> {\n  readonly URI: F\n  readonly fromState: <S, A, R, E>(fa: State<S, A>) => Kind4<F, S, R, E, A>\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.11.0\n */\nexport function get<F extends URIS4>(F: FromState4<F>): <S, R, E>() => Kind4<F, S, R, E, S>\nexport function get<F extends URIS3>(F: FromState3<F>): <S, E>() => Kind3<F, S, E, S>\nexport function get<F extends URIS3, E>(F: FromState3C<F, E>): <S>() => Kind3<F, S, E, S>\nexport function get<F extends URIS2>(F: FromState2<F>): <S>() => Kind2<F, S, S>\nexport function get<F>(F: FromState<F>): <S>() => HKT2<F, S, S>\nexport function get<F>(F: FromState<F>): <S>() => HKT2<F, S, S> {\n  return () => F.fromState(S.get())\n}\n\n/**\n * @category constructors\n * @since 2.11.0\n */\nexport function put<F extends URIS4>(F: FromState4<F>): <S, R, E>(s: S) => Kind4<F, S, R, E, void>\nexport function put<F extends URIS3>(F: FromState3<F>): <S, E>(s: S) => Kind3<F, S, E, void>\nexport function put<F extends URIS3, E>(F: FromState3C<F, E>): <S>(s: S) => Kind3<F, S, E, void>\nexport function put<F extends URIS2>(F: FromState2<F>): <S>(s: S) => Kind2<F, S, void>\nexport function put<F>(F: FromState<F>): <S>(s: S) => HKT2<F, S, void>\nexport function put<F>(F: FromState<F>): <S>(s: S) => HKT2<F, S, void> {\n  return (s) => F.fromState(S.put(s))\n}\n\n/**\n * @category constructors\n * @since 2.11.0\n */\nexport function modify<F extends URIS4>(F: FromState4<F>): <S, R, E>(f: Endomorphism<S>) => Kind4<F, S, R, E, void>\nexport function modify<F extends URIS3>(F: FromState3<F>): <S, E>(f: Endomorphism<S>) => Kind3<F, S, E, void>\nexport function modify<F extends URIS3, E>(F: FromState3C<F, E>): <S>(f: Endomorphism<S>) => Kind3<F, S, E, void>\nexport function modify<F extends URIS2>(F: FromState2<F>): <S>(f: Endomorphism<S>) => Kind2<F, S, void>\nexport function modify<F>(F: FromState<F>): <S>(f: Endomorphism<S>) => HKT2<F, S, void>\nexport function modify<F>(F: FromState<F>): <S>(f: Endomorphism<S>) => HKT2<F, S, void> {\n  return flow(S.modify, F.fromState)\n}\n\n/**\n * @category constructors\n * @since 2.11.0\n */\nexport function gets<F extends URIS4>(F: FromState4<F>): <S, R, E, A>(f: (s: S) => A) => Kind4<F, S, R, E, A>\nexport function gets<F extends URIS3>(F: FromState3<F>): <S, E, A>(f: (s: S) => A) => Kind3<F, S, E, A>\nexport function gets<F extends URIS3, E>(F: FromState3C<F, E>): <S, A>(f: (s: S) => A) => Kind3<F, S, E, A>\nexport function gets<F extends URIS2>(F: FromState2<F>): <S, A>(f: (s: S) => A) => Kind2<F, S, A>\nexport function gets<F>(F: FromState<F>): <S, A>(f: (s: S) => A) => HKT2<F, S, A>\nexport function gets<F>(F: FromState<F>): <S, A>(f: (s: S) => A) => HKT2<F, S, A> {\n  return flow(S.gets, F.fromState)\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport function fromStateK<F extends URIS4>(\n  F: FromState4<F>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => <R, E>(...a: A) => Kind4<F, S, R, E, B>\nexport function fromStateK<F extends URIS3>(\n  F: FromState3<F>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => <E>(...a: A) => Kind3<F, S, E, B>\nexport function fromStateK<F extends URIS3, E>(\n  F: FromState3C<F, E>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => Kind3<F, S, E, B>\nexport function fromStateK<F extends URIS2>(\n  F: FromState2<F>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => Kind2<F, S, B>\nexport function fromStateK<F>(\n  F: FromState<F>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => HKT2<F, S, B>\nexport function fromStateK<F>(\n  F: FromState<F>\n): <A extends ReadonlyArray<unknown>, S, B>(f: (...a: A) => State<S, B>) => (...a: A) => HKT2<F, S, B> {\n  return (f) => flow(f, F.fromState)\n}\n\n/**\n * @since 2.11.0\n */\nexport function chainStateK<M extends URIS4>(\n  F: FromState4<M>,\n  M: Chain4<M>\n): <A, S, B>(f: (a: A) => State<S, B>) => <R, E>(ma: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport function chainStateK<M extends URIS3>(\n  F: FromState3<M>,\n  M: Chain3<M>\n): <A, S, B>(f: (a: A) => State<S, B>) => <E>(ma: Kind3<M, S, E, A>) => Kind3<M, S, E, B>\nexport function chainStateK<M extends URIS2>(\n  F: FromState2<M>,\n  M: Chain2<M>\n): <A, S, B>(f: (a: A) => State<S, B>) => (ma: Kind2<M, S, A>) => Kind2<M, S, B>\nexport function chainStateK<M>(\n  F: FromState<M>,\n  M: Chain<M>\n): <A, S, B>(f: (a: A) => State<S, B>) => (ma: HKT2<M, S, A>) => HKT2<M, S, B>\nexport function chainStateK<M extends URIS2>(\n  F: FromState2<M>,\n  M: Chain2<M>\n): <A, S, B>(f: (a: A) => State<S, B>) => (ma: Kind2<M, S, A>) => Kind2<M, S, B> {\n  const fromStateKF = fromStateK(F)\n  return (f) => (ma) => M.chain(ma, fromStateKF(f))\n}\n"
  },
  {
    "path": "src/FromTask.ts",
    "content": "/**\n * Lift a computation from the `Task` monad\n *\n * @since 2.10.0\n */\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C, Chain4, tap } from './Chain'\nimport { FromIO, FromIO1, FromIO2, FromIO2C, FromIO3, FromIO3C, FromIO4 } from './FromIO'\nimport { flow } from './function'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Task } from './Task'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromTask<F> extends FromIO<F> {\n  readonly fromTask: <A>(fa: Task<A>) => HKT<F, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromTask1<F extends URIS> extends FromIO1<F> {\n  readonly fromTask: <A>(fa: Task<A>) => Kind<F, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromTask2<F extends URIS2> extends FromIO2<F> {\n  readonly fromTask: <A, E>(fa: Task<A>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromTask2C<F extends URIS2, E> extends FromIO2C<F, E> {\n  readonly fromTask: <A>(fa: Task<A>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromTask3<F extends URIS3> extends FromIO3<F> {\n  readonly fromTask: <A, R, E>(fa: Task<A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromTask3C<F extends URIS3, E> extends FromIO3C<F, E> {\n  readonly fromTask: <A, R>(fa: Task<A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface FromTask4<F extends URIS4> extends FromIO4<F> {\n  readonly fromTask: <A, S, R, E>(fa: Task<A>) => Kind4<F, S, R, E, A>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function fromTaskK<F extends URIS4>(\n  F: FromTask4<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <S, R, E>(...a: A) => Kind4<F, S, R, E, B>\nexport function fromTaskK<F extends URIS3>(\n  F: FromTask3<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <R, E>(...a: A) => Kind3<F, R, E, B>\nexport function fromTaskK<F extends URIS3, E>(\n  F: FromTask3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport function fromTaskK<F extends URIS2>(\n  F: FromTask2<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => <E>(...a: A) => Kind2<F, E, B>\nexport function fromTaskK<F extends URIS2, E>(\n  F: FromTask2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => Kind2<F, E, B>\nexport function fromTaskK<F extends URIS>(\n  F: FromTask1<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => Kind<F, B>\nexport function fromTaskK<F>(\n  F: FromTask<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => HKT<F, B>\nexport function fromTaskK<F>(\n  F: FromTask<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Task<B>) => (...a: A) => HKT<F, B> {\n  return (f) => flow(f, F.fromTask)\n}\n\n/**\n * @since 2.10.0\n */\nexport function chainTaskK<M extends URIS4>(\n  F: FromTask4<M>,\n  M: Chain4<M>\n): <A, B>(f: (a: A) => Task<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, B>\nexport function chainTaskK<M extends URIS3>(\n  F: FromTask3<M>,\n  M: Chain3<M>\n): <A, B>(f: (a: A) => Task<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport function chainTaskK<M extends URIS3, E>(\n  F: FromTask3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => Task<B>) => <R>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, B>\nexport function chainTaskK<M extends URIS2>(\n  F: FromTask2<M>,\n  M: Chain2<M>\n): <A, B>(f: (a: A) => Task<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, B>\nexport function chainTaskK<M extends URIS2, E>(\n  F: FromTask2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => Task<B>) => (first: Kind2<M, E, A>) => Kind2<M, E, B>\nexport function chainTaskK<M extends URIS>(\n  F: FromTask1<M>,\n  M: Chain1<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: Kind<M, A>) => Kind<M, B>\nexport function chainTaskK<M>(\n  F: FromTask<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: HKT<M, A>) => HKT<M, B>\nexport function chainTaskK<M>(\n  F: FromTask<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: HKT<M, A>) => HKT<M, B> {\n  return (f) => {\n    const g = flow(f, F.fromTask)\n    return (first) => M.chain(first, g)\n  }\n}\n\n/**\n * @since 2.10.0\n */\nexport function chainFirstTaskK<M extends URIS4>(\n  F: FromTask4<M>,\n  M: Chain4<M>\n): <A, B>(f: (a: A) => Task<B>) => <S, R, E>(first: Kind4<M, S, R, E, A>) => Kind4<M, S, R, E, A>\nexport function chainFirstTaskK<M extends URIS3>(\n  F: FromTask3<M>,\n  M: Chain3<M>\n): <A, B>(f: (a: A) => Task<B>) => <R, E>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirstTaskK<M extends URIS3, E>(\n  F: FromTask3C<M, E>,\n  M: Chain3C<M, E>\n): <A, B>(f: (a: A) => Task<B>) => <R>(first: Kind3<M, R, E, A>) => Kind3<M, R, E, A>\nexport function chainFirstTaskK<M extends URIS2>(\n  F: FromTask2<M>,\n  M: Chain2<M>\n): <A, B>(f: (a: A) => Task<B>) => <E>(first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport function chainFirstTaskK<M extends URIS2, E>(\n  F: FromTask2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(f: (a: A) => Task<B>) => (first: Kind2<M, E, A>) => Kind2<M, E, A>\nexport function chainFirstTaskK<M extends URIS>(\n  F: FromTask1<M>,\n  M: Chain1<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: Kind<M, A>) => Kind<M, A>\nexport function chainFirstTaskK<M>(\n  F: FromTask<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: HKT<M, A>) => HKT<M, A>\nexport function chainFirstTaskK<M>(\n  F: FromTask<M>,\n  M: Chain<M>\n): <A, B>(f: (a: A) => Task<B>) => (first: HKT<M, A>) => HKT<M, A> {\n  const tapTaskM = tapTask(F, M)\n  return (f) => (first) => tapTaskM(first, f)\n}\n\n/** @internal */\nexport function tapTask<M extends URIS4>(\n  F: FromTask4<M>,\n  M: Chain4<M>\n): <S, R, E, A, B>(self: Kind4<M, S, R, E, A>, f: (a: A) => Task<B>) => Kind4<M, S, R, E, A>\n/** @internal */\nexport function tapTask<M extends URIS3>(\n  F: FromTask3<M>,\n  M: Chain3<M>\n): <R, E, A, B>(self: Kind3<M, R, E, A>, f: (a: A) => Task<B>) => Kind3<M, R, E, A>\n/** @internal */\nexport function tapTask<M extends URIS3, E>(\n  F: FromTask3C<M, E>,\n  M: Chain3C<M, E>\n): <R, A, B>(self: Kind3<M, R, E, A>, f: (a: A) => Task<B>) => Kind3<M, R, E, A>\n/** @internal */\nexport function tapTask<M extends URIS2>(\n  F: FromTask2<M>,\n  M: Chain2<M>\n): <E, A, B>(self: Kind2<M, E, A>, f: (a: A) => Task<B>) => Kind2<M, E, A>\n/** @internal */\nexport function tapTask<M extends URIS2, E>(\n  F: FromTask2C<M, E>,\n  M: Chain2C<M, E>\n): <A, B>(self: Kind2<M, E, A>, f: (a: A) => Task<B>) => Kind2<M, E, A>\n/** @internal */\nexport function tapTask<M extends URIS>(\n  F: FromTask1<M>,\n  M: Chain1<M>\n): <A, B>(self: Kind<M, A>, f: (a: A) => Task<B>) => Kind<M, A>\n/** @internal */\nexport function tapTask<M>(F: FromTask<M>, M: Chain<M>): <A, B>(self: HKT<M, A>, f: (a: A) => Task<B>) => HKT<M, A>\n/** @internal */\nexport function tapTask<M>(F: FromTask<M>, M: Chain<M>): <A, B>(self: HKT<M, A>, f: (a: A) => Task<B>) => HKT<M, A> {\n  const tapM = tap(M)\n  return (self, f) => tapM(self, flow(f, F.fromTask))\n}\n"
  },
  {
    "path": "src/FromThese.ts",
    "content": "/**\n * The `FromThese` type class represents those data types which support errors and warnings.\n *\n * @since 2.11.0\n */\nimport { flow } from './function'\nimport { HKT2, Kind2, Kind3, Kind4, URIS2, URIS3, URIS4 } from './HKT'\nimport { These } from './These'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromThese<F> {\n  readonly URI: F\n  readonly fromThese: <E, A>(e: These<E, A>) => HKT2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromThese2<F extends URIS2> {\n  readonly URI: F\n  readonly fromThese: <E, A>(fa: These<E, A>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromThese2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromThese: <A>(fa: These<E, A>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromThese3<F extends URIS3> {\n  readonly URI: F\n  readonly fromThese: <E, A, R>(fa: These<E, A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromThese3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly fromThese: <A, R>(fa: These<E, A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface FromThese4<F extends URIS4> {\n  readonly URI: F\n  readonly fromThese: <E, A, S, R>(fa: These<E, A>) => Kind4<F, S, R, E, A>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport function fromTheseK<F extends URIS4>(\n  F: FromThese4<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => <S, R>(...a: A) => Kind4<F, S, R, E, B>\nexport function fromTheseK<F extends URIS3>(\n  F: FromThese3<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport function fromTheseK<F extends URIS3, E>(\n  F: FromThese3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => These<E, B>) => <R>(...a: A) => Kind3<F, R, E, B>\nexport function fromTheseK<F extends URIS2>(\n  F: FromThese2<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => (...a: A) => Kind2<F, E, B>\nexport function fromTheseK<F extends URIS2, E>(\n  F: FromThese2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => These<E, B>) => (...a: A) => Kind2<F, E, B>\nexport function fromTheseK<F>(\n  F: FromThese<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => (...a: A) => HKT2<F, E, B>\nexport function fromTheseK<F>(\n  F: FromThese<F>\n): <A extends ReadonlyArray<unknown>, E, B>(f: (...a: A) => These<E, B>) => (...a: A) => HKT2<F, E, B> {\n  return (f) => flow(f, F.fromThese)\n}\n"
  },
  {
    "path": "src/Functor.ts",
    "content": "/**\n * A `Functor` is a type constructor which supports a mapping operation `map`.\n *\n * `map` can be used to turn functions `a -> b` into functions `f a -> f b` whose argument and return types use the type\n * constructor `f` to represent some computational context.\n *\n * Instances must satisfy the following laws:\n *\n * 1. Identity: `F.map(fa, a => a) <-> fa`\n * 2. Composition: `F.map(fa, a => bc(ab(a))) <-> F.map(F.map(fa, ab), bc)`\n *\n * @since 2.0.0\n */\nimport { pipe } from './function'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Functor<F> {\n  readonly URI: F\n  readonly map: <A, B>(fa: HKT<F, A>, f: (a: A) => B) => HKT<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Functor1<F extends URIS> {\n  readonly URI: F\n  readonly map: <A, B>(fa: Kind<F, A>, f: (a: A) => B) => Kind<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Functor2<F extends URIS2> {\n  readonly URI: F\n  readonly map: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Functor2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly map: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Functor3<F extends URIS3> {\n  readonly URI: F\n  readonly map: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Functor3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly map: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Functor4<F extends URIS4> {\n  readonly URI: F\n  readonly map: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => B) => Kind4<F, S, R, E, B>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * `map` composition.\n *\n * @since 2.10.0\n */\nexport function map<F extends URIS3, G extends URIS>(\n  F: Functor3<F>,\n  G: Functor1<G>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, Kind<G, A>>) => Kind3<F, R, E, Kind<G, B>>\nexport function map<F extends URIS2, G extends URIS2>(\n  F: Functor2<F>,\n  G: Functor2<G>\n): <A, B>(f: (a: A) => B) => <EF, EG>(fa: Kind2<F, EF, Kind2<G, EG, A>>) => Kind2<F, EF, Kind2<G, EG, B>>\nexport function map<F extends URIS2, G extends URIS>(\n  F: Functor2<F>,\n  G: Functor1<G>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, Kind<G, A>>) => Kind2<F, E, Kind<G, B>>\nexport function map<F extends URIS, G extends URIS3>(\n  F: Functor1<F>,\n  G: Functor3<G>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind<F, Kind3<G, R, E, A>>) => Kind<F, Kind3<G, R, E, B>>\nexport function map<F extends URIS, G extends URIS2>(\n  F: Functor1<F>,\n  G: Functor2<G>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind<F, Kind2<G, E, A>>) => Kind<F, Kind2<G, E, B>>\nexport function map<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Functor1<G>\n): <A, B>(f: (a: A) => B) => (fa: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\nexport function map<F, G extends URIS2>(\n  F: Functor<F>,\n  G: Functor2<G>\n): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, Kind2<G, E, A>>) => HKT<F, Kind2<G, E, B>>\nexport function map<F, G extends URIS>(\n  F: Functor<F>,\n  G: Functor1<G>\n): <A, B>(f: (a: A) => B) => (fa: HKT<F, Kind<G, A>>) => HKT<F, Kind<G, B>>\nexport function map<F, G>(\n  F: Functor<F>,\n  G: Functor<G>\n): <A, B>(f: (a: A) => B) => (fa: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\nexport function map<F, G>(\n  F: Functor<F>,\n  G: Functor<G>\n): <A, B>(f: (a: A) => B) => (fa: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>> {\n  return (f) => (fa) => F.map(fa, (ga) => G.map(ga, f))\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport function flap<F extends URIS4>(\n  F: Functor4<F>\n): <A>(a: A) => <S, R, E, B>(fab: Kind4<F, S, R, E, (a: A) => B>) => Kind4<F, S, R, E, B>\nexport function flap<F extends URIS3>(\n  F: Functor3<F>\n): <A>(a: A) => <R, E, B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\nexport function flap<F extends URIS2>(\n  F: Functor2<F>\n): <A>(a: A) => <E, B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\nexport function flap<F extends URIS>(F: Functor1<F>): <A>(a: A) => <B>(fab: Kind<F, (a: A) => B>) => Kind<F, B>\nexport function flap<F>(F: Functor<F>): <A>(a: A) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B>\nexport function flap<F>(F: Functor<F>): <A>(a: A) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B> {\n  return (a) => (fab) => F.map(fab, (f) => f(a))\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function bindTo<F extends URIS4>(\n  F: Functor4<F>\n): <N extends string>(name: N) => <S, R, E, A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, { readonly [K in N]: A }>\nexport function bindTo<F extends URIS3>(\n  F: Functor3<F>\n): <N extends string>(name: N) => <R, E, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in N]: A }>\nexport function bindTo<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <N extends string>(name: N) => <R, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in N]: A }>\nexport function bindTo<F extends URIS2>(\n  F: Functor2<F>\n): <N extends string>(name: N) => <E, A>(fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in N]: A }>\nexport function bindTo<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <N extends string>(name: N) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in N]: A }>\nexport function bindTo<F extends URIS>(\n  F: Functor1<F>\n): <N extends string>(name: N) => <A>(fa: Kind<F, A>) => Kind<F, { readonly [K in N]: A }>\nexport function bindTo<F>(\n  F: Functor<F>\n): <N extends string>(name: N) => <A>(fa: HKT<F, A>) => HKT<F, { readonly [K in N]: A }>\nexport function bindTo<F>(\n  F: Functor<F>\n): <N extends string>(name: N) => <A>(fa: HKT<F, A>) => HKT<F, { readonly [K in N]: A }> {\n  return (name) => (fa) => F.map(fa, (a) => ({ [name]: a } as any))\n}\n\n/**\n * @since 2.13.0\n */\nfunction let_<F extends URIS4>(\n  F: Functor4<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <S, R, E>(\n  fa: Kind4<F, S, R, E, A>\n) => Kind4<F, S, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS3>(\n  F: Functor3<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS2>(\n  F: Functor2<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: Kind2<F, E, A>) => Kind2<F, E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F extends URIS>(\n  F: Functor1<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: Kind<F, A>) => Kind<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F>(\n  F: Functor<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: HKT<F, A>) => HKT<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }>\nfunction let_<F>(\n  F: Functor<F>\n): <N extends string, A, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => B\n) => (fa: HKT<F, A>) => HKT<F, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> {\n  return (name, f) => (fa) => F.map(fa, (a) => Object.assign({}, a, { [name]: f(a) }) as any)\n}\n\nexport {\n  /**\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorComposition<F, G> {\n  readonly map: <A, B>(fa: HKT<F, HKT<G, A>>, f: (a: A) => B) => HKT<F, HKT<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorCompositionHKT1<F, G extends URIS> {\n  readonly map: <A, B>(fa: HKT<F, Kind<G, A>>, f: (a: A) => B) => HKT<F, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorCompositionHKT2<F, G extends URIS2> {\n  readonly map: <E, A, B>(fa: HKT<F, Kind2<G, E, A>>, f: (a: A) => B) => HKT<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorCompositionHKT2C<F, G extends URIS2, E> {\n  readonly map: <A, B>(fa: HKT<F, Kind2<G, E, A>>, f: (a: A) => B) => HKT<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorComposition11<F extends URIS, G extends URIS> {\n  readonly map: <A, B>(fa: Kind<F, Kind<G, A>>, f: (a: A) => B) => Kind<F, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorComposition12<F extends URIS, G extends URIS2> {\n  readonly map: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => B) => Kind<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorComposition12C<F extends URIS, G extends URIS2, E> {\n  readonly map: <A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (a: A) => B) => Kind<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorComposition21<F extends URIS2, G extends URIS> {\n  readonly map: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => B) => Kind2<F, E, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorComposition2C1<F extends URIS2, G extends URIS, E> {\n  readonly map: <A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (a: A) => B) => Kind2<F, E, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorComposition22<F extends URIS2, G extends URIS2> {\n  readonly map: <FE, GE, A, B>(fa: Kind2<F, FE, Kind2<G, GE, A>>, f: (a: A) => B) => Kind2<F, FE, Kind2<G, GE, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorComposition22C<F extends URIS2, G extends URIS2, E> {\n  readonly map: <FE, A, B>(fa: Kind2<F, FE, Kind2<G, E, A>>, f: (a: A) => B) => Kind2<F, FE, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.2.0\n * @deprecated\n */\nexport interface FunctorComposition23<F extends URIS2, G extends URIS3> {\n  readonly map: <FE, R, E, A, B>(fa: Kind2<F, FE, Kind3<G, R, E, A>>, f: (a: A) => B) => Kind2<F, FE, Kind3<G, R, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.2.0\n * @deprecated\n */\nexport interface FunctorComposition23C<F extends URIS2, G extends URIS3, E> {\n  readonly map: <FE, R, A, B>(fa: Kind2<F, FE, Kind3<G, R, E, A>>, f: (a: A) => B) => Kind2<F, FE, Kind3<G, R, E, B>>\n}\n\n/**\n * Use [`map`](#map) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getFunctorComposition<F extends URIS2, G extends URIS3, E>(\n  F: Functor2<F>,\n  G: Functor3C<G, E>\n): FunctorComposition23C<F, G, E>\n/** @deprecated */\nexport function getFunctorComposition<F extends URIS2, G extends URIS2, E>(\n  F: Functor2<F>,\n  G: Functor2C<G, E>\n): FunctorComposition22C<F, G, E>\n/** @deprecated */\nexport function getFunctorComposition<F extends URIS2, G extends URIS2>(\n  F: Functor2<F>,\n  G: Functor2<G>\n): FunctorComposition22<F, G>\n/** @deprecated */\nexport function getFunctorComposition<F extends URIS2, G extends URIS, E>(\n  F: Functor2C<F, E>,\n  G: Functor1<G>\n): FunctorComposition2C1<F, G, E>\n/** @deprecated */\nexport function getFunctorComposition<F extends URIS2, G extends URIS>(\n  F: Functor2<F>,\n  G: Functor1<G>\n): FunctorComposition21<F, G>\n/** @deprecated */\nexport function getFunctorComposition<F extends URIS, G extends URIS2, E>(\n  F: Functor1<F>,\n  G: Functor2C<G, E>\n): FunctorComposition12C<F, G, E>\n/** @deprecated */\nexport function getFunctorComposition<F extends URIS, G extends URIS2>(\n  F: Functor1<F>,\n  G: Functor2<G>\n): FunctorComposition12<F, G>\n/** @deprecated */\nexport function getFunctorComposition<F extends URIS, G extends URIS>(\n  F: Functor1<F>,\n  G: Functor1<G>\n): FunctorComposition11<F, G>\n/** @deprecated */\nexport function getFunctorComposition<F, G>(F: Functor<F>, G: Functor<G>): FunctorComposition<F, G>\n/** @deprecated */\nexport function getFunctorComposition<F, G>(F: Functor<F>, G: Functor<G>): FunctorComposition<F, G> {\n  const _map = map(F, G)\n  return {\n    map: (fga, f) => pipe(fga, _map(f))\n  }\n}\n\n/** @internal */\nexport function as<F extends URIS4>(\n  F: Functor4<F>\n): <S, R, E, A, _>(self: Kind4<F, S, R, E, _>, a: A) => Kind4<F, S, R, E, A>\n/** @internal */\nexport function as<F extends URIS3>(F: Functor3<F>): <R, E, A, _>(self: Kind3<F, R, E, _>, a: _) => Kind3<F, R, E, A>\n/** @internal */\nexport function as<F extends URIS2>(F: Functor2<F>): <E, A, _>(self: Kind2<F, E, _>, a: A) => Kind2<F, E, A>\n/** @internal */\nexport function as<F extends URIS>(F: Functor1<F>): <A, _>(self: Kind<F, _>, a: A) => Kind<F, A>\n/** @internal */\nexport function as<F>(F: Functor<F>): <A, _>(self: HKT<F, _>, a: A) => HKT<F, A>\n/** @internal */\nexport function as<F>(F: Functor<F>): <A, _>(self: HKT<F, _>, b: A) => HKT<F, A> {\n  return (self, b) => F.map(self, () => b)\n}\n\n/** @internal */\nexport function asUnit<F extends URIS4>(\n  F: Functor4<F>\n): <S, R, E, _>(self: Kind4<F, S, R, E, _>) => Kind4<F, S, R, E, void>\n/** @internal */\nexport function asUnit<F extends URIS3>(F: Functor3<F>): <R, E, _>(self: Kind3<F, R, E, _>) => Kind3<F, R, E, void>\n/** @internal */\nexport function asUnit<F extends URIS2>(F: Functor2<F>): <E, _>(self: Kind2<F, E, _>) => Kind2<F, E, void>\n/** @internal */\nexport function asUnit<F extends URIS>(F: Functor1<F>): <_>(self: Kind<F, _>) => Kind<F, void>\n/** @internal */\nexport function asUnit<F>(F: Functor<F>): <_>(self: HKT<F, _>) => HKT<F, void>\n/** @internal */\nexport function asUnit<F>(F: Functor<F>): <_>(self: HKT<F, _>) => HKT<F, void> {\n  const asM = as(F)\n  return (self) => asM(self, undefined)\n}\n"
  },
  {
    "path": "src/FunctorWithIndex.ts",
    "content": "/**\n * A `FunctorWithIndex` is a type constructor which supports a mapping operation `mapWithIndex`.\n *\n * `mapWithIndex` can be used to turn functions `i -> a -> b` into functions `f a -> f b` whose argument and return types use the type\n * constructor `f` to represent some computational context.\n *\n * Instances must satisfy the following laws:\n *\n * 1. Identity: `F.mapWithIndex(fa, (_i, a) => a) <-> fa`\n * 2. Composition: `F.mapWithIndex(fa, (_i, a) => bc(ab(a))) <-> F.mapWithIndex(F.mapWithIndex(fa, ab), bc)`\n *\n * @since 2.0.0\n */\nimport { pipe } from './function'\nimport {\n  Functor,\n  Functor1,\n  Functor2,\n  Functor2C,\n  Functor3,\n  Functor3C,\n  Functor4,\n  FunctorComposition,\n  FunctorComposition2C1,\n  FunctorComposition11,\n  FunctorComposition12,\n  FunctorComposition12C,\n  FunctorComposition21,\n  FunctorComposition22,\n  FunctorComposition22C,\n  getFunctorComposition\n} from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FunctorWithIndex<F, I> extends Functor<F> {\n  readonly mapWithIndex: <A, B>(fa: HKT<F, A>, f: (i: I, a: A) => B) => HKT<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FunctorWithIndex1<F extends URIS, I> extends Functor1<F> {\n  readonly mapWithIndex: <A, B>(fa: Kind<F, A>, f: (i: I, a: A) => B) => Kind<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FunctorWithIndex2<F extends URIS2, I> extends Functor2<F> {\n  readonly mapWithIndex: <E, A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => B) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FunctorWithIndex2C<F extends URIS2, I, E> extends Functor2C<F, E> {\n  readonly mapWithIndex: <A, B>(fa: Kind2<F, E, A>, f: (i: I, a: A) => B) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FunctorWithIndex3<F extends URIS3, I> extends Functor3<F> {\n  readonly mapWithIndex: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => B) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface FunctorWithIndex3C<F extends URIS3, I, E> extends Functor3C<F, E> {\n  readonly mapWithIndex: <R, A, B>(fa: Kind3<F, R, E, A>, f: (i: I, a: A) => B) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface FunctorWithIndex4<F extends URIS4, I> extends Functor4<F> {\n  readonly mapWithIndex: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (i: I, a: A) => B) => Kind4<F, S, R, E, B>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * `mapWithIndex` composition.\n *\n * @since 2.10.0\n */\nexport function mapWithIndex<F extends URIS, I, G extends URIS, J>(\n  F: FunctorWithIndex1<F, I>,\n  G: FunctorWithIndex1<G, J>\n): <A, B>(f: (ij: readonly [I, J], a: A) => B) => (fa: Kind<F, Kind<G, A>>) => Kind<F, Kind<G, B>>\nexport function mapWithIndex<F, I, G, J>(\n  F: FunctorWithIndex<F, I>,\n  G: FunctorWithIndex<G, J>\n): <A, B>(f: (ij: readonly [I, J], a: A) => B) => (fa: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>>\nexport function mapWithIndex<F, I, G, J>(\n  F: FunctorWithIndex<F, I>,\n  G: FunctorWithIndex<G, J>\n): <A, B>(f: (ij: readonly [I, J], a: A) => B) => (fa: HKT<F, HKT<G, A>>) => HKT<F, HKT<G, B>> {\n  return (f) => (fa) => F.mapWithIndex(fa, (i, ga) => G.mapWithIndex(ga, (j, a) => f([i, j], a)))\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorWithIndexComposition<F, FI, G, GI> extends FunctorComposition<F, G> {\n  readonly mapWithIndex: <A, B>(fga: HKT<F, HKT<G, A>>, f: (i: [FI, GI], a: A) => B) => HKT<F, HKT<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorWithIndexComposition11<F extends URIS, FI, G extends URIS, GI>\n  extends FunctorComposition11<F, G> {\n  readonly mapWithIndex: <A, B>(fa: Kind<F, Kind<G, A>>, f: (i: [FI, GI], a: A) => B) => Kind<F, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorWithIndexComposition12<F extends URIS, FI, G extends URIS2, GI>\n  extends FunctorComposition12<F, G> {\n  readonly mapWithIndex: <E, A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => B) => Kind<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorWithIndexComposition12C<F extends URIS, FI, G extends URIS2, GI, E>\n  extends FunctorComposition12C<F, G, E> {\n  readonly mapWithIndex: <A, B>(fa: Kind<F, Kind2<G, E, A>>, f: (i: [FI, GI], a: A) => B) => Kind<F, Kind2<G, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorWithIndexComposition21<F extends URIS2, FI, G extends URIS, GI>\n  extends FunctorComposition21<F, G> {\n  readonly mapWithIndex: <E, A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (i: [FI, GI], a: A) => B) => Kind2<F, E, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorWithIndexComposition2C1<F extends URIS2, FI, G extends URIS, GI, E>\n  extends FunctorComposition2C1<F, G, E> {\n  readonly mapWithIndex: <A, B>(fa: Kind2<F, E, Kind<G, A>>, f: (i: [FI, GI], a: A) => B) => Kind2<F, E, Kind<G, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorWithIndexComposition22<F extends URIS2, FI, G extends URIS2, GI>\n  extends FunctorComposition22<F, G> {\n  readonly mapWithIndex: <FE, GE, A, B>(\n    fa: Kind2<F, FE, Kind2<G, GE, A>>,\n    f: (i: [FI, GI], a: A) => B\n  ) => Kind2<F, FE, Kind2<G, GE, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface FunctorWithIndexComposition22C<F extends URIS2, FI, G extends URIS2, GI, E>\n  extends FunctorComposition22C<F, G, E> {\n  readonly mapWithIndex: <FE, A, B>(\n    fa: Kind2<F, FE, Kind2<G, E, A>>,\n    f: (i: [FI, GI], a: A) => B\n  ) => Kind2<F, FE, Kind2<G, E, B>>\n}\n\n/**\n * Use [`mapWithIndex`](#mapwithindex) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI, E>(\n  F: FunctorWithIndex2<F, FI>,\n  G: FunctorWithIndex2C<G, FI, E>\n): FunctorWithIndexComposition22C<F, FI, G, GI, E>\n/** @deprecated */\nexport function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS2, GI>(\n  F: FunctorWithIndex2<F, FI>,\n  G: FunctorWithIndex2<G, FI>\n): FunctorWithIndexComposition22<F, FI, G, GI>\n/** @deprecated */\nexport function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS, GI, E>(\n  F: FunctorWithIndex2C<F, FI, E>,\n  G: FunctorWithIndex1<G, GI>\n): FunctorWithIndexComposition2C1<F, FI, G, GI, E>\n/** @deprecated */\nexport function getFunctorWithIndexComposition<F extends URIS2, FI, G extends URIS, GI>(\n  F: FunctorWithIndex2<F, FI>,\n  G: FunctorWithIndex1<G, GI>\n): FunctorWithIndexComposition21<F, FI, G, GI>\n/** @deprecated */\nexport function getFunctorWithIndexComposition<F extends URIS, FI, G extends URIS2, GI, E>(\n  F: FunctorWithIndex1<F, FI>,\n  G: FunctorWithIndex2C<G, GI, E>\n): FunctorWithIndexComposition12C<F, FI, G, GI, E>\n/** @deprecated */\nexport function getFunctorWithIndexComposition<F extends URIS, FI, G extends URIS2, GI>(\n  F: FunctorWithIndex1<F, FI>,\n  G: FunctorWithIndex2<G, GI>\n): FunctorWithIndexComposition12<F, FI, G, GI>\n/** @deprecated */\nexport function getFunctorWithIndexComposition<F extends URIS, FI, G extends URIS, GI>(\n  F: FunctorWithIndex1<F, FI>,\n  G: FunctorWithIndex1<G, GI>\n): FunctorWithIndexComposition11<F, FI, G, GI>\n/** @deprecated */\nexport function getFunctorWithIndexComposition<F, FI, G, GI>(\n  F: FunctorWithIndex<F, FI>,\n  G: FunctorWithIndex<G, GI>\n): FunctorWithIndexComposition<F, FI, G, GI>\n/** @deprecated */\nexport function getFunctorWithIndexComposition<F, FI, G, GI>(\n  F: FunctorWithIndex<F, FI>,\n  G: FunctorWithIndex<G, GI>\n): FunctorWithIndexComposition<F, FI, G, GI> {\n  const map = getFunctorComposition(F, G).map\n  const _mapWithIndex = mapWithIndex(F, G)\n  return {\n    map,\n    mapWithIndex: (fga, f: any) => pipe(fga, _mapWithIndex(f))\n  }\n}\n"
  },
  {
    "path": "src/Group.ts",
    "content": "/**\n * A `Group` is a `Monoid` with inverses. Instances must satisfy the following law in addition to the monoid laws:\n *\n * - Inverse: `concat(inverse(a), a) <-> empty = concat(a, inverse(a))`\n *\n * @since 2.0.0\n */\nimport { Monoid } from './Monoid'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Group<A> extends Monoid<A> {\n  readonly inverse: (a: A) => A\n}\n"
  },
  {
    "path": "src/HKT.ts",
    "content": "/**\n * Type defunctionalization (as describe in [Lightweight higher-kinded polymorphism](https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf))\n *\n * @since 2.0.0\n */\n\n/**\n * `* -> *` constructors\n * @since 2.0.0\n */\nexport interface HKT<URI, A> {\n  readonly _URI: URI\n  readonly _A: A\n}\n\n/**\n * `* -> * -> *` constructors\n * @since 2.0.0\n */\nexport interface HKT2<URI, E, A> extends HKT<URI, A> {\n  readonly _E: E\n}\n\n/**\n * `* -> * -> * -> *` constructors\n * @since 2.0.0\n */\nexport interface HKT3<URI, R, E, A> extends HKT2<URI, E, A> {\n  readonly _R: R\n}\n\n/**\n * `* -> * -> * -> * -> *` constructors\n * @since 2.0.0\n */\nexport interface HKT4<URI, S, R, E, A> extends HKT3<URI, R, E, A> {\n  readonly _S: S\n}\n\n//\n// inj: type-level dictionaries for HKTs: URI -> concrete type\n//\n\n/**\n * `* -> *` constructors\n * @since 2.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface URItoKind<A> {}\n\n/**\n * `* -> * -> *` constructors\n * @since 2.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface URItoKind2<E, A> {}\n\n/**\n * `* -> * -> * -> *` constructors\n * @since 2.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface URItoKind3<R, E, A> {}\n\n/**\n * `* -> * -> * -> * -> *` constructors\n * @since 2.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport interface URItoKind4<S, R, E, A> {}\n\n//\n// unions of URIs\n//\n\n/**\n * `* -> *` constructors\n * @since 2.0.0\n */\nexport type URIS = keyof URItoKind<any>\n\n/**\n * `* -> * -> *` constructors\n * @since 2.0.0\n */\nexport type URIS2 = keyof URItoKind2<any, any>\n\n/**\n * `* -> * -> * -> *` constructors\n * @since 2.0.0\n */\nexport type URIS3 = keyof URItoKind3<any, any, any>\n\n/**\n * `* -> * -> * -> * -> *` constructors\n * @since 2.0.0\n */\nexport type URIS4 = keyof URItoKind4<any, any, any, any>\n\n//\n// prj\n//\n\n/**\n * `* -> *` constructors\n * @since 2.0.0\n */\nexport type Kind<URI extends URIS, A> = URI extends URIS ? URItoKind<A>[URI] : any\n\n/**\n * `* -> * -> *` constructors\n * @since 2.0.0\n */\nexport type Kind2<URI extends URIS2, E, A> = URI extends URIS2 ? URItoKind2<E, A>[URI] : any\n\n/**\n * `* -> * -> * -> *` constructors\n * @since 2.0.0\n */\nexport type Kind3<URI extends URIS3, R, E, A> = URI extends URIS3 ? URItoKind3<R, E, A>[URI] : any\n\n/**\n * `* -> * -> * -> * -> *` constructors\n * @since 2.0.0\n */\nexport type Kind4<URI extends URIS4, S, R, E, A> = URI extends URIS4 ? URItoKind4<S, R, E, A>[URI] : any\n"
  },
  {
    "path": "src/HeytingAlgebra.ts",
    "content": "/**\n * Heyting algebras are bounded (distributive) lattices that are also equipped with an additional binary operation\n * `implies` (also written as `→`). Heyting algebras also define a complement operation `not` (sometimes written as\n * `¬a`)\n *\n * However, in Heyting algebras this operation is only a pseudo-complement, since Heyting algebras do not necessarily\n * provide the law of the excluded middle. This means that there is no guarantee that `a ∨ ¬a = 1`.\n *\n * Heyting algebras model intuitionistic logic. For a model of classical logic, see the boolean algebra type class\n * implemented as `BooleanAlgebra`.\n *\n * A `HeytingAlgebra` must satisfy the following laws in addition to `BoundedDistributiveLattice` laws:\n *\n * - Implication:\n *   - `a → a <-> 1`\n *   - `a ∧ (a → b) <-> a ∧ b`\n *   - `b ∧ (a → b) <-> b`\n *   - `a → (b ∧ c) <-> (a → b) ∧ (a → c)`\n * - Complemented\n *   - `¬a <-> a → 0`\n *\n * @since 2.0.0\n */\nimport { BoundedDistributiveLattice } from './BoundedDistributiveLattice'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface HeytingAlgebra<A> extends BoundedDistributiveLattice<A> {\n  readonly implies: (x: A, y: A) => A\n  readonly not: (x: A) => A\n}\n"
  },
  {
    "path": "src/IO.ts",
    "content": "/**\n * ```ts\n * interface IO<A> {\n *   (): A\n * }\n * ```\n *\n * `IO<A>` represents a non-deterministic synchronous computation that can cause side effects, yields a value of\n * type `A` and **never fails**.\n *\n * If you want to represent a synchronous computation that may fail, please see `IOEither`.\n * If you want to represent a synchronous computation that may yield nothing, please see `IOOption`.\n *\n * @since 2.0.0\n */\nimport { Applicative1, getApplicativeMonoid } from './Applicative'\nimport { apFirst as apFirst_, Apply1, apS as apS_, apSecond as apSecond_, getApplySemigroup } from './Apply'\nimport * as chainable from './Chain'\nimport { ChainRec1 } from './ChainRec'\nimport { FromIO1 } from './FromIO'\nimport { constant, dual, identity } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { Monad1 } from './Monad'\nimport { MonadIO1 } from './MonadIO'\nimport { Monoid } from './Monoid'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Pointed1 } from './Pointed'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface IO<A> {\n  (): A\n}\n\nconst _map: Monad1<URI>['map'] = (ma, f) => () => f(ma())\nconst _ap: Monad1<URI>['ap'] = (mab, ma) => () => mab()(ma())\nconst _chainRec: ChainRec1<URI>['chainRec'] = (a, f) => () => {\n  let e = f(a)()\n  while (e._tag === 'Left') {\n    e = f(e.left)()\n  }\n  return e.right\n}\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => (fa: IO<A>) => IO<B> = (f) => (fa) => _map(fa, f)\n\n/**\n * @since 2.0.0\n */\nexport const ap: <A>(fa: IO<A>) => <B>(fab: IO<(a: A) => B>) => IO<B> = (fa) => (fab) => _ap(fab, fa)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const of: <A>(a: A) => IO<A> = constant\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A) => IO<B>): (ma: IO<A>) => IO<B>\n  <A, B>(ma: IO<A>, f: (a: A) => IO<B>): IO<B>\n} = /*#__PURE__*/ dual(\n  2,\n  <A, B>(ma: IO<A>, f: (a: A) => IO<B>): IO<B> =>\n    () =>\n      f(ma())()\n)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <A>(mma: IO<IO<A>>) => IO<A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'IO'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: IO<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the value to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <_>(self: IO<_>) => IO<A>\n  <_, A>(self: IO<_>, a: A): IO<A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the value to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <_>(self: IO<_>) => IO<void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <A, _>(self: IO<A>, f: (a: A) => IO<_>): IO<A>\n  <A, _>(f: (a: A) => IO<_>): (self: IO<A>) => IO<A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const fromIO: <A>(fa: IO<A>) => IO<A> = identity\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const MonadIO: MonadIO1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const ChainRec: ChainRec1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap,\n  chainRec: _chainRec\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromIO: FromIO1<URI> = {\n  URI,\n  fromIO: identity\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: IO<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n/**\n * @since 2.11.0\n */\nexport const ApT: IO<readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex =\n  <A, B>(f: (index: number, a: A) => IO<B>) =>\n  (as: ReadonlyNonEmptyArray<A>): IO<ReadonlyNonEmptyArray<B>> =>\n  () => {\n    const out: NonEmptyArray<B> = [f(0, _.head(as))()]\n    for (let i = 1; i < as.length; i++) {\n      out.push(f(i, as[i])())\n    }\n    return out\n  }\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, B>(\n  f: (index: number, a: A) => IO<B>\n): ((as: ReadonlyArray<A>) => IO<ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => IO<B>\n) => (as: ReadonlyArray<A>) => IO<ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <A, B>(f: (a: A) => IO<B>): ((as: ReadonlyArray<A>) => IO<ReadonlyArray<B>>) =>\n  traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <A>(arr: ReadonlyArray<IO<A>>) => IO<ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <A, B>(f: (a: A) => IO<B>) => (ma: IO<A>) => IO<B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => IO<B>) => (first: IO<A>) => IO<A> = tap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `IO.Functor` instead of `IO.io`\n * (where `IO` is from `import IO from 'fp-ts/IO'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const io: Monad1<URI> & MonadIO1<URI> & ChainRec1<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  fromIO,\n  chainRec: _chainRec\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getSemigroup: <A>(S: Semigroup<A>) => Semigroup<IO<A>> = /*#__PURE__*/ getApplySemigroup(Apply)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getMonoid: <A>(M: Monoid<A>) => Monoid<IO<A>> = /*#__PURE__*/ getApplicativeMonoid(Applicative)\n"
  },
  {
    "path": "src/IOEither.ts",
    "content": "/**\n * `IOEither<E, A>` represents a synchronous computation that either yields a value of type `A` or fails yielding an\n * error of type `E`.\n *\n * If you want to represent a synchronous computation that never fails, please see `IO`.\n * If you want to represent a synchronous computation that may yield nothing, please see `IOOption`.\n *\n * @since 2.0.0\n */\nimport { Alt2, Alt2C } from './Alt'\nimport { Applicative2, Applicative2C, getApplicativeMonoid } from './Applicative'\nimport {\n  ap as ap_,\n  apFirst as apFirst_,\n  Apply2,\n  apS as apS_,\n  apSecond as apSecond_,\n  getApplySemigroup as getApplySemigroup_\n} from './Apply'\nimport { Bifunctor2 } from './Bifunctor'\nimport * as chainable from './Chain'\nimport { compact as compact_, Compactable2C, separate as separate_ } from './Compactable'\nimport * as E from './Either'\nimport * as ET from './EitherT'\nimport {\n  filter as filter_,\n  Filterable2C,\n  filterMap as filterMap_,\n  partition as partition_,\n  partitionMap as partitionMap_\n} from './Filterable'\nimport {\n  chainOptionK as chainOptionK_,\n  filterOrElse as filterOrElse_,\n  FromEither2,\n  fromEitherK as fromEitherK_,\n  fromOption as fromOption_,\n  fromOptionK as fromOptionK_,\n  fromPredicate as fromPredicate_,\n  tapEither as tapEither_\n} from './FromEither'\nimport { FromIO2, fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO'\nimport { dual, flow, identity, LazyArg, pipe, SK } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor2, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport * as I from './IO'\nimport { Monad2, Monad2C } from './Monad'\nimport { MonadIO2, MonadIO2C } from './MonadIO'\nimport { MonadThrow2, MonadThrow2C } from './MonadThrow'\nimport { Monoid } from './Monoid'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Option } from './Option'\nimport { Pointed2 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\nimport Either = E.Either\nimport IO = I.IO\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface IOEither<E, A> extends IO<Either<E, A>> {}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const left: <E = never, A = never>(l: E) => IOEither<E, A> = /*#__PURE__*/ ET.left(I.Pointed)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const right: <E = never, A = never>(a: A) => IOEither<E, A> = /*#__PURE__*/ ET.right(I.Pointed)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const rightIO: <E = never, A = never>(ma: IO<A>) => IOEither<E, A> = /*#__PURE__*/ ET.rightF(I.Functor)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const leftIO: <E = never, A = never>(me: IO<E>) => IOEither<E, A> = /*#__PURE__*/ ET.leftF(I.Functor)\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromEither: <E, A>(fa: Either<E, A>) => IOEither<E, A> = I.of\n\n/**\n * @category conversions\n * @since 2.7.0\n */\nexport const fromIO: <A, E = never>(fa: IO<A>) => IOEither<E, A> = rightIO\n\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: IOEither<E, A>) => IO<B> =\n  /*#__PURE__*/ ET.match(I.Functor)\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW: <E, B, A, C>(onLeft: (e: E) => B, onRight: (a: A) => C) => (ma: IOEither<E, A>) => IO<B | C> =\n  match as any\n\n/**\n * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`IO`).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchE: <E, A, B>(onLeft: (e: E) => IO<B>, onRight: (a: A) => IO<B>) => (ma: IOEither<E, A>) => IO<B> =\n  /*#__PURE__*/ ET.matchE(I.Monad)\n\n/**\n * Alias of [`matchE`](#matche).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const fold = matchE\n\n/**\n * Less strict version of [`matchE`](#matche).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchEW: <E, B, A, C>(\n  onLeft: (e: E) => IO<B>,\n  onRight: (a: A) => IO<C>\n) => (ma: IOEither<E, A>) => IO<B | C> = matchE as any\n\n/**\n * Alias of [`matchEW`](#matchew).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchEW\n\n/**\n * @category error handling\n * @since 2.0.0\n */\nexport const getOrElse: <E, A>(onLeft: (e: E) => IO<A>) => (ma: IOEither<E, A>) => IO<A> = /*#__PURE__*/ ET.getOrElse(\n  I.Monad\n)\n\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.6.0\n */\nexport const getOrElseW: <E, B>(onLeft: (e: E) => IO<B>) => <A>(ma: IOEither<E, A>) => IO<A | B> = getOrElse as any\n\n/**\n * Constructs a new `IOEither` from a function that performs a side effect and might throw\n *\n * See also [`tryCatchK`](#trycatchk).\n *\n * @category interop\n * @since 2.0.0\n */\nexport const tryCatch =\n  <E, A>(f: LazyArg<A>, onThrow: (reason: unknown) => E): IOEither<E, A> =>\n  () =>\n    E.tryCatch(f, onThrow)\n\n/**\n * Converts a function that may throw to one returning a `IOEither`.\n *\n * @category interop\n * @since 2.10.0\n */\nexport const tryCatchK =\n  <A extends ReadonlyArray<unknown>, B, E>(\n    f: (...a: A) => B,\n    onThrow: (reason: unknown) => E\n  ): ((...a: A) => IOEither<E, B>) =>\n  (...a) =>\n    tryCatch(() => f(...a), onThrow)\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const toUnion: <E, A>(fa: IOEither<E, A>) => IO<E | A> = /*#__PURE__*/ ET.toUnion(I.Functor)\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @category error handling\n * @since 2.0.0\n */\nexport const orElse: <E1, A, E2>(onLeft: (e: E1) => IOEither<E2, A>) => (ma: IOEither<E1, A>) => IOEither<E2, A> =\n  /*#__PURE__*/ ET.orElse(I.Monad)\n\n/**\n * Less strict version of [`orElse`](#orelse).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport const orElseW: <E1, E2, B>(\n  onLeft: (e: E1) => IOEither<E2, B>\n) => <A>(ma: IOEither<E1, A>) => IOEither<E2, A | B> = orElse as any\n\n/**\n * Returns an effect that effectfully \"peeks\" at the failure of this effect.\n *\n * @category error handling\n * @since 2.15.0\n */\nexport const tapError: {\n  <E1, E2, _>(onLeft: (e: E1) => IOEither<E2, _>): <A>(self: IOEither<E1, A>) => IOEither<E1 | E2, A>\n  <E1, A, E2, _>(self: IOEither<E1, A>, onLeft: (e: E1) => IOEither<E2, _>): IOEither<E1 | E2, A>\n} = /*#__PURE__*/ dual(2, ET.tapError(I.Monad))\n\n/**\n * @category error handling\n * @since 2.12.0\n */\nexport const orElseFirstIOK: <E, B>(onLeft: (e: E) => IO<B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A> = (onLeft) =>\n  tapError(fromIOK(onLeft))\n\n/**\n * @category error handling\n * @since 2.11.0\n */\nexport const orLeft: <E1, E2>(onLeft: (e: E1) => IO<E2>) => <A>(fa: IOEither<E1, A>) => IOEither<E2, A> =\n  /*#__PURE__*/ ET.orLeft(I.Monad)\n\n/**\n * @since 2.0.0\n */\nexport const swap: <E, A>(ma: IOEither<E, A>) => IOEither<A, E> = /*#__PURE__*/ ET.swap(I.Functor)\n\n/* istanbul ignore next */\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _ap: Apply2<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\nconst _apSeq: Apply2<URI>['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map(f)))\n/* istanbul ignore next */\nconst _alt: Alt2<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: IOEither<E, A>) => IOEither<E, B> = /*#__PURE__*/ ET.map(I.Functor)\n\n/**\n * Returns a `IOEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`.\n *\n * @example\n * import * as IOEither from 'fp-ts/IOEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n * const g = (n: number) => n * 2\n *\n * assert.deepStrictEqual(IOEither.mapBoth(IOEither.right(1), f, g)(), Either.right(2))\n * assert.deepStrictEqual(IOEither.mapBoth(IOEither.left('err'), f, g)(), Either.left(new Error('err')))\n *\n * @category error handling\n * @since 2.16.0\n */\nexport const mapBoth: {\n  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): (self: IOEither<E, A>) => IOEither<G, B>\n  <E, A, G, B>(self: IOEither<E, A>, f: (e: E) => G, g: (a: A) => B): IOEither<G, B>\n} = /*#__PURE__*/ dual(3, ET.mapBoth(I.Functor))\n\n/**\n * Alias of `mapBoth`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: IOEither<E, A>) => IOEither<G, B> = mapBoth\n\n/**\n * Returns a `IOEither` with its error channel mapped using the specified function.\n *\n * @example\n * import * as IOEither from 'fp-ts/IOEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n *\n * assert.deepStrictEqual(IOEither.mapError(IOEither.right(1), f)(), Either.right(1))\n * assert.deepStrictEqual(IOEither.mapError(IOEither.left('err'), f)(), Either.left(new Error('err')))\n *\n * @category error handling\n * @since 2.16.0\n */\nexport const mapError: {\n  <E, G>(f: (e: E) => G): <A>(self: IOEither<E, A>) => IOEither<G, A>\n  <E, A, G>(self: IOEither<E, A>, f: (e: E) => G): IOEither<G, A>\n} = /*#__PURE__*/ dual(2, ET.mapError(I.Functor))\n\n/**\n * Alias of `mapError`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: IOEither<E, A>) => IOEither<G, A> = mapError\n\n/**\n * @since 2.0.0\n */\nexport const ap: <E, A>(fa: IOEither<E, A>) => <B>(fab: IOEither<E, (a: A) => B>) => IOEither<E, B> =\n  /*#__PURE__*/ ET.ap(I.Apply)\n\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.8.0\n */\nexport const apW: <E2, A>(fa: IOEither<E2, A>) => <E1, B>(fab: IOEither<E1, (a: A) => B>) => IOEither<E1 | E2, B> =\n  ap as any\n\n/**\n * @category constructors\n * @since 2.8.5\n */\nexport const of: <E = never, A = never>(a: A) => IOEither<E, A> = right\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B>\n  <E1, A, E2, B>(ma: IOEither<E1, A>, f: (a: A) => IOEither<E2, B>): IOEither<E1 | E2, B>\n} = /*#__PURE__*/ dual(2, ET.flatMap(I.Monad))\n\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport const flattenW: <E1, E2, A>(mma: IOEither<E1, IOEither<E2, A>>) => IOEither<E1 | E2, A> =\n  /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <E, A>(mma: IOEither<E, IOEither<E, A>>) => IOEither<E, A> = flattenW\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const alt: <E, A>(that: LazyArg<IOEither<E, A>>) => (fa: IOEither<E, A>) => IOEither<E, A> =\n  /*#__PURE__*/ ET.alt(I.Monad)\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the error and the return types will be merged.\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW: <E2, B>(that: LazyArg<IOEither<E2, B>>) => <E1, A>(fa: IOEither<E1, A>) => IOEither<E2, A | B> =\n  alt as any\n\n/**\n * @since 2.7.0\n */\nexport const throwError: MonadThrow2<URI>['throwError'] = left\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'IOEither'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: IOEither<E, A>\n  }\n}\n\n/**\n * The default [`ApplicativePar`](#applicativepar) instance returns the first error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * See [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation).\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getApplicativeIOValidation<E>(S: Semigroup<E>): Applicative2C<URI, E> {\n  const ap = ap_(I.Apply, E.getApplicativeValidation(S))\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: (fab, fa) => pipe(fab, ap(fa)),\n    of\n  }\n}\n\n/**\n * The default [`Alt`](#alt) instance returns the last error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * See [`getAltValidation`](./Either.ts.html#getaltvalidation).\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getAltIOValidation<E>(S: Semigroup<E>): Alt2C<URI, E> {\n  const alt = ET.altValidation(I.Monad, S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    alt: (fa, that) => pipe(fa, alt(that))\n  }\n}\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const getCompactable = <E>(M: Monoid<E>): Compactable2C<URI, E> => {\n  const C = E.getCompactable(M)\n  return {\n    URI,\n    _E: undefined as any,\n    compact: compact_(I.Functor, C),\n    separate: separate_(I.Functor, C, E.Functor)\n  }\n}\n\n/**\n * @category filtering\n * @since 2.1.0\n */\nexport function getFilterable<E>(M: Monoid<E>): Filterable2C<URI, E> {\n  const F = E.getFilterable(M)\n  const C = getCompactable(M)\n\n  const filter = filter_(I.Functor, F)\n  const filterMap = filterMap_(I.Functor, F)\n  const partition = partition_(I.Functor, F)\n  const partitionMap = partitionMap_(I.Functor, F)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    compact: C.compact,\n    separate: C.separate,\n    filter: <A>(fa: IOEither<E, A>, predicate: Predicate<A>) => pipe(fa, filter(predicate)),\n    filterMap: (fa, f) => pipe(fa, filterMap(f)),\n    partition: <A>(fa: IOEither<E, A>, predicate: Predicate<A>) => pipe(fa, partition(predicate)),\n    partitionMap: (fa, f) => pipe(fa, partitionMap(f))\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the `Right` value of this `IOEither` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <E, _>(self: IOEither<E, _>) => IOEither<E, A>\n  <E, _, A>(self: IOEither<E, _>, a: A): IOEither<E, A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the `Right` value of this `IOEither` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <E, _>(self: IOEither<E, _>) => IOEither<E, void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed2<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor2<URI> = {\n  URI,\n  bimap: mapBoth,\n  mapLeft: mapError\n}\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplyPar: Apply2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(ApplyPar)\n\n/**\n * Less strict version of [`apFirst`](#apfirst).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apFirstW: <E2, B>(second: IOEither<E2, B>) => <E1, A>(first: IOEither<E1, A>) => IOEither<E1 | E2, A> =\n  apFirst as any\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(ApplyPar)\n\n/**\n * Less strict version of [`apSecond`](#apsecond).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apSecondW: <E2, B>(second: IOEither<E2, B>) => <E1, A>(first: IOEither<E1, A>) => IOEither<E1 | E2, B> =\n  apSecond as any\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.8.4\n */\nexport const ApplicativePar: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.8.4\n */\nexport const ApplicativeSeq: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromEither: FromEither2<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromIO: FromIO2<URI> = {\n  URI,\n  fromIO\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => IOEither<E2, _>): IOEither<E1 | E2, A>\n  <A, E2, _>(f: (a: A) => IOEither<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as IOE from 'fp-ts/IOEither'\n * import * as E from 'fp-ts/Either'\n *\n * const compute = (value: string) => pipe(\n *   IOE.of(value),\n *   IOE.tapEither(() => value.length > 0 ? E.right('ok') : E.left('error')),\n * )\n *\n * assert.deepStrictEqual(compute('')(), E.left('error'))\n * assert.deepStrictEqual(compute('fp-ts')(), E.right('fp-ts'))\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapEither: {\n  <A, E2, _>(f: (a: A) => Either<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A>\n  <E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => Either<E2, _>): IOEither<E1 | E2, A>\n} = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as IOE from 'fp-ts/IOEither'\n * import * as E from 'fp-ts/Either'\n * import * as Console from 'fp-ts/Console'\n *\n * const sayHello = (value: string) => Console.log(`Hello, ${value}`)\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effectA = IOE.tapIO(IOE.of('fp-ts'), sayHello)\n *\n * // No output to the stdout\n * const effectB = pipe(IOE.left<string>('error'), IOE.tapIO(sayHello))\n *\n * assert.deepStrictEqual(effectA(), E.right('fp-ts'))\n * assert.deepStrictEqual(effectB(), E.left('error'))\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <E>(self: IOEither<E, A>) => IOEither<E, A>\n  <E, A, _>(self: IOEither<E, A>, f: (a: A) => IO<_>): IOEither<E, A>\n} = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt2<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const MonadIO: MonadIO2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  fromIO: fromIO\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const MonadThrow: MonadThrow2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  throwError\n}\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => I.IO<B>\n) => <E = never>(...a: A) => IOEither<E, B> = /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, A> = tapIO\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => IOEither<E, A> =\n  /*#__PURE__*/ fromOption_(FromEither)\n\n/**\n * Use `liftOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => IOEither<E, B> =\n  /*#__PURE__*/ fromOptionK_(FromEither)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => (ma: IOEither<E, A>) => IOEither<E, B> = /*#__PURE__*/ chainOptionK_(\n  FromEither,\n  Chain\n)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.13.2\n */\nexport const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B> = chainOptionK as any\n\n/** @internal */\ninterface IOEitherTypeLambda extends _.TypeLambda {\n  readonly type: IOEither<this['Out1'], this['Target']>\n}\n\n/** @internal */\nconst _FromEither: _.FromEither<IOEitherTypeLambda> = {\n  fromEither: FromEither.fromEither\n}\n\n/** @internal */\nconst _FromIO: _.FromIO<IOEitherTypeLambda> = {\n  fromIO\n}\n\n/**\n * @category lifting\n * @since 2.15.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) => IOEither<E, NonNullable<B>> = /*#__PURE__*/ _.liftNullable(_FromEither)\n\n/**\n * @category lifting\n * @since 2.15.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) => IOEither<E, B> = /*#__PURE__*/ _.liftOption(_FromEither)\n\n/** @internal */\nconst _FlatMap: _.FlatMap<IOEitherTypeLambda> = {\n  flatMap\n}\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapNullable: {\n  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <E1>(\n    self: IOEither<E1, A>\n  ) => IOEither<E2 | E1, NonNullable<B>>\n  <E1, A, B, E2>(self: IOEither<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): IOEither<\n    E1 | E2,\n    NonNullable<B>\n  >\n} = /*#__PURE__*/ _.flatMapNullable(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapOption: {\n  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, B>\n  <E1, A, B, E2>(self: IOEither<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): IOEither<E1 | E2, B>\n} = /*#__PURE__*/ _.flatMapOption(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapEither: {\n  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <E1>(self: IOEither<E1, A>) => IOEither<E1 | E2, B>\n  <E1, A, E2, B>(self: IOEither<E1, A>, f: (a: A) => E.Either<E2, B>): IOEither<E1 | E2, B>\n} = /*#__PURE__*/ _.flatMapEither(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <E>(self: IOEither<E, A>) => IOEither<E, B>\n  <E, A, B>(self: IOEither<E, A>, f: (a: A) => IO<B>): IOEither<E, B>\n} = /*#__PURE__*/ _.flatMapIO(_FromIO, _FlatMap)\n\n/**\n * Alias of `flatMapIO`.\n * @category legacy\n * @since 2.10.0\n */\nexport const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, B> = flatMapIO\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainEitherK: <E, A, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B> =\n  flatMapEither\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainEitherKW: <E2, A, B>(\n  f: (a: A) => Either<E2, B>\n) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B> = flatMapEither\n\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherK: <A, E, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A> =\n  tapEither\n\n/**\n * Alias of `tapEither`.\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A> = tapEither\n\n/**\n * @category lifting\n * @since 2.0.0\n */\nexport const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => IOEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => IOEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => IOEither<E, A>\n} = /*#__PURE__*/ fromPredicate_(FromEither)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: IOEither<E, B>) => IOEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, A>\n} = /*#__PURE__*/ filterOrElse_(FromEither, Chain)\n\n/**\n * Less strict version of [`filterOrElse`](#filterorelse).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category filtering\n * @since 2.9.0\n */\nexport const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(\n    ma: IOEither<E1, A>\n  ) => IOEither<E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>(\n    mb: IOEither<E1, B>\n  ) => IOEither<E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A>\n} = filterOrElse\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => E.Either<E, B>\n) => (...a: A) => IOEither<E, B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Make sure that a resource is cleaned up in the event of an exception (\\*). The release action is called regardless of\n * whether the body action throws (\\*) or returns.\n *\n * (\\*) i.e. returns a `Left`\n *\n * @since 2.0.0\n */\nexport const bracket = <E, A, B>(\n  acquire: IOEither<E, A>,\n  use: (a: A) => IOEither<E, B>,\n  release: (a: A, e: Either<E, B>) => IOEither<E, void>\n): IOEither<E, B> => bracketW(acquire, use, release)\n\n/**\n * Less strict version of [`bracket`](#bracket).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const bracketW: <E1, A, E2, B, E3>(\n  acquire: IOEither<E1, A>,\n  use: (a: A) => IOEither<E2, B>,\n  release: (a: A, e: E.Either<E2, B>) => IOEither<E3, void>\n) => IOEither<E1 | E2 | E3, B> = (acquire, use, release) =>\n  flatMap(acquire, (a) => I.flatMap(use(a), (e) => flatMap(release(a, e), () => I.of(e))))\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: IOEither<never, {}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const bindW: <N extends string, A, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => IOEither<E2, B>\n) => <E1>(fa: IOEither<E1, A>) => IOEither<E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  bind as any\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(ApplyPar)\n\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const apSW: <A, N extends string, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: IOEither<E2, B>\n) => <E1>(fa: IOEither<E1, A>) => IOEither<E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  apS as any\n\n/**\n * @since 2.11.0\n */\nexport const ApT: IOEither<never, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => IOEither<E, ReadonlyNonEmptyArray<B>> = (f) =>\n  flow(I.traverseReadonlyNonEmptyArrayWithIndex(f), I.map(E.traverseReadonlyNonEmptyArrayWithIndex(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n): ((as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndexSeq =\n  <A, E, B>(f: (index: number, a: A) => IOEither<E, B>) =>\n  (as: ReadonlyNonEmptyArray<A>): IOEither<E, ReadonlyNonEmptyArray<B>> =>\n  () => {\n    const e = f(0, _.head(as))()\n    if (_.isLeft(e)) {\n      return e\n    }\n    const out: NonEmptyArray<B> = [e.right]\n    for (let i = 1; i < as.length; i++) {\n      const e = f(i, as[i])()\n      if (_.isLeft(e)) {\n        return e\n      }\n      out.push(e.right)\n    }\n    return _.right(out)\n  }\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndexSeq = <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n): ((as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndexSeq(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <A, E, B>(\n  f: (a: A) => IOEither<E, B>\n): ((as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <E, A>(arr: ReadonlyArray<IOEither<E, A>>) => IOEither<E, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseSeqArrayWithIndex: <A, E, B>(\n  f: (index: number, a: A) => IOEither<E, B>\n) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>> = traverseReadonlyArrayWithIndexSeq\n\n/**\n * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseSeqArray = <A, E, B>(\n  f: (a: A) => IOEither<E, B>\n): ((as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndexSeq((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceSeqArray: <E, A>(arr: ReadonlyArray<IOEither<E, A>>) => IOEither<E, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseSeqArray(identity)\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`ApplicativePar`](#applicativepar) instead\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const Applicative: Applicative2<URI> = ApplicativePar\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B> = flatMap\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.0\n */\nexport const chainW: <E2, A, B>(f: (a: A) => IOEither<E2, B>) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B> =\n  flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A> = tap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.8.0\n */\nexport const chainFirstW: <E2, A, B>(\n  f: (a: A) => IOEither<E2, B>\n) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A> = tap\n\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const orElseFirst: <E, B>(onLeft: (e: E) => IOEither<E, B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A> =\n  tapError\n\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const orElseFirstW: <E1, E2, B>(\n  onLeft: (e: E1) => IOEither<E2, B>\n) => <A>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A> = tapError\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `IOE.Functor` instead of `IOE.ioEither`\n * (where `IOE` is from `import IOE from 'fp-ts/IOEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const ioEither: Monad2<URI> & Bifunctor2<URI> & Alt2<URI> & MonadIO2<URI> & MonadThrow2<URI> = {\n  URI,\n  bimap: mapBoth,\n  mapLeft: mapError,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  alt: _alt,\n  fromIO,\n  throwError\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<IOEither<E, A>> =\n  /*#__PURE__*/ getApplySemigroup_(ApplyPar)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<IOEither<E, A>> =\n  /*#__PURE__*/ getApplicativeMonoid(ApplicativePar)\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getSemigroup = <E, A>(S: Semigroup<A>): Semigroup<IOEither<E, A>> =>\n  getApplySemigroup_(I.Apply)(E.getSemigroup(S))\n\n/**\n * Use [`getApplicativeIOValidation`](#getapplicativeiovalidation) and [`getAltIOValidation`](#getaltiovalidation).\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getIOValidation<E>(\n  SE: Semigroup<E>\n): Monad2C<URI, E> & Bifunctor2<URI> & Alt2C<URI, E> & MonadIO2C<URI, E> & MonadThrow2C<URI, E> {\n  const applicativeIOValidation = getApplicativeIOValidation(SE)\n  const altIOValidation = getAltIOValidation(SE)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: applicativeIOValidation.ap,\n    of,\n    chain: flatMap,\n    bimap: mapBoth,\n    mapLeft: mapError,\n    alt: altIOValidation.alt,\n    fromIO,\n    throwError\n  }\n}\n"
  },
  {
    "path": "src/IOOption.ts",
    "content": "/**\n * `IOOption<A>` represents a synchronous computation that either yields a value of type `A` or nothing.\n *\n * If you want to represent a synchronous computation that never fails, please see `IO`.\n * If you want to represent a synchronous computation that may fail, please see `IOEither`.\n *\n * @since 2.12.0\n */\nimport { Alt1 } from './Alt'\nimport { Alternative1 } from './Alternative'\nimport { Applicative1 } from './Applicative'\nimport { apFirst as apFirst_, Apply1, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport * as chainable from './Chain'\nimport { compact as compact_, Compactable1, separate as separate_ } from './Compactable'\nimport { Either } from './Either'\nimport {\n  filter as filter_,\n  Filterable1,\n  filterMap as filterMap_,\n  partition as partition_,\n  partitionMap as partitionMap_\n} from './Filterable'\nimport { FromEither1, fromEitherK as fromEitherK_, tapEither as tapEither_ } from './FromEither'\nimport { FromIO1, fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO'\nimport { dual, flow, identity, LazyArg, pipe, SK } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport * as I from './IO'\nimport { IOEither } from './IOEither'\nimport { Monad1 } from './Monad'\nimport { MonadIO1 } from './MonadIO'\nimport * as O from './Option'\nimport * as OT from './OptionT'\nimport { Pointed1 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Separated } from './Separated'\nimport { guard as guard_, Zero1 } from './Zero'\n\nimport IO = I.IO\nimport Option = O.Option\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.12.0\n */\nexport interface IOOption<A> extends IO<Option<A>> {}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.12.0\n */\nexport const some: <A>(a: A) => IOOption<A> = /*#__PURE__*/ OT.some(I.Pointed)\n\n/**\n * @category lifting\n * @since 2.12.0\n */\nexport const fromPredicate: {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => IOOption<B>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => IOOption<B>\n  <A>(predicate: Predicate<A>): (a: A) => IOOption<A>\n} = /*#__PURE__*/ OT.fromPredicate(I.Pointed)\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport const fromOption: <A>(fa: Option<A>) => IOOption<A> = I.of\n\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport const fromEither: <A>(fa: Either<unknown, A>) => IOOption<A> = /*#__PURE__*/ OT.fromEither(I.Pointed)\n\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport const fromIO: <A>(fa: IO<A>) => IOOption<A> = /*#__PURE__*/ OT.fromF(I.Functor)\n\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport const fromIOEither: <A>(fa: IOEither<unknown, A>) => IOOption<A> = /*#__PURE__*/ I.map(O.fromEither)\n\n/**\n * @category pattern matching\n * @since 2.12.0\n */\nexport const match: <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: IOOption<A>) => IO<B> = /*#__PURE__*/ OT.match(\n  I.Functor\n)\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.12.0\n */\nexport const matchW: <B, A, C>(onNone: () => B, onSome: (a: A) => C) => (ma: IOOption<A>) => IO<B | C> = match as any\n\n/**\n * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`IO`).\n *\n * @category pattern matching\n * @since 2.12.0\n */\nexport const matchE: <B, A>(onNone: () => IO<B>, onSome: (a: A) => IO<B>) => (ma: IOOption<A>) => IO<B> =\n  /*#__PURE__*/ OT.matchE(I.Chain)\n\n/**\n * Alias of [`matchE`](#matche).\n *\n * @category pattern matching\n * @since 2.12.0\n */\nexport const fold = matchE\n\n/**\n * Less strict version of [`matchE`](#matche).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.12.0\n */\nexport const matchEW: <B, C, A>(onNone: () => IO<B>, onSome: (a: A) => IO<C>) => (ma: IOOption<A>) => IO<B | C> =\n  matchE as any\n\n/**\n * @category error handling\n * @since 2.12.0\n */\nexport const getOrElse: <A>(onNone: LazyArg<IO<A>>) => (fa: IOOption<A>) => IO<A> = /*#__PURE__*/ OT.getOrElse(I.Monad)\n\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.12.0\n */\nexport const getOrElseW: <B>(onNone: LazyArg<IO<B>>) => <A>(ma: IOOption<A>) => IO<A | B> = getOrElse as any\n\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport const toUndefined: <A>(ma: IOOption<A>) => IO<A | undefined> = I.map(O.toUndefined)\n\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport const toNullable: <A>(ma: IOOption<A>) => IO<A | null> = I.map(O.toNullable)\n\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport const fromNullable: <A>(a: A) => IOOption<NonNullable<A>> = /*#__PURE__*/ OT.fromNullable(I.Pointed)\n\n/**\n * @category lifting\n * @since 2.12.0\n */\nexport const fromNullableK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => IOOption<NonNullable<B>> = /*#__PURE__*/ OT.fromNullableK(I.Pointed)\n\n/**\n * Alias of `flatMapNullable`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainNullableK: <A, B>(\n  f: (a: A) => B | null | undefined\n) => (ma: IOOption<A>) => IOOption<NonNullable<B>> = /*#__PURE__*/ OT.chainNullableK(I.Monad)\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @category lifting\n * @since 2.12.0\n */\nexport const fromOptionK: <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => IOOption<B> =\n  /*#__PURE__*/ OT.fromOptionK(I.Pointed)\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.12.0\n */\nexport const map: <A, B>(f: (a: A) => B) => (fa: IOOption<A>) => IOOption<B> = /*#__PURE__*/ OT.map(I.Functor)\n\n/**\n * @since 2.12.0\n */\nexport const ap: <A>(fa: IOOption<A>) => <B>(fab: IOOption<(a: A) => B>) => IOOption<B> = /*#__PURE__*/ OT.ap(I.Apply)\n\n/**\n * @category constructors\n * @since 2.12.0\n */\nexport const of: <A>(a: A) => IOOption<A> = some\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A) => IOOption<B>): (ma: IOOption<A>) => IOOption<B>\n  <A, B>(ma: IOOption<A>, f: (a: A) => IOOption<B>): IOOption<B>\n} = /*#__PURE__*/ dual(2, OT.flatMap(I.Monad))\n\n/**\n * @category sequencing\n * @since 2.12.0\n */\nexport const flatten: <A>(mma: IOOption<IOOption<A>>) => IOOption<A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category error handling\n * @since 2.12.0\n */\nexport const alt: <A>(second: LazyArg<IOOption<A>>) => (first: IOOption<A>) => IOOption<A> = /*#__PURE__*/ OT.alt(\n  I.Monad\n)\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category error handling\n * @since 2.12.0\n */\nexport const altW: <B>(second: LazyArg<IOOption<B>>) => <A>(first: IOOption<A>) => IOOption<A | B> = alt as any\n\n/**\n * @since 2.12.0\n */\nexport const zero: <A>() => IOOption<A> = /*#__PURE__*/ OT.zero(I.Pointed)\n\n/**\n * @category constructors\n * @since 2.12.0\n */\nexport const none: IOOption<never> = /*#__PURE__*/ zero()\n\n/**\n * @category filtering\n * @since 2.12.0\n */\nexport const compact: Compactable1<URI>['compact'] = /*#__PURE__*/ compact_(I.Functor, O.Compactable)\n\n/**\n * @category filtering\n * @since 2.12.0\n */\nexport const separate: Compactable1<URI>['separate'] = /*#__PURE__*/ separate_(I.Functor, O.Compactable, O.Functor)\n\n/**\n * @category filtering\n * @since 2.12.0\n */\nexport const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fb: IOOption<A>) => IOOption<B>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: IOOption<B>) => IOOption<B>\n  <A>(predicate: Predicate<A>): (fa: IOOption<A>) => IOOption<A>\n} = /*#__PURE__*/ filter_(I.Functor, O.Filterable)\n\n/**\n * @category filtering\n * @since 2.12.0\n */\nexport const filterMap: <A, B>(f: (a: A) => Option<B>) => (fga: IOOption<A>) => IOOption<B> = /*#__PURE__*/ filterMap_(\n  I.Functor,\n  O.Filterable\n)\n\n/**\n * @category filtering\n * @since 2.12.0\n */\nexport const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fb: IOOption<A>) => Separated<IOOption<A>, IOOption<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: IOOption<B>) => Separated<IOOption<B>, IOOption<B>>\n  <A>(predicate: Predicate<A>): (fa: IOOption<A>) => Separated<IOOption<A>, IOOption<A>>\n} = /*#__PURE__*/ partition_(I.Functor, O.Filterable)\n\n/**\n * @category filtering\n * @since 2.12.0\n */\nexport const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: IOOption<A>) => Separated<IOOption<B>, IOOption<C>> = /*#__PURE__*/ partitionMap_(I.Functor, O.Filterable)\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\nconst _map: Functor1<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _ap: Apply1<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n/* istanbul ignore next */\nconst _alt: Alt1<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n/* istanbul ignore next */\nconst _filter: Filterable1<URI>['filter'] = <A>(fa: IOOption<A>, predicate: Predicate<A>) => pipe(fa, filter(predicate))\n/* istanbul ignore next */\nconst _filterMap: Filterable1<URI>['filterMap'] = (fa, f) => pipe(fa, filterMap(f))\n/* istanbul ignore next */\nconst _partition: Filterable1<URI>['partition'] = <A>(fa: IOOption<A>, predicate: Predicate<A>) =>\n  pipe(fa, partition(predicate))\n/* istanbul ignore next */\nconst _partitionMap: Filterable1<URI>['partitionMap'] = (fa, f) => pipe(fa, partitionMap(f))\n\n/**\n * @category type lambdas\n * @since 2.12.0\n */\nexport const URI = 'IOOption'\n\n/**\n * @category type lambdas\n * @since 2.12.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: IOOption<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the `Some` value of this `IOOption` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <_>(self: IOOption<_>) => IOOption<A>\n  <_, A>(self: IOOption<_>, a: A): IOOption<A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the `Some` value of this `IOOption` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <_>(self: IOOption<_>) => IOOption<void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.12.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Apply: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.12.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.12.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Applicative: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Chain: chainable.Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const FromEither: FromEither1<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const FromIO: FromIO1<URI> = {\n  URI,\n  fromIO\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <A, _>(self: IOOption<A>, f: (a: A) => IOOption<_>): IOOption<A>\n  <A, _>(f: (a: A) => IOOption<_>): (self: IOOption<A>) => IOOption<A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as IOO from 'fp-ts/IOOption'\n * import * as O from 'fp-ts/Option'\n * import * as E from 'fp-ts/Either'\n *\n * const compute = (value: number) => pipe(\n *   IOO.of(value),\n *   IOO.tapEither((value) => value > 0 ? E.right('ok') : E.left('error')),\n * )\n *\n * assert.deepStrictEqual(compute(1)(), O.of(1))\n * assert.deepStrictEqual(compute(-1)(), O.none)\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapEither: {\n  <A, E, _>(f: (a: A) => Either<E, _>): (self: IOOption<A>) => IOOption<A>\n  <A, E, _>(self: IOOption<A>, f: (a: A) => Either<E, _>): IOOption<A>\n} = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as IOO from 'fp-ts/IOOption'\n * import * as O from 'fp-ts/Option'\n * import * as Console from 'fp-ts/Console'\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effectA = pipe(\n *   IOO.of('fp-ts'),\n *   IOO.tapIO((value) => Console.log(`Hello, ${value}`)),\n * )\n *\n * // No output to the stdout\n * const effectB = pipe(\n *   IOO.none as IOO.IOOption<string>,\n *   IOO.tapIO((value) => Console.log(`Hello, ${value}`)),\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(effectA(), O.of('fp-ts'))\n *   assert.deepStrictEqual(effectB(), O.none)\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): (self: IOOption<A>) => IOOption<A>\n  <A, _>(self: IOOption<A>, f: (a: A) => IO<_>): IOOption<A>\n} = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain))\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Alt: Alt1<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Zero: Zero1<URI> = {\n  URI,\n  zero\n}\n\n/**\n * @category do notation\n * @since 2.12.0\n */\nexport const guard = /*#__PURE__*/ guard_(Zero, Pointed)\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Alternative: Alternative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  alt: _alt,\n  zero\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const MonadIO: MonadIO1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Compactable: Compactable1<URI> = {\n  URI,\n  compact,\n  separate\n}\n\n/**\n * @category instances\n * @since 2.12.0\n */\nexport const Filterable: Filterable1<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n\n/** @internal */\ninterface IOOptionTypeLambda extends _.TypeLambda {\n  readonly type: IOOption<this['Target']>\n}\n\n/** @internal */\nconst _FlatMap: _.FlatMap<IOOptionTypeLambda> = {\n  flatMap\n}\n\n/** @internal */\nconst _FromIO: _.FromIO<IOOptionTypeLambda> = {\n  fromIO: FromIO.fromIO\n}\n\n/** @internal */\nconst _FromEither: _.FromEither<IOOptionTypeLambda> = {\n  fromEither\n}\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): (self: IOOption<A>) => IOOption<B>\n  <A, B>(self: IOOption<A>, f: (a: A) => IO<B>): IOOption<B>\n} = _.flatMapIO(_FromIO, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapOption: {\n  <A, B>(f: (a: A) => Option<B>): (self: IOOption<A>) => IOOption<B>\n  <A, B>(self: IOOption<A>, f: (a: A) => Option<B>): IOOption<B>\n} = /*#__PURE__*/ dual(\n  2,\n  <A, B>(self: IOOption<A>, f: (a: A) => Option<B>): IOOption<B> => flatMap(self, fromOptionK(f))\n)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapEither: {\n  <A, B, _>(f: (a: A) => Either<_, B>): (self: IOOption<A>) => IOOption<B>\n  <A, B, _>(self: IOOption<A>, f: (a: A) => Either<_, B>): IOOption<B>\n} = /*#__PURE__*/ _.flatMapEither(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapNullable: {\n  <A, B>(f: (a: A) => B | null | undefined): (self: IOOption<A>) => IOOption<B>\n  <A, B>(self: IOOption<A>, f: (a: A) => B | null | undefined): IOOption<B>\n} = /*#__PURE__*/ dual(\n  2,\n  <A, B>(self: IOOption<A>, f: (a: A) => B | null | undefined): IOOption<B> => flatMap(self, fromNullableK(f))\n)\n\n/**\n * @category lifting\n * @since 2.12.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => I.IO<B>) => (...a: A) => IOOption<B> =\n  /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => (first: IOOption<A>) => IOOption<B> = flatMapIO\n\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => (first: IOOption<A>) => IOOption<A> = tapIO\n\n/**\n * @category lifting\n * @since 2.12.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => IOOption<B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: IOOption<A>) => IOOption<B> = flatMapEither\n\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: IOOption<A>) => IOOption<A> = tapEither\n\n/**\n * Alias of `flatMapOption`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainOptionK: <A, B>(f: (a: A) => Option<B>) => (ma: IOOption<A>) => IOOption<B> = flatMapOption\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.12.0\n */\nexport const Do: IOOption<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.12.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.12.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * @category do notation\n * @since 2.12.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n/**\n * @since 2.12.0\n */\nexport const ApT: IOOption<readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.12.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex = <A, B>(\n  f: (index: number, a: A) => IOOption<B>\n): ((as: ReadonlyNonEmptyArray<A>) => IOOption<ReadonlyNonEmptyArray<B>>) =>\n  flow(I.traverseReadonlyNonEmptyArrayWithIndex(f), I.map(O.traverseReadonlyNonEmptyArrayWithIndex(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.12.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, B>(\n  f: (index: number, a: A) => IOOption<B>\n): ((as: ReadonlyArray<A>) => IOOption<ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chain: <A, B>(f: (a: A) => IOOption<B>) => (ma: IOOption<A>) => IOOption<B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => IOOption<B>) => (first: IOOption<A>) => IOOption<A> = tap\n"
  },
  {
    "path": "src/IORef.ts",
    "content": "/**\n * Mutable references in the `IO` monad\n *\n * @since 2.0.0\n */\nimport { IO } from './IO'\n\n/**\n * @example\n * import { flatMap } from 'fp-ts/IO'\n * import { newIORef } from 'fp-ts/IORef'\n *\n * assert.strictEqual(flatMap(newIORef(1), ref => flatMap(ref.write(2), () => ref.read))(), 2)\n *\n * @category model\n * @since 2.0.0\n */\nexport class IORef<A> {\n  /**\n   * @since 2.0.0\n   */\n  readonly read: IO<A>\n  constructor(private value: A) {\n    this.read = () => this.value\n    this.write = this.write.bind(this)\n    this.modify = this.modify.bind(this)\n  }\n  /**\n   * @since 2.0.0\n   */\n  write(a: A): IO<void> {\n    return () => {\n      this.value = a\n    }\n  }\n  /**\n   * @since 2.0.0\n   */\n  modify(f: (a: A) => A): IO<void> {\n    return () => {\n      this.value = f(this.value)\n    }\n  }\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function newIORef<A>(a: A): IO<IORef<A>> {\n  return () => new IORef(a)\n}\n"
  },
  {
    "path": "src/Identity.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Alt1 } from './Alt'\nimport { Applicative as ApplicativeHKT, Applicative1 } from './Applicative'\nimport { apFirst as apFirst_, Apply1, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport { bind as bind_, Chain1, tap as tap_ } from './Chain'\nimport { ChainRec1, tailRec } from './ChainRec'\nimport { Comonad1 } from './Comonad'\nimport { Eq } from './Eq'\nimport { Extend1 } from './Extend'\nimport { Foldable1 } from './Foldable'\nimport { dual, identity as id, pipe } from './function'\nimport { bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport { HKT } from './HKT'\nimport * as _ from './internal'\nimport { Monad1 } from './Monad'\nimport { Monoid } from './Monoid'\nimport { Pointed1 } from './Pointed'\nimport { Show } from './Show'\nimport { PipeableTraverse1, Traversable1 } from './Traversable'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport type Identity<A> = A\n\nconst _map: Monad1<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _ap: Monad1<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n/* istanbul ignore next */\nconst _reduce: Foldable1<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\n/* istanbul ignore next */\nconst _foldMap: Foldable1<URI>['foldMap'] = (M) => (fa, f) => pipe(fa, foldMap(M)(f))\n/* istanbul ignore next */\nconst _reduceRight: Foldable1<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\n/* istanbul ignore next */\nconst _alt: Alt1<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n/* istanbul ignore next */\nconst _extend: Extend1<URI>['extend'] = (wa, f) => pipe(wa, extend(f))\n/* istanbul ignore next */\nconst _traverse = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: Identity<A>, f: (a: A) => HKT<F, B>) => HKT<F, Identity<B>>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\nconst _chainRec: ChainRec1<URI>['chainRec'] = tailRec\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => (fa: Identity<A>) => Identity<B> = (f) => (fa) => f(fa)\n\n/**\n * @since 2.0.0\n */\nexport const ap: <A>(fa: Identity<A>) => <B>(fab: Identity<(a: A) => B>) => Identity<B> = (fa) => (fab) => fab(fa)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const of: <A>(a: A) => Identity<A> = id\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A) => Identity<B>): (ma: Identity<A>) => Identity<B>\n  <A, B>(ma: Identity<A>, f: (a: A) => Identity<B>): Identity<B>\n} = /*#__PURE__*/ dual(2, <A, B>(ma: Identity<A>, f: (a: A) => Identity<B>): Identity<B> => f(ma))\n\n/**\n * @since 2.0.0\n */\nexport const extend: <A, B>(f: (wa: Identity<A>) => B) => (wa: Identity<A>) => Identity<B> = (f) => (wa) => f(wa)\n\n/**\n * @category Extract\n * @since 2.6.2\n */\nexport const extract: <A>(wa: Identity<A>) => A = id\n\n/**\n * @since 2.0.0\n */\nexport const duplicate: <A>(ma: Identity<A>) => Identity<Identity<A>> = /*#__PURE__*/ extend(id)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <A>(mma: Identity<Identity<A>>) => Identity<A> = /*#__PURE__*/ flatMap(id)\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Identity<A>) => B = (b, f) => (fa) => f(b, fa)\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Identity<A>) => M = () => (f) => (fa) => f(fa)\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Identity<A>) => B = (b, f) => (fa) => f(fa, b)\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse1<URI> =\n  <F>(F: ApplicativeHKT<F>): (<A, B>(f: (a: A) => HKT<F, B>) => (ta: Identity<A>) => HKT<F, Identity<B>>) =>\n  (f) =>\n  (ta) =>\n    F.map(f(ta), id)\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable1<URI>['sequence'] =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A>(ta: Identity<HKT<F, A>>): HKT<F, Identity<A>> => {\n    return F.map(ta, id)\n  }\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW: <B>(that: () => Identity<B>) => <A>(fa: Identity<A>) => Identity<A | B> = () => id\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const alt: <A>(that: () => Identity<A>) => (fa: Identity<A>) => Identity<A> = altW\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Identity'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Identity<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getShow: <A>(S: Show<A>) => Show<Identity<A>> = id\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getEq: <A>(E: Eq<A>) => Eq<Identity<A>> = id\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.7\n */\nexport const tap: {\n  <A, _>(self: Identity<A>, f: (a: A) => Identity<_>): Identity<A>\n  <A, _>(f: (a: A) => Identity<_>): (self: Identity<A>) => Identity<A>\n} = /*#__PURE__*/ dual(2, tap_(Chain))\n\n/**\n * Alias of `tap`\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => B) => (first: A) => A = tap\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable1<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable1<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt1<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Comonad: Comonad1<URI> = {\n  URI,\n  map: _map,\n  extend: _extend,\n  extract\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const ChainRec: ChainRec1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap,\n  chainRec: _chainRec\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: Identity<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ bind_(Chain)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <A, B>(f: (a: A) => Identity<B>) => (ma: Identity<A>) => Identity<B> = flatMap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `I.Functor` instead of `I.identity`\n * (where `I` is from `import I from 'fp-ts/Identity'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const identity: Monad1<URI> & Foldable1<URI> & Traversable1<URI> & Alt1<URI> & Comonad1<URI> & ChainRec1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  alt: _alt,\n  extract,\n  extend: _extend,\n  chainRec: _chainRec\n}\n"
  },
  {
    "path": "src/Invariant.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Invariant<F> {\n  readonly URI: F\n  readonly imap: <A, B>(fa: HKT<F, A>, f: (a: A) => B, g: (b: B) => A) => HKT<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Invariant1<F extends URIS> {\n  readonly URI: F\n  readonly imap: <A, B>(fa: Kind<F, A>, f: (a: A) => B, g: (b: B) => A) => Kind<F, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Invariant2<F extends URIS2> {\n  readonly URI: F\n  readonly imap: <E, A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Invariant2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly imap: <A, B>(fa: Kind2<F, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind2<F, E, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Invariant3<F extends URIS3> {\n  readonly URI: F\n  readonly imap: <R, E, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.4.2\n */\nexport interface Invariant3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly imap: <R, A, B>(fa: Kind3<F, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind3<F, R, E, B>\n}\n\n/**\n * @category model\n * @since 2.4.2\n */\nexport interface Invariant4<F extends URIS4> {\n  readonly URI: F\n  readonly imap: <S, R, E, A, B>(fa: Kind4<F, S, R, E, A>, f: (a: A) => B, g: (b: B) => A) => Kind4<F, S, R, E, B>\n}\n"
  },
  {
    "path": "src/JoinSemilattice.ts",
    "content": "/**\n * A join-semilattice (or upper semilattice) is a semilattice whose operation is called `join`, and which can be thought\n * of as a least upper bound.\n *\n * A `JoinSemilattice` must satisfy the following laws:\n *\n * - Associativity: `a ∨ (b ∨ c) <-> (a ∨ b) ∨ c`\n * - Commutativity: `a ∨ b <-> b ∨ a`\n * - Idempotency:   `a ∨ a <-> a`\n *\n * @since 2.0.0\n */\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface JoinSemilattice<A> {\n  readonly join: (x: A, y: A) => A\n}\n"
  },
  {
    "path": "src/Json.ts",
    "content": "/**\n * @since 2.10.0\n */\nimport { Either, tryCatch } from './Either'\nimport { identity } from './function'\n\n/**\n * @since 2.10.0\n */\nexport type Json = boolean | number | string | null | JsonArray | JsonRecord\n\n/**\n * @since 2.10.0\n */\nexport interface JsonRecord {\n  readonly [key: string]: Json\n}\n\n/**\n * @since 2.10.0\n */\nexport interface JsonArray extends ReadonlyArray<Json> {}\n\n/**\n * Converts a JavaScript Object Notation (JSON) string into a `Json` type.\n *\n * @example\n * import * as J from 'fp-ts/Json'\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('{\"a\":1}', J.parse), E.right({ a: 1 }))\n * assert.deepStrictEqual(pipe('{\"a\":}', J.parse), E.left(new SyntaxError(`Unexpected token '}', \"{\"a\":}\" is not valid JSON`)))\n *\n * @since 2.10.0\n */\nexport const parse = (s: string): Either<unknown, Json> => tryCatch(() => JSON.parse(s), identity)\n\n/**\n * Converts a JavaScript value to a JavaScript Object Notation (JSON) string.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import * as J from 'fp-ts/Json'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(J.stringify({ a: 1 }), E.right('{\"a\":1}'))\n * const circular: any = { ref: null }\n * circular.ref = circular\n * assert.deepStrictEqual(\n *   pipe(\n *     J.stringify(circular),\n *     E.mapLeft(e => e instanceof Error && e.message.includes('Converting circular structure to JSON'))\n *   ),\n *   E.left(true)\n * )\n *\n *  @since 2.10.0\n */\nexport const stringify = <A>(a: A): Either<unknown, string> =>\n  tryCatch(() => {\n    const s = JSON.stringify(a)\n    if (typeof s !== 'string') {\n      throw new Error('Converting unsupported structure to JSON')\n    }\n    return s\n  }, identity)\n"
  },
  {
    "path": "src/Lattice.ts",
    "content": "/**\n * A `Lattice` must satisfy the following in addition to `JoinSemilattice` and `MeetSemilattice` laws:\n *\n * - Absorbtion law for meet: `a ∧ (a ∨ b) <-> a`\n * - Absorbtion law for join: `a ∨ (a ∧ b) <-> a`\n *\n * @since 2.0.0\n */\nimport { JoinSemilattice } from './JoinSemilattice'\nimport { MeetSemilattice } from './MeetSemilattice'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Lattice<A> extends JoinSemilattice<A>, MeetSemilattice<A> {}\n"
  },
  {
    "path": "src/Magma.ts",
    "content": "/**\n * A `Magma` is a pair `(A, concat)` in which `A` is a non-empty set and `concat` is a binary operation on `A`\n *\n * See [Semigroup](https://gcanti.github.io/fp-ts/modules/Semigroup.ts.html) for some instances.\n *\n * @since 2.0.0\n */\n\nimport { Endomorphism } from './Endomorphism'\nimport { Predicate } from './Predicate'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Magma<A> {\n  readonly concat: (x: A, y: A) => A\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * The dual of a `Magma`, obtained by swapping the arguments of `concat`.\n *\n * @example\n * import { reverse, concatAll } from 'fp-ts/Magma'\n * import * as N from 'fp-ts/number'\n *\n * const subAll = concatAll(reverse(N.MagmaSub))(0)\n *\n * assert.deepStrictEqual(subAll([1, 2, 3]), 2)\n *\n * @since 2.11.0\n */\nexport const reverse = <A>(M: Magma<A>): Magma<A> => ({\n  concat: (first, second) => M.concat(second, first)\n})\n\n/**\n * @since 2.11.0\n */\nexport const filterFirst =\n  <A>(predicate: Predicate<A>) =>\n  (M: Magma<A>): Magma<A> => ({\n    concat: (first, second) => (predicate(first) ? M.concat(first, second) : second)\n  })\n\n/**\n * @since 2.11.0\n */\nexport const filterSecond =\n  <A>(predicate: Predicate<A>) =>\n  (M: Magma<A>): Magma<A> => ({\n    concat: (first, second) => (predicate(second) ? M.concat(first, second) : first)\n  })\n\n/**\n * @since 2.11.0\n */\nexport const endo =\n  <A>(f: Endomorphism<A>) =>\n  (M: Magma<A>): Magma<A> => ({\n    concat: (first, second) => M.concat(f(first), f(second))\n  })\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Given a sequence of `as`, concat them and return the total.\n *\n * If `as` is empty, return the provided `startWith` value.\n *\n * @example\n * import { concatAll } from 'fp-ts/Magma'\n * import * as N from 'fp-ts/number'\n *\n * const subAll = concatAll(N.MagmaSub)(0)\n *\n * assert.deepStrictEqual(subAll([1, 2, 3]), -6)\n *\n * @since 2.11.0\n */\nexport const concatAll =\n  <A>(M: Magma<A>) =>\n  (startWith: A) =>\n  (as: ReadonlyArray<A>): A =>\n    as.reduce((a, acc) => M.concat(a, acc), startWith)\n"
  },
  {
    "path": "src/Map.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Applicative } from './Applicative'\nimport { Compactable2 } from './Compactable'\nimport { Either } from './Either'\nimport { Eq } from './Eq'\nimport { Filterable2 } from './Filterable'\nimport { FilterableWithIndex2C } from './FilterableWithIndex'\nimport { Foldable, Foldable1, Foldable2, Foldable2C, Foldable3 } from './Foldable'\nimport { FoldableWithIndex2C } from './FoldableWithIndex'\nimport { pipe } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'\nimport * as _ from './internal'\nimport { Magma } from './Magma'\nimport { Monoid } from './Monoid'\nimport * as O from './Option'\nimport { Ord } from './Ord'\nimport { Predicate } from './Predicate'\nimport * as RM from './ReadonlyMap'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport { Separated, separated } from './Separated'\nimport { Show } from './Show'\nimport { TraversableWithIndex2C } from './TraversableWithIndex'\nimport { Unfoldable, Unfoldable1 } from './Unfoldable'\nimport { wiltDefault, Witherable2C, witherDefault } from './Witherable'\n\nimport Option = O.Option\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getShow: <K, A>(SK: Show<K>, SA: Show<A>) => Show<Map<K, A>> = RM.getShow\n\n/**\n * Calculate the number of key/value pairs in a map\n *\n * @since 2.0.0\n */\nexport const size: <K, A>(m: Map<K, A>) => number = RM.size\n\n/**\n * Test whether or not a map is empty\n *\n * @since 2.0.0\n */\nexport const isEmpty: <K, A>(m: Map<K, A>) => boolean = RM.isEmpty\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test whether or not a key exists in a map\n *\n * @since 2.0.0\n */\nexport const member: <K>(E: Eq<K>) => {\n  (k: K): <A>(m: Map<K, A>) => boolean\n  <A>(k: K, m: Map<K, A>): boolean\n} = RM.member\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test whether or not a value is a member of a map\n *\n * @since 2.0.0\n */\nexport const elem: <A>(E: Eq<A>) => {\n  (a: A): <K>(m: Map<K, A>) => boolean\n  <K>(a: A, m: Map<K, A>): boolean\n} = RM.elem\n\n/**\n * Get a sorted `Array` of the keys contained in a `Map`.\n *\n * @since 2.0.0\n */\nexport const keys =\n  <K>(O: Ord<K>) =>\n  <A>(m: Map<K, A>): Array<K> =>\n    Array.from(m.keys()).sort(O.compare)\n\n/**\n * Get a sorted `Array` of the values contained in a `Map`.\n *\n * @since 2.0.0\n */\nexport const values =\n  <A>(O: Ord<A>) =>\n  <K>(m: Map<K, A>): Array<A> =>\n    Array.from(m.values()).sort(O.compare)\n\n/**\n * @since 2.0.0\n */\nexport function collect<K>(O: Ord<K>): <A, B>(f: (k: K, a: A) => B) => (m: Map<K, A>) => Array<B> {\n  const keysO = keys(O)\n  return <A, B>(f: (k: K, a: A) => B) =>\n    (m: Map<K, A>): Array<B> => {\n      const out: Array<B> = []\n      const ks = keysO(m)\n      for (const key of ks) {\n        out.push(f(key, m.get(key)!))\n      }\n      return out\n    }\n}\n\n/**\n * Get a sorted `Array` of the key/value pairs contained in a `Map`.\n *\n * @since 2.0.0\n */\nexport function toArray<K>(O: Ord<K>): <A>(m: Map<K, A>) => Array<[K, A]> {\n  return collect(O)((k, a) => [k, a])\n}\n\n/**\n * Unfolds a map into a list of key/value pairs\n *\n * @since 2.0.0\n */\nexport function toUnfoldable<K, F extends URIS>(ord: Ord<K>, U: Unfoldable1<F>): <A>(d: Map<K, A>) => Kind<F, [K, A]>\nexport function toUnfoldable<K, F>(ord: Ord<K>, U: Unfoldable<F>): <A>(d: Map<K, A>) => HKT<F, [K, A]>\nexport function toUnfoldable<K, F>(ord: Ord<K>, U: Unfoldable<F>): <A>(d: Map<K, A>) => HKT<F, [K, A]> {\n  const toArrayO = toArray(ord)\n  return (d) => {\n    const kas = toArrayO(d)\n    const len = kas.length\n    return U.unfold(0, (b) => (b < len ? _.some([kas[b], b + 1]) : _.none))\n  }\n}\n\n/**\n * Insert or replace a key/value pair in a `Map`.\n *\n * @since 2.0.0\n */\nexport const upsertAt = <K>(E: Eq<K>): (<A>(k: K, a: A) => (m: Map<K, A>) => Map<K, A>) => {\n  const lookupWithKeyE = lookupWithKey(E)\n  return (k, a) => {\n    const lookupWithKeyEk = lookupWithKeyE(k)\n    return (m) => {\n      const found = lookupWithKeyEk(m)\n      if (_.isNone(found)) {\n        const out = new Map(m)\n        out.set(k, a)\n        return out\n      } else if (found.value[1] !== a) {\n        const out = new Map(m)\n        out.set(found.value[0], a)\n        return out\n      }\n      return m\n    }\n  }\n}\n\n/**\n * Delete a key and value from a map\n *\n * @since 2.0.0\n */\nexport const deleteAt = <K>(E: Eq<K>): ((k: K) => <A>(m: Map<K, A>) => Map<K, A>) => {\n  const lookupWithKeyE = lookupWithKey(E)\n  return (k) => (m) => {\n    const found = lookupWithKeyE(k, m)\n    if (_.isSome(found)) {\n      const r = new Map(m)\n      r.delete(found.value[0])\n      return r\n    }\n    return m\n  }\n}\n\n/**\n * @since 2.0.0\n */\nexport const updateAt = <K>(E: Eq<K>): (<A>(k: K, a: A) => (m: Map<K, A>) => Option<Map<K, A>>) => {\n  const modifyAtE = modifyAt(E)\n  return (k, a) => modifyAtE(k, () => a)\n}\n\n/**\n * @since 2.0.0\n */\nexport const modifyAt = <K>(E: Eq<K>): (<A>(k: K, f: (a: A) => A) => (m: Map<K, A>) => Option<Map<K, A>>) => {\n  const lookupWithKeyE = lookupWithKey(E)\n  return (k, f) => (m) => {\n    const found = lookupWithKeyE(k, m)\n    if (_.isNone(found)) {\n      return _.none\n    }\n    const r = new Map(m)\n    r.set(found.value[0], f(found.value[1]))\n    return _.some(r)\n  }\n}\n\n/**\n * Delete a key and value from a map, returning the value as well as the subsequent map\n *\n * @since 2.0.0\n */\nexport function pop<K>(E: Eq<K>): (k: K) => <A>(m: Map<K, A>) => Option<[A, Map<K, A>]> {\n  const lookupE = lookup(E)\n  const deleteAtE = deleteAt(E)\n  return (k) => {\n    const deleteAtEk = deleteAtE(k)\n    return (m) =>\n      pipe(\n        lookupE(k, m),\n        O.map((a) => [a, deleteAtEk(m)])\n      )\n  }\n}\n\ntype Next<A> = IteratorResult<A, undefined>\n\n// TODO: remove non-curried overloading in v3\n/**\n * Lookup the value for a key in a `Map`.\n * If the result is a `Some`, the existing key is also returned.\n *\n * @since 2.0.0\n */\nexport function lookupWithKey<K>(E: Eq<K>): {\n  (k: K): <A>(m: Map<K, A>) => Option<[K, A]>\n  <A>(k: K, m: Map<K, A>): Option<[K, A]>\n}\nexport function lookupWithKey<K>(\n  E: Eq<K>\n): <A>(k: K, m?: Map<K, A>) => Option<[K, A]> | ((m: Map<K, A>) => Option<[K, A]>) {\n  return <A>(k: K, m?: Map<K, A>) => {\n    if (m === undefined) {\n      const lookupWithKeyE = lookupWithKey(E)\n      return (m) => lookupWithKeyE(k, m)\n    }\n    const entries = m.entries()\n    let e: Next<[K, A]>\n    while (!(e = entries.next()).done) {\n      const [ka, a] = e.value\n      if (E.equals(ka, k)) {\n        return _.some([ka, a])\n      }\n    }\n    return _.none\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Lookup the value for a key in a `Map`.\n *\n * @since 2.0.0\n */\nexport const lookup: <K>(E: Eq<K>) => {\n  (k: K): <A>(m: Map<K, A>) => Option<A>\n  <A>(k: K, m: Map<K, A>): Option<A>\n} = RM.lookup\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test whether or not one `Map` contains all of the keys and values contained in another `Map`\n *\n * @since 2.0.0\n */\nexport const isSubmap: <K, A>(\n  SK: Eq<K>,\n  SA: Eq<A>\n) => {\n  (that: Map<K, A>): (me: Map<K, A>) => boolean\n  (me: Map<K, A>, that: Map<K, A>): boolean\n} = RM.isSubmap\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getEq: <K, A>(SK: Eq<K>, SA: Eq<A>) => Eq<Map<K, A>> = RM.getEq\n\n/**\n * Gets `Monoid` instance for Maps given `Semigroup` instance for their values\n *\n * @category instances\n * @since 2.0.0\n */\nexport function getMonoid<K, A>(SK: Eq<K>, SA: Semigroup<A>): Monoid<Map<K, A>> {\n  const lookupWithKeyS = lookupWithKey(SK)\n  return {\n    concat: (mx, my) => {\n      if (isEmpty(mx)) {\n        return my\n      }\n      if (isEmpty(my)) {\n        return mx\n      }\n      const r = new Map(mx)\n      const entries = my.entries()\n      let e: Next<[K, A]>\n      while (!(e = entries.next()).done) {\n        const [k, a] = e.value\n        const mxOptA = lookupWithKeyS(k, mx)\n        if (_.isSome(mxOptA)) {\n          r.set(mxOptA.value[0], SA.concat(mxOptA.value[1], a))\n        } else {\n          r.set(k, a)\n        }\n      }\n      return r\n    },\n    empty: new Map()\n  }\n}\n\n/**\n * Create a map with one key/value pair\n *\n * @since 2.0.0\n */\nexport const singleton = <K, A>(k: K, a: A): Map<K, A> => new Map([[k, a]])\n\n/**\n * Create a map from a foldable collection of key/value pairs, using the\n * specified `Magma` to combine values for duplicate keys.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport function fromFoldable<F extends URIS3, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable3<F>\n): <R, E>(fka: Kind3<F, R, E, [K, A]>) => Map<K, A>\nexport function fromFoldable<F extends URIS2, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable2<F>\n): <E>(fka: Kind2<F, E, [K, A]>) => Map<K, A>\nexport function fromFoldable<F extends URIS, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable1<F>\n): (fka: Kind<F, [K, A]>) => Map<K, A>\nexport function fromFoldable<F, K, A>(E: Eq<K>, M: Magma<A>, F: Foldable<F>): (fka: HKT<F, [K, A]>) => Map<K, A>\nexport function fromFoldable<F, K, A>(E: Eq<K>, M: Magma<A>, F: Foldable<F>): (fka: HKT<F, [K, A]>) => Map<K, A> {\n  return (fka: HKT<F, [K, A]>) => {\n    const lookupWithKeyE = lookupWithKey(E)\n    return F.reduce<[K, A], Map<K, A>>(fka, new Map<K, A>(), (b, [k, a]) => {\n      const bOpt = lookupWithKeyE(k, b)\n      if (_.isSome(bOpt)) {\n        b.set(bOpt.value[0], M.concat(bOpt.value[1], a))\n      } else {\n        b.set(k, a)\n      }\n      return b\n    })\n  }\n}\n\nconst _mapWithIndex = <K, A, B>(fa: Map<K, A>, f: (k: K, a: A) => B): Map<K, B> => {\n  const m = new Map<K, B>()\n  const entries = fa.entries()\n  let e: Next<[K, A]>\n  while (!(e = entries.next()).done) {\n    const [key, a] = e.value\n    m.set(key, f(key, a))\n  }\n  return m\n}\n\n/**\n * @since 2.10.0\n */\nexport const partitionMapWithIndex =\n  <K, A, B, C>(f: (k: K, a: A) => Either<B, C>) =>\n  (fa: Map<K, A>): Separated<Map<K, B>, Map<K, C>> => {\n    const left = new Map<K, B>()\n    const right = new Map<K, C>()\n    const entries = fa.entries()\n    let e: Next<[K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      const ei = f(k, a)\n      if (_.isLeft(ei)) {\n        left.set(k, ei.left)\n      } else {\n        right.set(k, ei.right)\n      }\n    }\n    return separated(left, right)\n  }\n\n/**\n * @since 2.10.0\n */\nexport function partitionWithIndex<K, A, B extends A>(\n  predicateWithIndex: (k: K, a: A) => a is B\n): (fa: Map<K, A>) => Separated<Map<K, A>, Map<K, B>>\nexport function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): <B extends A>(fb: Map<K, B>) => Separated<Map<K, B>, Map<K, B>>\nexport function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): (fa: Map<K, A>) => Separated<Map<K, A>, Map<K, A>>\nexport function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): (fa: Map<K, A>) => Separated<Map<K, A>, Map<K, A>> {\n  return (fa: Map<K, A>) => {\n    const left = new Map<K, A>()\n    const right = new Map<K, A>()\n    const entries = fa.entries()\n    let e: Next<[K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      if (predicateWithIndex(k, a)) {\n        right.set(k, a)\n      } else {\n        left.set(k, a)\n      }\n    }\n    return separated(left, right)\n  }\n}\n\n/**\n * @since 2.10.0\n */\nexport const filterMapWithIndex =\n  <K, A, B>(f: (k: K, a: A) => Option<B>) =>\n  (fa: Map<K, A>): Map<K, B> => {\n    const m = new Map<K, B>()\n    const entries = fa.entries()\n    let e: Next<[K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      const o = f(k, a)\n      if (_.isSome(o)) {\n        m.set(k, o.value)\n      }\n    }\n    return m\n  }\n\n/**\n * @since 2.10.0\n */\nexport function filterWithIndex<K, A, B extends A>(p: (k: K, a: A) => a is B): (m: Map<K, A>) => Map<K, B>\nexport function filterWithIndex<K, A>(p: (k: K, a: A) => boolean): <B extends A>(m: Map<K, B>) => Map<K, B>\nexport function filterWithIndex<K, A>(p: (k: K, a: A) => boolean): (m: Map<K, A>) => Map<K, A>\nexport function filterWithIndex<K, A>(p: (k: K, a: A) => boolean): (m: Map<K, A>) => Map<K, A> {\n  return (m: Map<K, A>) => {\n    const out = new Map<K, A>()\n    const entries = m.entries()\n    let e: Next<[K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      if (p(k, a)) {\n        out.set(k, a)\n      }\n    }\n    return out\n  }\n}\n\nconst _map: Functor2<URI>['map'] = (fa, f) => _mapWithIndex(fa, (_, a) => f(a))\nconst _filter: Filterable2<URI>['filter'] = <K, A>(fa: Map<K, A>, p: Predicate<A>) =>\n  _filterWithIndex(fa, (_, a) => p(a))\nconst _filterMap: Filterable2<URI>['filterMap'] = (fa, f) => _filterMapWithIndex(fa, (_, a) => f(a))\nconst _partition: Filterable2<URI>['partition'] = <K, A>(fa: Map<K, A>, predicate: Predicate<A>) =>\n  _partitionWithIndex(fa, (_, a) => predicate(a))\nconst _partitionMap: Filterable2<URI>['partitionMap'] = (fa, f) => _partitionMapWithIndex(fa, (_, a) => f(a))\nconst _filterWithIndex = <K, A>(fa: Map<K, A>, p: (k: K, a: A) => boolean) => pipe(fa, filterWithIndex(p))\nconst _filterMapWithIndex = <K, A, B>(fa: Map<K, A>, f: (k: K, a: A) => Option<B>) => pipe(fa, filterMapWithIndex(f))\nconst _partitionWithIndex = <K, A>(fa: Map<K, A>, p: (k: K, a: A) => boolean) => pipe(fa, partitionWithIndex(p))\nconst _partitionMapWithIndex = <K, A, B, C>(fa: Map<K, A>, f: (k: K, a: A) => Either<B, C>) =>\n  pipe(fa, partitionMapWithIndex(f))\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const compact = <K, A>(fa: Map<K, Option<A>>): Map<K, A> => {\n  const m = new Map<K, A>()\n  const entries = fa.entries()\n  let e: Next<[K, Option<A>]>\n  while (!(e = entries.next()).done) {\n    const [k, oa] = e.value\n    if (_.isSome(oa)) {\n      m.set(k, oa.value)\n    }\n  }\n  return m\n}\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: Map<K, A>) => Map<K, B>\n  <A>(predicate: Predicate<A>): <K, B extends A>(fb: Map<K, B>) => Map<K, B>\n  <A>(predicate: Predicate<A>): <K>(fa: Map<K, A>) => Map<K, A>\n} =\n  <A>(predicate: Predicate<A>) =>\n  <K>(fa: Map<K, A>) =>\n    _filter(fa, predicate)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const filterMap: <A, B>(f: (a: A) => Option<B>) => <K>(fa: Map<K, A>) => Map<K, B> = (f) => (fa) =>\n  _filterMap(fa, f)\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <K>(fa: Map<K, A>) => Map<K, B> = (f) => (fa) => _map(fa, f)\n\n/**\n * @category mapping\n * @since 2.7.1\n */\nexport const mapWithIndex: <K, A, B>(f: (k: K, a: A) => B) => (fa: Map<K, A>) => Map<K, B> = (f) => (fa) =>\n  _mapWithIndex(fa, f)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: Map<K, A>) => Separated<Map<K, A>, Map<K, B>>\n  <A>(predicate: Predicate<A>): <K, B extends A>(fb: Map<K, B>) => Separated<Map<K, B>, Map<K, B>>\n  <A>(predicate: Predicate<A>): <K>(fa: Map<K, A>) => Separated<Map<K, A>, Map<K, A>>\n} =\n  <A>(predicate: Predicate<A>) =>\n  <K>(fa: Map<K, A>) =>\n    _partition(fa, predicate)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <K>(fa: Map<K, A>) => Separated<Map<K, B>, Map<K, C>> = (f) => (fa) => _partitionMap(fa, f)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const separate = <K, A, B>(fa: Map<K, Either<A, B>>): Separated<Map<K, A>, Map<K, B>> => {\n  const left = new Map<K, A>()\n  const right = new Map<K, B>()\n  const entries = fa.entries()\n  let e: Next<[K, Either<A, B>]>\n  while (!(e = entries.next()).done) {\n    const [k, ei] = e.value\n    if (_.isLeft(ei)) {\n      left.set(k, ei.left)\n    } else {\n      right.set(k, ei.right)\n    }\n  }\n  return separated(left, right)\n}\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Map'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: Map<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <K, A>(E: Eq<K>, S: Semigroup<A>): Semigroup<Map<K, A>> => {\n  const unionES = union(E, S)\n  return {\n    concat: (first, second) => unionES(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionMonoid = <K, A>(E: Eq<K>, S: Semigroup<A>): Monoid<Map<K, A>> => ({\n  concat: getUnionSemigroup(E, S).concat,\n  empty: new Map()\n})\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getIntersectionSemigroup = <K, A>(E: Eq<K>, S: Semigroup<A>): Semigroup<Map<K, A>> => {\n  const intersectionES = intersection(E, S)\n  return {\n    concat: (first, second) => intersectionES(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getDifferenceMagma =\n  <K>(E: Eq<K>) =>\n  <A>(): Magma<Map<K, A>> => {\n    const differenceE = difference(E)\n    return {\n      concat: (first, second) => differenceE(second)(first)\n    }\n  }\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport function getFilterableWithIndex<K = never>(): FilterableWithIndex2C<URI, K, K> {\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    mapWithIndex: _mapWithIndex,\n    compact,\n    separate,\n    filter: _filter,\n    filterMap: _filterMap,\n    partition: _partition,\n    partitionMap: _partitionMap,\n    partitionMapWithIndex: _partitionMapWithIndex,\n    partitionWithIndex: _partitionWithIndex,\n    filterMapWithIndex: _filterMapWithIndex,\n    filterWithIndex: _filterWithIndex\n  }\n}\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport function getWitherable<K>(O: Ord<K>): Witherable2C<URI, K> & TraversableWithIndex2C<URI, K, K> {\n  const TWI = getTraversableWithIndex(O)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    compact,\n    separate,\n    filter: _filter,\n    filterMap: _filterMap,\n    partition: _partition,\n    partitionMap: _partitionMap,\n    reduce: TWI.reduce,\n    foldMap: TWI.foldMap,\n    reduceRight: TWI.reduceRight,\n    traverse: TWI.traverse,\n    sequence: TWI.sequence,\n    mapWithIndex: _mapWithIndex,\n    reduceWithIndex: TWI.reduceWithIndex,\n    foldMapWithIndex: TWI.foldMapWithIndex,\n    reduceRightWithIndex: TWI.reduceRightWithIndex,\n    traverseWithIndex: TWI.traverseWithIndex,\n    wilt: wiltDefault(TWI, Compactable),\n    wither: witherDefault(TWI, Compactable)\n  }\n}\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduce: <K>(O: Ord<K>) => <B, A>(b: B, f: (b: B, a: A) => B) => (m: Map<K, A>) => B = RM.reduce\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const foldMap: <K>(O: Ord<K>) => <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (m: Map<K, A>) => M = RM.foldMap\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduceRight: <K>(O: Ord<K>) => <B, A>(b: B, f: (a: A, b: B) => B) => (m: Map<K, A>) => B = RM.reduceRight\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const getFoldable = <K>(O: Ord<K>): Foldable2C<URI, K> => {\n  return {\n    ...RM.getFoldable(O),\n    URI\n  }\n}\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduceWithIndex: <K>(O: Ord<K>) => <B, A>(b: B, f: (k: K, b: B, a: A) => B) => (m: Map<K, A>) => B =\n  RM.reduceWithIndex\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const foldMapWithIndex: <K>(O: Ord<K>) => <M>(M: Monoid<M>) => <A>(f: (k: K, a: A) => M) => (m: Map<K, A>) => M =\n  RM.foldMapWithIndex\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduceRightWithIndex: <K>(O: Ord<K>) => <B, A>(b: B, f: (k: K, a: A, b: B) => B) => (m: Map<K, A>) => B =\n  RM.reduceRightWithIndex\n\n/**\n * @category folding\n * @since 2.10.0\n */\nexport const getFoldableWithIndex = <K>(O: Ord<K>): FoldableWithIndex2C<URI, K, K> => {\n  return {\n    ...RM.getFoldableWithIndex(O),\n    URI\n  }\n}\n\n/**\n * @category traversing\n * @since 2.10.0\n */\nexport const getTraversableWithIndex = <K>(O: Ord<K>): TraversableWithIndex2C<URI, K, K> => {\n  const FWI = getFoldableWithIndex(O)\n  const keysO = keys(O)\n  const traverseWithIndex = <F>(\n    F: Applicative<F>\n  ): (<A, B>(ta: Map<K, A>, f: (k: K, a: A) => HKT<F, B>) => HKT<F, Map<K, B>>) => {\n    return <A, B>(ta: Map<K, A>, f: (k: K, a: A) => HKT<F, B>) => {\n      let fm: HKT<F, Map<K, B>> = F.of(new Map())\n      const ks = keysO(ta)\n      const len = ks.length\n      for (let i = 0; i < len; i++) {\n        const key = ks[i]\n        const a = ta.get(key)!\n        fm = F.ap(\n          F.map(fm, (m) => (b: B) => m.set(key, b)),\n          f(key, a)\n        )\n      }\n      return fm\n    }\n  }\n  const traverse = <F>(F: Applicative<F>): (<A, B>(ta: Map<K, A>, f: (a: A) => HKT<F, B>) => HKT<F, Map<K, B>>) => {\n    const traverseWithIndexF = traverseWithIndex(F)\n    return (ta, f) => traverseWithIndexF(ta, (_, a) => f(a))\n  }\n\n  const sequence = <F>(F: Applicative<F>): (<A>(ta: Map<K, HKT<F, A>>) => HKT<F, Map<K, A>>) => {\n    const traverseWithIndexF = traverseWithIndex(F)\n    return (ta) => traverseWithIndexF(ta, (_, a) => a)\n  }\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    mapWithIndex: _mapWithIndex,\n    reduce: FWI.reduce,\n    foldMap: FWI.foldMap,\n    reduceRight: FWI.reduceRight,\n    reduceWithIndex: FWI.reduceWithIndex,\n    foldMapWithIndex: FWI.foldMapWithIndex,\n    reduceRightWithIndex: FWI.reduceRightWithIndex,\n    traverse,\n    sequence,\n    traverseWithIndex\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Compactable: Compactable2<URI> = {\n  URI,\n  compact,\n  separate\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Filterable: Filterable2<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\nconst copy = <K, A>(m: Map<K, A>): Map<K, A> => new Map(m)\n\n/**\n * @since 2.11.0\n */\nexport const union = <K, A>(E: Eq<K>, M: Magma<A>): ((second: Map<K, A>) => (first: Map<K, A>) => Map<K, A>) => {\n  const unionEM = RM.union(E, M)\n  return (second) => (first) => {\n    if (isEmpty(first)) {\n      return copy(second)\n    }\n    if (isEmpty(second)) {\n      return copy(first)\n    }\n    return unionEM(second)(first) as any\n  }\n}\n\n/**\n * @since 2.11.0\n */\nexport const intersection = <K, A>(E: Eq<K>, M: Magma<A>): ((second: Map<K, A>) => (first: Map<K, A>) => Map<K, A>) => {\n  const intersectionEM = RM.intersection(E, M)\n  return (second) => (first) => {\n    if (isEmpty(first) || isEmpty(second)) {\n      return new Map()\n    }\n    return intersectionEM(second)(first) as any\n  }\n}\n\n/**\n * @since 2.11.0\n */\nexport const difference = <K>(E: Eq<K>): (<A>(_second: Map<K, A>) => (first: Map<K, A>) => Map<K, A>) => {\n  const differenceE = RM.difference(E)\n  return <A>(second: Map<K, A>) =>\n    (first: Map<K, A>) => {\n      if (isEmpty(first)) {\n        return copy(second)\n      }\n      if (isEmpty(second)) {\n        return copy(first)\n      }\n      return differenceE(second)(first) as any\n    }\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use a `new Map()` instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const empty = new Map<never, never>()\n\n/**\n * Use [`upsertAt`](#upsertat) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const insertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: Map<K, A>) => Map<K, A> = upsertAt\n\n/**\n * Use [`Filterable`](#filterable) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const map_: Filterable2<URI> = Filterable\n"
  },
  {
    "path": "src/MeetSemilattice.ts",
    "content": "/**\n * A meet-semilattice (or lower semilattice) is a semilattice whose operation is called `meet`, and which can be thought\n * of as a greatest lower bound.\n *\n * A `MeetSemilattice` must satisfy the following laws:\n *\n * - Associativity: `a ∧ (b ∧ c) <-> (a ∧ b) ∧ c`\n * - Commutativity: `a ∧ b <-> b ∧ a`\n * - Idempotency:   `a ∧ a <-> a`\n *\n * @since 2.0.0\n */\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MeetSemilattice<A> {\n  readonly meet: (x: A, y: A) => A\n}\n"
  },
  {
    "path": "src/Monad.ts",
    "content": "/**\n * The `Monad` type class combines the operations of the `Chain` and\n * `Applicative` type classes. Therefore, `Monad` instances represent type\n * constructors which support sequential composition, and also lifting of\n * functions of arbitrary arity.\n *\n * Instances must satisfy the following laws in addition to the `Applicative` and `Chain` laws:\n *\n * 1. Left identity: `M.chain(M.of(a), f) <-> f(a)`\n * 2. Right identity: `M.chain(fa, M.of) <-> fa`\n *\n * Note. `Functor`'s `map` can be derived: `A.map = (fa, f) => A.chain(fa, a => A.of(f(a)))`\n *\n * @since 2.0.0\n */\nimport {\n  Applicative,\n  Applicative1,\n  Applicative2,\n  Applicative2C,\n  Applicative3,\n  Applicative3C,\n  Applicative4\n} from './Applicative'\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C, Chain4 } from './Chain'\nimport { URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Monad<F> extends Applicative<F>, Chain<F> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Monad1<F extends URIS> extends Applicative1<F>, Chain1<F> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Monad2<M extends URIS2> extends Applicative2<M>, Chain2<M> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Monad2C<M extends URIS2, L> extends Applicative2C<M, L>, Chain2C<M, L> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Monad3<M extends URIS3> extends Applicative3<M>, Chain3<M> {}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Monad3C<M extends URIS3, E> extends Applicative3C<M, E>, Chain3C<M, E> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Monad4<M extends URIS4> extends Applicative4<M>, Chain4<M> {}\n"
  },
  {
    "path": "src/MonadIO.ts",
    "content": "/**\n * Lift a computation from the `IO` monad\n *\n * @since 2.0.0\n */\nimport { FromIO, FromIO1, FromIO2, FromIO2C, FromIO3, FromIO3C, FromIO4 } from './FromIO'\nimport { URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Monad, Monad1, Monad2, Monad2C, Monad3, Monad3C, Monad4 } from './Monad'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadIO<M> extends Monad<M>, FromIO<M> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadIO1<M extends URIS> extends Monad1<M>, FromIO1<M> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadIO2<M extends URIS2> extends Monad2<M>, FromIO2<M> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadIO2C<M extends URIS2, E> extends Monad2C<M, E>, FromIO2C<M, E> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadIO3<M extends URIS3> extends Monad3<M>, FromIO3<M> {}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface MonadIO3C<M extends URIS3, E> extends Monad3C<M, E>, FromIO3C<M, E> {}\n\n/**\n * @category model\n * @since 2.4.4\n */\nexport interface MonadIO4<M extends URIS4> extends Monad4<M>, FromIO4<M> {}\n"
  },
  {
    "path": "src/MonadTask.ts",
    "content": "/**\n * Lift a computation from the `Task` monad\n *\n * @since 2.0.0\n */\nimport { FromTask, FromTask1, FromTask2, FromTask2C, FromTask3, FromTask3C, FromTask4 } from './FromTask'\nimport { URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { MonadIO, MonadIO1, MonadIO2, MonadIO2C, MonadIO3, MonadIO3C, MonadIO4 } from './MonadIO'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadTask<M> extends MonadIO<M>, FromTask<M> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadTask1<M extends URIS> extends MonadIO1<M>, FromTask1<M> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadTask2<M extends URIS2> extends MonadIO2<M>, FromTask2<M> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadTask2C<M extends URIS2, E> extends MonadIO2C<M, E>, FromTask2C<M, E> {}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadTask3<M extends URIS3> extends MonadIO3<M>, FromTask3<M> {}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface MonadTask3C<M extends URIS3, E> extends MonadIO3C<M, E>, FromTask3C<M, E> {}\n\n/**\n * @category model\n * @since 2.4.4\n */\nexport interface MonadTask4<M extends URIS4> extends MonadIO4<M>, FromTask4<M> {}\n"
  },
  {
    "path": "src/MonadThrow.ts",
    "content": "/**\n * The `MonadThrow` type class represents those monads which support errors via\n * `throwError`, where `throwError(e)` halts, yielding the error `e`.\n *\n * Laws:\n *\n * - Left zero: `M.chain(M.throwError(e), f) = M.throwError(e)`\n *\n * @since 2.0.0\n */\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Monad, Monad1, Monad2, Monad2C, Monad3, Monad3C, Monad4 } from './Monad'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadThrow<M> extends Monad<M> {\n  readonly throwError: <E, A>(e: E) => HKT<M, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadThrow1<M extends URIS> extends Monad1<M> {\n  readonly throwError: <E, A>(e: E) => Kind<M, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadThrow2<M extends URIS2> extends Monad2<M> {\n  readonly throwError: <E, A>(e: E) => Kind2<M, E, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadThrow2C<M extends URIS2, E> extends Monad2C<M, E> {\n  readonly throwError: <A>(e: E) => Kind2<M, E, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadThrow3<M extends URIS3> extends Monad3<M> {\n  readonly throwError: <R, E, A>(e: E) => Kind3<M, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface MonadThrow3C<M extends URIS3, E> extends Monad3C<M, E> {\n  readonly throwError: <R, A>(e: E) => Kind3<M, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface MonadThrow4<M extends URIS4> extends Monad4<M> {\n  readonly throwError: <S, R, E, A>(e: E) => Kind4<M, S, R, E, A>\n}\n"
  },
  {
    "path": "src/Monoid.ts",
    "content": "/**\n * `Monoid` extends the power of `Semigroup` by providing an additional `empty` value.\n *\n * ```ts\n * interface Semigroup<A> {\n *   readonly concat: (x: A, y: A) => A\n * }\n *\n * interface Monoid<A> extends Semigroup<A> {\n *   readonly empty: A\n * }\n * ```\n *\n * This `empty` value should be an identity for the `concat` operation, which means the following equalities hold for any choice of `x`.\n *\n * ```ts\n * concat(x, empty) = concat(empty, x) = x\n * ```\n *\n * Many types that form a `Semigroup` also form a `Monoid`, such as `number`s (with `0`) and `string`s (with `''`).\n *\n * ```ts\n * import { Monoid } from 'fp-ts/Monoid'\n *\n * const monoidString: Monoid<string> = {\n *   concat: (x, y) => x + y,\n *   empty: ''\n * }\n * ```\n *\n * *Adapted from https://typelevel.org/cats*\n *\n * @since 2.0.0\n */\nimport { Bounded } from './Bounded'\nimport { Endomorphism, getMonoid as getEM } from './Endomorphism'\nimport { getMonoid as getFM } from './function'\nimport * as _ from './internal'\nimport { ReadonlyRecord } from './ReadonlyRecord'\nimport * as Se from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Monoid<A> extends Se.Semigroup<A> {\n  readonly empty: A\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Get a monoid where `concat` will return the minimum, based on the provided bounded order.\n *\n * The `empty` value is the `top` value.\n *\n * @example\n * import * as N from 'fp-ts/number'\n * import * as M from 'fp-ts/Monoid'\n *\n * const M1 = M.min(N.Bounded)\n *\n * assert.deepStrictEqual(M1.concat(1, 2), 1)\n *\n * @category constructors\n * @since 2.10.0\n */\nexport const min = <A>(B: Bounded<A>): Monoid<A> => ({\n  concat: Se.min(B).concat,\n  empty: B.top\n})\n/**\n * Get a monoid where `concat` will return the maximum, based on the provided bounded order.\n *\n * The `empty` value is the `bottom` value.\n *\n * @example\n * import * as N from 'fp-ts/number'\n * import * as M from 'fp-ts/Monoid'\n *\n * const M1 = M.max(N.Bounded)\n *\n * assert.deepStrictEqual(M1.concat(1, 2), 2)\n *\n * @category constructors\n * @since 2.10.0\n */\nexport const max = <A>(B: Bounded<A>): Monoid<A> => ({\n  concat: Se.max(B).concat,\n  empty: B.bottom\n})\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * The dual of a `Monoid`, obtained by swapping the arguments of `concat`.\n *\n * @example\n * import { reverse } from 'fp-ts/Monoid'\n * import * as S from 'fp-ts/string'\n *\n * assert.deepStrictEqual(reverse(S.Monoid).concat('a', 'b'), 'ba')\n *\n * @since 2.10.0\n */\nexport const reverse = <A>(M: Monoid<A>): Monoid<A> => ({\n  concat: Se.reverse(M).concat,\n  empty: M.empty\n})\n\n/**\n * Given a struct of monoids returns a monoid for the struct.\n *\n * @example\n * import { struct } from 'fp-ts/Monoid'\n * import * as N from 'fp-ts/number'\n *\n * interface Point {\n *   readonly x: number\n *   readonly y: number\n * }\n *\n * const M = struct<Point>({\n *   x: N.MonoidSum,\n *   y: N.MonoidSum\n * })\n *\n * assert.deepStrictEqual(M.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 })\n *\n * @since 2.10.0\n */\nexport const struct = <A>(monoids: { [K in keyof A]: Monoid<A[K]> }): Monoid<{ readonly [K in keyof A]: A[K] }> => {\n  const empty: A = {} as any\n  for (const k in monoids) {\n    if (_.has.call(monoids, k)) {\n      empty[k] = monoids[k].empty\n    }\n  }\n  return {\n    concat: Se.struct(monoids).concat,\n    empty\n  }\n}\n\n/**\n * Given a tuple of monoids returns a monoid for the tuple.\n *\n * @example\n * import { tuple } from 'fp-ts/Monoid'\n * import * as B from 'fp-ts/boolean'\n * import * as N from 'fp-ts/number'\n * import * as S from 'fp-ts/string'\n *\n * const M1 = tuple(S.Monoid, N.MonoidSum)\n * assert.deepStrictEqual(M1.concat(['a', 1], ['b', 2]), ['ab', 3])\n *\n * const M2 = tuple(S.Monoid, N.MonoidSum, B.MonoidAll)\n * assert.deepStrictEqual(M2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])\n *\n * @since 2.10.0\n */\nexport const tuple = <A extends ReadonlyArray<unknown>>(\n  ...monoids: { [K in keyof A]: Monoid<A[K]> }\n): Monoid<Readonly<A>> =>\n  ({\n    concat: Se.tuple(...(monoids as any)).concat,\n    empty: monoids.map((m) => m.empty)\n  } as any)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Given a sequence of `as`, concat them and return the total.\n *\n * If `as` is empty, return the monoid `empty` value.\n *\n * @example\n * import { concatAll } from 'fp-ts/Monoid'\n * import * as N from 'fp-ts/number'\n *\n * assert.deepStrictEqual(concatAll(N.MonoidSum)([1, 2, 3]), 6)\n * assert.deepStrictEqual(concatAll(N.MonoidSum)([]), 0)\n *\n * @since 2.10.0\n */\nexport const concatAll = <A>(M: Monoid<A>): ((as: ReadonlyArray<A>) => A) => Se.concatAll(M)(M.empty)\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`Monoid`](./void.ts.html#monoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const monoidVoid: Monoid<void> = {\n  concat: Se.semigroupVoid.concat,\n  empty: undefined\n}\n\n/**\n * Use [`tuple`](#tuple) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getTupleMonoid: <T extends ReadonlyArray<Monoid<any>>>(\n  ...monoids: T\n) => Monoid<{ [K in keyof T]: T[K] extends Se.Semigroup<infer A> ? A : never }> = tuple as any\n\n/**\n * Use [`struct`](#struct) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getStructMonoid: <O extends ReadonlyRecord<string, any>>(monoids: {\n  [K in keyof O]: Monoid<O[K]>\n}) => Monoid<O> = struct\n\n/**\n * Use [`reverse`](#reverse) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getDualMonoid = reverse\n\n/**\n * Use [`max`](#max) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getJoinMonoid = max\n\n/**\n * Use [`min`](#min) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getMeetMonoid = min\n\n/**\n * Use [`concatAll`](#concatall) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const fold = concatAll\n\n/**\n * Use [`MonoidAll`](./boolean.ts.html#monoidall) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const monoidAll: Monoid<boolean> = {\n  concat: Se.semigroupAll.concat,\n  empty: true\n}\n\n/**\n * Use [`MonoidAny`](./boolean.ts.html#monoidany) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const monoidAny: Monoid<boolean> = {\n  concat: Se.semigroupAny.concat,\n  empty: false\n}\n\n/**\n * Use [`getMonoid`](./function.ts.html#getmonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getFunctionMonoid: <M>(M: Monoid<M>) => <A = never>() => Monoid<(a: A) => M> = getFM\n\n/**\n * Use [`getEndomorphismMonoid`](./function.ts.html#getendomorphismmonoid) instead.\n *\n * **Note**. The execution order in [`getEndomorphismMonoid`](./function.ts.html#getendomorphismmonoid) is reversed.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getEndomorphismMonoid = <A = never>(): Monoid<Endomorphism<A>> => reverse(getEM())\n\n/**\n * Use [`Monoid`](./string.ts.html#monoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const monoidString: Monoid<string> = {\n  concat: Se.semigroupString.concat,\n  empty: ''\n}\n\n/**\n * Use [`MonoidSum`](./number.ts.html#monoidsum) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const monoidSum: Monoid<number> = {\n  concat: Se.semigroupSum.concat,\n  empty: 0\n}\n\n/**\n * Use [`MonoidProduct`](./number.ts.html#monoidproduct) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const monoidProduct: Monoid<number> = {\n  concat: Se.semigroupProduct.concat,\n  empty: 1\n}\n"
  },
  {
    "path": "src/NaturalTransformation.ts",
    "content": "/**\n * A type for natural transformations.\n *\n * A natural transformation is a mapping between type constructors of kind `* -> *` where the mapping\n * operation has no ability to manipulate the inner values.\n *\n * The definition of a natural transformation in category theory states that `F` and `G` should be functors,\n * but the `Functor` constraint is not enforced here; that the types are of kind `* -> *` is enough for our purposes.\n *\n * @since 2.11.0\n */\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation<F, G> {\n  <A>(fa: HKT<F, A>): HKT<G, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation11<F extends URIS, G extends URIS> {\n  <A>(fa: Kind<F, A>): Kind<G, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation12<F extends URIS, G extends URIS2> {\n  <A, E>(fa: Kind<F, A>): Kind2<G, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation12C<F extends URIS, G extends URIS2, E> {\n  <A>(fa: Kind<F, A>): Kind2<G, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation13<F extends URIS, G extends URIS3> {\n  <A, R, E>(fa: Kind<F, A>): Kind3<G, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation13C<F extends URIS, G extends URIS3, E> {\n  <A, R>(fa: Kind<F, A>): Kind3<G, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation14<F extends URIS, G extends URIS4> {\n  <A, S, R, E>(fa: Kind<F, A>): Kind4<G, S, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation14C<F extends URIS, G extends URIS4, E> {\n  <A, S, R>(fa: Kind<F, A>): Kind4<G, S, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation21<F extends URIS2, G extends URIS> {\n  <A>(fa: Kind2<F, unknown, A>): Kind<G, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation22<F extends URIS2, G extends URIS2> {\n  <E, A>(fa: Kind2<F, E, A>): Kind2<G, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation22C<F extends URIS2, G extends URIS2, E> {\n  <A>(fa: Kind2<F, E, A>): Kind2<G, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation23<F extends URIS2, G extends URIS3> {\n  <E, A, R>(fa: Kind2<F, E, A>): Kind3<G, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation23C<F extends URIS2, G extends URIS3, E> {\n  <A, R>(fa: Kind2<F, E, A>): Kind3<G, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation24<F extends URIS2, G extends URIS4> {\n  <E, A, S, R>(fa: Kind2<F, E, A>): Kind4<G, S, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation23R<F extends URIS2, G extends URIS3> {\n  <R, A, E>(fa: Kind2<F, R, A>): Kind3<G, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation23RC<F extends URIS2, G extends URIS3, E> {\n  <R, A>(fa: Kind2<F, R, A>): Kind3<G, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation24R<F extends URIS2, G extends URIS4> {\n  <R, A, S, E>(fa: Kind2<F, R, A>): Kind4<G, S, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation24S<F extends URIS2, G extends URIS4> {\n  <S, A, R, E>(fa: Kind2<F, S, A>): Kind4<G, S, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation33<F extends URIS3, G extends URIS3> {\n  <R, E, A>(fa: Kind3<F, R, E, A>): Kind3<G, R, E, A>\n}\n\n/**\n * @since 2.11.0\n */\nexport interface NaturalTransformation34<F extends URIS3, G extends URIS4> {\n  <R, E, A, S>(fa: Kind3<F, R, E, A>): Kind4<G, S, R, E, A>\n}\n"
  },
  {
    "path": "src/NonEmptyArray.ts",
    "content": "/**\n * Data structure which represents non-empty arrays.\n *\n * ```ts\n * export type NonEmptyArray<A> = Array<A> & {\n *   0: A\n * }\n * ```\n *\n * Note that you don't need any conversion, a `NonEmptyArray` is an `Array`,\n * so all `Array`'s APIs can be used with a `NonEmptyArray` without further ado.\n *\n * @since 2.0.0\n */\nimport { Alt1 } from './Alt'\nimport { Applicative as ApplicativeHKT, Applicative1 } from './Applicative'\nimport { apFirst as apFirst_, Apply1, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport { bind as bind_, Chain1, chainFirst as chainFirst_ } from './Chain'\nimport { Comonad1 } from './Comonad'\nimport { Endomorphism } from './Endomorphism'\nimport { Eq } from './Eq'\nimport { Extend1 } from './Extend'\nimport { Foldable1 } from './Foldable'\nimport { FoldableWithIndex1 } from './FoldableWithIndex'\nimport { dual, identity, LazyArg, pipe } from './function'\nimport { bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport { FunctorWithIndex1 } from './FunctorWithIndex'\nimport { HKT } from './HKT'\nimport * as _ from './internal'\nimport { Monad1 } from './Monad'\nimport { Option } from './Option'\nimport { getMonoid, Ord } from './Ord'\nimport { Pointed1 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport * as RNEA from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport * as Se from './Semigroup'\nimport { Show } from './Show'\nimport { PipeableTraverse1, Traversable1 } from './Traversable'\nimport { PipeableTraverseWithIndex1, TraversableWithIndex1 } from './TraversableWithIndex'\n\nimport Semigroup = Se.Semigroup\nimport ReadonlyNonEmptyArray = RNEA.ReadonlyNonEmptyArray\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface NonEmptyArray<A> extends Array<A> {\n  0: A\n}\n\n// -------------------------------------------------------------------------------------\n// internal\n// -------------------------------------------------------------------------------------\n\n/**\n * @internal\n */\nexport const isNonEmpty = <A>(as: Array<A>): as is NonEmptyArray<A> => as.length > 0\n\n/**\n * @internal\n */\nexport const isOutOfBound = <A>(i: number, as: Array<A>): boolean => i < 0 || i >= as.length\n\n/**\n * @internal\n */\nexport const prependW =\n  <B>(head: B) =>\n  <A>(tail: Array<A>): NonEmptyArray<A | B> =>\n    [head, ...tail]\n\n/**\n * @internal\n */\nexport const prepend: <A>(head: A) => (tail: Array<A>) => NonEmptyArray<A> = prependW\n\n/**\n * @internal\n */\nexport const appendW =\n  <B>(end: B) =>\n  <A>(init: Array<A>): NonEmptyArray<A | B> =>\n    [...init, end] as any\n\n/**\n * @internal\n */\nexport const append: <A>(end: A) => (init: Array<A>) => NonEmptyArray<A> = appendW\n\n/**\n * @internal\n */\nexport const unsafeInsertAt = <A>(i: number, a: A, as: Array<A>): NonEmptyArray<A> => {\n  if (isNonEmpty(as)) {\n    const xs = fromReadonlyNonEmptyArray(as)\n    xs.splice(i, 0, a)\n    return xs\n  }\n  return [a]\n}\n\n/**\n * @internal\n */\nexport const unsafeUpdateAt = <A>(i: number, a: A, as: NonEmptyArray<A>): NonEmptyArray<A> => {\n  const xs = fromReadonlyNonEmptyArray(as)\n  xs[i] = a\n  return xs\n}\n\n/**\n * Remove duplicates from a `NonEmptyArray`, keeping the first occurrence of an element.\n *\n * @example\n * import { uniq } from 'fp-ts/NonEmptyArray'\n * import * as N from 'fp-ts/number'\n *\n * assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])\n *\n * @since 2.11.0\n */\nexport const uniq =\n  <A>(E: Eq<A>) =>\n  (as: NonEmptyArray<A>): NonEmptyArray<A> => {\n    if (as.length === 1) {\n      return copy(as)\n    }\n    const out: NonEmptyArray<A> = [head(as)]\n    const rest = tail(as)\n    for (const a of rest) {\n      if (out.every((o) => !E.equals(o, a))) {\n        out.push(a)\n      }\n    }\n    return out\n  }\n\n/**\n * Sort the elements of a `NonEmptyArray` in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,\n * etc...\n *\n * @example\n * import * as NEA from 'fp-ts/NonEmptyArray'\n * import { contramap } from 'fp-ts/Ord'\n * import * as S from 'fp-ts/string'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * interface Person {\n *   name: string\n *   age: number\n * }\n *\n * const byName = pipe(S.Ord, contramap((p: Person) => p.name))\n *\n * const byAge = pipe(N.Ord, contramap((p: Person) => p.age))\n *\n * const sortByNameByAge = NEA.sortBy([byName, byAge])\n *\n * const persons: NEA.NonEmptyArray<Person> = [\n *   { name: 'a', age: 1 },\n *   { name: 'b', age: 3 },\n *   { name: 'c', age: 2 },\n *   { name: 'b', age: 2 }\n * ]\n *\n * assert.deepStrictEqual(sortByNameByAge(persons), [\n *   { name: 'a', age: 1 },\n *   { name: 'b', age: 2 },\n *   { name: 'b', age: 3 },\n *   { name: 'c', age: 2 }\n * ])\n *\n * @since 2.11.0\n */\nexport const sortBy = <B>(ords: Array<Ord<B>>): (<A extends B>(as: NonEmptyArray<A>) => NonEmptyArray<A>) => {\n  if (isNonEmpty(ords)) {\n    const M = getMonoid<B>()\n    return sort(ords.reduce(M.concat, M.empty))\n  }\n  return copy\n}\n\n/**\n * @since 2.11.0\n */\nexport const union = <A>(E: Eq<A>): ((second: NonEmptyArray<A>) => (first: NonEmptyArray<A>) => NonEmptyArray<A>) => {\n  const uniqE = uniq(E)\n  return (second) => (first) => uniqE(pipe(first, concat(second)))\n}\n\n/**\n * Rotate a `NonEmptyArray` by `n` steps.\n *\n * @example\n * import { rotate } from 'fp-ts/NonEmptyArray'\n *\n * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n * assert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n *\n * @since 2.11.0\n */\nexport const rotate =\n  (n: number) =>\n  <A>(as: NonEmptyArray<A>): NonEmptyArray<A> => {\n    const len = as.length\n    const m = Math.round(n) % len\n    if (isOutOfBound(Math.abs(m), as) || m === 0) {\n      return copy(as)\n    }\n    if (m < 0) {\n      const [f, s] = splitAt(-m)(as)\n      return pipe(s, concat(f))\n    } else {\n      return rotate(m - len)(as)\n    }\n  }\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromReadonlyNonEmptyArray: <A>(as: ReadonlyNonEmptyArray<A>) => NonEmptyArray<A> =\n  _.fromReadonlyNonEmptyArray\n\n/**\n * Builds a `NonEmptyArray` from an `Array` returning `none` if `as` is an empty array\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const fromArray = <A>(as: Array<A>): Option<NonEmptyArray<A>> => (isNonEmpty(as) ? _.some(as) : _.none)\n\n/**\n * Return a `NonEmptyArray` of length `n` with element `i` initialized with `f(i)`.\n *\n * **Note**. `n` is normalized to a natural number.\n *\n * @example\n * import { makeBy } from 'fp-ts/NonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * const double = (n: number): number => n * 2\n * assert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8])\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const makeBy =\n  <A>(f: (i: number) => A) =>\n  (n: number): NonEmptyArray<A> => {\n    const j = Math.max(0, Math.floor(n))\n    const out: NonEmptyArray<A> = [f(0)]\n    for (let i = 1; i < j; i++) {\n      out.push(f(i))\n    }\n    return out\n  }\n\n/**\n * Create a `NonEmptyArray` containing a value repeated the specified number of times.\n *\n * **Note**. `n` is normalized to a natural number.\n *\n * @example\n * import { replicate } from 'fp-ts/NonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a'])\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const replicate = <A>(a: A): ((n: number) => ReadonlyNonEmptyArray<A>) => makeBy(() => a)\n\n/**\n * Create a `NonEmptyArray` containing a range of integers, including both endpoints.\n *\n * @example\n * import { range } from 'fp-ts/NonEmptyArray'\n *\n * assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5])\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const range = (start: number, end: number): NonEmptyArray<number> =>\n  start <= end ? makeBy((i) => start + i)(end - start + 1) : [start]\n\n/**\n * Return the tuple of the `head` and the `tail`.\n *\n * @example\n * import { unprepend } from 'fp-ts/NonEmptyArray'\n *\n * assert.deepStrictEqual(unprepend([1, 2, 3]), [1, [2, 3]])\n *\n * @since 2.9.0\n */\nexport const unprepend = <A>(as: NonEmptyArray<A>): [A, Array<A>] => [head(as), tail(as)]\n\n/**\n * Return the tuple of the `init` and the `last`.\n *\n * @example\n * import { unappend } from 'fp-ts/NonEmptyArray'\n *\n * assert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4])\n *\n * @since 2.9.0\n */\nexport const unappend = <A>(as: NonEmptyArray<A>): [Array<A>, A] => [init(as), last(as)]\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport function concatW<B>(second: NonEmptyArray<B>): <A>(first: Array<A>) => NonEmptyArray<A | B>\nexport function concatW<B>(second: Array<B>): <A>(first: NonEmptyArray<A>) => NonEmptyArray<A | B>\nexport function concatW<B>(second: Array<B>): <A>(first: NonEmptyArray<A>) => Array<A | B> {\n  return <A>(first: NonEmptyArray<A | B>) => first.concat(second)\n}\n\n/**\n * @since 2.2.0\n */\nexport function concat<A>(second: NonEmptyArray<A>): (first: Array<A>) => NonEmptyArray<A>\nexport function concat<A>(second: Array<A>): (first: NonEmptyArray<A>) => NonEmptyArray<A>\n/** @deprecated */\nexport function concat<A>(first: Array<A>, second: NonEmptyArray<A>): NonEmptyArray<A>\n/** @deprecated */\nexport function concat<A>(first: NonEmptyArray<A>, second: Array<A>): NonEmptyArray<A>\nexport function concat<A>(x: Array<A>, y?: Array<A>): Array<A> | ((y: NonEmptyArray<A>) => Array<A>) {\n  return y ? x.concat(y) : (y) => y.concat(x)\n}\n\n/**\n * @since 2.0.0\n */\nexport const reverse = <A>(as: NonEmptyArray<A>): NonEmptyArray<A> => [last(as), ...as.slice(0, -1).reverse()]\n\n/**\n * Group equal, consecutive elements of an array into non empty arrays.\n *\n * @example\n * import { group } from 'fp-ts/NonEmptyArray'\n * import * as N from 'fp-ts/number'\n *\n * assert.deepStrictEqual(group(N.Ord)([1, 2, 1, 1]), [\n *   [1],\n *   [2],\n *   [1, 1]\n * ])\n *\n * @since 2.0.0\n */\nexport function group<B>(E: Eq<B>): {\n  <A extends B>(as: NonEmptyArray<A>): NonEmptyArray<NonEmptyArray<A>>\n  <A extends B>(as: Array<A>): Array<NonEmptyArray<A>>\n}\nexport function group<A>(E: Eq<A>): (as: Array<A>) => Array<NonEmptyArray<A>> {\n  return (as) => {\n    const len = as.length\n    if (len === 0) {\n      return []\n    }\n    const out: Array<NonEmptyArray<A>> = []\n    let head: A = as[0]\n    let nea: NonEmptyArray<A> = [head]\n    for (let i = 1; i < len; i++) {\n      const a = as[i]\n      if (E.equals(a, head)) {\n        nea.push(a)\n      } else {\n        out.push(nea)\n        head = a\n        nea = [head]\n      }\n    }\n    out.push(nea)\n    return out\n  }\n}\n\n/**\n * Splits an array 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 * @example\n * import { groupBy } from 'fp-ts/NonEmptyArray'\n *\n * assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), {\n *   '1': ['a', 'b'],\n *   '2': ['ab']\n * })\n *\n * @since 2.0.0\n */\nexport const groupBy =\n  <A>(f: (a: A) => string) =>\n  (as: Array<A>): Record<string, NonEmptyArray<A>> => {\n    const out: Record<string, NonEmptyArray<A>> = {}\n    for (const a of as) {\n      const k = f(a)\n      if (_.has.call(out, k)) {\n        out[k].push(a)\n      } else {\n        out[k] = [a]\n      }\n    }\n    return out\n  }\n\n/**\n * @since 2.0.0\n */\nexport const sort =\n  <B>(O: Ord<B>) =>\n  <A extends B>(as: NonEmptyArray<A>): NonEmptyArray<A> =>\n    as.slice().sort(O.compare) as any\n\n/**\n * @since 2.0.0\n */\nexport const insertAt =\n  <A>(i: number, a: A) =>\n  (as: Array<A>): Option<NonEmptyArray<A>> =>\n    i < 0 || i > as.length ? _.none : _.some(unsafeInsertAt(i, a, as))\n\n/**\n * @since 2.0.0\n */\nexport const updateAt = <A>(i: number, a: A): ((as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>) =>\n  modifyAt(i, () => a)\n\n/**\n * @since 2.0.0\n */\nexport const modifyAt =\n  <A>(i: number, f: (a: A) => A) =>\n  (as: NonEmptyArray<A>): Option<NonEmptyArray<A>> =>\n    isOutOfBound(i, as) ? _.none : _.some(unsafeUpdateAt(i, f(as[i]), as))\n\n/**\n * @since 2.0.0\n */\nexport const copy: <A>(as: NonEmptyArray<A>) => NonEmptyArray<A> = fromReadonlyNonEmptyArray\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const of: <A>(a: A) => NonEmptyArray<A> = (a) => [a]\n\n/**\n * @since 2.5.1\n */\nexport const zipWith = <A, B, C>(\n  as: NonEmptyArray<A>,\n  bs: NonEmptyArray<B>,\n  f: (a: A, b: B) => C\n): NonEmptyArray<C> => {\n  const cs: NonEmptyArray<C> = [f(as[0], bs[0])]\n  const len = Math.min(as.length, bs.length)\n  for (let i = 1; i < len; i++) {\n    cs[i] = f(as[i], bs[i])\n  }\n  return cs\n}\n\n/**\n * @since 2.5.1\n */\nexport function zip<B>(bs: NonEmptyArray<B>): <A>(as: NonEmptyArray<A>) => NonEmptyArray<[A, B]>\nexport function zip<A, B>(as: NonEmptyArray<A>, bs: NonEmptyArray<B>): NonEmptyArray<[A, B]>\nexport function zip<A, B>(\n  as: NonEmptyArray<A>,\n  bs?: NonEmptyArray<B>\n): NonEmptyArray<[A, B]> | ((bs: NonEmptyArray<B>) => NonEmptyArray<[B, A]>) {\n  if (bs === undefined) {\n    return (bs) => zip(bs, as)\n  }\n  return zipWith(as, bs, (a, b) => [a, b])\n}\n\n/**\n * @since 2.5.1\n */\nexport const unzip = <A, B>(abs: NonEmptyArray<[A, B]>): [NonEmptyArray<A>, NonEmptyArray<B>] => {\n  const fa: NonEmptyArray<A> = [abs[0][0]]\n  const fb: NonEmptyArray<B> = [abs[0][1]]\n  for (let i = 1; i < abs.length; i++) {\n    fa[i] = abs[i][0]\n    fb[i] = abs[i][1]\n  }\n  return [fa, fb]\n}\n\n/**\n * Prepend an element to every member of an array\n *\n * @example\n * import { prependAll } from 'fp-ts/NonEmptyArray'\n *\n * assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])\n *\n * @since 2.10.0\n */\nexport const prependAll =\n  <A>(middle: A) =>\n  (as: NonEmptyArray<A>): NonEmptyArray<A> => {\n    const out: NonEmptyArray<A> = [middle, as[0]]\n    for (let i = 1; i < as.length; i++) {\n      out.push(middle, as[i])\n    }\n    return out\n  }\n\n/**\n * Places an element in between members of an array\n *\n * @example\n * import { intersperse } from 'fp-ts/NonEmptyArray'\n *\n * assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])\n *\n * @since 2.9.0\n */\nexport const intersperse =\n  <A>(middle: A) =>\n  (as: NonEmptyArray<A>): NonEmptyArray<A> => {\n    const rest = tail(as)\n    return isNonEmpty(rest) ? pipe(rest, prependAll(middle), prepend(head(as))) : copy(as)\n  }\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const foldMapWithIndex: <S>(S: Semigroup<S>) => <A>(f: (i: number, a: A) => S) => (fa: NonEmptyArray<A>) => S =\n  RNEA.foldMapWithIndex\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const foldMap: <S>(S: Semigroup<S>) => <A>(f: (a: A) => S) => (fa: NonEmptyArray<A>) => S = RNEA.foldMap\n\n/**\n * @category sequencing\n * @since 2.10.0\n */\nexport const chainWithIndex =\n  <A, B>(f: (i: number, a: A) => NonEmptyArray<B>) =>\n  (as: NonEmptyArray<A>): NonEmptyArray<B> => {\n    const out: NonEmptyArray<B> = fromReadonlyNonEmptyArray(f(0, head(as)))\n    for (let i = 1; i < as.length; i++) {\n      const bs = f(i, as[i])\n      for (let j = 0; j < bs.length; j++) {\n        out.push(bs[j])\n      }\n    }\n    return out\n  }\n\n/**\n * @since 2.10.0\n */\nexport const chop =\n  <A, B>(f: (as: NonEmptyArray<A>) => [B, Array<A>]) =>\n  (as: NonEmptyArray<A>): NonEmptyArray<B> => {\n    const [b, rest] = f(as)\n    const out: NonEmptyArray<B> = [b]\n    let next: Array<A> = rest\n    while (isNonEmpty(next)) {\n      const [b, rest] = f(next)\n      out.push(b)\n      next = rest\n    }\n    return out\n  }\n\n/**\n * Splits a `NonEmptyArray` into two pieces, the first piece has max `n` elements.\n *\n * @since 2.10.0\n */\nexport const splitAt =\n  (n: number) =>\n  <A>(as: NonEmptyArray<A>): [NonEmptyArray<A>, Array<A>] => {\n    const m = Math.max(1, n)\n    return m >= as.length ? [copy(as), []] : [pipe(as.slice(1, m), prepend(head(as))), as.slice(m)]\n  }\n\n/**\n * @since 2.10.0\n */\nexport const chunksOf = (n: number): (<A>(as: NonEmptyArray<A>) => NonEmptyArray<NonEmptyArray<A>>) => chop(splitAt(n))\n\n/* istanbul ignore next */\nconst _map: Functor1<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _mapWithIndex: FunctorWithIndex1<URI, number>['mapWithIndex'] = (fa, f) => pipe(fa, mapWithIndex(f))\n/* istanbul ignore next */\nconst _ap: Apply1<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n/* istanbul ignore next */\nconst _extend: Extend1<URI>['extend'] = (wa, f) => pipe(wa, extend(f))\n/* istanbul ignore next */\nconst _reduce: Foldable1<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\n/* istanbul ignore next */\nconst _foldMap: Foldable1<URI>['foldMap'] = (M) => {\n  const foldMapM = foldMap(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\n/* istanbul ignore next */\nconst _reduceRight: Foldable1<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\n/* istanbul ignore next */\nconst _traverse: Traversable1<URI>['traverse'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: NonEmptyArray<A>, f: (a: A) => HKT<F, B>) => HKT<F, NonEmptyArray<B>>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\n/* istanbul ignore next */\nconst _alt: Alt1<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n/* istanbul ignore next */\nconst _reduceWithIndex: FoldableWithIndex1<URI, number>['reduceWithIndex'] = (fa, b, f) =>\n  pipe(fa, reduceWithIndex(b, f))\n/* istanbul ignore next */\nconst _foldMapWithIndex: FoldableWithIndex1<URI, number>['foldMapWithIndex'] = (M) => {\n  const foldMapWithIndexM = foldMapWithIndex(M)\n  return (fa, f) => pipe(fa, foldMapWithIndexM(f))\n}\n/* istanbul ignore next */\nconst _reduceRightWithIndex: FoldableWithIndex1<URI, number>['reduceRightWithIndex'] = (fa, b, f) =>\n  pipe(fa, reduceRightWithIndex(b, f))\n/* istanbul ignore next */\nconst _traverseWithIndex: TraversableWithIndex1<URI, number>['traverseWithIndex'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: NonEmptyArray<A>, f: (i: number, a: A) => HKT<F, B>) => HKT<F, NonEmptyArray<B>>) => {\n  const traverseWithIndexF = traverseWithIndex(F)\n  return (ta, f) => pipe(ta, traverseWithIndexF(f))\n}\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @example\n * import * as NEA from 'fp-ts/NonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3] as NEA.NonEmptyArray<number>,\n *     NEA.altW(() => ['a', 'b'])\n *   ),\n *   [1, 2, 3, 'a', 'b']\n * )\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW =\n  <B>(that: LazyArg<NonEmptyArray<B>>) =>\n  <A>(as: NonEmptyArray<A>): NonEmptyArray<A | B> =>\n    pipe(as, concatW(that()))\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * In case of `NonEmptyArray` concatenates the inputs into a single array.\n *\n * @example\n * import * as NEA from 'fp-ts/NonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     NEA.alt(() => [4, 5])\n *   ),\n *   [1, 2, 3, 4, 5]\n * )\n *\n * @category error handling\n * @since 2.6.2\n */\nexport const alt: <A>(that: LazyArg<NonEmptyArray<A>>) => (fa: NonEmptyArray<A>) => NonEmptyArray<A> = altW\n\n/**\n * Apply a function to an argument under a type constructor.\n *\n * @since 2.0.0\n */\nexport const ap = <A>(as: NonEmptyArray<A>): (<B>(fab: NonEmptyArray<(a: A) => B>) => NonEmptyArray<B>) =>\n  flatMap((f) => pipe(as, map(f)))\n\n/**\n * @example\n * import * as NEA from 'fp-ts/NonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     NEA.flatMap((n) => [`a${n}`, `b${n}`])\n *   ),\n *   ['a1', 'b1', 'a2', 'b2', 'a3', 'b3']\n * )\n *\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A, i: number) => NonEmptyArray<B>): (ma: NonEmptyArray<A>) => NonEmptyArray<B>\n  <A, B>(ma: NonEmptyArray<A>, f: (a: A, i: number) => NonEmptyArray<B>): NonEmptyArray<B>\n} = /*#__PURE__*/ dual(\n  2,\n  <A, B>(ma: NonEmptyArray<A>, f: (a: A, i: number) => NonEmptyArray<B>): NonEmptyArray<B> =>\n    pipe(\n      ma,\n      chainWithIndex((i, a) => f(a, i))\n    )\n)\n\n/**\n * @since 2.0.0\n */\nexport const extend =\n  <A, B>(f: (as: NonEmptyArray<A>) => B) =>\n  (as: NonEmptyArray<A>): NonEmptyArray<B> => {\n    let next: Array<A> = tail(as)\n    const out: NonEmptyArray<B> = [f(as)]\n    while (isNonEmpty(next)) {\n      out.push(f(next))\n      next = tail(next)\n    }\n    return out\n  }\n\n/**\n * @since 2.5.0\n */\nexport const duplicate: <A>(ma: NonEmptyArray<A>) => NonEmptyArray<NonEmptyArray<A>> = /*#__PURE__*/ extend(identity)\n\n/**\n * @category sequencing\n * @since 2.5.0\n */\nexport const flatten: <A>(mma: NonEmptyArray<NonEmptyArray<A>>) => NonEmptyArray<A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map = <A, B>(f: (a: A) => B): ((as: NonEmptyArray<A>) => NonEmptyArray<B>) => mapWithIndex((_, a) => f(a))\n\n/**\n * @category mapping\n * @since 2.0.0\n */\nexport const mapWithIndex =\n  <A, B>(f: (i: number, a: A) => B) =>\n  (as: NonEmptyArray<A>): NonEmptyArray<B> => {\n    const out: NonEmptyArray<B> = [f(0, head(as))]\n    for (let i = 1; i < as.length; i++) {\n      out.push(f(i, as[i]))\n    }\n    return out\n  }\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: NonEmptyArray<A>) => B = RNEA.reduce\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduceWithIndex: <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: NonEmptyArray<A>) => B =\n  RNEA.reduceWithIndex\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: NonEmptyArray<A>) => B = RNEA.reduceRight\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRightWithIndex: <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: NonEmptyArray<A>) => B =\n  RNEA.reduceRightWithIndex\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(f: (a: A) => HKT<F, B>) => (as: NonEmptyArray<A>) => HKT<F, NonEmptyArray<B>>) => {\n  const traverseWithIndexF = traverseWithIndex(F)\n  return (f) => traverseWithIndexF((_, a) => f(a))\n}\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable1<URI>['sequence'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A>(as: NonEmptyArray<HKT<F, A>>) => HKT<F, NonEmptyArray<A>>) => traverseWithIndex(F)((_, a) => a)\n\n/**\n * @category sequencing\n * @since 2.6.3\n */\nexport const traverseWithIndex: PipeableTraverseWithIndex1<URI, number> =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A, B>(f: (i: number, a: A) => HKT<F, B>) =>\n  (as: NonEmptyArray<A>): HKT<F, NonEmptyArray<B>> => {\n    let out: HKT<F, NonEmptyArray<B>> = F.map(f(0, head(as)), of)\n    for (let i = 1; i < as.length; i++) {\n      out = F.ap(\n        F.map(out, (bs) => (b: B) => pipe(bs, append(b))),\n        f(i, as[i])\n      )\n    }\n    return out\n  }\n\n/**\n * @since 2.7.0\n */\nexport const extract: Comonad1<URI>['extract'] = RNEA.head\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'NonEmptyArray'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: NonEmptyArray<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getShow: <A>(S: Show<A>) => Show<NonEmptyArray<A>> = RNEA.getShow\n\n/**\n * Builds a `Semigroup` instance for `NonEmptyArray`\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getSemigroup = <A = never>(): Semigroup<NonEmptyArray<A>> => ({\n  concat\n})\n\n/**\n * @example\n * import { getEq } from 'fp-ts/NonEmptyArray'\n * import * as N from 'fp-ts/number'\n *\n * const E = getEq(N.Eq)\n * assert.strictEqual(E.equals([1, 2], [1, 2]), true)\n * assert.strictEqual(E.equals([1, 2], [1, 3]), false)\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getEq: <A>(E: Eq<A>) => Eq<NonEmptyArray<A>> = RNEA.getEq\n\n/**\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <A>(E: Eq<A>): Semigroup<NonEmptyArray<A>> => {\n  const unionE = union(E)\n  return {\n    concat: (first, second) => unionE(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FunctorWithIndex: FunctorWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.5.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.5.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category sequencing\n * @since 2.5.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => NonEmptyArray<B>) => (first: NonEmptyArray<A>) => NonEmptyArray<A> =\n  /*#__PURE__*/ chainFirst_(Chain)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable1<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FoldableWithIndex: FoldableWithIndex1<URI, number> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable1<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const TraversableWithIndex: TraversableWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex,\n  traverseWithIndex: _traverseWithIndex\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt1<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Comonad: Comonad1<URI> = {\n  URI,\n  map: _map,\n  extend: _extend,\n  extract\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: NonEmptyArray<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ bind_(Chain)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.0.0\n */\nexport const head: <A>(nea: NonEmptyArray<A>) => A = RNEA.head\n\n/**\n * @since 2.0.0\n */\nexport const tail = <A>(as: NonEmptyArray<A>): Array<A> => as.slice(1)\n\n/**\n * @since 2.0.0\n */\nexport const last: <A>(nea: NonEmptyArray<A>) => A = RNEA.last\n\n/**\n * Get all but the last element of a non empty array, creating a new array.\n *\n * @example\n * import { init } from 'fp-ts/NonEmptyArray'\n *\n * assert.deepStrictEqual(init([1, 2, 3]), [1, 2])\n * assert.deepStrictEqual(init([1]), [])\n *\n * @since 2.2.0\n */\nexport const init = <A>(as: NonEmptyArray<A>): Array<A> => as.slice(0, -1)\n\n/**\n * @since 2.0.0\n */\nexport const min: <A>(ord: Ord<A>) => (nea: NonEmptyArray<A>) => A = RNEA.min\n\n/**\n * @since 2.0.0\n */\nexport const max: <A>(ord: Ord<A>) => (nea: NonEmptyArray<A>) => A = RNEA.max\n\n/**\n * @since 2.10.0\n */\nexport const concatAll =\n  <A>(S: Semigroup<A>) =>\n  (as: NonEmptyArray<A>): A =>\n    as.reduce(S.concat)\n\n/**\n * Break an `Array` into its first element and remaining elements.\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchLeft =\n  <A, B>(f: (head: A, tail: Array<A>) => B) =>\n  (as: NonEmptyArray<A>): B =>\n    f(head(as), tail(as))\n\n/**\n * Break an `Array` into its initial elements and the last element.\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchRight =\n  <A, B>(f: (init: Array<A>, last: A) => B) =>\n  (as: NonEmptyArray<A>): B =>\n    f(init(as), last(as))\n\n/**\n * Apply a function to the head, creating a new `NonEmptyArray`.\n *\n * @since 2.11.0\n */\nexport const modifyHead =\n  <A>(f: Endomorphism<A>) =>\n  (as: NonEmptyArray<A>): NonEmptyArray<A> =>\n    [f(head(as)), ...tail(as)]\n\n/**\n * Change the head, creating a new `NonEmptyArray`.\n *\n * @since 2.11.0\n */\nexport const updateHead = <A>(a: A): ((as: NonEmptyArray<A>) => NonEmptyArray<A>) => modifyHead(() => a)\n\n/**\n * Apply a function to the last element, creating a new `NonEmptyArray`.\n *\n * @since 2.11.0\n */\nexport const modifyLast =\n  <A>(f: Endomorphism<A>) =>\n  (as: NonEmptyArray<A>): NonEmptyArray<A> =>\n    pipe(init(as), append(f(last(as))))\n\n/**\n * Change the last element, creating a new `NonEmptyArray`.\n *\n * @since 2.11.0\n */\nexport const updateLast = <A>(a: A): ((as: NonEmptyArray<A>) => NonEmptyArray<A>) => modifyLast(() => a)\n\n/**\n * Places an element in between members of a `NonEmptyArray`, then folds the results using the provided `Semigroup`.\n *\n * @example\n * import * as S from 'fp-ts/string'\n * import { intercalate } from 'fp-ts/NonEmptyArray'\n *\n * assert.deepStrictEqual(intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c')\n *\n * @since 2.12.0\n */\nexport const intercalate: <A>(S: Semigroup<A>) => (middle: A) => (as: NonEmptyArray<A>) => A = RNEA.intercalate\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <A, B>(f: (a: A) => NonEmptyArray<B>) => (ma: NonEmptyArray<A>) => NonEmptyArray<B> = flatMap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This is just `sort` followed by `group`.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function groupSort<B>(O: Ord<B>): {\n  <A extends B>(as: NonEmptyArray<A>): NonEmptyArray<NonEmptyArray<A>>\n  <A extends B>(as: Array<A>): Array<NonEmptyArray<A>>\n}\nexport function groupSort<A>(O: Ord<A>): (as: Array<A>) => Array<NonEmptyArray<A>> {\n  const sortO = sort(O)\n  const groupO = group(O)\n  return (as) => (isNonEmpty(as) ? groupO(sortO(as)) : [])\n}\n\n/**\n * Use [`filter`](./Array.ts.html#filter) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function filter<A, B extends A>(refinement: Refinement<A, B>): (as: NonEmptyArray<A>) => Option<NonEmptyArray<B>>\nexport function filter<A>(predicate: Predicate<A>): <B extends A>(bs: NonEmptyArray<B>) => Option<NonEmptyArray<B>>\nexport function filter<A>(predicate: Predicate<A>): (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>>\nexport function filter<A>(predicate: Predicate<A>): (as: NonEmptyArray<A>) => Option<NonEmptyArray<A>> {\n  return filterWithIndex((_, a) => predicate(a))\n}\n\n/**\n * Use [`filterWithIndex`](./Array.ts.html#filterwithindex) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const filterWithIndex =\n  <A>(predicate: (i: number, a: A) => boolean) =>\n  (as: NonEmptyArray<A>): Option<NonEmptyArray<A>> =>\n    fromArray(as.filter((a, i) => predicate(i, a)))\n\n/**\n * Use [`unprepend`](#unprepend) instead.\n *\n * @category zone of death\n * @since 2.9.0\n * @deprecated\n */\nexport const uncons: <A>(as: NonEmptyArray<A>) => [A, Array<A>] = unprepend\n\n/**\n * Use [`unappend`](#unappend) instead.\n *\n * @category zone of death\n * @since 2.9.0\n * @deprecated\n */\nexport const unsnoc: <A>(as: NonEmptyArray<A>) => [Array<A>, A] = unappend\n\n/**\n * Use [`prepend`](./Array.ts.html#prepend) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function cons<A>(head: A): (tail: Array<A>) => NonEmptyArray<A>\n/** @deprecated */\nexport function cons<A>(head: A, tail: Array<A>): NonEmptyArray<A>\nexport function cons<A>(head: A, tail?: Array<A>): NonEmptyArray<A> | ((tail: Array<A>) => NonEmptyArray<A>) {\n  return tail === undefined ? prepend(head) : pipe(tail, prepend(head))\n}\n\n/**\n * Use [`append`](./Array.ts.html#append) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const snoc = <A>(init: Array<A>, end: A): NonEmptyArray<A> => pipe(init, append(end))\n\n/**\n * Use [`prependAll`](#prependall) instead.\n *\n * @category zone of death\n * @since 2.9.0\n * @deprecated\n */\nexport const prependToAll = prependAll\n\n/**\n * Use [`concatAll`](#concatall) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const fold: <A>(S: Semigroup<A>) => (fa: NonEmptyArray<A>) => A = RNEA.concatAll\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `NEA.Functor` instead of `NEA.nonEmptyArray`\n * (where `NEA` is from `import NEA from 'fp-ts/NonEmptyArray'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const nonEmptyArray: Monad1<URI> &\n  Comonad1<URI> &\n  TraversableWithIndex1<URI, number> &\n  FunctorWithIndex1<URI, number> &\n  FoldableWithIndex1<URI, number> &\n  Alt1<URI> = {\n  URI,\n  of,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  ap: _ap,\n  chain: flatMap,\n  extend: _extend,\n  extract: extract,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex,\n  traverseWithIndex: _traverseWithIndex,\n  alt: _alt\n}\n"
  },
  {
    "path": "src/Option.ts",
    "content": "/**\n * ```ts\n * type Option<A> = None | Some<A>\n * ```\n *\n * `Option<A>` is a container for an optional value of type `A`. If the value of type `A` is present, the `Option<A>` is\n * an instance of `Some<A>`, containing the present value of type `A`. If the value is absent, the `Option<A>` is an\n * instance of `None`.\n *\n * An option could be looked at as a collection or foldable structure with either one or zero elements.\n * Another way to look at `Option` is: it represents the effect of a possibly failing computation.\n *\n *\n * @example\n * import * as O from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * const double = (n: number): number => n * 2\n *\n * export const imperative = (as: ReadonlyArray<number>): string => {\n *   const head = (as: ReadonlyArray<number>): number => {\n *     if (as.length === 0) {\n *       throw new Error()\n *     }\n *     return as[0]\n *   }\n *   const inverse = (n: number): number => {\n *     if (n === 0) {\n *       throw new Error()\n *     }\n *     return 1 / n\n *   }\n *   try {\n *     return `Result is ${inverse(double(head(as)))}`\n *   } catch (e) {\n *     return 'no result'\n *   }\n * }\n *\n * export const functional = (as: ReadonlyArray<number>): string => {\n *   const head = <A>(as: ReadonlyArray<A>): O.Option<A> =>\n *     as.length === 0 ? O.none : O.some(as[0])\n *   const inverse = (n: number): O.Option<number> =>\n *     n === 0 ? O.none : O.some(1 / n)\n *   return pipe(\n *     as,\n *     head,\n *     O.map(double),\n *     O.flatMap(inverse),\n *     O.match(\n *       () => 'no result', // onNone handler\n *       (head) => `Result is ${head}` // onSome handler\n *     )\n *   )\n * }\n *\n * assert.deepStrictEqual(imperative([1, 2, 3]), functional([1, 2, 3]))\n * assert.deepStrictEqual(imperative([]), functional([]))\n * assert.deepStrictEqual(imperative([0]), functional([0]))\n *\n * @since 2.0.0\n */\nimport { Alt1 } from './Alt'\nimport { Alternative1 } from './Alternative'\nimport { Applicative as ApplicativeHKT, Applicative1, getApplicativeMonoid } from './Applicative'\nimport {\n  apFirst as apFirst_,\n  Apply1,\n  apS as apS_,\n  apSecond as apSecond_,\n  getApplySemigroup as getApplySemigroup_\n} from './Apply'\nimport * as chainable from './Chain'\nimport { Compactable1 } from './Compactable'\nimport { Either } from './Either'\nimport { Eq } from './Eq'\nimport { Extend1 } from './Extend'\nimport { Filterable1 } from './Filterable'\nimport { Foldable1 } from './Foldable'\nimport {\n  chainEitherK as chainEitherK_,\n  FromEither1,\n  fromEitherK as fromEitherK_,\n  tapEither as tapEither_\n} from './FromEither'\nimport { constNull, constUndefined, dual, flow, identity, LazyArg, pipe } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport { HKT } from './HKT'\nimport * as _ from './internal'\nimport { Monad1 } from './Monad'\nimport { MonadThrow1 } from './MonadThrow'\nimport { Monoid } from './Monoid'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Ord } from './Ord'\nimport { Pointed1 } from './Pointed'\nimport { not, Predicate } from './Predicate'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { first, last, Semigroup } from './Semigroup'\nimport { Separated, separated } from './Separated'\nimport { Show } from './Show'\nimport { PipeableTraverse1, Traversable1 } from './Traversable'\nimport { PipeableWilt1, PipeableWither1, wiltDefault, Witherable1, witherDefault } from './Witherable'\nimport { guard as guard_, Zero1 } from './Zero'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface None {\n  readonly _tag: 'None'\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Some<A> {\n  readonly _tag: 'Some'\n  readonly value: A\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport type Option<A> = None | Some<A>\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const none: Option<never> = _.none\n\n/**\n * Constructs a `Some`. Represents an optional value that exists.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const some: <A>(a: A) => Option<A> = _.some\n\n/**\n * Returns a *smart constructor* based on the given predicate.\n *\n * @example\n * import { none, some, fromPredicate } from 'fp-ts/Option'\n *\n * const getOption = fromPredicate((n: number) => n >= 0)\n *\n * assert.deepStrictEqual(getOption(-1), none)\n * assert.deepStrictEqual(getOption(1), some(1))\n *\n * @category lifting\n * @since 2.0.0\n */\nexport function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => Option<B>\nexport function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => Option<B>\nexport function fromPredicate<A>(predicate: Predicate<A>): (a: A) => Option<A>\nexport function fromPredicate<A>(predicate: Predicate<A>): (a: A) => Option<A> {\n  return (a) => (predicate(a) ? some(a) : none)\n}\n\n/**\n * Returns the `Left` value of an `Either` if possible.\n *\n * @example\n * import { getLeft, none, some } from 'fp-ts/Option'\n * import { right, left } from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(getLeft(right(1)), none)\n * assert.deepStrictEqual(getLeft(left('a')), some('a'))\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const getLeft = <E, A>(ma: Either<E, A>): Option<E> => (ma._tag === 'Right' ? none : some(ma.left))\n\n/**\n * Returns the `Right` value of an `Either` if possible.\n *\n * @example\n * import { getRight, none, some } from 'fp-ts/Option'\n * import { right, left } from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(getRight(right(1)), some(1))\n * assert.deepStrictEqual(getRight(left('a')), none)\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const getRight = <E, A>(ma: Either<E, A>): Option<A> => (ma._tag === 'Left' ? none : some(ma.right))\n\nconst _map: Monad1<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _ap: Monad1<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\nconst _reduce: Foldable1<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\nconst _foldMap: Foldable1<URI>['foldMap'] = (M) => {\n  const foldMapM = foldMap(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\nconst _reduceRight: Foldable1<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\nconst _traverse: Traversable1<URI>['traverse'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: Option<A>, f: (a: A) => HKT<F, B>) => HKT<F, Option<B>>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\n/* istanbul ignore next */\nconst _alt: Alt1<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\nconst _filter: Filterable1<URI>['filter'] = <A>(fa: Option<A>, predicate: Predicate<A>) => pipe(fa, filter(predicate))\n/* istanbul ignore next */\nconst _filterMap: Filterable1<URI>['filterMap'] = (fa, f) => pipe(fa, filterMap(f))\n/* istanbul ignore next */\nconst _extend: Extend1<URI>['extend'] = (wa, f) => pipe(wa, extend(f))\n/* istanbul ignore next */\nconst _partition: Filterable1<URI>['partition'] = <A>(fa: Option<A>, predicate: Predicate<A>) =>\n  pipe(fa, partition(predicate))\n/* istanbul ignore next */\nconst _partitionMap: Filterable1<URI>['partitionMap'] = (fa, f) => pipe(fa, partitionMap(f))\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Option'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Option<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getShow = <A>(S: Show<A>): Show<Option<A>> => ({\n  show: (ma) => (isNone(ma) ? 'none' : `some(${S.show(ma.value)})`)\n})\n\n/**\n * @example\n * import { none, some, getEq } from 'fp-ts/Option'\n * import * as N from 'fp-ts/number'\n *\n * const E = getEq(N.Eq)\n * assert.strictEqual(E.equals(none, none), true)\n * assert.strictEqual(E.equals(none, some(1)), false)\n * assert.strictEqual(E.equals(some(1), none), false)\n * assert.strictEqual(E.equals(some(1), some(2)), false)\n * assert.strictEqual(E.equals(some(1), some(1)), true)\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getEq = <A>(E: Eq<A>): Eq<Option<A>> => ({\n  equals: (x, y) => x === y || (isNone(x) ? isNone(y) : isNone(y) ? false : E.equals(x.value, y.value))\n})\n\n/**\n * The `Ord` instance allows `Option` values to be compared with\n * `compare`, whenever there is an `Ord` instance for\n * the type the `Option` contains.\n *\n * `None` is considered to be less than any `Some` value.\n *\n *\n * @example\n * import { none, some, getOrd } from 'fp-ts/Option'\n * import * as N from 'fp-ts/number'\n *\n * const O = getOrd(N.Ord)\n * assert.strictEqual(O.compare(none, none), 0)\n * assert.strictEqual(O.compare(none, some(1)), -1)\n * assert.strictEqual(O.compare(some(1), none), 1)\n * assert.strictEqual(O.compare(some(1), some(2)), -1)\n * assert.strictEqual(O.compare(some(1), some(1)), 0)\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getOrd = <A>(O: Ord<A>): Ord<Option<A>> => ({\n  equals: getEq(O).equals,\n  compare: (x, y) => (x === y ? 0 : isSome(x) ? (isSome(y) ? O.compare(x.value, y.value) : 1) : isSome(y) ? -1 : 0)\n})\n\n/**\n * Monoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are\n * concatenated using the provided `Semigroup`\n *\n * | x       | y       | concat(x, y)       |\n * | ------- | ------- | ------------------ |\n * | none    | none    | none               |\n * | some(a) | none    | some(a)            |\n * | none    | some(b) | some(b)            |\n * | some(a) | some(b) | some(concat(a, b)) |\n *\n * @example\n * import { getMonoid, some, none } from 'fp-ts/Option'\n * import { SemigroupSum } from 'fp-ts/number'\n *\n * const M = getMonoid(SemigroupSum)\n * assert.deepStrictEqual(M.concat(none, none), none)\n * assert.deepStrictEqual(M.concat(some(1), none), some(1))\n * assert.deepStrictEqual(M.concat(none, some(1)), some(1))\n * assert.deepStrictEqual(M.concat(some(1), some(2)), some(3))\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getMonoid = <A>(S: Semigroup<A>): Monoid<Option<A>> => ({\n  concat: (x, y) => (isNone(x) ? y : isNone(y) ? x : some(S.concat(x.value, y.value))),\n  empty: none\n})\n\n/**\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => (fa: Option<A>) => Option<B> = (f) => (fa) =>\n  isNone(fa) ? none : some(f(fa.value))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the `Some` value of this `Option` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <_>(self: Option<_>) => Option<A>\n  <_, A>(self: Option<_>, a: A): Option<A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the `Some` value of this `Option` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <_>(self: Option<_>) => Option<void> = asUnit_(Functor)\n\n/**\n * @category constructors\n * @since 2.7.0\n */\nexport const of: <A>(a: A) => Option<A> = some\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * @since 2.0.0\n */\nexport const ap: <A>(fa: Option<A>) => <B>(fab: Option<(a: A) => B>) => Option<B> = (fa) => (fab) =>\n  isNone(fab) ? none : isNone(fa) ? none : some(fab.value(fa.value))\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A) => Option<B>): (ma: Option<A>) => Option<B>\n  <A, B>(ma: Option<A>, f: (a: A) => Option<B>): Option<B>\n} = /*#__PURE__*/ dual(2, <A, B>(ma: Option<A>, f: (a: A) => Option<B>): Option<B> => (isNone(ma) ? none : f(ma.value)))\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Option<A>) => B = (b, f) => (fa) =>\n  isNone(fa) ? b : f(b, fa.value)\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Option<A>) => M = (M) => (f) => (fa) =>\n  isNone(fa) ? M.empty : f(fa.value)\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Option<A>) => B = (b, f) => (fa) =>\n  isNone(fa) ? b : f(fa.value, b)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable1<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\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/Option\"\n *\n * assert.deepStrictEqual(O.orElse(O.none, () => O.none), O.none)\n * assert.deepStrictEqual(O.orElse(O.some(1), () => O.none), O.some(1))\n * assert.deepStrictEqual(O.orElse(O.none, () => O.some('b')), O.some('b'))\n * assert.deepStrictEqual(O.orElse(O.some(1), () => O.some('b')), O.some(1))\n *\n * @category error handling\n * @since 2.16.0\n */\nexport const orElse: {\n  <B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<A | B>\n  <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<A | B>\n} = dual(2, <A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<A | B> => (isNone(self) ? that() : self))\n\n/**\n * Alias of `orElse`.\n *\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category legacy\n * @since 2.9.0\n */\nexport const altW: <B>(that: LazyArg<Option<B>>) => <A>(fa: Option<A>) => Option<A | B> = orElse\n\n/**\n * Alias of `orElse`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const alt: <A>(that: LazyArg<Option<A>>) => (fa: Option<A>) => Option<A> = orElse\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt1<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @since 2.7.0\n */\nexport const zero: <A>() => Option<A> = () => none\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const Zero: Zero1<URI> = {\n  URI,\n  zero\n}\n\n/**\n * @category do notation\n * @since 2.11.0\n */\nexport const guard = /*#__PURE__*/ guard_(Zero, Pointed)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alternative: Alternative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  alt: _alt,\n  zero\n}\n\n/**\n * @since 2.0.0\n */\nexport const extend: <A, B>(f: (wa: Option<A>) => B) => (wa: Option<A>) => Option<B> = (f) => (wa) =>\n  isNone(wa) ? none : some(f(wa))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Extend: Extend1<URI> = {\n  URI,\n  map: _map,\n  extend: _extend\n}\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const compact: <A>(fa: Option<Option<A>>) => Option<A> = /*#__PURE__*/ flatMap(identity)\n\nconst defaultSeparated = /*#__PURE__*/ separated(none, none)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const separate: <A, B>(ma: Option<Either<A, B>>) => Separated<Option<A>, Option<B>> = (ma) =>\n  isNone(ma) ? defaultSeparated : separated(getLeft(ma.value), getRight(ma.value))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Compactable: Compactable1<URI> = {\n  URI,\n  compact,\n  separate\n}\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Option<A>) => Option<B>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: Option<B>) => Option<B>\n  <A>(predicate: Predicate<A>): (fa: Option<A>) => Option<A>\n} =\n  <A>(predicate: Predicate<A>) =>\n  (fa: Option<A>) =>\n    isNone(fa) ? none : predicate(fa.value) ? fa : none\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Option<A>) => Option<B> = (f) => (fa) =>\n  isNone(fa) ? none : f(fa.value)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Option<A>) => Separated<Option<A>, Option<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: Option<B>) => Separated<Option<B>, Option<B>>\n  <A>(predicate: Predicate<A>): (fa: Option<A>) => Separated<Option<A>, Option<A>>\n} =\n  <A>(predicate: Predicate<A>) =>\n  (fa: Option<A>) =>\n    separated(_filter(fa, not(predicate)), _filter(fa, predicate))\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: Option<A>) => Separated<Option<B>, Option<C>> = (f) => flow(map(f), separate)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Filterable: Filterable1<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse1<URI> =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A, B>(f: (a: A) => HKT<F, B>) =>\n  (ta: Option<A>): HKT<F, Option<B>> =>\n    isNone(ta) ? F.of(none) : F.map(f(ta.value), some)\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable1<URI>['sequence'] =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A>(ta: Option<HKT<F, A>>): HKT<F, Option<A>> =>\n    isNone(ta) ? F.of(none) : F.map(ta.value, some)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable1<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\nconst _wither: Witherable1<URI>['wither'] = /*#__PURE__*/ witherDefault(Traversable, Compactable)\n\nconst _wilt: Witherable1<URI>['wilt'] = /*#__PURE__*/ wiltDefault(Traversable, Compactable)\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wither: PipeableWither1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(f: (a: A) => HKT<F, Option<B>>) => (fa: Option<A>) => HKT<F, Option<B>>) => {\n  const _witherF = _wither(F)\n  return (f) => (fa) => _witherF(fa, f)\n}\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wilt: PipeableWilt1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B, C>(f: (a: A) => HKT<F, Either<B, C>>) => (fa: Option<A>) => HKT<F, Separated<Option<B>, Option<C>>>) => {\n  const _wiltF = _wilt(F)\n  return (f) => (fa) => _wiltF(fa, f)\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Witherable: Witherable1<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  wither: _wither,\n  wilt: _wilt\n}\n\n/**\n * @since 2.7.0\n */\nexport const throwError: MonadThrow1<URI>['throwError'] = () => none\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const MonadThrow: MonadThrow1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  throwError\n}\n\n/**\n * Transforms an `Either` to an `Option` discarding the error.\n *\n * Alias of [getRight](#getright)\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const fromEither: <A>(fa: Either<unknown, A>) => Option<A> = getRight\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromEither: FromEither1<URI> = {\n  URI,\n  fromEither\n}\n\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n\n/**\n * Returns `true` if the option is an instance of `Some`, `false` otherwise.\n *\n * @example\n * import { some, none, isSome } from 'fp-ts/Option'\n *\n * assert.strictEqual(isSome(some(1)), true)\n * assert.strictEqual(isSome(none), false)\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isSome: <A>(fa: Option<A>) => fa is Some<A> = _.isSome\n\n/**\n * Returns `true` if the option is `None`, `false` otherwise.\n *\n * @example\n * import { some, none, isNone } from 'fp-ts/Option'\n *\n * assert.strictEqual(isNone(some(1)), false)\n * assert.strictEqual(isNone(none), true)\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isNone = (fa: Option<unknown>): fa is None => fa._tag === 'None'\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW =\n  <B, A, C>(onNone: LazyArg<B>, onSome: (a: A) => C) =>\n  (ma: Option<A>): B | C =>\n    isNone(ma) ? onNone() : onSome(ma.value)\n\n/**\n * Alias of [`matchW`](#matchw).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchW\n\n/**\n * Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is\n * returned, otherwise the function is applied to the value inside the `Some` and the result is returned.\n *\n * @example\n * import { some, none, match } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     match(() => 'a none', a => `a some containing ${a}`)\n *   ),\n *   'a some containing 1'\n * )\n *\n * assert.strictEqual(\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 2.10.0\n */\nexport const match: <A, B>(onNone: LazyArg<B>, onSome: (a: A) => B) => (ma: Option<A>) => B = matchW\n\n/**\n * Alias of [`match`](#match).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const fold = match\n\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.6.0\n */\nexport const getOrElseW =\n  <B>(onNone: LazyArg<B>) =>\n  <A>(ma: Option<A>): A | B =>\n    isNone(ma) ? onNone() : ma.value\n\n/**\n * Extracts the value out of the structure, if it exists. Otherwise returns the given default value\n *\n * @example\n * import { some, none, getOrElse } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     getOrElse(() => 0)\n *   ),\n *   1\n * )\n * assert.strictEqual(\n *   pipe(\n *     none,\n *     getOrElse(() => 0)\n *   ),\n *   0\n * )\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const getOrElse: <A>(onNone: LazyArg<A>) => (ma: Option<A>) => A = getOrElseW\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <A>(mma: Option<Option<A>>) => Option<A> = compact\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.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} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as O from 'fp-ts/Option'\n * import * as E from 'fp-ts/Either'\n *\n * const compute = (value: number) => pipe(\n *   O.of(value),\n *   O.tapEither((value) => value > 0 ? E.right('ok') : E.left('error')),\n * )\n *\n * assert.deepStrictEqual(compute(1), O.of(1))\n * assert.deepStrictEqual(compute(-42), O.none)\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapEither: {\n  <A, E, _>(f: (a: A) => Either<E, _>): (self: Option<A>) => Option<A>\n  <A, E, _>(self: Option<A>, f: (a: A) => Either<E, _>): Option<A>\n} = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain))\n\n/**\n * @since 2.0.0\n */\nexport const duplicate: <A>(ma: Option<A>) => Option<Option<A>> = /*#__PURE__*/ extend(identity)\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => Option<B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n/**\n * @category sequencing\n * @since 2.11.0\n */\nexport const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Option<A>) => Option<B> =\n  /*#__PURE__*/ chainEitherK_(FromEither, Chain)\n\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: Option<A>) => Option<A> = tapEither\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 * @example\n * import { none, some, fromNullable } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(fromNullable(undefined), none)\n * assert.deepStrictEqual(fromNullable(null), none)\n * assert.deepStrictEqual(fromNullable(1), some(1))\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const fromNullable = <A>(a: A): Option<NonNullable<A>> => (a == null ? none : some(a as NonNullable<A>))\n\n/**\n * Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a\n * `Some`.\n *\n * See also [`tryCatchK`](#trycatchk).\n *\n * @example\n * import { none, some, tryCatch } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(\n *   tryCatch(() => {\n *     throw new Error()\n *   }),\n *   none\n * )\n * assert.deepStrictEqual(tryCatch(() => 1), some(1))\n *\n * @category interop\n * @since 2.0.0\n */\nexport const tryCatch = <A>(f: LazyArg<A>): Option<A> => {\n  try {\n    return some(f())\n  } catch (e) {\n    return none\n  }\n}\n\n/**\n * Converts a function that may throw to one returning a `Option`.\n *\n * @category interop\n * @since 2.10.0\n */\nexport const tryCatchK =\n  <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): ((...a: A) => Option<B>) =>\n  (...a) =>\n    tryCatch(() => f(...a))\n\n/**\n * Returns a *smart constructor* from a function that returns a nullable value.\n *\n * @example\n * import { fromNullableK, none, some } from 'fp-ts/Option'\n *\n * const f = (s: string): number | undefined => {\n *   const n = parseFloat(s)\n *   return isNaN(n) ? undefined : n\n * }\n *\n * const g = fromNullableK(f)\n *\n * assert.deepStrictEqual(g('1'), some(1))\n * assert.deepStrictEqual(g('a'), none)\n *\n * @category lifting\n * @since 2.9.0\n */\nexport const fromNullableK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Option<NonNullable<B>> = (f) => flow(f, fromNullable)\n\n/**\n * This is `chain` + `fromNullable`, useful when working with optional values.\n *\n * @example\n * import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * interface Employee {\n *   readonly company?: {\n *     readonly address?: {\n *       readonly street?: {\n *         readonly name?: string\n *       }\n *     }\n *   }\n * }\n *\n * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     fromNullable(employee1.company),\n *     chainNullableK(company => company.address),\n *     chainNullableK(address => address.street),\n *     chainNullableK(street => street.name)\n *   ),\n *   some('high street')\n * )\n *\n * const employee2: Employee = { company: { address: { street: {} } } }\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     fromNullable(employee2.company),\n *     chainNullableK(company => company.address),\n *     chainNullableK(address => address.street),\n *     chainNullableK(street => street.name)\n *   ),\n *   none\n * )\n *\n * @category sequencing\n * @since 2.9.0\n */\nexport const chainNullableK =\n  <A, B>(f: (a: A) => B | null | undefined) =>\n  (ma: Option<A>): Option<NonNullable<B>> =>\n    isNone(ma) ? none : fromNullable(f(ma.value))\n\n/**\n * Extracts the value out of the structure, if it exists. Otherwise returns `null`.\n *\n * @example\n * import { some, none, toNullable } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     toNullable\n *   ),\n *   1\n * )\n * assert.strictEqual(\n *   pipe(\n *     none,\n *     toNullable\n *   ),\n *   null\n * )\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const toNullable: <A>(ma: Option<A>) => A | null = /*#__PURE__*/ match(constNull, identity)\n\n/**\n * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`.\n *\n * @example\n * import { some, none, toUndefined } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     toUndefined\n *   ),\n *   1\n * )\n * assert.strictEqual(\n *   pipe(\n *     none,\n *     toUndefined\n *   ),\n *   undefined\n * )\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const toUndefined: <A>(ma: Option<A>) => A | undefined = /*#__PURE__*/ match(constUndefined, identity)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Returns `true` if `ma` contains `a`\n *\n * @example\n * import { some, none, elem } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n * import * as N from 'fp-ts/number'\n *\n * assert.strictEqual(pipe(some(1), elem(N.Eq)(1)), true)\n * assert.strictEqual(pipe(some(1), elem(N.Eq)(2)), false)\n * assert.strictEqual(pipe(none, elem(N.Eq)(1)), false)\n *\n * @since 2.0.0\n */\nexport function elem<A>(E: Eq<A>): {\n  (a: A): (ma: Option<A>) => boolean\n  (a: A, ma: Option<A>): boolean\n}\nexport function elem<A>(E: Eq<A>): (a: A, ma?: Option<A>) => boolean | ((ma: Option<A>) => boolean) {\n  return (a, ma?) => {\n    if (ma === undefined) {\n      const elemE = elem(E)\n      return (ma) => elemE(a, ma)\n    }\n    return isNone(ma) ? false : E.equals(a, ma.value)\n  }\n}\n\n/**\n * Returns `true` if the predicate is satisfied by the wrapped value\n *\n * @example\n * import { some, none, exists } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     exists(n => n > 0)\n *   ),\n *   true\n * )\n * assert.strictEqual(\n *   pipe(\n *     some(1),\n *     exists(n => n > 1)\n *   ),\n *   false\n * )\n * assert.strictEqual(\n *   pipe(\n *     none,\n *     exists(n => n > 0)\n *   ),\n *   false\n * )\n *\n * @since 2.0.0\n */\nexport const exists =\n  <A>(predicate: Predicate<A>) =>\n  (ma: Option<A>): boolean =>\n    isNone(ma) ? false : predicate(ma.value)\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: Option<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n/**\n * @since 2.11.0\n */\nexport const ApT: Option<readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex =\n  <A, B>(f: (index: number, a: A) => Option<B>) =>\n  (as: ReadonlyNonEmptyArray<A>): Option<ReadonlyNonEmptyArray<B>> => {\n    const o = f(0, _.head(as))\n    if (isNone(o)) {\n      return none\n    }\n    const out: NonEmptyArray<B> = [o.value]\n    for (let i = 1; i < as.length; i++) {\n      const o = f(i, as[i])\n      if (isNone(o)) {\n        return none\n      }\n      out.push(o.value)\n    }\n    return some(out)\n  }\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, B>(\n  f: (index: number, a: A) => Option<B>\n): ((as: ReadonlyArray<A>) => Option<ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Option<B>\n) => (as: ReadonlyArray<A>) => Option<ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <A, B>(f: (a: A) => Option<B>): ((as: ReadonlyArray<A>) => Option<ReadonlyArray<B>>) =>\n  traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <A>(arr: ReadonlyArray<Option<A>>) => Option<ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <A, B>(f: (a: A) => Option<B>) => (ma: Option<A>) => Option<B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => Option<B>) => (first: Option<A>) => Option<A> = tap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use `Refinement` module instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getRefinement<A, B extends A>(getOption: (a: A) => Option<B>): Refinement<A, B> {\n  return (a: A): a is B => isSome(getOption(a))\n}\n\n/**\n * Use [`chainNullableK`](#chainnullablek) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const mapNullable = chainNullableK\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `O.Functor` instead of `O.option`\n * (where `O` is from `import O from 'fp-ts/Option'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const option: Monad1<URI> &\n  Foldable1<URI> &\n  Alternative1<URI> &\n  Extend1<URI> &\n  Witherable1<URI> &\n  MonadThrow1<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  zero,\n  alt: _alt,\n  extend: _extend,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  wither: _wither,\n  wilt: _wilt,\n  throwError\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplySemigroup: <A>(S: Semigroup<A>) => Semigroup<Option<A>> = /*#__PURE__*/ getApplySemigroup_(Apply)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplyMonoid: <A>(M: Monoid<A>) => Monoid<Option<A>> = /*#__PURE__*/ getApplicativeMonoid(Applicative)\n\n/**\n * Use\n *\n * ```ts\n * import { first } from 'fp-ts/Semigroup'\n * import { getMonoid } from 'fp-ts/Option'\n *\n * getMonoid(first())\n * ```\n *\n * instead.\n *\n * Monoid returning the left-most non-`None` value\n *\n * | x       | y       | concat(x, y) |\n * | ------- | ------- | ------------ |\n * | none    | none    | none         |\n * | some(a) | none    | some(a)      |\n * | none    | some(b) | some(b)      |\n * | some(a) | some(b) | some(a)      |\n *\n * @example\n * import { getFirstMonoid, some, none } from 'fp-ts/Option'\n *\n * const M = getFirstMonoid<number>()\n * assert.deepStrictEqual(M.concat(none, none), none)\n * assert.deepStrictEqual(M.concat(some(1), none), some(1))\n * assert.deepStrictEqual(M.concat(none, some(2)), some(2))\n * assert.deepStrictEqual(M.concat(some(1), some(2)), some(1))\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getFirstMonoid = <A = never>(): Monoid<Option<A>> => getMonoid(first())\n\n/**\n * Use\n *\n * ```ts\n * import { last } from 'fp-ts/Semigroup'\n * import { getMonoid } from 'fp-ts/Option'\n *\n * getMonoid(last())\n * ```\n *\n * instead.\n *\n * Monoid returning the right-most non-`None` value\n *\n * | x       | y       | concat(x, y) |\n * | ------- | ------- | ------------ |\n * | none    | none    | none         |\n * | some(a) | none    | some(a)      |\n * | none    | some(b) | some(b)      |\n * | some(a) | some(b) | some(b)      |\n *\n * @example\n * import { getLastMonoid, some, none } from 'fp-ts/Option'\n *\n * const M = getLastMonoid<number>()\n * assert.deepStrictEqual(M.concat(none, none), none)\n * assert.deepStrictEqual(M.concat(some(1), none), some(1))\n * assert.deepStrictEqual(M.concat(none, some(2)), some(2))\n * assert.deepStrictEqual(M.concat(some(1), some(2)), some(2))\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getLastMonoid = <A = never>(): Monoid<Option<A>> => getMonoid(last())\n"
  },
  {
    "path": "src/OptionT.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport {\n  ApplicativeComposition2C1,\n  ApplicativeComposition11,\n  ApplicativeComposition21,\n  ApplicativeCompositionHKT1\n} from './Applicative'\nimport { ap as ap_, Apply, Apply1, Apply2, Apply2C, Apply3, Apply3C, Apply4 } from './Apply'\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C, Chain4 } from './Chain'\nimport { Either } from './Either'\nimport { constant, flow, LazyArg, pipe } from './function'\nimport { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C, Functor4, map as map_ } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Monad, Monad1, Monad2, Monad2C, Monad3, Monad3C, Monad4 } from './Monad'\nimport * as O from './Option'\nimport { Pointed, Pointed1, Pointed2, Pointed2C, Pointed3, Pointed3C, Pointed4 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { Refinement } from './Refinement'\n\nimport Option = O.Option\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport function some<F extends URIS4>(F: Pointed4<F>): <A, S, R, E>(a: A) => Kind4<F, S, R, E, Option<A>>\nexport function some<F extends URIS3>(F: Pointed3<F>): <A, R, E>(a: A) => Kind3<F, R, E, Option<A>>\nexport function some<F extends URIS3, E>(F: Pointed3C<F, E>): <A, R>(a: A) => Kind3<F, R, E, Option<A>>\nexport function some<F extends URIS2>(F: Pointed2<F>): <A, E>(a: A) => Kind2<F, E, Option<A>>\nexport function some<F extends URIS2, E>(F: Pointed2C<F, E>): <A>(a: A) => Kind2<F, E, Option<A>>\nexport function some<F extends URIS>(F: Pointed1<F>): <A>(a: A) => Kind<F, Option<A>>\nexport function some<F>(F: Pointed<F>): <A>(a: A) => HKT<F, Option<A>>\nexport function some<F>(F: Pointed<F>): <A>(a: A) => HKT<F, Option<A>> {\n  return flow(O.some, F.of)\n}\n\n/**\n * @since 2.10.0\n */\nexport function zero<F extends URIS4>(F: Pointed4<F>): <S, R, E, A>() => Kind4<F, S, R, E, Option<A>>\nexport function zero<F extends URIS3>(F: Pointed3<F>): <R, E, A>() => Kind3<F, R, E, Option<A>>\nexport function zero<F extends URIS3, E>(F: Pointed3C<F, E>): <R, A>() => Kind3<F, R, E, Option<A>>\nexport function zero<F extends URIS2>(F: Pointed2<F>): <E, A>() => Kind2<F, E, Option<A>>\nexport function zero<F extends URIS2, E>(F: Pointed2C<F, E>): <A>() => Kind2<F, E, Option<A>>\nexport function zero<F extends URIS>(F: Pointed1<F>): <A>() => Kind<F, Option<A>>\nexport function zero<F>(F: Pointed<F>): <A>() => HKT<F, Option<A>>\nexport function zero<F>(F: Pointed<F>): <A>() => HKT<F, Option<A>> {\n  return constant(F.of(O.none))\n}\n\n/**\n * @since 2.10.0\n */\nexport function fromF<F extends URIS4>(\n  F: Functor4<F>\n): <S, R, E, A>(ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, Option<A>>\nexport function fromF<F extends URIS3>(F: Functor3<F>): <R, E, A>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, Option<A>>\nexport function fromF<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <R, A>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, Option<A>>\nexport function fromF<F extends URIS2>(F: Functor2<F>): <E, A>(ma: Kind2<F, E, A>) => Kind2<F, E, Option<A>>\nexport function fromF<F extends URIS2, E>(F: Functor2C<F, E>): <A>(ma: Kind2<F, E, A>) => Kind2<F, E, Option<A>>\nexport function fromF<F extends URIS>(F: Functor1<F>): <A>(ma: Kind<F, A>) => Kind<F, Option<A>>\nexport function fromF<F>(F: Functor<F>): <A>(ma: HKT<F, A>) => HKT<F, Option<A>>\nexport function fromF<F>(F: Functor<F>): <A>(ma: HKT<F, A>) => HKT<F, Option<A>> {\n  return (ma) => F.map(ma, O.some)\n}\n\n/**\n * @since 2.10.0\n */\nexport function fromNullable<F extends URIS4>(\n  F: Pointed4<F>\n): <A, S, R, E>(a: A) => Kind4<F, S, R, E, Option<NonNullable<A>>>\nexport function fromNullable<F extends URIS3>(F: Pointed3<F>): <A, R, E>(a: A) => Kind3<F, R, E, Option<NonNullable<A>>>\nexport function fromNullable<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): <A, R>(a: A) => Kind3<F, R, E, Option<NonNullable<A>>>\nexport function fromNullable<F extends URIS2>(F: Pointed2<F>): <A, E>(a: A) => Kind2<F, E, Option<NonNullable<A>>>\nexport function fromNullable<F extends URIS2, E>(F: Pointed2C<F, E>): <A>(a: A) => Kind2<F, E, Option<NonNullable<A>>>\nexport function fromNullable<F extends URIS>(F: Pointed1<F>): <A>(a: A) => Kind<F, Option<NonNullable<A>>>\nexport function fromNullable<F>(F: Pointed<F>): <A>(a: A) => HKT<F, Option<NonNullable<A>>>\nexport function fromNullable<F>(F: Pointed<F>): <A>(a: A) => HKT<F, Option<NonNullable<A>>> {\n  return flow(O.fromNullable, F.of)\n}\n\n/**\n * @since 2.10.0\n */\nexport function fromNullableK<F extends URIS4>(\n  F: Pointed4<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <S, R, E>(...a: A) => Kind4<F, S, R, E, Option<NonNullable<B>>>\nexport function fromNullableK<F extends URIS3>(\n  F: Pointed3<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <R, E>(...a: A) => Kind3<F, R, E, Option<NonNullable<B>>>\nexport function fromNullableK<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <R>(...a: A) => Kind3<F, R, E, Option<NonNullable<B>>>\nexport function fromNullableK<F extends URIS2>(\n  F: Pointed2<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <E>(...a: A) => Kind2<F, E, Option<NonNullable<B>>>\nexport function fromNullableK<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Kind2<F, E, Option<NonNullable<B>>>\nexport function fromNullableK<F extends URIS>(\n  F: Pointed1<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => Kind<F, Option<NonNullable<B>>>\nexport function fromNullableK<F>(\n  F: Pointed<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => HKT<F, Option<NonNullable<B>>>\nexport function fromNullableK<F>(\n  F: Pointed<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => HKT<F, Option<NonNullable<B>>> {\n  const fromNullableF = fromNullable(F)\n  return (f) => flow(f, fromNullableF)\n}\n\n/**\n * @since 2.10.0\n */\nexport function chainNullableK<M extends URIS4>(\n  M: Monad4<M>\n): <A, B>(\n  f: (a: A) => B | null | undefined\n) => <S, R, E>(ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<NonNullable<B>>>\nexport function chainNullableK<M extends URIS3>(\n  M: Monad3<M>\n): <A, B>(\n  f: (a: A) => B | null | undefined\n) => <R, E>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<NonNullable<B>>>\nexport function chainNullableK<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <A, B>(\n  f: (a: A) => B | null | undefined\n) => <R>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<NonNullable<B>>>\nexport function chainNullableK<M extends URIS2>(\n  M: Monad2<M>\n): <A, B>(f: (a: A) => B | null | undefined) => <E>(ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<NonNullable<B>>>\nexport function chainNullableK<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(f: (a: A) => B | null | undefined) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<NonNullable<B>>>\nexport function chainNullableK<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(f: (a: A) => B | null | undefined) => (ma: Kind<M, Option<A>>) => Kind<M, Option<NonNullable<B>>>\nexport function chainNullableK<M>(\n  M: Monad<M>\n): <A, B>(f: (a: A) => B | null | undefined) => (ma: HKT<M, Option<A>>) => HKT<M, Option<NonNullable<B>>>\nexport function chainNullableK<M>(\n  M: Monad<M>\n): <A, B>(f: (a: A) => B | null | undefined) => (ma: HKT<M, Option<A>>) => HKT<M, Option<NonNullable<B>>> {\n  const chainM = chain(M)\n  const fromNullableKM = fromNullableK(M)\n  return (f) => chainM(fromNullableKM(f))\n}\n\n/**\n * @since 2.10.0\n */\nexport function fromOptionK<F extends URIS4>(\n  F: Pointed4<F>\n): <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Option<B>\n) => <S, R, E>(...a: A) => Kind4<F, S, R, E, Option<B>>\nexport function fromOptionK<F extends URIS3>(\n  F: Pointed3<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R, E>(...a: A) => Kind3<F, R, E, Option<B>>\nexport function fromOptionK<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <R>(...a: A) => Kind3<F, R, E, Option<B>>\nexport function fromOptionK<F extends URIS2>(\n  F: Pointed2<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => <E>(...a: A) => Kind2<F, E, Option<B>>\nexport function fromOptionK<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind2<F, E, Option<B>>\nexport function fromOptionK<F extends URIS>(\n  F: Pointed1<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => Kind<F, Option<B>>\nexport function fromOptionK<F>(\n  F: Pointed<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => HKT<F, Option<B>>\nexport function fromOptionK<F>(\n  F: Pointed<F>\n): <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => HKT<F, Option<B>> {\n  return (f) => flow(f, F.of)\n}\n\n/**\n * @since 2.10.0\n */\nexport function chainOptionK<M extends URIS4>(\n  M: Monad4<M>\n): <A, B>(f: (a: A) => Option<B>) => <S, R, E>(ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<B>>\nexport function chainOptionK<M extends URIS3>(\n  M: Monad3<M>\n): <A, B>(f: (a: A) => Option<B>) => <R, E>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>\nexport function chainOptionK<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <A, B>(f: (a: A) => Option<B>) => <R>(ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>\nexport function chainOptionK<M extends URIS2>(\n  M: Monad2<M>\n): <A, B>(f: (a: A) => Option<B>) => <E>(ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>\nexport function chainOptionK<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(f: (a: A) => Option<B>) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>\nexport function chainOptionK<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(f: (a: A) => Option<B>) => (ma: Kind<M, Option<A>>) => Kind<M, Option<B>>\nexport function chainOptionK<M>(\n  M: Monad<M>\n): <A, B>(f: (a: A) => Option<B>) => (ma: HKT<M, Option<A>>) => HKT<M, Option<B>>\nexport function chainOptionK<M>(\n  M: Monad<M>\n): <A, B>(f: (a: A) => Option<B>) => (ma: HKT<M, Option<A>>) => HKT<M, Option<B>> {\n  const chainM = chain(M)\n  const fromOptionKM = fromOptionK(M)\n  return (f) => chainM(fromOptionKM(f))\n}\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport function fromPredicate<F extends URIS4>(\n  F: Pointed4<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(a: A) => Kind4<F, S, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <S, R, E, B extends A>(b: B) => Kind4<F, S, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <S, R, E>(a: A) => Kind4<F, S, R, E, Option<A>>\n}\nexport function fromPredicate<F extends URIS3>(\n  F: Pointed3<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R, E>(a: A) => Kind3<F, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <R, E, B extends A>(b: B) => Kind3<F, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <R, E>(a: A) => Kind3<F, R, E, Option<A>>\n}\nexport function fromPredicate<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(a: A) => Kind3<F, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <R, B extends A>(b: B) => Kind3<F, R, E, Option<B>>\n  <A>(predicate: Predicate<A>): <R>(a: A) => Kind3<F, R, E, Option<A>>\n}\nexport function fromPredicate<F extends URIS2>(\n  F: Pointed2<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <E>(a: A) => Kind2<F, E, Option<B>>\n  <A>(predicate: Predicate<A>): <E, B extends A>(b: B) => Kind2<F, E, Option<B>>\n  <A>(predicate: Predicate<A>): <E>(a: A) => Kind2<F, E, Option<A>>\n}\nexport function fromPredicate<F extends URIS2, E>(\n  F: Pointed2C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => Kind2<F, E, Option<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => Kind2<F, E, Option<B>>\n  <A>(predicate: Predicate<A>): (a: A) => Kind2<F, E, Option<A>>\n}\nexport function fromPredicate<F extends URIS>(\n  F: Pointed1<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => Kind<F, Option<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => Kind<F, Option<B>>\n  <A>(predicate: Predicate<A>): (a: A) => Kind<F, Option<A>>\n}\nexport function fromPredicate<F>(F: Pointed<F>): {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => HKT<F, Option<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => HKT<F, Option<B>>\n  <A>(predicate: Predicate<A>): (a: A) => HKT<F, Option<A>>\n}\nexport function fromPredicate<F>(F: Pointed<F>): {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => HKT<F, Option<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => HKT<F, Option<B>>\n  <A>(predicate: Predicate<A>): (a: A) => HKT<F, Option<A>>\n} {\n  return <A>(predicate: Predicate<A>) =>\n    (a: A) =>\n      F.of(O.fromPredicate(predicate)(a))\n}\n\n/**\n * @since 2.10.0\n */\nexport function fromEither<F extends URIS4>(\n  F: Pointed4<F>\n): <A, S, R, E>(e: Either<unknown, A>) => Kind4<F, S, R, E, Option<A>>\nexport function fromEither<F extends URIS3>(\n  F: Pointed3<F>\n): <A, R, E>(e: Either<unknown, A>) => Kind3<F, R, E, Option<A>>\nexport function fromEither<F extends URIS3, E>(\n  F: Pointed3C<F, E>\n): <A, R>(e: Either<unknown, A>) => Kind3<F, R, E, Option<A>>\nexport function fromEither<F extends URIS2>(F: Pointed2<F>): <A, E>(e: Either<unknown, A>) => Kind2<F, E, Option<A>>\nexport function fromEither<F extends URIS2, E>(F: Pointed2C<F, E>): <A>(e: Either<unknown, A>) => Kind2<F, E, Option<A>>\nexport function fromEither<F extends URIS2, E>(F: Pointed2C<F, E>): <A>(e: Either<unknown, A>) => Kind2<F, E, Option<A>>\nexport function fromEither<F extends URIS>(F: Pointed1<F>): <A>(e: Either<unknown, A>) => Kind<F, Option<A>>\nexport function fromEither<F>(F: Pointed<F>): <A>(e: Either<unknown, A>) => HKT<F, Option<A>>\nexport function fromEither<F>(F: Pointed<F>): <A>(e: Either<unknown, A>) => HKT<F, Option<A>> {\n  return flow(O.fromEither, F.of)\n}\n\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport function match<F extends URIS4>(\n  F: Functor4<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => <S, R, E>(ma: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, B>\nexport function match<F extends URIS3>(\n  F: Functor3<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => <R, E>(ma: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, B>\nexport function match<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => <R>(ma: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, B>\nexport function match<F extends URIS2>(\n  F: Functor2<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => <E>(ma: Kind2<F, E, Option<A>>) => Kind2<F, E, B>\nexport function match<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: Kind2<F, E, Option<A>>) => Kind2<F, E, B>\nexport function match<F extends URIS>(\n  F: Functor1<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: Kind<F, Option<A>>) => Kind<F, B>\nexport function match<F>(\n  F: Functor<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: HKT<F, Option<A>>) => HKT<F, B>\nexport function match<F>(\n  F: Functor<F>\n): <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: HKT<F, Option<A>>) => HKT<F, B> {\n  return (onNone, onSome) => (ma) => F.map(ma, O.match(onNone, onSome))\n}\n\n/**\n * @since 2.10.0\n */\nexport function matchE<M extends URIS4>(\n  M: Chain4<M>\n): <S, R, E, B, A>(\n  onNone: () => Kind4<M, S, R, E, B>,\n  onSome: (a: A) => Kind4<M, S, R, E, B>\n) => (ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, B>\nexport function matchE<M extends URIS3>(\n  M: Chain3<M>\n): <R, E, B, A>(\n  onNone: () => Kind3<M, R, E, B>,\n  onSome: (a: A) => Kind3<M, R, E, B>\n) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, B>\nexport function matchE<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <R, B, A>(\n  onNone: () => Kind3<M, R, E, B>,\n  onSome: (a: A) => Kind3<M, R, E, B>\n) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, B>\nexport function matchE<M extends URIS2>(\n  M: Chain2<M>\n): <E, B, A>(\n  onNone: () => Kind2<M, E, B>,\n  onSome: (a: A) => Kind2<M, E, B>\n) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, B>\nexport function matchE<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <B, A>(\n  onNone: () => Kind2<M, E, B>,\n  onSome: (a: A) => Kind2<M, E, B>\n) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, B>\nexport function matchE<M extends URIS>(\n  M: Chain1<M>\n): <B, A>(onNone: () => Kind<M, B>, onSome: (a: A) => Kind<M, B>) => (ma: Kind<M, Option<A>>) => Kind<M, B>\nexport function matchE<M>(\n  M: Chain<M>\n): <B, A>(onNone: () => HKT<M, B>, onSome: (a: A) => HKT<M, B>) => (ma: HKT<M, Option<A>>) => HKT<M, B>\nexport function matchE<M>(\n  M: Chain<M>\n): <B, A>(onNone: () => HKT<M, B>, onSome: (a: A) => HKT<M, B>) => (ma: HKT<M, Option<A>>) => HKT<M, B> {\n  return (onNone, onSome) => (ma) => M.chain(ma, O.match(onNone, onSome))\n}\n\n/**\n * @since 2.10.0\n */\nexport function getOrElse<M extends URIS4>(\n  M: Monad4<M>\n): <S, R, E, A>(onNone: LazyArg<Kind4<M, S, R, E, A>>) => (fa: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, A>\nexport function getOrElse<M extends URIS3>(\n  M: Monad3<M>\n): <R, E, A>(onNone: LazyArg<Kind3<M, R, E, A>>) => (fa: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, A>\nexport function getOrElse<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <R, A>(onNone: LazyArg<Kind3<M, R, E, A>>) => (fa: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, A>\nexport function getOrElse<M extends URIS2>(\n  M: Monad2<M>\n): <E, A>(onNone: LazyArg<Kind2<M, E, A>>) => (fa: Kind2<M, E, Option<A>>) => Kind2<M, E, A>\nexport function getOrElse<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A>(onNone: LazyArg<Kind2<M, E, A>>) => (fa: Kind2<M, E, Option<A>>) => Kind2<M, E, A>\nexport function getOrElse<M extends URIS>(\n  M: Monad1<M>\n): <A>(onNone: LazyArg<Kind<M, A>>) => (fa: Kind<M, Option<A>>) => Kind<M, A>\nexport function getOrElse<M>(M: Monad<M>): <A>(onNone: LazyArg<HKT<M, A>>) => (fa: HKT<M, Option<A>>) => HKT<M, A>\nexport function getOrElse<M>(M: Monad<M>): <A>(onNone: LazyArg<HKT<M, A>>) => (fa: HKT<M, Option<A>>) => HKT<M, A> {\n  return (onNone) => (fa) => M.chain(fa, O.match(onNone, M.of))\n}\n\n/**\n * @since 2.10.0\n */\nexport function map<F extends URIS4>(\n  F: Functor4<F>\n): <A, B>(f: (a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, Option<B>>\nexport function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, Option<B>>\nexport function map<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <A, B>(f: (a: A) => B) => <R>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, Option<B>>\nexport function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, Option<B>>\nexport function map<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <A, B>(f: (a: A) => B) => (fa: Kind2<F, E, Option<A>>) => Kind2<F, E, Option<B>>\nexport function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => (fa: Kind<F, Option<A>>) => Kind<F, Option<B>>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, Option<A>>) => HKT<F, Option<B>>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, Option<A>>) => HKT<F, Option<B>> {\n  return map_(F, O.Functor)\n}\n\n/**\n * @since 2.10.0\n */\nexport function ap<F extends URIS4>(\n  F: Apply4<F>\n): <S, R, E, A>(\n  fa: Kind4<F, S, R, E, Option<A>>\n) => <B>(fab: Kind4<F, S, R, E, Option<(a: A) => B>>) => Kind4<F, S, R, E, Option<B>>\nexport function ap<F extends URIS3>(\n  F: Apply3<F>\n): <R, E, A>(\n  fa: Kind3<F, R, E, Option<A>>\n) => <B>(fab: Kind3<F, R, E, Option<(a: A) => B>>) => Kind3<F, R, E, Option<B>>\nexport function ap<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <R, A>(fa: Kind3<F, R, E, Option<A>>) => <B>(fab: Kind3<F, R, E, Option<(a: A) => B>>) => Kind3<F, R, E, Option<B>>\nexport function ap<F extends URIS2>(\n  F: Apply2<F>\n): <E, A>(fa: Kind2<F, E, Option<A>>) => <B>(fab: Kind2<F, E, Option<(a: A) => B>>) => Kind2<F, E, Option<B>>\nexport function ap<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <A>(fa: Kind2<F, E, Option<A>>) => <B>(fab: Kind2<F, E, Option<(a: A) => B>>) => Kind2<F, E, Option<B>>\nexport function ap<F extends URIS>(\n  F: Apply1<F>\n): <A>(fa: Kind<F, Option<A>>) => <B>(fab: Kind<F, Option<(a: A) => B>>) => Kind<F, Option<B>>\nexport function ap<F>(\n  F: Apply<F>\n): <A>(fa: HKT<F, Option<A>>) => <B>(fab: HKT<F, Option<(a: A) => B>>) => HKT<F, Option<B>>\nexport function ap<F>(\n  F: Apply<F>\n): <A>(fa: HKT<F, Option<A>>) => <B>(fab: HKT<F, Option<(a: A) => B>>) => HKT<F, Option<B>> {\n  return ap_(F, O.Apply)\n}\n\n/**\n * @since 2.10.0\n */\nexport function chain<M extends URIS4>(\n  M: Monad4<M>\n): <A, S, R, E, B>(\n  f: (a: A) => Kind4<M, S, R, E, Option<B>>\n) => (ma: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<B>>\nexport function chain<M extends URIS3>(\n  M: Monad3<M>\n): <A, R, E, B>(f: (a: A) => Kind3<M, R, E, Option<B>>) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>\nexport function chain<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <A, R, B>(f: (a: A) => Kind3<M, R, E, Option<B>>) => (ma: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<B>>\nexport function chain<M extends URIS2>(\n  M: Monad2<M>\n): <A, E, B>(f: (a: A) => Kind2<M, E, Option<B>>) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>\nexport function chain<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(f: (a: A) => Kind2<M, E, Option<B>>) => (ma: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<B>>\nexport function chain<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(f: (a: A) => Kind<M, Option<B>>) => (ma: Kind<M, Option<A>>) => Kind<M, Option<B>>\nexport function chain<M>(\n  M: Monad<M>\n): <A, B>(f: (a: A) => HKT<M, Option<B>>) => (ma: HKT<M, Option<A>>) => HKT<M, Option<B>>\nexport function chain<M>(\n  M: Monad<M>\n): <A, B>(f: (a: A) => HKT<M, Option<B>>) => (ma: HKT<M, Option<A>>) => HKT<M, Option<B>> {\n  const flatMapM = flatMap(M)\n  return (f) => (ma) => flatMapM(ma, f)\n}\n\n/** @internal */\nexport function flatMap<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(ma: Kind<M, Option<A>>, f: (a: A) => Kind<M, Option<B>>) => Kind<M, Option<B>>\n/** @internal */\nexport function flatMap<M>(\n  M: Monad<M>\n): <A, B>(ma: HKT<M, Option<A>>, f: (a: A) => HKT<M, Option<B>>) => HKT<M, Option<B>>\n/** @internal */\nexport function flatMap<M>(\n  M: Monad<M>\n): <A, B>(ma: HKT<M, Option<A>>, f: (a: A) => HKT<M, Option<B>>) => HKT<M, Option<B>> {\n  const zeroM = zero(M)\n  return (ma, f) =>\n    M.chain(\n      ma,\n      O.match(() => zeroM(), f)\n    )\n}\n\n/**\n * @since 2.10.0\n */\nexport function alt<M extends URIS4>(\n  M: Monad4<M>\n): <S, R, E, A>(\n  second: LazyArg<Kind4<M, S, R, E, Option<A>>>\n) => (first: Kind4<M, S, R, E, Option<A>>) => Kind4<M, S, R, E, Option<A>>\nexport function alt<M extends URIS3>(\n  M: Monad3<M>\n): <R, E, A>(\n  second: LazyArg<Kind3<M, R, E, Option<A>>>\n) => (first: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<A>>\nexport function alt<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <R, A>(second: LazyArg<Kind3<M, R, E, Option<A>>>) => (first: Kind3<M, R, E, Option<A>>) => Kind3<M, R, E, Option<A>>\nexport function alt<M extends URIS2>(\n  M: Monad2<M>\n): <E, A>(second: LazyArg<Kind2<M, E, Option<A>>>) => (first: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<A>>\nexport function alt<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A>(second: LazyArg<Kind2<M, E, Option<A>>>) => (first: Kind2<M, E, Option<A>>) => Kind2<M, E, Option<A>>\nexport function alt<M extends URIS>(\n  M: Monad1<M>\n): <A>(second: LazyArg<Kind<M, Option<A>>>) => (first: Kind<M, Option<A>>) => Kind<M, Option<A>>\nexport function alt<M>(\n  M: Monad<M>\n): <A>(second: LazyArg<HKT<M, Option<A>>>) => (first: HKT<M, Option<A>>) => HKT<M, Option<A>>\nexport function alt<M>(\n  M: Monad<M>\n): <A>(second: LazyArg<HKT<M, Option<A>>>) => (first: HKT<M, Option<A>>) => HKT<M, Option<A>> {\n  const _some = some(M)\n  return (second) => (first) => M.chain(first, O.match(second, _some))\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface OptionT<M, A> extends HKT<M, Option<A>> {}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface OptionM<M> extends ApplicativeCompositionHKT1<M, O.URI> {\n  readonly chain: <A, B>(ma: OptionT<M, A>, f: (a: A) => OptionT<M, B>) => OptionT<M, B>\n  readonly alt: <A>(fa: OptionT<M, A>, that: LazyArg<OptionT<M, A>>) => OptionT<M, A>\n  readonly fold: <A, R>(ma: OptionT<M, A>, onNone: LazyArg<HKT<M, R>>, onSome: (a: A) => HKT<M, R>) => HKT<M, R>\n  readonly getOrElse: <A>(ma: OptionT<M, A>, onNone: LazyArg<HKT<M, A>>) => HKT<M, A>\n  readonly fromM: <A>(ma: HKT<M, A>) => OptionT<M, A>\n  readonly none: <A = never>() => OptionT<M, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport type OptionT1<M extends URIS, A> = Kind<M, Option<A>>\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface OptionM1<M extends URIS> extends ApplicativeComposition11<M, O.URI> {\n  readonly chain: <A, B>(ma: OptionT1<M, A>, f: (a: A) => OptionT1<M, B>) => OptionT1<M, B>\n  readonly alt: <A>(fa: OptionT1<M, A>, that: LazyArg<OptionT1<M, A>>) => OptionT1<M, A>\n  readonly fold: <A, R>(ma: OptionT1<M, A>, onNone: LazyArg<Kind<M, R>>, onSome: (a: A) => Kind<M, R>) => Kind<M, R>\n  readonly getOrElse: <A>(ma: OptionT1<M, A>, onNone: LazyArg<Kind<M, A>>) => Kind<M, A>\n  readonly fromM: <A>(ma: Kind<M, A>) => OptionT1<M, A>\n  readonly none: <A = never>() => OptionT1<M, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport type OptionT2<M extends URIS2, E, A> = Kind2<M, E, Option<A>>\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface OptionM2<M extends URIS2> extends ApplicativeComposition21<M, O.URI> {\n  readonly chain: <E, A, B>(ma: OptionT2<M, E, A>, f: (a: A) => OptionT2<M, E, B>) => OptionT2<M, E, B>\n  readonly alt: <E, A>(fa: OptionT2<M, E, A>, that: LazyArg<OptionT2<M, E, A>>) => OptionT2<M, E, A>\n  readonly fold: <E, A, R>(\n    ma: OptionT2<M, E, A>,\n    onNone: LazyArg<Kind2<M, E, R>>,\n    onSome: (a: A) => Kind2<M, E, R>\n  ) => Kind2<M, E, R>\n  readonly getOrElse: <E, A>(ma: OptionT2<M, E, A>, onNone: LazyArg<Kind2<M, E, A>>) => Kind2<M, E, A>\n  readonly fromM: <E, A>(ma: Kind2<M, E, A>) => OptionT2<M, E, A>\n  readonly none: <E = never, A = never>() => OptionT2<M, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.2.0\n * @deprecated\n */\nexport interface OptionM2C<M extends URIS2, E> extends ApplicativeComposition2C1<M, O.URI, E> {\n  readonly chain: <A, B>(ma: OptionT2<M, E, A>, f: (a: A) => OptionT2<M, E, B>) => OptionT2<M, E, B>\n  readonly alt: <A>(fa: OptionT2<M, E, A>, that: LazyArg<OptionT2<M, E, A>>) => OptionT2<M, E, A>\n  readonly fold: <A, R>(\n    ma: OptionT2<M, E, A>,\n    onNone: LazyArg<Kind2<M, E, R>>,\n    onSome: (a: A) => Kind2<M, E, R>\n  ) => Kind2<M, E, R>\n  readonly getOrElse: <A>(ma: OptionT2<M, E, A>, onNone: LazyArg<Kind2<M, E, A>>) => Kind2<M, E, A>\n  readonly fromM: <A>(ma: Kind2<M, E, A>) => OptionT2<M, E, A>\n  readonly none: <A = never>() => OptionT2<M, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getOptionM<M extends URIS2>(M: Monad2<M>): OptionM2<M>\n/** @deprecated */\nexport function getOptionM<M extends URIS2, E>(M: Monad2C<M, E>): OptionM2C<M, E>\n/** @deprecated */\nexport function getOptionM<M extends URIS>(M: Monad1<M>): OptionM1<M>\n/** @deprecated */\nexport function getOptionM<M>(M: Monad<M>): OptionM<M>\n/** @deprecated */\nexport function getOptionM<M>(M: Monad<M>): OptionM<M> {\n  const apM = ap(M)\n  const mapM = map(M)\n  const chainM = chain(M)\n  const altM = alt(M)\n  const foldM = matchE(M)\n  const getOrElseM = getOrElse(M)\n  const zeroM = zero(M)\n\n  return {\n    map: (fa, f) => pipe(fa, mapM(f)),\n    ap: (fab, fa) => pipe(fab, apM(fa)),\n    of: some(M),\n    chain: (ma, f) => pipe(ma, chainM(f)),\n    alt: (fa, that) => pipe(fa, altM(that)),\n    fold: (fa, onNone, onSome) => pipe(fa, foldM(onNone, onSome)),\n    getOrElse: (fa, onNone) => pipe(fa, getOrElseM(onNone)),\n    fromM: fromF(M),\n    none: () => zeroM()\n  }\n}\n"
  },
  {
    "path": "src/Ord.ts",
    "content": "/**\n * The `Ord` type class represents types which support comparisons with a _total order_.\n *\n * Instances should satisfy the laws of total orderings:\n *\n * 1. Reflexivity: `S.compare(a, a) <= 0`\n * 2. Antisymmetry: if `S.compare(a, b) <= 0` and `S.compare(b, a) <= 0` then `a <-> b`\n * 3. Transitivity: if `S.compare(a, b) <= 0` and `S.compare(b, c) <= 0` then `S.compare(a, c) <= 0`\n *\n * @since 2.0.0\n */\nimport { Contravariant1 } from './Contravariant'\nimport { Eq, eqStrict } from './Eq'\nimport { constant, constTrue, pipe } from './function'\nimport { Monoid } from './Monoid'\nimport { Ordering } from './Ordering'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Ord<A> extends Eq<A> {\n  readonly compare: (first: A, second: A) => Ordering\n}\n\n// -------------------------------------------------------------------------------------\n// defaults\n// -------------------------------------------------------------------------------------\n\n/**\n * @category defaults\n * @since 2.10.0\n */\nexport const equalsDefault =\n  <A>(compare: Ord<A>['compare']): Eq<A>['equals'] =>\n  (first, second) =>\n    first === second || compare(first, second) === 0\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const fromCompare = <A>(compare: Ord<A>['compare']): Ord<A> => ({\n  equals: equalsDefault(compare),\n  compare: (first, second) => (first === second ? 0 : compare(first, second))\n})\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Given a tuple of `Ord`s returns an `Ord` for the tuple.\n *\n * @example\n * import { tuple } from 'fp-ts/Ord'\n * import * as B from 'fp-ts/boolean'\n * import * as S from 'fp-ts/string'\n * import * as N from 'fp-ts/number'\n *\n * const O = tuple(S.Ord, N.Ord, B.Ord)\n * assert.strictEqual(O.compare(['a', 1, true], ['b', 2, true]), -1)\n * assert.strictEqual(O.compare(['a', 1, true], ['a', 2, true]), -1)\n * assert.strictEqual(O.compare(['a', 1, true], ['a', 1, false]), 1)\n *\n * @since 2.10.0\n */\nexport const tuple = <A extends ReadonlyArray<unknown>>(...ords: { [K in keyof A]: Ord<A[K]> }): Ord<Readonly<A>> =>\n  fromCompare((first, second) => {\n    let i = 0\n    for (; i < ords.length - 1; i++) {\n      const r = ords[i].compare(first[i], second[i])\n      if (r !== 0) {\n        return r\n      }\n    }\n    return ords[i].compare(first[i], second[i])\n  })\n\n/**\n * @since 2.10.0\n */\nexport const reverse = <A>(O: Ord<A>): Ord<A> => fromCompare((first, second) => O.compare(second, first))\n\n/* istanbul ignore next */\nconst contramap_: <A, B>(fa: Ord<A>, f: (b: B) => A) => Ord<B> = (fa, f) => pipe(fa, contramap(f))\n\n/**\n * A typical use case for `contramap` would be like, given some `User` type, to construct an `Ord<User>`.\n *\n * We can do so with a function from `User -> X` where `X` is some value that we know how to compare\n * for ordering (meaning we have an `Ord<X>`)\n *\n * For example, given the following `User` type, there are lots of possible choices for `X`,\n * but let's say we want to sort a list of users by `lastName`.\n *\n * If we have a way of comparing `lastName`s for ordering (`ordLastName: Ord<string>`) and we know how to go from `User -> string`,\n * using `contramap` we can do this\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import { contramap, Ord } from 'fp-ts/Ord'\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import * as S from 'fp-ts/string'\n *\n * interface User {\n *   readonly firstName: string\n *   readonly lastName: string\n * }\n *\n * const ordLastName: Ord<string> = S.Ord\n *\n * const ordByLastName: Ord<User> = pipe(\n *   ordLastName,\n *   contramap((user) => user.lastName)\n * )\n *\n * assert.deepStrictEqual(\n *   RA.sort(ordByLastName)([\n *     { firstName: 'a', lastName: 'd' },\n *     { firstName: 'c', lastName: 'b' }\n *   ]),\n *   [\n *     { firstName: 'c', lastName: 'b' },\n *     { firstName: 'a', lastName: 'd' }\n *   ]\n * )\n *\n * @since 2.0.0\n */\nexport const contramap: <A, B>(f: (b: B) => A) => (fa: Ord<A>) => Ord<B> = (f) => (fa) =>\n  fromCompare((first, second) => fa.compare(f(first), f(second)))\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Ord'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Ord<A>\n  }\n}\n\n/**\n * A typical use case for the `Semigroup` instance of `Ord` is merging two or more orderings.\n *\n * For example the following snippet builds an `Ord` for a type `User` which\n * sorts by `created` date descending, and **then** `lastName`\n *\n * @example\n * import * as D from 'fp-ts/Date'\n * import { pipe } from 'fp-ts/function'\n * import { contramap, getSemigroup, Ord, reverse } from 'fp-ts/Ord'\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import * as S from 'fp-ts/string'\n *\n * interface User {\n *   readonly id: string\n *   readonly lastName: string\n *   readonly created: Date\n * }\n *\n * const ordByLastName: Ord<User> = pipe(\n *   S.Ord,\n *   contramap((user) => user.lastName)\n * )\n *\n * const ordByCreated: Ord<User> = pipe(\n *   D.Ord,\n *   contramap((user) => user.created)\n * )\n *\n * const ordUserByCreatedDescThenLastName = getSemigroup<User>().concat(\n *   reverse(ordByCreated),\n *   ordByLastName\n * )\n *\n * assert.deepStrictEqual(\n *   RA.sort(ordUserByCreatedDescThenLastName)([\n *     { id: 'c', lastName: 'd', created: new Date(1973, 10, 30) },\n *     { id: 'a', lastName: 'b', created: new Date(1973, 10, 30) },\n *     { id: 'e', lastName: 'f', created: new Date(1980, 10, 30) }\n *   ]),\n *   [\n *     { id: 'e', lastName: 'f', created: new Date(1980, 10, 30) },\n *     { id: 'a', lastName: 'b', created: new Date(1973, 10, 30) },\n *     { id: 'c', lastName: 'd', created: new Date(1973, 10, 30) }\n *   ]\n * )\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getSemigroup = <A = never>(): Semigroup<Ord<A>> => ({\n  concat: (first, second) =>\n    fromCompare((a, b) => {\n      const ox = first.compare(a, b)\n      return ox !== 0 ? ox : second.compare(a, b)\n    })\n})\n\n/**\n * Returns a `Monoid` such that:\n *\n * - its `concat(ord1, ord2)` operation will order first by `ord1`, and then by `ord2`\n * - its `empty` value is an `Ord` that always considers compared elements equal\n *\n * @example\n * import { sort } from 'fp-ts/Array'\n * import { contramap, reverse, getMonoid } from 'fp-ts/Ord'\n * import * as S from 'fp-ts/string'\n * import * as B from 'fp-ts/boolean'\n * import { pipe } from 'fp-ts/function'\n * import { concatAll } from 'fp-ts/Monoid'\n * import * as N from 'fp-ts/number'\n *\n * interface User {\n *   readonly id: number\n *   readonly name: string\n *   readonly age: number\n *   readonly rememberMe: boolean\n * }\n *\n * const byName = pipe(\n *   S.Ord,\n *   contramap((p: User) => p.name)\n * )\n *\n * const byAge = pipe(\n *   N.Ord,\n *   contramap((p: User) => p.age)\n * )\n *\n * const byRememberMe = pipe(\n *   B.Ord,\n *   contramap((p: User) => p.rememberMe)\n * )\n *\n * const M = getMonoid<User>()\n *\n * const users: Array<User> = [\n *   { id: 1, name: 'Guido', age: 47, rememberMe: false },\n *   { id: 2, name: 'Guido', age: 46, rememberMe: true },\n *   { id: 3, name: 'Giulio', age: 44, rememberMe: false },\n *   { id: 4, name: 'Giulio', age: 44, rememberMe: true }\n * ]\n *\n * // sort by name, then by age, then by `rememberMe`\n * const O1 = concatAll(M)([byName, byAge, byRememberMe])\n * assert.deepStrictEqual(sort(O1)(users), [\n *   { id: 3, name: 'Giulio', age: 44, rememberMe: false },\n *   { id: 4, name: 'Giulio', age: 44, rememberMe: true },\n *   { id: 2, name: 'Guido', age: 46, rememberMe: true },\n *   { id: 1, name: 'Guido', age: 47, rememberMe: false }\n * ])\n *\n * // now `rememberMe = true` first, then by name, then by age\n * const O2 = concatAll(M)([reverse(byRememberMe), byName, byAge])\n * assert.deepStrictEqual(sort(O2)(users), [\n *   { id: 4, name: 'Giulio', age: 44, rememberMe: true },\n *   { id: 2, name: 'Guido', age: 46, rememberMe: true },\n *   { id: 3, name: 'Giulio', age: 44, rememberMe: false },\n *   { id: 1, name: 'Guido', age: 47, rememberMe: false }\n * ])\n *\n * @category instances\n * @since 2.4.0\n */\nexport const getMonoid = <A = never>(): Monoid<Ord<A>> => ({\n  concat: getSemigroup<A>().concat,\n  empty: fromCompare(() => 0)\n})\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Contravariant: Contravariant1<URI> = {\n  URI,\n  contramap: contramap_\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport const trivial: Ord<unknown> = {\n  equals: constTrue,\n  compare: /*#__PURE__*/ constant(0)\n}\n\n/**\n * @since 2.11.0\n */\nexport const equals =\n  <A>(O: Ord<A>) =>\n  (second: A) =>\n  (first: A): boolean =>\n    first === second || O.compare(first, second) === 0\n\n// TODO: curry in v3\n/**\n * Test whether one value is _strictly less than_ another\n *\n * @since 2.0.0\n */\nexport const lt =\n  <A>(O: Ord<A>) =>\n  (first: A, second: A): boolean =>\n    O.compare(first, second) === -1\n\n// TODO: curry in v3\n/**\n * Test whether one value is _strictly greater than_ another\n *\n * @since 2.0.0\n */\nexport const gt =\n  <A>(O: Ord<A>) =>\n  (first: A, second: A): boolean =>\n    O.compare(first, second) === 1\n\n// TODO: curry in v3\n/**\n * Test whether one value is _non-strictly less than_ another\n *\n * @since 2.0.0\n */\nexport const leq =\n  <A>(O: Ord<A>) =>\n  (first: A, second: A): boolean =>\n    O.compare(first, second) !== 1\n\n// TODO: curry in v3\n/**\n * Test whether one value is _non-strictly greater than_ another\n *\n * @since 2.0.0\n */\nexport const geq =\n  <A>(O: Ord<A>) =>\n  (first: A, second: A): boolean =>\n    O.compare(first, second) !== -1\n\n// TODO: curry in v3\n/**\n * Take the minimum of two values. If they are considered equal, the first argument is chosen\n *\n * @since 2.0.0\n */\nexport const min =\n  <A>(O: Ord<A>) =>\n  (first: A, second: A): A =>\n    first === second || O.compare(first, second) < 1 ? first : second\n\n// TODO: curry in v3\n/**\n * Take the maximum of two values. If they are considered equal, the first argument is chosen\n *\n * @since 2.0.0\n */\nexport const max =\n  <A>(O: Ord<A>) =>\n  (first: A, second: A): A =>\n    first === second || O.compare(first, second) > -1 ? first : second\n\n/**\n * Clamp a value between a minimum and a maximum\n *\n * @since 2.0.0\n */\nexport const clamp = <A>(O: Ord<A>): ((low: A, hi: A) => (a: A) => A) => {\n  const minO = min(O)\n  const maxO = max(O)\n  return (low, hi) => (a) => maxO(minO(a, hi), low)\n}\n\n/**\n * Test whether a value is between a minimum and a maximum (inclusive)\n *\n * @since 2.0.0\n */\nexport const between = <A>(O: Ord<A>): ((low: A, hi: A) => (a: A) => boolean) => {\n  const ltO = lt(O)\n  const gtO = gt(O)\n  return (low, hi) => (a) => ltO(a, low) || gtO(a, hi) ? false : true\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`tuple`](#tuple) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getTupleOrd: <T extends ReadonlyArray<Ord<any>>>(\n  ...ords: T\n) => Ord<{ [K in keyof T]: T[K] extends Ord<infer A> ? A : never }> = tuple\n\n/**\n * Use [`reverse`](#reverse) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getDualOrd = reverse\n\n/**\n * Use [`Contravariant`](#contravariant) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const ord: Contravariant1<URI> = Contravariant\n\n// default compare for primitive types\nfunction compare(first: any, second: any): Ordering {\n  return first < second ? -1 : first > second ? 1 : 0\n}\n\nconst strictOrd = {\n  equals: eqStrict.equals,\n  compare\n}\n\n/**\n * Use [`Ord`](./boolean.ts.html#ord) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const ordBoolean: Ord<boolean> = strictOrd\n\n/**\n * Use [`Ord`](./string.ts.html#ord) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const ordString: Ord<string> = strictOrd\n\n/**\n * Use [`Ord`](./number.ts.html#ord) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const ordNumber: Ord<number> = strictOrd\n\n/**\n * Use [`Ord`](./Date.ts.html#ord) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const ordDate: Ord<Date> = /*#__PURE__*/ pipe(\n  ordNumber,\n  /*#__PURE__*/\n  contramap((date) => date.valueOf())\n)\n"
  },
  {
    "path": "src/Ordering.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport * as E from './Eq'\nimport * as M from './Monoid'\nimport * as S from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport type Ordering = -1 | 0 | 1\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.12.0\n */\nexport const matchW =\n  <A, B, C>(onLessThan: () => A, onEqual: () => B, onGreaterThan: () => C) =>\n  (o: Ordering): A | B | C =>\n    o === -1 ? onLessThan() : o === 0 ? onEqual() : onGreaterThan()\n\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <A>(onLessThan: () => A, onEqual: () => A, onGreaterThan: () => A) => (o: Ordering) => A = matchW\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport const reverse = (o: Ordering): Ordering => (o === -1 ? 1 : o === 1 ? -1 : 0)\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Eq: E.Eq<Ordering> = {\n  equals: (x, y) => x === y\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Semigroup: S.Semigroup<Ordering> = {\n  concat: (x, y) => (x !== 0 ? x : y)\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Monoid: M.Monoid<Ordering> = {\n  concat: Semigroup.concat,\n  empty: 0\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.0.0\n */\nexport const sign = (n: number): Ordering => (n <= -1 ? -1 : n >= 1 ? 1 : 0)\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`reverse`](#reverse) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const invert = reverse\n\n/**\n * Use [`Semigroup`](#semigroup) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const semigroupOrdering: S.Semigroup<Ordering> = Semigroup\n\n/**\n * Use [`Eq`](#eq) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const eqOrdering: E.Eq<Ordering> = Eq\n\n/**\n * Use [`Monoid`](#monoid) instead\n *\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport const monoidOrdering: M.Monoid<Ordering> = Monoid\n"
  },
  {
    "path": "src/Pointed.ts",
    "content": "/**\n * @since 2.10.0\n */\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Pointed<F> {\n  readonly URI: F\n  readonly of: <A>(a: A) => HKT<F, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Pointed1<F extends URIS> {\n  readonly URI: F\n  readonly of: <A>(a: A) => Kind<F, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Pointed2<F extends URIS2> {\n  readonly URI: F\n  readonly of: <E, A>(a: A) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Pointed2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly of: <A>(a: A) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Pointed3<F extends URIS3> {\n  readonly URI: F\n  readonly of: <R, E, A>(a: A) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Pointed3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly of: <R, A>(a: A) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Pointed4<F extends URIS4> {\n  readonly URI: F\n  readonly of: <S, R, E, A>(a: A) => Kind4<F, S, R, E, A>\n}\n"
  },
  {
    "path": "src/Predicate.ts",
    "content": "/**\n * @since 2.11.0\n */\nimport { Contravariant1 } from './Contravariant'\nimport { constFalse, constTrue, flow, pipe } from './function'\nimport { Monoid } from './Monoid'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport interface Predicate<A> {\n  (a: A): boolean\n}\n\nconst contramap_: Contravariant1<URI>['contramap'] = (predicate, f) => pipe(predicate, contramap(f))\n\n/**\n * @since 2.11.0\n */\nexport const contramap =\n  <B, A>(f: (b: B) => A) =>\n  (predicate: Predicate<A>): Predicate<B> =>\n    flow(f, predicate)\n\n/**\n * @category type lambdas\n * @since 2.11.0\n */\nexport const URI = 'Predicate'\n\n/**\n * @category type lambdas\n * @since 2.11.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Predicate<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getSemigroupAny = <A = never>(): Semigroup<Predicate<A>> => ({\n  concat: (first, second) => pipe(first, or(second))\n})\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getMonoidAny = <A = never>(): Monoid<Predicate<A>> => ({\n  concat: getSemigroupAny<A>().concat,\n  empty: constFalse\n})\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getSemigroupAll = <A = never>(): Semigroup<Predicate<A>> => ({\n  concat: (first, second) => pipe(first, and(second))\n})\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getMonoidAll = <A = never>(): Monoid<Predicate<A>> => ({\n  concat: getSemigroupAll<A>().concat,\n  empty: constTrue\n})\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const Contravariant: Contravariant1<URI> = {\n  URI,\n  contramap: contramap_\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport const not =\n  <A>(predicate: Predicate<A>): Predicate<A> =>\n  (a) =>\n    !predicate(a)\n\n/**\n * @since 2.11.0\n */\nexport const or =\n  <A>(second: Predicate<A>) =>\n  (first: Predicate<A>): Predicate<A> =>\n  (a) =>\n    first(a) || second(a)\n\n/**\n * @since 2.11.0\n */\nexport const and =\n  <A>(second: Predicate<A>) =>\n  (first: Predicate<A>): Predicate<A> =>\n  (a) =>\n    first(a) && second(a)\n"
  },
  {
    "path": "src/Profunctor.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Functor2, Functor2C, Functor3, Functor3C, Functor4 } from './Functor'\nimport { HKT, HKT2, Kind2, Kind3, Kind4, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Profunctor<F> {\n  readonly URI: F\n  readonly map: <E, A, B>(fa: HKT2<F, E, A>, f: (a: A) => B) => HKT<F, B>\n  readonly promap: <E, A, D, B>(fea: HKT2<F, E, A>, f: (d: D) => E, g: (a: A) => B) => HKT2<F, D, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Profunctor2<F extends URIS2> extends Functor2<F> {\n  readonly promap: <E, A, D, B>(fea: Kind2<F, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind2<F, D, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Profunctor2C<F extends URIS2, E> extends Functor2C<F, E> {\n  readonly promap: <A, D, B>(fea: Kind2<F, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind2<F, D, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Profunctor3<F extends URIS3> extends Functor3<F> {\n  readonly promap: <R, E, A, D, B>(fea: Kind3<F, R, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind3<F, R, D, B>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Profunctor3C<F extends URIS3, E> extends Functor3C<F, E> {\n  readonly promap: <R, A, D, B>(fea: Kind3<F, R, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind3<F, R, D, B>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Profunctor4<F extends URIS4> extends Functor4<F> {\n  readonly promap: <S, R, E, A, D, B>(fea: Kind4<F, S, R, E, A>, f: (d: D) => E, g: (a: A) => B) => Kind4<F, S, R, D, B>\n}\n"
  },
  {
    "path": "src/Random.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { pipe } from './function'\nimport { IO, map } from './IO'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\n\n/**\n * Returns a random number between 0 (inclusive) and 1 (exclusive). This is a direct wrapper around JavaScript's\n * `Math.random()`.\n *\n * @since 2.0.0\n */\nexport const random: IO<number> = () => Math.random()\n\n/**\n * Takes a range specified by `low` (the first argument) and `high` (the second), and returns a random integer uniformly\n * distributed in the closed interval `[low, high]`. It is unspecified what happens if `low > high`, or if either of\n * `low` or `high` is not an integer.\n *\n * @since 2.0.0\n */\nexport function randomInt(low: number, high: number): IO<number> {\n  return pipe(\n    random,\n    map((n) => Math.floor((high - low + 1) * n + low))\n  )\n}\n\n/**\n * Returns a random number between a minimum value (inclusive) and a maximum value (exclusive). It is unspecified what\n * happens if `maximum < minimum`.\n *\n * @since 2.0.0\n */\nexport function randomRange(min: number, max: number): IO<number> {\n  return pipe(\n    random,\n    map((n) => (max - min) * n + min)\n  )\n}\n\n/**\n * Returns a random boolean value with an equal chance of being `true` or `false`\n *\n * @since 2.0.0\n */\nexport const randomBool: IO<boolean> = /*#__PURE__*/ pipe(\n  random,\n  map((n) => n < 0.5)\n)\n\n/**\n * Returns a random element of a `ReadonlyNonEmptyArray`.\n *\n * @since 2.10.0\n */\nexport const randomElem = <A>(as: ReadonlyNonEmptyArray<A>): IO<A> =>\n  pipe(\n    randomInt(0, as.length - 1),\n    map((i) => as[i])\n  )\n"
  },
  {
    "path": "src/Reader.ts",
    "content": "/**\n * The `Reader` monad (also called the Environment monad). Represents a computation, which can read values from a shared environment,\n * pass values from function to function, and execute sub-computations in a modified environment.\n * Using `Reader` monad for such computations is often clearer and easier than using the `State` monad.\n *\n * In this example the `Reader` monad provides access to variable bindings. `Bindings` are a map of `number` variables.\n * The variable count contains number of variables in the bindings. You can see how to run a `Reader` monad and retrieve\n * data from it, how to access the `Reader` data with `ask` and `asks`.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as O from 'fp-ts/Option'\n * import * as R from 'fp-ts/Reader'\n * import * as RR from 'fp-ts/ReadonlyRecord'\n *\n * interface Bindings extends RR.ReadonlyRecord<string, number> {}\n *\n * // The Reader monad, which implements this complicated check.\n * const isCountCorrect: R.Reader<Bindings, boolean> = pipe(\n *   R.Do,\n *   R.bind('count', () => R.asks(lookupVar('count'))),\n *   R.bind('bindings', () => R.ask()),\n *   R.map(({ count, bindings }) => count === RR.size(bindings))\n * )\n *\n * // The selector function to use with 'asks'.\n * // Returns value of the variable with specified name.\n * const lookupVar = (name: string) => (bindings: Bindings): number =>\n *   pipe(\n *     bindings,\n *     RR.lookup(name),\n *     O.getOrElse(() => 0)\n *   )\n *\n * const sampleBindings: Bindings = { count: 3, a: 1, b: 2 }\n *\n * assert.deepStrictEqual(isCountCorrect(sampleBindings), true)\n *\n * @since 2.0.0\n */\nimport { Applicative2, getApplicativeMonoid } from './Applicative'\nimport { apFirst as apFirst_, Apply2, apS as apS_, apSecond as apSecond_, getApplySemigroup } from './Apply'\nimport { Category2 } from './Category'\nimport * as chainable from './Chain'\nimport { Choice2 } from './Choice'\nimport * as E from './Either'\nimport { constant, dual, flow, identity, pipe } from './function'\nimport { bindTo as bindTo_, flap as flap_, Functor2, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { Monad2 } from './Monad'\nimport { Monoid } from './Monoid'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Pointed2 } from './Pointed'\nimport { Profunctor2 } from './Profunctor'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Semigroup } from './Semigroup'\nimport { Strong2 } from './Strong'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Reader<R, A> {\n  (r: R): A\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Reads the current context\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const ask: <R>() => Reader<R, R> = () => identity\n\n/**\n * Projects a value from the global context in a Reader\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const asks: <R, A>(f: (r: R) => A) => Reader<R, A> = identity\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n * `contramap`).\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as R from 'fp-ts/Reader'\n * import * as string from 'fp-ts/string'\n *\n * const calculateContentLen: R.Reader<string, number> = pipe(\n *   R.Do,\n *   R.bind('content', () => R.ask<string>()),\n *   R.map(({ content }) => string.size(content))\n * )\n *\n * // Calls calculateContentLen after adding a prefix to the Reader content.\n * const calculateModifiedContentLen: R.Reader<string, number> = pipe(\n *   calculateContentLen,\n *   R.local((s) => 'Prefix ' + s)\n * )\n *\n * const s = '12345'\n *\n * assert.deepStrictEqual(\n *   \"Modified 's' length: \" + calculateModifiedContentLen(s) + '\\n' + \"Original 's' length: \" + calculateContentLen(s),\n *   \"Modified 's' length: 12\\nOriginal 's' length: 5\"\n * )\n *\n * @since 2.0.0\n */\nexport const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: Reader<R1, A>) => Reader<R2, A> = (f) => (ma) => (r2) =>\n  ma(f(r2))\n\n/**\n * Less strict version of [`asksReader`](#asksreader).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksReaderW =\n  <R1, R2, A>(f: (r1: R1) => Reader<R2, A>): Reader<R1 & R2, A> =>\n  (r) =>\n    f(r)(r)\n\n/**\n * Effectfully accesses the environment.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksReader: <R, A>(f: (r: R) => Reader<R, A>) => Reader<R, A> = asksReaderW\n\n/* istanbul ignore next */\nconst _map: Monad2<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _ap: Monad2<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\nconst _compose: Category2<URI>['compose'] = (bc, ab) => pipe(bc, compose(ab))\nconst _promap: Profunctor2<URI>['promap'] = (fea, f, g) => pipe(fea, promap(f, g))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, A>) => Reader<R, B> = (f) => (fa) => (r) => f(fa(r))\n\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @since 2.8.0\n */\nexport const apW: <R2, A>(fa: Reader<R2, A>) => <R1, B>(fab: Reader<R1, (a: A) => B>) => Reader<R1 & R2, B> =\n  (fa) => (fab) => (r) =>\n    fab(r)(fa(r))\n\n/**\n * @since 2.0.0\n */\nexport const ap: <R, A>(fa: Reader<R, A>) => <B>(fab: Reader<R, (a: A) => B>) => Reader<R, B> = apW\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const of: <R = unknown, A = never>(a: A) => Reader<R, A> = constant\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, R2, B>(f: (a: A) => Reader<R2, B>): <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, B>\n  <R1, A, R2, B>(ma: Reader<R1, A>, f: (a: A) => Reader<R2, B>): Reader<R1 & R2, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <R1, A, R2, B>(ma: Reader<R1, A>, f: (a: A) => Reader<R2, B>): Reader<R1 & R2, B> =>\n    (r) =>\n      f(ma(r))(r)\n)\n\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport const flattenW: <R1, R2, A>(mma: Reader<R1, Reader<R2, A>>) => Reader<R1 & R2, A> =\n  /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <R, A>(mma: Reader<R, Reader<R, A>>) => Reader<R, A> = flattenW\n\n/**\n * @since 2.0.0\n */\nexport const compose: <A, B>(ab: Reader<A, B>) => <C>(bc: Reader<B, C>) => Reader<A, C> = (ab) => (bc) => flow(ab, bc)\n\n/**\n * @since 2.0.0\n */\nexport const promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fea: Reader<E, A>) => Reader<D, B> =\n  (f, g) => (fea) => (a) =>\n    g(fea(f(a)))\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const id: Category2<URI>['id'] = () => identity\n\n/**\n * @since 2.10.0\n */\nexport const first: Strong2<URI>['first'] =\n  (pab) =>\n  ([a, c]) =>\n    [pab(a), c]\n\n/**\n * @since 2.10.0\n */\nexport const second: Strong2<URI>['second'] =\n  (pbc) =>\n  ([a, b]) =>\n    [a, pbc(b)]\n\n/**\n * @since 2.10.0\n */\nexport const left: Choice2<URI>['left'] = (pab) => E.fold((a) => _.left(pab(a)), E.right)\n\n/**\n * @since 2.10.0\n */\nexport const right: Choice2<URI>['right'] = (pbc) => E.fold(E.left, (b) => _.right(pbc(b)))\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Reader'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: Reader<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed2<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Less strict version of [`apFirst`](#apfirst).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @since 2.12.0\n */\nexport const apFirstW: <R2, B>(second: Reader<R2, B>) => <R1, A>(first: Reader<R1, A>) => Reader<R1 & R2, A> =\n  apFirst as any\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * Less strict version of [`apSecond`](#apsecond).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @since 2.12.0\n */\nexport const apSecondW: <R2, B>(second: Reader<R2, B>) => <R1, A>(first: Reader<R1, A>) => Reader<R1 & R2, B> =\n  apSecond as any\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad2<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <R1, A, R2, _>(self: Reader<R1, A>, f: (a: A) => Reader<R2, _>): Reader<R1 & R2, A>\n  <A, R2, _>(f: (a: A) => Reader<R2, _>): <R1>(self: Reader<R1, A>) => Reader<R2 & R1, A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Profunctor: Profunctor2<URI> = {\n  URI,\n  map: _map,\n  promap: _promap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Category: Category2<URI> = {\n  URI,\n  compose: _compose,\n  id\n}\n\n/**\n * @category instances\n * @since 2.8.3\n */\nexport const Strong: Strong2<URI> = {\n  URI,\n  map: _map,\n  promap: _promap,\n  first,\n  second\n}\n\n/**\n * @category instances\n * @since 2.8.3\n */\nexport const Choice: Choice2<URI> = {\n  URI,\n  map: _map,\n  promap: _promap,\n  left,\n  right\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const bindW: <N extends string, A, R2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => Reader<R2, B>\n) => <R1>(fa: Reader<R1, A>) => Reader<R1 & R2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  bind as any\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: Reader<unknown, {}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const apSW: <A, N extends string, R2, B>(\n  name: Exclude<N, keyof A>,\n  fb: Reader<R2, B>\n) => <R1>(fa: Reader<R1, A>) => Reader<R1 & R2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  apS as any\n\n/**\n * @since 2.11.0\n */\nexport const ApT: Reader<unknown, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex =\n  <A, R, B>(f: (index: number, a: A) => Reader<R, B>) =>\n  (as: ReadonlyNonEmptyArray<A>): Reader<R, ReadonlyNonEmptyArray<B>> =>\n  (r) => {\n    const out: NonEmptyArray<B> = [f(0, _.head(as))(r)]\n    for (let i = 1; i < as.length; i++) {\n      out.push(f(i, as[i])(r))\n    }\n    return out\n  }\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, R, B>(\n  f: (index: number, a: A) => Reader<R, B>\n): ((as: ReadonlyArray<A>) => Reader<R, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <R, A, B>(\n  f: (index: number, a: A) => Reader<R, B>\n) => (as: ReadonlyArray<A>) => Reader<R, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <R, A, B>(\n  f: (a: A) => Reader<R, B>\n): ((as: ReadonlyArray<A>) => Reader<R, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <R, A>(arr: ReadonlyArray<Reader<R, A>>) => Reader<R, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.0\n */\nexport const chainW: <R2, A, B>(f: (a: A) => Reader<R2, B>) => <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, B> = flatMap\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <A, R, B>(f: (a: A) => Reader<R, B>) => (ma: Reader<R, A>) => Reader<R, B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <A, R, B>(f: (a: A) => Reader<R, B>) => (first: Reader<R, A>) => Reader<R, A> = tap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstW: <R2, A, B>(f: (a: A) => Reader<R2, B>) => <R1>(ma: Reader<R1, A>) => Reader<R1 & R2, A> = tap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `R.Functor` instead of `R.reader`\n * (where `R` is from `import R from 'fp-ts/Reader'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const reader: Monad2<URI> & Profunctor2<URI> & Category2<URI> & Strong2<URI> & Choice2<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  promap: _promap,\n  compose: _compose,\n  id,\n  first,\n  second,\n  left,\n  right\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getSemigroup: <R, A>(S: Semigroup<A>) => Semigroup<Reader<R, A>> = /*#__PURE__*/ getApplySemigroup(Apply)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getMonoid: <R, A>(M: Monoid<A>) => Monoid<Reader<R, A>> = /*#__PURE__*/ getApplicativeMonoid(Applicative)\n"
  },
  {
    "path": "src/ReaderEither.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Alt3, Alt3C } from './Alt'\nimport { Applicative3, Applicative3C, getApplicativeMonoid } from './Applicative'\nimport {\n  ap as ap_,\n  apFirst as apFirst_,\n  Apply3,\n  apS as apS_,\n  apSecond as apSecond_,\n  getApplySemigroup as getApplySemigroup_\n} from './Apply'\nimport { Bifunctor3 } from './Bifunctor'\nimport * as chainable from './Chain'\nimport { compact as compact_, Compactable3C, separate as separate_ } from './Compactable'\nimport * as E from './Either'\nimport * as ET from './EitherT'\nimport {\n  filter as filter_,\n  Filterable3C,\n  filterMap as filterMap_,\n  partition as partition_,\n  partitionMap as partitionMap_\n} from './Filterable'\nimport {\n  chainOptionK as chainOptionK_,\n  filterOrElse as filterOrElse_,\n  FromEither3,\n  fromEitherK as fromEitherK_,\n  fromOption as fromOption_,\n  fromOptionK as fromOptionK_,\n  fromPredicate as fromPredicate_,\n  tapEither as tapEither_\n} from './FromEither'\nimport {\n  ask as ask_,\n  asks as asks_,\n  FromReader3,\n  fromReaderK as fromReaderK_,\n  tapReader as tapReader_\n} from './FromReader'\nimport { dual, flow, identity, LazyArg, pipe, SK } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor3, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { Monad3, Monad3C } from './Monad'\nimport { MonadThrow3, MonadThrow3C } from './MonadThrow'\nimport { Monoid } from './Monoid'\nimport { Option } from './Option'\nimport { Pointed3 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport * as R from './Reader'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\n\nimport Reader = R.Reader\nimport Either = E.Either\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface ReaderEither<R, E, A> extends Reader<R, Either<E, A>> {}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const left: <R, E = never, A = never>(e: E) => ReaderEither<R, E, A> = /*#__PURE__*/ ET.left(R.Pointed)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const right: <R, E = never, A = never>(a: A) => ReaderEither<R, E, A> = /*#__PURE__*/ ET.right(R.Pointed)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const rightReader: <R, E = never, A = never>(ma: Reader<R, A>) => ReaderEither<R, E, A> =\n  /*#__PURE__*/ ET.rightF(R.Functor)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const leftReader: <R, E = never, A = never>(me: Reader<R, E>) => ReaderEither<R, E, A> = /*#__PURE__*/ ET.leftF(\n  R.Functor\n)\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromEither: <E, A, R = unknown>(fa: Either<E, A>) => ReaderEither<R, E, A> = R.of\n\n/**\n * @category conversions\n * @since 2.11.0\n */\nexport const fromReader: <R, A, E = never>(fa: Reader<R, A>) => ReaderEither<R, E, A> = rightReader\n\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B\n) => <R>(ma: ReaderEither<R, E, A>) => Reader<R, B> = /*#__PURE__*/ ET.match(R.Functor)\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW: <E, B, A, C>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C\n) => <R>(ma: Reader<R, Either<E, A>>) => Reader<R, B | C> = match as any\n\n/**\n * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Reader`).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchE: <R, E, A, B>(\n  onLeft: (e: E) => Reader<R, B>,\n  onRight: (a: A) => Reader<R, B>\n) => (ma: ReaderEither<R, E, A>) => Reader<R, B> = /*#__PURE__*/ ET.matchE(R.Monad)\n\n/**\n * Alias of [`matchE`](#matche).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const fold = matchE\n\n/**\n * Less strict version of [`matchE`](#matche).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchEW: <E, R2, B, A, R3, C>(\n  onLeft: (e: E) => Reader<R2, B>,\n  onRight: (a: A) => Reader<R3, C>\n) => <R1>(ma: ReaderEither<R1, E, A>) => Reader<R1 & R2 & R3, B | C> = matchE as any\n\n/**\n * Alias of [`matchEW`](#matchew).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchEW\n\n/**\n * @category error handling\n * @since 2.0.0\n */\nexport const getOrElse: <E, R, A>(onLeft: (e: E) => Reader<R, A>) => (ma: ReaderEither<R, E, A>) => Reader<R, A> =\n  /*#__PURE__*/ ET.getOrElse(R.Monad)\n\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.6.0\n */\nexport const getOrElseW: <R2, E, B>(\n  onLeft: (e: E) => Reader<R2, B>\n) => <R1, A>(ma: ReaderEither<R1, E, A>) => Reader<R1 & R2, A | B> = getOrElse as any\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const toUnion: <R, E, A>(fa: ReaderEither<R, E, A>) => Reader<R, E | A> = /*#__PURE__*/ ET.toUnion(R.Functor)\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n * `contramap`).\n *\n * @since 2.0.0\n */\nexport const local: <R2, R1>(f: (r2: R2) => R1) => <E, A>(ma: ReaderEither<R1, E, A>) => ReaderEither<R2, E, A> =\n  R.local\n\n/**\n * Less strict version of [`asksReaderEither`](#asksreadereither).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksReaderEitherW: <R1, R2, E, A>(f: (r1: R1) => ReaderEither<R2, E, A>) => ReaderEither<R1 & R2, E, A> =\n  R.asksReaderW\n\n/**\n * Effectfully accesses the environment.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksReaderEither: <R, E, A>(f: (r: R) => ReaderEither<R, E, A>) => ReaderEither<R, E, A> =\n  asksReaderEitherW\n\n/**\n * @category error handling\n * @since 2.0.0\n */\nexport const orElse: <E1, R, E2, A>(\n  onLeft: (e: E1) => ReaderEither<R, E2, A>\n) => (ma: ReaderEither<R, E1, A>) => ReaderEither<R, E2, A> = /*#__PURE__*/ ET.orElse(R.Monad)\n\n/**\n * Less strict version of [`orElse`](#orelse).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the return types will be merged.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport const orElseW: <E1, R1, E2, B>(\n  onLeft: (e: E1) => ReaderEither<R1, E2, B>\n) => <R2, A>(ma: ReaderEither<R2, E1, A>) => ReaderEither<R1 & R2, E2, A | B> = orElse as any\n\n/**\n * Returns an effect that effectfully \"peeks\" at the failure of this effect.\n *\n * @category error handling\n * @since 2.15.0\n */\nexport const tapError: {\n  <E1, R2, E2, _>(onLeft: (e: E1) => ReaderEither<R2, E2, _>): <R1, A>(\n    self: ReaderEither<R1, E1, A>\n  ) => ReaderEither<R1 & R2, E1 | E2, A>\n  <R1, E1, A, R2, E2, _>(self: ReaderEither<R1, E1, A>, onLeft: (e: E1) => ReaderEither<R2, E2, _>): ReaderEither<\n    R1 & R2,\n    E1 | E2,\n    A\n  >\n} = /*#__PURE__*/ dual(2, ET.tapError(R.Monad))\n\n/**\n * @category error handling\n * @since 2.11.0\n */\nexport const orLeft: <E1, R, E2>(\n  onLeft: (e: E1) => Reader<R, E2>\n) => <A>(fa: ReaderEither<R, E1, A>) => ReaderEither<R, E2, A> = /*#__PURE__*/ ET.orLeft(R.Monad)\n\n/**\n * @category error handling\n * @since 2.16.6\n */\nexport const orLeftW: <E1, R2, E2>(\n  onLeft: (e: E1) => Reader<R2, E2>\n) => <R1, A>(fa: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2, A> = orLeft as any\n\n/**\n * @since 2.0.0\n */\nexport const swap: <R, E, A>(ma: ReaderEither<R, E, A>) => ReaderEither<R, A, E> = /*#__PURE__*/ ET.swap(R.Functor)\n\n/* istanbul ignore next */\nconst _map: Monad3<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _ap: Monad3<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n/* istanbul ignore next */\nconst _alt: Alt3<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <R, E>(fa: ReaderEither<R, E, A>) => ReaderEither<R, E, B> =\n  /*#__PURE__*/ ET.map(R.Functor)\n\n/**\n * Returns a `ReaderEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`.\n *\n * @example\n * import * as ReaderEither from 'fp-ts/ReaderEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n * const g = (n: number) => n * 2\n *\n * assert.deepStrictEqual(ReaderEither.mapBoth(ReaderEither.right(1), f, g)({}), Either.right(2))\n * assert.deepStrictEqual(ReaderEither.mapBoth(ReaderEither.left('err'), f, g)({}), Either.left(new Error('err')))\n *\n * @category error handling\n * @since 2.16.0\n */\nexport const mapBoth: {\n  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): <R>(self: ReaderEither<R, E, A>) => ReaderEither<R, G, B>\n  <R, E, A, G, B>(self: ReaderEither<R, E, A>, f: (e: E) => G, g: (a: A) => B): ReaderEither<R, G, B>\n} = /*#__PURE__*/ dual(3, ET.mapBoth(R.Functor))\n\n/**\n * Alias of `mapBoth`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const bimap: <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R>(fa: ReaderEither<R, E, A>) => ReaderEither<R, G, B> = mapBoth\n\n/**\n * Returns a `ReaderEither` with its error channel mapped using the specified function.\n *\n * @example\n * import * as ReaderEither from 'fp-ts/ReaderEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n *\n * assert.deepStrictEqual(ReaderEither.mapError(ReaderEither.right(1), f)({}), Either.right(1))\n * assert.deepStrictEqual(ReaderEither.mapError(ReaderEither.left('err'), f)({}), Either.left(new Error('err')))\n *\n * @category error handling\n * @since 2.16.0\n */\nexport const mapError: {\n  <R, E, G>(f: (e: E) => G): <A>(self: ReaderEither<R, E, A>) => ReaderEither<R, G, A>\n  <R, E, A, G>(self: ReaderEither<R, E, A>, f: (e: E) => G): ReaderEither<R, G, A>\n} = /*#__PURE__*/ dual(2, ET.mapError(R.Functor))\n\n/**\n * Alias of `mapError`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: ReaderEither<R, E, A>) => ReaderEither<R, G, A> = mapError\n\n/**\n * @since 2.0.0\n */\nexport const ap: <R, E, A>(\n  fa: ReaderEither<R, E, A>\n) => <B>(fab: ReaderEither<R, E, (a: A) => B>) => ReaderEither<R, E, B> = /*#__PURE__*/ ET.ap(R.Apply)\n\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.8.0\n */\nexport const apW: <R2, E2, A>(\n  fa: ReaderEither<R2, E2, A>\n) => <R1, E1, B>(fab: ReaderEither<R1, E1, (a: A) => B>) => ReaderEither<R1 & R2, E1 | E2, B> = ap as any\n\n/**\n * @category constructors\n * @since 2.8.5\n */\nexport const of: <R = unknown, E = never, A = never>(a: A) => ReaderEither<R, E, A> = right\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, R2, E2, B>(f: (a: A) => ReaderEither<R2, E2, B>): <R1, E1>(\n    ma: ReaderEither<R1, E1, A>\n  ) => ReaderEither<R1 & R2, E1 | E2, B>\n  <R1, E1, A, R2, E2, B>(ma: ReaderEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, B>): ReaderEither<\n    R1 & R2,\n    E1 | E2,\n    B\n  >\n} = /*#__PURE__*/ dual(2, ET.flatMap(R.Monad))\n\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport const flattenW: <R1, R2, E1, E2, A>(\n  mma: ReaderEither<R1, E1, ReaderEither<R2, E2, A>>\n) => ReaderEither<R1 & R2, E1 | E2, A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <R, E, A>(mma: ReaderEither<R, E, ReaderEither<R, E, A>>) => ReaderEither<R, E, A> = flattenW\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const alt: <R, E, A>(that: () => ReaderEither<R, E, A>) => (fa: ReaderEither<R, E, A>) => ReaderEither<R, E, A> =\n  /*#__PURE__*/ ET.alt(R.Monad)\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged.\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW: <R2, E2, B>(\n  that: () => ReaderEither<R2, E2, B>\n) => <R1, E1, A>(fa: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E2, A | B> = alt as any\n\n/**\n * @since 2.7.0\n */\nexport const throwError: MonadThrow3<URI>['throwError'] = left\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'ReaderEither'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind3<R, E, A> {\n    readonly [URI]: ReaderEither<R, E, A>\n  }\n}\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const getCompactable = <E>(M: Monoid<E>): Compactable3C<URI, E> => {\n  const C = E.getCompactable(M)\n  return {\n    URI,\n    _E: undefined as any,\n    compact: compact_(R.Functor, C),\n    separate: separate_(R.Functor, C, E.Functor)\n  }\n}\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport function getFilterable<E>(M: Monoid<E>): Filterable3C<URI, E> {\n  const F = E.getFilterable(M)\n  const C = getCompactable(M)\n\n  const filter = filter_(R.Functor, F)\n  const filterMap = filterMap_(R.Functor, F)\n  const partition = partition_(R.Functor, F)\n  const partitionMap = partitionMap_(R.Functor, F)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    compact: C.compact,\n    separate: C.separate,\n    filter: <R, A>(fa: ReaderEither<R, E, A>, predicate: Predicate<A>) => pipe(fa, filter(predicate)),\n    filterMap: (fa, f) => pipe(fa, filterMap(f)),\n    partition: <R, A>(fa: ReaderEither<R, E, A>, predicate: Predicate<A>) => pipe(fa, partition(predicate)),\n    partitionMap: (fa, f) => pipe(fa, partitionMap(f))\n  }\n}\n\n/**\n * The default [`Applicative`](#applicative) instance returns the first error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * See [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation).\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getApplicativeReaderValidation<E>(S: Semigroup<E>): Applicative3C<URI, E> {\n  const ap = ap_(R.Apply, E.getApplicativeValidation(S))\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: (fab, fa) => pipe(fab, ap(fa)),\n    of\n  }\n}\n\n/**\n * The default [`Alt`](#alt) instance returns the last error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * See [`getAltValidation`](./Either.ts.html#getaltvalidation).\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getAltReaderValidation<E>(S: Semigroup<E>): Alt3C<URI, E> {\n  const alt = ET.altValidation(R.Monad, S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    alt: (fa, that) => pipe(fa, alt(that))\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor3<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the `Right` value of this `ReaderEither` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <R, E, _>(self: ReaderEither<R, E, _>) => ReaderEither<R, E, A>\n  <R, E, _, A>(self: ReaderEither<R, E, _>, a: A): ReaderEither<R, E, A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the `Right` value of this `ReaderEither` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <R, E, _>(self: ReaderEither<R, E, _>) => ReaderEither<R, E, void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed3<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply3<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Less strict version of [`apFirst`](#apfirst)\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apFirstW: <R2, E2, B>(\n  second: ReaderEither<R2, E2, B>\n) => <R1, E1, A>(first: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, A> = apFirst as any\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * Less strict version of [`apSecond`](#apsecond)\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apSecondW: <R2, E2, B>(\n  second: ReaderEither<R2, E2, B>\n) => <R1, E1, A>(first: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, B> = apSecond as any\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative3<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain3<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad3<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromEither: FromEither3<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromReader: FromReader3<URI> = {\n  URI,\n  fromReader\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <R1, E1, A, R2, E2, _>(self: ReaderEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, _>): ReaderEither<\n    R1 & R2,\n    E1 | E2,\n    A\n  >\n  <A, R2, E2, _>(f: (a: A) => ReaderEither<R2, E2, _>): <R1, E1>(\n    self: ReaderEither<R1, E1, A>\n  ) => ReaderEither<R1 & R2, E2 | E1, A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as RE from 'fp-ts/ReaderEither'\n *\n * const checkString = (value: string) => pipe(\n *   RE.ask<number>(),\n *   RE.tapEither(\n *     (minLength) => value.length > minLength\n *       ? E.right('ok')\n *       : E.left('error')\n *   )\n * )\n *\n * assert.deepStrictEqual(checkString('')(1), E.left('error'))\n * assert.deepStrictEqual(checkString('fp-ts')(2), E.right(2))\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapEither: {\n  <A, E2, _>(f: (a: A) => Either<E2, _>): <R1, E1>(self: ReaderEither<R1, E1, A>) => ReaderEither<R1, E1 | E2, A>\n  <R1, E1, A, E2, _>(self: ReaderEither<R1, E1, A>, f: (a: A) => Either<E2, _>): ReaderEither<R1, E1 | E2, A>\n} = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapReader: {\n  <R2, A, E, _>(f: (a: A) => Reader<R2, _>): <R1>(self: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, A>\n  <R1, R2, E, A, _>(self: ReaderEither<R1, E, A>, f: (a: A) => Reader<R2, _>): ReaderEither<R1 & R2, E, A>\n} = /*#__PURE__*/ dual(2, tapReader_(FromReader, Chain))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor3<URI> = {\n  URI,\n  bimap: mapBoth,\n  mapLeft: mapError\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt3<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * Reads the current context.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const ask: <R, E = never>() => ReaderEither<R, E, R> = /*#__PURE__*/ ask_(FromReader)\n\n/**\n * Projects a value from the global context in a `ReaderEither`.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const asks: <R, A, E = never>(f: (r: R) => A) => ReaderEither<R, E, A> = /*#__PURE__*/ asks_(FromReader)\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromReaderK: <A extends ReadonlyArray<unknown>, R, B>(\n  f: (...a: A) => Reader<R, B>\n) => <E = never>(...a: A) => ReaderEither<R, E, B> = /*#__PURE__*/ fromReaderK_(FromReader)\n\n/**\n * Alias of `tapReader`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderK: <A, R, B>(\n  f: (a: A) => Reader<R, B>\n) => <E>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A> = tapReader\n\n/**\n * Alias of `tapReader`.\n *\n * Less strict version of [`chainReaderK`](#chainreaderk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => Reader<R1, B>\n) => <R2, E>(ma: ReaderEither<R2, E, A>) => ReaderEither<R1 & R2, E, A> = tapReader\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const MonadThrow: MonadThrow3<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  throwError\n}\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromOption: <E>(onNone: LazyArg<E>) => <A, R = unknown>(fa: Option<A>) => ReaderEither<R, E, A> =\n  /*#__PURE__*/ fromOption_(FromEither)\n\n/**\n * Use `liftOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Option<B>\n) => <R = unknown>(...a: A) => ReaderEither<R, E, B> = /*#__PURE__*/ fromOptionK_(FromEither)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B> =\n  /*#__PURE__*/ chainOptionK_(FromEither, Chain)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.13.2\n */\nexport const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E1 | E2, B> =\n  chainOptionK as any\n\n/** @internal */\ninterface ReaderEitherTypeLambda extends _.TypeLambda {\n  readonly type: ReaderEither<this['In'], this['Out1'], this['Target']>\n}\n\n/** @internal */\nconst _FromEither: _.FromEither<ReaderEitherTypeLambda> = {\n  fromEither: FromEither.fromEither\n}\n\n/** @internal */\nconst _FromReader: _.FromReader<ReaderEitherTypeLambda> = {\n  fromReader: FromReader.fromReader\n}\n\n/**\n * @category lifting\n * @since 2.15.0\n */\nexport const liftNullable: <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => B | null | undefined,\n  onNullable: (...a: A) => E\n) => <R>(...a: A) => ReaderEither<R, E, NonNullable<B>> = /*#__PURE__*/ _.liftNullable(_FromEither)\n\n/**\n * @category lifting\n * @since 2.15.0\n */\nexport const liftOption: <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => Option<B>,\n  onNone: (...a: A) => E\n) => <R>(...a: A) => ReaderEither<R, E, B> = /*#__PURE__*/ _.liftOption(_FromEither)\n\n/** @internal */\nconst _FlatMap: _.FlatMap<ReaderEitherTypeLambda> = {\n  flatMap\n}\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapNullable: {\n  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <R, E1>(\n    self: ReaderEither<R, E1, A>\n  ) => ReaderEither<R, E2 | E1, NonNullable<B>>\n  <R, E1, A, B, E2>(\n    self: ReaderEither<R, E1, A>,\n    f: (a: A) => B | null | undefined,\n    onNullable: (a: A) => E2\n  ): ReaderEither<R, E1 | E2, NonNullable<B>>\n} = /*#__PURE__*/ _.flatMapNullable(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapOption: {\n  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <R, E1>(\n    self: ReaderEither<R, E1, A>\n  ) => ReaderEither<R, E2 | E1, B>\n  <R, E1, A, B, E2>(self: ReaderEither<R, E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): ReaderEither<\n    R,\n    E1 | E2,\n    B\n  >\n} = /*#__PURE__*/ _.flatMapOption(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapEither: {\n  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <R, E1>(self: ReaderEither<R, E1, A>) => ReaderEither<R, E1 | E2, B>\n  <R, E1, A, E2, B>(self: ReaderEither<R, E1, A>, f: (a: A) => E.Either<E2, B>): ReaderEither<R, E1 | E2, B>\n} = /*#__PURE__*/ _.flatMapEither(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReader: {\n  <A, R2, B>(f: (a: A) => Reader<R2, B>): <R1, E>(self: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, B>\n  <R1, E, A, R2, B>(self: ReaderEither<R1, E, A>, f: (a: A) => Reader<R2, B>): ReaderEither<R1 & R2, E, B>\n} = /*#__PURE__*/ _.flatMapReader(_FromReader, _FlatMap)\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainEitherK: <E, A, B>(\n  f: (a: A) => E.Either<E, B>\n) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B> = flatMapEither\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainEitherKW: <E2, A, B>(\n  f: (a: A) => Either<E2, B>\n) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E1 | E2, B> = flatMapEither\n\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherK: <A, E, B>(\n  f: (a: A) => E.Either<E, B>\n) => <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A> = tapEither\n\n/**\n * Alias of `tapEither`.\n *\n * Less strict version of [`chainFirstEitherK`](#chainfirsteitherk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => Either<E2, B>\n) => <R, E1>(ma: ReaderEither<R, E1, A>) => ReaderEither<R, E1 | E2, A> = tapEither\n\n/**\n * Alias of `flatMapReader`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderK: <A, R, B>(\n  f: (a: A) => Reader<R, B>\n) => <E>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B> = flatMapReader\n\n/**\n * Alias of `flatMapReader`.\n *\n * Less strict version of [`chainReaderK`](#chainreaderk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderKW: <A, R2, B>(\n  f: (a: A) => Reader<R2, B>\n) => <R1, E>(ma: ReaderEither<R1, E, A>) => ReaderEither<R1 & R2, E, B> = flatMapReader\n\n/**\n * @category lifting\n * @since 2.0.0\n */\nexport const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown, B extends A = A>(b: B) => ReaderEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderEither<R, E, A>\n} = /*#__PURE__*/ fromPredicate_(FromEither)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n    ma: ReaderEither<R, E, A>\n  ) => ReaderEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(\n    mb: ReaderEither<R, E, B>\n  ) => ReaderEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A>\n} = /*#__PURE__*/ filterOrElse_(FromEither, Chain)\n\n/**\n * Less strict version of [`filterOrElse`](#filterorelse).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category filtering\n * @since 2.9.0\n */\nexport const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <R, E1>(\n    ma: ReaderEither<R, E1, A>\n  ) => ReaderEither<R, E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1, B extends A>(\n    mb: ReaderEither<R, E1, B>\n  ) => ReaderEither<R, E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1>(\n    ma: ReaderEither<R, E1, A>\n  ) => ReaderEither<R, E1 | E2, A>\n} = filterOrElse\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => E.Either<E, B>\n) => <R = unknown>(...a: A) => ReaderEither<R, E, B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: ReaderEither<unknown, never, {}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const bindW: <N extends string, A, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(\n  fa: ReaderEither<R1, E1, A>\n) => ReaderEither<R1 & R2, E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> = bind as any\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const apSW: <A, N extends string, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderEither<R2, E2, B>\n) => <R1, E1>(\n  fa: ReaderEither<R1, E1, A>\n) => ReaderEither<R1 & R2, E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> = apS as any\n\n/**\n * @since 2.11.0\n */\nexport const ApT: ReaderEither<unknown, never, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex = <A, R, E, B>(\n  f: (index: number, a: A) => ReaderEither<R, E, B>\n): ((as: ReadonlyNonEmptyArray<A>) => ReaderEither<R, E, ReadonlyNonEmptyArray<B>>) =>\n  flow(R.traverseReadonlyNonEmptyArrayWithIndex(f), R.map(E.traverseReadonlyNonEmptyArrayWithIndex(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, R, E, B>(\n  f: (index: number, a: A) => ReaderEither<R, E, B>\n): ((as: ReadonlyArray<A>) => ReaderEither<R, E, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <R, E, A, B>(\n  f: (index: number, a: A) => ReaderEither<R, E, B>\n) => (as: ReadonlyArray<A>) => ReaderEither<R, E, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n): ((as: ReadonlyArray<A>) => ReaderEither<R, E, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <R, E, A>(\n  arr: ReadonlyArray<ReaderEither<R, E, A>>\n) => ReaderEither<R, E, ReadonlyArray<A>> = /*#__PURE__*/ traverseArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, B> = flatMap\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.0\n */\nexport const chainW: <R2, E2, A, B>(\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n) => (ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A> = tap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.8.0\n */\nexport const chainFirstW: <R2, E2, A, B>(\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, A> = tap\n\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const orElseFirst: <E, R, B>(\n  onLeft: (e: E) => ReaderEither<R, E, B>\n) => <A>(ma: ReaderEither<R, E, A>) => ReaderEither<R, E, A> = tapError\n\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const orElseFirstW: <E1, R2, E2, B>(\n  onLeft: (e: E1) => ReaderEither<R2, E2, B>\n) => <R1, A>(ma: ReaderEither<R1, E1, A>) => ReaderEither<R1 & R2, E1 | E2, A> = tapError\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RE.Functor` instead of `RE.readerEither`\n * (where `R` is from `import R from 'fp-ts/ReaderEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const readerEither: Monad3<URI> & Bifunctor3<URI> & Alt3<URI> & MonadThrow3<URI> = {\n  URI,\n  bimap: mapBoth,\n  mapLeft: mapError,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  alt: _alt,\n  throwError: left\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplySemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderEither<R, E, A>> =\n  /*#__PURE__*/ getApplySemigroup_(Apply)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplyMonoid: <R, E, A>(M: Monoid<A>) => Monoid<ReaderEither<R, E, A>> =\n  /*#__PURE__*/ getApplicativeMonoid(Applicative)\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getSemigroup = <R, E, A>(S: Semigroup<A>): Semigroup<ReaderEither<R, E, A>> =>\n  getApplySemigroup_(R.Apply)(E.getSemigroup(S))\n\n/**\n * Use [`getApplicativeReaderValidation`](#getapplicativereadervalidation) and [`getAltReaderValidation`](#getaltreadervalidation) instead.\n *\n * @category zone of death\n * @since 2.3.0\n * @deprecated\n */\nexport function getReaderValidation<E>(\n  SE: Semigroup<E>\n): Monad3C<URI, E> & Bifunctor3<URI> & Alt3C<URI, E> & MonadThrow3C<URI, E> {\n  const applicativeReaderValidation = getApplicativeReaderValidation(SE)\n  const altReaderValidation = getAltReaderValidation(SE)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: applicativeReaderValidation.ap,\n    of,\n    chain: flatMap,\n    bimap: mapBoth,\n    mapLeft: mapError,\n    alt: altReaderValidation.alt,\n    throwError\n  }\n}\n"
  },
  {
    "path": "src/ReaderIO.ts",
    "content": "/**\n * @since 2.13.0\n */\nimport { Applicative2 } from './Applicative'\nimport { apFirst as apFirst_, Apply2, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport * as chainable from './Chain'\nimport { FromIO2, fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO'\nimport {\n  ask as ask_,\n  asks as asks_,\n  FromReader2,\n  fromReaderK as fromReaderK_,\n  tapReader as tapReader_\n} from './FromReader'\nimport { dual, flow, identity, pipe, SK } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor2 } from './Functor'\nimport * as _ from './internal'\nimport * as I from './IO'\nimport { IO } from './IO'\nimport { Monad2 } from './Monad'\nimport { MonadIO2 } from './MonadIO'\nimport { Pointed2 } from './Pointed'\nimport * as R from './Reader'\nimport { Reader } from './Reader'\nimport * as RT from './ReaderT'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\n\n/**\n * @category model\n * @since 2.13.0\n */\n\nexport interface ReaderIO<R, A> {\n  (r: R): I.IO<A>\n}\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.13.0\n */\nexport const fromReader: <R, A>(fa: Reader<R, A>) => ReaderIO<R, A> = /*#__PURE__*/ RT.fromReader(I.Pointed)\n\n/**\n * @category conversions\n * @since 2.13.0\n */\nexport const fromIO: <A, R = unknown>(fa: IO<A>) => ReaderIO<R, A> = R.of\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n * `contramap`).\n *\n * @since 2.13.0\n */\nexport const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderIO<R1, A>) => ReaderIO<R2, A> = R.local\n\n/**\n * Less strict version of [`asksReaderIO`](#asksreaderio).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category constructors\n * @since 2.13.0\n */\nexport const asksReaderIOW: <R1, R2, A>(f: (r1: R1) => ReaderIO<R2, A>) => ReaderIO<R1 & R2, A> = R.asksReaderW\n\n/**\n * Effectfully accesses the environment.\n *\n * @category constructors\n * @since 2.13.0\n */\nexport const asksReaderIO: <R, A>(f: (r: R) => ReaderIO<R, A>) => ReaderIO<R, A> = asksReaderIOW\n\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _ap: Apply2<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.13.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <R>(fa: ReaderIO<R, A>) => ReaderIO<R, B> = /*#__PURE__*/ RT.map(I.Functor)\n\n/**\n * @since 2.13.0\n */\nexport const ap: <R, A>(fa: ReaderIO<R, A>) => <B>(fab: ReaderIO<R, (a: A) => B>) => ReaderIO<R, B> =\n  /*#__PURE__*/ RT.ap(I.Apply)\n\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @since 2.13.0\n */\nexport const apW: <R2, A>(fa: ReaderIO<R2, A>) => <R1, B>(fab: ReaderIO<R1, (a: A) => B>) => ReaderIO<R1 & R2, B> =\n  ap as any\n\n/**\n * @category constructors\n * @since 2.13.0\n */\nexport const of: <R = unknown, A = never>(a: A) => ReaderIO<R, A> = /*#__PURE__*/ RT.of(I.Pointed)\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, R2, B>(f: (a: A) => ReaderIO<R2, B>): <R1>(ma: ReaderIO<R1, A>) => ReaderIO<R1 & R2, B>\n  <R1, A, R2, B>(ma: ReaderIO<R1, A>, f: (a: A) => ReaderIO<R2, B>): ReaderIO<R1 & R2, B>\n} = /*#__PURE__*/ dual(2, RT.flatMap(I.Monad))\n\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category sequencing\n * @since 2.13.0\n */\nexport const flattenW: <R1, R2, A>(mma: ReaderIO<R1, ReaderIO<R2, A>>) => ReaderIO<R1 & R2, A> =\n  /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category sequencing\n * @since 2.13.0\n */\nexport const flatten: <R, A>(mma: ReaderIO<R, ReaderIO<R, A>>) => ReaderIO<R, A> = flattenW\n\n/**\n * @category type lambdas\n * @since 2.13.0\n */\nexport const URI = 'ReaderIO'\n\n/**\n * @category type lambdas\n * @since 2.13.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: ReaderIO<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.13.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the value to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <R, _>(self: ReaderIO<R, _>) => ReaderIO<R, A>\n  <R, _, A>(self: ReaderIO<R, _>, a: A): ReaderIO<R, A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the value to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <R, _>(self: ReaderIO<R, _>) => ReaderIO<R, void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.13.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.13.0\n */\nexport const Pointed: Pointed2<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.13.0\n */\nexport const Apply: Apply2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.13.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.13.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.13.0\n */\nexport const Applicative: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.13.0\n */\nexport const Chain: chainable.Chain2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.13.0\n */\nexport const Monad: Monad2<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.13.0\n */\nexport const MonadIO: MonadIO2<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.13.0\n */\nexport const FromIO: FromIO2<URI> = {\n  URI,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.13.0\n */\nexport const FromReader: FromReader2<URI> = {\n  URI,\n  fromReader\n}\n\n/** @internal */\ninterface ReaderIOTypeLambda extends _.TypeLambda {\n  readonly type: ReaderIO<this['In'], this['Target']>\n}\n\n/** @internal */\nconst _FlatMap: _.FlatMap<ReaderIOTypeLambda> = {\n  flatMap\n}\n\n/** @internal */\nconst _FromIO: _.FromIO<ReaderIOTypeLambda> = {\n  fromIO: FromIO.fromIO\n}\n\n/** @internal */\nconst _FromReader: _.FromReader<ReaderIOTypeLambda> = {\n  fromReader\n}\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <R>(self: ReaderIO<R, A>) => ReaderIO<R, B>\n  <R, A, B>(self: ReaderIO<R, A>, f: (a: A) => IO<B>): ReaderIO<R, B>\n} = _.flatMapIO(_FromIO, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReader: {\n  <A, R2, B>(f: (a: A) => Reader<R2, B>): <R1>(self: ReaderIO<R1, A>) => ReaderIO<R1 & R2, B>\n  <R1, A, R2, B>(self: ReaderIO<R1, A>, f: (a: A) => Reader<R2, B>): ReaderIO<R1 & R2, B>\n} = /*#__PURE__*/ _.flatMapReader(_FromReader, _FlatMap)\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <R1, A, R2, _>(self: ReaderIO<R1, A>, f: (a: A) => ReaderIO<R2, _>): ReaderIO<R1 & R2, A>\n  <A, R2, _>(f: (a: A) => ReaderIO<R2, _>): <R1>(self: ReaderIO<R1, A>) => ReaderIO<R2 & R1, A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as RIO from 'fp-ts/ReaderIO'\n * import * as Console from 'fp-ts/Console'\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effect = pipe(\n *   RIO.ask<string>(),\n *   RIO.tapIO((value) => Console.log(`Hello, ${value}`)),\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(effect('fp-ts')(), 'fp-ts')\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <R>(self: ReaderIO<R, A>) => ReaderIO<R, A>\n  <R, A, _>(self: ReaderIO<R, A>, f: (a: A) => IO<_>): ReaderIO<R, A>\n} = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapReader: {\n  <R2, A, _>(f: (a: A) => Reader<R2, _>): <R1>(self: ReaderIO<R1, A>) => ReaderIO<R1 & R2, A>\n  <R1, A, R2, _>(self: ReaderIO<R1, A>, f: (a: A) => Reader<R2, _>): ReaderIO<R1 & R2, A>\n} = /*#__PURE__*/ dual(2, tapReader_(FromReader, Chain))\n\n/**\n * @category lifting\n * @since 2.13.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => I.IO<B>\n) => <R = unknown>(...a: A) => ReaderIO<R, B> = /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: ReaderIO<E, A>) => ReaderIO<E, B> = flatMapIO\n\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: ReaderIO<E, A>) => ReaderIO<E, A> = tapIO\n\n/**\n * Reads the current context.\n *\n * @category constructors\n * @since 2.13.0\n */\nexport const ask = /*#__PURE__*/ ask_(FromReader)\n\n/**\n * Projects a value from the global context in a `ReaderIO`.\n *\n * @category constructors\n * @since 2.13.0\n */\nexport const asks = /*#__PURE__*/ asks_(FromReader)\n\n/**\n * @category lifting\n * @since 2.13.0\n */\nexport const fromReaderK: <A extends ReadonlyArray<unknown>, R, B>(\n  f: (...a: A) => R.Reader<R, B>\n) => (...a: A) => ReaderIO<R, B> = /*#__PURE__*/ fromReaderK_(FromReader)\n\n/**\n * Alias of `flatMapReader`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderIO<R, A>) => ReaderIO<R, B> =\n  flatMapReader\n\n/**\n * Alias of `flatMapReader`.\n *\n * Less strict version of [`chainReaderK`](#chainreaderk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2>(ma: ReaderIO<R2, A>) => ReaderIO<R1 & R2, B> = flatMapReader\n\n/**\n * Alias of `tapReader`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainFirstReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderIO<R, A>) => ReaderIO<R, A> =\n  tapReader\n\n/**\n * Alias of `tapReader`.\n *\n * Less strict version of [`chainFirstReaderK`](#chainfirstreaderk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2>(ma: ReaderIO<R2, A>) => ReaderIO<R1 & R2, A> = tapReader\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.13.0\n */\nexport const Do: ReaderIO<unknown, {}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.13.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\n/**\n * @category do notation\n * @since 2.13.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category do notation\n * @since 2.13.0\n */\nexport const bindW: <N extends string, A, R2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderIO<R2, B>\n) => <R1>(fa: ReaderIO<R1, A>) => ReaderIO<R1 & R2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  bind as any\n\n/**\n * @category do notation\n * @since 2.13.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category do notation\n * @since 2.13.0\n */\nexport const apSW: <N extends string, A, R2, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderIO<R2, B>\n) => <R1>(fa: ReaderIO<R1, A>) => ReaderIO<R1 & R2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  apS as any\n\n/**\n * @since 2.13.0\n */\nexport const ApT: ReaderIO<unknown, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.13.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex = <A, R, B>(\n  f: (index: number, a: A) => ReaderIO<R, B>\n): ((as: ReadonlyNonEmptyArray<A>) => ReaderIO<R, ReadonlyNonEmptyArray<B>>) =>\n  flow(R.traverseReadonlyNonEmptyArrayWithIndex(f), R.map(I.traverseReadonlyNonEmptyArrayWithIndex(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.13.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, R, B>(\n  f: (index: number, a: A) => ReaderIO<R, B>\n): ((as: ReadonlyArray<A>) => ReaderIO<R, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.13.0\n */\nexport const traverseArrayWithIndex: <A, R, B>(\n  f: (index: number, a: A) => ReaderIO<R, B>\n) => (as: ReadonlyArray<A>) => ReaderIO<R, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.13.0\n */\nexport const traverseArray = <A, R, B>(\n  f: (a: A) => ReaderIO<R, B>\n): ((as: ReadonlyArray<A>) => ReaderIO<R, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.13.0\n */\nexport const sequenceArray: <R, A>(arr: ReadonlyArray<ReaderIO<R, A>>) => ReaderIO<R, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chain: <A, R, B>(f: (a: A) => ReaderIO<R, B>) => (ma: ReaderIO<R, A>) => ReaderIO<R, B> = flatMap\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainW: <A, R2, B>(f: (a: A) => ReaderIO<R2, B>) => <R1>(ma: ReaderIO<R1, A>) => ReaderIO<R1 & R2, B> =\n  flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainFirst: <A, R, B>(f: (a: A) => ReaderIO<R, B>) => (first: ReaderIO<R, A>) => ReaderIO<R, A> = tap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainFirstW: <A, R2, B>(\n  f: (a: A) => ReaderIO<R2, B>\n) => <R1>(ma: ReaderIO<R1, A>) => ReaderIO<R1 & R2, A> = tap\n"
  },
  {
    "path": "src/ReaderT.ts",
    "content": "/**\n * The reader monad transformer, which adds a read-only environment to the given monad.\n *\n * The `of` function ignores the environment, while `chain` passes the inherited environment to both subcomputations.\n *\n * @since 2.0.0\n */\nimport { Apply, Apply1, Apply2, Apply2C, Apply3, Apply3C, Apply4 } from './Apply'\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C, Chain4 } from './Chain'\nimport { flow, pipe } from './function'\nimport { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C, Functor4 } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Monad, Monad1, Monad2, Monad2C, Monad3 } from './Monad'\nimport {\n  NaturalTransformation,\n  NaturalTransformation11,\n  NaturalTransformation12,\n  NaturalTransformation22,\n  NaturalTransformation23R,\n  NaturalTransformation24S\n} from './NaturalTransformation'\nimport { Pointed, Pointed1, Pointed2, Pointed2C, Pointed3, Pointed3C, Pointed4 } from './Pointed'\nimport { Reader } from './Reader'\n\n/**\n * @since 2.10.0\n */\nexport function of<F extends URIS4>(F: Pointed4<F>): <A, R, S, FR, FE>(a: A) => Reader<R, Kind4<F, S, FR, FE, A>>\nexport function of<F extends URIS3>(F: Pointed3<F>): <A, R, FR, FE>(a: A) => Reader<R, Kind3<F, FR, FE, A>>\nexport function of<F extends URIS3, FE>(F: Pointed3C<F, FE>): <A, R, FR>(a: A) => Reader<R, Kind3<F, FR, FE, A>>\nexport function of<F extends URIS2>(F: Pointed2<F>): <A, R, FE>(a: A) => Reader<R, Kind2<F, FE, A>>\nexport function of<F extends URIS2, FE>(F: Pointed2C<F, FE>): <A, R>(a: A) => Reader<R, Kind2<F, FE, A>>\nexport function of<F extends URIS>(F: Pointed1<F>): <A, R>(a: A) => Reader<R, Kind<F, A>>\nexport function of<F>(F: Pointed<F>): <A, R>(a: A) => Reader<R, HKT<F, A>>\nexport function of<F>(F: Pointed<F>): <A, R>(a: A) => Reader<R, HKT<F, A>> {\n  return (a) => () => F.of(a)\n}\n\n/**\n * @since 2.10.0\n */\nexport function map<F extends URIS4>(\n  F: Functor4<F>\n): <A, B>(f: (a: A) => B) => <R, S, FR, FE>(fa: Reader<R, Kind4<F, S, FR, FE, A>>) => Reader<R, Kind4<F, S, FR, FE, B>>\nexport function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, FR, FE>(fa: Reader<R, Kind3<F, FR, FE, A>>) => Reader<R, Kind3<F, FR, FE, B>>\nexport function map<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <A, B>(f: (a: A) => B) => <R, FR>(fa: Reader<R, Kind3<F, FR, FE, A>>) => Reader<R, Kind3<F, FR, FE, B>>\nexport function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <R, FE>(fa: Reader<R, Kind2<F, FE, A>>) => Reader<R, Kind2<F, FE, B>>\nexport function map<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, Kind2<F, FE, A>>) => Reader<R, Kind2<F, FE, B>>\nexport function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, Kind<F, A>>) => Reader<R, Kind<F, B>>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, HKT<F, A>>) => Reader<R, HKT<F, B>>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <R>(fa: Reader<R, HKT<F, A>>) => Reader<R, HKT<F, B>> {\n  return (f) => (fa) => (r) => F.map(fa(r), f)\n}\n\n/**\n * @since 2.10.0\n */\nexport function ap<F extends URIS4>(\n  F: Apply4<F>\n): <R, S, FR, FE, A>(\n  fa: Reader<R, Kind4<F, S, FR, FE, A>>\n) => <B>(fab: Reader<R, Kind4<F, S, FR, FE, (a: A) => B>>) => Reader<R, Kind4<F, S, FR, FE, B>>\nexport function ap<F extends URIS3>(\n  F: Apply3<F>\n): <R, FR, FE, A>(\n  fa: Reader<R, Kind3<F, FR, FE, A>>\n) => <B>(fab: Reader<R, Kind3<F, FR, FE, (a: A) => B>>) => Reader<R, Kind3<F, FR, FE, B>>\nexport function ap<F extends URIS3, FE>(\n  F: Apply3C<F, FE>\n): <R, FR, A>(\n  fa: Reader<R, Kind3<F, FR, FE, A>>\n) => <B>(fab: Reader<R, Kind3<F, FR, FE, (a: A) => B>>) => Reader<R, Kind3<F, FR, FE, B>>\nexport function ap<F extends URIS2>(\n  F: Apply2<F>\n): <R, FE, A>(\n  fa: Reader<R, Kind2<F, FE, A>>\n) => <B>(fab: Reader<R, Kind2<F, FE, (a: A) => B>>) => Reader<R, Kind2<F, FE, B>>\nexport function ap<F extends URIS2, FE>(\n  F: Apply2C<F, FE>\n): <R, A>(\n  fa: Reader<R, Kind2<F, FE, A>>\n) => <B>(fab: Reader<R, Kind2<F, FE, (a: A) => B>>) => Reader<R, Kind2<F, FE, B>>\nexport function ap<F extends URIS>(\n  F: Apply1<F>\n): <R, A>(fa: Reader<R, Kind<F, A>>) => <B>(fab: Reader<R, Kind<F, (a: A) => B>>) => Reader<R, Kind<F, B>>\nexport function ap<F>(\n  F: Apply<F>\n): <R, A>(fa: Reader<R, HKT<F, A>>) => <B>(fab: Reader<R, HKT<F, (a: A) => B>>) => Reader<R, HKT<F, B>>\nexport function ap<F>(\n  F: Apply<F>\n): <R, A>(fa: Reader<R, HKT<F, A>>) => <B>(fab: Reader<R, HKT<F, (a: A) => B>>) => Reader<R, HKT<F, B>> {\n  return (fa) => (fab) => (r) => F.ap(fab(r), fa(r))\n}\n\n/**\n * @since 2.10.0\n */\nexport function chain<M extends URIS4>(\n  M: Chain4<M>\n): <A, R, S, FR, FE, B>(\n  f: (a: A) => Reader<R, Kind4<M, S, FR, FE, B>>\n) => (ma: Reader<R, Kind4<M, S, FR, FE, A>>) => Reader<R, Kind4<M, S, FR, FE, B>>\nexport function chain<M extends URIS3>(\n  M: Chain3<M>\n): <A, R, FR, FE, B>(\n  f: (a: A) => Reader<R, Kind3<M, FR, FE, B>>\n) => (ma: Reader<R, Kind3<M, FR, FE, A>>) => Reader<R, Kind3<M, FR, FE, B>>\nexport function chain<M extends URIS3, FE>(\n  M: Chain3C<M, FE>\n): <A, R, FR, B>(\n  f: (a: A) => Reader<R, Kind3<M, FR, FE, B>>\n) => (ma: Reader<R, Kind3<M, FR, FE, A>>) => Reader<R, Kind3<M, FR, FE, B>>\nexport function chain<M extends URIS2>(\n  M: Chain2<M>\n): <A, R, FE, B>(\n  f: (a: A) => Reader<R, Kind2<M, FE, B>>\n) => (ma: Reader<R, Kind2<M, FE, A>>) => Reader<R, Kind2<M, FE, B>>\nexport function chain<M extends URIS2, FE>(\n  M: Chain2C<M, FE>\n): <A, R, B>(f: (a: A) => Reader<R, Kind2<M, FE, B>>) => (ma: Reader<R, Kind2<M, FE, A>>) => Reader<R, Kind2<M, FE, B>>\nexport function chain<M extends URIS>(\n  M: Chain1<M>\n): <A, R, B>(f: (a: A) => Reader<R, Kind<M, B>>) => (ma: Reader<R, Kind<M, A>>) => Reader<R, Kind<M, B>>\nexport function chain<M>(\n  M: Chain<M>\n): <A, R, B>(f: (a: A) => Reader<R, HKT<M, B>>) => (ma: Reader<R, HKT<M, A>>) => Reader<R, HKT<M, B>>\nexport function chain<M>(\n  M: Chain<M>\n): <A, R, B>(f: (a: A) => Reader<R, HKT<M, B>>) => (ma: Reader<R, HKT<M, A>>) => Reader<R, HKT<M, B>> {\n  const flatMapM = flatMap(M)\n  return (f) => (ma) => flatMapM(ma, f)\n}\n\n/** @internal */\nexport function flatMap<M extends URIS>(\n  M: Chain1<M>\n): <R, A, B>(ma: Reader<R, Kind<M, A>>, f: (a: A) => Reader<R, Kind<M, B>>) => Reader<R, Kind<M, B>>\n/** @internal */\nexport function flatMap<M>(\n  M: Chain<M>\n): <R, A, B>(ma: Reader<R, HKT<M, A>>, f: (a: A) => Reader<R, HKT<M, B>>) => Reader<R, HKT<M, B>>\n/** @internal */\nexport function flatMap<M>(\n  M: Chain<M>\n): <R, A, B>(ma: Reader<R, HKT<M, A>>, f: (a: A) => Reader<R, HKT<M, B>>) => Reader<R, HKT<M, B>> {\n  return (ma, f) => (r) => M.chain(ma(r), (a) => f(a)(r))\n}\n\n/**\n * @since 2.10.0\n */\nexport function fromReader<F extends URIS4>(\n  F: Pointed4<F>\n): <R, A, S, FR, FE>(ma: Reader<R, A>) => Reader<R, Kind4<F, S, FR, FE, A>>\nexport function fromReader<F extends URIS3>(\n  F: Pointed3<F>\n): <R, A, FR, FE>(ma: Reader<R, A>) => Reader<R, Kind3<F, FR, FE, A>>\nexport function fromReader<F extends URIS3, FE>(\n  F: Pointed3C<F, FE>\n): <R, A, FR>(ma: Reader<R, A>) => Reader<R, Kind3<F, FR, FE, A>>\nexport function fromReader<F extends URIS2>(F: Pointed2<F>): <R, A, FE>(ma: Reader<R, A>) => Reader<R, Kind2<F, FE, A>>\nexport function fromReader<F extends URIS2, FE>(\n  F: Pointed2C<F, FE>\n): <R, A>(ma: Reader<R, A>) => Reader<R, Kind2<F, FE, A>>\nexport function fromReader<F extends URIS>(F: Pointed1<F>): <R, A>(ma: Reader<R, A>) => Reader<R, Kind<F, A>>\nexport function fromReader<F>(F: Pointed<F>): <R, A>(ma: Reader<R, A>) => Reader<R, HKT<F, A>>\nexport function fromReader<F>(F: Pointed<F>): <R, A>(ma: Reader<R, A>) => Reader<R, HKT<F, A>> {\n  return (ma) => flow(ma, F.of)\n}\n\n/**\n * @category constructors\n * @since 2.11.0\n */\nexport function fromNaturalTransformation<F extends URIS2, G extends URIS4>(\n  nt: NaturalTransformation24S<F, G>\n): <R, S, A, E>(f: (r: R) => Kind2<F, S, A>) => Reader<R, Kind4<G, S, R, E, A>>\nexport function fromNaturalTransformation<F extends URIS2, G extends URIS3>(\n  nt: NaturalTransformation23R<F, G>\n): <R, A, E>(f: (r: R) => Kind2<F, R, A>) => Reader<R, Kind3<G, R, E, A>>\nexport function fromNaturalTransformation<F extends URIS2, G extends URIS2>(\n  nt: NaturalTransformation22<F, G>\n): <R, E, A>(f: (r: R) => Kind2<F, E, A>) => Reader<R, Kind2<G, E, A>>\nexport function fromNaturalTransformation<F extends URIS, G extends URIS2>(\n  nt: NaturalTransformation12<F, G>\n): <R, A, E>(f: (r: R) => Kind<F, A>) => Reader<R, Kind2<G, E, A>>\nexport function fromNaturalTransformation<F extends URIS, G extends URIS>(\n  nt: NaturalTransformation11<F, G>\n): <R, A>(f: (r: R) => Kind<F, A>) => Reader<R, Kind<G, A>>\nexport function fromNaturalTransformation<F, G>(\n  nt: NaturalTransformation<F, G>\n): <R, A>(f: (r: R) => HKT<F, A>) => Reader<R, HKT<G, A>>\nexport function fromNaturalTransformation<F, G>(\n  nt: NaturalTransformation<F, G>\n): <R, A>(f: (r: R) => HKT<F, A>) => Reader<R, HKT<G, A>> {\n  return (f) => flow(f, nt)\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ReaderT<M, R, A> {\n  (r: R): HKT<M, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ReaderM<M> {\n  readonly map: <R, A, B>(ma: ReaderT<M, R, A>, f: (a: A) => B) => ReaderT<M, R, B>\n  readonly of: <R, A>(a: A) => ReaderT<M, R, A>\n  readonly ap: <R, A, B>(mab: ReaderT<M, R, (a: A) => B>, ma: ReaderT<M, R, A>) => ReaderT<M, R, B>\n  readonly chain: <R, A, B>(ma: ReaderT<M, R, A>, f: (a: A) => ReaderT<M, R, B>) => ReaderT<M, R, B>\n  readonly ask: <R>() => ReaderT<M, R, R>\n  readonly asks: <R, A>(f: (r: R) => A) => ReaderT<M, R, A>\n  readonly local: <R1, A, R2>(ma: ReaderT<M, R1, A>, f: (d: R2) => R1) => ReaderT<M, R2, A>\n  readonly fromReader: <R, A>(ma: Reader<R, A>) => ReaderT<M, R, A>\n  readonly fromM: <R, A>(ma: HKT<M, A>) => ReaderT<M, R, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ReaderT1<M extends URIS, R, A> {\n  (r: R): Kind<M, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ReaderM1<M extends URIS> {\n  readonly map: <R, A, B>(ma: ReaderT1<M, R, A>, f: (a: A) => B) => ReaderT1<M, R, B>\n  readonly of: <R, A>(a: A) => ReaderT1<M, R, A>\n  readonly ap: <R, A, B>(mab: ReaderT1<M, R, (a: A) => B>, ma: ReaderT1<M, R, A>) => ReaderT1<M, R, B>\n  readonly chain: <R, A, B>(ma: ReaderT1<M, R, A>, f: (a: A) => ReaderT1<M, R, B>) => ReaderT1<M, R, B>\n  readonly ask: <R>() => ReaderT1<M, R, R>\n  readonly asks: <R, A>(f: (r: R) => A) => ReaderT1<M, R, A>\n  readonly local: <R1, A, R2>(ma: ReaderT1<M, R1, A>, f: (d: R2) => R1) => ReaderT1<M, R2, A>\n  readonly fromReader: <R, A>(ma: Reader<R, A>) => ReaderT1<M, R, A>\n  readonly fromM: <R, A>(ma: Kind<M, A>) => ReaderT1<M, R, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ReaderT2<M extends URIS2, R, E, A> {\n  (r: R): Kind2<M, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ReaderM2<M extends URIS2> {\n  readonly map: <R, E, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => B) => ReaderT2<M, R, E, B>\n  readonly of: <R, E, A>(a: A) => ReaderT2<M, R, E, A>\n  readonly ap: <R, E, A, B>(mab: ReaderT2<M, R, E, (a: A) => B>, ma: ReaderT2<M, R, E, A>) => ReaderT2<M, R, E, B>\n  readonly chain: <R, E, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => ReaderT2<M, R, E, B>) => ReaderT2<M, R, E, B>\n  readonly ask: <R, E>() => ReaderT2<M, R, E, R>\n  readonly asks: <R, E, A>(f: (r: R) => A) => ReaderT2<M, R, E, A>\n  readonly local: <R1, E, A, R2>(ma: ReaderT2<M, R1, E, A>, f: (d: R2) => R1) => ReaderT2<M, R2, E, A>\n  readonly fromReader: <R, E, A>(ma: Reader<R, A>) => ReaderT2<M, R, E, A>\n  readonly fromM: <R, E, A>(ma: Kind2<M, E, A>) => ReaderT2<M, R, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.2.0\n * @deprecated\n */\nexport interface ReaderM2C<M extends URIS2, E> {\n  readonly map: <R, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => B) => ReaderT2<M, R, E, B>\n  readonly of: <R, A>(a: A) => ReaderT2<M, R, E, A>\n  readonly ap: <R, A, B>(mab: ReaderT2<M, R, E, (a: A) => B>, ma: ReaderT2<M, R, E, A>) => ReaderT2<M, R, E, B>\n  readonly chain: <R, A, B>(ma: ReaderT2<M, R, E, A>, f: (a: A) => ReaderT2<M, R, E, B>) => ReaderT2<M, R, E, B>\n  readonly ask: <R>() => ReaderT2<M, R, E, R>\n  readonly asks: <R, A>(f: (r: R) => A) => ReaderT2<M, R, E, A>\n  readonly local: <R1, A, R2>(ma: ReaderT2<M, R1, E, A>, f: (d: R2) => R1) => ReaderT2<M, R2, E, A>\n  readonly fromReader: <R, A>(ma: Reader<R, A>) => ReaderT2<M, R, E, A>\n  readonly fromM: <R, A>(ma: Kind2<M, E, A>) => ReaderT2<M, R, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ReaderT3<M extends URIS3, R, U, E, A> {\n  (r: R): Kind3<M, U, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ReaderM3<M extends URIS3> {\n  readonly map: <R, U, E, A, B>(ma: ReaderT3<M, R, U, E, A>, f: (a: A) => B) => ReaderT3<M, R, U, E, B>\n  readonly of: <R, U, E, A>(a: A) => ReaderT3<M, R, U, E, A>\n  readonly ap: <R, U, E, A, B>(\n    mab: ReaderT3<M, R, U, E, (a: A) => B>,\n    ma: ReaderT3<M, R, U, E, A>\n  ) => ReaderT3<M, R, U, E, B>\n  readonly chain: <R, U, E, A, B>(\n    ma: ReaderT3<M, R, U, E, A>,\n    f: (a: A) => ReaderT3<M, R, U, E, B>\n  ) => ReaderT3<M, R, U, E, B>\n  readonly ask: <R, U, E>() => ReaderT3<M, R, U, E, R>\n  readonly asks: <R, U, E, A>(f: (r: R) => A) => ReaderT3<M, R, U, E, A>\n  readonly local: <R1, U, E, A, R2>(ma: ReaderT3<M, R1, U, E, A>, f: (d: R2) => R1) => ReaderT3<M, R2, U, E, A>\n  readonly fromReader: <R, U, E, A>(ma: Reader<R, A>) => ReaderT3<M, R, U, E, A>\n  readonly fromM: <R, U, E, A>(ma: Kind3<M, U, E, A>) => ReaderT3<M, R, U, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getReaderM<M extends URIS3>(M: Monad3<M>): ReaderM3<M>\n/** @deprecated */\nexport function getReaderM<M extends URIS2>(M: Monad2<M>): ReaderM2<M>\n/** @deprecated */\nexport function getReaderM<M extends URIS2, E>(M: Monad2C<M, E>): ReaderM2C<M, E>\n/** @deprecated */\nexport function getReaderM<M extends URIS>(M: Monad1<M>): ReaderM1<M>\n/** @deprecated */\nexport function getReaderM<M>(M: Monad<M>): ReaderM<M>\n/** @deprecated */\n/* istanbul ignore next */\nexport function getReaderM<M>(M: Monad<M>): ReaderM<M> {\n  const _ap = ap(M)\n  const _map = map(M)\n  const _chain = chain(M)\n\n  return {\n    map: (fa, f) => pipe(fa, _map(f)),\n    ap: (fab, fa) => pipe(fab, _ap(fa)),\n    of: of(M),\n    chain: (ma, f) => pipe(ma, _chain(f)),\n    ask: () => M.of,\n    asks: (f) => flow(f, M.of),\n    local: (ma, f) => (q) => ma(f(q)),\n    fromReader: fromReader(M),\n    fromM: (ma) => () => ma\n  }\n}\n"
  },
  {
    "path": "src/ReaderTask.ts",
    "content": "/**\n * @since 2.3.0\n */\nimport { Applicative2, getApplicativeMonoid } from './Applicative'\nimport {\n  apFirst as apFirst_,\n  Apply2,\n  apS as apS_,\n  apSecond as apSecond_,\n  getApplySemigroup as getApplySemigroup_\n} from './Apply'\nimport * as chainable from './Chain'\nimport { FromIO2, fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO'\nimport {\n  ask as ask_,\n  asks as asks_,\n  FromReader2,\n  fromReaderK as fromReaderK_,\n  tapReader as tapReader_\n} from './FromReader'\nimport { FromTask2, fromTaskK as fromTaskK_, tapTask as tapTask_ } from './FromTask'\nimport { dual, flow, identity, pipe, SK } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor2, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { IO } from './IO'\nimport { Monad2 } from './Monad'\nimport { MonadIO2 } from './MonadIO'\nimport { MonadTask2 } from './MonadTask'\nimport { Monoid } from './Monoid'\nimport { Pointed2 } from './Pointed'\nimport * as R from './Reader'\nimport * as RIO from './ReaderIO'\nimport * as RT from './ReaderT'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Semigroup } from './Semigroup'\nimport * as T from './Task'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\nimport ReaderIO = RIO.ReaderIO\nimport Task = T.Task\n\n/**\n * @category model\n * @since 2.3.0\n */\nexport interface ReaderTask<R, A> {\n  (r: R): Task<A>\n}\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.3.0\n */\nexport const fromReader: <R, A>(fa: R.Reader<R, A>) => ReaderTask<R, A> = /*#__PURE__*/ RT.fromReader(T.Pointed)\n\n/**\n * @category conversions\n * @since 2.3.0\n */\nexport const fromTask: <A, R = unknown>(fa: Task<A>) => ReaderTask<R, A> = R.of\n\n/**\n * @category conversions\n * @since 2.3.0\n */\nexport const fromIO: <A, R = unknown>(fa: IO<A>) => ReaderTask<R, A> = /*#__PURE__*/ flow(T.fromIO, fromTask)\n\n/**\n * @category conversions\n * @since 2.13.0\n */\nexport const fromReaderIO: <R, A>(fa: ReaderIO<R, A>) => ReaderTask<R, A> = R.map(T.fromIO)\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n * `contramap`).\n *\n * @since 2.3.0\n */\nexport const local: <R2, R1>(f: (r2: R2) => R1) => <A>(ma: ReaderTask<R1, A>) => ReaderTask<R2, A> = R.local\n\n/**\n * Less strict version of [`asksReaderTask`](#asksreadertask).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksReaderTaskW: <R1, R2, A>(f: (r1: R1) => ReaderTask<R2, A>) => ReaderTask<R1 & R2, A> = R.asksReaderW\n\n/**\n * Effectfully accesses the environment.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksReaderTask: <R, A>(f: (r: R) => ReaderTask<R, A>) => ReaderTask<R, A> = asksReaderTaskW\n\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _apPar: Apply2<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\nconst _apSeq: Apply2<URI>['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map(f)))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.3.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <R>(fa: ReaderTask<R, A>) => ReaderTask<R, B> = /*#__PURE__*/ RT.map(\n  T.Functor\n)\n\n/**\n * @since 2.3.0\n */\nexport const ap: <R, A>(fa: ReaderTask<R, A>) => <B>(fab: ReaderTask<R, (a: A) => B>) => ReaderTask<R, B> =\n  /*#__PURE__*/ RT.ap(T.ApplyPar)\n\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @since 2.8.0\n */\nexport const apW: <R2, A>(\n  fa: ReaderTask<R2, A>\n) => <R1, B>(fab: ReaderTask<R1, (a: A) => B>) => ReaderTask<R1 & R2, B> = ap as any\n\n/**\n * @category constructors\n * @since 2.3.0\n */\nexport const of: <R = unknown, A = never>(a: A) => ReaderTask<R, A> = /*#__PURE__*/ RT.of(T.Pointed)\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, R2, B>(f: (a: A) => ReaderTask<R2, B>): <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>\n  <R1, A, R2, B>(ma: ReaderTask<R1, A>, f: (a: A) => ReaderTask<R2, B>): ReaderTask<R1 & R2, B>\n} = /*#__PURE__*/ dual(2, RT.flatMap(T.Monad))\n\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport const flattenW: <R1, R2, A>(mma: ReaderTask<R1, ReaderTask<R2, A>>) => ReaderTask<R1 & R2, A> =\n  /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category sequencing\n * @since 2.3.0\n */\nexport const flatten: <R, A>(mma: ReaderTask<R, ReaderTask<R, A>>) => ReaderTask<R, A> = flattenW\n\n/**\n * @category type lambdas\n * @since 2.3.0\n */\nexport const URI = 'ReaderTask'\n\n/**\n * @category type lambdas\n * @since 2.3.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: ReaderTask<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the value to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <R, _>(self: ReaderTask<R, _>) => ReaderTask<R, A>\n  <R, _, A>(self: ReaderTask<R, _>, a: A): ReaderTask<R, A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the value to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <R, _>(self: ReaderTask<R, _>) => ReaderTask<R, void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed2<URI> = {\n  URI,\n  of\n}\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplyPar: Apply2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.3.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(ApplyPar)\n\n/**\n * Less strict version of [`apFirst`](#apfirst).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @since 2.16.10\n */\nexport const apFirstW: <R2, B>(\n  second: ReaderTask<R2, B>\n) => <R1, A>(first: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A> = apFirst as any\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.3.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(ApplyPar)\n\n/**\n * Less strict version of [`apSecond`](#apsecond).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @since 2.16.10\n */\nexport const apSecondW: <R2, B>(\n  second: ReaderTask<R2, B>\n) => <R1, A>(first: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B> = apSecond as any\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.7.0\n */\nexport const ApplicativePar: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  of\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplySeq: Apply2<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.7.0\n */\nexport const ApplicativeSeq: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Monad: Monad2<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadIO: MonadIO2<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadTask: MonadTask2<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromIO: FromIO2<URI> = {\n  URI,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromTask: FromTask2<URI> = {\n  URI,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromReader: FromReader2<URI> = {\n  URI,\n  fromReader\n}\n\n/** @internal */\ninterface ReaderTaskTypeLambda extends _.TypeLambda {\n  readonly type: ReaderTask<this['In'], this['Target']>\n}\n\n/** @internal */\nconst _FlatMap: _.FlatMap<ReaderTaskTypeLambda> = {\n  flatMap\n}\n\n/** @internal */\nconst _FromIO: _.FromIO<ReaderTaskTypeLambda> = {\n  fromIO: FromIO.fromIO\n}\n\n/** @internal */\nconst _FromTask: _.FromTask<ReaderTaskTypeLambda> = {\n  fromTask\n}\n\n/** @internal */\nconst _FromReader: _.FromReader<ReaderTaskTypeLambda> = {\n  fromReader\n}\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, B>\n  <R, A, B>(self: ReaderTask<R, A>, f: (a: A) => IO<B>): ReaderTask<R, B>\n} = _.flatMapIO(_FromIO, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapTask: {\n  <A, B>(f: (a: A) => Task<B>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, B>\n  <R, A, B>(self: ReaderTask<R, A>, f: (a: A) => Task<B>): ReaderTask<R, B>\n} = _.flatMapTask(_FromTask, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReader: {\n  <A, R2, B>(f: (a: A) => R.Reader<R2, B>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>\n  <R1, A, R2, B>(self: ReaderTask<R1, A>, f: (a: A) => R.Reader<R2, B>): ReaderTask<R1 & R2, B>\n} = _.flatMapReader(_FromReader, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReaderIO: {\n  <A, R2, B>(f: (a: A) => ReaderIO<R2, B>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B>\n  <R1, A, R2, B>(self: ReaderTask<R1, A>, f: (a: A) => ReaderIO<R2, B>): ReaderTask<R1 & R2, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <R1, A, R2, B>(self: ReaderTask<R1, A>, f: (a: A) => ReaderIO<R2, B>): ReaderTask<R1 & R2, B> =>\n    flatMap(self, fromReaderIOK(f))\n)\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <R1, A, R2, _>(self: ReaderTask<R1, A>, f: (a: A) => ReaderTask<R2, _>): ReaderTask<R1 & R2, A>\n  <A, R2, _>(f: (a: A) => ReaderTask<R2, _>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R2 & R1, A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as RT from 'fp-ts/ReaderTask'\n * import * as Console from 'fp-ts/Console'\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effect = pipe(\n *   RT.ask<string>(),\n *   RT.tapIO((value) => Console.log(`Hello, ${value}`)),\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effect('fp-ts')(), 'fp-ts')\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, A>\n  <R, A, _>(self: ReaderTask<R, A>, f: (a: A) => IO<_>): ReaderTask<R, A>\n} = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapReader: {\n  <R2, A, _>(f: (a: A) => R.Reader<R2, _>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>\n  <R1, R2, A, _>(self: ReaderTask<R1, A>, f: (a: A) => R.Reader<R2, _>): ReaderTask<R1 & R2, A>\n} = /*#__PURE__*/ dual(2, tapReader_(FromReader, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as RT from 'fp-ts/ReaderTask'\n * import * as T from 'fp-ts/Task'\n *\n * const effect = pipe(\n *   RT.ask<number>(),\n *   RT.tapTask((value) => T.of(value + 1)),\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effect(1)(), 1)\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapTask: {\n  <A, _>(f: (a: A) => Task<_>): <R>(self: ReaderTask<R, A>) => ReaderTask<R, A>\n  <R, A, _>(self: ReaderTask<R, A>, f: (a: A) => Task<_>): ReaderTask<R, A>\n} = /*#__PURE__*/ dual(2, tapTask_(FromTask, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapReaderIO: {\n  <R2, A, _>(f: (a: A) => ReaderIO<R2, _>): <R1>(self: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A>\n  <R1, R2, A, _>(self: ReaderTask<R1, A>, f: (a: A) => ReaderIO<R2, _>): ReaderTask<R1 & R2, A>\n} = /*#__PURE__*/ dual(\n  2,\n  <R1, R2, A, _>(self: ReaderTask<R1, A>, f: (a: A) => ReaderIO<R2, _>): ReaderTask<R1 & R2, A> =>\n    tap(self, fromReaderIOK(f))\n)\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => IO<B>\n) => <R = unknown>(...a: A) => ReaderTask<R, B> = /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainIOK: <A, B>(f: (a: A) => IO<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, B> = flatMapIO\n\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, A> = tapIO\n\n/**\n * Reads the current context.\n *\n * @category constructors\n * @since 2.3.0\n */\nexport const ask = /*#__PURE__*/ ask_(FromReader)\n\n/**\n * Projects a value from the global context in a `ReaderTask`.\n *\n * @category constructors\n * @since 2.3.0\n */\nexport const asks = /*#__PURE__*/ asks_(FromReader)\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromReaderK: <A extends ReadonlyArray<unknown>, R, B>(\n  f: (...a: A) => R.Reader<R, B>\n) => (...a: A) => ReaderTask<R, B> = /*#__PURE__*/ fromReaderK_(FromReader)\n\n/**\n * Alias of `flatMapReader`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderTask<R, A>) => ReaderTask<R, B> =\n  flatMapReader\n\n/**\n * Alias of `flatMapReader`.\n *\n * Less strict version of [`chainReaderK`](#chainreaderk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2>(ma: ReaderTask<R2, A>) => ReaderTask<R1 & R2, B> = flatMapReader\n\n/**\n * Alias of `tapReader`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderK: <A, R, B>(f: (a: A) => R.Reader<R, B>) => (ma: ReaderTask<R, A>) => ReaderTask<R, A> =\n  tapReader\n\n/**\n * Alias of `tapReader`.\n *\n * Less strict version of [`chainFirstReaderK`](#chainfirstreaderk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2>(ma: ReaderTask<R2, A>) => ReaderTask<R1 & R2, A> = tapReader\n\n/**\n * @category lifting\n * @since 2.13.0\n */\nexport const fromReaderIOK =\n  <A extends ReadonlyArray<unknown>, R, B>(f: (...a: A) => ReaderIO<R, B>): ((...a: A) => ReaderTask<R, B>) =>\n  (...a) =>\n    fromReaderIO(f(...a))\n\n/**\n * Alias of `flatMapReaderIO`.\n *\n * Less strict version of [`chainReaderIOK`](#chainreaderiok).\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainReaderIOKW: <A, R2, B>(\n  f: (a: A) => ReaderIO<R2, B>\n) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B> = flatMapReaderIO\n\n/**\n * Alias of `flatMapReaderIO`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainReaderIOK: <A, R, B>(f: (a: A) => ReaderIO<R, B>) => (ma: ReaderTask<R, A>) => ReaderTask<R, B> =\n  flatMapReaderIO\n\n/**\n * Alias of `tapReaderIO`.\n *\n * Less strict version of [`chainFirstReaderIOK`](#chainfirstreaderiok).\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainFirstReaderIOKW: <A, R2, B>(\n  f: (a: A) => ReaderIO<R2, B>\n) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A> = tapReaderIO\n\n/**\n * Alias of `tapReaderIO`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainFirstReaderIOK: <A, R, B>(f: (a: A) => ReaderIO<R, B>) => (ma: ReaderTask<R, A>) => ReaderTask<R, A> =\n  tapReaderIO\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromTaskK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => T.Task<B>\n) => <R = unknown>(...a: A) => ReaderTask<R, B> = /*#__PURE__*/ fromTaskK_(FromTask)\n\n/**\n * Alias of `flatMapTask`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainTaskK: <A, B>(f: (a: A) => T.Task<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, B> =\n  flatMapTask\n\n/**\n * Alias of `tapTask`.\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <R>(first: ReaderTask<R, A>) => ReaderTask<R, A> =\n  tapTask\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: ReaderTask<unknown, {}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const bindW: <N extends string, A, R2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderTask<R2, B>\n) => <R1>(fa: ReaderTask<R1, A>) => ReaderTask<R1 & R2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  bind as any\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(ApplyPar)\n\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const apSW: <A, N extends string, R2, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderTask<R2, B>\n) => <R1>(fa: ReaderTask<R1, A>) => ReaderTask<R1 & R2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  apS as any\n\n/**\n * @since 2.11.0\n */\nexport const ApT: ReaderTask<unknown, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex = <A, R, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n): ((as: ReadonlyNonEmptyArray<A>) => ReaderTask<R, ReadonlyNonEmptyArray<B>>) =>\n  flow(R.traverseReadonlyNonEmptyArrayWithIndex(f), R.map(T.traverseReadonlyNonEmptyArrayWithIndex(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, R, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n): ((as: ReadonlyArray<A>) => ReaderTask<R, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndexSeq = <R, A, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n): ((as: ReadonlyNonEmptyArray<A>) => ReaderTask<R, ReadonlyNonEmptyArray<B>>) =>\n  flow(R.traverseReadonlyNonEmptyArrayWithIndex(f), R.map(T.traverseReadonlyNonEmptyArrayWithIndexSeq(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndexSeq = <R, A, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n): ((as: ReadonlyArray<A>) => ReaderTask<R, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndexSeq(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <R, A, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n) => (as: ReadonlyArray<A>) => ReaderTask<R, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <R, A, B>(\n  f: (a: A) => ReaderTask<R, B>\n): ((as: ReadonlyArray<A>) => ReaderTask<R, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <R, A>(arr: ReadonlyArray<ReaderTask<R, A>>) => ReaderTask<R, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.10.0\n */\nexport const traverseSeqArrayWithIndex: <R, A, B>(\n  f: (index: number, a: A) => ReaderTask<R, B>\n) => (as: ReadonlyArray<A>) => ReaderTask<R, ReadonlyArray<B>> = traverseReadonlyArrayWithIndexSeq\n\n/**\n * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.10.0\n */\nexport const traverseSeqArray = <R, A, B>(\n  f: (a: A) => ReaderTask<R, B>\n): ((as: ReadonlyArray<A>) => ReaderTask<R, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndexSeq((_, a) => f(a))\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.3.0\n */\nexport const chain: <A, R, B>(f: (a: A) => ReaderTask<R, B>) => (ma: ReaderTask<R, A>) => ReaderTask<R, B> = flatMap\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.7\n */\nexport const chainW: <R2, A, B>(\n  f: (a: A) => ReaderTask<R2, B>\n) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.3.0\n */\nexport const chainFirst: <A, R, B>(f: (a: A) => ReaderTask<R, B>) => (first: ReaderTask<R, A>) => ReaderTask<R, A> = tap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstW: <R2, A, B>(\n  f: (a: A) => ReaderTask<R2, B>\n) => <R1>(ma: ReaderTask<R1, A>) => ReaderTask<R1 & R2, A> = tap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use `traverseReadonlyArrayWithIndexSeq` instead.\n *\n * @category zone of death\n * @since 2.10.0\n * @deprecated\n */\nexport const sequenceSeqArray: <R, A>(arr: ReadonlyArray<ReaderTask<R, A>>) => ReaderTask<R, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseSeqArray(identity)\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RT.Functor` instead of `RT.readerTask`\n * (where `RT` is from `import RT from 'fp-ts/ReaderTask'`)\n *\n * @category zone of death\n * @since 2.3.0\n * @deprecated\n */\nexport const readerTask: MonadTask2<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap,\n  fromIO,\n  fromTask\n}\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RT.Functor` instead of `RT.readerTaskSeq`\n * (where `RT` is from `import RT from 'fp-ts/ReaderTask'`)\n *\n * @category zone of death\n * @since 2.3.0\n * @deprecated\n */\n\nexport const readerTaskSeq: typeof readerTask = {\n  URI,\n  map: _map,\n  of,\n  ap: _apSeq,\n  chain: flatMap,\n  fromIO,\n  fromTask\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.3.0\n * @deprecated\n */\nexport const getSemigroup: <R, A>(S: Semigroup<A>) => Semigroup<ReaderTask<R, A>> =\n  /*#__PURE__*/ getApplySemigroup_(ApplySeq)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.3.0\n * @deprecated\n */\nexport const getMonoid: <R, A>(M: Monoid<A>) => Monoid<ReaderTask<R, A>> =\n  /*#__PURE__*/ getApplicativeMonoid(ApplicativeSeq)\n\n/**\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\n/* istanbul ignore next */\nexport function run<R, A>(ma: ReaderTask<R, A>, r: R): Promise<A> {\n  return ma(r)()\n}\n"
  },
  {
    "path": "src/ReaderTaskEither.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Alt3, Alt3C } from './Alt'\nimport { Applicative3, Applicative3C, getApplicativeMonoid } from './Applicative'\nimport {\n  ap as ap_,\n  apFirst as apFirst_,\n  Apply1,\n  Apply3,\n  apS as apS_,\n  apSecond as apSecond_,\n  getApplySemigroup as getApplySemigroup_\n} from './Apply'\nimport { Bifunctor3 } from './Bifunctor'\nimport * as chainable from './Chain'\nimport { compact as compact_, Compactable3C, separate as separate_ } from './Compactable'\nimport * as E from './Either'\nimport * as ET from './EitherT'\nimport {\n  filter as filter_,\n  Filterable3C,\n  filterMap as filterMap_,\n  partition as partition_,\n  partitionMap as partitionMap_\n} from './Filterable'\nimport {\n  chainOptionK as chainOptionK_,\n  filterOrElse as filterOrElse_,\n  FromEither3,\n  fromEitherK as fromEitherK_,\n  fromOption as fromOption_,\n  fromOptionK as fromOptionK_,\n  fromPredicate as fromPredicate_,\n  tapEither as tapEither_\n} from './FromEither'\nimport { FromIO3, fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO'\nimport {\n  ask as ask_,\n  asks as asks_,\n  FromReader3,\n  fromReaderK as fromReaderK_,\n  tapReader as tapReader_\n} from './FromReader'\nimport { FromTask3, fromTaskK as fromTaskK_, tapTask as tapTask_ } from './FromTask'\nimport { dual, flow, identity, LazyArg, pipe, SK } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor3, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { IO } from './IO'\nimport { IOEither } from './IOEither'\nimport { Monad3, Monad3C } from './Monad'\nimport { MonadIO3 } from './MonadIO'\nimport { MonadTask3, MonadTask3C } from './MonadTask'\nimport { MonadThrow3, MonadThrow3C } from './MonadThrow'\nimport { Monoid } from './Monoid'\nimport { Option } from './Option'\nimport { Pointed3 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport * as R from './Reader'\nimport { ReaderEither } from './ReaderEither'\nimport * as RIO from './ReaderIO'\nimport * as RT from './ReaderTask'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport * as T from './Task'\nimport * as TE from './TaskEither'\n\nimport Either = E.Either\nimport Task = T.Task\nimport TaskEither = TE.TaskEither\nimport Reader = R.Reader\nimport ReaderIO = RIO.ReaderIO\nimport ReaderTask = RT.ReaderTask\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface ReaderTaskEither<R, E, A> {\n  (r: R): TaskEither<E, A>\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromTaskEither: <E, A, R = unknown>(fa: TaskEither<E, A>) => ReaderTaskEither<R, E, A> = R.of\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const left: <R, E = never, A = never>(e: E) => ReaderTaskEither<R, E, A> = /*#__PURE__*/ ET.left(RT.Pointed)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const right: <R, E = never, A = never>(a: A) => ReaderTaskEither<R, E, A> = /*#__PURE__*/ ET.right(RT.Pointed)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const rightTask: <R, E = never, A = never>(ma: Task<A>) => ReaderTaskEither<R, E, A> = /*#__PURE__*/ flow(\n  TE.rightTask,\n  fromTaskEither\n)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const leftTask: <R, E = never, A = never>(me: Task<E>) => ReaderTaskEither<R, E, A> = /*#__PURE__*/ flow(\n  TE.leftTask,\n  fromTaskEither\n)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const rightReader: <R, E = never, A = never>(ma: Reader<R, A>) => ReaderTaskEither<R, E, A> = (ma) =>\n  flow(ma, TE.right)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const leftReader: <R, E = never, A = never>(me: Reader<R, E>) => ReaderTaskEither<R, E, A> = (me) =>\n  flow(me, TE.left)\n\n/**\n * @category constructors\n * @since 2.5.0\n */\nexport const rightReaderTask: <R, E = never, A = never>(ma: ReaderTask<R, A>) => ReaderTaskEither<R, E, A> =\n  /*#__PURE__*/ ET.rightF(RT.Functor)\n\n/**\n * @category constructors\n * @since 2.5.0\n */\nexport const leftReaderTask: <R, E = never, A = never>(me: ReaderTask<R, E>) => ReaderTaskEither<R, E, A> =\n  /*#__PURE__*/ ET.leftF(RT.Functor)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const rightIO: <R, E = never, A = never>(ma: IO<A>) => ReaderTaskEither<R, E, A> = /*#__PURE__*/ flow(\n  TE.rightIO,\n  fromTaskEither\n)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const leftIO: <R, E = never, A = never>(me: IO<E>) => ReaderTaskEither<R, E, A> = /*#__PURE__*/ flow(\n  TE.leftIO,\n  fromTaskEither\n)\n\n/**\n * @category constructors\n * @since 2.13.0\n */\nexport const rightReaderIO: <R, E = never, A = never>(ma: ReaderIO<R, A>) => ReaderTaskEither<R, E, A> = (ma) =>\n  flow(ma, TE.rightIO)\n\n/**\n * @category constructors\n * @since 2.13.0\n */\nexport const leftReaderIO: <R, E = never, A = never>(me: ReaderIO<R, E>) => ReaderTaskEither<R, E, A> = (me) =>\n  flow(me, TE.leftIO)\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromEither: <E, A, R = unknown>(fa: Either<E, A>) => ReaderTaskEither<R, E, A> = RT.of\n\n/**\n * @category conversions\n * @since 2.11.0\n */\nexport const fromReader: <R, A, E = never>(fa: Reader<R, A>) => ReaderTaskEither<R, E, A> = rightReader\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromIO: <A, R = unknown, E = never>(fa: IO<A>) => ReaderTaskEither<R, E, A> = rightIO\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromTask: <A, R = unknown, E = never>(fa: Task<A>) => ReaderTaskEither<R, E, A> = rightTask\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromIOEither: <E, A, R = unknown>(fa: IOEither<E, A>) => ReaderTaskEither<R, E, A> = /*#__PURE__*/ flow(\n  TE.fromIOEither,\n  fromTaskEither\n)\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromReaderEither: <R, E, A>(fa: ReaderEither<R, E, A>) => ReaderTaskEither<R, E, A> = (ma) =>\n  flow(ma, TE.fromEither)\n\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTask<R, B> = /*#__PURE__*/ ET.match(RT.Functor)\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW: <E, B, A, C>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTask<R, B | C> = match as any\n\n/**\n * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`ReaderTask`).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchE: <R, E, A, B>(\n  onLeft: (e: E) => ReaderTask<R, B>,\n  onRight: (a: A) => ReaderTask<R, B>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTask<R, B> = /*#__PURE__*/ ET.matchE(RT.Chain)\n\n/**\n * Alias of [`matchE`](#matche).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const fold = matchE\n\n/**\n * Less strict version of [`matchE`](#matche).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchEW: <E, R2, B, A, R3, C>(\n  onLeft: (e: E) => ReaderTask<R2, B>,\n  onRight: (a: A) => ReaderTask<R3, C>\n) => <R1>(ma: ReaderTaskEither<R1, E, A>) => ReaderTask<R1 & R2 & R3, B | C> = matchE as any\n\n/**\n * Alias of [`matchEW`](#matchew).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchEW\n\n/**\n * @category error handling\n * @since 2.0.0\n */\nexport const getOrElse: <R, E, A>(\n  onLeft: (e: E) => ReaderTask<R, A>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTask<R, A> = /*#__PURE__*/ ET.getOrElse(RT.Monad)\n\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.6.0\n */\nexport const getOrElseW: <R2, E, B>(\n  onLeft: (e: E) => ReaderTask<R2, B>\n) => <R1, A>(ma: ReaderTaskEither<R1, E, A>) => ReaderTask<R1 & R2, A | B> = getOrElse as any\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const toUnion: <R, E, A>(fa: ReaderTaskEither<R, E, A>) => ReaderTask<R, E | A> = /*#__PURE__*/ ET.toUnion(\n  RT.Functor\n)\n\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport const fromNullable: <E>(e: E) => <R, A>(a: A) => ReaderTaskEither<R, E, NonNullable<A>> =\n  /*#__PURE__*/ ET.fromNullable(RT.Pointed)\n\n/**\n * Use `liftNullable`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const fromNullableK: <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, NonNullable<B>> = /*#__PURE__*/ ET.fromNullableK(RT.Pointed)\n\n/**\n * Use `flatMapNullable`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainNullableK: <E>(\n  e: E\n) => <A, B>(\n  f: (a: A) => B | null | undefined\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, NonNullable<B>> = /*#__PURE__*/ ET.chainNullableK(\n  RT.Monad\n)\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n * `contramap`).\n *\n * @since 2.0.0\n */\nexport const local: <R2, R1>(\n  f: (r2: R2) => R1\n) => <E, A>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R2, E, A> = R.local\n\n/**\n * Less strict version of [`asksReaderTaskEither`](#asksreadertaskeither).\n *\n * The `W` suffix (short for **W**idening) means that the environment types will be merged.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksReaderTaskEitherW: <R1, R2, E, A>(\n  f: (r1: R1) => ReaderTaskEither<R2, E, A>\n) => ReaderTaskEither<R1 & R2, E, A> = R.asksReaderW\n\n/**\n * Effectfully accesses the environment.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksReaderTaskEither: <R, E, A>(f: (r: R) => ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> =\n  asksReaderTaskEitherW\n\n/**\n * @category error handling\n * @since 2.0.0\n */\nexport const orElse: <R, E1, A, E2>(\n  onLeft: (e: E1) => ReaderTaskEither<R, E2, A>\n) => (ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2, A> = /*#__PURE__*/ ET.orElse(RT.Monad)\n\n/**\n * Less strict version of [`orElse`](#orelse).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the return types will be merged.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport const orElseW: <E1, R1, E2, B>(\n  onLeft: (e: E1) => ReaderTaskEither<R1, E2, B>\n) => <R2, A>(ma: ReaderTaskEither<R2, E1, A>) => ReaderTaskEither<R1 & R2, E2, A | B> = orElse as any\n\n/**\n * Returns an effect that effectfully \"peeks\" at the failure of this effect.\n *\n * @category error handling\n * @since 2.15.0\n */\nexport const tapError: {\n  <E1, R2, E2, _>(onLeft: (e: E1) => ReaderTaskEither<R2, E2, _>): <R1, A>(\n    self: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E1 | E2, A>\n  <R1, E1, A, R2, E2, _>(\n    self: ReaderTaskEither<R1, E1, A>,\n    onLeft: (e: E1) => ReaderTaskEither<R2, E2, _>\n  ): ReaderTaskEither<R1 & R2, E1 | E2, A>\n} = /*#__PURE__*/ dual(2, ET.tapError(RT.Monad))\n\n/**\n * @category error handling\n * @since 2.11.0\n */\nexport const orLeft: <E1, R, E2>(\n  onLeft: (e: E1) => ReaderTask<R, E2>\n) => <A>(fa: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E2, A> = /*#__PURE__*/ ET.orLeft(RT.Monad)\n\n/**\n * @category error handling\n * @since 2.16.6\n */\nexport const orLeftW: <E1, R2, E2>(\n  onLeft: (e: E1) => ReaderTask<R2, E2>\n) => <R1, A>(fa: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2, A> = orLeft as any\n\n/**\n * @since 2.0.0\n */\nexport const swap: <R, E, A>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, A, E> = /*#__PURE__*/ ET.swap(\n  RT.Functor\n)\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromIOEitherK = <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => IOEither<E, B>\n): (<R = unknown>(...a: A) => ReaderTaskEither<R, E, B>) => flow(f, fromIOEither)\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromTaskEitherK = <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => TaskEither<E, B>\n): (<R = unknown>(...a: A) => ReaderTaskEither<R, E, B>) => flow(f, fromTaskEither)\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromReaderEitherK = <R, E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => ReaderEither<R, E, B>\n): ((...a: A) => ReaderTaskEither<R, E, B>) => flow(f, fromReaderEither)\n\nconst _map: Functor3<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _apPar: Apply3<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\nconst _apSeq: Apply3<URI>['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map(f)))\n/* istanbul ignore next */\nconst _alt: Alt3<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <R, E>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> =\n  /*#__PURE__*/ ET.map(RT.Functor)\n\n/**\n * Returns a `ReaderTaskEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`.\n *\n * @example\n * import * as ReaderTaskEither from 'fp-ts/ReaderTaskEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n * const g = (n: number) => n * 2\n *\n * async function test() {\n *   assert.deepStrictEqual(await ReaderTaskEither.mapBoth(ReaderTaskEither.right(1), f, g)({})(), Either.right(2))\n *   assert.deepStrictEqual(await ReaderTaskEither.mapBoth(ReaderTaskEither.left('err'), f, g)({})(), Either.left(new Error('err')))\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.16.0\n */\nexport const mapBoth: {\n  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): <R>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, B>\n  <R, E, A, G, B>(self: ReaderTaskEither<R, E, A>, f: (e: E) => G, g: (a: A) => B): ReaderTaskEither<R, G, B>\n} = /*#__PURE__*/ dual(3, ET.mapBoth(RT.Functor))\n\n/**\n * Alias of `mapBoth`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const bimap: <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, B> = mapBoth\n\n/**\n * Returns a `ReaderTaskEither` with its error channel mapped using the specified function.\n *\n * @example\n * import * as ReaderTaskEither from 'fp-ts/ReaderTaskEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n *\n * async function test() {\n *   assert.deepStrictEqual(await ReaderTaskEither.mapError(ReaderTaskEither.right(1), f)({})(), Either.right(1))\n *   assert.deepStrictEqual(await ReaderTaskEither.mapError(ReaderTaskEither.left('err'), f)({})(), Either.left(new Error('err')))\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.16.0\n */\nexport const mapError: {\n  <R, E, G>(f: (e: E) => G): <A>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, A>\n  <R, E, A, G>(self: ReaderTaskEither<R, E, A>, f: (e: E) => G): ReaderTaskEither<R, G, A>\n} = /*#__PURE__*/ dual(2, ET.mapError(RT.Functor))\n\n/**\n * Alias of `mapError`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, G, A> =\n  mapError\n\n/**\n * @since 2.0.0\n */\nexport const ap: <R, E, A>(\n  fa: ReaderTaskEither<R, E, A>\n) => <B>(fab: ReaderTaskEither<R, E, (a: A) => B>) => ReaderTaskEither<R, E, B> = /*#__PURE__*/ ET.ap(RT.ApplyPar)\n\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.8.0\n */\nexport const apW: <R2, E2, A>(\n  fa: ReaderTaskEither<R2, E2, A>\n) => <R1, E1, B>(fab: ReaderTaskEither<R1, E1, (a: A) => B>) => ReaderTaskEither<R1 & R2, E1 | E2, B> = ap as any\n\n/**\n * @category constructors\n * @since 2.7.0\n */\nexport const of: <R = unknown, E = never, A = never>(a: A) => ReaderTaskEither<R, E, A> = right\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, R2, E2, B>(f: (a: A) => ReaderTaskEither<R2, E2, B>): <R1, E1>(\n    ma: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E1 | E2, B>\n  <R1, E1, A, R2, E2, B>(ma: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderTaskEither<R2, E2, B>): ReaderTaskEither<\n    R1 & R2,\n    E1 | E2,\n    B\n  >\n} = /*#__PURE__*/ dual(2, ET.flatMap(RT.Monad))\n\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport const flattenW: <R1, E1, R2, E2, A>(\n  mma: ReaderTaskEither<R1, E1, ReaderTaskEither<R2, E2, A>>\n) => ReaderTaskEither<R1 & R2, E1 | E2, A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <R, E, A>(mma: ReaderTaskEither<R, E, ReaderTaskEither<R, E, A>>) => ReaderTaskEither<R, E, A> =\n  flattenW\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const alt: <R, E, A>(\n  that: () => ReaderTaskEither<R, E, A>\n) => (fa: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = /*#__PURE__*/ ET.alt(RT.Monad)\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged.\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW: <R2, E2, B>(\n  that: () => ReaderTaskEither<R2, E2, B>\n) => <R1, E1, A>(fa: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E2, A | B> = alt as any\n\n/**\n * @since 2.0.0\n */\nexport const throwError: MonadThrow3<URI>['throwError'] = left\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'ReaderTaskEither'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind3<R, E, A> {\n    readonly [URI]: ReaderTaskEither<R, E, A>\n  }\n}\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const getCompactable = <E>(M: Monoid<E>): Compactable3C<URI, E> => {\n  const C = E.getCompactable(M)\n  return {\n    URI,\n    _E: undefined as any,\n    compact: compact_(RT.Functor, C),\n    separate: separate_(RT.Functor, C, E.Functor)\n  }\n}\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport function getFilterable<E>(M: Monoid<E>): Filterable3C<URI, E> {\n  const F = E.getFilterable(M)\n  const C = getCompactable(M)\n\n  const filter = filter_(RT.Functor, F)\n  const filterMap = filterMap_(RT.Functor, F)\n  const partition = partition_(RT.Functor, F)\n  const partitionMap = partitionMap_(RT.Functor, F)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    compact: C.compact,\n    separate: C.separate,\n    filter: <R, A>(fa: ReaderTaskEither<R, E, A>, predicate: Predicate<A>) => pipe(fa, filter(predicate)),\n    filterMap: (fa, f) => pipe(fa, filterMap(f)),\n    partition: <R, A>(fa: ReaderTaskEither<R, E, A>, predicate: Predicate<A>) => pipe(fa, partition(predicate)),\n    partitionMap: (fa, f) => pipe(fa, partitionMap(f))\n  }\n}\n\n/**\n * The default [`ApplicativePar`](#applicativepar) instance returns the first error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * See [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation).\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getApplicativeReaderTaskValidation<E>(A: Apply1<T.URI>, S: Semigroup<E>): Applicative3C<URI, E> {\n  const ap = ap_(R.Apply, TE.getApplicativeTaskValidation(A, S))\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: (fab, fa) => pipe(fab, ap(fa)),\n    of\n  }\n}\n\n/**\n * The default [`Alt`](#alt) instance returns the last error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * See [`getAltValidation`](./Either.ts.html#getaltvalidation).\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getAltReaderTaskValidation<E>(S: Semigroup<E>): Alt3C<URI, E> {\n  const alt = ET.altValidation(RT.Monad, S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    alt: (fa, that) => pipe(fa, alt(that))\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor3<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the `Right` value of this `ReaderTaskEither` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <R, E, _>(self: ReaderTaskEither<R, E, _>) => ReaderTaskEither<R, E, A>\n  <R, E, _, A>(self: ReaderTaskEither<R, E, _>, a: A): ReaderTaskEither<R, E, A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the `Right` value of this `ReaderTaskEither` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <R, E, _>(self: ReaderTaskEither<R, E, _>) => ReaderTaskEither<R, E, void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed3<URI> = {\n  URI,\n  of\n}\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplyPar: Apply3<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(ApplyPar)\n\n/**\n * Less strict version of [`apFirst`](#apfirst).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apFirstW: <R2, E2, B>(\n  second: ReaderTaskEither<R2, E2, B>\n) => <R1, E1, A>(first: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E1 | E2, A> = apFirst as any\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(ApplyPar)\n\n/**\n * Less strict version of [`apSecond`](#apsecond).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apSecondW: <R2, E2, B>(\n  second: ReaderTaskEither<R2, E2, B>\n) => <R1, E1, A>(first: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E1 | E2, B> = apSecond as any\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.7.0\n */\nexport const ApplicativePar: Applicative3<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  of\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplySeq: Apply3<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.7.0\n */\nexport const ApplicativeSeq: Applicative3<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain3<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Monad: Monad3<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadIO: MonadIO3<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap,\n  of,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadTask: MonadTask3<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap,\n  of,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadThrow: MonadThrow3<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap,\n  of,\n  throwError\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromEither: FromEither3<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromIO: FromIO3<URI> = {\n  URI,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromTask: FromTask3<URI> = {\n  URI,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromReader: FromReader3<URI> = {\n  URI,\n  fromReader\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <R1, E1, A, R2, E2, _>(self: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderTaskEither<R2, E2, _>): ReaderTaskEither<\n    R1 & R2,\n    E1 | E2,\n    A\n  >\n  <A, R2, E2, _>(f: (a: A) => ReaderTaskEither<R2, E2, _>): <R1, E1>(\n    self: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E2 | E1, A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as RTE from 'fp-ts/ReaderTaskEither'\n *\n * const checkString = (value: string) => pipe(\n *   RTE.ask<number>(),\n *   RTE.tapEither((minLength) => value.length > minLength ? E.right('ok') : E.left('error'))\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await checkString('')(2)(), E.left('error'))\n *   assert.deepStrictEqual(await checkString('fp-ts')(2)(), E.right(2))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapEither: {\n  <A, E2, _>(f: (a: A) => Either<E2, _>): <R, E1>(self: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, A>\n  <R, E1, A, E2, _>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => Either<E2, _>): ReaderTaskEither<R, E1 | E2, A>\n} = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as RTE from 'fp-ts/ReaderTaskEither'\n * import * as E from 'fp-ts/Either'\n * import * as Console from 'fp-ts/Console'\n *\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effect = RTE.tapIO(\n *   RTE.ask<string>(),\n *   (value) => Console.log(`Hello, ${value}`)\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effect('fp-ts')(), E.of('fp-ts'))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n  <R, E, A, _>(self: ReaderTaskEither<R, E, A>, f: (a: A) => IO<_>): ReaderTaskEither<R, E, A>\n} = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as RTE from 'fp-ts/ReaderTaskEither'\n * import * as E from 'fp-ts/Either'\n * import * as T from 'fp-ts/Task'\n *\n *\n * const effect = RTE.tapTask(\n *   RTE.ask<number>(),\n *   (value) => T.of(value + 1)\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effect(1)(), E.of(1))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapTask: {\n  <A, _>(f: (a: A) => Task<_>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n  <R, E, A, _>(self: ReaderTaskEither<R, E, A>, f: (a: A) => Task<_>): ReaderTaskEither<R, E, A>\n} = /*#__PURE__*/ dual(2, tapTask_(FromTask, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapReader: {\n  <A, R2, _>(f: (a: A) => Reader<R2, _>): <R1, E>(self: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A>\n  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => Reader<R2, _>): ReaderTaskEither<R1 & R2, E, A>\n} = /*#__PURE__*/ dual(2, tapReader_(FromReader, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapReaderEither: {\n  <A, R2, E2, _>(f: (a: A) => ReaderEither<R2, E2, _>): <R1, E1>(\n    self: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E1 | E2, A>\n  <R1, E1, A, R2, E2, _>(self: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, _>): ReaderTaskEither<\n    R1 & R2,\n    E1 | E2,\n    A\n  >\n} = /*#__PURE__*/ dual(\n  2,\n  <R1, E1, A, R2, E2, _>(\n    self: ReaderTaskEither<R1, E1, A>,\n    f: (a: A) => ReaderEither<R2, E2, _>\n  ): ReaderTaskEither<R1 & R2, E1 | E2, A> => tap(self, fromReaderEitherK(f))\n)\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapTaskEither: {\n  <A, E2, _>(f: (a: A) => TaskEither<E2, _>): <R, E1>(\n    self: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E1 | E2, A>\n  <R, E1, A, E2, _>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => TaskEither<E2, _>): ReaderTaskEither<R, E1 | E2, A>\n} = /*#__PURE__*/ dual(\n  2,\n  <R, E1, A, E2, _>(\n    self: ReaderTaskEither<R, E1, A>,\n    f: (a: A) => TaskEither<E2, _>\n  ): ReaderTaskEither<R, E1 | E2, A> => tap(self, fromTaskEitherK(f))\n)\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapReaderTask: {\n  <A, R2, _>(f: (a: A) => ReaderTask<R2, _>): <R1, E>(\n    self: ReaderTaskEither<R1, E, A>\n  ) => ReaderTaskEither<R1 & R2, E, A>\n  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => ReaderTask<R2, _>): ReaderTaskEither<R1 & R2, E, A>\n} = /*#__PURE__*/ dual(\n  2,\n  <R1, E, A, R2, _>(\n    self: ReaderTaskEither<R1, E, A>,\n    f: (a: A) => ReaderTask<R2, _>\n  ): ReaderTaskEither<R1 & R2, E, A> => tap(self, fromReaderTaskK(f))\n)\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapReaderIO: {\n  <A, R2, _>(f: (a: A) => ReaderIO<R2, _>): <R1, E>(self: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A>\n  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => ReaderIO<R2, _>): ReaderTaskEither<R1 & R2, E, A>\n} = /*#__PURE__*/ dual(\n  2,\n  <R1, E, A, R2, _>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => ReaderIO<R2, _>): ReaderTaskEither<R1 & R2, E, A> =>\n    tap(self, fromReaderIOK(f))\n)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor3<URI> = {\n  URI,\n  bimap: mapBoth,\n  mapLeft: mapError\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt3<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * Reads the current context.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const ask: <R, E = never>() => ReaderTaskEither<R, E, R> = /*#__PURE__*/ ask_(FromReader)\n\n/**\n * Projects a value from the global context in a `ReaderEither`.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const asks: <R, A, E = never>(f: (r: R) => A) => ReaderTaskEither<R, E, A> = /*#__PURE__*/ asks_(FromReader)\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromReaderK: <A extends ReadonlyArray<unknown>, R, B>(\n  f: (...a: A) => Reader<R, B>\n) => <E = never>(...a: A) => ReaderTaskEither<R, E, B> = /*#__PURE__*/ fromReaderK_(FromReader)\n\n/**\n * Alias of `tapReader`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderK: <A, R, B>(\n  f: (a: A) => R.Reader<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tapReader\n\n/**\n * Alias of `tapReader`.\n *\n * Less strict version of [`chainFirstReaderK`](#chainfirstreaderk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2, E>(ma: ReaderTaskEither<R2, E, A>) => ReaderTaskEither<R1 & R2, E, A> = tapReader\n\n/**\n * Alias of `tapReaderEither`.\n *\n * Less strict version of [`chainFirstReaderEitherK`](#chainfirstreadereitherk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderEitherKW: <R2, E2, A, B>(\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E1 | E2, A> = tapReaderEither\n\n/**\n * Alias of `tapReaderEither`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderEitherK: <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tapReaderEither\n\n/**\n * Alias of `tapTaskEither`.\n *\n * Less strict version of [`chainFirstTaskEitherK`](#chainfirsttaskeitherk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstTaskEitherKW: <E2, A, B>(\n  f: (a: A) => TaskEither<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, A> = tapTaskEither\n\n/**\n * Alias of `tapTaskEither`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstTaskEitherK: <E, A, B>(\n  f: (a: A) => TaskEither<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tapTaskEither\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromReaderTaskK =\n  <A extends ReadonlyArray<unknown>, R, B>(\n    f: (...a: A) => ReaderTask<R, B>\n  ): (<E = never>(...a: A) => ReaderTaskEither<R, E, B>) =>\n  (...a) =>\n    rightReaderTask(f(...a))\n\n/**\n * Alias of `tapReaderTask`.\n *\n * Less strict version of [`chainFirstReaderTaskK`](#chainfirstreadertaskk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderTaskKW: <A, R2, B>(\n  f: (a: A) => RT.ReaderTask<R2, B>\n) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A> = tapReaderTask\n\n/**\n * Alias of `tapReaderTask`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderTaskK: <A, R, B>(\n  f: (a: A) => RT.ReaderTask<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tapReaderTask\n\n/**\n * @category lifting\n * @since 2.13.0\n */\nexport const fromReaderIOK =\n  <A extends ReadonlyArray<unknown>, R, B>(\n    f: (...a: A) => ReaderIO<R, B>\n  ): (<E = never>(...a: A) => ReaderTaskEither<R, E, B>) =>\n  (...a) =>\n    rightReaderIO(f(...a))\n\n/**\n * Alias of `tapReaderIO`.\n *\n * Less strict version of [`chainFirstReaderIOK`](#chainfirstreaderiok).\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainFirstReaderIOKW: <A, R2, B>(\n  f: (a: A) => ReaderIO<R2, B>\n) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, A> = tapReaderIO\n\n/**\n * Alias of `tapReaderIO`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainFirstReaderIOK: <A, R, B>(\n  f: (a: A) => ReaderIO<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tapReaderIO\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromOption: <E>(onNone: LazyArg<E>) => <A, R = unknown>(fa: Option<A>) => ReaderTaskEither<R, E, A> =\n  /*#__PURE__*/ fromOption_(FromEither)\n\n/**\n * Use `liftOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Option<B>\n) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B> = /*#__PURE__*/ fromOptionK_(FromEither)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> =\n  /*#__PURE__*/ chainOptionK_(FromEither, Chain)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.13.2\n */\nexport const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, B> =\n  chainOptionK as any\n\n/** @internal */\ninterface ReaderTaskEitherTypeLambda extends _.TypeLambda {\n  readonly type: ReaderTaskEither<this['In'], this['Out1'], this['Target']>\n}\n\n/** @internal */\nconst _FromEither: _.FromEither<ReaderTaskEitherTypeLambda> = {\n  fromEither: FromEither.fromEither\n}\n\n/**\n * @category lifting\n * @since 2.15.0\n */\nexport const liftNullable: <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => B | null | undefined,\n  onNullable: (...a: A) => E\n) => <R>(...a: A) => ReaderTaskEither<R, E, NonNullable<B>> = /*#__PURE__*/ _.liftNullable(_FromEither)\n\n/**\n * @category lifting\n * @since 2.15.0\n */\nexport const liftOption: <A extends ReadonlyArray<unknown>, B, E>(\n  f: (...a: A) => Option<B>,\n  onNone: (...a: A) => E\n) => <R>(...a: A) => ReaderTaskEither<R, E, B> = /*#__PURE__*/ _.liftOption(_FromEither)\n\n/** @internal */\nconst _FlatMap: _.FlatMap<ReaderTaskEitherTypeLambda> = {\n  flatMap\n}\n\n/** @internal */\nconst _FromIO: _.FromIO<ReaderTaskEitherTypeLambda> = {\n  fromIO\n}\n\n/** @internal */\nconst _FromTask: _.FromTask<ReaderTaskEitherTypeLambda> = {\n  fromTask\n}\n\n/** @internal */\nconst _FromReader: _.FromReader<ReaderTaskEitherTypeLambda> = {\n  fromReader\n}\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapNullable: {\n  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <R, E1>(\n    self: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E2 | E1, NonNullable<B>>\n  <R, E1, A, B, E2>(\n    self: ReaderTaskEither<R, E1, A>,\n    f: (a: A) => B | null | undefined,\n    onNullable: (a: A) => E2\n  ): ReaderTaskEither<R, E1 | E2, NonNullable<B>>\n} = /*#__PURE__*/ _.flatMapNullable(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapOption: {\n  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <R, E1>(\n    self: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E2 | E1, B>\n  <R, E1, A, B, E2>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): ReaderTaskEither<\n    R,\n    E1 | E2,\n    B\n  >\n} = /*#__PURE__*/ _.flatMapOption(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapEither: {\n  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <R, E1>(self: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, B>\n  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => E.Either<E2, B>): ReaderTaskEither<R, E1 | E2, B>\n} = /*#__PURE__*/ _.flatMapEither(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapTaskEither: {\n  <A, E2, B>(f: (a: A) => TaskEither<E2, B>): <R, E1>(\n    self: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E1 | E2, B>\n  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => TaskEither<E2, B>): ReaderTaskEither<R, E1 | E2, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <R, E1, A, E2, B>(\n    self: ReaderTaskEither<R, E1, A>,\n    f: (a: A) => TaskEither<E2, B>\n  ): ReaderTaskEither<R, E1 | E2, B> => flatMap(self, fromTaskEitherK(f))\n)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReaderTask: {\n  <A, R2, B>(f: (a: A) => ReaderTask<R2, B>): <R1, E>(\n    self: ReaderTaskEither<R1, E, A>\n  ) => ReaderTaskEither<R1 & R2, E, B>\n  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => ReaderTask<R2, B>): ReaderTaskEither<R1 & R2, E, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <R1, E, A, R2, B>(\n    self: ReaderTaskEither<R1, E, A>,\n    f: (a: A) => ReaderTask<R2, B>\n  ): ReaderTaskEither<R1 & R2, E, B> => flatMap(self, fromReaderTaskK(f))\n)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n  <R, E, A, B>(self: ReaderTaskEither<R, E, A>, f: (a: A) => IO<B>): ReaderTaskEither<R, E, B>\n} = /*#__PURE__*/ _.flatMapIO(_FromIO, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapTask: {\n  <A, B>(f: (a: A) => Task<B>): <R, E>(self: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B>\n  <R, E, A, B>(self: ReaderTaskEither<R, E, A>, f: (a: A) => Task<B>): ReaderTaskEither<R, E, B>\n} = /*#__PURE__*/ _.flatMapTask(_FromTask, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReader: {\n  <A, R2, B>(f: (a: A) => Reader<R2, B>): <R1, E>(self: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B>\n  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => Reader<R2, B>): ReaderTaskEither<R1 & R2, E, B>\n} = /*#__PURE__*/ _.flatMapReader(_FromReader, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReaderIO: {\n  <A, R2, B>(f: (a: A) => ReaderIO<R2, B>): <R1, E>(self: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B>\n  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => ReaderIO<R2, B>): ReaderTaskEither<R1 & R2, E, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <R1, E, A, R2, B>(self: ReaderTaskEither<R1, E, A>, f: (a: A) => ReaderIO<R2, B>): ReaderTaskEither<R1 & R2, E, B> =>\n    flatMap(self, fromReaderIOK(f))\n)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIOEither: {\n  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <R, E1>(self: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, B>\n  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => IOEither<E2, B>): ReaderTaskEither<R, E1 | E2, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <R, E1, A, E2, B>(self: ReaderTaskEither<R, E1, A>, f: (a: A) => IOEither<E2, B>): ReaderTaskEither<R, E1 | E2, B> =>\n    flatMap(self, fromIOEitherK(f))\n)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReaderEither: {\n  <A, R2, E2, B>(f: (a: A) => ReaderEither<R2, E2, B>): <R1, E1>(\n    self: ReaderTaskEither<R1, E1, A>\n  ) => ReaderTaskEither<R1 & R2, E1 | E2, B>\n  <R1, E1, A, R2, E2, B>(self: ReaderTaskEither<R1, E1, A>, f: (a: A) => ReaderEither<R2, E2, B>): ReaderTaskEither<\n    R1 & R2,\n    E1 | E2,\n    B\n  >\n} = /*#__PURE__*/ dual(\n  2,\n  <R1, E1, A, R2, E2, B>(\n    self: ReaderTaskEither<R1, E1, A>,\n    f: (a: A) => ReaderEither<R2, E2, B>\n  ): ReaderTaskEither<R1 & R2, E1 | E2, B> => flatMap(self, fromReaderEitherK(f))\n)\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainEitherK: <E, A, B>(\n  f: (a: A) => E.Either<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMapEither\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainEitherKW: <E2, A, B>(\n  f: (a: A) => Either<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, B> = flatMapEither\n\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherK: <A, E, B>(\n  f: (a: A) => E.Either<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tapEither\n\n/**\n * Alias of `tapEither`.\n *\n * Less strict version of [`chainFirstEitherK`](#chainfirsteitherk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => Either<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, A> = tapEither\n\n/**\n * Alias of `flatMapTaskEither`.\n *\n * Less strict version of [`chainTaskEitherK`](#chaintaskeitherk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainTaskEitherKW: <E2, A, B>(\n  f: (a: A) => TaskEither<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, B> = flatMapTaskEither\n\n/**\n * Alias of `flatMapTaskEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainTaskEitherK: <E, A, B>(\n  f: (a: A) => TaskEither<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMapTaskEither\n\n/**\n * Alias of `flatMapReaderTask`.\n *\n * Less strict version of [`chainReaderTaskK`](#chainreadertaskk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderTaskKW: <A, R2, B>(\n  f: (a: A) => RT.ReaderTask<R2, B>\n) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B> = flatMapReaderTask\n\n/**\n * Alias of `flatMapReaderTask`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderTaskK: <A, R, B>(\n  f: (a: A) => RT.ReaderTask<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMapReaderTask\n\n/**\n * @category lifting\n * @since 2.0.0\n */\nexport const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R = unknown>(\n    a: A\n  ) => ReaderTaskEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown, B extends A = A>(\n    b: B\n  ) => ReaderTaskEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R = unknown>(a: A) => ReaderTaskEither<R, E, A>\n} = /*#__PURE__*/ fromPredicate_(FromEither)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n    ma: ReaderTaskEither<R, E, A>\n  ) => ReaderTaskEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R, B extends A>(\n    mb: ReaderTaskEither<R, E, B>\n  ) => ReaderTaskEither<R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A>\n} = /*#__PURE__*/ filterOrElse_(FromEither, Chain)\n\n/**\n * Less strict version of [`filterOrElse`](#filterorelse).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category filtering\n * @since 2.9.0\n */\nexport const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <R, E1>(\n    ma: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1, B extends A>(\n    mb: ReaderTaskEither<R, E1, B>\n  ) => ReaderTaskEither<R, E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <R, E1>(\n    ma: ReaderTaskEither<R, E1, A>\n  ) => ReaderTaskEither<R, E1 | E2, A>\n} = filterOrElse\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => E.Either<E, B>\n) => <R = unknown>(...a: A) => ReaderTaskEither<R, E, B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => IO<B>\n) => <R = unknown, E = never>(...a: A) => ReaderTaskEither<R, E, B> = /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainIOK: <A, B>(\n  f: (a: A) => IO<B>\n) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMapIO\n\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstIOK: <A, B>(\n  f: (a: A) => IO<B>\n) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tapIO\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromTaskK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => T.Task<B>\n) => <R = unknown, E = never>(...a: A) => ReaderTaskEither<R, E, B> = /*#__PURE__*/ fromTaskK_(FromTask)\n\n/**\n * Alias of `flatMapTask`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainTaskK: <A, B>(\n  f: (a: A) => T.Task<B>\n) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMapTask\n\n/**\n * Alias of `tapTask`.\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstTaskK: <A, B>(\n  f: (a: A) => T.Task<B>\n) => <R, E>(first: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tapTask\n\n/**\n * Alias of `flatMapReader`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderK: <A, R, B>(\n  f: (a: A) => Reader<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMapReader\n\n/**\n * Alias of `flatMapReader`.\n *\n * Less strict version of [`chainReaderK`](#chainreaderk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderKW: <A, R1, B>(\n  f: (a: A) => R.Reader<R1, B>\n) => <R2, E>(ma: ReaderTaskEither<R2, E, A>) => ReaderTaskEither<R1 & R2, E, B> = flatMapReader\n\n/**\n * Alias of `flatMapReaderIO`.\n *\n * Less strict version of [`chainReaderIOK`](#chainreaderiok).\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainReaderIOKW: <A, R2, B>(\n  f: (a: A) => ReaderIO<R2, B>\n) => <R1, E>(ma: ReaderTaskEither<R1, E, A>) => ReaderTaskEither<R1 & R2, E, B> = flatMapReaderIO\n\n/**\n * Alias of `flatMapReaderIO`.\n *\n * @category legacy\n * @since 2.13.0\n */\nexport const chainReaderIOK: <A, R, B>(\n  f: (a: A) => ReaderIO<R, B>\n) => <E>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMapReaderIO\n\n/**\n * Alias of `flatMapIOEither`.\n *\n * Less strict version of [`chainIOEitherK`](#chainioeitherk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainIOEitherKW: <E2, A, B>(\n  f: (a: A) => IOEither<E2, B>\n) => <R, E1>(ma: ReaderTaskEither<R, E1, A>) => ReaderTaskEither<R, E1 | E2, B> = flatMapIOEither\n\n/**\n * Alias of `flatMapIOEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainIOEitherK: <E, A, B>(\n  f: (a: A) => IOEither<E, B>\n) => <R>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMapIOEither\n\n/**\n * Alias of `flatMapReaderEither`.\n *\n * Less strict version of [`chainReaderEitherK`](#chainreadereitherk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderEitherKW: <R2, E2, A, B>(\n  f: (a: A) => ReaderEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E1 | E2, B> = flatMapReaderEither\n\n/**\n * Alias of `flatMapReaderEither`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderEitherK: <R, E, A, B>(\n  f: (a: A) => ReaderEither<R, E, B>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMapReaderEither\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Make sure that a resource is cleaned up in the event of an exception (\\*). The release action is called regardless of\n * whether the body action throws (\\*) or returns.\n *\n * (\\*) i.e. returns a `Left`\n *\n * @since 2.0.4\n */\nexport function bracket<R, E, A, B>(\n  acquire: ReaderTaskEither<R, E, A>,\n  use: (a: A) => ReaderTaskEither<R, E, B>,\n  release: (a: A, e: Either<E, B>) => ReaderTaskEither<R, E, void>\n): ReaderTaskEither<R, E, B> {\n  return bracketW(acquire, use, release)\n}\n\n/**\n * Less strict version of [`bracket`](#bracket).\n *\n * @since 2.12.0\n */\nexport function bracketW<R1, E1, A, R2, E2, B, R3, E3>(\n  acquire: ReaderTaskEither<R1, E1, A>,\n  use: (a: A) => ReaderTaskEither<R2, E2, B>,\n  release: (a: A, e: Either<E2, B>) => ReaderTaskEither<R3, E3, void>\n): ReaderTaskEither<R1 & R2 & R3, E1 | E2 | E3, B> {\n  return (r) =>\n    TE.bracketW(\n      acquire(r),\n      (a) => use(a)(r),\n      (a, e) => release(a, e)(r)\n    )\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: ReaderTaskEither<unknown, never, {}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const bindW: <N extends string, A, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => ReaderTaskEither<R2, E2, B>\n) => <R1, E1>(\n  fa: ReaderTaskEither<R1, E1, A>\n) => ReaderTaskEither<R1 & R2, E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> = bind as any\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(ApplyPar)\n\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const apSW: <A, N extends string, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: ReaderTaskEither<R2, E2, B>\n) => <R1, E1>(\n  fa: ReaderTaskEither<R1, E1, A>\n) => ReaderTaskEither<R1 & R2, E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> = apS as any\n\n/**\n * @since 2.11.0\n */\nexport const ApT: ReaderTaskEither<unknown, never, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex = <A, R, E, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n): ((as: ReadonlyNonEmptyArray<A>) => ReaderTaskEither<R, E, ReadonlyNonEmptyArray<B>>) =>\n  flow(R.traverseReadonlyNonEmptyArrayWithIndex(f), R.map(TE.traverseReadonlyNonEmptyArrayWithIndex(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, R, E, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n): ((as: ReadonlyArray<A>) => ReaderTaskEither<R, E, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndexSeq = <A, R, E, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n): ((as: ReadonlyNonEmptyArray<A>) => ReaderTaskEither<R, E, ReadonlyNonEmptyArray<B>>) =>\n  flow(R.traverseReadonlyNonEmptyArrayWithIndex(f), R.map(TE.traverseReadonlyNonEmptyArrayWithIndexSeq(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndexSeq = <A, R, E, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n): ((as: ReadonlyArray<A>) => ReaderTaskEither<R, E, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndexSeq(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <R, E, A, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n) => (as: ReadonlyArray<A>) => ReaderTaskEither<R, E, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <R, E, A, B>(\n  f: (a: A) => ReaderTaskEither<R, E, B>\n): ((as: ReadonlyArray<A>) => ReaderTaskEither<R, E, ReadonlyArray<B>>) =>\n  traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <R, E, A>(\n  arr: ReadonlyArray<ReaderTaskEither<R, E, A>>\n) => ReaderTaskEither<R, E, ReadonlyArray<A>> = /*#__PURE__*/ traverseArray(identity)\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseSeqArrayWithIndex: <R, E, A, B>(\n  f: (index: number, a: A) => ReaderTaskEither<R, E, B>\n) => (as: ReadonlyArray<A>) => ReaderTaskEither<R, E, ReadonlyArray<B>> = traverseReadonlyArrayWithIndexSeq\n\n/**\n * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseSeqArray = <R, E, A, B>(\n  f: (a: A) => ReaderTaskEither<R, E, B>\n): ((as: ReadonlyArray<A>) => ReaderTaskEither<R, E, ReadonlyArray<B>>) =>\n  traverseReadonlyArrayWithIndexSeq((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceSeqArray: <R, E, A>(\n  arr: ReadonlyArray<ReaderTaskEither<R, E, A>>\n) => ReaderTaskEither<R, E, ReadonlyArray<A>> = /*#__PURE__*/ traverseSeqArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <R, E, A, B>(\n  f: (a: A) => ReaderTaskEither<R, E, B>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, B> = flatMap\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.0\n */\nexport const chainW: <R2, E2, A, B>(\n  f: (a: A) => ReaderTaskEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E1 | E2, B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <R, E, A, B>(\n  f: (a: A) => ReaderTaskEither<R, E, B>\n) => (ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.8.0\n */\nexport const chainFirstW: <R2, E2, A, B>(\n  f: (a: A) => ReaderTaskEither<R2, E2, B>\n) => <R1, E1>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E1 | E2, A> = tap\n\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const orElseFirst: <E, R, B>(\n  onLeft: (e: E) => ReaderTaskEither<R, E, B>\n) => <A>(ma: ReaderTaskEither<R, E, A>) => ReaderTaskEither<R, E, A> = tapError\n\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const orElseFirstW: <E1, R2, E2, B>(\n  onLeft: (e: E1) => ReaderTaskEither<R2, E2, B>\n) => <R1, A>(ma: ReaderTaskEither<R1, E1, A>) => ReaderTaskEither<R1 & R2, E1 | E2, A> = tapError\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RTE.Functor` instead of `RTE.readerTaskEither`\n * (where `RTE` is from `import RTE from 'fp-ts/ReaderTaskEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const readerTaskEither: Monad3<URI> & Bifunctor3<URI> & Alt3<URI> & MonadTask3<URI> & MonadThrow3<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap,\n  alt: _alt,\n  bimap: mapBoth,\n  mapLeft: mapError,\n  fromIO,\n  fromTask,\n  throwError\n}\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RTE.Functor` instead of `RTE.readerTaskEitherSeq`\n * (where `RTE` is from `import RTE from 'fp-ts/ReaderTaskEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n\nexport const readerTaskEitherSeq: typeof readerTaskEither = {\n  URI,\n  map: _map,\n  of,\n  ap: _apSeq,\n  chain: flatMap,\n  alt: _alt,\n  bimap: mapBoth,\n  mapLeft: mapError,\n  fromIO,\n  fromTask,\n  throwError\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * Semigroup returning the left-most `Left` value. If both operands are `Right`s then the inner values\n * are concatenated using the provided `Semigroup`\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplySemigroup: <R, E, A>(S: Semigroup<A>) => Semigroup<ReaderTaskEither<R, E, A>> =\n  /*#__PURE__*/ getApplySemigroup_(ApplySeq)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplyMonoid: <R, E, A>(M: Monoid<A>) => Monoid<ReaderTaskEither<R, E, A>> =\n  /*#__PURE__*/ getApplicativeMonoid(ApplicativeSeq)\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getSemigroup = <R, E, A>(S: Semigroup<A>): Semigroup<ReaderTaskEither<R, E, A>> =>\n  getApplySemigroup_(RT.ApplySeq)(E.getSemigroup(S))\n\n/**\n * Use [`getApplicativeReaderTaskValidation`](#getapplicativereadertaskvalidation) and [`getAltReaderTaskValidation`](#getaltreadertaskvalidation) instead.\n *\n * @category instances\n * @since 2.3.0\n * @deprecated\n */\nexport function getReaderTaskValidation<E>(\n  SE: Semigroup<E>\n): Monad3C<URI, E> & Bifunctor3<URI> & Alt3C<URI, E> & MonadTask3C<URI, E> & MonadThrow3C<URI, E> {\n  const applicativeReaderTaskValidation = getApplicativeReaderTaskValidation(T.ApplicativePar, SE)\n  const altReaderTaskValidation = getAltReaderTaskValidation(SE)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    of,\n    chain: flatMap,\n    bimap: mapBoth,\n    mapLeft: mapError,\n    ap: applicativeReaderTaskValidation.ap,\n    alt: altReaderTaskValidation.alt,\n    fromIO,\n    fromTask,\n    throwError\n  }\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n/* istanbul ignore next */\nexport function run<R, E, A>(ma: ReaderTaskEither<R, E, A>, r: R): Promise<Either<E, A>> {\n  return ma(r)()\n}\n"
  },
  {
    "path": "src/ReadonlyArray.ts",
    "content": "/**\n * @since 2.5.0\n */\nimport { Alt1 } from './Alt'\nimport { Alternative1 } from './Alternative'\nimport { Applicative as ApplicativeHKT, Applicative1 } from './Applicative'\nimport { apFirst as apFirst_, Apply1, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport { bind as bind_, Chain1, chainFirst as chainFirst_ } from './Chain'\nimport { ChainRec1 } from './ChainRec'\nimport { Compactable1 } from './Compactable'\nimport { Either } from './Either'\nimport { Eq, fromEquals } from './Eq'\nimport { Extend1 } from './Extend'\nimport { Filterable1 } from './Filterable'\nimport { FilterableWithIndex1, PredicateWithIndex, RefinementWithIndex } from './FilterableWithIndex'\nimport { Foldable1 } from './Foldable'\nimport { FoldableWithIndex1 } from './FoldableWithIndex'\nimport { FromEither1, fromEitherK as fromEitherK_ } from './FromEither'\nimport { dual, identity, LazyArg, pipe } from './function'\nimport { bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport { FunctorWithIndex1 } from './FunctorWithIndex'\nimport { HKT } from './HKT'\nimport * as _ from './internal'\nimport { Magma } from './Magma'\nimport { Monad1 } from './Monad'\nimport { Monoid } from './Monoid'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport * as N from './number'\nimport { Option } from './Option'\nimport { fromCompare, Ord } from './Ord'\nimport { Pointed1 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport * as RNEA from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport { Separated, separated } from './Separated'\nimport { Show } from './Show'\nimport { PipeableTraverse1, Traversable1 } from './Traversable'\nimport { PipeableTraverseWithIndex1, TraversableWithIndex1 } from './TraversableWithIndex'\nimport { Unfoldable1 } from './Unfoldable'\nimport {\n  filterE as filterE_,\n  PipeableWilt1,\n  PipeableWither1,\n  wiltDefault,\n  Witherable1,\n  witherDefault\n} from './Witherable'\nimport { guard as guard_, Zero1 } from './Zero'\n\nimport ReadonlyNonEmptyArray = RNEA.ReadonlyNonEmptyArray\n\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n\n/**\n * Test whether a `ReadonlyArray` is empty.\n *\n * @example\n * import { isEmpty } from 'fp-ts/ReadonlyArray'\n *\n * assert.strictEqual(isEmpty([]), true)\n *\n * @category refinements\n * @since 2.5.0\n */\nexport const isEmpty = <A>(as: ReadonlyArray<A>): as is readonly [] => as.length === 0\n\n/**\n * Test whether a `ReadonlyArray` is non empty.\n *\n * @category refinements\n * @since 2.5.0\n */\nexport const isNonEmpty: <A>(as: ReadonlyArray<A>) => as is ReadonlyNonEmptyArray<A> = RNEA.isNonEmpty\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Prepend an element to the front of a `ReadonlyArray`, creating a new `ReadonlyNonEmptyArray`.\n *\n * @example\n * import { prepend } from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([2, 3, 4], prepend(1)), [1, 2, 3, 4])\n *\n * @since 2.10.0\n */\nexport const prepend = RNEA.prepend\n\n/**\n * Less strict version of [`prepend`](#prepend).\n *\n * @since 2.11.0\n */\nexport const prependW = RNEA.prependW\n\n/**\n * Append an element to the end of a `ReadonlyArray`, creating a new `ReadonlyNonEmptyArray`.\n *\n * @example\n * import { append } from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2, 3], append(4)), [1, 2, 3, 4])\n *\n * @since 2.10.0\n */\nexport const append = RNEA.append\n\n/**\n * Less strict version of [`append`](#append).\n *\n * @since 2.11.0\n */\nexport const appendW = RNEA.appendW\n\n/**\n * Return a `ReadonlyArray` of length `n` with element `i` initialized with `f(i)`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import { makeBy } from 'fp-ts/ReadonlyArray'\n *\n * const double = (n: number): number => n * 2\n * assert.deepStrictEqual(makeBy(5, double), [0, 2, 4, 6, 8])\n *\n * @category constructors\n * @since 2.5.0\n */\nexport const makeBy = <A>(n: number, f: (i: number) => A): ReadonlyArray<A> => (n <= 0 ? empty : RNEA.makeBy(f)(n))\n\n/**\n * Create a `ReadonlyArray` containing a value repeated the specified number of times.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import { replicate } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(replicate(3, 'a'), ['a', 'a', 'a'])\n *\n * @category constructors\n * @since 2.5.0\n */\nexport const replicate = <A>(n: number, a: A): ReadonlyArray<A> => makeBy(n, () => a)\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport function fromPredicate<A, B extends A>(refinement: Refinement<A, B>): (a: A) => ReadonlyArray<B>\nexport function fromPredicate<A>(predicate: Predicate<A>): <B extends A>(b: B) => ReadonlyArray<B>\nexport function fromPredicate<A>(predicate: Predicate<A>): (a: A) => ReadonlyArray<A>\nexport function fromPredicate<A>(predicate: Predicate<A>): (a: A) => ReadonlyArray<A> {\n  return (a) => (predicate(a) ? [a] : empty)\n}\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.11.0\n */\nexport const fromOption: <A>(fa: Option<A>) => ReadonlyArray<A> = (ma) => (_.isNone(ma) ? empty : [ma.value])\n\n/**\n * Transforms an `Either` to a `ReadonlyArray`.\n *\n * @category conversions\n * @since 2.11.0\n */\nexport const fromEither: <A>(fa: Either<unknown, A>) => ReadonlyArray<A> = (e) => (_.isLeft(e) ? empty : [e.right])\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchW =\n  <B, A, C>(onEmpty: LazyArg<B>, onNonEmpty: (as: ReadonlyNonEmptyArray<A>) => C) =>\n  (as: ReadonlyArray<A>): B | C =>\n    isNonEmpty(as) ? onNonEmpty(as) : onEmpty()\n\n/**\n * @category pattern matching\n * @since 2.11.0\n */\nexport const match: <B, A>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (as: ReadonlyNonEmptyArray<A>) => B\n) => (as: ReadonlyArray<A>) => B = matchW\n\n/**\n * Less strict version of [`matchLeft`](#matchleft).\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchLeftW =\n  <B, A, C>(onEmpty: LazyArg<B>, onNonEmpty: (head: A, tail: ReadonlyArray<A>) => C) =>\n  (as: ReadonlyArray<A>): B | C =>\n    isNonEmpty(as) ? onNonEmpty(RNEA.head(as), RNEA.tail(as)) : onEmpty()\n\n/**\n * Break a `ReadonlyArray` into its first element and remaining elements.\n *\n * @example\n * import { matchLeft } from 'fp-ts/ReadonlyArray'\n *\n * const len: <A>(as: ReadonlyArray<A>) => number = matchLeft(() => 0, (_, tail) => 1 + len(tail))\n * assert.strictEqual(len([1, 2, 3]), 3)\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchLeft: <B, A>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (head: A, tail: ReadonlyArray<A>) => B\n) => (as: ReadonlyArray<A>) => B = matchLeftW\n\n/**\n * Alias of [`matchLeft`](#matchleft).\n *\n * @category pattern matching\n * @since 2.5.0\n */\nexport const foldLeft: <A, B>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (head: A, tail: ReadonlyArray<A>) => B\n) => (as: ReadonlyArray<A>) => B = matchLeft\n\n/**\n * Less strict version of [`matchRight`](#matchright).\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchRightW =\n  <B, A, C>(onEmpty: LazyArg<B>, onNonEmpty: (init: ReadonlyArray<A>, last: A) => C) =>\n  (as: ReadonlyArray<A>): B | C =>\n    isNonEmpty(as) ? onNonEmpty(RNEA.init(as), RNEA.last(as)) : onEmpty()\n\n/**\n * Break a `ReadonlyArray` into its initial elements and the last element.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchRight: <B, A>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (init: ReadonlyArray<A>, last: A) => B\n) => (as: ReadonlyArray<A>) => B = matchRightW\n\n/**\n * Alias of [`matchRight`](#matchright).\n *\n * @category pattern matching\n * @since 2.5.0\n */\nexport const foldRight: <A, B>(\n  onEmpty: LazyArg<B>,\n  onNonEmpty: (init: ReadonlyArray<A>, last: A) => B\n) => (as: ReadonlyArray<A>) => B = matchRight\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @category sequencing\n * @since 2.7.0\n */\nexport const chainWithIndex =\n  <A, B>(f: (i: number, a: A) => ReadonlyArray<B>) =>\n  (as: ReadonlyArray<A>): ReadonlyArray<B> => {\n    if (isEmpty(as)) {\n      return empty\n    }\n    const out: Array<B> = []\n    for (let i = 0; i < as.length; i++) {\n      const bs = f(i, as[i])\n      for (let j = 0; j < bs.length; j++) {\n        out.push(bs[j])\n      }\n    }\n    return out\n  }\n\n/**\n * Same as `reduce` but it carries over the intermediate steps.\n *\n * @example\n * import { scanLeft } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(scanLeft(10, (b, a: number) => b - a)([1, 2, 3]), [10, 9, 7, 4])\n *\n * @since 2.5.0\n */\nexport const scanLeft =\n  <A, B>(b: B, f: (b: B, a: A) => B) =>\n  (as: ReadonlyArray<A>): ReadonlyNonEmptyArray<B> => {\n    const len = as.length\n    const out = new Array(len + 1) as NonEmptyArray<B>\n    out[0] = b\n    for (let i = 0; i < len; i++) {\n      out[i + 1] = f(out[i], as[i])\n    }\n    return out\n  }\n\n/**\n * Fold an array from the right, keeping all intermediate results instead of only the final result\n *\n * @example\n * import { scanRight } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(scanRight(10, (a: number, b) => b - a)([1, 2, 3]), [4, 5, 7, 10])\n *\n * @since 2.5.0\n */\nexport const scanRight =\n  <A, B>(b: B, f: (a: A, b: B) => B) =>\n  (as: ReadonlyArray<A>): ReadonlyNonEmptyArray<B> => {\n    const len = as.length\n    const out = new Array(len + 1) as NonEmptyArray<B>\n    out[len] = b\n    for (let i = len - 1; i >= 0; i--) {\n      out[i] = f(as[i], out[i + 1])\n    }\n    return out\n  }\n\n/**\n * Calculate the number of elements in a `ReadonlyArray`.\n *\n * @since 2.10.0\n */\nexport const size = <A>(as: ReadonlyArray<A>): number => as.length\n\n/**\n * Test whether an array contains a particular index\n *\n * @since 2.5.0\n */\nexport const isOutOfBound: <A>(i: number, as: ReadonlyArray<A>) => boolean = RNEA.isOutOfBound\n\n// TODO: remove non-curried overloading in v3\n/**\n * This function provides a safe way to read a value at a particular index from an array\n *\n * @example\n * import { lookup } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2, 3], lookup(1)), some(2))\n * assert.deepStrictEqual(pipe([1, 2, 3], lookup(3)), none)\n *\n * @since 2.5.0\n */\nexport function lookup(i: number): <A>(as: ReadonlyArray<A>) => Option<A>\nexport function lookup<A>(i: number, as: ReadonlyArray<A>): Option<A>\nexport function lookup<A>(i: number, as?: ReadonlyArray<A>): Option<A> | (<A>(as: ReadonlyArray<A>) => Option<A>) {\n  return as === undefined ? (as) => lookup(i, as) : isOutOfBound(i, as) ? _.none : _.some(as[i])\n}\n\n/**\n * Get the first element in an array, or `None` if the array is empty\n *\n * @example\n * import { head } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(head([1, 2, 3]), some(1))\n * assert.deepStrictEqual(head([]), none)\n *\n * @since 2.5.0\n */\nexport const head = <A>(as: ReadonlyArray<A>): Option<A> => (isNonEmpty(as) ? _.some(RNEA.head(as)) : _.none)\n\n/**\n * Get the last element in an array, or `None` if the array is empty\n *\n * @example\n * import { last } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(last([1, 2, 3]), some(3))\n * assert.deepStrictEqual(last([]), none)\n *\n * @since 2.5.0\n */\nexport const last = <A>(as: ReadonlyArray<A>): Option<A> => (isNonEmpty(as) ? _.some(RNEA.last(as)) : _.none)\n\n/**\n * Get all but the first element of an array, creating a new array, or `None` if the array is empty\n *\n * @example\n * import { tail } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(tail([1, 2, 3]), some([2, 3]))\n * assert.deepStrictEqual(tail([]), none)\n *\n * @since 2.5.0\n */\nexport const tail = <A>(as: ReadonlyArray<A>): Option<ReadonlyArray<A>> =>\n  isNonEmpty(as) ? _.some(RNEA.tail(as)) : _.none\n\n/**\n * Get all but the last element of an array, creating a new array, or `None` if the array is empty\n *\n * @example\n * import { init } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(init([1, 2, 3]), some([1, 2]))\n * assert.deepStrictEqual(init([]), none)\n *\n * @since 2.5.0\n */\nexport const init = <A>(as: ReadonlyArray<A>): Option<ReadonlyArray<A>> =>\n  isNonEmpty(as) ? _.some(RNEA.init(as)) : _.none\n\n/**\n * Keep only a max number of elements from the start of an `ReadonlyArray`, creating a new `ReadonlyArray`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * const input: ReadonlyArray<number> = [1, 2, 3]\n * assert.deepStrictEqual(pipe(input, RA.takeLeft(2)), [1, 2])\n *\n * // out of bounds\n * assert.strictEqual(pipe(input, RA.takeLeft(4)), input)\n * assert.strictEqual(pipe(input, RA.takeLeft(-1)), input)\n *\n * @since 2.5.0\n */\nexport const takeLeft =\n  (n: number) =>\n  <A>(as: ReadonlyArray<A>): ReadonlyArray<A> =>\n    isOutOfBound(n, as) ? as : n === 0 ? empty : as.slice(0, n)\n\n/**\n * Keep only a max number of elements from the end of an `ReadonlyArray`, creating a new `ReadonlyArray`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * const input: ReadonlyArray<number> = [1, 2, 3]\n * assert.deepStrictEqual(pipe(input, RA.takeRight(2)), [2, 3])\n *\n * // out of bounds\n * assert.strictEqual(pipe(input, RA.takeRight(4)), input)\n * assert.strictEqual(pipe(input, RA.takeRight(-1)), input)\n *\n * @since 2.5.0\n */\nexport const takeRight =\n  (n: number) =>\n  <A>(as: ReadonlyArray<A>): ReadonlyArray<A> =>\n    isOutOfBound(n, as) ? as : n === 0 ? empty : as.slice(-n)\n\n/**\n * Calculate the longest initial subarray for which all element satisfy the specified predicate, creating a new array\n *\n * @example\n * import { takeLeftWhile } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(takeLeftWhile((n: number) => n % 2 === 0)([2, 4, 3, 6]), [2, 4])\n *\n * @since 2.5.0\n */\nexport function takeLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => ReadonlyArray<B>\nexport function takeLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => ReadonlyArray<B>\nexport function takeLeftWhile<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => ReadonlyArray<A>\nexport function takeLeftWhile<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => ReadonlyArray<A> {\n  return (as: ReadonlyArray<A>) => {\n    const out: Array<A> = []\n    for (const a of as) {\n      if (!predicate(a)) {\n        break\n      }\n      out.push(a)\n    }\n    const len = out.length\n    return len === as.length ? as : len === 0 ? empty : out\n  }\n}\n\n/**\n * @since 2.5.0\n */\nexport interface Spanned<I, R> {\n  readonly init: ReadonlyArray<I>\n  readonly rest: ReadonlyArray<R>\n}\n\nconst spanLeftIndex = <A>(as: ReadonlyArray<A>, predicate: Predicate<A>): number => {\n  const l = as.length\n  let i = 0\n  for (; i < l; i++) {\n    if (!predicate(as[i])) {\n      break\n    }\n  }\n  return i\n}\n\n/**\n * Split an array into two parts:\n * 1. the longest initial subarray for which all elements satisfy the specified predicate\n * 2. the remaining elements\n *\n * @example\n * import { spanLeft } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(spanLeft((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] })\n *\n * @since 2.5.0\n */\nexport function spanLeft<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => Spanned<B, A>\nexport function spanLeft<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Spanned<B, B>\nexport function spanLeft<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Spanned<A, A>\nexport function spanLeft<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Spanned<A, A> {\n  return (as) => {\n    const [init, rest] = splitAt(spanLeftIndex(as, predicate))(as)\n    return { init, rest }\n  }\n}\n\n/**\n * Drop a max number of elements from the start of an `ReadonlyArray`, creating a new `ReadonlyArray`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * const input: ReadonlyArray<number> = [1, 2, 3]\n * assert.deepStrictEqual(pipe(input, RA.dropLeft(2)), [3])\n * assert.strictEqual(pipe(input, RA.dropLeft(0)), input)\n * assert.strictEqual(pipe(input, RA.dropLeft(-1)), input)\n *\n * @since 2.5.0\n */\nexport const dropLeft =\n  (n: number) =>\n  <A>(as: ReadonlyArray<A>): ReadonlyArray<A> =>\n    n <= 0 || isEmpty(as) ? as : n >= as.length ? empty : as.slice(n, as.length)\n\n/**\n * Drop a max number of elements from the end of an `ReadonlyArray`, creating a new `ReadonlyArray`.\n *\n * **Note**. `n` is normalized to a non negative integer.\n *\n * @example\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * const input: ReadonlyArray<number> = [1, 2, 3]\n * assert.deepStrictEqual(pipe(input, RA.dropRight(2)), [1])\n * assert.strictEqual(pipe(input, RA.dropRight(0)), input)\n * assert.strictEqual(pipe(input, RA.dropRight(-1)), input)\n *\n * @since 2.5.0\n */\nexport const dropRight =\n  (n: number) =>\n  <A>(as: ReadonlyArray<A>): ReadonlyArray<A> =>\n    n <= 0 || isEmpty(as) ? as : n >= as.length ? empty : as.slice(0, as.length - n)\n\n/**\n * Remove the longest initial subarray for which all element satisfy the specified predicate, creating a new array\n *\n * @example\n * import { dropLeftWhile } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(dropLeftWhile((n: number) => n % 2 === 1)([1, 3, 2, 4, 5]), [2, 4, 5])\n *\n * @since 2.5.0\n */\nexport function dropLeftWhile<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => ReadonlyArray<B>\nexport function dropLeftWhile<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => ReadonlyArray<B>\nexport function dropLeftWhile<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => ReadonlyArray<A>\nexport function dropLeftWhile<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => ReadonlyArray<A> {\n  return (as) => {\n    const i = spanLeftIndex(as, predicate)\n    return i === 0 ? as : i === as.length ? empty : as.slice(i)\n  }\n}\n\n/**\n * Find the first index for which a predicate holds\n *\n * @example\n * import { findIndex } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(findIndex((n: number) => n === 2)([1, 2, 3]), some(1))\n * assert.deepStrictEqual(findIndex((n: number) => n === 2)([]), none)\n *\n * @since 2.5.0\n */\nexport const findIndex =\n  <A>(predicate: Predicate<A>) =>\n  (as: ReadonlyArray<A>): Option<number> => {\n    for (let i = 0; i < as.length; i++) {\n      if (predicate(as[i])) {\n        return _.some(i)\n      }\n    }\n    return _.none\n  }\n\n/**\n * Find the first element which satisfies a predicate (or a refinement) function\n *\n * @example\n * import { findFirst } from 'fp-ts/ReadonlyArray'\n * import { some } from 'fp-ts/Option'\n *\n * type X = {\n *   readonly a: number\n *   readonly b: number\n * }\n *\n * assert.deepStrictEqual(findFirst((x: X) => x.a === 1)([{ a: 1, b: 1 }, { a: 1, b: 2 }]), some({ a: 1, b: 1 }))\n *\n * @since 2.5.0\n */\nexport function findFirst<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => Option<B>\nexport function findFirst<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Option<B>\nexport function findFirst<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Option<A>\nexport function findFirst<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Option<A> {\n  return (as) => {\n    for (let i = 0; i < as.length; i++) {\n      if (predicate(as[i])) {\n        return _.some(as[i])\n      }\n    }\n    return _.none\n  }\n}\n\n/**\n * Find the first element returned by an option based selector function\n *\n * @example\n * import { findFirstMap } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * interface Person {\n *   readonly name: string\n *   readonly age?: number\n * }\n *\n * const persons: ReadonlyArray<Person> = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }]\n *\n * // returns the name of the first person that has an age\n * assert.deepStrictEqual(findFirstMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Mary'))\n *\n * @since 2.5.0\n */\nexport const findFirstMap =\n  <A, B>(f: (a: A) => Option<B>) =>\n  (as: ReadonlyArray<A>): Option<B> => {\n    for (let i = 0; i < as.length; i++) {\n      const out = f(as[i])\n      if (_.isSome(out)) {\n        return out\n      }\n    }\n    return _.none\n  }\n\n/**\n * Find the last element which satisfies a predicate function\n *\n * @example\n * import { findLast } from 'fp-ts/ReadonlyArray'\n * import { some } from 'fp-ts/Option'\n *\n * type X = {\n *   readonly a: number\n *   readonly b: number\n * }\n *\n * assert.deepStrictEqual(findLast((x: X) => x.a === 1)([{ a: 1, b: 1 }, { a: 1, b: 2 }]), some({ a: 1, b: 2 }))\n *\n * @since 2.5.0\n */\nexport function findLast<A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => Option<B>\nexport function findLast<A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Option<B>\nexport function findLast<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Option<A>\nexport function findLast<A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Option<A> {\n  return (as) => {\n    for (let i = as.length - 1; i >= 0; i--) {\n      if (predicate(as[i])) {\n        return _.some(as[i])\n      }\n    }\n    return _.none\n  }\n}\n\n/**\n * Find the last element returned by an option based selector function\n *\n * @example\n * import { findLastMap } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * interface Person {\n *   readonly name: string\n *   readonly age?: number\n * }\n *\n * const persons: ReadonlyArray<Person> = [{ name: 'John' }, { name: 'Mary', age: 45 }, { name: 'Joey', age: 28 }]\n *\n * // returns the name of the last person that has an age\n * assert.deepStrictEqual(findLastMap((p: Person) => (p.age === undefined ? none : some(p.name)))(persons), some('Joey'))\n *\n * @since 2.5.0\n */\nexport const findLastMap =\n  <A, B>(f: (a: A) => Option<B>) =>\n  (as: ReadonlyArray<A>): Option<B> => {\n    for (let i = as.length - 1; i >= 0; i--) {\n      const out = f(as[i])\n      if (_.isSome(out)) {\n        return out\n      }\n    }\n    return _.none\n  }\n\n/**\n * Returns the index of the last element of the list which matches the predicate\n *\n * @example\n * import { findLastIndex } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * interface X {\n *   readonly a: number\n *   readonly b: number\n * }\n * const xs: ReadonlyArray<X> = [{ a: 1, b: 0 }, { a: 1, b: 1 }]\n * assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 1)(xs), some(1))\n * assert.deepStrictEqual(findLastIndex((x: { readonly a: number }) => x.a === 4)(xs), none)\n *\n *\n * @since 2.5.0\n */\nexport const findLastIndex =\n  <A>(predicate: Predicate<A>) =>\n  (as: ReadonlyArray<A>): Option<number> => {\n    for (let i = as.length - 1; i >= 0; i--) {\n      if (predicate(as[i])) {\n        return _.some(i)\n      }\n    }\n    return _.none\n  }\n\n/**\n * Insert an element at the specified index, creating a new array, or returning `None` if the index is out of bounds\n *\n * @example\n * import { insertAt } from 'fp-ts/ReadonlyArray'\n * import { some } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(insertAt(2, 5)([1, 2, 3, 4]), some([1, 2, 5, 3, 4]))\n *\n * @since 2.5.0\n */\nexport const insertAt =\n  <A>(i: number, a: A) =>\n  (as: ReadonlyArray<A>): Option<ReadonlyNonEmptyArray<A>> =>\n    i < 0 || i > as.length ? _.none : _.some(RNEA.unsafeInsertAt(i, a, as))\n\n/**\n * Change the element at the specified index, creating a new array, or returning `None` if the index is out of bounds\n *\n * @example\n * import { updateAt } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(updateAt(1, 1)([1, 2, 3]), some([1, 1, 3]))\n * assert.deepStrictEqual(updateAt(1, 1)([]), none)\n *\n * @since 2.5.0\n */\nexport const updateAt = <A>(i: number, a: A): ((as: ReadonlyArray<A>) => Option<ReadonlyArray<A>>) =>\n  modifyAt(i, () => a)\n\n/**\n * Delete the element at the specified index, creating a new array, or returning `None` if the index is out of bounds\n *\n * @example\n * import { deleteAt } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(deleteAt(0)([1, 2, 3]), some([2, 3]))\n * assert.deepStrictEqual(deleteAt(1)([]), none)\n *\n * @since 2.5.0\n */\nexport const deleteAt =\n  (i: number) =>\n  <A>(as: ReadonlyArray<A>): Option<ReadonlyArray<A>> =>\n    isOutOfBound(i, as) ? _.none : _.some(unsafeDeleteAt(i, as))\n\n/**\n * Apply a function to the element at the specified index, creating a new array, or returning `None` if the index is out\n * of bounds\n *\n * @example\n * import { modifyAt } from 'fp-ts/ReadonlyArray'\n * import { some, none } from 'fp-ts/Option'\n *\n * const double = (x: number): number => x * 2\n * assert.deepStrictEqual(modifyAt(1, double)([1, 2, 3]), some([1, 4, 3]))\n * assert.deepStrictEqual(modifyAt(1, double)([]), none)\n *\n * @since 2.5.0\n */\nexport const modifyAt =\n  <A>(i: number, f: (a: A) => A) =>\n  (as: ReadonlyArray<A>): Option<ReadonlyArray<A>> =>\n    isOutOfBound(i, as) ? _.none : _.some(unsafeUpdateAt(i, f(as[i]), as))\n\n/**\n * Reverse an array, creating a new array\n *\n * @example\n * import { reverse } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1])\n *\n * @since 2.5.0\n */\nexport const reverse = <A>(as: ReadonlyArray<A>): ReadonlyArray<A> => (as.length <= 1 ? as : as.slice().reverse())\n\n/**\n * Extracts from an array of `Either` all the `Right` elements. All the `Right` elements are extracted in order\n *\n * @example\n * import { rights } from 'fp-ts/ReadonlyArray'\n * import { right, left } from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(rights([right(1), left('foo'), right(2)]), [1, 2])\n *\n * @since 2.5.0\n */\nexport const rights = <E, A>(as: ReadonlyArray<Either<E, A>>): ReadonlyArray<A> => {\n  const r: Array<A> = []\n  for (let i = 0; i < as.length; i++) {\n    const a = as[i]\n    if (a._tag === 'Right') {\n      r.push(a.right)\n    }\n  }\n  return r\n}\n\n/**\n * Extracts from an array of `Either` all the `Left` elements. All the `Left` elements are extracted in order\n *\n * @example\n * import { lefts } from 'fp-ts/ReadonlyArray'\n * import { left, right } from 'fp-ts/Either'\n *\n * assert.deepStrictEqual(lefts([right(1), left('foo'), right(2)]), ['foo'])\n *\n * @since 2.5.0\n */\nexport const lefts = <E, A>(as: ReadonlyArray<Either<E, A>>): ReadonlyArray<E> => {\n  const r: Array<E> = []\n  for (let i = 0; i < as.length; i++) {\n    const a = as[i]\n    if (a._tag === 'Left') {\n      r.push(a.left)\n    }\n  }\n  return r\n}\n\n/**\n * Sort the elements of an array in increasing order, creating a new array\n *\n * @example\n * import { sort } from 'fp-ts/ReadonlyArray'\n * import * as N from 'fp-ts/number'\n *\n * assert.deepStrictEqual(sort(N.Ord)([3, 2, 1]), [1, 2, 3])\n *\n * @since 2.5.0\n */\nexport const sort =\n  <B>(O: Ord<B>) =>\n  <A extends B>(as: ReadonlyArray<A>): ReadonlyArray<A> =>\n    as.length <= 1 ? as : as.slice().sort(O.compare)\n\n// TODO: curry and make data-last in v3\n/**\n * Apply a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one\n * input array is short, excess elements of the longer array are discarded.\n *\n * @example\n * import { zipWith } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n), ['a1', 'b2', 'c3'])\n *\n * @since 2.5.0\n */\nexport const zipWith = <A, B, C>(\n  fa: ReadonlyArray<A>,\n  fb: ReadonlyArray<B>,\n  f: (a: A, b: B) => C\n): ReadonlyArray<C> => {\n  const fc: Array<C> = []\n  const len = Math.min(fa.length, fb.length)\n  for (let i = 0; i < len; i++) {\n    fc[i] = f(fa[i], fb[i])\n  }\n  return fc\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Takes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the\n * longer array are discarded\n *\n * @example\n * import { zip } from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2, 3], zip(['a', 'b', 'c', 'd'])), [[1, 'a'], [2, 'b'], [3, 'c']])\n *\n * @since 2.5.0\n */\nexport function zip<B>(bs: ReadonlyArray<B>): <A>(as: ReadonlyArray<A>) => ReadonlyArray<readonly [A, B]>\nexport function zip<A, B>(as: ReadonlyArray<A>, bs: ReadonlyArray<B>): ReadonlyArray<readonly [A, B]>\nexport function zip<A, B>(\n  as: ReadonlyArray<A>,\n  bs?: ReadonlyArray<B>\n): ReadonlyArray<readonly [A, B]> | ((bs: ReadonlyArray<B>) => ReadonlyArray<readonly [B, A]>) {\n  if (bs === undefined) {\n    return (bs) => zip(bs, as)\n  }\n  return zipWith(as, bs, (a, b) => [a, b])\n}\n\n/**\n * The function is reverse of `zip`. Takes an array of pairs and return two corresponding arrays\n *\n * @example\n * import { unzip } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(unzip([[1, 'a'], [2, 'b'], [3, 'c']]), [[1, 2, 3], ['a', 'b', 'c']])\n *\n * @since 2.5.0\n */\nexport const unzip = <A, B>(as: ReadonlyArray<readonly [A, B]>): readonly [ReadonlyArray<A>, ReadonlyArray<B>] => {\n  const fa: Array<A> = []\n  const fb: Array<B> = []\n  for (let i = 0; i < as.length; i++) {\n    fa[i] = as[i][0]\n    fb[i] = as[i][1]\n  }\n  return [fa, fb]\n}\n\n/**\n * Prepend an element to every member of an array\n *\n * @example\n * import { prependAll } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])\n *\n * @since 2.10.0\n */\nexport const prependAll = <A>(middle: A): ((as: ReadonlyArray<A>) => ReadonlyArray<A>) => {\n  const f = RNEA.prependAll(middle)\n  return (as) => (isNonEmpty(as) ? f(as) : as)\n}\n\n/**\n * Places an element in between members of an array\n *\n * @example\n * import { intersperse } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])\n *\n * @since 2.9.0\n */\nexport const intersperse = <A>(middle: A): ((as: ReadonlyArray<A>) => ReadonlyArray<A>) => {\n  const f = RNEA.intersperse(middle)\n  return (as) => (isNonEmpty(as) ? f(as) : as)\n}\n\n/**\n * Rotate a `ReadonlyArray` by `n` steps.\n *\n * @example\n * import { rotate } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n *\n * @since 2.5.0\n */\nexport const rotate = (n: number): (<A>(as: ReadonlyArray<A>) => ReadonlyArray<A>) => {\n  const f = RNEA.rotate(n)\n  return (as) => (isNonEmpty(as) ? f(as) : as)\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test if a value is a member of an array. Takes a `Eq<A>` as a single\n * argument which returns the function to use to search for a value of type `A` in\n * an array of type `ReadonlyArray<A>`.\n *\n * @example\n * import { elem } from 'fp-ts/ReadonlyArray'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(2)), true)\n * assert.strictEqual(pipe([1, 2, 3], elem(N.Eq)(0)), false)\n *\n * @since 2.5.0\n */\nexport function elem<A>(E: Eq<A>): {\n  (a: A): (as: ReadonlyArray<A>) => boolean\n  (a: A, as: ReadonlyArray<A>): boolean\n}\nexport function elem<A>(E: Eq<A>): (a: A, as?: ReadonlyArray<A>) => boolean | ((as: ReadonlyArray<A>) => boolean) {\n  return (a, as?) => {\n    if (as === undefined) {\n      const elemE = elem(E)\n      return (as) => elemE(a, as)\n    }\n    const predicate = (element: A) => E.equals(element, a)\n    let i = 0\n    for (; i < as.length; i++) {\n      if (predicate(as[i])) {\n        return true\n      }\n    }\n    return false\n  }\n}\n\n/**\n * Remove duplicates from an array, keeping the first occurrence of an element.\n *\n * @example\n * import { uniq } from 'fp-ts/ReadonlyArray'\n * import * as N from 'fp-ts/number'\n *\n * assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])\n *\n * @since 2.5.0\n */\nexport const uniq = <A>(E: Eq<A>): ((as: ReadonlyArray<A>) => ReadonlyArray<A>) => {\n  const f = RNEA.uniq(E)\n  return (as) => (isNonEmpty(as) ? f(as) : as)\n}\n\n/**\n * Sort the elements of an array in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,\n * etc...\n *\n * @example\n * import { sortBy } from 'fp-ts/ReadonlyArray'\n * import { contramap } from 'fp-ts/Ord'\n * import * as S from 'fp-ts/string'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * interface Person {\n *   readonly name: string\n *   readonly age: number\n * }\n * const byName = pipe(S.Ord, contramap((p: Person) => p.name))\n * const byAge = pipe(N.Ord, contramap((p: Person) => p.age))\n *\n * const sortByNameByAge = sortBy([byName, byAge])\n *\n * const persons = [{ name: 'a', age: 1 }, { name: 'b', age: 3 }, { name: 'c', age: 2 }, { name: 'b', age: 2 }]\n * assert.deepStrictEqual(sortByNameByAge(persons), [\n *   { name: 'a', age: 1 },\n *   { name: 'b', age: 2 },\n *   { name: 'b', age: 3 },\n *   { name: 'c', age: 2 }\n * ])\n *\n * @since 2.5.0\n */\nexport const sortBy = <B>(ords: ReadonlyArray<Ord<B>>): (<A extends B>(as: ReadonlyArray<A>) => ReadonlyArray<A>) => {\n  const f = RNEA.sortBy(ords)\n  return (as) => (isNonEmpty(as) ? f(as) : as)\n}\n\n/**\n * A useful recursion pattern for processing a `ReadonlyArray` to produce a new `ReadonlyArray`, often used for \"chopping\" up the input\n * `ReadonlyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `ReadonlyArray` and produce a\n * value and the tail of the `ReadonlyArray`.\n *\n * @example\n * import { Eq } from 'fp-ts/Eq'\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * const group = <A>(S: Eq<A>): ((as: ReadonlyArray<A>) => ReadonlyArray<ReadonlyArray<A>>) => {\n *   return RA.chop(as => {\n *     const { init, rest } = pipe(as, RA.spanLeft((a: A) => S.equals(a, as[0])))\n *     return [init, rest]\n *   })\n * }\n * assert.deepStrictEqual(group(N.Eq)([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]])\n *\n * @since 2.5.0\n */\nexport const chop = <A, B>(\n  f: (as: ReadonlyNonEmptyArray<A>) => readonly [B, ReadonlyArray<A>]\n): ((as: ReadonlyArray<A>) => ReadonlyArray<B>) => {\n  const g = RNEA.chop(f)\n  return (as) => (isNonEmpty(as) ? g(as) : empty)\n}\n\n/**\n * Splits a `ReadonlyArray` into two pieces, the first piece has max `n` elements.\n *\n * @example\n * import { splitAt } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(splitAt(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4, 5]])\n *\n * @since 2.5.0\n */\nexport const splitAt =\n  (n: number) =>\n  <A>(as: ReadonlyArray<A>): readonly [ReadonlyArray<A>, ReadonlyArray<A>] =>\n    n >= 1 && isNonEmpty(as) ? RNEA.splitAt(n)(as) : isEmpty(as) ? [as, empty] : [empty, as]\n\n/**\n * Splits a `ReadonlyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\n * the `ReadonlyArray`. 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 `as`.\n *\n * @example\n * import { chunksOf } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])\n *\n * @since 2.5.0\n */\nexport const chunksOf = (n: number): (<A>(as: ReadonlyArray<A>) => ReadonlyArray<ReadonlyNonEmptyArray<A>>) => {\n  const f = RNEA.chunksOf(n)\n  return (as) => (isNonEmpty(as) ? f(as) : empty)\n}\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromOptionK =\n  <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) =>\n  (...a: A): ReadonlyArray<B> =>\n    fromOption(f(...a))\n\n/**\n * `ReadonlyArray` comprehension.\n *\n * ```\n * [ f(x, y, ...) | x ← xs, y ← ys, ..., g(x, y, ...) ]\n * ```\n *\n * @example\n * import { comprehension } from 'fp-ts/ReadonlyArray'\n * import { tuple } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(comprehension([[1, 2, 3], ['a', 'b']], tuple, (a, b) => (a + b.length) % 2 === 0), [\n *   [1, 'a'],\n *   [1, 'b'],\n *   [3, 'a'],\n *   [3, 'b']\n * ])\n *\n * @since 2.5.0\n */\nexport function comprehension<A, B, C, D, R>(\n  input: readonly [ReadonlyArray<A>, ReadonlyArray<B>, ReadonlyArray<C>, ReadonlyArray<D>],\n  f: (a: A, b: B, c: C, d: D) => R,\n  g?: (a: A, b: B, c: C, d: D) => boolean\n): ReadonlyArray<R>\nexport function comprehension<A, B, C, R>(\n  input: readonly [ReadonlyArray<A>, ReadonlyArray<B>, ReadonlyArray<C>],\n  f: (a: A, b: B, c: C) => R,\n  g?: (a: A, b: B, c: C) => boolean\n): ReadonlyArray<R>\nexport function comprehension<A, B, R>(\n  input: readonly [ReadonlyArray<A>, ReadonlyArray<B>],\n  f: (a: A, b: B) => R,\n  g?: (a: A, b: B) => boolean\n): ReadonlyArray<R>\nexport function comprehension<A, R>(\n  input: readonly [ReadonlyArray<A>],\n  f: (a: A) => R,\n  g?: (a: A) => boolean\n): ReadonlyArray<R>\nexport function comprehension<A, R>(\n  input: ReadonlyArray<ReadonlyArray<A>>,\n  f: (...xs: ReadonlyArray<A>) => R,\n  g: (...xs: ReadonlyArray<A>) => boolean = () => true\n): ReadonlyArray<R> {\n  const go = (scope: ReadonlyArray<A>, input: ReadonlyArray<ReadonlyArray<A>>): ReadonlyArray<R> =>\n    isNonEmpty(input)\n      ? flatMap(RNEA.head(input), (a) => go(pipe(scope, append(a)), RNEA.tail(input)))\n      : g(...scope)\n      ? [f(...scope)]\n      : empty\n  return go(empty, input)\n}\n\n/**\n * @since 2.11.0\n */\nexport const concatW =\n  <B>(second: ReadonlyArray<B>) =>\n  <A>(first: ReadonlyArray<A>): ReadonlyArray<A | B> =>\n    isEmpty(first) ? second : isEmpty(second) ? first : (first as ReadonlyArray<A | B>).concat(second)\n\n/**\n * @since 2.11.0\n */\nexport const concat: <A>(second: ReadonlyArray<A>) => (first: ReadonlyArray<A>) => ReadonlyArray<A> = concatW\n\n// TODO: remove non-curried overloading in v3\n/**\n * Creates an array of unique values, in order, from all given arrays using a `Eq` for equality comparisons\n *\n * @example\n * import { union } from 'fp-ts/ReadonlyArray'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2], union(N.Eq)([2, 3])), [1, 2, 3])\n *\n * @since 2.5.0\n */\nexport function union<A>(E: Eq<A>): {\n  (xs: ReadonlyArray<A>): (ys: ReadonlyArray<A>) => ReadonlyArray<A>\n  (xs: ReadonlyArray<A>, ys: ReadonlyArray<A>): ReadonlyArray<A>\n}\nexport function union<A>(\n  E: Eq<A>\n): (xs: ReadonlyArray<A>, ys?: ReadonlyArray<A>) => ReadonlyArray<A> | ((ys: ReadonlyArray<A>) => ReadonlyArray<A>) {\n  const unionE = RNEA.union(E)\n  return (first, second?) => {\n    if (second === undefined) {\n      const unionE = union(E)\n      return (second) => unionE(second, first)\n    }\n    return isNonEmpty(first) && isNonEmpty(second) ? unionE(second)(first) : isNonEmpty(first) ? first : second\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Creates an array of unique values that are included in all given arrays using a `Eq` for equality\n * comparisons. The order and references of result values are determined by the first array.\n *\n * @example\n * import { intersection } from 'fp-ts/ReadonlyArray'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2], intersection(N.Eq)([2, 3])), [2])\n *\n * @since 2.5.0\n */\nexport function intersection<A>(E: Eq<A>): {\n  (xs: ReadonlyArray<A>): (ys: ReadonlyArray<A>) => ReadonlyArray<A>\n  (xs: ReadonlyArray<A>, ys: ReadonlyArray<A>): ReadonlyArray<A>\n}\nexport function intersection<A>(\n  E: Eq<A>\n): (xs: ReadonlyArray<A>, ys?: ReadonlyArray<A>) => ReadonlyArray<A> | ((ys: ReadonlyArray<A>) => ReadonlyArray<A>) {\n  const elemE = elem(E)\n  return (xs, ys?) => {\n    if (ys === undefined) {\n      const intersectionE = intersection(E)\n      return (ys) => intersectionE(ys, xs)\n    }\n    return xs.filter((a) => elemE(a, ys))\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Creates an array of array values not included in the other given array using a `Eq` for equality\n * comparisons. The order and references of result values are determined by the first array.\n *\n * @example\n * import { difference } from 'fp-ts/ReadonlyArray'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe([1, 2], difference(N.Eq)([2, 3])), [1])\n *\n * @since 2.5.0\n */\nexport function difference<A>(E: Eq<A>): {\n  (xs: ReadonlyArray<A>): (ys: ReadonlyArray<A>) => ReadonlyArray<A>\n  (xs: ReadonlyArray<A>, ys: ReadonlyArray<A>): ReadonlyArray<A>\n}\nexport function difference<A>(\n  E: Eq<A>\n): (xs: ReadonlyArray<A>, ys?: ReadonlyArray<A>) => ReadonlyArray<A> | ((ys: ReadonlyArray<A>) => ReadonlyArray<A>) {\n  const elemE = elem(E)\n  return (xs, ys?) => {\n    if (ys === undefined) {\n      const differenceE = difference(E)\n      return (ys) => differenceE(ys, xs)\n    }\n    return xs.filter((a) => !elemE(a, ys))\n  }\n}\n\nconst _map: Monad1<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _mapWithIndex: FunctorWithIndex1<URI, number>['mapWithIndex'] = (fa, f) => pipe(fa, mapWithIndex(f))\nconst _ap: Apply1<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\nconst _filter: Filterable1<URI>['filter'] = <A>(fa: ReadonlyArray<A>, predicate: Predicate<A>) =>\n  pipe(fa, filter(predicate))\nconst _filterMap: Filterable1<URI>['filterMap'] = (fa, f) => pipe(fa, filterMap(f))\nconst _partition: Filterable1<URI>['partition'] = <A>(fa: ReadonlyArray<A>, predicate: Predicate<A>) =>\n  pipe(fa, partition(predicate))\nconst _partitionMap: Filterable1<URI>['partitionMap'] = (fa, f) => pipe(fa, partitionMap(f))\nconst _partitionWithIndex: FilterableWithIndex1<URI, number>['partitionWithIndex'] = <A>(\n  fa: ReadonlyArray<A>,\n  predicateWithIndex: (i: number, a: A) => boolean\n) => pipe(fa, partitionWithIndex(predicateWithIndex))\nconst _partitionMapWithIndex: FilterableWithIndex1<URI, number>['partitionMapWithIndex'] = <A, B, C>(\n  fa: ReadonlyArray<A>,\n  f: (i: number, a: A) => Either<B, C>\n) => pipe(fa, partitionMapWithIndex(f))\nconst _alt: Alt1<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\nconst _reduce: Foldable1<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\nconst _foldMap: Foldable1<URI>['foldMap'] = (M) => {\n  const foldMapM = foldMap(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\nconst _reduceRight: Foldable1<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\nconst _reduceWithIndex: FoldableWithIndex1<URI, number>['reduceWithIndex'] = (fa, b, f) =>\n  pipe(fa, reduceWithIndex(b, f))\nconst _foldMapWithIndex: FoldableWithIndex1<URI, number>['foldMapWithIndex'] = (M) => {\n  const foldMapWithIndexM = foldMapWithIndex(M)\n  return (fa, f) => pipe(fa, foldMapWithIndexM(f))\n}\nconst _reduceRightWithIndex: FoldableWithIndex1<URI, number>['reduceRightWithIndex'] = (fa, b, f) =>\n  pipe(fa, reduceRightWithIndex(b, f))\nconst _filterMapWithIndex: FilterableWithIndex1<URI, number>['filterMapWithIndex'] = <A, B>(\n  fa: ReadonlyArray<A>,\n  f: (i: number, a: A) => Option<B>\n) => pipe(fa, filterMapWithIndex(f))\nconst _filterWithIndex: FilterableWithIndex1<URI, number>['filterWithIndex'] = <A>(\n  fa: ReadonlyArray<A>,\n  predicateWithIndex: (i: number, a: A) => boolean\n) => pipe(fa, filterWithIndex(predicateWithIndex))\nconst _extend: Extend1<URI>['extend'] = (fa, f) => pipe(fa, extend(f))\nconst _traverse: Traversable1<URI>['traverse'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: ReadonlyArray<A>, f: (a: A) => HKT<F, B>) => HKT<F, ReadonlyArray<B>>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\n/* istanbul ignore next */\nconst _traverseWithIndex: TraversableWithIndex1<URI, number>['traverseWithIndex'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: ReadonlyArray<A>, f: (i: number, a: A) => HKT<F, B>) => HKT<F, ReadonlyArray<B>>) => {\n  const traverseWithIndexF = traverseWithIndex(F)\n  return (ta, f) => pipe(ta, traverseWithIndexF(f))\n}\n/** @internal */\nexport const _chainRecDepthFirst: ChainRec1<URI>['chainRec'] = (a, f) => pipe(a, chainRecDepthFirst(f))\n/** @internal */\nexport const _chainRecBreadthFirst: ChainRec1<URI>['chainRec'] = (a, f) => pipe(a, chainRecBreadthFirst(f))\n\n/**\n * @category constructors\n * @since 2.5.0\n */\nexport const of: <A>(a: A) => ReadonlyArray<A> = RNEA.of\n\n/**\n * @since 2.7.0\n */\nexport const zero: <A>() => ReadonlyArray<A> = () => empty\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @example\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     RA.altW(() => ['a', 'b'])\n *   ),\n *   [1, 2, 3, 'a', 'b']\n * )\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW =\n  <B>(that: LazyArg<ReadonlyArray<B>>) =>\n  <A>(fa: ReadonlyArray<A>): ReadonlyArray<A | B> =>\n    (fa as ReadonlyArray<A | B>).concat(that())\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * In case of `ReadonlyArray` concatenates the inputs into a single array.\n *\n * @example\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     RA.alt(() => [4, 5])\n *   ),\n *   [1, 2, 3, 4, 5]\n * )\n *\n * @category error handling\n * @since 2.5.0\n */\nexport const alt: <A>(that: LazyArg<ReadonlyArray<A>>) => (fa: ReadonlyArray<A>) => ReadonlyArray<A> = altW\n\n/**\n * @since 2.5.0\n */\nexport const ap: <A>(fa: ReadonlyArray<A>) => <B>(fab: ReadonlyArray<(a: A) => B>) => ReadonlyArray<B> = (fa) =>\n  flatMap((f) => pipe(fa, map(f)))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation.\n *\n * @example\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     RA.flatMap((n) => [`a${n}`, `b${n}`])\n *   ),\n *   ['a1', 'b1', 'a2', 'b2', 'a3', 'b3']\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     RA.flatMap(() => [])\n *   ),\n *   []\n * )\n *\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A, i: number) => ReadonlyArray<B>): (ma: ReadonlyArray<A>) => ReadonlyArray<B>\n  <A, B>(ma: ReadonlyArray<A>, f: (a: A, i: number) => ReadonlyArray<B>): ReadonlyArray<B>\n} = /*#__PURE__*/ dual(\n  2,\n  <A, B>(ma: ReadonlyArray<A>, f: (a: A, i: number) => ReadonlyArray<B>): ReadonlyArray<B> =>\n    pipe(\n      ma,\n      chainWithIndex((i, a) => f(a, i))\n    )\n)\n\n/**\n * @category sequencing\n * @since 2.5.0\n */\nexport const flatten: <A>(mma: ReadonlyArray<ReadonlyArray<A>>) => ReadonlyArray<A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.5.0\n */\nexport const map: <A, B>(f: (a: A) => B) => (fa: ReadonlyArray<A>) => ReadonlyArray<B> = (f) => (fa) =>\n  fa.map((a) => f(a))\n\n/**\n * @category mapping\n * @since 2.5.0\n */\nexport const mapWithIndex: <A, B>(f: (i: number, a: A) => B) => (fa: ReadonlyArray<A>) => ReadonlyArray<B> =\n  (f) => (fa) =>\n    fa.map((a, i) => f(i, a))\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const separate = <A, B>(fa: ReadonlyArray<Either<A, B>>): Separated<ReadonlyArray<A>, ReadonlyArray<B>> => {\n  const left: Array<A> = []\n  const right: Array<B> = []\n  for (const e of fa) {\n    if (e._tag === 'Left') {\n      left.push(e.left)\n    } else {\n      right.push(e.right)\n    }\n  }\n  return separated(left, right)\n}\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (as: ReadonlyArray<A>) => ReadonlyArray<B>\n  <A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => ReadonlyArray<B>\n  <A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => ReadonlyArray<A>\n} =\n  <A>(predicate: Predicate<A>) =>\n  <B extends A>(as: ReadonlyArray<B>) =>\n    as.filter(predicate)\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const filterMapWithIndex =\n  <A, B>(f: (i: number, a: A) => Option<B>) =>\n  (fa: ReadonlyArray<A>): ReadonlyArray<B> => {\n    const out: Array<B> = []\n    for (let i = 0; i < fa.length; i++) {\n      const optionB = f(i, fa[i])\n      if (_.isSome(optionB)) {\n        out.push(optionB.value)\n      }\n    }\n    return out\n  }\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: ReadonlyArray<A>) => ReadonlyArray<B> = (f) =>\n  filterMapWithIndex((_, a) => f(a))\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const compact: <A>(fa: ReadonlyArray<Option<A>>) => ReadonlyArray<A> = /*#__PURE__*/ filterMap(identity)\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    as: ReadonlyArray<A>\n  ) => Separated<ReadonlyArray<A>, ReadonlyArray<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(bs: ReadonlyArray<B>) => Separated<ReadonlyArray<B>, ReadonlyArray<B>>\n  <A>(predicate: Predicate<A>): (as: ReadonlyArray<A>) => Separated<ReadonlyArray<A>, ReadonlyArray<A>>\n} = <A>(predicate: Predicate<A>): ((as: ReadonlyArray<A>) => Separated<ReadonlyArray<A>, ReadonlyArray<A>>) =>\n  partitionWithIndex((_, a) => predicate(a))\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const partitionWithIndex: {\n  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (\n    as: ReadonlyArray<A>\n  ) => Separated<ReadonlyArray<A>, ReadonlyArray<B>>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(\n    bs: ReadonlyArray<B>\n  ) => Separated<ReadonlyArray<B>, ReadonlyArray<B>>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (\n    as: ReadonlyArray<A>\n  ) => Separated<ReadonlyArray<A>, ReadonlyArray<A>>\n} =\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>) =>\n  (as: ReadonlyArray<A>): Separated<ReadonlyArray<A>, ReadonlyArray<A>> => {\n    const left: Array<A> = []\n    const right: Array<A> = []\n    for (let i = 0; i < as.length; i++) {\n      const a = as[i]\n      if (predicateWithIndex(i, a)) {\n        right.push(a)\n      } else {\n        left.push(a)\n      }\n    }\n    return separated(left, right)\n  }\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: ReadonlyArray<A>) => Separated<ReadonlyArray<B>, ReadonlyArray<C>> = (f) =>\n  partitionMapWithIndex((_, a) => f(a))\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const partitionMapWithIndex =\n  <A, B, C>(f: (i: number, a: A) => Either<B, C>) =>\n  (fa: ReadonlyArray<A>): Separated<ReadonlyArray<B>, ReadonlyArray<C>> => {\n    const left: Array<B> = []\n    const right: Array<C> = []\n    for (let i = 0; i < fa.length; i++) {\n      const e = f(i, fa[i])\n      if (e._tag === 'Left') {\n        left.push(e.left)\n      } else {\n        right.push(e.right)\n      }\n    }\n    return separated(left, right)\n  }\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const filterWithIndex: {\n  <A, B extends A>(refinementWithIndex: RefinementWithIndex<number, A, B>): (as: ReadonlyArray<A>) => ReadonlyArray<B>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): <B extends A>(bs: ReadonlyArray<B>) => ReadonlyArray<B>\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>): (as: ReadonlyArray<A>) => ReadonlyArray<A>\n} =\n  <A>(predicateWithIndex: PredicateWithIndex<number, A>) =>\n  (as: ReadonlyArray<A>): ReadonlyArray<A> =>\n    as.filter((a, i) => predicateWithIndex(i, a))\n\n/**\n * @since 2.5.0\n */\nexport const extend: <A, B>(f: (fa: ReadonlyArray<A>) => B) => (wa: ReadonlyArray<A>) => ReadonlyArray<B> =\n  (f) => (wa) =>\n    wa.map((_, i) => f(wa.slice(i)))\n\n/**\n * @since 2.5.0\n */\nexport const duplicate: <A>(wa: ReadonlyArray<A>) => ReadonlyArray<ReadonlyArray<A>> = /*#__PURE__*/ extend(identity)\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const foldMapWithIndex =\n  <M>(M: Monoid<M>) =>\n  <A>(f: (i: number, a: A) => M) =>\n  (fa: ReadonlyArray<A>): M =>\n    fa.reduce((b, a, i) => M.concat(b, f(i, a)), M.empty)\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: ReadonlyArray<A>) => B = (b, f) =>\n  reduceWithIndex(b, (_, b, a) => f(b, a))\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: ReadonlyArray<A>) => M = (M) => {\n  const foldMapWithIndexM = foldMapWithIndex(M)\n  return (f) => foldMapWithIndexM((_, a) => f(a))\n}\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduceWithIndex: <A, B>(b: B, f: (i: number, b: B, a: A) => B) => (fa: ReadonlyArray<A>) => B =\n  (b, f) => (fa) => {\n    const len = fa.length\n    let out = b\n    for (let i = 0; i < len; i++) {\n      out = f(i, out, fa[i])\n    }\n    return out\n  }\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: ReadonlyArray<A>) => B = (b, f) =>\n  reduceRightWithIndex(b, (_, a, b) => f(a, b))\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduceRightWithIndex: <A, B>(b: B, f: (i: number, a: A, b: B) => B) => (fa: ReadonlyArray<A>) => B =\n  (b, f) => (fa) =>\n    fa.reduceRight((b, a, i) => f(i, a, b), b)\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(f: (a: A) => HKT<F, B>) => (ta: ReadonlyArray<A>) => HKT<F, ReadonlyArray<B>>) => {\n  const traverseWithIndexF = traverseWithIndex(F)\n  return (f) => traverseWithIndexF((_, a) => f(a))\n}\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable1<URI>['sequence'] =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A>(ta: ReadonlyArray<HKT<F, A>>): HKT<F, ReadonlyArray<A>> => {\n    return _reduce(ta, F.of(zero()), (fas, fa) =>\n      F.ap(\n        F.map(fas, (as) => (a: A) => pipe(as, append(a))),\n        fa\n      )\n    )\n  }\n\n/**\n * @category sequencing\n * @since 2.6.3\n */\nexport const traverseWithIndex: PipeableTraverseWithIndex1<URI, number> =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A, B>(f: (i: number, a: A) => HKT<F, B>): ((ta: ReadonlyArray<A>) => HKT<F, ReadonlyArray<B>>) =>\n    reduceWithIndex(F.of(zero()), (i, fbs, a) =>\n      F.ap(\n        F.map(fbs, (bs) => (b: B) => pipe(bs, append(b))),\n        f(i, a)\n      )\n    )\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wither: PipeableWither1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(f: (a: A) => HKT<F, Option<B>>) => (fa: ReadonlyArray<A>) => HKT<F, ReadonlyArray<B>>) => {\n  const _witherF = _wither(F)\n  return (f) => (fa) => _witherF(fa, f)\n}\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wilt: PipeableWilt1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B, C>(\n  f: (a: A) => HKT<F, Either<B, C>>\n) => (fa: ReadonlyArray<A>) => HKT<F, Separated<ReadonlyArray<B>, ReadonlyArray<C>>>) => {\n  const _wiltF = _wilt(F)\n  return (f) => (fa) => _wiltF(fa, f)\n}\n\n/**\n * @since 2.6.6\n */\nexport const unfold = <A, B>(b: B, f: (b: B) => Option<readonly [A, B]>): ReadonlyArray<A> => {\n  const out: Array<A> = []\n  let bb: B = b\n  // eslint-disable-next-line no-constant-condition\n  while (true) {\n    const mt = f(bb)\n    if (_.isSome(mt)) {\n      const [a, b] = mt.value\n      out.push(a)\n      bb = b\n    } else {\n      break\n    }\n  }\n  return out\n}\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport const URI = 'ReadonlyArray'\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: ReadonlyArray<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport const getShow = <A>(S: Show<A>): Show<ReadonlyArray<A>> => ({\n  show: (as) => `[${as.map(S.show).join(', ')}]`\n})\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport const getSemigroup = <A = never>(): Semigroup<ReadonlyArray<A>> => ({\n  concat: (first, second) => (isEmpty(first) ? second : isEmpty(second) ? first : first.concat(second))\n})\n\n/**\n * Returns a `Monoid` for `ReadonlyArray<A>`.\n *\n * @example\n * import { getMonoid } from 'fp-ts/ReadonlyArray'\n *\n * const M = getMonoid<number>()\n * assert.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4])\n *\n * @category instances\n * @since 2.5.0\n */\nexport const getMonoid = <A = never>(): Monoid<ReadonlyArray<A>> => ({\n  concat: getSemigroup<A>().concat,\n  empty\n})\n\n/**\n * Derives an `Eq` over the `ReadonlyArray` of a given element type from the `Eq` of that type. The derived `Eq` defines two\n * arrays as equal if all elements of both arrays are compared equal pairwise with the given `E`. In case of arrays of\n * different lengths, the result is non equality.\n *\n * @example\n * import * as S from 'fp-ts/string'\n * import { getEq } from 'fp-ts/ReadonlyArray'\n *\n * const E = getEq(S.Eq)\n * assert.strictEqual(E.equals(['a', 'b'], ['a', 'b']), true)\n * assert.strictEqual(E.equals(['a'], []), false)\n *\n * @category instances\n * @since 2.5.0\n */\nexport const getEq = <A>(E: Eq<A>): Eq<ReadonlyArray<A>> =>\n  fromEquals((xs, ys) => xs.length === ys.length && xs.every((x, i) => E.equals(x, ys[i])))\n\n/**\n * Derives an `Ord` over the `ReadonlyArray` of a given element type from the `Ord` of that type. The ordering between two such\n * arrays is equal to: the first non equal comparison of each arrays elements taken pairwise in increasing order, in\n * case of equality over all the pairwise elements; the longest array is considered the greatest, if both arrays have\n * the same length, the result is equality.\n *\n * @example\n * import { getOrd } from 'fp-ts/ReadonlyArray'\n * import * as S from 'fp-ts/string'\n *\n * const O = getOrd(S.Ord)\n * assert.strictEqual(O.compare(['b'], ['a']), 1)\n * assert.strictEqual(O.compare(['a'], ['a']), 0)\n * assert.strictEqual(O.compare(['a'], ['b']), -1)\n *\n *\n * @category instances\n * @since 2.5.0\n */\nexport const getOrd = <A>(O: Ord<A>): Ord<ReadonlyArray<A>> =>\n  fromCompare((a, b) => {\n    const aLen = a.length\n    const bLen = b.length\n    const len = Math.min(aLen, bLen)\n    for (let i = 0; i < len; i++) {\n      const ordering = O.compare(a[i], b[i])\n      if (ordering !== 0) {\n        return ordering\n      }\n    }\n    return N.Ord.compare(aLen, bLen)\n  })\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <A>(E: Eq<A>): Semigroup<ReadonlyArray<A>> => {\n  const unionE = union(E)\n  return {\n    concat: (first, second) => unionE(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionMonoid = <A>(E: Eq<A>): Monoid<ReadonlyArray<A>> => ({\n  concat: getUnionSemigroup(E).concat,\n  empty\n})\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getIntersectionSemigroup = <A>(E: Eq<A>): Semigroup<ReadonlyArray<A>> => {\n  const intersectionE = intersection(E)\n  return {\n    concat: (first, second) => intersectionE(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getDifferenceMagma = <A>(E: Eq<A>): Magma<ReadonlyArray<A>> => {\n  const differenceE = difference(E)\n  return {\n    concat: (first, second) => differenceE(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FunctorWithIndex: FunctorWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.5.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.5.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     RA.chainFirst(() => ['a', 'b'])\n *   ),\n *   [1, 1, 2, 2, 3, 3]\n * )\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     RA.chainFirst(() => [])\n *   ),\n *   []\n * )\n *\n * @category sequencing\n * @since 2.5.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => ReadonlyArray<B>) => (first: ReadonlyArray<A>) => ReadonlyArray<A> =\n  /*#__PURE__*/ chainFirst_(Chain)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Unfoldable: Unfoldable1<URI> = {\n  URI,\n  unfold\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt1<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const Zero: Zero1<URI> = {\n  URI,\n  zero\n}\n\n/**\n * @category do notation\n * @since 2.11.0\n */\nexport const guard = /*#__PURE__*/ guard_(Zero, Pointed)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alternative: Alternative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  alt: _alt,\n  zero\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Extend: Extend1<URI> = {\n  URI,\n  map: _map,\n  extend: _extend\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Compactable: Compactable1<URI> = {\n  URI,\n  compact,\n  separate\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Filterable: Filterable1<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FilterableWithIndex: FilterableWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  partitionMapWithIndex: _partitionMapWithIndex,\n  partitionWithIndex: _partitionWithIndex,\n  filterMapWithIndex: _filterMapWithIndex,\n  filterWithIndex: _filterWithIndex\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable1<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FoldableWithIndex: FoldableWithIndex1<URI, number> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable1<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const TraversableWithIndex: TraversableWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex,\n  traverse: _traverse,\n  sequence,\n  traverseWithIndex: _traverseWithIndex\n}\n\n/**\n * @category sequencing\n * @since 2.11.0\n */\nexport const chainRecDepthFirst =\n  <A, B>(f: (a: A) => ReadonlyArray<Either<A, B>>) =>\n  (a: A): ReadonlyArray<B> => {\n    const todo: Array<Either<A, B>> = [...f(a)]\n    const out: Array<B> = []\n\n    while (todo.length > 0) {\n      const e = todo.shift()!\n      if (_.isLeft(e)) {\n        todo.unshift(...f(e.left))\n      } else {\n        out.push(e.right)\n      }\n    }\n\n    return out\n  }\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const ChainRecDepthFirst: ChainRec1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap,\n  chainRec: _chainRecDepthFirst\n}\n\n/**\n * @category sequencing\n * @since 2.11.0\n */\nexport const chainRecBreadthFirst =\n  <A, B>(f: (a: A) => ReadonlyArray<Either<A, B>>) =>\n  (a: A): ReadonlyArray<B> => {\n    const initial = f(a)\n    const todo: Array<Either<A, B>> = []\n    const out: Array<B> = []\n\n    function go(e: Either<A, B>): void {\n      if (_.isLeft(e)) {\n        f(e.left).forEach((v) => todo.push(v))\n      } else {\n        out.push(e.right)\n      }\n    }\n\n    for (const e of initial) {\n      go(e)\n    }\n\n    while (todo.length > 0) {\n      go(todo.shift()!)\n    }\n\n    return out\n  }\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const ChainRecBreadthFirst: ChainRec1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap,\n  chainRec: _chainRecBreadthFirst\n}\n\nconst _wither: Witherable1<URI>['wither'] = /*#__PURE__*/ witherDefault(Traversable, Compactable)\nconst _wilt: Witherable1<URI>['wilt'] = /*#__PURE__*/ wiltDefault(Traversable, Compactable)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Witherable: Witherable1<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  wither: _wither,\n  wilt: _wilt\n}\n\n/**\n * Filter values inside a context.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import * as T from 'fp-ts/Task'\n *\n * const filterE = RA.filterE(T.ApplicativePar)\n * async function test() {\n *   assert.deepStrictEqual(\n *     await pipe(\n *       [-1, 2, 3],\n *       filterE((n) => T.of(n > 0))\n *     )(),\n *     [2, 3]\n *   )\n * }\n * test()\n *\n * @since 2.11.0\n */\nexport const filterE = /*#__PURE__*/ filterE_(Witherable)\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromEither: FromEither1<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => ReadonlyArray<B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n// -------------------------------------------------------------------------------------\n// unsafe\n// -------------------------------------------------------------------------------------\n\n/**\n * @category unsafe\n * @since 2.5.0\n */\nexport const unsafeInsertAt: <A>(i: number, a: A, as: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A> =\n  RNEA.unsafeInsertAt\n\n/**\n * @category unsafe\n * @since 2.5.0\n */\nexport const unsafeUpdateAt = <A>(i: number, a: A, as: ReadonlyArray<A>): ReadonlyArray<A> =>\n  isNonEmpty(as) ? RNEA.unsafeUpdateAt(i, a, as) : as\n\n/**\n * @category unsafe\n * @since 2.5.0\n */\nexport const unsafeDeleteAt = <A>(i: number, as: ReadonlyArray<A>): ReadonlyArray<A> => {\n  const xs = as.slice()\n  xs.splice(i, 1)\n  return xs\n}\n\n/**\n * @category conversions\n * @since 2.5.0\n */\nexport const toArray = <A>(as: ReadonlyArray<A>): Array<A> => as.slice()\n\n/**\n * @category conversions\n * @since 2.5.0\n */\nexport const fromArray = <A>(as: Array<A>): ReadonlyArray<A> => (isEmpty(as) ? empty : as.slice())\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * An empty array\n *\n * @since 2.5.0\n */\nexport const empty: ReadonlyArray<never> = RNEA.empty\n\n/**\n * Check if a predicate holds true for every array member.\n *\n * @example\n * import { every } from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * const isPositive = (n: number): boolean => n > 0\n *\n * assert.deepStrictEqual(pipe([1, 2, 3], every(isPositive)), true)\n * assert.deepStrictEqual(pipe([1, 2, -3], every(isPositive)), false)\n *\n * @since 2.9.0\n */\nexport function every<A, B extends A>(refinement: Refinement<A, B>): 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 (as) => as.every(predicate)\n}\n\n/**\n * Check if a predicate holds true for any array member.\n *\n * @example\n * import { some } from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * const isPositive = (n: number): boolean => n > 0\n *\n * assert.deepStrictEqual(pipe([-1, -2, 3], some(isPositive)), true)\n * assert.deepStrictEqual(pipe([-1, -2, -3], some(isPositive)), false)\n *\n * @since 2.9.0\n */\nexport const some =\n  <A>(predicate: Predicate<A>) =>\n  (as: ReadonlyArray<A>): as is ReadonlyNonEmptyArray<A> =>\n    as.some(predicate)\n\n/**\n * Alias of [`some`](#some)\n *\n * @since 2.11.0\n */\nexport const exists: <A>(predicate: Predicate<A>) => (as: ReadonlyArray<A>) => as is RNEA.ReadonlyNonEmptyArray<A> =\n  some\n\n/**\n * Places an element in between members of a `ReadonlyArray`, then folds the results using the provided `Monoid`.\n *\n * @example\n * import * as S from 'fp-ts/string'\n * import { intercalate } from 'fp-ts/ReadonlyArray'\n *\n * assert.deepStrictEqual(intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c')\n *\n * @since 2.12.0\n */\nexport const intercalate = <A>(M: Monoid<A>): ((middle: A) => (as: ReadonlyArray<A>) => A) => {\n  const intercalateM = RNEA.intercalate(M)\n  return (middle) => match(() => M.empty, intercalateM(middle))\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: ReadonlyArray<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ bind_(Chain)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.5.0\n */\nexport const chain: <A, B>(f: (a: A) => ReadonlyArray<B>) => (ma: ReadonlyArray<A>) => ReadonlyArray<B> = flatMap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use `ReadonlyNonEmptyArray` module instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const range = RNEA.range\n\n/**\n * Use [`prepend`](#prepend) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const cons = RNEA.cons\n\n/**\n * Use [`append`](#append) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const snoc = RNEA.snoc\n\n/**\n * Use [`prependAll`](#prependall) instead.\n *\n * @category zone of death\n * @since 2.9.0\n * @deprecated\n */\nexport const prependToAll = prependAll\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RA.Functor` instead of `RA.readonlyArray`\n * (where `RA` is from `import RA from 'fp-ts/ReadonlyArray'`)\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const readonlyArray: FunctorWithIndex1<URI, number> &\n  Monad1<URI> &\n  Unfoldable1<URI> &\n  Alternative1<URI> &\n  Extend1<URI> &\n  FilterableWithIndex1<URI, number> &\n  FoldableWithIndex1<URI, number> &\n  TraversableWithIndex1<URI, number> &\n  Witherable1<URI> = {\n  URI,\n  compact,\n  separate,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  mapWithIndex: _mapWithIndex,\n  partitionMapWithIndex: _partitionMapWithIndex,\n  partitionWithIndex: _partitionWithIndex,\n  filterMapWithIndex: _filterMapWithIndex,\n  filterWithIndex: _filterWithIndex,\n  alt: _alt,\n  zero,\n  unfold,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex,\n  traverseWithIndex: _traverseWithIndex,\n  extend: _extend,\n  wither: _wither,\n  wilt: _wilt\n}\n"
  },
  {
    "path": "src/ReadonlyMap.ts",
    "content": "/**\n * @since 2.5.0\n */\nimport { Applicative } from './Applicative'\nimport { Compactable2 } from './Compactable'\nimport { Either } from './Either'\nimport { Eq, fromEquals } from './Eq'\nimport { Filterable2 } from './Filterable'\nimport { FilterableWithIndex2C } from './FilterableWithIndex'\nimport { Foldable, Foldable1, Foldable2, Foldable2C, Foldable3 } from './Foldable'\nimport { FoldableWithIndex2C } from './FoldableWithIndex'\nimport { pipe, SK } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\nimport { FunctorWithIndex2C } from './FunctorWithIndex'\nimport { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'\nimport * as _ from './internal'\nimport { Magma } from './Magma'\nimport { Monoid } from './Monoid'\nimport * as O from './Option'\nimport { Ord } from './Ord'\nimport { Predicate } from './Predicate'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport { Separated, separated } from './Separated'\nimport { Show } from './Show'\nimport { Traversable2C } from './Traversable'\nimport { TraversableWithIndex2C } from './TraversableWithIndex'\nimport { Unfoldable, Unfoldable1 } from './Unfoldable'\nimport { wiltDefault, Witherable2C, witherDefault } from './Witherable'\n\nimport Option = O.Option\n\n/**\n * @category conversions\n * @since 2.5.0\n */\nexport const fromMap = <K, A>(m: Map<K, A>): ReadonlyMap<K, A> => new Map(m)\n\n/**\n * @category conversions\n * @since 2.5.0\n */\nexport function toMap<K, A>(m: ReadonlyMap<K, A>): Map<K, A> {\n  return new Map(m)\n}\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport function getShow<K, A>(SK: Show<K>, SA: Show<A>): Show<ReadonlyMap<K, A>> {\n  return {\n    show: (m) => {\n      const entries: Array<string> = []\n      m.forEach((a, k) => {\n        entries.push(`[${SK.show(k)}, ${SA.show(a)}]`)\n      })\n      return `new Map([${entries.sort().join(', ')}])`\n    }\n  }\n}\n\n/**\n * Calculate the number of key/value pairs in a map\n *\n * @since 2.5.0\n */\nexport const size = <K, A>(m: ReadonlyMap<K, A>): number => m.size\n\n/**\n * Test whether or not a map is empty\n *\n * @since 2.5.0\n */\nexport const isEmpty = <K, A>(m: ReadonlyMap<K, A>): boolean => m.size === 0\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test whether or not a key exists in a map\n *\n * @since 2.5.0\n */\nexport function member<K>(E: Eq<K>): {\n  (k: K): <A>(m: ReadonlyMap<K, A>) => boolean\n  <A>(k: K, m: ReadonlyMap<K, A>): boolean\n}\nexport function member<K>(E: Eq<K>): <A>(k: K, m?: ReadonlyMap<K, A>) => boolean | ((m: ReadonlyMap<K, A>) => boolean) {\n  const lookupE = lookup(E)\n  return (k, m?) => {\n    if (m === undefined) {\n      const memberE = member(E)\n      return (m) => memberE(k, m)\n    }\n    return _.isSome(lookupE(k, m))\n  }\n}\n\ntype Next<A> = IteratorResult<A, undefined>\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test whether or not a value is a member of a map\n *\n * @since 2.5.0\n */\nexport function elem<A>(E: Eq<A>): {\n  (a: A): <K>(m: ReadonlyMap<K, A>) => boolean\n  <K>(a: A, m: ReadonlyMap<K, A>): boolean\n}\nexport function elem<A>(E: Eq<A>): <K>(a: A, m?: ReadonlyMap<K, A>) => boolean | ((m: ReadonlyMap<K, A>) => boolean) {\n  return (a, m?) => {\n    if (m === undefined) {\n      const elemE = elem(E)\n      return (m) => elemE(a, m)\n    }\n    const values = m.values()\n    let e: Next<A>\n    while (!(e = values.next()).done) {\n      const v = e.value\n      if (E.equals(a, v)) {\n        return true\n      }\n    }\n    return false\n  }\n}\n\n/**\n * Get a sorted `ReadonlyArray` of the keys contained in a `ReadonlyMap`.\n *\n * @since 2.5.0\n */\nexport const keys =\n  <K>(O: Ord<K>) =>\n  <A>(m: ReadonlyMap<K, A>): ReadonlyArray<K> =>\n    Array.from(m.keys()).sort(O.compare)\n\n/**\n * Get a sorted `ReadonlyArray` of the values contained in a `ReadonlyMap`.\n *\n * @since 2.5.0\n */\nexport const values =\n  <A>(O: Ord<A>) =>\n  <K>(m: ReadonlyMap<K, A>): ReadonlyArray<A> =>\n    Array.from(m.values()).sort(O.compare)\n\n/**\n * @since 2.5.0\n */\nexport function collect<K>(O: Ord<K>): <A, B>(f: (k: K, a: A) => B) => (m: ReadonlyMap<K, A>) => ReadonlyArray<B> {\n  const keysO = keys(O)\n  return <A, B>(f: (k: K, a: A) => B) =>\n    (m: ReadonlyMap<K, A>): ReadonlyArray<B> => {\n      const out: Array<B> = []\n      const ks = keysO(m)\n      for (const key of ks) {\n        out.push(f(key, m.get(key)!))\n      }\n      return out\n    }\n}\n\n/**\n * Get a sorted `ReadonlyArray` of the key/value pairs contained in a `ReadonlyMap`.\n *\n * @category conversions\n * @since 2.5.0\n */\nexport const toReadonlyArray = <K>(O: Ord<K>): (<A>(m: ReadonlyMap<K, A>) => ReadonlyArray<readonly [K, A]>) =>\n  collect(O)((k, a) => [k, a] as const)\n\n/**\n * Unfolds a map into a list of key/value pairs\n *\n * @category conversions\n * @since 2.5.0\n */\nexport function toUnfoldable<K, F extends URIS>(\n  ord: Ord<K>,\n  U: Unfoldable1<F>\n): <A>(d: ReadonlyMap<K, A>) => Kind<F, readonly [K, A]>\nexport function toUnfoldable<K, F>(ord: Ord<K>, U: Unfoldable<F>): <A>(d: ReadonlyMap<K, A>) => HKT<F, readonly [K, A]>\nexport function toUnfoldable<K, F>(\n  ord: Ord<K>,\n  U: Unfoldable<F>\n): <A>(d: ReadonlyMap<K, A>) => HKT<F, readonly [K, A]> {\n  const toReadonlyArrayO = toReadonlyArray(ord)\n  return (d) => {\n    const kas = toReadonlyArrayO(d)\n    const len = kas.length\n    return U.unfold(0, (b) => (b < len ? _.some([kas[b], b + 1]) : _.none))\n  }\n}\n\n/**\n * Insert or replace a key/value pair in a `ReadonlyMap`.\n *\n * @since 2.10.0\n */\nexport const upsertAt = <K>(E: Eq<K>): (<A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>) => {\n  const lookupWithKeyE = lookupWithKey(E)\n  return (k, a) => {\n    const lookupWithKeyEk = lookupWithKeyE(k)\n    return (m) => {\n      const found = lookupWithKeyEk(m)\n      if (_.isNone(found)) {\n        const out = new Map(m)\n        out.set(k, a)\n        return out\n      } else if (found.value[1] !== a) {\n        const out = new Map(m)\n        out.set(found.value[0], a)\n        return out\n      }\n      return m\n    }\n  }\n}\n\n/**\n * Delete a key and value from a map\n *\n * @since 2.5.0\n */\nexport const deleteAt = <K>(E: Eq<K>): ((k: K) => <A>(m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>) => {\n  const lookupWithKeyE = lookupWithKey(E)\n  return (k) => (m) => {\n    const found = lookupWithKeyE(k, m)\n    if (_.isSome(found)) {\n      const r = new Map(m)\n      r.delete(found.value[0])\n      return r\n    }\n    return m\n  }\n}\n\n/**\n * @since 2.5.0\n */\nexport const updateAt = <K>(E: Eq<K>): (<A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => Option<ReadonlyMap<K, A>>) => {\n  const modifyAtE = modifyAt(E)\n  return (k, a) => modifyAtE(k, () => a)\n}\n\n/**\n * @since 2.5.0\n */\nexport const modifyAt = <K>(\n  E: Eq<K>\n): (<A>(k: K, f: (a: A) => A) => (m: ReadonlyMap<K, A>) => Option<ReadonlyMap<K, A>>) => {\n  const lookupWithKeyE = lookupWithKey(E)\n  return (k, f) => (m) => {\n    const found = lookupWithKeyE(k, m)\n    if (_.isNone(found)) {\n      return _.none\n    }\n    const [fk, fv] = found.value\n    const next = f(fv)\n    if (next === fv) {\n      return _.some(m)\n    }\n    const r = new Map(m)\n    r.set(fk, next)\n    return _.some(r)\n  }\n}\n\n/**\n * Delete a key and value from a map, returning the value as well as the subsequent map\n *\n * @since 2.5.0\n */\nexport function pop<K>(E: Eq<K>): (k: K) => <A>(m: ReadonlyMap<K, A>) => Option<readonly [A, ReadonlyMap<K, A>]> {\n  const lookupE = lookup(E)\n  const deleteAtE = deleteAt(E)\n  return (k) => {\n    const deleteAtEk = deleteAtE(k)\n    return (m) =>\n      pipe(\n        lookupE(k, m),\n        O.map((a) => [a, deleteAtEk(m)])\n      )\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Lookup the value for a key in a `Map`.\n * If the result is a `Some`, the existing key is also returned.\n *\n * @since 2.5.0\n */\nexport function lookupWithKey<K>(E: Eq<K>): {\n  (k: K): <A>(m: ReadonlyMap<K, A>) => Option<readonly [K, A]>\n  <A>(k: K, m: ReadonlyMap<K, A>): Option<readonly [K, A]>\n}\nexport function lookupWithKey<K>(\n  E: Eq<K>\n): <A>(k: K, m?: ReadonlyMap<K, A>) => Option<readonly [K, A]> | ((m: ReadonlyMap<K, A>) => Option<readonly [K, A]>) {\n  return <A>(k: K, m?: ReadonlyMap<K, A>) => {\n    if (m === undefined) {\n      const lookupWithKeyE = lookupWithKey(E)\n      return (m) => lookupWithKeyE(k, m)\n    }\n    const entries = m.entries()\n    let e: Next<readonly [K, A]>\n    while (!(e = entries.next()).done) {\n      const [ka, a] = e.value\n      if (E.equals(ka, k)) {\n        return _.some([ka, a])\n      }\n    }\n    return _.none\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Lookup the value for a key in a `Map`.\n *\n * @since 2.5.0\n */\nexport function lookup<K>(E: Eq<K>): {\n  (k: K): <A>(m: ReadonlyMap<K, A>) => Option<A>\n  <A>(k: K, m: ReadonlyMap<K, A>): Option<A>\n}\nexport function lookup<K>(\n  E: Eq<K>\n): <A>(k: K, m?: ReadonlyMap<K, A>) => Option<A> | ((m: ReadonlyMap<K, A>) => Option<A>) {\n  const lookupWithKeyE = lookupWithKey(E)\n  return (k, m?) => {\n    if (m === undefined) {\n      const lookupE = lookup(E)\n      return (m) => lookupE(k, m)\n    }\n    return pipe(\n      lookupWithKeyE(k, m),\n      O.map(([_, a]) => a)\n    )\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test whether or not one `Map` contains all of the keys and values contained in another `Map`\n *\n * @since 2.5.0\n */\nexport function isSubmap<K, A>(\n  SK: Eq<K>,\n  SA: Eq<A>\n): {\n  (that: ReadonlyMap<K, A>): (me: ReadonlyMap<K, A>) => boolean\n  (me: ReadonlyMap<K, A>, that: ReadonlyMap<K, A>): boolean\n}\nexport function isSubmap<K, A>(\n  SK: Eq<K>,\n  SA: Eq<A>\n): (me: ReadonlyMap<K, A>, that?: ReadonlyMap<K, A>) => boolean | ((me: ReadonlyMap<K, A>) => boolean) {\n  const lookupWithKeyS = lookupWithKey(SK)\n  return (me: ReadonlyMap<K, A>, that?: ReadonlyMap<K, A>) => {\n    if (that === undefined) {\n      const isSubmapSKSA = isSubmap(SK, SA)\n      return (that) => isSubmapSKSA(that, me)\n    }\n    const entries = me.entries()\n    let e: Next<readonly [K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      const d2OptA = lookupWithKeyS(k, that)\n      if (_.isNone(d2OptA) || !SK.equals(k, d2OptA.value[0]) || !SA.equals(a, d2OptA.value[1])) {\n        return false\n      }\n    }\n    return true\n  }\n}\n\n/**\n * @since 2.5.0\n */\nexport const empty: ReadonlyMap<never, never> =\n  // the type annotation here is intended (otherwise it doesn't type-check)\n  new Map<never, never>()\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport function getEq<K, A>(SK: Eq<K>, SA: Eq<A>): Eq<ReadonlyMap<K, A>> {\n  const isSubmapSKSA = isSubmap(SK, SA)\n  return fromEquals((x, y) => isSubmapSKSA(x, y) && isSubmapSKSA(y, x))\n}\n\n/**\n * Gets `Monoid` instance for Maps given `Semigroup` instance for their values\n *\n * @category instances\n * @since 2.5.0\n */\nexport function getMonoid<K, A>(SK: Eq<K>, SA: Semigroup<A>): Monoid<ReadonlyMap<K, A>> {\n  const lookupWithKeyS = lookupWithKey(SK)\n  return {\n    concat: (mx, my) => {\n      if (isEmpty(mx)) {\n        return my\n      }\n      if (isEmpty(my)) {\n        return mx\n      }\n      const r = new Map(mx)\n      const entries = my.entries()\n      let e: Next<readonly [K, A]>\n      while (!(e = entries.next()).done) {\n        const [k, a] = e.value\n        const mxOptA = lookupWithKeyS(k, mx)\n        if (_.isSome(mxOptA)) {\n          r.set(mxOptA.value[0], SA.concat(mxOptA.value[1], a))\n        } else {\n          r.set(k, a)\n        }\n      }\n      return r\n    },\n    empty\n  }\n}\n\n/**\n * Create a map with one key/value pair\n *\n * @category constructors\n * @since 2.5.0\n */\nexport const singleton = <K, A>(k: K, a: A): ReadonlyMap<K, A> => new Map([[k, a]])\n\n/**\n * Create a map from a foldable collection of key/value pairs, using the\n * specified `Magma` to combine values for duplicate keys.\n *\n * @category constructors\n * @since 2.5.0\n */\nexport function fromFoldable<F extends URIS3, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable3<F>\n): <R, E>(fka: Kind3<F, R, E, readonly [K, A]>) => ReadonlyMap<K, A>\nexport function fromFoldable<F extends URIS2, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable2<F>\n): <E>(fka: Kind2<F, E, readonly [K, A]>) => ReadonlyMap<K, A>\nexport function fromFoldable<F extends URIS, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable1<F>\n): (fka: Kind<F, readonly [K, A]>) => ReadonlyMap<K, A>\nexport function fromFoldable<F, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable<F>\n): (fka: HKT<F, readonly [K, A]>) => ReadonlyMap<K, A>\nexport function fromFoldable<F, K, A>(\n  E: Eq<K>,\n  M: Magma<A>,\n  F: Foldable<F>\n): (fka: HKT<F, readonly [K, A]>) => ReadonlyMap<K, A> {\n  return (fka: HKT<F, readonly [K, A]>) => {\n    const lookupWithKeyE = lookupWithKey(E)\n    return F.reduce<readonly [K, A], Map<K, A>>(fka, new Map<K, A>(), (b, [k, a]) => {\n      const bOpt = lookupWithKeyE(k, b)\n      if (_.isSome(bOpt)) {\n        b.set(bOpt.value[0], M.concat(bOpt.value[1], a))\n      } else {\n        b.set(k, a)\n      }\n      return b\n    })\n  }\n}\n\nconst _mapWithIndex = <K, A, B>(fa: ReadonlyMap<K, A>, f: (k: K, a: A) => B): ReadonlyMap<K, B> => {\n  const m = new Map<K, B>()\n  const entries = fa.entries()\n  let e: Next<readonly [K, A]>\n  while (!(e = entries.next()).done) {\n    const [key, a] = e.value\n    m.set(key, f(key, a))\n  }\n  return m\n}\n\n/**\n * @since 2.10.0\n */\nexport const partitionMapWithIndex =\n  <K, A, B, C>(f: (k: K, a: A) => Either<B, C>) =>\n  (fa: ReadonlyMap<K, A>): Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>> => {\n    const left = new Map<K, B>()\n    const right = new Map<K, C>()\n    const entries = fa.entries()\n    let e: Next<readonly [K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      const ei = f(k, a)\n      if (_.isLeft(ei)) {\n        left.set(k, ei.left)\n      } else {\n        right.set(k, ei.right)\n      }\n    }\n    return separated(left, right)\n  }\n\n/**\n * @since 2.10.0\n */\nexport function partitionWithIndex<K, A, B extends A>(\n  predicateWithIndex: (k: K, a: A) => a is B\n): (m: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>\nexport function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): <B extends A>(m: ReadonlyMap<K, B>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, B>>\nexport function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): (m: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>\nexport function partitionWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): (m: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>> {\n  return (m: ReadonlyMap<K, A>) => {\n    const left = new Map<K, A>()\n    const right = new Map<K, A>()\n    const entries = m.entries()\n    let e: Next<readonly [K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      if (predicateWithIndex(k, a)) {\n        right.set(k, a)\n      } else {\n        left.set(k, a)\n      }\n    }\n    return separated(left, right)\n  }\n}\n\n/**\n * @since 2.10.0\n */\nexport const filterMapWithIndex =\n  <K, A, B>(f: (k: K, a: A) => Option<B>) =>\n  (fa: ReadonlyMap<K, A>): ReadonlyMap<K, B> => {\n    const m = new Map<K, B>()\n    const entries = fa.entries()\n    let e: Next<readonly [K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      const o = f(k, a)\n      if (_.isSome(o)) {\n        m.set(k, o.value)\n      }\n    }\n    return m\n  }\n\n/**\n * @since 2.10.0\n */\nexport function filterWithIndex<K, A, B extends A>(\n  predicateWithIndex: (k: K, a: A) => a is B\n): (m: ReadonlyMap<K, A>) => ReadonlyMap<K, B>\nexport function filterWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): <B extends A>(m: ReadonlyMap<K, B>) => ReadonlyMap<K, B>\nexport function filterWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\nexport function filterWithIndex<K, A>(\n  predicateWithIndex: (k: K, a: A) => boolean\n): (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A> {\n  return (m: ReadonlyMap<K, A>) => {\n    const out = new Map<K, A>()\n    const entries = m.entries()\n    let e: Next<readonly [K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      if (predicateWithIndex(k, a)) {\n        out.set(k, a)\n      }\n    }\n    return out\n  }\n}\n\nconst _map: Functor2<URI>['map'] = (fa, f) => _mapWithIndex(fa, (_, a) => f(a))\nconst _filter: Filterable2<URI>['filter'] = <K, A>(fa: ReadonlyMap<K, A>, p: Predicate<A>) =>\n  _filterWithIndex(fa, (_, a) => p(a))\nconst _filterMap: Filterable2<URI>['filterMap'] = (fa, f) => _filterMapWithIndex(fa, (_, a) => f(a))\nconst _partition: Filterable2<URI>['partition'] = <K, A>(fa: ReadonlyMap<K, A>, predicate: Predicate<A>) =>\n  _partitionWithIndex(fa, (_, a) => predicate(a))\nconst _partitionMap: Filterable2<URI>['partitionMap'] = (fa, f) => _partitionMapWithIndex(fa, (_, a) => f(a))\nconst _filterWithIndex = <K, A>(fa: ReadonlyMap<K, A>, p: (k: K, a: A) => boolean) => pipe(fa, filterWithIndex(p))\nconst _filterMapWithIndex = <K, A, B>(fa: ReadonlyMap<K, A>, f: (k: K, a: A) => Option<B>) =>\n  pipe(fa, filterMapWithIndex(f))\nconst _partitionWithIndex = <K, A>(fa: ReadonlyMap<K, A>, p: (k: K, a: A) => boolean) => pipe(fa, partitionWithIndex(p))\nconst _partitionMapWithIndex = <K, A, B, C>(fa: ReadonlyMap<K, A>, f: (k: K, a: A) => Either<B, C>) =>\n  pipe(fa, partitionMapWithIndex(f))\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const compact = <K, A>(fa: ReadonlyMap<K, Option<A>>): ReadonlyMap<K, A> => {\n  const m = new Map<K, A>()\n  const entries = fa.entries()\n  let e: Next<readonly [K, Option<A>]>\n  while (!(e = entries.next()).done) {\n    const [k, oa] = e.value\n    if (_.isSome(oa)) {\n      m.set(k, oa.value)\n    }\n  }\n  return m\n}\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B>\n  <A>(predicate: Predicate<A>): <K, B extends A>(fb: ReadonlyMap<K, B>) => ReadonlyMap<K, B>\n  <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, A>\n} =\n  <A>(predicate: Predicate<A>) =>\n  <K>(fa: ReadonlyMap<K, A>) =>\n    _filter(fa, predicate)\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const filterMap: <A, B>(f: (a: A) => Option<B>) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B> =\n  (f) => (fa) =>\n    _filterMap(fa, f)\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.5.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <K>(fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B> = (f) => (fa) => _map(fa, f)\n\n/**\n * @category mapping\n * @since 2.7.1\n */\nexport const mapWithIndex: <K, A, B>(f: (k: K, a: A) => B) => (fa: ReadonlyMap<K, A>) => ReadonlyMap<K, B> =\n  (f) => (fa) =>\n    _mapWithIndex(fa, f)\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): <K>(\n    fa: ReadonlyMap<K, A>\n  ) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>>\n  <A>(predicate: Predicate<A>): <K, B extends A>(\n    fb: ReadonlyMap<K, B>\n  ) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, B>>\n  <A>(predicate: Predicate<A>): <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, A>, ReadonlyMap<K, A>>\n} =\n  <A>(predicate: Predicate<A>) =>\n  <K>(fa: ReadonlyMap<K, A>) =>\n    _partition(fa, predicate)\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <K>(fa: ReadonlyMap<K, A>) => Separated<ReadonlyMap<K, B>, ReadonlyMap<K, C>> = (f) => (fa) => _partitionMap(fa, f)\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport const separate = <K, A, B>(\n  fa: ReadonlyMap<K, Either<A, B>>\n): Separated<ReadonlyMap<K, A>, ReadonlyMap<K, B>> => {\n  const left = new Map<K, A>()\n  const right = new Map<K, B>()\n  const entries = fa.entries()\n  let e: Next<readonly [K, Either<A, B>]>\n  while (!(e = entries.next()).done) {\n    const [k, ei] = e.value\n    if (_.isLeft(ei)) {\n      left.set(k, ei.left)\n    } else {\n      right.set(k, ei.right)\n    }\n  }\n  return separated(left, right)\n}\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport const URI = 'ReadonlyMap'\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: ReadonlyMap<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <K, A>(E: Eq<K>, S: Semigroup<A>): Semigroup<ReadonlyMap<K, A>> => {\n  const unionES = union(E, S)\n  return {\n    concat: (first, second) => unionES(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionMonoid = <K, A>(E: Eq<K>, S: Semigroup<A>): Monoid<ReadonlyMap<K, A>> => ({\n  concat: getUnionSemigroup(E, S).concat,\n  empty\n})\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getIntersectionSemigroup = <K, A>(E: Eq<K>, S: Semigroup<A>): Semigroup<ReadonlyMap<K, A>> => {\n  const intersectionES = intersection(E, S)\n  return {\n    concat: (first, second) => intersectionES(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getDifferenceMagma =\n  <K>(E: Eq<K>) =>\n  <A>(): Magma<ReadonlyMap<K, A>> => {\n    const differenceE = difference(E)\n    return {\n      concat: (first, second) => differenceE(second)(first)\n    }\n  }\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport function getFilterableWithIndex<K = never>(): FilterableWithIndex2C<URI, K, K> {\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    mapWithIndex: _mapWithIndex,\n    compact,\n    separate,\n    filter: _filter,\n    filterMap: _filterMap,\n    partition: _partition,\n    partitionMap: _partitionMap,\n    partitionMapWithIndex: _partitionMapWithIndex,\n    partitionWithIndex: _partitionWithIndex,\n    filterMapWithIndex: _filterMapWithIndex,\n    filterWithIndex: _filterWithIndex\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getFunctorWithIndex = <K = never>(): FunctorWithIndex2C<URI, K, K> => ({\n  URI,\n  _E: undefined as any,\n  map: _map,\n  mapWithIndex: _mapWithIndex\n})\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Compactable: Compactable2<URI> = {\n  URI,\n  compact,\n  separate\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Filterable: Filterable2<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduce = <K>(O: Ord<K>): (<B, A>(b: B, f: (b: B, a: A) => B) => (m: ReadonlyMap<K, A>) => B) => {\n  const reduceWithIndexO = reduceWithIndex(O)\n  return (b, f) => reduceWithIndexO(b, (_, b, a) => f(b, a))\n}\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const foldMap = <K>(O: Ord<K>): (<M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (m: ReadonlyMap<K, A>) => M) => {\n  const foldMapWithIndexO = foldMapWithIndex(O)\n  return (M) => {\n    const foldMapWithIndexOM = foldMapWithIndexO(M)\n    return (f) => foldMapWithIndexOM((_, a) => f(a))\n  }\n}\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduceRight = <K>(O: Ord<K>): (<B, A>(b: B, f: (a: A, b: B) => B) => (m: ReadonlyMap<K, A>) => B) => {\n  const reduceRightWithIndexO = reduceRightWithIndex(O)\n  return (b, f) => reduceRightWithIndexO(b, (_, b, a) => f(b, a))\n}\n\n/**\n * @category folding\n * @since 2.10.0\n */\nexport const getFoldable = <K>(O: Ord<K>): Foldable2C<URI, K> => {\n  const reduceO = reduce(O)\n  const foldMapO = foldMap(O)\n  const reduceRightO = reduceRight(O)\n  return {\n    URI,\n    _E: undefined as any,\n    reduce: (fa, b, f) => pipe(fa, reduceO(b, f)),\n    foldMap: (M) => {\n      const foldMapOM = foldMapO(M)\n      return (fa, f) => pipe(fa, foldMapOM(f))\n    },\n    reduceRight: (fa, b, f) => pipe(fa, reduceRightO(b, f))\n  }\n}\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduceWithIndex = <K>(\n  O: Ord<K>\n): (<B, A>(b: B, f: (k: K, b: B, a: A) => B) => (m: ReadonlyMap<K, A>) => B) => {\n  const keysO = keys(O)\n  return (b, f) => (m) => {\n    let out = b\n    for (const k of keysO(m)) {\n      out = f(k, out, m.get(k)!)\n    }\n    return out\n  }\n}\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const foldMapWithIndex = <K>(\n  O: Ord<K>\n): (<M>(M: Monoid<M>) => <A>(f: (k: K, a: A) => M) => (m: ReadonlyMap<K, A>) => M) => {\n  const keysO = keys(O)\n  return (M) => (f) => (m) => {\n    let out = M.empty\n    for (const k of keysO(m)) {\n      out = M.concat(out, f(k, m.get(k)!))\n    }\n    return out\n  }\n}\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduceRightWithIndex = <K>(\n  O: Ord<K>\n): (<B, A>(b: B, f: (k: K, a: A, b: B) => B) => (m: ReadonlyMap<K, A>) => B) => {\n  const keysO = keys(O)\n  return (b, f) => (m) => {\n    let out = b\n    const ks = keysO(m)\n    const len = ks.length\n    for (let i = len - 1; i >= 0; i--) {\n      const k = ks[i]\n      out = f(k, m.get(k)!, out)\n    }\n    return out\n  }\n}\n\n/**\n * @category folding\n * @since 2.10.0\n */\nexport const getFoldableWithIndex = <K>(O: Ord<K>): FoldableWithIndex2C<URI, K, K> => {\n  const F = getFoldable(O)\n  const reduceWithIndexO = reduceWithIndex(O)\n  const foldMapWithIndexO = foldMapWithIndex(O)\n  const reduceRightWithIndexO = reduceRightWithIndex(O)\n  return {\n    URI,\n    _E: undefined as any,\n    reduce: F.reduce,\n    foldMap: F.foldMap,\n    reduceRight: F.reduceRight,\n    reduceWithIndex: (fa, b, f) => pipe(fa, reduceWithIndexO(b, f)),\n    foldMapWithIndex: (M) => {\n      const foldMapWithIndexOM = foldMapWithIndexO(M)\n      return (fa, f) => pipe(fa, foldMapWithIndexOM(f))\n    },\n    reduceRightWithIndex: (fa, b, f) => pipe(fa, reduceRightWithIndexO(b, f))\n  }\n}\n\n/**\n * @category traversing\n * @since 2.10.0\n */\nexport const getTraversable = <K>(O: Ord<K>): Traversable2C<URI, K> => {\n  const TWI = getTraversableWithIndex(O)\n  const F = getFoldable(O)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    reduce: F.reduce,\n    foldMap: F.foldMap,\n    reduceRight: F.reduceRight,\n    traverse: TWI.traverse,\n    sequence: TWI.sequence\n  }\n}\n\n/**\n * @category traversing\n * @since 2.10.0\n */\nexport const getTraversableWithIndex = <K>(O: Ord<K>): TraversableWithIndex2C<URI, K, K> => {\n  const FWI = getFoldableWithIndex(O)\n  const keysO = keys(O)\n  const traverseWithIndex = <F>(\n    F: Applicative<F>\n  ): (<A, B>(ta: ReadonlyMap<K, A>, f: (k: K, a: A) => HKT<F, B>) => HKT<F, ReadonlyMap<K, B>>) => {\n    return <A, B>(ta: ReadonlyMap<K, A>, f: (k: K, a: A) => HKT<F, B>) => {\n      let fm: HKT<F, Map<K, B>> = F.of(new Map())\n      const ks = keysO(ta)\n      const len = ks.length\n      for (let i = 0; i < len; i++) {\n        const key = ks[i]\n        const a = ta.get(key)!\n        fm = F.ap(\n          F.map(fm, (m) => (b: B) => m.set(key, b)),\n          f(key, a)\n        )\n      }\n      return fm\n    }\n  }\n  const traverse = <F>(\n    F: Applicative<F>\n  ): (<A, B>(ta: ReadonlyMap<K, A>, f: (a: A) => HKT<F, B>) => HKT<F, ReadonlyMap<K, B>>) => {\n    const traverseWithIndexF = traverseWithIndex(F)\n    return (ta, f) => traverseWithIndexF(ta, (_, a) => f(a))\n  }\n\n  const sequence = <F>(F: Applicative<F>): (<A>(ta: ReadonlyMap<K, HKT<F, A>>) => HKT<F, ReadonlyMap<K, A>>) => {\n    const traverseWithIndexF = traverseWithIndex(F)\n    return (ta) => traverseWithIndexF(ta, SK)\n  }\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    mapWithIndex: _mapWithIndex,\n    reduce: FWI.reduce,\n    foldMap: FWI.foldMap,\n    reduceRight: FWI.reduceRight,\n    reduceWithIndex: FWI.reduceWithIndex,\n    foldMapWithIndex: FWI.foldMapWithIndex,\n    reduceRightWithIndex: FWI.reduceRightWithIndex,\n    traverse,\n    sequence,\n    traverseWithIndex\n  }\n}\n\n/**\n * @category filtering\n * @since 2.5.0\n */\nexport function getWitherable<K>(O: Ord<K>): Witherable2C<URI, K> & TraversableWithIndex2C<URI, K, K> {\n  const TWI = getTraversableWithIndex(O)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    compact,\n    separate,\n    filter: _filter,\n    filterMap: _filterMap,\n    partition: _partition,\n    partitionMap: _partitionMap,\n    reduce: TWI.reduce,\n    foldMap: TWI.foldMap,\n    reduceRight: TWI.reduceRight,\n    traverse: TWI.traverse,\n    sequence: TWI.sequence,\n    mapWithIndex: _mapWithIndex,\n    reduceWithIndex: TWI.reduceWithIndex,\n    foldMapWithIndex: TWI.foldMapWithIndex,\n    reduceRightWithIndex: TWI.reduceRightWithIndex,\n    traverseWithIndex: TWI.traverseWithIndex,\n    wilt: wiltDefault(TWI, Compactable),\n    wither: witherDefault(TWI, Compactable)\n  }\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport const union = <K, A>(\n  E: Eq<K>,\n  M: Magma<A>\n): ((second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>) => {\n  const lookupE = lookup(E)\n  return (second) => (first) => {\n    if (isEmpty(first)) {\n      return second\n    }\n    if (isEmpty(second)) {\n      return first\n    }\n    const out: Map<K, A> = new Map()\n    const firstEntries = first.entries()\n    let e: Next<readonly [K, A]>\n    while (!(e = firstEntries.next()).done) {\n      const [k, a] = e.value\n      const oka = lookupE(k)(second)\n      if (_.isSome(oka)) {\n        out.set(k, M.concat(a, oka.value))\n      } else {\n        out.set(k, a)\n      }\n    }\n    const secondEntries = second.entries()\n    while (!(e = secondEntries.next()).done) {\n      const [k, a] = e.value\n      const oka = lookupE(k)(out)\n      if (_.isNone(oka)) {\n        out.set(k, a)\n      }\n    }\n    return out\n  }\n}\n\n/**\n * @since 2.11.0\n */\nexport const intersection = <K, A>(\n  E: Eq<K>,\n  M: Magma<A>\n): ((second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>) => {\n  const lookupE = lookup(E)\n  return (second) => (first) => {\n    if (isEmpty(first) || isEmpty(second)) {\n      return empty\n    }\n    const out: Map<K, A> = new Map()\n    const entries = first.entries()\n    let e: Next<readonly [K, A]>\n    while (!(e = entries.next()).done) {\n      const [k, a] = e.value\n      const oka = lookupE(k)(second)\n      if (_.isSome(oka)) {\n        out.set(k, M.concat(a, oka.value))\n      }\n    }\n    return out\n  }\n}\n\n/**\n * @since 2.11.0\n */\nexport const difference = <K>(\n  E: Eq<K>\n): (<A>(_second: ReadonlyMap<K, A>) => (first: ReadonlyMap<K, A>) => ReadonlyMap<K, A>) => {\n  const memberE = member(E)\n  return <A>(second: ReadonlyMap<K, A>) =>\n    (first: ReadonlyMap<K, A>) => {\n      if (isEmpty(first)) {\n        return second\n      }\n      if (isEmpty(second)) {\n        return first\n      }\n      const out: Map<K, A> = new Map()\n      const firstEntries = first.entries()\n      let e: Next<readonly [K, A]>\n      while (!(e = firstEntries.next()).done) {\n        const [k, a] = e.value\n        if (!memberE(k)(second)) {\n          out.set(k, a)\n        }\n      }\n      const secondEntries = second.entries()\n      while (!(e = secondEntries.next()).done) {\n        const [k, a] = e.value\n        if (!memberE(k)(first)) {\n          out.set(k, a)\n        }\n      }\n      return out\n    }\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`upsertAt`](#upsertat) instead.\n *\n @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const insertAt: <K>(E: Eq<K>) => <A>(k: K, a: A) => (m: ReadonlyMap<K, A>) => ReadonlyMap<K, A> = upsertAt\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RM.Functor` instead of `RM.readonlyMap`\n * (where `RM` is from `import RM from 'fp-ts/ReadonlyMap'`)\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const readonlyMap: Filterable2<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n"
  },
  {
    "path": "src/ReadonlyNonEmptyArray.ts",
    "content": "/**\n * Data structure which represents non-empty readonly arrays.\n *\n * ```ts\n * export type ReadonlyNonEmptyArray<A> = ReadonlyArray<A> & {\n *   readonly 0: A\n * }\n * ```\n *\n * Note that you don't need any conversion, a `ReadonlyNonEmptyArray` is a `ReadonlyArray`,\n * so all `ReadonlyArray`'s APIs can be used with a `ReadonlyNonEmptyArray` without further ado.\n *\n * @since 2.5.0\n */\nimport { Alt1 } from './Alt'\nimport { Applicative as ApplicativeHKT, Applicative1 } from './Applicative'\nimport { apFirst as apFirst_, Apply1, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport { bind as bind_, Chain1, chainFirst as chainFirst_ } from './Chain'\nimport { Comonad1 } from './Comonad'\nimport { Endomorphism } from './Endomorphism'\nimport { Eq, fromEquals } from './Eq'\nimport { Extend1 } from './Extend'\nimport { Foldable1 } from './Foldable'\nimport { FoldableWithIndex1 } from './FoldableWithIndex'\nimport { dual, flow, identity, LazyArg, pipe, SK } from './function'\nimport { bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport { FunctorWithIndex1 } from './FunctorWithIndex'\nimport { HKT } from './HKT'\nimport * as _ from './internal'\nimport { Monad1 } from './Monad'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Option } from './Option'\nimport { getMonoid, Ord } from './Ord'\nimport { Pointed1 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { ReadonlyRecord } from './ReadonlyRecord'\nimport { Refinement } from './Refinement'\nimport * as Se from './Semigroup'\nimport { Show } from './Show'\nimport { PipeableTraverse1, Traversable1 } from './Traversable'\nimport { PipeableTraverseWithIndex1, TraversableWithIndex1 } from './TraversableWithIndex'\n\nimport Semigroup = Se.Semigroup\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.5.0\n */\nexport type ReadonlyNonEmptyArray<A> = ReadonlyArray<A> & {\n  readonly 0: A\n}\n\n// -------------------------------------------------------------------------------------\n// internal\n// -------------------------------------------------------------------------------------\n\n/**\n * @internal\n */\nexport const empty: ReadonlyArray<never> = _.emptyReadonlyArray\n\n/**\n * @internal\n */\nexport const isNonEmpty: <A>(as: ReadonlyArray<A>) => as is ReadonlyNonEmptyArray<A> = _.isNonEmpty\n\n/**\n * @internal\n */\nexport const isOutOfBound = <A>(i: number, as: ReadonlyArray<A>): boolean => i < 0 || i >= as.length\n\n/**\n * @internal\n */\nexport const prependW =\n  <B>(head: B) =>\n  <A>(tail: ReadonlyArray<A>): ReadonlyNonEmptyArray<A | B> =>\n    [head, ...tail]\n\n/**\n * @internal\n */\nexport const prepend: <A>(head: A) => (tail: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A> = prependW\n\n/**\n * @internal\n */\nexport const appendW =\n  <B>(end: B) =>\n  <A>(init: ReadonlyArray<A>): ReadonlyNonEmptyArray<A | B> =>\n    [...init, end] as any\n\n/**\n * @internal\n */\nexport const append: <A>(end: A) => (init: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A> = appendW\n\n/**\n * @internal\n */\nexport const unsafeInsertAt = <A>(i: number, a: A, as: ReadonlyArray<A>): ReadonlyNonEmptyArray<A> => {\n  if (isNonEmpty(as)) {\n    const xs = _.fromReadonlyNonEmptyArray(as)\n    xs.splice(i, 0, a)\n    return xs\n  }\n  return [a]\n}\n\n/**\n * @internal\n */\nexport const unsafeUpdateAt = <A>(i: number, a: A, as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A> => {\n  if (as[i] === a) {\n    return as\n  } else {\n    const xs = _.fromReadonlyNonEmptyArray(as)\n    xs[i] = a\n    return xs\n  }\n}\n\n/**\n * Remove duplicates from a `ReadonlyNonEmptyArray`, keeping the first occurrence of an element.\n *\n * @example\n * import { uniq } from 'fp-ts/ReadonlyNonEmptyArray'\n * import * as N from 'fp-ts/number'\n *\n * assert.deepStrictEqual(uniq(N.Eq)([1, 2, 1]), [1, 2])\n *\n * @since 2.11.0\n */\nexport const uniq =\n  <A>(E: Eq<A>) =>\n  (as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A> => {\n    if (as.length === 1) {\n      return as\n    }\n    const out: NonEmptyArray<A> = [head(as)]\n    const rest = tail(as)\n    for (const a of rest) {\n      if (out.every((o) => !E.equals(o, a))) {\n        out.push(a)\n      }\n    }\n    return out\n  }\n\n/**\n * Sort the elements of a `ReadonlyNonEmptyArray` in increasing order, where elements are compared using first `ords[0]`, then `ords[1]`,\n * etc...\n *\n * @example\n * import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'\n * import { contramap } from 'fp-ts/Ord'\n * import * as S from 'fp-ts/string'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * interface Person {\n *   name: string\n *   age: number\n * }\n *\n * const byName = pipe(S.Ord, contramap((p: Person) => p.name))\n *\n * const byAge = pipe(N.Ord, contramap((p: Person) => p.age))\n *\n * const sortByNameByAge = RNEA.sortBy([byName, byAge])\n *\n * const persons: RNEA.ReadonlyNonEmptyArray<Person> = [\n *   { name: 'a', age: 1 },\n *   { name: 'b', age: 3 },\n *   { name: 'c', age: 2 },\n *   { name: 'b', age: 2 }\n * ]\n *\n * assert.deepStrictEqual(sortByNameByAge(persons), [\n *   { name: 'a', age: 1 },\n *   { name: 'b', age: 2 },\n *   { name: 'b', age: 3 },\n *   { name: 'c', age: 2 }\n * ])\n *\n * @since 2.11.0\n */\nexport const sortBy = <B>(\n  ords: ReadonlyArray<Ord<B>>\n): (<A extends B>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>) => {\n  if (isNonEmpty(ords)) {\n    const M = getMonoid<B>()\n    return sort(ords.reduce(M.concat, M.empty))\n  }\n  return identity\n}\n\n/**\n * @since 2.11.0\n */\nexport const union = <A>(\n  E: Eq<A>\n): ((second: ReadonlyNonEmptyArray<A>) => (first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>) => {\n  const uniqE = uniq(E)\n  return (second) => (first) => uniqE(pipe(first, concat(second)))\n}\n\n/**\n * Rotate a `ReadonlyNonEmptyArray` by `n` steps.\n *\n * @example\n * import { rotate } from 'fp-ts/ReadonlyNonEmptyArray'\n *\n * assert.deepStrictEqual(rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n * assert.deepStrictEqual(rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n *\n * @since 2.11.0\n */\nexport const rotate =\n  (n: number) =>\n  <A>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A> => {\n    const len = as.length\n    const m = Math.round(n) % len\n    if (isOutOfBound(Math.abs(m), as) || m === 0) {\n      return as\n    }\n    if (m < 0) {\n      const [f, s] = splitAt(-m)(as)\n      return pipe(s, concat(f))\n    } else {\n      return rotate(m - len)(as)\n    }\n  }\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Return a `ReadonlyNonEmptyArray` from a `ReadonlyArray` returning `none` if the input is empty.\n *\n * @category conversions\n * @since 2.5.0\n */\nexport const fromReadonlyArray = <A>(as: ReadonlyArray<A>): Option<ReadonlyNonEmptyArray<A>> =>\n  isNonEmpty(as) ? _.some(as) : _.none\n\n/**\n * Return a `ReadonlyNonEmptyArray` of length `n` with element `i` initialized with `f(i)`.\n *\n * **Note**. `n` is normalized to a natural number.\n *\n * @example\n * import { makeBy } from 'fp-ts/ReadonlyNonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * const double = (n: number): number => n * 2\n * assert.deepStrictEqual(pipe(5, makeBy(double)), [0, 2, 4, 6, 8])\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const makeBy =\n  <A>(f: (i: number) => A) =>\n  (n: number): ReadonlyNonEmptyArray<A> => {\n    const j = Math.max(0, Math.floor(n))\n    const out: NonEmptyArray<A> = [f(0)]\n    for (let i = 1; i < j; i++) {\n      out.push(f(i))\n    }\n    return out\n  }\n\n/**\n * Create a `ReadonlyNonEmptyArray` containing a value repeated the specified number of times.\n *\n * **Note**. `n` is normalized to a natural number.\n *\n * @example\n * import { replicate } from 'fp-ts/ReadonlyNonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe(3, replicate('a')), ['a', 'a', 'a'])\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const replicate = <A>(a: A): ((n: number) => ReadonlyNonEmptyArray<A>) => makeBy(() => a)\n\n/**\n * Create a `ReadonlyNonEmptyArray` containing a range of integers, including both endpoints.\n *\n * @example\n * import { range } from 'fp-ts/ReadonlyNonEmptyArray'\n *\n * assert.deepStrictEqual(range(1, 5), [1, 2, 3, 4, 5])\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const range = (start: number, end: number): ReadonlyNonEmptyArray<number> =>\n  start <= end ? makeBy((i) => start + i)(end - start + 1) : [start]\n\n/**\n * Return the tuple of the `head` and the `tail`.\n *\n * @example\n * import { unprepend } from 'fp-ts/ReadonlyNonEmptyArray'\n *\n * assert.deepStrictEqual(unprepend([1, 2, 3, 4]), [1, [2, 3, 4]])\n *\n * @since 2.9.0\n */\nexport const unprepend = <A>(as: ReadonlyNonEmptyArray<A>): readonly [A, ReadonlyArray<A>] => [head(as), tail(as)]\n\n/**\n * Return the tuple of the `init` and the `last`.\n *\n * @example\n * import { unappend } from 'fp-ts/ReadonlyNonEmptyArray'\n *\n * assert.deepStrictEqual(unappend([1, 2, 3, 4]), [[1, 2, 3], 4])\n *\n * @since 2.9.0\n */\nexport const unappend = <A>(as: ReadonlyNonEmptyArray<A>): readonly [ReadonlyArray<A>, A] => [init(as), last(as)]\n\n/**\n * @category conversions\n * @since 2.5.0\n */\nexport const fromArray = <A>(as: Array<A>): Option<ReadonlyNonEmptyArray<A>> => fromReadonlyArray(as.slice())\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport function concatW<B>(\n  second: ReadonlyNonEmptyArray<B>\n): <A>(first: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A | B>\nexport function concatW<B>(\n  second: ReadonlyArray<B>\n): <A>(first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A | B>\nexport function concatW<B>(second: ReadonlyArray<B>): <A>(first: ReadonlyNonEmptyArray<A>) => ReadonlyArray<A | B> {\n  return <A>(first: ReadonlyNonEmptyArray<A | B>) => first.concat(second)\n}\n\n/**\n * @since 2.5.0\n */\nexport function concat<A>(second: ReadonlyNonEmptyArray<A>): (first: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A>\nexport function concat<A>(second: ReadonlyArray<A>): (first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>\n/** @deprecated */\nexport function concat<A>(first: ReadonlyArray<A>, second: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A>\n/** @deprecated */\nexport function concat<A>(first: ReadonlyNonEmptyArray<A>, second: ReadonlyArray<A>): ReadonlyNonEmptyArray<A>\nexport function concat<A>(\n  x: ReadonlyArray<A>,\n  y?: ReadonlyArray<A>\n): ReadonlyArray<A> | ((y: ReadonlyNonEmptyArray<A>) => ReadonlyArray<A>) {\n  return y ? x.concat(y) : (y) => y.concat(x)\n}\n\n/**\n * @since 2.5.0\n */\nexport const reverse = <A>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A> =>\n  as.length === 1 ? as : [last(as), ...as.slice(0, -1).reverse()]\n\n/**\n * Group equal, consecutive elements of a `ReadonlyArray` into `ReadonlyNonEmptyArray`s.\n *\n * @example\n * import { group } from 'fp-ts/ReadonlyNonEmptyArray'\n * import * as N from 'fp-ts/number'\n *\n * assert.deepStrictEqual(group(N.Eq)([1, 2, 1, 1]), [\n *   [1],\n *   [2],\n *   [1, 1]\n * ])\n *\n * @since 2.5.0\n */\nexport function group<B>(E: Eq<B>): {\n  <A extends B>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>\n  <A extends B>(as: ReadonlyArray<A>): ReadonlyArray<ReadonlyNonEmptyArray<A>>\n}\nexport function group<A>(E: Eq<A>): (as: ReadonlyArray<A>) => ReadonlyArray<ReadonlyNonEmptyArray<A>> {\n  return (as) => {\n    const len = as.length\n    if (len === 0) {\n      return empty\n    }\n    const out: Array<ReadonlyNonEmptyArray<A>> = []\n    let head: A = as[0]\n    let nea: NonEmptyArray<A> = [head]\n    for (let i = 1; i < len; i++) {\n      const a = as[i]\n      if (E.equals(a, head)) {\n        nea.push(a)\n      } else {\n        out.push(nea)\n        head = a\n        nea = [head]\n      }\n    }\n    out.push(nea)\n    return out\n  }\n}\n\n/**\n * Splits an array 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 * @example\n * import { groupBy } from 'fp-ts/ReadonlyNonEmptyArray'\n *\n * assert.deepStrictEqual(groupBy((s: string) => String(s.length))(['a', 'b', 'ab']), {\n *   '1': ['a', 'b'],\n *   '2': ['ab']\n * })\n *\n * @since 2.5.0\n */\nexport const groupBy =\n  <A>(f: (a: A) => string) =>\n  (as: ReadonlyArray<A>): ReadonlyRecord<string, ReadonlyNonEmptyArray<A>> => {\n    const out: Record<string, NonEmptyArray<A>> = {}\n    for (const a of as) {\n      const k = f(a)\n      if (_.has.call(out, k)) {\n        out[k].push(a)\n      } else {\n        out[k] = [a]\n      }\n    }\n    return out\n  }\n\n/**\n * @since 2.5.0\n */\nexport const sort =\n  <B>(O: Ord<B>) =>\n  <A extends B>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A> =>\n    as.length === 1 ? as : (as.slice().sort(O.compare) as any)\n\n/**\n * @since 2.5.0\n */\nexport const updateAt = <A>(i: number, a: A): ((as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>) =>\n  modifyAt(i, () => a)\n\n/**\n * @since 2.5.0\n */\nexport const modifyAt =\n  <A>(i: number, f: (a: A) => A) =>\n  (as: ReadonlyNonEmptyArray<A>): Option<ReadonlyNonEmptyArray<A>> =>\n    isOutOfBound(i, as) ? _.none : _.some(unsafeUpdateAt(i, f(as[i]), as))\n\n/**\n * @since 2.5.1\n */\nexport const zipWith = <A, B, C>(\n  as: ReadonlyNonEmptyArray<A>,\n  bs: ReadonlyNonEmptyArray<B>,\n  f: (a: A, b: B) => C\n): ReadonlyNonEmptyArray<C> => {\n  const cs: NonEmptyArray<C> = [f(as[0], bs[0])]\n  const len = Math.min(as.length, bs.length)\n  for (let i = 1; i < len; i++) {\n    cs[i] = f(as[i], bs[i])\n  }\n  return cs\n}\n\n/**\n * @since 2.5.1\n */\nexport function zip<B>(\n  bs: ReadonlyNonEmptyArray<B>\n): <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<readonly [A, B]>\nexport function zip<A, B>(\n  as: ReadonlyNonEmptyArray<A>,\n  bs: ReadonlyNonEmptyArray<B>\n): ReadonlyNonEmptyArray<readonly [A, B]>\nexport function zip<A, B>(\n  as: ReadonlyNonEmptyArray<A>,\n  bs?: ReadonlyNonEmptyArray<B>\n): ReadonlyNonEmptyArray<readonly [A, B]> | ((bs: ReadonlyNonEmptyArray<B>) => ReadonlyNonEmptyArray<readonly [B, A]>) {\n  if (bs === undefined) {\n    return (bs) => zip(bs, as)\n  }\n  return zipWith(as, bs, (a, b) => [a, b])\n}\n\n/**\n * @since 2.5.1\n */\nexport const unzip = <A, B>(\n  abs: ReadonlyNonEmptyArray<readonly [A, B]>\n): readonly [ReadonlyNonEmptyArray<A>, ReadonlyNonEmptyArray<B>] => {\n  const fa: NonEmptyArray<A> = [abs[0][0]]\n  const fb: NonEmptyArray<B> = [abs[0][1]]\n  for (let i = 1; i < abs.length; i++) {\n    fa[i] = abs[i][0]\n    fb[i] = abs[i][1]\n  }\n  return [fa, fb]\n}\n\n/**\n * Prepend an element to every member of a `ReadonlyNonEmptyArray`.\n *\n * @example\n * import { prependAll } from 'fp-ts/ReadonlyNonEmptyArray'\n *\n * assert.deepStrictEqual(prependAll(9)([1, 2, 3, 4]), [9, 1, 9, 2, 9, 3, 9, 4])\n *\n * @since 2.10.0\n */\nexport const prependAll =\n  <A>(middle: A) =>\n  (as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A> => {\n    const out: NonEmptyArray<A> = [middle, as[0]]\n    for (let i = 1; i < as.length; i++) {\n      out.push(middle, as[i])\n    }\n    return out\n  }\n\n/**\n * Places an element in between members of a `ReadonlyNonEmptyArray`.\n *\n * @example\n * import { intersperse } from 'fp-ts/ReadonlyNonEmptyArray'\n *\n * assert.deepStrictEqual(intersperse(9)([1, 2, 3, 4]), [1, 9, 2, 9, 3, 9, 4])\n *\n * @since 2.9.0\n */\nexport const intersperse =\n  <A>(middle: A) =>\n  (as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A> => {\n    const rest = tail(as)\n    return isNonEmpty(rest) ? pipe(rest, prependAll(middle), prepend(head(as))) : as\n  }\n\n/**\n * @category sequencing\n * @since 2.10.0\n */\nexport const chainWithIndex =\n  <A, B>(f: (i: number, a: A) => ReadonlyNonEmptyArray<B>) =>\n  (as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<B> => {\n    const out: NonEmptyArray<B> = _.fromReadonlyNonEmptyArray(f(0, head(as)))\n    for (let i = 1; i < as.length; i++) {\n      const bs = f(i, as[i])\n      for (let j = 0; j < bs.length; j++) {\n        out.push(bs[j])\n      }\n    }\n    return out\n  }\n\n/**\n * A useful recursion pattern for processing a `ReadonlyNonEmptyArray` to produce a new `ReadonlyNonEmptyArray`, often used for \"chopping\" up the input\n * `ReadonlyNonEmptyArray`. Typically `chop` is called with some function that will consume an initial prefix of the `ReadonlyNonEmptyArray` and produce a\n * value and the tail of the `ReadonlyNonEmptyArray`.\n *\n * @since 2.10.0\n */\nexport const chop =\n  <A, B>(f: (as: ReadonlyNonEmptyArray<A>) => readonly [B, ReadonlyArray<A>]) =>\n  (as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<B> => {\n    const [b, rest] = f(as)\n    const out: NonEmptyArray<B> = [b]\n    let next: ReadonlyArray<A> = rest\n    while (isNonEmpty(next)) {\n      const [b, rest] = f(next)\n      out.push(b)\n      next = rest\n    }\n    return out\n  }\n\n/**\n * Splits a `ReadonlyNonEmptyArray` into two pieces, the first piece has max `n` elements.\n *\n * @since 2.10.0\n */\nexport const splitAt =\n  (n: number) =>\n  <A>(as: ReadonlyNonEmptyArray<A>): readonly [ReadonlyNonEmptyArray<A>, ReadonlyArray<A>] => {\n    const m = Math.max(1, n)\n    return m >= as.length ? [as, empty] : [pipe(as.slice(1, m), prepend(head(as))), as.slice(m)]\n  }\n\n/**\n * Splits a `ReadonlyNonEmptyArray` into length-`n` pieces. The last piece will be shorter if `n` does not evenly divide the length of\n * the `ReadonlyNonEmptyArray`.\n *\n * @since 2.10.0\n */\nexport const chunksOf = (\n  n: number\n): (<A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>) => chop(splitAt(n))\n\nconst _map: Functor1<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _mapWithIndex: FunctorWithIndex1<URI, number>['mapWithIndex'] = (fa, f) => pipe(fa, mapWithIndex(f))\nconst _ap: Apply1<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n/* istanbul ignore next */\nconst _extend: Extend1<URI>['extend'] = (wa, f) => pipe(wa, extend(f))\n/* istanbul ignore next */\nconst _reduce: Foldable1<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\n/* istanbul ignore next */\nconst _foldMap: Foldable1<URI>['foldMap'] = (M) => {\n  const foldMapM = foldMap(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\n/* istanbul ignore next */\nconst _reduceRight: Foldable1<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\n/* istanbul ignore next */\nconst _traverse: Traversable1<URI>['traverse'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: ReadonlyNonEmptyArray<A>, f: (a: A) => HKT<F, B>) => HKT<F, ReadonlyNonEmptyArray<B>>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\n/* istanbul ignore next */\nconst _alt: Alt1<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n/* istanbul ignore next */\nconst _reduceWithIndex: FoldableWithIndex1<URI, number>['reduceWithIndex'] = (fa, b, f) =>\n  pipe(fa, reduceWithIndex(b, f))\n/* istanbul ignore next */\nconst _foldMapWithIndex: FoldableWithIndex1<URI, number>['foldMapWithIndex'] = (M) => {\n  const foldMapWithIndexM = foldMapWithIndex(M)\n  return (fa, f) => pipe(fa, foldMapWithIndexM(f))\n}\n/* istanbul ignore next */\nconst _reduceRightWithIndex: FoldableWithIndex1<URI, number>['reduceRightWithIndex'] = (fa, b, f) =>\n  pipe(fa, reduceRightWithIndex(b, f))\n/* istanbul ignore next */\nconst _traverseWithIndex: TraversableWithIndex1<URI, number>['traverseWithIndex'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(ta: ReadonlyNonEmptyArray<A>, f: (i: number, a: A) => HKT<F, B>) => HKT<F, ReadonlyNonEmptyArray<B>>) => {\n  const traverseWithIndexF = traverseWithIndex(F)\n  return (ta, f) => pipe(ta, traverseWithIndexF(f))\n}\n\n/**\n * @category constructors\n * @since 2.5.0\n */\nexport const of: <A>(a: A) => ReadonlyNonEmptyArray<A> = _.singleton\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @example\n * import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3] as RNEA.ReadonlyNonEmptyArray<number>,\n *     RNEA.altW(() => ['a', 'b'])\n *   ),\n *   [1, 2, 3, 'a', 'b']\n * )\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW =\n  <B>(that: LazyArg<ReadonlyNonEmptyArray<B>>) =>\n  <A>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A | B> =>\n    pipe(as, concatW(that()))\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * In case of `ReadonlyNonEmptyArray` concatenates the inputs into a single array.\n *\n * @example\n * import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     RNEA.alt(() => [4, 5])\n *   ),\n *   [1, 2, 3, 4, 5]\n * )\n *\n * @category error handling\n * @since 2.6.2\n */\nexport const alt: <A>(\n  that: LazyArg<ReadonlyNonEmptyArray<A>>\n) => (as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A> = altW\n\n/**\n * @since 2.5.0\n */\nexport const ap = <A>(\n  as: ReadonlyNonEmptyArray<A>\n): (<B>(fab: ReadonlyNonEmptyArray<(a: A) => B>) => ReadonlyNonEmptyArray<B>) => flatMap((f) => pipe(as, map(f)))\n\n/**\n * @example\n * import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     RNEA.flatMap((n) => [`a${n}`, `b${n}`])\n *   ),\n *   ['a1', 'b1', 'a2', 'b2', 'a3', 'b3']\n * )\n *\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A, i: number) => ReadonlyNonEmptyArray<B>): (ma: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>\n  <A, B>(ma: ReadonlyNonEmptyArray<A>, f: (a: A, i: number) => ReadonlyNonEmptyArray<B>): ReadonlyNonEmptyArray<B>\n} = /*#__PURE__*/ dual(\n  2,\n  <A, B>(ma: ReadonlyNonEmptyArray<A>, f: (a: A, i: number) => ReadonlyNonEmptyArray<B>): ReadonlyNonEmptyArray<B> =>\n    pipe(\n      ma,\n      chainWithIndex((i, a) => f(a, i))\n    )\n)\n\n/**\n * @since 2.5.0\n */\nexport const extend =\n  <A, B>(f: (as: ReadonlyNonEmptyArray<A>) => B) =>\n  (as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<B> => {\n    let next: ReadonlyArray<A> = tail(as)\n    const out: NonEmptyArray<B> = [f(as)]\n    while (isNonEmpty(next)) {\n      out.push(f(next))\n      next = tail(next)\n    }\n    return out\n  }\n\n/**\n * @since 2.5.0\n */\nexport const duplicate: <A>(ma: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>> =\n  /*#__PURE__*/ extend(identity)\n\n/**\n * @category sequencing\n * @since 2.5.0\n */\nexport const flatten: <A>(mma: ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>) => ReadonlyNonEmptyArray<A> =\n  /*#__PURE__*/ flatMap(identity)\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.5.0\n */\nexport const map = <A, B>(f: (a: A) => B): ((as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B>) =>\n  mapWithIndex((_, a) => f(a))\n\n/**\n * @category mapping\n * @since 2.5.0\n */\nexport const mapWithIndex =\n  <A, B>(f: (i: number, a: A) => B) =>\n  (as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<B> => {\n    const out: NonEmptyArray<B> = [f(0, head(as))]\n    for (let i = 1; i < as.length; i++) {\n      out.push(f(i, as[i]))\n    }\n    return out\n  }\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduce = <A, B>(b: B, f: (b: B, a: A) => B): ((as: ReadonlyNonEmptyArray<A>) => B) =>\n  reduceWithIndex(b, (_, b, a) => f(b, a))\n\n/**\n * **Note**. The constraint is relaxed: a `Semigroup` instead of a `Monoid`.\n *\n * @category folding\n * @since 2.5.0\n */\nexport const foldMap =\n  <S>(S: Semigroup<S>) =>\n  <A>(f: (a: A) => S) =>\n  (as: ReadonlyNonEmptyArray<A>): S =>\n    as.slice(1).reduce((s, a) => S.concat(s, f(a)), f(as[0]))\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduceRight = <A, B>(b: B, f: (a: A, b: B) => B): ((as: ReadonlyNonEmptyArray<A>) => B) =>\n  reduceRightWithIndex(b, (_, b, a) => f(b, a))\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduceWithIndex =\n  <A, B>(b: B, f: (i: number, b: B, a: A) => B) =>\n  (as: ReadonlyNonEmptyArray<A>): B =>\n    as.reduce((b, a, i) => f(i, b, a), b)\n\n/**\n * **Note**. The constraint is relaxed: a `Semigroup` instead of a `Monoid`.\n *\n * @category folding\n * @since 2.5.0\n */\nexport const foldMapWithIndex =\n  <S>(S: Semigroup<S>) =>\n  <A>(f: (i: number, a: A) => S) =>\n  (as: ReadonlyNonEmptyArray<A>): S =>\n    as.slice(1).reduce((s, a, i) => S.concat(s, f(i + 1, a)), f(0, as[0]))\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduceRightWithIndex =\n  <A, B>(b: B, f: (i: number, a: A, b: B) => B) =>\n  (as: ReadonlyNonEmptyArray<A>): B =>\n    as.reduceRight((b, a, i) => f(i, a, b), b)\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(f: (a: A) => HKT<F, B>) => (as: ReadonlyNonEmptyArray<A>) => HKT<F, ReadonlyNonEmptyArray<B>>) => {\n  const traverseWithIndexF = traverseWithIndex(F)\n  return (f) => traverseWithIndexF((_, a) => f(a))\n}\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable1<URI>['sequence'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A>(as: ReadonlyNonEmptyArray<HKT<F, A>>) => HKT<F, ReadonlyNonEmptyArray<A>>) => traverseWithIndex(F)(SK)\n\n/**\n * @category sequencing\n * @since 2.6.3\n */\nexport const traverseWithIndex: PipeableTraverseWithIndex1<URI, number> =\n  <F>(F: ApplicativeHKT<F>) =>\n  <A, B>(f: (i: number, a: A) => HKT<F, B>) =>\n  (as: ReadonlyNonEmptyArray<A>): HKT<F, ReadonlyNonEmptyArray<B>> => {\n    let out: HKT<F, ReadonlyNonEmptyArray<B>> = F.map(f(0, head(as)), of)\n    for (let i = 1; i < as.length; i++) {\n      out = F.ap(\n        F.map(out, (bs) => (b: B) => pipe(bs, append(b))),\n        f(i, as[i])\n      )\n    }\n    return out\n  }\n\n/**\n * @category Comonad\n * @since 2.6.3\n */\nexport const extract: Comonad1<URI>['extract'] = _.head\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport const URI = 'ReadonlyNonEmptyArray'\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: ReadonlyNonEmptyArray<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport const getShow = <A>(S: Show<A>): Show<ReadonlyNonEmptyArray<A>> => ({\n  show: (as) => `[${as.map(S.show).join(', ')}]`\n})\n\n/**\n * Builds a `Semigroup` instance for `ReadonlyNonEmptyArray`\n *\n * @category instances\n * @since 2.5.0\n */\nexport const getSemigroup = <A = never>(): Semigroup<ReadonlyNonEmptyArray<A>> => ({\n  concat\n})\n\n/**\n * @example\n * import { getEq } from 'fp-ts/ReadonlyNonEmptyArray'\n * import * as N from 'fp-ts/number'\n *\n * const E = getEq(N.Eq)\n * assert.strictEqual(E.equals([1, 2], [1, 2]), true)\n * assert.strictEqual(E.equals([1, 2], [1, 3]), false)\n *\n * @category instances\n * @since 2.5.0\n */\nexport const getEq = <A>(E: Eq<A>): Eq<ReadonlyNonEmptyArray<A>> =>\n  fromEquals((xs, ys) => xs.length === ys.length && xs.every((x, i) => E.equals(x, ys[i])))\n\n/**\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <A>(E: Eq<A>): Semigroup<ReadonlyNonEmptyArray<A>> => {\n  const unionE = union(E)\n  return {\n    concat: (first, second) => unionE(second)(first)\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FunctorWithIndex: FunctorWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.5.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.5.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     [1, 2, 3],\n *     RA.chainFirst(() => ['a', 'b'])\n *   ),\n *   [1, 1, 2, 2, 3, 3]\n * )\n *\n * @category sequencing\n * @since 2.5.0\n */\nexport const chainFirst: <A, B>(\n  f: (a: A) => ReadonlyNonEmptyArray<B>\n) => (first: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A> = /*#__PURE__*/ chainFirst_(Chain)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable1<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FoldableWithIndex: FoldableWithIndex1<URI, number> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable1<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const TraversableWithIndex: TraversableWithIndex1<URI, number> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex,\n  traverseWithIndex: _traverseWithIndex\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt1<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Comonad: Comonad1<URI> = {\n  URI,\n  map: _map,\n  extend: _extend,\n  extract\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: ReadonlyNonEmptyArray<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ bind_(Chain)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.5.0\n */\nexport const head: <A>(as: ReadonlyNonEmptyArray<A>) => A = extract\n\n/**\n * @since 2.5.0\n */\nexport const tail: <A>(as: ReadonlyNonEmptyArray<A>) => ReadonlyArray<A> = _.tail\n\n/**\n * @since 2.5.0\n */\nexport const last = <A>(as: ReadonlyNonEmptyArray<A>): A => as[as.length - 1]\n\n/**\n * Get all but the last element of a non empty array, creating a new array.\n *\n * @example\n * import { init } from 'fp-ts/ReadonlyNonEmptyArray'\n *\n * assert.deepStrictEqual(init([1, 2, 3]), [1, 2])\n * assert.deepStrictEqual(init([1]), [])\n *\n * @since 2.5.0\n */\nexport const init = <A>(as: ReadonlyNonEmptyArray<A>): ReadonlyArray<A> => as.slice(0, -1)\n\n/**\n * @since 2.5.0\n */\nexport const min = <A>(O: Ord<A>): ((as: ReadonlyNonEmptyArray<A>) => A) => {\n  const S = Se.min(O)\n  return (as) => as.reduce(S.concat)\n}\n\n/**\n * @since 2.5.0\n */\nexport const max = <A>(O: Ord<A>): ((as: ReadonlyNonEmptyArray<A>) => A) => {\n  const S = Se.max(O)\n  return (as) => as.reduce(S.concat)\n}\n\n/**\n * @since 2.10.0\n */\nexport const concatAll =\n  <A>(S: Semigroup<A>) =>\n  (as: ReadonlyNonEmptyArray<A>): A =>\n    as.reduce(S.concat)\n\n/**\n * Break a `ReadonlyArray` into its first element and remaining elements.\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchLeft =\n  <A, B>(f: (head: A, tail: ReadonlyArray<A>) => B) =>\n  (as: ReadonlyNonEmptyArray<A>): B =>\n    f(head(as), tail(as))\n\n/**\n * Break a `ReadonlyArray` into its initial elements and the last element.\n *\n * @category pattern matching\n * @since 2.11.0\n */\nexport const matchRight =\n  <A, B>(f: (init: ReadonlyArray<A>, last: A) => B) =>\n  (as: ReadonlyNonEmptyArray<A>): B =>\n    f(init(as), last(as))\n\n/**\n * Apply a function to the head, creating a new `ReadonlyNonEmptyArray`.\n *\n * @since 2.11.0\n */\nexport const modifyHead =\n  <A>(f: Endomorphism<A>) =>\n  (as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A> =>\n    [f(head(as)), ...tail(as)]\n\n/**\n * Change the head, creating a new `ReadonlyNonEmptyArray`.\n *\n * @since 2.11.0\n */\nexport const updateHead = <A>(a: A): ((as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>) => modifyHead(() => a)\n\n/**\n * Apply a function to the last element, creating a new `ReadonlyNonEmptyArray`.\n *\n * @since 2.11.0\n */\nexport const modifyLast =\n  <A>(f: Endomorphism<A>) =>\n  (as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<A> =>\n    pipe(init(as), append(f(last(as))))\n\n/**\n * Change the last element, creating a new `ReadonlyNonEmptyArray`.\n *\n * @since 2.11.0\n */\nexport const updateLast = <A>(a: A): ((as: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<A>) => modifyLast(() => a)\n\n/**\n * Places an element in between members of a `ReadonlyNonEmptyArray`, then folds the results using the provided `Semigroup`.\n *\n * @example\n * import * as S from 'fp-ts/string'\n * import { intercalate } from 'fp-ts/ReadonlyNonEmptyArray'\n *\n * assert.deepStrictEqual(intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c')\n *\n * @since 2.12.0\n */\nexport const intercalate = <A>(S: Semigroup<A>): ((middle: A) => (as: ReadonlyNonEmptyArray<A>) => A) => {\n  const concatAllS = concatAll(S)\n  return (middle) => flow(intersperse(middle), concatAllS)\n}\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.5.0\n */\nexport const chain: <A, B>(\n  f: (a: A) => ReadonlyNonEmptyArray<B>\n) => (ma: ReadonlyNonEmptyArray<A>) => ReadonlyNonEmptyArray<B> = flatMap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This is just `sort` followed by `group`.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport function groupSort<B>(O: Ord<B>): {\n  <A extends B>(as: ReadonlyNonEmptyArray<A>): ReadonlyNonEmptyArray<ReadonlyNonEmptyArray<A>>\n  <A extends B>(as: ReadonlyArray<A>): ReadonlyArray<ReadonlyNonEmptyArray<A>>\n}\nexport function groupSort<A>(O: Ord<A>): (as: ReadonlyArray<A>) => ReadonlyArray<ReadonlyNonEmptyArray<A>> {\n  const sortO = sort(O)\n  const groupO = group(O)\n  return (as) => (isNonEmpty(as) ? groupO(sortO(as)) : empty)\n}\n\n/**\n * Use [`filter`](./ReadonlyArray.ts.html#filter) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport function filter<A, B extends A>(\n  refinement: Refinement<A, B>\n): (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<B>>\nexport function filter<A>(\n  predicate: Predicate<A>\n): <B extends A>(bs: ReadonlyNonEmptyArray<B>) => Option<ReadonlyNonEmptyArray<B>>\nexport function filter<A>(predicate: Predicate<A>): (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>\nexport function filter<A>(predicate: Predicate<A>): (as: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>> {\n  return filterWithIndex((_, a) => predicate(a))\n}\n\n/**\n * Use [`filterWithIndex`](./ReadonlyArray.ts.html#filterwithindex) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const filterWithIndex =\n  <A>(predicate: (i: number, a: A) => boolean) =>\n  (as: ReadonlyNonEmptyArray<A>): Option<ReadonlyNonEmptyArray<A>> =>\n    fromReadonlyArray(as.filter((a, i) => predicate(i, a)))\n\n/**\n * Use [`unprepend`](#unprepend) instead.\n *\n * @category zone of death\n * @since 2.10.0\n * @deprecated\n */\nexport const uncons: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [A, ReadonlyArray<A>] = unprepend\n\n/**\n * Use [`unappend`](#unappend) instead.\n *\n * @category zone of death\n * @since 2.10.0\n * @deprecated\n */\nexport const unsnoc: <A>(as: ReadonlyNonEmptyArray<A>) => readonly [ReadonlyArray<A>, A] = unappend\n\n/**\n * Use [`prepend`](./ReadonlyArray.ts.html#prepend) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport function cons<A>(head: A): (tail: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A>\n/** @deprecated */\nexport function cons<A>(head: A, tail: ReadonlyArray<A>): ReadonlyNonEmptyArray<A>\nexport function cons<A>(\n  head: A,\n  tail?: ReadonlyArray<A>\n): ReadonlyNonEmptyArray<A> | ((tail: ReadonlyArray<A>) => ReadonlyNonEmptyArray<A>) {\n  return tail === undefined ? prepend(head) : pipe(tail, prepend(head))\n}\n\n/**\n * Use [`append`](./ReadonlyArray.ts.html#append) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const snoc = <A>(init: ReadonlyArray<A>, end: A): ReadonlyNonEmptyArray<A> => pipe(init, concat([end]))\n\n/**\n * Use [`insertAt`](./ReadonlyArray.ts.html#insertat) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const insertAt =\n  <A>(i: number, a: A) =>\n  (as: ReadonlyArray<A>): Option<ReadonlyNonEmptyArray<A>> =>\n    i < 0 || i > as.length ? _.none : _.some(unsafeInsertAt(i, a, as))\n\n/**\n * Use [`prependAll`](#prependall) instead.\n *\n * @category zone of death\n * @since 2.9.0\n * @deprecated\n */\nexport const prependToAll = prependAll\n\n/**\n * Use [`concatAll`](#concatall) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const fold = concatAll\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RNEA.Functor` instead of `RNEA.readonlyNonEmptyArray`\n * (where `RNEA` is from `import RNEA from 'fp-ts/ReadonlyNonEmptyArray'`)\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const readonlyNonEmptyArray: Monad1<URI> &\n  Comonad1<URI> &\n  TraversableWithIndex1<URI, number> &\n  FunctorWithIndex1<URI, number> &\n  FoldableWithIndex1<URI, number> &\n  Alt1<URI> = {\n  URI,\n  of,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  ap: _ap,\n  chain: flatMap,\n  extend: _extend,\n  extract: extract,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  reduceWithIndex: _reduceWithIndex,\n  foldMapWithIndex: _foldMapWithIndex,\n  reduceRightWithIndex: _reduceRightWithIndex,\n  traverseWithIndex: _traverseWithIndex,\n  alt: _alt\n}\n"
  },
  {
    "path": "src/ReadonlyRecord.ts",
    "content": "/**\n * The `ReadonlyRecord.ts` module enables dealing in a functional way with\n * Typescript's `Readonly<Record<K, T>>` type. That is similar to the\n * `Record.ts` module, but for a record with all properties\n * declared as `readonly`.\n *\n * @since 2.5.0\n */\nimport {\n  Applicative,\n  Applicative1,\n  Applicative2,\n  Applicative2C,\n  Applicative3,\n  Applicative3C,\n  Applicative4\n} from './Applicative'\nimport { Compactable1 } from './Compactable'\nimport { Either } from './Either'\nimport { Eq, fromEquals } from './Eq'\nimport { Filterable1 } from './Filterable'\nimport { FilterableWithIndex1, PredicateWithIndex, RefinementWithIndex } from './FilterableWithIndex'\nimport { Foldable as FoldableHKT, Foldable1, Foldable2, Foldable3 } from './Foldable'\nimport { FoldableWithIndex1 } from './FoldableWithIndex'\nimport { flow, identity, pipe, SK } from './function'\nimport { flap as flap_, Functor1 } from './Functor'\nimport { FunctorWithIndex1 } from './FunctorWithIndex'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport * as _ from './internal'\nimport { Magma } from './Magma'\nimport { Monoid } from './Monoid'\nimport { Option } from './Option'\nimport { Ord } from './Ord'\nimport { Predicate } from './Predicate'\nimport { Refinement } from './Refinement'\nimport * as Se from './Semigroup'\nimport { Separated, separated } from './Separated'\nimport { Show } from './Show'\nimport * as S from './string'\nimport { Traversable1 } from './Traversable'\nimport { TraversableWithIndex1 } from './TraversableWithIndex'\nimport { Unfoldable, Unfoldable1 } from './Unfoldable'\nimport { PipeableWilt1, PipeableWither1, wiltDefault, Witherable1, witherDefault } from './Witherable'\n\nimport Semigroup = Se.Semigroup\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.5.0\n */\nexport type ReadonlyRecord<K extends string, T> = Readonly<Record<K, T>>\n\n/**\n * Builds a `ReadonlyRecord` by copying a `Record`.\n *\n * @example\n * import { ReadonlyRecord, fromRecord } from \"fp-ts/ReadonlyRecord\"\n *\n * const x: Record<string, number> = { a: 1, b: 2 };\n * const y: ReadonlyRecord<string, number> = fromRecord(x);\n * assert.deepStrictEqual(x,y);\n * // `y.a = 5` gives compiler error\n *\n * @category conversions\n * @since 2.5.0\n */\nexport const fromRecord = <K extends string, A>(r: Record<K, A>): ReadonlyRecord<K, A> => Object.assign({}, r)\n\n/**\n * Builds a mutable `Record` from a `ReadonlyRecord`.\n *\n * @example\n * import { ReadonlyRecord, toRecord } from \"fp-ts/ReadonlyRecord\"\n *\n * const x: ReadonlyRecord<string, number> = { a: 1, b: 2 };\n * const y: Record<string, number> = toRecord(x);\n * assert.deepStrictEqual(x,y);\n * y.a = 5; // it's ok, y is mutable\n *\n * @category conversions\n * @since 2.5.0\n */\nexport const toRecord = <K extends string, A>(r: ReadonlyRecord<K, A>): Record<K, A> => Object.assign({}, r)\n\n/**\n * Calculate the number of key/value pairs in a `ReadonlyRecord`,\n *\n * @example\n * import { size } from \"fp-ts/ReadonlyRecord\";\n *\n * assert.deepStrictEqual(size({ a: true, b: 2, c: \"three\" }), 3);\n *\n * @since 2.5.0\n */\nexport const size = <A>(r: ReadonlyRecord<string, A>): number => Object.keys(r).length\n\n/**\n * Test whether a `ReadonlyRecord` is empty.\n *\n * @example\n * import { isEmpty } from \"fp-ts/ReadonlyRecord\"\n *\n * assert.deepStrictEqual(isEmpty({}), true);\n * assert.deepStrictEqual(isEmpty({ a: 3 }), false);\n * @since 2.5.0\n */\nexport const isEmpty = <A>(r: ReadonlyRecord<string, A>): boolean => {\n  for (const k in r) {\n    if (_.has.call(r, k)) {\n      return false\n    }\n  }\n  return true\n}\n\nconst keys_ =\n  (O: Ord<string>) =>\n  <K extends string>(r: ReadonlyRecord<K, unknown>): ReadonlyArray<K> =>\n    (Object.keys(r) as any).sort(O.compare)\n\n/**\n * @since 2.5.0\n */\nexport const keys: <K extends string>(r: ReadonlyRecord<K, unknown>) => ReadonlyArray<K> = /*#__PURE__*/ keys_(S.Ord)\n\n/**\n * Map a `ReadonlyRecord` into an `ReadonlyArray`.\n *\n * @example\n * import { collect } from 'fp-ts/ReadonlyRecord'\n * import { Ord } from 'fp-ts/string'\n *\n * const f = <A>(k: string, a: A) => `${k.toUpperCase()}-${a}`;\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(collect(Ord)(f)(x), [\"A-foo\", \"B-false\", \"C-3\"]);\n *\n * @since 2.5.0\n */\nexport function collect(\n  O: Ord<string>\n): <K extends string, A, B>(f: (k: K, a: A) => B) => (r: ReadonlyRecord<K, A>) => ReadonlyArray<B>\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function collect<K extends string, A, B>(f: (k: K, a: A) => B): (r: ReadonlyRecord<K, A>) => ReadonlyArray<B>\nexport function collect<A, B>(\n  O: Ord<string> | ((k: string, a: A) => B)\n):\n  | (<K extends string, A, B>(f: (k: K, a: A) => B) => (r: ReadonlyRecord<K, A>) => ReadonlyArray<B>)\n  | ((r: ReadonlyRecord<string, A>) => ReadonlyArray<B>) {\n  if (typeof O === 'function') {\n    return collect(S.Ord)(O)\n  }\n  const keysO = keys_(O)\n  return <K extends string, A, B>(f: (k: K, a: A) => B) =>\n    (r: ReadonlyRecord<K, A>) => {\n      const out: Array<B> = []\n      for (const key of keysO(r)) {\n        out.push(f(key, r[key]))\n      }\n      return out\n    }\n}\n\n/**\n * Get a sorted `ReadonlyArray` of the key/value pairs contained in a `ReadonlyRecord`.\n *\n * @example\n * import { toReadonlyArray } from 'fp-ts/ReadonlyRecord'\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(toReadonlyArray(x), [\n *   [\"a\", \"foo\"],\n *   [\"b\", false],\n *   [\"c\", 3],\n * ]);\n *\n * @category conversions\n * @since 2.5.0\n */\nexport const toReadonlyArray: <K extends string, A>(r: ReadonlyRecord<K, A>) => ReadonlyArray<readonly [K, A]> =\n  /*#__PURE__*/ collect(S.Ord)((k, a) => [k, a])\n\n/**\n * Unfolds a `ReadonlyRecord` into a list of key/value pairs.\n *\n * Given an `Unfoldable` class type `U` such as `array` or `readonlyArray`,\n * it uses the `unfold` function to create an instance of `U`,\n * providing an iterating function that iterates over each\n * key/value pair in the record sorted alphabetically by key.\n *\n * @example\n * import { array, readonlyArray } from 'fp-ts'\n * import { toUnfoldable } from 'fp-ts/ReadonlyRecord'\n *\n * assert.deepStrictEqual(toUnfoldable(array)({ b: 2, a: 1 }),[ [ 'a', 1 ], [ 'b', 2 ]])\n * assert.deepStrictEqual(toUnfoldable(readonlyArray)({ b: 2, a: 1 }),[ [ 'a', 1 ], [ 'b', 2 ]])\n *\n * @category conversions\n * @since 2.5.0\n */\nexport function toUnfoldable<F extends URIS>(\n  U: Unfoldable1<F>\n): <K extends string, A>(r: ReadonlyRecord<K, A>) => Kind<F, readonly [K, A]>\nexport function toUnfoldable<F>(\n  U: Unfoldable<F>\n): <K extends string, A>(r: ReadonlyRecord<K, A>) => HKT<F, readonly [K, A]>\nexport function toUnfoldable<F>(U: Unfoldable<F>): <A>(r: ReadonlyRecord<string, A>) => HKT<F, readonly [string, A]> {\n  return (r) => {\n    const sas = toReadonlyArray(r)\n    const len = sas.length\n    return U.unfold(0, (b) => (b < len ? _.some([sas[b], b + 1]) : _.none))\n  }\n}\n\n/**\n * Insert or replace a key/value pair in a `ReadonlyRecord`.\n *\n * @example\n * import { upsertAt } from 'fp-ts/ReadonlyRecord'\n *\n * assert.deepStrictEqual(upsertAt(\"a\", 5)({ a: 1, b: 2 }), { a: 5, b: 2 });\n * assert.deepStrictEqual(upsertAt(\"c\", 5)({ a: 1, b: 2 }), { a: 1, b: 2, c: 5 });\n *\n * @since 2.10.0\n */\nexport const upsertAt =\n  <A>(k: string, a: A) =>\n  (r: ReadonlyRecord<string, A>): ReadonlyRecord<string, A> => {\n    if (_.has.call(r, k) && r[k] === a) {\n      return r\n    }\n    const out: Record<string, A> = Object.assign({}, r)\n    out[k] = a\n    return out\n  }\n\n/**\n * Test whether or not a key exists in a `ReadonlyRecord`.\n *\n * Note. This function is not pipeable because is a `Refinement`.\n *\n * @example\n * import { has } from 'fp-ts/ReadonlyRecord'\n *\n * assert.deepStrictEqual(has(\"a\", { a: 1, b: 2 }), true);\n * assert.deepStrictEqual(has(\"c\", { a: 1, b: 2 }), false);\n *\n * @since 2.10.0\n */\nexport const has = <K extends string>(k: string, r: ReadonlyRecord<K, unknown>): k is K => _.has.call(r, k)\n\n/**\n * Delete a key and value from a `ReadonlyRecord`.\n *\n * @example\n * import { deleteAt } from 'fp-ts/ReadonlyRecord'\n *\n * assert.deepStrictEqual(deleteAt(\"a\")({ a: 1, b: 2 }), { b: 2 });\n * assert.deepStrictEqual(deleteAt(\"c\")({ a: 1, b: 2 }), { a: 1, b: 2 });\n *\n * @since 2.5.0\n */\nexport function deleteAt<K extends string>(\n  k: K\n): <KS extends string, A>(r: ReadonlyRecord<KS, A>) => ReadonlyRecord<string extends K ? string : Exclude<KS, K>, A>\nexport function deleteAt(k: string): <A>(r: ReadonlyRecord<string, A>) => ReadonlyRecord<string, A> {\n  return <A>(r: ReadonlyRecord<string, A>) => {\n    if (!_.has.call(r, k)) {\n      return r\n    }\n    const out: Record<string, A> = Object.assign({}, r)\n    delete out[k]\n    return out\n  }\n}\n\n/**\n * Replace a key/value pair in a `ReadonlyRecord`.\n *\n * @returns If the specified key exists it returns an `Option` containing a new `Record`\n * with the entry updated, otherwise it returns `None`\n *\n * @example\n * import { updateAt } from 'fp-ts/ReadonlyRecord'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(updateAt(\"a\", 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }));\n * assert.deepStrictEqual(updateAt(\"c\", 3)({ a: 1, b: 2 }), option.none);\n *\n * @since 2.5.0\n */\nexport const updateAt =\n  <A>(k: string, a: A) =>\n  <K extends string>(r: ReadonlyRecord<K, A>): Option<ReadonlyRecord<K, A>> => {\n    if (!has(k, r)) {\n      return _.none\n    }\n    if (r[k] === a) {\n      return _.some(r)\n    }\n    const out: Record<K, A> = Object.assign({}, r)\n    out[k] = a\n    return _.some(out)\n  }\n\n/**\n * Applies a mapping function to one specific key/value pair in a `ReadonlyRecord`.\n *\n * @returns If the specified key exists it returns an `Option` containing a new `Record`\n * with the entry updated, otherwise it returns `None`\n *\n * @example\n * import { modifyAt } from 'fp-ts/ReadonlyRecord'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(modifyAt(\"a\", (x: number) => x * 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }));\n * assert.deepStrictEqual(modifyAt(\"c\", (x: number) => x * 3)({ a: 1, b: 2 }), option.none);\n *\n * @since 2.5.0\n */\nexport const modifyAt =\n  <A>(k: string, f: (a: A) => A) =>\n  <K extends string>(r: ReadonlyRecord<K, A>): Option<ReadonlyRecord<K, A>> => {\n    if (!has(k, r)) {\n      return _.none\n    }\n    const next = f(r[k])\n    if (next === r[k]) {\n      return _.some(r)\n    }\n    const out: Record<K, A> = Object.assign({}, r)\n    out[k] = next\n    return _.some(out)\n  }\n\n/**\n * Delete a key and value from a `ReadonlyRecord`, returning the value as well as the subsequent `ReadonlyRecord`.\n *\n * @returns If the specified key exists it returns an `Option` containing a new `ReadonlyRecord`\n * with the entry removed, otherwise it returns `None`\n *\n * @example\n * import { pop } from 'fp-ts/ReadonlyRecord'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(pop(\"a\")({ a: 1, b: 2, c: 3 }), option.some([1, { b: 2, c: 3 }]));\n * assert.deepStrictEqual(pop(\"x\")({ a: 1, b: 2, c: 3 }), option.none);\n *\n * @since 2.5.0\n */\nexport function pop<K extends string>(\n  k: K\n): <KS extends string, A>(\n  r: ReadonlyRecord<KS, A>\n) => Option<readonly [A, ReadonlyRecord<string extends K ? string : Exclude<KS, K>, A>]>\nexport function pop(k: string): <A>(r: ReadonlyRecord<string, A>) => Option<readonly [A, ReadonlyRecord<string, A>]> {\n  const deleteAtk = deleteAt(k)\n  return (r) => {\n    const oa = lookup(k, r)\n    return _.isNone(oa) ? _.none : _.some([oa.value, deleteAtk(r)])\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test whether one `ReadonlyRecord` contains all of the keys and values\n * contained in another `ReadonlyRecord`.\n *\n * @example\n * import { isSubrecord } from 'fp-ts/ReadonlyRecord'\n * import { string } from 'fp-ts'\n *\n * assert.deepStrictEqual(\n *   isSubrecord(string.Eq)({ a: \"foo\", b: \"bar\", c: \"baz\" })({ a: \"foo\", b: \"bar\", c: \"baz\" }),\n *   true\n * );\n * assert.deepStrictEqual(\n *   isSubrecord(string.Eq)({ a: \"foo\", b: \"bar\", c: \"baz\" })({ a: \"foo\", c: \"baz\" }),\n *   true\n * );\n * assert.deepStrictEqual(\n *   isSubrecord(string.Eq)({ a: \"foo\", b: \"bar\", c: \"baz\" })({ a: \"foo\", b: \"not-bar\", c: \"baz\" }),\n *   false\n * );\n * assert.deepStrictEqual(\n *   isSubrecord(string.Eq)({ a: \"foo\", b: \"bar\" })({ a: \"foo\", b: \"bar\", c: \"baz\" }),\n *   false\n * );\n *\n * @since 2.5.0\n */\nexport function isSubrecord<A>(E: Eq<A>): {\n  (that: ReadonlyRecord<string, A>): (me: ReadonlyRecord<string, A>) => boolean\n  (me: ReadonlyRecord<string, A>, that: ReadonlyRecord<string, A>): boolean\n}\nexport function isSubrecord<A>(\n  E: Eq<A>\n): (\n  me: ReadonlyRecord<string, A>,\n  that?: ReadonlyRecord<string, A>\n) => boolean | ((me: ReadonlyRecord<string, A>) => boolean) {\n  return (me, that?) => {\n    if (that === undefined) {\n      const isSubrecordE = isSubrecord(E)\n      return (that) => isSubrecordE(that, me)\n    }\n    for (const k in me) {\n      if (!_.has.call(that, k) || !E.equals(me[k], that[k])) {\n        return false\n      }\n    }\n    return true\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Lookup the value for a key in a `ReadonlyRecord`.\n *\n * @returns If the specified key exists it returns an `Option` containing the value,\n * otherwise it returns `None`\n *\n * @example\n * import { lookup } from 'fp-ts/ReadonlyRecord'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(lookup(\"b\")({ a: \"foo\", b: \"bar\" }), option.some(\"bar\"));\n * assert.deepStrictEqual(lookup(\"c\")({ a: \"foo\", b: \"bar\" }), option.none);\n *\n * @since 2.5.0\n */\nexport function lookup(k: string): <A>(r: ReadonlyRecord<string, A>) => Option<A>\nexport function lookup<A>(k: string, r: ReadonlyRecord<string, A>): Option<A>\nexport function lookup<A>(\n  k: string,\n  r?: ReadonlyRecord<string, A>\n): Option<A> | ((r: ReadonlyRecord<string, A>) => Option<A>) {\n  if (r === undefined) {\n    return (r) => lookup(k, r)\n  }\n  return _.has.call(r, k) ? _.some(r[k]) : _.none\n}\n\n/**\n * @since 2.5.0\n */\nexport const empty: ReadonlyRecord<string, never> = {}\n\n/**\n * Map a `ReadonlyRecord` passing the keys to the iterating function.\n *\n * @example\n * import { mapWithIndex } from \"fp-ts/ReadonlyRecord\";\n *\n * const f = (k: string, n: number) => `${k.toUpperCase()}-${n}`;\n * assert.deepStrictEqual(mapWithIndex(f)({ a: 3, b: 5 }), { a: \"A-3\", b: \"B-5\" });\n *\n * @since 2.5.0\n */\nexport function mapWithIndex<K extends string, A, B>(\n  f: (k: K, a: A) => B\n): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<K, B>\nexport function mapWithIndex<A, B>(\n  f: (k: string, a: A) => B\n): (fa: ReadonlyRecord<string, A>) => ReadonlyRecord<string, B> {\n  return (r) => {\n    const out: Record<string, B> = {}\n    for (const k in r) {\n      if (_.has.call(r, k)) {\n        out[k] = f(k, r[k])\n      }\n    }\n    return out\n  }\n}\n\n/**\n * Map a `ReadonlyRecord` passing the values to the iterating function.\n *\n * @example\n * import { map } from \"fp-ts/ReadonlyRecord\";\n *\n * const f = (n: number) => `-${n}-`;\n * assert.deepStrictEqual(map(f)({ a: 3, b: 5 }), { a: \"-3-\", b: \"-5-\" });\n *\n * @since 2.5.0\n */\nexport function map<A, B>(f: (a: A) => B): <K extends string>(fa: ReadonlyRecord<K, A>) => ReadonlyRecord<K, B>\nexport function map<A, B>(f: (a: A) => B): (fa: ReadonlyRecord<string, A>) => ReadonlyRecord<string, B> {\n  return mapWithIndex((_, a) => f(a))\n}\n\n/**\n * Reduces a `ReadonlyRecord` passing each key/value pair to the iterating function.\n * Entries are processed in the order, sorted by key according to\n * the given `Ord`.\n *\n * @example\n * import { reduceWithIndex } from \"fp-ts/ReadonlyRecord\";\n * import { Ord } from \"fp-ts/string\";\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(reduceWithIndex(Ord)([] as string[], (k, b, a) => [...b, `${k}-${a}`])(x), [\n *   \"a-foo\",\n *   \"b-false\",\n *   \"c-3\",\n * ]);\n *\n * @since 2.5.0\n */\nexport function reduceWithIndex(\n  O: Ord<string>\n): <K extends string, A, B>(b: B, f: (k: K, b: B, a: A) => B) => (fa: ReadonlyRecord<K, A>) => B\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function reduceWithIndex<K extends string, A, B>(\n  b: B,\n  f: (k: K, b: B, a: A) => B\n): (fa: ReadonlyRecord<K, A>) => B\nexport function reduceWithIndex<A, B>(\n  ...args: [Ord<string>] | [B, (k: string, b: B, a: A) => B]\n):\n  | ((b: B, f: (k: string, b: B, a: A) => B) => (fa: ReadonlyRecord<string, A>) => B)\n  | ((fa: ReadonlyRecord<string, A>) => B) {\n  if (args.length === 2) {\n    return reduceWithIndex(S.Ord)(...args)\n  }\n  const keysO = keys_(args[0])\n  return (b, f) => (fa) => {\n    let out: B = b\n    const ks = keysO(fa)\n    const len = ks.length\n    for (let i = 0; i < len; i++) {\n      const k = ks[i]\n      out = f(k, out, fa[k])\n    }\n    return out\n  }\n}\n\n/**\n * Map and fold a `ReadonlyRecord`.\n * Map the `ReadonlyRecord` passing each key/value pair to the iterating function.\n * Then fold the results using the provided `Monoid`.\n *\n * @example\n * import { foldMapWithIndex } from \"fp-ts/ReadonlyRecord\";\n * import { Ord } from \"fp-ts/string\";\n * import { Monoid } from \"fp-ts/Monoid\";\n *\n * const m: Monoid<string> = { empty: \"\", concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) };\n * const f = (k:string, a: number) => `${k}-${a}`\n * const x = { c: 3, a: 1, b: 2 };\n * assert.deepStrictEqual(foldMapWithIndex(Ord)(m)(f)(x), \"a-1 -> b-2 -> c-3\");\n *\n * @since 2.5.0\n */\nexport function foldMapWithIndex(\n  O: Ord<string>\n): <M>(M: Monoid<M>) => <K extends string, A>(f: (k: K, a: A) => M) => (fa: ReadonlyRecord<K, A>) => M\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function foldMapWithIndex<M>(\n  M: Monoid<M>\n): <K extends string, A>(f: (k: K, a: A) => M) => (fa: ReadonlyRecord<K, A>) => M\nexport function foldMapWithIndex<M>(\n  O: Ord<string> | Monoid<M>\n):\n  | ((M: Monoid<M>) => <A>(f: (k: string, a: A) => M) => (fa: ReadonlyRecord<string, A>) => M)\n  | (<A>(f: (k: string, a: A) => M) => (fa: ReadonlyRecord<string, A>) => M) {\n  if ('compare' in O) {\n    const keysO = keys_(O)\n    return (M: Monoid<M>) =>\n      <A>(f: (k: string, a: A) => M) =>\n      (fa: ReadonlyRecord<string, A>) => {\n        let out: M = M.empty\n        const ks = keysO(fa)\n        const len = ks.length\n        for (let i = 0; i < len; i++) {\n          const k = ks[i]\n          out = M.concat(out, f(k, fa[k]))\n        }\n        return out\n      }\n  }\n  return foldMapWithIndex(S.Ord)(O)\n}\n\n/**\n * Same as `reduceWithIndex`, but reduce starting from the right\n * (i.e. in reverse order, from the last to the first entry according to\n * the given `Ord`).\n *\n * @example\n * import { reduceRightWithIndex } from \"fp-ts/ReadonlyRecord\";\n * import { Ord } from \"fp-ts/string\";\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(reduceRightWithIndex(Ord)([] as string[], (k, a, b) => [...b, `${k}-${a}`])(x), [\n *   \"c-3\",\n *   \"b-false\",\n *   \"a-foo\",\n * ]);\n *\n * @since 2.5.0\n */\nexport function reduceRightWithIndex(\n  O: Ord<string>\n): <K extends string, A, B>(b: B, f: (k: K, a: A, b: B) => B) => (fa: ReadonlyRecord<K, A>) => B\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function reduceRightWithIndex<K extends string, A, B>(\n  b: B,\n  f: (k: K, a: A, b: B) => B\n): (fa: ReadonlyRecord<K, A>) => B\nexport function reduceRightWithIndex<A, B>(\n  ...args: [Ord<string>] | [B, (k: string, a: A, b: B) => B]\n):\n  | ((b: B, f: (k: string, a: A, b: B) => B) => (fa: ReadonlyRecord<string, A>) => B)\n  | ((fa: ReadonlyRecord<string, A>) => B) {\n  if (args.length === 2) {\n    return reduceRightWithIndex(S.Ord)(...args)\n  }\n  const keysO = keys_(args[0])\n  return (b, f) => (fa) => {\n    let out: B = b\n    const ks = keysO(fa)\n    const len = ks.length\n    for (let i = len - 1; i >= 0; i--) {\n      const k = ks[i]\n      out = f(k, fa[k], out)\n    }\n    return out\n  }\n}\n\n/**\n * Create a `ReadonlyRecord` with one key/value pair.\n *\n * @example\n * import { singleton } from \"fp-ts/ReadonlyRecord\";\n *\n * assert.deepStrictEqual(singleton(\"a\", 1), { a: 1 });\n *\n * @category constructors\n * @since 2.5.0\n */\nexport const singleton = <A>(k: string, a: A): ReadonlyRecord<string, A> => ({ [k]: a })\n\n/**\n * @since 2.5.0\n */\nexport function traverseWithIndex<F extends URIS4>(\n  F: Applicative4<F>\n): <K extends string, S, R, E, A, B>(\n  f: (k: K, a: A) => Kind4<F, S, R, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind4<F, S, R, E, ReadonlyRecord<K, B>>\nexport function traverseWithIndex<F extends URIS3>(\n  F: Applicative3<F>\n): <K extends string, R, E, A, B>(\n  f: (k: K, a: A) => Kind3<F, R, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>\nexport function traverseWithIndex<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <K extends string, R, A, B>(\n  f: (k: K, a: A) => Kind3<F, R, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>\nexport function traverseWithIndex<F extends URIS2>(\n  F: Applicative2<F>\n): <K extends string, E, A, B>(\n  f: (k: K, a: A) => Kind2<F, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>\nexport function traverseWithIndex<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <K extends string, A, B>(\n  f: (k: K, a: A) => Kind2<F, E, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>\nexport function traverseWithIndex<F extends URIS>(\n  F: Applicative1<F>\n): <K extends string, A, B>(\n  f: (k: K, a: A) => Kind<F, B>\n) => (ta: ReadonlyRecord<K, A>) => Kind<F, ReadonlyRecord<K, B>>\nexport function traverseWithIndex<F>(\n  F: Applicative<F>\n): <K extends string, A, B>(f: (k: K, a: A) => HKT<F, B>) => (ta: ReadonlyRecord<K, A>) => HKT<F, ReadonlyRecord<K, B>>\nexport function traverseWithIndex<F>(\n  F: Applicative<F>\n): <A, B>(f: (k: string, a: A) => HKT<F, B>) => (ta: ReadonlyRecord<string, A>) => HKT<F, ReadonlyRecord<string, B>> {\n  const traverseWithIndexOF = _traverseWithIndex(S.Ord)(F)\n  return (f) => (ta) => traverseWithIndexOF(ta, f)\n}\n\n/**\n * @since 2.5.0\n */\nexport function traverse<F extends URIS4>(\n  F: Applicative4<F>\n): <S, R, E, A, B>(\n  f: (a: A) => Kind4<F, S, R, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind4<F, S, R, E, ReadonlyRecord<K, B>>\nexport function traverse<F extends URIS3>(\n  F: Applicative3<F>\n): <R, E, A, B>(\n  f: (a: A) => Kind3<F, R, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>\nexport function traverse<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <R, A, B>(\n  f: (a: A) => Kind3<F, R, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind3<F, R, E, ReadonlyRecord<K, B>>\nexport function traverse<F extends URIS2>(\n  F: Applicative2<F>\n): <E, A, B>(\n  f: (a: A) => Kind2<F, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>\nexport function traverse<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <A, B>(\n  f: (a: A) => Kind2<F, E, B>\n) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind2<F, E, ReadonlyRecord<K, B>>\nexport function traverse<F extends URIS>(\n  F: Applicative1<F>\n): <A, B>(f: (a: A) => Kind<F, B>) => <K extends string>(ta: ReadonlyRecord<K, A>) => Kind<F, ReadonlyRecord<K, B>>\nexport function traverse<F>(\n  F: Applicative<F>\n): <A, B>(f: (a: A) => HKT<F, B>) => <K extends string>(ta: ReadonlyRecord<K, A>) => HKT<F, ReadonlyRecord<K, B>>\nexport function traverse<F>(\n  F: Applicative<F>\n): <A, B>(f: (a: A) => HKT<F, B>) => (ta: ReadonlyRecord<string, A>) => HKT<F, ReadonlyRecord<string, B>> {\n  const traverseOF = _traverse(S.Ord)(F)\n  return (f) => (ta) => traverseOF(ta, f)\n}\n\n/**\n * `ReadonlyRecord` sequencing,\n * i.e., take a `ReadonlyRecord` in which elements are monads\n * and return a monad of a `ReadonlyRecord` of the base types.\n * The following example for instance shows sequencing\n * a `ReadonlyRecord<string, Option<number>>`\n * into an `Option<ReadonlyRecord<string, number>>`.\n *\n * `sequence` in `ReadonlyRecord` is equivalent to `sequenceS` in `Apply.ts`.\n *\n * @example\n * import { sequence } from \"fp-ts/ReadonlyRecord\";\n * import { option } from \"fp-ts\";\n * import { sequenceS } from \"fp-ts/Apply\";\n *\n * assert.deepStrictEqual(\n *   sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),\n *   option.some({ a: 1, b: 2 })\n * );\n * assert.deepStrictEqual(sequence(option.Applicative)({ a: option.some(1), b: option.none }), option.none);\n * assert.deepStrictEqual(\n *   sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),\n *   sequenceS(option.Applicative)({ a: option.some(1), b: option.some(2) })\n * );\n *\n * @since 2.5.0\n */\nexport function sequence<F extends URIS3>(\n  F: Applicative3<F>\n): <K extends string, R, E, A>(ta: ReadonlyRecord<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, ReadonlyRecord<K, A>>\nexport function sequence<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <K extends string, R, A>(ta: ReadonlyRecord<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, ReadonlyRecord<K, A>>\nexport function sequence<F extends URIS2>(\n  F: Applicative2<F>\n): <K extends string, E, A>(ta: ReadonlyRecord<K, Kind2<F, E, A>>) => Kind2<F, E, ReadonlyRecord<K, A>>\nexport function sequence<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <K extends string, A>(ta: ReadonlyRecord<K, Kind2<F, E, A>>) => Kind2<F, E, ReadonlyRecord<K, A>>\nexport function sequence<F extends URIS>(\n  F: Applicative1<F>\n): <K extends string, A>(ta: ReadonlyRecord<K, Kind<F, A>>) => Kind<F, ReadonlyRecord<K, A>>\nexport function sequence<F>(\n  F: Applicative<F>\n): <K extends string, A>(ta: ReadonlyRecord<K, HKT<F, A>>) => HKT<F, ReadonlyRecord<K, A>>\nexport function sequence<F>(\n  F: Applicative<F>\n): <A>(ta: ReadonlyRecord<string, HKT<F, A>>) => HKT<F, ReadonlyRecord<string, A>> {\n  return _sequence(S.Ord)(F)\n}\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wither: PipeableWither1<URI> = <F>(\n  F: Applicative<F>\n): (<A, B>(f: (a: A) => HKT<F, Option<B>>) => (fa: ReadonlyRecord<string, A>) => HKT<F, ReadonlyRecord<string, B>>) => {\n  const traverseF = traverse(F)\n  return (f) => (fa) => F.map(pipe(fa, traverseF(f)), compact)\n}\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wilt: PipeableWilt1<URI> = <F>(\n  F: Applicative<F>\n): (<A, B, C>(\n  f: (a: A) => HKT<F, Either<B, C>>\n) => (fa: ReadonlyRecord<string, A>) => HKT<F, Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, C>>>) => {\n  const traverseF = traverse(F)\n  return (f) => (fa) => F.map(pipe(fa, traverseF(f)), separate)\n}\n\n/**\n * Maps a `ReadonlyRecord` with a function returning an `Either` and\n * partitions the resulting `ReadonlyRecord` into `Left`s and `Right`s.\n *\n * @example\n * import { partitionMapWithIndex } from \"fp-ts/ReadonlyRecord\"\n * import { either } from \"fp-ts\"\n *\n * const f = (key: string, a: number) =>\n *   a >= 0 ? either.right(`${key} is >= 0 (${a})`) : either.left(`${key} is < 0 (${a})`);\n * assert.deepStrictEqual(partitionMapWithIndex(f)({ a: -1, b: 2, c: 123 }), {\n *   left: {\n *     a: \"a is < 0 (-1)\",\n *   },\n *   right: {\n *     b: \"b is >= 0 (2)\",\n *     c: \"c is >= 0 (123)\",\n *   },\n * });\n *\n * @since 2.5.0\n */\nexport function partitionMapWithIndex<K extends string, A, B, C>(\n  f: (key: K, a: A) => Either<B, C>\n): (fa: ReadonlyRecord<K, A>) => Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, C>>\nexport function partitionMapWithIndex<A, B, C>(\n  f: (key: string, a: A) => Either<B, C>\n): (fa: ReadonlyRecord<string, A>) => Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, C>> {\n  return (r) => {\n    const left: Record<string, B> = {}\n    const right: Record<string, C> = {}\n    for (const k in r) {\n      if (_.has.call(r, k)) {\n        const e = f(k, r[k])\n        switch (e._tag) {\n          case 'Left':\n            left[k] = e.left\n            break\n          case 'Right':\n            right[k] = e.right\n            break\n        }\n      }\n    }\n    return separated(left, right)\n  }\n}\n\n/**\n * Partition a `ReadonlyRecord` into two parts according to a predicate\n * that takes a key and a value.\n *\n * @example\n * import { partitionWithIndex } from \"fp-ts/ReadonlyRecord\"\n *\n * assert.deepStrictEqual(\n *   partitionWithIndex((key: string, a: number) => key.length <= 1 && a > 0)({ a: -1, b: 2, ccc: 7 }),\n *   {\n *     left: {\n *       a: -1,\n *       ccc: 7,\n *     },\n *     right: {\n *       b: 2,\n *     },\n *   }\n * );\n *\n * @since 2.5.0\n */\nexport function partitionWithIndex<K extends string, A, B extends A>(\n  refinementWithIndex: RefinementWithIndex<K, A, B>\n): (fa: ReadonlyRecord<K, A>) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, B>>\nexport function partitionWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): <B extends A>(fb: ReadonlyRecord<K, B>) => Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, B>>\nexport function partitionWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): (fa: ReadonlyRecord<K, A>) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, A>>\nexport function partitionWithIndex<A>(\n  predicateWithIndex: PredicateWithIndex<string, A>\n): (fa: ReadonlyRecord<string, A>) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, A>> {\n  return (r) => {\n    const left: Record<string, A> = {}\n    const right: Record<string, A> = {}\n    for (const k in r) {\n      if (_.has.call(r, k)) {\n        const a = r[k]\n        if (predicateWithIndex(k, a)) {\n          right[k] = a\n        } else {\n          left[k] = a\n        }\n      }\n    }\n    return separated(left, right)\n  }\n}\n\n/**\n * Maps a `ReadonlyRecord` with an iterating function that takes key and value and\n * returns an `Option`, keeping only the `Some` values and discarding `None`s.\n *\n * @example\n * import { filterMapWithIndex } from \"fp-ts/ReadonlyRecord\"\n * import { option } from \"fp-ts\"\n *\n * const f = (key: string, a: number) => (a >= 0 ? option.some(`${key}${a}`) : option.none);\n * assert.deepStrictEqual(filterMapWithIndex(f)({ a: -1, b: 2, c: 3 }), {\n *   b: \"b2\",\n *   c: \"c3\",\n * });\n *\n * @since 2.5.0\n */\nexport function filterMapWithIndex<K extends string, A, B>(\n  f: (key: K, a: A) => Option<B>\n): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<string, B>\nexport function filterMapWithIndex<A, B>(\n  f: (key: string, a: A) => Option<B>\n): (fa: ReadonlyRecord<string, A>) => ReadonlyRecord<string, B> {\n  return (r) => {\n    const out: Record<string, B> = {}\n    for (const k in r) {\n      if (_.has.call(r, k)) {\n        const ob = f(k, r[k])\n        if (_.isSome(ob)) {\n          out[k] = ob.value\n        }\n      }\n    }\n    return out\n  }\n}\n\n/**\n * Produce a new `ReadonlyRecord` keeping only the entries that satisfy\n * a predicate taking key and value as input.\n *\n * @example\n * import { filterWithIndex } from \"fp-ts/ReadonlyRecord\"\n *\n * assert.deepStrictEqual(\n *   filterWithIndex((s: string, v: number) => s.length <= 1 && v > 0)({ a: 1, b: -2, ccc: 3 }),\n *   {\n *     a: 1,\n *   }\n * );\n *\n * @since 2.5.0\n */\nexport function filterWithIndex<K extends string, A, B extends A>(\n  refinementWithIndex: RefinementWithIndex<K, A, B>\n): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<string, B>\nexport function filterWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): <B extends A>(fb: ReadonlyRecord<K, B>) => ReadonlyRecord<string, B>\nexport function filterWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): (fa: ReadonlyRecord<K, A>) => ReadonlyRecord<string, A>\nexport function filterWithIndex<A>(\n  predicateWithIndex: PredicateWithIndex<string, A>\n): (fa: ReadonlyRecord<string, A>) => ReadonlyRecord<string, A> {\n  return (fa) => {\n    const out: Record<string, A> = {}\n    let changed = false\n    for (const key in fa) {\n      if (_.has.call(fa, key)) {\n        const a = fa[key]\n        if (predicateWithIndex(key, a)) {\n          out[key] = a\n        } else {\n          changed = true\n        }\n      }\n    }\n    return changed ? out : fa\n  }\n}\n\n/**\n * Create a `ReadonlyRecord` from a foldable collection of key/value pairs, using the\n * specified `Magma` to combine values for duplicate keys.\n *\n * @since 2.5.0\n */\nexport function fromFoldable<F extends URIS3, A>(\n  M: Magma<A>,\n  F: Foldable3<F>\n): <R, E>(fka: Kind3<F, R, E, readonly [string, A]>) => ReadonlyRecord<string, A>\nexport function fromFoldable<F extends URIS2, A>(\n  M: Magma<A>,\n  F: Foldable2<F>\n): <E>(fka: Kind2<F, E, readonly [string, A]>) => ReadonlyRecord<string, A>\nexport function fromFoldable<F extends URIS, A>(\n  M: Magma<A>,\n  F: Foldable1<F>\n): (fka: Kind<F, readonly [string, A]>) => ReadonlyRecord<string, A>\nexport function fromFoldable<F, A>(\n  M: Magma<A>,\n  F: FoldableHKT<F>\n): (fka: HKT<F, readonly [string, A]>) => ReadonlyRecord<string, A>\nexport function fromFoldable<F, A>(\n  M: Magma<A>,\n  F: FoldableHKT<F>\n): (fka: HKT<F, readonly [string, A]>) => ReadonlyRecord<string, A> {\n  const fromFoldableMapM = fromFoldableMap(M, F)\n  return (fka) => fromFoldableMapM(fka, identity)\n}\n\n/**\n * Create a `ReadonlyRecord` from a foldable collection using the specified functions to:\n *\n * - map to key/value pairs\n * - combine values for duplicate keys.\n *\n * @example\n * import { last } from 'fp-ts/Semigroup'\n * import { Foldable, zip } from 'fp-ts/ReadonlyArray'\n * import { identity } from 'fp-ts/function'\n * import { ReadonlyRecord, fromFoldableMap } from 'fp-ts/ReadonlyRecord'\n *\n * export const zipObject = <K extends string, A>(keys: ReadonlyArray<K>, values: ReadonlyArray<A>): ReadonlyRecord<K, A> =>\n *   fromFoldableMap(last<A>(), Foldable)(zip(keys, values), identity)\n *\n * assert.deepStrictEqual(zipObject(['a', 'b'], [1, 2, 3]), { a: 1, b: 2 })\n *\n * interface User {\n *   readonly id: string\n *   readonly name: string\n * }\n *\n * const users: ReadonlyArray<User> = [\n *   { id: 'id1', name: 'name1' },\n *   { id: 'id2', name: 'name2' },\n *   { id: 'id1', name: 'name3' }\n * ]\n *\n * assert.deepStrictEqual(fromFoldableMap(last<User>(), Foldable)(users, user => [user.id, user]), {\n *   id1: { id: 'id1', name: 'name3' },\n *   id2: { id: 'id2', name: 'name2' }\n * })\n *\n * @since 2.5.0\n */\nexport function fromFoldableMap<F extends URIS3, B>(\n  M: Magma<B>,\n  F: Foldable3<F>\n): <R, E, A>(fa: Kind3<F, R, E, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>\nexport function fromFoldableMap<F extends URIS2, B>(\n  M: Magma<B>,\n  F: Foldable2<F>\n): <E, A>(fa: Kind2<F, E, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>\nexport function fromFoldableMap<F extends URIS, B>(\n  M: Magma<B>,\n  F: Foldable1<F>\n): <A>(fa: Kind<F, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>\nexport function fromFoldableMap<F, B>(\n  M: Magma<B>,\n  F: FoldableHKT<F>\n): <A>(fa: HKT<F, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B>\nexport function fromFoldableMap<F, B>(\n  M: Magma<B>,\n  F: FoldableHKT<F>\n): <A>(fa: HKT<F, A>, f: (a: A) => readonly [string, B]) => ReadonlyRecord<string, B> {\n  return <A>(ta: HKT<F, A>, f: (a: A) => readonly [string, B]) => {\n    return F.reduce<A, Record<string, B>>(ta, {}, (r, a) => {\n      const [k, b] = f(a)\n      r[k] = _.has.call(r, k) ? M.concat(r[k], b) : b\n      return r\n    })\n  }\n}\n\n/**\n * Alias of [`toReadonlyArray`](#toreadonlyarray).\n *\n * @example\n * import { toEntries } from 'fp-ts/ReadonlyRecord'\n *\n * assert.deepStrictEqual(toEntries({ b: 2, a: 1 }), [['a', 1], ['b', 2]])\n *\n * @category conversions\n * @since 2.12.0\n */\nexport const toEntries = toReadonlyArray\n\n/**\n * Converts a `ReadonlyArray` of `[key, value]` tuples into a `ReadonlyRecord`.\n *\n * @example\n * import { fromEntries } from 'fp-ts/ReadonlyRecord'\n *\n * assert.deepStrictEqual(fromEntries([['a', 1], ['b', 2], ['a', 3]]), { b: 2, a: 3 })\n *\n * @since 2.12.0\n * @category conversions\n */\nexport const fromEntries = <A>(fa: ReadonlyArray<readonly [string, A]>): ReadonlyRecord<string, A> => {\n  const out: Record<string, A> = {}\n  for (const a of fa) {\n    out[a[0]] = a[1]\n  }\n  return out\n}\n\n/**\n * Test if every value in a `ReadonlyRecord` satisfies the predicate.\n *\n * @example\n * import { every } from \"fp-ts/ReadonlyRecord\"\n *\n * assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: 2 }), true);\n * assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: -1 }), false);\n *\n * @since 2.5.0\n */\nexport function every<A, B extends A>(\n  refinement: Refinement<A, B>\n): Refinement<ReadonlyRecord<string, A>, ReadonlyRecord<string, B>>\nexport function every<A>(predicate: Predicate<A>): Predicate<ReadonlyRecord<string, A>>\nexport function every<A>(predicate: Predicate<A>): Predicate<ReadonlyRecord<string, A>> {\n  return (r) => {\n    for (const k in r) {\n      if (!predicate(r[k])) {\n        return false\n      }\n    }\n    return true\n  }\n}\n\n/**\n * Test if at least one value in a `ReadonlyRecord` satisfies the predicate.\n *\n * @example\n * import { some } from \"fp-ts/ReadonlyRecord\"\n *\n * assert.deepStrictEqual(some((n: number) => n >= 0)({ a: 1, b: -2 }), true);\n * assert.deepStrictEqual(some((n: number) => n >= 0)({ a: -1, b: -2 }), false);\n *\n * @since 2.5.0\n */\nexport function some<A>(predicate: (a: A) => boolean): (r: ReadonlyRecord<string, A>) => boolean {\n  return (r) => {\n    for (const k in r) {\n      if (predicate(r[k])) {\n        return true\n      }\n    }\n    return false\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Given an `Eq` checks if a `ReadonlyRecord` contains an entry with\n * value equal to a provided value.\n *\n * @example\n * import { elem } from \"fp-ts/ReadonlyRecord\"\n * import { number } from \"fp-ts\"\n *\n * assert.deepStrictEqual(elem(number.Eq)(123, { foo: 123, bar: 234 }), true);\n * assert.deepStrictEqual(elem(number.Eq)(-7, { foo: 123, bar: 234 }), false);\n *\n * @since 2.5.0\n */\nexport function elem<A>(E: Eq<A>): {\n  (a: A): (fa: ReadonlyRecord<string, A>) => boolean\n  (a: A, fa: ReadonlyRecord<string, A>): boolean\n}\nexport function elem<A>(\n  E: Eq<A>\n): (a: A, fa?: ReadonlyRecord<string, A>) => boolean | ((fa: ReadonlyRecord<string, A>) => boolean) {\n  return (a, fa?) => {\n    if (fa === undefined) {\n      const elemE = elem(E)\n      return (fa) => elemE(a, fa)\n    }\n    for (const k in fa) {\n      if (E.equals(fa[k], a)) {\n        return true\n      }\n    }\n    return false\n  }\n}\n\n/**\n * Union of two `ReadonlyRecord`s.\n * Takes two `ReadonlyRecord`s and produces a `ReadonlyRecord` combining all the\n * entries of the two inputs.\n * It uses the `concat` function of the provided `Magma` to\n * combine the elements with the same key.\n *\n * @example\n * import { union } from \"fp-ts/ReadonlyRecord\";\n * import { Magma } from \"fp-ts/Magma\";\n *\n * const m1: Magma<number> = { concat: (x: number, y: number) => x + y };\n * assert.deepStrictEqual(union(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4, b: 2, c: 3 });\n * const m2: Magma<number> = { concat: (x: number) => x };\n * assert.deepStrictEqual(union(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 });\n *\n * @since 2.11.0\n */\nexport const union =\n  <A>(M: Magma<A>) =>\n  (second: ReadonlyRecord<string, A>) =>\n  (first: ReadonlyRecord<string, A>): ReadonlyRecord<string, A> => {\n    if (isEmpty(first)) {\n      return second\n    }\n    if (isEmpty(second)) {\n      return first\n    }\n    const out: Record<string, A> = {}\n    for (const k in first) {\n      if (has(k, second)) {\n        out[k] = M.concat(first[k], second[k])\n      } else {\n        out[k] = first[k]\n      }\n    }\n    for (const k in second) {\n      if (!has(k, out)) {\n        out[k] = second[k]\n      }\n    }\n    return out\n  }\n\n/**\n * Intersection of two `ReadonlyRecord`s.\n * Takes two `ReadonlyRecord`s and produces a `ReadonlyRecord` combining only the\n * entries of the two inputswith the same key.\n * It uses the `concat` function of the provided `Magma` to\n * combine the elements.\n *\n * @example\n * import { intersection } from \"fp-ts/ReadonlyRecord\";\n * import { Magma } from \"fp-ts/Magma\";\n *\n * const m1: Magma<number> = { concat: (x: number, y: number) => x + y };\n * assert.deepStrictEqual(intersection(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4});\n * const m2: Magma<number> = { concat: (x: number) => x };\n * assert.deepStrictEqual(intersection(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1});\n *\n * @since 2.11.0\n */\nexport const intersection =\n  <A>(M: Magma<A>) =>\n  (second: ReadonlyRecord<string, A>) =>\n  (first: ReadonlyRecord<string, A>): ReadonlyRecord<string, A> => {\n    if (isEmpty(first) || isEmpty(second)) {\n      return empty\n    }\n    const out: Record<string, A> = {}\n    for (const k in first) {\n      if (has(k, second)) {\n        out[k] = M.concat(first[k], second[k])\n      }\n    }\n    return out\n  }\n\n/**\n * Difference between two `ReadonlyRecord`s.\n * Takes two `ReadonlyRecord`s and produces a `ReadonlyRecord` composed by the\n * entries of the two inputs, removing the entries with the same\n * key in both inputs.\n *\n * @example\n * import { difference } from \"fp-ts/ReadonlyRecord\";\n *\n * assert.deepStrictEqual(difference({ a: 1 })({ a: 1, b: 2 }), { b: 2 });\n * assert.deepStrictEqual(difference({ a: 3 })({ a: 1, b: 2 }), { b: 2 });\n * assert.deepStrictEqual(difference({ a: 3, c: 3 })({ a: 1, b: 2 }), { b: 2, c: 3 });\n *\n * @since 2.11.0\n */\nexport const difference =\n  <A>(second: ReadonlyRecord<string, A>) =>\n  (first: ReadonlyRecord<string, A>): ReadonlyRecord<string, A> => {\n    if (isEmpty(first)) {\n      return second\n    }\n    if (isEmpty(second)) {\n      return first\n    }\n    const out: Record<string, A> = {}\n    for (const k in first) {\n      if (!has(k, second)) {\n        out[k] = first[k]\n      }\n    }\n    for (const k in second) {\n      if (!has(k, first)) {\n        out[k] = second[k]\n      }\n    }\n    return out\n  }\n\n/** @internal */\nexport const _map: Functor1<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/** @internal */\n/* istanbul ignore next */\nexport const _mapWithIndex: FunctorWithIndex1<URI, string>['mapWithIndex'] = (fa, f) => pipe(fa, mapWithIndex(f))\n/** @internal */\n/* istanbul ignore next */\nexport const _reduce: (O: Ord<string>) => Foldable1<URI>['reduce'] = (O: Ord<string>) => {\n  const reduceO = reduce(O)\n  return (fa, b, f) => pipe(fa, reduceO(b, f))\n}\n/** @internal */\nexport const _foldMap: (O: Ord<string>) => Foldable1<URI>['foldMap'] = (O) => (M) => {\n  const foldMapM = foldMap(O)(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\n/** @internal */\n/* istanbul ignore next */\nexport const _reduceRight: (O: Ord<string>) => Foldable1<URI>['reduceRight'] = (O) => {\n  const reduceRightO = reduceRight(O)\n  return (fa, b, f) => pipe(fa, reduceRightO(b, f))\n}\n/** @internal */\n/* istanbul ignore next */\nexport const _filter = <A>(fa: ReadonlyRecord<string, A>, predicate: Predicate<A>): ReadonlyRecord<string, A> =>\n  pipe(fa, filter(predicate))\n/** @internal */\n/* istanbul ignore next */\nexport const _filterMap: Filterable1<URI>['filterMap'] = (fa, f) => pipe(fa, filterMap(f))\n/** @internal */\n/* istanbul ignore next */\nexport const _partition = <A>(\n  fa: ReadonlyRecord<string, A>,\n  predicate: Predicate<A>\n): Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, A>> => pipe(fa, partition(predicate))\n/** @internal */\n/* istanbul ignore next */\nexport const _partitionMap: Filterable1<URI>['partitionMap'] = (fa, f) => pipe(fa, partitionMap(f))\n/** @internal */\n/* istanbul ignore next */\nexport const _reduceWithIndex: (O: Ord<string>) => FoldableWithIndex1<URI, string>['reduceWithIndex'] = (O) => {\n  const reduceWithIndexO = reduceWithIndex(O)\n  return (fa, b, f) => pipe(fa, reduceWithIndexO(b, f))\n}\n/** @internal */\nexport const _foldMapWithIndex: (O: Ord<string>) => FoldableWithIndex1<URI, string>['foldMapWithIndex'] = (O) => {\n  const foldMapWithIndexO = foldMapWithIndex(O)\n  return (M) => {\n    const foldMapWithIndexM = foldMapWithIndexO(M)\n    return (fa, f) => pipe(fa, foldMapWithIndexM(f))\n  }\n}\n/** @internal */\n/* istanbul ignore next */\nexport const _reduceRightWithIndex: (O: Ord<string>) => FoldableWithIndex1<URI, string>['reduceRightWithIndex'] = (\n  O\n) => {\n  const reduceRightWithIndexO = reduceRightWithIndex(O)\n  return (fa, b, f) => pipe(fa, reduceRightWithIndexO(b, f))\n}\n/** @internal */\n/* istanbul ignore next */\nexport const _partitionMapWithIndex = <A, B, C>(\n  fa: ReadonlyRecord<string, A>,\n  f: (key: string, a: A) => Either<B, C>\n): Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, C>> => pipe(fa, partitionMapWithIndex(f))\n/** @internal */\n/* istanbul ignore next */\nexport const _partitionWithIndex = <A>(\n  fa: ReadonlyRecord<string, A>,\n  predicateWithIndex: PredicateWithIndex<string, A>\n): Separated<Readonly<Record<string, A>>, Readonly<Record<string, A>>> =>\n  pipe(fa, partitionWithIndex(predicateWithIndex))\n/** @internal */\n/* istanbul ignore next */\nexport const _filterMapWithIndex = <A, B>(\n  fa: ReadonlyRecord<string, A>,\n  f: (key: string, a: A) => Option<B>\n): Readonly<Record<string, B>> => pipe(fa, filterMapWithIndex(f))\n/** @internal */\n/* istanbul ignore next */\nexport const _filterWithIndex = <A>(\n  fa: ReadonlyRecord<string, A>,\n  predicateWithIndex: PredicateWithIndex<string, A>\n): Readonly<Record<string, A>> => pipe(fa, filterWithIndex(predicateWithIndex))\n/** @internal */\nexport const _traverse = (\n  O: Ord<string>\n): (<F>(\n  F: Applicative<F>\n) => <A, B>(ta: ReadonlyRecord<string, A>, f: (a: A) => HKT<F, B>) => HKT<F, ReadonlyRecord<string, B>>) => {\n  const traverseWithIndexO = _traverseWithIndex(O)\n  return (F) => {\n    const traverseWithIndexOF = traverseWithIndexO(F)\n    return (ta, f) => traverseWithIndexOF(ta, flow(SK, f))\n  }\n}\n/** @internal */\nexport const _sequence = (\n  O: Ord<string>\n): (<F>(F: Applicative<F>) => <A>(ta: ReadonlyRecord<string, HKT<F, A>>) => HKT<F, ReadonlyRecord<string, A>>) => {\n  const traverseO = _traverse(O)\n  return (F) => {\n    const traverseOF = traverseO(F)\n    return (ta) => traverseOF(ta, identity)\n  }\n}\nconst _traverseWithIndex =\n  (O: Ord<string>) =>\n  <F>(\n    F: Applicative<F>\n  ): (<A, B>(\n    ta: ReadonlyRecord<string, A>,\n    f: (k: string, a: A) => HKT<F, B>\n  ) => HKT<F, ReadonlyRecord<string, B>>) => {\n    const keysO = keys_(O)\n    return <A, B>(ta: ReadonlyRecord<string, A>, f: (k: string, a: A) => HKT<F, B>) => {\n      const ks = keysO(ta)\n      if (ks.length === 0) {\n        return F.of(empty)\n      }\n      let fr: HKT<F, Record<string, B>> = F.of({})\n      for (const key of ks) {\n        fr = F.ap(\n          F.map(fr, (r) => (b: B) => Object.assign({}, r, { [key]: b })),\n          f(key, ta[key])\n        )\n      }\n      return fr\n    }\n  }\n\n/**\n * Given a `Predicate`, it produces a new `ReadonlyRecord` keeping only the entries with a\n * value that satisfies the provided predicate.\n *\n * @example\n * import { filter } from \"fp-ts/ReadonlyRecord\"\n *\n * assert.deepStrictEqual(filter((s: string) => s.length < 4)({ a: \"foo\", b: \"bar\", c: \"verylong\" }), {\n *   a: \"foo\",\n *   b: \"bar\",\n * });\n *\n * @category filtering\n * @since 2.5.0\n */\nexport const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: ReadonlyRecord<string, A>) => ReadonlyRecord<string, B>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: ReadonlyRecord<string, B>) => ReadonlyRecord<string, B>\n  <A>(predicate: Predicate<A>): (fa: ReadonlyRecord<string, A>) => ReadonlyRecord<string, A>\n} = <A>(predicate: Predicate<A>): ((fa: ReadonlyRecord<string, A>) => ReadonlyRecord<string, A>) =>\n  filterWithIndex((_, a) => predicate(a))\n\n/**\n * Maps a `ReadonlyRecord` with an iterating function that returns an `Option`\n * and it keeps only the `Some` values discarding the `None`s.\n *\n * @example\n * import { filterMap } from \"fp-ts/ReadonlyRecord\"\n * import { option } from \"fp-ts\"\n *\n * const f = (s: string) => s.length < 4 ? option.some(`${s} is short`): option.none\n * assert.deepStrictEqual(filterMap(f)({ a: \"foo\", b: \"bar\", c: \"verylong\" }), {\n *   a: \"foo is short\",\n *   b: \"bar is short\",\n * });\n *\n * @category filtering\n * @since 2.5.0\n */\nexport const filterMap: <A, B>(\n  f: (a: A) => Option<B>\n) => (fa: ReadonlyRecord<string, A>) => ReadonlyRecord<string, B> = (f) => filterMapWithIndex((_, a) => f(a))\n\n/**\n * Partition a `ReadonlyRecord` into two parts according to a `Predicate`.\n *\n * @example\n * import { partition } from \"fp-ts/ReadonlyRecord\"\n *\n * assert.deepStrictEqual(partition((s: string) => s.length < 4)({ a: \"foo\", b: \"bar\", c: \"verylong\" }), {\n *   left:{\n *     c: \"verylong\"\n *   },\n *   right: {\n *     a: \"foo\",\n *     b: \"bar\",\n *   },\n * });\n *\n * @category filtering\n * @since 2.5.0\n */\nexport const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fa: ReadonlyRecord<string, A>\n  ) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(\n    fb: ReadonlyRecord<string, B>\n  ) => Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, B>>\n  <A>(predicate: Predicate<A>): (\n    fa: ReadonlyRecord<string, A>\n  ) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, A>>\n} = <A>(\n  predicate: Predicate<A>\n): ((fa: ReadonlyRecord<string, A>) => Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, A>>) =>\n  partitionWithIndex((_, a) => predicate(a))\n\n/**\n * Maps a `ReadonlyRecord` with a function returning an `Either` and\n * partitions the resulting `ReadonlyRecord` into `Left`s and `Right`s.\n *\n * @example\n * import { partitionMap } from \"fp-ts/ReadonlyRecord\"\n * import { either } from \"fp-ts\"\n *\n * const f = (s: string) => (s.length < 4 ? either.right(`${s} is short`) : either.left(`${s} is not short`));\n * assert.deepStrictEqual(partitionMap(f)({ a: \"foo\", b: \"bar\", c: \"verylong\" }), {\n *   left: {\n *     c: \"verylong is not short\",\n *   },\n *   right: {\n *     a: \"foo is short\",\n *     b: \"bar is short\",\n *   },\n * });\n *\n * @category filtering\n * @since 2.5.0\n */\nexport const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: ReadonlyRecord<string, A>) => Separated<ReadonlyRecord<string, B>, ReadonlyRecord<string, C>> = (f) =>\n  partitionMapWithIndex((_, a) => f(a))\n\n/**\n * Reduces a `ReadonlyRecord` passing each value to the iterating function.\n * Entries are processed in order, sorted by key according to\n * the given `Ord`.\n *\n * @example\n * import { reduce } from \"fp-ts/ReadonlyRecord\";\n * import { Ord } from \"fp-ts/string\";\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(reduce(Ord)([] as string[], (b, a) => [...b, `-${a}-`])(x), [\n *   \"-foo-\",\n *   \"-false-\",\n *   \"-3-\",\n * ]);\n *\n * @category folding\n * @since 2.5.0\n */\nexport function reduce(O: Ord<string>): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: ReadonlyRecord<string, A>) => B\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function reduce<A, B>(b: B, f: (b: B, a: A) => B): (fa: ReadonlyRecord<string, A>) => B\nexport function reduce<A, B>(\n  ...args: [Ord<string>] | [B, (b: B, a: A) => B]\n): ((b: B, f: (b: B, a: A) => B) => (fa: ReadonlyRecord<string, A>) => B) | ((fa: ReadonlyRecord<string, A>) => B) {\n  if (args.length === 1) {\n    const reduceWithIndexO = reduceWithIndex(args[0])\n    return (b: B, f: (b: B, a: A) => B) => reduceWithIndexO(b, (_, b, a) => f(b, a))\n  }\n  return reduce(S.Ord)(...args)\n}\n\n/**\n * Map and fold a `ReadonlyRecord`.\n * Map the `ReadonlyRecord` passing each value to the iterating function.\n * Then fold the results using the provided `Monoid`.\n *\n * @example\n * import { foldMap } from \"fp-ts/ReadonlyRecord\";\n * import { Ord } from \"fp-ts/string\";\n * import { Monoid } from \"fp-ts/Monoid\";\n *\n * const m: Monoid<string> = { empty: \"\", concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) };\n * const f = (a: number) => `-${a}-`;\n * const x = { c: 3, a: 1, b: 2 };\n * assert.deepStrictEqual(foldMap(Ord)(m)(f)(x), \"-1- -> -2- -> -3-\");\n *\n * @category folding\n * @since 2.5.0\n */\nexport function foldMap(\n  O: Ord<string>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: ReadonlyRecord<string, A>) => M\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function foldMap<M>(M: Monoid<M>): <A>(f: (a: A) => M) => (fa: ReadonlyRecord<string, A>) => M\nexport function foldMap<M>(\n  O: Ord<string> | Monoid<M>\n):\n  | ((M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: ReadonlyRecord<string, A>) => M)\n  | (<A>(f: (a: A) => M) => (fa: ReadonlyRecord<string, A>) => M) {\n  if ('compare' in O) {\n    const foldMapWithIndexO = foldMapWithIndex(O)\n    return (M: Monoid<M>) => {\n      const foldMapWithIndexM = foldMapWithIndexO(M)\n      return <A>(f: (a: A) => M): ((fa: ReadonlyRecord<string, A>) => M) => foldMapWithIndexM((_, a) => f(a))\n    }\n  }\n  return foldMap(S.Ord)(O)\n}\n\n/**\n * Same as `reduce` but entries are processed _from the right_,\n * i.e. in reverse order, from the last to the first entry, according to\n * the given `Ord`.\n *\n * @example\n * import { reduceRight } from \"fp-ts/ReadonlyRecord\";\n * import { Ord } from \"fp-ts/string\";\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(reduceRight(Ord)([] as string[], (a, b) => [...b, `-${a}-`])(x), [\n *   \"-3-\",\n *   \"-false-\",\n *   \"-foo-\",\n * ]);\n *\n * @category folding\n * @since 2.5.0\n */\nexport function reduceRight(O: Ord<string>): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: ReadonlyRecord<string, A>) => B\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function reduceRight<A, B>(b: B, f: (a: A, b: B) => B): (fa: ReadonlyRecord<string, A>) => B\nexport function reduceRight<A, B>(\n  ...args: [Ord<string>] | [B, (a: A, b: B) => B]\n): ((b: B, f: (a: A, b: B) => B) => (fa: ReadonlyRecord<string, A>) => B) | ((fa: ReadonlyRecord<string, A>) => B) {\n  if (args.length === 1) {\n    const reduceRightWithIndexO = reduceRightWithIndex(args[0])\n    return (b: B, f: (a: A, b: B) => B) => reduceRightWithIndexO(b, (_, b, a) => f(b, a))\n  }\n  return reduceRight(S.Ord)(...args)\n}\n\n/**\n * Compact a `ReadonlyRecord` of `Option`s discarding the `None` values and\n * keeping the `Some` values.\n *\n * @example\n * import { compact } from 'fp-ts/ReadonlyRecord'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(compact({ a: option.some(\"foo\"), b: option.none, c: option.some(\"bar\") }), {\n *   a: \"foo\",\n *   c: \"bar\",\n * });\n *\n * @category filtering\n * @since 2.5.0\n */\nexport const compact = <A>(r: ReadonlyRecord<string, Option<A>>): ReadonlyRecord<string, A> => {\n  const out: Record<string, A> = {}\n  for (const k in r) {\n    if (_.has.call(r, k)) {\n      const oa = r[k]\n      if (_.isSome(oa)) {\n        out[k] = oa.value\n      }\n    }\n  }\n  return out\n}\n\n/**\n * Separate a `ReadonlyRecord` of `Either`s into `Left`s and `Right`s.\n *\n * @example\n * import { separate } from 'fp-ts/ReadonlyRecord'\n * import { either } from 'fp-ts'\n *\n * assert.deepStrictEqual(\n *   separate({ a: either.right(\"foo\"), b: either.left(\"bar\"), c: either.right(\"baz\") }),\n *   {\n *     right: {\n *       a: \"foo\",\n *       c: \"baz\",\n *     },\n *     left: {\n *       b: \"bar\",\n *     },\n *   }\n * );\n *\n * @category filtering\n * @since 2.5.0\n */\nexport const separate = <A, B>(\n  r: ReadonlyRecord<string, Either<A, B>>\n): Separated<ReadonlyRecord<string, A>, ReadonlyRecord<string, B>> => {\n  const left: Record<string, A> = {}\n  const right: Record<string, B> = {}\n  for (const k in r) {\n    if (_.has.call(r, k)) {\n      const e = r[k]\n      if (_.isLeft(e)) {\n        left[k] = e.left\n      } else {\n        right[k] = e.right\n      }\n    }\n  }\n  return separated(left, right)\n}\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport const URI = 'ReadonlyRecord'\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: ReadonlyRecord<string, A>\n  }\n}\n\n/**\n * Produces a `Show` for a `ReadonlyRecord`, given a `Show` for the base type\n * (a `Show` produces a human-readable representation of an instance).\n * `ReadonlyRecord` entries are sorted by key with the provided `Ord`.\n *\n * @example\n * import { getShow, ReadonlyRecord } from \"fp-ts/ReadonlyRecord\"\n * import { Show } from \"fp-ts/Show\"\n * import { Ord } from \"fp-ts/string\"\n *\n * const sNumber: Show<number> = { show: (n: number) => `${n}` };\n * const sRecord: Show<ReadonlyRecord<string, number>> = getShow(Ord)(sNumber);\n * assert.deepStrictEqual(sRecord.show({ b: 2, a: 1 }), '{ \"a\": 1, \"b\": 2 }');\n *\n * @category instances\n * @since 2.5.0\n */\nexport function getShow(O: Ord<string>): <A>(S: Show<A>) => Show<ReadonlyRecord<string, A>>\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @category zone of death\n * @deprecated\n */\nexport function getShow<A>(S: Show<A>): Show<ReadonlyRecord<string, A>>\nexport function getShow<A>(\n  O: Ord<string> | Show<A>\n): ((S: Show<A>) => Show<ReadonlyRecord<string, A>>) | Show<ReadonlyRecord<string, A>> {\n  if ('compare' in O) {\n    return (S: Show<A>) => ({\n      show: (r: ReadonlyRecord<string, A>) => {\n        const elements = collect(O)((k, a: A) => `${JSON.stringify(k)}: ${S.show(a)}`)(r).join(', ')\n        return elements === '' ? '{}' : `{ ${elements} }`\n      }\n    })\n  }\n  return getShow(S.Ord)(O)\n}\n\n/**\n * Given an `Eq` for the base type, it produces an `Eq`\n * for a `ReadonlyRecord` of that base type.\n *\n * @example\n * import { getEq, ReadonlyRecord } from \"fp-ts/ReadonlyRecord\";\n * import { string } from \"fp-ts\";\n * import { Eq } from \"fp-ts/Eq\";\n *\n * const eq: Eq<ReadonlyRecord<string, string>> = getEq(string.Eq);\n * assert.deepStrictEqual(eq.equals({ a: \"foo\" }, { b: \"bar\" }), false);\n * assert.deepStrictEqual(eq.equals({ a: \"foo\" }, { a: \"foo\" }), true);\n *\n * @category instances\n * @since 2.5.0\n */\nexport function getEq<K extends string, A>(E: Eq<A>): Eq<ReadonlyRecord<K, A>>\nexport function getEq<A>(E: Eq<A>): Eq<ReadonlyRecord<string, A>> {\n  const isSubrecordE = isSubrecord(E)\n  return fromEquals((x, y) => isSubrecordE(x)(y) && isSubrecordE(y)(x))\n}\n\n/**\n * Returns a `Monoid` instance for `ReadonlyRecord`s, given a `Semigroup`\n * instance for the base type.\n * The `Monoid` makes the union of two `ReadonlyRecord`s comining the\n * overlapping entries with the provided `Semigroup`.\n *\n * @example\n * import { SemigroupSum } from 'fp-ts/number'\n * import { getMonoid } from 'fp-ts/ReadonlyRecord'\n *\n * const M = getMonoid(SemigroupSum);\n * assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579 , bar: 234, baz: 567 });\n *\n * @category instances\n * @since 2.5.0\n */\nexport function getMonoid<K extends string, A>(S: Semigroup<A>): Monoid<ReadonlyRecord<K, A>>\nexport function getMonoid<A>(S: Semigroup<A>): Monoid<ReadonlyRecord<string, A>> {\n  return {\n    concat: (first, second) => {\n      if (isEmpty(first)) {\n        return second\n      }\n      if (isEmpty(second)) {\n        return first\n      }\n      const r: Record<string, A> = Object.assign({}, first)\n      for (const k in second) {\n        if (_.has.call(second, k)) {\n          r[k] = _.has.call(first, k) ? S.concat(first[k], second[k]) : second[k]\n        }\n      }\n      return r\n    },\n    empty\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Takes a value and a `ReadonlyRecord` of functions and returns a\n * `ReadonlyRecord` by applying each function to the input value.\n *\n * @example\n * import { flap } from \"fp-ts/ReadonlyRecord\"\n *\n * const fab = { x: (n: number) => `${n} times 2`, y: (n: number) => `${n * 2}` };\n * assert.deepStrictEqual(flap(3)(fab), {\n *   x: \"3 times 2\",\n *   y: \"6\",\n * });\n *\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FunctorWithIndex: FunctorWithIndex1<URI, string> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex\n}\n\n/**\n * Produces a `Foldable` instance for a `ReadonlyRecord`, using the\n * provided `Ord` to sort the `ReadonlyRecord`'s entries by key.\n *\n * @category folding\n * @since 2.11.0\n */\nexport const getFoldable = (O: Ord<string>): Foldable1<URI> => ({\n  URI,\n  reduce: _reduce(O),\n  foldMap: _foldMap(O),\n  reduceRight: _reduceRight(O)\n})\n\n/**\n * Produces a `FoldableWithIndex1` instance for a `ReadonlyRecord`, using the\n * provided `Ord` to sort the `ReadonlyRecord`'s entries by key.\n *\n * @category folding\n * @since 2.11.0\n */\nexport const getFoldableWithIndex = (O: Ord<string>): FoldableWithIndex1<URI, string> => ({\n  URI,\n  reduce: _reduce(O),\n  foldMap: _foldMap(O),\n  reduceRight: _reduceRight(O),\n  reduceWithIndex: _reduceWithIndex(O),\n  foldMapWithIndex: _foldMapWithIndex(O),\n  reduceRightWithIndex: _reduceRightWithIndex(O)\n})\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Compactable: Compactable1<URI> = {\n  URI,\n  compact,\n  separate\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Filterable: Filterable1<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FilterableWithIndex: FilterableWithIndex1<URI, string> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  filterMapWithIndex: _filterMapWithIndex,\n  filterWithIndex: _filterWithIndex,\n  partitionMapWithIndex: _partitionMapWithIndex,\n  partitionWithIndex: _partitionWithIndex\n}\n\n/**\n * Produces a `Traversable` instance for a `ReadonlyRecord`, using the\n * provided `Ord` to sort the `ReadonlyRecord`'s entries by key.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const getTraversable = (O: Ord<string>): Traversable1<URI> => ({\n  URI,\n  map: _map,\n  reduce: _reduce(O),\n  foldMap: _foldMap(O),\n  reduceRight: _reduceRight(O),\n  traverse: _traverse(O),\n  sequence: _sequence(O)\n})\n\n/**\n * Produces a `TraversableWithIndex` instance for a `ReadonlyRecord`, using the\n * provided `Ord` to sort the `ReadonlyRecord`'s entries by key.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const getTraversableWithIndex = (O: Ord<string>): TraversableWithIndex1<URI, string> => ({\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  reduce: _reduce(O),\n  foldMap: _foldMap(O),\n  reduceRight: _reduceRight(O),\n  reduceWithIndex: _reduceWithIndex(O),\n  foldMapWithIndex: _foldMapWithIndex(O),\n  reduceRightWithIndex: _reduceRightWithIndex(O),\n  traverse: _traverse(O),\n  sequence: _sequence(O),\n  traverseWithIndex: _traverseWithIndex(O)\n})\n\n/**\n * @category filtering\n * @since 2.11.0\n */\nexport const getWitherable = (O: Ord<string>): Witherable1<URI> => {\n  const T = getTraversable(O)\n  return {\n    URI,\n    map: _map,\n    reduce: _reduce(O),\n    foldMap: _foldMap(O),\n    reduceRight: _reduceRight(O),\n    traverse: T.traverse,\n    sequence: T.sequence,\n    compact,\n    separate,\n    filter: _filter,\n    filterMap: _filterMap,\n    partition: _partition,\n    partitionMap: _partitionMap,\n    wither: witherDefault(T, Compactable),\n    wilt: wiltDefault(T, Compactable)\n  }\n}\n\n/**\n * Given a `Semigroup` in the base type, it produces a `Semigroup`\n * in the `ReadonlyRecord` of the base type.\n * The resulting `Semigroup` concatenates two `ReadonlyRecord`s by\n * `union`.\n *\n * @example\n * import { getUnionSemigroup, ReadonlyRecord } from \"fp-ts/ReadonlyRecord\"\n * import { Semigroup } from \"fp-ts/Semigroup\"\n *\n * const sNumber: Semigroup<number> = { concat: (x, y) => x - y };\n * const sReadonlyRecord: Semigroup<ReadonlyRecord<string, number>> = getUnionSemigroup(sNumber);\n * assert.deepStrictEqual(sReadonlyRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { a: 1, b: -1, c: 4 });\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <A>(S: Semigroup<A>): Semigroup<ReadonlyRecord<string, A>> => {\n  const unionS = union(S)\n  return {\n    concat: (first, second) => unionS(second)(first)\n  }\n}\n\n/**\n * Same as `getMonoid`.\n * Returns a `Monoid` instance for `ReadonlyRecord`s given a `Semigroup`\n * instance for the base type.\n * The `Monoid` makes the union of two `ReadonlyRecord`s combining the\n * entries that have the same key with the provided `Semigroup`.\n *\n * @example\n * import { SemigroupSum } from 'fp-ts/number'\n * import { getUnionMonoid } from 'fp-ts/ReadonlyRecord'\n *\n * const M = getUnionMonoid(SemigroupSum);\n * assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579 , bar: 234, baz: 567 });\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionMonoid = <A>(S: Semigroup<A>): Monoid<ReadonlyRecord<string, A>> => ({\n  concat: getUnionSemigroup(S).concat,\n  empty\n})\n\n/**\n * Given a `Semigroup` in the base type, it produces a `Semigroup`\n * in the `ReadonlyRecord` of the base type.\n * The resulting `Semigroup` concatenates two `ReadonlyRecord`s by\n * `intersection`.\n *\n * @example\n * import { getIntersectionSemigroup, ReadonlyRecord } from \"fp-ts/ReadonlyRecord\"\n * import { Semigroup } from \"fp-ts/Semigroup\"\n *\n * const sNumber: Semigroup<number> = { concat: (x, y) => x - y };\n * const sReadonlyRecord: Semigroup<ReadonlyRecord<string, number>> = getIntersectionSemigroup(sNumber);\n * assert.deepStrictEqual(sReadonlyRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { b: -1 });\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getIntersectionSemigroup = <A>(S: Semigroup<A>): Semigroup<ReadonlyRecord<string, A>> => {\n  const intersectionS = intersection(S)\n  return {\n    concat: (first, second) => intersectionS(second)(first)\n  }\n}\n\n/**\n * Produces a `Magma` with a `concat` function that combines\n * two `ReadonlyRecord`s by making the `difference`.\n *\n * @example\n * import { getDifferenceMagma, difference, ReadonlyRecord } from \"fp-ts/ReadonlyRecord\"\n * import { Magma } from \"fp-ts/Magma\"\n *\n * const r1 = { a: 3, c: 3 };\n * const r2 = { a: 1, b: 2 };\n * const m: Magma<ReadonlyRecord<string, number>> = getDifferenceMagma<number>();\n * assert.deepStrictEqual(m.concat(r1, r2), difference(r2)(r1));\n * assert.deepStrictEqual(m.concat(r1, r2), { c: 3, b: 2 });\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getDifferenceMagma = <A>(): Magma<ReadonlyRecord<string, A>> => ({\n  concat: (first, second) => difference(second)(first)\n})\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use `getFoldable` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const Foldable: Foldable1<URI> = {\n  URI,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord)\n}\n\n/**\n * Use `getFoldableWithIndex` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const FoldableWithIndex: FoldableWithIndex1<URI, string> = {\n  URI,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  reduceWithIndex: /*#__PURE__*/ _reduceWithIndex(S.Ord),\n  foldMapWithIndex: /*#__PURE__*/ _foldMapWithIndex(S.Ord),\n  reduceRightWithIndex: /*#__PURE__*/ _reduceRightWithIndex(S.Ord)\n}\n\n/**\n * Use `getTraversable` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const Traversable: Traversable1<URI> = {\n  URI,\n  map: _map,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  traverse: /*#__PURE__*/ _traverse(S.Ord),\n  sequence\n}\n\n/**\n * Use `getTraversableWithIndex` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const TraversableWithIndex: TraversableWithIndex1<URI, string> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  reduceWithIndex: /*#__PURE__*/ _reduceWithIndex(S.Ord),\n  foldMapWithIndex: /*#__PURE__*/ _foldMapWithIndex(S.Ord),\n  reduceRightWithIndex: /*#__PURE__*/ _reduceRightWithIndex(S.Ord),\n  traverse: /*#__PURE__*/ _traverse(S.Ord),\n  sequence,\n  traverseWithIndex: /*#__PURE__*/ _traverseWithIndex(S.Ord)\n}\n\nconst _wither = /*#__PURE__*/ witherDefault(Traversable, Compactable)\nconst _wilt = /*#__PURE__*/ wiltDefault(Traversable, Compactable)\n\n/**\n * Use `getWitherable` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const Witherable: Witherable1<URI> = {\n  URI,\n  map: _map,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  traverse: /*#__PURE__*/ _traverse(S.Ord),\n  sequence,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  wither: _wither,\n  wilt: _wilt\n}\n\n/**\n * Use [`upsertAt`](#upsertat) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const insertAt: <A>(k: string, a: A) => (r: ReadonlyRecord<string, A>) => ReadonlyRecord<string, A> = upsertAt\n\n/**\n * Use [`has`](#has) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport function hasOwnProperty<K extends string>(k: string, r: ReadonlyRecord<K, unknown>): k is K\nexport function hasOwnProperty<K extends string>(this: any, k: string, r?: ReadonlyRecord<K, unknown>): k is K {\n  return _.has.call(r === undefined ? this : r, k)\n}\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RR.Functor` instead of `RR.readonlyRecord`\n * (where `RR` is from `import RR from 'fp-ts/ReadonlyRecord'`)\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const readonlyRecord: FunctorWithIndex1<URI, string> &\n  FoldableWithIndex1<URI, string> &\n  FilterableWithIndex1<URI, string> &\n  TraversableWithIndex1<URI, string> &\n  Witherable1<URI> = {\n  URI,\n  map: _map,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  traverse: /*#__PURE__*/ _traverse(S.Ord),\n  sequence,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  mapWithIndex: _mapWithIndex,\n  reduceWithIndex: /*#__PURE__*/ _reduceWithIndex(S.Ord),\n  foldMapWithIndex: /*#__PURE__*/ _foldMapWithIndex(S.Ord),\n  reduceRightWithIndex: /*#__PURE__*/ _reduceRightWithIndex(S.Ord),\n  filterMapWithIndex: _filterMapWithIndex,\n  filterWithIndex: _filterWithIndex,\n  partitionMapWithIndex: _partitionMapWithIndex,\n  partitionWithIndex: _partitionWithIndex,\n  traverseWithIndex: /*#__PURE__*/ _traverseWithIndex(S.Ord),\n  wither: _wither,\n  wilt: _wilt\n}\n"
  },
  {
    "path": "src/ReadonlySet.ts",
    "content": "/**\n * @since 2.5.0\n */\nimport { Either } from './Either'\nimport { Eq, fromEquals } from './Eq'\nimport { identity } from './function'\nimport { Magma } from './Magma'\nimport { Monoid } from './Monoid'\nimport { Option } from './Option'\nimport { Ord } from './Ord'\nimport { not, Predicate } from './Predicate'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport { Separated, separated } from './Separated'\nimport { Show } from './Show'\n\n/**\n * @category conversions\n * @since 2.5.0\n */\nexport const fromSet = <A>(s: Set<A>): ReadonlySet<A> => new Set(s)\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Create a set with one element\n *\n * @category constructors\n * @since 2.5.0\n */\nexport const singleton = <A>(a: A): ReadonlySet<A> => new Set([a])\n\n/**\n * Create a `ReadonlySet` from a `ReadonlyArray`\n *\n * @category conversions\n * @since 2.10.0\n */\nexport const fromReadonlyArray =\n  <A>(E: Eq<A>) =>\n  (as: ReadonlyArray<A>): ReadonlySet<A> => {\n    const len = as.length\n    const out = new Set<A>()\n    const has = elem(E)\n    for (let i = 0; i < len; i++) {\n      const a = as[i]\n      if (!has(a, out)) {\n        out.add(a)\n      }\n    }\n    return out\n  }\n\n/**\n * @category conversions\n * @since 2.5.0\n */\nexport function toSet<A>(s: ReadonlySet<A>): Set<A> {\n  return new Set(s)\n}\n\ntype Next<A> = IteratorResult<A, undefined>\n\n/**\n * Projects a Set through a function\n *\n * @since 2.5.0\n */\nexport function map<B>(E: Eq<B>): <A>(f: (x: A) => B) => (set: ReadonlySet<A>) => ReadonlySet<B> {\n  const elemE = elem(E)\n  return (f) => (set) => {\n    const r = new Set<B>()\n    set.forEach((e) => {\n      const v = f(e)\n      if (!elemE(v, r)) {\n        r.add(v)\n      }\n    })\n    return r\n  }\n}\n\n/**\n * @since 2.5.0\n */\nexport function chain<B>(E: Eq<B>): <A>(f: (x: A) => ReadonlySet<B>) => (set: ReadonlySet<A>) => ReadonlySet<B> {\n  const elemE = elem(E)\n  return (f) => (set) => {\n    const r = new Set<B>()\n    set.forEach((e) => {\n      f(e).forEach((e) => {\n        if (!elemE(e, r)) {\n          r.add(e)\n        }\n      })\n    })\n    return r\n  }\n}\n\n/**\n * @since 2.5.0\n */\nexport function filter<A, B extends A>(refinement: Refinement<A, B>): (set: ReadonlySet<A>) => ReadonlySet<B>\nexport function filter<A>(predicate: Predicate<A>): <B extends A>(set: ReadonlySet<B>) => ReadonlySet<B>\nexport function filter<A>(predicate: Predicate<A>): (set: ReadonlySet<A>) => ReadonlySet<A>\nexport function filter<A>(predicate: Predicate<A>): (set: ReadonlySet<A>) => ReadonlySet<A> {\n  return (set: ReadonlySet<A>) => {\n    const values = set.values()\n    let e: Next<A>\n    const r = new Set<A>()\n    while (!(e = values.next()).done) {\n      const a = e.value\n      if (predicate(a)) {\n        r.add(a)\n      }\n    }\n    return r\n  }\n}\n\n/**\n * @since 2.5.0\n */\nexport function partition<A, B extends A>(\n  refinement: Refinement<A, B>\n): (set: ReadonlySet<A>) => Separated<ReadonlySet<A>, ReadonlySet<B>>\nexport function partition<A>(\n  predicate: Predicate<A>\n): <B extends A>(set: ReadonlySet<B>) => Separated<ReadonlySet<B>, ReadonlySet<B>>\nexport function partition<A>(\n  predicate: Predicate<A>\n): (set: ReadonlySet<A>) => Separated<ReadonlySet<A>, ReadonlySet<A>>\nexport function partition<A>(\n  predicate: Predicate<A>\n): (set: ReadonlySet<A>) => Separated<ReadonlySet<A>, ReadonlySet<A>> {\n  return (set: ReadonlySet<A>) => {\n    const values = set.values()\n    let e: Next<A>\n    const right = new Set<A>()\n    const left = new Set<A>()\n    while (!(e = values.next()).done) {\n      const a = e.value\n      if (predicate(a)) {\n        right.add(a)\n      } else {\n        left.add(a)\n      }\n    }\n    return separated(left, right)\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Form the union of two sets\n *\n * @since 2.5.0\n */\nexport function union<A>(E: Eq<A>): {\n  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => ReadonlySet<A>\n  (me: ReadonlySet<A>, that: ReadonlySet<A>): ReadonlySet<A>\n}\nexport function union<A>(\n  E: Eq<A>\n): (me: ReadonlySet<A>, that?: ReadonlySet<A>) => ReadonlySet<A> | ((me: ReadonlySet<A>) => ReadonlySet<A>) {\n  const elemE = elem(E)\n  return (me, that?) => {\n    if (that === undefined) {\n      const unionE = union(E)\n      return (that) => unionE(me, that)\n    }\n    if (isEmpty(me)) {\n      return that\n    }\n    if (isEmpty(that)) {\n      return me\n    }\n    const r = new Set(me)\n    that.forEach((e) => {\n      if (!elemE(e, r)) {\n        r.add(e)\n      }\n    })\n    return r\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * The set of elements which are in both the first and second set\n *\n * @since 2.5.0\n */\nexport function intersection<A>(E: Eq<A>): {\n  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => ReadonlySet<A>\n  (me: ReadonlySet<A>, that: ReadonlySet<A>): ReadonlySet<A>\n}\nexport function intersection<A>(\n  E: Eq<A>\n): (me: ReadonlySet<A>, that?: ReadonlySet<A>) => ReadonlySet<A> | ((that: ReadonlySet<A>) => ReadonlySet<A>) {\n  const elemE = elem(E)\n  return (me, that?) => {\n    if (that === undefined) {\n      const intersectionE = intersection(E)\n      return (that) => intersectionE(that, me)\n    }\n    if (isEmpty(me) || isEmpty(that)) {\n      return empty\n    }\n    const r = new Set<A>()\n    me.forEach((e) => {\n      if (elemE(e, that)) {\n        r.add(e)\n      }\n    })\n    return r\n  }\n}\n\n/**\n * @since 2.5.0\n */\nexport function partitionMap<B, C>(\n  EB: Eq<B>,\n  EC: Eq<C>\n): <A>(f: (a: A) => Either<B, C>) => (set: ReadonlySet<A>) => Separated<ReadonlySet<B>, ReadonlySet<C>> {\n  return <A>(f: (a: A) => Either<B, C>) =>\n    (set: ReadonlySet<A>) => {\n      const values = set.values()\n      let e: Next<A>\n      const left = new Set<B>()\n      const right = new Set<C>()\n      const hasB = elem(EB)\n      const hasC = elem(EC)\n      while (!(e = values.next()).done) {\n        const v = f(e.value)\n        switch (v._tag) {\n          case 'Left':\n            if (!hasB(v.left, left)) {\n              left.add(v.left)\n            }\n            break\n          case 'Right':\n            if (!hasC(v.right, right)) {\n              right.add(v.right)\n            }\n            break\n        }\n      }\n      return separated(left, right)\n    }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Form the set difference (`x` - `y`)\n *\n * @example\n * import { difference } from 'fp-ts/ReadonlySet'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe(new Set([1, 2]), difference(N.Eq)(new Set([1, 3]))), new Set([2]))\n *\n * @since 2.5.0\n */\nexport function difference<A>(E: Eq<A>): {\n  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => ReadonlySet<A>\n  (me: ReadonlySet<A>, that: ReadonlySet<A>): ReadonlySet<A>\n}\nexport function difference<A>(\n  E: Eq<A>\n): (me: ReadonlySet<A>, that?: ReadonlySet<A>) => ReadonlySet<A> | ((me: ReadonlySet<A>) => ReadonlySet<A>) {\n  const elemE = elem(E)\n  return (me, that?) => {\n    if (that === undefined) {\n      const differenceE = difference(E)\n      return (that) => differenceE(that, me)\n    }\n    return filter((a: A) => !elemE(a, that))(me)\n  }\n}\n\n/**\n * @since 2.5.0\n */\nexport function reduce<A>(O: Ord<A>): <B>(b: B, f: (b: B, a: A) => B) => (fa: ReadonlySet<A>) => B {\n  const toReadonlyArrayO = toReadonlyArray(O)\n  return (b, f) => (fa) => toReadonlyArrayO(fa).reduce(f, b)\n}\n\n/**\n * @since 2.5.0\n */\nexport function foldMap<A, M>(O: Ord<A>, M: Monoid<M>): (f: (a: A) => M) => (fa: ReadonlySet<A>) => M {\n  const toReadonlyArrayO = toReadonlyArray(O)\n  return (f) => (fa) => toReadonlyArrayO(fa).reduce((b, a) => M.concat(b, f(a)), M.empty)\n}\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduceRight = <A>(O: Ord<A>): (<B>(b: B, f: (a: A, b: B) => B) => (fa: ReadonlySet<A>) => B) => {\n  const toReadonlyArrayO = toReadonlyArray(O)\n  return (b, f) => (fa) => toReadonlyArrayO(fa).reduceRight((b, a) => f(a, b), b)\n}\n\n/**\n * Insert a value into a set\n *\n * @since 2.5.0\n */\nexport function insert<A>(E: Eq<A>): (a: A) => (set: ReadonlySet<A>) => ReadonlySet<A> {\n  const elemE = elem(E)\n  return (a) => (set) => {\n    if (!elemE(a)(set)) {\n      const r = new Set(set)\n      r.add(a)\n      return r\n    } else {\n      return set\n    }\n  }\n}\n\n/**\n * Delete a value from a set\n *\n * @since 2.5.0\n */\nexport const remove =\n  <A>(E: Eq<A>) =>\n  (a: A) =>\n  (set: ReadonlySet<A>): ReadonlySet<A> =>\n    filter((ax: A) => !E.equals(a, ax))(set)\n\n/**\n * Checks an element is a member of a set;\n * If yes, removes the value from the set\n * If no, inserts the value to the set\n *\n * @since 2.10.0\n */\nexport const toggle = <A>(E: Eq<A>): ((a: A) => (set: ReadonlySet<A>) => ReadonlySet<A>) => {\n  const elemE = elem(E)\n  const removeE = remove(E)\n  const insertE = insert(E)\n  return (a) => (set) => (elemE(a, set) ? removeE : insertE)(a)(set)\n}\n\n/**\n * @since 2.5.0\n */\nexport const compact = <A>(E: Eq<A>): ((fa: ReadonlySet<Option<A>>) => ReadonlySet<A>) => filterMap(E)(identity)\n\n/**\n * @since 2.5.0\n */\nexport function separate<E, A>(\n  EE: Eq<E>,\n  EA: Eq<A>\n): (fa: ReadonlySet<Either<E, A>>) => Separated<ReadonlySet<E>, ReadonlySet<A>> {\n  return (fa) => {\n    const elemEE = elem(EE)\n    const elemEA = elem(EA)\n    const left: Set<E> = new Set()\n    const right: Set<A> = new Set()\n    fa.forEach((e) => {\n      switch (e._tag) {\n        case 'Left':\n          if (!elemEE(e.left, left)) {\n            left.add(e.left)\n          }\n          break\n        case 'Right':\n          if (!elemEA(e.right, right)) {\n            right.add(e.right)\n          }\n          break\n      }\n    })\n    return separated(left, right)\n  }\n}\n\n/**\n * @since 2.5.0\n */\nexport function filterMap<B>(E: Eq<B>): <A>(f: (a: A) => Option<B>) => (fa: ReadonlySet<A>) => ReadonlySet<B> {\n  const elemE = elem(E)\n  return (f) => (fa) => {\n    const r: Set<B> = new Set()\n    fa.forEach((a) => {\n      const ob = f(a)\n      if (ob._tag === 'Some' && !elemE(ob.value, r)) {\n        r.add(ob.value)\n      }\n    })\n    return r\n  }\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.5.0\n */\nexport const empty: ReadonlySet<never> = new Set()\n\n/**\n * Test whether a `ReadonlySet` is empty.\n *\n * @since 2.10.0\n */\nexport const isEmpty = <A>(set: ReadonlySet<A>): boolean => set.size === 0\n\n/**\n * Calculate the number of elements in a `ReadonlySet`.\n *\n * @since 2.10.0\n */\nexport const size = <A>(set: ReadonlySet<A>): number => set.size\n\n/**\n * @since 2.5.0\n */\nexport const some =\n  <A>(predicate: Predicate<A>) =>\n  (set: ReadonlySet<A>): boolean => {\n    const values = set.values()\n    let e: Next<A>\n    let found = false\n    while (!found && !(e = values.next()).done) {\n      found = predicate(e.value)\n    }\n    return found\n  }\n\n/**\n * @since 2.5.0\n */\nexport function every<A, B extends A>(refinement: Refinement<A, B>): Refinement<ReadonlySet<A>, ReadonlySet<B>>\nexport function every<A>(predicate: Predicate<A>): Predicate<ReadonlySet<A>>\nexport function every<A>(predicate: Predicate<A>): Predicate<ReadonlySet<A>> {\n  return not(some(not(predicate)))\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * `true` if and only if every element in the first set is an element of the second set\n *\n * @since 2.5.0\n */\nexport function isSubset<A>(E: Eq<A>): {\n  (that: ReadonlySet<A>): (me: ReadonlySet<A>) => boolean\n  (me: ReadonlySet<A>, that: ReadonlySet<A>): boolean\n}\nexport function isSubset<A>(\n  E: Eq<A>\n): (me: ReadonlySet<A>, that?: ReadonlySet<A>) => boolean | ((me: ReadonlySet<A>) => boolean) {\n  const elemE = elem(E)\n  return (me, that?) => {\n    if (that === undefined) {\n      const isSubsetE = isSubset(E)\n      return (that) => isSubsetE(that, me)\n    }\n    return every((a: A) => elemE(a, that))(me)\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test if a value is a member of a set\n *\n * @since 2.5.0\n */\nexport function elem<A>(E: Eq<A>): {\n  (a: A): (set: ReadonlySet<A>) => boolean\n  (a: A, set: ReadonlySet<A>): boolean\n}\nexport function elem<A>(E: Eq<A>): (a: A, set?: ReadonlySet<A>) => boolean | ((set: ReadonlySet<A>) => boolean) {\n  return (a, set?) => {\n    if (set === undefined) {\n      const elemE = elem(E)\n      return (set) => elemE(a, set)\n    }\n    const values = set.values()\n    let e: Next<A>\n    let found = false\n    while (!found && !(e = values.next()).done) {\n      found = E.equals(a, e.value)\n    }\n    return found\n  }\n}\n\n/**\n * Get a sorted `ReadonlyArray` of the values contained in a `ReadonlySet`.\n *\n * @category conversions\n * @since 2.5.0\n */\nexport const toReadonlyArray =\n  <A>(O: Ord<A>) =>\n  (set: ReadonlySet<A>): ReadonlyArray<A> => {\n    const out: Array<A> = []\n    set.forEach((e) => out.push(e))\n    return out.sort(O.compare)\n  }\n\n/**\n * @category type lambdas\n * @since 2.11.0\n */\nexport const URI = 'ReadonlySet'\n\n/**\n * @category type lambdas\n * @since 2.11.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: ReadonlySet<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport function getShow<A>(S: Show<A>): Show<ReadonlySet<A>> {\n  return {\n    show: (s) => {\n      const entries: Array<string> = []\n      s.forEach((a) => {\n        entries.push(S.show(a))\n      })\n      return `new Set([${entries.sort().join(', ')}])`\n    }\n  }\n}\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport function getEq<A>(E: Eq<A>): Eq<ReadonlySet<A>> {\n  const subsetE = isSubset(E)\n  return fromEquals((x, y) => subsetE(x, y) && subsetE(y, x))\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <A>(E: Eq<A>): Semigroup<ReadonlySet<A>> => ({\n  concat: union(E)\n})\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport const getUnionMonoid = <A>(E: Eq<A>): Monoid<ReadonlySet<A>> => ({\n  concat: getUnionSemigroup(E).concat,\n  empty\n})\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport const getIntersectionSemigroup = <A>(E: Eq<A>): Semigroup<ReadonlySet<A>> => ({\n  concat: intersection(E)\n})\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getDifferenceMagma = <A>(E: Eq<A>): Magma<ReadonlySet<A>> => ({\n  concat: difference(E)\n})\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`fromReadonlyArray`](#fromreadonlyarray) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const fromArray: <A>(E: Eq<A>) => (as: ReadonlyArray<A>) => ReadonlySet<A> = fromReadonlyArray\n"
  },
  {
    "path": "src/ReadonlyTuple.ts",
    "content": "/**\n * @since 2.5.0\n */\nimport { Applicative, Applicative2C } from './Applicative'\nimport { Apply2C } from './Apply'\nimport { Bifunctor2 } from './Bifunctor'\nimport { Chain2C } from './Chain'\nimport { ChainRec2C } from './ChainRec'\nimport { Comonad2 } from './Comonad'\nimport { Either } from './Either'\nimport { Extend2 } from './Extend'\nimport { Foldable2 } from './Foldable'\nimport { identity, pipe } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\nimport { HKT } from './HKT'\nimport { Monad2C } from './Monad'\nimport { Monoid } from './Monoid'\nimport { Semigroup } from './Semigroup'\nimport { Semigroupoid2 } from './Semigroupoid'\nimport { PipeableTraverse2, Traversable2 } from './Traversable'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.5.0\n */\nexport function fst<A, E>(ea: readonly [A, E]): A {\n  return ea[0]\n}\n\n/**\n * @since 2.5.0\n */\nexport function snd<A, E>(ea: readonly [A, E]): E {\n  return ea[1]\n}\n\n/**\n * @since 2.5.0\n */\nexport const swap = <A, E>(ea: readonly [A, E]): readonly [E, A] => [snd(ea), fst(ea)]\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport function getApply<S>(S: Semigroup<S>): Apply2C<URI, S> {\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: (fab, fa) => [fst(fab)(fst(fa)), S.concat(snd(fab), snd(fa))]\n  }\n}\n\nconst of =\n  <M>(M: Monoid<M>) =>\n  <A>(a: A): readonly [A, M] => {\n    return [a, M.empty]\n  }\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport function getApplicative<M>(M: Monoid<M>): Applicative2C<URI, M> {\n  const A = getApply(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: A.ap,\n    of: of(M)\n  }\n}\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport function getChain<S>(S: Semigroup<S>): Chain2C<URI, S> {\n  const A = getApply(S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: A.ap,\n    chain: (ma, f) => {\n      const [b, s] = f(fst(ma))\n      return [b, S.concat(snd(ma), s)]\n    }\n  }\n}\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport function getMonad<M>(M: Monoid<M>): Monad2C<URI, M> {\n  const C = getChain(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: C.ap,\n    chain: C.chain,\n    of: of(M)\n  }\n}\n\n/**\n * @category instances\n * @since 2.5.0\n */\nexport function getChainRec<M>(M: Monoid<M>): ChainRec2C<URI, M> {\n  const chainRec = <A, B>(a: A, f: (a: A) => readonly [Either<A, B>, M]): readonly [B, M] => {\n    let result: readonly [Either<A, B>, M] = f(a)\n    let acc: M = M.empty\n    let s: Either<A, B> = fst(result)\n    while (s._tag === 'Left') {\n      acc = M.concat(acc, snd(result))\n      result = f(s.left)\n      s = fst(result)\n    }\n    return [s.right, M.concat(acc, snd(result))]\n  }\n\n  const C = getChain(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: C.ap,\n    chain: C.chain,\n    chainRec\n  }\n}\n\n/* istanbul ignore next */\nconst _compose: Semigroupoid2<URI>['compose'] = (bc, ab) => pipe(bc, compose(ab))\n/* istanbul ignore next */\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, mapFst(f))\n/* istanbul ignore next */\nconst _bimap: Bifunctor2<URI>['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g))\n/* istanbul ignore next */\nconst _mapLeft: Bifunctor2<URI>['mapLeft'] = (fa, f) => pipe(fa, mapSnd(f))\n/* istanbul ignore next */\nconst _extend: Extend2<URI>['extend'] = (wa, f) => pipe(wa, extend(f))\n/* istanbul ignore next */\nconst _reduce: Foldable2<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\n/* istanbul ignore next */\nconst _foldMap: Foldable2<URI>['foldMap'] = (M) => {\n  const foldMapM = foldMap(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\n/* istanbul ignore next */\nconst _reduceRight: Foldable2<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\n/* istanbul ignore next */\nconst _traverse = <F>(\n  F: Applicative<F>\n): (<A, S, B>(ta: readonly [A, S], f: (a: A) => HKT<F, B>) => HKT<F, readonly [B, S]>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\n\n/**\n * Map a pair of functions over the two type arguments of the bifunctor.\n *\n * @category mapping\n * @since 2.5.0\n */\nexport const bimap: <E, G, A, B>(\n  mapSnd: (e: E) => G,\n  mapFst: (a: A) => B\n) => (fa: readonly [A, E]) => readonly [B, G] = (f, g) => (fa) => [g(fst(fa)), f(snd(fa))]\n\n/**\n * Map a function over the first component of a `ReadonlyTuple`.\n *\n * This is the `map` operation of the `Functor` instance.\n *\n * @category mapping\n * @since 2.10.0\n */\nexport const mapFst: <A, B>(f: (a: A) => B) => <E>(fa: readonly [A, E]) => readonly [B, E] = (f) => (fa) =>\n  [f(fst(fa)), snd(fa)]\n\n/**\n * Map a function over the second component of a `ReadonlyTuple`.\n *\n * This is the `mapLeft` operation of the `Bifunctor` instance.\n *\n * @category mapping\n * @since 2.10.0\n */\nexport const mapSnd: <E, G>(f: (e: E) => G) => <A>(fa: readonly [A, E]) => readonly [A, G] = (f) => (fa) =>\n  [fst(fa), f(snd(fa))]\n\n/**\n * @since 2.5.0\n */\nexport const compose: <A, B>(ab: readonly [B, A]) => <C>(bc: readonly [C, B]) => readonly [C, A] = (ab) => (bc) =>\n  [fst(bc), snd(ab)]\n\n/**\n * @since 2.5.0\n */\nexport const extend: <E, A, B>(f: (wa: readonly [A, E]) => B) => (wa: readonly [A, E]) => readonly [B, E] =\n  (f) => (wa) =>\n    [f(wa), snd(wa)]\n\n/**\n * @category Extract\n * @since 2.6.2\n */\nexport const extract: <E, A>(wa: readonly [A, E]) => A = fst\n\n/**\n * @since 2.5.0\n */\nexport const duplicate: <E, A>(wa: readonly [A, E]) => readonly [readonly [A, E], E] = /*#__PURE__*/ extend(identity)\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: readonly [A, E]) => B = (b, f) => (fa) =>\n  f(b, fst(fa))\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: readonly [A, E]) => M = () => {\n  return (f) => (fa) => f(fst(fa))\n}\n\n/**\n * @category folding\n * @since 2.5.0\n */\nexport const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: readonly [A, E]) => B = (b, f) => (fa) =>\n  f(fst(fa), b)\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse2<URI> = <F>(\n  F: Applicative<F>\n): (<A, B>(f: (a: A) => HKT<F, B>) => <E>(as: readonly [A, E]) => HKT<F, readonly [B, E]>) => {\n  return (f) => (ta) => F.map(f(fst(ta)), (b) => [b, snd(ta)])\n}\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable2<URI>['sequence'] =\n  <F>(F: Applicative<F>) =>\n  <A, E>(fas: readonly [HKT<F, A>, E]): HKT<F, readonly [A, E]> => {\n    return F.map(fst(fas), (a) => [a, snd(fas)])\n  }\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport const URI = 'ReadonlyTuple'\n\n/**\n * @category type lambdas\n * @since 2.5.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: readonly [A, E]\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * Alias of [`mapFst`](#mapfst).\n *\n * @category mapping\n * @since 2.5.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: readonly [A, E]) => readonly [B, E] = mapFst\n\n/**\n * Alias of [`mapSnd`](#mapsnd).\n *\n * @category error handling\n * @since 2.5.0\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: readonly [A, E]) => readonly [A, G] = mapSnd\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor2<URI> = {\n  URI,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Semigroupoid: Semigroupoid2<URI> = {\n  URI,\n  compose: _compose\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Comonad: Comonad2<URI> = {\n  URI,\n  map: _map,\n  extend: _extend,\n  extract\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable2<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable2<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `RT.Functor` instead of `RT.readonlyTuple`\n * (where `RT` is from `import RT from 'fp-ts/ReadonlyTuple'`)\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const readonlyTuple: Semigroupoid2<URI> & Bifunctor2<URI> & Comonad2<URI> & Foldable2<URI> & Traversable2<URI> =\n  {\n    URI,\n    compose: _compose,\n    map: _map,\n    bimap: _bimap,\n    mapLeft: _mapLeft,\n    extract,\n    extend: _extend,\n    reduce: _reduce,\n    foldMap: _foldMap,\n    reduceRight: _reduceRight,\n    traverse: _traverse,\n    sequence\n  }\n"
  },
  {
    "path": "src/Record.ts",
    "content": "/**\n * The `Record` module enables dealing with Typescript's `Record<K, T>`\n * type in a functional way, basically treating it as a `Functor` in `T`.\n *\n * @since 2.0.0\n */\nimport {\n  Applicative,\n  Applicative1,\n  Applicative2,\n  Applicative2C,\n  Applicative3,\n  Applicative3C,\n  Applicative4\n} from './Applicative'\nimport * as A from './Array'\nimport { Compactable1 } from './Compactable'\nimport { Either } from './Either'\nimport { Eq } from './Eq'\nimport { Filterable1 } from './Filterable'\nimport { FilterableWithIndex1, PredicateWithIndex, RefinementWithIndex } from './FilterableWithIndex'\nimport { Foldable as FoldableHKT, Foldable1, Foldable2, Foldable3 } from './Foldable'\nimport { FoldableWithIndex1 } from './FoldableWithIndex'\nimport { pipe } from './function'\nimport { flap as flap_, Functor1 } from './Functor'\nimport { FunctorWithIndex1 } from './FunctorWithIndex'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport * as _ from './internal'\nimport { Magma } from './Magma'\nimport { Monoid } from './Monoid'\nimport { Option } from './Option'\nimport { Ord } from './Ord'\nimport { Predicate } from './Predicate'\nimport * as RR from './ReadonlyRecord'\nimport { Refinement } from './Refinement'\nimport * as Se from './Semigroup'\nimport { Separated } from './Separated'\nimport { Show } from './Show'\nimport * as S from './string'\nimport { Traversable1 } from './Traversable'\nimport { TraversableWithIndex1 } from './TraversableWithIndex'\nimport { Unfoldable, Unfoldable1 } from './Unfoldable'\nimport { PipeableWilt1, PipeableWither1, wiltDefault, Witherable1, witherDefault } from './Witherable'\n\nimport Semigroup = Se.Semigroup\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * Calculate the number of key/value pairs in a `Record`.\n *\n * @example\n * import { size } from \"fp-ts/Record\";\n *\n * assert.deepStrictEqual(size({ a: true, b: 2, c: \"three\" }), 3);\n *\n * @since 2.0.0\n */\nexport const size: <A>(r: Record<string, A>) => number = RR.size\n\n/**\n * Test whether a `Record` is empty.\n *\n * @example\n * import { isEmpty } from \"fp-ts/Record\";\n *\n * assert.deepStrictEqual(isEmpty({}), true);\n * assert.deepStrictEqual(isEmpty({ a: 3 }), false);\n *\n * @since 2.0.0\n */\nexport const isEmpty: <A>(r: Record<string, A>) => boolean = RR.isEmpty\n\nconst keys_ =\n  (O: Ord<string>) =>\n  <K extends string>(r: Record<K, unknown>): Array<K> =>\n    (Object.keys(r) as any).sort(O.compare)\n\n/**\n * The keys of a `Record`, sorted alphabetically.\n *\n * @example\n * import { keys } from \"fp-ts/Record\";\n *\n * assert.deepStrictEqual(keys({ c: 1, a: 2, b: 3 }), [\"a\", \"b\", \"c\"]);\n *\n * @since 2.0.0\n */\nexport const keys: <K extends string>(r: Record<K, unknown>) => Array<K> = /*#__PURE__*/ keys_(S.Ord)\n\n/**\n * Map a `Record` into an `Array`.\n * It passes each key/value pair to the iterating function and collects\n * the results in an array, sorted alphabetically by the original key.\n *\n * @example\n * import { collect } from 'fp-ts/Record'\n * import { Ord } from 'fp-ts/string'\n *\n * const f = <A>(k: string, a: A) => `${k.toUpperCase()}-${a}`;\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(\n *   collect(Ord)(f)(x),\n *   [\n *     \"A-foo\",\n *     \"B-false\",\n *     \"C-3\",\n *   ]\n * );\n *\n * @since 2.0.0\n */\nexport function collect(O: Ord<string>): <K extends string, A, B>(f: (k: K, a: A) => B) => (r: Record<K, A>) => Array<B>\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function collect<K extends string, A, B>(f: (k: K, a: A) => B): (r: Record<K, A>) => Array<B>\nexport function collect<A, B>(\n  O: Ord<string> | ((k: string, a: A) => B)\n):\n  | (<K extends string, A, B>(f: (k: K, a: A) => B) => (r: Record<K, A>) => Array<B>)\n  | ((r: Record<string, A>) => Array<B>) {\n  if (typeof O === 'function') {\n    return collect(S.Ord)(O)\n  }\n  const keysO = keys_(O)\n  return <K extends string, A, B>(f: (k: K, a: A) => B) =>\n    (r: Record<K, A>) => {\n      const out: Array<B> = []\n      for (const key of keysO(r)) {\n        out.push(f(key, r[key]))\n      }\n      return out\n    }\n}\n\n/**\n * Get a sorted `Array` of the key/value pairs contained in a `Record`.\n * Sorted alphabetically by key.\n *\n * @example\n * import { toArray } from 'fp-ts/Record'\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(toArray(x), [\n *   [\"a\", \"foo\"],\n *   [\"b\", false],\n *   [\"c\", 3],\n * ]);\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const toArray: <K extends string, A>(r: Record<K, A>) => Array<[K, A]> = /*#__PURE__*/ collect(S.Ord)((k, a) => [\n  k,\n  a\n])\n\n/**\n * Unfolds a `Record` into a list of key/value pairs.\n *\n * Given an `Unfoldable` class type `U` such as `array` or `readonlyArray`,\n * it uses the `unfold` function to create an instance of `U`,\n * providing an iterating function that iterates over each\n * key/value pair in the record sorted alphabetically by key.\n *\n * @example\n * import { array, readonlyArray } from 'fp-ts'\n * import { toUnfoldable } from 'fp-ts/Record'\n *\n * assert.deepStrictEqual(toUnfoldable(array)({ b: 2, a: 1 }),[ [ 'a', 1 ], [ 'b', 2 ]])\n * assert.deepStrictEqual(toUnfoldable(readonlyArray)({ b: 2, a: 1 }),[ [ 'a', 1 ], [ 'b', 2 ]])\n *\n * @since 2.0.0\n */\nexport function toUnfoldable<F extends URIS>(\n  U: Unfoldable1<F>\n): <K extends string, A>(r: Record<K, A>) => Kind<F, [K, A]>\nexport function toUnfoldable<F>(U: Unfoldable<F>): <K extends string, A>(r: Record<K, A>) => HKT<F, [K, A]>\nexport function toUnfoldable<F>(U: Unfoldable<F>): <A>(r: Record<string, A>) => HKT<F, [string, A]> {\n  return (r) => {\n    const sas = toArray(r)\n    const len = sas.length\n    return U.unfold(0, (b) => (b < len ? _.some([sas[b], b + 1]) : _.none))\n  }\n}\n\n/**\n * Insert or replace a key/value pair in a `Record`.\n *\n * @example\n * import { upsertAt } from 'fp-ts/Record'\n *\n * assert.deepStrictEqual(upsertAt(\"a\", 5)({ a: 1, b: 2 }), { a: 5, b: 2 });\n * assert.deepStrictEqual(upsertAt(\"c\", 5)({ a: 1, b: 2 }), { a: 1, b: 2, c: 5 });\n *\n * @since 2.10.0\n */\nexport const upsertAt: <A>(k: string, a: A) => (r: Record<string, A>) => Record<string, A> = RR.upsertAt\n\n/**\n * Test whether or not a key exists in a `Record`.\n *\n * Note. This function is not pipeable because is a `Refinement`.\n *\n * @example\n * import { has } from 'fp-ts/Record'\n *\n * assert.deepStrictEqual(has(\"a\", { a: 1, b: 2 }), true);\n * assert.deepStrictEqual(has(\"c\", { a: 1, b: 2 }), false);\n *\n * @since 2.10.0\n */\nexport const has: <K extends string>(k: string, r: Record<K, unknown>) => k is K = RR.has\n\n/**\n * Delete a key and value from a `Record`.\n *\n * @example\n * import { deleteAt } from 'fp-ts/Record'\n *\n * assert.deepStrictEqual(deleteAt(\"a\")({ a: 1, b: 2 }), { b: 2 });\n * assert.deepStrictEqual(deleteAt(\"c\")({ a: 1, b: 2 }), { a: 1, b: 2 });\n *\n * @since 2.0.0\n */\nexport function deleteAt<K extends string>(\n  k: K\n): <KS extends string, A>(r: Record<KS, A>) => Record<string extends K ? string : Exclude<KS, K>, A>\nexport function deleteAt(k: string): <A>(r: Record<string, A>) => Record<string, A> {\n  return <A>(r: Record<string, A>) => {\n    if (!_.has.call(r, k)) {\n      return r\n    }\n    const out: Record<string, A> = Object.assign({}, r)\n    delete out[k]\n    return out\n  }\n}\n\n/**\n * Replace a key/value pair in a `Record`.\n *\n * @returns If the specified key exists it returns an `Option` containing a new `Record`\n * with the entry updated, otherwise it returns `None`\n *\n * @example\n * import { updateAt } from 'fp-ts/Record'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(updateAt(\"a\", 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }));\n * assert.deepStrictEqual(updateAt(\"c\", 3)({ a: 1, b: 2 }), option.none);\n *\n * @since 2.0.0\n */\nexport const updateAt = <A>(k: string, a: A): (<K extends string>(r: Record<K, A>) => Option<Record<K, A>>) =>\n  modifyAt(k, () => a)\n\n/**\n * Applies a mapping function to one spcific key/value pair in a `Record`.\n *\n * @returns If the specified key exists it returns an `Option` containing a new `Record`\n * with the entry updated, otherwise it returns `None`\n *\n * @example\n * import { modifyAt } from 'fp-ts/Record'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(modifyAt(\"a\", (x: number) => x * 3)({ a: 1, b: 2 }), option.some({ a: 3, b: 2 }));\n * assert.deepStrictEqual(modifyAt(\"c\", (x: number) => x * 3)({ a: 1, b: 2 }), option.none);\n *\n * @since 2.0.0\n */\nexport const modifyAt =\n  <A>(k: string, f: (a: A) => A) =>\n  <K extends string>(r: Record<K, A>): Option<Record<K, A>> => {\n    if (!has(k, r)) {\n      return _.none\n    }\n    const out: Record<K, A> = Object.assign({}, r)\n    out[k] = f(r[k])\n    return _.some(out)\n  }\n\n/**\n * Delete a key and value from a `Record`, returning the value as well as the subsequent `Record`.\n *\n * @returns If the specified key exists it returns an `Option` containing a new `Record`\n * with the entry removed, otherwise it returns `None`\n *\n * @example\n * import { pop } from 'fp-ts/Record'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(pop(\"a\")({ a: 1, b: 2, c: 3 }), option.some([1, { b: 2, c: 3 }]));\n * assert.deepStrictEqual(pop(\"x\")({ a: 1, b: 2, c: 3 }), option.none);\n *\n * @since 2.0.0\n */\nexport function pop<K extends string>(\n  k: K\n): <KS extends string, A>(r: Record<KS, A>) => Option<[A, Record<string extends K ? string : Exclude<KS, K>, A>]>\nexport function pop(k: string): <A>(r: Record<string, A>) => Option<[A, Record<string, A>]> {\n  const deleteAtk = deleteAt(k)\n  return (r) => {\n    const oa = lookup(k, r)\n    return _.isNone(oa) ? _.none : _.some([oa.value, deleteAtk(r)])\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test whether one `Record` contains all of the keys and values\n * contained in another `Record`.\n *\n * @example\n * import { isSubrecord } from 'fp-ts/Record'\n * import { string } from 'fp-ts'\n *\n * assert.deepStrictEqual(\n *   isSubrecord(string.Eq)({ a: \"foo\", b: \"bar\", c: \"baz\" })({ a: \"foo\", b: \"bar\", c: \"baz\" }),\n *   true\n * );\n * assert.deepStrictEqual(\n *   isSubrecord(string.Eq)({ a: \"foo\", b: \"bar\", c: \"baz\" })({ a: \"foo\", c: \"baz\" }),\n *   true\n * );\n * assert.deepStrictEqual(\n *   isSubrecord(string.Eq)({ a: \"foo\", b: \"bar\", c: \"baz\" })({ a: \"foo\", b: \"not-bar\", c: \"baz\" }),\n *   false\n * );\n * assert.deepStrictEqual(\n *   isSubrecord(string.Eq)({ a: \"foo\", b: \"bar\" })({ a: \"foo\", b: \"bar\", c: \"baz\" }),\n *   false\n * );\n *\n * @since 2.0.0\n */\nexport const isSubrecord: <A>(E: Eq<A>) => {\n  (that: Record<string, A>): (me: Record<string, A>) => boolean\n  (me: Record<string, A>, that: Record<string, A>): boolean\n} = RR.isSubrecord\n\n// TODO: remove non-curried overloading in v3\n/**\n * Lookup the value for a key in a `Record`.\n *\n * @returns If the specified key exists it returns an `Option` containing the value,\n * otherwise it returns `None`\n *\n * @example\n * import { lookup } from 'fp-ts/Record'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(lookup(\"b\")({ a: \"foo\", b: \"bar\" }), option.some(\"bar\"));\n * assert.deepStrictEqual(lookup(\"c\")({ a: \"foo\", b: \"bar\" }), option.none);\n *\n * @since 2.0.0\n */\nexport const lookup: {\n  (k: string): <A>(r: Record<string, A>) => Option<A>\n  <A>(k: string, r: Record<string, A>): Option<A>\n} = RR.lookup\n\n/**\n * Map a `Record` passing the key/value pairs to the iterating function.\n *\n * @example\n * import { mapWithIndex } from \"fp-ts/Record\";\n *\n * const f = (k: string, n: number) => `${k.toUpperCase()}-${n}`;\n * assert.deepStrictEqual(mapWithIndex(f)({ a: 3, b: 5 }), { a: \"A-3\", b: \"B-5\" });\n *\n * @since 2.0.0\n */\nexport const mapWithIndex: <K extends string, A, B>(f: (k: K, a: A) => B) => (fa: Record<K, A>) => Record<K, B> =\n  RR.mapWithIndex\n\n/**\n * Map a `Record` passing the values to the iterating function.\n *\n * @example\n * import { map } from \"fp-ts/Record\";\n *\n * const f = (n: number) => `-${n}-`;\n * assert.deepStrictEqual(map(f)({ a: 3, b: 5 }), { a: \"-3-\", b: \"-5-\" });\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <K extends string>(fa: Record<K, A>) => Record<K, B> = RR.map\n\n/**\n * Reduces a `Record` passing each key/value pair to the iterating function.\n * Entries are processed in the order, sorted by key according to\n * the given `Ord`.\n *\n * @example\n * import { reduceWithIndex } from \"fp-ts/Record\";\n * import { Ord } from \"fp-ts/string\";\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(reduceWithIndex(Ord)([] as string[], (k, b, a) => [...b, `${k}-${a}`])(x), [\n *   \"a-foo\",\n *   \"b-false\",\n *   \"c-3\",\n * ]);\n *\n * @since 2.0.0\n */\nexport function reduceWithIndex(\n  O: Ord<string>\n): <K extends string, A, B>(b: B, f: (k: K, b: B, a: A) => B) => (fa: Record<K, A>) => B\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function reduceWithIndex<K extends string, A, B>(b: B, f: (k: K, b: B, a: A) => B): (fa: Record<K, A>) => B\nexport function reduceWithIndex<A, B>(\n  ...args: [Ord<string>] | [B, (k: string, b: B, a: A) => B]\n): ((b: B, f: (k: string, b: B, a: A) => B) => (fa: Record<string, A>) => B) | ((fa: Record<string, A>) => B) {\n  return args.length === 1 ? RR.reduceWithIndex(args[0]) : RR.reduceWithIndex(S.Ord)(...args)\n}\n\n/**\n * Map and fold a `Record`.\n * Map the `Record` passing each key/value pair to the iterating function.\n * Then fold the results using the provided `Monoid`.\n *\n * @example\n * import { foldMapWithIndex } from \"fp-ts/Record\";\n * import { Ord } from \"fp-ts/string\";\n * import { Monoid } from \"fp-ts/Monoid\";\n *\n * const m: Monoid<string> = { empty: \"\", concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) };\n * const f = (k:string, a: number) => `${k}-${a}`\n * const x = { c: 3, a: 1, b: 2 };\n * assert.deepStrictEqual(foldMapWithIndex(Ord)(m)(f)(x), \"a-1 -> b-2 -> c-3\");\n *\n * @since 2.0.0\n */\nexport function foldMapWithIndex(\n  O: Ord<string>\n): <M>(M: Monoid<M>) => <K extends string, A>(f: (k: K, a: A) => M) => (fa: Record<K, A>) => M\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function foldMapWithIndex<M>(\n  M: Monoid<M>\n): <K extends string, A>(f: (k: K, a: A) => M) => (fa: Record<K, A>) => M\nexport function foldMapWithIndex<M>(\n  O: Ord<string> | Monoid<M>\n):\n  | ((M: Monoid<M>) => <A>(f: (k: string, a: A) => M) => (fa: Record<string, A>) => M)\n  | (<A>(f: (k: string, a: A) => M) => (fa: Record<string, A>) => M) {\n  return 'compare' in O ? RR.foldMapWithIndex(O) : RR.foldMapWithIndex(S.Ord)(O)\n}\n\n/**\n * Same as `reduceWithIndex`, but reduce starting from the right\n * (i.e. in reverse order, from the last to the first entry according to\n * the given `Ord`).\n *\n * @example\n * import { reduceRightWithIndex } from \"fp-ts/Record\";\n * import { Ord } from \"fp-ts/string\";\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(reduceRightWithIndex(Ord)([] as string[], (k, a, b) => [...b, `${k}-${a}`])(x), [\n *   \"c-3\",\n *   \"b-false\",\n *   \"a-foo\",\n * ]);\n *\n * @since 2.0.0\n */\nexport function reduceRightWithIndex(\n  O: Ord<string>\n): <K extends string, A, B>(b: B, f: (k: K, a: A, b: B) => B) => (fa: Record<K, A>) => B\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function reduceRightWithIndex<K extends string, A, B>(b: B, f: (k: K, a: A, b: B) => B): (fa: Record<K, A>) => B\nexport function reduceRightWithIndex<A, B>(\n  ...args: [Ord<string>] | [B, (k: string, a: A, b: B) => B]\n): ((b: B, f: (k: string, a: A, b: B) => B) => (fa: Record<string, A>) => B) | ((fa: Record<string, A>) => B) {\n  return args.length === 1 ? RR.reduceRightWithIndex(args[0]) : RR.reduceRightWithIndex(S.Ord)(...args)\n}\n\n/**\n * Create a `Record` with one key/value pair.\n *\n * @example\n * import { singleton } from \"fp-ts/Record\";\n *\n * assert.deepStrictEqual(singleton(\"a\", 1), { a: 1 });\n *\n * @since 2.0.0\n */\nexport const singleton: <A>(k: string, a: A) => Record<string, A> = RR.singleton\n\n/**\n * @since 2.0.0\n */\nexport function traverseWithIndex<F extends URIS4>(\n  F: Applicative4<F>\n): <K extends string, S, R, E, A, B>(\n  f: (k: K, a: A) => Kind4<F, S, R, E, B>\n) => (ta: Record<K, A>) => Kind4<F, S, R, E, Record<K, B>>\nexport function traverseWithIndex<F extends URIS3>(\n  F: Applicative3<F>\n): <K extends string, R, E, A, B>(\n  f: (k: K, a: A) => Kind3<F, R, E, B>\n) => (ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>\nexport function traverseWithIndex<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <K extends string, R, A, B>(\n  f: (k: K, a: A) => Kind3<F, R, E, B>\n) => (ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>\nexport function traverseWithIndex<F extends URIS2>(\n  F: Applicative2<F>\n): <K extends string, E, A, B>(f: (k: K, a: A) => Kind2<F, E, B>) => (ta: Record<K, A>) => Kind2<F, E, Record<K, B>>\nexport function traverseWithIndex<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <K extends string, A, B>(f: (k: K, a: A) => Kind2<F, E, B>) => (ta: Record<K, A>) => Kind2<F, E, Record<K, B>>\nexport function traverseWithIndex<F extends URIS>(\n  F: Applicative1<F>\n): <K extends string, A, B>(f: (k: K, a: A) => Kind<F, B>) => (ta: Record<K, A>) => Kind<F, Record<K, B>>\nexport function traverseWithIndex<F>(\n  F: Applicative<F>\n): <K extends string, A, B>(f: (k: K, a: A) => HKT<F, B>) => (ta: Record<K, A>) => HKT<F, Record<K, B>>\nexport function traverseWithIndex<F>(\n  F: Applicative<F>\n): <A, B>(f: (k: string, a: A) => HKT<F, B>) => (ta: Record<string, A>) => HKT<F, Record<string, B>> {\n  return RR.traverseWithIndex(F)\n}\n\n/**\n * @since 2.0.0\n */\nexport function traverse<F extends URIS4>(\n  F: Applicative4<F>\n): <S, R, E, A, B>(\n  f: (a: A) => Kind4<F, S, R, E, B>\n) => <K extends string>(ta: Record<K, A>) => Kind4<F, S, R, E, Record<K, B>>\nexport function traverse<F extends URIS3>(\n  F: Applicative3<F>\n): <R, E, A, B>(f: (a: A) => Kind3<F, R, E, B>) => <K extends string>(ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>\nexport function traverse<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <R, A, B>(f: (a: A) => Kind3<F, R, E, B>) => <K extends string>(ta: Record<K, A>) => Kind3<F, R, E, Record<K, B>>\nexport function traverse<F extends URIS2>(\n  F: Applicative2<F>\n): <E, A, B>(f: (a: A) => Kind2<F, E, B>) => <K extends string>(ta: Record<K, A>) => Kind2<F, E, Record<K, B>>\nexport function traverse<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <A, B>(f: (a: A) => Kind2<F, E, B>) => <K extends string>(ta: Record<K, A>) => Kind2<F, E, Record<K, B>>\nexport function traverse<F extends URIS>(\n  F: Applicative1<F>\n): <A, B>(f: (a: A) => Kind<F, B>) => <K extends string>(ta: Record<K, A>) => Kind<F, Record<K, B>>\nexport function traverse<F>(\n  F: Applicative<F>\n): <A, B>(f: (a: A) => HKT<F, B>) => <K extends string>(ta: Record<K, A>) => HKT<F, Record<K, B>>\nexport function traverse<F>(\n  F: Applicative<F>\n): <A, B>(f: (a: A) => HKT<F, B>) => (ta: Record<string, A>) => HKT<F, Record<string, B>> {\n  return RR.traverse(F)\n}\n\n/**\n * `Record` sequencing,\n * i.e., take a `Record` in which elements are monads\n * and return a monad of a `Record` of the base types.\n * The following example for instance shows sequencing\n * a `Record<string, Option<number>>`\n * into an `Option<Record<string, number>>`.\n *\n * `sequence` in `Record` is equivalent to `sequenceS` in `Apply.ts`.\n *\n * @example\n * import { sequence } from \"fp-ts/Record\";\n * import { option } from \"fp-ts\";\n * import { sequenceS } from \"fp-ts/Apply\";\n *\n * assert.deepStrictEqual(\n *   sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),\n *   option.some({ a: 1, b: 2 })\n * );\n * assert.deepStrictEqual(sequence(option.Applicative)({ a: option.some(1), b: option.none }), option.none);\n * assert.deepStrictEqual(\n *   sequence(option.Applicative)({ a: option.some(1), b: option.some(2) }),\n *   sequenceS(option.Applicative)({ a: option.some(1), b: option.some(2) })\n * );\n *\n * @since 2.0.0\n */\nexport function sequence<F extends URIS3>(\n  F: Applicative3<F>\n): <K extends string, R, E, A>(ta: Record<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, Record<K, A>>\nexport function sequence<F extends URIS3, E>(\n  F: Applicative3C<F, E>\n): <K extends string, R, A>(ta: Record<K, Kind3<F, R, E, A>>) => Kind3<F, R, E, Record<K, A>>\nexport function sequence<F extends URIS2>(\n  F: Applicative2<F>\n): <K extends string, E, A>(ta: Record<K, Kind2<F, E, A>>) => Kind2<F, E, Record<K, A>>\nexport function sequence<F extends URIS2, E>(\n  F: Applicative2C<F, E>\n): <K extends string, A>(ta: Record<K, Kind2<F, E, A>>) => Kind2<F, E, Record<K, A>>\nexport function sequence<F extends URIS>(\n  F: Applicative1<F>\n): <K extends string, A>(ta: Record<K, Kind<F, A>>) => Kind<F, Record<K, A>>\nexport function sequence<F>(F: Applicative<F>): <K extends string, A>(ta: Record<K, HKT<F, A>>) => HKT<F, Record<K, A>>\nexport function sequence<F>(F: Applicative<F>): <A>(ta: Record<string, HKT<F, A>>) => HKT<F, Record<string, A>> {\n  return RR.sequence(F)\n}\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wither: PipeableWither1<URI> = <F>(\n  F: Applicative<F>\n): (<A, B>(f: (a: A) => HKT<F, Option<B>>) => (fa: Record<string, A>) => HKT<F, Record<string, B>>) => {\n  const traverseF = traverse(F)\n  return (f) => (fa) => F.map(pipe(fa, traverseF(f)), compact)\n}\n\n/**\n * @category filtering\n * @since 2.6.5\n */\nexport const wilt: PipeableWilt1<URI> = <F>(\n  F: Applicative<F>\n): (<A, B, C>(\n  f: (a: A) => HKT<F, Either<B, C>>\n) => (fa: Record<string, A>) => HKT<F, Separated<Record<string, B>, Record<string, C>>>) => {\n  const traverseF = traverse(F)\n  return (f) => (fa) => F.map(pipe(fa, traverseF(f)), separate)\n}\n\n/**\n * Maps a `Record` with a function returning an `Either` and\n * partitions the resulting `Record` into `Left`s and `Right`s.\n *\n * @example\n * import { partitionMapWithIndex } from \"fp-ts/Record\"\n * import { either } from \"fp-ts\"\n *\n * const f = (key: string, a: number) =>\n *   a >= 0 ? either.right(`${key} is >= 0 (${a})`) : either.left(`${key} is < 0 (${a})`);\n * assert.deepStrictEqual(partitionMapWithIndex(f)({ a: -1, b: 2, c: 123 }), {\n *   left: {\n *     a: \"a is < 0 (-1)\",\n *   },\n *   right: {\n *     b: \"b is >= 0 (2)\",\n *     c: \"c is >= 0 (123)\",\n *   },\n * });\n *\n * @since 2.0.0\n */\nexport const partitionMapWithIndex: <K extends string, A, B, C>(\n  f: (key: K, a: A) => Either<B, C>\n) => (fa: Record<K, A>) => Separated<Record<string, B>, Record<string, C>> = RR.partitionMapWithIndex\n\n/**\n * Partition a `Record` into two parts according to a predicate\n * that takes a key and a value.\n *\n * @example\n * import { partitionWithIndex } from \"fp-ts/Record\"\n *\n * assert.deepStrictEqual(\n *   partitionWithIndex((key: string, a: number) => key.length <= 1 && a > 0)({ a: -1, b: 2, ccc: 7 }),\n *   {\n *     left: {\n *       a: -1,\n *       ccc: 7,\n *     },\n *     right: {\n *       b: 2,\n *     },\n *   }\n * );\n *\n * @since 2.0.0\n */\nexport function partitionWithIndex<K extends string, A, B extends A>(\n  refinementWithIndex: RefinementWithIndex<K, A, B>\n): (fa: Record<K, A>) => Separated<Record<string, A>, Record<string, B>>\nexport function partitionWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): <B extends A>(fb: Record<K, B>) => Separated<Record<string, B>, Record<string, B>>\nexport function partitionWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): (fa: Record<K, A>) => Separated<Record<string, A>, Record<string, A>>\nexport function partitionWithIndex<A>(\n  predicateWithIndex: PredicateWithIndex<string, A>\n): (fa: Record<string, A>) => Separated<Record<string, A>, Record<string, A>> {\n  return RR.partitionWithIndex(predicateWithIndex)\n}\n\n/**\n * Maps a `Record` with an iterating function that takes key and value and\n * returns an `Option`, keeping only the `Some` values and discarding `None`s.\n *\n * @example\n * import { filterMapWithIndex } from \"fp-ts/Record\"\n * import { option } from \"fp-ts\"\n *\n * const f = (key: string, a: number) => (a >= 0 ? option.some(`${key}${a}`) : option.none);\n * assert.deepStrictEqual(filterMapWithIndex(f)({ a: -1, b: 2, c: 3 }), {\n *   b: \"b2\",\n *   c: \"c3\",\n * });\n *\n * @since 2.0.0\n */\nexport const filterMapWithIndex: <K extends string, A, B>(\n  f: (key: K, a: A) => Option<B>\n) => (fa: Record<K, A>) => Record<string, B> = RR.filterMapWithIndex\n\n/**\n * Produce a new `Record` keeping only the entries that satisfy\n * a predicate taking key and value as input.\n *\n * @example\n * import { filterWithIndex } from \"fp-ts/Record\"\n *\n * assert.deepStrictEqual(\n *   filterWithIndex((s: string, v: number) => s.length <= 1 && v > 0)({ a: 1, b: -2, ccc: 3 }),\n *   {\n *     a: 1,\n *   }\n * );\n *\n * @since 2.0.0\n */\nexport function filterWithIndex<K extends string, A, B extends A>(\n  refinementWithIndex: RefinementWithIndex<K, A, B>\n): (fa: Record<K, A>) => Record<string, B>\nexport function filterWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): <B extends A>(fb: Record<K, B>) => Record<string, B>\nexport function filterWithIndex<K extends string, A>(\n  predicateWithIndex: PredicateWithIndex<K, A>\n): (fa: Record<K, A>) => Record<string, A>\nexport function filterWithIndex<A>(\n  predicateWithIndex: PredicateWithIndex<string, A>\n): (fa: Record<string, A>) => Record<string, A> {\n  return RR.filterWithIndex(predicateWithIndex)\n}\n\n/**\n * Create a `Record` from a foldable collection of key/value pairs, using the\n * specified `Magma` to combine values for duplicate keys.\n *\n * @since 2.0.0\n */\nexport function fromFoldable<F extends URIS3, A>(\n  M: Magma<A>,\n  F: Foldable3<F>\n): <R, E>(fka: Kind3<F, R, E, [string, A]>) => Record<string, A>\nexport function fromFoldable<F extends URIS2, A>(\n  M: Magma<A>,\n  F: Foldable2<F>\n): <E>(fka: Kind2<F, E, [string, A]>) => Record<string, A>\nexport function fromFoldable<F extends URIS, A>(\n  M: Magma<A>,\n  F: Foldable1<F>\n): (fka: Kind<F, [string, A]>) => Record<string, A>\nexport function fromFoldable<F, A>(M: Magma<A>, F: FoldableHKT<F>): (fka: HKT<F, [string, A]>) => Record<string, A>\nexport function fromFoldable<F, A>(M: Magma<A>, F: FoldableHKT<F>): (fka: HKT<F, [string, A]>) => Record<string, A> {\n  return RR.fromFoldable(M, F)\n}\n\n/**\n * Alias of [`toArray`](#toArray).\n *\n * @example\n * import { toEntries } from 'fp-ts/Record'\n *\n * assert.deepStrictEqual(toEntries({ b: 2, a: 1 }), [['a', 1], ['b', 2]])\n *\n * @since 2.12.0\n * @category conversions\n */\nexport const toEntries = toArray\n\n/**\n * Converts an `Array` of `[key, value]` tuples into a `Record`.\n *\n * @example\n * import { fromEntries } from 'fp-ts/Record'\n *\n * assert.deepStrictEqual(fromEntries([['a', 1], ['b', 2], ['a', 3]]), { b: 2, a: 3 })\n *\n * @since 2.12.0\n * @category conversions\n */\nexport const fromEntries = <A>(fa: Array<[string, A]>): Record<string, A> => fromFoldable(Se.last<A>(), A.Foldable)(fa)\n\n/**\n * Create a `Record` from a foldable collection using the specified functions to\n *\n * - map to key/value pairs\n * - combine values for duplicate keys.\n *\n * @example\n * import { last } from 'fp-ts/Semigroup'\n * import { Foldable, zip } from 'fp-ts/Array'\n * import { identity } from 'fp-ts/function'\n * import { fromFoldableMap } from 'fp-ts/Record'\n *\n * export const zipObject = <K extends string, A>(keys: Array<K>, values: Array<A>): Record<K, A> =>\n *   fromFoldableMap(last<A>(), Foldable)(zip(keys, values), identity)\n *\n * assert.deepStrictEqual(zipObject(['a', 'b'], [1, 2, 3]), { a: 1, b: 2 })\n *\n * interface User {\n *   readonly id: string\n *   readonly name: string\n * }\n *\n * const users: Array<User> = [\n *   { id: 'id1', name: 'name1' },\n *   { id: 'id2', name: 'name2' },\n *   { id: 'id1', name: 'name3' }\n * ]\n *\n * assert.deepStrictEqual(fromFoldableMap(last<User>(), Foldable)(users, user => [user.id, user]), {\n *   id1: { id: 'id1', name: 'name3' },\n *   id2: { id: 'id2', name: 'name2' }\n * })\n *\n * @since 2.0.0\n */\nexport function fromFoldableMap<F extends URIS3, B>(\n  M: Magma<B>,\n  F: Foldable3<F>\n): <R, E, A>(fa: Kind3<F, R, E, A>, f: (a: A) => [string, B]) => Record<string, B>\nexport function fromFoldableMap<F extends URIS2, B>(\n  M: Magma<B>,\n  F: Foldable2<F>\n): <E, A>(fa: Kind2<F, E, A>, f: (a: A) => [string, B]) => Record<string, B>\nexport function fromFoldableMap<F extends URIS, B>(\n  M: Magma<B>,\n  F: Foldable1<F>\n): <A>(fa: Kind<F, A>, f: (a: A) => [string, B]) => Record<string, B>\nexport function fromFoldableMap<F, B>(\n  M: Magma<B>,\n  F: FoldableHKT<F>\n): <A>(fa: HKT<F, A>, f: (a: A) => [string, B]) => Record<string, B>\nexport function fromFoldableMap<F, B>(\n  M: Magma<B>,\n  F: FoldableHKT<F>\n): <A>(fa: HKT<F, A>, f: (a: A) => [string, B]) => Record<string, B> {\n  return RR.fromFoldableMap(M, F)\n}\n\n/**\n * Test if every value in a `Record` satisfies the predicate.\n *\n * @example\n * import { every } from \"fp-ts/Record\"\n *\n * assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: 2 }), true);\n * assert.deepStrictEqual(every((n: number) => n >= 0)({ a: 1, b: -1 }), false);\n *\n * @since 2.0.0\n */\nexport const every: {\n  <A, B extends A>(refinement: Refinement<A, B>): Refinement<Record<string, A>, Record<string, B>>\n  <A>(predicate: Predicate<A>): Predicate<Record<string, A>>\n} = RR.every as any\n\n/**\n * Test if at least one value in a `Record` satisfies the predicate.\n *\n * @example\n * import { some } from \"fp-ts/Record\"\n *\n * assert.deepStrictEqual(some((n: number) => n >= 0)({ a: 1, b: -2 }), true);\n * assert.deepStrictEqual(some((n: number) => n >= 0)({ a: -1, b: -2 }), false);\n *\n * @since 2.0.0\n */\nexport const some: <A>(predicate: (a: A) => boolean) => (r: Record<string, A>) => boolean = RR.some\n\n// TODO: remove non-curried overloading in v3\n/**\n * Given an `Eq` checks if a `Record` contains an entry with\n * value equal to a provided value.\n *\n * @example\n * import { elem } from \"fp-ts/Record\"\n * import { number } from \"fp-ts\"\n *\n * assert.deepStrictEqual(elem(number.Eq)(123, { foo: 123, bar: 234 }), true);\n * assert.deepStrictEqual(elem(number.Eq)(-7, { foo: 123, bar: 234 }), false);\n *\n * @since 2.0.0\n */\nexport const elem: <A>(E: Eq<A>) => {\n  (a: A): (fa: Record<string, A>) => boolean\n  (a: A, fa: Record<string, A>): boolean\n} = RR.elem\n\n/**\n * Union of two `Record`s.\n * Takes two `Record`s and produces a `Record` combining all the\n * entries of the two inputs.\n * It uses the `concat` function of the provided `Magma` to\n * combine the elements with the same key.\n *\n * @example\n * import { union } from \"fp-ts/Record\";\n * import { Magma } from \"fp-ts/Magma\";\n *\n * const m1: Magma<number> = { concat: (x: number, y: number) => x + y };\n * assert.deepStrictEqual(union(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4, b: 2, c: 3 });\n * const m2: Magma<number> = { concat: (x: number) => x };\n * assert.deepStrictEqual(union(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 });\n *\n * @since 2.11.0\n */\nexport const union = <A>(\n  M: Magma<A>\n): ((second: Record<string, A>) => (first: Record<string, A>) => Record<string, A>) => {\n  const unionM = RR.union(M)\n  return (second) => (first) => {\n    if (isEmpty(first)) {\n      return { ...second }\n    }\n    if (isEmpty(second)) {\n      return { ...first }\n    }\n    return unionM(second)(first)\n  }\n}\n\n/**\n * Intersection of two `Record`s.\n * Takes two `Record`s and produces a `Record` combining only the\n * entries of the two inputswith the same key.\n * It uses the `concat` function of the provided `Magma` to\n * combine the elements.\n *\n * @example\n * import { intersection } from \"fp-ts/Record\";\n * import { Magma } from \"fp-ts/Magma\";\n *\n * const m1: Magma<number> = { concat: (x: number, y: number) => x + y };\n * assert.deepStrictEqual(intersection(m1)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 4});\n * const m2: Magma<number> = { concat: (x: number) => x };\n * assert.deepStrictEqual(intersection(m2)({ a: 3, c: 3 })({ a: 1, b: 2 }), { a: 1});\n *\n * @since 2.11.0\n */\nexport const intersection =\n  <A>(M: Magma<A>) =>\n  (second: Record<string, A>) =>\n  (first: Record<string, A>): Record<string, A> => {\n    if (isEmpty(first) || isEmpty(second)) {\n      return {}\n    }\n    return RR.intersection(M)(second)(first)\n  }\n\n/**\n * Difference between two `Record`s.\n * Takes two `Record`s and produces a `Record` composed by the\n * entries of the two inputs, removing the entries with the same\n * key in both inputs.\n *\n * @example\n * import { difference } from \"fp-ts/Record\";\n *\n * assert.deepStrictEqual(difference({ a: 1 })({ a: 1, b: 2 }), { b: 2 });\n * assert.deepStrictEqual(difference({ a: 3 })({ a: 1, b: 2 }), { b: 2 });\n * assert.deepStrictEqual(difference({ a: 3, c: 3 })({ a: 1, b: 2 }), { b: 2, c: 3 });\n *\n * @since 2.11.0\n */\nexport const difference =\n  <A>(second: Record<string, A>) =>\n  (first: Record<string, A>): Record<string, A> => {\n    if (isEmpty(first)) {\n      return { ...second }\n    }\n    if (isEmpty(second)) {\n      return { ...first }\n    }\n    return RR.difference(second)(first)\n  }\n\nconst _map = RR._map\nconst _mapWithIndex = RR._mapWithIndex\nconst _reduce = RR._reduce\nconst _foldMap = RR._foldMap\nconst _reduceRight = RR._reduceRight\nconst _filter = RR._filter\nconst _filterMap = RR._filterMap\nconst _partition = RR._partition\nconst _partitionMap = RR._partitionMap\nconst _reduceWithIndex = RR._reduceWithIndex\nconst _foldMapWithIndex = RR._foldMapWithIndex\nconst _reduceRightWithIndex = RR._reduceRightWithIndex\nconst _partitionMapWithIndex = RR._partitionMapWithIndex\nconst _partitionWithIndex = RR._partitionWithIndex\nconst _filterMapWithIndex = RR._filterMapWithIndex\nconst _filterWithIndex = RR._filterWithIndex\nconst _traverse = RR._traverse\nconst _sequence = RR._sequence\nconst _traverseWithIndex =\n  (O: Ord<string>) =>\n  <F>(\n    F: Applicative<F>\n  ): (<A, B>(ta: Record<string, A>, f: (k: string, a: A) => HKT<F, B>) => HKT<F, Record<string, B>>) => {\n    const keysO = keys_(O)\n    return <A, B>(ta: Record<string, A>, f: (k: string, a: A) => HKT<F, B>) => {\n      const ks = keysO(ta)\n      if (ks.length === 0) {\n        return F.of({})\n      }\n      let fr: HKT<F, Record<string, B>> = F.of({})\n      for (const key of ks) {\n        fr = F.ap(\n          F.map(fr, (r) => (b: B) => {\n            r[key] = b\n            return r\n          }),\n          f(key, ta[key])\n        )\n      }\n      return fr\n    }\n  }\n\n/**\n * Given a `Predicate`, it produces a new `Record` keeping only the entries with a\n * value that satisfies the provided predicate.\n *\n * @example\n * import { filter } from \"fp-ts/Record\"\n *\n * assert.deepStrictEqual(filter((s: string) => s.length < 4)({ a: \"foo\", b: \"bar\", c: \"verylong\" }), {\n *   a: \"foo\",\n *   b: \"bar\",\n * });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Record<string, A>) => Record<string, B>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: Record<string, B>) => Record<string, B>\n  <A>(predicate: Predicate<A>): (fa: Record<string, A>) => Record<string, A>\n} = RR.filter\n\n/**\n * Maps a `Record` with an iterating function that returns an `Option`\n * and it keeps only the `Some` values discarding the `None`s.\n *\n * @example\n * import { filterMap } from \"fp-ts/Record\"\n * import { option } from \"fp-ts\"\n *\n * const f = (s: string) => s.length < 4 ? option.some(`${s} is short`): option.none\n * assert.deepStrictEqual(filterMap(f)({ a: \"foo\", b: \"bar\", c: \"verylong\" }), {\n *   a: \"foo is short\",\n *   b: \"bar is short\",\n * });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Record<string, A>) => Record<string, B> = RR.filterMap\n\n/**\n * Partition a `Record` into two parts according to a `Predicate`.\n *\n * @example\n * import { partition } from \"fp-ts/Record\"\n *\n * assert.deepStrictEqual(partition((s: string) => s.length < 4)({ a: \"foo\", b: \"bar\", c: \"verylong\" }), {\n *   left:{\n *     c: \"verylong\"\n *   },\n *   right: {\n *     a: \"foo\",\n *     b: \"bar\",\n *   },\n * });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (\n    fa: Record<string, A>\n  ) => Separated<Record<string, A>, Record<string, B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: Record<string, B>) => Separated<Record<string, B>, Record<string, B>>\n  <A>(predicate: Predicate<A>): (fa: Record<string, A>) => Separated<Record<string, A>, Record<string, A>>\n} = RR.partition\n\n/**\n * Maps a `Record` with a function returning an `Either` and\n * partitions the resulting `Record` into `Left`s and `Right`s.\n *\n * @example\n * import { partitionMap } from \"fp-ts/Record\"\n * import { either } from \"fp-ts\"\n *\n * const f = (s: string) => (s.length < 4 ? either.right(`${s} is short`) : either.left(`${s} is not short`));\n * assert.deepStrictEqual(partitionMap(f)({ a: \"foo\", b: \"bar\", c: \"verylong\" }), {\n *   left: {\n *     c: \"verylong is not short\",\n *   },\n *   right: {\n *     a: \"foo is short\",\n *     b: \"bar is short\",\n *   },\n * });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: Record<string, A>) => Separated<Record<string, B>, Record<string, C>> = RR.partitionMap\n\n/**\n * Reduces a `Record` passing each value to the iterating function.\n * Entries are processed in order, sorted by key according to\n * the given `Ord`.\n *\n * @example\n * import { reduce } from \"fp-ts/Record\";\n * import { Ord } from \"fp-ts/string\";\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(reduce(Ord)([] as string[], (b, a) => [...b, `-${a}-`])(x), [\n *   \"-foo-\",\n *   \"-false-\",\n *   \"-3-\",\n * ]);\n *\n * @category folding\n * @since 2.0.0\n */\nexport function reduce(O: Ord<string>): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Record<string, A>) => B\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function reduce<A, B>(b: B, f: (b: B, a: A) => B): (fa: Record<string, A>) => B\nexport function reduce<A, B>(\n  ...args: [Ord<string>] | [B, (b: B, a: A) => B]\n): ((b: B, f: (b: B, a: A) => B) => (fa: Record<string, A>) => B) | ((fa: Record<string, A>) => B) {\n  return args.length === 1 ? RR.reduce(args[0]) : RR.reduce(S.Ord)(...args)\n}\n\n/**\n * Map and fold a `Record`.\n * Map the `Record` passing each value to the iterating function.\n * Then fold the results using the provided `Monoid`.\n *\n * @example\n * import { foldMap } from \"fp-ts/Record\";\n * import { Ord } from \"fp-ts/string\";\n * import { Monoid } from \"fp-ts/Monoid\";\n *\n * const m: Monoid<string> = { empty: \"\", concat: (x: string, y: string) => (x ? `${x} -> ${y}` : `${y}`) };\n * const f = (a: number) => `-${a}-`;\n * const x = { c: 3, a: 1, b: 2 };\n * assert.deepStrictEqual(foldMap(Ord)(m)(f)(x), \"-1- -> -2- -> -3-\");\n *\n * @category folding\n * @since 2.0.0\n */\nexport function foldMap(O: Ord<string>): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Record<string, A>) => M\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function foldMap<M>(M: Monoid<M>): <A>(f: (a: A) => M) => (fa: Record<string, A>) => M\nexport function foldMap<M>(\n  O: Ord<string> | Monoid<M>\n):\n  | ((M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Record<string, A>) => M)\n  | (<A>(f: (a: A) => M) => (fa: Record<string, A>) => M) {\n  return 'compare' in O ? RR.foldMap(O) : RR.foldMap(S.Ord)(O)\n}\n\n/**\n * Same as `reduce` but entries are processed _from the right_,\n * i.e. in reverse order, from the last to the first entry, according to\n * the given `Ord`.\n *\n * @example\n * import { reduceRight } from \"fp-ts/Record\";\n * import { Ord } from \"fp-ts/string\";\n *\n * const x = { c: 3, a: \"foo\", b: false };\n * assert.deepStrictEqual(reduceRight(Ord)([] as string[], (a, b) => [...b, `-${a}-`])(x), [\n *   \"-3-\",\n *   \"-false-\",\n *   \"-foo-\",\n * ]);\n *\n * @category folding\n * @since 2.0.0\n */\nexport function reduceRight(O: Ord<string>): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Record<string, A>) => B\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @deprecated\n */\nexport function reduceRight<A, B>(b: B, f: (a: A, b: B) => B): (fa: Record<string, A>) => B\nexport function reduceRight<A, B>(\n  ...args: [Ord<string>] | [B, (a: A, b: B) => B]\n): ((b: B, f: (a: A, b: B) => B) => (fa: Record<string, A>) => B) | ((fa: Record<string, A>) => B) {\n  return args.length === 1 ? RR.reduceRight(args[0]) : RR.reduceRight(S.Ord)(...args)\n}\n\n/**\n * Compact a `Record` of `Option`s discarding the `None` values and\n * keeping the `Some` values.\n *\n * @example\n * import { compact } from 'fp-ts/Record'\n * import { option } from 'fp-ts'\n *\n * assert.deepStrictEqual(compact({ a: option.some(\"foo\"), b: option.none, c: option.some(\"bar\") }), {\n *   a: \"foo\",\n *   c: \"bar\",\n * });\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const compact: <A>(fa: Record<string, Option<A>>) => Record<string, A> = RR.compact\n\n/**\n * Separate a `Record` of `Either`s into `Left`s and `Right`s.\n *\n * @example\n * import { separate } from 'fp-ts/Record'\n * import { either } from 'fp-ts'\n *\n * assert.deepStrictEqual(\n *   separate({ a: either.right(\"foo\"), b: either.left(\"bar\"), c: either.right(\"baz\") }),\n *   {\n *     right: {\n *       a: \"foo\",\n *       c: \"baz\",\n *     },\n *     left: {\n *       b: \"bar\",\n *     },\n *   }\n * );\n *\n * @category filtering\n * @since 2.0.0\n */\nexport const separate: <A, B>(fa: Record<string, Either<A, B>>) => Separated<Record<string, A>, Record<string, B>> =\n  RR.separate\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Record'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Record<string, A>\n  }\n}\n\n/**\n * Produces a `Show` for a `Record`, given a `Show` for the base type\n * (a `Show` produces a human-readable representation of an instance).\n * `Record` entries are sorted by key with the provided `Ord`.\n *\n * @example\n * import { getShow } from \"fp-ts/Record\"\n * import { Show } from \"fp-ts/Show\"\n * import { Ord } from \"fp-ts/string\"\n *\n * const sNumber: Show<number> = { show: (n: number) => `${n}` };\n * const sRecord: Show<Record<string, number>> = getShow(Ord)(sNumber);\n * assert.deepStrictEqual(sRecord.show({ b: 2, a: 1 }), '{ \"a\": 1, \"b\": 2 }');\n *\n * @category instances\n * @since 2.0.0\n */\nexport function getShow(O: Ord<string>): <A>(S: Show<A>) => Show<Record<string, A>>\n/**\n * Use the overload constrained by `Ord` instead.\n *\n * @category zone of death\n * @deprecated\n */\nexport function getShow<A>(S: Show<A>): Show<Record<string, A>>\nexport function getShow<A>(\n  O: Ord<string> | Show<A>\n): ((S: Show<A>) => Show<Record<string, A>>) | Show<Record<string, A>> {\n  return 'compare' in O ? RR.getShow(O) : RR.getShow(S.Ord)(O)\n}\n\n/**\n * Given an `Eq` for the base type, it produces an `Eq`\n * for a `Record` of that base type.\n *\n * @example\n * import { getEq } from \"fp-ts/Record\";\n * import { string } from \"fp-ts\";\n * import { Eq } from \"fp-ts/Eq\";\n *\n * const eq: Eq<Record<string, string>> = getEq(string.Eq);\n * assert.deepStrictEqual(eq.equals({ a: \"foo\" }, { b: \"bar\" }), false);\n * assert.deepStrictEqual(eq.equals({ a: \"foo\" }, { a: \"foo\" }), true);\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getEq: <K extends string, A>(E: Eq<A>) => Eq<Record<K, A>> = RR.getEq\n\n/**\n * Returns a `Monoid` instance for `Record`s, given a `Semigroup`\n * instance for the base type.\n * The `Monoid` makes the union of two `Record`s comining the\n * overlapping entries with the provided `Semigroup`.\n *\n * @example\n * import { SemigroupSum } from 'fp-ts/number'\n * import { getMonoid } from 'fp-ts/Record'\n *\n * const M = getMonoid(SemigroupSum);\n * assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579 , bar: 234, baz: 567 });\n *\n * @category instances\n * @since 2.0.0\n */\nexport const getMonoid: <K extends string, A>(S: Semigroup<A>) => Monoid<Record<K, A>> = RR.getMonoid\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Takes a value and a `Record` of functions and returns a\n * `Record` by applying each function to the input value.\n *\n * @example\n * import { flap } from \"fp-ts/Record\"\n *\n * const fab = { x: (n: number) => `${n} times 2`, y: (n: number) => `${n * 2}` };\n * assert.deepStrictEqual(flap(3)(fab), {\n *   x: \"3 times 2\",\n *   y: \"6\",\n * });\n *\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FunctorWithIndex: FunctorWithIndex1<URI, string> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex\n}\n\n/**\n * Produces a `Foldable` instance for a `Record`, using the\n * provided `Ord` to sort the `Record`'s entries by key.\n *\n * @category folding\n * @since 2.11.0\n */\nexport const getFoldable = (O: Ord<string>): Foldable1<URI> => ({\n  URI,\n  reduce: _reduce(O),\n  foldMap: _foldMap(O),\n  reduceRight: _reduceRight(O)\n})\n\n/**\n * Produces a `FoldableWithIndex1` instance for a `Record`, using the\n * provided `Ord` to sort the `Record`'s entries by key.\n *\n * @category folding\n * @since 2.11.0\n */\nexport const getFoldableWithIndex = (O: Ord<string>): FoldableWithIndex1<URI, string> => ({\n  URI,\n  reduce: _reduce(O),\n  foldMap: _foldMap(O),\n  reduceRight: _reduceRight(O),\n  reduceWithIndex: _reduceWithIndex(O),\n  foldMapWithIndex: _foldMapWithIndex(O),\n  reduceRightWithIndex: _reduceRightWithIndex(O)\n})\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Compactable: Compactable1<URI> = {\n  URI,\n  compact,\n  separate\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Filterable: Filterable1<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const FilterableWithIndex: FilterableWithIndex1<URI, string> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  filterMapWithIndex: _filterMapWithIndex,\n  filterWithIndex: _filterWithIndex,\n  partitionMapWithIndex: _partitionMapWithIndex,\n  partitionWithIndex: _partitionWithIndex\n}\n\n/**\n * Produces a `Traversable` instance for a `Record`, using the\n * provided `Ord` to sort the `Record`'s entries by key.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const getTraversable = (O: Ord<string>): Traversable1<URI> => ({\n  URI,\n  map: _map,\n  reduce: _reduce(O),\n  foldMap: _foldMap(O),\n  reduceRight: _reduceRight(O),\n  traverse: _traverse(O),\n  sequence: _sequence(O)\n})\n\n/**\n * Produces a `TraversableWithIndex` instance for a `Record`, using the\n * provided `Ord` to sort the `Record`'s entries by key.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const getTraversableWithIndex = (O: Ord<string>): TraversableWithIndex1<URI, string> => ({\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  reduce: _reduce(O),\n  foldMap: _foldMap(O),\n  reduceRight: _reduceRight(O),\n  reduceWithIndex: _reduceWithIndex(O),\n  foldMapWithIndex: _foldMapWithIndex(O),\n  reduceRightWithIndex: _reduceRightWithIndex(O),\n  traverse: _traverse(O),\n  sequence: _sequence(O),\n  traverseWithIndex: _traverseWithIndex(O)\n})\n\n/**\n * @category filtering\n * @since 2.11.0\n */\nexport const getWitherable = (O: Ord<string>): Witherable1<URI> => {\n  const T = getTraversable(O)\n  return {\n    URI,\n    map: _map,\n    reduce: _reduce(O),\n    foldMap: _foldMap(O),\n    reduceRight: _reduceRight(O),\n    traverse: T.traverse,\n    sequence: T.sequence,\n    compact,\n    separate,\n    filter: _filter,\n    filterMap: _filterMap,\n    partition: _partition,\n    partitionMap: _partitionMap,\n    wither: witherDefault(T, Compactable),\n    wilt: wiltDefault(T, Compactable)\n  }\n}\n\n/**\n * Given a `Semigroup` in the base type, it produces a `Semigroup`\n * in the `Record` of the base type.\n * The resulting `Semigroup` concatenates two `Record`s by\n * `union`.\n *\n * @example\n * import { getUnionSemigroup } from \"fp-ts/Record\"\n * import { Semigroup } from \"fp-ts/Semigroup\"\n *\n * const sNumber: Semigroup<number> = { concat: (x, y) => x - y };\n * const sRecord: Semigroup<Record<string, number>> = getUnionSemigroup(sNumber);\n * assert.deepStrictEqual(sRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { a: 1, b: -1, c: 4 });\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <A>(S: Semigroup<A>): Semigroup<Record<string, A>> => {\n  const unionS = union(S)\n  return {\n    concat: (first, second) => unionS(second)(first)\n  }\n}\n\n/**\n * Same as `getMonoid`.\n * Returns a `Monoid` instance for `Record`s given a `Semigroup`\n * instance for the base type.\n * The `Monoid` makes the union of two `Record`s combining the\n * entries that have the same key with the provided `Semigroup`.\n *\n * @example\n * import { SemigroupSum } from 'fp-ts/number'\n * import { getUnionMonoid } from 'fp-ts/Record'\n *\n * const M = getUnionMonoid(SemigroupSum);\n * assert.deepStrictEqual(M.concat({ foo: 123, bar: 234 }, { foo: 456, baz: 567 }), { foo: 579 , bar: 234, baz: 567 });\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionMonoid = <A>(S: Semigroup<A>): Monoid<Record<string, A>> => ({\n  concat: getUnionSemigroup(S).concat,\n  empty: {}\n})\n\n/**\n * Given a `Semigroup` in the base type, it produces a `Semigroup`\n * in the `Record` of the base type.\n * The resulting `Semigroup` concatenates two `Record`s by\n * `intersection`.\n *\n * @example\n * import { getIntersectionSemigroup } from \"fp-ts/Record\"\n * import { Semigroup } from \"fp-ts/Semigroup\"\n *\n * const sNumber: Semigroup<number> = { concat: (x, y) => x - y };\n * const sRecord: Semigroup<Record<string, number>> = getIntersectionSemigroup(sNumber);\n * assert.deepStrictEqual(sRecord.concat({ a: 1, b: 2 }, { b: 3, c: 4 }), { b: -1 });\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getIntersectionSemigroup = <A>(S: Semigroup<A>): Semigroup<Record<string, A>> => {\n  const intersectionS = intersection(S)\n  return {\n    concat: (first, second) => intersectionS(second)(first)\n  }\n}\n\n/**\n * Produces a `Magma` with a `concat` function that combines\n * two `Record`s by making the `difference`.\n *\n * @example\n * import { getDifferenceMagma, difference } from \"fp-ts/Record\"\n * import { Magma } from \"fp-ts/Magma\"\n *\n * const r1 = { a: 3, c: 3 };\n * const r2 = { a: 1, b: 2 };\n * const m: Magma<Record<string, number>> = getDifferenceMagma<number>();\n * assert.deepStrictEqual(m.concat(r1, r2), difference(r2)(r1));\n * assert.deepStrictEqual(m.concat(r1, r2), { c: 3, b: 2 });\n *\n * @category instances\n * @since 2.11.0\n */\nexport const getDifferenceMagma = <A>(): Magma<Record<string, A>> => ({\n  concat: (first, second) => difference(second)(first)\n})\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use `getFoldable` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const Foldable: Foldable1<URI> = {\n  URI,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord)\n}\n\n/**\n * Use `getFoldableWithIndex` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const FoldableWithIndex: FoldableWithIndex1<URI, string> = {\n  URI,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  reduceWithIndex: /*#__PURE__*/ _reduceWithIndex(S.Ord),\n  foldMapWithIndex: /*#__PURE__*/ _foldMapWithIndex(S.Ord),\n  reduceRightWithIndex: /*#__PURE__*/ _reduceRightWithIndex(S.Ord)\n}\n\n/**\n * Use `getTraversable` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const Traversable: Traversable1<URI> = {\n  URI,\n  map: _map,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  traverse: /*#__PURE__*/ _traverse(S.Ord),\n  sequence\n}\n\n/**\n * Use the `getTraversableWithIndex` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const TraversableWithIndex: TraversableWithIndex1<URI, string> = {\n  URI,\n  map: _map,\n  mapWithIndex: _mapWithIndex,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  reduceWithIndex: /*#__PURE__*/ _reduceWithIndex(S.Ord),\n  foldMapWithIndex: /*#__PURE__*/ _foldMapWithIndex(S.Ord),\n  reduceRightWithIndex: /*#__PURE__*/ _reduceRightWithIndex(S.Ord),\n  traverse: /*#__PURE__*/ _traverse(S.Ord),\n  sequence,\n  traverseWithIndex: /*#__PURE__*/ _traverseWithIndex(S.Ord)\n}\n\nconst _wither = /*#__PURE__*/ witherDefault(Traversable, Compactable)\nconst _wilt = /*#__PURE__*/ wiltDefault(Traversable, Compactable)\n\n/**\n * Use `getWitherable` instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const Witherable: Witherable1<URI> = {\n  URI,\n  map: _map,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  traverse: /*#__PURE__*/ _traverse(S.Ord),\n  sequence,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  wither: _wither,\n  wilt: _wilt\n}\n\n/**\n * Use a new `{}` instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const empty: Record<string, never> = {}\n\n/**\n * Use [`upsertAt`](#upsertat) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const insertAt: <A>(k: string, a: A) => (r: Record<string, A>) => Record<string, A> = upsertAt\n\n/**\n * Use [`has`](#has) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const hasOwnProperty: <K extends string>(k: string, r: Record<K, unknown>) => k is K = RR.hasOwnProperty\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `R.Functor` instead of `R.record`\n * (where `R` is from `import R from 'fp-ts/Record'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const record: FunctorWithIndex1<URI, string> &\n  FoldableWithIndex1<URI, string> &\n  FilterableWithIndex1<URI, string> &\n  TraversableWithIndex1<URI, string> &\n  Witherable1<URI> = {\n  URI,\n  map: _map,\n  reduce: /*#__PURE__*/ _reduce(S.Ord),\n  foldMap: /*#__PURE__*/ _foldMap(S.Ord),\n  reduceRight: /*#__PURE__*/ _reduceRight(S.Ord),\n  traverse: /*#__PURE__*/ _traverse(S.Ord),\n  sequence,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap,\n  mapWithIndex: _mapWithIndex,\n  reduceWithIndex: /*#__PURE__*/ _reduceWithIndex(S.Ord),\n  foldMapWithIndex: /*#__PURE__*/ _foldMapWithIndex(S.Ord),\n  reduceRightWithIndex: /*#__PURE__*/ _reduceRightWithIndex(S.Ord),\n  filterMapWithIndex: _filterMapWithIndex,\n  filterWithIndex: _filterWithIndex,\n  partitionMapWithIndex: _partitionMapWithIndex,\n  partitionWithIndex: _partitionWithIndex,\n  traverseWithIndex: /*#__PURE__*/ _traverseWithIndex(S.Ord),\n  wither: _wither,\n  wilt: _wilt\n}\n"
  },
  {
    "path": "src/Refinement.ts",
    "content": "/**\n * @since 2.11.0\n */\nimport { Either } from './Either'\nimport * as _ from './internal'\nimport { Option } from './Option'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport interface Refinement<A, B extends A> {\n  (a: A): a is B\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Returns a `Refinement` from a `Option` returning function.\n * This function ensures that a `Refinement` definition is type-safe.\n *\n * @category lifting\n * @since 2.11.0\n */\nexport const fromOptionK = <A, B extends A>(getOption: (a: A) => Option<B>): Refinement<A, B> => {\n  return (a: A): a is B => _.isSome(getOption(a))\n}\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromEitherK = <A, B extends A>(getEither: (a: A) => Either<unknown, B>): Refinement<A, B> => {\n  return (a: A): a is B => _.isRight(getEither(a))\n}\n\n/**\n * @category constructors\n * @since 2.11.0\n */\nexport const id = <A>(): Refinement<A, A> => {\n  return (_): _ is A => true\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport const not =\n  <A, B extends A>(refinement: Refinement<A, B>): Refinement<A, Exclude<A, B>> =>\n  (a): a is Exclude<A, B> =>\n    !refinement(a)\n\n/**\n * @since 2.11.0\n */\nexport const or =\n  <A, C extends A>(second: Refinement<A, C>) =>\n  <B extends A>(first: Refinement<A, B>): Refinement<A, B | C> =>\n  (a): a is B | C =>\n    first(a) || second(a)\n\n/**\n * @since 2.11.0\n */\nexport const and =\n  <A, C extends A>(second: Refinement<A, C>) =>\n  <B extends A>(first: Refinement<A, B>): Refinement<A, B & C> =>\n  (a): a is B & C =>\n    first(a) && second(a)\n\n/**\n * @since 2.11.0\n */\nexport const zero = <A, B extends A>(): Refinement<A, B> => {\n  return (_): _ is B => false\n}\n\n/**\n * @since 2.11.0\n */\nexport const compose =\n  <A, B extends A, C extends B>(bc: Refinement<B, C>) =>\n  (ab: Refinement<A, B>): Refinement<A, C> => {\n    return (i): i is C => ab(i) && bc(i)\n  }\n"
  },
  {
    "path": "src/Ring.ts",
    "content": "/**\n * The `Ring` class is for types that support addition, multiplication, and subtraction operations.\n *\n * Instances must satisfy the following law in addition to the `Semiring` laws:\n *\n * - Additive inverse: `a - a <-> (zero - a) + a <-> zero`\n *\n * Adapted from https://github.com/purescript/purescript-prelude/blob/master/src/Data/Ring.purs\n *\n * @since 2.0.0\n */\nimport { getRing } from './function'\nimport { Semiring } from './Semiring'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Ring<A> extends Semiring<A> {\n  readonly sub: (x: A, y: A) => A\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Given a tuple of `Ring`s returns a `Ring` for the tuple\n *\n * @example\n * import { tuple } from 'fp-ts/Ring'\n * import * as N from 'fp-ts/number'\n *\n * const R = tuple(N.Field, N.Field, N.Field)\n * assert.deepStrictEqual(R.add([1, 2, 3], [4, 5, 6]), [5, 7, 9])\n * assert.deepStrictEqual(R.mul([1, 2, 3], [4, 5, 6]), [4, 10, 18])\n * assert.deepStrictEqual(R.one, [1, 1, 1])\n * assert.deepStrictEqual(R.sub([1, 2, 3], [4, 5, 6]), [-3, -3, -3])\n * assert.deepStrictEqual(R.zero, [0, 0, 0])\n *\n * @since 2.10.0\n */\nexport const tuple = <A extends ReadonlyArray<unknown>>(...rings: { [K in keyof A]: Ring<A[K]> }): Ring<Readonly<A>> =>\n  ({\n    add: (x: any, y: any) => rings.map((R, i) => R.add(x[i], y[i])),\n    zero: rings.map((R) => R.zero),\n    mul: (x: any, y: any) => rings.map((R, i) => R.mul(x[i], y[i])),\n    one: rings.map((R) => R.one),\n    sub: (x: any, y: any) => rings.map((R, i) => R.sub(x[i], y[i]))\n  } as any)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * `negate x` can be used as a shorthand for `zero - x`\n *\n * @since 2.0.0\n */\nexport const negate =\n  <A>(R: Ring<A>) =>\n  (a: A): A =>\n    R.sub(R.zero, a)\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`tuple`](#tuple) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getTupleRing: <T extends ReadonlyArray<Ring<any>>>(\n  ...rings: T\n) => Ring<{ [K in keyof T]: T[K] extends Ring<infer A> ? A : never }> = tuple as any\n\n/**\n * Use [`getRing`](./function.ts.html#getring) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getFunctionRing: <A, B>(R: Ring<B>) => Ring<(a: A) => B> = getRing\n"
  },
  {
    "path": "src/Semigroup.ts",
    "content": "/**\n * If a type `A` can form a `Semigroup` it has an **associative** binary operation.\n *\n * ```ts\n * interface Semigroup<A> {\n *   readonly concat: (x: A, y: A) => A\n * }\n * ```\n *\n * Associativity means the following equality must hold for any choice of `x`, `y`, and `z`.\n *\n * ```ts\n * concat(x, concat(y, z)) = concat(concat(x, y), z)\n * ```\n *\n * A common example of a semigroup is the type `string` with the operation `+`.\n *\n * ```ts\n * import { Semigroup } from 'fp-ts/Semigroup'\n *\n * const semigroupString: Semigroup<string> = {\n *   concat: (x, y) => x + y\n * }\n *\n * const x = 'x'\n * const y = 'y'\n * const z = 'z'\n *\n * semigroupString.concat(x, y) // 'xy'\n *\n * semigroupString.concat(x, semigroupString.concat(y, z)) // 'xyz'\n *\n * semigroupString.concat(semigroupString.concat(x, y), z) // 'xyz'\n * ```\n *\n * *Adapted from https://typelevel.org/cats*\n *\n * @since 2.0.0\n */\nimport { getSemigroup, identity } from './function'\nimport * as _ from './internal'\nimport * as M from './Magma'\nimport * as Or from './Ord'\nimport { ReadonlyRecord } from './ReadonlyRecord'\n\nimport Ord = Or.Ord\nimport Magma = M.Magma\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Semigroup<A> extends Magma<A> {}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Get a semigroup where `concat` will return the minimum, based on the provided order.\n *\n * @example\n * import * as N from 'fp-ts/number'\n * import * as S from 'fp-ts/Semigroup'\n *\n * const S1 = S.min(N.Ord)\n *\n * assert.deepStrictEqual(S1.concat(1, 2), 1)\n *\n * @category constructors\n * @since 2.10.0\n */\nexport const min = <A>(O: Ord<A>): Semigroup<A> => ({\n  concat: Or.min(O)\n})\n\n/**\n * Get a semigroup where `concat` will return the maximum, based on the provided order.\n *\n * @example\n * import * as N from 'fp-ts/number'\n * import * as S from 'fp-ts/Semigroup'\n *\n * const S1 = S.max(N.Ord)\n *\n * assert.deepStrictEqual(S1.concat(1, 2), 2)\n *\n * @category constructors\n * @since 2.10.0\n */\nexport const max = <A>(O: Ord<A>): Semigroup<A> => ({\n  concat: Or.max(O)\n})\n\n/**\n * @category constructors\n * @since 2.10.0\n */\nexport const constant = <A>(a: A): Semigroup<A> => ({\n  concat: () => a\n})\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * The dual of a `Semigroup`, obtained by swapping the arguments of `concat`.\n *\n * @example\n * import { reverse } from 'fp-ts/Semigroup'\n * import * as S from 'fp-ts/string'\n *\n * assert.deepStrictEqual(reverse(S.Semigroup).concat('a', 'b'), 'ba')\n *\n * @since 2.10.0\n */\nexport const reverse: <A>(S: Semigroup<A>) => Semigroup<A> = M.reverse\n\n/**\n * Given a struct of semigroups returns a semigroup for the struct.\n *\n * @example\n * import { struct } from 'fp-ts/Semigroup'\n * import * as N from 'fp-ts/number'\n *\n * interface Point {\n *   readonly x: number\n *   readonly y: number\n * }\n *\n * const S = struct<Point>({\n *   x: N.SemigroupSum,\n *   y: N.SemigroupSum\n * })\n *\n * assert.deepStrictEqual(S.concat({ x: 1, y: 2 }, { x: 3, y: 4 }), { x: 4, y: 6 })\n *\n * @since 2.10.0\n */\nexport const struct = <A>(semigroups: { [K in keyof A]: Semigroup<A[K]> }): Semigroup<{\n  readonly [K in keyof A]: A[K]\n}> => ({\n  concat: (first, second) => {\n    const r: A = {} as any\n    for (const k in semigroups) {\n      if (_.has.call(semigroups, k)) {\n        r[k] = semigroups[k].concat(first[k], second[k])\n      }\n    }\n    return r\n  }\n})\n\n/**\n * Given a tuple of semigroups returns a semigroup for the tuple.\n *\n * @example\n * import { tuple } from 'fp-ts/Semigroup'\n * import * as B from 'fp-ts/boolean'\n * import * as N from 'fp-ts/number'\n * import * as S from 'fp-ts/string'\n *\n * const S1 = tuple(S.Semigroup, N.SemigroupSum)\n * assert.deepStrictEqual(S1.concat(['a', 1], ['b', 2]), ['ab', 3])\n *\n * const S2 = tuple(S.Semigroup, N.SemigroupSum, B.SemigroupAll)\n * assert.deepStrictEqual(S2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])\n *\n * @since 2.10.0\n */\nexport const tuple = <A extends ReadonlyArray<unknown>>(\n  ...semigroups: { [K in keyof A]: Semigroup<A[K]> }\n): Semigroup<Readonly<A>> => ({\n  concat: (first, second) => semigroups.map((s, i) => s.concat(first[i], second[i])) as any\n})\n\n/**\n * Between each pair of elements insert `middle`.\n *\n * @example\n * import { intercalate } from 'fp-ts/Semigroup'\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * const S1 = pipe(S.Semigroup, intercalate(' + '))\n *\n * assert.strictEqual(S1.concat('a', 'b'), 'a + b')\n *\n * @since 2.10.0\n */\nexport const intercalate =\n  <A>(middle: A) =>\n  (S: Semigroup<A>): Semigroup<A> => ({\n    concat: (x, y) => S.concat(x, S.concat(middle, y))\n  })\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * Always return the first argument.\n *\n * @example\n * import * as S from 'fp-ts/Semigroup'\n *\n * assert.deepStrictEqual(S.first<number>().concat(1, 2), 1)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const first = <A = never>(): Semigroup<A> => ({ concat: identity })\n\n/**\n * Always return the last argument.\n *\n * @example\n * import * as S from 'fp-ts/Semigroup'\n *\n * assert.deepStrictEqual(S.last<number>().concat(1, 2), 2)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const last = <A = never>(): Semigroup<A> => ({ concat: (_, y) => y })\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Given a sequence of `as`, concat them and return the total.\n *\n * If `as` is empty, return the provided `startWith` value.\n *\n * @example\n * import { concatAll } from 'fp-ts/Semigroup'\n * import * as N from 'fp-ts/number'\n *\n * const sum = concatAll(N.SemigroupSum)(0)\n *\n * assert.deepStrictEqual(sum([1, 2, 3]), 6)\n * assert.deepStrictEqual(sum([]), 0)\n *\n * @since 2.10.0\n */\nexport const concatAll: <A>(S: Semigroup<A>) => (startWith: A) => (as: ReadonlyArray<A>) => A = M.concatAll\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use `void` module instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const semigroupVoid: Semigroup<void> = constant<void>(undefined)\n\n/**\n * Use [`getAssignSemigroup`](./struct.ts.html#getAssignSemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getObjectSemigroup = <A extends object = never>(): Semigroup<A> => ({\n  concat: (first, second) => Object.assign({}, first, second)\n})\n\n/**\n * Use [`last`](#last) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getLastSemigroup = last\n\n/**\n * Use [`first`](#first) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getFirstSemigroup = first\n\n/**\n * Use [`tuple`](#tuple) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getTupleSemigroup: <T extends ReadonlyArray<Semigroup<any>>>(\n  ...semigroups: T\n) => Semigroup<{ [K in keyof T]: T[K] extends Semigroup<infer A> ? A : never }> = tuple as any\n\n/**\n * Use [`struct`](#struct) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getStructSemigroup: <O extends ReadonlyRecord<string, any>>(semigroups: {\n  [K in keyof O]: Semigroup<O[K]>\n}) => Semigroup<O> = struct\n\n/**\n * Use [`reverse`](#reverse) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getDualSemigroup = reverse\n\n/**\n * Use [`max`](#max) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getJoinSemigroup = max\n\n/**\n * Use [`min`](#min) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getMeetSemigroup = min\n\n/**\n * Use [`intercalate`](#intercalate) instead.\n *\n * @category zone of death\n * @since 2.5.0\n * @deprecated\n */\nexport const getIntercalateSemigroup = intercalate\n\n/**\n * Use [`concatAll`](#concatall) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function fold<A>(S: Semigroup<A>): {\n  (startWith: A): (as: ReadonlyArray<A>) => A\n  (startWith: A, as: ReadonlyArray<A>): A\n}\nexport function fold<A>(S: Semigroup<A>): (startWith: A, as?: ReadonlyArray<A>) => A | ((as: ReadonlyArray<A>) => A) {\n  const concatAllS = concatAll(S)\n  return (startWith, as?) => (as === undefined ? concatAllS(startWith) : concatAllS(startWith)(as))\n}\n\n/**\n * Use [`SemigroupAll`](./boolean.ts.html#SemigroupAll) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const semigroupAll: Semigroup<boolean> = {\n  concat: (x, y) => x && y\n}\n\n/**\n * Use [`SemigroupAny`](./boolean.ts.html#SemigroupAny) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const semigroupAny: Semigroup<boolean> = {\n  concat: (x, y) => x || y\n}\n\n/**\n * Use [`getSemigroup`](./function.ts.html#getSemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getFunctionSemigroup: <S>(S: Semigroup<S>) => <A = never>() => Semigroup<(a: A) => S> = getSemigroup\n\n/**\n * Use [`Semigroup`](./string.ts.html#Semigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const semigroupString: Semigroup<string> = {\n  concat: (x, y) => x + y\n}\n\n/**\n * Use [`SemigroupSum`](./number.ts.html#SemigroupSum) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const semigroupSum: Semigroup<number> = {\n  concat: (x, y) => x + y\n}\n\n/**\n * Use [`SemigroupProduct`](./number.ts.html#SemigroupProduct) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const semigroupProduct: Semigroup<number> = {\n  concat: (x, y) => x * y\n}\n"
  },
  {
    "path": "src/Semigroupoid.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { HKT2, Kind2, Kind3, Kind4, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Semigroupoid<F> {\n  readonly URI: F\n  readonly compose: <A, B, C>(bc: HKT2<F, B, C>, ab: HKT2<F, A, B>) => HKT2<F, A, C>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Semigroupoid2<F extends URIS2> {\n  readonly URI: F\n  readonly compose: <A, B, C>(ab: Kind2<F, B, C>, la: Kind2<F, A, B>) => Kind2<F, A, C>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Semigroupoid2C<F extends URIS2, A> {\n  readonly URI: F\n  readonly _E: A\n  readonly compose: <B, C>(ab: Kind2<F, B, C>, la: Kind2<F, A, B>) => Kind2<F, A, C>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Semigroupoid3<F extends URIS3> {\n  readonly URI: F\n  readonly compose: <R, A, B, C>(ab: Kind3<F, R, B, C>, la: Kind3<F, R, A, B>) => Kind3<F, R, A, C>\n}\n\n/**\n * @category model\n * @since 2.2.0\n */\nexport interface Semigroupoid3C<F extends URIS3, A> {\n  readonly URI: F\n  readonly _E: A\n  readonly compose: <R, B, C>(ab: Kind3<F, R, B, C>, la: Kind3<F, R, A, B>) => Kind3<F, R, A, C>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Semigroupoid4<F extends URIS4> {\n  readonly URI: F\n  readonly compose: <S, R, A, B, C>(ab: Kind4<F, S, R, B, C>, la: Kind4<F, S, R, A, B>) => Kind4<F, S, R, A, C>\n}\n"
  },
  {
    "path": "src/Semiring.ts",
    "content": "/**\n * The `Semiring` class is for types that support an addition and multiplication operation.\n *\n * Instances must satisfy the following laws:\n *\n * - Commutative monoid under addition:\n *   - Associativity: `(a + b) + c <-> a + (b + c)`\n *   - Identity: `zero + a = a + zero <-> a`\n *   - Commutative: `a + b <-> b + a`\n * - Monoid under multiplication:\n *   - Associativity: `(a * b) * c <-> a * (b * c)`\n *   - Identity: `one * a <-> a * one <-> a`\n * - Multiplication distributes over addition:\n *   - Left distributivity: `a * (b + c) <-> (a * b) + (a * c)`\n *   - Right distributivity: `(a + b) * c <-> (a * c) + (b * c)`\n * - Annihilation: `zero * a <-> a * zero <-> zero`\n *\n * **Note:** The `number` type is not fully law abiding members of this class hierarchy due to the potential\n * for arithmetic overflows, and the presence of `NaN` and `Infinity` values. The behaviour is\n * unspecified in these cases.\n *\n * @since 2.0.0\n */\nimport { getSemiring } from './function'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Semiring<A> {\n  readonly add: (x: A, y: A) => A\n  readonly zero: A\n  readonly mul: (x: A, y: A) => A\n  readonly one: A\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`getSemiring`](./function.ts.html#getsemiring) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getFunctionSemiring: <A, B>(S: Semiring<B>) => Semiring<(a: A) => B> = getSemiring\n"
  },
  {
    "path": "src/Separated.ts",
    "content": "/**\n * ```ts\n * interface Separated<E, A> {\n *    readonly left: E\n *    readonly right: A\n * }\n * ```\n *\n * Represents a result of separating a whole into two parts.\n *\n * @since 2.10.0\n */\n\nimport { Bifunctor2 } from './Bifunctor'\nimport { pipe } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * A `Separated` type which holds `left` and `right` parts.\n *\n * @category model\n * @since 2.10.0\n */\nexport interface Separated<E, A> {\n  readonly left: E\n  readonly right: A\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.10.0\n */\nexport const separated = <E, A>(left: E, right: A): Separated<E, A> => ({ left, right })\n\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _mapLeft: Bifunctor2<URI>['mapLeft'] = (fa, f) => pipe(fa, mapLeft(f))\nconst _bimap: Bifunctor2<URI>['bimap'] = (fa, g, f) => pipe(fa, bimap(g, f))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.10.0\n */\nexport const map =\n  <A, B>(f: (a: A) => B) =>\n  <E>(fa: Separated<E, A>): Separated<E, B> =>\n    separated(left(fa), f(right(fa)))\n\n/**\n * Map a function over the first type argument of a bifunctor.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport const mapLeft =\n  <E, G>(f: (e: E) => G) =>\n  <A>(fa: Separated<E, A>): Separated<G, A> =>\n    separated(f(left(fa)), right(fa))\n\n/**\n * Map a pair of functions over the two type arguments of the bifunctor.\n *\n * @category mapping\n * @since 2.10.0\n */\nexport const bimap =\n  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) =>\n  (fa: Separated<E, A>): Separated<G, B> =>\n    separated(f(left(fa)), g(right(fa)))\n\n/**\n * @category type lambdas\n * @since 2.10.0\n */\nexport const URI = 'Separated'\n\n/**\n * @category type lambdas\n * @since 2.10.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: Separated<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Bifunctor: Bifunctor2<URI> = {\n  URI,\n  mapLeft: _mapLeft,\n  bimap: _bimap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport const left = <E, A>(s: Separated<E, A>): E => s.left\n\n/**\n * @since 2.10.0\n */\nexport const right = <E, A>(s: Separated<E, A>): A => s.right\n"
  },
  {
    "path": "src/Set.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Either } from './Either'\nimport { Eq } from './Eq'\nimport { identity } from './function'\nimport { Magma } from './Magma'\nimport { Monoid } from './Monoid'\nimport { Option } from './Option'\nimport { Ord } from './Ord'\nimport { Predicate } from './Predicate'\nimport * as RS from './ReadonlySet'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport { Separated, separated } from './Separated'\nimport { Show } from './Show'\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getShow: <A>(S: Show<A>) => Show<Set<A>> = RS.getShow\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getEq: <A>(E: Eq<A>) => Eq<Set<A>> = RS.getEq\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @since 2.0.0\n */\nexport function map<B>(E: Eq<B>): <A>(f: (x: A) => B) => (set: Set<A>) => Set<B> {\n  const elemE = elem(E)\n  return (f) => (set) => {\n    const r = new Set<B>()\n    set.forEach((e) => {\n      const v = f(e)\n      if (!elemE(v, r)) {\n        r.add(v)\n      }\n    })\n    return r\n  }\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation.\n *\n * @since 2.0.0\n */\nexport function chain<B>(E: Eq<B>): <A>(f: (x: A) => Set<B>) => (set: Set<A>) => Set<B> {\n  const elemE = elem(E)\n  return (f) => (set) => {\n    const r = new Set<B>()\n    set.forEach((e) => {\n      f(e).forEach((e) => {\n        if (!elemE(e, r)) {\n          r.add(e)\n        }\n      })\n    })\n    return r\n  }\n}\n\ntype Next<A> = IteratorResult<A, undefined>\n\n/**\n * @since 2.0.0\n */\nexport function filter<A, B extends A>(refinement: Refinement<A, B>): (set: Set<A>) => Set<B>\nexport function filter<A>(predicate: Predicate<A>): <B extends A>(set: Set<B>) => Set<B>\nexport function filter<A>(predicate: Predicate<A>): (set: Set<A>) => Set<A>\nexport function filter<A>(predicate: Predicate<A>): (set: Set<A>) => Set<A> {\n  return (set: Set<A>) => {\n    const values = set.values()\n    let e: Next<A>\n    const r = new Set<A>()\n    while (!(e = values.next()).done) {\n      const a = e.value\n      if (predicate(a)) {\n        r.add(a)\n      }\n    }\n    return r\n  }\n}\n\n/**\n * @since 2.0.0\n */\nexport function partition<A, B extends A>(refinement: Refinement<A, B>): (set: Set<A>) => Separated<Set<A>, Set<B>>\nexport function partition<A>(predicate: Predicate<A>): <B extends A>(set: Set<B>) => Separated<Set<B>, Set<B>>\nexport function partition<A>(predicate: Predicate<A>): (set: Set<A>) => Separated<Set<A>, Set<A>>\nexport function partition<A>(predicate: Predicate<A>): (set: Set<A>) => Separated<Set<A>, Set<A>> {\n  return (set: Set<A>) => {\n    const values = set.values()\n    let e: Next<A>\n    const right = new Set<A>()\n    const left = new Set<A>()\n    while (!(e = values.next()).done) {\n      const a = e.value\n      if (predicate(a)) {\n        right.add(a)\n      } else {\n        left.add(a)\n      }\n    }\n    return separated(left, right)\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Form the union of two sets\n *\n * @since 2.0.0\n */\nexport function union<A>(E: Eq<A>): {\n  (that: Set<A>): (me: Set<A>) => Set<A>\n  (me: Set<A>, that: Set<A>): Set<A>\n}\nexport function union<A>(E: Eq<A>): (me: Set<A>, that?: Set<A>) => Set<A> | ((me: Set<A>) => Set<A>) {\n  const elemE = elem(E)\n  return (me, that?) => {\n    if (that === undefined) {\n      const unionE = union(E)\n      return (that) => unionE(me, that)\n    }\n    if (isEmpty(me)) {\n      return that\n    }\n    if (isEmpty(that)) {\n      return me\n    }\n    const r = new Set(me)\n    that.forEach((e) => {\n      if (!elemE(e, r)) {\n        r.add(e)\n      }\n    })\n    return r\n  }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * The set of elements which are in both the first and second set\n *\n * @since 2.0.0\n */\nexport function intersection<A>(E: Eq<A>): {\n  (that: Set<A>): (me: Set<A>) => Set<A>\n  (me: Set<A>, that: Set<A>): Set<A>\n}\nexport function intersection<A>(E: Eq<A>): (me: Set<A>, that?: Set<A>) => Set<A> | ((that: Set<A>) => Set<A>) {\n  const elemE = elem(E)\n  return (me, that?) => {\n    if (that === undefined) {\n      const intersectionE = intersection(E)\n      return (that) => intersectionE(that, me)\n    }\n    if (isEmpty(me) || isEmpty(that)) {\n      return new Set()\n    }\n    const r = new Set<A>()\n    me.forEach((e) => {\n      if (elemE(e, that)) {\n        r.add(e)\n      }\n    })\n    return r\n  }\n}\n\n/**\n * @since 2.0.0\n */\nexport function partitionMap<B, C>(\n  EB: Eq<B>,\n  EC: Eq<C>\n): <A>(f: (a: A) => Either<B, C>) => (set: Set<A>) => Separated<Set<B>, Set<C>> {\n  return <A>(f: (a: A) => Either<B, C>) =>\n    (set: Set<A>) => {\n      const values = set.values()\n      let e: Next<A>\n      const left = new Set<B>()\n      const right = new Set<C>()\n      const hasB = elem(EB)\n      const hasC = elem(EC)\n      while (!(e = values.next()).done) {\n        const v = f(e.value)\n        switch (v._tag) {\n          case 'Left':\n            if (!hasB(v.left, left)) {\n              left.add(v.left)\n            }\n            break\n          case 'Right':\n            if (!hasC(v.right, right)) {\n              right.add(v.right)\n            }\n            break\n        }\n      }\n      return separated(left, right)\n    }\n}\n\n// TODO: remove non-curried overloading in v3\n/**\n * Form the set difference (`x` - `y`)\n *\n * @example\n * import { difference } from 'fp-ts/Set'\n * import * as N from 'fp-ts/number'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe(new Set([1, 2]), difference(N.Eq)(new Set([1, 3]))), new Set([2]))\n *\n * @since 2.0.0\n */\nexport function difference<A>(E: Eq<A>): {\n  (that: Set<A>): (me: Set<A>) => Set<A>\n  (me: Set<A>, that: Set<A>): Set<A>\n}\nexport function difference<A>(E: Eq<A>): (me: Set<A>, that?: Set<A>) => Set<A> | ((me: Set<A>) => Set<A>) {\n  const elemE = elem(E)\n  return (me, that?) => {\n    if (that === undefined) {\n      const differenceE = difference(E)\n      return (that) => differenceE(that, me)\n    }\n    return filter((a: A) => !elemE(a, that))(me)\n  }\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getUnionSemigroup = <A>(E: Eq<A>): Semigroup<Set<A>> => ({\n  concat: union(E)\n})\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getUnionMonoid = <A>(E: Eq<A>): Monoid<Set<A>> => ({\n  concat: getUnionSemigroup(E).concat,\n  empty: new Set()\n})\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport const getIntersectionSemigroup = <A>(E: Eq<A>): Semigroup<Set<A>> => ({\n  concat: intersection(E)\n})\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const getDifferenceMagma = <A>(E: Eq<A>): Magma<Set<A>> => ({\n  concat: difference(E)\n})\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduce: <A>(O: Ord<A>) => <B>(b: B, f: (b: B, a: A) => B) => (fa: Set<A>) => B = RS.reduce\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const foldMap: <A, M>(O: Ord<A>, M: Monoid<M>) => (f: (a: A) => M) => (fa: Set<A>) => M = RS.foldMap\n\n/**\n * @category folding\n * @since 2.11.0\n */\nexport const reduceRight: <A>(O: Ord<A>) => <B>(b: B, f: (a: A, b: B) => B) => (fa: Set<A>) => B = RS.reduceRight\n\n/**\n * Create a set with one element\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const singleton = <A>(a: A): Set<A> => new Set([a])\n\n/**\n * Insert a value into a set\n *\n * @since 2.0.0\n */\nexport function insert<A>(E: Eq<A>): (a: A) => (set: Set<A>) => Set<A> {\n  const elemE = elem(E)\n  return (a) => (set) => {\n    if (!elemE(a)(set)) {\n      const r = new Set(set)\n      r.add(a)\n      return r\n    } else {\n      return set\n    }\n  }\n}\n\n/**\n * Delete a value from a set\n *\n * @since 2.0.0\n */\nexport const remove =\n  <A>(E: Eq<A>) =>\n  (a: A) =>\n  (set: Set<A>): Set<A> =>\n    filter((ax: A) => !E.equals(a, ax))(set)\n\n/**\n * Checks an element is a member of a set;\n * If yes, removes the value from the set\n * If no, inserts the value to the set\n *\n * @since 2.5.0\n */\nexport const toggle = <A>(E: Eq<A>): ((a: A) => (set: Set<A>) => Set<A>) => {\n  const elemE = elem(E)\n  const removeE = remove(E)\n  const insertE = insert(E)\n  return (a) => (set) => (elemE(a, set) ? removeE : insertE)(a)(set)\n}\n\n/**\n * Create a set from an array\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const fromArray =\n  <A>(E: Eq<A>) =>\n  (as: Array<A>): Set<A> => {\n    const len = as.length\n    const out = new Set<A>()\n    const has = elem(E)\n    for (let i = 0; i < len; i++) {\n      const a = as[i]\n      if (!has(a, out)) {\n        out.add(a)\n      }\n    }\n    return out\n  }\n\n/**\n * @since 2.0.0\n */\nexport const compact = <A>(E: Eq<A>): ((fa: Set<Option<A>>) => Set<A>) => filterMap(E)(identity)\n\n/**\n * @since 2.0.0\n */\nexport function separate<E, A>(EE: Eq<E>, EA: Eq<A>): (fa: Set<Either<E, A>>) => Separated<Set<E>, Set<A>> {\n  return (fa) => {\n    const elemEE = elem(EE)\n    const elemEA = elem(EA)\n    const left: Set<E> = new Set()\n    const right: Set<A> = new Set()\n    fa.forEach((e) => {\n      switch (e._tag) {\n        case 'Left':\n          if (!elemEE(e.left, left)) {\n            left.add(e.left)\n          }\n          break\n        case 'Right':\n          if (!elemEA(e.right, right)) {\n            right.add(e.right)\n          }\n          break\n      }\n    })\n    return separated(left, right)\n  }\n}\n\n/**\n * @since 2.0.0\n */\nexport function filterMap<B>(E: Eq<B>): <A>(f: (a: A) => Option<B>) => (fa: Set<A>) => Set<B> {\n  const elemE = elem(E)\n  return (f) => (fa) => {\n    const r: Set<B> = new Set()\n    fa.forEach((a) => {\n      const ob = f(a)\n      if (ob._tag === 'Some' && !elemE(ob.value, r)) {\n        r.add(ob.value)\n      }\n    })\n    return r\n  }\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.0.0\n */\nexport const empty: Set<never> = new Set()\n\n/**\n * Test whether a `Set` is empty.\n *\n * @since 2.10.0\n */\nexport const isEmpty = <A>(set: Set<A>): boolean => set.size === 0\n\n/**\n * Calculate the number of elements in a `Set`.\n *\n * @since 2.10.0\n */\nexport const size = <A>(set: Set<A>): number => set.size\n\n/**\n * @since 2.0.0\n */\nexport const some: <A>(predicate: Predicate<A>) => (set: Set<A>) => boolean = RS.some\n\n/**\n * @since 2.0.0\n */\nexport const every: {\n  <A, B extends A>(refinement: Refinement<A, B>): Refinement<Set<A>, Set<B>>\n  <A>(predicate: Predicate<A>): Predicate<Set<A>>\n} = RS.every as any\n\n/**\n * @since 2.10.0\n */\nexport const isSubset: <A>(E: Eq<A>) => (that: Set<A>) => (me: Set<A>) => boolean = RS.isSubset\n\n// TODO: remove non-curried overloading in v3\n/**\n * Test if a value is a member of a set\n *\n * @since 2.0.0\n */\nexport const elem: <A>(E: Eq<A>) => {\n  (a: A): (set: Set<A>) => boolean\n  (a: A, set: Set<A>): boolean\n} = RS.elem\n\n/**\n * Get a sorted `Array` of the values contained in a `Set`.\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const toArray =\n  <A>(O: Ord<A>) =>\n  (set: Set<A>): Array<A> => {\n    const out: Array<A> = []\n    set.forEach((e) => out.push(e))\n    return out.sort(O.compare)\n  }\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`isSubset`](#issubset) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const subset: <A>(E: Eq<A>) => {\n  (that: Set<A>): (me: Set<A>) => boolean\n  (me: Set<A>, that: Set<A>): boolean\n} = RS.isSubset\n"
  },
  {
    "path": "src/Show.ts",
    "content": "/**\n * The `Show` type class represents those types which can be converted into\n * a human-readable `string` representation.\n *\n * While not required, it is recommended that for any expression `x`, the\n * string `show(x)` be executable TypeScript code which evaluates to the same\n * value as the expression `x`.\n *\n * @since 2.0.0\n */\nimport * as _ from './internal'\nimport { ReadonlyRecord } from './ReadonlyRecord'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Show<A> {\n  readonly show: (a: A) => string\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport const struct = <A>(shows: { [K in keyof A]: Show<A[K]> }): Show<{ readonly [K in keyof A]: A[K] }> => ({\n  show: (a) => {\n    let s = '{'\n    for (const k in shows) {\n      if (_.has.call(shows, k)) {\n        s += ` ${k}: ${shows[k].show(a[k])},`\n      }\n    }\n    if (s.length > 1) {\n      s = s.slice(0, -1) + ' '\n    }\n    s += '}'\n    return s\n  }\n})\n\n/**\n * @since 2.10.0\n */\nexport const tuple = <A extends ReadonlyArray<unknown>>(\n  ...shows: { [K in keyof A]: Show<A[K]> }\n): Show<Readonly<A>> => ({\n  show: (t) => `[${t.map((a, i) => shows[i].show(a)).join(', ')}]`\n})\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`tuple`](#tuple) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getTupleShow: <T extends ReadonlyArray<Show<any>>>(\n  ...shows: T\n) => Show<{ [K in keyof T]: T[K] extends Show<infer A> ? A : never }> = tuple\n\n/**\n * Use [`struct`](#struct) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getStructShow: <O extends ReadonlyRecord<string, any>>(shows: { [K in keyof O]: Show<O[K]> }) => Show<O> =\n  struct\n\n/**\n * Use [`Show`](./boolean.ts.html#show) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const showBoolean: Show<boolean> = {\n  show: (a) => JSON.stringify(a)\n}\n\n/**\n * Use [`Show`](./string.ts.html#show) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const showString: Show<string> = {\n  show: (a) => JSON.stringify(a)\n}\n\n/**\n * Use [`Show`](./number.ts.html#show) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const showNumber: Show<number> = {\n  show: (a) => JSON.stringify(a)\n}\n"
  },
  {
    "path": "src/State.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Applicative2 } from './Applicative'\nimport { apFirst as apFirst_, Apply2, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport * as chainable from './Chain'\nimport { FromState2 } from './FromState'\nimport { dual, identity, pipe } from './function'\nimport { bindTo as bindTo_, flap as flap_, Functor2, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { Monad2 } from './Monad'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Pointed2 } from './Pointed'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface State<S, A> {\n  (s: S): [A, S]\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Get the current state\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const get: <S>() => State<S, S> = () => (s) => [s, s]\n\n/**\n * Set the state\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const put: <S>(s: S) => State<S, void> = (s) => () => [undefined, s]\n\n/**\n * Modify the state by applying a function to the current state\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const modify: <S>(f: (s: S) => S) => State<S, void> = (f) => (s) => [undefined, f(s)]\n\n/**\n * Get a value which depends on the current state\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const gets: <S, A>(f: (s: S) => A) => State<S, A> = (f) => (s) => [f(s), s]\n\n/* istanbul ignore next */\nconst _map: Monad2<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _ap: Monad2<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: State<E, A>) => State<E, B> = (f) => (fa) => (s1) => {\n  const [a, s2] = fa(s1)\n  return [f(a), s2]\n}\n\n/**\n * @since 2.0.0\n */\nexport const ap: <E, A>(fa: State<E, A>) => <B>(fab: State<E, (a: A) => B>) => State<E, B> = (fa) => (fab) => (s1) => {\n  const [f, s2] = fab(s1)\n  const [a, s3] = fa(s2)\n  return [f(a), s3]\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const of: <S, A>(a: A) => State<S, A> = (a) => (s) => [a, s]\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, S, B>(f: (a: A) => State<S, B>): (ma: State<S, A>) => State<S, B>\n  <S, A, B>(ma: State<S, A>, f: (a: A) => State<S, B>): State<S, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <S, A, B>(ma: State<S, A>, f: (a: A) => State<S, B>): State<S, B> =>\n    (s1) => {\n      const [a, s2] = ma(s1)\n      return f(a)(s2)\n    }\n)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <E, A>(mma: State<E, State<E, A>>) => State<E, A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'State'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: State<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed2<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad2<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <S, A, _>(self: State<S, A>, f: (a: A) => State<S, _>): State<S, A>\n  <A, S, _>(f: (a: A) => State<S, _>): (self: State<S, A>) => State<S, A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromState: FromState2<URI> = {\n  URI,\n  fromState: identity\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Run a computation in the `State` monad, discarding the final state\n *\n * @since 2.8.0\n */\nexport const evaluate =\n  <S>(s: S) =>\n  <A>(ma: State<S, A>): A =>\n    ma(s)[0]\n\n/**\n * Run a computation in the `State` monad discarding the result\n *\n * @since 2.8.0\n */\nexport const execute =\n  <S>(s: S) =>\n  <A>(ma: State<S, A>): S =>\n    ma(s)[1]\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n// -------------------------------------------------------------------------------------\n// pipeable sequence S\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex =\n  <A, S, B>(f: (index: number, a: A) => State<S, B>) =>\n  (as: ReadonlyNonEmptyArray<A>): State<S, ReadonlyNonEmptyArray<B>> =>\n  (s) => {\n    const [b, s2] = f(0, _.head(as))(s)\n    const bs: NonEmptyArray<B> = [b]\n    let out = s2\n    for (let i = 1; i < as.length; i++) {\n      const [b, s2] = f(i, as[i])(out)\n      bs.push(b)\n      out = s2\n    }\n    return [bs, out]\n  }\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, S, B>(\n  f: (index: number, a: A) => State<S, B>\n): ((as: ReadonlyArray<A>) => State<S, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : of(_.emptyReadonlyArray))\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <A, S, B>(\n  f: (index: number, a: A) => State<S, B>\n) => (as: ReadonlyArray<A>) => State<S, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <A, S, B>(\n  f: (a: A) => State<S, B>\n): ((as: ReadonlyArray<A>) => State<S, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <S, A>(arr: ReadonlyArray<State<S, A>>) => State<S, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <S, A, B>(f: (a: A) => State<S, B>) => (ma: State<S, A>) => State<S, B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <S, A, B>(f: (a: A) => State<S, B>) => (ma: State<S, A>) => State<S, A> = tap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`evaluate`](#evaluate) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const evalState: <S, A>(ma: State<S, A>, s: S) => A = (ma, s) => ma(s)[0]\n\n/**\n * Use [`execute`](#execute) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const execState: <S, A>(ma: State<S, A>, s: S) => S = (ma, s) => ma(s)[1]\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `S.Functor` instead of `S.state`\n * (where `S` is from `import S from 'fp-ts/State'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const state: Monad2<URI> = Monad\n"
  },
  {
    "path": "src/StateReaderTaskEither.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Alt4 } from './Alt'\nimport { Applicative4 } from './Applicative'\nimport { apFirst as apFirst_, Apply4, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport { Bifunctor4 } from './Bifunctor'\nimport * as chainable from './Chain'\nimport * as E from './Either'\nimport { Endomorphism } from './Endomorphism'\nimport {\n  chainOptionK as chainOptionK_,\n  filterOrElse as filterOrElse_,\n  FromEither4,\n  fromEitherK as fromEitherK_,\n  fromOption as fromOption_,\n  fromOptionK as fromOptionK_,\n  fromPredicate as fromPredicate_,\n  tapEither as tapEither_\n} from './FromEither'\nimport { FromIO4, fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO'\nimport {\n  ask as ask_,\n  asks as asks_,\n  FromReader4,\n  fromReaderK as fromReaderK_,\n  tapReader as tapReader_\n} from './FromReader'\nimport {\n  chainStateK as chainStateK_,\n  FromState4,\n  fromStateK as fromStateK_,\n  get as get_,\n  gets as gets_,\n  modify as modify_,\n  put as put_\n} from './FromState'\nimport { FromTask4, fromTaskK as fromTaskK_, tapTask as tapTask_ } from './FromTask'\nimport { dual, flow, identity, LazyArg, pipe } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor4, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { IO } from './IO'\nimport { IOEither } from './IOEither'\nimport { Monad4 } from './Monad'\nimport { MonadIO4 } from './MonadIO'\nimport { MonadTask4 } from './MonadTask'\nimport { MonadThrow4 } from './MonadThrow'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Option } from './Option'\nimport { Pointed4 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport * as R from './Reader'\nimport { ReaderEither } from './ReaderEither'\nimport * as RTE from './ReaderTaskEither'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { State } from './State'\nimport * as ST from './StateT'\nimport { Task } from './Task'\nimport { TaskEither } from './TaskEither'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\nimport ReaderTaskEither = RTE.ReaderTaskEither\nimport Either = E.Either\nimport Reader = R.Reader\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface StateReaderTaskEither<S, R, E, A> {\n  (s: S): ReaderTaskEither<R, E, [A, S]>\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const left: <S, R, E, A = never>(e: E) => StateReaderTaskEither<S, R, E, A> = (e) => () => RTE.left(e)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const right: <S, R, E = never, A = never>(a: A) => StateReaderTaskEither<S, R, E, A> = /*#__PURE__*/ ST.of(\n  RTE.Pointed\n)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function rightTask<S, R, E = never, A = never>(ma: Task<A>): StateReaderTaskEither<S, R, E, A> {\n  return fromReaderTaskEither(RTE.rightTask(ma))\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function leftTask<S, R, E, A = never>(me: Task<E>): StateReaderTaskEither<S, R, E, A> {\n  return fromReaderTaskEither(RTE.leftTask(me))\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function rightReader<S, R, E = never, A = never>(ma: Reader<R, A>): StateReaderTaskEither<S, R, E, A> {\n  return fromReaderTaskEither(RTE.rightReader(ma))\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function leftReader<S, R, E, A = never>(me: Reader<R, E>): StateReaderTaskEither<S, R, E, A> {\n  return fromReaderTaskEither(RTE.leftReader(me))\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function rightIO<S, R, E = never, A = never>(ma: IO<A>): StateReaderTaskEither<S, R, E, A> {\n  return fromReaderTaskEither(RTE.rightIO(ma))\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function leftIO<S, R, E, A = never>(me: IO<E>): StateReaderTaskEither<S, R, E, A> {\n  return fromReaderTaskEither(RTE.leftIO(me))\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const rightState: <S, R, E = never, A = never>(ma: State<S, A>) => StateReaderTaskEither<S, R, E, A> = (sa) =>\n  flow(sa, RTE.right)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const leftState: <S, R, E, A = never>(me: State<S, E>) => StateReaderTaskEither<S, R, E, A> = (me) => (s) =>\n  RTE.left(me(s)[0])\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromEither: <E, A, S, R = unknown>(fa: Either<E, A>) => StateReaderTaskEither<S, R, E, A> =\n  /*#__PURE__*/ E.match((e) => left(e), right)\n\n/**\n * @category conversions\n * @since 2.11.0\n */\nexport const fromReader: <R, A, S, E = never>(fa: Reader<R, A>) => StateReaderTaskEither<S, R, E, A> = rightReader\n\n/**\n * @category conversions\n * @since 2.7.0\n */\nexport const fromIO: <A, S, R = unknown, E = never>(fa: IO<A>) => StateReaderTaskEither<S, R, E, A> = rightIO\n\n/**\n * @category conversions\n * @since 2.7.0\n */\nexport const fromTask: <A, S, R = unknown, E = never>(fa: Task<A>) => StateReaderTaskEither<S, R, E, A> = rightTask\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromState: <S, A, R = unknown, E = never>(fa: State<S, A>) => StateReaderTaskEither<S, R, E, A> =\n  /*#__PURE__*/ ST.fromState(RTE.Pointed)\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromTaskEither: <E, A, S, R = unknown>(fa: TaskEither<E, A>) => StateReaderTaskEither<S, R, E, A> = (ma) =>\n  fromReaderTaskEither(RTE.fromTaskEither(ma))\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromIOEither: <E, A, S, R = unknown>(fa: IOEither<E, A>) => StateReaderTaskEither<S, R, E, A> = (ma) =>\n  fromReaderTaskEither(RTE.fromIOEither(ma))\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromReaderEither: <R, E, A, S>(fa: ReaderEither<R, E, A>) => StateReaderTaskEither<S, R, E, A> = (ma) =>\n  fromReaderTaskEither(RTE.fromReaderEither(ma))\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const fromReaderTaskEither: <R, E, A, S>(fa: ReaderTaskEither<R, E, A>) => StateReaderTaskEither<S, R, E, A> =\n  /*#__PURE__*/ ST.fromF(RTE.Functor)\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s\n * `contramap`).\n *\n * @since 2.11.0\n */\nexport const local =\n  <R2, R1>(f: (r2: R2) => R1) =>\n  <S, E, A>(ma: StateReaderTaskEither<S, R1, E, A>): StateReaderTaskEither<S, R2, E, A> =>\n    flow(ma, R.local(f))\n\n/**\n * Less strict version of [`asksStateReaderTaskEither`](#asksstatereadertaskeither).\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksStateReaderTaskEitherW =\n  <R1, S, R2, E, A>(f: (r1: R1) => StateReaderTaskEither<S, R2, E, A>): StateReaderTaskEither<S, R1 & R2, E, A> =>\n  (s) =>\n  (r) =>\n    f(r)(s)(r)\n\n/**\n * Effectfully accesses the environment.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asksStateReaderTaskEither: <R, S, E, A>(\n  f: (r: R) => StateReaderTaskEither<S, R, E, A>\n) => StateReaderTaskEither<S, R, E, A> = asksStateReaderTaskEitherW\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromIOEitherK =\n  <E, A extends ReadonlyArray<unknown>, B>(\n    f: (...a: A) => IOEither<E, B>\n  ): (<S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>) =>\n  (...a) =>\n    fromIOEither(f(...a))\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromTaskEitherK =\n  <E, A extends ReadonlyArray<unknown>, B>(\n    f: (...a: A) => TaskEither<E, B>\n  ): (<S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B>) =>\n  (...a) =>\n    fromTaskEither(f(...a))\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromReaderTaskEitherK =\n  <R, E, A extends ReadonlyArray<unknown>, B>(\n    f: (...a: A) => ReaderTaskEither<R, E, B>\n  ): (<S>(...a: A) => StateReaderTaskEither<S, R, E, B>) =>\n  (...a) =>\n    fromReaderTaskEither(f(...a))\n\n/**\n * Alias of `flatMapReaderTaskEither`.\n *\n * Less strict version of [`chainReaderTaskEitherK`](#chainreadertaskeitherk).\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainReaderTaskEitherKW =\n  <R, E2, A, B>(f: (a: A) => ReaderTaskEither<R, E2, B>) =>\n  <S, E1>(ma: StateReaderTaskEither<S, R, E1, A>): StateReaderTaskEither<S, R, E1 | E2, B> =>\n    flatMap<S, R, E1, A, R, E1 | E2, B>(ma, fromReaderTaskEitherK(f))\n\n/**\n * Alias of `flatMapReaderTaskEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainReaderTaskEitherK: <R, E, A, B>(\n  f: (a: A) => ReaderTaskEither<R, E, B>\n) => <S>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = chainReaderTaskEitherKW\n\n/* istanbul ignore next */\nconst _map: Monad4<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _ap: Monad4<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n/* istanbul ignore next */\nconst _alt: <S, R, E, A>(\n  fa: StateReaderTaskEither<S, R, E, A>,\n  that: LazyArg<StateReaderTaskEither<S, R, E, A>>\n) => StateReaderTaskEither<S, R, E, A> = (fa, that) => (s) =>\n  pipe(\n    fa(s),\n    RTE.alt(() => that()(s))\n  )\nconst _bimap: <S, R, E, A, G, B>(\n  fea: StateReaderTaskEither<S, R, E, A>,\n  f: (e: E) => G,\n  g: (a: A) => B\n) => StateReaderTaskEither<S, R, G, B> = (fea, f, g) => (s) =>\n  pipe(\n    fea(s),\n    RTE.bimap(f, ([a, s]) => [g(a), s])\n  )\nconst _mapLeft: <S, R, E, A, G>(\n  fea: StateReaderTaskEither<S, R, E, A>,\n  f: (e: E) => G\n) => StateReaderTaskEither<S, R, G, A> = (fea, f) => (s) => pipe(fea(s), RTE.mapLeft(f))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(\n  f: (a: A) => B\n) => <S, R, E>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ ST.map(\n  RTE.Functor\n)\n\n/**\n * Map a pair of functions over the two last type arguments of the bifunctor.\n *\n * @category mapping\n * @since 2.6.2\n */\nexport const bimap: <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <S, R>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, G, B> = (f, g) => (fa) =>\n  _bimap(fa, f, g)\n\n/**\n * Map a function over the third type argument of a bifunctor.\n *\n * @category error handling\n * @since 2.6.2\n */\nexport const mapLeft: <E, G>(\n  f: (e: E) => G\n) => <S, R, A>(fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, G, A> = (f) => (fa) =>\n  _mapLeft(fa, f)\n\n/**\n * @since 2.0.0\n */\nexport const ap: <S, R, E, A>(\n  fa: StateReaderTaskEither<S, R, E, A>\n) => <B>(fab: StateReaderTaskEither<S, R, E, (a: A) => B>) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ ST.ap(\n  RTE.Chain\n)\n\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.8.0\n */\nexport const apW: <S, R2, E2, A>(\n  fa: StateReaderTaskEither<S, R2, E2, A>\n) => <R1, E1, B>(fab: StateReaderTaskEither<S, R1, E1, (a: A) => B>) => StateReaderTaskEither<S, R1 & R2, E1 | E2, B> =\n  ap as any\n\n/**\n * @category constructors\n * @since 2.7.0\n */\nexport const of: <S, R = unknown, E = never, A = never>(a: A) => StateReaderTaskEither<S, R, E, A> = right\n\n/** @internal */\ninterface StateReaderTaskEitherTypeLambda extends _.TypeLambda {\n  readonly type: StateReaderTaskEither<this['Out2'], this['In'], this['Out1'], this['Target']>\n}\n\n/** @internal */\nconst _FromIO: _.FromIO<StateReaderTaskEitherTypeLambda> = {\n  fromIO\n}\n\n/** @internal */\nconst _FromTask: _.FromTask<StateReaderTaskEitherTypeLambda> = {\n  fromTask\n}\n\n/** @internal */\nconst _FromReader: _.FromReader<StateReaderTaskEitherTypeLambda> = {\n  fromReader\n}\n\n/** @internal */\nconst _FromEither: _.FromEither<StateReaderTaskEitherTypeLambda> = {\n  fromEither\n}\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, S, R2, E2, B>(f: (a: A) => StateReaderTaskEither<S, R2, E2, B>): <R1, E1>(\n    ma: StateReaderTaskEither<S, R1, E1, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E1 | E2, B>\n  <S, R1, E1, A, R2, E2, B>(\n    ma: StateReaderTaskEither<S, R1, E1, A>,\n    f: (a: A) => StateReaderTaskEither<S, R2, E2, B>\n  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, B>\n} = /*#__PURE__*/ dual(2, ST.flatMap(RTE.Monad))\n\n/** @internal */\nconst _FlatMap: _.FlatMap<StateReaderTaskEitherTypeLambda> = {\n  flatMap\n}\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapTaskEither: {\n  <A, E2, B>(f: (a: A) => TaskEither<E2, B>): <S, R, E1>(\n    self: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E1 | E2, B>\n  <S, R, E1, A, E2, B>(self: StateReaderTaskEither<S, R, E1, A>, f: (a: A) => TaskEither<E2, B>): StateReaderTaskEither<\n    S,\n    R,\n    E1 | E2,\n    B\n  >\n} = /*#__PURE__*/ dual(\n  2,\n  <S, R, E1, A, E2, B>(\n    self: StateReaderTaskEither<S, R, E1, A>,\n    f: (a: A) => TaskEither<E2, B>\n  ): StateReaderTaskEither<S, R, E1 | E2, B> => flatMap(self, (a: A) => fromTaskEitherK(f)<S, R>(a))\n)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n  <S, R, E, A, B>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => IO<B>): StateReaderTaskEither<S, R, E, B>\n} = /*#__PURE__*/ _.flatMapIO(_FromIO, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapTask: {\n  <A, B>(f: (a: A) => Task<B>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B>\n  <S, R, E, A, B>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => Task<B>): StateReaderTaskEither<S, R, E, B>\n} = /*#__PURE__*/ _.flatMapTask(_FromTask, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReader: {\n  <A, R2, B>(f: (a: A) => Reader<R2, B>): <S, R1, E>(\n    self: StateReaderTaskEither<S, R1, E, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E, B>\n  <S, R1, E, A, R2, B>(self: StateReaderTaskEither<S, R1, E, A>, f: (a: A) => Reader<R2, B>): StateReaderTaskEither<\n    S,\n    R1 & R2,\n    E,\n    B\n  >\n} = /*#__PURE__*/ _.flatMapReader(_FromReader, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIOEither: {\n  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <S, R, E1>(\n    self: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E1 | E2, B>\n  <S, R, E1, A, E2, B>(self: StateReaderTaskEither<S, R, E1, A>, f: (a: A) => IOEither<E2, B>): StateReaderTaskEither<\n    S,\n    R,\n    E1 | E2,\n    B\n  >\n} = /*#__PURE__*/ dual(\n  2,\n  <S, R, E1, A, E2, B>(\n    self: StateReaderTaskEither<S, R, E1, A>,\n    f: (a: A) => IOEither<E2, B>\n  ): StateReaderTaskEither<S, R, E1 | E2, B> => flatMap(self, (a: A) => fromIOEitherK(f)<S, R>(a))\n)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapEither: {\n  <A, E2, B>(f: (a: A) => Either<E2, B>): <S, R, E1>(\n    self: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E1 | E2, B>\n  <S, R, E1, A, E2, B>(self: StateReaderTaskEither<S, R, E1, A>, f: (a: A) => Either<E2, B>): StateReaderTaskEither<\n    S,\n    R,\n    E1 | E2,\n    B\n  >\n} = /*#__PURE__*/ dual(2, _.flatMapEither(_FromEither, _FlatMap))\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapOption: {\n  <A, E2, B>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <S, R, E1>(\n    self: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E1 | E2, B>\n  <S, R, E1, A, E2, B>(\n    self: StateReaderTaskEither<S, R, E1, A>,\n    f: (a: A) => Option<B>,\n    onNone: (a: A) => E2\n  ): StateReaderTaskEither<S, R, E1 | E2, B>\n} = /*#__PURE__*/ _.flatMapOption(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapReaderTaskEither: {\n  <A, R2, E2, B>(f: (a: A) => ReaderTaskEither<R2, E2, B>): <S, R1, E1>(\n    self: StateReaderTaskEither<S, R1, E1, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E1 | E2, B>\n  <S, R1, E1, A, R2, E2, B>(\n    self: StateReaderTaskEither<S, R1, E1, A>,\n    f: (a: A) => ReaderTaskEither<R2, E2, B>\n  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <S, R1, E1, A, R2, E2, B>(\n    self: StateReaderTaskEither<S, R1, E1, A>,\n    f: (a: A) => ReaderTaskEither<R2, E2, B>\n  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, B> => flatMap(self, (a: A) => fromReaderTaskEitherK(f)<S>(a))\n)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapState: {\n  <S, A, B>(f: (a: A) => State<S, B>): <R, E>(\n    self: StateReaderTaskEither<S, R, E, A>\n  ) => StateReaderTaskEither<S, R, E, B>\n  <S, R, E, A, B>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => State<S, B>): StateReaderTaskEither<S, R, E, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <S, R, E, A, B>(\n    self: StateReaderTaskEither<S, R, E, A>,\n    f: (a: A) => State<S, B>\n  ): StateReaderTaskEither<S, R, E, B> => flatMap(self, fromStateK(f))\n)\n\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport const flattenW: <S, R1, E1, R2, E2, A>(\n  mma: StateReaderTaskEither<S, R1, E1, StateReaderTaskEither<S, R2, E2, A>>\n) => StateReaderTaskEither<S, R1 & R2, E1 | E2, A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <S, R, E, A>(\n  mma: StateReaderTaskEither<S, R, E, StateReaderTaskEither<S, R, E, A>>\n) => StateReaderTaskEither<S, R, E, A> = flattenW\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged.\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW =\n  <S, R2, E2, B>(that: () => StateReaderTaskEither<S, R2, E2, B>) =>\n  <R1, E1, A>(fa: StateReaderTaskEither<S, R1, E1, A>): StateReaderTaskEither<S, R1 & R2, E2, A | B> =>\n  (r) =>\n    pipe(\n      fa(r),\n      RTE.altW(() => that()(r))\n    )\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * @category error handling\n * @since 2.6.2\n */\nexport const alt: <S, R, E, A>(\n  that: LazyArg<StateReaderTaskEither<S, R, E, A>>\n) => (fa: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A> = altW\n\n/**\n * @since 2.7.0\n */\nexport const throwError: MonadThrow4<URI>['throwError'] = left\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'StateReaderTaskEither'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind4<S, R, E, A> {\n    readonly [URI]: StateReaderTaskEither<S, R, E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor4<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the `Right` value of this `StateReaderTaskEither` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <S, R, E, _>(self: StateReaderTaskEither<S, R, E, _>) => StateReaderTaskEither<S, R, E, A>\n  <S, R, E, _, A>(self: StateReaderTaskEither<S, R, E, _>, a: A): StateReaderTaskEither<S, R, E, A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the `Right` value of this `StateReaderTaskEither` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <S, R, E, _>(self: StateReaderTaskEither<S, R, E, _>) => StateReaderTaskEither<S, R, E, void> =\n  asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed4<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply4<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Less strict version of [`apFirst`](#apfirst).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apFirstW: <S, R2, E2, A, B>(\n  second: StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(first: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E1 | E2, A> =\n  apFirst as any\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * Less strict version of [`apSecond`](#apsecond).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apSecondW: <S, R2, E2, A, B>(\n  second: StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(first: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E1 | E2, B> =\n  apSecond as any\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative4<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain4<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromState: FromState4<URI> = {\n  URI,\n  fromState\n}\n\n/**\n * Get the current state\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const get: <S, R, E = never>() => StateReaderTaskEither<S, R, E, S> = /*#__PURE__*/ get_(FromState)\n\n/**\n * Set the state\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const put: <S, R, E = never>(s: S) => StateReaderTaskEither<S, R, E, void> = /*#__PURE__*/ put_(FromState)\n\n/**\n * Modify the state by applying a function to the current state\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const modify: <S, R, E = never>(f: Endomorphism<S>) => StateReaderTaskEither<S, R, E, void> =\n  /*#__PURE__*/ modify_(FromState)\n\n/**\n * Get a value which depends on the current state\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const gets: <S, R, E = never, A = never>(f: (s: S) => A) => StateReaderTaskEither<S, R, E, A> =\n  /*#__PURE__*/ gets_(FromState)\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromStateK: <A extends ReadonlyArray<unknown>, S, B>(\n  f: (...a: A) => State<S, B>\n) => <R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ fromStateK_(FromState)\n\n/**\n * Alias of `flatMapState`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainStateK: <A, S, B>(\n  f: (a: A) => State<S, B>\n) => <R, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ chainStateK_(\n  FromState,\n  Chain\n)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Monad: Monad4<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadIO: MonadIO4<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadTask: MonadTask4<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadThrow: MonadThrow4<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  throwError\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromEither: FromEither4<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromIO: FromIO4<URI> = {\n  URI,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromTask: FromTask4<URI> = {\n  URI,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromReader: FromReader4<URI> = {\n  URI,\n  fromReader\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <S, R1, E1, A, R2, E2, _>(\n    self: StateReaderTaskEither<S, R1, E1, A>,\n    f: (a: A) => StateReaderTaskEither<S, R2, E2, _>\n  ): StateReaderTaskEither<S, R1 & R2, E1 | E2, A>\n  <A, S, R2, E2, _>(f: (a: A) => StateReaderTaskEither<S, R2, E2, _>): <R1, E1>(\n    self: StateReaderTaskEither<S, R1, E1, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E2 | E1, A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapEither: {\n  <A, E2, _>(f: (a: A) => Either<E2, _>): <S, R1, E1>(\n    self: StateReaderTaskEither<S, R1, E1, A>\n  ) => StateReaderTaskEither<S, R1, E2 | E1, A>\n  <S, R1, E1, A, E2, _>(self: StateReaderTaskEither<S, R1, E1, A>, f: (a: A) => Either<E2, _>): StateReaderTaskEither<\n    S,\n    R1,\n    E1 | E2,\n    A\n  >\n} = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n  <S, R, E, A, _>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => IO<_>): StateReaderTaskEither<S, R, E, A>\n} = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapTask: {\n  <A, _>(f: (a: A) => Task<_>): <S, R, E>(self: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A>\n  <S, R, E, A, _>(self: StateReaderTaskEither<S, R, E, A>, f: (a: A) => Task<_>): StateReaderTaskEither<S, R, E, A>\n} = /*#__PURE__*/ dual(2, tapTask_(FromTask, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapReader: {\n  <A, R2, _>(f: (a: A) => Reader<R2, _>): <S, R1, E>(\n    self: StateReaderTaskEither<S, R1, E, A>\n  ) => StateReaderTaskEither<S, R1 & R2, E, A>\n  <S, R1, E, A, R2, _>(self: StateReaderTaskEither<S, R1, E, A>, f: (a: A) => Reader<R2, _>): StateReaderTaskEither<\n    S,\n    R1 & R2,\n    E,\n    A\n  >\n} = /*#__PURE__*/ dual(2, tapReader_(FromReader, Chain))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor4<URI> = {\n  URI,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt4<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * Reads the current context.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const ask: <S, R, E = never>() => StateReaderTaskEither<S, R, E, R> = /*#__PURE__*/ ask_(FromReader)\n\n/**\n * Projects a value from the global context in a `ReaderEither`.\n *\n * @category constructors\n * @since 2.11.0\n */\nexport const asks: <S, R, A, E = never>(f: (r: R) => A) => StateReaderTaskEither<S, R, E, A> =\n  /*#__PURE__*/ asks_(FromReader)\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromReaderK: <A extends ReadonlyArray<unknown>, R, B>(\n  f: (...a: A) => Reader<R, B>\n) => <S, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ fromReaderK_(FromReader)\n\n/**\n * Alias of `flatMapReader`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderK: <A, R, B>(\n  f: (a: A) => Reader<R, B>\n) => <S, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = flatMapReader\n\n/**\n * Alias of `flatMapReader`.\n *\n * Less strict version of [`chainReaderK`](#chainReaderK).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainReaderKW: <A, R1, B>(\n  f: (a: A) => Reader<R1, B>\n) => <S, R2, E>(ma: StateReaderTaskEither<S, R2, E, A>) => StateReaderTaskEither<S, R1 & R2, E, B> = flatMapReader\n\n/**\n * Alias of `tapReader`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderK: <A, R, B>(\n  f: (a: A) => Reader<R, B>\n) => <S, E>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A> = tapReader\n\n/**\n * Alias of `tapReader`.\n *\n * Less strict version of [`chainFirstReaderK`](#chainFirstReaderK).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainFirstReaderKW: <A, R1, B>(\n  f: (a: A) => Reader<R1, B>\n) => <S, R2, E>(ma: StateReaderTaskEither<S, R2, E, A>) => StateReaderTaskEither<S, R1 & R2, E, A> = tapReader\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromOption: <E>(\n  onNone: LazyArg<E>\n) => <A, S, R = unknown>(fa: Option<A>) => StateReaderTaskEither<S, R, E, A> = /*#__PURE__*/ fromOption_(FromEither)\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Option<B>\n) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ fromOptionK_(FromEither)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(\n  f: (a: A) => Option<B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ chainOptionK_(\n  FromEither,\n  Chain\n)\n\n/**\n * Use `flatMapOption`.\n *\n * Less strict version of [`chainOptionK`](#chainoptionk).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category legacy\n * @since 2.13.2\n */\nexport const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(\n  f: (a: A) => Option<B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E1 | E2, B> = chainOptionK as any\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainEitherK: <E, A, B>(\n  f: (a: A) => E.Either<E, B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = flatMapEither\n\n/**\n * Alias of `flatMapEither`.\n *\n * Less strict version of [`chainEitherK`](#chaineitherk).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainEitherKW: <E2, A, B>(\n  f: (a: A) => Either<E2, B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E1 | E2, B> = flatMapEither\n\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherK: <A, E, B>(\n  f: (a: A) => E.Either<E, B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A> = tapEither\n\n/**\n * Alias of `tapEither`.\n *\n * Less strict version of [`chainFirstEitherK`](#chainfirsteitherk).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => Either<E2, B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E1 | E2, A> = tapEither\n\n/**\n * @category lifting\n * @since 2.4.4\n */\nexport const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R = unknown>(\n    a: A\n  ) => StateReaderTaskEither<S, R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R = unknown, B extends A = A>(\n    b: B\n  ) => StateReaderTaskEither<S, R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R = unknown>(a: A) => StateReaderTaskEither<S, R, E, A>\n} = /*#__PURE__*/ fromPredicate_(FromEither)\n\n/**\n * @category filtering\n * @since 2.4.4\n */\nexport const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(\n    ma: StateReaderTaskEither<S, R, E, A>\n  ) => StateReaderTaskEither<S, R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R, B extends A>(\n    mb: StateReaderTaskEither<S, R, E, B>\n  ) => StateReaderTaskEither<S, R, E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(\n    ma: StateReaderTaskEither<S, R, E, A>\n  ) => StateReaderTaskEither<S, R, E, A>\n} = /*#__PURE__*/ filterOrElse_(FromEither, Chain)\n\n/**\n * Less strict version of [`filterOrElse`](#filterorelse).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category filtering\n * @since 2.9.0\n */\nexport const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <S, R, E1>(\n    ma: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <S, R, E1, B extends A>(\n    mb: StateReaderTaskEither<S, R, E1, B>\n  ) => StateReaderTaskEither<S, R, E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <S, R, E1>(\n    ma: StateReaderTaskEither<S, R, E1, A>\n  ) => StateReaderTaskEither<S, R, E1 | E2, A>\n} = filterOrElse\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => E.Either<E, B>\n) => <S, R = unknown>(...a: A) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => IO<B>\n) => <S, R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainIOK: <A, B>(\n  f: (a: A) => IO<B>\n) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = flatMapIO\n\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstIOK: <A, B>(\n  f: (a: A) => IO<B>\n) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A> = tapIO\n\n/**\n * Alias of `flatMapTaskEither`.\n *\n * Less strict version of [`chainTaskEitherK`](#chaintaskeitherk).\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainTaskEitherKW: <E2, A, B>(\n  f: (a: A) => TaskEither<E2, B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E1 | E2, B> = flatMapTaskEither\n\n/**\n * Alias of `flatMapTaskEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainTaskEitherK: <E, A, B>(\n  f: (a: A) => TaskEither<E, B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = flatMapTaskEither\n\n/**\n * Alias of `flatMapIOEither`.\n *\n * Less strict version of [`chainIOEitherK`](#chainioeitherk).\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainIOEitherKW: <E2, A, B>(\n  f: (a: A) => IOEither<E2, B>\n) => <S, R, E1>(ma: StateReaderTaskEither<S, R, E1, A>) => StateReaderTaskEither<S, R, E1 | E2, B> = flatMapIOEither\n\n/**\n * Alias of `flatMapIOEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainIOEitherK: <E, A, B>(\n  f: (a: A) => IOEither<E, B>\n) => <S, R>(ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = flatMapIOEither\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromTaskK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Task<B>\n) => <S, R = unknown, E = never>(...a: A) => StateReaderTaskEither<S, R, E, B> = /*#__PURE__*/ fromTaskK_(FromTask)\n\n/**\n * Alias of `flatMapTask`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainTaskK: <A, B>(\n  f: (a: A) => Task<B>\n) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = flatMapTask\n\n/**\n * Alias of `tapTask`.\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstTaskK: <A, B>(\n  f: (a: A) => Task<B>\n) => <S, R, E>(first: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A> = tapTask\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Run a computation in the `StateReaderTaskEither` monad, discarding the final state\n *\n * @since 2.8.0\n */\nexport const evaluate: <S>(s: S) => <R, E, A>(ma: StateReaderTaskEither<S, R, E, A>) => ReaderTaskEither<R, E, A> =\n  /*#__PURE__*/ ST.evaluate(RTE.Functor)\n\n/**\n * Run a computation in the `StateReaderTaskEither` monad discarding the result\n *\n * @since 2.8.0\n */\nexport const execute: <S>(s: S) => <R, E, A>(ma: StateReaderTaskEither<S, R, E, A>) => ReaderTaskEither<R, E, S> =\n  /*#__PURE__*/ ST.execute(RTE.Functor)\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @since 2.8.0\n */\nexport const bindW: <N extends string, A, S, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(\n  fa: StateReaderTaskEither<S, R1, E1, A>\n) => StateReaderTaskEither<S, R1 & R2, E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  bind as any\n\n// -------------------------------------------------------------------------------------\n// pipeable sequence S\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const apSW: <A, N extends string, S, R2, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(\n  fa: StateReaderTaskEither<S, R1, E1, A>\n) => StateReaderTaskEither<S, R1 & R2, E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  apS as any\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex =\n  <A, S, R, E, B>(f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>) =>\n  (as: ReadonlyNonEmptyArray<A>): StateReaderTaskEither<S, R, E, ReadonlyNonEmptyArray<B>> =>\n  (s) =>\n  (r) =>\n  () =>\n    _.tail(as).reduce<Promise<Either<E, [NonEmptyArray<B>, S]>>>(\n      (acc, a, i) =>\n        acc.then((ebs) =>\n          _.isLeft(ebs)\n            ? acc\n            : f(\n                i + 1,\n                a\n              )(ebs.right[1])(r)().then((eb) => {\n                if (_.isLeft(eb)) {\n                  return eb\n                }\n                const [b, s] = eb.right\n                ebs.right[0].push(b)\n                ebs.right[1] = s\n                return ebs\n              })\n        ),\n      f(0, _.head(as))(s)(r)().then(E.map(([b, s]) => [[b], s]))\n    )\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, S, R, E, B>(\n  f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>\n): ((as: ReadonlyArray<A>) => StateReaderTaskEither<S, R, E, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : of(_.emptyReadonlyArray))\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <S, R, E, A, B>(\n  f: (index: number, a: A) => StateReaderTaskEither<S, R, E, B>\n) => (as: ReadonlyArray<A>) => StateReaderTaskEither<S, R, E, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <S, R, E, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R, E, B>\n): ((as: ReadonlyArray<A>) => StateReaderTaskEither<S, R, E, ReadonlyArray<B>>) =>\n  traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <S, R, E, A>(\n  arr: ReadonlyArray<StateReaderTaskEither<S, R, E, A>>\n) => StateReaderTaskEither<S, R, E, ReadonlyArray<A>> = /*#__PURE__*/ traverseArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <S, R, E, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R, E, B>\n) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, B> = flatMap\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.0\n */\nexport const chainW: <S, R2, E2, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(ma: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E1 | E2, B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <S, R, E, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R, E, B>\n) => (ma: StateReaderTaskEither<S, R, E, A>) => StateReaderTaskEither<S, R, E, A> = tap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.8.0\n */\nexport const chainFirstW: <S, R2, E2, A, B>(\n  f: (a: A) => StateReaderTaskEither<S, R2, E2, B>\n) => <R1, E1>(ma: StateReaderTaskEither<S, R1, E1, A>) => StateReaderTaskEither<S, R1 & R2, E1 | E2, A> = tap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `SRTE.Functor` instead of `SRTE.stateReaderTaskEither`\n * (where `SRTE` is from `import SRTE from 'fp-ts/StateReaderTaskEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const stateReaderTaskEither: Monad4<URI> & Bifunctor4<URI> & Alt4<URI> & MonadTask4<URI> & MonadThrow4<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  bimap: _bimap,\n  mapLeft: _mapLeft,\n  alt: _alt,\n  fromIO,\n  fromTask,\n  throwError\n}\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `SRTE.Functor` instead of `SRTE.stateReaderTaskEitherSeq`\n * (where `SRTE` is from `import SRTE from 'fp-ts/StateReaderTaskEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n\nexport const stateReaderTaskEitherSeq: typeof stateReaderTaskEither = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  bimap: _bimap,\n  mapLeft: _mapLeft,\n  alt: _alt,\n  fromIO,\n  fromTask,\n  throwError\n}\n\n/**\n * Use [`evaluate`](#evaluate) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n/* istanbul ignore next */\nexport const evalState: <S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S) => ReaderTaskEither<R, E, A> = (\n  fsa,\n  s\n) =>\n  pipe(\n    fsa(s),\n    RTE.map(([a]) => a)\n  )\n\n/**\n * Use [`execute`](#execute) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n/* istanbul ignore next */\nexport const execState: <S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S) => ReaderTaskEither<R, E, S> = (\n  fsa,\n  s\n) =>\n  pipe(\n    fsa(s),\n    RTE.map(([_, s]) => s)\n  )\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n/* istanbul ignore next */\nexport function run<S, R, E, A>(ma: StateReaderTaskEither<S, R, E, A>, s: S, r: R): Promise<Either<E, [A, S]>> {\n  return ma(s)(r)()\n}\n"
  },
  {
    "path": "src/StateT.ts",
    "content": "/**\n * The state monad transformer. It can be used to add state to other monads.\n *\n * The `of` function leaves the state unchanged, while `chain` uses the final state of the first computation\n * as the initial state of the second.\n *\n * @since 2.0.0\n */\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C } from './Chain'\nimport { pipe } from './function'\nimport { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'\nimport { Monad, Monad1, Monad2, Monad2C, Monad3, Monad3C } from './Monad'\nimport { Pointed, Pointed1, Pointed2, Pointed2C, Pointed3, Pointed3C } from './Pointed'\nimport { snd } from './ReadonlyTuple'\nimport { State } from './State'\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface StateT<M, S, A> {\n  (s: S): HKT<M, [A, S]>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface StateT1<M extends URIS, S, A> {\n  (s: S): Kind<M, [A, S]>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface StateT2<M extends URIS2, S, E, A> {\n  (s: S): Kind2<M, E, [A, S]>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface StateT3<M extends URIS3, S, R, E, A> {\n  (s: S): Kind3<M, R, E, [A, S]>\n}\n\n/**\n * @since 2.10.0\n */\nexport function of<F extends URIS3>(F: Pointed3<F>): <A, S, R, E>(a: A) => StateT3<F, S, R, E, A>\nexport function of<F extends URIS3, E>(F: Pointed3C<F, E>): <A, S, R>(a: A) => StateT3<F, S, R, E, A>\nexport function of<F extends URIS2>(F: Pointed2<F>): <A, S, E>(a: A) => StateT2<F, S, E, A>\nexport function of<F extends URIS2, E>(F: Pointed2C<F, E>): <A, S>(a: A) => StateT2<F, S, E, A>\nexport function of<F extends URIS>(F: Pointed1<F>): <A, S>(a: A) => StateT1<F, S, A>\nexport function of<F>(F: Pointed<F>): <A, S>(a: A) => StateT<F, S, A>\nexport function of<F>(F: Pointed<F>): <A, S>(a: A) => StateT<F, S, A> {\n  return (a) => (s) => F.of([a, s])\n}\n\n/**\n * @since 2.10.0\n */\nexport function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <S, R, E>(fa: StateT3<F, S, R, E, A>) => StateT3<F, S, R, E, B>\nexport function map<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <A, B>(f: (a: A) => B) => <S, R>(fa: StateT3<F, S, R, E, A>) => StateT3<F, S, R, E, B>\nexport function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <S, E>(fa: StateT2<F, S, E, A>) => StateT2<F, S, E, B>\nexport function map<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <A, B>(f: (a: A) => B) => <S>(fa: StateT2<F, S, E, A>) => StateT2<F, S, E, B>\nexport function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => <S>(fa: StateT1<F, S, A>) => StateT1<F, S, B>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <S>(fa: StateT<F, S, A>) => StateT<F, S, B>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <S>(fa: StateT<F, S, A>) => StateT<F, S, B> {\n  return (f) => (fa) => (s) => F.map(fa(s), ([a, s1]) => [f(a), s1])\n}\n\n/**\n * @since 2.10.0\n */\nexport function ap<M extends URIS3>(\n  M: Chain3<M>\n): <S, R, E, A>(fa: StateT3<M, S, R, E, A>) => <B>(fab: StateT3<M, S, R, E, (a: A) => B>) => StateT3<M, S, R, E, B>\nexport function ap<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <S, R, A>(fa: StateT3<M, S, R, E, A>) => <B>(fab: StateT3<M, S, R, E, (a: A) => B>) => StateT3<M, S, R, E, B>\nexport function ap<M extends URIS2>(\n  M: Chain2<M>\n): <S, E, A>(fa: StateT2<M, S, E, A>) => <B>(fab: StateT2<M, S, E, (a: A) => B>) => StateT2<M, S, E, B>\nexport function ap<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <S, A>(fa: StateT2<M, S, E, A>) => <B>(fab: StateT2<M, S, E, (a: A) => B>) => StateT2<M, S, E, B>\nexport function ap<M extends URIS>(\n  M: Chain1<M>\n): <S, A>(fa: StateT1<M, S, A>) => <B>(fab: StateT1<M, S, (a: A) => B>) => StateT1<M, S, B>\nexport function ap<M>(\n  M: Chain<M>\n): <S, A>(fa: StateT<M, S, A>) => <B>(fab: StateT<M, S, (a: A) => B>) => StateT<M, S, B>\nexport function ap<M>(\n  M: Chain<M>\n): <S, A>(fa: StateT<M, S, A>) => <B>(fab: StateT<M, S, (a: A) => B>) => StateT<M, S, B> {\n  return (fa) => (fab) => (s) => M.chain(fab(s), ([f, s]) => M.map(fa(s), ([a, s]) => [f(a), s]))\n}\n\n/**\n * @since 2.10.0\n */\nexport function chain<M extends URIS3>(\n  M: Chain3<M>\n): <A, S, R, E, B>(f: (a: A) => StateT3<M, S, R, E, B>) => (ma: StateT3<M, S, R, E, A>) => StateT3<M, S, R, E, B>\nexport function chain<M extends URIS3, E>(\n  M: Chain3C<M, E>\n): <A, S, R, B>(f: (a: A) => StateT3<M, S, R, E, B>) => (ma: StateT3<M, S, R, E, A>) => StateT3<M, S, R, E, B>\nexport function chain<M extends URIS2>(\n  M: Chain2<M>\n): <A, S, E, B>(f: (a: A) => StateT2<M, S, E, B>) => (ma: StateT2<M, S, E, A>) => StateT2<M, S, E, B>\nexport function chain<M extends URIS2, E>(\n  M: Chain2C<M, E>\n): <A, S, B>(f: (a: A) => StateT2<M, S, E, B>) => (ma: StateT2<M, S, E, A>) => StateT2<M, S, E, B>\nexport function chain<M extends URIS>(\n  M: Chain1<M>\n): <A, S, B>(f: (a: A) => StateT1<M, S, B>) => (ma: StateT1<M, S, A>) => StateT1<M, S, B>\nexport function chain<M>(\n  M: Chain<M>\n): <A, S, B>(f: (a: A) => StateT<M, S, B>) => (ma: StateT<M, S, A>) => StateT<M, S, B>\nexport function chain<M>(\n  M: Chain<M>\n): <A, S, B>(f: (a: A) => StateT<M, S, B>) => (ma: StateT<M, S, A>) => StateT<M, S, B> {\n  const flatMapM = flatMap(M)\n  return (f) => (ma) => flatMapM(ma, f)\n}\n\n/** @internal */\nexport function flatMap<M extends URIS3>(\n  M: Chain3<M>\n): <S, R, E, A, B>(ma: StateT3<M, S, R, E, A>, f: (a: A) => StateT3<M, S, R, E, B>) => StateT<M, S, B>\n/** @internal */\nexport function flatMap<M>(M: Chain<M>): <S, A, B>(ma: StateT<M, S, A>, f: (a: A) => StateT<M, S, B>) => StateT<M, S, B>\n/** @internal */\nexport function flatMap<M>(\n  M: Chain<M>\n): <S, A, B>(ma: StateT<M, S, A>, f: (a: A) => StateT<M, S, B>) => StateT<M, S, B> {\n  return (ma, f) => (s) => M.chain(ma(s), ([a, s1]) => f(a)(s1))\n}\n\n/**\n * @since 2.10.0\n */\nexport function fromState<F extends URIS3>(F: Pointed3<F>): <S, A, R, E>(sa: State<S, A>) => StateT3<F, S, R, E, A>\nexport function fromState<F extends URIS3, E>(F: Pointed3C<F, E>): <S, A, R>(sa: State<S, A>) => StateT3<F, S, R, E, A>\nexport function fromState<F extends URIS2>(F: Pointed2<F>): <S, A, E>(sa: State<S, A>) => StateT2<F, S, E, A>\nexport function fromState<F extends URIS2, E>(F: Pointed2C<F, E>): <S, A>(sa: State<S, A>) => StateT2<F, S, E, A>\nexport function fromState<F extends URIS>(F: Pointed1<F>): <S, A>(sa: State<S, A>) => StateT1<F, S, A>\nexport function fromState<F>(F: Pointed<F>): <S, A>(sa: State<S, A>) => StateT<F, S, A>\nexport function fromState<F>(F: Pointed<F>): <S, A>(sa: State<S, A>) => StateT<F, S, A> {\n  return (sa) => (s) => F.of(sa(s))\n}\n\n/**\n * @since 2.10.0\n */\nexport function fromF<F extends URIS3>(F: Functor3<F>): <R, E, A, S>(ma: Kind3<F, R, E, A>) => StateT3<F, S, R, E, A>\nexport function fromF<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <R, A, S>(ma: Kind3<F, R, E, A>) => StateT3<F, S, R, E, A>\nexport function fromF<F extends URIS2>(F: Functor2<F>): <E, A, S>(ma: Kind2<F, E, A>) => StateT2<F, S, E, A>\nexport function fromF<F extends URIS2, E>(F: Functor2C<F, E>): <A, S>(ma: Kind2<F, E, A>) => StateT2<F, S, E, A>\nexport function fromF<F extends URIS>(F: Functor1<F>): <A, S>(ma: Kind<F, A>) => StateT1<F, S, A>\nexport function fromF<F>(F: Functor<F>): <A, S>(ma: HKT<F, A>) => StateT<F, S, A>\nexport function fromF<F>(F: Functor<F>): <A, S>(ma: HKT<F, A>) => StateT<F, S, A> {\n  return (ma) => (s) => F.map(ma, (a) => [a, s])\n}\n\n/**\n * @since 2.10.0\n */\nexport function evaluate<F extends URIS3>(\n  F: Functor3<F>\n): <S>(s: S) => <R, E, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, A>\nexport function evaluate<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <S>(s: S) => <R, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, A>\nexport function evaluate<F extends URIS2>(\n  F: Functor2<F>\n): <S>(s: S) => <E, A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, A>\nexport function evaluate<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <S>(s: S) => <A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, A>\nexport function evaluate<F extends URIS>(F: Functor1<F>): <S>(s: S) => <A>(ma: StateT1<F, S, A>) => Kind<F, A>\nexport function evaluate<F>(F: Functor<F>): <S>(s: S) => <A>(ma: StateT<F, S, A>) => HKT<F, A>\nexport function evaluate<F>(F: Functor<F>): <S>(s: S) => <A>(ma: StateT<F, S, A>) => HKT<F, A> {\n  return (s) => (ma) => F.map(ma(s), ([a]) => a)\n}\n\n/**\n * @since 2.10.0\n */\nexport function execute<F extends URIS3>(\n  F: Functor3<F>\n): <S>(s: S) => <R, E, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, S>\nexport function execute<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <S>(s: S) => <R, A>(ma: StateT3<F, S, R, E, A>) => Kind3<F, R, E, S>\nexport function execute<F extends URIS2>(F: Functor2<F>): <S>(s: S) => <E, A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, S>\nexport function execute<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <S>(s: S) => <A>(ma: StateT2<F, S, E, A>) => Kind2<F, E, S>\nexport function execute<F extends URIS>(F: Functor1<F>): <S>(s: S) => <A>(ma: StateT1<F, S, A>) => Kind<F, S>\nexport function execute<F>(F: Functor<F>): <S>(s: S) => <A>(ma: StateT<F, S, A>) => HKT<F, S>\nexport function execute<F>(F: Functor<F>): <S>(s: S) => <A>(ma: StateT<F, S, A>) => HKT<F, S> {\n  return (s) => (ma) => F.map(ma(s), snd)\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface StateM<M> {\n  readonly map: <S, A, B>(fa: StateT<M, S, A>, f: (a: A) => B) => StateT<M, S, B>\n  readonly of: <S, A>(a: A) => StateT<M, S, A>\n  readonly ap: <S, A, B>(fab: StateT<M, S, (a: A) => B>, fa: StateT<M, S, A>) => StateT<M, S, B>\n  readonly chain: <S, A, B>(fa: StateT<M, S, A>, f: (a: A) => StateT<M, S, B>) => StateT<M, S, B>\n  readonly get: <S>() => StateT<M, S, S>\n  readonly put: <S>(s: S) => StateT<M, S, void>\n  readonly modify: <S>(f: (s: S) => S) => StateT<M, S, void>\n  readonly gets: <S, A>(f: (s: S) => A) => StateT<M, S, A>\n  readonly fromState: <S, A>(fa: State<S, A>) => StateT<M, S, A>\n  readonly fromM: <S, A>(ma: HKT<M, A>) => StateT<M, S, A>\n  readonly evalState: <S, A>(ma: StateT<M, S, A>, s: S) => HKT<M, A>\n  readonly execState: <S, A>(ma: StateT<M, S, A>, s: S) => HKT<M, S>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface StateM1<M extends URIS> {\n  readonly map: <S, A, B>(fa: StateT1<M, S, A>, f: (a: A) => B) => StateT1<M, S, B>\n  readonly of: <S, A>(a: A) => StateT1<M, S, A>\n  readonly ap: <S, A, B>(fab: StateT1<M, S, (a: A) => B>, fa: StateT1<M, S, A>) => StateT1<M, S, B>\n  readonly chain: <S, A, B>(fa: StateT1<M, S, A>, f: (a: A) => StateT1<M, S, B>) => StateT1<M, S, B>\n  readonly get: <S>() => StateT1<M, S, S>\n  readonly put: <S>(s: S) => StateT1<M, S, void>\n  readonly modify: <S>(f: (s: S) => S) => StateT1<M, S, void>\n  readonly gets: <S, A>(f: (s: S) => A) => StateT1<M, S, A>\n  readonly fromState: <S, A>(fa: State<S, A>) => StateT1<M, S, A>\n  readonly fromM: <S, A>(ma: Kind<M, A>) => StateT1<M, S, A>\n  readonly evalState: <S, A>(ma: StateT1<M, S, A>, s: S) => Kind<M, A>\n  readonly execState: <S, A>(ma: StateT1<M, S, A>, s: S) => Kind<M, S>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface StateM2<M extends URIS2> {\n  readonly map: <S, E, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => B) => StateT2<M, S, E, B>\n  readonly of: <S, E, A>(a: A) => StateT2<M, S, E, A>\n  readonly ap: <S, E, A, B>(fab: StateT2<M, S, E, (a: A) => B>, fa: StateT2<M, S, E, A>) => StateT2<M, S, E, B>\n  readonly chain: <S, E, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => StateT2<M, S, E, B>) => StateT2<M, S, E, B>\n  readonly get: <E, S>() => StateT2<M, S, E, S>\n  readonly put: <E, S>(s: S) => StateT2<M, S, E, void>\n  readonly modify: <E, S>(f: (s: S) => S) => StateT2<M, S, E, void>\n  readonly gets: <S, E, A>(f: (s: S) => A) => StateT2<M, S, E, A>\n  readonly fromState: <S, E, A>(fa: State<S, A>) => StateT2<M, S, E, A>\n  readonly fromM: <S, E, A>(ma: Kind2<M, E, A>) => StateT2<M, S, E, A>\n  readonly evalState: <S, E, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, A>\n  readonly execState: <S, E, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, S>\n}\n\n/**\n * @category zone of death\n * @since 2.5.4\n * @deprecated\n */\nexport interface StateM2C<M extends URIS2, E> {\n  readonly map: <S, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => B) => StateT2<M, S, E, B>\n  readonly of: <S, A>(a: A) => StateT2<M, S, E, A>\n  readonly ap: <S, A, B>(fab: StateT2<M, S, E, (a: A) => B>, fa: StateT2<M, S, E, A>) => StateT2<M, S, E, B>\n  readonly chain: <S, A, B>(fa: StateT2<M, S, E, A>, f: (a: A) => StateT2<M, S, E, B>) => StateT2<M, S, E, B>\n  readonly get: <S>() => StateT2<M, S, E, S>\n  readonly put: <S>(s: S) => StateT2<M, S, E, void>\n  readonly modify: <S>(f: (s: S) => S) => StateT2<M, S, E, void>\n  readonly gets: <S, A>(f: (s: S) => A) => StateT2<M, S, E, A>\n  readonly fromState: <S, A>(fa: State<S, A>) => StateT2<M, S, E, A>\n  readonly fromM: <S, A>(ma: Kind2<M, E, A>) => StateT2<M, S, E, A>\n  readonly evalState: <S, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, A>\n  readonly execState: <S, A>(ma: StateT2<M, S, E, A>, s: S) => Kind2<M, E, S>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface StateM3<M extends URIS3> {\n  readonly map: <S, R, E, A, B>(fa: StateT3<M, S, R, E, A>, f: (a: A) => B) => StateT3<M, S, R, E, B>\n  readonly of: <S, R, E, A>(a: A) => StateT3<M, S, R, E, A>\n  readonly ap: <S, R, E, A, B>(\n    fab: StateT3<M, S, R, E, (a: A) => B>,\n    fa: StateT3<M, S, R, E, A>\n  ) => StateT3<M, S, R, E, B>\n  readonly chain: <S, R, E, A, B>(\n    fa: StateT3<M, S, R, E, A>,\n    f: (a: A) => StateT3<M, S, R, E, B>\n  ) => StateT3<M, S, R, E, B>\n  readonly get: <R, E, S>() => StateT3<M, S, R, E, S>\n  readonly put: <R, E, S>(s: S) => StateT3<M, S, R, E, void>\n  readonly modify: <R, E, S>(f: (s: S) => S) => StateT3<M, S, R, E, void>\n  readonly gets: <S, R, E, A>(f: (s: S) => A) => StateT3<M, S, R, E, A>\n  readonly fromState: <S, R, E, A>(fa: State<S, A>) => StateT3<M, S, R, E, A>\n  readonly fromM: <S, R, E, A>(ma: Kind3<M, R, E, A>) => StateT3<M, S, R, E, A>\n  readonly evalState: <S, R, E, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, A>\n  readonly execState: <S, R, E, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, S>\n}\n\n/**\n * @category zone of death\n * @since 2.5.4\n * @deprecated\n */\nexport interface StateM3C<M extends URIS3, E> {\n  readonly map: <S, R, A, B>(fa: StateT3<M, S, R, E, A>, f: (a: A) => B) => StateT3<M, S, R, E, B>\n  readonly of: <S, R, A>(a: A) => StateT3<M, S, R, E, A>\n  readonly ap: <S, R, A, B>(fab: StateT3<M, S, R, E, (a: A) => B>, fa: StateT3<M, S, R, E, A>) => StateT3<M, S, R, E, B>\n  readonly chain: <S, R, A, B>(\n    fa: StateT3<M, S, R, E, A>,\n    f: (a: A) => StateT3<M, S, R, E, B>\n  ) => StateT3<M, S, R, E, B>\n  readonly get: <R, S>() => StateT3<M, S, R, E, S>\n  readonly put: <R, S>(s: S) => StateT3<M, S, R, E, void>\n  readonly modify: <R, S>(f: (s: S) => S) => StateT3<M, S, R, E, void>\n  readonly gets: <S, R, A>(f: (s: S) => A) => StateT3<M, S, R, E, A>\n  readonly fromState: <S, R, A>(fa: State<S, A>) => StateT3<M, S, R, E, A>\n  readonly fromM: <S, R, A>(ma: Kind3<M, R, E, A>) => StateT3<M, S, R, E, A>\n  readonly evalState: <S, R, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, A>\n  readonly execState: <S, R, A>(ma: StateT3<M, S, R, E, A>, s: S) => Kind3<M, R, E, S>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getStateM<M extends URIS3>(M: Monad3<M>): StateM3<M>\n/** @deprecated */\nexport function getStateM<M extends URIS3, E>(M: Monad3C<M, E>): StateM3C<M, E>\n/** @deprecated */\nexport function getStateM<M extends URIS2>(M: Monad2<M>): StateM2<M>\n/** @deprecated */\nexport function getStateM<M extends URIS2, E>(M: Monad2C<M, E>): StateM2C<M, E>\n/** @deprecated */\nexport function getStateM<M extends URIS>(M: Monad1<M>): StateM1<M>\n/** @deprecated */\nexport function getStateM<M>(M: Monad<M>): StateM<M>\n/** @deprecated */\n/* istanbul ignore next */\nexport function getStateM<M>(M: Monad<M>): StateM<M> {\n  const _ap = ap(M)\n  const _map = map(M)\n  const _chain = chain(M)\n  const _evaluate = evaluate(M)\n  const _execute = execute(M)\n\n  return {\n    map: (fa, f) => pipe(fa, _map(f)),\n    ap: (fab, fa) => pipe(fab, _ap(fa)),\n    of: of(M),\n    chain: (ma, f) => pipe(ma, _chain(f)),\n    get: () => (s) => M.of([s, s]),\n    put: (s) => () => M.of([undefined, s]),\n    modify: (f) => (s) => M.of([undefined, f(s)]),\n    gets: (f) => (s) => M.of([f(s), s]),\n    fromState: fromState(M),\n    fromM: fromF(M),\n    evalState: (fa, s) => pipe(fa, _evaluate(s)),\n    execState: (fa, s) => pipe(fa, _execute(s))\n  }\n}\n"
  },
  {
    "path": "src/Store.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Comonad2 } from './Comonad'\nimport { Endomorphism } from './Endomorphism'\nimport { Extend2 } from './Extend'\nimport { identity, pipe } from './function'\nimport { flap as flap_, Functor as FunctorHKT, Functor1, Functor2, Functor2C, Functor3, Functor3C } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Store<S, A> {\n  readonly peek: (s: S) => A\n  readonly pos: S\n}\n\n/**\n * Reposition the focus at the specified position\n *\n * @since 2.0.0\n */\nexport function seek<S>(s: S): <A>(wa: Store<S, A>) => Store<S, A> {\n  return (wa) => ({ peek: wa.peek, pos: s })\n}\n\n/**\n * Reposition the focus at the specified position, which depends on the current position\n *\n * @since 2.0.0\n */\nexport function seeks<S>(f: Endomorphism<S>): <A>(wa: Store<S, A>) => Store<S, A> {\n  return (wa) => ({ peek: wa.peek, pos: f(wa.pos) })\n}\n\n/**\n * Extract a value from a position which depends on the current position\n *\n * @since 2.0.0\n */\nexport function peeks<S>(f: Endomorphism<S>): <A>(wa: Store<S, A>) => A {\n  return (wa) => wa.peek(f(wa.pos))\n}\n\n/**\n * Extract a collection of values from positions which depend on the current position\n *\n * @since 2.0.0\n */\nexport function experiment<F extends URIS3>(\n  F: Functor3<F>\n): <R, E, S>(f: (s: S) => Kind3<F, R, E, S>) => <A>(wa: Store<S, A>) => Kind3<F, R, E, A>\nexport function experiment<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <R, S>(f: (s: S) => Kind3<F, R, E, S>) => <A>(wa: Store<S, A>) => Kind3<F, R, E, A>\nexport function experiment<F extends URIS2>(\n  F: Functor2<F>\n): <E, S>(f: (s: S) => Kind2<F, E, S>) => <A>(wa: Store<S, A>) => Kind2<F, E, A>\nexport function experiment<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <S>(f: (s: S) => Kind2<F, E, S>) => <A>(wa: Store<S, A>) => Kind2<F, E, A>\nexport function experiment<F extends URIS>(\n  F: Functor1<F>\n): <S>(f: (s: S) => Kind<F, S>) => <A>(wa: Store<S, A>) => Kind<F, A>\nexport function experiment<F>(F: FunctorHKT<F>): <S>(f: (s: S) => HKT<F, S>) => <A>(wa: Store<S, A>) => HKT<F, A>\nexport function experiment<F>(F: FunctorHKT<F>): <S>(f: (s: S) => HKT<F, S>) => <A>(wa: Store<S, A>) => HKT<F, A> {\n  return (f) => (wa) => F.map(f(wa.pos), (s) => wa.peek(s))\n}\n\n/* istanbul ignore next */\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _extend: Extend2<URI>['extend'] = (wa, f) => pipe(wa, extend(f))\n\n/**\n * @since 2.0.0\n */\nexport const extend: <E, A, B>(f: (wa: Store<E, A>) => B) => (wa: Store<E, A>) => Store<E, B> = (f) => (wa) => ({\n  peek: (s) => f({ peek: wa.peek, pos: s }),\n  pos: wa.pos\n})\n\n/**\n * @category Extract\n * @since 2.6.2\n */\nexport const extract: <E, A>(wa: Store<E, A>) => A = (wa) => wa.peek(wa.pos)\n\n/**\n * @since 2.0.0\n */\nexport const duplicate: <E, A>(wa: Store<E, A>) => Store<E, Store<E, A>> = /*#__PURE__*/ extend(identity)\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: Store<E, A>) => Store<E, B> = (f) => (fa) => ({\n  peek: (s) => f(fa.peek(s)),\n  pos: fa.pos\n})\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Store'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: Store<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Comonad: Comonad2<URI> = {\n  URI,\n  map: _map,\n  extend: _extend,\n  extract\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Comonad` instance, pass `S.Comonad` instead of `S.store`\n * (where `S` is from `import S from 'fp-ts/Store'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const store: Comonad2<URI> = Comonad\n"
  },
  {
    "path": "src/Strong.ts",
    "content": "/**\n * The `Strong` class extends `Profunctor` with combinators for working with product types.\n *\n * `first` and `second` lift values in a `Profunctor` to act on the first and second components of a tuple,\n * respectively.\n *\n * Another way to think about Strong is to piggyback on the intuition of\n * inputs and outputs.  Rewriting the type signature in this light then yields:\n *\n * ```purescript\n * first ::  forall input output a. p input output -> p (Tuple input a) (Tuple output a)\n * second :: forall input output a. p input output -> p (Tuple a input) (Tuple a output)\n * ```\n *\n * If we specialize the profunctor p to the function arrow, we get the following type\n * signatures, which may look a bit more familiar:\n *\n * ```purescript\n * first ::  forall input output a. (input -> output) -> (Tuple input a) -> (Tuple output a)\n * second :: forall input output a. (input -> output) -> (Tuple a input) -> (Tuple a output)\n * ```\n *\n * So, when the `profunctor` is `Function` application, `first` essentially applies your function\n * to the first element of a tuple, and `second` applies it to the second element (same as `map` would do).\n *\n * Adapted from https://github.com/purescript/purescript-profunctor/blob/master/src/Data/Profunctor/Strong.purs\n *\n * @since 2.0.0\n */\nimport { Category, Category2, Category3, Category4 } from './Category'\nimport { identity } from './function'\nimport { HKT2, Kind2, Kind3, Kind4, URIS2, URIS3, URIS4 } from './HKT'\nimport { Profunctor, Profunctor2, Profunctor3, Profunctor4 } from './Profunctor'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Strong<F> extends Profunctor<F> {\n  readonly first: <A, B, C>(pab: HKT2<F, A, B>) => HKT2<F, [A, C], [B, C]>\n  readonly second: <A, B, C>(pab: HKT2<F, B, C>) => HKT2<F, [A, B], [A, C]>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Strong2<F extends URIS2> extends Profunctor2<F> {\n  readonly first: <A, B, C>(pab: Kind2<F, A, B>) => Kind2<F, [A, C], [B, C]>\n  readonly second: <A, B, C>(pab: Kind2<F, B, C>) => Kind2<F, [A, B], [A, C]>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Strong3<F extends URIS3> extends Profunctor3<F> {\n  readonly first: <R, A, B, C>(pab: Kind3<F, R, A, B>) => Kind3<F, R, [A, C], [B, C]>\n  readonly second: <R, A, B, C>(pab: Kind3<F, R, B, C>) => Kind3<F, R, [A, B], [A, C]>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Strong4<F extends URIS4> extends Profunctor4<F> {\n  readonly first: <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, [A, C], [B, C]>\n  readonly second: <S, R, A, B, C>(pab: Kind4<F, S, R, B, C>) => Kind4<F, S, R, [A, B], [A, C]>\n}\n\n/**\n * Compose a value acting on a tuple from two values, each acting on one of the components of the tuple.\n *\n * Specializing `split` to function application would look like this:\n *\n * ```purescript\n * split :: forall a b c d. (a -> b) -> (c -> d) -> (Tuple a c) -> (Tuple b d)\n * ```\n *\n * We take two functions, `f` and `g`, and we transform them into a single function which takes a tuple and maps `f`\n * over the first element and `g` over the second.  Just like `bi-map` would do for the `bi-functor` instance of tuple.\n *\n * @since 2.10.0\n */\nexport function split<F extends URIS4>(\n  S: Strong4<F>,\n  C: Category4<F>\n): <S, R, A, B, C, D>(pab: Kind4<F, S, R, A, B>, pcd: Kind4<F, S, R, C, D>) => Kind4<F, S, R, [A, C], [B, D]>\nexport function split<F extends URIS3>(\n  S: Strong3<F>,\n  C: Category3<F>\n): <R, A, B, C, D>(pab: Kind3<F, R, A, B>, pcd: Kind3<F, R, C, D>) => Kind3<F, R, [A, C], [B, D]>\nexport function split<F extends URIS2>(\n  S: Strong2<F>,\n  C: Category2<F>\n): <A, B, C, D>(pab: Kind2<F, A, B>, pcd: Kind2<F, C, D>) => Kind2<F, [A, C], [B, D]>\nexport function split<F>(\n  S: Strong<F>,\n  C: Category<F>\n): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, [A, C], [B, D]>\nexport function split<F>(\n  S: Strong<F>,\n  C: Category<F>\n): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, [A, C], [B, D]> {\n  return <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) =>\n    C.compose(S.second<B, C, D>(pcd), S.first<A, B, C>(pab))\n}\n\n/**\n * Compose a value which introduces a tuple from two values, each introducing one side of the tuple.\n *\n * This combinator is useful when assembling values from smaller components, because it provides a way to support two\n * different types of output.\n *\n * Specializing `fanOut` to function application would look like this:\n *\n * ```purescript\n * fanOut :: forall a b c. (a -> b) -> (a -> c) -> (a -> (Tuple b c))\n * ```\n *\n * We take two functions, `f` and `g`, with the same parameter type and we transform them into a single function which\n * takes one parameter and returns a tuple of the results of running `f` and `g` on the parameter, respectively.  This\n * allows us to run two parallel computations on the same input and return both results in a tuple.\n *\n * @since 2.10.0\n */\nexport function fanOut<F extends URIS4>(\n  S: Strong4<F>,\n  C: Category4<F>\n): <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>, pac: Kind4<F, S, R, A, C>) => Kind4<F, S, R, A, [B, C]>\nexport function fanOut<F extends URIS3>(\n  S: Strong3<F>,\n  C: Category3<F>\n): <R, A, B, C>(pab: Kind3<F, R, A, B>, pac: Kind3<F, R, A, C>) => Kind3<F, R, A, [B, C]>\nexport function fanOut<F extends URIS2>(\n  S: Strong2<F>,\n  C: Category2<F>\n): <A, B, C>(pab: Kind2<F, A, B>, pac: Kind2<F, A, C>) => Kind2<F, A, [B, C]>\nexport function fanOut<F>(\n  S: Strong<F>,\n  C: Category<F>\n): <A, B, C>(pab: HKT2<F, A, B>, pac: HKT2<F, A, C>) => HKT2<F, A, [B, C]>\nexport function fanOut<F>(\n  S: Strong<F>,\n  C: Category<F>\n): <A, B, C>(pab: HKT2<F, A, B>, pac: HKT2<F, A, C>) => HKT2<F, A, [B, C]> {\n  const splitSC = split(S, C)\n  return <A, B, C>(pab: HKT2<F, A, B>, pac: HKT2<F, A, C>): HKT2<F, A, [B, C]> =>\n    C.compose(\n      splitSC(pab, pac),\n      S.promap<A, A, A, [A, A]>(C.id<A>(), identity, (a) => [a, a])\n    )\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`split`](#split) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function splitStrong<F extends URIS4>(\n  F: Category4<F> & Strong4<F>\n): <S, R, A, B, C, D>(pab: Kind4<F, S, R, A, B>, pcd: Kind4<F, S, R, C, D>) => Kind4<F, S, R, [A, C], [B, D]>\n/** @deprecated */\nexport function splitStrong<F extends URIS3>(\n  F: Category3<F> & Strong3<F>\n): <R, A, B, C, D>(pab: Kind3<F, R, A, B>, pcd: Kind3<F, R, C, D>) => Kind3<F, R, [A, C], [B, D]>\n/** @deprecated */\nexport function splitStrong<F extends URIS2>(\n  F: Category2<F> & Strong2<F>\n): <A, B, C, D>(pab: Kind2<F, A, B>, pcd: Kind2<F, C, D>) => Kind2<F, [A, C], [B, D]>\n/** @deprecated */\nexport function splitStrong<F>(\n  F: Category<F> & Strong<F>\n): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, [A, C], [B, D]>\nexport function splitStrong<F>(\n  F: Category<F> & Strong<F>\n): <A, B, C, D>(pab: HKT2<F, A, B>, pcd: HKT2<F, C, D>) => HKT2<F, [A, C], [B, D]> {\n  return split(F, F)\n}\n\n/**\n * Use [`fanOut`](#fanout) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function fanout<F extends URIS4>(\n  F: Category4<F> & Strong4<F>\n): <S, R, A, B, C>(pab: Kind4<F, S, R, A, B>, pac: Kind4<F, S, R, A, C>) => Kind4<F, S, R, A, [B, C]>\n/** @deprecated */\nexport function fanout<F extends URIS3>(\n  F: Category3<F> & Strong3<F>\n): <R, A, B, C>(pab: Kind3<F, R, A, B>, pac: Kind3<F, R, A, C>) => Kind3<F, R, A, [B, C]>\n/** @deprecated */\nexport function fanout<F extends URIS2>(\n  F: Category2<F> & Strong2<F>\n): <A, B, C>(pab: Kind2<F, A, B>, pac: Kind2<F, A, C>) => Kind2<F, A, [B, C]>\n/** @deprecated */\nexport function fanout<F>(\n  F: Category<F> & Strong<F>\n): <A, B, C>(pab: HKT2<F, A, B>, pac: HKT2<F, A, C>) => HKT2<F, A, [B, C]>\nexport function fanout<F>(\n  F: Category<F> & Strong<F>\n): <A, B, C>(pab: HKT2<F, A, B>, pac: HKT2<F, A, C>) => HKT2<F, A, [B, C]> {\n  return fanOut(F, F)\n}\n"
  },
  {
    "path": "src/Task.ts",
    "content": "/**\n * ```ts\n * interface Task<A> {\n *   (): Promise<A>\n * }\n * ```\n *\n * `Task<A>` represents an asynchronous computation that yields a value of type `A` and **never fails**.\n * If you want to represent an asynchronous computation that may fail, please see `TaskEither`.\n *\n * @since 2.0.0\n */\nimport { Applicative1, getApplicativeMonoid } from './Applicative'\nimport {\n  apFirst as apFirst_,\n  Apply1,\n  apS as apS_,\n  apSecond as apSecond_,\n  getApplySemigroup as getApplySemigroup_\n} from './Apply'\nimport * as chainable from './Chain'\nimport { FromIO1, fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO'\nimport { FromTask1 } from './FromTask'\nimport { dual, identity, pipe } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { IO } from './IO'\nimport { Monad1 } from './Monad'\nimport { MonadIO1 } from './MonadIO'\nimport { MonadTask1 } from './MonadTask'\nimport { Monoid } from './Monoid'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Pointed1 } from './Pointed'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Task<A> {\n  (): Promise<A>\n}\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromIO: <A>(fa: IO<A>) => Task<A> = (ma) => () => Promise.resolve().then(ma)\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Creates a task that will complete after a time delay\n *\n * @example\n * import { sequenceT } from 'fp-ts/Apply'\n * import * as T from 'fp-ts/Task'\n * import { takeRight } from 'fp-ts/Array'\n *\n * async function test() {\n *   const log: Array<string> = []\n *   const append = (message: string): T.Task<void> =>\n *     T.fromIO(() => {\n *       log.push(message)\n *     })\n *   const fa = append('a')\n *   const fb = T.delay(20)(append('b'))\n *   const fc = T.delay(10)(append('c'))\n *   const fd = append('d')\n *   await sequenceT(T.ApplyPar)(fa, fb, fc, fd)()\n *   assert.deepStrictEqual(takeRight(2)(log), ['c', 'b'])\n * }\n *\n * test()\n *\n * @since 2.0.0\n */\nexport function delay(millis: number): <A>(ma: Task<A>) => Task<A> {\n  return (ma) => () =>\n    new Promise((resolve) => {\n      setTimeout(() => {\n        Promise.resolve().then(ma).then(resolve)\n      }, millis)\n    })\n}\n\nconst _map: Functor1<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _apPar: Apply1<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\nconst _apSeq: Apply1<URI>['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map(f)))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => (fa: Task<A>) => Task<B> = (f) => (fa) => () =>\n  Promise.resolve().then(fa).then(f)\n\n/**\n * @since 2.0.0\n */\nexport const ap: <A>(fa: Task<A>) => <B>(fab: Task<(a: A) => B>) => Task<B> = (fa) => (fab) => () =>\n  Promise.all([Promise.resolve().then(fab), Promise.resolve().then(fa)]).then(([f, a]) => f(a))\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const of: <A>(a: A) => Task<A> = (a) => () => Promise.resolve(a)\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A) => Task<B>): (ma: Task<A>) => Task<B>\n  <A, B>(ma: Task<A>, f: (a: A) => Task<B>): Task<B>\n} = /*#__PURE__*/ dual(\n  2,\n  <A, B>(ma: Task<A>, f: (a: A) => Task<B>): Task<B> =>\n    () =>\n      Promise.resolve()\n        .then(ma)\n        .then((a) => f(a)())\n)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <A>(mma: Task<Task<A>>) => Task<A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Task'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Task<A>\n  }\n}\n\n/**\n * Monoid returning the first completed task.\n *\n * Note: uses `Promise.race` internally.\n *\n * @example\n * import * as T from 'fp-ts/Task'\n *\n * async function test() {\n *   const S = T.getRaceMonoid<string>()\n *   const fa = T.delay(20)(T.of('a'))\n *   const fb = T.delay(10)(T.of('b'))\n *   assert.deepStrictEqual(await S.concat(fa, fb)(), 'b')\n * }\n *\n * test()\n *\n * @category instances\n * @since 2.0.0\n */\nexport function getRaceMonoid<A = never>(): Monoid<Task<A>> {\n  return {\n    concat: (x, y) => () => Promise.race([Promise.resolve().then(x), Promise.resolve().then(y)]),\n    empty: never\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the value to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <_>(self: Task<_>) => Task<A>\n  <_, A>(self: Task<_>, a: A): Task<A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the value to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <_>(self: Task<_>) => Task<void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplyPar: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(ApplyPar)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(ApplyPar)\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.7.0\n */\nexport const ApplicativePar: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  of\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplySeq: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.7.0\n */\nexport const ApplicativeSeq: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadIO: MonadIO1<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap,\n  fromIO\n}\n\n/**\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const fromTask: <A>(fa: Task<A>) => Task<A> = identity\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadTask: MonadTask1<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromIO: FromIO1<URI> = {\n  URI,\n  fromIO\n}\n\n/** @internal */\ninterface TaskTypeLambda extends _.TypeLambda {\n  readonly type: Task<this['Target']>\n}\n\n/** @internal */\nconst _FlatMap: _.FlatMap<TaskTypeLambda> = {\n  flatMap\n}\n\n/** @internal */\nconst _FromIO: _.FromIO<TaskTypeLambda> = {\n  fromIO: FromIO.fromIO\n}\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): (self: Task<A>) => Task<B>\n  <A, B>(self: Task<A>, f: (a: A) => IO<B>): Task<B>\n} = _.flatMapIO(_FromIO, _FlatMap)\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <A, _>(self: Task<A>, f: (a: A) => Task<_>): Task<A>\n  <A, _>(f: (a: A) => Task<_>): (self: Task<A>) => Task<A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as T from 'fp-ts/Task'\n * import * as Console from 'fp-ts/Console'\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effect = pipe(\n *   T.of('fp-ts'),\n *   T.tapIO((value) => Console.log(`Hello, ${value}`)),\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effect(), 'fp-ts')\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): (self: Task<A>) => Task<A>\n  <A, _>(self: Task<A>, f: (a: A) => IO<_>): Task<A>\n} = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain))\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => Task<B> =\n  /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainIOK: <A, B>(f: (a: A) => IO<B>) => (first: Task<A>) => Task<B> = flatMapIO\n\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => (first: Task<A>) => Task<A> = tapIO\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromTask: FromTask1<URI> = {\n  URI,\n  fromIO,\n  fromTask\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * A `Task` that never completes.\n *\n * @since 2.0.0\n */\nexport const never: Task<never> = () => new Promise((_) => undefined)\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: Task<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(ApplyPar)\n\n/**\n * @since 2.11.0\n */\nexport const ApT: Task<readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex =\n  <A, B>(f: (index: number, a: A) => Task<B>) =>\n  (as: ReadonlyNonEmptyArray<A>): Task<ReadonlyNonEmptyArray<B>> =>\n  () =>\n    Promise.all(as.map((a, i) => Promise.resolve().then(() => f(i, a)()))) as any\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, B>(\n  f: (index: number, a: A) => Task<B>\n): ((as: ReadonlyArray<A>) => Task<ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndexSeq =\n  <A, B>(f: (index: number, a: A) => Task<B>) =>\n  (as: ReadonlyNonEmptyArray<A>): Task<ReadonlyNonEmptyArray<B>> =>\n  () =>\n    _.tail(as).reduce<Promise<NonEmptyArray<B>>>(\n      (acc, a, i) =>\n        acc.then((bs) =>\n          Promise.resolve()\n            .then(f(i + 1, a))\n            .then((b) => {\n              bs.push(b)\n              return bs\n            })\n        ),\n      Promise.resolve()\n        .then(f(0, _.head(as)))\n        .then(_.singleton)\n    )\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndexSeq = <A, B>(\n  f: (index: number, a: A) => Task<B>\n): ((as: ReadonlyArray<A>) => Task<ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndexSeq(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Task<B>\n) => (as: ReadonlyArray<A>) => Task<ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <A, B>(f: (a: A) => Task<B>): ((as: ReadonlyArray<A>) => Task<ReadonlyArray<B>>) =>\n  traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <A>(arr: ReadonlyArray<Task<A>>) => Task<ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseSeqArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => Task<B>\n) => (as: ReadonlyArray<A>) => Task<ReadonlyArray<B>> = traverseReadonlyArrayWithIndexSeq\n\n/**\n * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseSeqArray = <A, B>(f: (a: A) => Task<B>): ((as: ReadonlyArray<A>) => Task<ReadonlyArray<B>>) =>\n  traverseReadonlyArrayWithIndexSeq((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceSeqArray: <A>(arr: ReadonlyArray<Task<A>>) => Task<ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseSeqArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <A, B>(f: (a: A) => Task<B>) => (ma: Task<A>) => Task<B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => Task<B>) => (first: Task<A>) => Task<A> = tap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.task`\n * (where `T` is from `import T from 'fp-ts/Task'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const task: Monad1<URI> & MonadTask1<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap,\n  fromIO,\n  fromTask\n}\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.taskSeq`\n * (where `T` is from `import T from 'fp-ts/Task'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const taskSeq: Monad1<URI> & MonadTask1<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _apSeq,\n  chain: flatMap,\n  fromIO,\n  fromTask\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getSemigroup: <A>(S: Semigroup<A>) => Semigroup<Task<A>> = /*#__PURE__*/ getApplySemigroup_(ApplySeq)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * Lift a monoid into 'Task', the inner values are concatenated using the provided `Monoid`.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getMonoid: <A>(M: Monoid<A>) => Monoid<Task<A>> = /*#__PURE__*/ getApplicativeMonoid(ApplicativeSeq)\n"
  },
  {
    "path": "src/TaskEither.ts",
    "content": "/**\n * ```ts\n * interface TaskEither<E, A> extends Task<Either<E, A>> {}\n * ```\n *\n * `TaskEither<E, A>` represents an asynchronous computation that either yields a value of type `A` or fails yielding an\n * error of type `E`. If you want to represent an asynchronous computation that never fails, please see `Task`.\n *\n * @since 2.0.0\n */\nimport { Alt2, Alt2C } from './Alt'\nimport { Applicative2, Applicative2C, getApplicativeMonoid } from './Applicative'\nimport {\n  ap as ap_,\n  apFirst as apFirst_,\n  Apply1,\n  Apply2,\n  apS as apS_,\n  apSecond as apSecond_,\n  getApplySemigroup as getApplySemigroup_\n} from './Apply'\nimport { Bifunctor2 } from './Bifunctor'\nimport * as chainable from './Chain'\nimport { compact as compact_, Compactable2C, separate as separate_ } from './Compactable'\nimport * as E from './Either'\nimport * as ET from './EitherT'\nimport {\n  filter as filter_,\n  Filterable2C,\n  filterMap as filterMap_,\n  partition as partition_,\n  partitionMap as partitionMap_\n} from './Filterable'\nimport {\n  chainOptionK as chainOptionK_,\n  filterOrElse as filterOrElse_,\n  FromEither2,\n  fromEitherK as fromEitherK_,\n  fromOption as fromOption_,\n  fromOptionK as fromOptionK_,\n  fromPredicate as fromPredicate_,\n  tapEither as tapEither_\n} from './FromEither'\nimport { FromIO2, fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO'\nimport { FromTask2, fromTaskK as fromTaskK_, tapTask as tapTask_ } from './FromTask'\nimport { dual, flow, identity, LazyArg, pipe, SK } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor2, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { IO } from './IO'\nimport { IOEither } from './IOEither'\nimport { Monad2, Monad2C } from './Monad'\nimport { MonadIO2 } from './MonadIO'\nimport { MonadTask2, MonadTask2C } from './MonadTask'\nimport { MonadThrow2, MonadThrow2C } from './MonadThrow'\nimport { Monoid } from './Monoid'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Option } from './Option'\nimport { Pointed2 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport * as T from './Task'\nimport { TaskOption } from './TaskOption'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\nimport Either = E.Either\nimport Task = T.Task\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface TaskEither<E, A> extends Task<Either<E, A>> {}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const left: <E = never, A = never>(e: E) => TaskEither<E, A> = /*#__PURE__*/ ET.left(T.Pointed)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const right: <E = never, A = never>(a: A) => TaskEither<E, A> = /*#__PURE__*/ ET.right(T.Pointed)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const rightTask: <E = never, A = never>(ma: Task<A>) => TaskEither<E, A> = /*#__PURE__*/ ET.rightF(T.Functor)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const leftTask: <E = never, A = never>(me: Task<E>) => TaskEither<E, A> = /*#__PURE__*/ ET.leftF(T.Functor)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const rightIO: <E = never, A = never>(ma: IO<A>) => TaskEither<E, A> = /*#__PURE__*/ flow(T.fromIO, rightTask)\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const leftIO: <E = never, A = never>(me: IO<E>) => TaskEither<E, A> = /*#__PURE__*/ flow(T.fromIO, leftTask)\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.7.0\n */\nexport const fromIO: <A, E = never>(fa: IO<A>) => TaskEither<E, A> = rightIO\n\n/**\n * @category conversions\n * @since 2.7.0\n */\nexport const fromTask: <A, E = never>(fa: Task<A>) => TaskEither<E, A> = rightTask\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromEither: <E, A>(fa: Either<E, A>) => TaskEither<E, A> = T.of\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromIOEither: <E, A>(fa: IOEither<E, A>) => TaskEither<E, A> = T.fromIO\n\n/**\n * @category conversions\n * @since 2.11.0\n */\nexport const fromTaskOption: <E>(onNone: LazyArg<E>) => <A>(fa: TaskOption<A>) => TaskEither<E, A> = (onNone) =>\n  T.map(E.fromOption(onNone))\n\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: TaskEither<E, A>) => Task<B> =\n  /*#__PURE__*/ ET.match(T.Functor)\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW: <E, B, A, C>(onLeft: (e: E) => B, onRight: (a: A) => C) => (ma: TaskEither<E, A>) => Task<B | C> =\n  match as any\n\n/**\n * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Task`).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchE: <E, A, B>(\n  onLeft: (e: E) => Task<B>,\n  onRight: (a: A) => Task<B>\n) => (ma: TaskEither<E, A>) => Task<B> = /*#__PURE__*/ ET.matchE(T.Monad)\n\n/**\n * Alias of [`matchE`](#matche).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const fold = matchE\n\n/**\n * Less strict version of [`matchE`](#matche).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchEW: <E, B, A, C>(\n  onLeft: (e: E) => Task<B>,\n  onRight: (a: A) => Task<C>\n) => (ma: TaskEither<E, A>) => Task<B | C> = matchE as any\n\n/**\n * Alias of [`matchEW`](#matchew).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchEW\n\n/**\n * @category error handling\n * @since 2.0.0\n */\nexport const getOrElse: <E, A>(onLeft: (e: E) => Task<A>) => (ma: TaskEither<E, A>) => Task<A> =\n  /*#__PURE__*/ ET.getOrElse(T.Monad)\n\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.6.0\n */\nexport const getOrElseW: <E, B>(onLeft: (e: E) => Task<B>) => <A>(ma: TaskEither<E, A>) => Task<A | B> =\n  getOrElse as any\n\n/**\n * Transforms a `Promise` that may reject to a `Promise` that never rejects and returns an `Either` instead.\n *\n * See also [`tryCatchK`](#trycatchk).\n *\n * @example\n * import { left, right } from 'fp-ts/Either'\n * import { tryCatch } from 'fp-ts/TaskEither'\n *\n * tryCatch(() => Promise.resolve(1), String)().then(result => {\n *   assert.deepStrictEqual(result, right(1))\n * })\n * tryCatch(() => Promise.reject('error'), String)().then(result => {\n *   assert.deepStrictEqual(result, left('error'))\n * })\n *\n * @category interop\n * @since 2.0.0\n */\nexport const tryCatch =\n  <E, A>(f: LazyArg<Promise<A>>, onRejected: (reason: unknown) => E): TaskEither<E, A> =>\n  async () => {\n    try {\n      return await f().then(_.right)\n    } catch (reason) {\n      return _.left(onRejected(reason))\n    }\n  }\n\n/**\n * Converts a function returning a `Promise` to one returning a `TaskEither`.\n *\n * @category interop\n * @since 2.5.0\n */\nexport const tryCatchK =\n  <E, A extends ReadonlyArray<unknown>, B>(\n    f: (...a: A) => Promise<B>,\n    onRejected: (reason: unknown) => E\n  ): ((...a: A) => TaskEither<E, B>) =>\n  (...a) =>\n    tryCatch(() => f(...a), onRejected)\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const toUnion: <E, A>(fa: TaskEither<E, A>) => Task<E | A> = /*#__PURE__*/ ET.toUnion(T.Functor)\n\n/**\n * @category conversions\n * @since 2.12.0\n */\nexport const fromNullable: <E>(e: E) => <A>(a: A) => TaskEither<E, NonNullable<A>> = /*#__PURE__*/ ET.fromNullable(\n  T.Pointed\n)\n\n/**\n * Use `liftNullable`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const fromNullableK: <E>(\n  e: E\n) => <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => TaskEither<E, NonNullable<B>> = /*#__PURE__*/ ET.fromNullableK(T.Pointed)\n\n/**\n * Use `flatMapNullable`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainNullableK: <E>(\n  e: E\n) => <A, B>(f: (a: A) => B | null | undefined) => (ma: TaskEither<E, A>) => TaskEither<E, NonNullable<B>> =\n  /*#__PURE__*/ ET.chainNullableK(T.Monad)\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Returns `ma` if is a `Right` or the value returned by `onLeft` otherwise.\n *\n * See also [alt](#alt).\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as TE from 'fp-ts/TaskEither'\n *\n * async function test() {\n *   const errorHandler = TE.orElse((error: string) => TE.right(`recovering from ${error}...`))\n *   assert.deepStrictEqual(await pipe(TE.right('ok'), errorHandler)(), E.right('ok'))\n *   assert.deepStrictEqual(await pipe(TE.left('ko'), errorHandler)(), E.right('recovering from ko...'))\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const orElse: <E1, A, E2>(onLeft: (e: E1) => TaskEither<E2, A>) => (ma: TaskEither<E1, A>) => TaskEither<E2, A> =\n  /*#__PURE__*/ ET.orElse(T.Monad)\n\n/**\n * Less strict version of [`orElse`](#orelse).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport const orElseW: <E1, E2, B>(\n  onLeft: (e: E1) => TaskEither<E2, B>\n) => <A>(ma: TaskEither<E1, A>) => TaskEither<E2, A | B> = orElse as any\n\n/**\n * Returns an effect that effectfully \"peeks\" at the failure of this effect.\n *\n * @category error handling\n * @since 2.15.0\n */\nexport const tapError: {\n  <E1, E2, _>(onLeft: (e: E1) => TaskEither<E2, _>): <A>(self: TaskEither<E1, A>) => TaskEither<E1 | E2, A>\n  <E1, A, E2, _>(self: TaskEither<E1, A>, onLeft: (e: E1) => TaskEither<E2, _>): TaskEither<E1 | E2, A>\n} = /*#__PURE__*/ dual(2, ET.tapError(T.Monad))\n\n/**\n * @category error handling\n * @since 2.12.0\n */\nexport const orElseFirstIOK: <E, B>(onLeft: (e: E) => IO<B>) => <A>(ma: TaskEither<E, A>) => TaskEither<E, A> = (\n  onLeft\n) => tapError(fromIOK(onLeft))\n\n/**\n * @category error handling\n * @since 2.12.0\n */\nexport const orElseFirstTaskK: <E, B>(onLeft: (e: E) => Task<B>) => <A>(ma: TaskEither<E, A>) => TaskEither<E, A> = (\n  onLeft\n) => tapError(fromTaskK(onLeft))\n\n/**\n * @category error handling\n * @since 2.11.0\n */\nexport const orLeft: <E1, E2>(onLeft: (e: E1) => Task<E2>) => <A>(fa: TaskEither<E1, A>) => TaskEither<E2, A> =\n  /*#__PURE__*/ ET.orLeft(T.Monad)\n\n/**\n * @since 2.0.0\n */\nexport const swap: <E, A>(ma: TaskEither<E, A>) => TaskEither<A, E> = /*#__PURE__*/ ET.swap(T.Functor)\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromTaskOptionK = <E>(\n  onNone: LazyArg<E>\n): (<A extends ReadonlyArray<unknown>, B>(f: (...a: A) => TaskOption<B>) => (...a: A) => TaskEither<E, B>) => {\n  const from = fromTaskOption(onNone)\n  return (f) => flow(f, from)\n}\n\n/**\n * Use `flatMapTaskOption`.\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category legacy\n * @since 2.12.3\n */\nexport const chainTaskOptionKW =\n  <E2>(onNone: LazyArg<E2>) =>\n  <A, B>(f: (a: A) => TaskOption<B>) =>\n  <E1>(ma: TaskEither<E1, A>): TaskEither<E1 | E2, B> =>\n    flatMap(ma, fromTaskOptionK<E1 | E2>(onNone)(f))\n\n/**\n * Use `flatMapTaskOption`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const chainTaskOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => TaskOption<B>) => (ma: TaskEither<E, A>) => TaskEither<E, B> = chainTaskOptionKW\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromIOEitherK = <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => IOEither<E, B>\n): ((...a: A) => TaskEither<E, B>) => flow(f, fromIOEither)\n\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _apPar: Apply2<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\nconst _apSeq: Apply2<URI>['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map(f)))\n/* istanbul ignore next */\nconst _alt: Alt2<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: TaskEither<E, A>) => TaskEither<E, B> = /*#__PURE__*/ ET.map(\n  T.Functor\n)\n\n/**\n * Returns a `TaskEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`.\n *\n * @example\n * import * as TaskEither from 'fp-ts/TaskEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n * const g = (n: number) => n * 2\n *\n * async function test() {\n *   assert.deepStrictEqual(await TaskEither.mapBoth(TaskEither.right(1), f, g)(), Either.right(2))\n *   assert.deepStrictEqual(await TaskEither.mapBoth(TaskEither.left('err'), f, g)(), Either.left(new Error('err')))\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.16.0\n */\nexport const mapBoth: {\n  <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): (self: TaskEither<E, A>) => TaskEither<G, B>\n  <E, A, G, B>(self: TaskEither<E, A>, f: (e: E) => G, g: (a: A) => B): TaskEither<G, B>\n} = /*#__PURE__*/ dual(3, ET.mapBoth(T.Functor))\n\n/**\n * Alias of `mapBoth`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: TaskEither<E, A>) => TaskEither<G, B> = mapBoth\n\n/**\n * Returns a `TaskEither` with its error channel mapped using the specified function.\n *\n * @example\n * import * as TaskEither from 'fp-ts/TaskEither'\n * import * as Either from 'fp-ts/Either'\n *\n * const f = (s: string) => new Error(s)\n *\n * async function test() {\n *   assert.deepStrictEqual(await TaskEither.mapError(TaskEither.right(1), f)(), Either.right(1))\n *   assert.deepStrictEqual(await TaskEither.mapError(TaskEither.left('err'), f)(), Either.left(new Error('err')))\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.16.0\n */\nexport const mapError: {\n  <E, G>(f: (e: E) => G): <A>(self: TaskEither<E, A>) => TaskEither<G, A>\n  <E, A, G>(self: TaskEither<E, A>, f: (e: E) => G): TaskEither<G, A>\n} = /*#__PURE__*/ dual(2, ET.mapError(T.Functor))\n\n/**\n * Alias of `mapError`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: TaskEither<E, A>) => TaskEither<G, A> = mapError\n\n/**\n * @since 2.0.0\n */\nexport const ap: <E, A>(fa: TaskEither<E, A>) => <B>(fab: TaskEither<E, (a: A) => B>) => TaskEither<E, B> =\n  /*#__PURE__*/ ET.ap(T.ApplyPar)\n\n/**\n * Less strict version of [`ap`](#ap).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.8.0\n */\nexport const apW: <E2, A>(\n  fa: TaskEither<E2, A>\n) => <E1, B>(fab: TaskEither<E1, (a: A) => B>) => TaskEither<E1 | E2, B> = ap as any\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, E2, B>(f: (a: A) => TaskEither<E2, B>): <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, B>\n  <E1, A, E2, B>(ma: TaskEither<E1, A>, f: (a: A) => TaskEither<E2, B>): TaskEither<E1 | E2, B>\n} = /*#__PURE__*/ dual(2, ET.flatMap(T.Monad))\n\n/**\n * Less strict version of [`flatten`](#flatten).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category sequencing\n * @since 2.11.0\n */\nexport const flattenW: <E1, E2, A>(mma: TaskEither<E1, TaskEither<E2, A>>) => TaskEither<E1 | E2, A> =\n  /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <E, A>(mma: TaskEither<E, TaskEither<E, A>>) => TaskEither<E, A> = flattenW\n\n/**\n * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to\n * types of kind `* -> *`.\n *\n * In case of `TaskEither` returns `fa` if is a `Right` or the value returned by `that` otherwise.\n *\n * See also [orElse](#orelse).\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as TE from 'fp-ts/TaskEither'\n *\n * async function test() {\n *   assert.deepStrictEqual(\n *     await pipe(\n *       TE.right(1),\n *       TE.alt(() => TE.right(2))\n *     )(),\n *     E.right(1)\n *   )\n *   assert.deepStrictEqual(\n *     await pipe(\n *       TE.left('a'),\n *       TE.alt(() => TE.right(2))\n *     )(),\n *     E.right(2)\n *   )\n *   assert.deepStrictEqual(\n *     await pipe(\n *       TE.left('a'),\n *       TE.alt(() => TE.left('b'))\n *     )(),\n *     E.left('b')\n *   )\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const alt: <E, A>(that: LazyArg<TaskEither<E, A>>) => (fa: TaskEither<E, A>) => TaskEither<E, A> =\n  /*#__PURE__*/ ET.alt(T.Monad)\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the error and the return types will be merged.\n *\n * @category error handling\n * @since 2.9.0\n */\nexport const altW: <E2, B>(\n  that: LazyArg<TaskEither<E2, B>>\n) => <E1, A>(fa: TaskEither<E1, A>) => TaskEither<E2, A | B> = alt as any\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const of: <E = never, A = never>(a: A) => TaskEither<E, A> = right\n\n/**\n * @since 2.7.0\n */\nexport const throwError: MonadThrow2<URI>['throwError'] = left\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'TaskEither'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: TaskEither<E, A>\n  }\n}\n\n/**\n * The default [`ApplicativePar`](#applicativepar) instance returns the first error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as RA from 'fp-ts/ReadonlyArray'\n * import * as S from 'fp-ts/Semigroup'\n * import * as string from 'fp-ts/string'\n * import * as T from 'fp-ts/Task'\n * import * as TE from 'fp-ts/TaskEither'\n *\n * interface User {\n *   readonly id: string\n *   readonly name: string\n * }\n *\n * const remoteDatabase: ReadonlyArray<User> = [\n *   { id: 'id1', name: 'John' },\n *   { id: 'id2', name: 'Mary' },\n *   { id: 'id3', name: 'Joey' }\n * ]\n *\n * const fetchUser = (id: string): TE.TaskEither<string, User> =>\n *   pipe(\n *     remoteDatabase,\n *     RA.findFirst((user) => user.id === id),\n *     TE.fromOption(() => `${id} not found`)\n *   )\n *\n * async function test() {\n *   assert.deepStrictEqual(\n *     await pipe(['id4', 'id5'], RA.traverse(TE.ApplicativePar)(fetchUser))(),\n *     E.left('id4 not found') // <= first error\n *   )\n *\n *   const Applicative = TE.getApplicativeTaskValidation(\n *     T.ApplyPar,\n *     pipe(string.Semigroup, S.intercalate(', '))\n *   )\n *\n *   assert.deepStrictEqual(\n *     await pipe(['id4', 'id5'], RA.traverse(Applicative)(fetchUser))(),\n *     E.left('id4 not found, id5 not found') // <= all errors\n *   )\n * }\n *\n * test()\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getApplicativeTaskValidation<E>(A: Apply1<T.URI>, S: Semigroup<E>): Applicative2C<URI, E> {\n  const ap = ap_(A, E.getApplicativeValidation(S))\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: (fab, fa) => pipe(fab, ap(fa)),\n    of\n  }\n}\n\n/**\n * The default [`Alt`](#alt) instance returns the last error, if you want to\n * get all errors you need to provide a way to concatenate them via a `Semigroup`.\n *\n * See [`getAltValidation`](./Either.ts.html#getaltvalidation).\n *\n * @category error handling\n * @since 2.7.0\n */\nexport function getAltTaskValidation<E>(S: Semigroup<E>): Alt2C<URI, E> {\n  const alt = ET.altValidation(T.Monad, S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    alt: (fa, that) => pipe(fa, alt(that))\n  }\n}\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const getCompactable = <E>(M: Monoid<E>): Compactable2C<URI, E> => {\n  const C = E.getCompactable(M)\n  return {\n    URI,\n    _E: undefined as any,\n    compact: compact_(T.Functor, C),\n    separate: separate_(T.Functor, C, E.Functor)\n  }\n}\n\n/**\n * @category filtering\n * @since 2.1.0\n */\nexport function getFilterable<E>(M: Monoid<E>): Filterable2C<URI, E> {\n  const F = E.getFilterable(M)\n  const C = getCompactable(M)\n\n  const filter = filter_(T.Functor, F)\n  const filterMap = filterMap_(T.Functor, F)\n  const partition = partition_(T.Functor, F)\n  const partitionMap = partitionMap_(T.Functor, F)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    compact: C.compact,\n    separate: C.separate,\n    filter: <A>(fa: TaskEither<E, A>, predicate: Predicate<A>) => pipe(fa, filter(predicate)),\n    filterMap: (fa, f) => pipe(fa, filterMap(f)),\n    partition: <A>(fa: TaskEither<E, A>, predicate: Predicate<A>) => pipe(fa, partition(predicate)),\n    partitionMap: (fa, f) => pipe(fa, partitionMap(f))\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the `Right` value of this `TaskEither` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <E, _>(self: TaskEither<E, _>) => TaskEither<E, A>\n  <E, _, A>(self: TaskEither<E, _>, a: A): TaskEither<E, A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the `Right` value of this `TaskEither` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <E, _>(self: TaskEither<E, _>) => TaskEither<E, void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed2<URI> = {\n  URI,\n  of\n}\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplyPar: Apply2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(ApplyPar)\n\n/**\n * Less strict version of [`apFirst`](#apfirst).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apFirstW: <E2, B>(\n  second: TaskEither<E2, B>\n) => <E1, A>(first: TaskEither<E1, A>) => TaskEither<E1 | E2, A> = apFirst as any\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(ApplyPar)\n\n/**\n * Less strict version of [`apSecond`](#apsecond).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const apSecondW: <E2, B>(\n  second: TaskEither<E2, B>\n) => <E1, A>(first: TaskEither<E1, A>) => TaskEither<E1 | E2, B> = apSecond as any\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.7.0\n */\nexport const ApplicativePar: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  of\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplySeq: Apply2<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.7.0\n */\nexport const ApplicativeSeq: Applicative2<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Monad: Monad2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadIO: MonadIO2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap,\n  of,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadTask: MonadTask2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap,\n  of,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadThrow: MonadThrow2<URI> = {\n  URI,\n  map: _map,\n  ap: _apPar,\n  chain: flatMap,\n  of,\n  throwError\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromEither: FromEither2<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromIO: FromIO2<URI> = {\n  URI,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromTask: FromTask2<URI> = {\n  URI,\n  fromIO,\n  fromTask\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <E1, A, E2, _>(self: TaskEither<E1, A>, f: (a: A) => TaskEither<E2, _>): TaskEither<E1 | E2, A>\n  <A, E2, _>(f: (a: A) => TaskEither<E2, _>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as E from 'fp-ts/Either'\n * import { pipe } from 'fp-ts/function'\n * import * as TE from 'fp-ts/TaskEither'\n *\n * const checkString = (value: string) => pipe(\n *   TE.of(value),\n *   TE.tapEither(() => value.length > 0 ? E.right('ok') : E.left('error'))\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await checkString('')(), E.left('error'))\n *   assert.deepStrictEqual(await checkString('fp-ts')(), E.right('fp-ts'))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapEither: {\n  <A, E2, _>(f: (a: A) => Either<E2, _>): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, A>\n  <E1, A, E2, _>(self: TaskEither<E1, A>, f: (a: A) => Either<E2, _>): TaskEither<E1 | E2, A>\n} = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as TE from 'fp-ts/TaskEither'\n * import * as E from 'fp-ts/Either'\n * import * as Console from 'fp-ts/Console'\n *\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effectA = TE.tapIO(\n *   TE.of(1),\n *   (value) => Console.log(`Hello, ${value}`)\n * )\n *\n * // No output to the stdout\n * const effectB = pipe(\n *   TE.left('error'),\n *   TE.tapIO((value) => Console.log(`Hello, ${value}`))\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effectA(), E.of(1))\n *   assert.deepStrictEqual(await effectB(), E.left('error'))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): <E>(self: TaskEither<E, A>) => TaskEither<E, A>\n  <E, A, _>(self: TaskEither<E, A>, f: (a: A) => IO<_>): TaskEither<E, A>\n} = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as TE from 'fp-ts/TaskEither'\n * import * as T from 'fp-ts/Task'\n * import * as E from 'fp-ts/Either'\n *\n *\n * const effect = TE.tapIO(\n *   TE.of(1),\n *   (value) => T.of(value + 1)\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effect(), E.of(1))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapTask: {\n  <A, _>(f: (a: A) => Task<_>): <E>(self: TaskEither<E, A>) => TaskEither<E, A>\n  <E, A, _>(self: TaskEither<E, A>, f: (a: A) => Task<_>): TaskEither<E, A>\n} = /*#__PURE__*/ dual(2, tapTask_(FromTask, Chain))\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor2<URI> = {\n  URI,\n  bimap: mapBoth,\n  mapLeft: mapError\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Alt: Alt2<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @category conversions\n * @since 2.0.0\n */\nexport const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => TaskEither<E, A> =\n  /*#__PURE__*/ fromOption_(FromEither)\n\n/**\n * Use `liftOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => TaskEither<E, B> =\n  /*#__PURE__*/ fromOptionK_(FromEither)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A, B>(f: (a: A) => Option<B>) => (ma: TaskEither<E, A>) => TaskEither<E, B> = /*#__PURE__*/ chainOptionK_(\n  FromEither,\n  Chain\n)\n\n/**\n * Use `flatMapOption`.\n *\n * @category legacy\n * @since 2.13.2\n */\nexport const chainOptionKW: <E2>(\n  onNone: LazyArg<E2>\n) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, B> = chainOptionK as any\n\n/** @internal */\ninterface TaskEitherTypeLambda extends _.TypeLambda {\n  readonly type: TaskEither<this['Out1'], this['Target']>\n}\n\n/** @internal */\nconst _FromEither: _.FromEither<TaskEitherTypeLambda> = {\n  fromEither: FromEither.fromEither\n}\n\n/**\n * @category lifting\n * @since 2.15.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) => TaskEither<E, NonNullable<B>> = /*#__PURE__*/ _.liftNullable(_FromEither)\n\n/**\n * @category lifting\n * @since 2.15.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) => TaskEither<E, B> = /*#__PURE__*/ _.liftOption(_FromEither)\n\n/** @internal */\nconst _FlatMap: _.FlatMap<TaskEitherTypeLambda> = {\n  flatMap\n}\n\n/** @internal */\nconst _FromIO: _.FromIO<TaskEitherTypeLambda> = {\n  fromIO: FromIO.fromIO\n}\n\n/** @internal */\nconst _FromTask: _.FromTask<TaskEitherTypeLambda> = {\n  fromTask\n}\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapNullable: {\n  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <E1>(\n    self: TaskEither<E1, A>\n  ) => TaskEither<E2 | E1, NonNullable<B>>\n  <E1, A, B, E2>(self: TaskEither<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): TaskEither<\n    E1 | E2,\n    NonNullable<B>\n  >\n} = /*#__PURE__*/ _.flatMapNullable(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapOption: {\n  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <E1>(self: TaskEither<E1, A>) => TaskEither<E2 | E1, B>\n  <E1, A, B, E2>(self: TaskEither<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): TaskEither<E1 | E2, B>\n} = /*#__PURE__*/ _.flatMapOption(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapEither: {\n  <A, E2, B>(f: (a: A) => E.Either<E2, B>): <E1>(self: TaskEither<E1, A>) => TaskEither<E1 | E2, B>\n  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => E.Either<E2, B>): TaskEither<E1 | E2, B>\n} = /*#__PURE__*/ _.flatMapEither(_FromEither, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.15.0\n */\nexport const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): <E>(self: TaskEither<E, A>) => TaskEither<E, B>\n  <E, A, B>(self: TaskEither<E, A>, f: (a: A) => IO<B>): TaskEither<E, B>\n} = /*#__PURE__*/ _.flatMapIO(_FromIO, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapTask: {\n  <A, B>(f: (a: A) => Task<B>): <E>(self: TaskEither<E, A>) => TaskEither<E, B>\n  <E, A, B>(self: TaskEither<E, A>, f: (a: A) => Task<B>): TaskEither<E, B>\n} = /*#__PURE__*/ _.flatMapTask(_FromTask, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIOEither: {\n  <A, E2, B>(f: (a: A) => IOEither<E2, B>): <E1>(self: TaskEither<E1, A>) => TaskEither<E1 | E2, B>\n  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => IOEither<E2, B>): TaskEither<E1 | E2, B>\n} = /*#__PURE__*/ dual(\n  2,\n  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => IOEither<E2, B>): TaskEither<E1 | E2, B> =>\n    flatMap(self, fromIOEitherK(f))\n)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapTaskOption: {\n  <A, E2, B>(f: (a: A) => TaskOption<B>, onNone: (a: A) => E2): <E1>(self: TaskEither<E1, A>) => TaskEither<E1 | E2, B>\n  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => TaskOption<B>, onNone: (a: A) => E2): TaskEither<E1 | E2, B>\n} = /*#__PURE__*/ dual(\n  3,\n  <E1, A, E2, B>(self: TaskEither<E1, A>, f: (a: A) => TaskOption<B>, onNone: (a: A) => E2): TaskEither<E1 | E2, B> =>\n    flatMap(self, (a) => fromTaskOption(() => onNone(a))(f(a)))\n)\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainEitherK: <E, A, B>(f: (a: A) => E.Either<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, B> =\n  flatMapEither\n\n/**\n * Alias of `flatMapEither`.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainEitherKW: <E2, A, B>(\n  f: (a: A) => Either<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, B> = flatMapEither\n\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherK: <A, E, B>(f: (a: A) => E.Either<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, A> =\n  tapEither\n\n/**\n * Alias of `tapEither`.\n *\n * Less strict version of [`chainFirstEitherK`](#chainfirsteitherk).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherKW: <A, E2, B>(\n  f: (a: A) => E.Either<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, A> = tapEither\n\n/**\n * @category lifting\n * @since 2.0.0\n */\nexport const fromPredicate: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => TaskEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => TaskEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => TaskEither<E, A>\n} = /*#__PURE__*/ fromPredicate_(FromEither)\n\n/**\n * @category filtering\n * @since 2.0.0\n */\nexport const filterOrElse: {\n  <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: TaskEither<E, A>) => TaskEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: TaskEither<E, B>) => TaskEither<E, B>\n  <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: TaskEither<E, A>) => TaskEither<E, A>\n} = /*#__PURE__*/ filterOrElse_(FromEither, Chain)\n\n/**\n * Less strict version of [`filterOrElse`](#filterorelse).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category filtering\n * @since 2.9.0\n */\nexport const filterOrElseW: {\n  <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(\n    ma: TaskEither<E1, A>\n  ) => TaskEither<E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>(\n    mb: TaskEither<E1, B>\n  ) => TaskEither<E1 | E2, B>\n  <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, A>\n} = filterOrElse\n\n/**\n * @category lifting\n * @since 2.4.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => E.Either<E, B>\n) => (...a: A) => TaskEither<E, B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => IO<B>\n) => <E = never>(...a: A) => TaskEither<E, B> = /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainIOK: <A, B>(f: (a: A) => IO<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, B> = flatMapIO\n\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, A> = tapIO\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromTaskK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => T.Task<B>\n) => <E = never>(...a: A) => TaskEither<E, B> = /*#__PURE__*/ fromTaskK_(FromTask)\n\n/**\n * Alias of `flatMapTask`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainTaskK: <A, B>(f: (a: A) => T.Task<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, B> =\n  flatMapTask\n\n/**\n * Alias of `tapTask`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => <E>(first: TaskEither<E, A>) => TaskEither<E, A> =\n  tapTask\n\n/**\n * Alias of `flatMapIOEither`.\n *\n * Less strict version of [`chainIOEitherK`](#chainioeitherk).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category legacy\n * @since 2.6.1\n */\nexport const chainIOEitherKW: <E2, A, B>(\n  f: (a: A) => IOEither<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, B> = flatMapIOEither\n\n/**\n * Alias of `flatMapIOEither`.\n *\n * @category legacy\n * @since 2.4.0\n */\nexport const chainIOEitherK: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, B> =\n  flatMapIOEither\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Convert a node style callback function to one returning a `TaskEither`\n *\n * **Note**. If the function `f` admits multiple overloadings, `taskify` will pick last one. If you want a different\n * behaviour, add an explicit type annotation\n *\n * ```ts\n * // readFile admits multiple overloadings\n *\n * // const readFile: (a: string) => TaskEither<NodeJS.ErrnoException, Buffer>\n * const readFile = taskify(fs.readFile)\n *\n * const readFile2: (filename: string, encoding: string) => TaskEither<NodeJS.ErrnoException, Buffer> = taskify(\n *   fs.readFile\n * )\n * ```\n *\n * @example\n * import { taskify } from 'fp-ts/TaskEither'\n * import * as fs from 'fs'\n *\n * // const stat: (a: string | Buffer) => TaskEither<NodeJS.ErrnoException, fs.Stats>\n * const stat = taskify(fs.stat)\n * assert.strictEqual(stat.length, 0)\n *\n * @category interop\n * @since 2.0.0\n */\nexport function taskify<L, R>(f: (cb: (e: L | null | undefined, r?: R) => void) => void): () => TaskEither<L, R>\nexport function taskify<A, L, R>(\n  f: (a: A, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A) => TaskEither<L, R>\nexport function taskify<A, B, L, R>(\n  f: (a: A, b: B, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A, b: B) => TaskEither<L, R>\nexport function taskify<A, B, C, L, R>(\n  f: (a: A, b: B, c: C, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A, b: B, c: C) => TaskEither<L, R>\nexport function taskify<A, B, C, D, L, R>(\n  f: (a: A, b: B, c: C, d: D, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A, b: B, c: C, d: D) => TaskEither<L, R>\nexport function taskify<A, B, C, D, E, L, R>(\n  f: (a: A, b: B, c: C, d: D, e: E, cb: (e: L | null | undefined, r?: R) => void) => void\n): (a: A, b: B, c: C, d: D, e: E) => TaskEither<L, R>\nexport function taskify<L, R>(f: Function): () => TaskEither<L, R> {\n  return function () {\n    const args = Array.prototype.slice.call(arguments)\n    return () =>\n      new Promise((resolve) => {\n        const cbResolver = (e: L, r: R) => (e != null ? resolve(_.left(e)) : resolve(_.right(r)))\n        f.apply(null, args.concat(cbResolver))\n      })\n  }\n}\n\n/**\n * Make sure that a resource is cleaned up in the event of an exception (\\*). The release action is called regardless of\n * whether the body action throws (\\*) or returns.\n *\n * (\\*) i.e. returns a `Left`\n *\n * @since 2.0.0\n */\nexport const bracket = <E, A, B>(\n  acquire: TaskEither<E, A>,\n  use: (a: A) => TaskEither<E, B>,\n  release: (a: A, e: Either<E, B>) => TaskEither<E, void>\n): TaskEither<E, B> => bracketW(acquire, use, release)\n\n/**\n * Less strict version of [`bracket`](#bracket).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @since 2.12.0\n */\nexport const bracketW: <E1, A, E2, B, E3>(\n  acquire: TaskEither<E1, A>,\n  use: (a: A) => TaskEither<E2, B>,\n  release: (a: A, e: E.Either<E2, B>) => TaskEither<E3, void>\n) => TaskEither<E1 | E2 | E3, B> = (acquire, use, release) =>\n  flatMap(acquire, (a) => T.flatMap(use(a), (e) => flatMap(release(a, e), () => T.of(e))))\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: TaskEither<never, {}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const bindW: <N extends string, A, E2, B>(\n  name: Exclude<N, keyof A>,\n  f: (a: A) => TaskEither<E2, B>\n) => <E1>(fa: TaskEither<E1, A>) => TaskEither<E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  bind as any\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(ApplyPar)\n\n/**\n * Less strict version of [`apS`](#aps).\n *\n * The `W` suffix (short for **W**idening) means that the error types will be merged.\n *\n * @category do notation\n * @since 2.8.0\n */\nexport const apSW: <A, N extends string, E2, B>(\n  name: Exclude<N, keyof A>,\n  fb: TaskEither<E2, B>\n) => <E1>(fa: TaskEither<E1, A>) => TaskEither<E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> =\n  apS as any\n\n/**\n * @since 2.11.0\n */\nexport const ApT: TaskEither<never, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex = <A, E, B>(\n  f: (index: number, a: A) => TaskEither<E, B>\n): ((as: ReadonlyNonEmptyArray<A>) => TaskEither<E, ReadonlyNonEmptyArray<B>>) =>\n  flow(T.traverseReadonlyNonEmptyArrayWithIndex(f), T.map(E.traverseReadonlyNonEmptyArrayWithIndex(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, E, B>(\n  f: (index: number, a: A) => TaskEither<E, B>\n): ((as: ReadonlyArray<A>) => TaskEither<E, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndexSeq =\n  <A, E, B>(f: (index: number, a: A) => TaskEither<E, B>) =>\n  (as: ReadonlyNonEmptyArray<A>): TaskEither<E, ReadonlyNonEmptyArray<B>> =>\n  () =>\n    _.tail(as).reduce<Promise<Either<E, NonEmptyArray<B>>>>(\n      (acc, a, i) =>\n        acc.then((ebs) =>\n          _.isLeft(ebs)\n            ? acc\n            : f(i + 1, a)().then((eb) => {\n                if (_.isLeft(eb)) {\n                  return eb\n                }\n                ebs.right.push(eb.right)\n                return ebs\n              })\n        ),\n      f(0, _.head(as))().then(E.map(_.singleton))\n    )\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndexSeq = <A, E, B>(\n  f: (index: number, a: A) => TaskEither<E, B>\n): ((as: ReadonlyArray<A>) => TaskEither<E, ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndexSeq(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArrayWithIndex: <A, B, E>(\n  f: (index: number, a: A) => TaskEither<E, B>\n) => (as: ReadonlyArray<A>) => TaskEither<E, ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseArray = <A, B, E>(\n  f: (a: A) => TaskEither<E, B>\n): ((as: ReadonlyArray<A>) => TaskEither<E, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceArray: <A, E>(arr: ReadonlyArray<TaskEither<E, A>>) => TaskEither<E, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseSeqArrayWithIndex: <A, B, E>(\n  f: (index: number, a: A) => TaskEither<E, B>\n) => (as: ReadonlyArray<A>) => TaskEither<E, ReadonlyArray<B>> = traverseReadonlyArrayWithIndexSeq\n\n/**\n * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const traverseSeqArray = <A, B, E>(\n  f: (a: A) => TaskEither<E, B>\n): ((as: ReadonlyArray<A>) => TaskEither<E, ReadonlyArray<B>>) => traverseReadonlyArrayWithIndexSeq((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.9.0\n */\nexport const sequenceSeqArray: <A, E>(arr: ReadonlyArray<TaskEither<E, A>>) => TaskEither<E, ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseSeqArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <E, A, B>(f: (a: A) => TaskEither<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, B> = flatMap\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.6.0\n */\nexport const chainW: <E2, A, B>(\n  f: (a: A) => TaskEither<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chainFirst: <E, A, B>(f: (a: A) => TaskEither<E, B>) => (ma: TaskEither<E, A>) => TaskEither<E, A> = tap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.8.0\n */\nexport const chainFirstW: <E2, A, B>(\n  f: (a: A) => TaskEither<E2, B>\n) => <E1>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, A> = tap\n\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const orElseFirst: <E, B>(onLeft: (e: E) => TaskEither<E, B>) => <A>(ma: TaskEither<E, A>) => TaskEither<E, A> =\n  tapError\n\n/**\n * Alias of `tapError`.\n *\n * @category legacy\n * @since 2.11.0\n */\nexport const orElseFirstW: <E1, E2, B>(\n  onLeft: (e: E1) => TaskEither<E2, B>\n) => <A>(ma: TaskEither<E1, A>) => TaskEither<E1 | E2, A> = tapError\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `TE.Functor` instead of `TE.taskEither`\n * (where `TE` is from `import TE from 'fp-ts/TaskEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const taskEither: Monad2<URI> & Bifunctor2<URI> & Alt2<URI> & MonadTask2<URI> & MonadThrow2<URI> = {\n  URI,\n  bimap: mapBoth,\n  mapLeft: mapError,\n  map: _map,\n  of,\n  ap: _apPar,\n  chain: flatMap,\n  alt: _alt,\n  fromIO,\n  fromTask,\n  throwError\n}\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `TE.Functor` instead of `TE.taskEitherSeq`\n * (where `TE` is from `import TE from 'fp-ts/TaskEither'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n\nexport const taskEitherSeq: typeof taskEither = {\n  URI,\n  bimap: mapBoth,\n  mapLeft: mapError,\n  map: _map,\n  of,\n  ap: _apSeq,\n  chain: flatMap,\n  alt: _alt,\n  fromIO,\n  fromTask,\n  throwError\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<TaskEither<E, A>> =\n  /*#__PURE__*/ getApplySemigroup_(ApplySeq)\n\n/**\n * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<TaskEither<E, A>> =\n  /*#__PURE__*/ getApplicativeMonoid(ApplicativeSeq)\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const getSemigroup = <E, A>(S: Semigroup<A>): Semigroup<TaskEither<E, A>> =>\n  getApplySemigroup_(T.ApplySeq)(E.getSemigroup(S))\n\n/**\n * Use [`getApplicativeTaskValidation`](#getapplicativetaskvalidation) and [`getAltTaskValidation`](#getalttaskvalidation) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getTaskValidation<E>(\n  SE: Semigroup<E>\n): Monad2C<URI, E> & Bifunctor2<URI> & Alt2C<URI, E> & MonadTask2C<URI, E> & MonadThrow2C<URI, E> {\n  const applicativeTaskValidation = getApplicativeTaskValidation(T.ApplicativePar, SE)\n  const altTaskValidation = getAltTaskValidation(SE)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: applicativeTaskValidation.ap,\n    of,\n    chain: flatMap,\n    bimap: mapBoth,\n    mapLeft: mapError,\n    alt: altTaskValidation.alt,\n    fromIO,\n    fromTask,\n    throwError\n  }\n}\n"
  },
  {
    "path": "src/TaskOption.ts",
    "content": "/**\n * @since 2.10.0\n */\nimport { Alt1 } from './Alt'\nimport { Alternative1 } from './Alternative'\nimport { Applicative1 } from './Applicative'\nimport { apFirst as apFirst_, Apply1, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport * as chainable from './Chain'\nimport { compact as compact_, Compactable1, separate as separate_ } from './Compactable'\nimport { Either } from './Either'\nimport {\n  filter as filter_,\n  Filterable1,\n  filterMap as filterMap_,\n  partition as partition_,\n  partitionMap as partitionMap_\n} from './Filterable'\nimport {\n  chainEitherK as chainEitherK_,\n  FromEither1,\n  fromEitherK as fromEitherK_,\n  tapEither as tapEither_\n} from './FromEither'\nimport { FromIO1, fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO'\nimport { FromTask1, fromTaskK as fromTaskK_, tapTask as tapTask_ } from './FromTask'\nimport { dual, flow, identity, LazyArg, pipe, SK } from './function'\nimport { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport * as _ from './internal'\nimport { IO } from './IO'\nimport { Monad1 } from './Monad'\nimport { MonadIO1 } from './MonadIO'\nimport { MonadTask1 } from './MonadTask'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport * as O from './Option'\nimport * as OT from './OptionT'\nimport { Pointed1 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Separated } from './Separated'\nimport * as T from './Task'\nimport { TaskEither } from './TaskEither'\nimport { guard as guard_, Zero1 } from './Zero'\n\nimport Task = T.Task\nimport Option = O.Option\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface TaskOption<A> extends Task<Option<A>> {}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.10.0\n */\nexport const some: <A>(a: A) => TaskOption<A> = /*#__PURE__*/ OT.some(T.Pointed)\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromPredicate: {\n  <A, B extends A>(refinement: Refinement<A, B>): (a: A) => TaskOption<B>\n  <A>(predicate: Predicate<A>): <B extends A>(b: B) => TaskOption<B>\n  <A>(predicate: Predicate<A>): (a: A) => TaskOption<A>\n} = /*#__PURE__*/ OT.fromPredicate(T.Pointed)\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromOption: <A>(fa: Option<A>) => TaskOption<A> = T.of\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromEither: <A>(fa: Either<unknown, A>) => TaskOption<A> = /*#__PURE__*/ OT.fromEither(T.Pointed)\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromIO: <A>(fa: IO<A>) => TaskOption<A> = (ma) => fromTask(T.fromIO(ma))\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromTask: <A>(fa: Task<A>) => TaskOption<A> = /*#__PURE__*/ OT.fromF(T.Functor)\n\n/**\n * @category conversions\n * @since 2.11.0\n */\nexport const fromTaskEither: <A>(fa: TaskEither<unknown, A>) => TaskOption<A> = /*#__PURE__*/ T.map(O.fromEither)\n\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <B, A>(onNone: () => B, onSome: (a: A) => B) => (ma: TaskOption<A>) => Task<B> =\n  /*#__PURE__*/ OT.match(T.Functor)\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW: <B, A, C>(onNone: () => B, onSome: (a: A) => C) => (ma: TaskOption<A>) => Task<B | C> =\n  match as any\n\n/**\n * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Task`).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchE: <B, A>(onNone: () => Task<B>, onSome: (a: A) => Task<B>) => (ma: TaskOption<A>) => Task<B> =\n  /*#__PURE__*/ OT.matchE(T.Chain)\n\n/**\n * Alias of [`matchE`](#matche).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const fold = matchE\n\n/**\n * Less strict version of [`matchE`](#matche).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchEW: <B, C, A>(\n  onNone: () => Task<B>,\n  onSome: (a: A) => Task<C>\n) => (ma: TaskOption<A>) => Task<B | C> = matchE as any\n\n/**\n * Alias of [`matchEW`](#matchew).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchEW\n\n/**\n * @category error handling\n * @since 2.10.0\n */\nexport const getOrElse: <A>(onNone: LazyArg<Task<A>>) => (fa: TaskOption<A>) => Task<A> = /*#__PURE__*/ OT.getOrElse(\n  T.Monad\n)\n\n/**\n * Less strict version of [`getOrElse`](#getorelse).\n *\n * The `W` suffix (short for **W**idening) means that the handler return type will be merged.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport const getOrElseW: <B>(onNone: LazyArg<Task<B>>) => <A>(ma: TaskOption<A>) => Task<A | B> = getOrElse as any\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromNullable: <A>(a: A) => TaskOption<NonNullable<A>> = /*#__PURE__*/ OT.fromNullable(T.Pointed)\n\n/**\n * Transforms a `Promise` that may reject to a `Promise` that never rejects and returns an `Option` instead.\n *\n * See also [`tryCatchK`](#trycatchk).\n *\n * @category interop\n * @since 2.10.0\n */\nexport const tryCatch =\n  <A>(f: LazyArg<Promise<A>>): TaskOption<A> =>\n  async () => {\n    try {\n      return await f().then(_.some)\n    } catch (reason) {\n      return _.none\n    }\n  }\n\n/**\n * Converts a function returning a `Promise` to one returning a `TaskOption`.\n *\n * @category interop\n * @since 2.10.0\n */\nexport const tryCatchK =\n  <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Promise<B>): ((...a: A) => TaskOption<B>) =>\n  (...a) =>\n    tryCatch(() => f(...a))\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromNullableK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => B | null | undefined\n) => (...a: A) => TaskOption<NonNullable<B>> = /*#__PURE__*/ OT.fromNullableK(T.Pointed)\n\n/**\n * @category sequencing\n * @since 2.10.0\n */\nexport const chainNullableK: <A, B>(\n  f: (a: A) => B | null | undefined\n) => (ma: TaskOption<A>) => TaskOption<NonNullable<B>> = /*#__PURE__*/ OT.chainNullableK(T.Monad)\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromOptionK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Option<B>\n) => (...a: A) => TaskOption<B> = /*#__PURE__*/ OT.fromOptionK(T.Pointed)\n\n/**\n * @category sequencing\n * @since 2.10.0\n */\nexport const chainOptionK: <A, B>(f: (a: A) => Option<B>) => (ma: TaskOption<A>) => TaskOption<B> =\n  /*#__PURE__*/ OT.chainOptionK(T.Monad)\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.10.0\n */\nexport const map: <A, B>(f: (a: A) => B) => (fa: TaskOption<A>) => TaskOption<B> = /*#__PURE__*/ OT.map(T.Functor)\n\n/**\n * @since 2.10.0\n */\nexport const ap: <A>(fa: TaskOption<A>) => <B>(fab: TaskOption<(a: A) => B>) => TaskOption<B> = /*#__PURE__*/ OT.ap(\n  T.ApplyPar\n)\n\n/**\n * @category constructors\n * @since 2.10.0\n */\nexport const of: <A>(a: A) => TaskOption<A> = some\n\n/** @internal */\ninterface TaskOptionTypeLambda extends _.TypeLambda {\n  readonly type: TaskOption<this['Target']>\n}\n\n/** @internal */\nconst _FromIO: _.FromIO<TaskOptionTypeLambda> = {\n  fromIO\n}\n\n/** @internal */\nconst _FromTask: _.FromTask<TaskOptionTypeLambda> = {\n  fromTask\n}\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A) => TaskOption<B>): (ma: TaskOption<A>) => TaskOption<B>\n  <A, B>(ma: TaskOption<A>, f: (a: A) => TaskOption<B>): TaskOption<B>\n} = /*#__PURE__*/ dual(2, OT.flatMap(T.Monad))\n\n/** @internal */\nconst _FlatMap: _.FlatMap<TaskOptionTypeLambda> = {\n  flatMap\n}\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapIO: {\n  <A, B>(f: (a: A) => IO<B>): (self: TaskOption<A>) => TaskOption<B>\n  <A, B>(self: TaskOption<A>, f: (a: A) => IO<B>): TaskOption<B>\n} = /*#__PURE__*/ _.flatMapIO(_FromIO, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.16.0\n */\nexport const flatMapTask: {\n  <A, B>(f: (a: A) => Task<B>): (self: TaskOption<A>) => TaskOption<B>\n  <A, B>(self: TaskOption<A>, f: (a: A) => Task<B>): TaskOption<B>\n} = /*#__PURE__*/ _.flatMapTask(_FromTask, _FlatMap)\n\n/**\n * @category sequencing\n * @since 2.10.0\n */\nexport const flatten: <A>(mma: TaskOption<TaskOption<A>>) => TaskOption<A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * @category error handling\n * @since 2.10.0\n */\nexport const alt: <A>(second: LazyArg<TaskOption<A>>) => (first: TaskOption<A>) => TaskOption<A> = /*#__PURE__*/ OT.alt(\n  T.Monad\n)\n\n/**\n * Less strict version of [`alt`](#alt).\n *\n * The `W` suffix (short for **W**idening) means that the return types will be merged.\n *\n * @category error handling\n * @since 2.10.0\n */\nexport const altW: <B>(second: LazyArg<TaskOption<B>>) => <A>(first: TaskOption<A>) => TaskOption<A | B> = alt as any\n\n/**\n * @since 2.10.0\n */\nexport const zero: <A>() => TaskOption<A> = /*#__PURE__*/ OT.zero(T.Pointed)\n\n/**\n * @category constructors\n * @since 2.10.0\n */\nexport const none: TaskOption<never> = /*#__PURE__*/ zero()\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const compact: Compactable1<URI>['compact'] = /*#__PURE__*/ compact_(T.Functor, O.Compactable)\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const separate: Compactable1<URI>['separate'] = /*#__PURE__*/ separate_(T.Functor, O.Compactable, O.Functor)\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const filter: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fb: TaskOption<A>) => TaskOption<B>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: TaskOption<B>) => TaskOption<B>\n  <A>(predicate: Predicate<A>): (fa: TaskOption<A>) => TaskOption<A>\n} = /*#__PURE__*/ filter_(T.Functor, O.Filterable)\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const filterMap: <A, B>(f: (a: A) => Option<B>) => (fga: TaskOption<A>) => TaskOption<B> =\n  /*#__PURE__*/ filterMap_(T.Functor, O.Filterable)\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const partition: {\n  <A, B extends A>(refinement: Refinement<A, B>): (fb: TaskOption<A>) => Separated<TaskOption<A>, TaskOption<B>>\n  <A>(predicate: Predicate<A>): <B extends A>(fb: TaskOption<B>) => Separated<TaskOption<B>, TaskOption<B>>\n  <A>(predicate: Predicate<A>): (fa: TaskOption<A>) => Separated<TaskOption<A>, TaskOption<A>>\n} = /*#__PURE__*/ partition_(T.Functor, O.Filterable)\n\n/**\n * @category filtering\n * @since 2.10.0\n */\nexport const partitionMap: <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => (fa: TaskOption<A>) => Separated<TaskOption<B>, TaskOption<C>> = /*#__PURE__*/ partitionMap_(\n  T.Functor,\n  O.Filterable\n)\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\nconst _map: Functor1<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _ap: Apply1<URI>['ap'] = (fab, fa) => pipe(fab, ap(fa))\n/* istanbul ignore next */\nconst _alt: Alt1<URI>['alt'] = (fa, that) => pipe(fa, alt(that))\n/* istanbul ignore next */\nconst _filter: Filterable1<URI>['filter'] = <A>(fa: TaskOption<A>, predicate: Predicate<A>) =>\n  pipe(fa, filter(predicate))\n/* istanbul ignore next */\nconst _filterMap: Filterable1<URI>['filterMap'] = (fa, f) => pipe(fa, filterMap(f))\n/* istanbul ignore next */\nconst _partition: Filterable1<URI>['partition'] = <A>(fa: TaskOption<A>, predicate: Predicate<A>) =>\n  pipe(fa, partition(predicate))\n/* istanbul ignore next */\nconst _partitionMap: Filterable1<URI>['partitionMap'] = (fa, f) => pipe(fa, partitionMap(f))\n\n/**\n * @category type lambdas\n * @since 2.10.0\n */\nexport const URI = 'TaskOption'\n\n/**\n * @category type lambdas\n * @since 2.10.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: TaskOption<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Maps the `Some` value of this `TaskOption` to the specified constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const as: {\n  <A>(a: A): <_>(self: TaskOption<_>) => TaskOption<A>\n  <_, A>(self: TaskOption<_>, a: A): TaskOption<A>\n} = dual(2, as_(Functor))\n\n/**\n * Maps the `Some` value of this `TaskOption` to the void constant value.\n *\n * @category mapping\n * @since 2.16.0\n */\nexport const asUnit: <_>(self: TaskOption<_>) => TaskOption<void> = asUnit_(Functor)\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplyPar: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.10.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(ApplyPar)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.10.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(ApplyPar)\n\n/**\n * Runs computations in parallel.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplicativePar: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\nconst _apSeq: Apply1<URI>['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map(f)))\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplySeq: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq\n}\n\n/**\n * Runs computations sequentially.\n *\n * @category instances\n * @since 2.10.0\n */\nexport const ApplicativeSeq: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _apSeq,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: chainable.Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromEither: FromEither1<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromIO: FromIO1<URI> = {\n  URI,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromTask: FromTask1<URI> = {\n  URI,\n  fromIO,\n  fromTask\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @category combinators\n * @since 2.15.0\n */\nexport const tap: {\n  <A, _>(self: TaskOption<A>, f: (a: A) => TaskOption<_>): TaskOption<A>\n  <A, _>(f: (a: A) => TaskOption<_>): (self: TaskOption<A>) => TaskOption<A>\n} = /*#__PURE__*/ dual(2, chainable.tap(Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as TO from 'fp-ts/TaskOption'\n * import * as O from 'fp-ts/Option'\n * import * as E from 'fp-ts/Either'\n *\n * const compute = (value: number) => pipe(\n *   TO.of(value),\n *   TO.tapEither((value) => value > 0 ? E.right('ok') : E.left('error')),\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await compute(1)(), O.of(1))\n *   assert.deepStrictEqual(await compute(-1)(), O.none)\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapEither: {\n  <A, E, _>(f: (a: A) => Either<E, _>): (self: TaskOption<A>) => TaskOption<A>\n  <A, E, _>(self: TaskOption<A>, f: (a: A) => Either<E, _>): TaskOption<A>\n} = /*#__PURE__*/ dual(2, tapEither_(FromEither, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import * as TO from 'fp-ts/TaskOption'\n * import * as O from 'fp-ts/Option'\n * import * as Console from 'fp-ts/Console'\n *\n *\n * // Will produce `Hello, fp-ts` to the stdout\n * const effectA = TO.tapIO(\n *   TO.of(1),\n *   (value) => Console.log(`Hello, ${value}`)\n * )\n *\n * // No output to the stdout\n * const effectB = pipe(\n *   TO.none as TO.TaskOption<string>,\n *   TO.tapIO((value) => Console.log(`Hello, ${value}`))\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effectA(), O.of(1))\n *   assert.deepStrictEqual(await effectB(), O.none)\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapIO: {\n  <A, _>(f: (a: A) => IO<_>): (self: TaskOption<A>) => TaskOption<A>\n  <A, _>(self: TaskOption<A>, f: (a: A) => IO<_>): TaskOption<A>\n} = /*#__PURE__*/ dual(2, tapIO_(FromIO, Chain))\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @example\n * import * as TO from 'fp-ts/TaskOption'\n * import * as O from 'fp-ts/Option'\n * import * as T from 'fp-ts/Task'\n *\n * const effect = TO.tapIO(\n *   TO.of(1),\n *   (value) => T.of(value + 1)\n * )\n *\n * async function test() {\n *   assert.deepStrictEqual(await effect(), O.of(1))\n * }\n *\n * test()\n *\n * @category combinators\n * @since 2.16.0\n */\nexport const tapTask: {\n  <A, _>(f: (a: A) => Task<_>): (self: TaskOption<A>) => TaskOption<A>\n  <A, _>(self: TaskOption<A>, f: (a: A) => Task<_>): TaskOption<A>\n} = /*#__PURE__*/ dual(2, tapTask_(FromTask, Chain))\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Alt: Alt1<URI> = {\n  URI,\n  map: _map,\n  alt: _alt\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const Zero: Zero1<URI> = {\n  URI,\n  zero\n}\n\n/**\n * @category do notation\n * @since 2.11.0\n */\nexport const guard = /*#__PURE__*/ guard_(Zero, Pointed)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Alternative: Alternative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  alt: _alt,\n  zero\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadIO: MonadIO1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  fromIO\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const MonadTask: MonadTask1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Compactable: Compactable1<URI> = {\n  URI,\n  compact,\n  separate\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Filterable: Filterable1<URI> = {\n  URI,\n  map: _map,\n  compact,\n  separate,\n  filter: _filter,\n  filterMap: _filterMap,\n  partition: _partition,\n  partitionMap: _partitionMap\n}\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO<B>) => (...a: A) => TaskOption<B> =\n  /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * Alias of `flatMapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainIOK: <A, B>(f: (a: A) => IO<B>) => (first: TaskOption<A>) => TaskOption<B> = flatMapIO\n\n/**\n * Alias of `tapIO`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstIOK: <A, B>(f: (a: A) => IO<B>) => (first: TaskOption<A>) => TaskOption<A> = tapIO\n\n/**\n * @category lifting\n * @since 2.12.0\n */\nexport const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => Either<E, B>\n) => (...a: A) => TaskOption<B> = /*#__PURE__*/ fromEitherK_(FromEither)\n\n/**\n * @category sequencing\n * @since 2.12.0\n */\nexport const chainEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: TaskOption<A>) => TaskOption<B> =\n  /*#__PURE__*/ chainEitherK_(FromEither, Chain)\n\n/**\n * Alias of `tapEither`.\n *\n * @category legacy\n * @since 2.12.0\n */\nexport const chainFirstEitherK: <E, A, B>(f: (a: A) => Either<E, B>) => (ma: TaskOption<A>) => TaskOption<A> = tapEither\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromTaskK: <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => T.Task<B>) => (...a: A) => TaskOption<B> =\n  /*#__PURE__*/ fromTaskK_(FromTask)\n\n/**\n * Alias of `flatMapTask`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainTaskK: <A, B>(f: (a: A) => T.Task<B>) => (first: TaskOption<A>) => TaskOption<B> = flatMapTask\n\n/**\n * Alias of `tapTask`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirstTaskK: <A, B>(f: (a: A) => T.Task<B>) => (first: TaskOption<A>) => TaskOption<A> = tapTask\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.10.0\n */\nexport const Do: TaskOption<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.10.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.10.0\n */\nexport const bind = /*#__PURE__*/ chainable.bind(Chain)\n\n/**\n * @category do notation\n * @since 2.10.0\n */\nexport const apS = /*#__PURE__*/ apS_(ApplyPar)\n\n/**\n * @since 2.11.0\n */\nexport const ApT: TaskOption<readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex = <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n): ((as: ReadonlyNonEmptyArray<A>) => TaskOption<ReadonlyNonEmptyArray<B>>) =>\n  flow(T.traverseReadonlyNonEmptyArrayWithIndex(f), T.map(O.traverseReadonlyNonEmptyArrayWithIndex(SK)))\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex = <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n): ((as: ReadonlyArray<A>) => TaskOption<ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndex(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndexSeq =\n  <A, B>(f: (index: number, a: A) => TaskOption<B>) =>\n  (as: ReadonlyNonEmptyArray<A>): TaskOption<ReadonlyNonEmptyArray<B>> =>\n  () =>\n    _.tail(as).reduce<Promise<Option<NonEmptyArray<B>>>>(\n      (acc, a, i) =>\n        acc.then((obs) =>\n          _.isNone(obs)\n            ? acc\n            : f(i + 1, a)().then((ob) => {\n                if (_.isNone(ob)) {\n                  return ob\n                }\n                obs.value.push(ob.value)\n                return obs\n              })\n        ),\n      f(0, _.head(as))().then(O.map(_.singleton))\n    )\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndexSeq = <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n): ((as: ReadonlyArray<A>) => TaskOption<ReadonlyArray<B>>) => {\n  const g = traverseReadonlyNonEmptyArrayWithIndexSeq(f)\n  return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.\n *\n * @category traversing\n * @since 2.10.0\n */\nexport const traverseArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n) => (as: ReadonlyArray<A>) => TaskOption<ReadonlyArray<B>> = traverseReadonlyArrayWithIndex\n\n/**\n * Equivalent to `ReadonlyArray#traverse(Applicative)`.\n *\n * @category traversing\n * @since 2.10.0\n */\nexport const traverseArray: <A, B>(\n  f: (a: A) => TaskOption<B>\n) => (as: ReadonlyArray<A>) => TaskOption<ReadonlyArray<B>> = (f) => traverseReadonlyArrayWithIndex((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(Applicative)`.\n *\n * @category traversing\n * @since 2.10.0\n */\nexport const sequenceArray: <A>(as: ReadonlyArray<TaskOption<A>>) => TaskOption<ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseArray(identity)\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.10.0\n */\nexport const traverseSeqArrayWithIndex: <A, B>(\n  f: (index: number, a: A) => TaskOption<B>\n) => (as: ReadonlyArray<A>) => TaskOption<ReadonlyArray<B>> = traverseReadonlyArrayWithIndexSeq\n\n/**\n * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.10.0\n */\nexport const traverseSeqArray: <A, B>(\n  f: (a: A) => TaskOption<B>\n) => (as: ReadonlyArray<A>) => TaskOption<ReadonlyArray<B>> = (f) => traverseReadonlyArrayWithIndexSeq((_, a) => f(a))\n\n/**\n * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.\n *\n * @category traversing\n * @since 2.10.0\n */\nexport const sequenceSeqArray: <A>(as: ReadonlyArray<TaskOption<A>>) => TaskOption<ReadonlyArray<A>> =\n  /*#__PURE__*/ traverseSeqArray(identity)\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chain: <A, B>(f: (a: A) => TaskOption<B>) => (ma: TaskOption<A>) => TaskOption<B> = flatMap\n\n/**\n * Alias of `tap`.\n *\n * @category legacy\n * @since 2.10.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => TaskOption<B>) => (first: TaskOption<A>) => TaskOption<A> = tap\n"
  },
  {
    "path": "src/TaskThese.ts",
    "content": "/**\n * @since 2.4.0\n */\nimport { Applicative2C } from './Applicative'\nimport { Apply1, Apply2C, getApplySemigroup } from './Apply'\nimport { Bifunctor2 } from './Bifunctor'\nimport { Chain2C } from './Chain'\nimport { Either } from './Either'\nimport {\n  FromEither2,\n  fromOption as fromOption_,\n  fromOptionK as fromOptionK_,\n  fromPredicate as fromPredicate_\n} from './FromEither'\nimport { FromIO2, fromIOK as fromIOK_ } from './FromIO'\nimport { FromTask2, fromTaskK as fromTaskK_ } from './FromTask'\nimport { FromThese2, fromTheseK as fromTheseK_ } from './FromThese'\nimport { flow, LazyArg, pipe, SK } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\nimport * as _ from './internal'\nimport { IO } from './IO'\nimport { IOEither } from './IOEither'\nimport { Monad2C } from './Monad'\nimport { MonadTask2C } from './MonadTask'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Option } from './Option'\nimport { Pointed2 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport * as T from './Task'\nimport * as TH from './These'\nimport * as TT from './TheseT'\n\nimport These = TH.These\nimport Task = T.Task\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.4.0\n */\nexport interface TaskThese<E, A> extends Task<These<E, A>> {}\n\n/**\n * @category constructors\n * @since 2.4.0\n */\nexport const left: <E = never, A = never>(e: E) => TaskThese<E, A> = /*#__PURE__*/ TT.left(T.Pointed)\n\n/**\n * @category constructors\n * @since 2.4.0\n */\nexport const right: <E = never, A = never>(a: A) => TaskThese<E, A> = /*#__PURE__*/ TT.right(T.Pointed)\n\n/**\n * @category constructors\n * @since 2.4.0\n */\nexport const both: <E, A>(e: E, a: A) => TaskThese<E, A> = /*#__PURE__*/ TT.both(T.Pointed)\n\n/**\n * @category constructors\n * @since 2.4.0\n */\nexport const rightTask: <E = never, A = never>(ma: Task<A>) => TaskThese<E, A> = /*#__PURE__*/ TT.rightF(T.Functor)\n\n/**\n * @category constructors\n * @since 2.4.0\n */\nexport const leftTask: <E = never, A = never>(me: Task<E>) => TaskThese<E, A> = /*#__PURE__*/ TT.leftF(T.Functor)\n\n/**\n * @category constructors\n * @since 2.4.0\n */\nexport const rightIO: <E = never, A = never>(ma: IO<A>) => TaskThese<E, A> = /*#__PURE__*/ flow(T.fromIO, rightTask)\n\n/**\n * @category constructors\n * @since 2.4.0\n */\nexport const leftIO: <E = never, A = never>(me: IO<E>) => TaskThese<E, A> = /*#__PURE__*/ flow(T.fromIO, leftTask)\n\n// -------------------------------------------------------------------------------------\n// conversions\n// -------------------------------------------------------------------------------------\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromEither: <E, A>(fa: Either<E, A>) => TaskThese<E, A> = T.of\n\n/**\n * @category conversions\n * @since 2.11.0\n */\nexport const fromThese: <E, A>(fa: These<E, A>) => TaskThese<E, A> = T.of\n\n/**\n * @category conversions\n * @since 2.7.0\n */\nexport const fromIO: <A, E = never>(fa: IO<A>) => TaskThese<E, A> = rightIO\n\n/**\n * @category conversions\n * @since 2.4.0\n */\nexport const fromIOEither: <E, A>(fa: IOEither<E, A>) => TaskThese<E, A> = T.fromIO\n\n/**\n * @category conversions\n * @since 2.7.0\n */\nexport const fromTask: <A, E = never>(fa: Task<A>) => TaskThese<E, A> = rightTask\n\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (fa: TaskThese<E, A>) => Task<B> = /*#__PURE__*/ TT.match(T.Functor)\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW: <E, B, A, C, D>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => C,\n  onBoth: (e: E, a: A) => D\n) => (ma: TaskThese<E, A>) => T.Task<B | C | D> = match as any\n\n/**\n * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Task`).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchE: <E, B, A>(\n  onLeft: (e: E) => Task<B>,\n  onRight: (a: A) => Task<B>,\n  onBoth: (e: E, a: A) => Task<B>\n) => (fa: TaskThese<E, A>) => Task<B> = /*#__PURE__*/ TT.matchE(T.Monad)\n\n/**\n * Alias of [`matchE`](#matche).\n *\n * @category pattern matching\n * @since 2.4.0\n */\nexport const fold = matchE\n\n/**\n * Less strict version of [`matchE`](#matche).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchEW: <E, B, A, C, D>(\n  onLeft: (e: E) => Task<B>,\n  onRight: (a: A) => Task<C>,\n  onBoth: (e: E, a: A) => Task<D>\n) => (fa: TaskThese<E, A>) => Task<B | C | D> = fold as any\n\n/**\n * Alias of [`matchEW`](#matchew).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchEW\n\n/**\n * @since 2.4.0\n */\nexport const swap: <E, A>(fa: TaskThese<E, A>) => TaskThese<A, E> = /*#__PURE__*/ TT.swap(T.Functor)\n\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _bimap: Bifunctor2<URI>['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g))\n/* istanbul ignore next */\nconst _mapLeft: Bifunctor2<URI>['mapLeft'] = (fa, f) => pipe(fa, mapLeft(f))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.4.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: TaskThese<E, A>) => TaskThese<E, B> = /*#__PURE__*/ TT.map(\n  T.Functor\n)\n\n/**\n * Map a pair of functions over the two type arguments of the bifunctor.\n *\n * @category mapping\n * @since 2.4.0\n */\nexport const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: TaskThese<E, A>) => TaskThese<G, B> =\n  /*#__PURE__*/ TT.bimap(T.Functor)\n\n/**\n * Map a function over the first type argument of a bifunctor.\n *\n * @category error handling\n * @since 2.4.0\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: TaskThese<E, A>) => TaskThese<G, A> = /*#__PURE__*/ TT.mapLeft(\n  T.Functor\n)\n\n/**\n * @category constructors\n * @since 2.7.0\n */\nexport const of: <E = never, A = never>(a: A) => TaskThese<E, A> = right\n\n/**\n * @category type lambdas\n * @since 2.4.0\n */\nexport const URI = 'TaskThese'\n\n/**\n * @category type lambdas\n * @since 2.4.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: TaskThese<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getApply = <E>(A: Apply1<T.URI>, S: Semigroup<E>): Apply2C<URI, E> => {\n  const ap = TT.ap(A, S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: (fab, fa) => pipe(fab, ap(fa))\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport function getApplicative<E>(A: Apply1<T.URI>, S: Semigroup<E>): Applicative2C<URI, E> {\n  const { ap } = getApply(A, S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap,\n    of\n  }\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport function getChain<E>(S: Semigroup<E>): Chain2C<URI, E> {\n  const A = getApply(T.ApplicativePar, S)\n  const chain = TT.chain(T.Monad, S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: A.ap,\n    chain: (ma, f) => pipe(ma, chain(f))\n  }\n}\n\n/**\n * @category instances\n * @since 2.4.0\n */\nexport function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> & MonadTask2C<URI, E> {\n  const A = getApplicative(T.ApplicativePar, S)\n  const C = getChain(S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: A.ap,\n    of,\n    chain: C.chain,\n    fromIO,\n    fromTask\n  }\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed2<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Bifunctor: Bifunctor2<URI> = {\n  URI,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromEither: FromEither2<URI> = {\n  URI,\n  fromEither\n}\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => TaskThese<E, A> =\n  /*#__PURE__*/ fromOption_(FromEither)\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => TaskThese<E, B> =\n  /*#__PURE__*/ fromOptionK_(FromEither)\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromPredicate: {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => TaskThese<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => TaskThese<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => TaskThese<E, A>\n} = /*#__PURE__*/ fromPredicate_(FromEither)\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromThese: FromThese2<URI> = {\n  URI,\n  fromThese\n}\n\n/**\n * @category lifting\n * @since 2.11.0\n */\nexport const fromTheseK: <A extends ReadonlyArray<unknown>, E, B>(\n  f: (...a: A) => TH.These<E, B>\n) => (...a: A) => TaskThese<E, B> = /*#__PURE__*/ fromTheseK_(FromThese)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromIO: FromIO2<URI> = {\n  URI,\n  fromIO\n}\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromIOK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => IO<B>\n) => <E = never>(...a: A) => TaskThese<E, B> = /*#__PURE__*/ fromIOK_(FromIO)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromTask: FromTask2<URI> = {\n  URI,\n  fromIO,\n  fromTask\n}\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromTaskK: <A extends ReadonlyArray<unknown>, B>(\n  f: (...a: A) => T.Task<B>\n) => <E = never>(...a: A) => TaskThese<E, B> = /*#__PURE__*/ fromTaskK_(FromTask)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.10.0\n */\nexport const toTuple2: <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: TaskThese<E, A>) => Task<readonly [E, A]> =\n  /*#__PURE__*/ TT.toTuple2(T.Functor)\n\n/**\n * @since 2.11.0\n */\nexport const ApT: TaskThese<never, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(T.ApplicativePar, S))`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex = <E>(\n  S: Semigroup<E>\n): (<A, B>(\n  f: (index: number, a: A) => TaskThese<E, B>\n) => (as: ReadonlyNonEmptyArray<A>) => TaskThese<E, ReadonlyNonEmptyArray<B>>) => {\n  const g = TH.traverseReadonlyNonEmptyArrayWithIndex(S)\n  return (f) => flow(T.traverseReadonlyNonEmptyArrayWithIndex(f), T.map(g(SK)))\n}\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(getApplicative(T.ApplicativePar, S))`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex =\n  <E>(S: Semigroup<E>) =>\n  <A, B>(f: (index: number, a: A) => TaskThese<E, B>): ((as: ReadonlyArray<A>) => TaskThese<E, ReadonlyArray<B>>) => {\n    const g = traverseReadonlyNonEmptyArrayWithIndex(S)(f)\n    return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n  }\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(T.ApplicativeSeq, S))`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndexSeq =\n  <E>(S: Semigroup<E>) =>\n  <A, B>(f: (index: number, a: A) => TaskThese<E, B>) =>\n  (as: ReadonlyNonEmptyArray<A>): TaskThese<E, ReadonlyNonEmptyArray<B>> =>\n  () =>\n    _.tail(as).reduce<Promise<These<E, NonEmptyArray<B>>>>(\n      (acc, a, i) =>\n        acc.then((ebs) =>\n          TH.isLeft(ebs)\n            ? acc\n            : f(i + 1, a)().then((eb) => {\n                if (TH.isLeft(eb)) {\n                  return eb\n                }\n                if (TH.isBoth(eb)) {\n                  const right = ebs.right\n                  right.push(eb.right)\n                  return TH.isBoth(ebs) ? TH.both(S.concat(ebs.left, eb.left), right) : TH.both(eb.left, right)\n                }\n                ebs.right.push(eb.right)\n                return ebs\n              })\n        ),\n      f(0, _.head(as))().then(TH.map(_.singleton))\n    )\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(getApplicative(T.ApplicativeSeq, S))`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndexSeq =\n  <E>(S: Semigroup<E>) =>\n  <A, B>(f: (index: number, a: A) => TaskThese<E, B>): ((as: ReadonlyArray<A>) => TaskThese<E, ReadonlyArray<B>>) => {\n    const g = traverseReadonlyNonEmptyArrayWithIndexSeq(S)(f)\n    return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n  }\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`Functor`](#functor) instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const functorTaskThese: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * Use [`Bifunctor`](#bifunctor) instead.\n *\n * @category zone of death\n * @since 2.7.0\n * @deprecated\n */\nexport const bifunctorTaskThese: Bifunctor2<URI> = {\n  URI,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n\n/**\n * Use [`toTuple2`](#totuple2) instead.\n *\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport const toTuple = <E, A>(e: E, a: A): ((fa: TaskThese<E, A>) => Task<[E, A]>) =>\n  toTuple2(\n    () => e,\n    () => a\n  ) as any\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `TT.Functor` instead of `TT.taskThese`\n * (where `TT` is from `import TT from 'fp-ts/TaskThese'`)\n *\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport const taskThese: Functor2<URI> & Bifunctor2<URI> = {\n  URI,\n  map: _map,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n\n/**\n * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.\n *\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport const getSemigroup = <E, A>(SE: Semigroup<E>, SA: Semigroup<A>): Semigroup<TaskThese<E, A>> =>\n  getApplySemigroup(T.ApplySeq)(TH.getSemigroup(SE, SA))\n"
  },
  {
    "path": "src/These.ts",
    "content": "/**\n * A data structure providing \"inclusive-or\" as opposed to `Either`'s \"exclusive-or\".\n *\n * If 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 *\n * There are a few ways to interpret the both case:\n *\n * - You can think of a computation that has a non-fatal error.\n * - You can think of a computation that went as far as it could before erroring.\n * - You can think of a computation that keeps track of errors as it completes.\n *\n * Another way you can think of `These<E, A>` is saying that we want to handle `E` kind of data, `A` kind of data, or\n * both `E` and `A` kind of data at the same time. This is particularly useful when it comes to displaying UI's.\n *\n * (description adapted from https://package.elm-lang.org/packages/joneshf/elm-these)\n *\n * Adapted from https://github.com/purescript-contrib/purescript-these\n *\n * @since 2.0.0\n */\nimport { Applicative, Applicative2C } from './Applicative'\nimport { Apply2C } from './Apply'\nimport { Bifunctor2 } from './Bifunctor'\nimport { Chain2C } from './Chain'\nimport { Either, Left, Right } from './Either'\nimport { Eq, fromEquals } from './Eq'\nimport { Foldable2 } from './Foldable'\nimport {\n  FromEither2,\n  fromOption as fromOption_,\n  fromOptionK as fromOptionK_,\n  fromPredicate as fromPredicate_\n} from './FromEither'\nimport { FromThese2 } from './FromThese'\nimport { identity, LazyArg, pipe } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\nimport { HKT } from './HKT'\nimport * as _ from './internal'\nimport { Monad2C } from './Monad'\nimport { MonadThrow2C } from './MonadThrow'\nimport { Monoid } from './Monoid'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { Option } from './Option'\nimport { Pointed2 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport { Show } from './Show'\nimport { PipeableTraverse2, Traversable2 } from './Traversable'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.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 2.0.0\n */\nexport type These<E, A> = Either<E, A> | Both<E, A>\n\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n\n/**\n * Returns `true` if the these is an instance of `Left`, `false` otherwise\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isLeft = <E>(fa: These<E, unknown>): fa is Left<E> => fa._tag === 'Left'\n\n/**\n * Returns `true` if the these is an instance of `Right`, `false` otherwise\n *\n * @category refinements\n * @since 2.0.0\n */\nexport const isRight = <A>(fa: These<unknown, A>): fa is Right<A> => fa._tag === 'Right'\n\n/**\n * Returns `true` if the these is an instance of `Both`, `false` otherwise\n *\n * @category refinements\n * @since 2.0.0\n */\nexport function isBoth<E, A>(fa: These<E, A>): fa is Both<E, A> {\n  return fa._tag === 'Both'\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function left<E = never, A = never>(left: E): These<E, A> {\n  return { _tag: 'Left', left }\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function right<E = never, A = never>(right: A): These<E, A> {\n  return { _tag: 'Right', right }\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function both<E, A>(left: E, right: A): These<E, A> {\n  return { _tag: 'Both', left, right }\n}\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW =\n  <E, B, A, C, D>(onLeft: (e: E) => B, onRight: (a: A) => C, onBoth: (e: E, a: A) => D) =>\n  (fa: These<E, A>): B | C | D => {\n    switch (fa._tag) {\n      case 'Left':\n        return onLeft(fa.left)\n      case 'Right':\n        return onRight(fa.right)\n      case 'Both':\n        return onBoth(fa.left, fa.right)\n    }\n  }\n\n/**\n * Alias of [`matchW`](#matchw).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchW\n\n/**\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <E, A, B>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (fa: These<E, A>) => B = matchW\n\n/**\n * Alias of [`match`](#match).\n *\n * @category pattern matching\n * @since 2.0.0\n */\nexport const fold = match\n\n/**\n * @since 2.4.0\n */\nexport const swap: <E, A>(fa: These<E, A>) => These<A, E> = match(right, left, (e, a) => both(a, e))\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getShow<E, A>(SE: Show<E>, SA: Show<A>): Show<These<E, A>> {\n  return {\n    show: match(\n      (l) => `left(${SE.show(l)})`,\n      (a) => `right(${SA.show(a)})`,\n      (l, a) => `both(${SE.show(l)}, ${SA.show(a)})`\n    )\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getEq<E, A>(EE: Eq<E>, EA: Eq<A>): Eq<These<E, A>> {\n  return fromEquals((x, y) =>\n    isLeft(x)\n      ? isLeft(y) && EE.equals(x.left, y.left)\n      : isRight(x)\n      ? isRight(y) && EA.equals(x.right, y.right)\n      : isBoth(y) && EE.equals(x.left, y.left) && EA.equals(x.right, y.right)\n  )\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getSemigroup<E, A>(SE: Semigroup<E>, SA: Semigroup<A>): Semigroup<These<E, A>> {\n  return {\n    concat: (x, y) =>\n      isLeft(x)\n        ? isLeft(y)\n          ? left(SE.concat(x.left, y.left))\n          : isRight(y)\n          ? both(x.left, y.right)\n          : both(SE.concat(x.left, y.left), y.right)\n        : isRight(x)\n        ? isLeft(y)\n          ? both(y.left, x.right)\n          : isRight(y)\n          ? right(SA.concat(x.right, y.right))\n          : both(y.left, SA.concat(x.right, y.right))\n        : isLeft(y)\n        ? both(SE.concat(x.left, y.left), x.right)\n        : isRight(y)\n        ? both(x.left, SA.concat(x.right, y.right))\n        : both(SE.concat(x.left, y.left), SA.concat(x.right, y.right))\n  }\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getApply = <E>(S: Semigroup<E>): Apply2C<URI, E> => ({\n  URI,\n  _E: undefined as any,\n  map: _map,\n  ap: (fab, fa) =>\n    isLeft(fab)\n      ? isLeft(fa)\n        ? left(S.concat(fab.left, fa.left))\n        : isRight(fa)\n        ? left(fab.left)\n        : left(S.concat(fab.left, fa.left))\n      : isRight(fab)\n      ? isLeft(fa)\n        ? left(fa.left)\n        : isRight(fa)\n        ? right(fab.right(fa.right))\n        : both(fa.left, fab.right(fa.right))\n      : isLeft(fa)\n      ? left(S.concat(fab.left, fa.left))\n      : isRight(fa)\n      ? both(fab.left, fab.right(fa.right))\n      : both(S.concat(fab.left, fa.left), fab.right(fa.right))\n})\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport function getApplicative<E>(S: Semigroup<E>): Applicative2C<URI, E> {\n  const A = getApply(S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: A.ap,\n    of\n  }\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport function getChain<E>(S: Semigroup<E>): Chain2C<URI, E> {\n  const A = getApply(S)\n\n  const chain = <A, B>(ma: These<E, A>, f: (a: A) => These<E, B>): These<E, B> => {\n    if (isLeft(ma)) {\n      return ma\n    }\n    if (isRight(ma)) {\n      return f(ma.right)\n    }\n    const fb = f(ma.right)\n    return isLeft(fb)\n      ? left(S.concat(ma.left, fb.left))\n      : isRight(fb)\n      ? both(ma.left, fb.right)\n      : both(S.concat(ma.left, fb.left), fb.right)\n  }\n\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: A.ap,\n    chain\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getMonad<E>(S: Semigroup<E>): Monad2C<URI, E> & MonadThrow2C<URI, E> {\n  const C = getChain(S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    of,\n    ap: C.ap,\n    chain: C.chain,\n    throwError: left\n  }\n}\n\n/**\n * Returns an `E` value if possible\n *\n * @example\n * import { getLeft, left, right, both } from 'fp-ts/These'\n * import { none, some } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(getLeft(left('a')), some('a'))\n * assert.deepStrictEqual(getLeft(right(1)), none)\n * assert.deepStrictEqual(getLeft(both('a', 1)), some('a'))\n *\n * @category conversions\n * @since 2.0.0\n */\nexport function getLeft<E, A>(fa: These<E, A>): Option<E> {\n  return isLeft(fa) ? _.some(fa.left) : isRight(fa) ? _.none : _.some(fa.left)\n}\n\n/**\n * Returns an `A` value if possible\n *\n * @example\n * import { getRight, left, right, both } from 'fp-ts/These'\n * import { none, some } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(getRight(left('a')), none)\n * assert.deepStrictEqual(getRight(right(1)), some(1))\n * assert.deepStrictEqual(getRight(both('a', 1)), some(1))\n *\n * @category conversions\n * @since 2.0.0\n */\nexport function getRight<E, A>(fa: These<E, A>): Option<A> {\n  return isLeft(fa) ? _.none : isRight(fa) ? _.some(fa.right) : _.some(fa.right)\n}\n\n// TODO: make lazy in v3\n/**\n * @example\n * import { leftOrBoth, left, both } from 'fp-ts/These'\n * import { none, some } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(leftOrBoth('a')(none), left('a'))\n * assert.deepStrictEqual(leftOrBoth('a')(some(1)), both('a', 1))\n *\n * @category constructors\n * @since 2.0.0\n */\nexport function leftOrBoth<E>(e: E): <A>(ma: Option<A>) => These<E, A> {\n  return (ma) => (_.isNone(ma) ? left(e) : both(e, ma.value))\n}\n\n// TODO: make lazy in v3\n/**\n * @example\n * import { rightOrBoth, right, both } from 'fp-ts/These'\n * import { none, some } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(rightOrBoth(1)(none), right(1))\n * assert.deepStrictEqual(rightOrBoth(1)(some('a')), both('a', 1))\n *\n * @category constructors\n * @since 2.0.0\n */\nexport function rightOrBoth<A>(a: A): <E>(me: Option<E>) => These<E, A> {\n  return (me) => (_.isNone(me) ? right(a) : both(me.value, a))\n}\n\n/**\n * Returns the `E` value if and only if the value is constructed with `Left`\n *\n * @example\n * import { getLeftOnly, left, right, both } from 'fp-ts/These'\n * import { none, some } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(getLeftOnly(left('a')), some('a'))\n * assert.deepStrictEqual(getLeftOnly(right(1)), none)\n * assert.deepStrictEqual(getLeftOnly(both('a', 1)), none)\n *\n * @category conversions\n * @since 2.0.0\n */\nexport function getLeftOnly<E, A>(fa: These<E, A>): Option<E> {\n  return isLeft(fa) ? _.some(fa.left) : _.none\n}\n\n/**\n * Returns the `A` value if and only if the value is constructed with `Right`\n *\n * @example\n * import { getRightOnly, left, right, both } from 'fp-ts/These'\n * import { none, some } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(getRightOnly(left('a')), none)\n * assert.deepStrictEqual(getRightOnly(right(1)), some(1))\n * assert.deepStrictEqual(getRightOnly(both('a', 1)), none)\n *\n * @category conversions\n * @since 2.0.0\n */\nexport function getRightOnly<E, A>(fa: These<E, A>): Option<A> {\n  return isRight(fa) ? _.some(fa.right) : _.none\n}\n\n/**\n * Takes a pair of `Option`s and attempts to create a `These` from them\n *\n * @example\n * import { fromOptions, left, right, both } from 'fp-ts/These'\n * import { none, some } from 'fp-ts/Option'\n *\n * assert.deepStrictEqual(fromOptions(none, none), none)\n * assert.deepStrictEqual(fromOptions(some('a'), none), some(left('a')))\n * assert.deepStrictEqual(fromOptions(none, some(1)), some(right(1)))\n * assert.deepStrictEqual(fromOptions(some('a'), some(1)), some(both('a', 1)))\n *\n * @category conversions\n * @since 2.0.0\n */\nexport const fromOptions = <E, A>(fe: Option<E>, fa: Option<A>): Option<These<E, A>> =>\n  _.isNone(fe)\n    ? _.isNone(fa)\n      ? _.none\n      : _.some(right(fa.value))\n    : _.isNone(fa)\n    ? _.some(left(fe.value))\n    : _.some(both(fe.value, fa.value))\n\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\n/* istanbul ignore next */\nconst _bimap: Bifunctor2<URI>['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g))\n/* istanbul ignore next */\nconst _mapLeft: Bifunctor2<URI>['mapLeft'] = (fa, f) => pipe(fa, mapLeft(f))\n/* istanbul ignore next */\nconst _reduce: Foldable2<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\n/* istanbul ignore next */\nconst _foldMap: Foldable2<URI>['foldMap'] = (M) => {\n  const foldMapM = foldMap(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\n/* istanbul ignore next */\nconst _reduceRight: Foldable2<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\n/* istanbul ignore next */\nconst _traverse = <F>(\n  F: Applicative<F>\n): (<E, A, B>(ta: These<E, A>, f: (a: A) => HKT<F, B>) => HKT<F, These<E, B>>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\n\n/**\n * Map a pair of functions over the two type arguments of the bifunctor.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: These<E, A>) => These<G, B> = (f, g) => (fa) =>\n  isLeft(fa) ? left(f(fa.left)) : isRight(fa) ? right(g(fa.right)) : both(f(fa.left), g(fa.right))\n\n/**\n * Map a function over the first type argument of a bifunctor.\n *\n * @category error handling\n * @since 2.0.0\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: These<E, A>) => These<G, A> = (f) => (fa) =>\n  isLeft(fa) ? left(f(fa.left)) : isBoth(fa) ? both(f(fa.left), fa.right) : fa\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: These<E, A>) => These<E, B> = (f) => (fa) =>\n  isLeft(fa) ? fa : isRight(fa) ? right(f(fa.right)) : both(fa.left, f(fa.right))\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: These<E, A>) => B = (b, f) => (fa) =>\n  isLeft(fa) ? b : f(b, fa.right)\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: These<E, A>) => M = (M) => (f) => (fa) =>\n  isLeft(fa) ? M.empty : f(fa.right)\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: These<E, A>) => B = (b, f) => (fa) =>\n  isLeft(fa) ? b : f(fa.right, b)\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse2<URI> =\n  <F>(F: Applicative<F>): (<A, B>(f: (a: A) => HKT<F, B>) => <E>(ta: These<E, A>) => HKT<F, These<E, B>>) =>\n  (f) =>\n  (ta) =>\n    isLeft(ta) ? F.of(ta) : isRight(ta) ? F.map(f(ta.right), right) : F.map(f(ta.right), (b) => both(ta.left, b))\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable2<URI>['sequence'] =\n  <F>(F: Applicative<F>) =>\n  <E, A>(ta: These<E, HKT<F, A>>): HKT<F, These<E, A>> => {\n    return isLeft(ta) ? F.of(ta) : isRight(ta) ? F.map(ta.right, right) : F.map(ta.right, (b) => both(ta.left, b))\n  }\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport const of: <E = never, A = never>(right: A) => These<E, A> = right\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'These'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: These<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed2<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor2<URI> = {\n  URI,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const FromThese: FromThese2<URI> = {\n  URI,\n  fromThese: identity\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable2<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable2<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const FromEither: FromEither2<URI> = {\n  URI,\n  fromEither: identity\n}\n\n/**\n * @category lifting\n * @since 2.13.0\n */\nexport const fromPredicate: {\n  <A, B extends A, E>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => These<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => These<E, B>\n  <A, E>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => These<E, A>\n} = /*#__PURE__*/ fromPredicate_(FromEither)\n\n/**\n * @category conversions\n * @since 2.10.0\n */\nexport const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => These<E, A> =\n  /*#__PURE__*/ fromOption_(FromEither)\n\n/**\n * @category lifting\n * @since 2.10.0\n */\nexport const fromOptionK: <E>(\n  onNone: LazyArg<E>\n) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => These<E, B> =\n  /*#__PURE__*/ fromOptionK_(FromEither)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport const elem =\n  <A>(E: Eq<A>) =>\n  (a: A) =>\n  <E>(ma: These<E, A>): boolean =>\n    isLeft(ma) ? false : E.equals(a, ma.right)\n\n/**\n * @since 2.11.0\n */\nexport const exists =\n  <A>(predicate: Predicate<A>) =>\n  (ma: These<unknown, A>): boolean =>\n    isLeft(ma) ? false : predicate(ma.right)\n\n/**\n * @example\n * import { toTuple2, left, right, both } from 'fp-ts/These'\n *\n * assert.deepStrictEqual(toTuple2(() => 'a', () => 1)(left('b')), ['b', 1])\n * assert.deepStrictEqual(toTuple2(() => 'a', () => 1)(right(2)), ['a', 2])\n * assert.deepStrictEqual(toTuple2(() => 'a', () => 1)(both('b', 2)), ['b', 2])\n *\n * @category conversions\n * @since 2.10.0\n */\nexport const toTuple2 =\n  <E, A>(e: LazyArg<E>, a: LazyArg<A>) =>\n  (fa: These<E, A>): readonly [E, A] =>\n    isLeft(fa) ? [fa.left, a()] : isRight(fa) ? [e(), fa.right] : [fa.left, fa.right]\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`toTuple2`](#totuple2) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const toTuple = <E, A>(e: E, a: A): ((fa: These<E, A>) => [E, A]) =>\n  toTuple2(\n    () => e,\n    () => a\n  ) as any\n\n/**\n * @since 2.11.0\n */\nexport const ApT: These<never, readonly []> = /*#__PURE__*/ of(_.emptyReadonlyArray)\n\n// -------------------------------------------------------------------------------------\n// array utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(getApplicative(S))`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyNonEmptyArrayWithIndex =\n  <E>(S: Semigroup<E>) =>\n  <A, B>(f: (index: number, a: A) => These<E, B>) =>\n  (as: ReadonlyNonEmptyArray<A>): These<E, ReadonlyNonEmptyArray<B>> => {\n    let e: Option<E> = _.none\n    const t = f(0, _.head(as))\n    if (isLeft(t)) {\n      return t\n    }\n    if (isBoth(t)) {\n      e = _.some(t.left)\n    }\n    const out: NonEmptyArray<B> = [t.right]\n    for (let i = 1; i < as.length; i++) {\n      const t = f(i, as[i])\n      if (isLeft(t)) {\n        return t\n      }\n      if (isBoth(t)) {\n        e = _.isNone(e) ? _.some(t.left) : _.some(S.concat(e.value, t.left))\n      }\n      out.push(t.right)\n    }\n    return _.isNone(e) ? right(out) : both(e.value, out)\n  }\n\n/**\n * Equivalent to `ReadonlyArray#traverseWithIndex(getApplicative(S))`.\n *\n * @category traversing\n * @since 2.11.0\n */\nexport const traverseReadonlyArrayWithIndex =\n  <E>(S: Semigroup<E>) =>\n  <A, B>(f: (index: number, a: A) => These<E, B>): ((as: ReadonlyArray<A>) => These<E, ReadonlyArray<B>>) => {\n    const g = traverseReadonlyNonEmptyArrayWithIndex(S)(f)\n    return (as) => (_.isNonEmpty(as) ? g(as) : ApT)\n  }\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.these`\n * (where `T` is from `import T from 'fp-ts/These'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const these: Functor2<URI> & Bifunctor2<URI> & Foldable2<URI> & Traversable2<URI> = {\n  URI,\n  map: _map,\n  bimap: _bimap,\n  mapLeft: _mapLeft,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n"
  },
  {
    "path": "src/TheseT.ts",
    "content": "/**\n * @since 2.4.0\n */\nimport { ap as ap_, Apply, Apply1, Apply2, Apply2C, Apply3, Apply3C } from './Apply'\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C } from './Chain'\nimport { flow, LazyArg, pipe } from './function'\nimport { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C, map as map_ } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'\nimport { Monad, Monad1, Monad2, Monad2C, Monad3, Monad3C } from './Monad'\nimport { Pointed, Pointed1, Pointed2, Pointed2C, Pointed3, Pointed3C } from './Pointed'\nimport { Semigroup } from './Semigroup'\nimport * as T from './These'\n\nimport These = T.These\n\n/**\n * @since 2.10.0\n */\nexport function right<F extends URIS3>(F: Pointed3<F>): <A, R, FE, E = never>(a: A) => Kind3<F, R, FE, These<E, A>>\nexport function right<F extends URIS3, FE>(F: Pointed3C<F, FE>): <A, R, E = never>(a: A) => Kind3<F, R, FE, These<E, A>>\nexport function right<F extends URIS2>(F: Pointed2<F>): <A, FE, E = never>(a: A) => Kind2<F, FE, These<E, A>>\nexport function right<F extends URIS2, FE>(F: Pointed2C<F, FE>): <A, E = never>(a: A) => Kind2<F, FE, These<E, A>>\nexport function right<F extends URIS>(F: Pointed1<F>): <A, E = never>(a: A) => Kind<F, These<E, A>>\nexport function right<F>(F: Pointed<F>): <A, E = never>(a: A) => HKT<F, These<E, A>>\nexport function right<F>(F: Pointed<F>): <A, E = never>(a: A) => HKT<F, These<E, A>> {\n  return flow(T.right, F.of)\n}\n\n/**\n * @since 2.10.0\n */\nexport function left<F extends URIS3>(F: Pointed3<F>): <E, R, FE, A = never>(e: E) => Kind3<F, R, FE, These<E, A>>\nexport function left<F extends URIS3, FE>(F: Pointed3C<F, FE>): <E, R, A = never>(e: E) => Kind3<F, R, FE, These<E, A>>\nexport function left<F extends URIS2>(F: Pointed2<F>): <E, FE, A = never>(e: E) => Kind2<F, FE, These<E, A>>\nexport function left<F extends URIS2, FE>(F: Pointed2C<F, FE>): <E, A = never>(e: E) => Kind2<F, FE, These<E, A>>\nexport function left<F extends URIS>(F: Pointed1<F>): <E, A = never>(e: E) => Kind<F, These<E, A>>\nexport function left<F>(F: Pointed<F>): <E, A = never>(e: E) => HKT<F, These<E, A>>\nexport function left<F>(F: Pointed<F>): <E, A = never>(e: E) => HKT<F, These<E, A>> {\n  return flow(T.left, F.of)\n}\n\n/**\n * @since 2.10.0\n */\nexport function both<F extends URIS3>(F: Pointed3<F>): <E, A, S, R>(e: E, a: A) => Kind3<F, S, R, These<E, A>>\nexport function both<F extends URIS3, R>(F: Pointed3C<F, R>): <E, A>(e: E, a: A) => Kind3<F, R, R, These<E, A>>\nexport function both<F extends URIS2>(F: Pointed2<F>): <E, A, R>(e: E, a: A) => Kind2<F, R, These<E, A>>\nexport function both<F extends URIS2, R>(F: Pointed2C<F, R>): <E, A>(e: E, a: A) => Kind2<F, R, These<E, A>>\nexport function both<F extends URIS>(F: Pointed1<F>): <E, A>(e: E, a: A) => Kind<F, These<E, A>>\nexport function both<F>(F: Pointed<F>): <E, A = never>(e: E, a: A) => HKT<F, These<E, A>>\nexport function both<F>(F: Pointed<F>): <E, A = never>(e: E, a: A) => HKT<F, These<E, A>> {\n  return flow(T.both, F.of)\n}\n\n/**\n * @since 2.10.0\n */\nexport function rightF<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, These<E, A>>\nexport function rightF<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, A, E = never>(fa: Kind3<F, R, FE, A>) => Kind3<F, R, FE, These<E, A>>\nexport function rightF<F extends URIS2>(\n  F: Functor2<F>\n): <FE, A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, These<E, A>>\nexport function rightF<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, E = never>(fa: Kind2<F, FE, A>) => Kind2<F, FE, These<E, A>>\nexport function rightF<F extends URIS>(F: Functor1<F>): <A, E = never>(fa: Kind<F, A>) => Kind<F, These<E, A>>\nexport function rightF<F>(F: Functor<F>): <A, E = never>(fa: HKT<F, A>) => HKT<F, These<E, A>>\nexport function rightF<F>(F: Functor<F>): <A, E = never>(fa: HKT<F, A>) => HKT<F, These<E, A>> {\n  return (fa) => F.map(fa, T.right)\n}\n\n/**\n * @since 2.10.0\n */\nexport function leftF<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, These<E, A>>\nexport function leftF<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A = never>(fe: Kind3<F, R, FE, E>) => Kind3<F, R, FE, These<E, A>>\nexport function leftF<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, These<E, A>>\nexport function leftF<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A = never>(fe: Kind2<F, FE, E>) => Kind2<F, FE, These<E, A>>\nexport function leftF<F extends URIS>(F: Functor1<F>): <E, A = never>(fe: Kind<F, E>) => Kind<F, These<E, A>>\nexport function leftF<F>(F: Functor<F>): <E, A = never>(fe: HKT<F, E>) => HKT<F, These<E, A>>\nexport function leftF<F>(F: Functor<F>): <E, A = never>(fe: HKT<F, E>) => HKT<F, These<E, A>> {\n  return (fe) => F.map(fe, T.left)\n}\n\n/**\n * @since 2.10.0\n */\nexport function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, FE, E>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<E, B>>\nexport function map<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<E, B>>\nexport function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <FE, E>(fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<E, B>>\nexport function map<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<E, B>>\nexport function map<F extends URIS>(\n  F: Functor1<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind<F, These<E, A>>) => Kind<F, These<E, B>>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, These<E, A>>) => HKT<F, These<E, B>>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => <E>(fa: HKT<F, These<E, A>>) => HKT<F, These<E, B>> {\n  return map_(F, T.Functor)\n}\n\n/**\n * @since 2.10.0\n */\nexport function ap<F extends URIS3, E>(\n  F: Apply3<F>,\n  S: Semigroup<E>\n): <R, FE, A>(\n  fa: Kind3<F, R, FE, These<E, A>>\n) => <B>(fab: Kind3<F, R, FE, These<E, (a: A) => B>>) => Kind3<F, R, FE, These<E, B>>\nexport function ap<F extends URIS3, FE, E>(\n  F: Apply3C<F, FE>,\n  S: Semigroup<E>\n): <R, A>(\n  fa: Kind3<F, R, FE, These<E, A>>\n) => <B>(fab: Kind3<F, R, FE, These<E, (a: A) => B>>) => Kind3<F, R, FE, These<E, B>>\nexport function ap<F extends URIS2, E>(\n  F: Apply2<F>,\n  S: Semigroup<E>\n): <FE, A>(fa: Kind2<F, FE, These<E, A>>) => <B>(fab: Kind2<F, FE, These<E, (a: A) => B>>) => Kind2<F, FE, These<E, B>>\nexport function ap<F extends URIS2, FE, E>(\n  F: Apply2C<F, FE>,\n  S: Semigroup<E>\n): <A>(fa: Kind2<F, FE, These<E, A>>) => <B>(fab: Kind2<F, FE, These<E, (a: A) => B>>) => Kind2<F, FE, These<E, B>>\nexport function ap<F extends URIS, E>(\n  F: Apply1<F>,\n  S: Semigroup<E>\n): <A>(fa: Kind<F, These<E, A>>) => <B>(fab: Kind<F, These<E, (a: A) => B>>) => Kind<F, These<E, B>>\nexport function ap<F, E>(\n  F: Apply<F>,\n  S: Semigroup<E>\n): <A>(fa: HKT<F, These<E, A>>) => <B>(fab: HKT<F, These<E, (a: A) => B>>) => HKT<F, These<E, B>>\nexport function ap<F, E>(\n  F: Apply<F>,\n  S: Semigroup<E>\n): <A>(fa: HKT<F, These<E, A>>) => <B>(fab: HKT<F, These<E, (a: A) => B>>) => HKT<F, These<E, B>> {\n  return ap_(F, T.getApply(S))\n}\n\n/**\n * @since 2.10.0\n */\nexport function chain<M extends URIS3, E>(\n  M: Monad3<M>,\n  S: Semigroup<E>\n): <A, R, ME, B>(\n  f: (a: A) => Kind3<M, R, ME, These<E, B>>\n) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, These<E, B>>\nexport function chain<M extends URIS3, ME, E>(\n  M: Monad3C<M, ME>,\n  S: Semigroup<E>\n): <A, R, B>(\n  f: (a: A) => Kind3<M, R, ME, These<E, B>>\n) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, These<E, B>>\nexport function chain<M extends URIS2, E>(\n  M: Monad2<M>,\n  S: Semigroup<E>\n): <A, ME, B>(f: (a: A) => Kind2<M, ME, These<E, B>>) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, These<E, B>>\nexport function chain<M extends URIS2, ME, E>(\n  M: Monad2C<M, ME>,\n  S: Semigroup<E>\n): <A, B>(f: (a: A) => Kind2<M, ME, These<E, B>>) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, These<E, B>>\nexport function chain<M extends URIS, E>(\n  M: Monad1<M>,\n  S: Semigroup<E>\n): <A, B>(f: (a: A) => Kind<M, These<E, B>>) => (ma: Kind<M, These<E, A>>) => Kind<M, These<E, B>>\nexport function chain<M, E>(\n  M: Monad<M>,\n  S: Semigroup<E>\n): <A, B>(f: (a: A) => HKT<M, These<E, B>>) => (ma: HKT<M, These<E, A>>) => HKT<M, These<E, B>>\nexport function chain<M, E>(\n  M: Monad<M>,\n  S: Semigroup<E>\n): <A, B>(f: (a: A) => HKT<M, These<E, B>>) => (ma: HKT<M, These<E, A>>) => HKT<M, These<E, B>> {\n  const _left = left(M)\n  return (f) => (ma) =>\n    M.chain(\n      ma,\n      T.match(_left, f, (e1, a) =>\n        M.map(\n          f(a),\n          T.match(\n            (e2) => T.left(S.concat(e1, e2)),\n            (b) => T.both(e1, b),\n            (e2, b) => T.both(S.concat(e1, e2), b)\n          )\n        )\n      )\n    )\n}\n\n/**\n * @since 2.10.0\n */\nexport function bimap<F extends URIS3>(\n  F: Functor3<F>\n): <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R, FE>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, B>>\nexport function bimap<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, G, A, B>(\n  f: (e: E) => G,\n  g: (a: A) => B\n) => <R>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, B>>\nexport function bimap<F extends URIS2>(\n  F: Functor2<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <FE>(fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, B>>\nexport function bimap<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, B>>\nexport function bimap<F extends URIS>(\n  F: Functor1<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind<F, These<E, A>>) => Kind<F, These<G, B>>\nexport function bimap<F>(\n  F: Functor<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: HKT<F, These<E, A>>) => HKT<F, These<G, B>>\nexport function bimap<F>(\n  F: Functor<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: HKT<F, These<E, A>>) => HKT<F, These<G, B>> {\n  return (f, g) => (fea) => F.map(fea, T.bimap(f, g))\n}\n\n/**\n * @since 2.10.0\n */\nexport function mapLeft<F extends URIS3>(\n  F: Functor3<F>\n): <E, G>(f: (e: E) => G) => <R, FE, A>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, A>>\nexport function mapLeft<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, G>(f: (e: E) => G) => <R, A>(fea: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<G, A>>\nexport function mapLeft<F extends URIS2>(\n  F: Functor2<F>\n): <E, G>(f: (e: E) => G) => <FE, A>(fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, A>>\nexport function mapLeft<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, G>(f: (e: E) => G) => <A>(fea: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<G, A>>\nexport function mapLeft<F extends URIS>(\n  F: Functor1<F>\n): <E, G>(f: (e: E) => G) => <A>(fea: Kind<F, These<E, A>>) => Kind<F, These<G, A>>\nexport function mapLeft<F>(\n  F: Functor<F>\n): <E, G>(f: (e: E) => G) => <A>(fea: HKT<F, These<E, A>>) => HKT<F, These<G, A>>\nexport function mapLeft<F>(\n  F: Functor<F>\n): <E, G>(f: (e: E) => G) => <A>(fea: HKT<F, These<E, A>>) => HKT<F, These<G, A>> {\n  return (f) => (fea) => F.map(fea, T.mapLeft(f))\n}\n\n/**\n * @since 2.10.0\n */\nexport function match<F extends URIS3>(\n  F: Functor3<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => <S, R>(ma: Kind3<F, S, R, These<E, A>>) => Kind3<F, S, R, B>\nexport function match<F extends URIS3, R>(\n  F: Functor3C<F, R>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => <S>(ma: Kind3<F, S, R, These<E, A>>) => Kind3<F, S, R, B>\nexport function match<F extends URIS2>(\n  F: Functor2<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => <R>(ma: Kind2<F, R, These<E, A>>) => Kind2<F, R, B>\nexport function match<M extends URIS2, R>(\n  F: Functor2C<M, R>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (ma: Kind2<M, R, These<E, A>>) => Kind2<M, R, B>\nexport function match<F extends URIS>(\n  F: Functor1<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (ma: Kind<F, These<E, A>>) => Kind<F, B>\nexport function match<F>(\n  F: Functor<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (ma: HKT<F, These<E, A>>) => HKT<F, B>\nexport function match<F>(\n  F: Functor<F>\n): <E, B, A>(\n  onLeft: (e: E) => B,\n  onRight: (a: A) => B,\n  onBoth: (e: E, a: A) => B\n) => (ma: HKT<F, These<E, A>>) => HKT<F, B> {\n  return (onLeft, onRight, onBoth) => (ma) => F.map(ma, T.match(onLeft, onRight, onBoth))\n}\n\n/**\n * @since 2.10.0\n */\nexport function matchE<M extends URIS3>(\n  M: Chain3<M>\n): <E, R, ME, B, A>(\n  onLeft: (e: E) => Kind3<M, R, ME, B>,\n  onRight: (a: A) => Kind3<M, R, ME, B>,\n  onBoth: (e: E, a: A) => Kind3<M, R, ME, B>\n) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, B>\nexport function matchE<M extends URIS3, ME>(\n  M: Chain3C<M, ME>\n): <E, R, B, A>(\n  onLeft: (e: E) => Kind3<M, R, ME, B>,\n  onRight: (a: A) => Kind3<M, R, ME, B>,\n  onBoth: (e: E, a: A) => Kind3<M, R, ME, B>\n) => (ma: Kind3<M, R, ME, These<E, A>>) => Kind3<M, R, ME, B>\nexport function matchE<M extends URIS2>(\n  M: Chain2<M>\n): <E, ME, B, A>(\n  onLeft: (e: E) => Kind2<M, ME, B>,\n  onRight: (a: A) => Kind2<M, ME, B>,\n  onBoth: (e: E, a: A) => Kind2<M, ME, B>\n) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, B>\nexport function matchE<M extends URIS2, ME>(\n  M: Chain2C<M, ME>\n): <E, B, A>(\n  onLeft: (e: E) => Kind2<M, ME, B>,\n  onRight: (a: A) => Kind2<M, ME, B>,\n  onBoth: (e: E, a: A) => Kind2<M, ME, B>\n) => (ma: Kind2<M, ME, These<E, A>>) => Kind2<M, ME, B>\nexport function matchE<M extends URIS>(\n  M: Chain1<M>\n): <E, B, A>(\n  onLeft: (e: E) => Kind<M, B>,\n  onRight: (a: A) => Kind<M, B>,\n  onBoth: (e: E, a: A) => Kind<M, B>\n) => (ma: Kind<M, These<E, A>>) => Kind<M, B>\nexport function matchE<M>(\n  M: Chain<M>\n): <E, B, A>(\n  onLeft: (e: E) => HKT<M, B>,\n  onRight: (a: A) => HKT<M, B>,\n  onBoth: (e: E, a: A) => HKT<M, B>\n) => (ma: HKT<M, These<E, A>>) => HKT<M, B>\nexport function matchE<M>(\n  M: Chain<M>\n): <E, B, A>(\n  onLeft: (e: E) => HKT<M, B>,\n  onRight: (a: A) => HKT<M, B>,\n  onBoth: (e: E, a: A) => HKT<M, B>\n) => (ma: HKT<M, These<E, A>>) => HKT<M, B> {\n  return (onLeft, onRight, onBoth) => (ma) => M.chain(ma, T.match(onLeft, onRight, onBoth))\n}\n\n/**\n * @since 2.10.0\n */\nexport function swap<F extends URIS3>(\n  F: Functor3<F>\n): <R, FE, E, A>(ma: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<A, E>>\nexport function swap<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <R, E, A>(ma: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, These<A, E>>\nexport function swap<F extends URIS2>(\n  F: Functor2<F>\n): <FE, E, A>(ma: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<A, E>>\nexport function swap<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A>(ma: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, These<A, E>>\nexport function swap<F extends URIS>(F: Functor1<F>): <E, A>(ma: Kind<F, These<E, A>>) => Kind<F, These<A, E>>\nexport function swap<F>(F: Functor<F>): <E, A>(ma: HKT<F, These<E, A>>) => HKT<F, These<A, E>>\nexport function swap<F>(F: Functor<F>): <E, A>(ma: HKT<F, These<E, A>>) => HKT<F, These<A, E>> {\n  return (ma) => F.map(ma, T.swap)\n}\n\n/**\n * @since 2.10.0\n */\nexport function toTuple2<F extends URIS3>(\n  F: Functor3<F>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => <R, FE>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, readonly [E, A]>\nexport function toTuple2<F extends URIS3, FE>(\n  F: Functor3C<F, FE>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => <R>(fa: Kind3<F, R, FE, These<E, A>>) => Kind3<F, R, FE, readonly [E, A]>\nexport function toTuple2<F extends URIS2>(\n  F: Functor2<F>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => <FE>(fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, readonly [E, A]>\nexport function toTuple2<F extends URIS2, FE>(\n  F: Functor2C<F, FE>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: Kind2<F, FE, These<E, A>>) => Kind2<F, FE, readonly [E, A]>\nexport function toTuple2<F extends URIS>(\n  F: Functor1<F>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: Kind<F, These<E, A>>) => Kind<F, readonly [E, A]>\nexport function toTuple2<F>(\n  F: Functor<F>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: HKT<F, These<E, A>>) => HKT<F, readonly [E, A]>\nexport function toTuple2<F>(\n  F: Functor<F>\n): <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: HKT<F, These<E, A>>) => HKT<F, readonly [E, A]> {\n  return (e, a) => (fa) => F.map(fa, T.toTuple2(e, a))\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport interface TheseT<M, E, A> extends HKT<M, These<E, A>> {}\n\n/**\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport interface TheseM<M> {\n  readonly map: <E, A, B>(fa: TheseT<M, E, A>, f: (a: A) => B) => TheseT<M, E, B>\n  readonly bimap: <E, A, N, B>(fa: TheseT<M, E, A>, f: (e: E) => N, g: (a: A) => B) => TheseT<M, N, B>\n  readonly mapLeft: <E, A, N>(fa: TheseT<M, E, A>, f: (e: E) => N) => TheseT<M, N, A>\n  readonly fold: <E, A, R>(\n    fa: TheseT<M, E, A>,\n    onLeft: (e: E) => HKT<M, R>,\n    onRight: (a: A) => HKT<M, R>,\n    onBoth: (e: E, a: A) => HKT<M, R>\n  ) => HKT<M, R>\n  readonly swap: <E, A>(fa: TheseT<M, E, A>) => TheseT<M, A, E>\n  readonly rightM: <E, A>(ma: HKT<M, A>) => TheseT<M, E, A>\n  readonly leftM: <E, A>(me: HKT<M, E>) => TheseT<M, E, A>\n  readonly left: <E, A>(e: E) => TheseT<M, E, A>\n  readonly right: <E, A>(a: A) => TheseT<M, E, A>\n  readonly both: <E, A>(e: E, a: A) => TheseT<M, E, A>\n  readonly toTuple: <E, A>(fa: TheseT<M, E, A>, e: E, a: A) => HKT<M, [E, A]>\n  readonly getMonad: <E>(S: Semigroup<E>) => {\n    readonly _E: E\n    readonly map: <A, B>(ma: TheseT<M, E, A>, f: (a: A) => B) => TheseT<M, E, B>\n    readonly of: <A>(a: A) => TheseT<M, E, A>\n    readonly ap: <A, B>(mab: TheseT<M, E, (a: A) => B>, ma: TheseT<M, E, A>) => TheseT<M, E, B>\n    readonly chain: <A, B>(ma: TheseT<M, E, A>, f: (a: A) => TheseT<M, E, B>) => TheseT<M, E, B>\n  }\n}\n\n/**\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport type TheseT1<M extends URIS, E, A> = Kind<M, These<E, A>>\n\n/**\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport interface TheseM1<M extends URIS> {\n  readonly map: <E, A, B>(fa: TheseT1<M, E, A>, f: (a: A) => B) => TheseT1<M, E, B>\n  readonly bimap: <E, A, N, B>(fa: TheseT1<M, E, A>, f: (e: E) => N, g: (a: A) => B) => TheseT1<M, N, B>\n  readonly mapLeft: <E, A, N>(fa: TheseT1<M, E, A>, f: (e: E) => N) => TheseT1<M, N, A>\n  readonly fold: <E, A, R>(\n    fa: TheseT1<M, E, A>,\n    onLeft: (e: E) => Kind<M, R>,\n    onRight: (a: A) => Kind<M, R>,\n    onBoth: (e: E, a: A) => Kind<M, R>\n  ) => Kind<M, R>\n  readonly swap: <E, A>(fa: TheseT1<M, E, A>) => TheseT1<M, A, E>\n  readonly rightM: <E, A>(ma: Kind<M, A>) => TheseT1<M, E, A>\n  readonly leftM: <E, A>(me: Kind<M, E>) => TheseT1<M, E, A>\n  readonly left: <E, A>(e: E) => TheseT1<M, E, A>\n  readonly right: <E, A>(a: A) => TheseT1<M, E, A>\n  readonly both: <E, A>(e: E, a: A) => TheseT1<M, E, A>\n  readonly toTuple: <E, A>(fa: TheseT1<M, E, A>, e: E, a: A) => Kind<M, [E, A]>\n  readonly getMonad: <E>(S: Semigroup<E>) => {\n    readonly _E: E\n    readonly map: <A, B>(ma: TheseT1<M, E, A>, f: (a: A) => B) => TheseT1<M, E, B>\n    readonly of: <A>(a: A) => TheseT1<M, E, A>\n    readonly ap: <A, B>(mab: TheseT1<M, E, (a: A) => B>, ma: TheseT1<M, E, A>) => TheseT1<M, E, B>\n    readonly chain: <A, B>(ma: TheseT1<M, E, A>, f: (a: A) => TheseT1<M, E, B>) => TheseT1<M, E, B>\n  }\n}\n\n/**\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport type TheseT2<M extends URIS2, R, E, A> = Kind2<M, R, These<E, A>>\n\n/**\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport interface TheseM2<M extends URIS2> {\n  readonly map: <R, E, A, B>(fa: TheseT2<M, R, E, A>, f: (a: A) => B) => TheseT2<M, R, E, B>\n  readonly bimap: <R, E, A, N, B>(fa: TheseT2<M, R, E, A>, f: (e: E) => N, g: (a: A) => B) => TheseT2<M, R, N, B>\n  readonly mapLeft: <R, E, A, N>(fa: TheseT2<M, R, E, A>, f: (e: E) => N) => TheseT2<M, R, N, A>\n  readonly fold: <R, E, A, B>(\n    fa: TheseT2<M, R, E, A>,\n    onLeft: (e: E) => Kind2<M, R, B>,\n    onRight: (a: A) => Kind2<M, R, B>,\n    onBoth: (e: E, a: A) => Kind2<M, R, B>\n  ) => Kind2<M, R, B>\n  readonly swap: <R, E, A>(fa: TheseT2<M, R, E, A>) => TheseT2<M, R, A, E>\n  readonly rightM: <R, E, A>(ma: Kind2<M, R, A>) => TheseT2<M, R, E, A>\n  readonly leftM: <R, E, A>(me: Kind2<M, R, E>) => TheseT2<M, R, E, A>\n  readonly left: <R, E, A>(e: E) => TheseT2<M, R, E, A>\n  readonly right: <R, E, A>(a: A) => TheseT2<M, R, E, A>\n  readonly both: <R, E, A>(e: E, a: A) => TheseT2<M, R, E, A>\n  readonly toTuple: <R, E, A>(fa: TheseT2<M, R, E, A>, e: E, a: A) => Kind2<M, R, [E, A]>\n  readonly getMonad: <E>(S: Semigroup<E>) => {\n    readonly _E: E\n    readonly map: <R, A, B>(ma: TheseT2<M, R, E, A>, f: (a: A) => B) => TheseT2<M, R, E, B>\n    readonly of: <R, A>(a: A) => TheseT2<M, R, E, A>\n    readonly ap: <R, A, B>(mab: TheseT2<M, R, E, (a: A) => B>, ma: TheseT2<M, R, E, A>) => TheseT2<M, R, E, B>\n    readonly chain: <R, A, B>(ma: TheseT2<M, R, E, A>, f: (a: A) => TheseT2<M, R, E, B>) => TheseT2<M, R, E, B>\n  }\n}\n\n/**\n * @category zone of death\n * @since 2.4.0\n * @deprecated\n */\nexport function getTheseM<M extends URIS2>(M: Monad2<M>): TheseM2<M>\n/** @deprecated */\nexport function getTheseM<M extends URIS>(M: Monad1<M>): TheseM1<M>\n/** @deprecated */\nexport function getTheseM<M>(M: Monad<M>): TheseM<M>\n/** @deprecated */\n/* istanbul ignore next */\nexport function getTheseM<M>(M: Monad<M>): TheseM<M> {\n  const _map = map(M)\n  const _bimap = bimap(M)\n  const _mapLeft = mapLeft(M)\n  const _fold = matchE(M)\n  const _toTuple2: <E, A>(e: LazyArg<E>, a: LazyArg<A>) => (fa: HKT<M, T.These<E, A>>) => HKT<M, [E, A]> = toTuple2(\n    M\n  ) as any\n  const of = right(M)\n\n  const mapT = <E, A, B>(fa: TheseT<M, E, A>, f: (a: A) => B): TheseT<M, E, B> => pipe(fa, _map(f))\n\n  return {\n    map: mapT,\n    bimap: (fea, f, g) => pipe(fea, _bimap(f, g)),\n    mapLeft: (fea, f) => pipe(fea, _mapLeft(f)),\n    fold: (fa, onLeft, onRight, onBoth) => pipe(fa, _fold(onLeft, onRight, onBoth)),\n    swap: swap(M),\n    rightM: rightF(M),\n    leftM: leftF(M),\n    left: left(M),\n    right: right(M),\n    both: both(M),\n    toTuple: (fa, e, a) =>\n      pipe(\n        fa,\n        _toTuple2(\n          () => e,\n          () => a\n        )\n      ),\n    getMonad: (S) => {\n      const _ap = ap(M, S)\n      const _chain = chain(M, S)\n      return {\n        _E: undefined as any,\n        map: mapT,\n        of,\n        ap: (fab, fa) => pipe(fab, _ap(fa)),\n        chain: (ma, f) => pipe(ma, _chain(f))\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "src/Traced.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Comonad2C } from './Comonad'\nimport { pipe } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\nimport { Monoid } from './Monoid'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Traced<P, A> {\n  (p: P): A\n}\n\n// TODO: curry in v3\n/**\n * Extracts a value at a relative position which depends on the current value.\n *\n * @since 2.0.0\n */\nexport function tracks<P, A>(M: Monoid<P>, f: (a: A) => P): (wa: Traced<P, A>) => A {\n  return (wa) => wa(f(wa(M.empty)))\n}\n\n/**\n * Get the current position\n *\n * @since 2.0.0\n */\nexport function listen<P, A>(wa: Traced<P, A>): Traced<P, [A, P]> {\n  return (e) => [wa(e), e]\n}\n\n/**\n * Get a value which depends on the current position\n *\n * @since 2.0.0\n */\nexport function listens<P, B>(f: (p: P) => B): <A>(wa: Traced<P, A>) => Traced<P, [A, B]> {\n  return (wa) => (e) => [wa(e), f(e)]\n}\n\n/**\n * Apply a function to the current position\n *\n * @since 2.0.0\n */\nexport function censor<P>(f: (p: P) => P): <A>(wa: Traced<P, A>) => Traced<P, A> {\n  return (wa) => (e) => wa(f(e))\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getComonad<P>(monoid: Monoid<P>): Comonad2C<URI, P> {\n  function extend<A, B>(wa: Traced<P, A>, f: (wa: Traced<P, A>) => B): Traced<P, B> {\n    return (p1) => f((p2) => wa(monoid.concat(p1, p2)))\n  }\n\n  function extract<A>(wa: Traced<P, A>): A {\n    return wa(monoid.empty)\n  }\n\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    extend,\n    extract\n  }\n}\n\n/* istanbul ignore next */\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: Traced<E, A>) => Traced<E, B> = (f) => (fa) => (p) => f(fa(p))\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Traced'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: Traced<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`Functor`](#functor) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const traced: Functor2<URI> = Functor\n"
  },
  {
    "path": "src/Traversable.ts",
    "content": "/**\n * `Traversable` represents data structures which can be _traversed_ accumulating results and effects in some\n * `Applicative` functor.\n *\n * - `traverse` runs an action for every element in a data structure, and accumulates the results.\n * - `sequence` runs the actions _contained_ in a data structure, and accumulates the results.\n *\n * The `traverse` and `sequence` functions should be compatible in the following sense:\n *\n * - `traverse(A)(xs, f) <-> sequence(A)(A.map(xs, f))`\n * - `sequence(A)(xs) <-> traverse(A)(xs, identity)`\n *\n * where `A` is an `Applicative` instance\n *\n * `Traversable` instances should also be compatible with the corresponding `Foldable` instances, in the following sense:\n *\n * ```ts\n * import { getApplicative, make } from 'fp-ts/Const'\n *\n * const A = getApplicative(M)\n *\n * foldMap(M)(xs, f) = traverse(A)(xs, a => make(f(a)))\n * ```\n *\n * where `M` is a `Monoid` instance\n *\n * @since 2.0.0\n */\nimport {\n  Applicative,\n  Applicative1,\n  Applicative2,\n  Applicative2C,\n  Applicative3,\n  Applicative3C,\n  Applicative4\n} from './Applicative'\nimport {\n  Foldable,\n  Foldable1,\n  Foldable2,\n  Foldable2C,\n  Foldable3,\n  FoldableComposition,\n  FoldableComposition11,\n  getFoldableComposition\n} from './Foldable'\nimport { pipe } from './function'\nimport {\n  Functor,\n  Functor1,\n  Functor2,\n  Functor2C,\n  Functor3,\n  FunctorComposition,\n  FunctorComposition11,\n  getFunctorComposition\n} from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Traversable<T> extends Functor<T>, Foldable<T> {\n  /**\n   * Runs an action for every element in a data structure and accumulates the results\n   */\n  readonly traverse: Traverse<T>\n  readonly sequence: Sequence<T>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Traversable1<T extends URIS> extends Functor1<T>, Foldable1<T> {\n  readonly traverse: Traverse1<T>\n  readonly sequence: Sequence1<T>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Traversable2<T extends URIS2> extends Functor2<T>, Foldable2<T> {\n  readonly traverse: Traverse2<T>\n  readonly sequence: Sequence2<T>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Traversable2C<T extends URIS2, TL> extends Functor2C<T, TL>, Foldable2C<T, TL> {\n  readonly traverse: Traverse2C<T, TL>\n  readonly sequence: Sequence2C<T, TL>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Traversable3<T extends URIS3> extends Functor3<T>, Foldable3<T> {\n  readonly traverse: Traverse3<T>\n  readonly sequence: Sequence3<T>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Traverse<T> {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, E, B>(\n    ta: HKT<T, A>,\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => Kind4<F, S, R, E, HKT<T, B>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: HKT<T, A>,\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, HKT<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: HKT<T, A>,\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, HKT<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(ta: HKT<T, A>, f: (a: A) => Kind2<F, E, B>) => Kind2<F, E, HKT<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: HKT<T, A>,\n    f: (a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, HKT<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: HKT<T, A>, f: (a: A) => Kind<F, B>) => Kind<F, HKT<T, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: HKT<T, A>, f: (a: A) => HKT<F, B>) => HKT<F, HKT<T, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Traverse1<T extends URIS> {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, E, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => Kind4<F, S, R, E, Kind<T, B>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: Kind<T, A>,\n    f: (a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind<T, A>, f: (a: A) => Kind<F, B>) => Kind<F, Kind<T, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind<T, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind<T, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Traverse2<T extends URIS2> {\n  <F extends URIS4>(F: Applicative4<F>): <TE, A, S, R, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind4<F, S, R, FE, B>\n  ) => Kind4<F, S, R, FE, Kind2<T, TE, B>>\n  <F extends URIS3>(F: Applicative3<F>): <TE, A, R, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, TE, B>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TE, A, R, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <TE, A, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <TE, A, B>(\n    ta: Kind2<T, TE, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <E, A, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind<F, B>\n  ) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <E, A, B>(ta: Kind2<T, E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Traverse2C<T extends URIS2, E> {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind4<F, S, R, FE, B>\n  ) => Kind4<F, S, R, FE, Kind2<T, E, B>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, E, B>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <A, R, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, E, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, E, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    ta: Kind2<T, E, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, E, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind2<T, E, A>, f: (a: A) => Kind<F, B>) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind2<T, E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Traverse3<T extends URIS3> {\n  <F extends URIS4>(F: Applicative4<F>): <TR, TE, A, S, FR, FE, B>(\n    ta: Kind3<T, TR, TE, A>,\n    f: (a: A) => Kind4<F, S, FR, FE, B>\n  ) => Kind4<F, S, FR, FE, Kind3<T, TR, TE, B>>\n  <F extends URIS3>(F: Applicative3<F>): <TR, TE, A, FR, FE, B>(\n    ta: Kind3<T, TR, TE, A>,\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, B>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TR, TE, A, FR, B>(\n    ta: Kind3<T, TR, TE, A>,\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <TR, A, TE, FE, B>(\n    ta: Kind3<T, TR, TE, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind3<T, TR, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, TE, A, B>(\n    ta: Kind3<T, R, TE, A>,\n    f: (a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind3<T, R, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <R, E, A, B>(\n    ta: Kind3<T, R, E, A>,\n    f: (a: A) => Kind<F, B>\n  ) => Kind<F, Kind3<T, R, E, B>>\n  <F>(F: Applicative<F>): <R, E, A, B>(ta: Kind3<T, R, E, A>, f: (a: A) => HKT<F, B>) => HKT<F, Kind3<T, R, E, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Sequence<T> {\n  <F extends URIS4>(F: Applicative4<F>): <S, R, E, A>(ta: HKT<T, Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, HKT<T, A>>\n  <F extends URIS3>(F: Applicative3<F>): <R, E, A>(ta: HKT<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, HKT<T, A>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <R, A>(ta: HKT<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, HKT<T, A>>\n  <F extends URIS2>(F: Applicative2<F>): <E, A>(ta: HKT<T, Kind2<F, E, A>>) => Kind2<F, E, HKT<T, A>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(ta: HKT<T, Kind2<F, E, A>>) => Kind2<F, E, HKT<T, A>>\n  <F extends URIS>(F: Applicative1<F>): <A>(ta: HKT<T, Kind<F, A>>) => Kind<F, HKT<T, A>>\n  <F>(F: Applicative<F>): <A>(ta: HKT<T, HKT<F, A>>) => HKT<F, HKT<T, A>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Sequence1<T extends URIS> {\n  <F extends URIS4>(F: Applicative4<F>): <S, R, E, A>(\n    ta: Kind<T, Kind4<F, S, R, E, A>>\n  ) => Kind4<F, S, R, E, Kind<T, A>>\n  <F extends URIS3>(F: Applicative3<F>): <R, E, A>(ta: Kind<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, Kind<T, A>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <R, A>(ta: Kind<T, Kind3<F, R, E, A>>) => Kind3<F, R, E, Kind<T, A>>\n  <F extends URIS2>(F: Applicative2<F>): <E, A>(ta: Kind<T, Kind2<F, E, A>>) => Kind2<F, E, Kind<T, A>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(ta: Kind<T, Kind2<F, E, A>>) => Kind2<F, E, Kind<T, A>>\n  <F extends URIS>(F: Applicative1<F>): <A>(ta: Kind<T, Kind<F, A>>) => Kind<F, Kind<T, A>>\n  <F>(F: Applicative<F>): <A>(ta: Kind<T, HKT<F, A>>) => HKT<F, Kind<T, A>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Sequence2<T extends URIS2> {\n  <F extends URIS4>(F: Applicative4<F>): <TE, S, R, FE, A>(\n    ta: Kind2<T, TE, Kind4<F, S, R, FE, A>>\n  ) => Kind4<F, S, R, FE, Kind2<T, TE, A>>\n  <F extends URIS3>(F: Applicative3<F>): <TE, R, FE, A>(\n    ta: Kind2<T, TE, Kind3<F, R, FE, A>>\n  ) => Kind3<F, R, FE, Kind2<T, TE, A>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TE, R, A>(\n    ta: Kind2<T, TE, Kind3<F, R, FE, A>>\n  ) => Kind3<F, R, FE, Kind2<T, TE, A>>\n  <F extends URIS2>(F: Applicative2<F>): <TE, FE, A>(ta: Kind2<T, TE, Kind2<F, FE, A>>) => Kind2<F, FE, Kind2<T, TE, A>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <TE, A>(\n    ta: Kind2<T, TE, Kind2<F, FE, A>>\n  ) => Kind2<F, FE, Kind2<T, TE, A>>\n  <F extends URIS>(F: Applicative1<F>): <E, A>(ta: Kind2<T, E, Kind<F, A>>) => Kind<F, Kind2<T, E, A>>\n  <F>(F: Applicative<F>): <E, A>(ta: Kind2<T, E, HKT<F, A>>) => HKT<F, Kind2<T, E, A>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Sequence2C<T extends URIS2, E> {\n  <F extends URIS4>(F: Applicative4<F>): <S, R, FE, A>(\n    ta: Kind2<T, E, Kind4<F, S, R, FE, A>>\n  ) => Kind4<F, S, R, FE, Kind2<T, E, A>>\n  <F extends URIS3>(F: Applicative3<F>): <R, FE, A>(\n    ta: Kind2<T, E, Kind3<F, R, FE, A>>\n  ) => Kind3<F, R, FE, Kind2<T, E, A>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <R, A>(\n    ta: Kind2<T, E, Kind3<F, R, FE, A>>\n  ) => Kind3<F, R, FE, Kind2<T, E, A>>\n  <F extends URIS2>(F: Applicative2<F>): <FE, A>(ta: Kind2<T, E, Kind2<F, FE, A>>) => Kind2<F, FE, Kind2<T, E, A>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A>(ta: Kind2<T, E, Kind2<F, FE, A>>) => Kind2<F, FE, Kind2<T, E, A>>\n  <F extends URIS>(F: Applicative1<F>): <A>(ta: Kind2<T, E, Kind<F, A>>) => Kind<F, Kind2<T, E, A>>\n  <F>(F: Applicative<F>): <A>(ta: Kind2<T, E, HKT<F, A>>) => HKT<F, Kind2<T, E, A>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Sequence3<T extends URIS3> {\n  <F extends URIS4>(F: Applicative4<F>): <TR, TE, S, FR, FE, A>(\n    ta: Kind3<T, TR, TE, Kind4<F, S, FR, FE, A>>\n  ) => Kind4<F, S, FR, FE, Kind3<T, TR, TE, A>>\n  <F extends URIS3>(F: Applicative3<F>): <TR, TE, FR, FE, A>(\n    ta: Kind3<T, TR, TE, Kind3<F, FR, FE, A>>\n  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, A>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <TR, TE, FR, A>(\n    ta: Kind3<T, TR, TE, Kind3<F, FR, FE, A>>\n  ) => Kind3<F, FR, FE, Kind3<T, TR, TE, A>>\n  <F extends URIS2>(F: Applicative2<F>): <R, TE, FE, A>(\n    ta: Kind3<T, R, TE, Kind2<F, FE, A>>\n  ) => Kind2<F, FE, Kind3<T, R, TE, A>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, TE, A>(\n    ta: Kind3<T, R, TE, Kind2<F, FE, A>>\n  ) => Kind2<F, FE, Kind3<T, R, TE, A>>\n  <F extends URIS>(F: Applicative1<F>): <R, E, A>(ta: Kind3<T, R, E, Kind<F, A>>) => Kind<F, Kind3<T, R, E, A>>\n  <F>(F: Applicative<F>): <R, E, A>(ta: Kind3<T, R, E, HKT<F, A>>) => HKT<F, Kind3<T, R, E, A>>\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * `traverse` composition.\n *\n * @since 2.10.0\n */\nexport function traverse<T extends URIS, G extends URIS2>(\n  T: Traversable1<T>,\n  G: Traversable2<G>\n): {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, FE, B>(\n    f: (a: A) => Kind4<F, S, R, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind4<F, S, R, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <A, R, B>(\n    f: (a: A) => Kind3<F, R, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind2<F, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind2<F, FE, Kind<T, Kind2<G, GE, B>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => Kind<F, Kind<T, Kind2<G, GE, B>>>\n  <F>(F: Applicative<F>): <A, B>(\n    f: (a: A) => HKT<F, B>\n  ) => <GE>(tga: Kind<T, Kind2<G, GE, A>>) => HKT<F, Kind<T, Kind2<G, GE, B>>>\n}\nexport function traverse<T extends URIS, G extends URIS>(\n  T: Traversable1<T>,\n  G: Traversable1<G>\n): {\n  <F extends URIS4>(F: Applicative4<F>): <A, S, R, E, B>(\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind4<F, S, R, E, Kind<T, Kind<G, B>>>\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind3<F, R, E, Kind<T, Kind<G, B>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    f: (a: A) => Kind3<F, R, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind3<F, R, E, Kind<T, Kind<G, B>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    f: (a: A) => Kind2<F, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind2<F, E, Kind<T, Kind<G, B>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    f: (a: A) => Kind2<F, E, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind2<F, E, Kind<T, Kind<G, B>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, B>\n  ) => (tga: Kind<T, Kind<G, A>>) => Kind<F, Kind<T, Kind<G, B>>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, B>) => (tga: Kind<T, Kind<G, A>>) => HKT<F, Kind<T, Kind<G, B>>>\n}\nexport function traverse<T, G>(\n  T: Traversable<T>,\n  G: Traversable<G>\n): <F>(F: Applicative<F>) => <A, B>(f: (a: A) => HKT<F, B>) => (tga: HKT<T, HKT<G, A>>) => HKT<F, HKT<T, HKT<G, B>>>\nexport function traverse<T, G>(\n  T: Traversable<T>,\n  G: Traversable<G>\n): <F>(F: Applicative<F>) => <A, B>(f: (a: A) => HKT<F, B>) => (tga: HKT<T, HKT<G, A>>) => HKT<F, HKT<T, HKT<G, B>>> {\n  return (F) => {\n    const traverseT = T.traverse(F)\n    const traverseG = G.traverse(F)\n    return (f) => (fga) => traverseT(fga, (ga) => traverseG(ga, f))\n  }\n}\n\n/**\n * `sequence` composition.\n *\n * @since 2.10.0\n */\nexport function sequence<T extends URIS, G extends URIS2>(\n  T: Traversable1<T>,\n  G: Traversable2<G>\n): {\n  <F extends URIS4>(F: Applicative4<F>): <GE, S, R, FE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind4<F, S, R, FE, A>>>\n  ) => Kind4<F, S, R, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS3>(F: Applicative3<F>): <GE, R, FE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind3<F, R, FE, A>>>\n  ) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <GE, R, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind3<F, R, FE, A>>>\n  ) => Kind3<F, R, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS2>(F: Applicative2<F>): <GE, FE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind2<F, FE, A>>>\n  ) => Kind2<F, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <GE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind2<F, FE, A>>>\n  ) => Kind2<F, FE, Kind<T, Kind2<G, GE, A>>>\n  <F extends URIS>(F: Applicative1<F>): <GE, A>(\n    tgfa: Kind<T, Kind2<G, GE, Kind<F, A>>>\n  ) => Kind<F, Kind<T, Kind2<G, GE, A>>>\n  <F>(F: Applicative<F>): <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>>\n}\nexport function sequence<T extends URIS, G extends URIS>(\n  T: Traversable1<T>,\n  G: Traversable1<G>\n): {\n  <F extends URIS4>(F: Applicative4<F>): <S, R, E, A>(\n    tgfa: Kind<T, Kind<G, Kind4<F, S, R, E, A>>>\n  ) => Kind4<F, S, R, E, Kind<T, Kind<G, A>>>\n  <F extends URIS3>(F: Applicative3<F>): <R, E, A>(\n    tgfa: Kind<T, Kind<G, Kind3<F, R, E, A>>>\n  ) => Kind3<F, R, E, Kind<T, Kind<G, A>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <R, A>(\n    tgfa: Kind<T, Kind<G, Kind3<F, R, E, A>>>\n  ) => Kind3<F, R, E, Kind<T, Kind<G, A>>>\n  <F extends URIS2>(F: Applicative2<F>): <E, A>(\n    tgfa: Kind<T, Kind<G, Kind2<F, E, A>>>\n  ) => Kind2<F, E, Kind<T, Kind<G, A>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(\n    tgfa: Kind<T, Kind<G, Kind2<F, E, A>>>\n  ) => Kind2<F, E, Kind<T, Kind<G, A>>>\n  <F extends URIS>(F: Applicative1<F>): <A>(tgfa: Kind<T, Kind<G, Kind<F, A>>>) => Kind<F, Kind<T, Kind<G, A>>>\n  <F>(F: Applicative<F>): <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>>\n}\nexport function sequence<T, G>(\n  T: Traversable<T>,\n  G: Traversable<G>\n): <F>(F: Applicative<F>) => <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>>\nexport function sequence<T, G>(\n  T: Traversable<T>,\n  G: Traversable<G>\n): <F>(F: Applicative<F>) => <A>(tgfa: HKT<T, HKT<G, HKT<F, A>>>) => HKT<F, HKT<T, HKT<G, A>>> {\n  return (F) => {\n    const sequenceT = T.sequence(F)\n    const sequenceG = G.sequence(F)\n    return (fgha) => sequenceT(T.map(fgha, sequenceG))\n  }\n}\n\n//\n// pipeable `Traverse`\n//\n\n/**\n * @since 2.6.3\n */\nexport interface PipeableTraverse1<T extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B>(\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => (ta: Kind<T, A>) => Kind3<F, FR, FE, Kind<T, B>>\n  <F extends URIS3, FE>(F: Applicative3C<F, FE>): <A, FR, B>(\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => (ta: Kind<T, A>) => Kind3<F, FR, FE, Kind<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => (ta: Kind<T, A>) => Kind2<F, FE, Kind<T, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => (ta: Kind<T, A>) => Kind2<F, FE, Kind<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(f: (a: A) => Kind<F, B>) => (ta: Kind<T, A>) => Kind<F, Kind<T, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, B>) => (ta: Kind<T, A>) => HKT<F, Kind<T, B>>\n}\n\n/**\n * @since 2.6.3\n */\nexport interface PipeableTraverse2<T extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B>(\n    f: (a: A) => Kind3<F, FR, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind3<F, FR, FE, Kind2<T, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind<F, Kind2<T, TE, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, B>) => <TE>(ta: Kind2<T, TE, A>) => HKT<F, Kind2<T, TE, B>>\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface TraversableComposition<F, G> extends FoldableComposition<F, G>, FunctorComposition<F, G> {\n  readonly traverse: <H>(\n    H: Applicative<H>\n  ) => <A, B>(fga: HKT<F, HKT<G, A>>, f: (a: A) => HKT<H, B>) => HKT<H, HKT<F, HKT<G, B>>>\n  readonly sequence: <H>(H: Applicative<H>) => <A>(fga: HKT<F, HKT<G, HKT<H, A>>>) => HKT<H, HKT<F, HKT<G, A>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface TraverseComposition11<F extends URIS, G extends URIS> {\n  <H extends URIS3>(H: Applicative3<H>): <R, E, A, B>(\n    fga: Kind<F, Kind<G, A>>,\n    f: (a: A) => Kind3<H, R, E, B>\n  ) => Kind3<H, R, E, Kind<F, Kind<G, B>>>\n  <H extends URIS2>(H: Applicative2<H>): <E, A, B>(\n    fga: Kind<F, Kind<G, A>>,\n    f: (a: A) => Kind2<H, E, B>\n  ) => Kind2<H, E, Kind<F, Kind<G, B>>>\n  <H extends URIS2, E>(H: Applicative2C<H, E>): <A, B>(\n    fga: Kind<F, Kind<G, A>>,\n    f: (a: A) => Kind2<H, E, B>\n  ) => Kind2<H, E, Kind<F, Kind<G, B>>>\n  <H extends URIS>(H: Applicative1<H>): <A, B>(\n    fga: Kind<F, Kind<G, A>>,\n    f: (a: A) => Kind<H, B>\n  ) => Kind<H, Kind<F, Kind<G, B>>>\n  <H>(H: Applicative<H>): <A, B>(fga: Kind<F, Kind<G, A>>, f: (a: A) => HKT<H, B>) => HKT<H, Kind<F, Kind<G, B>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface SequenceComposition11<F extends URIS, G extends URIS> {\n  <H extends URIS3>(H: Applicative3<H>): <R, E, A>(\n    fga: Kind<F, Kind<G, Kind3<H, R, E, A>>>\n  ) => Kind3<H, R, E, Kind<F, Kind<G, A>>>\n  <H extends URIS2>(H: Applicative2<H>): <E, A>(\n    fga: Kind<F, Kind<G, Kind2<H, E, A>>>\n  ) => Kind2<H, E, Kind<F, Kind<G, A>>>\n  <H extends URIS2, E>(H: Applicative2C<H, E>): <A>(\n    fga: Kind<F, Kind<G, Kind2<H, E, A>>>\n  ) => Kind2<H, E, Kind<F, Kind<G, A>>>\n  <H extends URIS>(H: Applicative1<H>): <A>(fga: Kind<F, Kind<G, Kind<H, A>>>) => Kind<H, Kind<F, Kind<G, A>>>\n  <H>(H: Applicative<H>): <A>(fga: Kind<F, Kind<G, HKT<H, A>>>) => HKT<H, Kind<F, Kind<G, A>>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface TraversableComposition11<F extends URIS, G extends URIS>\n  extends FoldableComposition11<F, G>,\n    FunctorComposition11<F, G> {\n  readonly traverse: TraverseComposition11<F, G>\n  readonly sequence: SequenceComposition11<F, G>\n}\n\n/**\n * Use\n * - [`traverse`](#traverse)\n * - [`sequence`](#sequence)\n *\n * instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function getTraversableComposition<F extends URIS, G extends URIS>(\n  F: Traversable1<F>,\n  G: Traversable1<G>\n): TraversableComposition11<F, G>\n/** @deprecated */\nexport function getTraversableComposition<F, G>(F: Traversable<F>, G: Traversable<G>): TraversableComposition<F, G>\n/** @deprecated */\nexport function getTraversableComposition<F, G>(F: Traversable<F>, G: Traversable<G>): TraversableComposition<F, G> {\n  const map = getFunctorComposition(F, G).map\n  const FC = getFoldableComposition(F, G)\n  const _traverse = traverse(F, G)\n  const _sequence = sequence(F, G)\n  return {\n    map,\n    reduce: FC.reduce,\n    foldMap: FC.foldMap,\n    reduceRight: FC.reduceRight,\n    traverse: (H) => {\n      const traverseH = _traverse(H)\n      return (fga, f) => pipe(fga, traverseH(f))\n    },\n    sequence: (H) => {\n      const sequenceH = _sequence(H)\n      return (fgha) => pipe(fgha, sequenceH)\n    }\n  }\n}\n"
  },
  {
    "path": "src/TraversableWithIndex.ts",
    "content": "/**\n * A `Traversable` with an additional index.\n * A `TraversableWithIndex` instance must be compatible with its `Traversable` instance\n *\n * ```ts\n * traverse(F)(ta, f) = traverseWithIndex(F)(ta, (_, a) => f(a))\n * ```\n *\n * with its `FoldableWithIndex` instance\n *\n * ```ts\n * foldMapWithIndex(M)(ta, f) = traverseWithIndex(getApplicative(M))(ta, (i, a) => new Const(f(i, a))).value\n * ```\n *\n * and with its `FunctorWithIndex` instance\n *\n * ```purescript\n * mapWithIndex(ta, f) = traverseWithIndex(identity)(ta, (i, a) => new Identity(f(i, a))).value\n * ```\n *\n * @since 2.0.0\n */\nimport { Applicative, Applicative1, Applicative2, Applicative2C, Applicative3, Applicative3C } from './Applicative'\nimport { FoldableWithIndex, FoldableWithIndex1, FoldableWithIndex2, FoldableWithIndex2C } from './FoldableWithIndex'\nimport { FunctorWithIndex, FunctorWithIndex1, FunctorWithIndex2, FunctorWithIndex2C } from './FunctorWithIndex'\nimport { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'\nimport { Traversable, Traversable1, Traversable2, Traversable2C } from './Traversable'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.0.0\n */\nexport interface TraversableWithIndex<T, I> extends FunctorWithIndex<T, I>, FoldableWithIndex<T, I>, Traversable<T> {\n  readonly traverseWithIndex: TraverseWithIndex<T, I>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface TraversableWithIndex1<T extends URIS, I>\n  extends FunctorWithIndex1<T, I>,\n    FoldableWithIndex1<T, I>,\n    Traversable1<T> {\n  readonly traverseWithIndex: TraverseWithIndex1<T, I>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface TraversableWithIndex2<T extends URIS2, I>\n  extends FunctorWithIndex2<T, I>,\n    FoldableWithIndex2<T, I>,\n    Traversable2<T> {\n  readonly traverseWithIndex: TraverseWithIndex2<T, I>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface TraversableWithIndex2C<T extends URIS2, I, E>\n  extends FunctorWithIndex2C<T, I, E>,\n    FoldableWithIndex2C<T, I, E>,\n    Traversable2C<T, E> {\n  readonly traverseWithIndex: TraverseWithIndex2C<T, I, E>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface TraverseWithIndex<T, I> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: HKT<T, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, HKT<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: HKT<T, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, HKT<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: HKT<T, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, HKT<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: HKT<T, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, HKT<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: HKT<T, A>, f: (i: I, a: A) => Kind<F, B>) => Kind<F, HKT<T, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: HKT<T, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, HKT<T, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface TraverseWithIndex1<T extends URIS, I> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: Kind<T, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: Kind<T, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: Kind<T, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: Kind<T, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind<T, A>, f: (i: I, a: A) => Kind<F, B>) => Kind<F, Kind<T, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind<T, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, Kind<T, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface TraverseWithIndex2<T extends URIS2, I> {\n  <F extends URIS3>(F: Applicative3<F>): <TE, A, R, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (i: I, a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <TE, A, FE, B>(\n    ta: Kind2<T, TE, A>,\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <TE, A, B>(\n    ta: Kind2<T, TE, A>,\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <E, A, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind<F, B>\n  ) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <E, A, B>(ta: Kind2<T, E, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface TraverseWithIndex2C<T extends URIS2, I, E> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind3<F, R, FE, B>\n  ) => Kind3<F, R, FE, Kind2<T, E, B>>\n  <F extends URIS3>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => Kind3<F, R, E, Kind2<T, E, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => Kind2<F, FE, Kind2<T, E, B>>\n  <F extends URIS2>(F: Applicative2C<F, E>): <A, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => Kind2<F, E, Kind2<T, E, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    ta: Kind2<T, E, A>,\n    f: (i: I, a: A) => Kind<F, B>\n  ) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind2<T, E, A>, f: (i: I, a: A) => HKT<F, B>) => HKT<F, Kind2<T, E, B>>\n}\n\n//\n// pipeable `TraverseWithIndex`\n//\n\n/**\n * @since 2.6.3\n */\nexport interface PipeableTraverseWithIndex1<T extends URIS, I> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => (ta: Kind<T, A>) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    f: (i: I, a: A) => Kind3<F, R, E, B>\n  ) => (ta: Kind<T, A>) => Kind3<F, R, E, Kind<T, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => (ta: Kind<T, A>) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    f: (i: I, a: A) => Kind2<F, E, B>\n  ) => (ta: Kind<T, A>) => Kind2<F, E, Kind<T, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(f: (i: I, a: A) => Kind<F, B>) => (ta: Kind<T, A>) => Kind<F, Kind<T, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (i: I, a: A) => HKT<F, B>) => (ta: Kind<T, A>) => HKT<F, Kind<T, B>>\n}\n\n/**\n * @since 2.6.3\n */\nexport interface PipeableTraverseWithIndex2<T extends URIS2, I> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    f: (i: I, a: A) => Kind3<F, R, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind3<F, R, FE, Kind2<T, TE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (i: I, a: A) => Kind2<F, FE, B>\n  ) => <TE>(ta: Kind2<T, TE, A>) => Kind2<F, FE, Kind2<T, TE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (i: I, a: A) => Kind<F, B>\n  ) => <E>(ta: Kind2<T, E, A>) => Kind<F, Kind2<T, E, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (i: I, a: A) => HKT<F, B>) => <E>(ta: Kind2<T, E, A>) => HKT<F, Kind2<T, E, B>>\n}\n"
  },
  {
    "path": "src/Tree.ts",
    "content": "/**\n * Multi-way trees (aka rose trees) and forests, where a forest is\n *\n * ```ts\n * type Forest<A> = Array<Tree<A>>\n * ```\n *\n * @since 2.0.0\n */\nimport { Applicative as ApplicativeHKT, Applicative1 } from './Applicative'\nimport { apFirst as apFirst_, Apply1, apS as apS_, apSecond as apSecond_ } from './Apply'\nimport * as A from './Array'\nimport { bind as bind_, Chain1, chainFirst as chainFirst_ } from './Chain'\nimport { Comonad1 } from './Comonad'\nimport { Eq, fromEquals } from './Eq'\nimport { Extend1 } from './Extend'\nimport { Foldable1 } from './Foldable'\nimport { dual, identity, pipe } from './function'\nimport { bindTo as bindTo_, flap as flap_, Functor1, let as let__ } from './Functor'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport * as _ from './internal'\nimport { Monad as MonadHKT, Monad1, Monad2, Monad2C, Monad3, Monad3C, Monad4 } from './Monad'\nimport { Monoid } from './Monoid'\nimport { Pointed1 } from './Pointed'\nimport { Predicate } from './Predicate'\nimport { Show } from './Show'\nimport { PipeableTraverse1, Traversable1 } from './Traversable'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport type Forest<A> = Array<Tree<A>>\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Tree<A> {\n  readonly value: A\n  readonly forest: Forest<A>\n}\n\n/**\n * @category constructors\n * @since 2.0.0\n */\nexport function make<A>(value: A, forest: Forest<A> = []): Tree<A> {\n  return {\n    value,\n    forest\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getShow<A>(S: Show<A>): Show<Tree<A>> {\n  const show = (t: Tree<A>): string => {\n    return A.isEmpty(t.forest)\n      ? `make(${S.show(t.value)})`\n      : `make(${S.show(t.value)}, [${t.forest.map(show).join(', ')}])`\n  }\n  return {\n    show\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getEq<A>(E: Eq<A>): Eq<Tree<A>> {\n  // eslint-disable-next-line prefer-const\n  let SA: Eq<Array<Tree<A>>>\n  const R: Eq<Tree<A>> = fromEquals((x, y) => E.equals(x.value, y.value) && SA.equals(x.forest, y.forest))\n  SA = A.getEq(R)\n  return R\n}\n\nconst draw = (indentation: string, forest: Forest<string>): string => {\n  let r = ''\n  const len = forest.length\n  let tree: Tree<string>\n  for (let i = 0; i < len; i++) {\n    tree = forest[i]\n    const isLast = i === len - 1\n    r += indentation + (isLast ? '└' : '├') + '─ ' + tree.value\n    r += draw(indentation + (len > 1 && !isLast ? '│  ' : '   '), tree.forest)\n  }\n  return r\n}\n\n/**\n * Neat 2-dimensional drawing of a forest\n *\n * @since 2.0.0\n */\nexport function drawForest(forest: Forest<string>): string {\n  return draw('\\n', forest)\n}\n\n/**\n * Neat 2-dimensional drawing of a tree\n *\n * @example\n * import { make, drawTree } from 'fp-ts/Tree'\n *\n * const fa = make('a', [\n *   make('b'),\n *   make('c'),\n *   make('d', [make('e'), make('f')])\n * ])\n *\n * assert.strictEqual(drawTree(fa), `a\n * ├─ b\n * ├─ c\n * └─ d\n *    ├─ e\n *    └─ f`)\n *\n *\n * @since 2.0.0\n */\nexport function drawTree(tree: Tree<string>): string {\n  return tree.value + drawForest(tree.forest)\n}\n\n/**\n * Build a (possibly infinite) tree from a seed value in breadth-first order.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport function unfoldTree<A, B>(b: B, f: (b: B) => [A, Array<B>]): Tree<A> {\n  const [a, bs] = f(b)\n  return { value: a, forest: unfoldForest(bs, f) }\n}\n\n/**\n * Build a (possibly infinite) forest from a list of seed values in breadth-first order.\n *\n * @category constructors\n * @since 2.0.0\n */\nexport function unfoldForest<A, B>(bs: Array<B>, f: (b: B) => [A, Array<B>]): Forest<A> {\n  return bs.map((b) => unfoldTree(b, f))\n}\n\n/**\n * Monadic tree builder, in depth-first order\n *\n * @category constructors\n * @since 2.0.0\n */\nexport function unfoldTreeM<M extends URIS4>(\n  M: Monad4<M>\n): <S, R, E, A, B>(b: B, f: (b: B) => Kind4<M, S, R, E, [A, Array<B>]>) => Kind4<M, S, R, E, Tree<A>>\nexport function unfoldTreeM<M extends URIS3>(\n  M: Monad3<M>\n): <R, E, A, B>(b: B, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Tree<A>>\nexport function unfoldTreeM<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <R, A, B>(b: B, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Tree<A>>\nexport function unfoldTreeM<M extends URIS2>(\n  M: Monad2<M>\n): <E, A, B>(b: B, f: (b: B) => Kind2<M, E, [A, Array<B>]>) => Kind2<M, E, Tree<A>>\nexport function unfoldTreeM<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(b: B, f: (b: B) => Kind2<M, E, [A, Array<B>]>) => Kind2<M, E, Tree<A>>\nexport function unfoldTreeM<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(b: B, f: (b: B) => Kind<M, [A, Array<B>]>) => Kind<M, Tree<A>>\nexport function unfoldTreeM<M>(M: MonadHKT<M>): <A, B>(b: B, f: (b: B) => HKT<M, [A, Array<B>]>) => HKT<M, Tree<A>>\nexport function unfoldTreeM<M>(M: MonadHKT<M>): <A, B>(b: B, f: (b: B) => HKT<M, [A, Array<B>]>) => HKT<M, Tree<A>> {\n  const unfoldForestMM = unfoldForestM(M)\n  return (b, f) => M.chain(f(b), ([a, bs]) => M.map(unfoldForestMM(bs, f), (ts) => ({ value: a, forest: ts })))\n}\n\n/**\n * Monadic forest builder, in depth-first order\n *\n * @category constructors\n * @since 2.0.0\n */\nexport function unfoldForestM<M extends URIS4>(\n  M: Monad4<M>\n): <S, R, E, A, B>(bs: Array<B>, f: (b: B) => Kind4<M, S, R, E, [A, Array<B>]>) => Kind4<M, S, R, E, Forest<A>>\nexport function unfoldForestM<M extends URIS3>(\n  M: Monad3<M>\n): <R, E, A, B>(bs: Array<B>, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Forest<A>>\nexport function unfoldForestM<M extends URIS3, E>(\n  M: Monad3C<M, E>\n): <R, A, B>(bs: Array<B>, f: (b: B) => Kind3<M, R, E, [A, Array<B>]>) => Kind3<M, R, E, Forest<A>>\nexport function unfoldForestM<M extends URIS2>(\n  M: Monad2<M>\n): <R, E, B>(bs: Array<B>, f: (b: B) => Kind2<M, R, [E, Array<B>]>) => Kind2<M, R, Forest<E>>\nexport function unfoldForestM<M extends URIS2, E>(\n  M: Monad2C<M, E>\n): <A, B>(bs: Array<B>, f: (b: B) => Kind2<M, E, [A, Array<B>]>) => Kind2<M, E, Forest<A>>\nexport function unfoldForestM<M extends URIS>(\n  M: Monad1<M>\n): <A, B>(bs: Array<B>, f: (b: B) => Kind<M, [A, Array<B>]>) => Kind<M, Forest<A>>\nexport function unfoldForestM<M>(\n  M: MonadHKT<M>\n): <A, B>(bs: Array<B>, f: (b: B) => HKT<M, [A, Array<B>]>) => HKT<M, Forest<A>>\nexport function unfoldForestM<M>(\n  M: MonadHKT<M>\n): <A, B>(bs: Array<B>, f: (b: B) => HKT<M, [A, Array<B>]>) => HKT<M, Forest<A>> {\n  const traverseM = A.traverse(M)\n  return (bs, f) =>\n    pipe(\n      bs,\n      traverseM((b) => unfoldTreeM(M)(b, f))\n    )\n}\n\n/**\n * Fold a tree into a \"summary\" value in depth-first order.\n *\n * For each node in the tree, apply `f` to the `value` and the result of applying `f` to each `forest`.\n *\n * This is also known as the catamorphism on trees.\n *\n * @example\n * import { fold, make } from 'fp-ts/Tree'\n * import { concatAll } from 'fp-ts/Monoid'\n * import { MonoidSum } from 'fp-ts/number'\n *\n * const t = make(1, [make(2), make(3)])\n *\n * const sum = concatAll(MonoidSum)\n *\n * // Sum the values in a tree:\n * assert.deepStrictEqual(fold((a: number, bs: Array<number>) => a + sum(bs))(t), 6)\n *\n * // Find the maximum value in the tree:\n * assert.deepStrictEqual(fold((a: number, bs: Array<number>) => bs.reduce((b, acc) => Math.max(b, acc), a))(t), 3)\n *\n * // Count the number of leaves in the tree:\n * assert.deepStrictEqual(fold((_: number, bs: Array<number>) => (bs.length === 0 ? 1 : sum(bs)))(t), 2)\n *\n * @category folding\n * @since 2.6.0\n */\nexport function fold<A, B>(f: (a: A, bs: Array<B>) => B): (tree: Tree<A>) => B {\n  const go = (tree: Tree<A>): B => f(tree.value, tree.forest.map(go))\n  return go\n}\n\n/* istanbul ignore next */\nconst _map: Monad1<URI>['map'] = (fa, f) => pipe(fa, map(f))\nconst _ap: Monad1<URI>['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map(f)))\n/* istanbul ignore next */\nconst _reduce = <A, B>(fa: Tree<A>, b: B, f: (b: B, a: A) => B): B => pipe(fa, reduce(b, f))\n/* istanbul ignore next */\nconst _foldMap: Foldable1<URI>['foldMap'] = (M) => {\n  const foldMapM = foldMap(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\n/* istanbul ignore next */\nconst _reduceRight = <A, B>(fa: Tree<A>, b: B, f: (a: A, b: B) => B): B => pipe(fa, reduceRight(b, f))\n/* istanbul ignore next */\nconst _extend: Extend1<URI>['extend'] = (wa, f) => pipe(wa, extend(f))\n/* istanbul ignore next */\nconst _traverse = <F>(F: ApplicativeHKT<F>): (<A, B>(ta: Tree<A>, f: (a: A) => HKT<F, B>) => HKT<F, Tree<B>>) => {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\n\n/**\n * @since 2.0.0\n */\nexport const ap: <A>(fa: Tree<A>) => <B>(fab: Tree<(a: A) => B>) => Tree<B> = (fa) => (fab) => _ap(fab, fa)\n\n/**\n * @category sequencing\n * @since 2.14.0\n */\nexport const flatMap: {\n  <A, B>(f: (a: A) => Tree<B>): (ma: Tree<A>) => Tree<B>\n  <A, B>(ma: Tree<A>, f: (a: A) => Tree<B>): Tree<B>\n} = /*#__PURE__*/ dual(2, <A, B>(ma: Tree<A>, f: (a: A) => Tree<B>): Tree<B> => {\n  const { value, forest } = f(ma.value)\n  const concat = A.getMonoid<Tree<B>>().concat\n  return {\n    value,\n    forest: concat(forest, ma.forest.map(flatMap(f)))\n  }\n})\n\n/**\n * @since 2.0.0\n */\nexport const extend: <A, B>(f: (wa: Tree<A>) => B) => (wa: Tree<A>) => Tree<B> = (f) => (wa) => ({\n  value: f(wa),\n  forest: wa.forest.map(extend(f))\n})\n\n/**\n * @since 2.0.0\n */\nexport const duplicate: <A>(wa: Tree<A>) => Tree<Tree<A>> = /*#__PURE__*/ extend(identity)\n\n/**\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatten: <A>(mma: Tree<Tree<A>>) => Tree<A> = /*#__PURE__*/ flatMap(identity)\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => (fa: Tree<A>) => Tree<B> = (f) => (fa) => ({\n  value: f(fa.value),\n  forest: fa.forest.map(map(f))\n})\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduce =\n  <A, B>(b: B, f: (b: B, a: A) => B) =>\n  (fa: Tree<A>): B => {\n    let r: B = f(b, fa.value)\n    const len = fa.forest.length\n    for (let i = 0; i < len; i++) {\n      r = pipe(fa.forest[i], reduce(r, f))\n    }\n    return r\n  }\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Tree<A>) => M = (M) => (f) =>\n  reduce(M.empty, (acc, a) => M.concat(acc, f(a)))\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRight =\n  <A, B>(b: B, f: (a: A, b: B) => B) =>\n  (fa: Tree<A>): B => {\n    let r: B = b\n    const len = fa.forest.length\n    for (let i = len - 1; i >= 0; i--) {\n      r = pipe(fa.forest[i], reduceRight(r, f))\n    }\n    return f(fa.value, r)\n  }\n\n/**\n * @category Extract\n * @since 2.6.2\n */\nexport const extract: <A>(wa: Tree<A>) => A = (wa) => wa.value\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse1<URI> = <F>(\n  F: ApplicativeHKT<F>\n): (<A, B>(f: (a: A) => HKT<F, B>) => (ta: Tree<A>) => HKT<F, Tree<B>>) => {\n  const traverseF = A.traverse(F)\n  const out =\n    <A, B>(f: (a: A) => HKT<F, B>) =>\n    (ta: Tree<A>): HKT<F, Tree<B>> =>\n      F.ap(\n        F.map(f(ta.value), (value: B) => (forest: Forest<B>) => ({\n          value,\n          forest\n        })),\n        pipe(ta.forest, traverseF(out(f)))\n      )\n  return out\n}\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable1<URI>['sequence'] = <F>(\n  F: ApplicativeHKT<F>\n): (<A>(ta: Tree<HKT<F, A>>) => HKT<F, Tree<A>>) => traverse(F)(identity)\n\n/**\n * @category constructors\n * @since 2.7.0\n */\nexport const of: <A>(a: A) => Tree<A> = (a) => make(a)\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Tree'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind<A> {\n    readonly [URI]: Tree<A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor1<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Pointed: Pointed1<URI> = {\n  URI,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Apply: Apply1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap\n}\n\n/**\n * Combine two effectful actions, keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const apFirst = /*#__PURE__*/ apFirst_(Apply)\n\n/**\n * Combine two effectful actions, keeping only the result of the second.\n *\n * @since 2.0.0\n */\nexport const apSecond = /*#__PURE__*/ apSecond_(Apply)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Applicative: Applicative1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Chain: Chain1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  chain: flatMap\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Monad: Monad1<URI> = {\n  URI,\n  map: _map,\n  ap: _ap,\n  of,\n  chain: flatMap\n}\n\n/**\n * Composes computations in sequence, using the return value of one computation to determine the next computation and\n * keeping only the result of the first.\n *\n * @since 2.0.0\n */\nexport const chainFirst: <A, B>(f: (a: A) => Tree<B>) => (first: Tree<A>) => Tree<A> = /*#__PURE__*/ chainFirst_(Chain)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable1<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable1<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Comonad: Comonad1<URI> = {\n  URI,\n  map: _map,\n  extend: _extend,\n  extract\n}\n\n// -------------------------------------------------------------------------------------\n// do notation\n// -------------------------------------------------------------------------------------\n\n/**\n * @category do notation\n * @since 2.9.0\n */\nexport const Do: Tree<{}> = /*#__PURE__*/ of(_.emptyRecord)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bindTo = /*#__PURE__*/ bindTo_(Functor)\n\nconst let_ = /*#__PURE__*/ let__(Functor)\n\nexport {\n  /**\n   * @category do notation\n   * @since 2.13.0\n   */\n  let_ as let\n}\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const bind = /*#__PURE__*/ bind_(Chain)\n\n/**\n * @category do notation\n * @since 2.8.0\n */\nexport const apS = /*#__PURE__*/ apS_(Apply)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.0.0\n */\nexport function elem<A>(E: Eq<A>): (a: A, fa: Tree<A>) => boolean {\n  const go = (a: A, fa: Tree<A>): boolean => E.equals(a, fa.value) || fa.forest.some((tree) => go(a, tree))\n  return go\n}\n\n/**\n * @since 2.11.0\n */\nexport const exists =\n  <A>(predicate: Predicate<A>) =>\n  (ma: Tree<A>): boolean =>\n    predicate(ma.value) || ma.forest.some(exists(predicate))\n\n// -------------------------------------------------------------------------------------\n// legacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Alias of `flatMap`.\n *\n * @category legacy\n * @since 2.0.0\n */\nexport const chain: <A, B>(f: (a: A) => Tree<B>) => (ma: Tree<A>) => Tree<B> = flatMap\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.tree`\n * (where `T` is from `import T from 'fp-ts/Tree'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const tree: Monad1<URI> & Foldable1<URI> & Traversable1<URI> & Comonad1<URI> = {\n  URI,\n  map: _map,\n  of,\n  ap: _ap,\n  chain: flatMap,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence,\n  extract,\n  extend: _extend\n}\n"
  },
  {
    "path": "src/Tuple.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Applicative, Applicative2C } from './Applicative'\nimport { Apply2C } from './Apply'\nimport { Bifunctor2 } from './Bifunctor'\nimport { Chain2C } from './Chain'\nimport { ChainRec2C } from './ChainRec'\nimport { Comonad2 } from './Comonad'\nimport { Either } from './Either'\nimport { Extend2 } from './Extend'\nimport { Foldable2 } from './Foldable'\nimport { identity, pipe } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\nimport { HKT } from './HKT'\nimport { Monad2C } from './Monad'\nimport { Monoid } from './Monoid'\nimport * as RT from './ReadonlyTuple'\nimport { Semigroup } from './Semigroup'\nimport { Semigroupoid2 } from './Semigroupoid'\nimport { PipeableTraverse2, Traversable2 } from './Traversable'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.0.0\n */\nexport const fst: <A, E>(ea: [A, E]) => A = RT.fst\n\n/**\n * @since 2.0.0\n */\nexport const snd: <A, E>(ea: [A, E]) => E = RT.snd\n\n/**\n * @since 2.0.0\n */\nexport const swap = <A, E>(ea: [A, E]): [E, A] => [snd(ea), fst(ea)]\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getApply<S>(S: Semigroup<S>): Apply2C<URI, S> {\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: (fab, fa) => [fst(fab)(fst(fa)), S.concat(snd(fab), snd(fa))]\n  }\n}\n\nconst of =\n  <M>(M: Monoid<M>) =>\n  <A>(a: A): [A, M] => {\n    return [a, M.empty]\n  }\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getApplicative<M>(M: Monoid<M>): Applicative2C<URI, M> {\n  const A = getApply(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: A.map,\n    ap: A.ap,\n    of: of(M)\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getChain<S>(S: Semigroup<S>): Chain2C<URI, S> {\n  const A = getApply(S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: A.map,\n    ap: A.ap,\n    chain: (ma, f) => {\n      const [b, s] = f(fst(ma))\n      return [b, S.concat(snd(ma), s)]\n    }\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getMonad<M>(M: Monoid<M>): Monad2C<URI, M> {\n  const C = getChain(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: C.map,\n    ap: C.ap,\n    chain: C.chain,\n    of: of(M)\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getChainRec<M>(M: Monoid<M>): ChainRec2C<URI, M> {\n  const chainRec = <A, B>(a: A, f: (a: A) => [Either<A, B>, M]): [B, M] => {\n    let result: [Either<A, B>, M] = f(a)\n    let acc: M = M.empty\n    let s: Either<A, B> = fst(result)\n    while (s._tag === 'Left') {\n      acc = M.concat(acc, snd(result))\n      result = f(s.left)\n      s = fst(result)\n    }\n    return [s.right, M.concat(acc, snd(result))]\n  }\n\n  const C = getChain(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: C.map,\n    ap: C.ap,\n    chain: C.chain,\n    chainRec\n  }\n}\n\n/* istanbul ignore next */\nconst _compose: Semigroupoid2<URI>['compose'] = (bc, ab) => pipe(bc, compose(ab))\n/* istanbul ignore next */\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, mapFst(f))\n/* istanbul ignore next */\nconst _bimap: Bifunctor2<URI>['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g))\n/* istanbul ignore next */\nconst _mapLeft: Bifunctor2<URI>['mapLeft'] = (fa, f) => pipe(fa, mapSnd(f))\n/* istanbul ignore next */\nconst _extend: Extend2<URI>['extend'] = (wa, f) => pipe(wa, extend(f))\n/* istanbul ignore next */\nconst _reduce: Foldable2<URI>['reduce'] = (fa, b, f) => pipe(fa, reduce(b, f))\n/* istanbul ignore next */\nconst _foldMap: Foldable2<URI>['foldMap'] = (M) => {\n  const foldMapM = foldMap(M)\n  return (fa, f) => pipe(fa, foldMapM(f))\n}\n/* istanbul ignore next */\nconst _reduceRight: Foldable2<URI>['reduceRight'] = (fa, b, f) => pipe(fa, reduceRight(b, f))\n/* istanbul ignore next */\nfunction _traverse<F>(F: Applicative<F>): <A, S, B>(ta: [A, S], f: (a: A) => HKT<F, B>) => HKT<F, [B, S]> {\n  const traverseF = traverse(F)\n  return (ta, f) => pipe(ta, traverseF(f))\n}\n\n/**\n * Map a pair of functions over the two type arguments of the bifunctor.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const bimap: <E, G, A, B>(mapSnd: (e: E) => G, mapFst: (a: A) => B) => (fa: [A, E]) => [B, G] = (f, g) => (fa) =>\n  [g(fst(fa)), f(snd(fa))]\n\n/**\n * Map a function over the first component of a `Tuple`.\n *\n * This is the `map` operation of the `Functor` instance.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const mapFst: <A, B>(f: (a: A) => B) => <E>(fa: [A, E]) => [B, E] = (f) => (fa) => [f(fst(fa)), snd(fa)]\n\n/**\n * Map a function over the second component of a `Tuple`.\n *\n * This is the `mapLeft` operation of the `Bifunctor` instance.\n *\n * @category mapping\n * @since 2.10.0\n */\nexport const mapSnd: <E, G>(f: (e: E) => G) => <A>(fa: [A, E]) => [A, G] = (f) => (fa) => [fst(fa), f(snd(fa))]\n\n/**\n * @since 2.0.0\n */\nexport const compose: <A, B>(ab: [B, A]) => <C>(bc: [C, B]) => [C, A] = (ab) => (bc) => [fst(bc), snd(ab)]\n\n/**\n * @since 2.0.0\n */\nexport const extend: <E, A, B>(f: (wa: [A, E]) => B) => (wa: [A, E]) => [B, E] = (f) => (wa) => [f(wa), snd(wa)]\n\n/**\n * @since 2.0.0\n */\nexport const duplicate: <E, A>(wa: [A, E]) => [[A, E], E] = /*#__PURE__*/ extend(identity)\n\n/**\n * @category Extract\n * @since 2.6.2\n */\nexport const extract: <E, A>(wa: [A, E]) => A = RT.extract\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: [A, E]) => M = RT.foldMap\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: [A, E]) => B = RT.reduce\n\n/**\n * @category folding\n * @since 2.0.0\n */\nexport const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: [A, E]) => B = RT.reduceRight\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const traverse: PipeableTraverse2<URI> = <F>(\n  F: Applicative<F>\n): (<A, B>(f: (a: A) => HKT<F, B>) => <E>(as: [A, E]) => HKT<F, [B, E]>) => {\n  return (f) => (ta) => F.map(f(fst(ta)), (b) => [b, snd(ta)])\n}\n\n/**\n * @category traversing\n * @since 2.6.3\n */\nexport const sequence: Traversable2<URI>['sequence'] =\n  <F>(F: Applicative<F>) =>\n  <A, E>(fas: [HKT<F, A>, E]): HKT<F, [A, E]> => {\n    return F.map(fst(fas), (a) => [a, snd(fas)])\n  }\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Tuple'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: [A, E]\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Bifunctor: Bifunctor2<URI> = {\n  URI,\n  bimap: _bimap,\n  mapLeft: _mapLeft\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Semigroupoid: Semigroupoid2<URI> = {\n  URI,\n  compose: _compose\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Comonad: Comonad2<URI> = {\n  URI,\n  map: _map,\n  extend: _extend,\n  extract\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Foldable: Foldable2<URI> = {\n  URI,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Traversable: Traversable2<URI> = {\n  URI,\n  map: _map,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`mapFst`](#mapfst) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: [A, E]) => [B, E] = mapFst\n\n/**\n * Use [`mapSnd`](#mapsnd) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: [A, E]) => [A, G] = mapSnd\n\n/**\n * This instance is deprecated, use small, specific instances instead.\n * For example if a function needs a `Functor` instance, pass `T.Functor` instead of `T.tuple`\n * (where `T` is from `import T from 'fp-ts/Tuple'`)\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const tuple: Semigroupoid2<URI> & Bifunctor2<URI> & Comonad2<URI> & Foldable2<URI> & Traversable2<URI> = {\n  URI,\n  compose: _compose,\n  map: _map,\n  bimap: _bimap,\n  mapLeft: _mapLeft,\n  extract,\n  extend: _extend,\n  reduce: _reduce,\n  foldMap: _foldMap,\n  reduceRight: _reduceRight,\n  traverse: _traverse,\n  sequence\n}\n"
  },
  {
    "path": "src/Unfoldable.ts",
    "content": "/**\n * This class identifies data structures which can be _unfolded_, generalizing `unfold` on arrays.\n *\n * @since 2.0.0\n */\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Option } from './Option'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Unfoldable<F> {\n  readonly URI: F\n  readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => HKT<F, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Unfoldable1<F extends URIS> {\n  readonly URI: F\n  readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind<F, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Unfoldable2<F extends URIS2> {\n  readonly URI: F\n  readonly unfold: <E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Unfoldable2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly unfold: <A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Unfoldable3<F extends URIS3> {\n  readonly URI: F\n  readonly unfold: <R, E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.10.0\n */\nexport interface Unfoldable3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly unfold: <R, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Unfoldable4<F extends URIS4> {\n  readonly URI: F\n  readonly unfold: <S, R, E, A, B>(b: B, f: (b: B) => Option<[A, B]>) => Kind4<F, S, R, E, A>\n}\n"
  },
  {
    "path": "src/ValidationT.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport {\n  ApplicativeComposition12C,\n  ApplicativeComposition22C,\n  ApplicativeCompositionHKT2C,\n  getApplicativeComposition\n} from './Applicative'\nimport * as E from './Either'\nimport { LazyArg } from './function'\nimport { HKT, Kind, Kind2, URIS, URIS2 } from './HKT'\nimport * as _ from './internal'\nimport { Monad, Monad1, Monad2 } from './Monad'\nimport { Semigroup } from './Semigroup'\n\nimport Either = E.Either\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface ValidationT<M, E, A> extends HKT<M, Either<E, A>> {}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n\nexport interface ValidationM<M, E> extends ApplicativeCompositionHKT2C<M, E.URI, E> {\n  readonly chain: <A, B>(ma: ValidationT<M, E, A>, f: (a: A) => ValidationT<M, E, B>) => ValidationT<M, E, B>\n\n  readonly alt: <A>(fa: ValidationT<M, E, A>, that: LazyArg<ValidationT<M, E, A>>) => ValidationT<M, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport type ValidationT1<M extends URIS, E, A> = Kind<M, Either<E, A>>\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n\nexport interface ValidationM1<M extends URIS, E> extends ApplicativeComposition12C<M, E.URI, E> {\n  readonly chain: <A, B>(ma: ValidationT1<M, E, A>, f: (a: A) => ValidationT1<M, E, B>) => ValidationT1<M, E, B>\n\n  readonly alt: <A>(fa: ValidationT1<M, E, A>, that: LazyArg<ValidationT1<M, E, A>>) => ValidationT1<M, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport type ValidationT2<M extends URIS2, R, E, A> = Kind2<M, R, Either<E, A>>\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n\nexport interface ValidationM2<M extends URIS2, E> extends ApplicativeComposition22C<M, E.URI, E> {\n  readonly chain: <R, A, B>(\n    ma: ValidationT2<M, R, E, A>,\n\n    f: (a: A) => ValidationT2<M, R, E, B>\n  ) => ValidationT2<M, R, E, B>\n\n  readonly alt: <R, A>(\n    fa: ValidationT2<M, R, E, A>,\n    that: LazyArg<ValidationT2<M, R, E, A>>\n  ) => ValidationT2<M, R, E, A>\n}\n\n/**\n * Use `EitherT` instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\n\nexport function getValidationM<E, M extends URIS2>(S: Semigroup<E>, M: Monad2<M>): ValidationM2<M, E>\n/** @deprecated */\n\nexport function getValidationM<E, M extends URIS>(S: Semigroup<E>, M: Monad1<M>): ValidationM1<M, E>\n/** @deprecated */\n\nexport function getValidationM<E, M>(S: Semigroup<E>, M: Monad<M>): ValidationM<M, E>\n/** @deprecated */\n\nexport function getValidationM<E, M>(S: Semigroup<E>, M: Monad<M>): ValidationM<M, E> {\n  const A = getApplicativeComposition(M, E.getApplicativeValidation(S))\n\n  return {\n    map: A.map,\n    ap: A.ap,\n    of: A.of,\n    chain: (ma, f) => M.chain(ma, (e) => (_.isLeft(e) ? M.of(_.left(e.left)) : f(e.right))),\n    alt: (me, that) =>\n      M.chain(me, (e1) =>\n        _.isRight(e1) ? M.of(e1) : M.map(that(), (e2) => (_.isLeft(e2) ? _.left(S.concat(e1.left, e2.left)) : e2))\n      )\n  }\n}\n"
  },
  {
    "path": "src/Witherable.ts",
    "content": "/**\n * `Witherable` represents data structures which can be _partitioned_ with effects in some `Applicative` functor.\n *\n * Adapted from https://github.com/LiamGoodacre/purescript-filterable/blob/master/src/Data/Witherable.purs\n *\n * @since 2.0.0\n */\nimport { Applicative, Applicative1, Applicative2, Applicative2C, Applicative3, Applicative3C } from './Applicative'\nimport { Compactable, Compactable1, Compactable2, Compactable2C } from './Compactable'\nimport { Either } from './Either'\nimport { Filterable, Filterable1, Filterable2, Filterable2C, Filterable3 } from './Filterable'\nimport { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'\nimport * as _ from './internal'\nimport { Option } from './Option'\nimport { Separated } from './Separated'\nimport { Traversable, Traversable1, Traversable2, Traversable2C, Traversable3 } from './Traversable'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Witherable<T> extends Traversable<T>, Filterable<T> {\n  /**\n   * Partition a structure with effects\n   */\n  readonly wilt: Wilt<T>\n\n  /**\n   * Filter a structure  with effects\n   */\n  readonly wither: Wither<T>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Witherable1<T extends URIS> extends Traversable1<T>, Filterable1<T> {\n  readonly wilt: Wilt1<T>\n  readonly wither: Wither1<T>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Witherable2<T extends URIS2> extends Traversable2<T>, Filterable2<T> {\n  readonly wilt: Wilt2<T>\n  readonly wither: Wither2<T>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Witherable2C<T extends URIS2, TL> extends Traversable2C<T, TL>, Filterable2C<T, TL> {\n  readonly wilt: Wilt2C<T, TL>\n  readonly wither: Wither2C<T, TL>\n}\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Witherable3<T extends URIS3> extends Traversable3<T>, Filterable3<T> {\n  readonly wilt: Wilt3<T>\n  readonly wither: Wither3<T>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wither<W> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: HKT<W, A>,\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => Kind3<F, R, E, HKT<W, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: HKT<W, A>,\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => Kind3<F, R, E, HKT<W, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: HKT<W, A>,\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => Kind2<F, E, HKT<W, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: HKT<W, A>,\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => Kind2<F, E, HKT<W, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: HKT<W, A>, f: (a: A) => Kind<F, Option<B>>) => Kind<F, HKT<W, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: HKT<W, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, HKT<W, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wither1<W extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    ta: Kind<W, A>,\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => Kind3<F, R, E, Kind<W, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    ta: Kind<W, A>,\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => Kind3<F, R, E, Kind<W, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    ta: Kind<W, A>,\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => Kind2<F, E, Kind<W, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    ta: Kind<W, A>,\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => Kind2<F, E, Kind<W, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(ta: Kind<W, A>, f: (a: A) => Kind<F, Option<B>>) => Kind<F, Kind<W, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind<W, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, Kind<W, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wither2<W extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <WE, A, R, FE, B>(\n    ta: Kind2<W, WE, A>,\n    f: (a: A) => Kind3<F, R, FE, Option<B>>\n  ) => Kind3<F, R, FE, Kind2<W, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <WE, A, FE, B>(\n    ta: Kind2<W, WE, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <WE, A, B>(\n    ta: Kind2<W, WE, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <E, A, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind<F, Option<B>>\n  ) => Kind<F, Kind2<W, E, B>>\n  <F>(F: Applicative<F>): <E, A, B>(ta: Kind2<W, E, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, Kind2<W, E, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wither2C<W extends URIS2, E> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind3<F, R, FE, Option<B>>\n  ) => Kind3<F, R, FE, Kind2<W, E, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind2<W, E, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind2<W, E, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    ta: Kind2<W, E, A>,\n    f: (a: A) => Kind<F, Option<B>>\n  ) => Kind<F, Kind2<W, E, B>>\n  <F>(F: Applicative<F>): <A, B>(ta: Kind2<W, E, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, Kind2<W, E, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wither3<W extends URIS3> {\n  <F extends URIS3>(F: Applicative3<F>): <WR, WE, A, FR, FE, B>(\n    ta: Kind3<W, WR, WE, A>,\n    f: (a: A) => Kind3<F, FR, FE, Option<B>>\n  ) => Kind3<F, FR, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <WR, WE, A, FE, B>(\n    ta: Kind3<W, WR, WE, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, WE, A, B>(\n    ta: Kind3<W, R, WE, A>,\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => Kind2<F, FE, Kind3<W, R, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <R, E, A, B>(\n    ta: Kind3<W, R, E, A>,\n    f: (a: A) => Kind<F, Option<B>>\n  ) => Kind<F, Kind3<W, R, E, B>>\n  <F>(F: Applicative<F>): <R, E, A, B>(\n    ta: Kind3<W, R, E, A>,\n    f: (a: A) => HKT<F, Option<B>>\n  ) => HKT<F, Kind3<W, R, E, B>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wilt<W> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<HKT<W, B>, HKT<W, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    wa: HKT<W, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<HKT<W, B>, HKT<W, C>>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wilt1<W extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<Kind<W, B>, Kind<W, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    wa: Kind<W, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<Kind<W, B>, Kind<W, C>>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wilt2<W extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <WE, A, R, FE, B, C>(\n    wa: Kind2<W, WE, A>,\n    f: (a: A) => Kind3<F, R, FE, Either<B, C>>\n  ) => Kind3<F, R, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <WE, A, FE, B, C>(\n    wa: Kind2<W, WE, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <WE, A, B, C>(\n    wa: Kind2<W, WE, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <E, A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F>(F: Applicative<F>): <E, A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wilt2C<W extends URIS2, E> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind3<F, R, FE, Either<B, C>>\n  ) => Kind3<F, R, FE, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    wa: Kind2<W, E, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<Kind2<W, E, B>, Kind2<W, E, C>>>\n}\n\n/**\n * @since 2.0.0\n */\nexport interface Wilt3<W extends URIS3> {\n  <F extends URIS3>(F: Applicative3<F>): <WR, WE, A, FR, FE, B, C>(\n    wa: Kind3<W, WR, WE, A>,\n    f: (a: A) => Kind3<F, FR, FE, Either<B, C>>\n  ) => Kind3<F, FR, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <R, WE, A, FE, B, C>(\n    wa: Kind3<W, R, WE, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind3<W, R, WE, B>, Kind3<W, R, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <R, WE, A, B, C>(\n    wa: Kind3<W, R, WE, A>,\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => Kind2<F, FE, Separated<Kind3<W, R, WE, B>, Kind3<W, R, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <R, E, A, B, C>(\n    wa: Kind3<W, R, E, A>,\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => Kind<F, Separated<Kind3<W, R, E, B>, Kind3<W, R, E, C>>>\n  <F>(F: Applicative<F>): <R, E, A, B, C>(\n    wa: Kind3<W, R, E, A>,\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => HKT<F, Separated<Kind3<W, R, E, B>, Kind3<W, R, E, C>>>\n}\n\n//\n// pipeable `Wither`\n//\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWither<W> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => (ta: HKT<W, A>) => Kind3<F, R, E, HKT<W, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => (ta: HKT<W, A>) => Kind3<F, R, E, HKT<W, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => (ta: HKT<W, A>) => Kind2<F, E, HKT<W, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => (ta: HKT<W, A>) => Kind2<F, E, HKT<W, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(f: (a: A) => Kind<F, Option<B>>) => (ta: HKT<W, A>) => Kind<F, HKT<W, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => (ta: HKT<W, A>) => HKT<F, HKT<W, B>>\n}\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWither1<W extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B>(\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind3<F, R, E, Kind<W, B>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B>(\n    f: (a: A) => Kind3<F, R, E, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind3<F, R, E, Kind<W, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B>(\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind2<F, E, Kind<W, B>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B>(\n    f: (a: A) => Kind2<F, E, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind2<F, E, Kind<W, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, Option<B>>\n  ) => (ta: Kind<W, A>) => Kind<F, Kind<W, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => (ta: Kind<W, A>) => HKT<F, Kind<W, B>>\n}\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWither2<W extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    f: (a: A) => Kind3<F, R, FE, Option<B>>\n  ) => <WE>(ta: Kind2<W, WE, A>) => Kind3<F, R, FE, Kind2<W, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => <WE>(ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => <WE>(ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, Option<B>>\n  ) => <WE>(ta: Kind2<W, WE, A>) => Kind<F, Kind2<W, WE, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => <WE>(ta: Kind2<W, WE, A>) => HKT<F, Kind2<W, WE, B>>\n}\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWither2C<W extends URIS2, WE> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B>(\n    f: (a: A) => Kind3<F, R, FE, Option<B>>\n  ) => (ta: Kind2<W, WE, A>) => Kind3<F, R, FE, Kind2<W, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => (ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => (ta: Kind2<W, WE, A>) => Kind2<F, FE, Kind2<W, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, Option<B>>\n  ) => (ta: Kind2<W, WE, A>) => Kind<F, Kind2<W, WE, B>>\n  <F>(F: Applicative<F>): <A, B>(f: (a: A) => HKT<F, Option<B>>) => (ta: Kind2<W, WE, A>) => HKT<F, Kind2<W, WE, B>>\n}\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWither3<W extends URIS3> {\n  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B>(\n    f: (a: A) => Kind3<F, FR, FE, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind3<F, FR, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind2<F, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B>(\n    f: (a: A) => Kind2<F, FE, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind2<F, FE, Kind3<W, WR, WE, B>>\n  <F extends URIS>(F: Applicative1<F>): <A, B>(\n    f: (a: A) => Kind<F, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => Kind<F, Kind3<W, WR, WE, B>>\n  <F>(F: Applicative<F>): <A, B>(\n    f: (a: A) => HKT<F, Option<B>>\n  ) => <WR, WE>(ta: Kind3<W, WR, WE, A>) => HKT<F, Kind3<W, WR, WE, B>>\n}\n\n//\n// pipeable `Wilt`\n//\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWilt<W> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind3<F, R, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind2<F, E, Separated<HKT<W, B>, HKT<W, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => (wa: HKT<W, A>) => Kind<F, Separated<HKT<W, B>, HKT<W, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => (wa: HKT<W, A>) => HKT<F, Separated<HKT<W, B>, HKT<W, C>>>\n}\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWilt1<W extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E, B, C>(\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R, B, C>(\n    f: (a: A) => Kind3<F, R, E, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind3<F, R, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E, B, C>(\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A, B, C>(\n    f: (a: A) => Kind2<F, E, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind2<F, E, Separated<Kind<W, B>, Kind<W, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => (wa: Kind<W, A>) => Kind<F, Separated<Kind<W, B>, Kind<W, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => (wa: Kind<W, A>) => HKT<F, Separated<Kind<W, B>, Kind<W, C>>>\n}\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWilt2<W extends URIS2> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B, C>(\n    f: (a: A) => Kind3<F, R, FE, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => Kind3<F, R, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => Kind<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => <WE>(wa: Kind2<W, WE, A>) => HKT<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n}\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWilt2C<W extends URIS2, WE> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, FE, B, C>(\n    f: (a: A) => Kind3<F, R, FE, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => Kind3<F, R, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => Kind2<F, FE, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => Kind<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => (wa: Kind2<W, WE, A>) => HKT<F, Separated<Kind2<W, WE, B>, Kind2<W, WE, C>>>\n}\n\n/**\n * @since 2.6.5\n */\nexport interface PipeableWilt3<W extends URIS3> {\n  <F extends URIS3>(F: Applicative3<F>): <A, FR, FE, B, C>(\n    f: (a: A) => Kind3<F, FR, FE, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind3<F, FR, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F extends URIS2>(F: Applicative2<F>): <A, FE, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind2<F, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F extends URIS2, FE>(F: Applicative2C<F, FE>): <A, B, C>(\n    f: (a: A) => Kind2<F, FE, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind2<F, FE, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F extends URIS>(F: Applicative1<F>): <A, B, C>(\n    f: (a: A) => Kind<F, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => Kind<F, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n  <F>(F: Applicative<F>): <A, B, C>(\n    f: (a: A) => HKT<F, Either<B, C>>\n  ) => <WR, WE>(wa: Kind3<W, WR, WE, A>) => HKT<F, Separated<Kind3<W, WR, WE, B>, Kind3<W, WR, WE, C>>>\n}\n\n// -------------------------------------------------------------------------------------\n// defaults\n// -------------------------------------------------------------------------------------\n\n/**\n * Return a `wilt` implementation from `Traversable` and `Compactable`.\n *\n * @category defaults\n * @since 2.11.0\n */\nexport function wiltDefault<W extends URIS2, E>(T: Traversable2C<W, E>, C: Compactable2<W>): Witherable2C<W, E>['wilt']\nexport function wiltDefault<W extends URIS2, E>(T: Traversable2<W>, C: Compactable2C<W, E>): Witherable2C<W, E>['wilt']\nexport function wiltDefault<W extends URIS>(T: Traversable1<W>, C: Compactable1<W>): Witherable1<W>['wilt']\nexport function wiltDefault<W>(T: Traversable<W>, C: Compactable<W>): Witherable<W>['wilt']\nexport function wiltDefault<W>(T: Traversable<W>, C: Compactable<W>): Witherable<W>['wilt'] {\n  return <F>(\n    F: Applicative<F>\n  ): (<A, B, C>(wa: HKT<W, A>, f: (a: A) => HKT<F, Either<B, C>>) => HKT<F, Separated<HKT<W, B>, HKT<W, C>>>) => {\n    const traverseF = T.traverse(F)\n    return (wa, f) => F.map(traverseF(wa, f), C.separate)\n  }\n}\n\n/**\n * Return a `wither` implementation from `Traversable` and `Compactable`.\n *\n * @category defaults\n * @since 2.11.0\n */\nexport function witherDefault<W extends URIS2, E>(\n  T: Traversable2C<W, E>,\n  C: Compactable2<W>\n): Witherable2C<W, E>['wither']\nexport function witherDefault<W extends URIS2, E>(\n  T: Traversable2<W>,\n  C: Compactable2C<W, E>\n): Witherable2C<W, E>['wither']\nexport function witherDefault<W extends URIS>(T: Traversable1<W>, C: Compactable1<W>): Witherable1<W>['wither']\nexport function witherDefault<W>(T: Traversable<W>, C: Compactable<W>): Witherable<W>['wither']\nexport function witherDefault<W>(T: Traversable<W>, C: Compactable<W>): Witherable<W>['wither'] {\n  return <F>(F: Applicative<F>): (<A, B>(wa: HKT<W, A>, f: (a: A) => HKT<F, Option<B>>) => HKT<F, HKT<W, B>>) => {\n    const traverseF = T.traverse(F)\n    return (wa, f) => F.map(traverseF(wa, f), C.compact)\n  }\n}\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport interface FilterE1<G extends URIS> {\n  <F extends URIS3>(F: Applicative3<F>): <A, R, E>(\n    predicate: (a: A) => Kind3<F, R, E, boolean>\n  ) => (ga: Kind<G, A>) => Kind3<F, R, E, Kind<G, A>>\n  <F extends URIS3, E>(F: Applicative3C<F, E>): <A, R>(\n    predicate: (a: A) => Kind3<F, R, E, boolean>\n  ) => (ga: Kind<G, A>) => Kind3<F, R, E, Kind<G, A>>\n  <F extends URIS2>(F: Applicative2<F>): <A, E>(\n    predicate: (a: A) => Kind2<F, E, boolean>\n  ) => (ga: Kind<G, A>) => Kind2<F, E, Kind<G, A>>\n  <F extends URIS2, E>(F: Applicative2C<F, E>): <A>(\n    predicate: (a: A) => Kind2<F, E, boolean>\n  ) => (ga: Kind<G, A>) => Kind2<F, E, Kind<G, A>>\n  <F extends URIS>(F: Applicative1<F>): <A>(\n    predicate: (a: A) => Kind<F, boolean>\n  ) => (ga: Kind<G, A>) => Kind<F, Kind<G, A>>\n  <F>(F: Applicative<F>): <A>(predicate: (a: A) => HKT<F, boolean>) => (ga: Kind<G, A>) => HKT<F, Kind<G, A>>\n}\n\n/**\n * Filter values inside a `F` context.\n *\n * See `ReadonlyArray`'s `filterE` for an example of usage.\n *\n * @since 2.11.0\n */\nexport function filterE<G extends URIS>(W: Witherable1<G>): FilterE1<G>\nexport function filterE<G>(\n  W: Witherable<G>\n): <F>(F: Applicative<F>) => <A>(predicate: (a: A) => HKT<F, boolean>) => (ga: HKT<G, A>) => HKT<F, HKT<G, A>>\nexport function filterE<G>(\n  W: Witherable<G>\n): <F>(F: Applicative<F>) => <A>(predicate: (a: A) => HKT<F, boolean>) => (ga: HKT<G, A>) => HKT<F, HKT<G, A>> {\n  return (F) => {\n    const witherF = W.wither(F)\n    return (predicate) => (ga) => witherF(ga, (a) => F.map(predicate(a), (b) => (b ? _.some(a) : _.none)))\n  }\n}\n"
  },
  {
    "path": "src/Writer.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Applicative2C } from './Applicative'\nimport { Apply2C } from './Apply'\nimport { Chain2C } from './Chain'\nimport { pipe } from './function'\nimport { flap as flap_, Functor2 } from './Functor'\nimport { Monad2C } from './Monad'\nimport { Monoid } from './Monoid'\nimport { Pointed2C } from './Pointed'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.0.0\n */\nexport interface Writer<W, A> {\n  (): [A, W]\n}\n\n// -------------------------------------------------------------------------------------\n// constructors\n// -------------------------------------------------------------------------------------\n\n/**\n * Appends a value to the accumulator\n *\n * @category constructors\n * @since 2.0.0\n */\nexport const tell: <W>(w: W) => Writer<W, void> = (w) => () => [undefined, w]\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * Modifies the result to include the changes to the accumulator\n *\n * @since 2.0.0\n */\nexport const listen: <W, A>(fa: Writer<W, A>) => Writer<W, [A, W]> = (fa) => () => {\n  const [a, w] = fa()\n  return [[a, w], w]\n}\n\n/**\n * Applies the returned function to the accumulator\n *\n * @since 2.0.0\n */\nexport const pass: <W, A>(fa: Writer<W, [A, (w: W) => W]>) => Writer<W, A> = (fa) => () => {\n  const [[a, f], w] = fa()\n  return [a, f(w)]\n}\n\n/**\n * Projects a value from modifications made to the accumulator during an action\n *\n * @since 2.0.0\n */\nexport const listens: <W, B>(f: (w: W) => B) => <A>(fa: Writer<W, A>) => Writer<W, [A, B]> = (f) => (fa) => () => {\n  const [a, w] = fa()\n  return [[a, f(w)], w]\n}\n\n/**\n * Modify the final accumulator value by applying a function\n *\n * @since 2.0.0\n */\nexport const censor: <W>(f: (w: W) => W) => <A>(fa: Writer<W, A>) => Writer<W, A> = (f) => (fa) => () => {\n  const [a, w] = fa()\n  return [a, f(w)]\n}\n\n/* istanbul ignore next */\nconst _map: Functor2<URI>['map'] = (fa, f) => pipe(fa, map(f))\n\n/**\n * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types\n * use the type constructor `F` to represent some computational context.\n *\n * @category mapping\n * @since 2.0.0\n */\nexport const map: <A, B>(f: (a: A) => B) => <E>(fa: Writer<E, A>) => Writer<E, B> = (f) => (fa) => () => {\n  const [a, w] = fa()\n  return [f(a), w]\n}\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport const URI = 'Writer'\n\n/**\n * @category type lambdas\n * @since 2.0.0\n */\nexport type URI = typeof URI\n\ndeclare module './HKT' {\n  interface URItoKind2<E, A> {\n    readonly [URI]: Writer<E, A>\n  }\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getPointed = <W>(M: Monoid<W>): Pointed2C<URI, W> => ({\n  URI,\n  _E: undefined as any,\n  of: (a) => () => [a, M.empty]\n})\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getApply = <W>(S: Semigroup<W>): Apply2C<URI, W> => ({\n  URI,\n  _E: undefined as any,\n  map: _map,\n  ap: (fab, fa) => () => {\n    const [f, w1] = fab()\n    const [a, w2] = fa()\n    return [f(a), S.concat(w1, w2)]\n  }\n})\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getApplicative = <W>(M: Monoid<W>): Applicative2C<URI, W> => {\n  const A = getApply(M)\n  const P = getPointed(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: A.ap,\n    of: P.of\n  }\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport function getChain<W>(S: Semigroup<W>): Chain2C<URI, W> {\n  const A = getApply(S)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: A.ap,\n    chain: (fa, f) => () => {\n      const [a, w1] = fa()\n      const [b, w2] = f(a)()\n      return [b, S.concat(w1, w2)]\n    }\n  }\n}\n\n/**\n * @category instances\n * @since 2.0.0\n */\nexport function getMonad<W>(M: Monoid<W>): Monad2C<URI, W> {\n  const A = getApplicative(M)\n  const C = getChain(M)\n  return {\n    URI,\n    _E: undefined as any,\n    map: _map,\n    ap: A.ap,\n    of: A.of,\n    chain: C.chain\n  }\n}\n\n/**\n * @category instances\n * @since 2.7.0\n */\nexport const Functor: Functor2<URI> = {\n  URI,\n  map: _map\n}\n\n/**\n * @category mapping\n * @since 2.10.0\n */\nexport const flap = /*#__PURE__*/ flap_(Functor)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.8.0\n */\nexport const evaluate: <W, A>(fa: Writer<W, A>) => A = (fa) => fa()[0]\n\n/**\n * @since 2.8.0\n */\nexport const execute: <W, A>(fa: Writer<W, A>) => W = (fa) => fa()[1]\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use [`evaluate`](#evaluate) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const evalWriter: <W, A>(fa: Writer<W, A>) => A = (fa) => fa()[0]\n\n/**\n * Use [`execute`](#execute) instead\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const execWriter: <W, A>(fa: Writer<W, A>) => W = (fa) => fa()[1]\n\n/**\n * Use [`Functor`](#functor) instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport const writer: Functor2<URI> = Functor\n"
  },
  {
    "path": "src/WriterT.ts",
    "content": "/**\n * @since 2.4.0\n */\nimport { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT'\nimport { Monad, Monad1, Monad2, Monad2C, Monad3 } from './Monad'\nimport { Monoid } from './Monoid'\n\n// TODO: remove module in v3\n\n/**\n * @category model\n * @since 2.4.0\n */\nexport interface WriterT<M, W, A> {\n  (): HKT<M, [A, W]>\n}\n\n/**\n * @since 2.4.0\n */\nexport interface WriterM<M> {\n  readonly map: <W, A, B>(fa: WriterT<M, W, A>, f: (a: A) => B) => WriterT<M, W, B>\n  readonly evalWriter: <W, A>(fa: WriterT<M, W, A>) => HKT<M, A>\n  readonly execWriter: <W, A>(fa: WriterT<M, W, A>) => HKT<M, W>\n  readonly tell: <W>(w: W) => WriterT<M, W, void>\n  readonly listen: <W, A>(fa: WriterT<M, W, A>) => WriterT<M, W, [A, W]>\n  readonly pass: <W, A>(fa: WriterT<M, W, [A, (w: W) => W]>) => WriterT<M, W, A>\n  readonly listens: <W, A, B>(fa: WriterT<M, W, A>, f: (w: W) => B) => WriterT<M, W, [A, B]>\n  readonly censor: <W, A>(fa: WriterT<M, W, A>, f: (w: W) => W) => WriterT<M, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <A, B>(ma: WriterT<M, W, A>, f: (a: A) => B) => WriterT<M, W, B>\n    readonly of: <A>(a: A) => WriterT<M, W, A>\n    readonly ap: <A, B>(mab: WriterT<M, W, (a: A) => B>, ma: WriterT<M, W, A>) => WriterT<M, W, B>\n    readonly chain: <A, B>(ma: WriterT<M, W, A>, f: (a: A) => WriterT<M, W, B>) => WriterT<M, W, B>\n  }\n}\n\n/**\n * @category model\n * @since 2.4.0\n */\nexport interface WriterT1<M extends URIS, W, A> {\n  (): Kind<M, [A, W]>\n}\n\n/**\n * @since 2.4.0\n */\nexport interface WriterM1<M extends URIS> {\n  readonly map: <W, A, B>(fa: WriterT1<M, W, A>, f: (a: A) => B) => WriterT1<M, W, B>\n  readonly evalWriter: <W, A>(fa: WriterT1<M, W, A>) => Kind<M, A>\n  readonly execWriter: <W, A>(fa: WriterT1<M, W, A>) => Kind<M, W>\n  readonly tell: <W>(w: W) => WriterT1<M, W, void>\n  readonly listen: <W, A>(fa: WriterT1<M, W, A>) => WriterT1<M, W, [A, W]>\n  readonly pass: <W, A>(fa: WriterT1<M, W, [A, (w: W) => W]>) => WriterT1<M, W, A>\n  readonly listens: <W, A, B>(fa: WriterT1<M, W, A>, f: (w: W) => B) => WriterT1<M, W, [A, B]>\n  readonly censor: <W, A>(fa: WriterT1<M, W, A>, f: (w: W) => W) => WriterT1<M, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <A, B>(ma: WriterT1<M, W, A>, f: (a: A) => B) => WriterT1<M, W, B>\n    readonly of: <A>(a: A) => WriterT1<M, W, A>\n    readonly ap: <A, B>(mab: WriterT1<M, W, (a: A) => B>, ma: WriterT1<M, W, A>) => WriterT1<M, W, B>\n    readonly chain: <A, B>(ma: WriterT1<M, W, A>, f: (a: A) => WriterT1<M, W, B>) => WriterT1<M, W, B>\n  }\n}\n\n/**\n * @category model\n * @since 2.4.0\n */\nexport interface WriterT2<M extends URIS2, E, W, A> {\n  (): Kind2<M, E, [A, W]>\n}\n\n/**\n * @since 2.4.0\n */\nexport interface WriterM2<M extends URIS2> {\n  readonly map: <E, W, A, B>(fa: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>\n  readonly evalWriter: <E, W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, A>\n  readonly execWriter: <E, W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, W>\n  readonly tell: <E, W>(w: W) => WriterT2<M, E, W, void>\n  readonly listen: <E, W, A>(fa: WriterT2<M, E, W, A>) => WriterT2<M, E, W, [A, W]>\n  readonly pass: <E, W, A>(fa: WriterT2<M, E, W, [A, (w: W) => W]>) => WriterT2<M, E, W, A>\n  readonly listens: <E, W, A, B>(fa: WriterT2<M, E, W, A>, f: (w: W) => B) => WriterT2<M, E, W, [A, B]>\n  readonly censor: <E, W, A>(fa: WriterT2<M, E, W, A>, f: (w: W) => W) => WriterT2<M, E, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <E, A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>\n    readonly of: <E, A>(a: A) => WriterT2<M, E, W, A>\n    readonly ap: <E, A, B>(mab: WriterT2<M, E, W, (a: A) => B>, ma: WriterT2<M, E, W, A>) => WriterT2<M, E, W, B>\n    readonly chain: <E, A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => WriterT2<M, E, W, B>) => WriterT2<M, E, W, B>\n  }\n}\n\n/**\n * @since 2.4.0\n */\nexport interface WriterM2C<M extends URIS2, E> {\n  readonly map: <W, A, B>(fa: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>\n  readonly evalWriter: <W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, A>\n  readonly execWriter: <W, A>(fa: WriterT2<M, E, W, A>) => Kind2<M, E, W>\n  readonly tell: <W>(w: W) => WriterT2<M, E, W, void>\n  readonly listen: <W, A>(fa: WriterT2<M, E, W, A>) => WriterT2<M, E, W, [A, W]>\n  readonly pass: <W, A>(fa: WriterT2<M, E, W, [A, (w: W) => W]>) => WriterT2<M, E, W, A>\n  readonly listens: <W, A, B>(fa: WriterT2<M, E, W, A>, f: (w: W) => B) => WriterT2<M, E, W, [A, B]>\n  readonly censor: <W, A>(fa: WriterT2<M, E, W, A>, f: (w: W) => W) => WriterT2<M, E, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => B) => WriterT2<M, E, W, B>\n    readonly of: <A>(a: A) => WriterT2<M, E, W, A>\n    readonly ap: <A, B>(mab: WriterT2<M, E, W, (a: A) => B>, ma: WriterT2<M, E, W, A>) => WriterT2<M, E, W, B>\n    readonly chain: <A, B>(ma: WriterT2<M, E, W, A>, f: (a: A) => WriterT2<M, E, W, B>) => WriterT2<M, E, W, B>\n  }\n}\n\n/**\n * @since 2.4.0\n */\nexport interface WriterT3<M extends URIS3, R, E, W, A> {\n  (): Kind3<M, R, E, [A, W]>\n}\n\n/**\n * @since 2.4.0\n */\nexport interface WriterM3<M extends URIS3> {\n  readonly map: <R, E, W, A, B>(fa: WriterT3<M, R, E, W, A>, f: (a: A) => B) => WriterT3<M, R, E, W, B>\n  readonly evalWriter: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>) => Kind3<M, R, E, A>\n  readonly execWriter: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>) => Kind3<M, R, E, W>\n  readonly tell: <R, E, W>(w: W) => WriterT3<M, R, E, W, void>\n  readonly listen: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>) => WriterT3<M, R, E, W, [A, W]>\n  readonly pass: <R, E, W, A>(fa: WriterT3<M, R, E, W, [A, (w: W) => W]>) => WriterT3<M, R, E, W, A>\n  readonly listens: <R, E, W, A, B>(fa: WriterT3<M, R, E, W, A>, f: (w: W) => B) => WriterT3<M, R, E, W, [A, B]>\n  readonly censor: <R, E, W, A>(fa: WriterT3<M, R, E, W, A>, f: (w: W) => W) => WriterT3<M, R, E, W, A>\n  readonly getMonad: <W>(M: Monoid<W>) => {\n    readonly _E: W\n    readonly map: <R, E, A, B>(ma: WriterT3<M, R, E, W, A>, f: (a: A) => B) => WriterT3<M, R, E, W, B>\n    readonly of: <R, E, A>(a: A) => WriterT3<M, R, E, W, A>\n    readonly ap: <R, E, A, B>(\n      mab: WriterT3<M, R, E, W, (a: A) => B>,\n      ma: WriterT3<M, R, E, W, A>\n    ) => WriterT3<M, R, E, W, B>\n    readonly chain: <R, E, A, B>(\n      ma: WriterT3<M, R, E, W, A>,\n      f: (a: A) => WriterT3<M, R, E, W, B>\n    ) => WriterT3<M, R, E, W, B>\n  }\n}\n\n/**\n * @since 2.4.0\n */\nexport function getWriterM<M extends URIS3>(M: Monad3<M>): WriterM3<M>\nexport function getWriterM<M extends URIS2>(M: Monad2<M>): WriterM2<M>\nexport function getWriterM<M extends URIS2, E>(M: Monad2C<M, E>): WriterM2C<M, E>\nexport function getWriterM<M extends URIS>(M: Monad1<M>): WriterM1<M>\nexport function getWriterM<M>(M: Monad<M>): WriterM<M>\nexport function getWriterM<M>(M: Monad<M>): WriterM<M> {\n  const map =\n    <W, A, B>(fa: WriterT<M, W, A>, f: (a: A) => B): WriterT<M, W, B> =>\n    () =>\n      M.map(fa(), ([a, w]) => [f(a), w])\n  return {\n    map,\n    evalWriter: (fa) => M.map(fa(), ([a]) => a),\n    execWriter: (fa) => M.map(fa(), ([_, w]) => w),\n    tell: (w) => () => M.of([undefined, w]),\n    listen: (fa) => () => M.map(fa(), ([a, w]) => [[a, w], w]),\n    pass: (fa) => () => M.map(fa(), ([[a, f], w]) => [a, f(w)]),\n    listens: (fa, f) => () => M.map(fa(), ([a, w]) => [[a, f(w)], w]),\n    censor: (fa, f) => () => M.map(fa(), ([a, w]) => [a, f(w)]),\n    getMonad: (W) => {\n      return {\n        _E: undefined as any,\n        map,\n        of: (a) => () => M.of([a, W.empty]),\n        ap: (mab, ma) => () => M.chain(mab(), ([f, w1]) => M.map(ma(), ([a, w2]) => [f(a), W.concat(w1, w2)])),\n        chain: (ma, f) => () => M.chain(ma(), ([a, w1]) => M.map(f(a)(), ([b, w2]) => [b, W.concat(w1, w2)]))\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "src/Zero.ts",
    "content": "/**\n * @since 2.11.0\n */\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport { Pointed, Pointed1, Pointed2, Pointed2C, Pointed3, Pointed3C, Pointed4 } from './Pointed'\n\n// -------------------------------------------------------------------------------------\n// model\n// -------------------------------------------------------------------------------------\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface Zero<F> {\n  readonly URI: F\n  readonly zero: <A>() => HKT<F, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface Zero1<F extends URIS> {\n  readonly URI: F\n  readonly zero: <A>() => Kind<F, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface Zero2<F extends URIS2> {\n  readonly URI: F\n  readonly zero: <E, A>() => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface Zero2C<F extends URIS2, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly zero: <A>() => Kind2<F, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface Zero3<F extends URIS3> {\n  readonly URI: F\n  readonly zero: <R, E, A>() => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface Zero3C<F extends URIS3, E> {\n  readonly URI: F\n  readonly _E: E\n  readonly zero: <R, A>() => Kind3<F, R, E, A>\n}\n\n/**\n * @category model\n * @since 2.11.0\n */\nexport interface Zero4<F extends URIS4> {\n  readonly URI: F\n  readonly zero: <S, R, E, A>() => Kind4<F, S, R, E, A>\n}\n\n/**\n * @category do notation\n * @since 2.11.0\n */\nexport function guard<F extends URIS4>(F: Zero4<F>, P: Pointed4<F>): <S, R, E>(b: boolean) => Kind4<F, S, R, E, void>\nexport function guard<F extends URIS3>(F: Zero3<F>, P: Pointed3<F>): <R, E>(b: boolean) => Kind3<F, R, E, void>\nexport function guard<F extends URIS3, E>(F: Zero3C<F, E>, P: Pointed3C<F, E>): <R>(b: boolean) => Kind3<F, R, E, void>\nexport function guard<F extends URIS2>(F: Zero2<F>, P: Pointed2<F>): <E>(b: boolean) => Kind2<F, E, void>\nexport function guard<F extends URIS2, E>(F: Zero2C<F, E>, P: Pointed2C<F, E>): (b: boolean) => Kind2<F, E, void>\nexport function guard<F extends URIS>(F: Zero1<F>, P: Pointed1<F>): (b: boolean) => Kind<F, void>\nexport function guard<F>(F: Zero<F>, P: Pointed<F>): (b: boolean) => HKT<F, void>\nexport function guard<F>(F: Zero<F>, P: Pointed<F>): (b: boolean) => HKT<F, void> {\n  return (b) => (b ? P.of(undefined) : F.zero())\n}\n"
  },
  {
    "path": "src/boolean.ts",
    "content": "/**\n * @since 2.2.0\n */\nimport * as BA from './BooleanAlgebra'\nimport * as E from './Eq'\nimport { LazyArg } from './function'\nimport { Monoid } from './Monoid'\nimport * as O from './Ord'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport * as S from './Show'\n\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n\n/**\n * @category refinements\n * @since 2.11.0\n */\nexport const isBoolean: Refinement<unknown, boolean> = (u: unknown): u is boolean => typeof u === 'boolean'\n\n/**\n * Less strict version of [`match`](#match).\n *\n * The `W` suffix (short for **W**idening) means that the handler return types will be merged.\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const matchW =\n  <A, B>(onFalse: LazyArg<A>, onTrue: LazyArg<B>) =>\n  (value: boolean): A | B =>\n    value ? onTrue() : onFalse()\n\n/**\n * Alias of [`matchW`](#matchw).\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const foldW = matchW\n\n/**\n * Defines the fold over a boolean value.\n * Takes two thunks `onTrue`, `onFalse` and a `boolean` value.\n * If `value` is false, `onFalse()` is returned, otherwise `onTrue()`.\n *\n * @example\n * import { some, map } from 'fp-ts/Option'\n * import { pipe } from 'fp-ts/function'\n * import { match } from 'fp-ts/boolean'\n *\n * assert.deepStrictEqual(\n *  pipe(\n *    some(true),\n *    map(match(() => 'false', () => 'true'))\n *  ),\n *  some('true')\n * )\n *\n * @category pattern matching\n * @since 2.10.0\n */\nexport const match: <A>(onFalse: LazyArg<A>, onTrue: LazyArg<A>) => (value: boolean) => A = foldW\n\n/**\n * Alias of [`match`](#match).\n *\n * @category pattern matching\n * @since 2.2.0\n */\nexport const fold = match\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Eq: E.Eq<boolean> = {\n  equals: (first, second) => first === second\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const BooleanAlgebra: BA.BooleanAlgebra<boolean> = {\n  meet: (first, second) => first && second,\n  join: (first, second) => first || second,\n  zero: false,\n  one: true,\n  implies: (first, second) => !first || second,\n  not: (b) => !b\n}\n\n/**\n * `boolean` semigroup under conjunction.\n *\n * @example\n * import { SemigroupAll } from 'fp-ts/boolean'\n *\n * assert.deepStrictEqual(SemigroupAll.concat(true, true), true)\n * assert.deepStrictEqual(SemigroupAll.concat(true, false), false)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const SemigroupAll: Semigroup<boolean> = {\n  concat: (first, second) => first && second\n}\n\n/**\n * `boolean` semigroup under disjunction.\n *\n * @example\n * import { SemigroupAny } from 'fp-ts/boolean'\n *\n * assert.deepStrictEqual(SemigroupAny.concat(true, true), true)\n * assert.deepStrictEqual(SemigroupAny.concat(true, false), true)\n * assert.deepStrictEqual(SemigroupAny.concat(false, false), false)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const SemigroupAny: Semigroup<boolean> = {\n  concat: (first, second) => first || second\n}\n\n/**\n * `boolean` monoid under conjunction.\n *\n * The `empty` value is `true`.\n *\n * @example\n * import { MonoidAll } from 'fp-ts/boolean'\n *\n * assert.deepStrictEqual(MonoidAll.concat(true, true), true)\n * assert.deepStrictEqual(MonoidAll.concat(true, false), false)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const MonoidAll: Monoid<boolean> = {\n  concat: SemigroupAll.concat,\n  empty: true\n}\n\n/**\n * `boolean` monoid under disjunction.\n *\n * The `empty` value is `false`.\n *\n * @example\n * import { MonoidAny } from 'fp-ts/boolean'\n *\n * assert.deepStrictEqual(MonoidAny.concat(true, true), true)\n * assert.deepStrictEqual(MonoidAny.concat(true, false), true)\n * assert.deepStrictEqual(MonoidAny.concat(false, false), false)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const MonoidAny: Monoid<boolean> = {\n  concat: SemigroupAny.concat,\n  empty: false\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Ord: O.Ord<boolean> = {\n  equals: Eq.equals,\n  compare: (first, second) => (first < second ? -1 : first > second ? 1 : 0)\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Show: S.Show<boolean> = {\n  show: (b) => JSON.stringify(b)\n}\n"
  },
  {
    "path": "src/function.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { BooleanAlgebra } from './BooleanAlgebra'\nimport { Monoid } from './Monoid'\nimport { Ring } from './Ring'\nimport { Semigroup } from './Semigroup'\nimport { Semiring } from './Semiring'\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getBooleanAlgebra =\n  <B>(B: BooleanAlgebra<B>) =>\n  <A = never>(): BooleanAlgebra<(a: A) => B> => ({\n    meet: (x, y) => (a) => B.meet(x(a), y(a)),\n    join: (x, y) => (a) => B.join(x(a), y(a)),\n    zero: () => B.zero,\n    one: () => B.one,\n    implies: (x, y) => (a) => B.implies(x(a), y(a)),\n    not: (x) => (a) => B.not(x(a))\n  })\n\n/**\n * Unary functions form a semigroup as long as you can provide a semigroup for the codomain.\n *\n * @example\n * import { Predicate, getSemigroup } from 'fp-ts/function'\n * import * as B from 'fp-ts/boolean'\n *\n * const f: Predicate<number> = (n) => n <= 2\n * const g: Predicate<number> = (n) => n >= 0\n *\n * const S1 = getSemigroup(B.SemigroupAll)<number>()\n *\n * assert.deepStrictEqual(S1.concat(f, g)(1), true)\n * assert.deepStrictEqual(S1.concat(f, g)(3), false)\n *\n * const S2 = getSemigroup(B.SemigroupAny)<number>()\n *\n * assert.deepStrictEqual(S2.concat(f, g)(1), true)\n * assert.deepStrictEqual(S2.concat(f, g)(3), true)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const getSemigroup =\n  <S>(S: Semigroup<S>) =>\n  <A = never>(): Semigroup<(a: A) => S> => ({\n    concat: (f, g) => (a) => S.concat(f(a), g(a))\n  })\n\n/**\n * Unary functions form a monoid as long as you can provide a monoid for the codomain.\n *\n * @example\n * import { Predicate } from 'fp-ts/Predicate'\n * import { getMonoid } from 'fp-ts/function'\n * import * as B from 'fp-ts/boolean'\n *\n * const f: Predicate<number> = (n) => n <= 2\n * const g: Predicate<number> = (n) => n >= 0\n *\n * const M1 = getMonoid(B.MonoidAll)<number>()\n *\n * assert.deepStrictEqual(M1.concat(f, g)(1), true)\n * assert.deepStrictEqual(M1.concat(f, g)(3), false)\n *\n * const M2 = getMonoid(B.MonoidAny)<number>()\n *\n * assert.deepStrictEqual(M2.concat(f, g)(1), true)\n * assert.deepStrictEqual(M2.concat(f, g)(3), true)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const getMonoid = <M>(M: Monoid<M>): (<A = never>() => Monoid<(a: A) => M>) => {\n  const getSemigroupM = getSemigroup(M)\n  return <A>() => ({\n    concat: getSemigroupM<A>().concat,\n    empty: () => M.empty\n  })\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getSemiring = <A, B>(S: Semiring<B>): Semiring<(a: A) => B> => ({\n  add: (f, g) => (x) => S.add(f(x), g(x)),\n  zero: () => S.zero,\n  mul: (f, g) => (x) => S.mul(f(x), g(x)),\n  one: () => S.one\n})\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const getRing = <A, B>(R: Ring<B>): Ring<(a: A) => B> => {\n  const S = getSemiring<A, B>(R)\n  return {\n    add: S.add,\n    mul: S.mul,\n    one: S.one,\n    zero: S.zero,\n    sub: (f, g) => (x) => R.sub(f(x), g(x))\n  }\n}\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * @since 2.11.0\n */\nexport const apply =\n  <A>(a: A) =>\n  <B>(f: (a: A) => B): B =>\n    f(a)\n\n/**\n * @example\n * import { FunctionN } from 'fp-ts/function'\n *\n * export const sum: FunctionN<[number, number], number> = (a, b) => a + b\n *\n * @since 2.0.0\n */\nexport interface FunctionN<A extends ReadonlyArray<unknown>, B> {\n  (...args: A): B\n}\n\n/**\n * @since 2.0.0\n */\nexport function identity<A>(a: A): A {\n  return a\n}\n\n/**\n * @since 2.0.0\n */\nexport const unsafeCoerce: <A, B>(a: A) => B = identity as any\n\n/**\n * @since 2.0.0\n */\nexport function constant<A>(a: A): LazyArg<A> {\n  return () => a\n}\n\n/**\n * A thunk that returns always `true`.\n *\n * @since 2.0.0\n */\nexport const constTrue: LazyArg<boolean> = /*#__PURE__*/ constant(true)\n\n/**\n * A thunk that returns always `false`.\n *\n * @since 2.0.0\n */\nexport const constFalse: LazyArg<boolean> = /*#__PURE__*/ constant(false)\n\n/**\n * A thunk that returns always `null`.\n *\n * @since 2.0.0\n */\nexport const constNull: LazyArg<null> = /*#__PURE__*/ constant(null)\n\n/**\n * A thunk that returns always `undefined`.\n *\n * @since 2.0.0\n */\nexport const constUndefined: LazyArg<undefined> = /*#__PURE__*/ constant(undefined)\n\n/**\n * A thunk that returns always `void`.\n *\n * @since 2.0.0\n */\nexport const constVoid: LazyArg<void> = constUndefined\n\n/**\n * Flips the arguments of a curried function.\n *\n * @example\n * import { flip } from 'fp-ts/function'\n *\n * const f = (a: number) => (b: string) => a - b.length\n *\n * assert.strictEqual(flip(f)('aaa')(2), -1)\n *\n * @since 2.0.0\n */\nexport function flip<A, B, C>(f: (a: A) => (b: B) => C): (b: B) => (a: A) => C\n/** @deprecated */\nexport function flip<A, B, C>(f: (a: A, b: B) => C): (b: B, a: A) => C\nexport function flip(f: Function): Function {\n  return (...args: Array<any>) => {\n    if (args.length > 1) {\n      return f(args[1], args[0])\n    }\n\n    return (a: any) => f(a)(args[0])\n  }\n}\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 [`pipe`](#pipe).\n *\n * @example\n * import { flow } from 'fp-ts/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.strictEqual(f('aaa'), 6)\n *\n * @since 2.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>(ab: (...a: A) => B, bc: (b: B) => C): (...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 * @since 2.0.0\n */\nexport function tuple<T extends ReadonlyArray<any>>(...t: T): T {\n  return t\n}\n\n/**\n * @since 2.0.0\n */\nexport function increment(n: number): number {\n  return n + 1\n}\n\n/**\n * @since 2.0.0\n */\nexport function decrement(n: number): number {\n  return n - 1\n}\n\n/**\n * @since 2.0.0\n */\nexport function 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/function'\n *\n * const add = tupled((x: number, y: number): number => x + y)\n *\n * assert.strictEqual(add([1, 2]), 3)\n *\n * @since 2.4.0\n */\nexport function tupled<A extends ReadonlyArray<unknown>, B>(f: (...a: A) => B): (a: A) => B {\n  return (a) => f(...a)\n}\n\n/**\n * Inverse function of `tupled`\n *\n * @since 2.4.0\n */\nexport function untupled<A extends ReadonlyArray<unknown>, B>(f: (a: A) => B): (...a: A) => B {\n  return (...a) => f(a)\n}\n\n/**\n * Pipes the value of an expression into a pipeline of functions.\n *\n * See also [`flow`](#flow).\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n *\n * const len = (s: string): number => s.length\n * const double = (n: number): number => n * 2\n *\n * // without pipe\n * assert.strictEqual(double(len('aaa')), 6)\n *\n * // with pipe\n * assert.strictEqual(pipe('aaa', len, double), 6)\n *\n * @since 2.6.3\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>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): 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 2.7.0\n */\nexport const hole: <T>() => T = absurd as any\n\n/**\n * @since 2.11.0\n */\nexport const SK = <A, B>(_: A, b: B): B => b\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * Use `Refinement` module instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface Refinement<A, B extends A> {\n  (a: A): a is B\n}\n\n/**\n * Use `Predicate` module instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface Predicate<A> {\n  (a: A): boolean\n}\n\n/**\n * Use `Predicate` module instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function not<A>(predicate: Predicate<A>): Predicate<A> {\n  return (a) => !predicate(a)\n}\n\n/**\n * Use `Endomorphism` module instead.\n *\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface Endomorphism<A> {\n  (a: A): A\n}\n\n/**\n * Use `Endomorphism` module instead.\n *\n * @category zone of death\n * @since 2.10.0\n * @deprecated\n */\nexport const getEndomorphismMonoid = <A = never>(): Monoid<Endomorphism<A>> => ({\n  concat: (first, second) => flow(first, second),\n  empty: identity\n})\n\n/**\n * A lazy argument.\n *\n * @since 2.15.0\n */\nexport interface LazyArg<A> {\n  (): A\n}\n\n/** @internal */\nexport const dual: {\n  <DataLast extends (...args: Array<any>) => any, DataFirst extends (...args: Array<any>) => any>(\n    arity: Parameters<DataFirst>['length'],\n    body: DataFirst\n  ): DataLast & DataFirst\n  <DataLast extends (...args: Array<any>) => any, DataFirst extends (...args: Array<any>) => any>(\n    isDataFirst: (args: IArguments) => boolean,\n    body: DataFirst\n  ): DataLast & DataFirst\n} = (arity: any, body: any) => {\n  const isDataFirst: (args: IArguments) => boolean = typeof arity === 'number' ? (args) => args.length >= arity : arity\n  return function (this: any) {\n    const args = Array.from(arguments)\n    if (isDataFirst(arguments)) {\n      return body.apply(this, args)\n    }\n    return (self: any) => body(self, ...args)\n  }\n}\n\n// -------------------------------------------------------------------------------------\n// lagacy\n// -------------------------------------------------------------------------------------\n\n/**\n * Use `LazyArg` instead.\n *\n * @category lagacy\n * @since 2.0.0\n */\nexport interface Lazy<A> {\n  (): A\n}\n"
  },
  {
    "path": "src/index.ts",
    "content": "/**\n * @since 2.0.0\n */\n\nimport * as alt from './Alt'\nimport * as alternative from './Alternative'\nimport * as applicative from './Applicative'\nimport * as apply from './Apply'\nimport * as array from './Array'\nimport * as bifunctor from './Bifunctor'\nimport * as boolean from './boolean'\nimport * as booleanAlgebra from './BooleanAlgebra'\nimport * as bounded from './Bounded'\nimport * as boundedDistributiveLattice from './BoundedDistributiveLattice'\nimport * as boundedJoinSemilattice from './BoundedJoinSemilattice'\nimport * as boundedLattice from './BoundedLattice'\nimport * as boundedMeetSemilattice from './BoundedMeetSemilattice'\nimport * as category from './Category'\nimport * as chain from './Chain'\nimport * as chainRec from './ChainRec'\nimport * as choice from './Choice'\nimport * as comonad from './Comonad'\nimport * as compactable from './Compactable'\nimport * as console from './Console'\nimport * as const_ from './Const'\nimport * as contravariant from './Contravariant'\nimport * as date from './Date'\nimport * as distributiveLattice from './DistributiveLattice'\nimport * as either from './Either'\nimport * as eitherT from './EitherT'\nimport * as endomorphism from './Endomorphism'\nimport * as eq from './Eq'\nimport * as extend from './Extend'\nimport * as field from './Field'\nimport * as filterable from './Filterable'\nimport * as filterableWithIndex from './FilterableWithIndex'\nimport * as foldable from './Foldable'\nimport * as foldableWithIndex from './FoldableWithIndex'\nimport * as fromEither from './FromEither'\nimport * as fromIO from './FromIO'\nimport * as fromReader from './FromReader'\nimport * as fromState from './FromState'\nimport * as fromTask from './FromTask'\nimport * as fromThese from './FromThese'\nimport * as function_ from './function'\nimport * as functor from './Functor'\nimport * as functorWithIndex from './FunctorWithIndex'\nimport * as group from './Group'\nimport * as heytingAlgebra from './HeytingAlgebra'\nimport * as hkt from './HKT'\nimport * as identity from './Identity'\nimport * as invariant from './Invariant'\nimport * as io from './IO'\nimport * as ioEither from './IOEither'\nimport * as ioOption from './IOOption'\nimport * as ioRef from './IORef'\nimport * as joinSemilattice from './JoinSemilattice'\nimport * as json from './Json'\nimport * as lattice from './Lattice'\nimport * as magma from './Magma'\nimport * as map from './Map'\nimport * as meetSemilattice from './MeetSemilattice'\nimport * as monad from './Monad'\nimport * as monadIO from './MonadIO'\nimport * as monadTask from './MonadTask'\nimport * as monadThrow from './MonadThrow'\nimport * as monoid from './Monoid'\nimport * as naturalTransformation from './NaturalTransformation'\nimport * as nonEmptyArray from './NonEmptyArray'\nimport * as number from './number'\nimport * as option from './Option'\nimport * as optionT from './OptionT'\nimport * as ord from './Ord'\nimport * as ordering from './Ordering'\nimport * as pipeable from './pipeable'\nimport * as pointed from './Pointed'\nimport * as predicate from './Predicate'\nimport * as profunctor from './Profunctor'\nimport * as random from './Random'\nimport * as reader from './Reader'\nimport * as readerEither from './ReaderEither'\nimport * as readerIO from './ReaderIO'\nimport * as readerT from './ReaderT'\nimport * as readerTask from './ReaderTask'\nimport * as readerTaskEither from './ReaderTaskEither'\nimport * as readonlyArray from './ReadonlyArray'\nimport * as readonlyMap from './ReadonlyMap'\nimport * as readonlyNonEmptyArray from './ReadonlyNonEmptyArray'\nimport * as readonlyRecord from './ReadonlyRecord'\nimport * as readonlySet from './ReadonlySet'\nimport * as readonlyTuple from './ReadonlyTuple'\nimport * as record from './Record'\nimport * as refinement from './Refinement'\nimport * as ring from './Ring'\nimport * as semigroup from './Semigroup'\nimport * as semigroupoid from './Semigroupoid'\nimport * as semiring from './Semiring'\nimport * as separated from './Separated'\nimport * as set from './Set'\nimport * as show from './Show'\nimport * as state from './State'\nimport * as stateReaderTaskEither from './StateReaderTaskEither'\nimport * as stateT from './StateT'\nimport * as store from './Store'\nimport * as string from './string'\nimport * as strong from './Strong'\nimport * as struct from './struct'\nimport * as task from './Task'\nimport * as taskEither from './TaskEither'\nimport * as taskOption from './TaskOption'\nimport * as taskThese from './TaskThese'\nimport * as these from './These'\nimport * as theseT from './TheseT'\nimport * as traced from './Traced'\nimport * as traversable from './Traversable'\nimport * as traversableWithIndex from './TraversableWithIndex'\nimport * as tree from './Tree'\nimport * as tuple from './Tuple'\nimport * as unfoldable from './Unfoldable'\nimport * as validationT from './ValidationT'\nimport * as void_ from './void'\nimport * as witherable from './Witherable'\nimport * as writer from './Writer'\nimport * as writerT from './WriterT'\nimport * as zero from './Zero'\n\nexport {\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  alt,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  alternative,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  applicative,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  apply,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  array,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  bifunctor,\n  /**\n   * @since 2.2.0\n   */\n  boolean,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  booleanAlgebra,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  bounded,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  boundedDistributiveLattice,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  boundedJoinSemilattice,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  boundedLattice,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  boundedMeetSemilattice,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  category,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  chain,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  chainRec,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  choice,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  comonad,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  compactable,\n  /**\n   * @since 2.0.0\n   */\n  console,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  const_ as const,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  contravariant,\n  /**\n   * @since 2.0.0\n   */\n  date,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  distributiveLattice,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  either,\n  /**\n   * @category monad transformers\n   * @since 2.0.0\n   */\n  eitherT,\n  /**\n   * @category data types\n   * @since 2.11.0\n   */\n  endomorphism,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  extend,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  field,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  filterable,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  filterableWithIndex,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  foldable,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  foldableWithIndex,\n  /**\n   * @category model\n   * @since 2.10.0\n   */\n  fromEither,\n  /**\n   * @category model\n   * @since 2.10.0\n   */\n  fromIO,\n  /**\n   * @category model\n   * @since 2.11.0\n   */\n  fromReader,\n  /**\n   * @category model\n   * @since 2.11.0\n   */\n  fromState,\n  /**\n   * @category model\n   * @since 2.10.0\n   */\n  fromTask,\n  /**\n   * @category model\n   * @since 2.11.0\n   */\n  fromThese,\n  /**\n   * @since 2.0.0\n   */\n  function_ as function,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  functor,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  functorWithIndex,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  group,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  heytingAlgebra,\n  /**\n   * @since 2.0.0\n   */\n  hkt,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  identity,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  invariant,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  io,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  ioEither,\n  /**\n   * @category data types\n   * @since 2.12.0\n   */\n  ioOption,\n  /**\n   * @since 2.0.0\n   */\n  ioRef,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  joinSemilattice,\n  /**\n   * @since 2.10.0\n   */\n  json,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  lattice,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  magma,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  map,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  meetSemilattice,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  monad,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  monadIO,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  monadTask,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  monadThrow,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  monoid,\n  /**\n   * @since 2.11.0\n   */\n  naturalTransformation,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  nonEmptyArray,\n  /**\n   * @since 2.10.0\n   */\n  number,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  option,\n  /**\n   * @category monad transformers\n   * @since 2.0.0\n   */\n  optionT,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  ord,\n  /**\n   * @since 2.0.0\n   */\n  ordering,\n  /**\n   * @since 2.0.0\n   */\n  pipeable,\n  /**\n   * @category model\n   * @since 2.10.0\n   */\n  pointed,\n  /**\n   * @category data types\n   * @since 2.11.0\n   */\n  predicate,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  profunctor,\n  /**\n   * @since 2.0.0\n   */\n  random,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  reader,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  readerEither,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  readerIO,\n  /**\n   * @category monad transformers\n   * @since 2.0.0\n   */\n  readerT,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  readerTaskEither,\n  /**\n   * @category data types\n   * @since 2.5.0\n   */\n  readonlyArray,\n  /**\n   * @category data types\n   * @since 2.5.0\n   */\n  readonlyMap,\n  /**\n   * @category data types\n   * @since 2.5.0\n   */\n  readonlyNonEmptyArray,\n  /**\n   * @category data types\n   * @since 2.5.0\n   */\n  readonlyRecord,\n  /**\n   * @category data types\n   * @since 2.5.0\n   */\n  readonlySet,\n  /**\n   * @category data types\n   * @since 2.5.0\n   */\n  readonlyTuple,\n  /**\n   * @category data types\n   * @since 2.3.0\n   */\n  readerTask,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  record,\n  /**\n   * @category data types\n   * @since 2.11.0\n   */\n  refinement,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  ring,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  semigroup,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  semigroupoid,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  semiring,\n  /**\n   * @category data types\n   * @since 2.10.0\n   */\n  separated,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  set,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  eq,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  show,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  state,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  stateReaderTaskEither,\n  /**\n   * @category monad transformers\n   * @since 2.0.0\n   */\n  stateT,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  store,\n  /**\n   * @since 2.10.0\n   */\n  string,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  strong,\n  /**\n   * @since 2.10.0\n   */\n  struct,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  task,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  taskEither,\n  /**\n   * @category data types\n   * @since 2.10.0\n   */\n  taskOption,\n  /**\n   * @category data types\n   * @since 2.4.0\n   */\n  taskThese,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  these,\n  /**\n   * @category monad transformers\n   * @since 2.4.0\n   */\n  theseT,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  traced,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  traversable,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  traversableWithIndex,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  tree,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  tuple,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  unfoldable,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  validationT,\n  /**\n   * @category zone of death\n   * @since 2.11.0\n   * @deprecated\n   */\n  void_ as void,\n  /**\n   * @category model\n   * @since 2.0.0\n   */\n  witherable,\n  /**\n   * @category data types\n   * @since 2.0.0\n   */\n  writer,\n  /**\n   * @category monad transformers\n   * @since 2.4.0\n   */\n  writerT,\n  /**\n   * @category model\n   * @since 2.11.0\n   */\n  zero\n}\n"
  },
  {
    "path": "src/internal.ts",
    "content": "import { Either, Left, Right } from './Either'\nimport { dual } from './function'\nimport { IO } from './IO'\nimport { NonEmptyArray } from './NonEmptyArray'\nimport { None, Option, Some } from './Option'\nimport { Reader } from './Reader'\nimport { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Task } from './Task'\n\n// -------------------------------------------------------------------------------------\n// Option\n// -------------------------------------------------------------------------------------\n\n/** @internal */\nexport const isNone = (fa: Option<unknown>): 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> = { _tag: 'None' }\n\n/** @internal */\nexport const some = <A>(a: A): Option<A> => ({ _tag: 'Some', value: a })\n\n// -------------------------------------------------------------------------------------\n// Either\n// -------------------------------------------------------------------------------------\n\n/** @internal */\nexport const isLeft = <E>(ma: Either<E, unknown>): ma is Left<E> => ma._tag === 'Left'\n\n/** @internal */\nexport const isRight = <A>(ma: Either<unknown, A>): ma is Right<A> => ma._tag === 'Right'\n\n/** @internal */\nexport const left = <E, A = never>(e: E): Either<E, A> => ({ _tag: 'Left', left: e })\n\n/** @internal */\nexport const right = <A, E = never>(a: A): Either<E, A> => ({ _tag: 'Right', right: a })\n\n// -------------------------------------------------------------------------------------\n// ReadonlyNonEmptyArray\n// -------------------------------------------------------------------------------------\n\n/** @internal */\nexport const singleton = <A>(a: A): NonEmptyArray<A> => [a]\n\n/** @internal */\nexport const isNonEmpty = <A>(as: ReadonlyArray<A>): as is ReadonlyNonEmptyArray<A> => as.length > 0\n\n/** @internal */\nexport const head = <A>(as: ReadonlyNonEmptyArray<A>): A => as[0]\n\n/** @internal */\nexport const tail = <A>(as: ReadonlyNonEmptyArray<A>): ReadonlyArray<A> => as.slice(1)\n\n// -------------------------------------------------------------------------------------\n// empty\n// -------------------------------------------------------------------------------------\n\n/** @internal */\nexport const emptyReadonlyArray: readonly [] = []\n\n/** @internal */\nexport const emptyRecord: {} = {}\n\n// -------------------------------------------------------------------------------------\n// Record\n// -------------------------------------------------------------------------------------\n\n/** @internal */\nexport const has = Object.prototype.hasOwnProperty\n\n// -------------------------------------------------------------------------------------\n// NonEmptyArray\n// -------------------------------------------------------------------------------------\n\n/** @internal */\nexport const fromReadonlyNonEmptyArray = <A>(as: ReadonlyNonEmptyArray<A>): NonEmptyArray<A> => [as[0], ...as.slice(1)]\n\n// -------------------------------------------------------------------------------------\n// HKT\n// -------------------------------------------------------------------------------------\n\n/** @internal */\nexport declare const URI: unique symbol\n\n/** @internal */\nexport interface TypeLambda {\n  readonly In: unknown\n  readonly Out2: unknown\n  readonly Out1: unknown\n  readonly Target: unknown\n}\n\n/** @internal */\nexport interface TypeClass<F extends TypeLambda> {\n  readonly [URI]?: F\n}\n\n/** @internal */\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// -------------------------------------------------------------------------------------\n// type classes\n// -------------------------------------------------------------------------------------\n\n/** @internal */\nexport interface FromEither<F extends TypeLambda> extends TypeClass<F> {\n  readonly fromEither: <R, O, E, A>(e: Either<E, A>) => Kind<F, R, O, E, A>\n}\n\n/** @internal */\nexport interface FromIO<F extends TypeLambda> extends TypeClass<F> {\n  readonly fromIO: <R, O, E, A>(e: IO<A>) => Kind<F, R, O, E, A>\n}\n\n/** @internal */\nexport interface FromTask<F extends TypeLambda> extends TypeClass<F> {\n  readonly fromTask: <R, O, E, A>(e: Task<A>) => Kind<F, R, O, E, A>\n}\n\n/** @internal */\nexport interface FromReader<F extends TypeLambda> extends TypeClass<F> {\n  readonly fromReader: <R, O, E, A>(e: Reader<R, A>) => Kind<F, R, O, E, A>\n}\n\n/** @internal */\nexport const liftNullable =\n  <F extends TypeLambda>(F: FromEither<F>) =>\n  <A extends ReadonlyArray<unknown>, B, E>(f: (...a: A) => B | null | undefined, onNullable: (...a: A) => E) =>\n  <R, O>(...a: A): Kind<F, R, O, E, NonNullable<B>> => {\n    const o = f(...a)\n    return F.fromEither<R, O, E, NonNullable<B>>(\n      o == null ? left(onNullable(...a)) : right<NonNullable<B>, E>(o as any)\n    )\n  }\n\n/** @internal */\nexport const liftOption =\n  <F extends TypeLambda>(F: FromEither<F>) =>\n  <A extends ReadonlyArray<unknown>, B, E>(f: (...a: A) => Option<B>, onNone: (...a: A) => E) =>\n  <R, O>(...a: A): Kind<F, R, O, E, B> => {\n    const o = f(...a)\n    return F.fromEither(isNone(o) ? left(onNone(...a)) : right(o.value))\n  }\n\n/** @internal */\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/** @internal */\nexport const flatMapNullable = <F extends TypeLambda>(\n  F: FromEither<F>,\n  M: FlatMap<F>\n): {\n  <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <R, O, E1>(\n    self: Kind<F, R, O, E1, A>\n  ) => Kind<F, R, O, E1 | E2, NonNullable<B>>\n  <R, O, E1, A, B, E2>(self: Kind<F, R, O, E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): Kind<\n    F,\n    R,\n    O,\n    E1 | E2,\n    NonNullable<B>\n  >\n} => {\n  return /*#__PURE__*/ dual(\n    3,\n    <R, O, E1, A, B, E2>(\n      self: Kind<F, R, O, E1, A>,\n      f: (a: A) => B | null | undefined,\n      onNullable: (a: A) => E2\n    ): Kind<F, R, O, E1 | E2, NonNullable<B>> =>\n      M.flatMap<R, O, E1, A, R, O, E2, NonNullable<B>>(self, liftNullable(F)(f, onNullable))\n  )\n}\n\n/** @internal */\nexport const flatMapOption = <F extends TypeLambda>(\n  F: FromEither<F>,\n  M: FlatMap<F>\n): {\n  <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <R, O, E1>(\n    self: Kind<F, R, O, E1, A>\n  ) => Kind<F, R, O, E1 | E2, B>\n  <R, O, E1, A, B, E2>(self: Kind<F, R, O, E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): Kind<\n    F,\n    R,\n    O,\n    E1 | E2,\n    B\n  >\n} => {\n  return /*#__PURE__*/ dual(\n    3,\n    <R, O, E1, A, B, E2>(\n      self: Kind<F, R, O, E1, A>,\n      f: (a: A) => Option<B>,\n      onNone: (a: A) => E2\n    ): Kind<F, R, O, E1 | E2, B> => M.flatMap<R, O, E1, A, R, O, E2, B>(self, liftOption(F)(f, onNone))\n  )\n}\n\n/** @internal */\nexport const flatMapEither = <F extends TypeLambda>(\n  F: FromEither<F>,\n  M: FlatMap<F>\n): {\n  <A, E2, B>(f: (a: A) => Either<E2, B>): <R, O, E1>(self: Kind<F, R, O, E1, A>) => Kind<F, R, O, E1 | E2, B>\n  <R, O, E1, A, E2, B>(self: Kind<F, R, O, E1, A>, f: (a: A) => Either<E2, B>): Kind<F, R, O, E1 | E2, B>\n} => {\n  return /*#__PURE__*/ dual(\n    2,\n    <R, O, E1, A, E2, B>(self: Kind<F, R, O, E1, A>, f: (a: A) => Either<E2, B>): Kind<F, R, O, E1 | E2, B> =>\n      M.flatMap(self, (a) => F.fromEither(f(a)))\n  )\n}\n\n/** @internal */\nexport const flatMapIO = <F extends TypeLambda>(\n  F: FromIO<F>,\n  M: FlatMap<F>\n): {\n  <A, B>(f: (a: A) => IO<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) => IO<B>): Kind<F, R, O, E, B>\n} => {\n  return /*#__PURE__*/ dual(\n    2,\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => IO<B>): Kind<F, R, O, E, B> =>\n      M.flatMap(self, (a) => F.fromIO(f(a)))\n  )\n}\n\n/** @internal */\nexport const flatMapTask = <F extends TypeLambda>(\n  F: FromTask<F>,\n  M: FlatMap<F>\n): {\n  <A, B>(f: (a: A) => Task<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) => Task<B>): Kind<F, R, O, E, B>\n} => {\n  return /*#__PURE__*/ dual(\n    2,\n    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => Task<B>): Kind<F, R, O, E, B> =>\n      M.flatMap(self, (a) => F.fromTask(f(a)))\n  )\n}\n\n/** @internal */\nexport const flatMapReader = <F extends TypeLambda>(\n  F: FromReader<F>,\n  M: FlatMap<F>\n): {\n  <A, R2, B>(f: (a: A) => Reader<R2, B>): <R1, O, E>(self: Kind<F, R1, O, E, A>) => Kind<F, R1 & R2, O, E, B>\n  <R1, O, E, A, R2, B>(self: Kind<F, R1, O, E, A>, f: (a: A) => Reader<R2, B>): Kind<F, R1 & R2, O, E, B>\n} => {\n  return /*#__PURE__*/ dual(\n    2,\n    <R1, O, E, A, R2, B>(self: Kind<F, R1, O, E, A>, f: (a: A) => Reader<R2, B>): Kind<F, R1 & R2, O, E, B> =>\n      M.flatMap(self, (a) => F.fromReader(f(a)))\n  )\n}\n"
  },
  {
    "path": "src/number.ts",
    "content": "/**\n * @since 2.10.0\n */\nimport * as B from './Bounded'\nimport * as E from './Eq'\nimport * as F from './Field'\nimport { Magma } from './Magma'\nimport { Monoid } from './Monoid'\nimport * as O from './Ord'\nimport { Refinement } from './Refinement'\nimport { Semigroup } from './Semigroup'\nimport * as S from './Show'\n\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n\n/**\n * @category refinements\n * @since 2.11.0\n */\nexport const isNumber: Refinement<unknown, number> = (u: unknown): u is number => typeof u === 'number'\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Eq: E.Eq<number> = {\n  equals: (first, second) => first === second\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Ord: O.Ord<number> = {\n  equals: Eq.equals,\n  compare: (first, second) => (first < second ? -1 : first > second ? 1 : 0)\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Bounded: B.Bounded<number> = {\n  equals: Eq.equals,\n  compare: Ord.compare,\n  top: Infinity,\n  bottom: -Infinity\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Show: S.Show<number> = {\n  show: (n) => JSON.stringify(n)\n}\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const MagmaSub: Magma<number> = {\n  concat: (first, second) => first - second\n}\n\n/**\n * `number` semigroup under addition.\n *\n * @example\n * import { SemigroupSum } from 'fp-ts/number'\n *\n * assert.deepStrictEqual(SemigroupSum.concat(2, 3), 5)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const SemigroupSum: Semigroup<number> = {\n  concat: (first, second) => first + second\n}\n\n/**\n * `number` semigroup under multiplication.\n *\n * @example\n * import { SemigroupProduct } from 'fp-ts/number'\n *\n * assert.deepStrictEqual(SemigroupProduct.concat(2, 3), 6)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const SemigroupProduct: Semigroup<number> = {\n  concat: (first, second) => first * second\n}\n\n/**\n * `number` monoid under addition.\n *\n * The `empty` value is `0`.\n *\n * @example\n * import { MonoidSum } from 'fp-ts/number'\n *\n * assert.deepStrictEqual(MonoidSum.concat(2, MonoidSum.empty), 2)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const MonoidSum: Monoid<number> = {\n  concat: SemigroupSum.concat,\n  empty: 0\n}\n\n/**\n * `number` monoid under multiplication.\n *\n * The `empty` value is `1`.\n *\n * @example\n * import { MonoidProduct } from 'fp-ts/number'\n *\n * assert.deepStrictEqual(MonoidProduct.concat(2, MonoidProduct.empty), 2)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const MonoidProduct: Monoid<number> = {\n  concat: SemigroupProduct.concat,\n  empty: 1\n}\n\n/**\n * @category instances\n * @since 2.10.0\n */\nexport const Field: F.Field<number> = {\n  add: SemigroupSum.concat,\n  zero: 0,\n  mul: SemigroupProduct.concat,\n  one: 1,\n  sub: MagmaSub.concat,\n  degree: (_) => 1,\n  div: (first, second) => first / second,\n  mod: (first, second) => first % second\n}\n"
  },
  {
    "path": "src/pipeable.ts",
    "content": "/**\n * @since 2.0.0\n */\nimport { Alt, Alt1, Alt2, Alt2C, Alt3, Alt3C, Alt4 } from './Alt'\nimport {\n  apFirst as apFirst_,\n  Apply,\n  Apply1,\n  Apply2,\n  Apply2C,\n  Apply3,\n  Apply3C,\n  Apply4,\n  apSecond as apSecond_\n} from './Apply'\nimport { Bifunctor, Bifunctor2, Bifunctor2C, Bifunctor3, Bifunctor3C, Bifunctor4 } from './Bifunctor'\nimport { Chain, Chain1, Chain2, Chain2C, Chain3, Chain3C, Chain4, chainFirst as chainFirst_ } from './Chain'\nimport {\n  Compactable,\n  Compactable1,\n  Compactable2,\n  Compactable2C,\n  Compactable3,\n  Compactable3C,\n  Compactable4\n} from './Compactable'\nimport {\n  Contravariant,\n  Contravariant1,\n  Contravariant2,\n  Contravariant2C,\n  Contravariant3,\n  Contravariant3C,\n  Contravariant4\n} from './Contravariant'\nimport { Either } from './Either'\nimport { Extend, Extend1, Extend2, Extend2C, Extend3, Extend3C, Extend4 } from './Extend'\nimport {\n  Filterable,\n  Filterable1,\n  Filterable2,\n  Filterable2C,\n  Filterable3,\n  Filterable3C,\n  Filterable4\n} from './Filterable'\nimport {\n  FilterableWithIndex,\n  FilterableWithIndex1,\n  FilterableWithIndex2,\n  FilterableWithIndex2C,\n  FilterableWithIndex3,\n  FilterableWithIndex3C,\n  FilterableWithIndex4,\n  PredicateWithIndex,\n  RefinementWithIndex\n} from './FilterableWithIndex'\nimport { Foldable, Foldable1, Foldable2, Foldable2C, Foldable3, Foldable3C, Foldable4 } from './Foldable'\nimport {\n  FoldableWithIndex,\n  FoldableWithIndex1,\n  FoldableWithIndex2,\n  FoldableWithIndex2C,\n  FoldableWithIndex3,\n  FoldableWithIndex3C,\n  FoldableWithIndex4\n} from './FoldableWithIndex'\nimport { identity, LazyArg, pipe as pipeFromFunctionModule } from './function'\nimport { Functor, Functor1, Functor2, Functor2C, Functor3, Functor3C, Functor4 } from './Functor'\nimport {\n  FunctorWithIndex,\n  FunctorWithIndex1,\n  FunctorWithIndex2,\n  FunctorWithIndex2C,\n  FunctorWithIndex3,\n  FunctorWithIndex3C,\n  FunctorWithIndex4\n} from './FunctorWithIndex'\nimport { HKT, HKT2, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from './HKT'\nimport {\n  MonadThrow,\n  MonadThrow1,\n  MonadThrow2,\n  MonadThrow2C,\n  MonadThrow3,\n  MonadThrow3C,\n  MonadThrow4\n} from './MonadThrow'\nimport { Monoid } from './Monoid'\nimport { Option } from './Option'\nimport { Predicate } from './Predicate'\nimport { Profunctor, Profunctor2, Profunctor2C, Profunctor3, Profunctor3C, Profunctor4 } from './Profunctor'\nimport { Refinement } from './Refinement'\nimport {\n  Semigroupoid,\n  Semigroupoid2,\n  Semigroupoid2C,\n  Semigroupoid3,\n  Semigroupoid3C,\n  Semigroupoid4\n} from './Semigroupoid'\nimport { Separated } from './Separated'\n\n// -------------------------------------------------------------------------------------\n// pipeable helpers\n// -------------------------------------------------------------------------------------\n\n/**\n * Returns a pipeable `map`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function map<F extends URIS4>(\n  F: Functor4<F>\n): <A, B>(f: (a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport function map<F extends URIS3>(\n  F: Functor3<F>\n): <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function map<F extends URIS3, E>(\n  F: Functor3C<F, E>\n): <A, B>(f: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function map<F extends URIS2>(\n  F: Functor2<F>\n): <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function map<F extends URIS2, E>(\n  F: Functor2C<F, E>\n): <A, B>(f: (a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function map<F extends URIS>(F: Functor1<F>): <A, B>(f: (a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>\nexport function map<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B> {\n  return (f) => (fa) => F.map(fa, f)\n}\n\n/**\n * Returns a pipeable `contramap`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function contramap<F extends URIS4>(\n  F: Contravariant4<F>\n): <A, B>(f: (b: B) => A) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport function contramap<F extends URIS3>(\n  F: Contravariant3<F>\n): <A, B>(f: (b: B) => A) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function contramap<F extends URIS3, E>(\n  F: Contravariant3C<F, E>\n): <A, B>(f: (b: B) => A) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function contramap<F extends URIS2>(\n  F: Contravariant2<F>\n): <A, B>(f: (b: B) => A) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function contramap<F extends URIS2, E>(\n  F: Contravariant2C<F, E>\n): <A, B>(f: (b: B) => A) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function contramap<F extends URIS>(\n  F: Contravariant1<F>\n): <A, B>(f: (b: B) => A) => (fa: Kind<F, A>) => Kind<F, B>\nexport function contramap<F>(F: Contravariant<F>): <A, B>(f: (b: B) => A) => (fa: HKT<F, A>) => HKT<F, B>\nexport function contramap<F>(F: Contravariant<F>): <A, B>(f: (b: B) => A) => (fa: HKT<F, A>) => HKT<F, B> {\n  return (f) => (fa) => F.contramap(fa, f)\n}\n\n/**\n * Returns a pipeable `mapWithIndex`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function mapWithIndex<F extends URIS4, I>(\n  F: FunctorWithIndex4<F, I>\n): <A, B>(f: (i: I, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport function mapWithIndex<F extends URIS3, I>(\n  F: FunctorWithIndex3<F, I>\n): <A, B>(f: (i: I, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function mapWithIndex<F extends URIS3, I, E>(\n  F: FunctorWithIndex3C<F, I, E>\n): <A, B>(f: (i: I, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function mapWithIndex<F extends URIS2, I>(\n  F: FunctorWithIndex2<F, I>\n): <A, B>(f: (i: I, a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function mapWithIndex<F extends URIS2, I, E>(\n  F: FunctorWithIndex2C<F, I, E>\n): <A, B>(f: (i: I, a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function mapWithIndex<F extends URIS, I>(\n  F: FunctorWithIndex1<F, I>\n): <A, B>(f: (i: I, a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>\nexport function mapWithIndex<F, I>(\n  F: FunctorWithIndex<F, I>\n): <A, B>(f: (i: I, a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>\nexport function mapWithIndex<F, I>(\n  F: FunctorWithIndex<F, I>\n): <A, B>(f: (i: I, a: A) => B) => (fa: HKT<F, A>) => HKT<F, B> {\n  return (f) => (fa) => F.mapWithIndex(fa, f)\n}\n\n/**\n * Returns a pipeable `ap`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function ap<F extends URIS4>(\n  F: Apply4<F>\n): <S, R, E, A>(fa: Kind4<F, S, R, E, A>) => <B>(fab: Kind4<F, S, R, E, (a: A) => B>) => Kind4<F, S, R, E, B>\nexport function ap<F extends URIS3>(\n  F: Apply3<F>\n): <R, E, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\nexport function ap<F extends URIS3, E>(\n  F: Apply3C<F, E>\n): <R, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\nexport function ap<F extends URIS2>(\n  F: Apply2<F>\n): <E, A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\nexport function ap<F extends URIS2, E>(\n  F: Apply2C<F, E>\n): <A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\nexport function ap<F extends URIS>(F: Apply1<F>): <A>(fa: Kind<F, A>) => <B>(fab: Kind<F, (a: A) => B>) => Kind<F, B>\nexport function ap<F>(F: Apply<F>): <A>(fa: HKT<F, A>) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B>\nexport function ap<F>(F: Apply<F>): <A>(fa: HKT<F, A>) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B> {\n  return (fa) => (fab) => F.ap(fab, fa)\n}\n\n/**\n * Returns a pipeable `chain`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function chain<F extends URIS4>(\n  F: Chain4<F>\n): <A, S, R, E, B>(f: (a: A) => Kind4<F, S, R, E, B>) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport function chain<F extends URIS3>(\n  F: Chain3<F>\n): <A, R, E, B>(f: (a: A) => Kind3<F, R, E, B>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function chain<F extends URIS3, E>(\n  F: Chain3C<F, E>\n): <A, R, B>(f: (a: A) => Kind3<F, R, E, B>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function chain<F extends URIS2>(\n  F: Chain2<F>\n): <A, E, B>(f: (a: A) => Kind2<F, E, B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function chain<F extends URIS2, E>(\n  F: Chain2C<F, E>\n): <A, B>(f: (a: A) => Kind2<F, E, B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function chain<F extends URIS>(F: Chain1<F>): <A, B>(f: (a: A) => Kind<F, B>) => (fa: Kind<F, A>) => Kind<F, B>\nexport function chain<F>(F: Chain<F>): <A, B>(f: (a: A) => HKT<F, B>) => (fa: HKT<F, A>) => HKT<F, B>\nexport function chain<F>(F: Chain<F>): <A, B>(f: (a: A) => HKT<F, B>) => (fa: HKT<F, A>) => HKT<F, B> {\n  return (f) => (fa) => F.chain(fa, f)\n}\n\n/**\n * Returns a pipeable `bimap`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function bimap<F extends URIS4>(\n  F: Bifunctor4<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <S, R>(fea: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, B>\nexport function bimap<F extends URIS3>(\n  F: Bifunctor3<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, B>\nexport function bimap<F extends URIS3, E>(\n  F: Bifunctor3C<F, E>\n): <G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, B>\nexport function bimap<F extends URIS2>(\n  F: Bifunctor2<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind2<F, E, A>) => Kind2<F, G, B>\nexport function bimap<F extends URIS2, E>(\n  F: Bifunctor2C<F, E>\n): <G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: Kind2<F, E, A>) => Kind2<F, G, B>\nexport function bimap<F>(\n  F: Bifunctor<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: HKT2<F, E, A>) => HKT2<F, G, B>\nexport function bimap<F>(\n  F: Bifunctor<F>\n): <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: HKT2<F, E, A>) => HKT2<F, G, B> {\n  return (f, g) => (fea) => F.bimap(fea, f, g)\n}\n\n/**\n * Returns a pipeable `mapLeft`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function mapLeft<F extends URIS4>(\n  F: Bifunctor4<F>\n): <E, G>(f: (e: E) => G) => <S, R, A>(fea: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, A>\nexport function mapLeft<F extends URIS3>(\n  F: Bifunctor3<F>\n): <E, G>(f: (e: E) => G) => <R, A>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, A>\nexport function mapLeft<F extends URIS3, E>(\n  F: Bifunctor3C<F, E>\n): <E, G>(f: (e: E) => G) => <R, A>(fea: Kind3<F, R, E, A>) => Kind3<F, R, G, A>\nexport function mapLeft<F extends URIS2>(\n  F: Bifunctor2<F>\n): <E, G>(f: (e: E) => G) => <A>(fea: Kind2<F, E, A>) => Kind2<F, G, A>\nexport function mapLeft<F extends URIS2, E>(\n  F: Bifunctor2C<F, E>\n): <E, G>(f: (e: E) => G) => <A>(fea: Kind2<F, E, A>) => Kind2<F, G, A>\nexport function mapLeft<F>(F: Bifunctor<F>): <E, G>(f: (e: E) => G) => <A>(fea: HKT2<F, E, A>) => HKT2<F, G, A>\nexport function mapLeft<F>(F: Bifunctor<F>): <E, G>(f: (e: E) => G) => <A>(fea: HKT2<F, E, A>) => HKT2<F, G, A> {\n  return (f) => (fea) => F.mapLeft(fea, f)\n}\n\n/**\n * Returns a pipeable `extend`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function extend<F extends URIS4>(\n  F: Extend4<F>\n): <S, R, E, A, B>(f: (wa: Kind4<F, S, R, E, A>) => B) => (wa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport function extend<F extends URIS3>(\n  F: Extend3<F>\n): <R, E, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function extend<F extends URIS3, E>(\n  F: Extend3C<F, E>\n): <R, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function extend<F extends URIS2>(\n  F: Extend2<F>\n): <E, A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function extend<F extends URIS2, E>(\n  F: Extend2C<F, E>\n): <A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function extend<F extends URIS>(\n  F: Extend1<F>\n): <A, B>(f: (wa: Kind<F, A>) => B) => (wa: Kind<F, A>) => Kind<F, B>\nexport function extend<F>(F: Extend<F>): <A, B>(f: (wa: HKT<F, A>) => B) => (wa: HKT<F, A>) => HKT<F, B>\nexport function extend<F>(F: Extend<F>): <A, B>(f: (wa: HKT<F, A>) => B) => (wa: HKT<F, A>) => HKT<F, B> {\n  return (f) => (wa) => F.extend(wa, f)\n}\n\n/**\n * Returns a pipeable `reduce`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function reduce<F extends URIS4>(\n  F: Foldable4<F>\n): <A, B>(b: B, f: (b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\nexport function reduce<F extends URIS3>(\n  F: Foldable3<F>\n): <A, B>(b: B, f: (b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\nexport function reduce<F extends URIS3, E>(\n  F: Foldable3C<F, E>\n): <A, B>(b: B, f: (b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B\nexport function reduce<F extends URIS2>(\n  F: Foldable2<F>\n): <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B\nexport function reduce<F extends URIS2, E>(\n  F: Foldable2C<F, E>\n): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B\nexport function reduce<F extends URIS>(F: Foldable1<F>): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind<F, A>) => B\nexport function reduce<F>(F: Foldable<F>): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: HKT<F, A>) => B\nexport function reduce<F>(F: Foldable<F>): <A, B>(b: B, f: (b: B, a: A) => B) => (fa: HKT<F, A>) => B {\n  return (b, f) => (fa) => F.reduce(fa, b, f)\n}\n\n/**\n * Returns a pipeable `foldMap`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function foldMap<F extends URIS4>(\n  F: Foldable4<F>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M\nexport function foldMap<F extends URIS3>(\n  F: Foldable3<F>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M\nexport function foldMap<F extends URIS3, E>(\n  F: Foldable3C<F, E>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M\nexport function foldMap<F extends URIS2>(\n  F: Foldable2<F>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: Kind2<F, E, A>) => M\nexport function foldMap<F extends URIS2, E>(\n  F: Foldable2C<F, E>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind2<F, E, A>) => M\nexport function foldMap<F extends URIS>(\n  F: Foldable1<F>\n): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind<F, A>) => M\nexport function foldMap<F>(F: Foldable<F>): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: HKT<F, A>) => M\nexport function foldMap<F>(F: Foldable<F>): <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: HKT<F, A>) => M {\n  return (M) => {\n    const foldMapM = F.foldMap(M)\n    return (f) => (fa) => foldMapM(fa, f)\n  }\n}\n\n/**\n * Returns a pipeable `reduceRight`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function reduceRight<F extends URIS4>(\n  F: Foldable4<F>\n): <A, B>(b: B, f: (a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\nexport function reduceRight<F extends URIS3>(\n  F: Foldable3<F>\n): <A, B>(b: B, f: (a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\nexport function reduceRight<F extends URIS3, E>(\n  F: Foldable3C<F, E>\n): <A, B>(b: B, f: (a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B\nexport function reduceRight<F extends URIS2>(\n  F: Foldable2<F>\n): <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B\nexport function reduceRight<F extends URIS2, E>(\n  F: Foldable2C<F, E>\n): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B\nexport function reduceRight<F extends URIS>(\n  F: Foldable1<F>\n): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind<F, A>) => B\nexport function reduceRight<F>(F: Foldable<F>): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: HKT<F, A>) => B\nexport function reduceRight<F>(F: Foldable<F>): <A, B>(b: B, f: (a: A, b: B) => B) => (fa: HKT<F, A>) => B {\n  return (b, f) => (fa) => F.reduceRight(fa, b, f)\n}\n\n/**\n * Returns a pipeable `reduceWithIndex`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function reduceWithIndex<F extends URIS4, I>(\n  F: FoldableWithIndex4<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\nexport function reduceWithIndex<F extends URIS3, I>(\n  F: FoldableWithIndex3<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\nexport function reduceWithIndex<F extends URIS3, I, E>(\n  F: FoldableWithIndex3C<F, I, E>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B\nexport function reduceWithIndex<F extends URIS2, I>(\n  F: FoldableWithIndex2<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B\nexport function reduceWithIndex<F extends URIS2, I, E>(\n  F: FoldableWithIndex2C<F, I, E>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B\nexport function reduceWithIndex<F extends URIS, I>(\n  F: FoldableWithIndex1<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind<F, A>) => B\nexport function reduceWithIndex<F, I>(\n  F: FoldableWithIndex<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: HKT<F, A>) => B\nexport function reduceWithIndex<F, I>(\n  F: FoldableWithIndex<F, I>\n): <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: HKT<F, A>) => B {\n  return (b, f) => (fa) => F.reduceWithIndex(fa, b, f)\n}\n\n/**\n * Returns a pipeable `foldMapWithIndex`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function foldMapWithIndex<F extends URIS4, I>(\n  F: FoldableWithIndex4<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M\nexport function foldMapWithIndex<F extends URIS3, I>(\n  F: FoldableWithIndex3<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M\nexport function foldMapWithIndex<F extends URIS3, I, E>(\n  F: FoldableWithIndex3C<F, I, E>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M\nexport function foldMapWithIndex<F extends URIS2, I>(\n  F: FoldableWithIndex2<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <E>(fa: Kind2<F, E, A>) => M\nexport function foldMapWithIndex<F extends URIS2, I, E>(\n  F: FoldableWithIndex2C<F, I, E>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind2<F, E, A>) => M\nexport function foldMapWithIndex<F extends URIS, I>(\n  F: FoldableWithIndex1<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind<F, A>) => M\nexport function foldMapWithIndex<F, I>(\n  F: FoldableWithIndex<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: HKT<F, A>) => M\nexport function foldMapWithIndex<F, I>(\n  F: FoldableWithIndex<F, I>\n): <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: HKT<F, A>) => M {\n  return (M) => {\n    const foldMapWithIndexM = F.foldMapWithIndex(M)\n    return (f) => (fa) => foldMapWithIndexM(fa, f)\n  }\n}\n\n/**\n * Returns a pipeable `reduceRightWithIndex`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function reduceRightWithIndex<F extends URIS4, I>(\n  F: FoldableWithIndex4<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\nexport function reduceRightWithIndex<F extends URIS3, I>(\n  F: FoldableWithIndex3<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\nexport function reduceRightWithIndex<F extends URIS3, I, E>(\n  F: FoldableWithIndex3C<F, I, E>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B\nexport function reduceRightWithIndex<F extends URIS2, I>(\n  F: FoldableWithIndex2<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B\nexport function reduceRightWithIndex<F extends URIS2, I, E>(\n  F: FoldableWithIndex2C<F, I, E>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B\nexport function reduceRightWithIndex<F extends URIS, I>(\n  F: FoldableWithIndex1<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind<F, A>) => B\nexport function reduceRightWithIndex<F, I>(\n  F: FoldableWithIndex<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: HKT<F, A>) => B\nexport function reduceRightWithIndex<F, I>(\n  F: FoldableWithIndex<F, I>\n): <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: HKT<F, A>) => B {\n  return (b, f) => (fa) => F.reduceRightWithIndex(fa, b, f)\n}\n\n/**\n * Returns a pipeable `alt`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function alt<F extends URIS4>(\n  F: Alt4<F>\n): <S, R, E, A>(that: LazyArg<Kind4<F, S, R, E, A>>) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\nexport function alt<F extends URIS3>(\n  F: Alt3<F>\n): <R, E, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\nexport function alt<F extends URIS3, E>(\n  F: Alt3C<F, E>\n): <R, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\nexport function alt<F extends URIS2>(\n  F: Alt2<F>\n): <E, A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>\nexport function alt<F extends URIS2, E>(\n  F: Alt2C<F, E>\n): <A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>\nexport function alt<F extends URIS>(F: Alt1<F>): <A>(that: LazyArg<Kind<F, A>>) => (fa: Kind<F, A>) => Kind<F, A>\nexport function alt<F>(F: Alt<F>): <A>(that: LazyArg<HKT<F, A>>) => (fa: HKT<F, A>) => HKT<F, A>\nexport function alt<F>(F: Alt<F>): <A>(that: LazyArg<HKT<F, A>>) => (fa: HKT<F, A>) => HKT<F, A> {\n  return (that) => (fa) => F.alt(fa, that)\n}\n\n/**\n * Returns a pipeable `filter`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function filter<F extends URIS4>(\n  F: Filterable4<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n  <A>(predicate: Predicate<A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n}\nexport function filter<F extends URIS3>(\n  F: Filterable3<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\nexport function filter<F extends URIS3, E>(\n  F: Filterable3C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\nexport function filter<F extends URIS2>(\n  F: Filterable2<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\nexport function filter<F extends URIS2, E>(\n  F: Filterable2C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\nexport function filter<F extends URIS>(\n  F: Filterable1<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Kind<F, B>\n  <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Kind<F, A>\n}\nexport function filter<F>(F: Filterable<F>): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => HKT<F, B>\n  <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => HKT<F, A>\n}\nexport function filter<F>(F: Filterable<F>): <A>(predicate: Predicate<A>) => (fa: HKT<F, A>) => HKT<F, A> {\n  return (predicate) => (fa) => F.filter(fa, predicate)\n}\n\n/**\n * Returns a pipeable `filterMap`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function filterMap<F extends URIS4>(\n  F: Filterable4<F>\n): <A, B>(f: (a: A) => Option<B>) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport function filterMap<F extends URIS3>(\n  F: Filterable3<F>\n): <A, B>(f: (a: A) => Option<B>) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function filterMap<F extends URIS3, E>(\n  F: Filterable3C<F, E>\n): <A, B>(f: (a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function filterMap<F extends URIS2>(\n  F: Filterable2<F>\n): <A, B>(f: (a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function filterMap<F extends URIS2, E>(\n  F: Filterable2C<F, E>\n): <A, B>(f: (a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function filterMap<F extends URIS>(\n  F: Filterable1<F>\n): <A, B>(f: (a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>\nexport function filterMap<F>(F: Filterable<F>): <A, B>(f: (a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>\nexport function filterMap<F>(F: Filterable<F>): <A, B>(f: (a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B> {\n  return (f) => (fa) => F.filterMap(fa, f)\n}\n\n/**\n * Returns a pipeable `partition`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function partition<F extends URIS4>(\n  F: Filterable4<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n  <A>(predicate: Predicate<A>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n}\nexport function partition<F extends URIS3>(\n  F: Filterable3<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R, E>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n  <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\nexport function partition<F extends URIS3, E>(\n  F: Filterable3C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <R>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n  <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\nexport function partition<F extends URIS2>(\n  F: Filterable2<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\nexport function partition<F extends URIS2, E>(\n  F: Filterable2C<F, E>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\nexport function partition<F extends URIS>(\n  F: Filterable1<F>\n): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, B>>\n  <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>\n}\nexport function partition<F>(F: Filterable<F>): {\n  <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, B>>\n  <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>\n}\nexport function partition<F>(\n  F: Filterable<F>\n): <A>(predicate: Predicate<A>) => (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>> {\n  return (f) => (fa) => F.partition(fa, f)\n}\n\n/**\n * Returns a pipeable `partitionMap`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function partitionMap<F extends URIS4>(\n  F: Filterable4<F>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\nexport function partitionMap<F extends URIS3>(\n  F: Filterable3<F>\n): <A, B, C>(\n  f: (a: A) => Either<B, C>\n) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\nexport function partitionMap<F extends URIS3, E>(\n  F: Filterable3C<F, E>\n): <A, B, C>(f: (a: A) => Either<B, C>) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\nexport function partitionMap<F extends URIS2>(\n  F: Filterable2<F>\n): <A, B, C>(f: (a: A) => Either<B, C>) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\nexport function partitionMap<F extends URIS2, E>(\n  F: Filterable2C<F, E>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\nexport function partitionMap<F extends URIS>(\n  F: Filterable1<F>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>\nexport function partitionMap<F>(\n  F: Filterable<F>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>\nexport function partitionMap<F>(\n  F: Filterable<F>\n): <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>> {\n  return (f) => (fa) => F.partitionMap(fa, f)\n}\n\n/**\n * Returns a pipeable `filterWithIndex`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function filterWithIndex<F extends URIS4, I>(\n  F: FilterableWithIndex4<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Kind4<F, S, R, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n}\nexport function filterWithIndex<F extends URIS3, I>(\n  F: FilterableWithIndex3<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\nexport function filterWithIndex<F extends URIS3, I, E>(\n  F: FilterableWithIndex3C<F, I, E>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\nexport function filterWithIndex<F extends URIS2, I>(\n  F: FilterableWithIndex2<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\nexport function filterWithIndex<F extends URIS2, E, I>(\n  F: FilterableWithIndex2C<F, I, E>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\nexport function filterWithIndex<F extends URIS, I>(\n  F: FilterableWithIndex1<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: Kind<F, A>) => Kind<F, B>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Kind<F, A>\n}\nexport function filterWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: HKT<F, A>) => HKT<F, B>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => HKT<F, A>\n}\nexport function filterWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): <A>(predicate: PredicateWithIndex<I, A>) => (fa: HKT<F, A>) => HKT<F, A> {\n  return (predicate) => (fa) => F.filterWithIndex(fa, predicate)\n}\n\n/**\n * Returns a pipeable `filterMapWithIndex`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function filterMapWithIndex<F extends URIS4, I>(\n  F: FilterableWithIndex4<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\nexport function filterMapWithIndex<F extends URIS3, I>(\n  F: FilterableWithIndex3<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function filterMapWithIndex<F extends URIS3, I, E>(\n  F: FilterableWithIndex3C<F, I, E>\n): <A, B>(f: (i: I, a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\nexport function filterMapWithIndex<F extends URIS2, I>(\n  F: FilterableWithIndex2<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function filterMapWithIndex<F extends URIS2, I, E>(\n  F: FilterableWithIndex2C<F, I, E>\n): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\nexport function filterMapWithIndex<F extends URIS, I>(\n  F: FilterableWithIndex1<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>\nexport function filterMapWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>\nexport function filterMapWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): <A, B>(f: (i: I, a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B> {\n  return (f) => (fa) => F.filterMapWithIndex(fa, f)\n}\n\n/**\n * Returns a pipeable `partitionWithIndex`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function partitionWithIndex<F extends URIS4, I>(\n  F: FilterableWithIndex4<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): <S, R, E>(\n    fa: Kind4<F, S, R, E, A>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n}\nexport function partitionWithIndex<F extends URIS3, I>(\n  F: FilterableWithIndex3<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R, E>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): <R, E>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\nexport function partitionWithIndex<F extends URIS3, I, E>(\n  F: FilterableWithIndex3C<F, I, E>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <R>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): <R>(\n    fa: Kind3<F, R, E, A>\n  ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n}\nexport function partitionWithIndex<F extends URIS2, I>(\n  F: FilterableWithIndex2<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): <E>(\n    fa: Kind2<F, E, A>\n  ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\nexport function partitionWithIndex<F extends URIS2, I, E>(\n  F: FilterableWithIndex2C<F, I, E>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (\n    fa: Kind2<F, E, A>\n  ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n}\nexport function partitionWithIndex<F extends URIS, I>(\n  F: FilterableWithIndex1<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>\n}\nexport function partitionWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): {\n  <A, B extends A>(refinement: RefinementWithIndex<I, A, B>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, B>>\n  <A>(predicate: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>\n}\nexport function partitionWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): <A>(predicate: PredicateWithIndex<I, A>) => (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>> {\n  return (f) => (fa) => F.partitionWithIndex(fa, f)\n}\n\n/**\n * Returns a pipeable `partitionMapWithIndex`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function partitionMapWithIndex<F extends URIS4, I>(\n  F: FilterableWithIndex4<F, I>\n): <A, B, C>(\n  f: (i: I, a: A) => Either<B, C>\n) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\nexport function partitionMapWithIndex<F extends URIS3, I>(\n  F: FilterableWithIndex3<F, I>\n): <A, B, C>(\n  f: (i: I, a: A) => Either<B, C>\n) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\nexport function partitionMapWithIndex<F extends URIS3, I, E>(\n  F: FilterableWithIndex3C<F, I, E>\n): <A, B, C>(\n  f: (i: I, a: A) => Either<B, C>\n) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\nexport function partitionMapWithIndex<F extends URIS2, I>(\n  F: FilterableWithIndex2<F, I>\n): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\nexport function partitionMapWithIndex<F extends URIS2, I, E>(\n  F: FilterableWithIndex2C<F, I, E>\n): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\nexport function partitionMapWithIndex<F extends URIS, I>(\n  F: FilterableWithIndex1<F, I>\n): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>\nexport function partitionMapWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>\nexport function partitionMapWithIndex<F, I>(\n  F: FilterableWithIndex<F, I>\n): <A, B, C>(f: (i: I, a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>> {\n  return (f) => (fa) => F.partitionMapWithIndex(fa, f)\n}\n\n/**\n * Returns a pipeable `promap`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function promap<F extends URIS4>(\n  F: Profunctor4<F>\n): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => <S, R>(fbc: Kind4<F, S, R, E, A>) => Kind4<F, S, R, D, B>\nexport function promap<F extends URIS3>(\n  F: Profunctor3<F>\n): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => <R>(fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>\nexport function promap<F extends URIS3, E>(\n  F: Profunctor3C<F, E>\n): <A, D, B>(f: (d: D) => E, g: (a: A) => B) => <R>(fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>\nexport function promap<F extends URIS2>(\n  F: Profunctor2<F>\n): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>\nexport function promap<F extends URIS2, E>(\n  F: Profunctor2C<F, E>\n): <A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>\nexport function promap<F>(\n  F: Profunctor<F>\n): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: HKT2<F, E, A>) => HKT2<F, D, B>\nexport function promap<F>(\n  F: Profunctor<F>\n): <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: HKT2<F, E, A>) => HKT2<F, D, B> {\n  return (f, g) => (fbc) => F.promap(fbc, f, g)\n}\n\n/**\n * Returns a pipeable `compose`\n *\n * @category pipeable helper\n * @since 2.13.0\n */\nexport function compose<F extends URIS4>(\n  F: Semigroupoid4<F>\n): <S, R, E, A>(ea: Kind4<F, S, R, E, A>) => <B>(ab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, E, B>\nexport function compose<F extends URIS3>(\n  F: Semigroupoid3<F>\n): <R, E, A>(ea: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>\nexport function compose<F extends URIS3, E>(\n  F: Semigroupoid3C<F, E>\n): <R, A>(ea: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>\nexport function compose<F extends URIS2>(\n  F: Semigroupoid2<F>\n): <E, A>(ea: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>\nexport function compose<F extends URIS2, E>(\n  F: Semigroupoid2C<F, E>\n): <A>(ea: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>\nexport function compose<F>(F: Semigroupoid<F>): <E, A>(ea: HKT2<F, E, A>) => <B>(ab: HKT2<F, A, B>) => HKT2<F, E, B>\nexport function compose<F>(F: Semigroupoid<F>): <E, A>(ea: HKT2<F, E, A>) => <B>(ab: HKT2<F, A, B>) => HKT2<F, E, B> {\n  return (ea) => (ab) => F.compose(ab, ea)\n}\n\n// -------------------------------------------------------------------------------------\n// deprecated\n// -------------------------------------------------------------------------------------\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctor<F> {\n  readonly map: <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctor1<F extends URIS> {\n  readonly map: <A, B>(f: (a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctor2<F extends URIS2> {\n  readonly map: <A, B>(f: (a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctor2C<F extends URIS2, E> {\n  readonly map: <A, B>(f: (a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctor3<F extends URIS3> {\n  readonly map: <A, B>(f: (a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableFunctor3C<F extends URIS3, E> {\n  readonly map: <A, B>(f: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctor4<F extends URIS4> {\n  readonly map: <A, B>(f: (a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableContravariant<F> {\n  readonly contramap: <A, B>(f: (b: B) => A) => (fa: HKT<F, A>) => HKT<F, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableContravariant1<F extends URIS> {\n  readonly contramap: <A, B>(f: (b: B) => A) => (fa: Kind<F, A>) => Kind<F, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableContravariant2<F extends URIS2> {\n  readonly contramap: <A, B>(f: (b: B) => A) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableContravariant2C<F extends URIS2, E> {\n  readonly contramap: <A, B>(f: (b: B) => A) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableContravariant3<F extends URIS3> {\n  readonly contramap: <A, B>(f: (b: B) => A) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableContravariant3C<F extends URIS3, E> {\n  readonly contramap: <A, B>(f: (b: B) => A) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableContravariant4<F extends URIS4> {\n  readonly contramap: <A, B>(f: (b: B) => A) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctorWithIndex<F, I> extends PipeableFunctor<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => (fa: HKT<F, A>) => HKT<F, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctorWithIndex1<F extends URIS, I> extends PipeableFunctor1<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => (fa: Kind<F, A>) => Kind<F, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctorWithIndex2<F extends URIS2, I> extends PipeableFunctor2<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctorWithIndex2C<F extends URIS2, I, E> extends PipeableFunctor2C<F, E> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctorWithIndex3<F extends URIS3, I> extends PipeableFunctor3<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableFunctorWithIndex3C<F extends URIS3, I, E> extends PipeableFunctor3C<F, E> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFunctorWithIndex4<F extends URIS4, I> extends PipeableFunctor4<F> {\n  readonly mapWithIndex: <A, B>(f: (i: I, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableApply<F> extends PipeableFunctor<F> {\n  readonly ap: <A>(fa: HKT<F, A>) => <B>(fab: HKT<F, (a: A) => B>) => HKT<F, B>\n  readonly apFirst: <B>(fb: HKT<F, B>) => <A>(fa: HKT<F, A>) => HKT<F, A>\n  readonly apSecond: <B>(fb: HKT<F, B>) => <A>(fa: HKT<F, A>) => HKT<F, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableApply1<F extends URIS> extends PipeableFunctor1<F> {\n  readonly ap: <A>(fa: Kind<F, A>) => <B>(fab: Kind<F, (a: A) => B>) => Kind<F, B>\n  readonly apFirst: <B>(fb: Kind<F, B>) => <A>(fa: Kind<F, A>) => Kind<F, A>\n  readonly apSecond: <B>(fb: Kind<F, B>) => <A>(fa: Kind<F, A>) => Kind<F, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableApply2<F extends URIS2> extends PipeableFunctor2<F> {\n  readonly ap: <E, A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\n  readonly apFirst: <E, B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  readonly apSecond: <E, B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableApply2C<F extends URIS2, E> extends PipeableFunctor2C<F, E> {\n  readonly ap: <A>(fa: Kind2<F, E, A>) => <B>(fab: Kind2<F, E, (a: A) => B>) => Kind2<F, E, B>\n  readonly apFirst: <B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  readonly apSecond: <B>(fb: Kind2<F, E, B>) => <A>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableApply3<F extends URIS3> extends PipeableFunctor3<F> {\n  readonly ap: <R, E, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\n  readonly apFirst: <R, E, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly apSecond: <R, E, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableApply3C<F extends URIS3, E> extends PipeableFunctor3C<F, E> {\n  readonly ap: <R, A>(fa: Kind3<F, R, E, A>) => <B>(fab: Kind3<F, R, E, (a: A) => B>) => Kind3<F, R, E, B>\n  readonly apFirst: <R, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly apSecond: <R, B>(fb: Kind3<F, R, E, B>) => <A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableApply4<F extends URIS4> extends PipeableFunctor4<F> {\n  readonly ap: <S, R, E, A>(\n    fa: Kind4<F, S, R, E, A>\n  ) => <B>(fab: Kind4<F, S, R, E, (a: A) => B>) => Kind4<F, S, R, E, B>\n  readonly apFirst: <S, R, E, B>(fb: Kind4<F, S, R, E, B>) => <A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  readonly apSecond: <S, R, E, B>(fb: Kind4<F, S, R, E, B>) => <A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableChain<F> extends PipeableApply<F> {\n  readonly chain: <A, B>(f: (a: A) => HKT<F, B>) => (ma: HKT<F, A>) => HKT<F, B>\n  readonly chainFirst: <A, B>(f: (a: A) => HKT<F, B>) => (ma: HKT<F, A>) => HKT<F, A>\n  readonly flatten: <A>(mma: HKT<F, HKT<F, A>>) => HKT<F, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableChain1<F extends URIS> extends PipeableApply1<F> {\n  readonly chain: <A, B>(f: (a: A) => Kind<F, B>) => (ma: Kind<F, A>) => Kind<F, B>\n  readonly chainFirst: <A, B>(f: (a: A) => Kind<F, B>) => (ma: Kind<F, A>) => Kind<F, A>\n  readonly flatten: <A>(mma: Kind<F, Kind<F, A>>) => Kind<F, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableChain2<F extends URIS2> extends PipeableApply2<F> {\n  readonly chain: <E, A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly chainFirst: <E, A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, A>\n  readonly flatten: <E, A>(mma: Kind2<F, E, Kind2<F, E, A>>) => Kind2<F, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableChain2C<F extends URIS2, E> extends PipeableApply2C<F, E> {\n  readonly chain: <A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly chainFirst: <A, B>(f: (a: A) => Kind2<F, E, B>) => (ma: Kind2<F, E, A>) => Kind2<F, E, A>\n  readonly flatten: <A>(mma: Kind2<F, E, Kind2<F, E, A>>) => Kind2<F, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableChain3<F extends URIS3> extends PipeableApply3<F> {\n  readonly chain: <R, E, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  readonly chainFirst: <R, E, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly flatten: <R, E, A>(mma: Kind3<F, R, E, Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableChain3C<F extends URIS3, E> extends PipeableApply3C<F, E> {\n  readonly chain: <R, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  readonly chainFirst: <R, A, B>(f: (a: A) => Kind3<F, R, E, B>) => (ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly flatten: <R, A>(mma: Kind3<F, R, E, Kind3<F, R, E, A>>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableChain4<F extends URIS4> extends PipeableApply4<F> {\n  readonly chain: <S, R, E, A, B>(\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => (ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n  readonly chainFirst: <S, R, E, A, B>(\n    f: (a: A) => Kind4<F, S, R, E, B>\n  ) => (ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  readonly flatten: <S, R, E, A>(mma: Kind4<F, S, R, E, Kind4<F, S, R, E, A>>) => Kind4<F, S, R, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableExtend<F> extends PipeableFunctor<F> {\n  readonly extend: <A, B>(f: (wa: HKT<F, A>) => B) => (wa: HKT<F, A>) => HKT<F, B>\n  readonly duplicate: <A>(wa: HKT<F, A>) => HKT<F, HKT<F, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableExtend1<F extends URIS> extends PipeableFunctor1<F> {\n  readonly extend: <A, B>(f: (wa: Kind<F, A>) => B) => (wa: Kind<F, A>) => Kind<F, B>\n  readonly duplicate: <A>(wa: Kind<F, A>) => Kind<F, Kind<F, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableExtend2<F extends URIS2> extends PipeableFunctor2<F> {\n  readonly extend: <E, A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly duplicate: <E, A>(wa: Kind2<F, E, A>) => Kind2<F, E, Kind2<F, E, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableExtend2C<F extends URIS2, E> extends PipeableFunctor2C<F, E> {\n  readonly extend: <A, B>(f: (wa: Kind2<F, E, A>) => B) => (wa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly duplicate: <A>(wa: Kind2<F, E, A>) => Kind2<F, E, Kind2<F, E, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableExtend3<F extends URIS3> extends PipeableFunctor3<F> {\n  readonly extend: <R, E, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  readonly duplicate: <R, E, A>(wa: Kind3<F, R, E, A>) => Kind3<F, R, E, Kind3<F, R, E, A>>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableExtend3C<F extends URIS3, E> extends PipeableFunctor3C<F, E> {\n  readonly extend: <R, A, B>(f: (wa: Kind3<F, R, E, A>) => B) => (wa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n  readonly duplicate: <R, A>(wa: Kind3<F, R, E, A>) => Kind3<F, R, E, Kind3<F, R, E, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableExtend4<F extends URIS4> extends PipeableFunctor4<F> {\n  readonly extend: <S, R, E, A, B>(\n    f: (wa: Kind4<F, S, R, E, A>) => B\n  ) => (wa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n  readonly duplicate: <S, R, E, A>(wa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, Kind4<F, S, R, E, A>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableBifunctor<F> {\n  readonly bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: HKT2<F, E, A>) => HKT2<F, G, B>\n  readonly mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: HKT2<F, E, A>) => HKT2<F, G, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableBifunctor2<F extends URIS2> {\n  readonly bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Kind2<F, E, A>) => Kind2<F, G, B>\n  readonly mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Kind2<F, E, A>) => Kind2<F, G, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableBifunctor3<F extends URIS3> {\n  readonly bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, B>\n  readonly mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, A>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableBifunctor3C<F extends URIS3, E> {\n  readonly bimap: <G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, B>\n  readonly mapLeft: <G>(f: (e: E) => G) => <R, A>(fa: Kind3<F, R, E, A>) => Kind3<F, R, G, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableBifunctor4<F extends URIS4> {\n  readonly bimap: <E, G, A, B>(\n    f: (e: E) => G,\n    g: (a: A) => B\n  ) => <S, R>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, B>\n  readonly mapLeft: <E, G>(f: (e: E) => G) => <S, R, A>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, G, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldable<F> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: HKT<F, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: HKT<F, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: HKT<F, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldable1<F extends URIS> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind<F, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind<F, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind<F, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldable2<F extends URIS2> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: Kind2<F, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldable2C<F extends URIS2, E> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => (fa: Kind2<F, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldable3<F extends URIS3> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableFoldable3C<F extends URIS3, E> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldable4<F extends URIS4> {\n  readonly reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\n  readonly foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M\n  readonly reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldableWithIndex<F, I> extends PipeableFoldable<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: HKT<F, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: HKT<F, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: HKT<F, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldableWithIndex1<F extends URIS, I> extends PipeableFoldable1<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind<F, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind<F, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind<F, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldableWithIndex2<F extends URIS2, I> extends PipeableFoldable2<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <E>(fa: Kind2<F, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <E>(fa: Kind2<F, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <E>(fa: Kind2<F, E, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldableWithIndex2C<F extends URIS2, I, E> extends PipeableFoldable2C<F, E> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => (fa: Kind2<F, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => (fa: Kind2<F, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => (fa: Kind2<F, E, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldableWithIndex3<F extends URIS3, I> extends PipeableFoldable3<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R, E>(fa: Kind3<F, R, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R, E>(fa: Kind3<F, R, E, A>) => B\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableFoldableWithIndex3C<F extends URIS3, I, E> extends PipeableFoldable3C<F, E> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <R>(fa: Kind3<F, R, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <R>(fa: Kind3<F, R, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <R>(fa: Kind3<F, R, E, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFoldableWithIndex4<F extends URIS4, I> extends PipeableFoldable4<F> {\n  readonly reduceWithIndex: <A, B>(b: B, f: (i: I, b: B, a: A) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\n  readonly foldMapWithIndex: <M>(M: Monoid<M>) => <A>(f: (i: I, a: A) => M) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => M\n  readonly reduceRightWithIndex: <A, B>(b: B, f: (i: I, a: A, b: B) => B) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => B\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableAlt<F> {\n  readonly alt: <A>(that: LazyArg<HKT<F, A>>) => (fa: HKT<F, A>) => HKT<F, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableAlt1<F extends URIS> {\n  readonly alt: <A>(that: LazyArg<Kind<F, A>>) => (fa: Kind<F, A>) => Kind<F, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableAlt2<F extends URIS2> {\n  readonly alt: <E, A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableAlt2C<F extends URIS2, E> {\n  readonly alt: <A>(that: LazyArg<Kind2<F, E, A>>) => (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableAlt3<F extends URIS3> {\n  readonly alt: <R, E, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableAlt3C<F extends URIS3, E> {\n  readonly alt: <R, A>(that: LazyArg<Kind3<F, R, E, A>>) => (fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableAlt4<F extends URIS4> {\n  readonly alt: <S, R, E, A>(that: LazyArg<Kind4<F, S, R, E, A>>) => (fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableCompactable<F> {\n  readonly compact: <A>(fa: HKT<F, Option<A>>) => HKT<F, A>\n  readonly separate: <A, B>(fa: HKT<F, Either<A, B>>) => Separated<HKT<F, A>, HKT<F, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableCompactable1<F extends URIS> {\n  readonly compact: <A>(fa: Kind<F, Option<A>>) => Kind<F, A>\n  readonly separate: <A, B>(fa: Kind<F, Either<A, B>>) => Separated<Kind<F, A>, Kind<F, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableCompactable2<F extends URIS2> {\n  readonly compact: <E, A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>\n  readonly separate: <E, A, B>(fa: Kind2<F, E, Either<A, B>>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableCompactable2C<F extends URIS2, E> {\n  readonly compact: <A>(fa: Kind2<F, E, Option<A>>) => Kind2<F, E, A>\n  readonly separate: <A, B>(fa: Kind2<F, E, Either<A, B>>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableCompactable3<F extends URIS3> {\n  readonly compact: <R, E, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>\n  readonly separate: <R, E, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableCompactable3C<F extends URIS3, E> {\n  readonly compact: <R, A>(fa: Kind3<F, R, E, Option<A>>) => Kind3<F, R, E, A>\n  readonly separate: <R, A, B>(fa: Kind3<F, R, E, Either<A, B>>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableCompactable4<F extends URIS4> {\n  readonly compact: <S, R, E, A>(fa: Kind4<F, S, R, E, Option<A>>) => Kind4<F, S, R, E, A>\n  readonly separate: <S, R, E, A, B>(\n    fa: Kind4<F, S, R, E, Either<A, B>>\n  ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterable<F> extends PipeableCompactable<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => HKT<F, B>\n    <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => HKT<F, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, B>>\n    <A>(predicate: Predicate<A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>\n  }\n  readonly partitionMap: <A, B, C>(f: (a: A) => Either<B, C>) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterable1<F extends URIS> extends PipeableCompactable1<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Kind<F, B>\n    <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Kind<F, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, B>>\n    <A>(predicate: Predicate<A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>\n  }\n  readonly partitionMap: <A, B, C>(f: (a: A) => Either<B, C>) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterable2<F extends URIS2> extends PipeableCompactable2<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n    <A>(predicate: Predicate<A>): <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterable2C<F extends URIS2, E> extends PipeableCompactable2C<F, E> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n    <A>(predicate: Predicate<A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterable3<F extends URIS3> extends PipeableCompactable3<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n    <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): <R, E>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n    <A>(predicate: Predicate<A>): <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableFilterable3C<F extends URIS3, E> extends PipeableCompactable3C<F, E> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n    <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): <R>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n    <A>(predicate: Predicate<A>): <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterable4<F extends URIS4> extends PipeableCompactable4<F> {\n  readonly filter: {\n    <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, B>\n    <A>(predicate: Predicate<A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  }\n  readonly filterMap: <A, B>(f: (a: A) => Option<B>) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  readonly partition: {\n    <A, B extends A>(refinement: Refinement<A, B>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n    <A>(predicate: Predicate<A>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n  }\n  readonly partitionMap: <A, B, C>(\n    f: (a: A) => Either<B, C>\n  ) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterableWithIndex<F, I> extends PipeableFilterable<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (fa: HKT<F, A>) => HKT<F, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => HKT<F, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => (fa: HKT<F, A>) => HKT<F, B>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (\n      fa: HKT<F, A>\n    ) => Separated<HKT<F, A>, HKT<F, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: HKT<F, A>) => Separated<HKT<F, A>, HKT<F, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => (fa: HKT<F, A>) => Separated<HKT<F, B>, HKT<F, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterableWithIndex1<F extends URIS, I> extends PipeableFilterable1<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (fa: Kind<F, A>) => Kind<F, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Kind<F, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind<F, A>) => Kind<F, B>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (\n      fa: Kind<F, A>\n    ) => Separated<Kind<F, A>, Kind<F, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind<F, A>) => Separated<Kind<F, A>, Kind<F, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => (fa: Kind<F, A>) => Separated<Kind<F, B>, Kind<F, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterableWithIndex2<F extends URIS2, I> extends PipeableFilterable2<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <E>(fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => <E>(fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <E>(\n      fa: Kind2<F, E, A>\n    ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <E>(\n      fa: Kind2<F, E, A>\n    ) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => <E>(fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterableWithIndex2C<F extends URIS2, I, E> extends PipeableFilterable2C<F, E> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => (fa: Kind2<F, E, A>) => Kind2<F, E, B>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): (\n      fa: Kind2<F, E, A>\n    ) => Separated<Kind2<F, E, A>, Kind2<F, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, A>, Kind2<F, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => (fa: Kind2<F, E, A>) => Separated<Kind2<F, E, B>, Kind2<F, E, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterableWithIndex3<F extends URIS3, I> extends PipeableFilterable3<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R, E>(\n      fa: Kind3<F, R, E, A>\n    ) => Kind3<F, R, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(\n    f: (i: I, a: A) => Option<B>\n  ) => <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R, E>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R, E>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => <R, E>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableFilterableWithIndex3C<F extends URIS3, I, E> extends PipeableFilterable3C<F, E> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R, E>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(f: (i: I, a: A) => Option<B>) => <R>(fa: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <R>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <R>(\n      fa: Kind3<F, R, E, A>\n    ) => Separated<Kind3<F, R, E, A>, Kind3<F, R, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => <R>(fa: Kind3<F, R, E, A>) => Separated<Kind3<F, R, E, B>, Kind3<F, R, E, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableFilterableWithIndex4<F extends URIS4, I> extends PipeableFilterable4<F> {\n  readonly filterWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Kind4<F, S, R, E, B>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  }\n  readonly filterMapWithIndex: <A, B>(\n    f: (i: I, a: A) => Option<B>\n  ) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  readonly partitionWithIndex: {\n    <A, B extends A>(refinementWithIndex: RefinementWithIndex<I, A, B>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, B>>\n    <A>(predicateWithIndex: PredicateWithIndex<I, A>): <S, R, E>(\n      fa: Kind4<F, S, R, E, A>\n    ) => Separated<Kind4<F, S, R, E, A>, Kind4<F, S, R, E, A>>\n  }\n  readonly partitionMapWithIndex: <A, B, C>(\n    f: (i: I, a: A) => Either<B, C>\n  ) => <S, R, E>(fa: Kind4<F, S, R, E, A>) => Separated<Kind4<F, S, R, E, B>, Kind4<F, S, R, E, C>>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableProfunctor<F> {\n  readonly promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: HKT2<F, E, A>) => HKT2<F, D, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableProfunctor2<F extends URIS2> extends PipeableFunctor2<F> {\n  readonly promap: <E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableProfunctor2C<F extends URIS2, E> extends PipeableFunctor2C<F, E> {\n  readonly promap: <A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind2<F, E, A>) => Kind2<F, D, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableProfunctor3<F extends URIS3> extends PipeableFunctor3<F> {\n  readonly promap: <R, E, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableProfunctor3C<F extends URIS3, E> extends PipeableFunctor3C<F, E> {\n  readonly promap: <R, A, D, B>(f: (d: D) => E, g: (a: A) => B) => (fbc: Kind3<F, R, E, A>) => Kind3<F, R, D, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableProfunctor4<F extends URIS4> extends PipeableFunctor4<F> {\n  readonly promap: <S, R, E, A, D, B>(\n    f: (d: D) => E,\n    g: (a: A) => B\n  ) => (fbc: Kind4<F, S, R, E, A>) => Kind4<F, S, R, D, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableSemigroupoid<F> {\n  readonly compose: <E, A>(la: HKT2<F, E, A>) => <B>(ab: HKT2<F, A, B>) => HKT2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableSemigroupoid2<F extends URIS2> {\n  readonly compose: <E, A>(la: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableSemigroupoid2C<F extends URIS2, E> {\n  readonly compose: <A>(la: Kind2<F, E, A>) => <B>(ab: Kind2<F, A, B>) => Kind2<F, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableSemigroupoid3<F extends URIS3> {\n  readonly compose: <R, E, A>(la: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableSemigroupoid3C<F extends URIS3, E> {\n  readonly compose: <R, A>(la: Kind3<F, R, E, A>) => <B>(ab: Kind3<F, R, A, B>) => Kind3<F, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableSemigroupoid4<F extends URIS4> {\n  readonly compose: <S, R, E, A>(la: Kind4<F, S, R, E, A>) => <B>(ab: Kind4<F, S, R, A, B>) => Kind4<F, S, R, E, B>\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableMonadThrow<F> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => HKT<F, A>\n  readonly fromEither: <E, A>(ma: Either<E, A>) => HKT<F, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => HKT<F, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => HKT<F, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: HKT<F, A>) => HKT<F, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: HKT<F, A>) => HKT<F, A>\n  }\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableMonadThrow1<F extends URIS> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => Kind<F, A>\n  readonly fromEither: <E, A>(ma: Either<E, A>) => Kind<F, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind<F, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind<F, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind<F, A>) => Kind<F, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind<F, A>) => Kind<F, A>\n  }\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableMonadThrow2<F extends URIS2> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <A>(ma: Option<A>) => Kind2<F, E, A>\n  readonly fromEither: <E, A>(ma: Either<E, A>) => Kind2<F, E, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableMonadThrow2C<F extends URIS2, E> {\n  readonly fromOption: (onNone: LazyArg<E>) => <A>(ma: Option<A>) => Kind2<F, E, A>\n  readonly fromEither: <A>(ma: Either<E, A>) => Kind2<F, E, A>\n  readonly fromPredicate: {\n    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, B>\n    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind2<F, E, A>\n  }\n  readonly filterOrElse: {\n    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, B>\n    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: Kind2<F, E, A>) => Kind2<F, E, A>\n  }\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableMonadThrow3<F extends URIS3> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <R, A>(ma: Option<A>) => Kind3<F, R, E, A>\n  readonly fromEither: <R, E, A>(ma: Either<E, A>) => Kind3<F, R, E, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <U>(a: A) => Kind3<F, U, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n      ma: Kind3<F, R, E, A>\n    ) => Kind3<F, R, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n}\n\n/**\n * @since 2.2.0\n * @deprecated\n */\nexport interface PipeableMonadThrow3C<F extends URIS3, E> {\n  readonly fromOption: (onNone: LazyArg<E>) => <R, A>(ma: Option<A>) => Kind3<F, R, E, A>\n  readonly fromEither: <R, A>(ma: Either<E, A>) => Kind3<F, R, E, A>\n  readonly fromPredicate: {\n    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <U>(a: A) => Kind3<F, U, E, B>\n    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(a: A) => Kind3<F, R, E, A>\n  }\n  readonly filterOrElse: {\n    <A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <R>(\n      ma: Kind3<F, R, E, A>\n    ) => Kind3<F, R, E, B>\n    <A>(predicate: Predicate<A>, onFalse: (a: A) => E): <R>(ma: Kind3<F, R, E, A>) => Kind3<F, R, E, A>\n  }\n}\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport interface PipeableMonadThrow4<F extends URIS4> {\n  readonly fromOption: <E>(onNone: LazyArg<E>) => <S, R, A>(ma: Option<A>) => Kind4<F, S, R, E, A>\n  readonly fromEither: <S, R, E, A>(ma: Either<E, A>) => Kind4<F, S, R, E, A>\n  readonly fromPredicate: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(a: A) => Kind4<F, S, R, E, A>\n  }\n  readonly filterOrElse: {\n    <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>(\n      ma: Kind4<F, S, R, E, A>\n    ) => Kind4<F, S, R, E, B>\n    <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>(ma: Kind4<F, S, R, E, A>) => Kind4<F, S, R, E, A>\n  }\n}\n\nconst isFunctor = <F>(I: any): I is Functor<F> => typeof I.map === 'function'\nconst isContravariant = <F>(I: any): I is Contravariant<F> => typeof I.contramap === 'function'\nconst isFunctorWithIndex = <F>(I: any): I is FunctorWithIndex<F, unknown> => typeof I.mapWithIndex === 'function'\nconst isApply = <F>(I: any): I is Apply<F> => typeof I.ap === 'function'\nconst isChain = <F>(I: any): I is Chain<F> => typeof I.chain === 'function'\nconst isBifunctor = <F>(I: any): I is Bifunctor<F> => typeof I.bimap === 'function'\nconst isExtend = <F>(I: any): I is Extend<F> => typeof I.extend === 'function'\nconst isFoldable = <F>(I: any): I is Foldable<F> => typeof I.reduce === 'function'\nconst isFoldableWithIndex = <F>(I: any): I is FoldableWithIndex<F, unknown> => typeof I.reduceWithIndex === 'function'\nconst isAlt = <F>(I: any): I is Alt<F> => typeof I.alt === 'function'\nconst isCompactable = <F>(I: any): I is Compactable<F> => typeof I.compact === 'function'\nconst isFilterable = <F>(I: any): I is Filterable<F> => typeof I.filter === 'function'\nconst isFilterableWithIndex = <F>(I: any): I is FilterableWithIndex<F, unknown> =>\n  typeof I.filterWithIndex === 'function'\nconst isProfunctor = <F>(I: any): I is Profunctor<F> => typeof I.promap === 'function'\nconst isSemigroupoid = <F>(I: any): I is Semigroupoid<F> => typeof I.compose === 'function'\nconst isMonadThrow = <F>(I: any): I is MonadThrow<F> => typeof I.throwError === 'function'\n\n/**\n * @category zone of death\n * @since 2.0.0\n * @deprecated\n */\nexport function pipeable<F extends URIS4, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain4<F>\n  ? PipeableChain4<F>\n  : I extends Apply4<F>\n  ? PipeableApply4<F>\n  : I extends Functor4<F>\n  ? PipeableFunctor4<F>\n  : {}) &\n  (I extends Contravariant4<F> ? PipeableContravariant4<F> : {}) &\n  (I extends FunctorWithIndex4<F, infer Ix> ? PipeableFunctorWithIndex4<F, Ix> : {}) &\n  (I extends Bifunctor4<F> ? PipeableBifunctor4<F> : {}) &\n  (I extends Extend4<F> ? PipeableExtend4<F> : {}) &\n  (I extends FoldableWithIndex4<F, infer Ix>\n    ? PipeableFoldableWithIndex4<F, Ix>\n    : I extends Foldable4<F>\n    ? PipeableFoldable4<F>\n    : {}) &\n  (I extends Alt4<F> ? PipeableAlt4<F> : {}) &\n  (I extends FilterableWithIndex4<F, infer Ix>\n    ? PipeableFilterableWithIndex4<F, Ix>\n    : I extends Filterable4<F>\n    ? PipeableFilterable4<F>\n    : I extends Compactable4<F>\n    ? PipeableCompactable4<F>\n    : {}) &\n  (I extends Profunctor4<F> ? PipeableProfunctor4<F> : {}) &\n  (I extends Semigroupoid4<F> ? PipeableSemigroupoid4<F> : {}) &\n  (I extends MonadThrow4<F> ? PipeableMonadThrow4<F> : {})\n/** @deprecated */\nexport function pipeable<F extends URIS3, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain3<F>\n  ? PipeableChain3<F>\n  : I extends Apply3<F>\n  ? PipeableApply3<F>\n  : I extends Functor3<F>\n  ? PipeableFunctor3<F>\n  : {}) &\n  (I extends Contravariant3<F> ? PipeableContravariant3<F> : {}) &\n  (I extends FunctorWithIndex3<F, infer Ix> ? PipeableFunctorWithIndex3<F, Ix> : {}) &\n  (I extends Bifunctor3<F> ? PipeableBifunctor3<F> : {}) &\n  (I extends Extend3<F> ? PipeableExtend3<F> : {}) &\n  (I extends FoldableWithIndex3<F, infer Ix>\n    ? PipeableFoldableWithIndex3<F, Ix>\n    : I extends Foldable3<F>\n    ? PipeableFoldable3<F>\n    : {}) &\n  (I extends Alt3<F> ? PipeableAlt3<F> : {}) &\n  (I extends FilterableWithIndex3<F, infer Ix>\n    ? PipeableFilterableWithIndex3<F, Ix>\n    : I extends Filterable3<F>\n    ? PipeableFilterable3<F>\n    : I extends Compactable3<F>\n    ? PipeableCompactable3<F>\n    : {}) &\n  (I extends Profunctor3<F> ? PipeableProfunctor3<F> : {}) &\n  (I extends Semigroupoid3<F> ? PipeableSemigroupoid3<F> : {}) &\n  (I extends MonadThrow3<F> ? PipeableMonadThrow3<F> : {})\n/** @deprecated */\nexport function pipeable<F extends URIS3, I, E>(\n  I: { readonly URI: F } & I\n): (I extends Chain3C<F, E>\n  ? PipeableChain3C<F, E>\n  : I extends Apply3C<F, E>\n  ? PipeableApply3C<F, E>\n  : I extends Functor3C<F, E>\n  ? PipeableFunctor3C<F, E>\n  : {}) &\n  (I extends Contravariant3C<F, E> ? PipeableContravariant3C<F, E> : {}) &\n  (I extends FunctorWithIndex3C<F, infer Ix, E> ? PipeableFunctorWithIndex3C<F, Ix, E> : {}) &\n  (I extends Bifunctor3C<F, E> ? PipeableBifunctor3C<F, E> : {}) &\n  (I extends Extend3C<F, E> ? PipeableExtend3C<F, E> : {}) &\n  (I extends FoldableWithIndex3C<F, infer Ix, E>\n    ? PipeableFoldableWithIndex3C<F, Ix, E>\n    : I extends Foldable3C<F, E>\n    ? PipeableFoldable3C<F, E>\n    : {}) &\n  (I extends Alt3C<F, E> ? PipeableAlt3C<F, E> : {}) &\n  (I extends FilterableWithIndex3C<F, infer Ix, E>\n    ? PipeableFilterableWithIndex3C<F, Ix, E>\n    : I extends Filterable3C<F, E>\n    ? PipeableFilterable3C<F, E>\n    : I extends Compactable3C<F, E>\n    ? PipeableCompactable3C<F, E>\n    : {}) &\n  (I extends Profunctor3C<F, E> ? PipeableProfunctor3C<F, E> : {}) &\n  (I extends Semigroupoid3C<F, E> ? PipeableSemigroupoid3C<F, E> : {}) &\n  (I extends MonadThrow3C<F, E> ? PipeableMonadThrow3C<F, E> : {})\n/** @deprecated */\nexport function pipeable<F extends URIS2, I, E>(\n  I: { readonly URI: F; readonly _E: E } & I\n): (I extends Chain2C<F, E>\n  ? PipeableChain2C<F, E>\n  : I extends Apply2C<F, E>\n  ? PipeableApply2C<F, E>\n  : I extends Functor2C<F, E>\n  ? PipeableFunctor2C<F, E>\n  : {}) &\n  (I extends Contravariant2C<F, E> ? PipeableContravariant2C<F, E> : {}) &\n  (I extends FunctorWithIndex2C<F, infer Ix, E> ? PipeableFunctorWithIndex2C<F, Ix, E> : {}) &\n  (I extends Extend2C<F, E> ? PipeableExtend2C<F, E> : {}) &\n  (I extends FoldableWithIndex2C<F, infer Ix, E>\n    ? PipeableFoldableWithIndex2C<F, Ix, E>\n    : I extends Foldable2C<F, E>\n    ? PipeableFoldable2C<F, E>\n    : {}) &\n  (I extends Alt2C<F, E> ? PipeableAlt2C<F, E> : {}) &\n  (I extends FilterableWithIndex2C<F, infer Ix, E>\n    ? PipeableFilterableWithIndex2C<F, Ix, E>\n    : I extends Filterable2C<F, E>\n    ? PipeableFilterable2C<F, E>\n    : I extends Compactable2C<F, E>\n    ? PipeableCompactable2C<F, E>\n    : {}) &\n  (I extends Profunctor2C<F, E> ? PipeableProfunctor2C<F, E> : {}) &\n  (I extends Semigroupoid2C<F, E> ? PipeableSemigroupoid2C<F, E> : {}) &\n  (I extends MonadThrow2C<F, E> ? PipeableMonadThrow2C<F, E> : {})\n/** @deprecated */\nexport function pipeable<F extends URIS2, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain2<F>\n  ? PipeableChain2<F>\n  : I extends Apply2<F>\n  ? PipeableApply2<F>\n  : I extends Functor2<F>\n  ? PipeableFunctor2<F>\n  : {}) &\n  (I extends Contravariant2<F> ? PipeableContravariant2<F> : {}) &\n  (I extends FunctorWithIndex2<F, infer Ix> ? PipeableFunctorWithIndex2<F, Ix> : {}) &\n  (I extends Bifunctor2<F> ? PipeableBifunctor2<F> : {}) &\n  (I extends Extend2<F> ? PipeableExtend2<F> : {}) &\n  (I extends FoldableWithIndex2<F, infer Ix>\n    ? PipeableFoldableWithIndex2<F, Ix>\n    : I extends Foldable2<F>\n    ? PipeableFoldable2<F>\n    : {}) &\n  (I extends Alt2<F> ? PipeableAlt2<F> : {}) &\n  (I extends FilterableWithIndex2<F, infer Ix>\n    ? PipeableFilterableWithIndex2<F, Ix>\n    : I extends Filterable2<F>\n    ? PipeableFilterable2<F>\n    : I extends Compactable2<F>\n    ? PipeableCompactable2<F>\n    : {}) &\n  (I extends Profunctor2<F> ? PipeableProfunctor2<F> : {}) &\n  (I extends Semigroupoid2<F> ? PipeableSemigroupoid2<F> : {}) &\n  (I extends MonadThrow2<F> ? PipeableMonadThrow2<F> : {})\n/** @deprecated */\nexport function pipeable<F extends URIS, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain1<F>\n  ? PipeableChain1<F>\n  : I extends Apply1<F>\n  ? PipeableApply1<F>\n  : I extends Functor1<F>\n  ? PipeableFunctor1<F>\n  : {}) &\n  (I extends Contravariant1<F> ? PipeableContravariant1<F> : {}) &\n  (I extends FunctorWithIndex1<F, infer Ix> ? PipeableFunctorWithIndex1<F, Ix> : {}) &\n  (I extends Extend1<F> ? PipeableExtend1<F> : {}) &\n  (I extends FoldableWithIndex1<F, infer Ix>\n    ? PipeableFoldableWithIndex1<F, Ix>\n    : I extends Foldable1<F>\n    ? PipeableFoldable1<F>\n    : {}) &\n  (I extends Alt1<F> ? PipeableAlt1<F> : {}) &\n  (I extends FilterableWithIndex1<F, infer Ix>\n    ? PipeableFilterableWithIndex1<F, Ix>\n    : I extends Filterable1<F>\n    ? PipeableFilterable1<F>\n    : I extends Compactable1<F>\n    ? PipeableCompactable1<F>\n    : {}) &\n  (I extends MonadThrow1<F> ? PipeableMonadThrow1<F> : {})\n/** @deprecated */\nexport function pipeable<F, I>(\n  I: { readonly URI: F } & I\n): (I extends Chain<F>\n  ? PipeableChain<F>\n  : I extends Apply<F>\n  ? PipeableApply<F>\n  : I extends Functor<F>\n  ? PipeableFunctor<F>\n  : {}) &\n  (I extends Contravariant<F> ? PipeableContravariant<F> : {}) &\n  (I extends FunctorWithIndex<F, infer Ix> ? PipeableFunctorWithIndex<F, Ix> : {}) &\n  (I extends Bifunctor<F> ? PipeableBifunctor<F> : {}) &\n  (I extends Extend<F> ? PipeableExtend<F> : {}) &\n  (I extends FoldableWithIndex<F, infer Ix>\n    ? PipeableFoldableWithIndex<F, Ix>\n    : I extends Foldable<F>\n    ? PipeableFoldable<F>\n    : {}) &\n  (I extends Alt<F> ? PipeableAlt<F> : {}) &\n  (I extends FilterableWithIndex<F, infer Ix>\n    ? PipeableFilterableWithIndex<F, Ix>\n    : I extends Filterable<F>\n    ? PipeableFilterable<F>\n    : I extends Compactable<F>\n    ? PipeableCompactable<F>\n    : {}) &\n  (I extends Profunctor<F> ? PipeableProfunctor<F> : {}) &\n  (I extends Semigroupoid<F> ? PipeableSemigroupoid<F> : {}) &\n  (I extends MonadThrow<F> ? PipeableMonadThrow<F> : {})\n/** @deprecated */\nexport function pipeable<F, I>(I: { readonly URI: F } & I): Record<string, unknown> {\n  const r: any = {}\n  if (isFunctor<F>(I)) {\n    r.map = map(I)\n  }\n  if (isContravariant<F>(I)) {\n    r.contramap = contramap(I)\n  }\n  if (isFunctorWithIndex<F>(I)) {\n    r.mapWithIndex = mapWithIndex(I)\n  }\n  if (isApply<F>(I)) {\n    r.ap = ap(I)\n    r.apFirst = apFirst_(I)\n    r.apSecond = apSecond_(I)\n  }\n  if (isChain<F>(I)) {\n    r.chain = chain(I)\n    r.chainFirst = chainFirst_(I)\n    r.flatten = r.chain(identity)\n  }\n  if (isBifunctor<F>(I)) {\n    r.bimap = bimap(I)\n    r.mapLeft = mapLeft(I)\n  }\n  if (isExtend<F>(I)) {\n    r.extend = extend(I)\n    r.duplicate = r.extend(identity)\n  }\n  if (isFoldable<F>(I)) {\n    r.reduce = reduce(I)\n    r.foldMap = foldMap(I)\n    r.reduceRight = reduceRight(I)\n  }\n  if (isFoldableWithIndex<F>(I)) {\n    r.reduceWithIndex = reduceWithIndex(I)\n    r.foldMapWithIndex = foldMapWithIndex(I)\n    r.reduceRightWithIndex = reduceRightWithIndex(I)\n  }\n  if (isAlt<F>(I)) {\n    r.alt = alt(I)\n  }\n  if (isCompactable<F>(I)) {\n    r.compact = I.compact\n    r.separate = I.separate\n  }\n  if (isFilterable<F>(I)) {\n    r.filter = filter(I)\n    r.filterMap = filterMap(I)\n    r.partition = partition(I)\n    r.partitionMap = partitionMap(I)\n  }\n  if (isFilterableWithIndex<F>(I)) {\n    r.filterWithIndex = filterWithIndex(I)\n    r.filterMapWithIndex = filterMapWithIndex(I)\n    r.partitionWithIndex = partitionWithIndex(I)\n    r.partitionMapWithIndex = partitionMapWithIndex(I)\n  }\n  if (isProfunctor<F>(I)) {\n    r.promap = promap(I)\n  }\n  if (isSemigroupoid<F>(I)) {\n    r.compose = compose(I)\n  }\n  if (isMonadThrow<F>(I)) {\n    const fromOption: PipeableMonadThrow<F>['fromOption'] = (onNone) => (ma) =>\n      ma._tag === 'None' ? I.throwError(onNone()) : I.of(ma.value)\n    const fromEither: PipeableMonadThrow<F>['fromEither'] = (ma) =>\n      ma._tag === 'Left' ? I.throwError(ma.left) : I.of(ma.right)\n    const fromPredicate: PipeableMonadThrow<F>['fromPredicate'] =\n      <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E) =>\n      (a: A) =>\n        predicate(a) ? I.of(a) : I.throwError(onFalse(a))\n    const filterOrElse: PipeableMonadThrow<F>['filterOrElse'] =\n      <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E) =>\n      (ma: HKT<F, A>) =>\n        I.chain(ma, (a) => (predicate(a) ? I.of(a) : I.throwError(onFalse(a))))\n    r.fromOption = fromOption\n    r.fromEither = fromEither\n    r.fromPredicate = fromPredicate\n    r.filterOrElse = filterOrElse\n  }\n  return r\n}\n\n/**\n * Use [`pipe`](https://gcanti.github.io/fp-ts/modules/function.ts.html#pipe) from `function` module instead.\n *\n * @since 2.0.0\n * @deprecated\n */\nexport const pipe = pipeFromFunctionModule\n"
  },
  {
    "path": "src/string.ts",
    "content": "/**\n * @since 2.10.0\n */\nimport * as E from './Eq'\nimport * as M from './Monoid'\nimport * as O from './Ord'\nimport { isNonEmpty, ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'\nimport { Refinement } from './Refinement'\nimport * as S from './Semigroup'\nimport * as Sh from './Show'\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n *\n * assert.deepStrictEqual(S.Eq.equals('a', 'a'), true)\n * assert.deepStrictEqual(S.Eq.equals('a', 'b'), false)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const Eq: E.Eq<string> = {\n  equals: (first, second) => first === second\n}\n\n/**\n * `string` semigroup under concatenation.\n *\n * @example\n * import * as S from 'fp-ts/string'\n *\n * assert.deepStrictEqual(S.Semigroup.concat('a', 'b'), 'ab')\n *\n * @category instances\n * @since 2.10.0\n */\nexport const Semigroup: S.Semigroup<string> = {\n  concat: (first, second) => first + second\n}\n\n/**\n * An empty `string`.\n *\n * @since 2.10.0\n */\nexport const empty = ''\n\n/**\n * `string` monoid under concatenation.\n *\n * The `empty` value is `''`.\n *\n * @example\n * import * as S from 'fp-ts/string'\n *\n * assert.deepStrictEqual(S.Monoid.concat('a', 'b'), 'ab')\n * assert.deepStrictEqual(S.Monoid.concat('a', S.Monoid.empty), 'a')\n *\n * @category instances\n * @since 2.10.0\n */\nexport const Monoid: M.Monoid<string> = {\n  concat: Semigroup.concat,\n  empty\n}\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n *\n * assert.deepStrictEqual(S.Ord.compare('a', 'a'), 0)\n * assert.deepStrictEqual(S.Ord.compare('a', 'b'), -1)\n * assert.deepStrictEqual(S.Ord.compare('b', 'a'), 1)\n *\n * @category instances\n * @since 2.10.0\n */\nexport const Ord: O.Ord<string> = {\n  equals: Eq.equals,\n  compare: (first, second) => (first < second ? -1 : first > second ? 1 : 0)\n}\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n *\n * assert.deepStrictEqual(S.Show.show('a'), '\"a\"')\n *\n * @category instances\n * @since 2.10.0\n */\nexport const Show: Sh.Show<string> = {\n  show: (s) => JSON.stringify(s)\n}\n\n// -------------------------------------------------------------------------------------\n// refinements\n// -------------------------------------------------------------------------------------\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n *\n * assert.deepStrictEqual(S.isString('a'), true)\n * assert.deepStrictEqual(S.isString(1), false)\n *\n * @category refinements\n * @since 2.11.0\n */\nexport const isString: Refinement<unknown, string> = (u: unknown): u is string => typeof u === 'string'\n\n// -------------------------------------------------------------------------------------\n// combinators\n// -------------------------------------------------------------------------------------\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('a', S.toUpperCase), 'A')\n *\n * @since 2.11.0\n */\nexport const toUpperCase = (s: string): string => s.toUpperCase()\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('A', S.toLowerCase), 'a')\n *\n * @since 2.11.0\n */\nexport const toLowerCase = (s: string): string => s.toLowerCase()\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('abc', S.replace('b', 'd')), 'adc')\n *\n * @since 2.11.0\n */\nexport const replace =\n  (searchValue: string | RegExp, replaceValue: string) =>\n  (s: string): string =>\n    s.replace(searchValue, replaceValue)\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe(' a ', S.trim), 'a')\n *\n * @since 2.11.0\n */\nexport const trim = (s: string): string => s.trim()\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe(' a ', S.trimLeft), 'a ')\n *\n * @since 2.11.0\n */\nexport const trimLeft = (s: string): string => s.trimLeft()\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe(' a ', S.trimRight), ' a')\n *\n * @since 2.11.0\n */\nexport const trimRight = (s: string): string => s.trimRight()\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('abcd', S.slice(1, 3)), 'bc')\n *\n * @since 2.11.0\n */\nexport const slice =\n  (start: number, end: number) =>\n  (s: string): string =>\n    s.slice(start, end)\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Test whether a `string` is empty.\n *\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('', S.isEmpty), true)\n * assert.deepStrictEqual(pipe('a', S.isEmpty), false)\n *\n * @since 2.10.0\n */\nexport const isEmpty = (s: string): boolean => s.length === 0\n\n/**\n * Calculate the number of characters in a `string`.\n *\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('abc', S.size), 3)\n *\n * @since 2.10.0\n */\nexport const size = (s: string): number => s.length\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('abc', S.split('')), ['a', 'b', 'c'])\n * assert.deepStrictEqual(pipe('', S.split('')), [''])\n *\n * @since 2.11.0\n */\nexport const split =\n  (separator: string | RegExp) =>\n  (s: string): ReadonlyNonEmptyArray<string> => {\n    const out = s.split(separator)\n    return isNonEmpty(out) ? out : [s]\n  }\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('abc', S.includes('b')), true)\n * assert.deepStrictEqual(pipe('abc', S.includes('d')), false)\n *\n * @since 2.11.0\n */\nexport const includes =\n  (searchString: string, position?: number) =>\n  (s: string): boolean =>\n    s.includes(searchString, position)\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('abc', S.startsWith('a')), true)\n * assert.deepStrictEqual(pipe('bc', S.startsWith('a')), false)\n *\n * @since 2.11.0\n */\nexport const startsWith =\n  (searchString: string, position?: number) =>\n  (s: string): boolean =>\n    s.startsWith(searchString, position)\n\n/**\n * @example\n * import * as S from 'fp-ts/string'\n * import { pipe } from 'fp-ts/function'\n *\n * assert.deepStrictEqual(pipe('abc', S.endsWith('c')), true)\n * assert.deepStrictEqual(pipe('ab', S.endsWith('c')), false)\n *\n * @since 2.11.0\n */\nexport const endsWith =\n  (searchString: string, position?: number) =>\n  (s: string): boolean =>\n    s.endsWith(searchString, position)\n"
  },
  {
    "path": "src/struct.ts",
    "content": "/**\n * @since 2.10.0\n */\nimport * as _ from './internal'\nimport { Semigroup } from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * Return a semigroup which works like `Object.assign`.\n *\n * @example\n * import { getAssignSemigroup } from 'fp-ts/struct'\n *\n * interface Person {\n *   readonly name: string\n *   readonly age: number\n * }\n *\n * const S = getAssignSemigroup<Person>()\n * assert.deepStrictEqual(S.concat({ name: 'name', age: 23 }, { name: 'name', age: 24 }), { name: 'name', age: 24 })\n *\n * @category instances\n * @since 2.10.0\n */\nexport const getAssignSemigroup = <A extends object = never>(): Semigroup<A> => ({\n  concat: (first, second) => Object.assign({}, first, second)\n})\n\n// -------------------------------------------------------------------------------------\n// utils\n// -------------------------------------------------------------------------------------\n\n/**\n * Creates a new object by recursively evolving a shallow copy of `a`, according to the `transformation` functions.\n *\n * @example\n * import { pipe } from 'fp-ts/function'\n * import { evolve } from 'fp-ts/struct'\n *\n * assert.deepStrictEqual(\n *   pipe(\n *     { a: 'a', b: 1 },\n *     evolve({\n *       a: (a) => a.length,\n *       b: (b) => b * 2\n *     })\n *   ),\n *   { a: 1, b: 2 }\n * )\n *\n * @since 2.11.0\n */\nexport const evolve =\n  <A, F extends { [K in keyof A]: (a: A[K]) => unknown }>(transformations: F) =>\n  (a: A): { [K in keyof F]: ReturnType<F[K]> } => {\n    const out: Record<string, unknown> = {}\n    for (const k in a) {\n      if (_.has.call(a, k)) {\n        out[k] = transformations[k](a[k])\n      }\n    }\n    return out as any\n  }\n"
  },
  {
    "path": "src/void.ts",
    "content": "/**\n * @since 2.11.0\n */\nimport * as M from './Monoid'\nimport * as Se from './Semigroup'\n\n// -------------------------------------------------------------------------------------\n// instances\n// -------------------------------------------------------------------------------------\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const Semigroup: Se.Semigroup<void> = Se.constant<void>(undefined)\n\n/**\n * @category instances\n * @since 2.11.0\n */\nexport const Monoid: M.Monoid<void> = {\n  concat: Semigroup.concat,\n  empty: undefined\n}\n"
  },
  {
    "path": "test/Alternative.ts",
    "content": "import * as _ from '../src/Alternative'\nimport * as M from '../src/Monoid'\nimport * as NEA from '../src/NonEmptyArray'\nimport * as O from '../src/Option'\nimport * as S from '../src/Semigroup'\nimport * as U from './util'\n\ndescribe('Alternative', () => {\n  it('altAll', () => {\n    const altAll = _.altAll(O.Alternative)\n    U.deepStrictEqual(altAll([]), O.none)\n    U.deepStrictEqual(altAll([O.none]), O.none)\n    U.deepStrictEqual(altAll([O.none, O.some(1)]), O.some(1))\n  })\n\n  it('getAlternativeMonoid', () => {\n    const altConcatAll = M.concatAll(_.getAlternativeMonoid(O.Alternative)(NEA.getSemigroup<number>()))\n    U.deepStrictEqual(altConcatAll([]), O.none)\n    U.deepStrictEqual(altConcatAll([O.none]), O.none)\n    U.deepStrictEqual(altConcatAll([O.none, O.some([1]), O.some([2])]), O.some([1, 2]))\n\n    const pickFirst = _.getAlternativeMonoid(O.Alternative)(S.first<string>())\n    U.deepStrictEqual(pickFirst.concat(O.some('a'), O.some('b')), O.some('a'))\n    U.deepStrictEqual(pickFirst.concat(O.none, O.some('b')), O.some('b'))\n    U.deepStrictEqual(pickFirst.concat(O.some('a'), O.none), O.some('a'))\n\n    const pickLast = _.getAlternativeMonoid(O.Alternative)(S.last<string>())\n    U.deepStrictEqual(pickLast.concat(O.some('a'), O.some('b')), O.some('b'))\n    U.deepStrictEqual(pickLast.concat(O.none, O.some('b')), O.some('b'))\n    U.deepStrictEqual(pickLast.concat(O.some('a'), O.none), O.some('a'))\n  })\n})\n"
  },
  {
    "path": "test/Applicative.ts",
    "content": "import { getApplicativeComposition } from '../src/Applicative'\nimport { increment } from '../src/function'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport * as U from './util'\n\ndescribe('Applicative', () => {\n  it('getApplicativeComposition', () => {\n    const AC = getApplicativeComposition(RA.Applicative, O.Applicative)\n    U.deepStrictEqual(AC.of(1), [O.some(1)])\n    U.deepStrictEqual(AC.map(AC.of(1), increment), [O.some(2)])\n    U.deepStrictEqual(AC.ap([O.some(U.double), O.some(increment)], [O.some(1), O.some(2)]), [\n      O.some(2),\n      O.some(4),\n      O.some(2),\n      O.some(3)\n    ])\n    U.deepStrictEqual(AC.ap([O.some(U.double), O.none], [O.some(1), O.some(2)]), [O.some(2), O.some(4), O.none, O.none])\n  })\n})\n"
  },
  {
    "path": "test/Apply.ts",
    "content": "import { sequenceS, sequenceT } from '../src/Apply'\nimport * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport * as U from './util'\n\ndescribe('Apply', () => {\n  it('sequenceT', () => {\n    const sequenceTOption = sequenceT(O.Applicative)\n    U.deepStrictEqual(sequenceTOption(O.some(1)), O.some([1]))\n    U.deepStrictEqual(sequenceTOption(O.some(1), O.some('a')), O.some([1, 'a']))\n    U.deepStrictEqual(sequenceTOption(O.some(1), O.some('a'), O.some(true)), O.some([1, 'a', true]))\n    U.deepStrictEqual(sequenceTOption(O.some(1), O.some('a'), O.some(true), O.some(2)), O.some([1, 'a', true, 2]))\n    U.deepStrictEqual(\n      sequenceTOption(O.some(1), O.some('a'), O.some(true), O.some(2), O.some('b')),\n      O.some([1, 'a', true, 2, 'b'])\n    )\n    U.deepStrictEqual(\n      sequenceTOption(O.some(1), O.some('a'), O.some(true), O.some(2), O.some('b'), O.some(false)),\n      O.some([1, 'a', true, 2, 'b', false])\n    )\n    U.deepStrictEqual(sequenceTOption(O.some(1), O.some('a'), O.none), O.none)\n\n    // #914\n    const a1: ReadonlyArray<number> = [1, 2, 3]\n    const a2: ReadonlyArray<string> = ['a', 'b', 'c']\n    const a3: ReadonlyArray<boolean> = [true, false]\n    U.deepStrictEqual(\n      pipe(sequenceT(RA.Applicative)(a1, a2, a3), (arr) => arr.map(([x, y, z]) => `(${x}, ${y}, ${z})`)),\n      [\n        '(1, a, true)',\n        '(1, a, false)',\n        '(1, b, true)',\n        '(1, b, false)',\n        '(1, c, true)',\n        '(1, c, false)',\n        '(2, a, true)',\n        '(2, a, false)',\n        '(2, b, true)',\n        '(2, b, false)',\n        '(2, c, true)',\n        '(2, c, false)',\n        '(3, a, true)',\n        '(3, a, false)',\n        '(3, b, true)',\n        '(3, b, false)',\n        '(3, c, true)',\n        '(3, c, false)'\n      ]\n    )\n  })\n\n  it('sequenceS', () => {\n    const adoOption = sequenceS(O.Applicative)\n    U.deepStrictEqual(adoOption({ a: O.some(1) }), O.some({ a: 1 }))\n    U.deepStrictEqual(adoOption({ a: O.some(1), b: O.some('a') }), O.some({ a: 1, b: 'a' }))\n    U.deepStrictEqual(adoOption({ a: O.some(1), b: O.some('a'), c: O.some(true) }), O.some({ a: 1, b: 'a', c: true }))\n    U.deepStrictEqual(\n      adoOption({ a: O.some(1), b: O.some('a'), c: O.some(true), d: O.some(2) }),\n      O.some({ a: 1, b: 'a', c: true, d: 2 })\n    )\n    U.deepStrictEqual(\n      adoOption({ a: O.some(1), b: O.some('a'), c: O.some(true), d: O.some(2), e: O.some('b') }),\n      O.some({ a: 1, b: 'a', c: true, d: 2, e: 'b' })\n    )\n    U.deepStrictEqual(\n      adoOption({ a: O.some(1), b: O.some('a'), c: O.some(true), d: O.some(2), e: O.some('b'), f: O.some(false) }),\n      O.some({ a: 1, b: 'a', c: true, d: 2, e: 'b', f: false })\n    )\n    U.deepStrictEqual(adoOption({ a: O.some(1), b: O.none }), O.none)\n\n    const adoEither = sequenceS(E.Applicative)\n    U.deepStrictEqual(adoEither({ a: E.right(1) }), E.right({ a: 1 }))\n    U.deepStrictEqual(adoEither({ a: E.right(1), b: E.right(2) }), E.right({ a: 1, b: 2 }))\n    U.deepStrictEqual(adoEither({ a: E.right(1), b: E.left('error') }), E.left('error'))\n\n    const adoValidation = sequenceS(E.getApplicativeValidation(RA.getMonoid<string>()))\n    U.deepStrictEqual(adoValidation({ a: E.right(1) }), E.right({ a: 1 }))\n    U.deepStrictEqual(adoValidation({ a: E.right(1), b: E.right(2) }), E.right({ a: 1, b: 2 }))\n    U.deepStrictEqual(adoValidation({ a: E.right(1), b: E.left(['error']) }), E.left(['error']))\n    U.deepStrictEqual(adoValidation({ a: E.left(['error1']), b: E.left(['error2']) }), E.left(['error1', 'error2']))\n\n    // #914\n    const a1: ReadonlyArray<number> = [1, 2, 3]\n    const a2: ReadonlyArray<string> = ['a', 'b', 'c']\n    const a3: ReadonlyArray<boolean> = [true, false]\n    U.deepStrictEqual(\n      pipe(sequenceS(RA.Applicative)({ a1, a2, a3 }), (arr) => arr.map(({ a1, a2, a3 }) => `(${a1}, ${a2}, ${a3})`)),\n      [\n        '(1, a, true)',\n        '(1, a, false)',\n        '(1, b, true)',\n        '(1, b, false)',\n        '(1, c, true)',\n        '(1, c, false)',\n        '(2, a, true)',\n        '(2, a, false)',\n        '(2, b, true)',\n        '(2, b, false)',\n        '(2, c, true)',\n        '(2, c, false)',\n        '(3, a, true)',\n        '(3, a, false)',\n        '(3, b, true)',\n        '(3, b, false)',\n        '(3, c, true)',\n        '(3, c, false)'\n      ]\n    )\n  })\n})\n"
  },
  {
    "path": "test/Array.ts",
    "content": "import * as fc from 'fast-check'\nimport { isDeepStrictEqual } from 'util'\n\nimport * as _ from '../src/Array'\nimport * as B from '../src/boolean'\nimport * as E from '../src/Either'\nimport * as Eq from '../src/Eq'\nimport { identity, pipe, tuple } from '../src/function'\nimport * as M from '../src/Monoid'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as Ord from '../src/Ord'\nimport { Predicate } from '../src/Predicate'\nimport { Refinement } from '../src/Refinement'\nimport { separated } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\n/* tslint:disable:readonly-array */\n\ndescribe('Array', () => {\n  describe('pipeables', () => {\n    it('traverse', () => {\n      const traverse = _.traverse(O.Applicative)((n: number): O.Option<number> => (n % 2 === 0 ? O.none : O.some(n)))\n      U.deepStrictEqual(traverse([1, 2]), O.none)\n      U.deepStrictEqual(traverse([1, 3]), O.some([1, 3]))\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      U.deepStrictEqual(sequence([O.some(1), O.some(3)]), O.some([1, 3]))\n      U.deepStrictEqual(sequence([O.some(1), O.none]), O.none)\n    })\n\n    it('traverseWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'bb'],\n          _.traverseWithIndex(O.Applicative)((i, s) => (s.length >= 1 ? O.some(s + i) : O.none))\n        ),\n        O.some(['a0', 'bb1'])\n      )\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'bb'],\n          _.traverseWithIndex(O.Applicative)((i, s) => (s.length > 1 ? O.some(s + i) : O.none))\n        ),\n        O.none\n      )\n    })\n\n    it('lookup', () => {\n      U.deepStrictEqual(_.lookup(0, [1, 2, 3]), O.some(1))\n      U.deepStrictEqual(_.lookup(3, [1, 2, 3]), O.none)\n      U.deepStrictEqual(pipe([1, 2, 3], _.lookup(0)), O.some(1))\n      U.deepStrictEqual(pipe([1, 2, 3], _.lookup(3)), O.none)\n    })\n\n    it('elem', () => {\n      U.deepStrictEqual(_.elem(N.Eq)(2, [1, 2, 3]), true)\n      U.deepStrictEqual(_.elem(N.Eq)(0, [1, 2, 3]), false)\n      U.deepStrictEqual(pipe([1, 2, 3], _.elem(N.Eq)(2)), true)\n      U.deepStrictEqual(pipe([1, 2, 3], _.elem(N.Eq)(0)), false)\n    })\n\n    it('unfold', () => {\n      const as = _.unfold(5, (n) => (n > 0 ? O.some([n, n - 1]) : O.none))\n      U.deepStrictEqual(as, [5, 4, 3, 2, 1])\n    })\n\n    it('wither', async () => {\n      const wither = _.wither(T.ApplicativePar)((n: number) => T.of(n > 2 ? O.some(n + 1) : O.none))\n      U.deepStrictEqual(await pipe([], wither)(), [])\n      U.deepStrictEqual(await pipe([1, 3], wither)(), [4])\n    })\n\n    it('wilt', async () => {\n      const wilt = _.wilt(T.ApplicativePar)((n: number) => T.of(n > 2 ? E.right(n + 1) : E.left(n - 1)))\n      U.deepStrictEqual(await pipe([], wilt)(), separated([], []))\n      U.deepStrictEqual(await pipe([1, 3], wilt)(), separated([0], [4]))\n    })\n  })\n\n  describe('pipeables', () => {\n    it('map', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.map((n) => n * 2)\n        ),\n        [2, 4, 6]\n      )\n    })\n\n    it('mapWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.mapWithIndex((i, n) => n + i)\n        ),\n        [1, 3, 5]\n      )\n    })\n\n    it('alt', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2],\n          _.alt(() => [3, 4])\n        ),\n        [1, 2, 3, 4]\n      )\n    })\n\n    it('ap', () => {\n      U.deepStrictEqual(pipe([(x: number) => x * 2, (x: number) => x * 3], _.ap([1, 2, 3])), [2, 4, 6, 3, 6, 9])\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe([1, 2], _.apFirst(['a', 'b', 'c'])), [1, 1, 1, 2, 2, 2])\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe([1, 2], _.apSecond(['a', 'b', 'c'])), ['a', 'b', 'c', 'a', 'b', 'c'])\n    })\n\n    it('flatMap', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.flatMap((n) => [n, n + 1])\n        ),\n        [1, 2, 2, 3, 3, 4]\n      )\n      U.deepStrictEqual(\n        _.flatMap([1, 2, 3], (n) => [n, n + 1]),\n        [1, 2, 2, 3, 3, 4]\n      )\n    })\n\n    it('chain', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.chain((n) => [n, n + 1])\n        ),\n        [1, 2, 2, 3, 3, 4]\n      )\n    })\n\n    it('chainWithIndex', () => {\n      const f = _.chainWithIndex((i, n: number) => [n + i])\n      U.deepStrictEqual(pipe([1, 2, 3], f), [1, 3, 5])\n      U.deepStrictEqual(pipe([], f), [])\n    })\n\n    it('chainFirst', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.chainFirst((n) => [n, n + 1])\n        ),\n        [1, 1, 2, 2, 3, 3]\n      )\n    })\n\n    it('extend', () => {\n      const sum = (as: Array<number>) => M.concatAll(N.MonoidSum)(as)\n      U.deepStrictEqual(pipe([1, 2, 3, 4], _.extend(sum)), [10, 9, 7, 4])\n      U.deepStrictEqual(pipe([1, 2, 3, 4], _.extend(identity)), [[1, 2, 3, 4], [2, 3, 4], [3, 4], [4]])\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe(['a', 'b', 'c'], _.foldMap(S.Monoid)(identity)), 'abc')\n      U.deepStrictEqual(pipe([], _.foldMap(S.Monoid)(identity)), '')\n    })\n\n    it('compact', () => {\n      U.deepStrictEqual(_.compact([]), [])\n      U.deepStrictEqual(_.compact([O.some(1), O.some(2), O.some(3)]), [1, 2, 3])\n      U.deepStrictEqual(_.compact([O.some(1), O.none, O.some(3)]), [1, 3])\n    })\n\n    it('separate', () => {\n      U.deepStrictEqual(_.separate([]), separated([], []))\n      U.deepStrictEqual(_.separate([E.left(123), E.right('123')]), separated([123], ['123']))\n    })\n\n    it('filter', () => {\n      const g = (n: number) => n % 2 === 1\n      U.deepStrictEqual(pipe([1, 2, 3], _.filter(g)), [1, 3])\n      const x = pipe([O.some(3), O.some(2), O.some(1)], _.filter(O.isSome))\n      U.deepStrictEqual(x, [O.some(3), O.some(2), O.some(1)])\n      const y = pipe([O.some(3), O.none, O.some(1)], _.filter(O.isSome))\n      U.deepStrictEqual(y, [O.some(3), O.some(1)])\n    })\n\n    it('filterWithIndex', () => {\n      const f = (n: number) => n % 2 === 0\n      U.deepStrictEqual(pipe(['a', 'b', 'c'], _.filterWithIndex(f)), ['a', 'c'])\n    })\n\n    it('filterMap', () => {\n      const f = (n: number) => (n % 2 === 0 ? O.none : O.some(n))\n      U.deepStrictEqual(pipe([1, 2, 3], _.filterMap(f)), [1, 3])\n      U.deepStrictEqual(pipe([], _.filterMap(f)), [])\n    })\n\n    it('foldMapWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'b'],\n          _.foldMapWithIndex(S.Monoid)((i, a) => i + a)\n        ),\n        '0a1b'\n      )\n    })\n\n    it('filterMapWithIndex', () => {\n      const f = (i: number, n: number) => ((i + n) % 2 === 0 ? O.none : O.some(n))\n      U.deepStrictEqual(pipe([1, 2, 4], _.filterMapWithIndex(f)), [1, 2])\n      U.deepStrictEqual(pipe([], _.filterMapWithIndex(f)), [])\n    })\n\n    it('partitionMap', () => {\n      U.deepStrictEqual(pipe([], _.partitionMap(identity)), separated([], []))\n      U.deepStrictEqual(\n        pipe([E.right(1), E.left('foo'), E.right(2)], _.partitionMap(identity)),\n        separated(['foo'], [1, 2])\n      )\n    })\n\n    it('partition', () => {\n      U.deepStrictEqual(\n        pipe(\n          [],\n          _.partition((n) => n > 2)\n        ),\n        separated([], [])\n      )\n      U.deepStrictEqual(\n        pipe(\n          [1, 3],\n          _.partition((n) => n > 2)\n        ),\n        separated([1], [3])\n      )\n    })\n\n    it('partitionMapWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          [],\n          _.partitionMapWithIndex((_, a) => a)\n        ),\n        separated([], [])\n      )\n      U.deepStrictEqual(\n        pipe(\n          [E.right(1), E.left('foo'), E.right(2)],\n          _.partitionMapWithIndex((i, a) =>\n            pipe(\n              a,\n              E.filterOrElse(\n                (n) => n > i,\n                () => 'err'\n              )\n            )\n          )\n        ),\n        separated(['foo', 'err'], [1])\n      )\n    })\n\n    it('partitionWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          [],\n          _.partitionWithIndex((i, n) => i + n > 2)\n        ),\n        separated([], [])\n      )\n      U.deepStrictEqual(\n        pipe(\n          [1, 2],\n          _.partitionWithIndex((i, n) => i + n > 2)\n        ),\n        separated([1], [2])\n      )\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'b', 'c'],\n          _.reduce('', (acc, a) => acc + a)\n        ),\n        'abc'\n      )\n    })\n\n    it('reduceWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'b'],\n          _.reduceWithIndex('', (i, b, a) => b + i + a)\n        ),\n        '0a1b'\n      )\n    })\n\n    it('reduceRight', () => {\n      const as: Array<string> = ['a', 'b', 'c']\n      const b = ''\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(pipe(as, _.reduceRight(b, f)), 'cba')\n      const x2: Array<string> = []\n      U.deepStrictEqual(pipe(x2, _.reduceRight(b, f)), '')\n    })\n\n    it('reduceRightWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'b'],\n          _.reduceRightWithIndex('', (i, a, b) => b + i + a)\n        ),\n        '1b0a'\n      )\n    })\n\n    it('duplicate', () => {\n      U.deepStrictEqual(pipe(['a', 'b'], _.duplicate), [['a', 'b'], ['b']])\n    })\n  })\n\n  it('getMonoid', () => {\n    const M = _.getMonoid<number>()\n    U.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4])\n    U.deepStrictEqual(M.concat([1, 2], M.empty), [1, 2])\n    U.deepStrictEqual(M.concat(M.empty, [1, 2]), [1, 2])\n  })\n\n  it('getEq', () => {\n    const O = _.getEq(S.Ord)\n    U.deepStrictEqual(O.equals([], []), true)\n    U.deepStrictEqual(O.equals(['a'], ['a']), true)\n    U.deepStrictEqual(O.equals(['a', 'b'], ['a', 'b']), true)\n    U.deepStrictEqual(O.equals(['a'], []), false)\n    U.deepStrictEqual(O.equals([], ['a']), false)\n    U.deepStrictEqual(O.equals(['a'], ['b']), false)\n    U.deepStrictEqual(O.equals(['a', 'b'], ['b', 'a']), false)\n    U.deepStrictEqual(O.equals(['a', 'a'], ['a']), false)\n  })\n\n  it('getOrd', () => {\n    const O = _.getOrd(S.Ord)\n    U.deepStrictEqual(O.compare([], []), 0)\n    U.deepStrictEqual(O.compare(['a'], ['a']), 0)\n\n    U.deepStrictEqual(O.compare(['b'], ['a']), 1)\n    U.deepStrictEqual(O.compare(['a'], ['b']), -1)\n\n    U.deepStrictEqual(O.compare(['a'], []), 1)\n    U.deepStrictEqual(O.compare([], ['a']), -1)\n    U.deepStrictEqual(O.compare(['a', 'a'], ['a']), 1)\n    U.deepStrictEqual(O.compare(['a', 'a'], ['b']), -1)\n\n    U.deepStrictEqual(O.compare(['a', 'a'], ['a', 'a']), 0)\n    U.deepStrictEqual(O.compare(['a', 'b'], ['a', 'b']), 0)\n\n    U.deepStrictEqual(O.compare(['a', 'a'], ['a', 'b']), -1)\n    U.deepStrictEqual(O.compare(['a', 'b'], ['a', 'a']), 1)\n\n    U.deepStrictEqual(O.compare(['a', 'b'], ['b', 'a']), -1)\n    U.deepStrictEqual(O.compare(['b', 'a'], ['a', 'a']), 1)\n    U.deepStrictEqual(O.compare(['b', 'a'], ['a', 'b']), 1)\n    U.deepStrictEqual(O.compare(['b', 'b'], ['b', 'a']), 1)\n    U.deepStrictEqual(O.compare(['b', 'a'], ['b', 'b']), -1)\n  })\n\n  it('isEmpty', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.isEmpty(as), false)\n    U.deepStrictEqual(_.isEmpty([]), true)\n  })\n\n  it('isNotEmpty', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.isNonEmpty(as), true)\n    U.deepStrictEqual(_.isNonEmpty([]), false)\n  })\n\n  it('cons', () => {\n    U.deepStrictEqual(_.cons(0, [1, 2, 3]), [0, 1, 2, 3])\n    U.deepStrictEqual(_.cons([1], [[2]]), [[1], [2]])\n    U.deepStrictEqual(pipe([1, 2, 3], _.cons(0)), [0, 1, 2, 3])\n    U.deepStrictEqual(pipe([[2]], _.cons([1])), [[1], [2]])\n  })\n\n  it('snoc', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.snoc(as, 4), [1, 2, 3, 4])\n    U.deepStrictEqual(_.snoc([[1]], [2]), [[1], [2]])\n  })\n\n  it('head', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.head(as), O.some(1))\n    U.deepStrictEqual(_.head([]), O.none)\n  })\n\n  it('last', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.last(as), O.some(3))\n    U.deepStrictEqual(_.last([]), O.none)\n  })\n\n  it('tail', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.tail(as), O.some([2, 3]))\n    U.deepStrictEqual(_.tail([]), O.none)\n  })\n\n  it('takeLeft', () => {\n    // empty\n    const empty: Array<number> = []\n    U.deepStrictEqual(_.takeLeft(0)(empty), empty)\n    const full: Array<number> = [1, 2]\n    // non empty\n    U.deepStrictEqual(_.takeLeft(0)(full), [])\n    U.deepStrictEqual(_.takeLeft(1)(full), [1])\n    // full\n    U.deepStrictEqual(_.takeLeft(2)(full), full)\n    // out of bound\n    U.deepStrictEqual(_.takeLeft(1)(empty), empty)\n    U.deepStrictEqual(_.takeLeft(3)(full), full)\n    U.deepStrictEqual(_.takeLeft(-1)(empty), empty)\n    U.deepStrictEqual(_.takeLeft(-1)(full), full)\n  })\n\n  it('takeRight', () => {\n    // empty\n    const empty: Array<number> = []\n    U.deepStrictEqual(_.takeRight(0)(empty), empty)\n    const full: Array<number> = [1, 2]\n    // non empty\n    U.deepStrictEqual(_.takeRight(0)(full), [])\n    U.deepStrictEqual(_.takeRight(1)(full), [2])\n    // full\n    U.deepStrictEqual(_.takeRight(2)(full), full)\n    // out of bound\n    U.deepStrictEqual(_.takeRight(1)(empty), empty)\n    U.deepStrictEqual(_.takeRight(3)(full), full)\n    U.deepStrictEqual(_.takeRight(-1)(empty), empty)\n    U.deepStrictEqual(_.takeRight(-1)(full), full)\n  })\n\n  it('spanLeft', () => {\n    const f = _.spanLeft((n: number) => n % 2 === 1)\n    const assertSpanLeft = (input: Array<number>, expectedInit: Array<number>, expectedRest: Array<number>) => {\n      const { init, rest } = f(input)\n      U.deepStrictEqual(init, expectedInit)\n      U.deepStrictEqual(rest, expectedRest)\n    }\n    U.deepStrictEqual(f([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] })\n    const empty: Array<number> = []\n    assertSpanLeft(empty, empty, [])\n    assertSpanLeft([], [], [])\n    const inputAll: Array<number> = [1, 3]\n    assertSpanLeft(inputAll, inputAll, [])\n    const inputNone: Array<number> = [2, 4]\n    assertSpanLeft(inputNone, [], inputNone)\n  })\n\n  it('takeLeftWhile', () => {\n    const f = (n: number) => n % 2 === 0\n    U.deepStrictEqual(_.takeLeftWhile(f)([2, 4, 3, 6]), [2, 4])\n    U.deepStrictEqual(_.takeLeftWhile(f)([]), [])\n    U.deepStrictEqual(_.takeLeftWhile(f)([1, 2, 4]), [])\n    U.deepStrictEqual(_.takeLeftWhile(f)([2, 4]), [2, 4])\n  })\n\n  it('dropLeft', () => {\n    // empty\n    const empty: Array<number> = []\n    U.deepStrictEqual(_.dropLeft(0)(empty), empty)\n    const full: Array<number> = [1, 2]\n    // non empty\n    U.deepStrictEqual(_.dropLeft(0)(full), full)\n    U.deepStrictEqual(_.dropLeft(1)(full), [2])\n    // full\n    U.deepStrictEqual(_.dropLeft(2)(full), [])\n    // out of bound\n    U.deepStrictEqual(_.dropLeft(1)(empty), empty)\n    U.deepStrictEqual(_.dropLeft(3)(full), [])\n    U.deepStrictEqual(_.dropLeft(-1)(empty), empty)\n    U.deepStrictEqual(_.dropLeft(-1)(full), full)\n  })\n\n  it('dropRight', () => {\n    // empty\n    const empty: Array<number> = []\n    U.deepStrictEqual(_.dropRight(0)(empty), empty)\n    const full: Array<number> = [1, 2]\n    // non empty\n    U.deepStrictEqual(_.dropRight(0)(full), full)\n    U.deepStrictEqual(_.dropRight(1)(full), [1])\n    // full\n    U.deepStrictEqual(_.dropRight(2)(full), [])\n    // out of bound\n    U.deepStrictEqual(_.dropRight(1)(empty), empty)\n    U.deepStrictEqual(_.dropRight(3)(full), [])\n    U.deepStrictEqual(_.dropRight(-1)(empty), empty)\n    U.deepStrictEqual(_.dropRight(-1)(full), full)\n  })\n\n  it('dropLeftWhile', () => {\n    const f = _.dropLeftWhile((n: number) => n > 0)\n    U.deepStrictEqual(f([]), [])\n    U.deepStrictEqual(f([1, 2]), [])\n    U.deepStrictEqual(f([-1, -2]), [-1, -2])\n    U.deepStrictEqual(f([-1, 2]), [-1, 2])\n    U.deepStrictEqual(f([1, -2, 3]), [-2, 3])\n  })\n\n  it('init', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.init(as), O.some([1, 2]))\n    U.deepStrictEqual(_.init([]), O.none)\n  })\n\n  it('findIndex', () => {\n    U.deepStrictEqual(_.findIndex((x) => x === 2)([1, 2, 3]), O.some(1))\n    U.deepStrictEqual(_.findIndex((x) => x === 2)([]), O.none)\n  })\n\n  it('findFirst', () => {\n    U.deepStrictEqual(\n      pipe(\n        [],\n        _.findFirst((x: { readonly a: number }) => x.a > 1)\n      ),\n      O.none\n    )\n    U.deepStrictEqual(\n      pipe(\n        [{ a: 1 }, { a: 2 }, { a: 3 }],\n        _.findFirst((x) => x.a > 1)\n      ),\n      O.some({ a: 2 })\n    )\n    U.deepStrictEqual(\n      pipe(\n        [{ a: 1 }, { a: 2 }, { a: 3 }],\n        _.findFirst((x) => x.a > 3)\n      ),\n      O.none\n    )\n  })\n\n  it('findFirstMap', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        _.findFirstMap((n) => (n > 1 ? O.some(n * 2) : O.none))\n      ),\n      O.some(4)\n    )\n    U.deepStrictEqual(\n      pipe(\n        [1],\n        _.findFirstMap((n) => (n < 1 ? O.some(n * 2) : O.none))\n      ),\n      O.none\n    )\n  })\n\n  it('findLast', () => {\n    U.deepStrictEqual(\n      pipe(\n        [],\n        _.findLast((x: { readonly a: number }) => x.a > 1)\n      ),\n      O.none\n    )\n    U.deepStrictEqual(\n      pipe(\n        [{ a: 1 }, { a: 2 }, { a: 3 }],\n        _.findLast((x) => x.a > 1)\n      ),\n      O.some({ a: 3 })\n    )\n    U.deepStrictEqual(\n      pipe(\n        [{ a: 1 }, { a: 2 }, { a: 3 }],\n        _.findLast((x) => x.a > 3)\n      ),\n      O.none\n    )\n  })\n\n  it('findLastMap', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        _.findLastMap((n) => (n > 1 ? O.some(n * 2) : O.none))\n      ),\n      O.some(6)\n    )\n    U.deepStrictEqual(\n      pipe(\n        [1],\n        _.findLastMap((n) => (n > 1 ? O.some(n * 2) : O.none))\n      ),\n      O.none\n    )\n  })\n\n  it('findLastIndex', () => {\n    interface X {\n      readonly a: number\n      readonly b: number\n    }\n    const xs: Array<X> = [\n      { a: 1, b: 0 },\n      { a: 1, b: 1 }\n    ]\n    U.deepStrictEqual(_.findLastIndex((x: X) => x.a === 1)(xs), O.some(1))\n    U.deepStrictEqual(_.findLastIndex((x: X) => x.a === 4)(xs), O.none)\n    U.deepStrictEqual(_.findLastIndex((x: X) => x.a === 1)([]), O.none)\n  })\n\n  it('insertAt', () => {\n    U.deepStrictEqual(_.insertAt(1, 1)([]), O.none)\n    U.deepStrictEqual(_.insertAt(0, 1)([]), O.some([1]))\n    U.deepStrictEqual(_.insertAt(2, 5)([1, 2, 3, 4]), O.some([1, 2, 5, 3, 4]))\n  })\n\n  it('unsafeUpdateAt', () => {\n    U.deepStrictEqual(pipe(_.unsafeUpdateAt(1, 2, []), _.isEmpty), true)\n    // should not return the same reference if nothing changed\n    const input: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(\n      pipe(_.unsafeUpdateAt(1, 2, input), (out) => out === input),\n      false\n    )\n  })\n\n  it('updateAt', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.updateAt(1, 1)(as), O.some([1, 1, 3]))\n    U.deepStrictEqual(_.updateAt(1, 1)([]), O.none)\n  })\n\n  it('deleteAt', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.deleteAt(0)(as), O.some([2, 3]))\n    U.deepStrictEqual(_.deleteAt(1)([]), O.none)\n  })\n\n  it('modifyAt', () => {\n    const as: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(_.modifyAt(1, U.double)(as), O.some([1, 4, 3]))\n    U.deepStrictEqual(_.modifyAt(1, U.double)([]), O.none)\n    // should not return the same reference if nothing changed\n    const input: Array<number> = [1, 2, 3]\n    U.deepStrictEqual(\n      pipe(\n        input,\n        _.modifyAt(1, identity),\n        O.map((out) => out === input)\n      ),\n      O.some(false)\n    )\n  })\n\n  it('sort', () => {\n    U.deepStrictEqual(_.sort(N.Ord)([3, 2, 1]), [1, 2, 3])\n    U.deepStrictEqual(_.sort(N.Ord)([]), [])\n    const byName = pipe(\n      S.Ord,\n      Ord.contramap((x: { readonly name: string }) => x.name)\n    )\n    U.deepStrictEqual(\n      _.sort(byName)([\n        { name: 'b', age: 0 },\n        { name: 'a', age: 1 },\n        { name: 'c', age: 2 }\n      ]),\n      [\n        { name: 'a', age: 1 },\n        { name: 'b', age: 0 },\n        { name: 'c', age: 2 }\n      ]\n    )\n  })\n\n  it('prependAll', () => {\n    U.deepStrictEqual(_.prependAll(0)([1, 2, 3]), [0, 1, 0, 2, 0, 3])\n    U.deepStrictEqual(_.prependAll(0)([]), [])\n    U.deepStrictEqual(_.prependAll(0)([1]), [0, 1])\n    U.deepStrictEqual(_.prependAll(0)([1, 2, 3, 4]), [0, 1, 0, 2, 0, 3, 0, 4])\n  })\n\n  it('intersperse', () => {\n    U.deepStrictEqual(_.intersperse(0)([]), [])\n    U.deepStrictEqual(_.intersperse(0)([1]), [1])\n    U.deepStrictEqual(_.intersperse(0)([1, 2, 3]), [1, 0, 2, 0, 3])\n    U.deepStrictEqual(_.intersperse(0)([1, 2]), [1, 0, 2])\n    U.deepStrictEqual(_.intersperse(0)([1, 2, 3, 4]), [1, 0, 2, 0, 3, 0, 4])\n  })\n\n  it('intercalate', () => {\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')([]), '')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a']), 'a')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a', '', 'c']), 'a--c')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a', 'b']), 'a-b')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a', 'b', 'c', 'd']), 'a-b-c-d')\n  })\n\n  it('zipWith', () => {\n    U.deepStrictEqual(\n      _.zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n),\n      ['a1', 'b2', 'c3']\n    )\n  })\n\n  it('zip', () => {\n    U.deepStrictEqual(_.zip([1, 2, 3], ['a', 'b', 'c', 'd']), [\n      [1, 'a'],\n      [2, 'b'],\n      [3, 'c']\n    ])\n    U.deepStrictEqual(pipe([1, 2, 3], _.zip(['a', 'b', 'c', 'd'])), [\n      [1, 'a'],\n      [2, 'b'],\n      [3, 'c']\n    ])\n  })\n\n  it('unzip', () => {\n    U.deepStrictEqual(\n      _.unzip([\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('rights', () => {\n    U.deepStrictEqual(_.rights([E.right(1), E.left('foo'), E.right(2)]), [1, 2])\n    U.deepStrictEqual(_.rights([]), [])\n  })\n\n  it('lefts', () => {\n    U.deepStrictEqual(_.lefts([E.right(1), E.left('foo'), E.right(2)]), ['foo'])\n    U.deepStrictEqual(_.lefts([]), [])\n  })\n\n  it('flatten', () => {\n    U.deepStrictEqual(_.flatten([[1], [2], [3]]), [1, 2, 3])\n  })\n\n  it('rotate', () => {\n    U.deepStrictEqual(_.rotate(0)([]), [])\n    U.deepStrictEqual(_.rotate(1)([]), [])\n\n    U.deepStrictEqual(_.rotate(1)([1]), [1])\n    U.deepStrictEqual(_.rotate(1)([1, 2]), [2, 1])\n    U.deepStrictEqual(_.rotate(2)([1, 2]), [1, 2])\n    U.deepStrictEqual(_.rotate(0)([1, 2]), [1, 2])\n    U.deepStrictEqual(_.rotate(1)([1, 2, 3, 4, 5]), [5, 1, 2, 3, 4])\n    U.deepStrictEqual(_.rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n    U.deepStrictEqual(_.rotate(-1)([1, 2, 3, 4, 5]), [2, 3, 4, 5, 1])\n    U.deepStrictEqual(_.rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n\n    U.deepStrictEqual(_.rotate(7)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n    U.deepStrictEqual(_.rotate(-7)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n\n    U.deepStrictEqual(_.rotate(2.2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n    U.deepStrictEqual(_.rotate(-2.2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n  })\n\n  it('reverse', () => {\n    U.deepStrictEqual(_.reverse([1, 2, 3]), [3, 2, 1])\n    U.deepStrictEqual(_.reverse([]), [])\n  })\n\n  it('foldLeft', () => {\n    const len: <A>(as: Array<A>) => number = _.foldLeft(\n      () => 0,\n      (_, tail) => 1 + len(tail)\n    )\n    U.deepStrictEqual(len([1, 2, 3]), 3)\n  })\n\n  it('foldRight', () => {\n    const len: <A>(as: Array<A>) => number = _.foldRight(\n      () => 0,\n      (init, _) => 1 + len(init)\n    )\n    U.deepStrictEqual(len([1, 2, 3]), 3)\n  })\n\n  it('scanLeft', () => {\n    const f = (b: number, a: number) => b - a\n    U.deepStrictEqual(_.scanLeft(10, f)([1, 2, 3]), [10, 9, 7, 4])\n    U.deepStrictEqual(_.scanLeft(10, f)([0]), [10, 10])\n    U.deepStrictEqual(_.scanLeft(10, f)([]), [10])\n  })\n\n  it('scanRight', () => {\n    const f = (b: number, a: number) => b - a\n    U.deepStrictEqual(_.scanRight(10, f)([1, 2, 3]), [-8, 9, -7, 10])\n    U.deepStrictEqual(_.scanRight(10, f)([0]), [-10, 10])\n    U.deepStrictEqual(_.scanRight(10, f)([]), [10])\n  })\n\n  it('uniq', () => {\n    interface A {\n      readonly a: string\n      readonly b: number\n    }\n\n    const eqA = pipe(\n      N.Ord,\n      Eq.contramap((f: A) => f.b)\n    )\n    const arrA: A = { a: 'a', b: 1 }\n    const arrB: A = { a: 'b', b: 1 }\n    const arrC: A = { a: 'c', b: 2 }\n    const arrD: A = { a: 'd', b: 2 }\n    const arrUniq: Array<A> = [arrA, arrC]\n\n    U.deepStrictEqual(_.uniq(eqA)(arrUniq), arrUniq)\n    U.deepStrictEqual(_.uniq(eqA)([arrA, arrB, arrC, arrD]), [arrA, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrB, arrA, arrC, arrD]), [arrB, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrA, arrA, arrC, arrD, arrA]), [arrA, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrA, arrC]), [arrA, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrC, arrA]), [arrC, arrA])\n    U.deepStrictEqual(_.uniq(B.Eq)([true, false, true, false]), [true, false])\n    U.deepStrictEqual(_.uniq(N.Eq)([]), [])\n    U.deepStrictEqual(_.uniq(N.Eq)([-0, -0]), [-0])\n    U.deepStrictEqual(_.uniq(N.Eq)([0, -0]), [0])\n    U.deepStrictEqual(_.uniq(N.Eq)([1]), [1])\n    U.deepStrictEqual(_.uniq(N.Eq)([2, 1, 2]), [2, 1])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 2, 1]), [1, 2])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 1, 2, 2, 3, 3, 4, 4, 5, 5]), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.uniq(S.Eq)(['a', 'b', 'a']), ['a', 'b'])\n    U.deepStrictEqual(_.uniq(S.Eq)(['a', 'b', 'A']), ['a', 'b', 'A'])\n  })\n\n  it('sortBy', () => {\n    interface Person {\n      readonly name: string\n      readonly age: number\n    }\n    const byName = pipe(\n      S.Ord,\n      Ord.contramap((p: Person) => p.name)\n    )\n    const byAge = pipe(\n      N.Ord,\n      Ord.contramap((p: Person) => p.age)\n    )\n    const f = _.sortBy([byName, byAge])\n    const persons: Array<Person> = [\n      { name: 'a', age: 1 },\n      { name: 'b', age: 3 },\n      { name: 'c', age: 2 },\n      { name: 'b', age: 2 }\n    ]\n    U.deepStrictEqual(f(persons), [\n      { name: 'a', age: 1 },\n      { name: 'b', age: 2 },\n      { name: 'b', age: 3 },\n      { name: 'c', age: 2 }\n    ])\n    const sortByAgeByName = _.sortBy([byAge, byName])\n    U.deepStrictEqual(sortByAgeByName(persons), [\n      { name: 'a', age: 1 },\n      { name: 'b', age: 2 },\n      { name: 'c', age: 2 },\n      { name: 'b', age: 3 }\n    ])\n\n    U.deepStrictEqual(f([]), [])\n    U.deepStrictEqual(_.sortBy([])(persons), persons)\n  })\n\n  it('chop', () => {\n    const group = <A>(E: Eq.Eq<A>): ((as: Array<A>) => Array<Array<A>>) => {\n      return _.chop((as) => {\n        const { init, rest } = _.spanLeft((a: A) => E.equals(a, as[0]))(as)\n        return [init, rest]\n      })\n    }\n    const f = group(N.Eq)\n    U.deepStrictEqual(f([]), [])\n    U.deepStrictEqual(f([1, 1, 2, 3, 3, 4]), [[1, 1], [2], [3, 3], [4]])\n  })\n\n  it('splitAt', () => {\n    const assertSplitAt = (\n      input: Array<number>,\n      index: number,\n      expectedInit: Array<number>,\n      expectedRest: Array<number>\n    ) => {\n      const [init, rest] = _.splitAt(index)(input)\n      U.deepStrictEqual(init, expectedInit)\n      U.deepStrictEqual(rest, expectedRest)\n    }\n    U.deepStrictEqual(_.splitAt(1)([1, 2]), [[1], [2]])\n    const two: Array<number> = [1, 2]\n    assertSplitAt(two, 2, two, [])\n    U.deepStrictEqual(_.splitAt(2)([1, 2, 3, 4, 5]), [\n      [1, 2],\n      [3, 4, 5]\n    ])\n    // zero\n    const empty: Array<number> = []\n    assertSplitAt([], 0, [], [])\n    assertSplitAt(empty, 0, empty, [])\n    assertSplitAt(two, 0, [], two)\n    // out of bounds\n    assertSplitAt([], -1, [], [])\n    assertSplitAt(empty, -1, empty, [])\n    assertSplitAt(two, -1, [], two)\n    assertSplitAt(two, 3, two, [])\n    assertSplitAt([], 3, [], [])\n    assertSplitAt(empty, 3, empty, [])\n  })\n\n  describe('chunksOf', () => {\n    it('should split an array into length-n pieces', () => {\n      U.deepStrictEqual(_.chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])\n      U.deepStrictEqual(_.chunksOf(2)([1, 2, 3, 4, 5, 6]), [\n        [1, 2],\n        [3, 4],\n        [5, 6]\n      ])\n      U.deepStrictEqual(_.chunksOf(1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n      U.deepStrictEqual(_.chunksOf(5)([1, 2, 3, 4, 5]), [[1, 2, 3, 4, 5]])\n      // out of bounds\n      U.deepStrictEqual(_.chunksOf(0)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n      U.deepStrictEqual(_.chunksOf(-1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n\n      const assertSingleChunk = (input: Array<number>, n: number) => {\n        const chunks = _.chunksOf(n)(input)\n        U.deepStrictEqual(chunks.length, 1)\n        U.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    // #897\n    it('returns an empty array if provided an empty array', () => {\n      U.deepStrictEqual(_.chunksOf(1)([]), [])\n      U.deepStrictEqual(_.chunksOf(2)([]), [])\n      U.deepStrictEqual(_.chunksOf(0)([]), [])\n    })\n\n    // #897\n    it('should respect the law: RA.chunksOf(n)(xs).concat(RA.chunksOf(n)(ys)) == RA.chunksOf(n)(xs.concat(ys)))', () => {\n      const xs: Array<number> = []\n      const ys: Array<number> = [1, 2]\n      U.deepStrictEqual(_.chunksOf(2)(xs).concat(_.chunksOf(2)(ys)), _.chunksOf(2)(xs.concat(ys)))\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 = _.chunksOf(n)(xs).concat(_.chunksOf(n)(ys))\n            const bs = _.chunksOf(n)(xs.concat(ys))\n            isDeepStrictEqual(as, bs)\n          }\n        )\n      )\n    })\n  })\n\n  it('prepend', () => {\n    U.deepStrictEqual(pipe(['a', 'b'], _.prepend('c')), ['c', 'a', 'b'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.prependW(3)), [3, 'a', 'b'])\n  })\n\n  it('append', () => {\n    U.deepStrictEqual(pipe(['a', 'b'], _.append('c')), ['a', 'b', 'c'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.appendW(3)), ['a', 'b', 3])\n  })\n\n  it('makeBy', () => {\n    U.deepStrictEqual(_.makeBy(5, U.double), [0, 2, 4, 6, 8])\n    U.deepStrictEqual(_.makeBy(0, U.double), [])\n    U.deepStrictEqual(_.makeBy(-1, U.double), [])\n  })\n\n  it('range', () => {\n    U.deepStrictEqual(_.range(0, 0), [0])\n    U.deepStrictEqual(_.range(0, 1), [0, 1])\n    U.deepStrictEqual(_.range(1, 5), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.range(10, 15), [10, 11, 12, 13, 14, 15])\n    U.deepStrictEqual(_.range(-1, 0), [-1, 0])\n    U.deepStrictEqual(_.range(-5, -1), [-5, -4, -3, -2, -1])\n    // out of bound\n    U.deepStrictEqual(_.range(2, 1), [2])\n    U.deepStrictEqual(_.range(-1, -2), [-1])\n  })\n\n  it('replicate', () => {\n    U.deepStrictEqual(_.replicate(0, 'a'), [])\n    U.deepStrictEqual(_.replicate(3, 'a'), ['a', 'a', 'a'])\n  })\n\n  it('comprehension', () => {\n    U.deepStrictEqual(\n      _.comprehension([[1, 2, 3]], (a) => a * 2),\n      [2, 4, 6]\n    )\n    U.deepStrictEqual(\n      _.comprehension(\n        [\n          [1, 2, 3],\n          ['a', 'b']\n        ],\n        tuple\n      ),\n      [\n        [1, 'a'],\n        [1, 'b'],\n        [2, 'a'],\n        [2, 'b'],\n        [3, 'a'],\n        [3, 'b']\n      ]\n    )\n    U.deepStrictEqual(\n      _.comprehension(\n        [\n          [1, 2, 3],\n          ['a', 'b']\n        ],\n        tuple,\n        (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('union', () => {\n    const concat = _.union(N.Eq)\n    const two: Array<number> = [1, 2]\n    U.deepStrictEqual(concat(two, [3, 4]), [1, 2, 3, 4])\n    U.deepStrictEqual(concat(two, [2, 3]), [1, 2, 3])\n    U.deepStrictEqual(concat(two, [1, 2]), [1, 2])\n    U.deepStrictEqual(pipe(two, concat([3, 4])), [1, 2, 3, 4])\n    U.deepStrictEqual(pipe(two, concat([2, 3])), [1, 2, 3])\n    U.deepStrictEqual(pipe(two, concat([1, 2])), [1, 2])\n\n    U.deepStrictEqual(pipe(two, concat([])), two)\n    U.deepStrictEqual(pipe([], concat(two)), two)\n    U.deepStrictEqual(pipe([], concat([])), [])\n  })\n\n  it('intersection', () => {\n    U.deepStrictEqual(_.intersection(N.Eq)([1, 2], [3, 4]), [])\n    U.deepStrictEqual(_.intersection(N.Eq)([1, 2], [2, 3]), [2])\n    U.deepStrictEqual(_.intersection(N.Eq)([1, 2], [1, 2]), [1, 2])\n    U.deepStrictEqual(pipe([1, 2], _.intersection(N.Eq)([3, 4])), [])\n    U.deepStrictEqual(pipe([1, 2], _.intersection(N.Eq)([2, 3])), [2])\n    U.deepStrictEqual(pipe([1, 2], _.intersection(N.Eq)([1, 2])), [1, 2])\n  })\n\n  it('difference', () => {\n    U.deepStrictEqual(_.difference(N.Eq)([1, 2], [3, 4]), [1, 2])\n    U.deepStrictEqual(_.difference(N.Eq)([1, 2], [2, 3]), [1])\n    U.deepStrictEqual(_.difference(N.Eq)([1, 2], [1, 2]), [])\n    U.deepStrictEqual(pipe([1, 2], _.difference(N.Eq)([3, 4])), [1, 2])\n    U.deepStrictEqual(pipe([1, 2], _.difference(N.Eq)([2, 3])), [1])\n    U.deepStrictEqual(pipe([1, 2], _.difference(N.Eq)([1, 2])), [])\n  })\n\n  it('getUnionMonoid', () => {\n    const concat = _.getUnionMonoid(N.Eq).concat\n    const two: Array<number> = [1, 2]\n    U.deepStrictEqual(concat(two, [3, 4]), [1, 2, 3, 4])\n    U.deepStrictEqual(concat(two, [2, 3]), [1, 2, 3])\n    U.deepStrictEqual(concat(two, [1, 2]), [1, 2])\n\n    U.deepStrictEqual(concat(two, []), two)\n    U.deepStrictEqual(concat([], two), two)\n    U.deepStrictEqual(concat([], []), [])\n  })\n\n  it('getIntersectionSemigroup', () => {\n    const concat = _.getIntersectionSemigroup(N.Eq).concat\n    U.deepStrictEqual(concat([1, 2], [3, 4]), [])\n    U.deepStrictEqual(concat([1, 2], [2, 3]), [2])\n    U.deepStrictEqual(concat([1, 2], [1, 2]), [1, 2])\n  })\n\n  it('getDifferenceMagma', () => {\n    const concat = _.getDifferenceMagma(N.Eq).concat\n    U.deepStrictEqual(concat([1, 2], [3, 4]), [1, 2])\n    U.deepStrictEqual(concat([1, 2], [2, 3]), [1])\n    U.deepStrictEqual(concat([1, 2], [1, 2]), [])\n  })\n\n  it('should be safe when calling map with a binary function', () => {\n    interface Foo {\n      readonly bar: () => number\n    }\n    const f = (a: number, x?: Foo) => (x !== undefined ? `${a}${x.bar()}` : `${a}`)\n    U.deepStrictEqual(_.Functor.map([1, 2], f), ['1', '2'])\n    U.deepStrictEqual(pipe([1, 2], _.map(f)), ['1', '2'])\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    U.deepStrictEqual(Sh.show([]), `[]`)\n    U.deepStrictEqual(Sh.show(['a']), `[\"a\"]`)\n    U.deepStrictEqual(Sh.show(['a', 'b']), `[\"a\", \"b\"]`)\n  })\n\n  it('size', () => {\n    U.deepStrictEqual(_.size([]), 0)\n    U.deepStrictEqual(_.size(['a']), 1)\n  })\n\n  it('every', () => {\n    const isPositive: Predicate<number> = (n) => n > 0\n    U.deepStrictEqual(pipe([1, 2, 3], _.every(isPositive)), true)\n    U.deepStrictEqual(pipe([1, 2, -3], _.every(isPositive)), false)\n  })\n\n  it('some', () => {\n    const isPositive: Predicate<number> = (n) => n > 0\n    U.deepStrictEqual(pipe([-1, -2, 3], _.some(isPositive)), true)\n    U.deepStrictEqual(pipe([-1, -2, -3], _.some(isPositive)), false)\n  })\n\n  it('copy', () => {\n    U.deepStrictEqual(pipe([1, 2, 3], _.copy), [1, 2, 3])\n  })\n\n  describe('fromPredicate', () => {\n    it('can create an array from a Refinement', () => {\n      const refinement: Refinement<unknown, string> = (a): a is string => typeof a === 'string'\n      U.deepStrictEqual(_.fromPredicate(refinement)('hello'), ['hello'])\n      U.deepStrictEqual(_.fromPredicate(refinement)(null), [])\n    })\n\n    it('can create an array from a Predicate', () => {\n      const predicate = (a: string) => a.length > 0\n      U.deepStrictEqual(_.fromPredicate(predicate)('hi'), ['hi'])\n      U.deepStrictEqual(_.fromPredicate(predicate)(''), [])\n    })\n  })\n\n  it('fromOption', () => {\n    U.deepStrictEqual(_.fromOption(O.some('hello')), ['hello'])\n    U.deepStrictEqual(_.fromOption(O.none), [])\n  })\n\n  it('fromEither', () => {\n    U.deepStrictEqual(_.fromEither(E.right(1)), [1])\n    U.deepStrictEqual(_.fromEither(E.left('a')), [])\n  })\n\n  it('match', () => {\n    const f = _.match(\n      () => 'empty',\n      (as) => `nonEmpty ${as.length}`\n    )\n    U.deepStrictEqual(pipe([], f), 'empty')\n    U.deepStrictEqual(pipe([1, 2, 3], f), 'nonEmpty 3')\n  })\n\n  it('concatW', () => {\n    U.deepStrictEqual(pipe([1], _.concatW(['a'])), [1, 'a'])\n    const as = [1, 2, 3]\n    const empty: Array<string> = []\n    U.deepStrictEqual(pipe(empty, _.concatW(as)), as)\n    U.deepStrictEqual(pipe(as, _.concatW(empty)), as)\n  })\n\n  it('fromOptionK', () => {\n    const f = (n: number) => (n > 0 ? O.some(n) : O.none)\n    const g = _.fromOptionK(f)\n    U.deepStrictEqual(g(0), [])\n    U.deepStrictEqual(g(1), [1])\n  })\n\n  it('isOutOfBound', () => {\n    U.deepStrictEqual(_.isOutOfBound(0, ['a']), false)\n    U.deepStrictEqual(_.isOutOfBound(100, ['a']), true)\n    U.deepStrictEqual(_.isOutOfBound(-1, ['a']), true)\n  })\n})\n"
  },
  {
    "path": "test/BooleanAlgebra.ts",
    "content": "import * as B from '../src/boolean'\nimport * as _ from '../src/BooleanAlgebra'\nimport * as U from './util'\n\ndescribe('BooleanAlgebra', () => {\n  it('booleanAlgebraBoolean', () => {\n    const BA = _.booleanAlgebraBoolean\n    U.deepStrictEqual(BA.implies(true, true), true)\n    U.deepStrictEqual(BA.implies(true, false), false)\n    U.deepStrictEqual(BA.implies(false, true), true)\n    U.deepStrictEqual(BA.implies(false, false), true)\n\n    U.deepStrictEqual(BA.join(true, true), true)\n    U.deepStrictEqual(BA.join(true, false), true)\n    U.deepStrictEqual(BA.join(false, true), true)\n    U.deepStrictEqual(BA.join(false, false), false)\n\n    U.deepStrictEqual(BA.meet(true, true), true)\n    U.deepStrictEqual(BA.meet(true, false), false)\n\n    U.deepStrictEqual(BA.not(true), false)\n    U.deepStrictEqual(BA.not(false), true)\n\n    U.deepStrictEqual(BA.one, true)\n    U.deepStrictEqual(BA.zero, false)\n  })\n\n  it('booleanAlgebraVoid', () => {\n    const BA = _.booleanAlgebraVoid\n    U.deepStrictEqual(BA.implies(undefined, undefined), undefined)\n\n    U.deepStrictEqual(BA.join(undefined, undefined), undefined)\n\n    U.deepStrictEqual(BA.meet(undefined, undefined), undefined)\n\n    U.deepStrictEqual(BA.not(undefined), undefined)\n\n    U.deepStrictEqual(BA.one, undefined)\n    U.deepStrictEqual(BA.zero, undefined)\n  })\n\n  it('reverse', () => {\n    const BA = _.reverse(B.BooleanAlgebra)\n    U.deepStrictEqual(BA.implies(true, true), true)\n    U.deepStrictEqual(BA.implies(true, false), false)\n    U.deepStrictEqual(BA.implies(false, true), true)\n    U.deepStrictEqual(BA.implies(false, false), true)\n\n    U.deepStrictEqual(BA.join(true, true), true)\n    U.deepStrictEqual(BA.join(true, false), false)\n    U.deepStrictEqual(BA.join(false, true), false)\n    U.deepStrictEqual(BA.join(false, false), false)\n\n    U.deepStrictEqual(BA.meet(true, true), true)\n    U.deepStrictEqual(BA.meet(true, false), true)\n\n    U.deepStrictEqual(BA.not(true), false)\n    U.deepStrictEqual(BA.not(false), true)\n\n    U.deepStrictEqual(BA.one, false)\n    U.deepStrictEqual(BA.zero, true)\n  })\n})\n"
  },
  {
    "path": "test/Bounded.ts",
    "content": "import * as _ from '../src/Bounded'\nimport * as N from '../src/number'\nimport * as U from './util'\n\ndescribe('Bounded', () => {\n  it('clamp', () => {\n    const B: _.Bounded<number> = {\n      ...N.Ord,\n      top: 10,\n      bottom: 0\n    }\n    const clamp = _.clamp(B)\n    U.deepStrictEqual(clamp(5), 5)\n    U.deepStrictEqual(clamp(-1), 0)\n    U.deepStrictEqual(clamp(11), 10)\n  })\n\n  it('reverse', () => {\n    const B: _.Bounded<number> = _.reverse({\n      ...N.Ord,\n      top: 10,\n      bottom: 0\n    })\n    U.deepStrictEqual(B.top, 0)\n    U.deepStrictEqual(B.bottom, 10)\n  })\n})\n"
  },
  {
    "path": "test/BoundedDistributiveLattice.ts",
    "content": "import { getMinMaxBoundedDistributiveLattice } from '../src/BoundedDistributiveLattice'\nimport * as N from '../src/number'\nimport * as U from './util'\n\ndescribe('BoundedDistributiveLattice', () => {\n  it('getMinMaxBoundedDistributiveLattice', () => {\n    const BDL = getMinMaxBoundedDistributiveLattice(N.Ord)(0, 1)\n    U.deepStrictEqual(BDL.join(0.2, 0.4), 0.4)\n    U.deepStrictEqual(BDL.meet(0.2, 0.4), 0.2)\n    U.deepStrictEqual(BDL.one, 1)\n    U.deepStrictEqual(BDL.zero, 0)\n  })\n})\n"
  },
  {
    "path": "test/Choice.ts",
    "content": "import { fanin, splitChoice } from '../src/Choice'\nimport { left, right } from '../src/Either'\nimport * as R from '../src/Reader'\nimport * as U from './util'\n\ndescribe('Choice', () => {\n  it('splitChoice', () => {\n    const ab = (s: string) => s.length\n    const cd = (n: number) => n >= 2\n    U.deepStrictEqual(splitChoice({ ...R.Choice, ...R.Category })(ab, cd)(right(3)), right(true))\n    U.deepStrictEqual(splitChoice({ ...R.Choice, ...R.Category })(ab, cd)(right(1)), right(false))\n    U.deepStrictEqual(splitChoice({ ...R.Choice, ...R.Category })(ab, cd)(left('foo')), left(3))\n  })\n\n  it('fanin', () => {\n    const ac = (s: string) => s === s.toLowerCase()\n    const bc = (n: number) => n >= 2\n    U.deepStrictEqual(fanin({ ...R.Choice, ...R.Category })(ac, bc)(right(3)), true)\n    U.deepStrictEqual(fanin({ ...R.Choice, ...R.Category })(ac, bc)(right(1)), false)\n    U.deepStrictEqual(fanin({ ...R.Choice, ...R.Category })(ac, bc)(left('foo')), true)\n    U.deepStrictEqual(fanin({ ...R.Choice, ...R.Category })(ac, bc)(left('A')), false)\n  })\n})\n"
  },
  {
    "path": "test/Compactable.ts",
    "content": "import { getCompactableComposition } from '../src/Compactable'\nimport { left, right } from '../src/Either'\nimport { none, some } from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport { separated } from '../src/Separated'\nimport * as U from './util'\n\ndescribe('Compactable', () => {\n  it('getCompactableComposition', () => {\n    const C = getCompactableComposition(RA.Functor, { ...RA.Functor, ...RA.Compactable })\n    U.deepStrictEqual(\n      C.map([[1], [2]], (n) => n * 2),\n      [[2], [4]]\n    )\n    U.deepStrictEqual(\n      C.compact([\n        [some(1), none],\n        [none, some(2)]\n      ]),\n      [[1], [2]]\n    )\n    U.deepStrictEqual(\n      C.separate([\n        [left('a'), right(1)],\n        [right(2), left('b')]\n      ]),\n      separated([['a'], ['b']], [[1], [2]])\n    )\n  })\n})\n"
  },
  {
    "path": "test/Console.ts",
    "content": "import { error, info, log, warn } from '../src/Console'\nimport * as U from './util'\n\ndescribe('Console', () => {\n  it('log', () => {\n    const log_ = console.log\n    const logger: Array<any> = []\n    console.log = (a: any) => {\n      logger.push(a)\n    }\n    log('log')()\n    U.deepStrictEqual(logger, ['log'])\n    console.log = log_\n  })\n\n  it('info', () => {\n    const info_ = console.info\n    const logger: Array<any> = []\n    console.info = (a: any) => {\n      logger.push(a)\n    }\n    info('info')()\n    U.deepStrictEqual(logger, ['info'])\n    console.info = info_\n  })\n\n  it('error', () => {\n    const error_ = console.error\n    const logger: Array<any> = []\n    console.error = (a: any) => {\n      logger.push(a)\n    }\n    error('error')()\n    U.deepStrictEqual(logger, ['error'])\n    console.error = error_\n  })\n\n  it('warn', () => {\n    const warn_ = console.warn\n    const logger: Array<any> = []\n    console.warn = (a: any) => {\n      logger.push(a)\n    }\n    warn('warn')()\n    U.deepStrictEqual(logger, ['warn'])\n    console.warn = warn_\n  })\n})\n"
  },
  {
    "path": "test/Const.ts",
    "content": "import * as _ from '../src/Const'\nimport { pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('Const', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      const fa = _.make('foo')\n      U.deepStrictEqual(pipe(fa, _.map(U.double)), fa)\n    })\n\n    it('contramap', () => {\n      const fa: _.Const<string, number> = _.make('foo')\n      U.deepStrictEqual(pipe(fa, _.contramap(U.double)), fa)\n    })\n\n    it('bimap', () => {\n      const fa: _.Const<string, number> = _.make('a')\n      const f = (s: string): string => s.toUpperCase()\n      const g = (n: number): number => n * 2\n      U.deepStrictEqual(pipe(fa, _.bimap(f, g)), _.make('A'))\n    })\n\n    it('mapLeft', () => {\n      const fa: _.Const<string, number> = _.make('a')\n      const f = (s: string): string => s.toUpperCase()\n      U.deepStrictEqual(pipe(fa, _.mapLeft(f)), _.make('A'))\n    })\n  })\n\n  it('getApplicative', () => {\n    const F = _.getApplicative(S.Monoid)\n    U.deepStrictEqual(F.of(1), _.make(''))\n  })\n\n  it('getEq', () => {\n    const S = _.getEq(N.Eq)\n    U.deepStrictEqual(S.equals(_.make(1), _.make(1)), true)\n    U.deepStrictEqual(S.equals(_.make(1), _.make(2)), false)\n  })\n\n  it('getApplicative', () => {\n    const F = _.getApply(S.Semigroup)\n    const fa = _.make('foo')\n    U.deepStrictEqual(F.ap(fa, _.make('bar')), _.make('foobar'))\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    const x: _.Const<string, number> = _.make('a')\n    U.deepStrictEqual(Sh.show(x), `make(\"a\")`)\n  })\n})\n"
  },
  {
    "path": "test/Date.ts",
    "content": "import * as _ from '../src/Date'\nimport * as U from './util'\n\ndescribe('Date', () => {\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('Eq', () => {\n    U.deepStrictEqual(_.Eq.equals(new Date(0), new Date(0)), true)\n    U.deepStrictEqual(_.Eq.equals(new Date(0), new Date(1)), false)\n    U.deepStrictEqual(_.Eq.equals(new Date(1), new Date(0)), false)\n  })\n\n  it('eqDate', () => {\n    U.deepStrictEqual(_.eqDate.equals(new Date(2000, 10, 1), new Date(2000, 11, 1)), true)\n    U.deepStrictEqual(_.eqDate.equals(new Date(2000, 10, 1), new Date(2000, 11, 2)), false)\n  })\n\n  it('eqMonth', () => {\n    U.deepStrictEqual(_.eqMonth.equals(new Date(2000, 10, 1), new Date(2000, 10, 7)), true)\n    U.deepStrictEqual(_.eqMonth.equals(new Date(2000, 10, 1), new Date(2000, 11, 7)), false)\n  })\n\n  it('eqYear', () => {\n    U.deepStrictEqual(_.eqYear.equals(new Date(2000, 10, 1), new Date(2000, 11, 7)), true)\n    U.deepStrictEqual(_.eqYear.equals(new Date(2000, 10, 1), new Date(2001, 11, 7)), false)\n  })\n\n  it('Ord', () => {\n    U.deepStrictEqual(_.Ord.compare(new Date(0), new Date(0)), 0)\n    U.deepStrictEqual(_.Ord.compare(new Date(0), new Date(1)), -1)\n    U.deepStrictEqual(_.Ord.compare(new Date(1), new Date(0)), 1)\n  })\n\n  // -------------------------------------------------------------------------------------\n  // utils\n  // -------------------------------------------------------------------------------------\n\n  it('create', () => {\n    const d1 = _.create()\n    U.deepStrictEqual(d1 instanceof Date, true)\n  })\n\n  it('now', () => {\n    const m1 = _.now()\n    U.deepStrictEqual(typeof m1, 'number')\n  })\n})\n"
  },
  {
    "path": "test/Either.ts",
    "content": "import { sequenceT } from '../src/Apply'\nimport * as _ from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport { separated } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\ndescribe('Either', () => {\n  describe('pipeables', () => {\n    it('mapLeft', () => {\n      U.deepStrictEqual(pipe(_.right('bar'), _.mapLeft(U.double)), _.right('bar'))\n      U.deepStrictEqual(pipe(_.left(2), _.mapLeft(U.double)), _.left(4))\n    })\n\n    it('alt', () => {\n      U.deepStrictEqual(\n        pipe(\n          _.right(1),\n          _.alt(() => _.right(2))\n        ),\n        _.right(1)\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.right(1),\n          _.alt(() => _.left('a'))\n        ),\n        _.right(1)\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.left('a'),\n          _.alt(() => _.right(2))\n        ),\n        _.right(2)\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.left('a'),\n          _.alt(() => _.left('b'))\n        ),\n        _.left('b')\n      )\n    })\n\n    it('map', () => {\n      const f = (s: string): number => s.length\n      U.deepStrictEqual(pipe(_.right('abc'), _.map(f)), _.right(3))\n      U.deepStrictEqual(pipe(_.left('s'), _.map(f)), _.left('s'))\n    })\n\n    it('ap', () => {\n      const f = (s: string): number => s.length\n      U.deepStrictEqual(pipe(_.right(f), _.ap(_.right('abc'))), _.right(3))\n      U.deepStrictEqual(pipe(_.right(f), _.ap(_.left('maError'))), _.left('maError'))\n      U.deepStrictEqual(\n        pipe(_.left<string, (s: string) => number>('mabError'), _.ap(_.right('abc'))),\n        _.left('mabError')\n      )\n      U.deepStrictEqual(pipe(_.left('mabError'), _.ap(_.left('maError'))), _.left('mabError'))\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe(_.right('a'), _.apFirst(_.right(1))), _.right('a'))\n    })\n\n    it('apFirstW', () => {\n      const f = _.right(true)\n      U.deepStrictEqual(pipe(_.right('abc'), _.apFirstW(f)), _.right('abc'))\n      U.deepStrictEqual(pipe(_.left<string, string>('maError'), _.apFirstW(f)), _.left('maError'))\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe(_.right('a'), _.apSecond(_.right(1))), _.right(1))\n    })\n\n    it('apSecondW', () => {\n      const f = _.right(true)\n      U.deepStrictEqual(pipe(_.right('abc'), _.apSecondW(f)), _.right(true))\n      U.deepStrictEqual(pipe(_.left<string, string>('maError'), _.apSecondW(f)), _.left('maError'))\n    })\n\n    it('flatMap', () => {\n      const f = (s: string) => _.right<string, number>(s.length)\n      U.deepStrictEqual(pipe(_.right('abc'), _.flatMap(f)), _.right(3))\n      U.deepStrictEqual(_.flatMap(_.right('abc'), f), _.right(3))\n      U.deepStrictEqual(pipe(_.left<string, string>('maError'), _.flatMap(f)), _.left('maError'))\n      U.deepStrictEqual(_.flatMap(_.left<string, string>('maError'), f), _.left('maError'))\n    })\n\n    it('chain', () => {\n      const f = (s: string) => _.right<string, number>(s.length)\n      U.deepStrictEqual(pipe(_.right('abc'), _.chain(f)), _.right(3))\n      U.deepStrictEqual(pipe(_.left<string, string>('maError'), _.chain(f)), _.left('maError'))\n    })\n\n    it('tap', () => {\n      const f = (s: string) => _.right<string, number>(s.length)\n      U.deepStrictEqual(pipe(_.right('abc'), _.tap(f)), _.right('abc'))\n      U.deepStrictEqual(pipe(_.left<string, string>('maError'), _.tap(f)), _.left('maError'))\n      U.deepStrictEqual(_.tap(_.right('abc'), f), _.right('abc'))\n      U.deepStrictEqual(_.tap(_.left<string, string>('maError'), f), _.left('maError'))\n    })\n\n    it('chainFirst', () => {\n      const f = (s: string) => _.right<string, number>(s.length)\n      U.deepStrictEqual(pipe(_.right('abc'), _.chainFirst(f)), _.right('abc'))\n      U.deepStrictEqual(pipe(_.left<string, string>('maError'), _.chainFirst(f)), _.left('maError'))\n    })\n\n    it('chainFirstW', () => {\n      const f = (s: string) => _.right<boolean, number>(s.length)\n      U.deepStrictEqual(pipe(_.right('abc'), _.chainFirstW(f)), _.right('abc'))\n      U.deepStrictEqual(pipe(_.left<string, string>('maError'), _.chainFirstW(f)), _.left('maError'))\n    })\n\n    it('duplicate', () => {\n      U.deepStrictEqual(pipe(_.right('a'), _.duplicate), _.right(_.right('a')))\n    })\n\n    it('extend', () => {\n      U.deepStrictEqual(\n        pipe(\n          _.right(1),\n          _.extend(() => 2)\n        ),\n        _.right(2)\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.left('err'),\n          _.extend(() => 2)\n        ),\n        _.left('err')\n      )\n    })\n\n    it('flatten', () => {\n      U.deepStrictEqual(pipe(_.right(_.right('a')), _.flatten), _.right('a'))\n    })\n\n    it('flattenW', () => {\n      U.deepStrictEqual(pipe(_.right<'left1', _.Either<'left2', 'a'>>(_.right('a')), _.flattenW), _.right('a'))\n    })\n\n    it('bimap', () => {\n      const f = (s: string): number => s.length\n      const g = (n: number): boolean => n > 2\n      U.deepStrictEqual(pipe(_.right(1), _.bimap(f, g)), _.right(false))\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe(_.right('a'), _.foldMap(S.Monoid)(identity)), 'a')\n      U.deepStrictEqual(pipe(_.left(1), _.foldMap(S.Monoid)(identity)), '')\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          _.right('bar'),\n          _.reduce('foo', (b, a) => b + a)\n        ),\n        'foobar'\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.left('bar'),\n          _.reduce('foo', (b, a) => b + a)\n        ),\n        'foo'\n      )\n    })\n\n    it('reduceRight', () => {\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(pipe(_.right('a'), _.reduceRight('', f)), 'a')\n      U.deepStrictEqual(pipe(_.left(1), _.reduceRight('', f)), '')\n    })\n\n    it('traverse', () => {\n      const traverse = _.traverse(O.Applicative)((n: number) => (n >= 2 ? O.some(n) : O.none))\n      U.deepStrictEqual(pipe(_.left('a'), traverse), O.some(_.left('a')))\n      U.deepStrictEqual(pipe(_.right(1), traverse), O.none)\n      U.deepStrictEqual(pipe(_.right(3), traverse), O.some(_.right(3)))\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      U.deepStrictEqual(sequence(_.right(O.some(1))), O.some(_.right(1)))\n      U.deepStrictEqual(sequence(_.left('a')), O.some(_.left('a')))\n      U.deepStrictEqual(sequence(_.right(O.none)), O.none)\n    })\n  })\n\n  it('fold', () => {\n    const f = (s: string) => `left${s.length}`\n    const g = (s: string) => `right${s.length}`\n    const fold = _.fold(f, g)\n    U.deepStrictEqual(fold(_.left('abc')), 'left3')\n    U.deepStrictEqual(fold(_.right('abc')), 'right3')\n  })\n\n  it('getOrElse', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.right(12),\n        _.getOrElse(() => 17)\n      ),\n      12\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.left('a'),\n        _.getOrElse(() => 17)\n      ),\n      17\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.left('a'),\n        _.getOrElse((l: string) => l.length + 1)\n      ),\n      2\n    )\n  })\n\n  it('elem', () => {\n    U.deepStrictEqual(_.elem(N.Eq)(2, _.left('a')), false)\n    U.deepStrictEqual(_.elem(N.Eq)(2, _.right(2)), true)\n    U.deepStrictEqual(_.elem(N.Eq)(1, _.right(2)), false)\n    U.deepStrictEqual(pipe(_.left('a'), _.elem(N.Eq)(2)), false)\n    U.deepStrictEqual(pipe(_.right(2), _.elem(N.Eq)(2)), true)\n    U.deepStrictEqual(pipe(_.right(2), _.elem(N.Eq)(1)), false)\n  })\n\n  it('filterOrElse', () => {\n    const gt10 = (n: number): boolean => n > 10\n    U.deepStrictEqual(\n      pipe(\n        _.right(12),\n        _.filterOrElse(gt10, () => -1)\n      ),\n      _.right(12)\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.right(7),\n        _.filterOrElse(gt10, () => -1)\n      ),\n      _.left(-1)\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.left(12),\n        _.filterOrElse(gt10, () => -1)\n      ),\n      _.left(12)\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.right(7),\n        _.filterOrElse(gt10, (n) => `invalid ${n}`)\n      ),\n      _.left('invalid 7')\n    )\n\n    type Color = 'red' | 'blue'\n    const isColor = (s: string): s is Color => s === 'red' || s === 'blue'\n    const errorHandler = (s: string) => `invalid color ${s}`\n\n    U.deepStrictEqual(pipe(_.right('red'), _.filterOrElse(isColor, errorHandler)), _.right('red'))\n    U.deepStrictEqual(pipe(_.right('foo'), _.filterOrElse(isColor, errorHandler)), _.left('invalid color foo'))\n    U.deepStrictEqual(pipe(_.left('err'), _.filterOrElse(isColor, errorHandler)), _.left('err'))\n  })\n\n  it('isLeft', () => {\n    U.deepStrictEqual(_.isLeft(_.right(1)), false)\n    U.deepStrictEqual(_.isLeft(_.left(1)), true)\n  })\n\n  it('isRight', () => {\n    U.deepStrictEqual(_.isRight(_.right(1)), true)\n    U.deepStrictEqual(_.isRight(_.left(1)), false)\n  })\n\n  it('orElse', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.right(1),\n        _.orElse(() => _.right(2))\n      ),\n      _.right(1)\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.right(1),\n        _.orElse(() => _.left('foo'))\n      ),\n      _.right(1)\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.left('a'),\n        _.orElse(() => _.right(1))\n      ),\n      _.right(1)\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.left('a'),\n        _.orElse(() => _.left('b'))\n      ),\n      _.left('b')\n    )\n  })\n\n  it('swap', () => {\n    U.deepStrictEqual(_.swap(_.right('a')), _.left('a'))\n    U.deepStrictEqual(_.swap(_.left('b')), _.right('b'))\n  })\n\n  it('parseJSON', () => {\n    U.deepStrictEqual(_.parseJSON('{\"a\":1}', _.toError), _.right({ a: 1 }))\n    U.deepStrictEqual(\n      _.parseJSON('{\"a\":}', _.toError),\n      _.left(new SyntaxError(`Unexpected token '}', \"{\"a\":}\" is not valid JSON`))\n    )\n  })\n\n  it('stringifyJSON', () => {\n    U.deepStrictEqual(_.stringifyJSON({ a: 1 }, _.toError), _.right('{\"a\":1}'))\n    const circular: any = { ref: null }\n    circular.ref = circular\n    U.deepStrictEqual(\n      pipe(\n        _.stringifyJSON(circular, _.toError),\n        _.mapLeft((e) => e.message.includes('Converting circular structure to JSON'))\n      ),\n      _.left(true)\n    )\n    interface Person {\n      readonly name: string\n      readonly age: number\n    }\n    const person: Person = { name: 'Giulio', age: 45 }\n    U.deepStrictEqual(_.stringifyJSON(person, _.toError), _.right('{\"name\":\"Giulio\",\"age\":45}'))\n\n    // #1397\n    U.deepStrictEqual(\n      _.stringifyJSON(undefined, _.toError),\n      _.left(new Error('Converting unsupported structure to JSON'))\n    )\n  })\n\n  it('fromPredicate', () => {\n    const gt2 = _.fromPredicate(\n      (n: number) => n >= 2,\n      (n) => `Invalid number ${n}`\n    )\n    U.deepStrictEqual(gt2(3), _.right(3))\n    U.deepStrictEqual(gt2(1), _.left('Invalid number 1'))\n\n    // refinements\n    type Color = 'red' | 'blue'\n    const isColor = (s: string): s is Color => s === 'red' || s === 'blue'\n    const from = _.fromPredicate(isColor, (s) => `invalid color ${s}`)\n    U.deepStrictEqual(from('red'), _.right('red'))\n    U.deepStrictEqual(from('foo'), _.left('invalid color foo'))\n  })\n\n  it('fromNullable', () => {\n    U.deepStrictEqual(_.fromNullable('default')(null), _.left('default'))\n    U.deepStrictEqual(_.fromNullable('default')(undefined), _.left('default'))\n    U.deepStrictEqual(_.fromNullable('default')(1), _.right(1))\n  })\n\n  it('tryCatch', () => {\n    U.deepStrictEqual(\n      _.tryCatch(() => {\n        return 1\n      }, _.toError),\n      _.right(1)\n    )\n\n    U.deepStrictEqual(\n      _.tryCatch(() => {\n        throw 'string error'\n      }, _.toError),\n      _.left(new Error('string error'))\n    )\n\n    U.deepStrictEqual(\n      _.tryCatch(() => {\n        throw Object.create(null)\n      }, _.toError),\n      _.left(new Error())\n    )\n\n    U.deepStrictEqual(\n      _.tryCatch(() => {\n        throw { toString: [] }\n      }, _.toError),\n      _.left(new Error())\n    )\n  })\n\n  describe('getEq', () => {\n    it('equals', () => {\n      const equals = _.getEq(S.Eq, N.Eq).equals\n      U.deepStrictEqual(equals(_.right(1), _.right(1)), true)\n      U.deepStrictEqual(equals(_.right(1), _.right(2)), false)\n      U.deepStrictEqual(equals(_.right(1), _.left('foo')), false)\n      U.deepStrictEqual(equals(_.left('foo'), _.left('foo')), true)\n      U.deepStrictEqual(equals(_.left('foo'), _.left('bar')), false)\n      U.deepStrictEqual(equals(_.left('foo'), _.right(1)), false)\n    })\n  })\n\n  describe('ChainRec', () => {\n    it('chainRec', () => {\n      const chainRec = _.ChainRec.chainRec\n      U.deepStrictEqual(\n        chainRec(1, () => _.left('foo')),\n        _.left('foo')\n      )\n      U.deepStrictEqual(\n        chainRec(1, () => _.right(_.right(1))),\n        _.right(1)\n      )\n      U.deepStrictEqual(\n        chainRec(1, (a) => {\n          if (a < 5) {\n            return _.right(_.left(a + 1))\n          } else {\n            return _.right(_.right(a))\n          }\n        }),\n        _.right(5)\n      )\n    })\n  })\n\n  describe('getWitherable', () => {\n    const W = _.getWitherable(S.Monoid)\n    const p = (n: number) => n > 2\n\n    it('compact', () => {\n      U.deepStrictEqual(W.compact(_.left('1')), _.left('1'))\n      U.deepStrictEqual(W.compact(_.right(O.none)), _.left(S.Monoid.empty))\n      U.deepStrictEqual(W.compact(_.right(O.some(123))), _.right(123))\n    })\n\n    it('separate', () => {\n      U.deepStrictEqual(W.separate(_.left('123')), separated(_.left('123'), _.left('123')))\n      U.deepStrictEqual(W.separate(_.right(_.left('123'))), separated(_.right('123'), _.left(S.Monoid.empty)))\n      U.deepStrictEqual(W.separate(_.right(_.right('123'))), separated(_.left(S.Monoid.empty), _.right('123')))\n    })\n\n    it('partition', () => {\n      U.deepStrictEqual(W.partition(_.left('123'), p), separated(_.left('123'), _.left('123')))\n      U.deepStrictEqual(W.partition(_.right(1), p), separated(_.right(1), _.left(S.Monoid.empty)))\n      U.deepStrictEqual(W.partition(_.right(3), p), separated(_.left(S.Monoid.empty), _.right(3)))\n    })\n\n    it('partitionMap', () => {\n      const f = (n: number) => (p(n) ? _.right(n + 1) : _.left(n - 1))\n      U.deepStrictEqual(W.partitionMap(_.left('123'), f), separated(_.left('123'), _.left('123')))\n      U.deepStrictEqual(W.partitionMap(_.right(1), f), separated(_.right(0), _.left(S.Monoid.empty)))\n      U.deepStrictEqual(W.partitionMap(_.right(3), f), separated(_.left(S.Monoid.empty), _.right(4)))\n    })\n\n    it('filter', () => {\n      U.deepStrictEqual(W.filter(_.left('123'), p), _.left('123'))\n      U.deepStrictEqual(W.filter(_.right(1), p), _.left(S.Monoid.empty))\n      U.deepStrictEqual(W.filter(_.right(3), p), _.right(3))\n    })\n\n    it('filterMap', () => {\n      const f = (n: number) => (p(n) ? O.some(n + 1) : O.none)\n      U.deepStrictEqual(W.filterMap(_.left('123'), f), _.left('123'))\n      U.deepStrictEqual(W.filterMap(_.right(1), f), _.left(S.Monoid.empty))\n      U.deepStrictEqual(W.filterMap(_.right(3), f), _.right(4))\n    })\n\n    it('wither', async () => {\n      const wither = W.wither(T.ApplicativePar)\n      const f = (n: number) => T.of(p(n) ? O.some(n + 1) : O.none)\n      U.deepStrictEqual(await wither(_.left('foo'), f)(), _.left('foo'))\n      U.deepStrictEqual(await wither(_.right(1), f)(), _.left(S.Monoid.empty))\n      U.deepStrictEqual(await wither(_.right(3), f)(), _.right(4))\n    })\n\n    it('wilt', async () => {\n      const wilt = W.wilt(T.ApplicativePar)\n      const f = (n: number) => T.of(p(n) ? _.right(n + 1) : _.left(n - 1))\n      U.deepStrictEqual(await wilt(_.left('foo'), f)(), separated(_.left('foo'), _.left('foo')))\n      U.deepStrictEqual(await wilt(_.right(1), f)(), separated(_.right(0), _.left(S.Monoid.empty)))\n      U.deepStrictEqual(await wilt(_.right(3), f)(), separated(_.left(S.Monoid.empty), _.right(4)))\n    })\n  })\n\n  describe('getSemigroup', () => {\n    it('concat', () => {\n      const S = _.getSemigroup(N.SemigroupSum)\n      U.deepStrictEqual(S.concat(_.left('a'), _.left('b')), _.left('a'))\n      U.deepStrictEqual(S.concat(_.left('a'), _.right(2)), _.right(2))\n      U.deepStrictEqual(S.concat(_.right(1), _.left('b')), _.right(1))\n      U.deepStrictEqual(S.concat(_.right(1), _.right(2)), _.right(3))\n    })\n  })\n\n  describe('getApplySemigroup', () => {\n    it('concat', () => {\n      const S = _.getApplySemigroup(N.SemigroupSum)\n      U.deepStrictEqual(S.concat(_.left('a'), _.left('b')), _.left('a'))\n      U.deepStrictEqual(S.concat(_.left('a'), _.right(2)), _.left('a'))\n      U.deepStrictEqual(S.concat(_.right(1), _.left('b')), _.left('b'))\n      U.deepStrictEqual(S.concat(_.right(1), _.right(2)), _.right(3))\n    })\n  })\n\n  describe('getApplyMonoid', () => {\n    it('concat', () => {\n      const M = _.getApplyMonoid(N.MonoidSum)\n      U.deepStrictEqual(M.concat(_.left('a'), M.empty), _.left('a'))\n      U.deepStrictEqual(M.concat(M.empty, _.left('b')), _.left('b'))\n      U.deepStrictEqual(M.concat(_.right(1), M.empty), _.right(1))\n      U.deepStrictEqual(M.concat(M.empty, _.right(2)), _.right(2))\n    })\n  })\n\n  describe('getShow', () => {\n    it('show', () => {\n      const Sh = _.getShow(S.Show, S.Show)\n      U.deepStrictEqual(Sh.show(_.left('a')), `left(\"a\")`)\n      U.deepStrictEqual(Sh.show(_.right('a')), `right(\"a\")`)\n    })\n  })\n\n  it('getApplicativeValidation', () => {\n    const A = _.getApplicativeValidation(S.Monoid)\n    U.deepStrictEqual(sequenceT(A)(_.left('a'), _.left('b')), _.left('ab'))\n    const AV = _.getValidation(S.Monoid)\n    U.deepStrictEqual(sequenceT(AV)(_.left('a'), _.left('b')), _.left('ab'))\n  })\n\n  it('getAltValidation', () => {\n    const A = _.getAltValidation(S.Monoid)\n    U.deepStrictEqual(\n      A.alt(_.left('a'), () => _.left('b')),\n      _.left('ab')\n    )\n    U.deepStrictEqual(\n      A.alt(_.right(1), () => _.left('b')),\n      _.right(1)\n    )\n    U.deepStrictEqual(\n      A.alt(_.left('a'), () => _.right(2)),\n      _.right(2)\n    )\n    const AV = _.getValidation(S.Monoid)\n    U.deepStrictEqual(\n      AV.alt(_.left('a'), () => _.left('b')),\n      _.left('ab')\n    )\n  })\n\n  it('getValidationSemigroup', () => {\n    const VS = _.getValidationSemigroup(S.Monoid, N.MonoidSum)\n    U.deepStrictEqual(VS.concat(_.right(1), _.right(2)), _.right(3))\n    U.deepStrictEqual(VS.concat(_.right(1), _.left('foo')), _.left('foo'))\n    U.deepStrictEqual(VS.concat(_.left('foo'), _.right(1)), _.left('foo'))\n    U.deepStrictEqual(VS.concat(_.left('foo'), _.left('bar')), _.left('foobar'))\n  })\n\n  it('getValidationMonoid', () => {\n    const M = _.getValidationMonoid(S.Monoid, N.MonoidSum)\n    U.deepStrictEqual(M.concat(_.right(1), M.empty), _.right(1))\n    U.deepStrictEqual(M.concat(M.empty, _.right(1)), _.right(1))\n  })\n\n  it('fromOption', () => {\n    U.deepStrictEqual(_.fromOption(() => 'none')(O.none), _.left('none'))\n    U.deepStrictEqual(_.fromOption(() => 'none')(O.some(1)), _.right(1))\n  })\n\n  it('fromOptionK', () => {\n    const f = _.fromOptionK(() => 'a')((n: number) => (n > 0 ? O.some(n) : O.none))\n    U.deepStrictEqual(f(1), _.right(1))\n    U.deepStrictEqual(f(-1), _.left('a'))\n  })\n\n  it('flatMapOption', () => {\n    const f = _.flatMapOption(\n      (n: number) => (n > 0 ? O.some(n) : O.none),\n      () => 'a'\n    )\n    U.deepStrictEqual(f(_.right(1)), _.right(1))\n    U.deepStrictEqual(f(_.right(-1)), _.left('a'))\n    U.deepStrictEqual(f(_.left('b')), _.left('b'))\n  })\n\n  it('chainOptionK', () => {\n    const f = _.chainOptionK(() => 'a')((n: number) => (n > 0 ? O.some(n) : O.none))\n    U.deepStrictEqual(f(_.right(1)), _.right(1))\n    U.deepStrictEqual(f(_.right(-1)), _.left('a'))\n    U.deepStrictEqual(f(_.left('b')), _.left('b'))\n  })\n\n  it('exists', () => {\n    const gt2 = _.exists((n: number) => n > 2)\n    U.deepStrictEqual(gt2(_.left('a')), false)\n    U.deepStrictEqual(gt2(_.right(1)), false)\n    U.deepStrictEqual(gt2(_.right(3)), true)\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.right<string, number>(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.right('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      ),\n      _.right({ a: 1, b: 'b', c: [1, 'b'] })\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(\n      pipe(_.right<string, number>(1), _.bindTo('a'), _.apS('b', _.right('b'))),\n      _.right({ a: 1, b: 'b' })\n    )\n  })\n\n  it('fromNullableK', () => {\n    const f = _.fromNullableK('error')((n: number) => (n > 0 ? n : null))\n    U.deepStrictEqual(f(1), _.right(1))\n    U.deepStrictEqual(f(-1), _.left('error'))\n  })\n\n  it('flatMapNullable', () => {\n    const f = _.flatMapNullable(\n      (n: number) => (n > 0 ? n : null),\n      () => 'error'\n    )\n    U.deepStrictEqual(f(_.right(1)), _.right(1))\n    U.deepStrictEqual(f(_.right(-1)), _.left('error'))\n    U.deepStrictEqual(f(_.left('a')), _.left('a'))\n  })\n\n  it('chainNullableK', () => {\n    const f = _.chainNullableK('error')((n: number) => (n > 0 ? n : null))\n    U.deepStrictEqual(f(_.right(1)), _.right(1))\n    U.deepStrictEqual(f(_.right(-1)), _.left('error'))\n    U.deepStrictEqual(f(_.left('a')), _.left('a'))\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.right(a + i) : _.left('e')))\n      U.deepStrictEqual(pipe(RA.empty, f), _.right(RA.empty))\n      U.deepStrictEqual(pipe(input, f), _.right(['a0', 'b1']))\n      U.deepStrictEqual(pipe(['a', ''], f), _.left('e'))\n    })\n\n    // old\n    it('sequenceArray', () => {\n      U.deepStrictEqual(pipe([_.right(1), _.right(2)], _.sequenceArray), _.right([1, 2]))\n      U.deepStrictEqual(pipe([_.right(1), _.left('a')], _.sequenceArray), _.left('a'))\n    })\n  })\n\n  describe('getCompactable', () => {\n    const C = _.getCompactable(S.Monoid)\n    it('compact', () => {\n      U.deepStrictEqual(C.compact(_.left('1')), _.left('1'))\n      U.deepStrictEqual(C.compact(_.right(O.none)), _.left(S.Monoid.empty))\n      U.deepStrictEqual(C.compact(_.right(O.some(123))), _.right(123))\n    })\n\n    it('separate', () => {\n      U.deepStrictEqual(C.separate(_.left('123')), separated(_.left('123'), _.left('123')))\n      U.deepStrictEqual(C.separate(_.right(_.left('123'))), separated(_.right('123'), _.left(S.Monoid.empty)))\n      U.deepStrictEqual(C.separate(_.right(_.right('123'))), separated(_.left(S.Monoid.empty), _.right('123')))\n    })\n  })\n\n  it('toUnion', () => {\n    U.deepStrictEqual(_.toUnion(_.right(1)), 1)\n    U.deepStrictEqual(_.toUnion(_.left('a')), 'a')\n  })\n\n  it('tryCatchK', () => {\n    const f = _.tryCatchK((s: string) => {\n      const len = s.length\n      if (len > 0) {\n        return len\n      }\n      throw new Error('empty string')\n    }, identity)\n    U.deepStrictEqual(f('a'), _.right(1))\n    U.deepStrictEqual(f(''), _.left(new Error('empty string')))\n  })\n\n  it('as', () => {\n    U.deepStrictEqual(pipe(_.right('a'), _.as('b')), _.right('b'))\n    U.deepStrictEqual(_.as(_.of('a'), 'b'), _.right('b'))\n    U.deepStrictEqual(_.as(_.left('error'), 'b'), _.left('error'))\n  })\n\n  it('asUnit', () => {\n    U.deepStrictEqual(pipe(_.of('a'), _.asUnit), _.of(undefined))\n  })\n})\n"
  },
  {
    "path": "test/EitherT.ts",
    "content": "import * as E from '../src/Either'\nimport { getEitherM } from '../src/EitherT'\nimport * as I from '../src/IO'\nimport * as U from './util'\n\ndescribe('EitherT', () => {\n  const T = getEitherM(I.Monad)\n\n  it('fold', () => {\n    const onLeft = (s: string) => I.of(`left(${s})`)\n    const onRight = (n: number) => I.of(`right(${n})`)\n    U.deepStrictEqual(T.fold(I.of(E.right(1)), onLeft, onRight)(), 'right(1)')\n    U.deepStrictEqual(T.fold(I.of(E.left('bb')), onLeft, onRight)(), 'left(bb)')\n  })\n\n  it('getOrElse', () => {\n    const onLeft = (s: string) => I.of(`left(${s})`)\n    U.deepStrictEqual(T.getOrElse(I.of(E.right('a')), onLeft)(), 'a')\n    U.deepStrictEqual(T.getOrElse(I.of(E.left('bb')), onLeft)(), 'left(bb)')\n  })\n})\n"
  },
  {
    "path": "test/Endomorphism.ts",
    "content": "import * as _ from '../src/Endomorphism'\nimport * as U from './util'\n\ndescribe('Endomorphism', () => {\n  it('getMonoid', () => {\n    const M = _.getMonoid<number>()\n    const inc = (n: number) => n + 1\n    const f = M.concat(inc, U.double)\n    U.deepStrictEqual(f(3), 8)\n  })\n})\n"
  },
  {
    "path": "test/Eq.ts",
    "content": "import * as B from '../src/boolean'\nimport * as _ from '../src/Eq'\nimport { pipe } from '../src/function'\nimport { concatAll } from '../src/Monoid'\nimport * as N from '../src/number'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('Eq', () => {\n  describe('pipeables', () => {\n    it('contramap', () => {\n      const E = pipe(\n        S.Eq,\n        _.contramap((p: Person) => p.name)\n      )\n      U.deepStrictEqual(E.equals({ name: 'a', age: 1 }, { name: 'a', age: 2 }), true)\n      U.deepStrictEqual(E.equals({ name: 'a', age: 1 }, { name: 'a', age: 1 }), true)\n      U.deepStrictEqual(E.equals({ name: 'a', age: 1 }, { name: 'b', age: 1 }), false)\n      U.deepStrictEqual(E.equals({ name: 'a', age: 1 }, { name: 'b', age: 2 }), false)\n    })\n  })\n\n  it('tuple', () => {\n    const E = _.tuple(S.Eq, N.Eq, B.Eq)\n    U.deepStrictEqual(E.equals(['a', 1, true], ['a', 1, true]), true)\n    U.deepStrictEqual(E.equals(['a', 1, true], ['b', 1, true]), false)\n    U.deepStrictEqual(E.equals(['a', 1, true], ['a', 2, true]), false)\n    U.deepStrictEqual(E.equals(['a', 1, true], ['a', 1, false]), false)\n  })\n\n  interface Person {\n    readonly name: string\n    readonly age: number\n  }\n\n  it('fromEquals', () => {\n    interface A {\n      readonly x: number\n    }\n    let nbCall = 0\n    const S1 = _.fromEquals<A>((a, b) => {\n      nbCall += 1\n      return a.x === b.x\n    })\n    const a1 = { x: 1 }\n    const a2 = { x: 1 }\n    S1.equals(a1, a1)\n    U.deepStrictEqual(nbCall, 0)\n    S1.equals(a1, a2)\n    U.deepStrictEqual(nbCall, 1)\n  })\n\n  it('struct', () => {\n    const E = _.struct<Person>({\n      name: S.Eq,\n      age: N.Eq\n    })\n    U.deepStrictEqual(E.equals({ name: 'a', age: 1 }, { name: 'a', age: 1 }), true)\n    U.deepStrictEqual(E.equals({ name: 'a', age: 1 }, { name: 'a', age: 2 }), false)\n    U.deepStrictEqual(E.equals({ name: 'a', age: 1 }, { name: 'b', age: 1 }), false)\n  })\n\n  it('eqStrict', () => {\n    U.deepStrictEqual(_.eqStrict.equals(1, 1), true)\n    U.deepStrictEqual(_.eqStrict.equals(1, 'a'), false)\n  })\n\n  it('getMonoid', () => {\n    type T = readonly [string, number, boolean]\n    const M = _.getMonoid<T>()\n    const eqFst: _.Eq<T> = _.contramap((x: T) => x[0])(S.Eq)\n    const eqSnd: _.Eq<T> = _.contramap((x: T) => x[1])(N.Eq)\n    const eq3rd: _.Eq<T> = _.contramap((x: T) => x[2])(B.Eq)\n    const eq = concatAll(M)([eqFst, eqSnd, eq3rd])\n    U.deepStrictEqual(eq.equals(['a', 1, true], ['a', 1, true]), true)\n    U.deepStrictEqual(eq.equals(['a', 1, true], ['b', 1, true]), false)\n    U.deepStrictEqual(eq.equals(['a', 1, true], ['a', 2, true]), false)\n    U.deepStrictEqual(eq.equals(['a', 1, true], ['a', 1, false]), false)\n  })\n\n  it('eqDate', () => {\n    const E = _.eqDate\n    U.deepStrictEqual(E.equals(new Date(0), new Date(0)), true)\n    U.deepStrictEqual(E.equals(new Date(0), new Date(1)), false)\n    U.deepStrictEqual(E.equals(new Date(1), new Date(0)), false)\n  })\n})\n"
  },
  {
    "path": "test/Field.ts",
    "content": "import * as _ from '../src/Field'\nimport * as N from '../src/number'\nimport * as U from './util'\n\ndescribe('Field', () => {\n  it('gcd', () => {\n    const gcdNumber = _.gcd(N.Eq, N.Field)\n    U.deepStrictEqual(gcdNumber(10, 5), 5)\n    U.deepStrictEqual(gcdNumber(10, 2), 2)\n    U.deepStrictEqual(gcdNumber(10, 3), 1)\n  })\n\n  it('lcm', () => {\n    const lcmNumber = _.lcm(N.Eq, N.Field)\n    U.deepStrictEqual(lcmNumber(4, 6), 12)\n    U.deepStrictEqual(lcmNumber(4, 0), 0)\n  })\n\n  it('fieldNumber', () => {\n    const F = _.fieldNumber\n    U.deepStrictEqual(F.add(1, 2), 3)\n    U.deepStrictEqual(F.div(4, 2), 2)\n    U.deepStrictEqual(F.mod(4, 2), 0)\n    U.deepStrictEqual(F.mul(4, 2), 8)\n    U.deepStrictEqual(F.sub(3, 2), 1)\n    U.deepStrictEqual(F.degree(0), 1)\n    U.deepStrictEqual(F.degree(1), 1)\n    U.deepStrictEqual(F.degree(2), 1)\n  })\n})\n"
  },
  {
    "path": "test/Filterable.ts",
    "content": "import { left, right } from '../src/Either'\nimport { getFilterableComposition } from '../src/Filterable'\nimport { increment } from '../src/function'\nimport { none, some } from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport { separated } from '../src/Separated'\nimport * as U from './util'\n\ndescribe('Filterable', () => {\n  it('getFilterableComposition', () => {\n    const F = getFilterableComposition(RA.Functor, RA.Filterable)\n\n    U.deepStrictEqual(F.map([[1]], increment), [[2]])\n\n    U.deepStrictEqual(\n      F.filter(\n        [\n          [1, 2],\n          [3, 4]\n        ],\n        (a) => a > 1\n      ),\n      [[2], [3, 4]]\n    )\n\n    U.deepStrictEqual(\n      F.filterMap(\n        [\n          ['a', 'bb'],\n          ['ccc', 'dddd']\n        ],\n        (a) => (a.length > 1 ? some(a.length) : none)\n      ),\n      [[2], [3, 4]]\n    )\n\n    U.deepStrictEqual(\n      F.partition(\n        [\n          ['a', 'bb'],\n          ['ccc', 'dddd']\n        ],\n        (a) => a.length % 2 === 0\n      ),\n      separated([['a'], ['ccc']], [['bb'], ['dddd']])\n    )\n\n    U.deepStrictEqual(\n      F.partitionMap(\n        [\n          ['a', 'bb'],\n          ['ccc', 'dddd']\n        ],\n        (a) => (a.length % 2 === 0 ? right(a.length) : left(a))\n      ),\n      separated([['a'], ['ccc']], [[2], [4]])\n    )\n  })\n})\n"
  },
  {
    "path": "test/Foldable.ts",
    "content": "import * as _ from '../src/Foldable'\nimport { pipe } from '../src/function'\nimport * as I from '../src/IO'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport * as S from '../src/string'\nimport * as T from '../src/Tree'\nimport * as U from './util'\n\nexport const ArrayOptionURI = 'ArrayOption'\n\nexport type ArrayOptionURI = typeof ArrayOptionURI\n\ndescribe('Foldable', () => {\n  it('getFoldableComposition', () => {\n    const F = _.getFoldableComposition(RA.Foldable, O.Foldable)\n    // reduce\n    U.deepStrictEqual(F.reduce([O.some('a'), O.some('b'), O.some('c')], '', S.Semigroup.concat), 'abc')\n    U.deepStrictEqual(F.reduce([O.none, O.some('b'), O.none], '', S.Semigroup.concat), 'b')\n    U.deepStrictEqual(F.reduce([O.none, O.none, O.none], '', S.Semigroup.concat), '')\n    U.deepStrictEqual(F.reduce([], '', S.Semigroup.concat), '')\n    // foldMap\n    U.deepStrictEqual(\n      F.foldMap(S.Monoid)([O.some('a'), O.some('b'), O.some('c')], (a) => a),\n      'abc'\n    )\n    U.deepStrictEqual(\n      F.foldMap(S.Monoid)([O.none, O.some('b'), O.none], (a) => a),\n      'b'\n    )\n    U.deepStrictEqual(\n      F.foldMap(S.Monoid)([O.none, O.none, O.none], (a) => a),\n      ''\n    )\n    U.deepStrictEqual(\n      F.foldMap(S.Monoid)([], (a: string) => a),\n      ''\n    )\n    // reduceRight\n    U.deepStrictEqual(F.reduceRight([O.some('a'), O.some('b'), O.some('c')], '', S.Semigroup.concat), 'abc')\n    U.deepStrictEqual(F.reduceRight([O.none, O.some('b'), O.none], '', S.Semigroup.concat), 'b')\n    U.deepStrictEqual(F.reduceRight([O.none, O.none, O.none], '', S.Semigroup.concat), '')\n    U.deepStrictEqual(F.reduceRight([], '', S.Semigroup.concat), '')\n  })\n\n  it('intercalate', () => {\n    U.deepStrictEqual(_.intercalate(S.Monoid, RA.Foldable)(',', ['a', 'b', 'c']), 'a,b,c')\n  })\n\n  it('toReadonlyArray', () => {\n    // Option\n    const optionToArray = _.toReadonlyArray(O.Foldable)\n    U.deepStrictEqual(optionToArray(O.some(1)), [1])\n    U.deepStrictEqual(optionToArray(O.none), [])\n\n    // Tree\n    const treeToArray = _.toReadonlyArray(T.Foldable)\n    U.deepStrictEqual(treeToArray(T.make(1, [T.make(2, []), T.make(3, []), T.make(4, [])])), [1, 2, 3, 4])\n  })\n\n  it('traverse_', () => {\n    let log = ''\n    const append = (s: String) => () => (log += s)\n    _.traverse_(I.Applicative, RA.Foldable)(['a', 'b', 'c'], append)()\n    U.deepStrictEqual(log, 'abc')\n  })\n\n  it('foldM', () => {\n    U.deepStrictEqual(\n      _.foldM(O.Monad, RA.Foldable)([], 1, () => O.none),\n      O.some(1)\n    )\n    U.deepStrictEqual(\n      _.foldM(O.Monad, RA.Foldable)([2], 1, () => O.none),\n      O.none\n    )\n    U.deepStrictEqual(\n      _.foldM(O.Monad, RA.Foldable)([2], 1, (b, a) => O.some(b + a)),\n      O.some(3)\n    )\n  })\n\n  it('reduceM', () => {\n    U.deepStrictEqual(\n      pipe(\n        [],\n        _.reduceM(O.Monad, RA.Foldable)(1, () => O.none)\n      ),\n      O.some(1)\n    )\n    U.deepStrictEqual(\n      pipe(\n        [2],\n        _.reduceM(O.Monad, RA.Foldable)(1, () => O.none)\n      ),\n      O.none\n    )\n    U.deepStrictEqual(\n      pipe(\n        [2],\n        _.reduceM(O.Monad, RA.Foldable)(1, (b, a) => O.some(b + a))\n      ),\n      O.some(3)\n    )\n  })\n})\n"
  },
  {
    "path": "test/FoldableWithIndex.ts",
    "content": "import { getFoldableWithIndexComposition } from '../src/FoldableWithIndex'\nimport * as RA from '../src/ReadonlyArray'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('FoldableWithIndex', () => {\n  it('getFoldableWithIndexComposition', () => {\n    const arrayOfArray = getFoldableWithIndexComposition(RA.FoldableWithIndex, RA.FoldableWithIndex)\n    const fa: ReadonlyArray<ReadonlyArray<string>> = [\n      ['a', 'b'],\n      ['c', 'd']\n    ]\n\n    U.deepStrictEqual(\n      arrayOfArray.reduceWithIndex(fa, '', ([i, j], b: string, a: string) => b + a + i + j),\n      'a00b01c10d11'\n    )\n\n    U.deepStrictEqual(\n      arrayOfArray.foldMapWithIndex(S.Monoid)(fa, ([i, j], a) => a + i + j),\n      'a00b01c10d11'\n    )\n\n    U.deepStrictEqual(\n      arrayOfArray.reduceRightWithIndex(fa, '', ([i, j], a: string, b: string) => b + a + i + j),\n      'd11c10b01a00'\n    )\n  })\n})\n"
  },
  {
    "path": "test/Functor.ts",
    "content": "import { getFunctorComposition } from '../src/Functor'\nimport * as option from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport * as U from './util'\n\ndescribe('Functor', () => {\n  it('getFunctorComposition', () => {\n    const arrayOption = getFunctorComposition(RA.Functor, option.Functor)\n    U.deepStrictEqual(arrayOption.map([option.some(1)], U.double), [option.some(2)])\n  })\n})\n"
  },
  {
    "path": "test/FunctorWithIndex.ts",
    "content": "import { getFunctorWithIndexComposition } from '../src/FunctorWithIndex'\nimport * as RA from '../src/ReadonlyArray'\nimport * as U from './util'\n\ndescribe('FunctorWithIndex', () => {\n  it('getFunctorComposition', () => {\n    const FWI = getFunctorWithIndexComposition(RA.FunctorWithIndex, RA.FunctorWithIndex)\n    const f = ([i, j]: readonly [number, number], a: string) => a + i + j\n    U.deepStrictEqual(\n      FWI.map([[1], [2]], (n) => n * 2),\n      [[2], [4]]\n    )\n    U.deepStrictEqual(\n      FWI.mapWithIndex(\n        [\n          ['a', 'b'],\n          ['c', 'd']\n        ],\n        f\n      ),\n      [\n        ['a00', 'b01'],\n        ['c10', 'd11']\n      ]\n    )\n  })\n})\n"
  },
  {
    "path": "test/IO.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as _ from '../src/IO'\nimport * as N from '../src/number'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport * as U from './util'\n\ndescribe('IO', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      U.deepStrictEqual(pipe(_.of(1), _.map(U.double))(), 2)\n    })\n\n    it('ap', () => {\n      U.deepStrictEqual(pipe(_.of(U.double), _.ap(_.of(1)))(), 2)\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe(_.of('a'), _.apFirst(_.of('b')))(), 'a')\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe(_.of('a'), _.apSecond(_.of('b')))(), 'b')\n    })\n\n    it('flatMap', () => {\n      const f = (n: number) => _.of(n * 2)\n      U.deepStrictEqual(pipe(_.of(1), _.flatMap(f))(), 2)\n      U.deepStrictEqual(_.flatMap(_.of(1), f)(), 2)\n    })\n\n    it('chain', () => {\n      const f = (n: number) => _.of(n * 2)\n      U.deepStrictEqual(pipe(_.of(1), _.chain(f))(), 2)\n    })\n\n    it('flatten', () => {\n      U.deepStrictEqual(pipe(_.of(_.of(1)), _.flatten)(), 1)\n    })\n\n    it('tap', () => {\n      const f = (n: number) => _.of(n * 2)\n      U.deepStrictEqual(pipe(_.of(1), _.tap(f))(), 1)\n      U.deepStrictEqual(_.tap(_.of(1), f)(), 1)\n    })\n\n    it('chainFirst', () => {\n      const f = (n: number) => _.of(n * 2)\n      U.deepStrictEqual(pipe(_.of(1), _.chainFirst(f))(), 1)\n    })\n  })\n\n  it('getSemigroup', () => {\n    const S = _.getSemigroup(N.SemigroupSum)\n    const log: Array<string> = []\n    const append =\n      (message: string): _.IO<number> =>\n      () =>\n        log.push(message)\n    U.deepStrictEqual(S.concat(append('a'), append('b'))(), 3)\n    U.deepStrictEqual(log, ['a', 'b'])\n  })\n\n  it('getMonoid', () => {\n    const M = _.getMonoid(N.MonoidSum)\n    const log: Array<string> = []\n    const append =\n      (message: string): _.IO<number> =>\n      () =>\n        log.push(message)\n    U.deepStrictEqual(M.concat(append('a'), M.empty)(), 1)\n    U.deepStrictEqual(M.concat(M.empty, append('b'))(), 2)\n    U.deepStrictEqual(log, ['a', 'b'])\n  })\n\n  it('chainRec', () => {\n    const f = (n: number) => (n < 15000 ? _.of(E.left(n + 1)) : _.of(E.right('ok ' + n)))\n    U.deepStrictEqual(_.ChainRec.chainRec(0, f)(), 'ok 15000')\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )(),\n      { a: 1, b: 'b', c: [1, 'b'] }\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b')))(), { a: 1, b: 'b' })\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => _.of(a + i))\n      U.strictEqual(pipe(RA.empty, f)(), RA.empty)\n      U.deepStrictEqual(pipe(input, f)(), ['a0', 'b1'])\n    })\n\n    // old\n    it('sequenceArray', () => {\n      const log: Array<number | string> = []\n      const append =\n        (n: number): _.IO<number> =>\n        () => {\n          log.push(n)\n          return n\n        }\n      U.deepStrictEqual(pipe([append(1), append(2)], _.sequenceArray)(), [1, 2])\n      U.deepStrictEqual(log, [1, 2])\n    })\n  })\n\n  it('as', () => {\n    U.deepStrictEqual(pipe(_.of('a'), _.as('b'))(), 'b')\n  })\n\n  it('asUnit', () => {\n    U.deepStrictEqual(pipe(_.of('a'), _.asUnit)(), undefined)\n  })\n})\n"
  },
  {
    "path": "test/IOEither.ts",
    "content": "import { sequenceT } from '../src/Apply'\nimport * as E from '../src/Either'\nimport { constVoid, identity, pipe, SK } from '../src/function'\nimport * as I from '../src/IO'\nimport * as _ from '../src/IOEither'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport { pipeable } from '../src/pipeable'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport { left, right } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('IOEither', () => {\n  describe('pipeables', () => {\n    it('alt', () => {\n      const r1 = _.right<string, number>(1)\n      const r2 = _.right<string, number>(2)\n      const l1 = _.left<string, number>('foo')\n      const l2 = _.left<string, number>('bar')\n\n      U.deepStrictEqual(\n        pipe(\n          l1,\n          _.alt(() => l2)\n        )(),\n        E.left('bar')\n      )\n      U.deepStrictEqual(\n        pipe(\n          l1,\n          _.alt(() => r1)\n        )(),\n        E.right(1)\n      )\n      U.deepStrictEqual(\n        pipe(\n          r1,\n          _.alt(() => l1)\n        )(),\n        E.right(1)\n      )\n      U.deepStrictEqual(\n        pipe(\n          r1,\n          _.alt(() => r2)\n        )(),\n        E.right(1)\n      )\n    })\n\n    it('map', () => {\n      U.deepStrictEqual(pipe(_.right(1), _.map(U.double))(), E.right(2))\n    })\n\n    it('ap', () => {\n      U.deepStrictEqual(pipe(_.right(U.double), _.ap(_.right(1)))(), E.right(2))\n    })\n\n    it('ApplicativePar', () => {\n      const log: Array<string> = []\n      const x = sequenceT(_.ApplicativePar)(\n        _.rightIO<string, number>(() => log.push('a')),\n        _.leftIO(() => {\n          log.push('b')\n          return 'error'\n        }),\n        _.rightIO(() => log.push('c'))\n      )()\n      U.deepStrictEqual(x, E.left('error'))\n      U.deepStrictEqual(log, ['a', 'b', 'c'])\n    })\n\n    it('ApplicativeSeq', () => {\n      const log: Array<string> = []\n      const x = sequenceT(_.ApplicativeSeq)(\n        _.rightIO<string, number>(() => log.push('a')),\n        _.leftIO(() => {\n          log.push('b')\n          return 'error'\n        }),\n        _.rightIO(() => log.push('c'))\n      )()\n      U.deepStrictEqual(x, E.left('error'))\n      U.deepStrictEqual(log, ['a', 'b'])\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe(_.right('a'), _.apFirst(_.right('b')))(), E.right('a'))\n    })\n\n    it('apFirstW', () => {\n      const fa = _.right<'Foo', string>('a')\n      const fb = _.right<'Bar', number>(1)\n      U.deepStrictEqual(pipe(fa, _.apFirstW(fb))(), E.right('a'))\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe(_.right('a'), _.apSecond(_.right('b')))(), E.right('b'))\n    })\n\n    it('apSecondW', () => {\n      const fa = _.right<'Foo', string>('a')\n      const fb = _.right<'Bar', number>(1)\n      U.deepStrictEqual(pipe(fa, _.apSecondW(fb))(), E.right(1))\n    })\n\n    it('flatMap', () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('foo'))\n      U.deepStrictEqual(pipe(_.right('foo'), _.flatMap(f))(), E.right(3))\n      U.deepStrictEqual(_.flatMap(_.right('foo'), f)(), E.right(3))\n      U.deepStrictEqual(pipe(_.right('a'), _.flatMap(f))(), E.left('foo'))\n      U.deepStrictEqual(_.flatMap(_.right('a'), f)(), E.left('foo'))\n    })\n\n    it('chain', () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('foo'))\n      U.deepStrictEqual(pipe(_.right('foo'), _.chain(f))(), E.right(3))\n      U.deepStrictEqual(pipe(_.right('a'), _.chain(f))(), E.left('foo'))\n    })\n\n    it('tap', () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('foo'))\n      U.deepStrictEqual(pipe(_.right('foo'), _.tap(f))(), E.right('foo'))\n      U.deepStrictEqual(pipe(_.right('a'), _.tap(f))(), E.left('foo'))\n      U.deepStrictEqual(_.tap(_.right('foo'), f)(), E.right('foo'))\n      U.deepStrictEqual(_.tap(_.right('a'), f)(), E.left('foo'))\n    })\n\n    it('chainFirst', () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('foo'))\n      U.deepStrictEqual(pipe(_.right('foo'), _.chainFirst(f))(), E.right('foo'))\n      U.deepStrictEqual(pipe(_.right('a'), _.chainFirst(f))(), E.left('foo'))\n    })\n\n    it('chainFirstW', () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('foo'))\n      U.deepStrictEqual(pipe(_.right<boolean, string>('foo'), _.chainFirstW(f))(), E.right('foo'))\n      U.deepStrictEqual(pipe(_.right<boolean, string>('a'), _.chainFirstW(f))(), E.left('foo'))\n    })\n\n    it('flatten', () => {\n      U.deepStrictEqual(pipe(_.right(_.right('a')), _.flatten)(), E.right('a'))\n    })\n\n    it('flattenW', () => {\n      U.deepStrictEqual(pipe(_.right<'left1', _.IOEither<'left2', 'a'>>(_.right('a')), _.flattenW)(), E.right('a'))\n    })\n\n    it('bimap', () => {\n      const f = (s: string): number => s.length\n      const g = (n: number): boolean => n > 2\n      U.deepStrictEqual(pipe(_.right(1), _.bimap(f, g))(), E.right(false))\n      U.deepStrictEqual(pipe(_.left('foo'), _.bimap(f, g))(), E.left(3))\n    })\n\n    it('mapLeft', () => {\n      U.deepStrictEqual(pipe(_.left(1), _.mapLeft(U.double))(), E.left(2))\n    })\n\n    it('filterOrElse', () => {\n      const isNumber = (u: string | number): u is number => typeof u === 'number'\n\n      U.deepStrictEqual(\n        pipe(\n          _.right(12),\n          _.filterOrElse(\n            (n) => n > 10,\n            () => 'bar'\n          )\n        )(),\n        E.right(12)\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.right(7),\n          _.filterOrElse(\n            (n) => n > 10,\n            () => 'bar'\n          )\n        )(),\n        E.left('bar')\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.left('foo'),\n          _.filterOrElse(\n            (n) => n > 10,\n            () => 'bar'\n          )\n        )(),\n        E.left('foo')\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.right(7),\n          _.filterOrElse(\n            (n) => n > 10,\n            (n) => `invalid ${n}`\n          )\n        )(),\n        E.left('invalid 7')\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.right(12),\n          _.filterOrElse(isNumber, () => 'not a number')\n        )(),\n        E.right(12)\n      )\n    })\n\n    it('fromOption', () => {\n      U.deepStrictEqual(_.fromOption(() => 'a')(O.none)(), E.left('a'))\n      U.deepStrictEqual(_.fromOption(() => 'a')(O.some(1))(), E.right(1))\n    })\n\n    it('fromOptionK', () => {\n      const f = _.fromOptionK(() => 'a')((n: number) => (n > 0 ? O.some(n) : O.none))\n      U.deepStrictEqual(f(1)(), E.right(1))\n      U.deepStrictEqual(f(-1)(), E.left('a'))\n    })\n\n    it('flatMapOption', () => {\n      const f = _.flatMapOption(\n        (n: number) => (n > 0 ? O.some(n) : O.none),\n        () => 'a'\n      )\n      U.deepStrictEqual(f(_.right(1))(), E.right(1))\n      U.deepStrictEqual(f(_.right(-1))(), E.left('a'))\n      U.deepStrictEqual(f(_.left('b'))(), E.left('b'))\n    })\n\n    it('chainOptionK', () => {\n      const f = _.chainOptionK(() => 'a')((n: number) => (n > 0 ? O.some(n) : O.none))\n      U.deepStrictEqual(f(_.right(1))(), E.right(1))\n      U.deepStrictEqual(f(_.right(-1))(), E.left('a'))\n      U.deepStrictEqual(f(_.left('b'))(), E.left('b'))\n    })\n\n    it('flatMapEither', () => {\n      const f = _.flatMapEither((n: number) => (n > 0 ? E.right(n) : E.left('a')))\n      U.deepStrictEqual(f(_.right(1))(), E.right(1))\n      U.deepStrictEqual(f(_.right(-1))(), E.left('a'))\n      U.deepStrictEqual(f(_.left('b'))(), E.left('b'))\n    })\n\n    it('chainEitherK', () => {\n      const f = _.chainEitherK((n: number) => (n > 0 ? E.right(n) : E.left('a')))\n      U.deepStrictEqual(f(_.right(1))(), E.right(1))\n      U.deepStrictEqual(f(_.right(-1))(), E.left('a'))\n      U.deepStrictEqual(f(_.left('b'))(), E.left('b'))\n    })\n\n    it('fromEither', () => {\n      U.deepStrictEqual(_.fromEither(E.right('a'))(), E.right('a'))\n      U.deepStrictEqual(_.fromEither(E.left('a'))(), E.left('a'))\n    })\n\n    it('fromPredicate', () => {\n      const gt2 = _.fromPredicate(\n        (n: number) => n >= 2,\n        (n) => `Invalid number ${n}`\n      )\n      U.deepStrictEqual(gt2(3)(), E.right(3))\n      U.deepStrictEqual(gt2(1)(), E.left('Invalid number 1'))\n\n      // refinements\n      const isNumber = (u: string | number): u is number => typeof u === 'number'\n      const from = _.fromPredicate(isNumber, () => 'not a number')\n      U.deepStrictEqual(from(4)(), E.right(4))\n    })\n  })\n\n  it('fold', () => {\n    U.deepStrictEqual(\n      _.fold(\n        () => I.of('left'),\n        () => I.of('right')\n      )(_.right(1))(),\n      'right'\n    )\n    U.deepStrictEqual(\n      _.fold(\n        () => I.of('left'),\n        () => I.of('right')\n      )(_.left('a'))(),\n      'left'\n    )\n  })\n\n  it('getOrElse', () => {\n    U.deepStrictEqual(_.getOrElse(() => I.of(2))(_.right(1))(), 1)\n    U.deepStrictEqual(_.getOrElse(() => I.of(2))(_.left(1))(), 2)\n  })\n\n  it('orElse', () => {\n    U.deepStrictEqual(_.orElse(() => _.right(2))(_.right(1))(), E.right(1))\n  })\n\n  it('orElseW', () => {\n    U.deepStrictEqual(_.orElseW(() => _.right(2))(_.right(1))(), E.right(1))\n  })\n\n  it('tapError', () => {\n    const f = (e: string) => (e.length <= 1 ? _.right(true) : _.left(e + '!'))\n    U.deepStrictEqual(pipe(_.right(1), _.tapError(f))(), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), _.tapError(f))(), E.left('a'))\n    U.deepStrictEqual(pipe(_.left('aa'), _.tapError(f))(), E.left('aa!'))\n    U.deepStrictEqual(_.tapError(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(_.tapError(_.left('a'), f)(), E.left('a'))\n    U.deepStrictEqual(_.tapError(_.left('aa'), f)(), E.left('aa!'))\n  })\n\n  it('orElseFirst', () => {\n    const f = _.orElseFirst((e: string) => (e.length <= 1 ? _.right(true) : _.left(e + '!')))\n    U.deepStrictEqual(pipe(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), f)(), E.left('a'))\n    U.deepStrictEqual(pipe(_.left('aa'), f)(), E.left('aa!'))\n  })\n\n  it('orElseFirstW', () => {\n    const f = _.orElseFirstW((e: string) => (e.length <= 1 ? _.right(true) : _.left(e + '!')))\n    U.deepStrictEqual(pipe(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), f)(), E.left('a'))\n    U.deepStrictEqual(pipe(_.left('aa'), f)(), E.left('aa!'))\n  })\n\n  it('orElseFirstIOK', () => {\n    const f = _.orElseFirstIOK((e: string) => I.of(e.length))\n    U.deepStrictEqual(pipe(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), f)(), E.left('a'))\n  })\n\n  it('orLeft', () => {\n    const f = _.orLeft((e: string) => I.of(e + '!'))\n    U.deepStrictEqual(pipe(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), f)(), E.left('a!'))\n  })\n\n  it('tryCatch', () => {\n    U.deepStrictEqual(_.tryCatch(() => 1, E.toError)(), E.right(1))\n    U.deepStrictEqual(\n      _.tryCatch(() => {\n        throw new Error('error')\n      }, E.toError)(),\n      E.left(new Error('error'))\n    )\n  })\n\n  describe('getSemigroup', () => {\n    it('concat', () => {\n      const S = _.getSemigroup<string, number>(N.SemigroupSum)\n      U.deepStrictEqual(S.concat(_.leftIO(I.of('a')), _.leftIO(I.of('b')))(), E.left('a'))\n      U.deepStrictEqual(S.concat(_.leftIO(I.of('a')), _.rightIO(I.of(2)))(), E.right(2))\n      U.deepStrictEqual(S.concat(_.rightIO(I.of(1)), _.leftIO(I.of('b')))(), E.right(1))\n      U.deepStrictEqual(S.concat(_.rightIO(I.of(1)), _.rightIO(I.of(2)))(), E.right(3))\n    })\n  })\n\n  describe('getApplyMonoid', () => {\n    it('concat', () => {\n      const M = _.getApplyMonoid(S.Monoid)\n      U.deepStrictEqual(M.concat(_.rightIO(I.of('a')), _.rightIO(I.of('b')))(), E.right('ab'))\n      U.deepStrictEqual(M.concat(_.rightIO(I.of('a')), _.leftIO(I.of('b')))(), E.left('b'))\n      U.deepStrictEqual(M.concat(_.rightIO(I.of('a')), M.empty)(), E.right('a'))\n      U.deepStrictEqual(M.concat(M.empty, _.rightIO(I.of('a')))(), E.right('a'))\n    })\n  })\n\n  describe('bracket', () => {\n    let log: Array<string> = []\n\n    const acquireFailure = _.left('acquire failure')\n    const acquireSuccess = _.right({ res: 'acquire success' })\n    const useSuccess = () => _.right('use success')\n    const useFailure = () => _.left('use failure')\n    const releaseSuccess = () =>\n      _.rightIO(() => {\n        log.push('release success')\n      })\n    const releaseFailure = () => _.left('release failure')\n\n    beforeEach(() => {\n      log = []\n    })\n\n    it('should return the acquire error if acquire fails', () => {\n      const e = _.bracket(acquireFailure, useSuccess, releaseSuccess)()\n      U.deepStrictEqual(e, E.left('acquire failure'))\n    })\n\n    it('body and release must not be called if acquire fails', () => {\n      _.bracket(acquireFailure, useSuccess, releaseSuccess)()\n      U.deepStrictEqual(log, [])\n    })\n\n    it('should return the use error if use fails and release does not', () => {\n      const e = _.bracket(acquireSuccess, useFailure, releaseSuccess)()\n      U.deepStrictEqual(e, E.left('use failure'))\n    })\n\n    it('should return the release error if both use and release fail', () => {\n      const e = _.bracket(acquireSuccess, useFailure, releaseFailure)()\n      U.deepStrictEqual(e, E.left('release failure'))\n    })\n\n    it('release must be called if the body returns', () => {\n      _.bracket(acquireSuccess, useSuccess, releaseSuccess)()\n      U.deepStrictEqual(log, ['release success'])\n    })\n\n    it('release must be called if the body throws', () => {\n      _.bracket(acquireSuccess, useFailure, releaseSuccess)()\n      U.deepStrictEqual(log, ['release success'])\n    })\n\n    it('should return the release error if release fails', () => {\n      const e = _.bracket(acquireSuccess, useSuccess, releaseFailure)()\n      U.deepStrictEqual(e, E.left('release failure'))\n    })\n  })\n\n  it('bracketW', async () => {\n    const res = _.bracketW(\n      _.right<string, string>('string'),\n      (_a: string) => _.right<number, string>('test'),\n      (_a: string, _e: E.Either<number, string>) => _.right<Error, void>(constVoid())\n    )()\n    U.deepStrictEqual(res, E.right('test'))\n  })\n\n  it('getApplicativeIOValidation', () => {\n    const A = _.getApplicativeIOValidation(S.Monoid)\n    U.deepStrictEqual(sequenceT(A)(_.left('a'), _.left('b'))(), E.left('ab'))\n    U.deepStrictEqual(sequenceT(A)(_.left('a'), _.right(1))(), E.left('a'))\n    const AV = _.getIOValidation(S.Monoid)\n    U.deepStrictEqual(sequenceT(AV)(_.left('a'), _.left('b'))(), E.left('ab'))\n  })\n\n  it('getAltIOValidation', () => {\n    const A = _.getAltIOValidation(S.Monoid)\n    U.deepStrictEqual(A.alt(_.left('a'), () => _.left('b'))(), E.left('ab'))\n    const AV = _.getIOValidation(S.Monoid)\n    U.deepStrictEqual(AV.alt(_.left('a'), () => _.left('b'))(), E.left('ab'))\n  })\n\n  describe('getCompactable', () => {\n    const C = _.getCompactable(S.Monoid)\n\n    it('compact', () => {\n      U.deepStrictEqual(C.compact(_.right(O.some(1)))(), E.right(1))\n    })\n\n    it('separate', () => {\n      const s1 = C.separate(_.left('a'))\n      U.deepStrictEqual(left(s1)(), E.left('a'))\n      U.deepStrictEqual(right(s1)(), E.left('a'))\n      const s2 = C.separate(_.right(E.left('a')))\n      U.deepStrictEqual(left(s2)(), E.right('a'))\n      U.deepStrictEqual(right(s2)(), E.left(''))\n      const s3 = C.separate(_.right(E.right(1)))\n      U.deepStrictEqual(left(s3)(), E.left(''))\n      U.deepStrictEqual(right(s3)(), E.right(1))\n    })\n  })\n\n  describe('getFilterable', () => {\n    const F_ = _.getFilterable(RA.getMonoid<string>())\n    const { filter, filterMap, partition, partitionMap } = pipeable(F_)\n\n    it('filter', async () => {\n      const r1 = pipe(\n        _.right(1),\n        filter((n) => n > 0)\n      )\n      U.deepStrictEqual(r1(), _.right(1)())\n      const r2 = pipe(\n        _.right(-1),\n        filter((n) => n > 0)\n      )\n      U.deepStrictEqual(r2(), _.left([])())\n      const r3 = pipe(\n        _.left(['a']),\n        filter((n) => n > 0)\n      )\n      U.deepStrictEqual(r3(), _.left(['a'])())\n    })\n\n    it('filterMap', () => {\n      U.deepStrictEqual(\n        pipe(\n          _.right('aaa'),\n          filterMap((s) => (s.length > 1 ? O.some(s.length) : O.none))\n        )(),\n        E.right(3)\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.right('a'),\n          filterMap((s) => (s.length > 1 ? O.some(s.length) : O.none))\n        )(),\n        E.left([])\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.left<ReadonlyArray<string>, string>(['e']),\n          filterMap((s) => (s.length > 1 ? O.some(s.length) : O.none))\n        )(),\n        E.left(['e'])\n      )\n    })\n\n    it('partition', () => {\n      const s = pipe(\n        _.right('a'),\n        partition((s) => s.length > 2)\n      )\n      U.deepStrictEqual(left(s)(), E.right('a'))\n      U.deepStrictEqual(right(s)(), E.left([]))\n    })\n\n    it('partitionMap', () => {\n      const s = pipe(\n        _.right('a'),\n        partitionMap((s) => (s.length > 2 ? E.right(s.length) : E.left(false)))\n      )\n      U.deepStrictEqual(left(s)(), E.right(false))\n      U.deepStrictEqual(right(s)(), E.left([]))\n    })\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.right<string, number>(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.right('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )(),\n      E.right({ a: 1, b: 'b', c: [1, 'b'] })\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(\n      pipe(_.right<string, number>(1), _.bindTo('a'), _.apS('b', _.right('b')))(),\n      E.right({ a: 1, b: 'b' })\n    )\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.right(a + i) : _.left('e')))\n      U.deepStrictEqual(pipe(RA.empty, f)(), E.right(RA.empty))\n      U.deepStrictEqual(pipe(input, f)(), E.right(['a0', 'b1']))\n      U.deepStrictEqual(pipe(['a', ''], f)(), E.left('e'))\n    })\n\n    it('sequenceReadonlyArray', () => {\n      U.deepStrictEqual(pipe(RA.empty, _.traverseReadonlyArrayWithIndex(SK))(), E.right(RA.empty))\n\n      const log: Array<number | string> = []\n      const right = (n: number): _.IOEither<string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.IOEither<string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(pipe([right(1), right(2)], _.traverseReadonlyArrayWithIndex(SK))(), E.right([1, 2]))\n      U.deepStrictEqual(pipe([right(3), left('a')], _.traverseReadonlyArrayWithIndex(SK))(), E.left('a'))\n      U.deepStrictEqual(pipe([left('b'), right(4)], _.traverseReadonlyArrayWithIndex(SK))(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n    })\n\n    it('sequenceReadonlyArraySeq', () => {\n      U.deepStrictEqual(pipe(RA.empty, _.traverseReadonlyArrayWithIndexSeq(SK))(), E.right(RA.empty))\n\n      const log: Array<number | string> = []\n      const right = (n: number): _.IOEither<string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.IOEither<string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(pipe([right(1), right(2)], _.traverseReadonlyArrayWithIndexSeq(SK))(), E.right([1, 2]))\n      U.deepStrictEqual(pipe([right(3), left('a')], _.traverseReadonlyArrayWithIndexSeq(SK))(), E.left('a'))\n      U.deepStrictEqual(pipe([left('b'), right(4)], _.traverseReadonlyArrayWithIndexSeq(SK))(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n\n    // old\n    it('sequenceArray', () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.IOEither<string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.IOEither<string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(pipe([right(1), right(2)], _.sequenceArray)(), E.right([1, 2]))\n      U.deepStrictEqual(pipe([right(3), left('a')], _.sequenceArray)(), E.left('a'))\n      U.deepStrictEqual(pipe([left('b'), right(4)], _.sequenceArray)(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n    })\n\n    it('sequenceSeqArray', () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.IOEither<string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.IOEither<string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(pipe([right(1), right(2)], _.sequenceSeqArray)(), E.right([1, 2]))\n      U.deepStrictEqual(pipe([right(3), left('a')], _.sequenceSeqArray)(), E.left('a'))\n      U.deepStrictEqual(pipe([left('b'), right(4)], _.sequenceSeqArray)(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n  })\n\n  it('tryCatchK', () => {\n    const f = (n: number) => {\n      if (n > 0) {\n        return n * 2\n      }\n      throw new Error('negative')\n    }\n    const g = _.tryCatchK(f, identity)\n    U.deepStrictEqual(g(1)(), E.right(2))\n    U.deepStrictEqual(g(-1)(), E.left(new Error('negative')))\n  })\n\n  it('toUnion', () => {\n    U.deepStrictEqual(_.toUnion(_.right(1))(), 1)\n    U.deepStrictEqual(_.toUnion(_.left('a'))(), 'a')\n  })\n\n  // -------------------------------------------------------------------------------------\n  // destructors\n  // -------------------------------------------------------------------------------------\n\n  it('match', () => {\n    const f = _.match(\n      () => 'left',\n      () => 'right'\n    )\n    U.deepStrictEqual(f(_.right(1))(), 'right')\n    U.deepStrictEqual(f(_.left(1))(), 'left')\n  })\n\n  it('matchE', () => {\n    const f = _.matchE(\n      () => I.of('left'),\n      () => I.of('right')\n    )\n    U.deepStrictEqual(f(_.right(1))(), 'right')\n    U.deepStrictEqual(f(_.left(1))(), 'left')\n  })\n\n  it('tapEither', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(pipe(_.right('a'), _.tapEither(f))(), E.right('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(pipe(_.right('a'), _.tapEither(g))(), E.left(1))\n  })\n\n  it('chainFirstEitherK', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(pipe(_.right('a'), _.chainFirstEitherK(f))(), E.right('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(pipe(_.right('a'), _.chainFirstEitherK(g))(), E.left(1))\n  })\n\n  it('tapIO', () => {\n    const ref: Array<number> = []\n    const add = (value: number) => () => ref.push(value)\n\n    U.deepStrictEqual(pipe(_.of(1), _.tapIO(add))(), E.of(1))\n    U.deepStrictEqual(pipe(_.left('error'), _.tapIO(add))(), E.left('error'))\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('as', () => {\n    U.deepStrictEqual(pipe(_.right('a'), _.as('b'))(), E.right('b'))\n    U.deepStrictEqual(_.as(_.of('a'), 'b')(), E.right('b'))\n    U.deepStrictEqual(_.as(_.left('error'), 'b')(), E.left('error'))\n  })\n\n  it('asUnit', () => {\n    U.deepStrictEqual(pipe(_.of('a'), _.asUnit)(), E.of(undefined))\n  })\n\n  it('flatMapIO', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.flatMapIO(() => I.of(2))\n      )(),\n      E.of(2)\n    )\n  })\n})\n"
  },
  {
    "path": "test/IOOption.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe, SK } from '../src/function'\nimport * as I from '../src/IO'\nimport * as IE from '../src/IOEither'\nimport * as _ from '../src/IOOption'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport * as U from './util'\n\ndescribe('IOOption', () => {\n  // -------------------------------------------------------------------------------------\n  // type class members\n  // -------------------------------------------------------------------------------------\n\n  it('map', () => {\n    U.deepStrictEqual(pipe(_.some(1), _.map(U.double))(), O.some(2))\n  })\n\n  it('ap', () => {\n    U.deepStrictEqual(pipe(_.some(U.double), _.ap(_.some(2)))(), O.some(4))\n    U.deepStrictEqual(pipe(_.some(U.double), _.ap(_.none))(), O.none)\n    U.deepStrictEqual(pipe(_.none, _.ap(_.some(2)))(), O.none)\n    U.deepStrictEqual(pipe(_.none, _.ap(_.none))(), O.none)\n  })\n\n  it('flatMap', () => {\n    const f = (n: number) => _.some(n * 2)\n    const g = () => _.none\n    U.deepStrictEqual(pipe(_.some(1), _.flatMap(f))(), O.some(2))\n    U.deepStrictEqual(pipe(_.none, _.flatMap(f))(), O.none)\n    U.deepStrictEqual(pipe(_.some(1), _.flatMap(g))(), O.none)\n    U.deepStrictEqual(pipe(_.none, _.flatMap(g))(), O.none)\n\n    U.deepStrictEqual(_.flatMap(_.some(1), f)(), O.some(2))\n    U.deepStrictEqual(_.flatMap(_.none, f)(), O.none)\n    U.deepStrictEqual(_.flatMap(_.some(1), g)(), O.none)\n    U.deepStrictEqual(_.flatMap(_.none, g)(), O.none)\n  })\n\n  it('chain', () => {\n    const f = (n: number) => _.some(n * 2)\n    const g = () => _.none\n    U.deepStrictEqual(pipe(_.some(1), _.chain(f))(), O.some(2))\n    U.deepStrictEqual(pipe(_.none, _.chain(f))(), O.none)\n    U.deepStrictEqual(pipe(_.some(1), _.chain(g))(), O.none)\n    U.deepStrictEqual(pipe(_.none, _.chain(g))(), O.none)\n  })\n\n  it('alt', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.some(1),\n        _.alt(() => _.some(2))\n      )(),\n      O.some(1)\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.some(2),\n        _.alt(() => _.none as _.IOOption<number>)\n      )(),\n      O.some(2)\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.none,\n        _.alt(() => _.some(1))\n      )(),\n      O.some(1)\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.none,\n        _.alt(() => _.none)\n      )(),\n      O.none\n    )\n  })\n\n  it('zero', () => {\n    U.deepStrictEqual(_.zero()(), O.none)\n  })\n\n  it('fromIO', () => {\n    U.deepStrictEqual(_.fromIO(() => 1)(), O.some(1))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // constructors\n  // -------------------------------------------------------------------------------------\n\n  it('fromNullable', () => {\n    U.deepStrictEqual(_.fromNullable(1)(), O.some(1))\n    U.deepStrictEqual(_.fromNullable(null)(), O.none)\n    U.deepStrictEqual(_.fromNullable(undefined)(), O.none)\n  })\n\n  it('fromNullableK', () => {\n    const f = _.fromNullableK((n: number) => (n > 0 ? n : n === 0 ? null : undefined))\n    U.deepStrictEqual(f(1)(), O.some(1))\n    U.deepStrictEqual(f(0)(), O.none)\n    U.deepStrictEqual(f(-1)(), O.none)\n  })\n\n  it('chainNullableK', () => {\n    const f = _.chainNullableK((n: number) => (n > 0 ? n : n === 0 ? null : undefined))\n    U.deepStrictEqual(f(_.of(1))(), O.some(1))\n    U.deepStrictEqual(f(_.of(0))(), O.none)\n    U.deepStrictEqual(f(_.of(-1))(), O.none)\n  })\n\n  it('fromPredicate', () => {\n    const p = (n: number): boolean => n > 2\n    const f = _.fromPredicate(p)\n    U.deepStrictEqual(f(1)(), O.none)\n    U.deepStrictEqual(f(3)(), O.some(3))\n  })\n\n  it('fromIOEither', () => {\n    const pl = IE.left('a')\n    const pr = IE.right('a')\n    const fl = _.fromIOEither(pl)\n    const fr = _.fromIOEither(pr)\n    U.deepStrictEqual(fl(), O.none)\n    U.deepStrictEqual(fr(), O.some('a'))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // destructors\n  // -------------------------------------------------------------------------------------\n\n  it('getOrElse', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.some(1),\n        _.getOrElse(() => I.of(2))\n      )(),\n      1\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.none,\n        _.getOrElse(() => I.of(2))\n      )(),\n      2\n    )\n  })\n\n  // -------------------------------------------------------------------------------------\n  // combinators\n  // -------------------------------------------------------------------------------------\n\n  it('fromOptionK', () => {\n    const f = _.fromOptionK((n: number) => (n > 0 ? O.some(n) : O.none))\n    U.deepStrictEqual(f(1)(), O.some(1))\n    U.deepStrictEqual(f(-1)(), O.none)\n  })\n\n  it('chainOptionK', () => {\n    const f = _.chainOptionK((n: number) => (n > 0 ? O.some(n) : O.none))\n    U.deepStrictEqual(f(_.some(1))(), O.some(1))\n    U.deepStrictEqual(f(_.some(-1))(), O.none)\n    U.deepStrictEqual(f(_.none)(), O.none)\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.some(a + i) : _.none))\n      U.deepStrictEqual(pipe(RA.empty, f)(), O.some(RA.empty))\n      U.deepStrictEqual(pipe(input, f)(), O.some(['a0', 'b1']))\n      U.deepStrictEqual(pipe(['a', ''], f)(), O.none)\n    })\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.some(a + i) : _.none))\n      U.deepStrictEqual(pipe(RA.empty, f)(), O.some(RA.empty))\n      U.deepStrictEqual(pipe(input, f)(), O.some(['a0', 'b1']))\n      U.deepStrictEqual(pipe(['a', ''], f)(), O.none)\n    })\n\n    it('sequenceReadonlyArray', () => {\n      const log: Array<number | string> = []\n      const some = (n: number): _.IOOption<number> =>\n        _.fromIO(() => {\n          log.push(n)\n          return n\n        })\n      const none = (s: string): _.IOOption<number> =>\n        pipe(\n          () => {\n            log.push(s)\n            return s\n          },\n          I.map(() => O.none)\n        )\n      U.deepStrictEqual(pipe([some(1), some(2)], _.traverseReadonlyArrayWithIndex(SK))(), O.some([1, 2]))\n      U.deepStrictEqual(pipe([some(3), none('a')], _.traverseReadonlyArrayWithIndex(SK))(), O.none)\n      U.deepStrictEqual(pipe([none('b'), some(4)], _.traverseReadonlyArrayWithIndex(SK))(), O.none)\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n    })\n  })\n\n  it('match', () => {\n    const f = _.match(\n      () => 'none',\n      (a) => `some(${a})`\n    )\n    U.deepStrictEqual(pipe(_.some(1), f)(), 'some(1)')\n    U.deepStrictEqual(pipe(_.none, f)(), 'none')\n  })\n\n  it('matchE', () => {\n    const f = _.matchE(\n      () => I.of('none'),\n      (a) => I.of(`some(${a})`)\n    )\n    U.deepStrictEqual(pipe(_.some(1), f)(), 'some(1)')\n    U.deepStrictEqual(pipe(_.none, f)(), 'none')\n  })\n\n  it('fromEitherK', () => {\n    const f = (s: string) => (s.length <= 2 ? E.right(s + '!') : E.left(s.length))\n    const g = _.fromEitherK(f)\n    U.deepStrictEqual(g('')(), O.some('!'))\n    U.deepStrictEqual(g('a')(), O.some('a!'))\n    U.deepStrictEqual(g('aa')(), O.some('aa!'))\n    U.deepStrictEqual(g('aaa')(), O.none)\n  })\n\n  it('chainEitherK', () => {\n    const f = (s: string) => (s.length <= 2 ? E.right(s + '!') : E.left(s.length))\n    const g = _.chainEitherK(f)\n    U.deepStrictEqual(g(_.of(''))(), O.some('!'))\n    U.deepStrictEqual(g(_.of('a'))(), O.some('a!'))\n    U.deepStrictEqual(g(_.of('aa'))(), O.some('aa!'))\n    U.deepStrictEqual(g(_.of('aaa'))(), O.none)\n  })\n\n  it('tapEither', () => {\n    const f = (s: string) => (s.length <= 2 ? E.right(s + '!') : E.left(s.length))\n    const g = _.tapEither(f)\n    U.deepStrictEqual(g(_.of(''))(), O.some(''))\n    U.deepStrictEqual(g(_.of('a'))(), O.some('a'))\n    U.deepStrictEqual(g(_.of('aa'))(), O.some('aa'))\n    U.deepStrictEqual(g(_.of('aaa'))(), O.none)\n  })\n\n  it('chainFirstEitherK', () => {\n    const f = (s: string) => (s.length <= 2 ? E.right(s + '!') : E.left(s.length))\n    const g = _.chainFirstEitherK(f)\n    U.deepStrictEqual(g(_.of(''))(), O.some(''))\n    U.deepStrictEqual(g(_.of('a'))(), O.some('a'))\n    U.deepStrictEqual(g(_.of('aa'))(), O.some('aa'))\n    U.deepStrictEqual(g(_.of('aaa'))(), O.none)\n  })\n\n  it('tapIO', () => {\n    const ref: Array<number> = []\n    const add = (value: number) => () => ref.push(value)\n\n    U.deepStrictEqual(pipe(_.of(1), _.tapIO(add))(), O.of(1))\n    U.deepStrictEqual(pipe(_.none, _.tapIO(add))(), O.none)\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('as', () => {\n    U.deepStrictEqual(pipe(_.some('a'), _.as('b'))(), O.some('b'))\n    U.deepStrictEqual(_.as(_.of('a'), 'b')(), O.some('b'))\n    U.deepStrictEqual(_.as(_.none, 'b')(), O.none)\n  })\n\n  it('asUnit', () => {\n    U.deepStrictEqual(pipe(_.some('a'), _.asUnit)(), O.some(undefined))\n  })\n\n  it('flatMapIO', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.flatMapIO(() => I.of(2))\n      )(),\n      O.of(2)\n    )\n  })\n\n  it('flatMapOption', () => {\n    const f = _.flatMapOption((n: number) => (n > 0 ? O.some(n) : O.none))\n    U.deepStrictEqual(f(_.some(1))(), O.some(1))\n    U.deepStrictEqual(f(_.some(-1))(), O.none)\n    U.deepStrictEqual(f(_.none)(), O.none)\n  })\n\n  it('flatMapNullable', () => {\n    const f = _.flatMapNullable((n: number) => (n > 0 ? n : n === 0 ? null : undefined))\n    U.deepStrictEqual(f(_.of(1))(), O.some(1))\n    U.deepStrictEqual(f(_.of(0))(), O.none)\n    U.deepStrictEqual(f(_.of(-1))(), O.none)\n  })\n\n  it('flatMapEither', () => {\n    const f = (s: string) => (s.length <= 2 ? E.right(s + '!') : E.left(s.length))\n    const g = _.flatMapEither(f)\n    U.deepStrictEqual(g(_.of(''))(), O.some('!'))\n    U.deepStrictEqual(g(_.of('a'))(), O.some('a!'))\n    U.deepStrictEqual(g(_.of('aa'))(), O.some('aa!'))\n    U.deepStrictEqual(g(_.of('aaa'))(), O.none)\n  })\n})\n"
  },
  {
    "path": "test/IORef.ts",
    "content": "import { pipe } from '../src/function'\nimport * as I from '../src/IO'\nimport { IORef, newIORef } from '../src/IORef'\nimport * as U from './util'\n\ndescribe('IORef', () => {\n  it('read', () => {\n    const ref = new IORef(1)\n    U.deepStrictEqual(ref.read(), 1)\n  })\n\n  it('write', () => {\n    const ref = new IORef(1)\n    U.deepStrictEqual(\n      pipe(\n        ref.write(2),\n        I.chain(() => ref.read)\n      )(),\n      2\n    )\n  })\n\n  it('modify', () => {\n    const ref = new IORef(1)\n    U.deepStrictEqual(\n      pipe(\n        ref.modify(U.double),\n        I.chain(() => ref.read)\n      )(),\n      2\n    )\n  })\n\n  it('newIORef', () => {\n    U.deepStrictEqual(\n      pipe(\n        newIORef(1),\n        I.chain((ref) => ref.read)\n      )(),\n      1\n    )\n  })\n\n  it('pipe', () => {\n    const ref = new IORef(1)\n    pipe(2, ref.write)()\n    U.deepStrictEqual(ref.read(), 2)\n    pipe(() => 3, ref.modify)()\n    U.deepStrictEqual(ref.read(), 3)\n  })\n})\n"
  },
  {
    "path": "test/Identity.ts",
    "content": "import { left, right } from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as _ from '../src/Identity'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('Identity', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      U.deepStrictEqual(pipe(1, _.map(U.double)), 2)\n    })\n\n    it('ap', () => {\n      const fab = U.double\n      U.deepStrictEqual(pipe(fab, _.ap(1)), 2)\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe('a', _.apFirst('b')), 'a')\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe('a', _.apSecond('b')), 'b')\n    })\n\n    it('flatMap', () => {\n      const f = (n: number) => n * 2\n      U.deepStrictEqual(pipe(1, _.flatMap(f)), 2)\n      U.deepStrictEqual(_.flatMap(1, f), 2)\n    })\n\n    it('chain', () => {\n      const f = (n: number) => n * 2\n      U.deepStrictEqual(pipe(1, _.chain(f)), 2)\n    })\n\n    it('tap', () => {\n      const f = (n: number) => n * 2\n      U.deepStrictEqual(pipe(1, _.tap(f)), 1)\n    })\n\n    it('chainFirst', () => {\n      const f = (n: number) => n * 2\n      U.deepStrictEqual(pipe(1, _.chainFirst(f)), 1)\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          'b',\n          _.reduce('a', (b, a) => b + a)\n        ),\n        'ab'\n      )\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe('a', _.foldMap(S.Monoid)(identity)), 'a')\n    })\n\n    it('reduceRight', () => {\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(pipe('a', _.reduceRight('', f)), 'a')\n    })\n\n    it('alt', () => {\n      U.deepStrictEqual(\n        pipe(\n          1,\n          _.alt(() => 2)\n        ),\n        1\n      )\n    })\n\n    it('extract', () => {\n      U.deepStrictEqual(pipe(1, _.extract), 1)\n    })\n\n    it('extend', () => {\n      const f = (fa: _.Identity<string>): number => fa.length\n      U.deepStrictEqual(pipe('foo', _.extend(f)), 3)\n    })\n\n    it('duplicate', () => {\n      U.deepStrictEqual(pipe('a', _.duplicate), 'a')\n    })\n\n    it('flatten', () => {\n      U.deepStrictEqual(pipe('a', _.flatten), 'a')\n    })\n\n    it('traverse', () => {\n      const traverse = _.traverse(O.Applicative)\n      U.deepStrictEqual(pipe(1, traverse(O.some)), O.some(1))\n      U.deepStrictEqual(\n        pipe(\n          1,\n          traverse(() => O.none)\n        ),\n        O.none\n      )\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      U.deepStrictEqual(sequence(O.some('a')), O.some('a'))\n      U.deepStrictEqual(sequence(O.none), O.none)\n    })\n  })\n\n  it('getEq', () => {\n    const S = _.getEq(N.Eq)\n    U.deepStrictEqual(S.equals(1, 1), true)\n    U.deepStrictEqual(S.equals(1, 2), false)\n    U.deepStrictEqual(S.equals(2, 1), false)\n  })\n\n  it('ChainRec', () => {\n    const x = _.ChainRec.chainRec<number, number>(0, (a) => (a < 10 ? left(a + 1) : right(a)))\n    const expected = 10\n    U.deepStrictEqual(x, expected)\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    U.deepStrictEqual(Sh.show('a'), `\"a\"`)\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      ),\n      { a: 1, b: 'b', c: [1, 'b'] }\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b'))), { a: 1, b: 'b' })\n  })\n})\n"
  },
  {
    "path": "test/Json.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as _ from '../src/Json'\nimport * as U from './util'\n\ndescribe('Json', () => {\n  it('parse', () => {\n    U.deepStrictEqual(pipe('{\"a\":1}', _.parse), E.right({ a: 1 }))\n    U.deepStrictEqual(\n      pipe('{\"a\":}', _.parse),\n      E.left(new SyntaxError(`Unexpected token '}', \"{\"a\":}\" is not valid JSON`))\n    )\n  })\n\n  it('stringify', () => {\n    U.deepStrictEqual(pipe({ a: 1 }, _.stringify), E.right('{\"a\":1}'))\n    const circular: any = { ref: null }\n    circular.ref = circular\n    U.deepStrictEqual(\n      pipe(\n        circular,\n        _.stringify,\n        E.mapLeft((e) => (e as Error).message.includes('Converting circular structure to JSON'))\n      ),\n      E.left(true)\n    )\n    type Person = {\n      readonly name: string\n      readonly age: number\n    }\n    const person: Person = { name: 'Giulio', age: 45 }\n    U.deepStrictEqual(pipe(person, _.stringify), E.right('{\"name\":\"Giulio\",\"age\":45}'))\n\n    U.deepStrictEqual(_.stringify(undefined as any), E.left(new Error('Converting unsupported structure to JSON')))\n  })\n})\n"
  },
  {
    "path": "test/Magma.ts",
    "content": "import { increment, pipe } from '../src/function'\nimport * as _ from '../src/Magma'\nimport * as N from '../src/number'\nimport * as U from './util'\n\ndescribe('Magma', () => {\n  it('reverse', () => {\n    const subAll = _.concatAll(_.reverse(N.MagmaSub))(0)\n    U.deepStrictEqual(subAll([1, 2, 3]), 2)\n  })\n\n  it('filterFirst', () => {\n    const M = pipe(\n      N.SemigroupSum,\n      _.filterFirst((n) => n >= 0)\n    )\n    // sum ignoring negative partials\n    const sum = _.concatAll(M)(0)\n    U.deepStrictEqual(sum([1, -2, 3]), 3)\n  })\n\n  it('filterSecond', () => {\n    const M = pipe(\n      N.SemigroupSum,\n      _.filterSecond((n) => n >= 0)\n    )\n    // sum ignoring negative elements\n    const sum = _.concatAll(M)(0)\n    U.deepStrictEqual(sum([1, -2, 3]), 4)\n  })\n\n  it('endo', () => {\n    const M = pipe(N.SemigroupSum, _.endo(increment))\n    const sum = _.concatAll(M)(0)\n    U.deepStrictEqual(sum([1, -2, 3]), 8)\n  })\n\n  it('concatAll', () => {\n    const subAll = _.concatAll(N.MagmaSub)(0)\n    U.deepStrictEqual(subAll([1, 2, 3]), -6)\n  })\n})\n"
  },
  {
    "path": "test/Map.ts",
    "content": "import * as assert from 'assert'\n\nimport { Either, left, right } from '../src/Either'\nimport { Eq, fromEquals } from '../src/Eq'\nimport { identity, pipe } from '../src/function'\nimport * as _ from '../src/Map'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as Ord from '../src/Ord'\nimport * as RA from '../src/ReadonlyArray'\nimport { Refinement } from '../src/Refinement'\nimport * as Se from '../src/Semigroup'\nimport { separated } from '../src/Separated'\nimport { Show, struct } from '../src/Show'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\ninterface User {\n  readonly id: string\n}\n\nconst ordUser = pipe(\n  S.Ord,\n  Ord.contramap((u: User) => u.id)\n)\n\nconst eqUser: Eq<User> = { equals: ordUser.equals }\n\nconst p = ((n: number): boolean => n > 2) as Refinement<number, number>\n\ninterface Key {\n  readonly id: number\n}\n\ninterface Value {\n  readonly value: number\n}\n\nconst eqKey: Eq<Key> = fromEquals((x, y) => x.id % 3 === y.id % 3)\n\nconst ordKey = Ord.fromCompare<Key>((x, y) => N.Ord.compare(x.id % 3, y.id % 3))\n\nconst eqValue: Eq<Value> = fromEquals((x, y) => x.value % 3 === y.value % 3)\n\nconst semigroupValue = Se.struct({ value: N.SemigroupSum })\n\nconst key1 = { id: 1 }\nconst value1 = { value: 1 }\nconst repo = new Map<Key, Value>([\n  [key1, value1],\n  [{ id: 2 }, { value: 2 }]\n])\n\ndescribe('Map', () => {\n  it('URI', () => {\n    U.deepStrictEqual(_.URI, 'Map')\n  })\n\n  it('size', () => {\n    const emptyMap = new Map<string, number>()\n    const a1 = new Map<string, number>([['a', 1]])\n    U.deepStrictEqual(_.size(emptyMap), 0)\n    U.deepStrictEqual(_.size(a1), 1)\n\n    U.deepStrictEqual(_.size(new Map()), 0)\n    U.deepStrictEqual(_.size(new Map([['a', 1]])), 1)\n  })\n\n  it('isEmpty', () => {\n    const emptyMap = new Map<string, number>()\n    const a1 = new Map<string, number>([['a', 1]])\n    U.deepStrictEqual(_.isEmpty(emptyMap), true)\n    U.deepStrictEqual(_.isEmpty(a1), false)\n\n    U.deepStrictEqual(_.isEmpty(new Map()), true)\n    U.deepStrictEqual(_.isEmpty(new Map([['a', 1]])), false)\n  })\n\n  it('member', () => {\n    const x = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const memberS = _.member(eqUser)\n    U.deepStrictEqual(memberS({ id: 'a' }, x), true)\n    U.deepStrictEqual(memberS({ id: 'c' }, x), false)\n    U.deepStrictEqual(memberS({ id: 'a' })(x), true)\n    U.deepStrictEqual(memberS({ id: 'c' })(x), false)\n\n    const member = _.member(eqKey)\n    U.deepStrictEqual(member({ id: 1 }, repo), true)\n    U.deepStrictEqual(member({ id: 2 }, repo), true)\n    U.deepStrictEqual(member({ id: 4 }, repo), true)\n    U.deepStrictEqual(member({ id: 3 }, repo), false)\n    U.deepStrictEqual(member({ id: 1 })(repo), true)\n    U.deepStrictEqual(member({ id: 2 })(repo), true)\n    U.deepStrictEqual(member({ id: 4 })(repo), true)\n    U.deepStrictEqual(member({ id: 3 })(repo), false)\n  })\n\n  it('elem', () => {\n    const x = new Map<string, number>([\n      ['a', 1],\n      ['b', 2]\n    ])\n    const elemS = _.elem(N.Eq)\n    U.deepStrictEqual(elemS(2, x), true)\n    U.deepStrictEqual(elemS(3, x), false)\n    U.deepStrictEqual(elemS(2)(x), true)\n    U.deepStrictEqual(elemS(3)(x), false)\n\n    const elem = _.elem(eqValue)\n    U.deepStrictEqual(elem({ value: 1 })(repo), true)\n    U.deepStrictEqual(elem({ value: 2 })(repo), true)\n    U.deepStrictEqual(elem({ value: 4 })(repo), true)\n    U.deepStrictEqual(elem({ value: 3 })(repo), false)\n    U.deepStrictEqual(elem({ value: 1 })(repo), true)\n    U.deepStrictEqual(elem({ value: 2 })(repo), true)\n    U.deepStrictEqual(elem({ value: 4 })(repo), true)\n    U.deepStrictEqual(elem({ value: 3 })(repo), false)\n  })\n\n  it('keys', () => {\n    const m = new Map<User, number>([\n      [{ id: 'b' }, 2],\n      [{ id: 'a' }, 1]\n    ])\n    const ks = _.keys(ordUser)(m)\n    U.deepStrictEqual(ks, Array.from(m.keys()).sort(ordUser.compare))\n    U.deepStrictEqual(ks, [{ id: 'a' }, { id: 'b' }])\n\n    U.deepStrictEqual(\n      _.keys(S.Ord)(\n        new Map([\n          ['a', 1],\n          ['b', 2]\n        ])\n      ),\n      ['a', 'b']\n    )\n    U.deepStrictEqual(\n      _.keys(S.Ord)(\n        new Map([\n          ['b', 2],\n          ['a', 1]\n        ])\n      ),\n      ['a', 'b']\n    )\n  })\n\n  it('values', () => {\n    const m = new Map<number, User>([\n      [2, { id: 'b' }],\n      [1, { id: 'a' }]\n    ])\n    const vals = _.values(ordUser)(m)\n    U.deepStrictEqual(vals, Array.from(m.values()).sort(ordUser.compare))\n    U.deepStrictEqual(vals, [{ id: 'a' }, { id: 'b' }])\n  })\n\n  it('collect', () => {\n    const m1 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const m2 = new Map<User, number>([\n      [{ id: 'b' }, 2],\n      [{ id: 'a' }, 1]\n    ])\n    const collectO = _.collect(ordUser)\n    const f = (_k: User, a: number): number => a + 1\n    U.deepStrictEqual(collectO(f)(m1), [2, 3])\n    U.deepStrictEqual(collectO(f)(m2), [2, 3])\n\n    const collect = _.collect(ordKey)\n    const g = (k: Key, a: Value): readonly [number, number] => [k.id, a.value]\n    U.deepStrictEqual(\n      collect(g)(\n        new Map([\n          [{ id: 1 }, { value: 1 }],\n          [{ id: 2 }, { value: 2 }]\n        ])\n      ),\n      [\n        [1, 1],\n        [2, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      collect(g)(\n        new Map([\n          [{ id: 2 }, { value: 2 }],\n          [{ id: 1 }, { value: 1 }]\n        ])\n      ),\n      [\n        [1, 1],\n        [2, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      collect(g)(\n        new Map([\n          [{ id: 4 }, { value: 1 }],\n          [{ id: 2 }, { value: 2 }]\n        ])\n      ),\n      [\n        [4, 1],\n        [2, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      collect(g)(\n        new Map([\n          [{ id: 2 }, { value: 2 }],\n          [{ id: 4 }, { value: 1 }]\n        ])\n      ),\n      [\n        [4, 1],\n        [2, 2]\n      ]\n    )\n  })\n\n  it('toArray', () => {\n    const m1 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const m2 = new Map<User, number>([\n      [{ id: 'b' }, 2],\n      [{ id: 'a' }, 1]\n    ])\n    const toArrayO = _.toArray(ordUser)\n    U.deepStrictEqual(toArrayO(m1), [\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    U.deepStrictEqual(toArrayO(m2), [\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n\n    const toArray = _.toArray(ordKey)\n    U.deepStrictEqual(\n      toArray(\n        new Map([\n          [{ id: 1 }, 1],\n          [{ id: 2 }, 2]\n        ])\n      ),\n      [\n        [{ id: 1 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toArray(\n        new Map([\n          [{ id: 2 }, 2],\n          [{ id: 1 }, 1]\n        ])\n      ),\n      [\n        [{ id: 1 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toArray(\n        new Map([\n          [{ id: 4 }, 1],\n          [{ id: 2 }, 2]\n        ])\n      ),\n      [\n        [{ id: 4 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toArray(\n        new Map([\n          [{ id: 2 }, 2],\n          [{ id: 4 }, 1]\n        ])\n      ),\n      [\n        [{ id: 4 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n  })\n\n  it('toUnfoldable', () => {\n    const a1 = new Map<User, number>([[{ id: 'a' }, 1]])\n    const toUnfoldableO = _.toUnfoldable(ordUser, RA.Unfoldable)\n    U.deepStrictEqual(toUnfoldableO(a1), [[{ id: 'a' }, 1]])\n\n    const toUnfoldable = _.toUnfoldable(ordKey, RA.Unfoldable)\n    U.deepStrictEqual(\n      toUnfoldable(\n        new Map([\n          [{ id: 1 }, 1],\n          [{ id: 2 }, 2]\n        ])\n      ),\n      [\n        [{ id: 1 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toUnfoldable(\n        new Map([\n          [{ id: 2 }, 2],\n          [{ id: 1 }, 1]\n        ])\n      ),\n      [\n        [{ id: 1 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toUnfoldable(\n        new Map([\n          [{ id: 4 }, 1],\n          [{ id: 2 }, 2]\n        ])\n      ),\n      [\n        [{ id: 4 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toUnfoldable(\n        new Map([\n          [{ id: 2 }, 2],\n          [{ id: 4 }, 1]\n        ])\n      ),\n      [\n        [{ id: 4 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n  })\n\n  it('insertAt', () => {\n    const emptyMap = new Map<User, number>()\n    const a1 = new Map<User, number>([[{ id: 'a' }, 1]])\n    const a1b2 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const a2b2 = new Map<User, number>([\n      [{ id: 'a' }, 2],\n      [{ id: 'b' }, 2]\n    ])\n    const a1b2c3 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2],\n      [{ id: 'c' }, 3]\n    ])\n    const insertS = _.insertAt(eqUser)\n    U.deepStrictEqual(insertS({ id: 'a' }, 1)(emptyMap), a1)\n    U.deepStrictEqual(insertS({ id: 'a' }, 1)(a1b2), a1b2)\n    U.deepStrictEqual(insertS({ id: 'a' }, 2)(a1b2), a2b2)\n    U.deepStrictEqual(insertS({ id: 'c' }, 3)(a1b2), a1b2c3)\n\n    const insert = _.insertAt(eqKey)\n    U.deepStrictEqual(insert({ id: 1 }, { value: 1 })(new Map()), new Map([[{ id: 1 }, { value: 1 }]]))\n    const x = insert({ id: 1 }, value1)(repo)\n    U.deepStrictEqual(\n      x,\n      new Map<Key, Value>([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n    U.deepStrictEqual(x.get(key1), value1)\n    U.deepStrictEqual(\n      insert({ id: 1 }, { value: 2 })(repo),\n      new Map<Key, Value>([\n        [{ id: 1 }, { value: 2 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n    U.deepStrictEqual(\n      insert({ id: 4 }, { value: 2 })(repo),\n      new Map<Key, Value>([\n        [{ id: 1 }, { value: 2 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n    U.deepStrictEqual(\n      insert({ id: 3 }, { value: 3 })(repo),\n      new Map<Key, Value>([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }],\n        [{ id: 3 }, { value: 3 }]\n      ])\n    )\n    // should not modify the source\n    U.deepStrictEqual(\n      repo,\n      new Map([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n  })\n\n  it('deleteAt', () => {\n    const a1b2 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const a1b2_ = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const b2 = new Map<User, number>([[{ id: 'b' }, 2]])\n    const removeS = _.deleteAt(eqUser)\n    U.deepStrictEqual(removeS({ id: 'a' })(a1b2), b2)\n    U.deepStrictEqual(a1b2, a1b2_)\n    U.deepStrictEqual(removeS({ id: 'c' })(a1b2), a1b2)\n\n    const remove = _.deleteAt(eqKey)\n    U.deepStrictEqual(remove({ id: 1 })(repo), new Map([[{ id: 2 }, { value: 2 }]]))\n    U.deepStrictEqual(remove({ id: 4 })(repo), new Map([[{ id: 2 }, { value: 2 }]]))\n    U.deepStrictEqual(remove({ id: 3 })(repo), repo)\n    // should not modify the source\n    U.deepStrictEqual(\n      repo,\n      new Map([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n  })\n\n  it('pop', () => {\n    const a1b2 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const b2 = new Map<User, number>([[{ id: 'b' }, 2]])\n    const popS = _.pop(eqUser)\n    U.deepStrictEqual(popS({ id: 'a' })(a1b2), O.some([1, b2]))\n    U.deepStrictEqual(popS({ id: 'c' })(a1b2), O.none)\n\n    const pop = _.pop(eqKey)\n    U.deepStrictEqual(pop({ id: 1 })(repo), O.some([{ value: 1 }, new Map([[{ id: 2 }, { value: 2 }]])]))\n    U.deepStrictEqual(pop({ id: 4 })(repo), O.some([{ value: 1 }, new Map([[{ id: 2 }, { value: 2 }]])]))\n    U.deepStrictEqual(pop({ id: 3 })(repo), O.none)\n    // should not modify the source\n    U.deepStrictEqual(\n      repo,\n      new Map([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n  })\n\n  it('lookupWithKey', () => {\n    const x = new Map<User, number>([[{ id: 'a' }, 1]])\n    const lookupWithKeyS = _.lookupWithKey(eqUser)\n    U.deepStrictEqual(lookupWithKeyS({ id: 'a' }, x), O.some([{ id: 'a' }, 1]))\n    U.deepStrictEqual(lookupWithKeyS({ id: 'b' }, x), O.none)\n    U.deepStrictEqual(lookupWithKeyS({ id: 'a' })(x), O.some([{ id: 'a' }, 1]))\n    U.deepStrictEqual(lookupWithKeyS({ id: 'b' })(x), O.none)\n\n    const lookupWithKey = _.lookupWithKey(eqKey)\n    assert.deepStrictEqual(lookupWithKey({ id: 1 }, repo), O.some([{ id: 1 }, { value: 1 }]))\n    assert.deepStrictEqual(lookupWithKey({ id: 4 }, repo), O.some([{ id: 1 }, { value: 1 }]))\n    U.deepStrictEqual(lookupWithKey({ id: 3 }, repo), O.none)\n    assert.deepStrictEqual(lookupWithKey({ id: 1 })(repo), O.some([{ id: 1 }, { value: 1 }]))\n    assert.deepStrictEqual(lookupWithKey({ id: 4 })(repo), O.some([{ id: 1 }, { value: 1 }]))\n    U.deepStrictEqual(lookupWithKey({ id: 3 })(repo), O.none)\n  })\n\n  it('lookup', () => {\n    const x = new Map<User, number>([[{ id: 'a' }, 1]])\n    const lookupS = _.lookup(eqUser)\n    U.deepStrictEqual(lookupS({ id: 'a' }, x), O.some(1))\n    U.deepStrictEqual(lookupS({ id: 'b' }, x), O.none)\n    U.deepStrictEqual(lookupS({ id: 'a' })(x), O.some(1))\n    U.deepStrictEqual(lookupS({ id: 'b' })(x), O.none)\n\n    const lookup = _.lookup(eqKey)\n    U.deepStrictEqual(lookup({ id: 1 }, repo), O.some({ value: 1 }))\n    U.deepStrictEqual(lookup({ id: 4 }, repo), O.some({ value: 1 }))\n    U.deepStrictEqual(lookup({ id: 3 }, repo), O.none)\n    U.deepStrictEqual(lookup({ id: 1 })(repo), O.some({ value: 1 }))\n    U.deepStrictEqual(lookup({ id: 4 })(repo), O.some({ value: 1 }))\n    U.deepStrictEqual(lookup({ id: 3 })(repo), O.none)\n  })\n\n  it('isSubmap', () => {\n    const me = new Map<User, number>([[{ id: 'a' }, 1]])\n    const that = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const isSubmapS = _.isSubmap(eqUser, N.Eq)\n    U.deepStrictEqual(isSubmapS(me, that), true)\n    U.deepStrictEqual(isSubmapS(that)(me), true)\n\n    const isSubmap = _.isSubmap(eqKey, eqValue)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 1 }, { value: 1 }]]), repo), true)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 1 }, { value: 2 }]]), repo), false)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 1 }, { value: 4 }]]), repo), true)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 4 }, { value: 1 }]]), repo), true)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 3 }, { value: 3 }]]), repo), false)\n\n    U.deepStrictEqual(pipe(new Map([[{ id: 1 }, { value: 1 }]]), isSubmap(repo)), true)\n    U.deepStrictEqual(pipe(new Map([[{ id: 1 }, { value: 2 }]]), isSubmap(repo)), false)\n    U.deepStrictEqual(pipe(new Map([[{ id: 1 }, { value: 4 }]]), isSubmap(repo)), true)\n    U.deepStrictEqual(pipe(new Map([[{ id: 4 }, { value: 1 }]]), isSubmap(repo)), true)\n    U.deepStrictEqual(pipe(new Map([[{ id: 3 }, { value: 3 }]]), isSubmap(repo)), false)\n  })\n\n  it('singleton', () => {\n    U.deepStrictEqual(_.singleton('k1', 0), new Map<string, number>([['k1', 0]]))\n  })\n\n  it('getEq', () => {\n    const a1 = new Map<User, number>([[{ id: 'a' }, 1]])\n    const a1_ = new Map<User, number>([[{ id: 'a' }, 1]])\n    const a2 = new Map<User, number>([[{ id: 'a' }, 2]])\n    const b1 = new Map<User, number>([[{ id: 'b' }, 1]])\n    const S = _.getEq(eqUser, N.Eq)\n    U.deepStrictEqual(S.equals(a1, a1), true)\n    U.deepStrictEqual(S.equals(a1, a1_), true)\n    U.deepStrictEqual(S.equals(a1_, a1), true)\n    U.deepStrictEqual(S.equals(a1, a2), false)\n    U.deepStrictEqual(S.equals(a2, a1), false)\n    U.deepStrictEqual(S.equals(a1, b1), false)\n    U.deepStrictEqual(S.equals(b1, a1), false)\n\n    const equals = _.getEq(eqKey, eqValue).equals\n    U.deepStrictEqual(equals(repo, repo), true)\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 1 }, { value: 1 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      true\n    )\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 1 }, { value: 2 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      false\n    )\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 1 }, { value: 4 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      true\n    )\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 4 }, { value: 1 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      true\n    )\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 3 }, { value: 3 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      false\n    )\n  })\n\n  it('getMonoid', () => {\n    const d1 = new Map<User, number>([\n      [{ id: 'k1' }, 1],\n      [{ id: 'k2' }, 3]\n    ])\n    const d2 = new Map<User, number>([\n      [{ id: 'k2' }, 2],\n      [{ id: 'k3' }, 4]\n    ])\n    const expected = new Map<User, number>([\n      [{ id: 'k1' }, 1],\n      [{ id: 'k2' }, 5],\n      [{ id: 'k3' }, 4]\n    ])\n    const M1 = _.getMonoid(eqUser, N.SemigroupSum)\n    U.deepStrictEqual(M1.concat(d1, d2), expected)\n    U.deepStrictEqual(M1.concat(d1, M1.empty), d1)\n    U.deepStrictEqual(M1.concat(M1.empty, d2), d2)\n\n    const M2 = _.getMonoid(eqKey, semigroupValue)\n    U.deepStrictEqual(\n      M2.concat(repo, new Map([[{ id: 3 }, { value: 3 }]])),\n      new Map([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }],\n        [{ id: 3 }, { value: 3 }]\n      ])\n    )\n    U.deepStrictEqual(\n      M2.concat(repo, new Map([[{ id: 1 }, { value: 2 }]])),\n      new Map([\n        [{ id: 1 }, { value: 3 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n    U.deepStrictEqual(\n      M2.concat(repo, new Map([[{ id: 4 }, { value: 2 }]])),\n      new Map([\n        [{ id: 1 }, { value: 3 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n  })\n\n  describe('map_', () => {\n    describe('functor', () => {\n      it('map', () => {\n        const d1 = new Map<string, number>([\n          ['k1', 1],\n          ['k2', 2]\n        ])\n        const expected = new Map<string, number>([\n          ['k1', 2],\n          ['k2', 4]\n        ])\n        U.deepStrictEqual(pipe(d1, _.map(U.double)), expected)\n      })\n    })\n\n    describe('filterable', () => {\n      it('compact', () => {\n        const fooBar = new Map<string, O.Option<number>>([\n          ['foo', O.none],\n          ['bar', O.some(123)]\n        ])\n        const bar = new Map<string, number>([['bar', 123]])\n        U.deepStrictEqual(_.compact(fooBar), bar)\n      })\n\n      it('partitionMap', () => {\n        const emptyMap = new Map<string, number>()\n        const a1b3 = new Map<string, number>([\n          ['a', 1],\n          ['b', 3]\n        ])\n        const a0 = new Map<string, number>([['a', 0]])\n        const b4 = new Map<string, number>([['b', 4]])\n        const f = (n: number) => (p(n) ? right(n + 1) : left(n - 1))\n        U.deepStrictEqual(pipe(emptyMap, _.partitionMap(f)), separated(emptyMap, emptyMap))\n        U.deepStrictEqual(pipe(a1b3, _.partitionMap(f)), separated(a0, b4))\n      })\n\n      it('partition', () => {\n        const emptyMap = new Map<string, number>()\n        const a1b3 = new Map<string, number>([\n          ['a', 1],\n          ['b', 3]\n        ])\n        const a1 = new Map<string, number>([['a', 1]])\n        const b3 = new Map<string, number>([['b', 3]])\n        U.deepStrictEqual(pipe(emptyMap, _.partition(p)), separated(emptyMap, emptyMap))\n        U.deepStrictEqual(pipe(a1b3, _.partition(p)), separated(a1, b3))\n      })\n\n      it('separate', () => {\n        const fooBar = new Map<string, Either<number, number>>([\n          ['foo', left(123)],\n          ['bar', right(123)]\n        ])\n        const foo = new Map<string, number>([['foo', 123]])\n        const bar = new Map<string, number>([['bar', 123]])\n        U.deepStrictEqual(_.separate(fooBar), separated(foo, bar))\n      })\n\n      it('filter', () => {\n        const a1b3 = new Map<string, number>([\n          ['a', 1],\n          ['b', 3]\n        ])\n        const b3 = new Map<string, number>([['b', 3]])\n        U.deepStrictEqual(pipe(a1b3, _.filter(p)), b3)\n\n        // refinements\n        const isNumber = (u: string | number): u is number => typeof u === 'number'\n        const y = new Map<string, string | number>([\n          ['a', 1],\n          ['b', 'foo']\n        ])\n        const a1 = new Map<string, number>([['a', 1]])\n        const actual = pipe(y, _.filter(isNumber))\n        U.deepStrictEqual(actual, a1)\n      })\n\n      it('filterMap', () => {\n        const emptyMap = new Map<string, number>()\n        const a1b3 = new Map<string, number>([\n          ['a', 1],\n          ['b', 3]\n        ])\n        const b4 = new Map<string, number>([['b', 4]])\n        const f = (n: number) => (p(n) ? O.some(n + 1) : O.none)\n        U.deepStrictEqual(pipe(emptyMap, _.filterMap(f)), emptyMap)\n        U.deepStrictEqual(pipe(a1b3, _.filterMap(f)), b4)\n      })\n    })\n  })\n\n  describe('getFoldable', () => {\n    const F = _.getFoldable(ordUser)\n    it('reduce', () => {\n      const d1 = new Map<User, string>([\n        [{ id: 'k1' }, 'a'],\n        [{ id: 'k2' }, 'b']\n      ])\n      const reduceO = F.reduce\n      U.deepStrictEqual(\n        reduceO(d1, '', (b, a) => b + a),\n        'ab'\n      )\n      const d2 = new Map<User, string>([\n        [{ id: 'k2' }, 'b'],\n        [{ id: 'k1' }, 'a']\n      ])\n      U.deepStrictEqual(\n        reduceO(d2, '', (b, a) => b + a),\n        'ab'\n      )\n    })\n\n    it('foldMap', () => {\n      const foldMapOM = F.foldMap(S.Monoid)\n      const m = new Map<User, string>([\n        [{ id: 'a' }, 'a'],\n        [{ id: 'a' }, 'b']\n      ])\n      U.deepStrictEqual(foldMapOM(m, identity), 'ab')\n    })\n\n    it('reduceRight', () => {\n      const reduceRightO = F.reduceRight\n      const m = new Map<User, string>([\n        [{ id: 'a' }, 'a'],\n        [{ id: 'b' }, 'b']\n      ])\n      const init = ''\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(reduceRightO(m, init, f), 'ba')\n    })\n  })\n\n  describe('getWitherable', () => {\n    const W = _.getWitherable(ordUser)\n\n    it('mapWithIndex', () => {\n      const mapWithIndex = W.mapWithIndex\n      const aa1 = new Map<User, number>([[{ id: 'aa' }, 1]])\n      const aa3 = new Map<User, number>([[{ id: 'aa' }, 3]])\n      U.deepStrictEqual(\n        mapWithIndex(aa1, (k, a) => a + k.id.length),\n        aa3\n      )\n    })\n\n    it('reduceWithIndex', () => {\n      const d1 = new Map<User, string>([\n        [{ id: 'k1' }, 'a'],\n        [{ id: 'k2' }, 'b']\n      ])\n      const reduceWithIndexO = W.reduceWithIndex\n      U.deepStrictEqual(\n        reduceWithIndexO(d1, '', (k, b, a) => b + k.id + a),\n        'k1ak2b'\n      )\n      const d2 = new Map<User, string>([\n        [{ id: 'k2' }, 'b'],\n        [{ id: 'k1' }, 'a']\n      ])\n      U.deepStrictEqual(\n        reduceWithIndexO(d2, '', (k, b, a) => b + k.id + a),\n        'k1ak2b'\n      )\n    })\n\n    it('foldMapWithIndex', () => {\n      const foldMapWithIndexOM = W.foldMapWithIndex(S.Monoid)\n      const m = new Map<User, string>([\n        [{ id: 'k1' }, 'a'],\n        [{ id: 'k2' }, 'b']\n      ])\n      U.deepStrictEqual(\n        foldMapWithIndexOM(m, (k, a) => k.id + a),\n        'k1ak2b'\n      )\n    })\n\n    it('reduceRightWithIndex', () => {\n      const reduceRightWithIndexO = W.reduceRightWithIndex\n      const m = new Map<User, string>([\n        [{ id: 'k1' }, 'a'],\n        [{ id: 'k2' }, 'b']\n      ])\n      U.deepStrictEqual(\n        reduceRightWithIndexO(m, '', (k, a, b) => b + k.id + a),\n        'k2bk1a'\n      )\n    })\n\n    it('traverse', () => {\n      const traverse = W.traverse(O.Applicative)\n      const x = new Map([\n        [{ id: 'k1' }, 1],\n        [{ id: 'k2' }, 2]\n      ])\n      U.deepStrictEqual(\n        traverse(x, (n) => (n <= 2 ? O.some(n) : O.none)),\n        O.some(x)\n      )\n      U.deepStrictEqual(\n        traverse(x, (n) => (n >= 2 ? O.some(n) : O.none)),\n        O.none\n      )\n    })\n\n    it('sequence', () => {\n      const sequence = W.sequence(O.Applicative)\n      U.deepStrictEqual(\n        sequence(\n          new Map([\n            [{ id: 'k1' }, O.some(1)],\n            [{ id: 'k2' }, O.some(2)]\n          ])\n        ),\n        O.some(\n          new Map([\n            [{ id: 'k1' }, 1],\n            [{ id: 'k2' }, 2]\n          ])\n        )\n      )\n      U.deepStrictEqual(\n        sequence(\n          new Map([\n            [{ id: 'k1' }, O.none],\n            [{ id: 'k2' }, O.some(2)]\n          ])\n        ),\n        O.none\n      )\n    })\n\n    it('traverseWithIndex', () => {\n      const traverseWithIndex = W.traverseWithIndex(O.Applicative)\n      U.deepStrictEqual(\n        traverseWithIndex(\n          new Map([\n            [{ id: 'k1' }, 1],\n            [{ id: 'k2' }, 2]\n          ]),\n          (k, n): O.Option<number> => (!ordUser.equals(k, { id: 'k1' }) ? O.some(n) : O.none)\n        ),\n        O.none\n      )\n      U.deepStrictEqual(\n        traverseWithIndex(\n          new Map([\n            [{ id: 'k1' }, 2],\n            [{ id: 'k2' }, 3]\n          ]),\n          (k, n): O.Option<number> => (!ordUser.equals(k, { id: 'k3' }) ? O.some(n) : O.none)\n        ),\n        O.some(\n          new Map([\n            [{ id: 'k1' }, 2],\n            [{ id: 'k2' }, 3]\n          ])\n        )\n      )\n    })\n\n    it('wither', async () => {\n      const wither = W.wither(T.ApplicativePar)\n      const f = (n: number) => T.of(p(n) ? O.some(n + 1) : O.none)\n      U.deepStrictEqual(await wither(new Map(), f)(), new Map())\n      U.deepStrictEqual(\n        await wither(\n          new Map([\n            [{ id: 'a' }, 1],\n            [{ id: 'b' }, 3]\n          ]),\n          f\n        )(),\n        new Map([[{ id: 'b' }, 4]])\n      )\n    })\n\n    it('wilt', async () => {\n      const wilt = W.wilt(T.ApplicativePar)\n      const f = (n: number) => T.of(p(n) ? right(n + 1) : left(n - 1))\n      U.deepStrictEqual(await wilt(new Map(), f)(), separated(new Map(), new Map()))\n      U.deepStrictEqual(\n        await wilt(\n          new Map([\n            [{ id: 'a' }, 1],\n            [{ id: 'b' }, 3]\n          ]),\n          f\n        )(),\n        separated(new Map([[{ id: 'a' }, 0]]), new Map([[{ id: 'b' }, 4]]))\n      )\n    })\n  })\n\n  describe('getFilterableWithIndex', () => {\n    it('partitionMapWithIndex', () => {\n      const partitionMapWithIndex = _.getFilterableWithIndex<string>().partitionMapWithIndex\n      const emptyMap = new Map<string, number>()\n      const a1b3 = new Map<string, number>([\n        ['a', 1],\n        ['b', 3]\n      ])\n      const a0 = new Map<string, number>([['a', 0]])\n      const b4 = new Map<string, number>([['b', 4]])\n      const f = (_: string, n: number) => (p(n) ? right(n + 1) : left(n - 1))\n      U.deepStrictEqual(partitionMapWithIndex(emptyMap, f), separated(emptyMap, emptyMap))\n      U.deepStrictEqual(partitionMapWithIndex(a1b3, f), separated(a0, b4))\n    })\n\n    it('partitionWithIndex', () => {\n      const partitionWithIndex = _.getFilterableWithIndex<string>().partitionWithIndex\n      const emptyMap = new Map<string, number>()\n      const a1b3 = new Map<string, number>([\n        ['a', 1],\n        ['b', 3]\n      ])\n      const a1 = new Map<string, number>([['a', 1]])\n      const b3 = new Map<string, number>([['b', 3]])\n      const f = (_: string, n: number) => p(n)\n      U.deepStrictEqual(partitionWithIndex(emptyMap, f), separated(emptyMap, emptyMap))\n      U.deepStrictEqual(partitionWithIndex(a1b3, f), separated(a1, b3))\n    })\n\n    it('filterMapWithIndex', () => {\n      const filterMapWithIndex = _.getFilterableWithIndex<string>().filterMapWithIndex\n      const emptyMap = new Map<string, number>()\n      const a1b3 = new Map<string, number>([\n        ['a', 1],\n        ['b', 3]\n      ])\n      const b4 = new Map<string, number>([['b', 4]])\n      const f = (_: string, n: number) => (p(n) ? O.some(n + 1) : O.none)\n      U.deepStrictEqual(filterMapWithIndex(emptyMap, f), emptyMap)\n      U.deepStrictEqual(filterMapWithIndex(a1b3, f), b4)\n    })\n\n    it('filterWithIndex', () => {\n      const filterWithIndex = _.getFilterableWithIndex<string>().filterWithIndex\n      const a1b3 = new Map<string, number>([\n        ['a', 1],\n        ['b', 3]\n      ])\n      const b3 = new Map<string, number>([['b', 3]])\n      const f = (_: string, n: number) => p(n)\n      U.deepStrictEqual(filterWithIndex(a1b3, f), b3)\n\n      // refinements\n      const filterWithIndexStr = _.getFilterableWithIndex<string>().filterWithIndex\n      const isNumber = (_: string, u: string | number): u is number => typeof u === 'number'\n      const y = new Map<string, string | number>([\n        ['a', 1],\n        ['b', 'foo']\n      ])\n      const a1 = new Map<string, number>([['a', 1]])\n      const actual = filterWithIndexStr(y, isNumber)\n      U.deepStrictEqual(actual, a1)\n    })\n  })\n\n  it('fromFoldable', () => {\n    const a1 = new Map<User, number>([[{ id: 'a' }, 1]])\n    const a2 = new Map<User, number>([[{ id: 'a' }, 2]])\n    const fromFoldableS1 = _.fromFoldable(eqUser, Se.first<number>(), RA.Foldable)\n    U.deepStrictEqual(fromFoldableS1([[{ id: 'a' }, 1]]), a1)\n    U.deepStrictEqual(\n      fromFoldableS1([\n        [{ id: 'a' }, 1],\n        [{ id: 'a' }, 2]\n      ]),\n      a1\n    )\n    const fromFoldableS2 = _.fromFoldable(eqUser, Se.last<number>(), RA.Foldable)\n    U.deepStrictEqual(\n      fromFoldableS2([\n        [{ id: 'a' }, 1],\n        [{ id: 'a' }, 2]\n      ]),\n      a2\n    )\n  })\n\n  it('getShow', () => {\n    const showUser: Show<User> = struct({ id: S.Show })\n    const Sh = _.getShow(showUser, S.Show)\n    const m1 = new Map<User, string>([])\n    U.deepStrictEqual(Sh.show(m1), `new Map([])`)\n    const m2 = new Map<User, string>([[{ id: 'a' }, 'b']])\n    U.deepStrictEqual(Sh.show(m2), `new Map([[{ id: \"a\" }, \"b\"]])`)\n    const m3 = new Map<User, string>([\n      [{ id: 'c' }, 'd'],\n      [{ id: 'a' }, 'b']\n    ])\n    U.deepStrictEqual(Sh.show(m3), `new Map([[{ id: \"a\" }, \"b\"], [{ id: \"c\" }, \"d\"]])`)\n  })\n\n  it('updateAt', () => {\n    const m1 = new Map<User, string>([])\n    U.deepStrictEqual(_.updateAt(eqUser)({ id: 'a' }, 'a')(m1), O.none)\n    const m2 = new Map<User, string>([[{ id: 'a' }, 'b']])\n    U.deepStrictEqual(_.updateAt(eqUser)({ id: 'a' }, 'a')(m2), O.some(new Map<User, string>([[{ id: 'a' }, 'a']])))\n  })\n\n  it('modifyAt', () => {\n    const m1 = new Map<User, number>([])\n    U.deepStrictEqual(_.modifyAt(eqUser)({ id: 'a' }, (n: number) => n * 2)(m1), O.none)\n    const m2 = new Map<User, number>([[{ id: 'a' }, 1]])\n    U.deepStrictEqual(\n      _.modifyAt(eqUser)({ id: 'a' }, (n: number) => n * 2)(m2),\n      O.some(new Map<User, number>([[{ id: 'a' }, 2]]))\n    )\n    // should not return the same reference if nothing changed\n    const input: Map<string, number> = new Map([['a', 1]])\n    U.deepStrictEqual(\n      pipe(\n        input,\n        _.modifyAt(S.Eq)('a', identity),\n        O.map((out) => out === input)\n      ),\n      O.some(false)\n    )\n  })\n\n  it('mapWithIndex', () => {\n    const aa1 = new Map<User, number>([[{ id: 'aa' }, 1]])\n    const aa3 = new Map<User, number>([[{ id: 'aa' }, 3]])\n    U.deepStrictEqual(\n      pipe(\n        aa1,\n        _.mapWithIndex((k, a) => a + k.id.length)\n      ),\n      aa3\n    )\n  })\n\n  it('getUnionMonoid', () => {\n    const M = _.getUnionMonoid(eqUser, S.Semigroup)\n    const x = new Map<User, string>([\n      [{ id: 'a' }, 'a1'],\n      [{ id: 'b' }, 'b1'],\n      [{ id: 'c' }, 'c1']\n    ])\n    const y = new Map<User, string>([\n      [{ id: 'b' }, 'b2'],\n      [{ id: 'c' }, 'c2'],\n      [{ id: 'd' }, 'd2']\n    ])\n    U.deepStrictEqual(M.concat(x, M.empty), x)\n    U.deepStrictEqual(M.concat(M.empty, x), x)\n    U.deepStrictEqual(M.concat(x, new Map()), x)\n    U.deepStrictEqual(M.concat(new Map(), x), x)\n    U.deepStrictEqual(\n      M.concat(x, y),\n      new Map([\n        [{ id: 'a' }, 'a1'],\n        [{ id: 'b' }, 'b1b2'],\n        [{ id: 'c' }, 'c1c2'],\n        [{ id: 'd' }, 'd2']\n      ])\n    )\n  })\n\n  it('getIntersectionSemigroup', () => {\n    const M = _.getIntersectionSemigroup(eqUser, S.Semigroup)\n    const x = new Map<User, string>([\n      [{ id: 'a' }, 'a1'],\n      [{ id: 'b' }, 'b1'],\n      [{ id: 'c' }, 'c1']\n    ])\n    const y = new Map<User, string>([\n      [{ id: 'b' }, 'b2'],\n      [{ id: 'c' }, 'c2'],\n      [{ id: 'd' }, 'd2']\n    ])\n    U.deepStrictEqual(M.concat(x, new Map()), new Map())\n    U.deepStrictEqual(M.concat(new Map(), x), new Map())\n    U.deepStrictEqual(\n      M.concat(x, y),\n      new Map([\n        [{ id: 'b' }, 'b1b2'],\n        [{ id: 'c' }, 'c1c2']\n      ])\n    )\n  })\n\n  it('getDifferenceMagma', () => {\n    const M = _.getDifferenceMagma(eqUser)<string>()\n    const x = new Map<User, string>([\n      [{ id: 'a' }, 'a1'],\n      [{ id: 'b' }, 'b1'],\n      [{ id: 'c' }, 'c1']\n    ])\n    const y = new Map<User, string>([\n      [{ id: 'b' }, 'b2'],\n      [{ id: 'c' }, 'c2'],\n      [{ id: 'd' }, 'd2']\n    ])\n    U.deepStrictEqual(M.concat(x, new Map()), x)\n    U.deepStrictEqual(M.concat(new Map(), x), x)\n    U.deepStrictEqual(\n      M.concat(x, y),\n      new Map([\n        [{ id: 'a' }, 'a1'],\n        [{ id: 'd' }, 'd2']\n      ])\n    )\n  })\n})\n"
  },
  {
    "path": "test/Monoid.ts",
    "content": "import * as B from '../src/boolean'\nimport { increment } from '../src/function'\nimport * as _ from '../src/Monoid'\nimport * as N from '../src/number'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('Monoid', () => {\n  it('tuple', () => {\n    const M1 = _.tuple(S.Monoid, N.MonoidSum)\n    U.deepStrictEqual(M1.concat(['a', 1], ['b', 2]), ['ab', 3])\n    const M2 = _.tuple(S.Monoid, N.MonoidSum, B.MonoidAll)\n    U.deepStrictEqual(M2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])\n  })\n\n  it('concatAll', () => {\n    U.deepStrictEqual(_.concatAll(N.MonoidSum)([1, 2, 3]), 6)\n  })\n\n  it('getEndomorphismMonoid', () => {\n    const M = _.getEndomorphismMonoid<number>()\n    const f = M.concat(U.double, increment)\n    U.deepStrictEqual(f(3), 8)\n  })\n\n  it('min', () => {\n    const M = _.min(N.Bounded)\n    U.deepStrictEqual(_.concatAll(M)([]), +Infinity)\n    U.deepStrictEqual(_.concatAll(M)([1]), 1)\n    U.deepStrictEqual(_.concatAll(M)([1, -1]), -1)\n  })\n\n  it('max', () => {\n    const M = _.max(N.Bounded)\n    U.deepStrictEqual(_.concatAll(M)([]), -Infinity)\n    U.deepStrictEqual(_.concatAll(M)([1]), 1)\n    U.deepStrictEqual(_.concatAll(M)([1, -1]), 1)\n  })\n\n  it('reverse', () => {\n    const M = _.reverse(S.Monoid)\n    U.deepStrictEqual(M.concat('a', 'b'), 'ba')\n    U.deepStrictEqual(M.concat('a', M.empty), 'a')\n    U.deepStrictEqual(M.concat(M.empty, 'a'), 'a')\n  })\n\n  it('struct', () => {\n    // should ignore non own properties\n    const monoids = Object.create({ a: 1 })\n    const s = _.struct(monoids)\n    U.deepStrictEqual(s.empty, {})\n  })\n})\n"
  },
  {
    "path": "test/NonEmptyArray.ts",
    "content": "import * as assert from 'assert'\n\nimport { Endomorphism } from '../src/Endomorphism'\nimport { identity, pipe } from '../src/function'\nimport * as _ from '../src/NonEmptyArray'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('NonEmptyArray', () => {\n  describe('pipeables', () => {\n    it('traverse', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.traverse(O.Applicative)((n) => (n >= 0 ? O.some(n) : O.none))\n        ),\n        O.some([1, 2, 3])\n      )\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.traverse(O.Applicative)((n) => (n >= 2 ? O.some(n) : O.none))\n        ),\n        O.none\n      )\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      U.deepStrictEqual(sequence([O.some(1), O.some(2), O.some(3)]), O.some([1, 2, 3]))\n      U.deepStrictEqual(sequence([O.none, O.some(2), O.some(3)]), O.none)\n    })\n\n    it('traverseWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'bb'],\n          _.traverseWithIndex(O.Applicative)((i, s) => (s.length >= 1 ? O.some(s + i) : O.none))\n        ),\n        O.some(['a0', 'bb1'])\n      )\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'bb'],\n          _.traverseWithIndex(O.Applicative)((i, s) => (s.length > 1 ? O.some(s + i) : O.none))\n        ),\n        O.none\n      )\n    })\n  })\n\n  it('head', () => {\n    U.deepStrictEqual(_.head([1, 2]), 1)\n  })\n\n  it('tail', () => {\n    U.deepStrictEqual(_.tail([1, 2]), [2])\n  })\n\n  it('map', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2],\n        _.map((n) => n * 2)\n      ),\n      [2, 4]\n    )\n  })\n\n  it('mapWithIndex', () => {\n    const add = (i: number, n: number) => n + i\n    U.deepStrictEqual(pipe([1, 2], _.mapWithIndex(add)), [1, 3])\n  })\n\n  it('of', () => {\n    U.deepStrictEqual(_.of(1), [1])\n  })\n\n  it('ap', () => {\n    const fab: _.NonEmptyArray<(n: number) => number> = [U.double, U.double]\n    U.deepStrictEqual(pipe(fab, _.ap([1, 2])), [2, 4, 2, 4])\n  })\n\n  it('flatMap', () => {\n    const f = (a: number): _.NonEmptyArray<number> => [a, 4]\n    U.deepStrictEqual(pipe([1, 2], _.flatMap(f)), [1, 4, 2, 4])\n    U.deepStrictEqual(_.flatMap([1, 2], f), [1, 4, 2, 4])\n  })\n\n  it('chain', () => {\n    const f = (a: number): _.NonEmptyArray<number> => [a, 4]\n    U.deepStrictEqual(pipe([1, 2], _.chain(f)), [1, 4, 2, 4])\n  })\n\n  it('extend', () => {\n    const sum = _.concatAll(N.MonoidSum)\n    U.deepStrictEqual(pipe([1, 2, 3, 4], _.extend(sum)), [10, 9, 7, 4])\n  })\n\n  it('extract', () => {\n    U.deepStrictEqual(_.extract([1, 2, 3]), 1)\n  })\n\n  it('min', () => {\n    U.deepStrictEqual(_.min(N.Ord)([2, 1, 3]), 1)\n    U.deepStrictEqual(_.min(N.Ord)([3]), 3)\n  })\n\n  it('max', () => {\n    U.deepStrictEqual(_.max(N.Ord)([1, 2, 3]), 3)\n    U.deepStrictEqual(_.max(N.Ord)([1]), 1)\n  })\n\n  it('reduce', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a', 'b'],\n        _.reduce('', (b, a) => b + a)\n      ),\n      'ab'\n    )\n  })\n\n  it('foldMap', () => {\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.foldMap(S.Monoid)(identity)), 'abc')\n  })\n\n  it('reduceRight', () => {\n    const f = (a: string, acc: string) => acc + a\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.reduceRight('', f)), 'cba')\n  })\n\n  it('fromArray', () => {\n    U.deepStrictEqual(_.fromArray([]), O.none)\n    U.deepStrictEqual(_.fromArray([1]), O.some([1]))\n    U.deepStrictEqual(_.fromArray([1, 2]), O.some([1, 2]))\n  })\n\n  it('getSemigroup', () => {\n    const S = _.getSemigroup<number>()\n    U.deepStrictEqual(S.concat([1], [2]), [1, 2])\n    U.deepStrictEqual(S.concat([1, 2], [3, 4]), [1, 2, 3, 4])\n  })\n\n  it('getEq', () => {\n    const S = _.getEq(N.Eq)\n    U.deepStrictEqual(S.equals([1], [1]), true)\n    U.deepStrictEqual(S.equals([1], [1, 2]), false)\n  })\n\n  it('group', () => {\n    U.deepStrictEqual(_.group(N.Ord)([]), [])\n\n    U.deepStrictEqual(_.group(N.Ord)([1, 2, 1, 1]), [[1], [2], [1, 1]])\n\n    U.deepStrictEqual(_.group(N.Ord)([1, 2, 1, 1, 3]), [[1], [2], [1, 1], [3]])\n  })\n\n  it('groupSort', () => {\n    U.deepStrictEqual(_.groupSort(N.Ord)([]), [])\n    U.deepStrictEqual(_.groupSort(N.Ord)([1, 2, 1, 1]), [[1, 1, 1], [2]])\n  })\n\n  it('last', () => {\n    U.deepStrictEqual(_.last([1, 2, 3]), 3)\n    U.deepStrictEqual(_.last([1]), 1)\n  })\n\n  it('init', () => {\n    U.deepStrictEqual(_.init([1, 2, 3]), [1, 2])\n    U.deepStrictEqual(_.init([1]), [])\n  })\n\n  it('sort', () => {\n    const sort = _.sort(N.Ord)\n    U.deepStrictEqual(sort([3, 2, 1]), [1, 2, 3])\n    U.deepStrictEqual(sort([1]), [1])\n  })\n\n  it('prependAll', () => {\n    U.deepStrictEqual(_.prependAll(0)([1, 2, 3]), [0, 1, 0, 2, 0, 3])\n    U.deepStrictEqual(_.prependAll(0)([1]), [0, 1])\n    U.deepStrictEqual(_.prependAll(0)([1, 2, 3, 4]), [0, 1, 0, 2, 0, 3, 0, 4])\n  })\n\n  it('intersperse', () => {\n    U.deepStrictEqual(_.intersperse(0)([1, 2, 3]), [1, 0, 2, 0, 3])\n    U.deepStrictEqual(_.intersperse(0)([1]), [1])\n    U.deepStrictEqual(_.intersperse(0)([1, 2]), [1, 0, 2])\n    U.deepStrictEqual(_.intersperse(0)([1, 2, 3, 4]), [1, 0, 2, 0, 3, 0, 4])\n  })\n\n  it('intercalate', () => {\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a']), 'a')\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c')\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a', '', 'c']), 'a--c')\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a', 'b']), 'a-b')\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a', 'b', 'c', 'd']), 'a-b-c-d')\n  })\n\n  it('reverse', () => {\n    U.deepStrictEqual(_.reverse([1, 2, 3]), [3, 2, 1])\n  })\n\n  it('groupBy', () => {\n    U.deepStrictEqual(_.groupBy((_) => '')([]), {})\n    U.deepStrictEqual(_.groupBy(String)([1]), { '1': [1] })\n    U.deepStrictEqual(_.groupBy((s: string) => String(s.length))(['foo', 'bar', 'foobar']), {\n      '3': ['foo', 'bar'],\n      '6': ['foobar']\n    })\n  })\n\n  it('union', () => {\n    const concat = _.getUnionSemigroup(N.Eq).concat\n    U.deepStrictEqual(concat([1, 2], [3, 4]), [1, 2, 3, 4])\n    U.deepStrictEqual(concat([1, 2], [2, 3]), [1, 2, 3])\n    U.deepStrictEqual(concat([1, 2], [1, 2]), [1, 2])\n  })\n\n  it('insertAt', () => {\n    const make = (x: number) => ({ x })\n    const a1 = make(1)\n    const a2 = make(1)\n    const a3 = make(2)\n    const a4 = make(3)\n    U.deepStrictEqual(pipe([], _.insertAt(1, 1)), O.none)\n    U.deepStrictEqual(pipe([], _.insertAt(0, 1)), O.some([1]))\n    U.deepStrictEqual(_.insertAt(0, a4)([a1, a2, a3]), O.some([a4, a1, a2, a3]))\n    U.deepStrictEqual(_.insertAt(-1, a4)([a1, a2, a3]), O.none)\n    U.deepStrictEqual(_.insertAt(3, a4)([a1, a2, a3]), O.some([a1, a2, a3, a4]))\n    U.deepStrictEqual(_.insertAt(1, a4)([a1, a2, a3]), O.some([a1, a4, a2, a3]))\n    U.deepStrictEqual(_.insertAt(4, a4)([a1, a2, a3]), O.none)\n  })\n\n  it('updateAt', () => {\n    const make2 = (x: number) => ({ x })\n    const a1 = make2(1)\n    const a2 = make2(1)\n    const a3 = make2(2)\n    const a4 = make2(3)\n    const arr: _.NonEmptyArray<{ readonly x: number }> = [a1, a2, a3]\n    U.deepStrictEqual(_.updateAt(0, a4)(arr), O.some([a4, a2, a3]))\n    U.deepStrictEqual(_.updateAt(-1, a4)(arr), O.none)\n    U.deepStrictEqual(_.updateAt(3, a4)(arr), O.none)\n    U.deepStrictEqual(_.updateAt(1, a4)(arr), O.some([a1, a4, a3]))\n    // should return the same reference if nothing changed\n    const r1 = _.updateAt(0, a1)(arr)\n    if (O.isSome(r1)) {\n      U.deepStrictEqual(r1.value, arr)\n    } else {\n      assert.fail('is not a Some')\n    }\n    const r2 = _.updateAt(2, a3)(arr)\n    if (O.isSome(r2)) {\n      U.deepStrictEqual(r2.value, arr)\n    } else {\n      assert.fail('is not a Some')\n    }\n  })\n\n  it('modifyAt', () => {\n    U.deepStrictEqual(_.modifyAt(1, U.double)([1]), O.none)\n    U.deepStrictEqual(_.modifyAt(1, U.double)([1, 2]), O.some([1, 4]))\n    // should not return the same reference if nothing changed\n    const input: _.NonEmptyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(\n      pipe(\n        input,\n        _.modifyAt(1, identity),\n        O.map((out) => out === input)\n      ),\n      O.some(false)\n    )\n  })\n\n  it('copy', () => {\n    const nea1: _.NonEmptyArray<number> = [1]\n    const nea2 = _.copy(nea1)\n    U.deepStrictEqual(nea2, nea1)\n    U.deepStrictEqual(nea2 === nea1, false)\n  })\n\n  it('filter', () => {\n    const make = (x: number) => ({ x })\n    const a1 = make(1)\n    const a2 = make(1)\n    const a3 = make(2)\n    const as: _.NonEmptyArray<{ readonly x: number }> = [a1, a2, a3]\n    U.deepStrictEqual(\n      pipe(\n        as,\n        _.filter(({ x }) => x !== 1)\n      ),\n      O.some([a3])\n    )\n    U.deepStrictEqual(\n      pipe(\n        as,\n        _.filter(({ x }) => x !== 2)\n      ),\n      O.some([a1, a2])\n    )\n    U.deepStrictEqual(\n      _.filter(({ x }) => {\n        return !(x === 1 || x === 2)\n      })([a1, a2, a3]),\n      O.none\n    )\n    U.deepStrictEqual(\n      pipe(\n        as,\n        _.filter(({ x }) => x !== 10)\n      ),\n      O.some([a1, a2, a3])\n    )\n\n    // refinements\n    const actual1 = _.filter(O.isSome)([O.some(3), O.some(2), O.some(1)])\n    U.deepStrictEqual(actual1, O.some([O.some(3), O.some(2), O.some(1)]))\n    const actual2 = _.filter(O.isSome)([O.some(3), O.none, O.some(1)])\n    U.deepStrictEqual(actual2, O.some([O.some(3), O.some(1)]))\n  })\n\n  it('filterWithIndex', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        _.filterWithIndex((i) => i % 2 === 0)\n      ),\n      O.some([1, 3])\n    )\n    U.deepStrictEqual(_.filterWithIndex((i, a: number) => i % 2 === 1 && a > 2)([1, 2, 3]), O.none)\n  })\n\n  it('reduceWithIndex', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a', 'b'],\n        _.reduceWithIndex('', (i, b, a) => b + i + a)\n      ),\n      '0a1b'\n    )\n  })\n\n  it('foldMapWithIndex', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a', 'b'],\n        _.foldMapWithIndex(S.Monoid)((i, a) => i + a)\n      ),\n      '0a1b'\n    )\n  })\n\n  it('reduceRightWithIndex', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a', 'b'],\n        _.reduceRightWithIndex('', (i, a, b) => b + i + a)\n      ),\n      '1b0a'\n    )\n  })\n\n  it('cons', () => {\n    U.deepStrictEqual(_.cons(1, [2, 3, 4]), [1, 2, 3, 4])\n  })\n\n  it('snoc', () => {\n    U.deepStrictEqual(_.snoc([1, 2, 3], 4), [1, 2, 3, 4])\n  })\n\n  it('unprepend', () => {\n    U.deepStrictEqual(_.unprepend([0]), [0, []])\n    U.deepStrictEqual(_.unprepend([1, 2, 3, 4]), [1, [2, 3, 4]])\n  })\n\n  it('unappend', () => {\n    U.deepStrictEqual(_.unappend([0]), [[], 0])\n    U.deepStrictEqual(_.unappend([1, 2, 3, 4]), [[1, 2, 3], 4])\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    U.deepStrictEqual(Sh.show(['a']), `[\"a\"]`)\n    U.deepStrictEqual(Sh.show(['a', 'b', 'c']), `[\"a\", \"b\", \"c\"]`)\n  })\n\n  it('alt', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a'],\n        _.alt(() => ['b'])\n      ),\n      ['a', 'b']\n    )\n  })\n\n  it('foldMap', () => {\n    const f = _.foldMap(N.SemigroupSum)((s: string) => s.length)\n    U.deepStrictEqual(f(['a']), 1)\n    U.deepStrictEqual(f(['a', 'bb']), 3)\n  })\n\n  it('foldMapWithIndex', () => {\n    const f = _.foldMapWithIndex(N.SemigroupSum)((i: number, s: string) => s.length + i)\n    U.deepStrictEqual(f(['a']), 1)\n    U.deepStrictEqual(f(['a', 'bb']), 4)\n  })\n\n  it('concatAll', () => {\n    const f = _.concatAll(S.Semigroup)\n    U.deepStrictEqual(f(['a']), 'a')\n    U.deepStrictEqual(f(['a', 'bb']), 'abb')\n  })\n\n  it('zipWith', () => {\n    U.deepStrictEqual(\n      _.zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n),\n      ['a1', 'b2', 'c3']\n    )\n  })\n\n  it('zip', () => {\n    const x: _.NonEmptyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.zip(x, ['a', 'b', 'c', 'd']), [\n      [1, 'a'],\n      [2, 'b'],\n      [3, 'c']\n    ])\n    U.deepStrictEqual(pipe(x, _.zip(['a', 'b', 'c', 'd'])), [\n      [1, 'a'],\n      [2, 'b'],\n      [3, 'c']\n    ])\n  })\n\n  it('unzip', () => {\n    U.deepStrictEqual(\n      _.unzip([\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('splitAt', () => {\n    const assertSplitAt = (\n      input: _.NonEmptyArray<number>,\n      index: number,\n      expectedInit: ReadonlyArray<number>,\n      expectedRest: ReadonlyArray<number>\n    ) => {\n      const [init, rest] = _.splitAt(index)(input)\n      U.deepStrictEqual(init, expectedInit)\n      U.deepStrictEqual(rest, expectedRest)\n    }\n\n    const two: _.NonEmptyArray<number> = [1, 2]\n    U.deepStrictEqual(_.splitAt(1)(two), [[1], [2]])\n    assertSplitAt(two, 2, two, [])\n    const singleton: _.NonEmptyArray<number> = [1]\n    assertSplitAt(singleton, 1, singleton, [])\n\n    // out of bounds\n    assertSplitAt(singleton, 0, singleton, [])\n    assertSplitAt(singleton, 2, singleton, [])\n    U.deepStrictEqual(_.splitAt(0)(two), [[1], [2]])\n    assertSplitAt(two, 3, two, [])\n  })\n\n  it('chunksOf', () => {\n    U.deepStrictEqual(_.chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])\n    U.deepStrictEqual(_.chunksOf(2)([1, 2, 3, 4, 5, 6]), [\n      [1, 2],\n      [3, 4],\n      [5, 6]\n    ])\n    U.deepStrictEqual(_.chunksOf(1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n    U.deepStrictEqual(_.chunksOf(5)([1, 2, 3, 4, 5]), [[1, 2, 3, 4, 5]])\n    // out of bounds\n    U.deepStrictEqual(_.chunksOf(0)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n    U.deepStrictEqual(_.chunksOf(-1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n\n    const assertSingleChunk = (input: _.NonEmptyArray<number>, n: number) => {\n      const chunks = _.chunksOf(n)(input)\n      U.deepStrictEqual(chunks.length, 1)\n      U.deepStrictEqual(_.head(chunks), input)\n    }\n    // n = length\n    assertSingleChunk([1, 2], 2)\n    // n out of bounds\n    assertSingleChunk([1, 2], 3)\n  })\n\n  it('matchLeft', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        _.matchLeft((head, tail) => [head, tail])\n      ),\n      [1, [2, 3]]\n    )\n  })\n\n  it('matchRight', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        _.matchRight((init, last) => [init, last])\n      ),\n      [[1, 2], 3]\n    )\n  })\n\n  it('modifyHead', () => {\n    const f: Endomorphism<string> = (s) => s + '!'\n    U.deepStrictEqual(pipe(['a'], _.modifyHead(f)), ['a!'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.modifyHead(f)), ['a!', 'b'])\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.modifyHead(f)), ['a!', 'b', 'c'])\n  })\n\n  it('modifyLast', () => {\n    const f: Endomorphism<string> = (s) => s + '!'\n    U.deepStrictEqual(pipe(['a'], _.modifyLast(f)), ['a!'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.modifyLast(f)), ['a', 'b!'])\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.modifyLast(f)), ['a', 'b', 'c!'])\n  })\n\n  it('replicate', () => {\n    const f = _.replicate('a')\n    U.deepStrictEqual(pipe(0, f), ['a'])\n    U.deepStrictEqual(pipe(1, f), ['a'])\n    U.deepStrictEqual(pipe(2, f), ['a', 'a'])\n  })\n\n  it('updateHead', () => {\n    U.deepStrictEqual(pipe(['a'], _.updateHead('d')), ['d'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.updateHead('d')), ['d', 'b'])\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.updateHead('d')), ['d', 'b', 'c'])\n  })\n\n  it('updateLast', () => {\n    U.deepStrictEqual(pipe(['a'], _.updateLast('d')), ['d'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.updateLast('d')), ['a', 'd'])\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.updateLast('d')), ['a', 'b', 'd'])\n  })\n\n  it('concatW', () => {\n    U.deepStrictEqual(pipe(['a'], _.concatW(['b'])), ['a', 'b'])\n  })\n\n  it('concat', () => {\n    U.deepStrictEqual(pipe(['a'], _.concat(['b'])), ['a', 'b'])\n    U.deepStrictEqual(pipe([], _.concat(['b'])), ['b'])\n    U.deepStrictEqual(pipe(['a'], _.concat<string>([])), ['a'])\n    U.deepStrictEqual(_.concat(['a'], ['b']), ['a', 'b'])\n    U.deepStrictEqual(_.concat(['a'], []), ['a'])\n    U.deepStrictEqual(_.concat([], ['b']), ['b'])\n  })\n})\n"
  },
  {
    "path": "test/Option.ts",
    "content": "import * as E from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as _ from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport { separated } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\nconst p = (n: number): boolean => n > 2\n\ndescribe('Option', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      U.deepStrictEqual(pipe(_.some(2), _.map(U.double)), _.some(4))\n      U.deepStrictEqual(pipe(_.none, _.map(U.double)), _.none)\n    })\n\n    it('flap', () => {\n      U.deepStrictEqual(pipe(_.some(U.double), _.flap(2)), _.some(4))\n      U.deepStrictEqual(pipe(_.none, _.flap(2)), _.none)\n    })\n\n    it('ap', () => {\n      U.deepStrictEqual(pipe(_.some(U.double), _.ap(_.some(2))), _.some(4))\n      U.deepStrictEqual(pipe(_.some(U.double), _.ap(_.none)), _.none)\n      U.deepStrictEqual(pipe(_.none, _.ap(_.some(2))), _.none)\n      U.deepStrictEqual(pipe(_.none, _.ap(_.none)), _.none)\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe(_.some('a'), _.apFirst(_.some('b'))), _.some('a'))\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe(_.some('a'), _.apSecond(_.some('b'))), _.some('b'))\n    })\n\n    it('flatMap', () => {\n      const f = (n: number) => _.some(n * 2)\n      const g = () => _.none\n      U.deepStrictEqual(pipe(_.some(1), _.flatMap(f)), _.some(2))\n      U.deepStrictEqual(pipe(_.none, _.flatMap(f)), _.none)\n      U.deepStrictEqual(pipe(_.some(1), _.flatMap(g)), _.none)\n      U.deepStrictEqual(pipe(_.none, _.flatMap(g)), _.none)\n\n      U.deepStrictEqual(_.flatMap(_.some(1), f), _.some(2))\n      U.deepStrictEqual(_.flatMap(_.none, f), _.none)\n      U.deepStrictEqual(_.flatMap(_.some(1), g), _.none)\n      U.deepStrictEqual(_.flatMap(_.none, g), _.none)\n    })\n\n    it('chain', () => {\n      const f = (n: number) => _.some(n * 2)\n      const g = () => _.none\n      U.deepStrictEqual(pipe(_.some(1), _.chain(f)), _.some(2))\n      U.deepStrictEqual(pipe(_.none, _.chain(f)), _.none)\n      U.deepStrictEqual(pipe(_.some(1), _.chain(g)), _.none)\n      U.deepStrictEqual(pipe(_.none, _.chain(g)), _.none)\n    })\n\n    it('tap', () => {\n      const f = (n: number) => _.some(n * 2)\n      U.deepStrictEqual(pipe(_.some(1), _.tap(f)), _.some(1))\n      U.deepStrictEqual(_.tap(_.some(1), f), _.some(1))\n    })\n\n    it('chainFirst', () => {\n      const f = (n: number) => _.some(n * 2)\n      U.deepStrictEqual(pipe(_.some(1), _.chainFirst(f)), _.some(1))\n    })\n\n    it('duplicate', () => {\n      U.deepStrictEqual(pipe(_.some(1), _.duplicate), _.some(_.some(1)))\n    })\n\n    it('flatten', () => {\n      U.deepStrictEqual(pipe(_.some(_.some(1)), _.flatten), _.some(1))\n    })\n\n    it('alt', () => {\n      U.deepStrictEqual(\n        pipe(\n          _.some(1),\n          _.alt(() => _.some(2))\n        ),\n        _.some(1)\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.some(2),\n          _.alt(() => _.none as _.Option<number>)\n        ),\n        _.some(2)\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.none,\n          _.alt(() => _.some(1))\n        ),\n        _.some(1)\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.none,\n          _.alt(() => _.none)\n        ),\n        _.none\n      )\n    })\n\n    it('extend', () => {\n      const f = _.getOrElse(() => 0)\n      U.deepStrictEqual(pipe(_.some(2), _.extend(f)), _.some(2))\n      U.deepStrictEqual(pipe(_.none, _.extend(f)), _.none)\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          _.none,\n          _.reduce(2, (b, a) => b + a)\n        ),\n        2\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.some(3),\n          _.reduce(2, (b, a) => b + a)\n        ),\n        5\n      )\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe(_.some('a'), _.foldMap(S.Monoid)(identity)), 'a')\n      U.deepStrictEqual(pipe(_.none, _.foldMap(S.Monoid)(identity)), '')\n    })\n\n    it('reduceRight', () => {\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(pipe(_.some('a'), _.reduceRight('', f)), 'a')\n      U.deepStrictEqual(pipe(_.none, _.reduceRight('', f)), '')\n    })\n\n    it('compact', () => {\n      U.deepStrictEqual(_.compact(_.none), _.none)\n      U.deepStrictEqual(_.compact(_.some(_.none)), _.none)\n      U.deepStrictEqual(_.compact(_.some(_.some('123'))), _.some('123'))\n    })\n\n    it('separate', () => {\n      U.deepStrictEqual(_.separate(_.none), separated(_.none, _.none))\n      U.deepStrictEqual(_.separate(_.some(E.left('123'))), separated(_.some('123'), _.none))\n      U.deepStrictEqual(_.separate(_.some(E.right('123'))), separated(_.none, _.some('123')))\n    })\n\n    it('filter', () => {\n      const predicate = (a: number) => a === 2\n      U.deepStrictEqual(pipe(_.none, _.filter(predicate)), _.none)\n      U.deepStrictEqual(pipe(_.some(1), _.filter(predicate)), _.none)\n      U.deepStrictEqual(pipe(_.some(2), _.filter(predicate)), _.some(2))\n    })\n\n    it('filterMap', () => {\n      const f = (n: number) => (p(n) ? _.some(n + 1) : _.none)\n      U.deepStrictEqual(pipe(_.none, _.filterMap(f)), _.none)\n      U.deepStrictEqual(pipe(_.some(1), _.filterMap(f)), _.none)\n      U.deepStrictEqual(pipe(_.some(3), _.filterMap(f)), _.some(4))\n    })\n\n    it('partition', () => {\n      U.deepStrictEqual(pipe(_.none, _.partition(p)), separated(_.none, _.none))\n      U.deepStrictEqual(pipe(_.some(1), _.partition(p)), separated(_.some(1), _.none))\n      U.deepStrictEqual(pipe(_.some(3), _.partition(p)), separated(_.none, _.some(3)))\n    })\n\n    it('partitionMap', () => {\n      const f = (n: number) => (p(n) ? E.right(n + 1) : E.left(n - 1))\n      U.deepStrictEqual(pipe(_.none, _.partitionMap(f)), separated(_.none, _.none))\n      U.deepStrictEqual(pipe(_.some(1), _.partitionMap(f)), separated(_.some(0), _.none))\n      U.deepStrictEqual(pipe(_.some(3), _.partitionMap(f)), separated(_.none, _.some(4)))\n    })\n\n    it('traverse', () => {\n      U.deepStrictEqual(\n        pipe(\n          _.some('hello'),\n          _.traverse(RA.Applicative)(() => [])\n        ),\n        []\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.some('hello'),\n          _.traverse(RA.Applicative)((s) => [s.length])\n        ),\n        [_.some(5)]\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.none,\n          _.traverse(RA.Applicative)((s) => [s])\n        ),\n        [_.none]\n      )\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(RA.Applicative)\n      U.deepStrictEqual(sequence(_.some([1, 2])), [_.some(1), _.some(2)])\n      U.deepStrictEqual(sequence(_.none), [_.none])\n    })\n\n    it('wither', async () => {\n      const wither = _.wither(T.ApplicativePar)((n: number) => T.of(p(n) ? _.some(n + 1) : _.none))\n      U.deepStrictEqual(await pipe(_.none, wither)(), _.none)\n      U.deepStrictEqual(await pipe(_.some(1), wither)(), _.none)\n      U.deepStrictEqual(await pipe(_.some(3), wither)(), _.some(4))\n    })\n\n    it('wilt', async () => {\n      const wilt = _.wilt(T.ApplicativePar)((n: number) => T.of(p(n) ? E.right(n + 1) : E.left(n - 1)))\n      U.deepStrictEqual(await pipe(_.none, wilt)(), separated(_.none, _.none))\n      U.deepStrictEqual(await pipe(_.some(1), wilt)(), separated(_.some(0), _.none))\n      U.deepStrictEqual(await pipe(_.some(3), wilt)(), separated(_.none, _.some(4)))\n    })\n  })\n\n  describe('constructors', () => {\n    it('fromEither', () => {\n      U.deepStrictEqual(_.fromEither(E.left('a')), _.none)\n      U.deepStrictEqual(_.fromEither(E.right(1)), _.some(1))\n    })\n  })\n\n  it('zero', () => {\n    U.deepStrictEqual(_.zero(), _.none)\n  })\n\n  it('fold', () => {\n    const f = () => 'none'\n    const g = (s: string) => `some${s.length}`\n    const fold = _.fold(f, g)\n    U.deepStrictEqual(fold(_.none), 'none')\n    U.deepStrictEqual(fold(_.some('abc')), 'some3')\n  })\n\n  it('toNullable', () => {\n    U.deepStrictEqual(_.toNullable(_.none), null)\n    U.deepStrictEqual(_.toNullable(_.some(1)), 1)\n  })\n\n  it('toUndefined', () => {\n    U.deepStrictEqual(_.toUndefined(_.none), undefined)\n    U.deepStrictEqual(_.toUndefined(_.some(1)), 1)\n  })\n\n  it('getOrElse', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.some(1),\n        _.getOrElse(() => 0)\n      ),\n      1\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.none,\n        _.getOrElse(() => 0)\n      ),\n      0\n    )\n  })\n\n  it('equals', () => {\n    const { equals } = _.getEq(N.Eq)\n    U.deepStrictEqual(equals(_.none, _.none), true)\n    U.deepStrictEqual(equals(_.none, _.some(1)), false)\n    U.deepStrictEqual(equals(_.some(1), _.none), false)\n    U.deepStrictEqual(equals(_.some(2), _.some(1)), false)\n    U.deepStrictEqual(equals(_.some(1), _.some(2)), false)\n    U.deepStrictEqual(equals(_.some(2), _.some(2)), true)\n  })\n\n  it('getEq', () => {\n    const E = _.getEq(S.Ord)\n    U.deepStrictEqual(E.equals(_.none, _.none), true)\n    U.deepStrictEqual(E.equals(_.some('a'), _.none), false)\n    U.deepStrictEqual(E.equals(_.none, _.some('a')), false)\n    U.deepStrictEqual(E.equals(_.some('a'), _.some('a')), true)\n    U.deepStrictEqual(E.equals(_.some('a'), _.some('b')), false)\n  })\n\n  it('getOrd', () => {\n    const OS = _.getOrd(S.Ord)\n    U.deepStrictEqual(OS.compare(_.none, _.none), 0)\n    U.deepStrictEqual(OS.compare(_.none, { _tag: 'None' }), 0)\n    U.deepStrictEqual(OS.compare(_.some('a'), _.none), 1)\n    U.deepStrictEqual(OS.compare(_.none, _.some('a')), -1)\n    U.deepStrictEqual(OS.compare(_.some('a'), _.some('a')), 0)\n    U.deepStrictEqual(OS.compare(_.some('a'), _.some('b')), -1)\n    U.deepStrictEqual(OS.compare(_.some('b'), _.some('a')), 1)\n  })\n\n  it('chainNullableK', () => {\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    U.deepStrictEqual(\n      pipe(\n        _.fromNullable(x1.a),\n        _.chainNullableK((x) => x.b),\n        _.chainNullableK((x) => x.c),\n        _.chainNullableK((x) => x.d)\n      ),\n      _.none\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.fromNullable(x2.a),\n        _.chainNullableK((x) => x.b),\n        _.chainNullableK((x) => x.c),\n        _.chainNullableK((x) => x.d)\n      ),\n      _.none\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.fromNullable(x3.a),\n        _.chainNullableK((x) => x.b),\n        _.chainNullableK((x) => x.c),\n        _.chainNullableK((x) => x.d)\n      ),\n      _.some(1)\n    )\n  })\n\n  it('getMonoid', () => {\n    const { concat } = _.getMonoid(S.Semigroup)\n    U.deepStrictEqual(concat(_.none, _.none), _.none)\n    U.deepStrictEqual(concat(_.none, _.some('a')), _.some('a'))\n    U.deepStrictEqual(concat(_.some('a'), _.none), _.some('a'))\n    U.deepStrictEqual(concat(_.some('b'), _.some('a')), _.some('ba'))\n    U.deepStrictEqual(concat(_.some('a'), _.some('b')), _.some('ab'))\n  })\n\n  it('fromNullable', () => {\n    U.deepStrictEqual(_.fromNullable(2), _.some(2))\n    U.deepStrictEqual(_.fromNullable(null), _.none)\n    U.deepStrictEqual(_.fromNullable(undefined), _.none)\n  })\n\n  it('fromPredicate', () => {\n    const f = _.fromPredicate(p)\n    U.deepStrictEqual(f(1), _.none)\n    U.deepStrictEqual(f(3), _.some(3))\n\n    type Direction = 'asc' | 'desc'\n    const parseDirection = _.fromPredicate((s: string): s is Direction => s === 'asc' || s === 'desc')\n    U.deepStrictEqual(parseDirection('asc'), _.some('asc'))\n    U.deepStrictEqual(parseDirection('foo'), _.none)\n  })\n\n  it('getApplySemigroup', () => {\n    const S = _.getApplySemigroup(N.SemigroupSum)\n    U.deepStrictEqual(S.concat(_.none, _.none), _.none)\n    U.deepStrictEqual(S.concat(_.some(1), _.none), _.none)\n    U.deepStrictEqual(S.concat(_.none, _.some(1)), _.none)\n    U.deepStrictEqual(S.concat(_.some(1), _.some(2)), _.some(3))\n  })\n\n  it('getApplyMonoid', () => {\n    const M = _.getApplyMonoid(N.MonoidSum)\n    U.deepStrictEqual(M.concat(M.empty, _.none), _.none)\n    U.deepStrictEqual(M.concat(_.none, M.empty), _.none)\n    U.deepStrictEqual(M.concat(M.empty, _.some(1)), _.some(1))\n    U.deepStrictEqual(M.concat(_.some(1), M.empty), _.some(1))\n  })\n\n  it('getFirstMonoid', () => {\n    const M = _.getFirstMonoid<number>()\n    U.deepStrictEqual(M.concat(_.none, _.none), _.none)\n    U.deepStrictEqual(M.concat(_.some(1), _.none), _.some(1))\n    U.deepStrictEqual(M.concat(_.none, _.some(2)), _.some(2))\n    U.deepStrictEqual(M.concat(_.some(1), _.some(2)), _.some(1))\n  })\n\n  it('getLastMonoid', () => {\n    const M = _.getLastMonoid<number>()\n    U.deepStrictEqual(M.concat(_.none, _.none), _.none)\n    U.deepStrictEqual(M.concat(_.some(1), _.none), _.some(1))\n    U.deepStrictEqual(M.concat(_.none, _.some(2)), _.some(2))\n    U.deepStrictEqual(M.concat(_.some(1), _.some(2)), _.some(2))\n  })\n\n  it('elem', () => {\n    U.deepStrictEqual(_.elem(N.Eq)(2, _.none), false)\n    U.deepStrictEqual(_.elem(N.Eq)(2, _.some(2)), true)\n    U.deepStrictEqual(_.elem(N.Eq)(1, _.some(2)), false)\n    U.deepStrictEqual(pipe(_.none, _.elem(N.Eq)(2)), false)\n    U.deepStrictEqual(pipe(_.some(2), _.elem(N.Eq)(2)), true)\n    U.deepStrictEqual(pipe(_.some(2), _.elem(N.Eq)(1)), false)\n  })\n\n  it('isNone', () => {\n    U.deepStrictEqual(_.isNone(_.none), true)\n    U.deepStrictEqual(_.isNone(_.some(1)), false)\n  })\n\n  it('isSome', () => {\n    U.deepStrictEqual(_.isSome(_.none), false)\n    U.deepStrictEqual(_.isSome(_.some(1)), true)\n  })\n\n  it('exists', () => {\n    const predicate = (a: number) => a === 2\n    U.deepStrictEqual(pipe(_.none, _.exists(predicate)), false)\n    U.deepStrictEqual(pipe(_.some(1), _.exists(predicate)), false)\n    U.deepStrictEqual(pipe(_.some(2), _.exists(predicate)), true)\n  })\n\n  it('tryCatch', () => {\n    U.deepStrictEqual(\n      _.tryCatch(() => JSON.parse('2')),\n      _.some(2)\n    )\n    U.deepStrictEqual(\n      _.tryCatch(() => JSON.parse('(')),\n      _.none\n    )\n  })\n\n  it('getRefinement', () => {\n    const f = (s: string | number): _.Option<string> => (typeof s === 'string' ? _.some(s) : _.none)\n    const isString = _.getRefinement(f)\n    U.deepStrictEqual(isString('s'), true)\n    U.deepStrictEqual(isString(1), false)\n    type A = { readonly type: 'A' }\n    type B = { readonly type: 'B' }\n    type C = A | B\n    const isA = _.getRefinement<C, A>((c) => (c.type === 'A' ? _.some(c) : _.none))\n    U.deepStrictEqual(isA({ type: 'A' }), true)\n    U.deepStrictEqual(isA({ type: 'B' }), false)\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    U.deepStrictEqual(Sh.show(_.some('a')), `some(\"a\")`)\n    U.deepStrictEqual(Sh.show(_.none), `none`)\n  })\n\n  it('getLeft', () => {\n    U.deepStrictEqual(_.getLeft(E.right(1)), _.none)\n    U.deepStrictEqual(_.getLeft(E.left('err')), _.some('err'))\n  })\n\n  it('getRight', () => {\n    U.deepStrictEqual(_.getRight(E.right(1)), _.some(1))\n    U.deepStrictEqual(_.getRight(E.left('err')), _.none)\n  })\n\n  it('throwError', () => {\n    U.deepStrictEqual(_.throwError(undefined), _.none)\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.some(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.some('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      ),\n      _.some({ a: 1, b: 'b', c: [1, 'b'] })\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(pipe(_.some(1), _.bindTo('a'), _.apS('b', _.some('b'))), _.some({ a: 1, b: 'b' }))\n  })\n\n  it('fromNullableK', () => {\n    const f = _.fromNullableK((n: number) => (n > 0 ? n : null))\n    U.deepStrictEqual(f(1), _.some(1))\n    U.deepStrictEqual(f(-1), _.none)\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.some(a + i) : _.none))\n      U.deepStrictEqual(pipe(RA.empty, f), _.some(RA.empty))\n      U.deepStrictEqual(pipe(input, f), _.some(['a0', 'b1']))\n      U.deepStrictEqual(pipe(['a', ''], f), _.none)\n    })\n\n    it('sequenceArray', () => {\n      U.deepStrictEqual(pipe([_.of(1), _.of(2)], _.sequenceArray), _.some([1, 2]))\n      U.deepStrictEqual(pipe([_.of(1), _.none], _.sequenceArray), _.none)\n    })\n  })\n\n  it('tryCatchK', () => {\n    const f = _.tryCatchK((s: string) => {\n      const len = s.length\n      if (len > 0) {\n        return len\n      }\n      throw new Error('empty string')\n    })\n    U.deepStrictEqual(f('a'), _.some(1))\n    U.deepStrictEqual(f(''), _.none)\n  })\n\n  it('guard', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.Do,\n        _.bind('x', () => _.some('a')),\n        _.bind('y', () => _.some('a')),\n        _.chainFirst(({ x, y }) => _.guard(x === y))\n      ),\n      _.some({ x: 'a', y: 'a' })\n    )\n    U.deepStrictEqual(\n      pipe(\n        _.Do,\n        _.bind('x', () => _.some('a')),\n        _.bind('y', () => _.some('b')),\n        _.chainFirst(({ x, y }) => _.guard(x === y))\n      ),\n      _.none\n    )\n  })\n\n  it('tapEither', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(pipe(_.some('a'), _.tapEither(f)), _.some('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(pipe(_.some('a'), _.tapEither(g)), _.none)\n  })\n\n  it('chainFirstEitherK', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(pipe(_.some('a'), _.chainFirstEitherK(f)), _.some('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(pipe(_.some('a'), _.chainFirstEitherK(g)), _.none)\n  })\n\n  it('as', () => {\n    U.deepStrictEqual(pipe(_.some('a'), _.as('b')), _.some('b'))\n    U.deepStrictEqual(_.as(_.of('a'), 'b'), _.some('b'))\n    U.deepStrictEqual(_.as(_.none, 'b'), _.none)\n  })\n\n  it('asUnit', () => {\n    U.deepStrictEqual(pipe(_.some('a'), _.asUnit), _.some(undefined))\n  })\n})\n"
  },
  {
    "path": "test/OptionT.ts",
    "content": "import * as O from '../src/Option'\nimport { getOptionM } from '../src/OptionT'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\nconst MT = getOptionM(T.Monad)\n\ndescribe('OptionT', () => {\n  it('map', async () => {\n    const greetingT = MT.of('welcome')\n    const excitedGreetingT = MT.map(greetingT, (s) => s + '!')\n    U.deepStrictEqual(await excitedGreetingT(), O.some('welcome!'))\n  })\n\n  it('ap', async () => {\n    const a = MT.of('a')\n    const b = MT.of('b')\n    U.deepStrictEqual(\n      await MT.ap(\n        MT.map(a, (a) => (b) => [a, b]),\n        b\n      )(),\n      O.some(['a', 'b'])\n    )\n  })\n\n  it('chain', async () => {\n    const to1 = MT.chain(MT.of('foo'), (a) => MT.of(a.length))\n    const to2 = MT.chain(T.of(O.none), (a: string) => MT.of(a.length))\n    const [o1, o2] = await Promise.all([to1(), to2()])\n    U.deepStrictEqual(o1, O.some(3))\n    U.deepStrictEqual(o2, O.none)\n  })\n\n  it('fold', async () => {\n    const f = () => T.of('none')\n    const g = (s: string) => T.of(`some${s.length}`)\n    const s1 = await MT.fold(T.of(O.none), f, g)()\n    U.deepStrictEqual(s1, 'none')\n    const s2 = await MT.fold(MT.of('s'), f, g)()\n    U.deepStrictEqual(s2, 'some1')\n  })\n\n  it('alt', async () => {\n    const o1 = await MT.alt(T.of(O.some(1)), () => T.of(O.some(2)))()\n    U.deepStrictEqual(o1, O.some(1))\n    const o2 = await MT.alt(T.of(O.none), () => T.of(O.some(2)))()\n    U.deepStrictEqual(o2, O.some(2))\n  })\n\n  it('getOrElse', async () => {\n    const n1 = await MT.getOrElse(T.of(O.some(1)), () => T.of(2))()\n    U.deepStrictEqual(n1, 1)\n    const n2 = await MT.getOrElse(T.of(O.none), () => T.of(2))()\n    U.deepStrictEqual(n2, 2)\n  })\n\n  it('fromM', async () => {\n    U.deepStrictEqual(await MT.fromM(T.of(1))(), O.some(1))\n  })\n\n  it('none', async () => {\n    U.deepStrictEqual(await MT.none()(), O.none)\n  })\n})\n"
  },
  {
    "path": "test/Ord.ts",
    "content": "import * as B from '../src/boolean'\nimport { pipe } from '../src/function'\nimport { concatAll } from '../src/Monoid'\nimport * as N from '../src/number'\nimport * as _ from '../src/Ord'\nimport { sort } from '../src/ReadonlyArray'\nimport * as RR from '../src/ReadonlyRecord'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('Ord', () => {\n  it('tuple', () => {\n    const O = _.tuple(S.Ord, N.Ord, B.Ord)\n    U.deepStrictEqual(O.compare(['a', 1, true], ['b', 2, true]), -1)\n    U.deepStrictEqual(O.compare(['a', 1, true], ['a', 2, true]), -1)\n    U.deepStrictEqual(O.compare(['a', 1, true], ['a', 1, false]), 1)\n  })\n\n  it('getMonoid', () => {\n    type T = readonly [number, string]\n    const tuples: ReadonlyArray<T> = [\n      [2, 'c'],\n      [1, 'b'],\n      [2, 'a'],\n      [1, 'c']\n    ]\n    const M = _.getMonoid<T>()\n    const sortByFst = pipe(\n      N.Ord,\n      _.contramap((x: T) => x[0])\n    )\n    const sortBySnd = pipe(\n      S.Ord,\n      _.contramap((x: T) => x[1])\n    )\n    //                  v-- left unit\n    const O1 = concatAll(M)([M.empty, sortByFst, sortBySnd])\n    U.deepStrictEqual(sort(O1)(tuples), [\n      [1, 'b'],\n      [1, 'c'],\n      [2, 'a'],\n      [2, 'c']\n    ])\n    //                           right unit --v\n    const O2 = concatAll(M)([sortBySnd, sortByFst, M.empty])\n    U.deepStrictEqual(sort(O2)(tuples), [\n      [2, 'a'],\n      [1, 'b'],\n      [1, 'c'],\n      [2, 'c']\n    ])\n  })\n\n  it('clamp', () => {\n    const clampNumber = _.clamp(N.Ord)\n    U.deepStrictEqual(clampNumber(1, 10)(2), 2)\n    U.deepStrictEqual(clampNumber(1, 10)(10), 10)\n    U.deepStrictEqual(clampNumber(1, 10)(20), 10)\n    U.deepStrictEqual(clampNumber(1, 10)(1), 1)\n    U.deepStrictEqual(clampNumber(1, 10)(-10), 1)\n  })\n\n  it('between', () => {\n    const betweenNumber = _.between(N.Ord)\n    U.deepStrictEqual(betweenNumber(1, 10)(2), true)\n    U.deepStrictEqual(betweenNumber(1, 10)(10), true)\n    U.deepStrictEqual(betweenNumber(1, 10)(20), false)\n    U.deepStrictEqual(betweenNumber(1, 10)(1), true)\n    U.deepStrictEqual(betweenNumber(1, 10)(-10), false)\n  })\n\n  it('reverse', () => {\n    const O = _.reverse(N.Ord)\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('leq', () => {\n    U.deepStrictEqual(_.leq(N.Ord)(0, 1), true)\n    U.deepStrictEqual(_.leq(N.Ord)(1, 1), true)\n    U.deepStrictEqual(_.leq(N.Ord)(2, 1), false)\n  })\n\n  it('geq', () => {\n    U.deepStrictEqual(_.geq(N.Ord)(0, 1), false)\n    U.deepStrictEqual(_.geq(N.Ord)(1, 1), true)\n    U.deepStrictEqual(_.geq(N.Ord)(2, 1), true)\n  })\n\n  it('fromCompare', () => {\n    const O1 = _.fromCompare(N.Ord.compare)\n    U.deepStrictEqual(O1.equals(0, 1), false)\n    U.deepStrictEqual(O1.equals(1, 1), true)\n    interface A {\n      readonly x: number\n    }\n    let nbCall = 0\n    const O2 = _.fromCompare<A>((a, b) => {\n      nbCall += 1\n      return N.Ord.compare(a.x, b.x)\n    })\n    const a1 = { x: 1 }\n    const a2 = { x: 1 }\n    U.deepStrictEqual(O2.equals(a1, a1), true)\n    U.deepStrictEqual(nbCall, 0)\n    U.deepStrictEqual(O2.equals(a1, a2), true)\n    U.deepStrictEqual(nbCall, 1)\n    U.deepStrictEqual(O2.compare(a1, a1), 0)\n    U.deepStrictEqual(nbCall, 1)\n    U.deepStrictEqual(O2.compare(a1, a2), 0)\n    U.deepStrictEqual(nbCall, 2)\n  })\n\n  it('min', () => {\n    type A = { readonly a: number }\n    const min = _.min(\n      pipe(\n        N.Ord,\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 = { readonly a: number }\n    const max = _.max(\n      pipe(\n        N.Ord,\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  it('equals', () => {\n    const equals = _.equals(N.Ord)\n    U.deepStrictEqual(equals(1)(1), true)\n    U.deepStrictEqual(equals(1)(2), false)\n  })\n\n  it('trivial', () => {\n    const toReadonlyArray = RR.collect(_.trivial)((k, a) => [k, a])\n    U.deepStrictEqual(toReadonlyArray({ a: 1, b: 2 }), [\n      ['a', 1],\n      ['b', 2]\n    ])\n    U.deepStrictEqual(toReadonlyArray({ b: 2, a: 1 }), [\n      ['b', 2],\n      ['a', 1]\n    ])\n  })\n\n  it('ordDate', () => {\n    const O = _.ordDate\n    U.deepStrictEqual(O.compare(new Date(0), new Date(0)), 0)\n    U.deepStrictEqual(O.compare(new Date(0), new Date(1)), -1)\n    U.deepStrictEqual(O.compare(new Date(1), new Date(0)), 1)\n  })\n})\n"
  },
  {
    "path": "test/Ordering.ts",
    "content": "import * as _ from '../src/Ordering'\nimport * as U from './util'\n\ndescribe('Ordering', () => {\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('Eq', () => {\n    U.deepStrictEqual(_.Eq.equals(-1, -1), true)\n    U.deepStrictEqual(_.Eq.equals(-1, 0), false)\n    U.deepStrictEqual(_.Eq.equals(-1, 1), false)\n    U.deepStrictEqual(_.Eq.equals(0, -1), false)\n    U.deepStrictEqual(_.Eq.equals(0, 0), true)\n    U.deepStrictEqual(_.Eq.equals(0, 1), false)\n    U.deepStrictEqual(_.Eq.equals(1, -1), false)\n    U.deepStrictEqual(_.Eq.equals(1, 0), false)\n    U.deepStrictEqual(_.Eq.equals(1, 1), true)\n  })\n\n  it('Monoid', () => {\n    // concat\n    U.deepStrictEqual(_.Monoid.concat(-1, -1), -1)\n    U.deepStrictEqual(_.Monoid.concat(-1, 0), -1)\n    U.deepStrictEqual(_.Monoid.concat(-1, 1), -1)\n    U.deepStrictEqual(_.Monoid.concat(0, -1), -1)\n    U.deepStrictEqual(_.Monoid.concat(0, 0), 0)\n    U.deepStrictEqual(_.Monoid.concat(0, 1), 1)\n    U.deepStrictEqual(_.Monoid.concat(1, -1), 1)\n    U.deepStrictEqual(_.Monoid.concat(1, 0), 1)\n    U.deepStrictEqual(_.Monoid.concat(1, 1), 1)\n\n    // empty\n    U.deepStrictEqual(_.Monoid.concat(1, _.Monoid.empty), 1)\n    U.deepStrictEqual(_.Monoid.concat(_.Monoid.empty, 1), 1)\n    U.deepStrictEqual(_.Monoid.concat(-1, _.Monoid.empty), -1)\n    U.deepStrictEqual(_.Monoid.concat(_.Monoid.empty, -1), -1)\n    U.deepStrictEqual(_.Monoid.concat(0, _.Monoid.empty), 0)\n    U.deepStrictEqual(_.Monoid.concat(_.Monoid.empty, 0), 0)\n  })\n\n  // -------------------------------------------------------------------------------------\n  // destructors\n  // -------------------------------------------------------------------------------------\n\n  it('sign', () => {\n    const f = _.match(\n      () => 'lt',\n      () => 'eq',\n      () => 'gt'\n    )\n    U.deepStrictEqual(f(-1), 'lt')\n    U.deepStrictEqual(f(0), 'eq')\n    U.deepStrictEqual(f(1), 'gt')\n  })\n\n  // -------------------------------------------------------------------------------------\n  // utils\n  // -------------------------------------------------------------------------------------\n\n  it('sign', () => {\n    U.deepStrictEqual(_.sign(10), 1)\n    U.deepStrictEqual(_.sign(0), 0)\n    U.deepStrictEqual(_.sign(-10), -1)\n  })\n\n  it('reverse', () => {\n    U.deepStrictEqual(_.reverse(-1), 1)\n    U.deepStrictEqual(_.reverse(0), 0)\n    U.deepStrictEqual(_.reverse(1), -1)\n  })\n})\n"
  },
  {
    "path": "test/Predicate.ts",
    "content": "import { pipe } from '../src/function'\nimport * as _ from '../src/Predicate'\nimport * as U from './util'\n\nconst isPositive: _.Predicate<number> = (n) => n > 0\nconst isNegative: _.Predicate<number> = (n) => n < 0\nconst lt2: _.Predicate<number> = (n) => n < 2\n\ndescribe('Predicate', () => {\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    U.deepStrictEqual(predicate({ a: -1 }), false)\n    U.deepStrictEqual(predicate({ a: 0 }), false)\n    U.deepStrictEqual(predicate({ a: 1 }), true)\n  })\n\n  it('Contravariant.contramap', () => {\n    type A = {\n      readonly a: number\n    }\n    const predicate = _.Contravariant.contramap(isPositive, (a: A) => a.a)\n    U.deepStrictEqual(predicate({ a: -1 }), false)\n    U.deepStrictEqual(predicate({ a: 0 }), false)\n    U.deepStrictEqual(predicate({ a: 1 }), true)\n  })\n\n  it('not', () => {\n    const predicate = _.not(isPositive)\n    U.deepStrictEqual(predicate(1), false)\n    U.deepStrictEqual(predicate(0), true)\n    U.deepStrictEqual(predicate(-1), true)\n  })\n\n  it('getMonoidAny', () => {\n    const M = _.getMonoidAny<number>()\n    const predicate = M.concat(isPositive, isNegative)\n    U.deepStrictEqual(predicate(0), false)\n    U.deepStrictEqual(predicate(-1), true)\n    U.deepStrictEqual(predicate(1), true)\n  })\n\n  it('getMonoidAll', () => {\n    const M = _.getMonoidAll<number>()\n    const predicate = M.concat(isPositive, lt2)\n    U.deepStrictEqual(predicate(0), false)\n    U.deepStrictEqual(predicate(-2), false)\n    U.deepStrictEqual(predicate(1), true)\n  })\n})\n"
  },
  {
    "path": "test/Random.ts",
    "content": "import * as _ from '../src/Random'\nimport * as U from './util'\n\ndescribe('Random', () => {\n  it('random', () => {\n    const n = _.random()\n    U.deepStrictEqual(typeof n, 'number')\n  })\n\n  it('randomInt', () => {\n    const n = _.randomInt(0, 10)()\n    U.deepStrictEqual(typeof n, 'number')\n    U.deepStrictEqual(n % 1 === 0, true)\n    U.deepStrictEqual(n >= 0, true)\n    U.deepStrictEqual(n <= 10, true)\n  })\n\n  it('randomRange', () => {\n    for (let i = 0; i < 10; i++) {\n      const n = _.randomRange(0, 10)()\n      U.deepStrictEqual(typeof n, 'number')\n      U.deepStrictEqual(n >= 0, true)\n      U.deepStrictEqual(n < 10, true)\n    }\n  })\n\n  it('randomBool', () => {\n    const b = _.randomBool()\n    U.deepStrictEqual(typeof b, 'boolean')\n  })\n\n  it('randomElem', () => {\n    const e = _.randomElem([1, 2, 3])()\n    U.deepStrictEqual(e >= 1 && e <= 3, true)\n  })\n})\n"
  },
  {
    "path": "test/Reader.ts",
    "content": "import { pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as _ from '../src/Reader'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ninterface Env {\n  readonly count: number\n}\n\ndescribe('Reader', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      U.deepStrictEqual(pipe(_.of(1), _.map(U.double))({}), 2)\n    })\n\n    it('ap', () => {\n      U.deepStrictEqual(pipe(_.of(U.double), _.ap(_.of(1)))({}), 2)\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe(_.of('a'), _.apFirst(_.of('b')))({}), 'a')\n    })\n\n    it('apFirstW', () => {\n      const fb = _.of<{ readonly k: string }, boolean>(true)\n      U.deepStrictEqual(pipe(_.of<{ readonly x: number }, string>('foo'), _.apFirstW(fb))({ x: 1, k: 'v' }), 'foo')\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe(_.of('a'), _.apSecond(_.of('b')))({}), 'b')\n    })\n\n    it('apSecondW', () => {\n      const fb = _.of<{ readonly k: string }, boolean>(true)\n      U.deepStrictEqual(pipe(_.of<{ readonly x: number }, string>('foo'), _.apSecondW(fb))({ x: 1, k: 'v' }), true)\n    })\n\n    it('flatMap', () => {\n      const f = (s: string): _.Reader<object, number> => _.of(s.length)\n      U.deepStrictEqual(pipe(_.of('foo'), _.chain(f))({}), 3)\n    })\n\n    it('chain', () => {\n      const f = (s: string): _.Reader<object, number> => _.of(s.length)\n      U.deepStrictEqual(pipe(_.of('foo'), _.flatMap(f))({}), 3)\n      U.deepStrictEqual(_.flatMap(_.of('foo'), f)({}), 3)\n    })\n\n    it('tap', () => {\n      const f = (s: string): _.Reader<object, number> => _.of(s.length)\n      U.deepStrictEqual(pipe(_.of('foo'), _.tap(f))({}), 'foo')\n      U.deepStrictEqual(_.tap(_.of('foo'), f)({}), 'foo')\n    })\n\n    it('chainFirst', () => {\n      const f = (s: string): _.Reader<object, number> => _.of(s.length)\n      U.deepStrictEqual(pipe(_.of('foo'), _.chainFirst(f))({}), 'foo')\n    })\n\n    it('chainFirstW', () => {\n      const f = (s: string) => _.of(s.length)\n      U.deepStrictEqual(pipe(_.of<object, string>('foo'), _.chainFirstW(f))({}), 'foo')\n    })\n\n    it('flatten', () => {\n      U.deepStrictEqual(pipe(_.of(_.of('a')), _.flatten)({}), 'a')\n    })\n\n    type R1 = { readonly env1: unknown }\n    type R2 = { readonly env2: unknown }\n\n    it('flattenW', () => {\n      U.deepStrictEqual(pipe(_.of<R1, _.Reader<R2, 'a'>>(_.of('a')), _.flattenW)({ env1: '', env2: '' }), 'a')\n    })\n\n    it('compose', () => {\n      U.deepStrictEqual(pipe(U.double, _.compose(S.size))('aaa'), 6)\n    })\n\n    it('promap', () => {\n      const x = (s: string) => s.length\n      const reader = pipe(\n        x,\n        _.promap(\n          (a: { readonly name: string }) => a.name,\n          (n) => n >= 2\n        )\n      )\n      U.deepStrictEqual(reader({ name: 'foo' }), true)\n      U.deepStrictEqual(reader({ name: 'a' }), false)\n    })\n  })\n\n  it('of', () => {\n    U.deepStrictEqual(_.of(1)({}), 1)\n  })\n\n  it('local', () => {\n    interface E {\n      readonly name: string\n    }\n    const x = pipe(\n      (s: string) => s.length,\n      _.local((e: E) => e.name)\n    )\n    U.deepStrictEqual(x({ name: 'foo' }), 3)\n  })\n\n  it('id', () => {\n    const x = _.id<number>()\n    U.deepStrictEqual(x(1), 1)\n  })\n\n  it('compose', () => {\n    const x = (s: string) => s.length\n    const y = (n: number) => n >= 2\n    const z = pipe(y, _.compose(x))\n    U.deepStrictEqual(z('foo'), true)\n    U.deepStrictEqual(z('a'), false)\n  })\n\n  it('getSemigroup', () => {\n    const S = _.getSemigroup(N.SemigroupSum)\n    U.deepStrictEqual(S.concat(_.of(1), _.of(2))({}), 3)\n  })\n\n  it('getMonoid', () => {\n    const M = _.getMonoid(N.MonoidSum)\n    U.deepStrictEqual(M.concat(_.of(1), M.empty)({}), 1)\n    U.deepStrictEqual(M.concat(M.empty, _.of(1))({}), 1)\n  })\n\n  it('ask', () => {\n    const e: Env = { count: 0 }\n    U.deepStrictEqual(_.ask<Env>()(e), e)\n  })\n\n  it('asks', () => {\n    const e: Env = { count: 0 }\n    const f = (e: Env) => e.count + 1\n    U.deepStrictEqual(_.asks(f)(e), 1)\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )(undefined),\n      { a: 1, b: 'b', c: [1, 'b'] }\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b')))(undefined), { a: 1, b: 'b' })\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => _.of(a + i))\n      U.strictEqual(pipe(RA.empty, f)({}), RA.empty)\n      U.deepStrictEqual(pipe(input, f)({}), ['a0', 'b1'])\n    })\n\n    it('sequenceArray', () => {\n      U.deepStrictEqual(pipe([_.of(1), _.of(2)], _.sequenceArray)(undefined), [1, 2])\n    })\n  })\n\n  it('asksReader', () => {\n    const e: Env = { count: 0 }\n    const f = (e: Env) => _.of(e.count + 1)\n    U.deepStrictEqual(_.asksReader(f)(e), 1)\n  })\n})\n"
  },
  {
    "path": "test/ReaderEither.ts",
    "content": "import * as Apply from '../src/Apply'\nimport * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as R from '../src/Reader'\nimport * as _ from '../src/ReaderEither'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport { left, right } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('ReaderEither', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      U.deepStrictEqual(pipe(_.right(1), _.map(U.double))({}), E.right(2))\n    })\n\n    it('alt', () => {\n      U.deepStrictEqual(\n        pipe(\n          _.right('a'),\n          _.alt(() => _.right('b'))\n        )({}),\n        E.right('a')\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.left(1),\n          _.alt(() => _.right('b'))\n        )({}),\n        E.right('b')\n      )\n    })\n\n    it('ap', () => {\n      U.deepStrictEqual(pipe(_.right(U.double), _.ap(_.right(1)))({}), E.right(2))\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe(_.right('a'), _.apFirst(_.right('b')))({}), E.right('a'))\n    })\n\n    it('apFirstW', () => {\n      const fa = _.right<{ readonly k: string }, 'Foo', string>('a')\n      const fb = _.right<{ readonly x: number }, 'Bar', number>(4)\n      U.deepStrictEqual(pipe(fa, _.apFirstW(fb))({ k: 'v', x: 1 }), E.right('a'))\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe(_.right('a'), _.apSecond(_.right('b')))({}), E.right('b'))\n    })\n\n    it('apSecondW', () => {\n      const fa = _.right<{ readonly k: string }, 'Foo', string>('a')\n      const fb = _.right<{ readonly x: number }, 'Bar', number>(4)\n      U.deepStrictEqual(pipe(fa, _.apSecondW(fb))({ k: 'v', x: 1 }), E.right(4))\n    })\n\n    it('tap', () => {\n      const f = (n: number) => _.right(n * 2)\n      U.deepStrictEqual(pipe(_.right(1), _.tap(f))({}), E.right(1))\n      U.deepStrictEqual(_.tap(_.right(1), f)({}), E.right(1))\n    })\n\n    it('chainFirst', () => {\n      const f = (n: number) => _.right(n * 2)\n      U.deepStrictEqual(pipe(_.right(1), _.chainFirst(f))({}), E.right(1))\n    })\n\n    it('chainFirstW', () => {\n      const f = (n: number) => _.right<unknown, boolean, number>(n * 2)\n      U.deepStrictEqual(pipe(_.right<unknown, string, number>(1), _.chainFirstW(f))({}), E.right(1))\n    })\n\n    it('flatten', () => {\n      U.deepStrictEqual(pipe(_.right(_.right('a')), _.flatten)({}), E.right('a'))\n    })\n\n    type R1 = { readonly env1: unknown }\n    type R2 = { readonly env2: unknown }\n    type E1 = { readonly left1: unknown }\n    type E2 = { readonly left2: unknown }\n\n    it('flattenW', () => {\n      U.deepStrictEqual(\n        pipe(_.right<R1, E1, _.ReaderEither<R2, E2, 'a'>>(_.right('a')), _.flattenW)({ env1: '', env2: '' }),\n        E.right('a')\n      )\n    })\n\n    it('mapLeft', () => {\n      U.deepStrictEqual(pipe(_.right(1), _.mapLeft(S.size))({}), E.right(1))\n      U.deepStrictEqual(pipe(_.left('aa'), _.mapLeft(S.size))({}), E.left(2))\n    })\n\n    it('bimap', () => {\n      U.deepStrictEqual(pipe(_.right(1), _.bimap(S.size, U.double))({}), E.right(2))\n      U.deepStrictEqual(pipe(_.left('aaa'), _.bimap(S.size, U.double))({}), E.left(3))\n    })\n\n    it('fromOption', () => {\n      U.deepStrictEqual(\n        pipe(\n          O.none,\n          _.fromOption(() => 'none')\n        )({}),\n        E.left('none')\n      )\n      U.deepStrictEqual(\n        pipe(\n          O.some(1),\n          _.fromOption(() => 'none')\n        )({}),\n        E.right(1)\n      )\n    })\n\n    it('fromPredicate', () => {\n      const gt2 = _.fromPredicate(\n        (n: number) => n >= 2,\n        (n) => `Invalid number ${n}`\n      )\n      U.deepStrictEqual(gt2(3)({}), E.right(3))\n      U.deepStrictEqual(gt2(1)({}), E.left('Invalid number 1'))\n    })\n\n    it('filterOrElse', () => {\n      const e1 = pipe(\n        _.right(12),\n        _.filterOrElse(\n          (n) => n > 10,\n          () => 'a'\n        )\n      )({})\n      U.deepStrictEqual(e1, E.right(12))\n      const e2 = pipe(\n        _.right(7),\n        _.filterOrElse(\n          (n) => n > 10,\n          () => 'a'\n        )\n      )({})\n      U.deepStrictEqual(e2, E.left('a'))\n    })\n  })\n\n  it('fold', () => {\n    const fold = _.fold(\n      (s: string) => R.of(s.length),\n      (n: number) => R.of(n * 2)\n    )\n    U.deepStrictEqual(fold(_.right(1))({}), 2)\n    U.deepStrictEqual(fold(_.left('aaa'))({}), 3)\n  })\n\n  it('getOrElse', () => {\n    const getOrElse = _.getOrElse((s: string) => R.of(s.length))\n    U.deepStrictEqual(getOrElse(_.right(1))({}), 1)\n    U.deepStrictEqual(getOrElse(_.left('aaa'))({}), 3)\n  })\n\n  it('orElse', () => {\n    const orElse = _.orElse((s: string) => (s.length > 2 ? _.right(1) : _.left(2)))\n    U.deepStrictEqual(orElse(_.right(1))({}), E.right(1))\n  })\n\n  it('orElseW', () => {\n    const orElse = _.orElseW((s: string) => (s.length > 2 ? _.right(1) : _.left(2)))\n    U.deepStrictEqual(orElse(_.right(1))({}), E.right(1))\n  })\n\n  it('flatMapOption', () => {\n    const f = _.flatMapOption(\n      (n: number) => (n > 0 ? O.some(n) : O.none),\n      () => 'a'\n    )\n    U.deepStrictEqual(f(_.right(1))(undefined), E.right(1))\n    U.deepStrictEqual(f(_.right(-1))(undefined), E.left('a'))\n    U.deepStrictEqual(f(_.left('b'))(undefined), E.left('b'))\n  })\n\n  it('tapError', () => {\n    const f = (s: string) => (s.length <= 1 ? _.right(true) : _.left(s + '!'))\n    U.deepStrictEqual(pipe(_.right(1), _.tapError(f))({}), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), _.tapError(f))({}), E.left('a'))\n    U.deepStrictEqual(pipe(_.left('aa'), _.tapError(f))({}), E.left('aa!'))\n    U.deepStrictEqual(_.tapError(_.right(1), f)({}), E.right(1))\n    U.deepStrictEqual(_.tapError(_.left('a'), f)({}), E.left('a'))\n    U.deepStrictEqual(_.tapError(_.left('aa'), f)({}), E.left('aa!'))\n  })\n\n  it('orElseFirst', () => {\n    const f = _.orElseFirst((s: string) => (s.length <= 1 ? _.right(true) : _.left(s + '!')))\n    U.deepStrictEqual(pipe(_.right(1), f)({}), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), f)({}), E.left('a'))\n    U.deepStrictEqual(pipe(_.left('aa'), f)({}), E.left('aa!'))\n  })\n\n  it('orElseFirstW', () => {\n    const f = _.orElseFirstW((s: string) => (s.length <= 1 ? _.right(true) : _.left(s + '!')))\n    U.deepStrictEqual(pipe(_.right(1), f)({}), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), f)({}), E.left('a'))\n    U.deepStrictEqual(pipe(_.left('aa'), f)({}), E.left('aa!'))\n  })\n\n  it('orLeft', () => {\n    const f = _.orLeft((s: string) => R.of(s + '!'))\n    U.deepStrictEqual(pipe(_.right(1), f)({}), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), f)({}), E.left('a!'))\n  })\n\n  it('orLeftW', () => {\n    const f = _.orLeftW((s: string) => R.of(s + '!'))\n    U.deepStrictEqual(pipe(_.right(1), f)({}), E.right(1))\n    U.deepStrictEqual(pipe(_.left('a'), f)({}), E.left('a!'))\n  })\n\n  describe('getSemigroup', () => {\n    it('concat', () => {\n      const S = _.getSemigroup(N.SemigroupSum)\n      const e1 = S.concat(_.left('a'), _.left('b'))({})\n      U.deepStrictEqual(e1, E.left('a'))\n\n      const e2 = S.concat(_.left('a'), _.right(2))({})\n      U.deepStrictEqual(e2, E.right(2))\n\n      const e3 = S.concat(_.right(1), _.left('b'))({})\n      U.deepStrictEqual(e3, E.right(1))\n\n      const e4 = S.concat(_.right(1), _.right(2))({})\n      U.deepStrictEqual(e4, E.right(3))\n    })\n  })\n\n  describe('getApplyMonoid', () => {\n    const M = _.getApplyMonoid(S.Monoid)\n\n    it('concat (right)', () => {\n      const x = M.concat(_.right('a'), _.right('b'))({})\n      return U.deepStrictEqual(x, E.right('ab'))\n    })\n\n    it('concat (left)', () => {\n      const x = M.concat(_.right('a'), _.left('b'))({})\n      return U.deepStrictEqual(x, E.left('b'))\n    })\n\n    it('empty (right)', () => {\n      const x = M.concat(_.right('a'), M.empty)({})\n      return U.deepStrictEqual(x, E.right('a'))\n    })\n\n    it('empty (left)', () => {\n      const x = M.concat(M.empty, _.right('a'))({})\n      return U.deepStrictEqual(x, E.right('a'))\n    })\n  })\n\n  it('ask', () => {\n    U.deepStrictEqual(_.ask()({}), E.right({}))\n  })\n\n  it('asks', () => {\n    U.deepStrictEqual(_.asks((r: { readonly a: number }) => r.a)({ a: 1 }), E.right(1))\n  })\n\n  it('local', () => {\n    U.deepStrictEqual(_.local((n: number) => ({ a: n }))((r: { readonly a: number }) => E.right(r.a))(1), E.right(1))\n  })\n\n  it('getApplicativeReaderValidation', () => {\n    const A = _.getApplicativeReaderValidation(S.Monoid)\n    U.deepStrictEqual(Apply.sequenceT(A)(_.left('a'), _.left('b'))(null), E.left('ab'))\n    const AV = _.getReaderValidation(S.Monoid)\n    U.deepStrictEqual(Apply.sequenceT(AV)(_.left('a'), _.left('b'))(null), E.left('ab'))\n  })\n\n  it('getAltReaderValidation', () => {\n    const A = _.getAltReaderValidation(S.Monoid)\n    U.deepStrictEqual(A.alt(_.left('a'), () => _.left('b'))(null), E.left('ab'))\n    const AV = _.getReaderValidation(S.Monoid)\n    U.deepStrictEqual(AV.alt(_.left('a'), () => _.left('b'))(null), E.left('ab'))\n  })\n\n  it('flatMapEither', () => {\n    const f = (s: string) => (s.length === 1 ? E.right(s.length) : E.left('b'))\n    U.deepStrictEqual(pipe(_.right('a'), _.flatMapEither(f))({}), E.right(1))\n    U.deepStrictEqual(pipe(_.right('aa'), _.flatMapEither(f))({}), E.left('b'))\n  })\n\n  it('chainEitherK', () => {\n    const f = (s: string) => (s.length === 1 ? E.right(s.length) : E.left('b'))\n    U.deepStrictEqual(pipe(_.right('a'), _.chainEitherK(f))({}), E.right(1))\n    U.deepStrictEqual(pipe(_.right('aa'), _.chainEitherK(f))({}), E.left('b'))\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.right<void, string, number>(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.right('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )(undefined),\n      E.right({ a: 1, b: 'b', c: [1, 'b'] })\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(\n      pipe(_.right<void, string, number>(1), _.bindTo('a'), _.apS('b', _.right('b')))(undefined),\n      E.right({ a: 1, b: 'b' })\n    )\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.right(a + i) : _.left('e')))\n      U.deepStrictEqual(pipe(RA.empty, f)({}), E.right(RA.empty))\n      U.deepStrictEqual(pipe(input, f)({}), E.right(['a0', 'b1']))\n      U.deepStrictEqual(pipe(['a', ''], f)({}), E.left('e'))\n    })\n\n    // old\n    it('sequenceArray', () => {\n      U.deepStrictEqual(pipe([_.right(1), _.right(2)], _.sequenceArray)(undefined), E.right([1, 2]))\n      U.deepStrictEqual(pipe([_.right(1), _.left('a')], _.sequenceArray)(undefined), E.left('a'))\n    })\n  })\n\n  it('getCompactable', () => {\n    const C = _.getCompactable(S.Monoid)\n    U.deepStrictEqual(C.compact(_.of(O.some('a')))({}), E.right('a'))\n  })\n\n  it('getFilterable', () => {\n    const F = _.getFilterable(S.Monoid)\n    U.deepStrictEqual(F.filter(_.of('a'), (s) => s.length > 0)({}), E.right('a'))\n    U.deepStrictEqual(F.filterMap(_.of('a'), (s) => (s.length > 0 ? O.some(s.length) : O.none))({}), E.right(1))\n    const s1 = F.partition(_.of('a'), (s) => s.length > 0)\n    U.deepStrictEqual(left(s1)({}), E.left(''))\n    U.deepStrictEqual(right(s1)({}), E.right('a'))\n    const s2 = F.partitionMap(_.of('a'), (s) => (s.length > 0 ? E.right(s.length) : E.left(s)))\n    U.deepStrictEqual(left(s2)({}), E.left(''))\n    U.deepStrictEqual(right(s2)({}), E.right(1))\n  })\n\n  it('match', () => {\n    const f = _.match(\n      () => 'left',\n      () => 'right'\n    )\n    U.deepStrictEqual(f(_.right(1))({}), 'right')\n    U.deepStrictEqual(f(_.left('a'))({}), 'left')\n  })\n\n  it('matchE', () => {\n    const f = _.matchE(\n      () => R.of('left'),\n      () => R.of('right')\n    )\n    U.deepStrictEqual(f(_.right(1))({}), 'right')\n    U.deepStrictEqual(f(_.left('a'))({}), 'left')\n  })\n\n  it('fromReaderK', () => {\n    const ma = _.fromReaderK(\n      (n: number): R.Reader<number, number> =>\n        (c) =>\n          n * c\n    )\n    U.deepStrictEqual(ma(3)(2), E.right(6))\n  })\n\n  it('chainReaderK', () => {\n    const f = _.chainReaderK(\n      (n: number): R.Reader<number, number> =>\n        (c) =>\n          n * c\n    )\n    U.deepStrictEqual(pipe(_.right(3), f)(2), E.right(6))\n    U.deepStrictEqual(pipe(_.left('a'), f)(2), E.left('a'))\n  })\n\n  it('chainReaderKW', () => {\n    const f = _.chainReaderKW((): R.Reader<unknown, number> => () => 2)\n    U.deepStrictEqual(pipe(_.right<{}, never, number>(3), f)({}), E.right(2))\n  })\n\n  it('chainFirstReaderK', () => {\n    const f = _.chainFirstReaderK(\n      (n: number): R.Reader<number, number> =>\n        (c) =>\n          n * c\n    )\n    U.deepStrictEqual(pipe(_.right(3), f)(2), E.right(3))\n    U.deepStrictEqual(pipe(_.left('a'), f)(2), E.left('a'))\n  })\n\n  it('chainFirstReaderKW', () => {\n    const f = _.chainFirstReaderKW((): R.Reader<unknown, number> => () => 2)\n    U.deepStrictEqual(pipe(_.right<{}, never, number>(3), f)({}), E.right(3))\n  })\n\n  it('tapEither', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(pipe(_.right('a'), _.tapEither(f))({}), E.right('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(pipe(_.right('a'), _.tapEither(g))({}), E.left(1))\n  })\n\n  it('chainFirstEitherK', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(pipe(_.right('a'), _.chainFirstEitherK(f))({}), E.right('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(pipe(_.right('a'), _.chainFirstEitherK(g))({}), E.left(1))\n  })\n\n  it('as', () => {\n    U.deepStrictEqual(pipe(_.right('a'), _.as('b'))(undefined), E.right('b'))\n    U.deepStrictEqual(_.as(_.of('a'), 'b')(undefined), E.right('b'))\n    U.deepStrictEqual(_.as(_.left('error'), 'b')(undefined), E.left('error'))\n  })\n\n  it('asUnit', () => {\n    U.deepStrictEqual(pipe(_.of('a'), _.asUnit)(undefined), E.of(undefined))\n  })\n\n  it('tapReader', () => {\n    U.deepStrictEqual(_.tapReader(_.of(1), () => R.of(2))({}), E.of(1))\n  })\n\n  it('flatMapReader', () => {\n    U.deepStrictEqual(_.flatMapReader(_.of(1), () => R.of(2))({}), E.of(2))\n  })\n})\n"
  },
  {
    "path": "test/ReaderIO.ts",
    "content": "import { pipe } from '../src/function'\nimport * as I from '../src/IO'\nimport * as R from '../src/Reader'\nimport * as _ from '../src/ReaderIO'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('ReaderIO', () => {\n  // -------------------------------------------------------------------------------------\n  // pipeables\n  // -------------------------------------------------------------------------------------\n\n  it('map', () => {\n    U.deepStrictEqual(pipe(_.of(1), _.map(U.double))({})(), 2)\n  })\n\n  it('ap', () => {\n    U.deepStrictEqual(pipe(_.of(U.double), _.ap(_.of(1)))({})(), 2)\n  })\n\n  it('apFirst', () => {\n    U.deepStrictEqual(pipe(_.of('a'), _.apFirst(_.of('b')))({})(), 'a')\n  })\n\n  it('apSecond', () => {\n    U.deepStrictEqual(pipe(_.of('a'), _.apSecond(_.of('b')))({})(), 'b')\n  })\n\n  it('flatMap', () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(pipe(_.of('foo'), _.flatMap(f))({})(), 3)\n    U.deepStrictEqual(_.flatMap(_.of('foo'), f)({})(), 3)\n  })\n\n  it('chain', () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(pipe(_.of('foo'), _.chain(f))({})(), 3)\n    U.deepStrictEqual(_.Monad.chain(_.of('foo'), f)({})(), 3)\n  })\n\n  it('tap', () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(pipe(_.of('foo'), _.tap(f))({})(), 'foo')\n    U.deepStrictEqual(_.tap(_.of('foo'), f)({})(), 'foo')\n  })\n\n  it('chainFirst', () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(pipe(_.of('foo'), _.chainFirst(f))({})(), 'foo')\n  })\n\n  it('chainFirstW', () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(pipe(_.of<object, string>('foo'), _.chainFirstW(f))({})(), 'foo')\n  })\n\n  it('flatten', () => {\n    U.deepStrictEqual(pipe(_.of(_.of('a')), _.flatten)({})(), 'a')\n  })\n\n  type R1 = { readonly env1: unknown }\n  type R2 = { readonly env2: unknown }\n\n  it('flattenW', () => {\n    U.deepStrictEqual(pipe(_.of<R1, _.ReaderIO<R2, 'a'>>(_.of('a')), _.flattenW)({ env1: '', env2: '' })(), 'a')\n  })\n\n  it('of', () => {\n    U.deepStrictEqual(_.fromReader(R.of(1))({})(), 1)\n  })\n\n  it('fromIO', async () => {\n    U.deepStrictEqual(_.fromIO(() => 1)({})(), 1)\n  })\n\n  // -------------------------------------------------------------------------------------\n  // constructors\n  // -------------------------------------------------------------------------------------\n\n  it('ask', () => {\n    return U.deepStrictEqual(_.ask<number>()(1)(), 1)\n  })\n\n  it('asks', () => {\n    return U.deepStrictEqual(_.asks((s: string) => s.length)('foo')(), 3)\n  })\n\n  it('fromReader', () => {\n    U.deepStrictEqual(_.fromReader(R.of(1))({})(), 1)\n  })\n\n  // -------------------------------------------------------------------------------------\n  // combinators\n  // -------------------------------------------------------------------------------------\n\n  it('local', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.asks((n: number) => n + 1),\n        _.local(S.size)\n      )('aaa')(),\n      4\n    )\n  })\n\n  it('chainIOK', () => {\n    const f = (s: string) => I.of(s.length)\n    U.deepStrictEqual(pipe(_.of('a'), _.chainIOK(f))(undefined)(), 1)\n  })\n\n  it('fromIOK', () => {\n    const f = _.fromIOK((s: string) => I.of(s.length))\n    U.deepStrictEqual(pipe(_.of('a'), _.chain(f))({})(), 1)\n  })\n\n  // -------------------------------------------------------------------------------------\n  // utils\n  // -------------------------------------------------------------------------------------\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b'))\n      )(undefined)(),\n      { a: 1, b: 'b' }\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b')))(undefined)(), { a: 1, b: 'b' })\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => _.of(a + i))\n      U.deepStrictEqual(pipe(RA.empty, f)(undefined)(), RA.empty)\n      U.deepStrictEqual(pipe(input, f)(undefined)(), ['a0', 'b1'])\n    })\n\n    // old\n    it('sequenceArray', () => {\n      // tslint:disable-next-line: readonly-array\n      const log: Array<number | string> = []\n      const append =\n        (n: number): _.ReaderIO<unknown, number> =>\n        () =>\n        () => {\n          log.push(n)\n          return n\n        }\n      // tslint:disable-next-line: deprecation\n      U.deepStrictEqual(pipe([append(1), append(2)], _.sequenceArray)(undefined)(), [1, 2])\n      U.deepStrictEqual(log, [1, 2])\n    })\n  })\n\n  it('tapIO', () => {\n    const ref: Array<number> = []\n    const add = (value: number) => () => ref.push(value)\n\n    U.deepStrictEqual(pipe(_.ask<number>(), _.tapIO(add))(1)(), 1)\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('as', () => {\n    U.deepStrictEqual(pipe(_.of('a'), _.as('b'))('c')(), 'b')\n  })\n\n  it('asUnit', () => {\n    U.deepStrictEqual(pipe(_.of('a'), _.asUnit)('b')(), undefined)\n  })\n\n  it('tapReader', () => {\n    U.deepStrictEqual(_.tapReader(_.of(1), () => R.of(2))({})(), 1)\n  })\n\n  it('flatMapIO', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.flatMapIO(() => I.of(2))\n      )(undefined)(),\n      2\n    )\n  })\n\n  it('flatMapReader', () => {\n    U.deepStrictEqual(_.flatMapReader(_.of(1), () => R.of(2))(undefined)(), 2)\n  })\n})\n"
  },
  {
    "path": "test/ReaderT.ts",
    "content": "import * as E from '../src/Either'\nimport * as IO from '../src/IO'\nimport * as _ from '../src/ReaderT'\nimport * as TE from '../src/TaskEither'\nimport * as U from './util'\n\ndescribe('ReaderT', () => {\n  it('fromNaturalTransformation', async () => {\n    const fromReaderIO = _.fromNaturalTransformation<'IO', 'TaskEither'>(TE.fromIO)\n    const f = (s: string): IO.IO<number> => IO.of(s.length)\n    const fa = fromReaderIO(f)\n    U.deepStrictEqual(await fa('a')(), E.right(1))\n  })\n})\n"
  },
  {
    "path": "test/ReaderTask.ts",
    "content": "import { pipe, SK } from '../src/function'\nimport * as I from '../src/IO'\nimport { monoidString } from '../src/Monoid'\nimport * as R from '../src/Reader'\nimport * as RIO from '../src/ReaderIO'\nimport * as _ from '../src/ReaderTask'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport { semigroupString } from '../src/Semigroup'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\ndescribe('ReaderTask', () => {\n  // -------------------------------------------------------------------------------------\n  // pipeables\n  // -------------------------------------------------------------------------------------\n\n  it('map', async () => {\n    U.deepStrictEqual(await pipe(_.of(1), _.map(U.double))({})(), 2)\n  })\n\n  it('ap', async () => {\n    U.deepStrictEqual(await pipe(_.of(U.double), _.ap(_.of(1)))({})(), 2)\n  })\n\n  it('apFirst', async () => {\n    U.deepStrictEqual(await pipe(_.of('a'), _.apFirst(_.of('b')))({})(), 'a')\n  })\n\n  it('apFirstW', async () => {\n    const fa = _.of<{ readonly k: string }, string>('a')\n    const fb = _.of<{ readonly x: number }, boolean>(true)\n    U.deepStrictEqual(await pipe(fa, _.apFirstW(fb))({ k: 'v', x: 42 })(), 'a')\n  })\n\n  it('apSecond', async () => {\n    U.deepStrictEqual(await pipe(_.of('a'), _.apSecond(_.of('b')))({})(), 'b')\n  })\n\n  it('apSecondW', async () => {\n    const fa = _.of<{ readonly k: string }, string>('a')\n    const fb = _.of<{ readonly x: number }, boolean>(true)\n    U.deepStrictEqual(await pipe(fa, _.apSecondW(fb))({ k: 'v', x: 42 })(), true)\n  })\n\n  it('flatMap', async () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(await pipe(_.of('foo'), _.flatMap(f))({})(), 3)\n    U.deepStrictEqual(await _.flatMap(_.of('foo'), f)({})(), 3)\n  })\n\n  it('chain', async () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(await pipe(_.of('foo'), _.chain(f))({})(), 3)\n    U.deepStrictEqual(await _.Monad.chain(_.of('foo'), f)({})(), 3)\n  })\n\n  it('tap', async () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(await pipe(_.of('foo'), _.tap(f))({})(), 'foo')\n    U.deepStrictEqual(await _.tap(_.of('foo'), f)({})(), 'foo')\n  })\n\n  it('chainFirst', async () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(await pipe(_.of('foo'), _.chainFirst(f))({})(), 'foo')\n  })\n\n  it('chainFirstW', async () => {\n    const f = (a: string) => _.of(a.length)\n    U.deepStrictEqual(await pipe(_.of<object, string>('foo'), _.chainFirstW(f))({})(), 'foo')\n  })\n\n  it('flatten', async () => {\n    U.deepStrictEqual(await pipe(_.of(_.of('a')), _.flatten)({})(), 'a')\n  })\n\n  type R1 = { readonly env1: unknown }\n  type R2 = { readonly env2: unknown }\n\n  it('flattenW', async () => {\n    U.deepStrictEqual(await pipe(_.of<R1, _.ReaderTask<R2, 'a'>>(_.of('a')), _.flattenW)({ env1: '', env2: '' })(), 'a')\n  })\n\n  it('of', async () => {\n    U.deepStrictEqual(await _.fromReader(R.of(1))({})(), 1)\n  })\n\n  it('fromIO', async () => {\n    U.deepStrictEqual(await _.fromIO(() => 1)({})(), 1)\n  })\n\n  // -------------------------------------------------------------------------------------\n  // constructors\n  // -------------------------------------------------------------------------------------\n\n  it('ask', async () => {\n    return U.deepStrictEqual(await _.ask<number>()(1)(), 1)\n  })\n\n  it('asks', async () => {\n    return U.deepStrictEqual(await _.asks((s: string) => s.length)('foo')(), 3)\n  })\n\n  it('fromTask', async () => {\n    U.deepStrictEqual(await _.fromTask(T.of(1))({})(), 1)\n  })\n\n  it('fromReader', async () => {\n    U.deepStrictEqual(await _.fromReader(R.of(1))({})(), 1)\n  })\n\n  it('fromReaderIO', async () => {\n    U.deepStrictEqual(await _.fromReaderIO(RIO.of(1))({})(), 1)\n  })\n\n  // -------------------------------------------------------------------------------------\n  // combinators\n  // -------------------------------------------------------------------------------------\n\n  it('local', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.asks((n: number) => n + 1),\n        _.local(S.size)\n      )('aaa')(),\n      4\n    )\n  })\n\n  it('chainIOK', async () => {\n    const f = (s: string) => I.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.chainIOK(f))(undefined)(), 1)\n  })\n\n  it('chainTaskK', async () => {\n    const f = (s: string) => T.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.chainTaskK(f))(undefined)(), 1)\n  })\n\n  it('flatMapTask', async () => {\n    const f = (s: string) => T.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.flatMapTask(f))(undefined)(), 1)\n  })\n\n  it('chainFirstTaskK', async () => {\n    const f = (s: string) => T.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.chainFirstTaskK(f))(undefined)(), 'a')\n  })\n\n  it('fromIOK', async () => {\n    const f = _.fromIOK((s: string) => I.of(s.length))\n    U.deepStrictEqual(await pipe(_.of('a'), _.chain(f))({})(), 1)\n  })\n\n  it('fromTaskK', async () => {\n    const f = _.fromTaskK((s: string) => T.of(s.length))\n    U.deepStrictEqual(await pipe(_.of('a'), _.chain(f))({})(), 1)\n  })\n\n  it('fromReaderIOK', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await _.fromReaderIOK(f)('a')(undefined)(), 1)\n  })\n\n  it('chainReaderIOKW', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.chainReaderIOKW(f))({})(), 1)\n  })\n\n  it('chainReaderIOK', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.chainReaderIOK(f))(undefined)(), 1)\n  })\n\n  it('chainFirstReaderIOKW', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.chainFirstReaderIOKW(f))({})(), 'a')\n  })\n\n  it('chainFirstReaderIOK', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.chainFirstReaderIOK(f))({})(), 'a')\n  })\n\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('getSemigroup', async () => {\n    const M = _.getSemigroup(semigroupString)\n    U.deepStrictEqual(await M.concat(_.of('a'), _.of('b'))({})(), 'ab')\n  })\n\n  it('getMonoid', async () => {\n    const M = _.getMonoid(monoidString)\n    U.deepStrictEqual(await M.concat(_.of('a'), M.empty)({})(), 'a')\n    U.deepStrictEqual(await M.concat(M.empty, _.of('b'))({})(), 'b')\n    U.deepStrictEqual(await M.concat(_.of('a'), _.of('b'))({})(), 'ab')\n  })\n\n  it('applicativeTaskEitherSeq', async () => {\n    await U.assertSeq(_.ApplicativeSeq, _.FromTask, (fa) => fa(null)())\n  })\n\n  it('applicativeTaskEitherPar', async () => {\n    await U.assertPar(_.ApplicativePar, _.FromTask, (fa) => fa(null)())\n  })\n\n  // -------------------------------------------------------------------------------------\n  // utils\n  // -------------------------------------------------------------------------------------\n\n  it('do notation', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )(undefined)(),\n      { a: 1, b: 'b', c: [1, 'b'] }\n    )\n  })\n\n  it('apS', async () => {\n    U.deepStrictEqual(await pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b')))(undefined)(), { a: 1, b: 'b' })\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', async () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => _.of(a + i))\n      U.deepStrictEqual(await pipe(RA.empty, f)(undefined)(), RA.empty)\n      U.deepStrictEqual(await pipe(input, f)(undefined)(), ['a0', 'b1'])\n    })\n\n    it('sequenceReadonlyArray', async () => {\n      U.deepStrictEqual(await pipe(RA.empty, _.traverseReadonlyArrayWithIndex(SK))(undefined)(), RA.empty)\n      const log: Array<number> = []\n      const append = (n: number): _.ReaderTask<undefined, number> =>\n        _.fromTask(\n          T.delay(n % 2 === 0 ? 50 : 100)(\n            T.fromIO(() => {\n              log.push(n)\n              return n\n            })\n          )\n        )\n      const as = RA.makeBy(4, append)\n      U.deepStrictEqual(await pipe(as, _.traverseReadonlyArrayWithIndex(SK))(undefined)(), [0, 1, 2, 3])\n      U.deepStrictEqual(log, [0, 2, 1, 3])\n    })\n\n    it('sequenceReadonlyArraySeq', async () => {\n      U.deepStrictEqual(await pipe(RA.empty, _.traverseReadonlyArrayWithIndexSeq(SK))(undefined)(), RA.empty)\n      const log: Array<number> = []\n      const append = (n: number): _.ReaderTask<undefined, number> =>\n        _.fromTask(\n          T.delay(n % 2 === 0 ? 50 : 100)(\n            T.fromIO(() => {\n              log.push(n)\n              return n\n            })\n          )\n        )\n      const as = RA.makeBy(4, append)\n      U.deepStrictEqual(await pipe(as, _.traverseReadonlyArrayWithIndexSeq(SK))(undefined)(), [0, 1, 2, 3])\n      U.deepStrictEqual(log, [0, 1, 2, 3])\n    })\n\n    // old\n    it('sequenceArray', async () => {\n      const log: Array<number> = []\n      const append = (n: number): _.ReaderTask<undefined, number> =>\n        _.fromTask(\n          T.delay(n % 2 === 0 ? 50 : 100)(\n            T.fromIO(() => {\n              log.push(n)\n              return n\n            })\n          )\n        )\n      const as = RA.makeBy(4, append)\n      U.deepStrictEqual(await pipe(as, _.sequenceArray)(undefined)(), [0, 1, 2, 3])\n      U.deepStrictEqual(log, [0, 2, 1, 3])\n    })\n\n    it('sequenceSeqArray', async () => {\n      const log: Array<number> = []\n      const append = (n: number): _.ReaderTask<undefined, number> =>\n        _.fromTask(\n          T.delay(n % 2 === 0 ? 50 : 100)(\n            T.fromIO(() => {\n              log.push(n)\n              return n\n            })\n          )\n        )\n      const as = RA.makeBy(4, append)\n      U.deepStrictEqual(await pipe(as, _.sequenceSeqArray)(undefined)(), [0, 1, 2, 3])\n      U.deepStrictEqual(log, [0, 1, 2, 3])\n    })\n  })\n\n  it('tapIO', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => () => ref.push(value)\n\n    U.deepStrictEqual(await pipe(_.ask<number>(), _.tapIO(add))(1)(), 1)\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('tapTask', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => T.fromIO(() => ref.push(value))\n\n    U.deepStrictEqual(await pipe(_.ask<number>(), _.tapTask(add))(1)(), 1)\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('as', async () => {\n    U.deepStrictEqual(await pipe(_.of('a'), _.as('b'))('c')(), 'b')\n  })\n\n  it('asUnit', async () => {\n    U.deepStrictEqual(await pipe(_.of('a'), _.asUnit)('b')(), undefined)\n  })\n\n  it('tapReader', async () => {\n    U.deepStrictEqual(await _.tapReader(_.of(1), () => R.of(2))({})(), 1)\n  })\n\n  it('tapReaderIO', async () => {\n    U.deepStrictEqual(await _.tapReaderIO(_.of(1), () => RIO.of(2))({})(), 1)\n  })\n\n  it('flatMapIO', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.of(1),\n        _.flatMapIO(() => I.of(2))\n      )(undefined)(),\n      2\n    )\n  })\n\n  it('flatMapReader', async () => {\n    U.deepStrictEqual(await _.flatMapReader(_.of(1), () => R.of(2))(undefined)(), 2)\n  })\n\n  it('flatMapReaderIO', async () => {\n    U.deepStrictEqual(await _.flatMapReaderIO(_.of(1), () => RIO.of(2))(undefined)(), 2)\n  })\n})\n"
  },
  {
    "path": "test/ReaderTaskEither.ts",
    "content": "import { sequenceT } from '../src/Apply'\nimport * as E from '../src/Either'\nimport { constVoid, flow, pipe, SK } from '../src/function'\nimport * as I from '../src/IO'\nimport * as IE from '../src/IOEither'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as R from '../src/Reader'\nimport * as RE from '../src/ReaderEither'\nimport * as RIO from '../src/ReaderIO'\nimport * as RT from '../src/ReaderTask'\nimport * as _ from '../src/ReaderTaskEither'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport { left, right } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as TE from '../src/TaskEither'\nimport * as U from './util'\n\ndescribe('ReaderTaskEither', () => {\n  describe('pipeables', () => {\n    it('map', async () => {\n      U.deepStrictEqual(await pipe(_.right(1), _.map(U.double))({})(), E.right(2))\n    })\n\n    it('ap', async () => {\n      U.deepStrictEqual(await pipe(_.right(U.double), _.ap(_.right(1)))({})(), E.right(2))\n    })\n\n    it('apFirst', async () => {\n      U.deepStrictEqual(await pipe(_.right('a'), _.apFirst(_.right('b')))({})(), E.right('a'))\n    })\n\n    it('apFirstW', async () => {\n      const fa = _.right<{ readonly k: string }, 'Foo', string>('a')\n      const fb = _.right<{ readonly x: number }, 'Bar', boolean>(true)\n      U.deepStrictEqual(await pipe(fa, _.apFirstW(fb))({ k: 'v', x: 42 })(), E.right('a'))\n    })\n\n    it('apSecond', async () => {\n      U.deepStrictEqual(await pipe(_.right('a'), _.apSecond(_.right('b')))({})(), E.right('b'))\n    })\n\n    it('apSecondW', async () => {\n      const fa = _.right<{ readonly k: string }, 'Foo', string>('a')\n      const fb = _.right<{ readonly x: number }, 'Bar', boolean>(true)\n      U.deepStrictEqual(await pipe(fa, _.apSecondW(fb))({ k: 'v', x: 42 })(), E.right(true))\n    })\n\n    it('flatMap', async () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('b'))\n      U.deepStrictEqual(await pipe(_.right('aaa'), _.flatMap(f))({})(), E.right(3))\n      U.deepStrictEqual(await _.flatMap(_.right('a'), f)({})(), E.left('b'))\n    })\n\n    it('chain', async () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('b'))\n      U.deepStrictEqual(await pipe(_.right('aaa'), _.chain(f))({})(), E.right(3))\n      U.deepStrictEqual(await pipe(_.right('a'), _.chain(f))({})(), E.left('b'))\n    })\n\n    it('tap', async () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('b'))\n      U.deepStrictEqual(await pipe(_.right('aaa'), _.tap(f))({})(), E.right('aaa'))\n      U.deepStrictEqual(await _.tap(_.right('aaa'), f)({})(), E.right('aaa'))\n    })\n\n    it('chainFirst', async () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('b'))\n      U.deepStrictEqual(await pipe(_.right('aaa'), _.chainFirst(f))({})(), E.right('aaa'))\n    })\n\n    it('chainFirstW', async () => {\n      const f = (a: string) => (a.length > 2 ? _.right(a.length) : _.left('b'))\n      U.deepStrictEqual(await pipe(_.right<object, number, string>('aaa'), _.chainFirstW(f))({})(), E.right('aaa'))\n    })\n\n    it('flatten', async () => {\n      U.deepStrictEqual(await pipe(_.right(_.right('a')), _.flatten)({})(), E.right('a'))\n    })\n\n    type R1 = { readonly env1: unknown }\n    type R2 = { readonly env2: unknown }\n    type E1 = { readonly left1: unknown }\n    type E2 = { readonly left2: unknown }\n\n    it('flattenW', async () => {\n      U.deepStrictEqual(\n        await pipe(\n          _.right<R1, E1, _.ReaderTaskEither<R2, E2, 'a'>>(_.right('a')),\n          _.flattenW\n        )({ env1: '', env2: '' })(),\n        E.right('a')\n      )\n    })\n\n    it('bimap', async () => {\n      const f = (s: string): number => s.length\n      const g = (n: number): boolean => n > 2\n      U.deepStrictEqual(await pipe(_.right(1), _.bimap(f, g))({})(), E.right(false))\n      U.deepStrictEqual(await pipe(_.left('error'), _.bimap(f, g))({})(), E.left(5))\n    })\n\n    it('mapLeft', async () => {\n      U.deepStrictEqual(await pipe(_.right(1), _.mapLeft(S.size))({})(), E.right(1))\n      U.deepStrictEqual(await pipe(_.left('err'), _.mapLeft(S.size))({})(), E.left(3))\n    })\n\n    it('alt', async () => {\n      U.deepStrictEqual(\n        await pipe(\n          _.right(1),\n          _.alt(() => _.right(2))\n        )({})(),\n        E.right(1)\n      )\n      U.deepStrictEqual(\n        await pipe(\n          _.left('a'),\n          _.alt(() => _.right(2))\n        )({})(),\n        E.right(2)\n      )\n      U.deepStrictEqual(\n        await pipe(\n          _.left('a'),\n          _.alt(() => _.left('b'))\n        )({})(),\n        E.left('b')\n      )\n    })\n\n    it('fromPredicate', async () => {\n      const predicate = (n: number) => n >= 2\n      const gt2 = _.fromPredicate(predicate, (n) => `Invalid number ${n}`)\n\n      const refinement = (u: string | number): u is number => typeof u === 'number'\n      const isNumber = _.fromPredicate(refinement, (u) => `Invalid number ${String(u)}`)\n\n      U.deepStrictEqual(await gt2(3)({})(), E.right(3))\n      U.deepStrictEqual(await gt2(1)({})(), E.left('Invalid number 1'))\n      U.deepStrictEqual(await isNumber(4)({})(), E.right(4))\n    })\n\n    it('fromEither', async () => {\n      U.deepStrictEqual(await _.fromEither(E.right(1))({})(), E.right(1))\n      U.deepStrictEqual(await _.fromEither(E.left('a'))({})(), E.left('a'))\n    })\n\n    it('fromOption', async () => {\n      U.deepStrictEqual(await _.fromOption(() => 'none')(O.none)({})(), E.left('none'))\n      U.deepStrictEqual(await _.fromOption(() => 'none')(O.some(1))({})(), E.right(1))\n    })\n\n    it('filterOrElse', async () => {\n      U.deepStrictEqual(\n        await pipe(\n          _.right(12),\n          _.filterOrElse(\n            (n) => n > 10,\n            () => 'a'\n          )\n        )({})(),\n        E.right(12)\n      )\n      U.deepStrictEqual(\n        await pipe(\n          _.right(8),\n          _.filterOrElse(\n            (n) => n > 10,\n            () => 'a'\n          )\n        )({})(),\n        E.left('a')\n      )\n    })\n  })\n\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('applicativeReaderTaskEitherSeq', async () => {\n    await U.assertSeq(_.ApplicativeSeq, _.FromTask, (fa) => fa(null)())\n  })\n\n  it('applicativeReaderTaskEitherPar', async () => {\n    await U.assertPar(_.ApplicativePar, _.FromTask, (fa) => fa(null)())\n  })\n\n  // -------------------------------------------------------------------------------------\n  // constructors\n  // -------------------------------------------------------------------------------------\n\n  it('ask', async () => {\n    return U.deepStrictEqual(await _.ask<number>()(1)(), E.right(1))\n  })\n\n  it('asks', async () => {\n    return U.deepStrictEqual(await _.asks((s: string) => s.length)('foo')(), E.right(3))\n  })\n\n  it('local', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.asks((n: number) => n + 1),\n        _.local(S.size)\n      )('aaa')(),\n      E.right(4)\n    )\n  })\n\n  it('leftTask', async () => {\n    U.deepStrictEqual(await _.leftTask(T.of(1))({})(), E.left(1))\n  })\n\n  it('rightTask', async () => {\n    U.deepStrictEqual(await _.rightTask(T.of(1))({})(), E.right(1))\n  })\n\n  it('leftReaderTask', async () => {\n    U.deepStrictEqual(await _.leftReaderTask(RT.of(1))({})(), E.left(1))\n  })\n\n  it('rightReaderTask', async () => {\n    U.deepStrictEqual(await _.rightReaderTask(RT.of(1))({})(), E.right(1))\n  })\n\n  it('rightReader', async () => {\n    U.deepStrictEqual(await _.rightReader(R.of(1))({})(), E.right(1))\n  })\n\n  it('leftReader', async () => {\n    U.deepStrictEqual(await _.leftReader(R.of(1))({})(), E.left(1))\n  })\n\n  it('fromTaskEither', async () => {\n    U.deepStrictEqual(await _.fromTaskEither(TE.of(1))({})(), E.right(1))\n  })\n\n  it('leftIO', async () => {\n    U.deepStrictEqual(await _.leftIO(I.of(1))({})(), E.left(1))\n  })\n\n  it('rightReaderIO', async () => {\n    U.deepStrictEqual(await _.rightReaderIO(RIO.of(1))({})(), E.right(1))\n  })\n\n  it('leftReaderIO', async () => {\n    U.deepStrictEqual(await _.leftReaderIO(RIO.of(1))({})(), E.left(1))\n  })\n\n  it('fromIOEither', async () => {\n    U.deepStrictEqual(await _.fromIOEither(() => E.right(1))({})(), E.right(1))\n    U.deepStrictEqual(await _.fromIOEither(() => E.left('error'))({})(), E.left('error'))\n  })\n\n  it('fold', async () => {\n    const fold = _.fold(\n      (l: string) => R.of(T.of(l.length)),\n      (a: number) => R.of(T.of(a * 2))\n    )\n    U.deepStrictEqual(await fold(_.right(1))({})(), 2)\n    U.deepStrictEqual(await fold(_.left('err'))({})(), 3)\n  })\n\n  it('getOrElse', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right(1),\n        _.getOrElse((l: string) => R.of(T.of(l.length)))\n      )({})(),\n      1\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.left('err'),\n        _.getOrElse((l: string) => R.of(T.of(l.length)))\n      )({})(),\n      3\n    )\n  })\n\n  it('orElse', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right(1),\n        _.orElse((s: string) => _.right(s.length))\n      )({})(),\n      E.right(1)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.left('error'),\n        _.orElse((s) => _.right(s.length))\n      )({})(),\n      E.right(5)\n    )\n  })\n\n  it('orElseW', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right(1),\n        _.orElseW((s: string) => _.right(s.length))\n      )({})(),\n      E.right(1)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.left('error'),\n        _.orElseW((s) => _.right(s.length))\n      )({})(),\n      E.right(5)\n    )\n  })\n\n  it('tapError', async () => {\n    const f = (s: string) => (s.length <= 1 ? _.right(true) : _.left(s + '!'))\n    U.deepStrictEqual(await pipe(_.right(1), _.tapError(f))({})(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), _.tapError(f))({})(), E.left('a'))\n    U.deepStrictEqual(await pipe(_.left('aa'), _.tapError(f))({})(), E.left('aa!'))\n    U.deepStrictEqual(await pipe(_.tapError(_.right(1), f))({})(), E.right(1))\n    U.deepStrictEqual(await pipe(_.tapError(_.left('a'), f))({})(), E.left('a'))\n    U.deepStrictEqual(await pipe(_.tapError(_.left('aa'), f))({})(), E.left('aa!'))\n  })\n\n  it('orElseFirst', async () => {\n    const f = _.orElseFirst((s: string) => (s.length <= 1 ? _.right(true) : _.left(s + '!')))\n    U.deepStrictEqual(await pipe(_.right(1), f)({})(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), f)({})(), E.left('a'))\n    U.deepStrictEqual(await pipe(_.left('aa'), f)({})(), E.left('aa!'))\n  })\n\n  it('orElseFirstW', async () => {\n    const f = _.orElseFirstW((s: string) => (s.length <= 1 ? _.right(true) : _.left(s + '!')))\n    U.deepStrictEqual(await pipe(_.right(1), f)({})(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), f)({})(), E.left('a'))\n    U.deepStrictEqual(await pipe(_.left('aa'), f)({})(), E.left('aa!'))\n  })\n\n  it('orLeft', async () => {\n    const f = _.orLeft((s: string) => RT.of(s + '!'))\n    U.deepStrictEqual(await pipe(_.right(1), f)({})(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), f)({})(), E.left('a!'))\n  })\n\n  it('orLeftW', async () => {\n    const f = _.orLeftW((s: string) => RT.of(s + '!'))\n    U.deepStrictEqual(await pipe(_.right(1), f)({})(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), f)({})(), E.left('a!'))\n  })\n\n  describe('MonadIO', () => {\n    it('fromIO', async () => {\n      U.deepStrictEqual(await _.fromIO(() => 1)({})(), E.right(1))\n    })\n  })\n\n  it('swap', async () => {\n    U.deepStrictEqual(await _.swap(_.right(1))({})(), E.left(1))\n    U.deepStrictEqual(await _.swap(_.left('a'))({})(), E.right('a'))\n  })\n\n  describe('getSemigroup', () => {\n    it('concat', async () => {\n      const S = _.getSemigroup(N.SemigroupSum)\n      U.deepStrictEqual(await S.concat(_.left('a'), _.left('b'))({})(), E.left('a'))\n      U.deepStrictEqual(await S.concat(_.left('a'), _.right(2))({})(), E.right(2))\n      U.deepStrictEqual(await S.concat(_.right(1), _.left('b'))({})(), E.right(1))\n      U.deepStrictEqual(await S.concat(_.right(1), _.right(2))({})(), E.right(3))\n    })\n  })\n\n  it('getApplyMonoid', async () => {\n    const M = _.getApplyMonoid(N.MonoidSum)\n\n    U.deepStrictEqual(await M.concat(_.right(1), _.right(2))({})(), E.right(3))\n    U.deepStrictEqual(await M.concat(_.right(1), _.left('b'))({})(), E.left('b'))\n    U.deepStrictEqual(await M.concat(_.right(1), M.empty)({})(), E.right(1))\n    U.deepStrictEqual(await M.concat(M.empty, _.right(1))({})(), E.right(1))\n  })\n\n  it('fromReaderEither', async () => {\n    U.deepStrictEqual(await _.fromReaderEither(RE.left('a'))({})(), E.left('a'))\n    U.deepStrictEqual(await _.fromReaderEither(RE.right(1))({})(), E.right(1))\n  })\n\n  it('getApplicativeReaderTaskValidation', async () => {\n    const A = _.getApplicativeReaderTaskValidation(T.ApplicativePar, S.Semigroup)\n    U.deepStrictEqual(await sequenceT(A)(_.left('a'), _.left('b'))(null)(), E.left('ab'))\n    const AV = _.getReaderTaskValidation(S.Semigroup)\n    U.deepStrictEqual(await sequenceT(AV)(_.left('a'), _.left('b'))(null)(), E.left('ab'))\n  })\n\n  it('getAltReaderTaskValidation', async () => {\n    const A = _.getAltReaderTaskValidation(S.Semigroup)\n    U.deepStrictEqual(await A.alt(_.left('a'), () => _.left('b'))(null)(), E.left('ab'))\n    const AV = _.getReaderTaskValidation(S.Semigroup)\n    U.deepStrictEqual(await AV.alt(_.left('a'), () => _.left('b'))(null)(), E.left('ab'))\n  })\n\n  describe('bracket', () => {\n    let log: Array<string> = []\n\n    const acquireFailure = _.left('acquire failure')\n    const acquireSuccess = _.right({ res: 'acquire success' })\n    const useSuccess = () => _.right('use success')\n    const useFailure = () => _.left('use failure')\n    const releaseSuccess = () =>\n      _.fromIO(() => {\n        log.push('release success')\n      })\n    const releaseFailure = () => _.left('release failure')\n\n    beforeEach(() => {\n      log = []\n    })\n\n    it('should return the acquire error if acquire fails', async () => {\n      U.deepStrictEqual(\n        await _.bracket(acquireFailure, useSuccess, releaseSuccess)(undefined)(),\n        E.left('acquire failure')\n      )\n    })\n\n    it('body and release must not be called if acquire fails', async () => {\n      await _.bracket(acquireFailure, useSuccess, releaseSuccess)(undefined)()\n      U.deepStrictEqual(log, [])\n    })\n\n    it('should return the use error if use fails and release does not', async () => {\n      U.deepStrictEqual(await _.bracket(acquireSuccess, useFailure, releaseSuccess)(undefined)(), E.left('use failure'))\n    })\n\n    it('should return the release error if both use and release fail', async () => {\n      U.deepStrictEqual(\n        await _.bracket(acquireSuccess, useFailure, releaseFailure)(undefined)(),\n        E.left('release failure')\n      )\n    })\n\n    it('release must be called if the body returns', async () => {\n      await _.bracket(acquireSuccess, useSuccess, releaseSuccess)(undefined)()\n      U.deepStrictEqual(log, ['release success'])\n    })\n\n    it('release must be called if the body throws', async () => {\n      await _.bracket(acquireSuccess, useFailure, releaseSuccess)(undefined)()\n      U.deepStrictEqual(log, ['release success'])\n    })\n\n    it('should return the release error if release fails', async () => {\n      U.deepStrictEqual(\n        await _.bracket(acquireSuccess, useSuccess, releaseFailure)(undefined)(),\n        E.left('release failure')\n      )\n    })\n  })\n\n  it('bracketW', async () => {\n    const acquire = _.right<{ readonly a: string }, string, string>('string')\n    const use = (_a: string) => _.right<{ readonly b: number }, number, string>('test')\n    const release = (_a: string, _e: E.Either<number, string>) =>\n      _.right<{ readonly c: boolean }, Error, void>(constVoid())\n    const res = await _.bracketW(\n      acquire,\n      use,\n      release\n    )({\n      a: 'string',\n      b: 5,\n      c: true\n    })()\n    U.deepStrictEqual(res, E.right('test'))\n  })\n\n  it('flatMapEither', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.flatMapEither(f))(undefined)(), E.right(1))\n  })\n\n  it('chainEitherK', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainEitherK(f))(undefined)(), E.right(1))\n  })\n\n  it('tapEither', async () => {\n    const f = (s: string) => E.right<string, number>(s.length)\n    U.deepStrictEqual(await pipe(_.right<{}, number, string>('a'), _.tapEither(f))({})(), E.right('a'))\n  })\n\n  it('chainFirstEitherKW', async () => {\n    const f = (s: string) => E.right<string, number>(s.length)\n    U.deepStrictEqual(await pipe(_.right<{}, number, string>('a'), _.chainFirstEitherKW(f))({})(), E.right('a'))\n  })\n\n  it('chainIOEitherK', async () => {\n    const f = (s: string) => IE.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainIOEitherK(f))(undefined)(), E.right(1))\n  })\n\n  it('chainTaskEitherK', async () => {\n    const f = (s: string) => TE.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainTaskEitherK(f))(undefined)(), E.right(1))\n  })\n\n  it('flatMapTaskEither', async () => {\n    const f = (s: string) => TE.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.flatMapTaskEither(f))(undefined)(), E.right(1))\n  })\n\n  it('chainFirstTaskEitherKW', async () => {\n    const f = (s: string) => TE.right<string, number>(s.length)\n    U.deepStrictEqual(await pipe(_.right<{}, number, string>('a'), _.chainFirstTaskEitherKW(f))({})(), E.right('a'))\n  })\n\n  it('chainReaderTaskK', async () => {\n    const f = flow(S.size, RT.of)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainReaderTaskK(f))(undefined)(), E.right(1))\n  })\n\n  it('flatMapReaderTask', async () => {\n    const f = flow(S.size, RT.of)\n    U.deepStrictEqual(await pipe(_.right('a'), _.flatMapReaderTask(f))(undefined)(), E.right(1))\n  })\n\n  it('chainReaderTaskKW', async () => {\n    const f = flow(S.size, RT.of)\n    U.deepStrictEqual(await pipe(_.right<{}, never, string>('a'), _.chainReaderTaskKW(f))({})(), E.right(1))\n  })\n\n  it('chainFirstReaderTaskKW', async () => {\n    const f = flow(S.size, RT.of)\n    U.deepStrictEqual(await pipe(_.right<{}, never, string>('a'), _.chainFirstReaderTaskKW(f))({})(), E.right('a'))\n  })\n\n  it('chainReaderEitherKW', async () => {\n    const f = (s: string) => RE.right(s.length)\n    U.deepStrictEqual(await pipe(_.right<{}, never, string>('a'), _.chainReaderEitherKW(f))({})(), E.right(1))\n  })\n\n  it('chainFirstReaderEitherKW', async () => {\n    const f = (s: string) => RE.right(s.length)\n    U.deepStrictEqual(await pipe(_.right<{}, never, string>('a'), _.chainFirstReaderEitherKW(f))({})(), E.right('a'))\n  })\n\n  it('fromReaderIOK', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await _.fromReaderIOK(f)('a')(undefined)(), E.right(1))\n  })\n\n  it('chainReaderIOKW', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainReaderIOKW(f))({})(), E.right(1))\n  })\n\n  it('chainReaderIOK', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainReaderIOK(f))(undefined)(), E.right(1))\n  })\n\n  it('chainFirstReaderIOKW', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstReaderIOKW(f))({})(), E.right('a'))\n  })\n\n  it('chainFirstReaderIOK', async () => {\n    const f = (s: string) => RIO.of(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstReaderIOK(f))({})(), E.right('a'))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // utils\n  // -------------------------------------------------------------------------------------\n\n  it('do notation', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right<void, string, number>(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.right('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )(undefined)(),\n      E.right({ a: 1, b: 'b', c: [1, 'b'] })\n    )\n  })\n\n  it('apS', async () => {\n    U.deepStrictEqual(\n      await pipe(_.right<void, string, number>(1), _.bindTo('a'), _.apS('b', _.right('b')))(undefined)(),\n      E.right({ a: 1, b: 'b' })\n    )\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', async () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.right(a + i) : _.left('e')))\n      U.deepStrictEqual(await pipe(RA.empty, f)(undefined)(), E.right(RA.empty))\n      U.deepStrictEqual(await pipe(input, f)(undefined)(), E.right(['a0', 'b1']))\n      U.deepStrictEqual(await pipe(['a', ''], f)(undefined)(), E.left('e'))\n    })\n\n    it('traverseReadonlyArrayWithIndexSeq', async () => {\n      const f = _.traverseReadonlyArrayWithIndexSeq((i, a: string) => (a.length > 0 ? _.right(a + i) : _.left('e')))\n      U.deepStrictEqual(await pipe(RA.empty, f)(undefined)(), E.right(RA.empty))\n      U.deepStrictEqual(await pipe(input, f)(undefined)(), E.right(['a0', 'b1']))\n      U.deepStrictEqual(await pipe(['a', ''], f)(undefined)(), E.left('e'))\n    })\n\n    it('sequenceReadonlyArray', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.ReaderTaskEither<undefined, string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.ReaderTaskEither<undefined, string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(\n        await pipe([right(1), right(2)], _.traverseReadonlyArrayWithIndex(SK))(undefined)(),\n        E.right([1, 2])\n      )\n      U.deepStrictEqual(\n        await pipe([right(3), left('a')], _.traverseReadonlyArrayWithIndex(SK))(undefined)(),\n        E.left('a')\n      )\n      U.deepStrictEqual(\n        await pipe([left('b'), right(4)], _.traverseReadonlyArrayWithIndex(SK))(undefined)(),\n        E.left('b')\n      )\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n    })\n\n    it('sequenceReadonlyArraySeq', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.ReaderTaskEither<undefined, string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.ReaderTaskEither<undefined, string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(\n        await pipe([right(1), right(2)], _.traverseReadonlyArrayWithIndexSeq(SK))(undefined)(),\n        E.right([1, 2])\n      )\n      U.deepStrictEqual(\n        await pipe([right(3), left('a')], _.traverseReadonlyArrayWithIndexSeq(SK))(undefined)(),\n        E.left('a')\n      )\n      U.deepStrictEqual(\n        await pipe([left('b'), right(4)], _.traverseReadonlyArrayWithIndexSeq(SK))(undefined)(),\n        E.left('b')\n      )\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n\n    // old\n    it('sequenceArray', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.ReaderTaskEither<undefined, string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.ReaderTaskEither<undefined, string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(await pipe([right(1), right(2)], _.sequenceArray)(undefined)(), E.right([1, 2]))\n      U.deepStrictEqual(await pipe([right(3), left('a')], _.sequenceArray)(undefined)(), E.left('a'))\n      U.deepStrictEqual(await pipe([left('b'), right(4)], _.sequenceArray)(undefined)(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n    })\n\n    it('sequenceSeqArray', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.ReaderTaskEither<undefined, string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.ReaderTaskEither<undefined, string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(await pipe([right(1), right(2)], _.sequenceSeqArray)(undefined)(), E.right([1, 2]))\n      U.deepStrictEqual(await pipe([right(3), left('a')], _.sequenceSeqArray)(undefined)(), E.left('a'))\n      U.deepStrictEqual(await pipe([left('b'), right(4)], _.sequenceSeqArray)(undefined)(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n  })\n\n  it('getCompactable', async () => {\n    const C = _.getCompactable(S.Monoid)\n    U.deepStrictEqual(await C.compact(_.of(O.some('a')))({})(), E.right('a'))\n  })\n\n  it('getFilterable', async () => {\n    const F = _.getFilterable(S.Monoid)\n    U.deepStrictEqual(await F.filter(_.of('a'), (s) => s.length > 0)({})(), E.right('a'))\n    U.deepStrictEqual(await F.filterMap(_.of('a'), (s) => (s.length > 0 ? O.some(s.length) : O.none))({})(), E.right(1))\n    const s1 = F.partition(_.of('a'), (s) => s.length > 0)\n    U.deepStrictEqual(await left(s1)({})(), E.left(''))\n    U.deepStrictEqual(await right(s1)({})(), E.right('a'))\n    const s2 = F.partitionMap(_.of('a'), (s) => (s.length > 0 ? E.right(s.length) : E.left(s)))\n    U.deepStrictEqual(await left(s2)({})(), E.left(''))\n    U.deepStrictEqual(await right(s2)({})(), E.right(1))\n  })\n\n  it('match', async () => {\n    const f = _.match(\n      () => 'left',\n      () => 'right'\n    )\n    U.deepStrictEqual(await f(_.right(1))({})(), 'right')\n    U.deepStrictEqual(await f(_.left(''))({})(), 'left')\n  })\n\n  it('matchE', async () => {\n    const f = _.matchE(\n      () => RT.of('left'),\n      () => RT.of('right')\n    )\n    U.deepStrictEqual(await f(_.right(1))({})(), 'right')\n    U.deepStrictEqual(await f(_.left(''))({})(), 'left')\n  })\n\n  it('fromNullable', async () => {\n    const testNullable = _.fromNullable('foo')\n    U.deepStrictEqual(await testNullable(1)(undefined)(), E.right(1))\n    U.deepStrictEqual(await testNullable(null)(undefined)(), E.left('foo'))\n    U.deepStrictEqual(await testNullable(undefined)(undefined)(), E.left('foo'))\n  })\n\n  it('fromNullableK', async () => {\n    const f = _.fromNullableK('foo')((n: number) => (n > 0 ? n : n === 0 ? null : undefined))\n    U.deepStrictEqual(await f(1)(undefined)(), E.right(1))\n    U.deepStrictEqual(await f(0)(undefined)(), E.left('foo'))\n    U.deepStrictEqual(await f(-1)(undefined)(), E.left('foo'))\n  })\n\n  it('chainNullableK', async () => {\n    const f = _.chainNullableK('foo')((n: number) => (n > 0 ? n : n === 0 ? null : undefined))\n    U.deepStrictEqual(await f(_.of(1))(undefined)(), E.right(1))\n    U.deepStrictEqual(await f(_.of(0))(undefined)(), E.left('foo'))\n    U.deepStrictEqual(await f(_.of(-1))(undefined)(), E.left('foo'))\n  })\n\n  it('tapIO', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => () => ref.push(value)\n\n    U.deepStrictEqual(await pipe(_.ask<number>(), _.tapIO(add))(1)(), E.of(1))\n    U.deepStrictEqual(await pipe(_.left('error'), _.tapIO(add))(undefined)(), E.left('error'))\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('as', async () => {\n    U.deepStrictEqual(await pipe(_.right('a'), _.as('b'))(undefined)(), E.right('b'))\n    U.deepStrictEqual(await _.as(_.of('a'), 'b')(undefined)(), E.right('b'))\n    U.deepStrictEqual(await _.as(_.left('error'), 'b')(undefined)(), E.left('error'))\n  })\n\n  it('asUnit', async () => {\n    U.deepStrictEqual(await pipe(_.of('a'), _.asUnit)(undefined)(), E.of(undefined))\n  })\n\n  it('tapTask', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => T.fromIO(() => ref.push(value))\n\n    U.deepStrictEqual(await pipe(_.ask<number>(), _.tapTask(add))(1)(), E.of(1))\n    U.deepStrictEqual(await pipe(_.left('error'), _.tapTask(add))(undefined)(), E.left('error'))\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('tapReader', async () => {\n    U.deepStrictEqual(await _.tapReader(_.of(1), () => R.of(2))({})(), E.of(1))\n  })\n\n  it('tapReaderEither', async () => {\n    U.deepStrictEqual(await _.tapReaderEither(_.of(1), () => RE.of(2))({})(), E.of(1))\n  })\n\n  it('tapTaskEither', async () => {\n    U.deepStrictEqual(await _.tapTaskEither(_.of(1), () => TE.of(2))({})(), E.of(1))\n  })\n\n  it('tapReaderTask', async () => {\n    U.deepStrictEqual(await _.tapReaderTask(_.of(1), () => RT.of(2))({})(), E.of(1))\n  })\n\n  it('tapReaderIO', async () => {\n    U.deepStrictEqual(await _.tapReaderIO(_.of(1), () => RIO.of(2))({})(), E.of(1))\n  })\n\n  it('flatMapIO', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.of(1),\n        _.flatMapIO(() => I.of(2))\n      )(undefined)(),\n      E.of(2)\n    )\n  })\n\n  it('flatMapTask', async () => {\n    const f = (s: string) => T.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.flatMapTask(f))(undefined)(), E.of(1))\n  })\n\n  it('flatMapReader', async () => {\n    U.deepStrictEqual(await _.flatMapReader(_.of(1), () => R.of(2))(undefined)(), E.of(2))\n  })\n\n  it('flatMapReaderIO', async () => {\n    U.deepStrictEqual(await _.flatMapReaderIO(_.of(1), () => RIO.of(2))(undefined)(), E.of(2))\n  })\n\n  it('flatMapIOEither', async () => {\n    U.deepStrictEqual(await _.flatMapIOEither(_.of(1), () => IE.of(2))(undefined)(), E.of(2))\n  })\n\n  it('flatMapReaderEither', async () => {\n    U.deepStrictEqual(await _.flatMapReaderEither(_.of(1), () => RE.of(2))(undefined)(), E.of(2))\n  })\n})\n"
  },
  {
    "path": "test/ReadonlyArray.ts",
    "content": "import * as assert from 'assert'\nimport * as fc from 'fast-check'\nimport { isDeepStrictEqual } from 'util'\n\nimport * as B from '../src/boolean'\nimport * as E from '../src/Either'\nimport * as Eq from '../src/Eq'\nimport { identity, pipe, tuple } from '../src/function'\nimport * as M from '../src/Monoid'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as Ord from '../src/Ord'\nimport { Predicate } from '../src/Predicate'\nimport * as _ from '../src/ReadonlyArray'\nimport { Refinement } from '../src/Refinement'\nimport { separated } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\ndescribe('ReadonlyArray', () => {\n  describe('pipeables', () => {\n    it('traverse', () => {\n      const traverse = _.traverse(O.Applicative)((n: number): O.Option<number> => (n % 2 === 0 ? O.none : O.some(n)))\n      U.deepStrictEqual(traverse([1, 2]), O.none)\n      U.deepStrictEqual(traverse([1, 3]), O.some([1, 3]))\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      U.deepStrictEqual(sequence([O.some(1), O.some(3)]), O.some([1, 3]))\n      U.deepStrictEqual(sequence([O.some(1), O.none]), O.none)\n    })\n\n    it('traverseWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'bb'],\n          _.traverseWithIndex(O.Applicative)((i, s) => (s.length >= 1 ? O.some(s + i) : O.none))\n        ),\n        O.some(['a0', 'bb1'])\n      )\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'bb'],\n          _.traverseWithIndex(O.Applicative)((i, s) => (s.length > 1 ? O.some(s + i) : O.none))\n        ),\n        O.none\n      )\n    })\n\n    it('lookup', () => {\n      U.deepStrictEqual(_.lookup(0, [1, 2, 3]), O.some(1))\n      U.deepStrictEqual(_.lookup(3, [1, 2, 3]), O.none)\n      U.deepStrictEqual(pipe([1, 2, 3], _.lookup(0)), O.some(1))\n      U.deepStrictEqual(pipe([1, 2, 3], _.lookup(3)), O.none)\n    })\n\n    it('elem', () => {\n      U.deepStrictEqual(_.elem(N.Eq)(2, [1, 2, 3]), true)\n      U.deepStrictEqual(_.elem(N.Eq)(0, [1, 2, 3]), false)\n      U.deepStrictEqual(pipe([1, 2, 3], _.elem(N.Eq)(2)), true)\n      U.deepStrictEqual(pipe([1, 2, 3], _.elem(N.Eq)(0)), false)\n    })\n\n    it('unfold', () => {\n      const as = _.unfold(5, (n) => (n > 0 ? O.some([n, n - 1]) : O.none))\n      U.deepStrictEqual(as, [5, 4, 3, 2, 1])\n    })\n\n    it('wither', async () => {\n      const wither = _.wither(T.ApplicativePar)((n: number) => T.of(n > 2 ? O.some(n + 1) : O.none))\n      U.deepStrictEqual(await pipe([], wither)(), [])\n      U.deepStrictEqual(await pipe([1, 3], wither)(), [4])\n    })\n\n    it('wilt', async () => {\n      const wilt = _.wilt(T.ApplicativePar)((n: number) => T.of(n > 2 ? E.right(n + 1) : E.left(n - 1)))\n      U.deepStrictEqual(await pipe([], wilt)(), separated([], []))\n      U.deepStrictEqual(await pipe([1, 3], wilt)(), separated([0], [4]))\n    })\n\n    it('map', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.map((n) => n * 2)\n        ),\n        [2, 4, 6]\n      )\n    })\n\n    it('mapWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.mapWithIndex((i, n) => n + i)\n        ),\n        [1, 3, 5]\n      )\n    })\n\n    it('alt', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2],\n          _.alt(() => [3, 4])\n        ),\n        [1, 2, 3, 4]\n      )\n    })\n\n    it('ap', () => {\n      U.deepStrictEqual(pipe([(x: number) => x * 2, (x: number) => x * 3], _.ap([1, 2, 3])), [2, 4, 6, 3, 6, 9])\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe([1, 2], _.apFirst(['a', 'b', 'c'])), [1, 1, 1, 2, 2, 2])\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe([1, 2], _.apSecond(['a', 'b', 'c'])), ['a', 'b', 'c', 'a', 'b', 'c'])\n    })\n\n    it('flatMap', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.flatMap((n) => [n, n + 1])\n        ),\n        [1, 2, 2, 3, 3, 4]\n      )\n      U.deepStrictEqual(\n        _.flatMap([1, 2, 3], (n) => [n, n + 1]),\n        [1, 2, 2, 3, 3, 4]\n      )\n    })\n\n    it('chain', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.chain((n) => [n, n + 1])\n        ),\n        [1, 2, 2, 3, 3, 4]\n      )\n    })\n\n    it('chainWithIndex', () => {\n      const f = _.chainWithIndex((i, n: number) => [n + i])\n      U.deepStrictEqual(pipe([1, 2, 3], f), [1, 3, 5])\n      U.strictEqual(pipe(_.empty, f), _.empty)\n      const empty: ReadonlyArray<number> = []\n      U.strictEqual(pipe(empty, f), _.empty)\n    })\n\n    it('chainFirst', () => {\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.chainFirst((n) => [n, n + 1])\n        ),\n        [1, 1, 2, 2, 3, 3]\n      )\n    })\n\n    it('extend', () => {\n      const sum = (as: ReadonlyArray<number>) => M.concatAll(N.MonoidSum)(as)\n      U.deepStrictEqual(pipe([1, 2, 3, 4], _.extend(sum)), [10, 9, 7, 4])\n      U.deepStrictEqual(pipe([1, 2, 3, 4], _.extend(identity)), [[1, 2, 3, 4], [2, 3, 4], [3, 4], [4]])\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe(['a', 'b', 'c'], _.foldMap(S.Monoid)(identity)), 'abc')\n      U.deepStrictEqual(pipe([], _.foldMap(S.Monoid)(identity)), '')\n    })\n\n    it('compact', () => {\n      U.deepStrictEqual(_.compact([]), [])\n      U.deepStrictEqual(_.compact([O.some(1), O.some(2), O.some(3)]), [1, 2, 3])\n      U.deepStrictEqual(_.compact([O.some(1), O.none, O.some(3)]), [1, 3])\n    })\n\n    it('separate', () => {\n      U.deepStrictEqual(_.separate([]), separated([], []))\n      U.deepStrictEqual(_.separate([E.left(123), E.right('123')]), separated([123], ['123']))\n    })\n\n    it('filter', () => {\n      const g = (n: number) => n % 2 === 1\n      U.deepStrictEqual(pipe([1, 2, 3], _.filter(g)), [1, 3])\n      const x = pipe([O.some(3), O.some(2), O.some(1)], _.filter(O.isSome))\n      assert.deepStrictEqual(x, [O.some(3), O.some(2), O.some(1)])\n      const y = pipe([O.some(3), O.none, O.some(1)], _.filter(O.isSome))\n      assert.deepStrictEqual(y, [O.some(3), O.some(1)])\n    })\n\n    it('filterWithIndex', () => {\n      const f = (n: number) => n % 2 === 0\n      U.deepStrictEqual(pipe(['a', 'b', 'c'], _.filterWithIndex(f)), ['a', 'c'])\n    })\n\n    it('filterMap', () => {\n      const f = (n: number) => (n % 2 === 0 ? O.none : O.some(n))\n      U.deepStrictEqual(pipe([1, 2, 3], _.filterMap(f)), [1, 3])\n      U.deepStrictEqual(pipe([], _.filterMap(f)), [])\n    })\n\n    it('foldMapWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'b'],\n          _.foldMapWithIndex(S.Monoid)((i, a) => i + a)\n        ),\n        '0a1b'\n      )\n    })\n\n    it('filterMapWithIndex', () => {\n      const f = (i: number, n: number) => ((i + n) % 2 === 0 ? O.none : O.some(n))\n      U.deepStrictEqual(pipe([1, 2, 4], _.filterMapWithIndex(f)), [1, 2])\n      U.deepStrictEqual(pipe([], _.filterMapWithIndex(f)), [])\n    })\n\n    it('partitionMap', () => {\n      U.deepStrictEqual(pipe([], _.partitionMap(identity)), separated([], []))\n      U.deepStrictEqual(\n        pipe([E.right(1), E.left('foo'), E.right(2)], _.partitionMap(identity)),\n        separated(['foo'], [1, 2])\n      )\n    })\n\n    it('partition', () => {\n      U.deepStrictEqual(\n        pipe(\n          [],\n          _.partition((n) => n > 2)\n        ),\n        separated([], [])\n      )\n      U.deepStrictEqual(\n        pipe(\n          [1, 3],\n          _.partition((n) => n > 2)\n        ),\n        separated([1], [3])\n      )\n    })\n\n    it('partitionMapWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          [],\n          _.partitionMapWithIndex((_, a) => a)\n        ),\n        separated([], [])\n      )\n      U.deepStrictEqual(\n        pipe(\n          [E.right(1), E.left('foo'), E.right(2)],\n          _.partitionMapWithIndex((i, a) =>\n            pipe(\n              a,\n              E.filterOrElse(\n                (n) => n > i,\n                () => 'err'\n              )\n            )\n          )\n        ),\n        separated(['foo', 'err'], [1])\n      )\n    })\n\n    it('partitionWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          [],\n          _.partitionWithIndex((i, n) => i + n > 2)\n        ),\n        separated([], [])\n      )\n      U.deepStrictEqual(\n        pipe(\n          [1, 2],\n          _.partitionWithIndex((i, n) => i + n > 2)\n        ),\n        separated([1], [2])\n      )\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'b', 'c'],\n          _.reduce('', (acc, a) => acc + a)\n        ),\n        'abc'\n      )\n    })\n\n    it('reduceWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'b'],\n          _.reduceWithIndex('', (i, b, a) => b + i + a)\n        ),\n        '0a1b'\n      )\n    })\n\n    it('reduceRight', () => {\n      const as: ReadonlyArray<string> = ['a', 'b', 'c']\n      const b = ''\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(pipe(as, _.reduceRight(b, f)), 'cba')\n      const x2: ReadonlyArray<string> = []\n      U.deepStrictEqual(pipe(x2, _.reduceRight(b, f)), '')\n    })\n\n    it('reduceRightWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'b'],\n          _.reduceRightWithIndex('', (i, a, b) => b + i + a)\n        ),\n        '1b0a'\n      )\n    })\n\n    it('duplicate', () => {\n      U.deepStrictEqual(pipe(['a', 'b'], _.duplicate), [['a', 'b'], ['b']])\n    })\n  })\n\n  it('getMonoid', () => {\n    const M = _.getMonoid<number>()\n    U.deepStrictEqual(M.concat([1, 2], [3, 4]), [1, 2, 3, 4])\n    const x = [1, 2]\n    U.strictEqual(M.concat(x, M.empty), x)\n    U.strictEqual(M.concat(M.empty, x), x)\n  })\n\n  it('getEq', () => {\n    const O = _.getEq(S.Ord)\n    U.deepStrictEqual(O.equals([], []), true)\n    U.deepStrictEqual(O.equals(['a'], ['a']), true)\n    U.deepStrictEqual(O.equals(['a', 'b'], ['a', 'b']), true)\n    U.deepStrictEqual(O.equals(['a'], []), false)\n    U.deepStrictEqual(O.equals([], ['a']), false)\n    U.deepStrictEqual(O.equals(['a'], ['b']), false)\n    U.deepStrictEqual(O.equals(['a', 'b'], ['b', 'a']), false)\n    U.deepStrictEqual(O.equals(['a', 'a'], ['a']), false)\n  })\n\n  it('getOrd', () => {\n    const O = _.getOrd(S.Ord)\n    U.deepStrictEqual(O.compare([], []), 0)\n    U.deepStrictEqual(O.compare(['a'], ['a']), 0)\n\n    U.deepStrictEqual(O.compare(['b'], ['a']), 1)\n    U.deepStrictEqual(O.compare(['a'], ['b']), -1)\n\n    U.deepStrictEqual(O.compare(['a'], []), 1)\n    U.deepStrictEqual(O.compare([], ['a']), -1)\n    U.deepStrictEqual(O.compare(['a', 'a'], ['a']), 1)\n    U.deepStrictEqual(O.compare(['a', 'a'], ['b']), -1)\n\n    U.deepStrictEqual(O.compare(['a', 'a'], ['a', 'a']), 0)\n    U.deepStrictEqual(O.compare(['a', 'b'], ['a', 'b']), 0)\n\n    U.deepStrictEqual(O.compare(['a', 'a'], ['a', 'b']), -1)\n    U.deepStrictEqual(O.compare(['a', 'b'], ['a', 'a']), 1)\n\n    U.deepStrictEqual(O.compare(['a', 'b'], ['b', 'a']), -1)\n    U.deepStrictEqual(O.compare(['b', 'a'], ['a', 'a']), 1)\n    U.deepStrictEqual(O.compare(['b', 'a'], ['a', 'b']), 1)\n    U.deepStrictEqual(O.compare(['b', 'b'], ['b', 'a']), 1)\n    U.deepStrictEqual(O.compare(['b', 'a'], ['b', 'b']), -1)\n  })\n\n  it('isEmpty', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.isEmpty(as), false)\n    U.deepStrictEqual(_.isEmpty([]), true)\n  })\n\n  it('isNotEmpty', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.isNonEmpty(as), true)\n    U.deepStrictEqual(_.isNonEmpty([]), false)\n  })\n\n  it('cons', () => {\n    U.deepStrictEqual(_.cons(0, [1, 2, 3]), [0, 1, 2, 3])\n    U.deepStrictEqual(_.cons([1], [[2]]), [[1], [2]])\n    U.deepStrictEqual(pipe([1, 2, 3], _.cons(0)), [0, 1, 2, 3])\n    U.deepStrictEqual(pipe([[2]], _.cons([1])), [[1], [2]])\n  })\n\n  it('snoc', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.snoc(as, 4), [1, 2, 3, 4])\n    U.deepStrictEqual(_.snoc([[1]], [2]), [[1], [2]])\n  })\n\n  it('head', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.head(as), O.some(1))\n    U.deepStrictEqual(_.head([]), O.none)\n  })\n\n  it('last', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.last(as), O.some(3))\n    U.deepStrictEqual(_.last([]), O.none)\n  })\n\n  it('tail', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.tail(as), O.some([2, 3]))\n    U.deepStrictEqual(_.tail([]), O.none)\n  })\n\n  it('takeLeft', () => {\n    // _.empty\n    U.strictEqual(_.takeLeft(0)(_.empty), _.empty)\n    // empty\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(_.takeLeft(0)(empty), empty)\n    const full: ReadonlyArray<number> = [1, 2]\n    // non empty\n    U.strictEqual(_.takeLeft(0)(full), _.empty)\n    U.deepStrictEqual(_.takeLeft(1)(full), [1])\n    // full\n    U.strictEqual(_.takeLeft(2)(full), full)\n    // out of bound\n    U.strictEqual(_.takeLeft(1)(_.empty), _.empty)\n    U.strictEqual(_.takeLeft(1)(empty), empty)\n    U.strictEqual(_.takeLeft(3)(full), full)\n    U.strictEqual(_.takeLeft(-1)(_.empty), _.empty)\n    U.strictEqual(_.takeLeft(-1)(empty), empty)\n    U.strictEqual(_.takeLeft(-1)(full), full)\n  })\n\n  it('takeRight', () => {\n    // _.empty\n    U.strictEqual(_.takeRight(0)(_.empty), _.empty)\n    // empty\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(_.takeRight(0)(empty), empty)\n    const full: ReadonlyArray<number> = [1, 2]\n    // non empty\n    U.strictEqual(_.takeRight(0)(full), _.empty)\n    U.deepStrictEqual(_.takeRight(1)(full), [2])\n    // full\n    U.strictEqual(_.takeRight(2)(full), full)\n    // out of bound\n    U.strictEqual(_.takeRight(1)(_.empty), _.empty)\n    U.strictEqual(_.takeRight(1)(empty), empty)\n    U.strictEqual(_.takeRight(3)(full), full)\n    U.strictEqual(_.takeRight(-1)(_.empty), _.empty)\n    U.strictEqual(_.takeRight(-1)(empty), empty)\n    U.strictEqual(_.takeRight(-1)(full), full)\n  })\n\n  it('spanLeft', () => {\n    const f = _.spanLeft((n: number) => n % 2 === 1)\n    const assertSpanLeft = (\n      input: ReadonlyArray<number>,\n      expectedInit: ReadonlyArray<number>,\n      expectedRest: ReadonlyArray<number>\n    ) => {\n      const { init, rest } = f(input)\n      U.strictEqual(init, expectedInit)\n      U.strictEqual(rest, expectedRest)\n    }\n    U.deepStrictEqual(f([1, 3, 2, 4, 5]), { init: [1, 3], rest: [2, 4, 5] })\n    const empty: ReadonlyArray<number> = []\n    assertSpanLeft(empty, empty, _.empty)\n    assertSpanLeft(_.empty, _.empty, _.empty)\n    const inputAll: ReadonlyArray<number> = [1, 3]\n    assertSpanLeft(inputAll, inputAll, _.empty)\n    const inputNone: ReadonlyArray<number> = [2, 4]\n    assertSpanLeft(inputNone, _.empty, inputNone)\n  })\n\n  it('takeLeftWhile', () => {\n    const f = (n: number) => n % 2 === 0\n    U.deepStrictEqual(_.takeLeftWhile(f)([2, 4, 3, 6]), [2, 4])\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(_.takeLeftWhile(f)(empty), empty)\n    U.strictEqual(_.takeLeftWhile(f)(_.empty), _.empty)\n    U.strictEqual(_.takeLeftWhile(f)([1, 2, 4]), _.empty)\n    const input: ReadonlyArray<number> = [2, 4]\n    U.strictEqual(_.takeLeftWhile(f)(input), input)\n  })\n\n  it('dropLeft', () => {\n    // _.empty\n    U.strictEqual(_.dropLeft(0)(_.empty), _.empty)\n    // empty\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(_.dropLeft(0)(empty), empty)\n    const full: ReadonlyArray<number> = [1, 2]\n    // non empty\n    U.strictEqual(_.dropLeft(0)(full), full)\n    U.deepStrictEqual(_.dropLeft(1)(full), [2])\n    // full\n    U.strictEqual(_.dropLeft(2)(full), _.empty)\n    // out of bound\n    U.strictEqual(_.dropLeft(1)(_.empty), _.empty)\n    U.strictEqual(_.dropLeft(1)(empty), empty)\n    U.strictEqual(_.dropLeft(3)(full), _.empty)\n    U.strictEqual(_.dropLeft(-1)(_.empty), _.empty)\n    U.strictEqual(_.dropLeft(-1)(empty), empty)\n    U.strictEqual(_.dropLeft(-1)(full), full)\n  })\n\n  it('dropRight', () => {\n    // _.empty\n    U.strictEqual(_.dropRight(0)(_.empty), _.empty)\n    // empty\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(_.dropRight(0)(empty), empty)\n    const full: ReadonlyArray<number> = [1, 2]\n    // non empty\n    U.strictEqual(_.dropRight(0)(full), full)\n    U.deepStrictEqual(_.dropRight(1)(full), [1])\n    // full\n    U.strictEqual(_.dropRight(2)(full), _.empty)\n    // out of bound\n    U.strictEqual(_.dropRight(1)(_.empty), _.empty)\n    U.strictEqual(_.dropRight(1)(empty), empty)\n    U.strictEqual(_.dropRight(3)(full), _.empty)\n    U.strictEqual(_.dropRight(-1)(_.empty), _.empty)\n    U.strictEqual(_.dropRight(-1)(empty), empty)\n    U.strictEqual(_.dropRight(-1)(full), full)\n  })\n\n  it('dropLeftWhile', () => {\n    const f = _.dropLeftWhile((n: number) => n > 0)\n    U.strictEqual(f(_.empty), _.empty)\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(f(empty), empty)\n    U.strictEqual(f([1, 2]), _.empty)\n    const x1: ReadonlyArray<number> = [-1, -2]\n    U.strictEqual(f(x1), x1)\n    const x2: ReadonlyArray<number> = [-1, 2]\n    U.strictEqual(f(x2), x2)\n    U.deepStrictEqual(f([1, -2, 3]), [-2, 3])\n  })\n\n  it('init', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.init(as), O.some([1, 2]))\n    U.deepStrictEqual(_.init([]), O.none)\n  })\n\n  it('findIndex', () => {\n    U.deepStrictEqual(_.findIndex((x) => x === 2)([1, 2, 3]), O.some(1))\n    U.deepStrictEqual(_.findIndex((x) => x === 2)([]), O.none)\n  })\n\n  it('findFirst', () => {\n    U.deepStrictEqual(\n      pipe(\n        [],\n        _.findFirst((x: { readonly a: number }) => x.a > 1)\n      ),\n      O.none\n    )\n    U.deepStrictEqual(\n      pipe(\n        [{ a: 1 }, { a: 2 }, { a: 3 }],\n        _.findFirst((x) => x.a > 1)\n      ),\n      O.some({ a: 2 })\n    )\n    U.deepStrictEqual(\n      pipe(\n        [{ a: 1 }, { a: 2 }, { a: 3 }],\n        _.findFirst((x) => x.a > 3)\n      ),\n      O.none\n    )\n  })\n\n  it('findFirstMap', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        _.findFirstMap((n) => (n > 1 ? O.some(n * 2) : O.none))\n      ),\n      O.some(4)\n    )\n    U.deepStrictEqual(\n      pipe(\n        [1],\n        _.findFirstMap((n) => (n < 1 ? O.some(n * 2) : O.none))\n      ),\n      O.none\n    )\n  })\n\n  it('findLast', () => {\n    U.deepStrictEqual(\n      pipe(\n        [],\n        _.findLast((x: { readonly a: number }) => x.a > 1)\n      ),\n      O.none\n    )\n    U.deepStrictEqual(\n      pipe(\n        [{ a: 1 }, { a: 2 }, { a: 3 }],\n        _.findLast((x) => x.a > 1)\n      ),\n      O.some({ a: 3 })\n    )\n    U.deepStrictEqual(\n      pipe(\n        [{ a: 1 }, { a: 2 }, { a: 3 }],\n        _.findLast((x) => x.a > 3)\n      ),\n      O.none\n    )\n  })\n\n  it('findLastMap', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        _.findLastMap((n) => (n > 1 ? O.some(n * 2) : O.none))\n      ),\n      O.some(6)\n    )\n    U.deepStrictEqual(\n      pipe(\n        [1],\n        _.findLastMap((n) => (n > 1 ? O.some(n * 2) : O.none))\n      ),\n      O.none\n    )\n  })\n\n  it('findLastIndex', () => {\n    interface X {\n      readonly a: number\n      readonly b: number\n    }\n    const xs: ReadonlyArray<X> = [\n      { a: 1, b: 0 },\n      { a: 1, b: 1 }\n    ]\n    U.deepStrictEqual(_.findLastIndex((x: X) => x.a === 1)(xs), O.some(1))\n    U.deepStrictEqual(_.findLastIndex((x: X) => x.a === 4)(xs), O.none)\n    U.deepStrictEqual(_.findLastIndex((x: X) => x.a === 1)([]), O.none)\n  })\n\n  it('insertAt', () => {\n    U.deepStrictEqual(_.insertAt(1, 1)([]), O.none)\n    U.deepStrictEqual(_.insertAt(0, 1)([]), O.some([1] as const))\n    U.deepStrictEqual(_.insertAt(2, 5)([1, 2, 3, 4]), O.some([1, 2, 5, 3, 4] as const))\n  })\n\n  it('unsafeUpdateAt', () => {\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(_.unsafeUpdateAt(1, 2, empty), empty)\n    U.strictEqual(_.unsafeUpdateAt(1, 2, _.empty), _.empty)\n    // should return the same reference if nothing changed\n    const input: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(\n      pipe(_.unsafeUpdateAt(1, 2, input), (out) => out === input),\n      true\n    )\n  })\n\n  it('updateAt', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.updateAt(1, 1)(as), O.some([1, 1, 3]))\n    U.deepStrictEqual(_.updateAt(1, 1)([]), O.none)\n  })\n\n  it('deleteAt', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(_.deleteAt(0)(as), O.some([2, 3]))\n    U.deepStrictEqual(_.deleteAt(1)([]), O.none)\n  })\n\n  it('modifyAt', () => {\n    U.deepStrictEqual(_.modifyAt(1, U.double)([1, 2, 3]), O.some([1, 4, 3]))\n    U.deepStrictEqual(_.modifyAt(1, U.double)([]), O.none)\n    // should return the same reference if nothing changed\n    const input: ReadonlyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(\n      pipe(\n        input,\n        _.modifyAt(1, identity),\n        O.map((out) => out === input)\n      ),\n      O.some(true)\n    )\n  })\n\n  it('sort', () => {\n    const O = pipe(\n      N.Ord,\n      Ord.contramap((x: { readonly a: number }) => x.a)\n    )\n    U.deepStrictEqual(\n      pipe(\n        [\n          { a: 3, b: 'b1' },\n          { a: 2, b: 'b2' },\n          { a: 1, b: 'b3' }\n        ],\n        _.sort(O)\n      ),\n      [\n        { a: 1, b: 'b3' },\n        { a: 2, b: 'b2' },\n        { a: 3, b: 'b1' }\n      ]\n    )\n    U.strictEqual(_.sort(N.Ord)(_.empty), _.empty)\n    const as: ReadonlyArray<number> = [1]\n    U.strictEqual(_.sort(N.Ord)(as), as)\n  })\n\n  it('zipWith', () => {\n    U.deepStrictEqual(\n      _.zipWith([1, 2, 3], [], (n, s) => s + n),\n      []\n    )\n    U.deepStrictEqual(\n      _.zipWith([], ['a', 'b', 'c', 'd'], (n, s) => s + n),\n      []\n    )\n    U.deepStrictEqual(\n      _.zipWith([], [], (n, s) => s + n),\n      []\n    )\n    U.deepStrictEqual(\n      _.zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n),\n      ['a1', 'b2', 'c3']\n    )\n  })\n\n  it('zip', () => {\n    U.deepStrictEqual(_.zip([], ['a', 'b', 'c', 'd']), [])\n    U.deepStrictEqual(_.zip([1, 2, 3], []), [])\n    U.deepStrictEqual(_.zip([1, 2, 3], ['a', 'b', 'c', 'd']), [\n      [1, 'a'],\n      [2, 'b'],\n      [3, 'c']\n    ])\n    U.deepStrictEqual(pipe([1, 2, 3], _.zip(['a', 'b', 'c', 'd'])), [\n      [1, 'a'],\n      [2, 'b'],\n      [3, 'c']\n    ])\n  })\n\n  it('unzip', () => {\n    U.deepStrictEqual(_.unzip([]), [[], []])\n    U.deepStrictEqual(\n      _.unzip([\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('rights', () => {\n    U.deepStrictEqual(_.rights([E.right(1), E.left('foo'), E.right(2)]), [1, 2])\n    U.deepStrictEqual(_.rights([]), [])\n  })\n\n  it('lefts', () => {\n    U.deepStrictEqual(_.lefts([E.right(1), E.left('foo'), E.right(2)]), ['foo'])\n    U.deepStrictEqual(_.lefts([]), [])\n  })\n\n  it('flatten', () => {\n    U.deepStrictEqual(_.flatten([[1], [2], [3]]), [1, 2, 3])\n  })\n\n  it('prependAll', () => {\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(_.prependAll(0)(empty), empty)\n    U.strictEqual(_.prependAll(0)(_.empty), _.empty)\n    U.deepStrictEqual(_.prependAll(0)([1, 2, 3]), [0, 1, 0, 2, 0, 3])\n    U.deepStrictEqual(_.prependAll(0)([1]), [0, 1])\n    U.deepStrictEqual(_.prependAll(0)([1, 2, 3, 4]), [0, 1, 0, 2, 0, 3, 0, 4])\n  })\n\n  it('intersperse', () => {\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(_.intersperse(0)(empty), empty)\n    U.strictEqual(_.intersperse(0)(_.empty), _.empty)\n    const singleton = [1]\n    U.strictEqual(_.intersperse(0)(singleton), singleton)\n    U.deepStrictEqual(_.intersperse(0)([1, 2, 3]), [1, 0, 2, 0, 3])\n    U.deepStrictEqual(_.intersperse(0)([1, 2]), [1, 0, 2])\n    U.deepStrictEqual(_.intersperse(0)([1, 2, 3, 4]), [1, 0, 2, 0, 3, 0, 4])\n  })\n\n  it('intercalate', () => {\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')([]), '')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a']), 'a')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a', 'b', 'c']), 'a-b-c')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a', '', 'c']), 'a--c')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a', 'b']), 'a-b')\n    U.deepStrictEqual(_.intercalate(S.Monoid)('-')(['a', 'b', 'c', 'd']), 'a-b-c-d')\n  })\n\n  it('rotate', () => {\n    U.strictEqual(_.rotate(0)(_.empty), _.empty)\n    U.strictEqual(_.rotate(1)(_.empty), _.empty)\n\n    const singleton: ReadonlyArray<number> = [1]\n    U.strictEqual(_.rotate(1)(singleton), singleton)\n    U.strictEqual(_.rotate(2)(singleton), singleton)\n    U.strictEqual(_.rotate(-1)(singleton), singleton)\n    U.strictEqual(_.rotate(-2)(singleton), singleton)\n    const two: ReadonlyArray<number> = [1, 2]\n    U.strictEqual(_.rotate(2)(two), two)\n    U.strictEqual(_.rotate(0)(two), two)\n    U.strictEqual(_.rotate(-2)(two), two)\n\n    U.deepStrictEqual(_.rotate(1)([1, 2]), [2, 1])\n    U.deepStrictEqual(_.rotate(1)([1, 2, 3, 4, 5]), [5, 1, 2, 3, 4])\n    U.deepStrictEqual(_.rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n    U.deepStrictEqual(_.rotate(-1)([1, 2, 3, 4, 5]), [2, 3, 4, 5, 1])\n    U.deepStrictEqual(_.rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n\n    U.deepStrictEqual(_.rotate(7)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n    U.deepStrictEqual(_.rotate(-7)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n\n    U.deepStrictEqual(_.rotate(2.2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n    U.deepStrictEqual(_.rotate(-2.2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n  })\n\n  it('reverse', () => {\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(_.reverse(empty), empty)\n    U.strictEqual(_.reverse(_.empty), _.empty)\n    const singleton: ReadonlyArray<number> = [1]\n    U.strictEqual(_.reverse(singleton), singleton)\n    U.deepStrictEqual(_.reverse([1, 2, 3]), [3, 2, 1])\n  })\n\n  it('foldLeft', () => {\n    const len: <A>(as: ReadonlyArray<A>) => number = _.foldLeft(\n      () => 0,\n      (_, tail) => 1 + len(tail)\n    )\n    U.deepStrictEqual(len([1, 2, 3]), 3)\n  })\n\n  it('foldRight', () => {\n    const len: <A>(as: ReadonlyArray<A>) => number = _.foldRight(\n      () => 0,\n      (init, _) => 1 + len(init)\n    )\n    U.deepStrictEqual(len([1, 2, 3]), 3)\n  })\n\n  it('scanLeft', () => {\n    const f = (b: number, a: number) => b - a\n    U.deepStrictEqual(_.scanLeft(10, f)([1, 2, 3]), [10, 9, 7, 4])\n    U.deepStrictEqual(_.scanLeft(10, f)([0]), [10, 10])\n    U.deepStrictEqual(_.scanLeft(10, f)([]), [10])\n  })\n\n  it('scanRight', () => {\n    const f = (b: number, a: number) => b - a\n    U.deepStrictEqual(_.scanRight(10, f)([1, 2, 3]), [-8, 9, -7, 10])\n    U.deepStrictEqual(_.scanRight(10, f)([0]), [-10, 10])\n    U.deepStrictEqual(_.scanRight(10, f)([]), [10])\n  })\n\n  it('uniq', () => {\n    interface A {\n      readonly a: string\n      readonly b: number\n    }\n\n    const eqA = pipe(\n      N.Eq,\n      Eq.contramap((f: A) => f.b)\n    )\n    const arrA: A = { a: 'a', b: 1 }\n    const arrB: A = { a: 'b', b: 1 }\n    const arrC: A = { a: 'c', b: 2 }\n    const arrD: A = { a: 'd', b: 2 }\n    const arrUniq: ReadonlyArray<A> = [arrA, arrC]\n\n    U.deepStrictEqual(_.uniq(eqA)(arrUniq), arrUniq)\n    U.deepStrictEqual(_.uniq(eqA)([arrA, arrB, arrC, arrD]), [arrA, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrB, arrA, arrC, arrD]), [arrB, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrA, arrA, arrC, arrD, arrA]), [arrA, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrA, arrC]), [arrA, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrC, arrA]), [arrC, arrA])\n    U.deepStrictEqual(_.uniq(B.Eq)([true, false, true, false]), [true, false])\n    U.deepStrictEqual(_.uniq(N.Eq)([-0, -0]), [-0])\n    U.deepStrictEqual(_.uniq(N.Eq)([0, -0]), [0])\n    U.deepStrictEqual(_.uniq(N.Eq)([1]), [1])\n    U.deepStrictEqual(_.uniq(N.Eq)([2, 1, 2]), [2, 1])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 2, 1]), [1, 2])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 1, 2, 2, 3, 3, 4, 4, 5, 5]), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.uniq(S.Eq)(['a', 'b', 'a']), ['a', 'b'])\n    U.deepStrictEqual(_.uniq(S.Eq)(['a', 'b', 'A']), ['a', 'b', 'A'])\n\n    U.strictEqual(_.uniq(N.Eq)(_.empty), _.empty)\n    const as: ReadonlyArray<number> = [1]\n    U.strictEqual(_.uniq(N.Eq)(as), as)\n  })\n\n  it('sortBy', () => {\n    interface X {\n      readonly a: string\n      readonly b: number\n      readonly c: boolean\n    }\n    const byName = pipe(\n      S.Ord,\n      Ord.contramap((p: { readonly a: string; readonly b: number }) => p.a)\n    )\n    const byAge = pipe(\n      N.Ord,\n      Ord.contramap((p: { readonly a: string; readonly b: number }) => p.b)\n    )\n    const f = _.sortBy([byName, byAge])\n    const xs: ReadonlyArray<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    U.deepStrictEqual(f(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    const sortByAgeByName = _.sortBy([byAge, byName])\n    U.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    U.strictEqual(f(_.empty), _.empty)\n    U.strictEqual(_.sortBy([])(xs), xs)\n  })\n\n  it('chop', () => {\n    const f = _.chop<number, number>((as) => [as[0] * 2, as.slice(1)])\n    const empty: ReadonlyArray<number> = []\n    U.strictEqual(f(empty), _.empty)\n    U.strictEqual(f(_.empty), _.empty)\n    U.deepStrictEqual(f([1, 2, 3]), [2, 4, 6])\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] = _.splitAt(index)(input)\n      U.strictEqual(init, expectedInit)\n      U.strictEqual(rest, expectedRest)\n    }\n    U.deepStrictEqual(_.splitAt(1)([1, 2]), [[1], [2]])\n    const two: ReadonlyArray<number> = [1, 2]\n    assertSplitAt(two, 2, two, _.empty)\n    U.deepStrictEqual(_.splitAt(2)([1, 2, 3, 4, 5]), [\n      [1, 2],\n      [3, 4, 5]\n    ])\n    // zero\n    const empty: ReadonlyArray<number> = []\n    assertSplitAt(_.empty, 0, _.empty, _.empty)\n    assertSplitAt(empty, 0, empty, _.empty)\n    assertSplitAt(two, 0, _.empty, two)\n    // out of bounds\n    assertSplitAt(_.empty, -1, _.empty, _.empty)\n    assertSplitAt(empty, -1, empty, _.empty)\n    assertSplitAt(two, -1, _.empty, two)\n    assertSplitAt(two, 3, two, _.empty)\n    assertSplitAt(_.empty, 3, _.empty, _.empty)\n    assertSplitAt(empty, 3, empty, _.empty)\n  })\n\n  describe('chunksOf', () => {\n    it('should split a `ReadonlyArray` into length-n pieces', () => {\n      U.deepStrictEqual(_.chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])\n      U.deepStrictEqual(_.chunksOf(2)([1, 2, 3, 4, 5, 6]), [\n        [1, 2],\n        [3, 4],\n        [5, 6]\n      ])\n      U.deepStrictEqual(_.chunksOf(1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n      U.deepStrictEqual(_.chunksOf(5)([1, 2, 3, 4, 5]), [[1, 2, 3, 4, 5]])\n      // out of bounds\n      U.deepStrictEqual(_.chunksOf(0)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n      U.deepStrictEqual(_.chunksOf(-1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n\n      const assertSingleChunk = (input: ReadonlyArray<number>, n: number) => {\n        const chunks = _.chunksOf(n)(input)\n        U.strictEqual(chunks.length, 1)\n        U.strictEqual(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    // #897\n    it('returns an empty array if provided an empty array', () => {\n      const empty: ReadonlyArray<number> = []\n      U.strictEqual(_.chunksOf(0)(empty), _.empty)\n      U.strictEqual(_.chunksOf(0)(_.empty), _.empty)\n      U.strictEqual(_.chunksOf(1)(empty), _.empty)\n      U.strictEqual(_.chunksOf(1)(_.empty), _.empty)\n      U.strictEqual(_.chunksOf(2)(empty), _.empty)\n      U.strictEqual(_.chunksOf(2)(_.empty), _.empty)\n    })\n\n    // #897\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      U.deepStrictEqual(_.chunksOf(2)(xs).concat(_.chunksOf(2)(ys)), _.chunksOf(2)(xs.concat(ys)))\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 = _.chunksOf(n)(xs).concat(_.chunksOf(n)(ys))\n            const bs = _.chunksOf(n)(xs.concat(ys))\n            isDeepStrictEqual(as, bs)\n          }\n        )\n      )\n    })\n  })\n\n  it('prepend', () => {\n    U.deepStrictEqual(pipe(['a', 'b'], _.prepend('c')), ['c', 'a', 'b'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.prependW(3)), [3, 'a', 'b'])\n  })\n\n  it('append', () => {\n    U.deepStrictEqual(pipe(['a', 'b'], _.append('c')), ['a', 'b', 'c'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.appendW(3)), ['a', 'b', 3])\n  })\n\n  it('makeBy', () => {\n    U.deepStrictEqual(_.makeBy(5, U.double), [0, 2, 4, 6, 8])\n    U.strictEqual(_.makeBy(0, U.double), _.empty)\n    U.strictEqual(_.makeBy(-1, U.double), _.empty)\n    U.deepStrictEqual(_.makeBy(2.2, U.double), [0, 2])\n  })\n\n  it('replicate', () => {\n    U.strictEqual(_.replicate(0, 'a'), _.empty)\n    U.strictEqual(_.replicate(-1, 'a'), _.empty)\n    U.deepStrictEqual(_.replicate(3, 'a'), ['a', 'a', 'a'])\n    U.deepStrictEqual(_.replicate(2.2, 'a'), ['a', 'a'])\n  })\n\n  it('range', () => {\n    U.deepStrictEqual(_.range(0, 0), [0])\n    U.deepStrictEqual(_.range(0, 1), [0, 1])\n    U.deepStrictEqual(_.range(1, 5), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.range(10, 15), [10, 11, 12, 13, 14, 15])\n    U.deepStrictEqual(_.range(-1, 0), [-1, 0])\n    U.deepStrictEqual(_.range(-5, -1), [-5, -4, -3, -2, -1])\n    // out of bound\n    U.deepStrictEqual(_.range(2, 1), [2])\n    U.deepStrictEqual(_.range(-1, -2), [-1])\n  })\n\n  it('comprehension', () => {\n    U.deepStrictEqual(\n      _.comprehension([[1, 2, 3]], (a) => a * 2),\n      [2, 4, 6]\n    )\n    U.deepStrictEqual(\n      _.comprehension(\n        [\n          [1, 2, 3],\n          ['a', 'b']\n        ],\n        tuple\n      ),\n      [\n        [1, 'a'],\n        [1, 'b'],\n        [2, 'a'],\n        [2, 'b'],\n        [3, 'a'],\n        [3, 'b']\n      ]\n    )\n    U.deepStrictEqual(\n      _.comprehension(\n        [\n          [1, 2, 3],\n          ['a', 'b']\n        ],\n        tuple,\n        (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('union', () => {\n    const concat = _.union(N.Eq)\n    const two: ReadonlyArray<number> = [1, 2]\n    U.deepStrictEqual(concat(two, [3, 4]), [1, 2, 3, 4])\n    U.deepStrictEqual(concat(two, [2, 3]), [1, 2, 3])\n    U.deepStrictEqual(concat(two, [1, 2]), [1, 2])\n    U.deepStrictEqual(pipe(two, concat([3, 4])), [1, 2, 3, 4])\n    U.deepStrictEqual(pipe(two, concat([2, 3])), [1, 2, 3])\n    U.deepStrictEqual(pipe(two, concat([1, 2])), [1, 2])\n\n    U.strictEqual(pipe(two, concat(_.empty)), two)\n    U.strictEqual(pipe(_.empty, concat(two)), two)\n    U.strictEqual(pipe(_.empty, concat(_.empty)), _.empty)\n  })\n\n  it('intersection', () => {\n    U.deepStrictEqual(_.intersection(N.Eq)([1, 2], [3, 4]), [])\n    U.deepStrictEqual(_.intersection(N.Eq)([1, 2], [2, 3]), [2])\n    U.deepStrictEqual(_.intersection(N.Eq)([1, 2], [1, 2]), [1, 2])\n    U.deepStrictEqual(pipe([1, 2], _.intersection(N.Eq)([3, 4])), [])\n    U.deepStrictEqual(pipe([1, 2], _.intersection(N.Eq)([2, 3])), [2])\n    U.deepStrictEqual(pipe([1, 2], _.intersection(N.Eq)([1, 2])), [1, 2])\n  })\n\n  it('difference', () => {\n    U.deepStrictEqual(_.difference(N.Eq)([1, 2], [3, 4]), [1, 2])\n    U.deepStrictEqual(_.difference(N.Eq)([1, 2], [2, 3]), [1])\n    U.deepStrictEqual(_.difference(N.Eq)([1, 2], [1, 2]), [])\n    U.deepStrictEqual(pipe([1, 2], _.difference(N.Eq)([3, 4])), [1, 2])\n    U.deepStrictEqual(pipe([1, 2], _.difference(N.Eq)([2, 3])), [1])\n    U.deepStrictEqual(pipe([1, 2], _.difference(N.Eq)([1, 2])), [])\n  })\n\n  it('getUnionMonoid', () => {\n    const M = _.getUnionMonoid(N.Eq)\n    const two: ReadonlyArray<number> = [1, 2]\n    U.deepStrictEqual(M.concat(two, [3, 4]), [1, 2, 3, 4])\n    U.deepStrictEqual(M.concat(two, [2, 3]), [1, 2, 3])\n    U.deepStrictEqual(M.concat(two, [1, 2]), [1, 2])\n\n    U.strictEqual(M.concat(two, M.empty), two)\n    U.strictEqual(M.concat(M.empty, two), two)\n    U.strictEqual(M.concat(M.empty, M.empty), M.empty)\n  })\n\n  it('getIntersectionSemigroup', () => {\n    const concat = _.getIntersectionSemigroup(N.Eq).concat\n    U.deepStrictEqual(concat([1, 2], [3, 4]), [])\n    U.deepStrictEqual(concat([1, 2], [2, 3]), [2])\n    U.deepStrictEqual(concat([1, 2], [1, 2]), [1, 2])\n  })\n\n  it('getDifferenceMagma', () => {\n    const concat = _.getDifferenceMagma(N.Eq).concat\n    U.deepStrictEqual(concat([1, 2], [3, 4]), [1, 2])\n    U.deepStrictEqual(concat([1, 2], [2, 3]), [1])\n    U.deepStrictEqual(concat([1, 2], [1, 2]), [])\n  })\n\n  it('should be safe when calling map with a binary function', () => {\n    interface Foo {\n      readonly bar: () => number\n    }\n    const f = (a: number, x?: Foo) => (x !== undefined ? `${a}${x.bar()}` : `${a}`)\n    U.deepStrictEqual(_.Functor.map([1, 2], f), ['1', '2'])\n    U.deepStrictEqual(pipe([1, 2], _.map(f)), ['1', '2'])\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    U.deepStrictEqual(Sh.show([]), `[]`)\n    U.deepStrictEqual(Sh.show(['a']), `[\"a\"]`)\n    U.deepStrictEqual(Sh.show(['a', 'b']), `[\"a\", \"b\"]`)\n  })\n\n  it('fromArray', () => {\n    U.strictEqual(_.fromArray([]), _.empty)\n    const as = [1, 2, 3]\n    const bs = _.fromArray(as)\n    U.deepStrictEqual(bs, as)\n    assert.notStrictEqual(bs, as)\n  })\n\n  it('toArray', () => {\n    U.deepStrictEqual(_.toArray(_.empty), [])\n    assert.notStrictEqual(_.toArray(_.empty), _.empty)\n    const as = [1, 2, 3]\n    const bs = _.toArray(as)\n    U.deepStrictEqual(bs, as)\n    assert.notStrictEqual(bs, as)\n  })\n\n  it('empty', () => {\n    U.deepStrictEqual(_.empty.length, 0)\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      ),\n      [{ a: 1, b: 'b', c: [1, 'b'] }]\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b'))), [{ a: 1, b: 'b' }])\n  })\n\n  it('every', () => {\n    const isPositive: Predicate<number> = (n) => n > 0\n    U.deepStrictEqual(pipe([1, 2, 3], _.every(isPositive)), true)\n    U.deepStrictEqual(pipe([1, 2, -3], _.every(isPositive)), false)\n  })\n\n  it('some', () => {\n    const isPositive: Predicate<number> = (n) => n > 0\n    U.deepStrictEqual(pipe([-1, -2, 3], _.some(isPositive)), true)\n    U.deepStrictEqual(pipe([-1, -2, -3], _.some(isPositive)), false)\n  })\n\n  it('size', () => {\n    U.deepStrictEqual(_.size(_.empty), 0)\n    U.deepStrictEqual(_.size([]), 0)\n    U.deepStrictEqual(_.size(['a']), 1)\n  })\n\n  describe('chainRec', () => {\n    it('depth-first', () => {\n      const chainRec = _.ChainRecDepthFirst.chainRec\n      assert.deepStrictEqual(\n        chainRec(1, () => []),\n        []\n      )\n      assert.deepStrictEqual(\n        chainRec(1, () => [E.right('foo')]),\n        ['foo']\n      )\n      assert.deepStrictEqual(\n        chainRec(1, (a) => {\n          if (a < 5) {\n            return [E.right(a), E.left(a + 1)]\n          } else {\n            return [E.right(a)]\n          }\n        }),\n        [1, 2, 3, 4, 5]\n      )\n      assert.deepStrictEqual(\n        chainRec(1, (a) => {\n          if (a < 5) {\n            return [E.left(a + 1), E.right(a)]\n          } else {\n            return [E.right(a)]\n          }\n        }),\n        [5, 4, 3, 2, 1]\n      )\n      assert.deepStrictEqual(\n        chainRec(1, (a) => {\n          if (a < 5) {\n            return a % 2 === 0 ? [E.right(a), E.left(a + 1)] : [E.left(a + 1), E.right(a)]\n          } else {\n            return [E.right(a)]\n          }\n        }),\n        [2, 4, 5, 3, 1]\n      )\n      assert.deepStrictEqual(\n        chainRec(0, (a) => {\n          if (a === 0) {\n            return [E.right(a), E.left(a - 1), E.left(a + 1)]\n          } else if (0 < a && a < 5) {\n            return [E.right(a), E.left(a + 1)]\n          } else if (-5 < a && a < 0) {\n            return [E.right(a), E.left(a - 1)]\n          } else {\n            return [E.right(a)]\n          }\n        }),\n        [0, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5]\n      )\n      assert.deepStrictEqual(\n        chainRec(0, (a) => {\n          if (a === 0) {\n            return [E.left(a - 1), E.right(a), E.left(a + 1)]\n          } else if (0 < a && a < 5) {\n            return [E.right(a), E.left(a + 1)]\n          } else if (-5 < a && a < 0) {\n            return [E.left(a - 1), E.right(a)]\n          } else {\n            return [E.right(a)]\n          }\n        }),\n        [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n      )\n    })\n    it('breadth-first', () => {\n      const chainRec = _.ChainRecBreadthFirst.chainRec\n      assert.deepStrictEqual(\n        chainRec(1, () => []),\n        []\n      )\n      assert.deepStrictEqual(\n        chainRec(1, () => [E.right('foo')]),\n        ['foo']\n      )\n      assert.deepStrictEqual(\n        chainRec(1, (a) => {\n          if (a < 5) {\n            return [E.right(a), E.left(a + 1)]\n          } else {\n            return [E.right(a)]\n          }\n        }),\n        [1, 2, 3, 4, 5]\n      )\n      assert.deepStrictEqual(\n        chainRec(1, (a) => {\n          if (a < 5) {\n            return [E.left(a + 1), E.right(a)]\n          } else {\n            return [E.right(a)]\n          }\n        }),\n        [1, 2, 3, 4, 5]\n      )\n      assert.deepStrictEqual(\n        chainRec(0, (a) => {\n          if (a === 0) {\n            return [E.right(a), E.left(a - 1), E.left(a + 1)]\n          } else if (0 < a && a < 5) {\n            return [E.right(a), E.left(a + 1)]\n          } else if (-5 < a && a < 0) {\n            return [E.right(a), E.left(a - 1)]\n          } else {\n            return [E.right(a)]\n          }\n        }),\n        [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5]\n      )\n      assert.deepStrictEqual(\n        chainRec(0, (a) => {\n          if (a === 0) {\n            return [E.left(a - 1), E.right(a), E.left(a + 1)]\n          } else if (0 < a && a < 5) {\n            return [E.right(a), E.left(a + 1)]\n          } else if (-5 < a && a < 0) {\n            return [E.left(a - 1), E.right(a)]\n          } else {\n            return [E.right(a)]\n          }\n        }),\n        [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5]\n      )\n    })\n  })\n\n  describe('fromPredicate', () => {\n    it('can create an array from a Refinement', () => {\n      const refinement: Refinement<unknown, string> = (a): a is string => typeof a === 'string'\n      U.deepStrictEqual(_.fromPredicate(refinement)('hello'), ['hello'])\n      U.deepStrictEqual(_.fromPredicate(refinement)(null), [])\n    })\n\n    it('can create an array from a Predicate', () => {\n      const predicate = (a: string) => a.length > 0\n      U.deepStrictEqual(_.fromPredicate(predicate)('hi'), ['hi'])\n      U.deepStrictEqual(_.fromPredicate(predicate)(''), [])\n    })\n  })\n\n  it('fromOption', () => {\n    U.deepStrictEqual(_.fromOption(O.some('hello')), ['hello'])\n    U.deepStrictEqual(_.fromOption(O.none), [])\n  })\n\n  it('fromEither', () => {\n    U.deepStrictEqual(_.fromEither(E.right(1)), [1])\n    U.strictEqual(_.fromEither(E.left('a')), _.empty)\n  })\n\n  it('match', () => {\n    const f = _.match(\n      () => 'empty',\n      (as) => `nonEmpty ${as.length}`\n    )\n    U.deepStrictEqual(pipe(_.empty, f), 'empty')\n    U.deepStrictEqual(pipe([1, 2, 3], f), 'nonEmpty 3')\n  })\n\n  it('concatW', () => {\n    U.deepStrictEqual(pipe([1], _.concatW(['a'])), [1, 'a'])\n    const as = [1, 2, 3]\n    U.strictEqual(pipe(_.empty, _.concatW(as)), as)\n    U.strictEqual(pipe(as, _.concatW(_.empty)), as)\n    const empty: ReadonlyArray<string> = []\n    U.strictEqual(pipe(empty, _.concatW(as)), as)\n    U.strictEqual(pipe(as, _.concatW(empty)), as)\n  })\n\n  it('fromOptionK', () => {\n    const f = (n: number) => (n > 0 ? O.some(n) : O.none)\n    const g = _.fromOptionK(f)\n    U.strictEqual(g(0), _.empty)\n    U.deepStrictEqual(g(1), [1])\n  })\n\n  it('isOutOfBound', () => {\n    U.deepStrictEqual(_.isOutOfBound(0, ['a']), false)\n    U.deepStrictEqual(_.isOutOfBound(100, ['a']), true)\n    U.deepStrictEqual(_.isOutOfBound(-1, ['a']), true)\n  })\n})\n"
  },
  {
    "path": "test/ReadonlyMap.ts",
    "content": "import * as assert from 'assert'\n\nimport { Either, left, right } from '../src/Either'\nimport { Eq, fromEquals } from '../src/Eq'\nimport { identity, pipe } from '../src/function'\nimport * as IO from '../src/IO'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as Ord from '../src/Ord'\nimport * as RA from '../src/ReadonlyArray'\nimport * as _ from '../src/ReadonlyMap'\nimport { Refinement } from '../src/Refinement'\nimport * as Se from '../src/Semigroup'\nimport { separated } from '../src/Separated'\nimport { Show, struct } from '../src/Show'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\ninterface User {\n  readonly id: string\n}\n\nconst ordUser = pipe(\n  S.Ord,\n  Ord.contramap((u: User) => u.id)\n)\n\nconst eqUser: Eq<User> = { equals: ordUser.equals }\n\nconst p = ((n: number): boolean => n > 2) as Refinement<number, number>\n\ninterface Key {\n  readonly id: number\n}\n\ninterface Value {\n  readonly value: number\n}\n\nconst eqKey: Eq<Key> = fromEquals((x, y) => x.id % 3 === y.id % 3)\n\nconst ordKey = Ord.fromCompare<Key>((x, y) => N.Ord.compare(x.id % 3, y.id % 3))\n\nconst eqValue: Eq<Value> = fromEquals((x, y) => x.value % 3 === y.value % 3)\n\nconst semigroupValue = Se.struct({ value: N.SemigroupSum })\n\nconst key1 = { id: 1 }\nconst value1 = { value: 1 }\nconst repo = new Map<Key, Value>([\n  [key1, value1],\n  [{ id: 2 }, { value: 2 }]\n])\n\ndescribe('ReadonlyMap', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      U.deepStrictEqual(\n        pipe(\n          new Map<string, number>([\n            ['k1', 1],\n            ['k2', 2]\n          ]),\n          _.map(U.double)\n        ),\n        new Map<string, number>([\n          ['k1', 2],\n          ['k2', 4]\n        ])\n      )\n    })\n\n    it('filter', () => {\n      U.deepStrictEqual(\n        pipe(\n          new Map<string, number>([\n            ['a', 1],\n            ['b', 3]\n          ]),\n          _.filter(p)\n        ),\n        new Map<string, number>([['b', 3]])\n      )\n\n      // refinements\n      const isNumber = (u: string | number): u is number => typeof u === 'number'\n      U.deepStrictEqual(\n        pipe(\n          new Map<string, string | number>([\n            ['a', 1],\n            ['b', 'foo']\n          ]),\n          _.filter(isNumber)\n        ),\n        new Map<string, number>([['a', 1]])\n      )\n    })\n\n    it('filterMap', () => {\n      const empty = new Map<string, number>()\n      const f = (n: number) => (p(n) ? O.some(n + 1) : O.none)\n      U.deepStrictEqual(pipe(empty, _.filterMap(f)), empty)\n      U.deepStrictEqual(\n        pipe(\n          new Map<string, number>([\n            ['a', 1],\n            ['b', 3]\n          ]),\n          _.filterMap(f)\n        ),\n        new Map<string, number>([['b', 4]])\n      )\n    })\n\n    it('partitionMap', () => {\n      const empty = new Map<string, number>()\n      const f = (n: number) => (p(n) ? right(n + 1) : left(n - 1))\n      U.deepStrictEqual(pipe(empty, _.partitionMap(f)), separated(empty, empty))\n      U.deepStrictEqual(\n        pipe(\n          new Map<string, number>([\n            ['a', 1],\n            ['b', 3]\n          ]),\n          _.partitionMap(f)\n        ),\n        separated(new Map<string, number>([['a', 0]]), new Map<string, number>([['b', 4]]))\n      )\n    })\n\n    it('partition', () => {\n      const empty = new Map<string, number>()\n      U.deepStrictEqual(pipe(empty, _.partition(p)), separated(empty, empty))\n      U.deepStrictEqual(\n        pipe(\n          new Map<string, number>([\n            ['a', 1],\n            ['b', 3]\n          ]),\n          _.partition(p)\n        ),\n        separated(new Map<string, number>([['a', 1]]), new Map<string, number>([['b', 3]]))\n      )\n    })\n  })\n\n  it('size', () => {\n    const emptyMap = new Map<string, number>()\n    const a1 = new Map<string, number>([['a', 1]])\n    U.deepStrictEqual(_.size(emptyMap), 0)\n    U.deepStrictEqual(_.size(a1), 1)\n\n    U.deepStrictEqual(_.size(_.empty), 0)\n    U.deepStrictEqual(_.size(new Map()), 0)\n    U.deepStrictEqual(_.size(new Map([['a', 1]])), 1)\n  })\n\n  it('isEmpty', () => {\n    const emptyMap = new Map<string, number>()\n    const a1 = new Map<string, number>([['a', 1]])\n    U.deepStrictEqual(_.isEmpty(emptyMap), true)\n    U.deepStrictEqual(_.isEmpty(a1), false)\n\n    U.deepStrictEqual(_.isEmpty(_.empty), true)\n    U.deepStrictEqual(_.isEmpty(new Map()), true)\n    U.deepStrictEqual(_.isEmpty(new Map([['a', 1]])), false)\n  })\n\n  it('member', () => {\n    const x = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const memberS = _.member(eqUser)\n    U.deepStrictEqual(memberS({ id: 'a' }, x), true)\n    U.deepStrictEqual(memberS({ id: 'c' }, x), false)\n    U.deepStrictEqual(memberS({ id: 'a' })(x), true)\n    U.deepStrictEqual(memberS({ id: 'c' })(x), false)\n\n    const member = _.member(eqKey)\n    U.deepStrictEqual(member({ id: 1 }, repo), true)\n    U.deepStrictEqual(member({ id: 2 }, repo), true)\n    U.deepStrictEqual(member({ id: 4 }, repo), true)\n    U.deepStrictEqual(member({ id: 3 }, repo), false)\n    U.deepStrictEqual(member({ id: 1 })(repo), true)\n    U.deepStrictEqual(member({ id: 2 })(repo), true)\n    U.deepStrictEqual(member({ id: 4 })(repo), true)\n    U.deepStrictEqual(member({ id: 3 })(repo), false)\n  })\n\n  it('elem', () => {\n    const x = new Map<string, number>([\n      ['a', 1],\n      ['b', 2]\n    ])\n    const elemS = _.elem(N.Eq)\n    U.deepStrictEqual(elemS(2, x), true)\n    U.deepStrictEqual(elemS(3, x), false)\n    U.deepStrictEqual(elemS(2)(x), true)\n    U.deepStrictEqual(elemS(3)(x), false)\n\n    const elem = _.elem(eqValue)\n    U.deepStrictEqual(elem({ value: 1 })(repo), true)\n    U.deepStrictEqual(elem({ value: 2 })(repo), true)\n    U.deepStrictEqual(elem({ value: 4 })(repo), true)\n    U.deepStrictEqual(elem({ value: 3 })(repo), false)\n    U.deepStrictEqual(elem({ value: 1 })(repo), true)\n    U.deepStrictEqual(elem({ value: 2 })(repo), true)\n    U.deepStrictEqual(elem({ value: 4 })(repo), true)\n    U.deepStrictEqual(elem({ value: 3 })(repo), false)\n  })\n\n  it('keys', () => {\n    const m = new Map<User, number>([\n      [{ id: 'b' }, 2],\n      [{ id: 'a' }, 1]\n    ])\n    const ks = _.keys(ordUser)(m)\n    U.deepStrictEqual(ks, Array.from(m.keys()).sort(ordUser.compare))\n    U.deepStrictEqual(ks, [{ id: 'a' }, { id: 'b' }])\n\n    U.deepStrictEqual(\n      _.keys(S.Ord)(\n        new Map([\n          ['a', 1],\n          ['b', 2]\n        ])\n      ),\n      ['a', 'b']\n    )\n    U.deepStrictEqual(\n      _.keys(S.Ord)(\n        new Map([\n          ['b', 2],\n          ['a', 1]\n        ])\n      ),\n      ['a', 'b']\n    )\n  })\n\n  it('values', () => {\n    const m = new Map<number, User>([\n      [2, { id: 'b' }],\n      [1, { id: 'a' }]\n    ])\n    const vals = _.values(ordUser)(m)\n    U.deepStrictEqual(vals, Array.from(m.values()).sort(ordUser.compare))\n    U.deepStrictEqual(vals, [{ id: 'a' }, { id: 'b' }])\n  })\n\n  it('collect', () => {\n    const m1 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const m2 = new Map<User, number>([\n      [{ id: 'b' }, 2],\n      [{ id: 'a' }, 1]\n    ])\n    const collectO = _.collect(ordUser)\n    const f = (_k: User, a: number): number => a + 1\n    U.deepStrictEqual(collectO(f)(m1), [2, 3])\n    U.deepStrictEqual(collectO(f)(m2), [2, 3])\n\n    const collect = _.collect(ordKey)\n    const g = (k: Key, a: Value): readonly [number, number] => [k.id, a.value]\n    U.deepStrictEqual(\n      collect(g)(\n        new Map([\n          [{ id: 1 }, { value: 1 }],\n          [{ id: 2 }, { value: 2 }]\n        ])\n      ),\n      [\n        [1, 1],\n        [2, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      collect(g)(\n        new Map([\n          [{ id: 2 }, { value: 2 }],\n          [{ id: 1 }, { value: 1 }]\n        ])\n      ),\n      [\n        [1, 1],\n        [2, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      collect(g)(\n        new Map([\n          [{ id: 4 }, { value: 1 }],\n          [{ id: 2 }, { value: 2 }]\n        ])\n      ),\n      [\n        [4, 1],\n        [2, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      collect(g)(\n        new Map([\n          [{ id: 2 }, { value: 2 }],\n          [{ id: 4 }, { value: 1 }]\n        ])\n      ),\n      [\n        [4, 1],\n        [2, 2]\n      ]\n    )\n  })\n\n  it('toReadonlyArray', () => {\n    const m1 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const m2 = new Map<User, number>([\n      [{ id: 'b' }, 2],\n      [{ id: 'a' }, 1]\n    ])\n    const toArrayO = _.toReadonlyArray(ordUser)\n    U.deepStrictEqual(toArrayO(m1), [\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    U.deepStrictEqual(toArrayO(m2), [\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n\n    const toArray = _.toReadonlyArray(ordKey)\n    U.deepStrictEqual(\n      toArray(\n        new Map([\n          [{ id: 1 }, 1],\n          [{ id: 2 }, 2]\n        ])\n      ),\n      [\n        [{ id: 1 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toArray(\n        new Map([\n          [{ id: 2 }, 2],\n          [{ id: 1 }, 1]\n        ])\n      ),\n      [\n        [{ id: 1 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toArray(\n        new Map([\n          [{ id: 4 }, 1],\n          [{ id: 2 }, 2]\n        ])\n      ),\n      [\n        [{ id: 4 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toArray(\n        new Map([\n          [{ id: 2 }, 2],\n          [{ id: 4 }, 1]\n        ])\n      ),\n      [\n        [{ id: 4 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n  })\n\n  it('toUnfoldable', () => {\n    const a1 = new Map<User, number>([[{ id: 'a' }, 1]])\n    const toUnfoldableO = _.toUnfoldable(ordUser, RA.Unfoldable)\n    U.deepStrictEqual(toUnfoldableO(a1), [[{ id: 'a' }, 1]])\n\n    const toUnfoldable = _.toUnfoldable(ordKey, RA.Unfoldable)\n    U.deepStrictEqual(\n      toUnfoldable(\n        new Map([\n          [{ id: 1 }, 1],\n          [{ id: 2 }, 2]\n        ])\n      ),\n      [\n        [{ id: 1 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toUnfoldable(\n        new Map([\n          [{ id: 2 }, 2],\n          [{ id: 1 }, 1]\n        ])\n      ),\n      [\n        [{ id: 1 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toUnfoldable(\n        new Map([\n          [{ id: 4 }, 1],\n          [{ id: 2 }, 2]\n        ])\n      ),\n      [\n        [{ id: 4 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n    U.deepStrictEqual(\n      toUnfoldable(\n        new Map([\n          [{ id: 2 }, 2],\n          [{ id: 4 }, 1]\n        ])\n      ),\n      [\n        [{ id: 4 }, 1],\n        [{ id: 2 }, 2]\n      ]\n    )\n  })\n\n  it('insertAt', () => {\n    const emptyMap = new Map<User, number>()\n    const a1 = new Map<User, number>([[{ id: 'a' }, 1]])\n    const a1b2 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const a2b2 = new Map<User, number>([\n      [{ id: 'a' }, 2],\n      [{ id: 'b' }, 2]\n    ])\n    const a1b2c3 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2],\n      [{ id: 'c' }, 3]\n    ])\n    const insertS = _.insertAt(eqUser)\n    U.deepStrictEqual(insertS({ id: 'a' }, 1)(emptyMap), a1)\n    U.deepStrictEqual(insertS({ id: 'a' }, 1)(a1b2), a1b2)\n    U.deepStrictEqual(insertS({ id: 'a' }, 2)(a1b2), a2b2)\n    U.deepStrictEqual(insertS({ id: 'c' }, 3)(a1b2), a1b2c3)\n\n    const insert = _.insertAt(eqKey)\n    U.deepStrictEqual(insert({ id: 1 }, { value: 1 })(_.empty), new Map([[{ id: 1 }, { value: 1 }]]))\n    const x = insert({ id: 1 }, value1)(repo)\n    U.deepStrictEqual(\n      x,\n      new Map<Key, Value>([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n    U.deepStrictEqual(x.get(key1), value1)\n    U.deepStrictEqual(\n      insert({ id: 1 }, { value: 2 })(repo),\n      new Map<Key, Value>([\n        [{ id: 1 }, { value: 2 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n    U.deepStrictEqual(\n      insert({ id: 4 }, { value: 2 })(repo),\n      new Map<Key, Value>([\n        [{ id: 1 }, { value: 2 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n    U.deepStrictEqual(\n      insert({ id: 3 }, { value: 3 })(repo),\n      new Map<Key, Value>([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }],\n        [{ id: 3 }, { value: 3 }]\n      ])\n    )\n    // should not modify the source\n    U.deepStrictEqual(\n      repo,\n      new Map([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n  })\n\n  it('deleteAt', () => {\n    const a1b2 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const a1b2_ = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const b2 = new Map<User, number>([[{ id: 'b' }, 2]])\n    const removeS = _.deleteAt(eqUser)\n    U.deepStrictEqual(removeS({ id: 'a' })(a1b2), b2)\n    U.deepStrictEqual(a1b2, a1b2_)\n    U.deepStrictEqual(removeS({ id: 'c' })(a1b2), a1b2)\n\n    const remove = _.deleteAt(eqKey)\n    U.deepStrictEqual(remove({ id: 1 })(repo), new Map([[{ id: 2 }, { value: 2 }]]))\n    U.deepStrictEqual(remove({ id: 4 })(repo), new Map([[{ id: 2 }, { value: 2 }]]))\n    U.deepStrictEqual(remove({ id: 3 })(repo), repo)\n    // should not modify the source\n    U.deepStrictEqual(\n      repo,\n      new Map([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n  })\n\n  it('pop', () => {\n    const a1b2 = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const b2 = new Map<User, number>([[{ id: 'b' }, 2]])\n    const popS = _.pop(eqUser)\n    assert.deepStrictEqual(popS({ id: 'a' })(a1b2), O.some([1, b2]))\n    U.deepStrictEqual(popS({ id: 'c' })(a1b2), O.none)\n\n    const pop = _.pop(eqKey)\n    assert.deepStrictEqual(pop({ id: 1 })(repo), O.some([{ value: 1 }, new Map([[{ id: 2 }, { value: 2 }]])]))\n    assert.deepStrictEqual(pop({ id: 4 })(repo), O.some([{ value: 1 }, new Map([[{ id: 2 }, { value: 2 }]])]))\n    U.deepStrictEqual(pop({ id: 3 })(repo), O.none)\n    // should not modify the source\n    U.deepStrictEqual(\n      repo,\n      new Map([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n  })\n\n  it('lookupWithKey', () => {\n    const x = new Map<User, number>([[{ id: 'a' }, 1]])\n    const lookupWithKeyS = _.lookupWithKey(eqUser)\n    assert.deepStrictEqual(lookupWithKeyS({ id: 'a' }, x), O.some([{ id: 'a' }, 1]))\n    U.deepStrictEqual(lookupWithKeyS({ id: 'b' }, x), O.none)\n    assert.deepStrictEqual(lookupWithKeyS({ id: 'a' })(x), O.some([{ id: 'a' }, 1]))\n    U.deepStrictEqual(lookupWithKeyS({ id: 'b' })(x), O.none)\n\n    const lookupWithKey = _.lookupWithKey(eqKey)\n    assert.deepStrictEqual(lookupWithKey({ id: 1 }, repo), O.some([{ id: 1 }, { value: 1 }]))\n    assert.deepStrictEqual(lookupWithKey({ id: 4 }, repo), O.some([{ id: 1 }, { value: 1 }]))\n    U.deepStrictEqual(lookupWithKey({ id: 3 }, repo), O.none)\n    assert.deepStrictEqual(lookupWithKey({ id: 1 })(repo), O.some([{ id: 1 }, { value: 1 }]))\n    assert.deepStrictEqual(lookupWithKey({ id: 4 })(repo), O.some([{ id: 1 }, { value: 1 }]))\n    U.deepStrictEqual(lookupWithKey({ id: 3 })(repo), O.none)\n  })\n\n  it('lookup', () => {\n    const x = new Map<User, number>([[{ id: 'a' }, 1]])\n    const lookupS = _.lookup(eqUser)\n    U.deepStrictEqual(lookupS({ id: 'a' }, x), O.some(1))\n    U.deepStrictEqual(lookupS({ id: 'b' }, x), O.none)\n    U.deepStrictEqual(lookupS({ id: 'a' })(x), O.some(1))\n    U.deepStrictEqual(lookupS({ id: 'b' })(x), O.none)\n\n    const lookup = _.lookup(eqKey)\n    U.deepStrictEqual(lookup({ id: 1 }, repo), O.some({ value: 1 }))\n    U.deepStrictEqual(lookup({ id: 4 }, repo), O.some({ value: 1 }))\n    U.deepStrictEqual(lookup({ id: 3 }, repo), O.none)\n    U.deepStrictEqual(lookup({ id: 1 })(repo), O.some({ value: 1 }))\n    U.deepStrictEqual(lookup({ id: 4 })(repo), O.some({ value: 1 }))\n    U.deepStrictEqual(lookup({ id: 3 })(repo), O.none)\n  })\n\n  it('isSubmap', () => {\n    const me = new Map<User, number>([[{ id: 'a' }, 1]])\n    const that = new Map<User, number>([\n      [{ id: 'a' }, 1],\n      [{ id: 'b' }, 2]\n    ])\n    const isSubmapS = _.isSubmap(eqUser, N.Eq)\n    U.deepStrictEqual(isSubmapS(me, that), true)\n    U.deepStrictEqual(isSubmapS(that)(me), true)\n\n    const isSubmap = _.isSubmap(eqKey, eqValue)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 1 }, { value: 1 }]]), repo), true)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 1 }, { value: 2 }]]), repo), false)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 1 }, { value: 4 }]]), repo), true)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 4 }, { value: 1 }]]), repo), true)\n    U.deepStrictEqual(isSubmap(new Map([[{ id: 3 }, { value: 3 }]]), repo), false)\n\n    U.deepStrictEqual(pipe(new Map([[{ id: 1 }, { value: 1 }]]), isSubmap(repo)), true)\n    U.deepStrictEqual(pipe(new Map([[{ id: 1 }, { value: 2 }]]), isSubmap(repo)), false)\n    U.deepStrictEqual(pipe(new Map([[{ id: 1 }, { value: 4 }]]), isSubmap(repo)), true)\n    U.deepStrictEqual(pipe(new Map([[{ id: 4 }, { value: 1 }]]), isSubmap(repo)), true)\n    U.deepStrictEqual(pipe(new Map([[{ id: 3 }, { value: 3 }]]), isSubmap(repo)), false)\n  })\n\n  it('empty', () => {\n    assert.deepStrictEqual(_.empty, new Map<string, number>())\n    U.deepStrictEqual(_.isEmpty(_.empty), true)\n  })\n\n  it('singleton', () => {\n    U.deepStrictEqual(_.singleton('k1', 0), new Map<string, number>([['k1', 0]]))\n  })\n\n  it('getEq', () => {\n    const a1 = new Map<User, number>([[{ id: 'a' }, 1]])\n    const a1_ = new Map<User, number>([[{ id: 'a' }, 1]])\n    const a2 = new Map<User, number>([[{ id: 'a' }, 2]])\n    const b1 = new Map<User, number>([[{ id: 'b' }, 1]])\n    const S = _.getEq(eqUser, N.Eq)\n    U.deepStrictEqual(S.equals(a1, a1), true)\n    U.deepStrictEqual(S.equals(a1, a1_), true)\n    U.deepStrictEqual(S.equals(a1_, a1), true)\n    U.deepStrictEqual(S.equals(a1, a2), false)\n    U.deepStrictEqual(S.equals(a2, a1), false)\n    U.deepStrictEqual(S.equals(a1, b1), false)\n    U.deepStrictEqual(S.equals(b1, a1), false)\n\n    const equals = _.getEq(eqKey, eqValue).equals\n    U.deepStrictEqual(equals(repo, repo), true)\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 1 }, { value: 1 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      true\n    )\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 1 }, { value: 2 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      false\n    )\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 1 }, { value: 4 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      true\n    )\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 4 }, { value: 1 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      true\n    )\n    U.deepStrictEqual(\n      equals(\n        new Map([\n          [{ id: 3 }, { value: 3 }],\n          [{ id: 2 }, { value: 2 }]\n        ]),\n        repo\n      ),\n      false\n    )\n  })\n\n  it('getMonoid', () => {\n    const d1 = new Map<User, number>([\n      [{ id: 'k1' }, 1],\n      [{ id: 'k2' }, 3]\n    ])\n    const d2 = new Map<User, number>([\n      [{ id: 'k2' }, 2],\n      [{ id: 'k3' }, 4]\n    ])\n    const expected = new Map<User, number>([\n      [{ id: 'k1' }, 1],\n      [{ id: 'k2' }, 5],\n      [{ id: 'k3' }, 4]\n    ])\n    const M1 = _.getMonoid(eqUser, N.SemigroupSum)\n    U.deepStrictEqual(M1.concat(d1, d2), expected)\n    U.deepStrictEqual(M1.concat(d1, M1.empty), d1)\n    U.deepStrictEqual(M1.concat(M1.empty, d2), d2)\n\n    const M2 = _.getMonoid(eqKey, semigroupValue)\n    U.deepStrictEqual(\n      M2.concat(repo, new Map([[{ id: 3 }, { value: 3 }]])),\n      new Map([\n        [{ id: 1 }, { value: 1 }],\n        [{ id: 2 }, { value: 2 }],\n        [{ id: 3 }, { value: 3 }]\n      ])\n    )\n    U.deepStrictEqual(\n      M2.concat(repo, new Map([[{ id: 1 }, { value: 2 }]])),\n      new Map([\n        [{ id: 1 }, { value: 3 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n    U.deepStrictEqual(\n      M2.concat(repo, new Map([[{ id: 4 }, { value: 2 }]])),\n      new Map([\n        [{ id: 1 }, { value: 3 }],\n        [{ id: 2 }, { value: 2 }]\n      ])\n    )\n  })\n\n  describe('readonlyMap', () => {\n    describe('compactable', () => {\n      it('compact', () => {\n        const fooBar = new Map<string, O.Option<number>>([\n          ['foo', O.none],\n          ['bar', O.some(123)]\n        ])\n        const bar = new Map<string, number>([['bar', 123]])\n        U.deepStrictEqual(_.compact(fooBar), bar)\n      })\n\n      it('separate', () => {\n        const fooBar = new Map<string, Either<number, number>>([\n          ['foo', left(123)],\n          ['bar', right(123)]\n        ])\n        const foo = new Map<string, number>([['foo', 123]])\n        const bar = new Map<string, number>([['bar', 123]])\n        U.deepStrictEqual(_.separate(fooBar), separated(foo, bar))\n      })\n    })\n  })\n\n  describe('getTraversable', () => {\n    const T = _.getTraversable(ordUser)\n\n    it('traverse', () => {\n      const traverse = T.traverse(O.Applicative)\n      const x = new Map([\n        [{ id: 'k1' }, 1],\n        [{ id: 'k2' }, 2]\n      ])\n      U.deepStrictEqual(\n        traverse(x, (n) => (n <= 2 ? O.some(n) : O.none)),\n        O.some(x)\n      )\n      U.deepStrictEqual(\n        traverse(x, (n) => (n >= 2 ? O.some(n) : O.none)),\n        O.none\n      )\n    })\n\n    it('sequence', () => {\n      const sequence = T.sequence(O.Applicative)\n      U.deepStrictEqual(\n        sequence(\n          new Map([\n            [{ id: 'k1' }, O.some(1)],\n            [{ id: 'k2' }, O.some(2)]\n          ])\n        ),\n        O.some(\n          new Map<User, number>([\n            [{ id: 'k1' }, 1],\n            [{ id: 'k2' }, 2]\n          ])\n        )\n      )\n      U.deepStrictEqual(\n        sequence(\n          new Map([\n            [{ id: 'k1' }, O.none],\n            [{ id: 'k2' }, O.some(2)]\n          ])\n        ),\n        O.none\n      )\n    })\n  })\n\n  describe('getWitherable', () => {\n    const W = _.getWitherable(ordUser)\n\n    it('traverseWithIndex should sort the keys', () => {\n      const W = _.getWitherable(S.Ord)\n      const log: Array<string> = []\n      const append =\n        (message: string): IO.IO<void> =>\n        () => {\n          log.push(message)\n        }\n\n      W.traverseWithIndex(IO.Applicative)(\n        new Map([\n          ['b', append('b')],\n          ['a', append('a')]\n        ]),\n        (_, io) => io\n      )()\n      U.deepStrictEqual(log, ['a', 'b'])\n    })\n\n    it('reduce', () => {\n      const d1 = new Map<User, string>([\n        [{ id: 'k1' }, 'a'],\n        [{ id: 'k2' }, 'b']\n      ])\n      const reduceO = W.reduce\n      U.deepStrictEqual(\n        reduceO(d1, '', (b, a) => b + a),\n        'ab'\n      )\n      const d2 = new Map<User, string>([\n        [{ id: 'k2' }, 'b'],\n        [{ id: 'k1' }, 'a']\n      ])\n      U.deepStrictEqual(\n        reduceO(d2, '', (b, a) => b + a),\n        'ab'\n      )\n    })\n\n    it('foldMap', () => {\n      const foldMapOM = W.foldMap(S.Monoid)\n      const m = new Map<User, string>([\n        [{ id: 'a' }, 'a'],\n        [{ id: 'a' }, 'b']\n      ])\n      U.deepStrictEqual(foldMapOM(m, identity), 'ab')\n    })\n\n    it('reduceRight', () => {\n      const reduceRightO = W.reduceRight\n      const m = new Map<User, string>([\n        [{ id: 'a' }, 'a'],\n        [{ id: 'b' }, 'b']\n      ])\n      const init = ''\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(reduceRightO(m, init, f), 'ba')\n    })\n\n    it('reduceWithIndex', () => {\n      const d1 = new Map<User, string>([\n        [{ id: 'k1' }, 'a'],\n        [{ id: 'k2' }, 'b']\n      ])\n      const reduceWithIndexO = W.reduceWithIndex\n      U.deepStrictEqual(\n        reduceWithIndexO(d1, '', (k, b, a) => b + k.id + a),\n        'k1ak2b'\n      )\n      const d2 = new Map<User, string>([\n        [{ id: 'k2' }, 'b'],\n        [{ id: 'k1' }, 'a']\n      ])\n      U.deepStrictEqual(\n        reduceWithIndexO(d2, '', (k, b, a) => b + k.id + a),\n        'k1ak2b'\n      )\n    })\n\n    it('foldMapWithIndex', () => {\n      const foldMapWithIndexOM = W.foldMapWithIndex(S.Monoid)\n      const m = new Map<User, string>([\n        [{ id: 'k1' }, 'a'],\n        [{ id: 'k2' }, 'b']\n      ])\n      U.deepStrictEqual(\n        foldMapWithIndexOM(m, (k, a) => k.id + a),\n        'k1ak2b'\n      )\n    })\n\n    it('reduceRightWithIndex', () => {\n      const reduceRightWithIndexO = W.reduceRightWithIndex\n      const m = new Map<User, string>([\n        [{ id: 'k1' }, 'a'],\n        [{ id: 'k2' }, 'b']\n      ])\n      U.deepStrictEqual(\n        reduceRightWithIndexO(m, '', (k, a, b) => b + k.id + a),\n        'k2bk1a'\n      )\n    })\n\n    it('traverseWithIndex', () => {\n      const traverseWithIndex = W.traverseWithIndex(O.Applicative)\n      U.deepStrictEqual(\n        traverseWithIndex(\n          new Map([\n            [{ id: 'k1' }, 1],\n            [{ id: 'k2' }, 2]\n          ]),\n          (k, n): O.Option<number> => (!ordUser.equals(k, { id: 'k1' }) ? O.some(n) : O.none)\n        ),\n        O.none\n      )\n      U.deepStrictEqual(\n        traverseWithIndex(\n          new Map([\n            [{ id: 'k1' }, 2],\n            [{ id: 'k2' }, 3]\n          ]),\n          (k, n): O.Option<number> => (!ordUser.equals(k, { id: 'k3' }) ? O.some(n) : O.none)\n        ),\n        O.some(\n          new Map([\n            [{ id: 'k1' }, 2],\n            [{ id: 'k2' }, 3]\n          ])\n        )\n      )\n      U.deepStrictEqual(_.empty, new Map<never, never>())\n    })\n\n    it('wither', async () => {\n      const wither = W.wither(T.ApplicativePar)\n      const f = (n: number) => T.of(p(n) ? O.some(n + 1) : O.none)\n      U.deepStrictEqual(await wither(_.empty, f)(), _.empty)\n      U.deepStrictEqual(\n        await wither(\n          new Map([\n            [{ id: 'a' }, 1],\n            [{ id: 'b' }, 3]\n          ]),\n          f\n        )(),\n        new Map([[{ id: 'b' }, 4]])\n      )\n    })\n\n    it('wilt', async () => {\n      const wilt = W.wilt(T.ApplicativePar)\n      const f = (n: number) => T.of(p(n) ? right(n + 1) : left(n - 1))\n      U.deepStrictEqual(await wilt(_.empty, f)(), separated(_.empty, _.empty))\n      U.deepStrictEqual(\n        await wilt(\n          new Map([\n            [{ id: 'a' }, 1],\n            [{ id: 'b' }, 3]\n          ]),\n          f\n        )(),\n        separated(new Map([[{ id: 'a' }, 0]]), new Map([[{ id: 'b' }, 4]]))\n      )\n    })\n  })\n\n  describe('getFilterableWithIndex', () => {\n    it('partitionMapWithIndex', () => {\n      const partitionMapWithIndex = _.getFilterableWithIndex<string>().partitionMapWithIndex\n      const emptyMap = new Map<string, number>()\n      const a1b3 = new Map<string, number>([\n        ['a', 1],\n        ['b', 3]\n      ])\n      const a0 = new Map<string, number>([['a', 0]])\n      const b4 = new Map<string, number>([['b', 4]])\n      const f = (_: string, n: number) => (p(n) ? right(n + 1) : left(n - 1))\n      U.deepStrictEqual(partitionMapWithIndex(emptyMap, f), separated(emptyMap, emptyMap))\n      U.deepStrictEqual(partitionMapWithIndex(a1b3, f), separated(a0, b4))\n    })\n\n    it('partitionWithIndex', () => {\n      const partitionWithIndex = _.getFilterableWithIndex<string>().partitionWithIndex\n      const emptyMap = new Map<string, number>()\n      const a1b3 = new Map<string, number>([\n        ['a', 1],\n        ['b', 3]\n      ])\n      const a1 = new Map<string, number>([['a', 1]])\n      const b3 = new Map<string, number>([['b', 3]])\n      const f = (_: string, n: number) => p(n)\n      U.deepStrictEqual(partitionWithIndex(emptyMap, f), separated(emptyMap, emptyMap))\n      U.deepStrictEqual(partitionWithIndex(a1b3, f), separated(a1, b3))\n    })\n\n    it('filterMapWithIndex', () => {\n      const filterMapWithIndex = _.getFilterableWithIndex<string>().filterMapWithIndex\n      const emptyMap = new Map<string, number>()\n      const a1b3 = new Map<string, number>([\n        ['a', 1],\n        ['b', 3]\n      ])\n      const b4 = new Map<string, number>([['b', 4]])\n      const f = (_: string, n: number) => (p(n) ? O.some(n + 1) : O.none)\n      U.deepStrictEqual(filterMapWithIndex(emptyMap, f), emptyMap)\n      U.deepStrictEqual(filterMapWithIndex(a1b3, f), b4)\n    })\n\n    it('filterWithIndex', () => {\n      const filterWithIndex = _.getFilterableWithIndex<string>().filterWithIndex\n      const a1b3 = new Map<string, number>([\n        ['a', 1],\n        ['b', 3]\n      ])\n      const b3 = new Map<string, number>([['b', 3]])\n      const f = (_: string, n: number) => p(n)\n      U.deepStrictEqual(filterWithIndex(a1b3, f), b3)\n\n      // refinements\n      const filterWithIndexStr = _.getFilterableWithIndex<string>().filterWithIndex\n      const isNumber = (_: string, u: string | number): u is number => typeof u === 'number'\n      const y = new Map<string, string | number>([\n        ['a', 1],\n        ['b', 'foo']\n      ])\n      const a1 = new Map<string, number>([['a', 1]])\n      const actual = filterWithIndexStr(y, isNumber)\n      U.deepStrictEqual(actual, a1)\n    })\n  })\n\n  it('fromFoldable', () => {\n    const a1 = new Map<User, number>([[{ id: 'a' }, 1]])\n    const a2 = new Map<User, number>([[{ id: 'a' }, 2]])\n    const fromFoldableS1 = _.fromFoldable(eqUser, Se.first<number>(), RA.Foldable)\n    U.deepStrictEqual(fromFoldableS1([[{ id: 'a' }, 1]]), a1)\n    U.deepStrictEqual(\n      fromFoldableS1([\n        [{ id: 'a' }, 1],\n        [{ id: 'a' }, 2]\n      ]),\n      a1\n    )\n    const fromFoldableS2 = _.fromFoldable(eqUser, Se.last<number>(), RA.Foldable)\n    U.deepStrictEqual(\n      fromFoldableS2([\n        [{ id: 'a' }, 1],\n        [{ id: 'a' }, 2]\n      ]),\n      a2\n    )\n  })\n\n  it('getShow', () => {\n    const showUser: Show<User> = struct({ id: S.Show })\n    const Sh = _.getShow(showUser, S.Show)\n    const m1 = new Map<User, string>([])\n    U.deepStrictEqual(Sh.show(m1), `new Map([])`)\n    const m2 = new Map<User, string>([[{ id: 'a' }, 'b']])\n    U.deepStrictEqual(Sh.show(m2), `new Map([[{ id: \"a\" }, \"b\"]])`)\n    const m3 = new Map<User, string>([\n      [{ id: 'c' }, 'd'],\n      [{ id: 'a' }, 'b']\n    ])\n    U.deepStrictEqual(Sh.show(m3), `new Map([[{ id: \"a\" }, \"b\"], [{ id: \"c\" }, \"d\"]])`)\n  })\n\n  it('updateAt', () => {\n    const m1 = new Map<User, string>([])\n    U.deepStrictEqual(_.updateAt(eqUser)({ id: 'a' }, 'a')(m1), O.none)\n    const m2 = new Map<User, string>([[{ id: 'a' }, 'b']])\n    U.deepStrictEqual(_.updateAt(eqUser)({ id: 'a' }, 'a')(m2), O.some(new Map<User, string>([[{ id: 'a' }, 'a']])))\n  })\n\n  it('modifyAt', () => {\n    const m1 = new Map<User, number>([])\n    U.deepStrictEqual(_.modifyAt(eqUser)({ id: 'a' }, (n: number) => n * 2)(m1), O.none)\n    const m2 = new Map<User, number>([[{ id: 'a' }, 1]])\n    U.deepStrictEqual(\n      _.modifyAt(eqUser)({ id: 'a' }, (n: number) => n * 2)(m2),\n      O.some(new Map<User, number>([[{ id: 'a' }, 2]]))\n    )\n    // should return the same reference if nothing changed\n    const input: ReadonlyMap<string, number> = new Map([['a', 1]])\n    U.deepStrictEqual(\n      pipe(\n        input,\n        _.modifyAt(S.Eq)('a', identity),\n        O.map((out) => out === input)\n      ),\n      O.some(true)\n    )\n  })\n\n  it('fromMap', () => {\n    const as = new Map([[1, 'a']])\n    const bs = _.fromMap(as)\n    U.deepStrictEqual(bs, as)\n    assert.notStrictEqual(bs, as)\n  })\n\n  it('toMap', () => {\n    const as: ReadonlyMap<number, string> = new Map([[1, 'a']])\n    const bs = _.toMap(as)\n    U.deepStrictEqual(bs, as)\n    assert.notStrictEqual(bs, as)\n  })\n\n  it('mapWithIndex', () => {\n    const aa1 = new Map<User, number>([[{ id: 'aa' }, 1]])\n    const aa3 = new Map<User, number>([[{ id: 'aa' }, 3]])\n    U.deepStrictEqual(\n      pipe(\n        aa1,\n        _.mapWithIndex((k, a) => a + k.id.length)\n      ),\n      aa3\n    )\n  })\n\n  it('getFunctorWithIndex', () => {\n    const FWI = _.getFunctorWithIndex<User>()\n    const aa1 = new Map<User, number>([[{ id: 'aa' }, 1]])\n    const aa3 = new Map<User, number>([[{ id: 'aa' }, 3]])\n    U.deepStrictEqual(\n      FWI.mapWithIndex(aa1, (k, a) => a + k.id.length),\n      aa3\n    )\n  })\n\n  it('getUnionMonoid', () => {\n    const M = _.getUnionMonoid(eqUser, S.Semigroup)\n    const x = new Map<User, string>([\n      [{ id: 'a' }, 'a1'],\n      [{ id: 'b' }, 'b1'],\n      [{ id: 'c' }, 'c1']\n    ])\n    const y = new Map<User, string>([\n      [{ id: 'b' }, 'b2'],\n      [{ id: 'c' }, 'c2'],\n      [{ id: 'd' }, 'd2']\n    ])\n    U.strictEqual(M.concat(x, M.empty), x)\n    U.strictEqual(M.concat(M.empty, x), x)\n    U.strictEqual(M.concat(x, new Map()), x)\n    U.strictEqual(M.concat(new Map(), x), x)\n    U.deepStrictEqual(\n      M.concat(x, y),\n      new Map([\n        [{ id: 'a' }, 'a1'],\n        [{ id: 'b' }, 'b1b2'],\n        [{ id: 'c' }, 'c1c2'],\n        [{ id: 'd' }, 'd2']\n      ])\n    )\n  })\n\n  it('getIntersectionSemigroup', () => {\n    const M = _.getIntersectionSemigroup(eqUser, S.Semigroup)\n    const x = new Map<User, string>([\n      [{ id: 'a' }, 'a1'],\n      [{ id: 'b' }, 'b1'],\n      [{ id: 'c' }, 'c1']\n    ])\n    const y = new Map<User, string>([\n      [{ id: 'b' }, 'b2'],\n      [{ id: 'c' }, 'c2'],\n      [{ id: 'd' }, 'd2']\n    ])\n    U.strictEqual(M.concat(x, _.empty), _.empty)\n    U.strictEqual(M.concat(_.empty, x), _.empty)\n    U.strictEqual(M.concat(x, new Map()), _.empty)\n    U.strictEqual(M.concat(new Map(), x), _.empty)\n    U.deepStrictEqual(\n      M.concat(x, y),\n      new Map([\n        [{ id: 'b' }, 'b1b2'],\n        [{ id: 'c' }, 'c1c2']\n      ])\n    )\n  })\n\n  it('getDifferenceMagma', () => {\n    const M = _.getDifferenceMagma(eqUser)<string>()\n    const x = new Map<User, string>([\n      [{ id: 'a' }, 'a1'],\n      [{ id: 'b' }, 'b1'],\n      [{ id: 'c' }, 'c1']\n    ])\n    const y = new Map<User, string>([\n      [{ id: 'b' }, 'b2'],\n      [{ id: 'c' }, 'c2'],\n      [{ id: 'd' }, 'd2']\n    ])\n    U.strictEqual(M.concat(x, _.empty), x)\n    U.strictEqual(M.concat(_.empty, x), x)\n    U.strictEqual(M.concat(x, new Map()), x)\n    U.strictEqual(M.concat(new Map(), x), x)\n    U.deepStrictEqual(\n      M.concat(x, y),\n      new Map([\n        [{ id: 'a' }, 'a1'],\n        [{ id: 'd' }, 'd2']\n      ])\n    )\n  })\n})\n"
  },
  {
    "path": "test/ReadonlyNonEmptyArray.ts",
    "content": "import * as assert from 'assert'\n\nimport * as B from '../src/boolean'\nimport { Endomorphism } from '../src/Endomorphism'\nimport * as Eq from '../src/Eq'\nimport { identity, pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as Ord from '../src/Ord'\nimport * as _ from '../src/ReadonlyNonEmptyArray'\nimport * as Se from '../src/Semigroup'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('ReadonlyNonEmptyArray', () => {\n  describe('pipeables', () => {\n    it('traverse', () => {\n      assert.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.traverse(O.Applicative)((n) => (n >= 0 ? O.some(n) : O.none))\n        ),\n        O.some([1, 2, 3])\n      )\n      U.deepStrictEqual(\n        pipe(\n          [1, 2, 3],\n          _.traverse(O.Applicative)((n) => (n >= 2 ? O.some(n) : O.none))\n        ),\n        O.none\n      )\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      assert.deepStrictEqual(sequence([O.some(1), O.some(2), O.some(3)]), O.some([1, 2, 3]))\n      U.deepStrictEqual(sequence([O.none, O.some(2), O.some(3)]), O.none)\n    })\n\n    it('traverseWithIndex', () => {\n      assert.deepStrictEqual(\n        pipe(\n          ['a', 'bb'],\n          _.traverseWithIndex(O.Applicative)((i, s) => (s.length >= 1 ? O.some(s + i) : O.none))\n        ),\n        O.some(['a0', 'bb1'])\n      )\n      U.deepStrictEqual(\n        pipe(\n          ['a', 'bb'],\n          _.traverseWithIndex(O.Applicative)((i, s) => (s.length > 1 ? O.some(s + i) : O.none))\n        ),\n        O.none\n      )\n    })\n  })\n\n  it('head', () => {\n    U.deepStrictEqual(_.head([1, 2]), 1)\n  })\n\n  it('tail', () => {\n    U.deepStrictEqual(_.tail([1, 2]), [2])\n  })\n\n  it('map', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2],\n        _.map((n) => n * 2)\n      ),\n      [2, 4]\n    )\n  })\n\n  it('mapWithIndex', () => {\n    const add = (i: number, n: number) => n + i\n    U.deepStrictEqual(pipe([1, 2], _.mapWithIndex(add)), [1, 3])\n  })\n\n  it('of', () => {\n    U.deepStrictEqual(_.of(1), [1])\n  })\n\n  it('ap', () => {\n    const fab: _.ReadonlyNonEmptyArray<(n: number) => number> = [U.double, U.double]\n    U.deepStrictEqual(pipe(fab, _.ap([1, 2])), [2, 4, 2, 4])\n  })\n\n  it('flatMap', () => {\n    const f = (a: number): _.ReadonlyNonEmptyArray<number> => [a, 4]\n    U.deepStrictEqual(pipe([1, 2], _.flatMap(f)), [1, 4, 2, 4])\n    U.deepStrictEqual(_.flatMap([1, 2], f), [1, 4, 2, 4])\n  })\n\n  it('chain', () => {\n    const f = (a: number): _.ReadonlyNonEmptyArray<number> => [a, 4]\n    U.deepStrictEqual(pipe([1, 2], _.chain(f)), [1, 4, 2, 4])\n  })\n\n  it('extend', () => {\n    const sum = (as: _.ReadonlyNonEmptyArray<number>): number => {\n      const head = _.head(as)\n      assert.ok(typeof (head as any) === 'number')\n      return Se.concatAll(N.MonoidSum)(head)(_.tail(as))\n    }\n    U.deepStrictEqual(pipe([1, 2, 3, 4], _.extend(sum)), [10, 9, 7, 4])\n    U.deepStrictEqual(pipe([1], _.extend(sum)), [1])\n  })\n\n  it('extract', () => {\n    U.deepStrictEqual(_.extract([1, 2, 3]), 1)\n  })\n\n  it('min', () => {\n    U.deepStrictEqual(_.min(N.Ord)([2, 1, 3]), 1)\n    U.deepStrictEqual(_.min(N.Ord)([3]), 3)\n  })\n\n  it('max', () => {\n    U.deepStrictEqual(_.max(N.Ord)([1, 2, 3]), 3)\n    U.deepStrictEqual(_.max(N.Ord)([1]), 1)\n  })\n\n  it('reduce', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a', 'b'],\n        _.reduce('', (b, a) => b + a)\n      ),\n      'ab'\n    )\n  })\n\n  it('foldMap', () => {\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.foldMap(S.Monoid)(identity)), 'abc')\n  })\n\n  it('reduceRight', () => {\n    const f = (a: string, acc: string) => acc + a\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.reduceRight('', f)), 'cba')\n  })\n\n  it('fromReadonlyArray', () => {\n    U.deepStrictEqual(_.fromReadonlyArray([]), O.none)\n    assert.deepStrictEqual(_.fromReadonlyArray([1]), O.some([1]))\n    assert.deepStrictEqual(_.fromReadonlyArray([1, 2]), O.some([1, 2]))\n  })\n\n  it('getSemigroup', () => {\n    const S = _.getSemigroup<number>()\n    U.deepStrictEqual(S.concat([1], [2]), [1, 2])\n    U.deepStrictEqual(S.concat([1, 2], [3, 4]), [1, 2, 3, 4])\n  })\n\n  it('getEq', () => {\n    const S = _.getEq(N.Eq)\n    U.deepStrictEqual(S.equals([1], [1]), true)\n    U.deepStrictEqual(S.equals([1], [1, 2]), false)\n  })\n\n  it('group', () => {\n    U.deepStrictEqual(_.group(N.Eq)([]), [])\n\n    U.deepStrictEqual(_.group(N.Eq)([1, 2, 1, 1]), [[1], [2], [1, 1]])\n\n    U.deepStrictEqual(_.group(N.Eq)([1, 2, 1, 1, 3]), [[1], [2], [1, 1], [3]])\n  })\n\n  it('groupSort', () => {\n    U.deepStrictEqual(_.groupSort(N.Ord)([]), [])\n    U.deepStrictEqual(_.groupSort(N.Ord)([1, 2, 1, 1]), [[1, 1, 1], [2]])\n  })\n\n  it('last', () => {\n    U.deepStrictEqual(_.last([1, 2, 3]), 3)\n    U.deepStrictEqual(_.last([1]), 1)\n  })\n\n  it('init', () => {\n    U.deepStrictEqual(_.init([1, 2, 3]), [1, 2])\n    U.deepStrictEqual(_.init([1]), [])\n  })\n\n  it('sort', () => {\n    const sort = _.sort(N.Ord)\n    U.deepStrictEqual(sort([3, 2, 1]), [1, 2, 3])\n    // should optimize `1`-length `ReadonlyNonEmptyArray`s\n    const singleton: _.ReadonlyNonEmptyArray<number> = [1]\n    U.strictEqual(sort(singleton), singleton)\n  })\n\n  it('prependAll', () => {\n    U.deepStrictEqual(_.prependAll(0)([1, 2, 3]), [0, 1, 0, 2, 0, 3])\n    U.deepStrictEqual(_.prependAll(0)([1]), [0, 1])\n    U.deepStrictEqual(_.prependAll(0)([1, 2, 3, 4]), [0, 1, 0, 2, 0, 3, 0, 4])\n  })\n\n  it('intersperse', () => {\n    U.deepStrictEqual(_.intersperse(0)([1, 2, 3]), [1, 0, 2, 0, 3])\n    U.deepStrictEqual(_.intersperse(0)([1]), [1])\n    U.deepStrictEqual(_.intersperse(0)([1, 2]), [1, 0, 2])\n    U.deepStrictEqual(_.intersperse(0)([1, 2, 3, 4]), [1, 0, 2, 0, 3, 0, 4])\n  })\n\n  it('intercalate', () => {\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a']), 'a')\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a', 'b', 'c']), 'a-b-c')\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a', '', 'c']), 'a--c')\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a', 'b']), 'a-b')\n    U.deepStrictEqual(_.intercalate(S.Semigroup)('-')(['a', 'b', 'c', 'd']), 'a-b-c-d')\n  })\n\n  it('reverse', () => {\n    const singleton: _.ReadonlyNonEmptyArray<number> = [1]\n    U.strictEqual(_.reverse(singleton), singleton)\n    U.deepStrictEqual(_.reverse([1, 2, 3]), [3, 2, 1])\n  })\n\n  it('groupBy', () => {\n    U.deepStrictEqual(_.groupBy((_) => '')([]), {})\n    U.deepStrictEqual(_.groupBy(String)([1]), { '1': [1] })\n    U.deepStrictEqual(_.groupBy((s: string) => String(s.length))(['foo', 'bar', 'foobar']), {\n      '3': ['foo', 'bar'],\n      '6': ['foobar']\n    })\n  })\n\n  it('insertAt', () => {\n    const make = (x: number) => ({ x })\n    const a1 = make(1)\n    const a2 = make(1)\n    const a3 = make(2)\n    const a4 = make(3)\n    U.deepStrictEqual(pipe([], _.insertAt(1, 1)), O.none)\n    assert.deepStrictEqual(_.insertAt(0, a4)([a1, a2, a3]), O.some([a4, a1, a2, a3]))\n    U.deepStrictEqual(_.insertAt(-1, a4)([a1, a2, a3]), O.none)\n    assert.deepStrictEqual(_.insertAt(3, a4)([a1, a2, a3]), O.some([a1, a2, a3, a4]))\n    assert.deepStrictEqual(_.insertAt(1, a4)([a1, a2, a3]), O.some([a1, a4, a2, a3]))\n    U.deepStrictEqual(_.insertAt(4, a4)([a1, a2, a3]), O.none)\n  })\n\n  it('updateAt', () => {\n    const make2 = (x: number) => ({ x })\n    const a1 = make2(1)\n    const a2 = make2(1)\n    const a3 = make2(2)\n    const a4 = make2(3)\n    const arr: _.ReadonlyNonEmptyArray<{ readonly x: number }> = [a1, a2, a3]\n    assert.deepStrictEqual(_.updateAt(0, a4)(arr), O.some([a4, a2, a3]))\n    U.deepStrictEqual(_.updateAt(-1, a4)(arr), O.none)\n    U.deepStrictEqual(_.updateAt(3, a4)(arr), O.none)\n    assert.deepStrictEqual(_.updateAt(1, a4)(arr), O.some([a1, a4, a3]))\n    // should return the same reference if nothing changed\n    const r1 = _.updateAt(0, a1)(arr)\n    if (O.isSome(r1)) {\n      U.deepStrictEqual(r1.value, arr)\n    } else {\n      assert.fail('is not a Some')\n    }\n    const r2 = _.updateAt(2, a3)(arr)\n    if (O.isSome(r2)) {\n      U.deepStrictEqual(r2.value, arr)\n    } else {\n      assert.fail('is not a Some')\n    }\n  })\n\n  it('modifyAt', () => {\n    U.deepStrictEqual(_.modifyAt(1, U.double)([1]), O.none)\n    U.deepStrictEqual(_.modifyAt(1, U.double)([1, 2]), O.some([1, 4] as const))\n    // should return the same reference if nothing changed\n    const input: _.ReadonlyNonEmptyArray<number> = [1, 2, 3]\n    U.deepStrictEqual(\n      pipe(\n        input,\n        _.modifyAt(1, identity),\n        O.map((out) => out === input)\n      ),\n      O.some(true)\n    )\n  })\n\n  it('filter', () => {\n    const make = (x: number) => ({ x })\n    const a1 = make(1)\n    const a2 = make(1)\n    const a3 = make(2)\n    assert.deepStrictEqual(_.filter(({ x }) => x !== 1)([a1, a2, a3]), O.some([a3]))\n    assert.deepStrictEqual(_.filter(({ x }) => x !== 2)([a1, a2, a3]), O.some([a1, a2]))\n    U.deepStrictEqual(\n      _.filter(({ x }) => {\n        return !(x === 1 || x === 2)\n      })([a1, a2, a3]),\n      O.none\n    )\n    assert.deepStrictEqual(_.filter(({ x }) => x !== 10)([a1, a2, a3]), O.some([a1, a2, a3]))\n\n    // refinements\n    const actual1 = _.filter(O.isSome)([O.some(3), O.some(2), O.some(1)])\n    assert.deepStrictEqual(actual1, O.some([O.some(3), O.some(2), O.some(1)]))\n    const actual2 = _.filter(O.isSome)([O.some(3), O.none, O.some(1)])\n    assert.deepStrictEqual(actual2, O.some([O.some(3), O.some(1)]))\n  })\n\n  it('filterWithIndex', () => {\n    assert.deepStrictEqual(_.filterWithIndex((i) => i % 2 === 0)([1, 2, 3]), O.some([1, 3]))\n    U.deepStrictEqual(_.filterWithIndex((i, a: number) => i % 2 === 1 && a > 2)([1, 2, 3]), O.none)\n  })\n\n  it('reduceWithIndex', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a', 'b'],\n        _.reduceWithIndex('', (i, b, a) => b + i + a)\n      ),\n      '0a1b'\n    )\n  })\n\n  it('foldMapWithIndex', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a', 'b'],\n        _.foldMapWithIndex(S.Monoid)((i, a) => i + a)\n      ),\n      '0a1b'\n    )\n  })\n\n  it('reduceRightWithIndex', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a', 'b'],\n        _.reduceRightWithIndex('', (i, a, b) => b + i + a)\n      ),\n      '1b0a'\n    )\n  })\n\n  it('cons', () => {\n    U.deepStrictEqual(_.cons(1, [2, 3, 4]), [1, 2, 3, 4])\n    U.deepStrictEqual(pipe([2, 3, 4], _.cons(1)), [1, 2, 3, 4])\n  })\n\n  it('snoc', () => {\n    U.deepStrictEqual(_.snoc([], 0), [0])\n    U.deepStrictEqual(_.snoc([1, 2, 3], 4), [1, 2, 3, 4])\n  })\n\n  it('unprepend', () => {\n    U.deepStrictEqual(_.unprepend([0]), [0, []])\n    U.deepStrictEqual(_.unprepend([1, 2, 3, 4]), [1, [2, 3, 4]])\n  })\n\n  it('unappend', () => {\n    U.deepStrictEqual(_.unappend([0]), [[], 0])\n    U.deepStrictEqual(_.unappend([1, 2, 3, 4]), [[1, 2, 3], 4])\n    U.deepStrictEqual(_.unappend([0]), [[], 0])\n    U.deepStrictEqual(_.unappend([1, 2, 3, 4]), [[1, 2, 3], 4])\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    U.deepStrictEqual(Sh.show(['a']), `[\"a\"]`)\n    U.deepStrictEqual(Sh.show(['a', 'b', 'c']), `[\"a\", \"b\", \"c\"]`)\n  })\n\n  it('alt', () => {\n    U.deepStrictEqual(\n      pipe(\n        ['a'],\n        _.alt(() => ['b'])\n      ),\n      ['a', 'b']\n    )\n  })\n\n  it('foldMap', () => {\n    const f = _.foldMap(N.SemigroupSum)((s: string) => s.length)\n    U.deepStrictEqual(f(['a']), 1)\n    U.deepStrictEqual(f(['a', 'bb']), 3)\n  })\n\n  it('foldMapWithIndex', () => {\n    const f = _.foldMapWithIndex(N.SemigroupSum)((i: number, s: string) => s.length + i)\n    U.deepStrictEqual(f(['a']), 1)\n    U.deepStrictEqual(f(['a', 'bb']), 4)\n  })\n\n  it('fromArray', () => {\n    U.strictEqual(_.fromArray([]), O.none)\n    const as = [1, 2, 3]\n    const bs = _.fromArray(as)\n    assert.deepStrictEqual(bs, O.some(as))\n    assert.notStrictEqual((bs as any).value, as)\n  })\n\n  it('fromReadonlyArray', () => {\n    const as: ReadonlyArray<number> = [1, 2, 3]\n    const bs = _.fromReadonlyArray(as)\n    U.deepStrictEqual(bs, O.some(as))\n    U.strictEqual((bs as any).value, as)\n  })\n\n  it('concatAll', () => {\n    const f = _.concatAll(S.Semigroup)\n    U.deepStrictEqual(f(['a']), 'a')\n    U.deepStrictEqual(f(['a', 'bb']), 'abb')\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      ),\n      [{ a: 1, b: 'b', c: [1, 'b'] }]\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b'))), [{ a: 1, b: 'b' }])\n  })\n\n  it('zipWith', () => {\n    U.deepStrictEqual(\n      _.zipWith([1, 2, 3], ['a', 'b', 'c', 'd'], (n, s) => s + n),\n      ['a1', 'b2', 'c3']\n    )\n  })\n\n  it('zip', () => {\n    U.deepStrictEqual(_.zip([1, 2, 3], ['a', 'b', 'c', 'd']), [\n      [1, 'a'],\n      [2, 'b'],\n      [3, 'c']\n    ])\n    U.deepStrictEqual(pipe([1, 2, 3] as const, _.zip(['a', 'b', 'c', 'd'])), [\n      [1, 'a'],\n      [2, 'b'],\n      [3, 'c']\n    ])\n  })\n\n  it('unzip', () => {\n    U.deepStrictEqual(\n      _.unzip([\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('splitAt', () => {\n    const assertSplitAt = (\n      input: _.ReadonlyNonEmptyArray<number>,\n      index: number,\n      expectedInit: ReadonlyArray<number>,\n      expectedRest: ReadonlyArray<number>\n    ) => {\n      const [init, rest] = _.splitAt(index)(input)\n      U.strictEqual(init, expectedInit)\n      U.strictEqual(rest, expectedRest)\n    }\n\n    const two: _.ReadonlyNonEmptyArray<number> = [1, 2]\n    U.deepStrictEqual(_.splitAt(1)(two), [[1], [2]])\n    assertSplitAt(two, 2, two, _.empty)\n    const singleton: _.ReadonlyNonEmptyArray<number> = [1]\n    assertSplitAt(singleton, 1, singleton, _.empty)\n\n    // out of bounds\n    assertSplitAt(singleton, 0, singleton, _.empty)\n    assertSplitAt(singleton, 2, singleton, _.empty)\n    U.deepStrictEqual(_.splitAt(0)(two), [[1], [2]])\n    assertSplitAt(two, 3, two, _.empty)\n  })\n\n  it('chunksOf', () => {\n    U.deepStrictEqual(_.chunksOf(2)([1, 2, 3, 4, 5]), [[1, 2], [3, 4], [5]])\n    U.deepStrictEqual(_.chunksOf(2)([1, 2, 3, 4, 5, 6]), [\n      [1, 2],\n      [3, 4],\n      [5, 6]\n    ])\n    U.deepStrictEqual(_.chunksOf(1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n    U.deepStrictEqual(_.chunksOf(5)([1, 2, 3, 4, 5]), [[1, 2, 3, 4, 5]])\n    // out of bounds\n    U.deepStrictEqual(_.chunksOf(0)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n    U.deepStrictEqual(_.chunksOf(-1)([1, 2, 3, 4, 5]), [[1], [2], [3], [4], [5]])\n\n    const assertSingleChunk = (input: _.ReadonlyNonEmptyArray<number>, n: number) => {\n      const chunks = _.chunksOf(n)(input)\n      U.strictEqual(chunks.length, 1)\n      U.strictEqual(_.head(chunks), input)\n    }\n    // n = length\n    assertSingleChunk([1, 2], 2)\n    // n out of bounds\n    assertSingleChunk([1, 2], 3)\n  })\n\n  it('rotate', () => {\n    const singleton: _.ReadonlyNonEmptyArray<number> = [1]\n    U.strictEqual(_.rotate(1)(singleton), singleton)\n    U.strictEqual(_.rotate(2)(singleton), singleton)\n    U.strictEqual(_.rotate(-1)(singleton), singleton)\n    U.strictEqual(_.rotate(-2)(singleton), singleton)\n    const two: _.ReadonlyNonEmptyArray<number> = [1, 2]\n    U.strictEqual(_.rotate(2)(two), two)\n    U.strictEqual(_.rotate(0)(two), two)\n    U.strictEqual(_.rotate(-2)(two), two)\n\n    U.deepStrictEqual(_.rotate(1)([1, 2]), [2, 1])\n    U.deepStrictEqual(_.rotate(1)([1, 2, 3, 4, 5]), [5, 1, 2, 3, 4])\n    U.deepStrictEqual(_.rotate(2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n    U.deepStrictEqual(_.rotate(-1)([1, 2, 3, 4, 5]), [2, 3, 4, 5, 1])\n    U.deepStrictEqual(_.rotate(-2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n\n    U.deepStrictEqual(_.rotate(7)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n    U.deepStrictEqual(_.rotate(-7)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n\n    U.deepStrictEqual(_.rotate(2.2)([1, 2, 3, 4, 5]), [4, 5, 1, 2, 3])\n    U.deepStrictEqual(_.rotate(-2.2)([1, 2, 3, 4, 5]), [3, 4, 5, 1, 2])\n  })\n\n  it('uniq', () => {\n    interface A {\n      readonly a: string\n      readonly b: number\n    }\n\n    const eqA = pipe(\n      N.Eq,\n      Eq.contramap((f: A) => f.b)\n    )\n    const arrA: A = { a: 'a', b: 1 }\n    const arrB: A = { a: 'b', b: 1 }\n    const arrC: A = { a: 'c', b: 2 }\n    const arrD: A = { a: 'd', b: 2 }\n    const arrUniq: _.ReadonlyNonEmptyArray<A> = [arrA, arrC]\n\n    U.deepStrictEqual(_.uniq(eqA)(arrUniq), arrUniq)\n    U.deepStrictEqual(_.uniq(eqA)([arrA, arrB, arrC, arrD]), [arrA, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrB, arrA, arrC, arrD]), [arrB, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrA, arrA, arrC, arrD, arrA]), [arrA, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrA, arrC]), [arrA, arrC])\n    U.deepStrictEqual(_.uniq(eqA)([arrC, arrA]), [arrC, arrA])\n    U.deepStrictEqual(_.uniq(B.Eq)([true, false, true, false]), [true, false])\n    U.deepStrictEqual(_.uniq(N.Eq)([-0, -0]), [-0])\n    U.deepStrictEqual(_.uniq(N.Eq)([0, -0]), [0])\n    U.deepStrictEqual(_.uniq(N.Eq)([1]), [1])\n    U.deepStrictEqual(_.uniq(N.Eq)([2, 1, 2]), [2, 1])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 2, 1]), [1, 2])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 1, 2, 2, 3, 3, 4, 4, 5, 5]), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.uniq(N.Eq)([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.uniq(S.Eq)(['a', 'b', 'a']), ['a', 'b'])\n    U.deepStrictEqual(_.uniq(S.Eq)(['a', 'b', 'A']), ['a', 'b', 'A'])\n\n    const as: _.ReadonlyNonEmptyArray<number> = [1]\n    U.strictEqual(_.uniq(N.Eq)(as), as)\n  })\n\n  it('sortBy', () => {\n    interface X {\n      readonly a: string\n      readonly b: number\n      readonly c: boolean\n    }\n    const byName = pipe(\n      S.Ord,\n      Ord.contramap((p: { readonly a: string; readonly b: number }) => p.a)\n    )\n    const byAge = pipe(\n      N.Ord,\n      Ord.contramap((p: { readonly a: string; readonly b: number }) => p.b)\n    )\n    const f = _.sortBy([byName, byAge])\n    const xs: _.ReadonlyNonEmptyArray<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    U.deepStrictEqual(f(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    const sortByAgeByName = _.sortBy([byAge, byName])\n    U.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    U.deepStrictEqual(_.sortBy([])(xs), xs)\n  })\n\n  it('union', () => {\n    const concat = _.getUnionSemigroup(N.Eq).concat\n    U.deepStrictEqual(concat([1, 2], [3, 4]), [1, 2, 3, 4])\n    U.deepStrictEqual(concat([1, 2], [2, 3]), [1, 2, 3])\n    U.deepStrictEqual(concat([1, 2], [1, 2]), [1, 2])\n  })\n\n  it('matchLeft', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        _.matchLeft((head, tail) => [head, tail])\n      ),\n      [1, [2, 3]]\n    )\n  })\n\n  it('matchRight', () => {\n    U.deepStrictEqual(\n      pipe(\n        [1, 2, 3],\n        _.matchRight((init, last) => [init, last])\n      ),\n      [[1, 2], 3]\n    )\n  })\n\n  it('modifyHead', () => {\n    const f: Endomorphism<string> = (s) => s + '!'\n    U.deepStrictEqual(pipe(['a'], _.modifyHead(f)), ['a!'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.modifyHead(f)), ['a!', 'b'])\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.modifyHead(f)), ['a!', 'b', 'c'])\n  })\n\n  it('modifyLast', () => {\n    const f: Endomorphism<string> = (s) => s + '!'\n    U.deepStrictEqual(pipe(['a'], _.modifyLast(f)), ['a!'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.modifyLast(f)), ['a', 'b!'])\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.modifyLast(f)), ['a', 'b', 'c!'])\n  })\n\n  it('makeBy', () => {\n    const f = _.makeBy(U.double)\n    U.deepStrictEqual(f(5), [0, 2, 4, 6, 8])\n    // If `n` (must be a natural number) is non positive return `[f(0)]`.\n    U.deepStrictEqual(f(0), [0])\n    U.deepStrictEqual(f(-1), [0])\n  })\n\n  it('range', () => {\n    U.deepStrictEqual(_.range(0, 0), [0])\n    U.deepStrictEqual(_.range(0, 1), [0, 1])\n    U.deepStrictEqual(_.range(1, 5), [1, 2, 3, 4, 5])\n    U.deepStrictEqual(_.range(10, 15), [10, 11, 12, 13, 14, 15])\n    U.deepStrictEqual(_.range(-1, 0), [-1, 0])\n    U.deepStrictEqual(_.range(-5, -1), [-5, -4, -3, -2, -1])\n    // out of bound\n    U.deepStrictEqual(_.range(2, 1), [2])\n    U.deepStrictEqual(_.range(-1, -2), [-1])\n  })\n\n  it('replicate', () => {\n    const f = _.replicate('a')\n    U.deepStrictEqual(pipe(0, f), ['a'])\n    U.deepStrictEqual(pipe(1, f), ['a'])\n    U.deepStrictEqual(pipe(2, f), ['a', 'a'])\n  })\n\n  it('updateHead', () => {\n    U.deepStrictEqual(pipe(['a'], _.updateHead('d')), ['d'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.updateHead('d')), ['d', 'b'])\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.updateHead('d')), ['d', 'b', 'c'])\n  })\n\n  it('updateLast', () => {\n    U.deepStrictEqual(pipe(['a'], _.updateLast('d')), ['d'])\n    U.deepStrictEqual(pipe(['a', 'b'], _.updateLast('d')), ['a', 'd'])\n    U.deepStrictEqual(pipe(['a', 'b', 'c'], _.updateLast('d')), ['a', 'b', 'd'])\n  })\n\n  it('concatW', () => {\n    U.deepStrictEqual(pipe(['a'], _.concatW(['b'])), ['a', 'b'])\n  })\n\n  it('concat', () => {\n    U.deepStrictEqual(pipe(['a'], _.concat(['b'])), ['a', 'b'])\n    U.deepStrictEqual(pipe(_.empty, _.concat(['b'])), ['b'])\n    U.deepStrictEqual(pipe(['a'], _.concat<string>(_.empty)), ['a'])\n    U.deepStrictEqual(_.concat(['a'], ['b']), ['a', 'b'])\n    U.deepStrictEqual(_.concat(['a'], _.empty), ['a'])\n    U.deepStrictEqual(_.concat(_.empty, ['b']), ['b'])\n  })\n\n  it('isOutOfBound', () => {\n    U.deepStrictEqual(_.isOutOfBound(0, ['a']), false)\n    U.deepStrictEqual(_.isOutOfBound(100, ['a']), true)\n    U.deepStrictEqual(_.isOutOfBound(-1, ['a']), true)\n  })\n})\n"
  },
  {
    "path": "test/ReadonlyRecord.ts",
    "content": "import * as assert from 'assert'\n\nimport * as E from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as IO from '../src/IO'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport { reverse } from '../src/Ord'\nimport * as RA from '../src/ReadonlyArray'\nimport * as _ from '../src/ReadonlyRecord'\nimport * as Se from '../src/Semigroup'\nimport { separated } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\nconst p = (n: number) => n > 2\n\nconst noPrototype = Object.create(null)\n\ndescribe('ReadonlyRecord', () => {\n  describe('pipeables', () => {\n    it('collect', () => {\n      const x: { readonly a: string; readonly b: boolean } = { a: 'c', b: false }\n      U.deepStrictEqual(_.collect(S.Ord)((key, val) => ({ key: key, value: val }))(x), [\n        { key: 'a', value: 'c' },\n        { key: 'b', value: false }\n      ])\n      U.deepStrictEqual(_.collect((key, val) => ({ key: key, value: val }))(x), [\n        { key: 'a', value: 'c' },\n        { key: 'b', value: false }\n      ])\n    })\n\n    it('map', () => {\n      U.deepStrictEqual(pipe({ k1: 1, k2: 2 }, _.map(U.double)), { k1: 2, k2: 4 })\n      U.deepStrictEqual(pipe({ a: 1, b: 2 }, _.map(U.double)), { a: 2, b: 4 })\n      U.deepStrictEqual(_.Functor.map({ a: 1, b: 2 }, U.double), { a: 2, b: 4 })\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduce(S.Ord)('', (b, a) => b + a)\n        ),\n        'ab'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k2: 'b', k1: 'a' },\n          _.reduce(S.Ord)('', (b, a) => b + a)\n        ),\n        'ab'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduce('', (b, a) => b + a)\n        ),\n        'ab'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k2: 'b', k1: 'a' },\n          _.reduce('', (b, a) => b + a)\n        ),\n        'ab'\n      )\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe({ a: 'a', b: 'b' }, _.foldMap(S.Ord)(S.Monoid)(identity)), 'ab')\n      U.deepStrictEqual(_.getFoldable(S.Ord).foldMap(S.Monoid)({ a: 'a', b: 'b' }, identity), 'ab')\n\n      U.deepStrictEqual(pipe({ a: 'a', b: 'b' }, _.foldMap(S.Monoid)(identity)), 'ab')\n      U.deepStrictEqual(_.Foldable.foldMap(S.Monoid)({ a: 'a', b: 'b' }, identity), 'ab')\n    })\n\n    it('reduceRight', () => {\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(pipe({ a: 'a', b: 'b' }, _.reduceRight(S.Ord)('', f)), 'ba')\n      U.deepStrictEqual(pipe({ a: 'a', b: 'b' }, _.reduceRight('', f)), 'ba')\n    })\n\n    it('compact', () => {\n      U.deepStrictEqual(_.compact({ foo: O.none, bar: O.some(123) }), { bar: 123 })\n      // should ignore non own properties\n      const o: _.ReadonlyRecord<string, O.Option<number>> = Object.create({ a: 1 })\n      U.deepStrictEqual(pipe(o, _.compact), {})\n    })\n\n    it('separate', () => {\n      U.deepStrictEqual(_.separate({ foo: E.left(123), bar: E.right(123) }), separated({ foo: 123 }, { bar: 123 }))\n      // should ignore non own properties\n      const o: _.ReadonlyRecord<string, E.Either<string, number>> = Object.create({ a: 1 })\n      U.deepStrictEqual(pipe(o, _.separate), separated({}, {}))\n    })\n\n    it('filter', () => {\n      const d = { a: 1, b: 3 }\n      U.deepStrictEqual(pipe(d, _.filter(p)), { b: 3 })\n\n      // refinements\n      const isNumber = (u: string | number): u is number => typeof u === 'number'\n      const y: _.ReadonlyRecord<string, string | number> = { a: 1, b: 'foo' }\n      const actual = pipe(y, _.filter(isNumber))\n      U.deepStrictEqual(actual, { a: 1 })\n      U.deepStrictEqual(\n        pipe(\n          y,\n          _.filter((_) => true)\n        ),\n        y\n      )\n\n      const x = Object.assign(Object.create({ c: true }), { a: 1, b: 'foo' })\n      U.deepStrictEqual(pipe(x, _.filter(isNumber)), { a: 1 })\n      U.deepStrictEqual(pipe(noPrototype, _.filter(isNumber)), noPrototype)\n    })\n\n    it('filterMap', () => {\n      const f = (n: number) => (p(n) ? O.some(n + 1) : O.none)\n      U.deepStrictEqual(pipe({}, _.filterMap(f)), {})\n      U.deepStrictEqual(pipe({ a: 1, b: 3 }, _.filterMap(f)), { b: 4 })\n    })\n\n    it('partition', () => {\n      U.deepStrictEqual(pipe({}, _.partition(p)), separated({}, {}))\n      U.deepStrictEqual(pipe({ a: 1, b: 3 }, _.partition(p)), separated({ a: 1 }, { b: 3 }))\n    })\n\n    it('partitionMap', () => {\n      const f = (n: number) => (p(n) ? E.right(n + 1) : E.left(n - 1))\n      U.deepStrictEqual(pipe({}, _.partitionMap(f)), separated({}, {}))\n      U.deepStrictEqual(pipe({ a: 1, b: 3 }, _.partitionMap(f)), separated({ a: 0 }, { b: 4 }))\n    })\n\n    it('reduceWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduceWithIndex(S.Ord)('', (k, b, a) => b + k + a)\n        ),\n        'k1ak2b'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k2: 'b', k1: 'a' },\n          _.reduceWithIndex(S.Ord)('', (k, b, a) => b + k + a)\n        ),\n        'k1ak2b'\n      )\n\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduceWithIndex('', (k, b, a) => b + k + a)\n        ),\n        'k1ak2b'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k2: 'b', k1: 'a' },\n          _.reduceWithIndex('', (k, b, a) => b + k + a)\n        ),\n        'k1ak2b'\n      )\n    })\n\n    it('foldMapWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.foldMapWithIndex(S.Ord)(S.Monoid)((k, a) => k + a)\n        ),\n        'k1ak2b'\n      )\n      U.deepStrictEqual(\n        _.getFoldableWithIndex(S.Ord).foldMapWithIndex(S.Monoid)({ k1: 'a', k2: 'b' }, (k, a) => k + a),\n        'k1ak2b'\n      )\n\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.foldMapWithIndex(S.Monoid)((k, a) => k + a)\n        ),\n        'k1ak2b'\n      )\n      U.deepStrictEqual(\n        _.FoldableWithIndex.foldMapWithIndex(S.Monoid)({ k1: 'a', k2: 'b' }, (k, a) => k + a),\n        'k1ak2b'\n      )\n    })\n\n    it('reduceRightWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduceRightWithIndex(S.Ord)('', (k, a, b) => b + k + a)\n        ),\n        'k2bk1a'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduceRightWithIndex('', (k, a, b) => b + k + a)\n        ),\n        'k2bk1a'\n      )\n    })\n\n    it('partitionMapWithIndex', () => {\n      const f = _.partitionMapWithIndex((k, a: number) => (a > 1 ? E.right(a) : E.left(k)))\n      U.deepStrictEqual(pipe({ a: 1, b: 2 }, f), separated({ a: 'a' }, { b: 2 }))\n      // should ignore non own properties\n      const o: _.ReadonlyRecord<string, number> = Object.create({ a: 1 })\n      U.deepStrictEqual(pipe(o, f), separated({}, {}))\n    })\n\n    it('partitionWithIndex', () => {\n      const f = _.partitionWithIndex((_, a: number) => a > 1)\n      U.deepStrictEqual(pipe({ a: 1, b: 2 }, f), separated({ a: 1 }, { b: 2 }))\n      // should ignore non own properties\n      const o: _.ReadonlyRecord<string, number> = Object.create({ a: 1 })\n      U.deepStrictEqual(pipe(o, f), separated({}, {}))\n    })\n\n    it('filterMapWithIndex', () => {\n      const f = _.filterMapWithIndex((_, a: number) => (a > 1 ? O.some(a) : O.none))\n      U.deepStrictEqual(pipe({ a: 1, b: 2 }, f), { b: 2 })\n      // should ignore non own properties\n      const o: _.ReadonlyRecord<string, number> = Object.create({ a: 1 })\n      U.deepStrictEqual(pipe(o, f), {})\n    })\n\n    it('filterWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { a: 1, b: 2 },\n          _.filterWithIndex((_, a: number) => a > 1)\n        ),\n        { b: 2 }\n      )\n    })\n\n    it('traverse', () => {\n      U.deepStrictEqual(\n        _.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      U.deepStrictEqual(_.traverse(O.Applicative)((n: number) => (n >= 2 ? O.some(n) : O.none))({ a: 1, b: 2 }), O.none)\n    })\n\n    it('getTraversable', () => {\n      const T = _.getTraversable(reverse(S.Ord))\n      const f = (n: number) => (n <= 2 ? O.some(n) : O.none)\n      U.deepStrictEqual(T.traverse(O.Applicative)({ a: 1, b: 2 }, f), O.some({ a: 1, b: 2 }))\n      U.deepStrictEqual(T.traverse(O.Applicative)({ a: 1, b: 3 }, f), O.none)\n      // should respect the order\n      U.deepStrictEqual(pipe(T.traverse(O.Applicative)({ b: 2, a: 1 }, f), O.map(Object.keys)), O.some(['b', 'a']))\n      U.deepStrictEqual(\n        pipe(T.sequence(O.Applicative)({ b: O.some(2), a: O.some(1) }), O.map(Object.keys)),\n        O.some(['b', 'a'])\n      )\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      U.deepStrictEqual(sequence({ a: O.some(1), b: O.some(2) }), O.some({ a: 1, b: 2 }))\n      U.deepStrictEqual(sequence({ a: O.none, b: O.some(2) }), O.none)\n\n      U.deepStrictEqual(\n        _.readonlyRecord.sequence(O.Applicative)({ a: O.some(1), b: O.some(2) }),\n        O.some({ a: 1, b: 2 })\n      )\n    })\n\n    describe('traverseWithIndex', () => {\n      it('simple Traversal', () => {\n        const f = (k: string, n: number): O.Option<number> => (k !== 'a' ? O.some(n) : O.none)\n        const traverseWithIndex = _.traverseWithIndex(O.Applicative)(f)\n        U.deepStrictEqual(pipe({ a: 1, b: 2 }, traverseWithIndex), O.none)\n        U.deepStrictEqual(pipe({ b: 2 }, traverseWithIndex), O.some({ b: 2 }))\n      })\n\n      it('should not modify arrays in place', () => {\n        const result = pipe(\n          { a: 2, b: 3 },\n          _.fromRecord,\n          _.traverseWithIndex(RA.Applicative)((_, n) => RA.makeBy(n, (i) => i * 4))\n        )\n\n        U.deepStrictEqual(result, [\n          { a: 0, b: 0 },\n          { a: 0, b: 4 },\n          { a: 0, b: 8 },\n          { a: 4, b: 0 },\n          { a: 4, b: 4 },\n          { a: 4, b: 8 }\n        ])\n      })\n    })\n\n    it('getTraversableWithIndex', () => {\n      const TWI = _.getTraversableWithIndex(reverse(S.Ord))\n      const f = (k: string, n: number): O.Option<number> => (k !== 'a' ? O.some(n) : O.none)\n      U.deepStrictEqual(TWI.traverseWithIndex(O.Applicative)({ b: 2 }, f), O.some({ b: 2 }))\n      U.deepStrictEqual(TWI.traverseWithIndex(O.Applicative)({ a: 1, b: 2 }, f), O.none)\n      // should respect the order\n      U.deepStrictEqual(\n        pipe(TWI.traverseWithIndex(O.Applicative)({ b: 2, c: 1 }, f), O.map(Object.keys)),\n        O.some(['c', 'b'])\n      )\n    })\n\n    it('wither', async () => {\n      const f = (n: number) => T.of(p(n) ? O.some(n + 1) : O.none)\n      const wither = _.wither(T.ApplicativePar)(f)\n      U.deepStrictEqual(await pipe({}, wither)(), {})\n      U.deepStrictEqual(await pipe({ a: 1, b: 3 }, wither)(), { b: 4 })\n\n      U.deepStrictEqual(await _.getWitherable(S.Ord).wither(T.ApplicativePar)({ a: 1, b: 3 }, f)(), { b: 4 })\n    })\n\n    it('wilt', async () => {\n      const wilt = _.wilt(T.ApplicativePar)((n: number) => T.of(p(n) ? E.right(n + 1) : E.left(n - 1)))\n      U.deepStrictEqual(await pipe({}, wilt)(), separated({}, {}))\n      U.deepStrictEqual(await pipe({ a: 1, b: 3 }, wilt)(), separated({ a: 0 }, { b: 4 }))\n    })\n  })\n\n  it('getMonoid', () => {\n    const d1 = { k1: 1, k2: 3 }\n    const d2 = { k2: 2, k3: 4 }\n    const M = _.getMonoid(N.SemigroupSum)\n    U.deepStrictEqual(M.concat(d1, d2), { k1: 1, k2: 5, k3: 4 })\n    U.deepStrictEqual(M.concat(d1, M.empty), d1)\n    U.deepStrictEqual(M.concat(M.empty, d2), d2)\n    U.deepStrictEqual(M.concat(d1, {}), d1)\n    // should ignore non own properties\n    const o = Object.create({ a: 1 })\n    o.k2 = 2\n    o.k3 = 4\n    U.deepStrictEqual(M.concat(d1, o), { k1: 1, k2: 5, k3: 4 })\n  })\n\n  it('getEq', () => {\n    U.deepStrictEqual(_.getEq(N.Eq).equals({ a: 1 }, { a: 1 }), true)\n    U.deepStrictEqual(_.getEq(N.Eq).equals({ a: 1 }, { a: 2 }), false)\n    U.deepStrictEqual(_.getEq(N.Eq).equals({ a: 1 }, { b: 1 }), false)\n    U.deepStrictEqual(_.getEq(N.Eq).equals(noPrototype, { b: 1 }), false)\n  })\n\n  it('lookup', () => {\n    U.deepStrictEqual(_.lookup('a', { a: 1 }), O.some(1))\n    U.deepStrictEqual(_.lookup('b', { a: 1 }), O.none)\n    U.deepStrictEqual(_.lookup('b', noPrototype), O.none)\n\n    U.deepStrictEqual(_.lookup('a')({ a: 1 }), O.some(1))\n    U.deepStrictEqual(_.lookup('b')({ a: 1 }), O.none)\n    U.deepStrictEqual(_.lookup('b')(noPrototype), O.none)\n  })\n\n  it('fromFoldable', () => {\n    const First = Se.first<number>()\n    U.deepStrictEqual(_.fromFoldable(First, RA.Foldable)([['a', 1]]), { a: 1 })\n    U.deepStrictEqual(\n      _.fromFoldable(\n        First,\n        RA.Foldable\n      )([\n        ['a', 1],\n        ['a', 2]\n      ]),\n      {\n        a: 1\n      }\n    )\n    const Last = Se.last<number>()\n    U.deepStrictEqual(\n      _.fromFoldable(\n        Last,\n        RA.Foldable\n      )([\n        ['a', 1],\n        ['a', 2]\n      ]),\n      {\n        a: 2\n      }\n    )\n  })\n\n  it('toReadonlyArray', () => {\n    U.deepStrictEqual(_.toReadonlyArray({ a: 1, b: 2 }), [\n      ['a', 1],\n      ['b', 2]\n    ])\n    U.deepStrictEqual(_.toReadonlyArray({ b: 2, a: 1 }), [\n      ['a', 1],\n      ['b', 2]\n    ])\n  })\n\n  it('toUnfoldable', () => {\n    U.deepStrictEqual(_.toUnfoldable(RA.Unfoldable)({ a: 1 }), [['a', 1]])\n  })\n\n  it('toEntries', () => {\n    U.deepStrictEqual(_.toEntries({ a: 1, b: 2 }), [\n      ['a', 1],\n      ['b', 2]\n    ])\n  })\n\n  it('fromEntries', () => {\n    U.deepStrictEqual(\n      _.fromEntries([\n        ['a', 1],\n        ['b', 2],\n        ['a', 3]\n      ]),\n      { b: 2, a: 3 }\n    )\n  })\n\n  it('traverseWithIndex should sort the keys', () => {\n    const log: Array<string> = []\n    const append =\n      (message: string): IO.IO<void> =>\n      () => {\n        log.push(message)\n      }\n\n    pipe(\n      { b: append('b'), a: append('a') },\n      _.traverseWithIndex(IO.Applicative)((_, io) => io)\n    )()\n    U.deepStrictEqual(log, ['a', 'b'])\n  })\n\n  it('size', () => {\n    U.deepStrictEqual(_.size({}), 0)\n    U.deepStrictEqual(_.size({ a: 1 }), 1)\n  })\n\n  it('isEmpty', () => {\n    U.deepStrictEqual(_.isEmpty(_.empty), true)\n    U.deepStrictEqual(_.isEmpty({}), true)\n    U.deepStrictEqual(_.isEmpty({ a: 1 }), false)\n    // should ignore non own properties\n    U.deepStrictEqual(_.isEmpty(Object.create({ a: 1 })), true)\n  })\n\n  it('insertAt', () => {\n    U.deepStrictEqual(_.insertAt('a', 1)({}), { a: 1 })\n    U.deepStrictEqual(_.insertAt('c', 3)({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 })\n    // should return the same reference if the value is already there\n    const x = { a: 1 }\n    U.deepStrictEqual(_.insertAt('a', 1)(x), x)\n  })\n\n  it('deleteAt', () => {\n    U.deepStrictEqual(_.deleteAt('a')({ a: 1, b: 2 }), { b: 2 })\n    // should return the same reference if the key is missing\n    const x = { a: 1 }\n    U.deepStrictEqual(_.deleteAt('b')(x), x)\n    U.deepStrictEqual(_.deleteAt('b')(noPrototype), noPrototype)\n  })\n\n  it('pop', () => {\n    assert.deepStrictEqual(_.pop('a')({ a: 1, b: 2 }), O.some([1, { b: 2 }]))\n    U.deepStrictEqual(_.pop('c')({ a: 1, b: 2 }), O.none)\n  })\n\n  it('every', () => {\n    const x: _.ReadonlyRecord<string, number> = { a: 1, b: 2 }\n    const y: _.ReadonlyRecord<string, number> = { a: 1, b: 2 }\n    U.deepStrictEqual(_.every((n: number) => n <= 2)(x), true)\n    U.deepStrictEqual(_.every((n: number) => n <= 1)(y), false)\n  })\n\n  it('some', () => {\n    const x: _.ReadonlyRecord<string, number> = { a: 1, b: 2 }\n    const y: _.ReadonlyRecord<string, number> = { a: 1, b: 2 }\n    U.deepStrictEqual(_.some((n: number) => n <= 1)(x), true)\n    U.deepStrictEqual(_.some((n: number) => n <= 0)(y), false)\n  })\n\n  it('elem', () => {\n    U.deepStrictEqual(_.elem(N.Eq)(1, { a: 1, b: 2 }), true)\n    U.deepStrictEqual(_.elem(N.Eq)(3, { a: 1, b: 2 }), false)\n\n    U.deepStrictEqual(_.elem(N.Eq)(1)({ a: 1, b: 2 }), true)\n    U.deepStrictEqual(_.elem(N.Eq)(3)({ a: 1, b: 2 }), false)\n  })\n\n  it('fromFoldableMap', () => {\n    const zipObject = <K extends string, A>(keys: ReadonlyArray<K>, values: ReadonlyArray<A>): _.ReadonlyRecord<K, A> =>\n      _.fromFoldableMap(Se.last<A>(), RA.Foldable)(RA.zip(keys, values), identity)\n\n    U.deepStrictEqual(zipObject(['a', 'b'], [1, 2, 3]), { a: 1, b: 2 })\n\n    interface User {\n      readonly id: string\n      readonly name: string\n    }\n\n    const users: ReadonlyArray<User> = [\n      { id: 'id1', name: 'name1' },\n      { id: 'id2', name: 'name2' },\n      { id: 'id1', name: 'name3' }\n    ]\n\n    U.deepStrictEqual(\n      _.fromFoldableMap(Se.last<User>(), RA.Foldable)(users, (user) => [user.id, user]),\n      {\n        id1: { id: 'id1', name: 'name3' },\n        id2: { id: 'id2', name: 'name2' }\n      }\n    )\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Ord)(S.Show)\n    U.deepStrictEqual(Sh.show({}), `{}`)\n    U.deepStrictEqual(Sh.show({ a: 'a' }), `{ \"a\": \"a\" }`)\n    U.deepStrictEqual(Sh.show({ a: 'a', b: 'b' }), `{ \"a\": \"a\", \"b\": \"b\" }`)\n\n    const DepSh = _.getShow(S.Show)\n    U.deepStrictEqual(DepSh.show({}), `{}`)\n    U.deepStrictEqual(DepSh.show({ a: 'a' }), `{ \"a\": \"a\" }`)\n    U.deepStrictEqual(DepSh.show({ a: 'a', b: 'b' }), `{ \"a\": \"a\", \"b\": \"b\" }`)\n  })\n\n  it('singleton', () => {\n    U.deepStrictEqual(_.singleton('a', 1), { a: 1 })\n  })\n\n  it('has', () => {\n    const x: _.ReadonlyRecord<string, number> = { a: 1 }\n    U.deepStrictEqual(_.has('a', x), true)\n    U.deepStrictEqual(_.has('b', x), false)\n    // TODO: remove in v3\n    // #1249\n    // eslint-disable-next-line no-prototype-builtins\n    U.deepStrictEqual(_.hasOwnProperty('a', x), true)\n    // eslint-disable-next-line no-prototype-builtins\n    U.deepStrictEqual(_.hasOwnProperty('b', x), false)\n    // eslint-disable-next-line deprecation/deprecation\n    const hasOwnProperty: any = _.hasOwnProperty\n    U.deepStrictEqual(hasOwnProperty.call(x, 'a'), true)\n    U.deepStrictEqual(hasOwnProperty.call(x, 'b'), false)\n  })\n\n  it('updateAt', () => {\n    const x: _.ReadonlyRecord<string, number> = { a: 1 }\n    U.deepStrictEqual(_.updateAt('b', 2)(x), O.none)\n    U.deepStrictEqual(_.updateAt('a', 2)(x), O.some({ a: 2 }))\n    const r = _.updateAt('a', 1)(x)\n    if (O.isSome(r)) {\n      U.deepStrictEqual(r.value, x)\n    } else {\n      assert.fail()\n    }\n  })\n\n  it('modifyAt', () => {\n    const x: _.ReadonlyRecord<string, number> = { a: 1 }\n    U.deepStrictEqual(_.modifyAt('b', (n: number) => n * 2)(x), O.none)\n    U.deepStrictEqual(_.modifyAt('a', (n: number) => n * 2)(x), O.some({ a: 2 }))\n    // should return the same reference if nothing changed\n    const input: _.ReadonlyRecord<string, number> = { a: 1 }\n    U.deepStrictEqual(\n      pipe(\n        input,\n        _.modifyAt('a', identity),\n        O.map((out) => out === input)\n      ),\n      O.some(true)\n    )\n  })\n\n  it('fromRecord', () => {\n    const as = { a: 1, b: 2 }\n    const bs = _.fromRecord(as)\n    U.deepStrictEqual(bs, as)\n    assert.notStrictEqual(bs, as)\n  })\n\n  it('toRecord', () => {\n    const as: _.ReadonlyRecord<string, number> = { a: 1, b: 2 }\n    const bs = _.toRecord(as)\n    U.deepStrictEqual(bs, as)\n    assert.notStrictEqual(bs, as)\n  })\n\n  it('getUnionMonoid', () => {\n    const M = _.getUnionMonoid(S.Semigroup)\n    const x: _.ReadonlyRecord<string, string> = {\n      a: 'a1',\n      b: 'b1',\n      c: 'c1'\n    }\n    const y: _.ReadonlyRecord<string, string> = {\n      b: 'b2',\n      c: 'c2',\n      d: 'd2'\n    }\n    U.strictEqual(M.concat(x, M.empty), x)\n    U.strictEqual(M.concat(M.empty, x), x)\n    U.strictEqual(M.concat(x, {}), x)\n    U.strictEqual(M.concat({}, x), x)\n    U.deepStrictEqual(M.concat(x, y), {\n      a: 'a1',\n      b: 'b1b2',\n      c: 'c1c2',\n      d: 'd2'\n    })\n  })\n\n  it('getIntersectionSemigroup', () => {\n    const M = _.getIntersectionSemigroup(S.Semigroup)\n    const x: _.ReadonlyRecord<string, string> = {\n      a: 'a1',\n      b: 'b1',\n      c: 'c1'\n    }\n    const y: _.ReadonlyRecord<string, string> = {\n      b: 'b2',\n      c: 'c2',\n      d: 'd2'\n    }\n    U.strictEqual(M.concat(x, _.empty), _.empty)\n    U.strictEqual(M.concat(x, _.empty), _.empty)\n    U.strictEqual(M.concat(x, {}), _.empty)\n    U.strictEqual(M.concat(x, {}), _.empty)\n    U.deepStrictEqual(M.concat(x, y), {\n      b: 'b1b2',\n      c: 'c1c2'\n    })\n  })\n\n  it('getDifferenceMagma', () => {\n    const M = _.getDifferenceMagma<string>()\n    const x: _.ReadonlyRecord<string, string> = {\n      a: 'a1',\n      b: 'b1',\n      c: 'c1'\n    }\n    const y: _.ReadonlyRecord<string, string> = {\n      b: 'b2',\n      c: 'c2',\n      d: 'd2'\n    }\n    U.strictEqual(M.concat(_.empty, x), x)\n    U.strictEqual(M.concat(x, _.empty), x)\n    U.strictEqual(M.concat({}, x), x)\n    U.strictEqual(M.concat(x, {}), x)\n    U.deepStrictEqual(M.concat(x, y), {\n      a: 'a1',\n      d: 'd2'\n    })\n  })\n\n  it('mapWithIndex', () => {\n    // should ignore non own properties\n    const o: _.ReadonlyRecord<string, number> = Object.create({ a: 1 })\n    U.deepStrictEqual(\n      pipe(\n        o,\n        _.mapWithIndex((_, a) => U.double(a))\n      ),\n      {}\n    )\n  })\n})\n"
  },
  {
    "path": "test/ReadonlySet.ts",
    "content": "import * as assert from 'assert'\n\nimport { getMonoid } from '../src/Array'\nimport { left, right } from '../src/Either'\nimport * as Eq from '../src/Eq'\nimport { pipe } from '../src/function'\nimport * as N from '../src/number'\nimport { none, some as optionSome } from '../src/Option'\nimport * as _ from '../src/ReadonlySet'\nimport { separated } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as U from './util'\n\nconst gte2 = (n: number) => n >= 2\n\ninterface Foo {\n  readonly x: string\n}\nconst foo = (x: string): Foo => ({ x })\nconst fooEq: Eq.Eq<Foo> = {\n  equals: (a: Foo, b: Foo) => a.x === b.x\n}\n\ndescribe('ReadonlySet', () => {\n  it('toReadonlyArray', () => {\n    U.deepStrictEqual(_.toReadonlyArray(N.Ord)(new Set()), [])\n    U.deepStrictEqual(_.toReadonlyArray(N.Ord)(new Set([1, 2, 3])), [1, 2, 3])\n    U.deepStrictEqual(_.toReadonlyArray(N.Ord)(new Set([3, 2, 1])), [1, 2, 3])\n  })\n\n  it('getEq', () => {\n    const E = _.getEq(N.Eq)\n    U.deepStrictEqual(E.equals(new Set([1, 2, 3]), new Set([1, 2, 3])), true)\n    U.deepStrictEqual(E.equals(new Set([1, 2, 3]), new Set([1, 2])), false)\n    U.deepStrictEqual(E.equals(new Set([1, 2]), new Set([1, 2, 3])), false)\n  })\n\n  it('some', () => {\n    U.deepStrictEqual(_.some((s: string) => s.trim() === '')(new Set<string>()), false)\n    U.deepStrictEqual(_.some(gte2)(new Set([1, 2, 3])), true)\n    U.deepStrictEqual(_.some(gte2)(new Set([1])), false)\n  })\n\n  it('map', () => {\n    U.deepStrictEqual(_.map(N.Eq)((n: number) => n % 2)(new Set([])), new Set([]))\n    U.deepStrictEqual(_.map(N.Eq)((n: number) => n % 2)(new Set([1, 2, 3, 4])), new Set([0, 1]))\n    U.deepStrictEqual(_.map(S.Eq)((n: number) => `${n % 2}`)(new Set([1, 2, 3, 4])), new Set(['0', '1']))\n  })\n\n  it('every', () => {\n    U.deepStrictEqual(_.every(gte2)(new Set([1, 2, 3])), false)\n    U.deepStrictEqual(_.every(gte2)(new Set([2, 3])), true)\n  })\n\n  it('chain', () => {\n    U.deepStrictEqual(_.chain(S.Eq)((n: number) => new Set([n.toString()]))(new Set([])), new Set([]))\n    U.deepStrictEqual(_.chain(S.Eq)(() => new Set([]))(new Set([1, 2])), new Set([]))\n    U.deepStrictEqual(\n      _.chain(S.Eq)((n: number) => new Set([`${n}`, `${n + 1}`]))(new Set([1, 2])),\n      new Set(['1', '2', '3'])\n    )\n  })\n\n  it('isSubset', () => {\n    U.deepStrictEqual(_.isSubset(N.Eq)(new Set([1, 2]), new Set([1, 2, 3])), true)\n    U.deepStrictEqual(_.isSubset(N.Eq)(new Set([1, 2, 4]), new Set([1, 2, 3])), false)\n\n    U.deepStrictEqual(pipe(new Set([1, 2]), _.isSubset(N.Eq)(new Set([1, 2, 3]))), true)\n    U.deepStrictEqual(pipe(new Set([1, 2, 4]), _.isSubset(N.Eq)(new Set([1, 2, 3]))), false)\n  })\n\n  it('filter', () => {\n    U.deepStrictEqual(_.filter(gte2)(new Set([1, 2, 3])), new Set([2, 3]))\n\n    // refinements\n    const isNumber = (u: string | number): u is number => typeof u === 'number'\n    const actual = _.filter(isNumber)(new Set([1, 'a', 2]))\n    U.deepStrictEqual(actual, new Set([1, 2]))\n  })\n\n  it('partition', () => {\n    U.deepStrictEqual(_.partition(() => true)(new Set([])), separated(new Set([]), new Set([])))\n    U.deepStrictEqual(_.partition(() => true)(new Set([1])), separated(new Set([]), new Set([1])))\n    U.deepStrictEqual(_.partition(() => false)(new Set([1])), separated(new Set([1]), new Set([])))\n    U.deepStrictEqual(\n      _.partition((n: number) => n % 2 === 0)(new Set([1, 2, 3, 4])),\n      separated(new Set([1, 3]), new Set([2, 4]))\n    )\n\n    // refinements\n    const isNumber = (u: string | number): u is number => typeof u === 'number'\n    const actual = _.partition(isNumber)(new Set([1, 'a', 2]))\n    U.deepStrictEqual(actual, separated(new Set(['a']), new Set([1, 2])))\n  })\n\n  it('union', () => {\n    U.deepStrictEqual(_.union(N.Eq)(new Set([1, 2]), new Set([1, 3])), new Set([1, 2, 3]))\n\n    U.deepStrictEqual(pipe(new Set([1, 2]), _.union(N.Eq)(new Set([1, 3]))), new Set([1, 2, 3]))\n  })\n\n  it('intersection', () => {\n    U.deepStrictEqual(_.intersection(N.Eq)(new Set([1, 2]), new Set([1, 3])), new Set([1]))\n\n    U.deepStrictEqual(pipe(new Set([1, 2]), _.intersection(N.Eq)(new Set([1, 3]))), new Set([1]))\n  })\n\n  it('partitionMap', () => {\n    U.deepStrictEqual(\n      _.partitionMap(N.Eq, S.Eq)((n: number) => left(n))(new Set([])),\n      separated(new Set([]), new Set([]))\n    )\n    U.deepStrictEqual(\n      _.partitionMap(N.Eq, S.Eq)((n: number) => (n % 2 === 0 ? left(n) : right(`${n}`)))(new Set([1, 2, 3])),\n      separated(new Set([2]), new Set(['1', '3']))\n    )\n    const SL = Eq.struct({ value: N.Eq })\n    const SR = Eq.struct({ value: S.Eq })\n    U.deepStrictEqual(\n      _.partitionMap(\n        SL,\n        SR\n      )((x: { readonly value: number }) => (x.value % 2 === 0 ? left({ value: 2 }) : right({ value: 'odd' })))(\n        new Set([{ value: 1 }, { value: 2 }, { value: 3 }, { value: 4 }])\n      ),\n      separated(new Set([{ value: 2 }]), new Set([{ value: 'odd' }]))\n    )\n  })\n\n  it('getUnionMonoid', () => {\n    const M = _.getUnionMonoid(N.Eq)\n    U.deepStrictEqual(M.concat(new Set([1, 2]), new Set([1, 3])), new Set([1, 2, 3]))\n    U.deepStrictEqual(M.concat(new Set([1, 2]), M.empty), new Set([1, 2]))\n    U.deepStrictEqual(M.concat(M.empty, new Set([1, 3])), new Set([1, 3]))\n  })\n\n  it('getIntersectionSemigroup', () => {\n    const IS = _.getIntersectionSemigroup(N.Eq)\n    U.deepStrictEqual(IS.concat(new Set([1, 2]), new Set([1, 3])), new Set([1]))\n    U.deepStrictEqual(IS.concat(new Set([1, 2]), _.empty), _.empty)\n    U.deepStrictEqual(IS.concat(_.empty, new Set([1, 3])), _.empty)\n  })\n\n  it('getDifferenceMagma', () => {\n    const M = _.getDifferenceMagma(N.Eq)\n    U.deepStrictEqual(M.concat(new Set([1, 2]), new Set([1, 3])), new Set([2]))\n  })\n\n  it('difference', () => {\n    U.deepStrictEqual(_.difference(N.Eq)(new Set([1, 2]), new Set([1, 3])), new Set([2]))\n\n    U.deepStrictEqual(pipe(new Set([1, 2]), _.difference(N.Eq)(new Set([1, 3]))), new Set([2]))\n  })\n\n  it('reduce', () => {\n    U.deepStrictEqual(_.reduce(N.Ord)('', (b, a) => b + a)(new Set([1, 2, 3])), '123')\n    U.deepStrictEqual(_.reduce(N.Ord)('', (b, a) => b + a)(new Set([3, 2, 1])), '123')\n  })\n\n  it('foldMap', () => {\n    U.deepStrictEqual(_.foldMap(N.Ord, getMonoid<number>())((a) => [a])(new Set([1, 2, 3])), [1, 2, 3])\n    U.deepStrictEqual(_.foldMap(N.Ord, getMonoid<number>())((a) => [a])(new Set([3, 2, 1])), [1, 2, 3])\n  })\n\n  it('reduceRight', () => {\n    const f = _.reduceRight(N.Ord)('', (a, b) => b + a)\n    U.deepStrictEqual(f(new Set([1, 2, 3])), '321')\n    U.deepStrictEqual(f(new Set([3, 2, 1])), '321')\n  })\n\n  it('singleton', () => {\n    U.deepStrictEqual(_.singleton(1), new Set([1]))\n  })\n\n  it('insert', () => {\n    const x = new Set([1, 2])\n    U.deepStrictEqual(_.insert(N.Eq)(3)(x), new Set([1, 2, 3]))\n    // should return the same ference if the element is already a member\n    U.deepStrictEqual(_.insert(N.Eq)(2)(x), x)\n  })\n\n  it('remove', () => {\n    U.deepStrictEqual(_.remove(N.Eq)(3)(new Set([1, 2])), new Set([1, 2]))\n    U.deepStrictEqual(_.remove(N.Eq)(1)(new Set([1, 2])), new Set([2]))\n  })\n\n  it('fromArray', () => {\n    U.deepStrictEqual(_.fromArray(N.Eq)([]), new Set([]))\n    U.deepStrictEqual(_.fromArray(N.Eq)([1]), new Set([1]))\n    U.deepStrictEqual(_.fromArray(N.Eq)([1, 1]), new Set([1]))\n    U.deepStrictEqual(_.fromArray(N.Eq)([1, 2]), new Set([1, 2]))\n    U.deepStrictEqual(_.fromArray(fooEq)(['a', 'a', 'b'].map(foo)), new Set(['a', 'b'].map(foo)))\n  })\n\n  it('compact', () => {\n    U.deepStrictEqual(_.compact(N.Eq)(new Set([optionSome(1), none, optionSome(2)])), new Set([1, 2]))\n    type R = { readonly id: string }\n    const E: Eq.Eq<R> = pipe(\n      S.Eq,\n      Eq.contramap((x) => x.id)\n    )\n    U.deepStrictEqual(\n      _.compact(E)(new Set([optionSome({ id: 'a' }), none, optionSome({ id: 'a' })])),\n      new Set([{ id: 'a' }])\n    )\n  })\n\n  it('separate', () => {\n    U.deepStrictEqual(\n      _.separate(S.Eq, N.Eq)(new Set([right(1), left('a'), right(2)])),\n      separated(new Set(['a']), new Set([1, 2]))\n    )\n    type L = { readonly error: string }\n    type R = { readonly id: string }\n    const SL: Eq.Eq<L> = pipe(\n      S.Eq,\n      Eq.contramap((x) => x.error)\n    )\n    const SR: Eq.Eq<R> = pipe(\n      S.Eq,\n      Eq.contramap((x) => x.id)\n    )\n    U.deepStrictEqual(\n      _.separate(\n        SL,\n        SR\n      )(new Set([right({ id: 'a' }), left({ error: 'error' }), right({ id: 'a' }), left({ error: 'error' })])),\n      separated(new Set([{ error: 'error' }]), new Set([{ id: 'a' }]))\n    )\n  })\n\n  it('filterMap', () => {\n    U.deepStrictEqual(\n      _.filterMap(N.Eq)((s: string) => (s.length > 1 ? optionSome(s.length) : none))(new Set(['a', 'bb', 'ccc'])),\n      new Set([2, 3])\n    )\n    type R = { readonly id: string }\n    const E: Eq.Eq<R> = pipe(\n      S.Eq,\n      Eq.contramap((x) => x.id)\n    )\n    U.deepStrictEqual(\n      _.filterMap(E)((x: { readonly id: string }) => optionSome(x))(new Set([{ id: 'a' }, { id: 'a' }])),\n      new Set([{ id: 'a' }])\n    )\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    const s1 = new Set<string>([])\n    U.deepStrictEqual(Sh.show(s1), `new Set([])`)\n    const s2 = new Set<string>(['a'])\n    U.deepStrictEqual(Sh.show(s2), `new Set([\"a\"])`)\n    const s3 = new Set<string>(['b', 'a'])\n    U.deepStrictEqual(Sh.show(s3), `new Set([\"a\", \"b\"])`)\n  })\n\n  it('fromSet', () => {\n    const as = new Set(['a'])\n    const bs = _.fromSet(as)\n    U.deepStrictEqual(bs, as)\n    assert.notStrictEqual(bs, as)\n  })\n\n  it('toSet', () => {\n    const as: ReadonlySet<string> = new Set(['a'])\n    const bs = _.toSet(as)\n    U.deepStrictEqual(bs, as)\n    assert.notStrictEqual(bs, as)\n  })\n\n  it('isEmpty', () => {\n    U.deepStrictEqual(_.isEmpty(_.empty), true)\n    U.deepStrictEqual(_.isEmpty(new Set()), true)\n    U.deepStrictEqual(_.isEmpty(new Set(['a'])), false)\n  })\n\n  it('size', () => {\n    U.deepStrictEqual(_.size(_.empty), 0)\n    U.deepStrictEqual(_.size(new Set()), 0)\n    U.deepStrictEqual(_.size(new Set(['a'])), 1)\n  })\n\n  it('toggle', () => {\n    U.deepStrictEqual(_.toggle(N.Eq)(1)(new Set([2])), new Set([1, 2]))\n    U.deepStrictEqual(_.toggle(N.Eq)(1)(new Set([1, 2])), new Set([2]))\n  })\n})\n"
  },
  {
    "path": "test/ReadonlyTuple.ts",
    "content": "import * as assert from 'assert'\n\nimport { getMonoid } from '../src/Array'\nimport { left, right } from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as O from '../src/Option'\nimport * as _ from '../src/ReadonlyTuple'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('ReadonlyTuple', () => {\n  describe('pipeables', () => {\n    it('compose', () => {\n      U.deepStrictEqual(pipe([true, 2] as const, _.compose([1, 'a'])), [true, 'a'])\n    })\n\n    it('mapFst', () => {\n      U.deepStrictEqual(pipe([1, 'a'] as const, _.mapFst(U.double)), [2, 'a'])\n    })\n\n    it('extract', () => {\n      U.deepStrictEqual(pipe([1, 'a'] as const, _.extract), 1)\n    })\n\n    it('extend', () => {\n      const f = (fa: readonly [number, string]): number => _.snd(fa).length + _.fst(fa)\n      U.deepStrictEqual(pipe([1, 'bb'], _.extend(f)), [3, 'bb'])\n    })\n\n    it('bimap', () => {\n      U.deepStrictEqual(pipe([1, 'a'], _.bimap(S.size, U.double)), [2, 1])\n    })\n\n    it('mapSnd', () => {\n      U.deepStrictEqual(pipe([1, 'a'] as const, _.mapSnd(S.size)), [1, 1])\n    })\n\n    it('duplicate', () => {\n      U.deepStrictEqual(pipe([1, 'a'] as const, _.duplicate), [[1, 'a'], 'a'])\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['b', 1] as const,\n          _.reduce('a', (acc, a) => acc + a)\n        ),\n        'ab'\n      )\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe(['a', 1] as const, _.foldMap(S.Monoid)(identity)), 'a')\n    })\n\n    it('reduceRight', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['b', 1] as const,\n          _.reduceRight('a', (acc, a) => acc + a)\n        ),\n        'ba'\n      )\n    })\n\n    it('traverse', () => {\n      const traverse = _.traverse(O.Applicative)((n: number) => (n > 1 ? O.some(n) : O.none))\n      assert.deepStrictEqual(traverse([2, 'a']), O.some([2, 'a']))\n      U.deepStrictEqual(traverse([1, 'a']), O.none)\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      assert.deepStrictEqual(sequence([O.some(1), 'a']), O.some([1, 'a']))\n      U.deepStrictEqual(sequence([O.none, 'a']), O.none)\n    })\n  })\n\n  it('swap', () => {\n    U.deepStrictEqual(_.swap([1, 'a']), ['a', 1])\n  })\n\n  it('getApply', () => {\n    const apply = _.getApply(S.Monoid)\n    U.deepStrictEqual(apply.ap([U.double, 'a'], [1, 'b']), [2, 'ab'])\n  })\n\n  it('getApplicative', () => {\n    const applicative = _.getApplicative(S.Monoid)\n    U.deepStrictEqual(applicative.of(1), [1, ''])\n  })\n\n  it('getMonad', () => {\n    const monad = _.getMonad(S.Monoid)\n    U.deepStrictEqual(\n      monad.chain([1, 'a'], (a) => [a * 2, 'b']),\n      [2, 'ab']\n    )\n  })\n\n  it('chainRec', () => {\n    const { chainRec } = _.getChainRec(getMonoid<number>())\n    function seqReq(upper: number): readonly [number, ReadonlyArray<number>] {\n      return chainRec(1, (init) => [init >= upper ? right(init) : left(init + 1), [init]])\n    }\n    const xs = _.snd(seqReq(10000))\n    U.deepStrictEqual(xs.length, 10000)\n    U.deepStrictEqual(xs[0], 1)\n    U.deepStrictEqual(xs[xs.length - 1], 10000)\n  })\n})\n"
  },
  {
    "path": "test/Record.ts",
    "content": "import * as assert from 'assert'\n\nimport * as A from '../src/Array'\nimport { left, right } from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as IO from '../src/IO'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport { reverse } from '../src/Ord'\nimport * as _ from '../src/Record'\nimport * as Se from '../src/Semigroup'\nimport { separated } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as U from './util'\n\nconst p = (n: number) => n > 2\n\nconst noPrototype = Object.create(null)\n\ndescribe('Record', () => {\n  describe('pipeables', () => {\n    it('collect', () => {\n      const x: { readonly a: string; readonly b: boolean } = { a: 'c', b: false }\n      U.deepStrictEqual(_.collect(S.Ord)((key, val) => ({ key: key, value: val }))(x), [\n        { key: 'a', value: 'c' },\n        { key: 'b', value: false }\n      ])\n      U.deepStrictEqual(_.collect((key, val) => ({ key: key, value: val }))(x), [\n        { key: 'a', value: 'c' },\n        { key: 'b', value: false }\n      ])\n    })\n\n    it('map', () => {\n      U.deepStrictEqual(pipe({ k1: 1, k2: 2 }, _.map(U.double)), { k1: 2, k2: 4 })\n      U.deepStrictEqual(pipe({ a: 1, b: 2 }, _.map(U.double)), { a: 2, b: 4 })\n    })\n\n    it('mapWithIndex', () => {\n      const doubleWithIndex = (_: string, n: number): number => n * 2\n      U.deepStrictEqual(pipe({ a: 1, b: 2 }, _.mapWithIndex(doubleWithIndex)), { a: 2, b: 4 })\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduce(S.Ord)('', (b, a) => b + a)\n        ),\n        'ab'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k2: 'b', k1: 'a' },\n          _.reduce(S.Ord)('', (b, a) => b + a)\n        ),\n        'ab'\n      )\n\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduce('', (b, a) => b + a)\n        ),\n        'ab'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k2: 'b', k1: 'a' },\n          _.reduce('', (b, a) => b + a)\n        ),\n        'ab'\n      )\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe({ a: 'a', b: 'b' }, _.foldMap(S.Ord)(S.Monoid)(identity)), 'ab')\n      U.deepStrictEqual(_.getFoldable(S.Ord).foldMap(S.Monoid)({ a: 'a', b: 'b' }, identity), 'ab')\n\n      U.deepStrictEqual(pipe({ a: 'a', b: 'b' }, _.foldMap(S.Monoid)(identity)), 'ab')\n      U.deepStrictEqual(_.Foldable.foldMap(S.Monoid)({ a: 'a', b: 'b' }, identity), 'ab')\n    })\n\n    it('reduceRight', () => {\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(pipe({ a: 'a', b: 'b' }, _.reduceRight(S.Ord)('', f)), 'ba')\n      U.deepStrictEqual(pipe({ a: 'a', b: 'b' }, _.reduceRight('', f)), 'ba')\n    })\n\n    it('compact', () => {\n      U.deepStrictEqual(_.compact({ foo: O.none, bar: O.some(123) }), { bar: 123 })\n    })\n\n    it('separate', () => {\n      U.deepStrictEqual(_.separate({ foo: left(123), bar: right(123) }), separated({ foo: 123 }, { bar: 123 }))\n    })\n\n    it('filter', () => {\n      const d = { a: 1, b: 3 }\n      U.deepStrictEqual(pipe(d, _.filter(p)), { b: 3 })\n\n      // refinements\n      const isNumber = (u: string | number): u is number => typeof u === 'number'\n      const y: Record<string, string | number> = { a: 1, b: 'foo' }\n      const actual = pipe(y, _.filter(isNumber))\n      U.deepStrictEqual(actual, { a: 1 })\n      U.deepStrictEqual(\n        pipe(\n          y,\n          _.filter((_) => true)\n        ),\n        y\n      )\n\n      const x = Object.assign(Object.create({ c: true }), { a: 1, b: 'foo' })\n      U.deepStrictEqual(pipe(x, _.filter(isNumber)), { a: 1 })\n      U.deepStrictEqual(pipe(noPrototype, _.filter(isNumber)), noPrototype)\n    })\n\n    it('filterMap', () => {\n      const f = (n: number) => (p(n) ? O.some(n + 1) : O.none)\n      U.deepStrictEqual(pipe({}, _.filterMap(f)), {})\n      U.deepStrictEqual(pipe({ a: 1, b: 3 }, _.filterMap(f)), { b: 4 })\n    })\n\n    it('partition', () => {\n      U.deepStrictEqual(pipe({}, _.partition(p)), separated({}, {}))\n      U.deepStrictEqual(pipe({ a: 1, b: 3 }, _.partition(p)), separated({ a: 1 }, { b: 3 }))\n    })\n\n    it('partitionMap', () => {\n      const f = (n: number) => (p(n) ? right(n + 1) : left(n - 1))\n      U.deepStrictEqual(pipe({}, _.partitionMap(f)), separated({}, {}))\n      U.deepStrictEqual(pipe({ a: 1, b: 3 }, _.partitionMap(f)), separated({ a: 0 }, { b: 4 }))\n    })\n\n    it('reduceWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduceWithIndex(S.Ord)('', (k, b, a) => b + k + a)\n        ),\n        'k1ak2b'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k2: 'b', k1: 'a' },\n          _.reduceWithIndex(S.Ord)('', (k, b, a) => b + k + a)\n        ),\n        'k1ak2b'\n      )\n\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduceWithIndex('', (k, b, a) => b + k + a)\n        ),\n        'k1ak2b'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k2: 'b', k1: 'a' },\n          _.reduceWithIndex('', (k, b, a) => b + k + a)\n        ),\n        'k1ak2b'\n      )\n    })\n\n    it('foldMapWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.foldMapWithIndex(S.Ord)(S.Monoid)((k, a) => k + a)\n        ),\n        'k1ak2b'\n      )\n      U.deepStrictEqual(\n        _.getFoldableWithIndex(S.Ord).foldMapWithIndex(S.Monoid)({ k1: 'a', k2: 'b' }, (k, a) => k + a),\n        'k1ak2b'\n      )\n\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.foldMapWithIndex(S.Monoid)((k, a) => k + a)\n        ),\n        'k1ak2b'\n      )\n      U.deepStrictEqual(\n        _.FoldableWithIndex.foldMapWithIndex(S.Monoid)({ k1: 'a', k2: 'b' }, (k, a) => k + a),\n        'k1ak2b'\n      )\n    })\n\n    it('reduceRightWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduceRightWithIndex(S.Ord)('', (k, a, b) => b + k + a)\n        ),\n        'k2bk1a'\n      )\n      U.deepStrictEqual(\n        pipe(\n          { k1: 'a', k2: 'b' },\n          _.reduceRightWithIndex('', (k, a, b) => b + k + a)\n        ),\n        'k2bk1a'\n      )\n    })\n\n    it('partitionMapWithIndex', () => {\n      assert.deepStrictEqual(\n        pipe(\n          { a: 1, b: 2 },\n          _.partitionMapWithIndex((k, a: number) => (a > 1 ? right(a) : left(k)))\n        ),\n        separated({ a: 'a' }, { b: 2 })\n      )\n    })\n\n    it('partitionWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { a: 1, b: 2 },\n          _.partitionWithIndex((_, a: number) => a > 1)\n        ),\n        separated({ a: 1 }, { b: 2 })\n      )\n    })\n\n    it('filterMapWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { a: 1, b: 2 },\n          _.filterMapWithIndex((_, a: number) => (a > 1 ? O.some(a) : O.none))\n        ),\n        { b: 2 }\n      )\n    })\n\n    it('filterWithIndex', () => {\n      U.deepStrictEqual(\n        pipe(\n          { a: 1, b: 2 },\n          _.filterWithIndex((_, a: number) => a > 1)\n        ),\n        { b: 2 }\n      )\n    })\n\n    it('traverse', () => {\n      U.deepStrictEqual(\n        _.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      U.deepStrictEqual(_.traverse(O.Applicative)((n: number) => (n >= 2 ? O.some(n) : O.none))({ a: 1, b: 2 }), O.none)\n    })\n\n    it('getTraversable', () => {\n      const T = _.getTraversable(reverse(S.Ord))\n      const f = (n: number) => (n <= 2 ? O.some(n) : O.none)\n      U.deepStrictEqual(T.traverse(O.Applicative)({ a: 1, b: 2 }, f), O.some({ a: 1, b: 2 }))\n      U.deepStrictEqual(T.traverse(O.Applicative)({ a: 1, b: 3 }, f), O.none)\n      // should respect the order\n      U.deepStrictEqual(pipe(T.traverse(O.Applicative)({ b: 2, a: 1 }, f), O.map(Object.keys)), O.some(['b', 'a']))\n      U.deepStrictEqual(\n        pipe(T.sequence(O.Applicative)({ b: O.some(2), a: O.some(1) }), O.map(Object.keys)),\n        O.some(['b', 'a'])\n      )\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      U.deepStrictEqual(sequence({ a: O.some(1), b: O.some(2) }), O.some({ a: 1, b: 2 }))\n      U.deepStrictEqual(sequence({ a: O.none, b: O.some(2) }), O.none)\n\n      U.deepStrictEqual(_.record.sequence(O.Applicative)({ a: O.some(1), b: O.some(2) }), O.some({ a: 1, b: 2 }))\n    })\n\n    it('traverseWithIndex', () => {\n      const f = (k: string, n: number): O.Option<number> => (k !== 'a' ? O.some(n) : O.none)\n      const traverseWithIndex = _.traverseWithIndex(O.Applicative)(f)\n      U.deepStrictEqual(pipe({ a: 1, b: 2 }, traverseWithIndex), O.none)\n      U.deepStrictEqual(pipe({ b: 2 }, traverseWithIndex), O.some({ b: 2 }))\n      U.deepStrictEqual(pipe({}, traverseWithIndex), O.some({}))\n    })\n\n    it('getTraversableWithIndex', () => {\n      const TWI = _.getTraversableWithIndex(reverse(S.Ord))\n      const f = (k: string, n: number): O.Option<number> => (k !== 'a' ? O.some(n) : O.none)\n      U.deepStrictEqual(TWI.traverseWithIndex(O.Applicative)({ b: 2 }, f), O.some({ b: 2 }))\n      U.deepStrictEqual(TWI.traverseWithIndex(O.Applicative)({ a: 1, b: 2 }, f), O.none)\n      U.deepStrictEqual(TWI.traverseWithIndex(O.Applicative)({}, f), O.some({}))\n      // should respect the order\n      U.deepStrictEqual(\n        pipe(TWI.traverseWithIndex(O.Applicative)({ b: 2, c: 1 }, f), O.map(Object.keys)),\n        O.some(['c', 'b'])\n      )\n    })\n\n    it('wither', async () => {\n      const f = (n: number) => T.of(p(n) ? O.some(n + 1) : O.none)\n      const wither = _.wither(T.ApplicativePar)(f)\n      U.deepStrictEqual(await pipe({}, wither)(), {})\n      U.deepStrictEqual(await pipe({ a: 1, b: 3 }, wither)(), { b: 4 })\n\n      U.deepStrictEqual(await _.getWitherable(S.Ord).wither(T.ApplicativePar)({ a: 1, b: 3 }, f)(), { b: 4 })\n    })\n\n    it('wilt', async () => {\n      const wilt = _.wilt(T.ApplicativePar)((n: number) => T.of(p(n) ? right(n + 1) : left(n - 1)))\n      U.deepStrictEqual(await pipe({}, wilt)(), separated({}, {}))\n      U.deepStrictEqual(await pipe({ a: 1, b: 3 }, wilt)(), separated({ a: 0 }, { b: 4 }))\n    })\n  })\n\n  it('getMonoid', () => {\n    const d1 = { k1: 1, k2: 3 }\n    const d2 = { k2: 2, k3: 4 }\n    const M = _.getMonoid(N.SemigroupSum)\n    U.deepStrictEqual(M.concat(d1, d2), { k1: 1, k2: 5, k3: 4 })\n    U.deepStrictEqual(M.concat(d1, M.empty), d1)\n    U.deepStrictEqual(M.concat(M.empty, d2), d2)\n    U.deepStrictEqual(M.concat(d1, {}), d1)\n  })\n\n  it('getEq', () => {\n    U.deepStrictEqual(_.getEq(N.Eq).equals({ a: 1 }, { a: 1 }), true)\n    U.deepStrictEqual(_.getEq(N.Eq).equals({ a: 1 }, { a: 2 }), false)\n    U.deepStrictEqual(_.getEq(N.Eq).equals({ a: 1 }, { b: 1 }), false)\n    U.deepStrictEqual(_.getEq(N.Eq).equals(noPrototype, { b: 1 }), false)\n  })\n\n  it('lookup', () => {\n    U.deepStrictEqual(_.lookup('a', { a: 1 }), O.some(1))\n    U.deepStrictEqual(_.lookup('b', { a: 1 }), O.none)\n    U.deepStrictEqual(_.lookup('b', noPrototype), O.none)\n\n    U.deepStrictEqual(_.lookup('a')({ a: 1 }), O.some(1))\n    U.deepStrictEqual(_.lookup('b')({ a: 1 }), O.none)\n    U.deepStrictEqual(_.lookup('b')(noPrototype), O.none)\n  })\n\n  it('fromFoldable', () => {\n    const First = Se.first<number>()\n    U.deepStrictEqual(_.fromFoldable(First, A.Foldable)([['a', 1]]), { a: 1 })\n    U.deepStrictEqual(\n      _.fromFoldable(\n        First,\n        A.Foldable\n      )([\n        ['a', 1],\n        ['a', 2]\n      ]),\n      {\n        a: 1\n      }\n    )\n    const Last = Se.last<number>()\n    U.deepStrictEqual(\n      _.fromFoldable(\n        Last,\n        A.Foldable\n      )([\n        ['a', 1],\n        ['a', 2]\n      ]),\n      {\n        a: 2\n      }\n    )\n  })\n\n  it('toUnfoldable', () => {\n    U.deepStrictEqual(_.toUnfoldable(A.Unfoldable)({ a: 1 }), [['a', 1]])\n  })\n\n  it('toEntries', () => {\n    U.deepStrictEqual(_.toEntries({ a: 1, b: 2 }), [\n      ['a', 1],\n      ['b', 2]\n    ])\n  })\n\n  it('fromEntries', () => {\n    U.deepStrictEqual(\n      _.fromEntries([\n        ['a', 1],\n        ['b', 2],\n        ['a', 3]\n      ]),\n      { b: 2, a: 3 }\n    )\n  })\n\n  it('traverseWithIndex should sort the keys', () => {\n    const log: Array<string> = []\n    const append =\n      (message: string): IO.IO<void> =>\n      () => {\n        log.push(message)\n      }\n\n    pipe(\n      { b: append('b'), a: append('a') },\n      _.traverseWithIndex(IO.Applicative)((_, io) => io)\n    )()\n    U.deepStrictEqual(log, ['a', 'b'])\n  })\n\n  it('size', () => {\n    U.deepStrictEqual(_.size({}), 0)\n    U.deepStrictEqual(_.size({ a: 1 }), 1)\n  })\n\n  it('isEmpty', () => {\n    U.deepStrictEqual(_.isEmpty({}), true)\n    U.deepStrictEqual(_.isEmpty({ a: 1 }), false)\n  })\n\n  it('insertAt', () => {\n    U.deepStrictEqual(_.insertAt('a', 1)({}), { a: 1 })\n    U.deepStrictEqual(_.insertAt('c', 3)({ a: 1, b: 2 }), { a: 1, b: 2, c: 3 })\n    // should return the same reference if the value is already there\n    const x = { a: 1 }\n    U.deepStrictEqual(_.insertAt('a', 1)(x), x)\n  })\n\n  it('deleteAt', () => {\n    U.deepStrictEqual(_.deleteAt('a')({ a: 1, b: 2 }), { b: 2 })\n    // should return the same reference if the key is missing\n    const x = { a: 1 }\n    U.deepStrictEqual(_.deleteAt('b')(x), x)\n    U.deepStrictEqual(_.deleteAt('b')(noPrototype), noPrototype)\n  })\n\n  it('pop', () => {\n    U.deepStrictEqual(_.pop('a')({ a: 1, b: 2 }), O.some([1, { b: 2 }]))\n    U.deepStrictEqual(_.pop('c')({ a: 1, b: 2 }), O.none)\n  })\n\n  it('every', () => {\n    const x: Record<string, number> = { a: 1, b: 2 }\n    const y: Record<string, number> = { a: 1, b: 2 }\n    U.deepStrictEqual(_.every((n: number) => n <= 2)(x), true)\n    U.deepStrictEqual(_.every((n: number) => n <= 1)(y), false)\n  })\n\n  it('some', () => {\n    const x: Record<string, number> = { a: 1, b: 2 }\n    const y: Record<string, number> = { a: 1, b: 2 }\n    U.deepStrictEqual(_.some((n: number) => n <= 1)(x), true)\n    U.deepStrictEqual(_.some((n: number) => n <= 0)(y), false)\n  })\n\n  it('elem', () => {\n    U.deepStrictEqual(_.elem(N.Eq)(1, { a: 1, b: 2 }), true)\n    U.deepStrictEqual(_.elem(N.Eq)(3, { a: 1, b: 2 }), false)\n\n    U.deepStrictEqual(_.elem(N.Eq)(1)({ a: 1, b: 2 }), true)\n    U.deepStrictEqual(_.elem(N.Eq)(3)({ a: 1, b: 2 }), false)\n  })\n\n  it('fromFoldableMap', () => {\n    const zipObject = <K extends string, A>(keys: Array<K>, values: Array<A>): Record<K, A> =>\n      _.fromFoldableMap(Se.last<A>(), A.Foldable)(A.zip(keys, values), identity)\n\n    U.deepStrictEqual(zipObject(['a', 'b'], [1, 2, 3]), { a: 1, b: 2 })\n\n    interface User {\n      readonly id: string\n      readonly name: string\n    }\n\n    const users: Array<User> = [\n      { id: 'id1', name: 'name1' },\n      { id: 'id2', name: 'name2' },\n      { id: 'id1', name: 'name3' }\n    ]\n\n    U.deepStrictEqual(\n      _.fromFoldableMap(Se.last<User>(), A.Foldable)(users, (user) => [user.id, user]),\n      {\n        id1: { id: 'id1', name: 'name3' },\n        id2: { id: 'id2', name: 'name2' }\n      }\n    )\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Ord)(S.Show)\n    U.deepStrictEqual(Sh.show({}), `{}`)\n    U.deepStrictEqual(Sh.show({ a: 'a' }), `{ \"a\": \"a\" }`)\n    U.deepStrictEqual(Sh.show({ a: 'a', b: 'b' }), `{ \"a\": \"a\", \"b\": \"b\" }`)\n\n    const DepSh = _.getShow(S.Show)\n    U.deepStrictEqual(DepSh.show({}), `{}`)\n    U.deepStrictEqual(DepSh.show({ a: 'a' }), `{ \"a\": \"a\" }`)\n    U.deepStrictEqual(DepSh.show({ a: 'a', b: 'b' }), `{ \"a\": \"a\", \"b\": \"b\" }`)\n  })\n\n  it('singleton', () => {\n    U.deepStrictEqual(_.singleton('a', 1), { a: 1 })\n  })\n\n  it('has', () => {\n    const x: Record<string, number> = { a: 1 }\n    U.deepStrictEqual(_.has('a', x), true)\n    U.deepStrictEqual(_.has('b', x), false)\n  })\n\n  it('updateAt', () => {\n    const x: Record<string, number> = { a: 1 }\n    U.deepStrictEqual(_.updateAt('b', 2)(x), O.none)\n    U.deepStrictEqual(_.updateAt('a', 2)(x), O.some({ a: 2 }))\n    const r = _.updateAt('a', 1)(x)\n    if (O.isSome(r)) {\n      U.deepStrictEqual(r.value, x)\n    } else {\n      assert.fail()\n    }\n  })\n\n  it('modifyAt', () => {\n    const x: Record<string, number> = { a: 1 }\n    U.deepStrictEqual(_.modifyAt('b', (n: number) => n * 2)(x), O.none)\n    U.deepStrictEqual(_.modifyAt('a', (n: number) => n * 2)(x), O.some({ a: 2 }))\n    // should not return the same reference if nothing changed\n    const input: Record<string, number> = { a: 1 }\n    U.deepStrictEqual(\n      pipe(\n        input,\n        _.modifyAt('a', identity),\n        O.map((out) => out === input)\n      ),\n      O.some(false)\n    )\n  })\n\n  it('getUnionMonoid', () => {\n    const M = _.getUnionMonoid(S.Semigroup)\n    const x: Record<string, string> = {\n      a: 'a1',\n      b: 'b1',\n      c: 'c1'\n    }\n    const y: Record<string, string> = {\n      b: 'b2',\n      c: 'c2',\n      d: 'd2'\n    }\n    U.deepStrictEqual(M.concat(x, M.empty), x)\n    U.deepStrictEqual(M.concat(M.empty, x), x)\n    U.deepStrictEqual(M.concat(x, {}), x)\n    U.deepStrictEqual(M.concat({}, x), x)\n    U.deepStrictEqual(M.concat(x, y), {\n      a: 'a1',\n      b: 'b1b2',\n      c: 'c1c2',\n      d: 'd2'\n    })\n  })\n\n  it('getIntersectionSemigroup', () => {\n    const M = _.getIntersectionSemigroup(S.Semigroup)\n    const x: Record<string, string> = {\n      a: 'a1',\n      b: 'b1',\n      c: 'c1'\n    }\n    const y: Record<string, string> = {\n      b: 'b2',\n      c: 'c2',\n      d: 'd2'\n    }\n    U.deepStrictEqual(M.concat(x, {}), {})\n    U.deepStrictEqual(M.concat(x, {}), {})\n    U.deepStrictEqual(M.concat(x, {}), {})\n    U.deepStrictEqual(M.concat(x, {}), {})\n    U.deepStrictEqual(M.concat(x, y), {\n      b: 'b1b2',\n      c: 'c1c2'\n    })\n  })\n\n  it('getDifferenceMagma', () => {\n    const M = _.getDifferenceMagma<string>()\n    const x: Record<string, string> = {\n      a: 'a1',\n      b: 'b1',\n      c: 'c1'\n    }\n    const y: Record<string, string> = {\n      b: 'b2',\n      c: 'c2',\n      d: 'd2'\n    }\n    U.deepStrictEqual(M.concat({}, x), x)\n    U.deepStrictEqual(M.concat(x, {}), x)\n    U.deepStrictEqual(M.concat({}, x), x)\n    U.deepStrictEqual(M.concat(x, {}), x)\n    U.deepStrictEqual(M.concat(x, y), {\n      a: 'a1',\n      d: 'd2'\n    })\n  })\n})\n"
  },
  {
    "path": "test/Refinement.ts",
    "content": "import * as B from '../src/boolean'\nimport * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport { ReadonlyRecord } from '../src/ReadonlyRecord'\nimport * as _ from '../src/Refinement'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ninterface NonEmptyStringBrand {\n  readonly NonEmptyString: unique symbol\n}\n\ntype NonEmptyString = string & NonEmptyStringBrand\n\nconst NonEmptyString: _.Refinement<string, NonEmptyString> = (s): s is NonEmptyString => s.length > 0\n\ndescribe('Refinement', () => {\n  it('not', () => {\n    const r1: _.Refinement<string | number, string> = S.isString\n    const r2 = _.not(r1)\n    U.deepStrictEqual(r2('a'), false)\n    U.deepStrictEqual(r2(1), true)\n  })\n\n  it('or', () => {\n    const r = pipe(S.isString, _.or(N.isNumber), _.or(B.isBoolean))\n    U.deepStrictEqual(r({}), false)\n    U.deepStrictEqual(r('a'), true)\n    U.deepStrictEqual(r(1), true)\n    U.deepStrictEqual(r(true), true)\n  })\n\n  it('and', () => {\n    const ra = (r: ReadonlyRecord<string, unknown>): r is { readonly a: string } => S.isString(r['a'])\n    const rb = (r: ReadonlyRecord<string, unknown>): r is { readonly b: number } => N.isNumber(r['b'])\n    const r = pipe(ra, _.and(rb))\n    U.deepStrictEqual(r({ a: 'a' }), false)\n    U.deepStrictEqual(r({ b: 1 }), false)\n    U.deepStrictEqual(r({}), false)\n    U.deepStrictEqual(r({ a: 'a', b: 'b' }), false)\n    U.deepStrictEqual(r({ a: 1, b: 2 }), false)\n    U.deepStrictEqual(r({ a: 'a', b: 1 }), true)\n  })\n\n  it('fromOptionK', () => {\n    const f = (s: string | number): O.Option<string> => (typeof s === 'string' ? O.some(s) : O.none)\n    const isString = _.fromOptionK(f)\n    U.deepStrictEqual(isString('s'), true)\n    U.deepStrictEqual(isString(1), false)\n    type A = { readonly type: 'A' }\n    type B = { readonly type: 'B' }\n    type C = A | B\n    const isA = _.fromOptionK<C, A>((c) => (c.type === 'A' ? O.some(c) : O.none))\n    U.deepStrictEqual(isA({ type: 'A' }), true)\n    U.deepStrictEqual(isA({ type: 'B' }), false)\n  })\n\n  it('zero', () => {\n    const refinement = _.zero()\n    U.strictEqual(refinement('a'), false)\n  })\n\n  it('id', () => {\n    const refinement = _.id<string>()\n    U.strictEqual(refinement('a'), true)\n  })\n\n  it('compose', () => {\n    const refinement = pipe(S.isString, _.compose(NonEmptyString))\n    U.strictEqual(refinement('a'), true)\n    U.strictEqual(refinement(null), false)\n    U.strictEqual(refinement(''), false)\n  })\n\n  it('fromEitherK', () => {\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 = _.fromEitherK(f)\n    U.deepStrictEqual(isString('s'), true)\n    U.deepStrictEqual(isString(1), false)\n    type A = { readonly type: 'A' }\n    type B = { readonly type: 'B' }\n    type C = A | B\n    const isA = _.fromEitherK<C, A>((c) => (c.type === 'A' ? E.right(c) : E.left('not as A')))\n    U.deepStrictEqual(isA({ type: 'A' }), true)\n    U.deepStrictEqual(isA({ type: 'B' }), false)\n  })\n})\n"
  },
  {
    "path": "test/Ring.ts",
    "content": "import * as N from '../src/number'\nimport * as _ from '../src/Ring'\nimport * as U from './util'\n\ndescribe('Ring', () => {\n  it('tuple', () => {\n    const R = _.tuple(N.Field, N.Field, N.Field)\n    U.deepStrictEqual(R.add([1, 2, 3], [4, 5, 6]), [5, 7, 9])\n    U.deepStrictEqual(R.mul([1, 2, 3], [4, 5, 6]), [4, 10, 18])\n    U.deepStrictEqual(R.one, [1, 1, 1])\n    U.deepStrictEqual(R.sub([1, 2, 3], [4, 5, 6]), [-3, -3, -3])\n    U.deepStrictEqual(R.zero, [0, 0, 0])\n  })\n\n  it('negate', () => {\n    U.deepStrictEqual(_.negate(N.Field)(1), -1)\n  })\n})\n"
  },
  {
    "path": "test/Semigroup.ts",
    "content": "import * as B from '../src/boolean'\nimport * as N from '../src/number'\nimport * as _ from '../src/Semigroup'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('Semigroup', () => {\n  it('tuple', () => {\n    const S1 = _.tuple(S.Semigroup, N.SemigroupSum)\n    U.deepStrictEqual(S1.concat(['a', 1], ['b', 2]), ['ab', 3])\n    const S2 = _.tuple(S.Semigroup, N.SemigroupSum, B.SemigroupAll)\n    U.deepStrictEqual(S2.concat(['a', 1, true], ['b', 2, false]), ['ab', 3, false])\n  })\n\n  it('concatAll', () => {\n    U.deepStrictEqual(_.concatAll(S.Monoid)('')(['a', 'b', 'c']), 'abc')\n  })\n\n  it('fold', () => {\n    U.deepStrictEqual(_.fold(S.Monoid)('', ['a', 'b', 'c']), 'abc')\n    U.deepStrictEqual(_.fold(S.Monoid)('')(['a', 'b', 'c']), 'abc')\n  })\n\n  it('min', () => {\n    U.deepStrictEqual(_.min(N.Ord).concat(1, 2), 1)\n  })\n\n  it('max', () => {\n    U.deepStrictEqual(_.max(N.Ord).concat(1, 2), 2)\n  })\n\n  it('first', () => {\n    U.deepStrictEqual(_.first<number>().concat(1, 2), 1)\n  })\n\n  it('semigroupVoid', () => {\n    U.deepStrictEqual(_.semigroupVoid.concat(undefined, undefined), undefined)\n  })\n\n  it('reverse', () => {\n    const DS = _.reverse(S.Semigroup)\n    U.deepStrictEqual(DS.concat('a', 'b'), 'ba')\n  })\n\n  it('intercalate', () => {\n    const IS = _.intercalate(' ')(S.Semigroup)\n    U.strictEqual(IS.concat('a', 'b'), 'a b')\n    U.strictEqual(IS.concat(IS.concat('a', 'b'), 'c'), IS.concat('a', IS.concat('b', 'c')))\n  })\n\n  it('struct', () => {\n    // should ignore non own properties\n    const S = _.struct(Object.create({ a: 1 }))\n    U.deepStrictEqual(S.concat({}, {}), {})\n  })\n\n  it('semigroupAll', () => {\n    const S = _.semigroupAll\n    U.deepStrictEqual(S.concat(true, true), true)\n    U.deepStrictEqual(S.concat(false, true), false)\n    U.deepStrictEqual(S.concat(true, false), false)\n    U.deepStrictEqual(S.concat(false, false), false)\n  })\n\n  it('semigroupAny', () => {\n    const S = _.semigroupAny\n    U.deepStrictEqual(S.concat(true, true), true)\n    U.deepStrictEqual(S.concat(false, true), true)\n    U.deepStrictEqual(S.concat(true, false), true)\n    U.deepStrictEqual(S.concat(false, false), false)\n  })\n\n  it('semigroupSum', () => {\n    U.deepStrictEqual(_.semigroupSum.concat(2, 3), 5)\n  })\n\n  it('semigroupProduct', () => {\n    U.deepStrictEqual(_.semigroupProduct.concat(2, 3), 6)\n  })\n\n  it('getObjectSemigroup', () => {\n    type T = {\n      readonly foo?: number\n      readonly bar: string\n    }\n    const foo: T = {\n      foo: 123,\n      bar: '456'\n    }\n    const bar: T = {\n      bar: '123'\n    }\n    const S = _.getObjectSemigroup<T>()\n    U.deepStrictEqual(S.concat(foo, bar), Object.assign({}, foo, bar))\n  })\n})\n"
  },
  {
    "path": "test/Separated.ts",
    "content": "import * as fc from 'fast-check'\nimport { isDeepStrictEqual } from 'util'\n\nimport { pipe } from '../src/function'\nimport * as _ from '../src/Separated'\n\ndescribe('Separated', () => {\n  describe('pipeables', () => {\n    it('mapLeft', () =>\n      fc.assert(\n        fc.property(fc.integer(), fc.integer(), (left, right) => {\n          isDeepStrictEqual(\n            pipe(\n              _.separated(left, right),\n              _.mapLeft((n) => n.toString())\n            ),\n            _.separated(`${left}`, right)\n          )\n          isDeepStrictEqual(\n            _.Bifunctor.mapLeft(_.separated(left, right), (n) => n.toString()),\n            _.separated(`${left}`, right)\n          )\n        })\n      ))\n\n    it('map', () =>\n      fc.assert(\n        fc.property(fc.integer(), fc.integer(), (left, right) => {\n          isDeepStrictEqual(\n            pipe(\n              _.separated(left, right),\n              _.map((n) => n.toString())\n            ),\n            _.separated(left, `${right}`)\n          )\n          isDeepStrictEqual(\n            _.Functor.map(_.separated(left, right), (n) => n.toString()),\n            _.separated(left, `${right}`)\n          )\n        })\n      ))\n\n    it('bimap', () =>\n      fc.assert(\n        fc.property(fc.integer(), fc.integer(), (left, right) => {\n          isDeepStrictEqual(\n            pipe(\n              _.separated(left, right),\n              _.bimap(\n                (n) => n.toString(),\n                (n) => n.toString()\n              )\n            ),\n            _.separated(`${left}`, `${right}`)\n          )\n          isDeepStrictEqual(\n            _.Bifunctor.bimap(\n              _.separated(left, right),\n              (n) => n.toString(),\n              (n) => n.toString()\n            ),\n            _.separated(`${left}`, `${right}`)\n          )\n        })\n      ))\n  })\n})\n"
  },
  {
    "path": "test/Set.ts",
    "content": "import { getMonoid } from '../src/Array'\nimport { left, right } from '../src/Either'\nimport * as Eq from '../src/Eq'\nimport { pipe } from '../src/function'\nimport * as N from '../src/number'\nimport { none, some as optionSome } from '../src/Option'\nimport { separated } from '../src/Separated'\nimport * as _ from '../src/Set'\nimport * as S from '../src/string'\nimport * as U from './util'\n\nconst gte2 = (n: number) => n >= 2\n\ninterface Foo {\n  readonly x: string\n}\nconst foo = (x: string): Foo => ({ x })\nconst fooEq: Eq.Eq<Foo> = {\n  equals: (a: Foo, b: Foo) => a.x === b.x\n}\n\ndescribe('Set', () => {\n  it('toArray', () => {\n    U.deepStrictEqual(_.toArray(N.Ord)(new Set()), [])\n    U.deepStrictEqual(_.toArray(N.Ord)(new Set([1, 2, 3])), [1, 2, 3])\n    U.deepStrictEqual(_.toArray(N.Ord)(new Set([3, 2, 1])), [1, 2, 3])\n  })\n\n  it('getEq', () => {\n    const E = _.getEq(N.Eq)\n    U.deepStrictEqual(E.equals(new Set([1, 2, 3]), new Set([1, 2, 3])), true)\n    U.deepStrictEqual(E.equals(new Set([1, 2, 3]), new Set([1, 2])), false)\n    U.deepStrictEqual(E.equals(new Set([1, 2]), new Set([1, 2, 3])), false)\n  })\n\n  it('some', () => {\n    U.deepStrictEqual(_.some((s: string) => s.trim() === '')(new Set<string>()), false)\n    U.deepStrictEqual(_.some(gte2)(new Set([1, 2, 3])), true)\n    U.deepStrictEqual(_.some(gte2)(new Set([1])), false)\n  })\n\n  it('map', () => {\n    U.deepStrictEqual(_.map(N.Eq)((n: number) => n % 2)(new Set([])), new Set([]))\n    U.deepStrictEqual(_.map(N.Eq)((n: number) => n % 2)(new Set([1, 2, 3, 4])), new Set([0, 1]))\n    U.deepStrictEqual(_.map(S.Eq)((n: number) => `${n % 2}`)(new Set([1, 2, 3, 4])), new Set(['0', '1']))\n  })\n\n  it('every', () => {\n    U.deepStrictEqual(_.every(gte2)(new Set([1, 2, 3])), false)\n    U.deepStrictEqual(_.every(gte2)(new Set([2, 3])), true)\n  })\n\n  it('chain', () => {\n    U.deepStrictEqual(_.chain(S.Eq)((n: number) => new Set([n.toString()]))(new Set([])), new Set([]))\n    U.deepStrictEqual(_.chain(S.Eq)(() => new Set([]))(new Set([1, 2])), new Set([]))\n    U.deepStrictEqual(\n      _.chain(S.Eq)((n: number) => new Set([`${n}`, `${n + 1}`]))(new Set([1, 2])),\n      new Set(['1', '2', '3'])\n    )\n  })\n\n  it('isSubset', () => {\n    U.deepStrictEqual(pipe(new Set([1, 2]), _.isSubset(N.Eq)(new Set([1, 2, 3]))), true)\n    U.deepStrictEqual(pipe(new Set([1, 2, 4]), _.isSubset(N.Eq)(new Set([1, 2, 3]))), false)\n  })\n\n  it('filter', () => {\n    U.deepStrictEqual(_.filter(gte2)(new Set([1, 2, 3])), new Set([2, 3]))\n\n    // refinements\n    const isNumber = (u: string | number): u is number => typeof u === 'number'\n    const actual = _.filter(isNumber)(new Set([1, 'a', 2]))\n    U.deepStrictEqual(actual, new Set([1, 2]))\n  })\n\n  it('partition', () => {\n    U.deepStrictEqual(_.partition(() => true)(new Set([])), separated(new Set([]), new Set([])))\n    U.deepStrictEqual(_.partition(() => true)(new Set([1])), separated(new Set([]), new Set([1])))\n    U.deepStrictEqual(_.partition(() => false)(new Set([1])), separated(new Set([1]), new Set([])))\n    U.deepStrictEqual(\n      _.partition((n: number) => n % 2 === 0)(new Set([1, 2, 3, 4])),\n      separated(new Set([1, 3]), new Set([2, 4]))\n    )\n\n    // refinements\n    const isNumber = (u: string | number): u is number => typeof u === 'number'\n    const actual = _.partition(isNumber)(new Set([1, 'a', 2]))\n    U.deepStrictEqual(actual, separated(new Set(['a']), new Set([1, 2])))\n  })\n\n  it('union', () => {\n    U.deepStrictEqual(_.union(N.Eq)(new Set([1, 2]), new Set([1, 3])), new Set([1, 2, 3]))\n\n    U.deepStrictEqual(pipe(new Set([1, 2]), _.union(N.Eq)(new Set([1, 3]))), new Set([1, 2, 3]))\n  })\n\n  it('intersection', () => {\n    U.deepStrictEqual(_.intersection(N.Eq)(new Set([1, 2]), new Set([1, 3])), new Set([1]))\n\n    U.deepStrictEqual(pipe(new Set([1, 2]), _.intersection(N.Eq)(new Set([1, 3]))), new Set([1]))\n  })\n\n  it('partitionMap', () => {\n    U.deepStrictEqual(\n      _.partitionMap(N.Eq, S.Eq)((n: number) => left(n))(new Set([])),\n      separated(new Set([]), new Set([]))\n    )\n    U.deepStrictEqual(\n      _.partitionMap(N.Eq, S.Eq)((n: number) => (n % 2 === 0 ? left(n) : right(`${n}`)))(new Set([1, 2, 3])),\n      separated(new Set([2]), new Set(['1', '3']))\n    )\n    const SL = Eq.struct({ value: N.Eq })\n    const SR = Eq.struct({ value: S.Eq })\n    U.deepStrictEqual(\n      _.partitionMap(\n        SL,\n        SR\n      )((x: { readonly value: number }) => (x.value % 2 === 0 ? left({ value: 2 }) : right({ value: 'odd' })))(\n        new Set([{ value: 1 }, { value: 2 }, { value: 3 }, { value: 4 }])\n      ),\n      separated(new Set([{ value: 2 }]), new Set([{ value: 'odd' }]))\n    )\n  })\n\n  it('getUnionMonoid', () => {\n    const M = _.getUnionMonoid(N.Eq)\n    U.deepStrictEqual(M.concat(new Set([1, 2]), new Set([1, 3])), new Set([1, 2, 3]))\n    U.deepStrictEqual(M.concat(new Set([1, 2]), M.empty), new Set([1, 2]))\n    U.deepStrictEqual(M.concat(M.empty, new Set([1, 3])), new Set([1, 3]))\n  })\n\n  it('getIntersectionSemigroup', () => {\n    const IS = _.getIntersectionSemigroup(N.Eq)\n    U.deepStrictEqual(IS.concat(new Set([1, 2]), new Set([1, 3])), new Set([1]))\n    U.deepStrictEqual(IS.concat(new Set([1, 2]), _.empty), _.empty)\n    U.deepStrictEqual(IS.concat(_.empty, new Set([1, 3])), _.empty)\n  })\n\n  it('getDifferenceMagma', () => {\n    const M = _.getDifferenceMagma(N.Eq)\n    U.deepStrictEqual(M.concat(new Set([1, 2]), new Set([1, 3])), new Set([2]))\n  })\n\n  it('difference', () => {\n    U.deepStrictEqual(_.difference(N.Eq)(new Set([1, 2]), new Set([1, 3])), new Set([2]))\n\n    U.deepStrictEqual(pipe(new Set([1, 2]), _.difference(N.Eq)(new Set([1, 3]))), new Set([2]))\n  })\n\n  it('reduce', () => {\n    U.deepStrictEqual(_.reduce(N.Ord)('', (b, a) => b + a)(new Set([1, 2, 3])), '123')\n    U.deepStrictEqual(_.reduce(N.Ord)('', (b, a) => b + a)(new Set([3, 2, 1])), '123')\n  })\n\n  it('foldMap', () => {\n    U.deepStrictEqual(_.foldMap(N.Ord, getMonoid<number>())((a) => [a])(new Set([1, 2, 3])), [1, 2, 3])\n    U.deepStrictEqual(_.foldMap(N.Ord, getMonoid<number>())((a) => [a])(new Set([3, 2, 1])), [1, 2, 3])\n  })\n\n  it('singleton', () => {\n    U.deepStrictEqual(_.singleton(1), new Set([1]))\n  })\n\n  it('insert', () => {\n    const x = new Set([1, 2])\n    U.deepStrictEqual(_.insert(N.Eq)(3)(x), new Set([1, 2, 3]))\n    // should return the same ference if the element is already a member\n    U.deepStrictEqual(_.insert(N.Eq)(2)(x), x)\n  })\n\n  it('remove', () => {\n    U.deepStrictEqual(_.remove(N.Eq)(3)(new Set([1, 2])), new Set([1, 2]))\n    U.deepStrictEqual(_.remove(N.Eq)(1)(new Set([1, 2])), new Set([2]))\n  })\n\n  it('toggle', () => {\n    U.deepStrictEqual(_.toggle(N.Eq)(1)(new Set([2])), new Set([1, 2]))\n    U.deepStrictEqual(_.toggle(N.Eq)(1)(new Set([1, 2])), new Set([2]))\n  })\n\n  it('fromArray', () => {\n    U.deepStrictEqual(_.fromArray(N.Eq)([]), new Set([]))\n    U.deepStrictEqual(_.fromArray(N.Eq)([1]), new Set([1]))\n    U.deepStrictEqual(_.fromArray(N.Eq)([1, 1]), new Set([1]))\n    U.deepStrictEqual(_.fromArray(N.Eq)([1, 2]), new Set([1, 2]))\n\n    U.deepStrictEqual(_.fromArray(fooEq)(['a', 'a', 'b'].map(foo)), new Set(['a', 'b'].map(foo)))\n  })\n\n  it('compact', () => {\n    U.deepStrictEqual(_.compact(N.Eq)(new Set([optionSome(1), none, optionSome(2)])), new Set([1, 2]))\n    type R = { readonly id: string }\n    const E: Eq.Eq<R> = pipe(\n      S.Eq,\n      Eq.contramap((x) => x.id)\n    )\n    U.deepStrictEqual(\n      _.compact(E)(new Set([optionSome({ id: 'a' }), none, optionSome({ id: 'a' })])),\n      new Set([{ id: 'a' }])\n    )\n  })\n\n  it('separate', () => {\n    U.deepStrictEqual(\n      _.separate(S.Eq, N.Eq)(new Set([right(1), left('a'), right(2)])),\n      separated(new Set(['a']), new Set([1, 2]))\n    )\n    type L = { readonly error: string }\n    type R = { readonly id: string }\n    const SL: Eq.Eq<L> = pipe(\n      S.Eq,\n      Eq.contramap((x) => x.error)\n    )\n    const SR: Eq.Eq<R> = pipe(\n      S.Eq,\n      Eq.contramap((x) => x.id)\n    )\n    U.deepStrictEqual(\n      _.separate(\n        SL,\n        SR\n      )(new Set([right({ id: 'a' }), left({ error: 'error' }), right({ id: 'a' }), left({ error: 'error' })])),\n      separated(new Set([{ error: 'error' }]), new Set([{ id: 'a' }]))\n    )\n  })\n\n  it('filterMap', () => {\n    U.deepStrictEqual(\n      _.filterMap(N.Eq)((s: string) => (s.length > 1 ? optionSome(s.length) : none))(new Set(['a', 'bb', 'ccc'])),\n      new Set([2, 3])\n    )\n    type R = { readonly id: string }\n    const E: Eq.Eq<R> = pipe(\n      S.Eq,\n      Eq.contramap((x) => x.id)\n    )\n    U.deepStrictEqual(\n      _.filterMap(E)((x: { readonly id: string }) => optionSome(x))(new Set([{ id: 'a' }, { id: 'a' }])),\n      new Set([{ id: 'a' }])\n    )\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    const s1 = new Set<string>([])\n    U.deepStrictEqual(Sh.show(s1), `new Set([])`)\n    const s2 = new Set<string>(['a'])\n    U.deepStrictEqual(Sh.show(s2), `new Set([\"a\"])`)\n    const s3 = new Set<string>(['b', 'a'])\n    U.deepStrictEqual(Sh.show(s3), `new Set([\"a\", \"b\"])`)\n  })\n\n  it('isEmpty', () => {\n    U.deepStrictEqual(_.isEmpty(_.empty), true)\n    U.deepStrictEqual(_.isEmpty(new Set()), true)\n    U.deepStrictEqual(_.isEmpty(new Set(['a'])), false)\n  })\n\n  it('size', () => {\n    U.deepStrictEqual(_.size(_.empty), 0)\n    U.deepStrictEqual(_.size(new Set()), 0)\n    U.deepStrictEqual(_.size(new Set(['a'])), 1)\n  })\n})\n"
  },
  {
    "path": "test/Show.ts",
    "content": "import * as N from '../src/number'\nimport * as _ from '../src/Show'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('Show', () => {\n  it('struct', () => {\n    U.deepStrictEqual(_.struct({ a: S.Show }).show({ a: 'a' }), '{ a: \"a\" }')\n    U.deepStrictEqual(_.struct({ a: S.Show, b: N.Show }).show({ a: 'a', b: 1 }), '{ a: \"a\", b: 1 }')\n    // should ignore non own properties\n    const shows = Object.create({ a: 1 })\n    const s = _.struct(shows)\n    U.deepStrictEqual(s.show({}), '{}')\n  })\n\n  it('tuple', () => {\n    const Sh = _.tuple(S.Show, N.Show)\n    U.deepStrictEqual(Sh.show(['a', 1]), '[\"a\", 1]')\n  })\n\n  it('showBoolean', () => {\n    const Sh = _.showBoolean\n    U.deepStrictEqual(Sh.show(true), 'true')\n    U.deepStrictEqual(Sh.show(false), 'false')\n  })\n\n  it('showNumber', () => {\n    U.deepStrictEqual(_.showNumber.show(1), '1')\n  })\n\n  it('showString', () => {\n    U.deepStrictEqual(_.showString.show('a'), '\"a\"')\n  })\n})\n"
  },
  {
    "path": "test/State.ts",
    "content": "import { pipe, tuple } from '../src/function'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport * as _ from '../src/State'\nimport * as U from './util'\n\ndescribe('State', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      const x = (s: number) => tuple(s - 1, s + 1)\n      U.deepStrictEqual(pipe(x, _.map(U.double))(0), [-2, 1])\n    })\n\n    it('ap', () => {\n      U.deepStrictEqual(pipe(_.of(U.double), _.ap(_.of(1)))(0), [2, 0])\n    })\n\n    it('apFirst', () => {\n      U.deepStrictEqual(pipe(_.of('a'), _.apFirst(_.of('b')))(0), ['a', 0])\n    })\n\n    it('apSecond', () => {\n      U.deepStrictEqual(pipe(_.of('a'), _.apSecond(_.of('b')))(0), ['b', 0])\n    })\n\n    it('flatMap', () => {\n      const f = (_n: number) => (s: number) => tuple(s - 1, s + 1)\n      const x = (s: number) => tuple(s - 1, s + 1)\n      U.deepStrictEqual(pipe(x, _.flatMap(f))(0), [0, 2])\n      U.deepStrictEqual(_.flatMap(x, f)(0), [0, 2])\n    })\n\n    it('chain', () => {\n      const f = (_n: number) => (s: number) => tuple(s - 1, s + 1)\n      const x = (s: number) => tuple(s - 1, s + 1)\n      U.deepStrictEqual(pipe(x, _.chain(f))(0), [0, 2])\n    })\n\n    it('tap', () => {\n      const f = (_n: number) => (s: number) => tuple(s - 1, s + 1)\n      const x = (s: number) => tuple(s - 1, s + 1)\n      U.deepStrictEqual(pipe(x, _.tap(f))(0), [-1, 2])\n      U.deepStrictEqual(_.tap(x, f)(0), [-1, 2])\n    })\n\n    it('chainFirst', () => {\n      const f = (_n: number) => (s: number) => tuple(s - 1, s + 1)\n      const x = (s: number) => tuple(s - 1, s + 1)\n      U.deepStrictEqual(pipe(x, _.chainFirst(f))(0), [-1, 2])\n    })\n\n    it('flatten', () => {\n      U.deepStrictEqual(pipe(_.of(_.of('a')), _.flatten)(0), ['a', 0])\n    })\n  })\n\n  it('evalState', () => {\n    U.deepStrictEqual(_.evalState(_.of<number, string>('a'), 0), 'a')\n  })\n\n  it('execState', () => {\n    U.deepStrictEqual(_.execState(_.of<number, string>('a'), 0), 0)\n  })\n\n  it('evaluate', () => {\n    U.deepStrictEqual(pipe(_.of<number, string>('a'), _.evaluate(0)), 'a')\n  })\n\n  it('execute', () => {\n    U.deepStrictEqual(pipe(_.of<number, string>('a'), _.execute(0)), 0)\n  })\n\n  it('put', () => {\n    U.deepStrictEqual(_.put(2)(1), [undefined, 2])\n  })\n\n  it('get', () => {\n    U.deepStrictEqual(_.get()(1), [1, 1])\n  })\n\n  it('modify', () => {\n    U.deepStrictEqual(_.modify(U.double)(1), [undefined, 2])\n  })\n\n  it('gets', () => {\n    U.deepStrictEqual(_.gets(U.double)(1), [2, 1])\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )('state'),\n      [{ a: 1, b: 'b', c: [1, 'b'] }, 'state']\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b')))(undefined), [{ a: 1, b: 'b' }, undefined])\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => _.of(a + i))\n      U.deepStrictEqual(pipe(RA.empty, f)({}), [RA.empty, {}])\n      U.deepStrictEqual(pipe(input, f)({}), [['a0', 'b1'], {}])\n    })\n\n    // old\n    it('sequenceArray', () => {\n      const append =\n        (n: number): _.State<ReadonlyArray<number>, number> =>\n        (s) =>\n          [n, [...s, n]]\n      U.deepStrictEqual(pipe([append(1), append(2)], _.sequenceArray)([]), [\n        [1, 2],\n        [1, 2]\n      ])\n    })\n  })\n})\n"
  },
  {
    "path": "test/StateReaderTaskEither.ts",
    "content": "import * as assert from 'assert'\n\nimport * as A from '../src/Array'\nimport * as E from '../src/Either'\nimport { pipe, SK, tuple } from '../src/function'\nimport * as I from '../src/IO'\nimport * as IE from '../src/IOEither'\nimport * as O from '../src/Option'\nimport * as R from '../src/Reader'\nimport * as RE from '../src/ReaderEither'\nimport * as RTE from '../src/ReaderTaskEither'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport { of as stateOf, State } from '../src/State'\nimport * as _ from '../src/StateReaderTaskEither'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as TE from '../src/TaskEither'\nimport * as U from './util'\n\nconst state: unknown = {}\n\ndescribe('StateReaderTaskEither', () => {\n  describe('pipeables', () => {\n    it('alt', async () => {\n      const e1 = await pipe(\n        _.right('a'),\n        _.alt(() => _.left(1)),\n        _.evaluate(state)\n      )({})()\n      U.deepStrictEqual(e1, E.right('a'))\n      const e2 = await pipe(\n        pipe(\n          _.left(1),\n          _.alt(() => _.right('b')),\n          _.evaluate(state)\n        )\n      )({})()\n      U.deepStrictEqual(e2, E.right('b'))\n      const e3 = await pipe(\n        pipe(\n          _.left(1),\n          _.alt(() => _.left(2)),\n          _.evaluate(state)\n        )\n      )({})()\n      U.deepStrictEqual(e3, E.left(2))\n    })\n\n    it('map', async () => {\n      const e = await pipe(_.right('aaa'), _.map(S.size), _.evaluate(state))({})()\n      U.deepStrictEqual(e, E.right(3))\n    })\n\n    it('ap', async () => {\n      const e = await pipe(_.right(S.size), _.ap(_.right('aaa')), _.evaluate(state))({})()\n      U.deepStrictEqual(e, E.right(3))\n    })\n\n    it('apFirst', async () => {\n      const e = await pipe(_.right('a'), _.apFirst(_.right('b')), _.evaluate(state))({})()\n      U.deepStrictEqual(e, E.right('a'))\n    })\n\n    it('apFirstW', async () => {\n      const fa = _.right<unknown, { readonly k: string }, 'Foo', string>('a')\n      const fb = _.right<unknown, { readonly x: number }, 'Bar', number>(6)\n      const e = await pipe(fa, _.apFirstW(fb), _.evaluate(state))({ k: 'v', x: 5 })()\n      U.deepStrictEqual(e, E.right('a'))\n    })\n\n    it('apSecond', async () => {\n      const e = await pipe(_.right('a'), _.apSecond(_.right('b')), _.evaluate(state))({})()\n      U.deepStrictEqual(e, E.right('b'))\n    })\n\n    it('apSecondW', async () => {\n      const fa = _.right<unknown, { readonly k: string }, 'Foo', string>('a')\n      const fb = _.right<unknown, { readonly x: number }, 'Bar', number>(6)\n      const e = await pipe(fa, _.apSecondW(fb), _.evaluate(state))({ k: 'v', x: 5 })()\n      U.deepStrictEqual(e, E.right(6))\n    })\n\n    it('flatMap', async () => {\n      const f = (s: string) => (s.length > 2 ? _.right(s.length) : _.right(0))\n      U.deepStrictEqual(await pipe(_.right('aaa'), _.flatMap(f), _.evaluate(state))({})(), E.right(3))\n      U.deepStrictEqual(await pipe(_.flatMap(_.right('aaa'), f), _.evaluate(state))({})(), E.right(3))\n    })\n\n    it('chain', async () => {\n      const f = (s: string) => (s.length > 2 ? _.right(s.length) : _.right(0))\n      const e = await pipe(_.right('aaa'), _.chain(f), _.evaluate(state))({})()\n      U.deepStrictEqual(e, E.right(3))\n    })\n\n    it('tap', async () => {\n      const f = (s: string) => (s.length > 2 ? _.right(s.length) : _.right(0))\n      U.deepStrictEqual(await pipe(_.right('aaa'), _.tap(f), _.evaluate(state))({})(), E.right('aaa'))\n      U.deepStrictEqual(await pipe(_.tap(_.right('aaa'), f), _.evaluate(state))({})(), E.right('aaa'))\n    })\n\n    it('chainFirst', async () => {\n      const f = (s: string) => (s.length > 2 ? _.right(s.length) : _.right(0))\n      const e = await pipe(_.right('aaa'), _.chainFirst(f), _.evaluate(state))({})()\n      U.deepStrictEqual(e, E.right('aaa'))\n    })\n\n    it('flatten', async () => {\n      const e = await pipe(_.right(_.right('a')), _.flatten, _.evaluate(state))({})()\n      U.deepStrictEqual(e, E.right('a'))\n    })\n\n    type S = unknown\n    type R1 = { readonly env1: unknown }\n    type R2 = { readonly env2: unknown }\n    type E1 = { readonly left1: unknown }\n    type E2 = { readonly left2: unknown }\n\n    it('flattenW', async () => {\n      const e = await pipe(\n        _.right<S, R1, E1, _.StateReaderTaskEither<S, R2, E2, 'a'>>(_.right('a')),\n        _.flattenW,\n        _.evaluate(state)\n      )({ env1: '', env2: '' })()\n      U.deepStrictEqual(e, E.right('a'))\n    })\n\n    it('bimap', async () => {\n      const gt2 = (n: number): boolean => n > 2\n      const e1 = await pipe(_.right('aaa'), _.bimap(gt2, S.size), _.evaluate(state))({})()\n      U.deepStrictEqual(e1, E.right(3))\n      const e2 = await pipe(_.left(3), _.bimap(gt2, S.size), _.evaluate(state))({})()\n      U.deepStrictEqual(e2, E.left(true))\n    })\n\n    it('mapLeft', async () => {\n      const gt2 = (n: number): boolean => n > 2\n      const e = await pipe(_.left(3), _.mapLeft(gt2), _.evaluate(state))({})()\n      U.deepStrictEqual(e, E.left(true))\n    })\n\n    it('fromPredicate', async () => {\n      const predicate = (n: number) => n >= 2\n      const gt2 = _.fromPredicate(predicate, (n) => `Invalid number ${n}`)\n\n      const refinement = (u: string | number): u is number => typeof u === 'number'\n      const isNumber = _.fromPredicate(refinement, (u) => `Invalid number ${String(u)}`)\n\n      const e1 = await pipe(gt2(3), _.evaluate(state))({})()\n      const e2 = await pipe(gt2(1), _.evaluate(state))({})()\n      const e3 = await pipe(isNumber(4), _.evaluate(state))({})()\n      U.deepStrictEqual(e1, E.right(3))\n      U.deepStrictEqual(e2, E.left('Invalid number 1'))\n      U.deepStrictEqual(e3, E.right(4))\n    })\n\n    it('filterOrElse', async () => {\n      const e1 = await pipe(\n        _.right(12),\n        _.filterOrElse(\n          (n) => n > 10,\n          () => 'a'\n        ),\n        _.evaluate(state)\n      )({})()\n      U.deepStrictEqual(e1, E.right(12))\n\n      const e2 = await pipe(\n        _.right(8),\n        _.filterOrElse(\n          (n) => n > 10,\n          () => 'a'\n        ),\n        _.evaluate(state)\n      )({})()\n      U.deepStrictEqual(e2, E.left('a'))\n    })\n  })\n\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('applicativeStateReaderTaskEither', async () => {\n    await U.assertSeq(_.Applicative, _.FromTask, (fa) => fa(null)(null)())\n  })\n\n  // -------------------------------------------------------------------------------------\n  // utils\n  // -------------------------------------------------------------------------------------\n\n  it('run', async () => {\n    const ma = _.right('a')\n    const e = await ma({})({})()\n    assert.deepStrictEqual(e, E.right(['a', {}]))\n  })\n\n  it('applicativeReaderTaskEitherSeq', async () => {\n    const log: Array<string> = []\n    const append = (message: string): _.StateReaderTaskEither<{}, {}, void, number> =>\n      _.rightTask(() => Promise.resolve(log.push(message)))\n    const t1 = pipe(\n      append('start 1'),\n      _.chain(() => append('end 1'))\n    )\n    const t2 = pipe(\n      append('start 2'),\n      _.chain(() => append('end 2'))\n    )\n    const sequence = A.sequence(_.Applicative)\n    U.deepStrictEqual(await sequence([t1, t2])({})({})(), E.right([[2, 4], {}]))\n    U.deepStrictEqual(log, ['start 1', 'end 1', 'start 2', 'end 2'])\n  })\n\n  it('execute', async () => {\n    const ma = _.right('a')\n    const e = await pipe(ma, _.execute(state))({})()\n    U.deepStrictEqual(e, E.right({}))\n  })\n\n  it('rightState', async () => {\n    const s: State<unknown, number> = (s) => [1, s]\n    const e = await pipe(_.rightState(s), _.evaluate(state))({})()\n    U.deepStrictEqual(e, E.right(1))\n  })\n\n  it('leftState', async () => {\n    const s: State<unknown, number> = (s) => [1, s]\n    const e = await pipe(_.leftState(s), _.evaluate(state))({})()\n    U.deepStrictEqual(e, E.left(1))\n  })\n\n  it('fromReaderTaskEither', async () => {\n    const rte: RTE.ReaderTaskEither<{}, string, number> = RTE.right(1)\n    const e = await pipe(_.fromReaderTaskEither(rte), _.evaluate(state))({})()\n    U.deepStrictEqual(e, E.right(1))\n  })\n\n  it('left', async () => {\n    const e = await _.left(1)({})({})()\n    U.deepStrictEqual(e, E.left(1))\n  })\n\n  it('rightTask', async () => {\n    const e = await _.rightTask(T.of(1))({})({})()\n    assert.deepStrictEqual(e, E.right([1, {}]))\n  })\n\n  it('leftTask', async () => {\n    const e = await _.leftTask(T.of(1))({})({})()\n    U.deepStrictEqual(e, E.left(1))\n  })\n\n  it('fromTaskEither', async () => {\n    const e = await _.fromTaskEither(TE.of(1))({})({})()\n    assert.deepStrictEqual(e, E.right([1, {}]))\n  })\n\n  it('rightReader', async () => {\n    const e = await _.rightReader(R.of(1))({})({})()\n    assert.deepStrictEqual(e, E.right([1, {}]))\n  })\n\n  it('leftReader', async () => {\n    const e = await _.leftReader(R.of(1))({})({})()\n    U.deepStrictEqual(e, E.left(1))\n  })\n\n  it('fromIOEither', async () => {\n    const e1 = await _.fromIOEither(IE.right(1))({})({})()\n    assert.deepStrictEqual(e1, E.right([1, {}]))\n    const e2 = await _.fromIOEither(IE.left(1))({})({})()\n    U.deepStrictEqual(e2, E.left(1))\n  })\n\n  it('fromEither', async () => {\n    const e1 = await _.fromEither(E.right(1))({})({})()\n    assert.deepStrictEqual(e1, E.right([1, {}]))\n    const e2 = await _.fromEither(E.left(1))({})({})()\n    U.deepStrictEqual(e2, E.left(1))\n  })\n\n  it('fromOption', async () => {\n    const e1 = await _.fromOption(() => 'err')(O.some(1))({})({})()\n    assert.deepStrictEqual(e1, E.right([1, {}]))\n    const e2 = await _.fromOption(() => 'err')(O.none)({})({})()\n    U.deepStrictEqual(e2, E.left('err'))\n  })\n\n  it('rightIO', async () => {\n    const e = await _.rightIO(I.of(1))({})({})()\n    assert.deepStrictEqual(e, E.right([1, {}]))\n  })\n\n  it('leftIO', async () => {\n    const e = await _.leftIO(I.of(1))({})({})()\n    U.deepStrictEqual(e, E.left(1))\n  })\n\n  it('fromOption', async () => {\n    const e1 = await _.fromOption(() => 'none')(O.none)({})({})()\n    U.deepStrictEqual(e1, E.left('none'))\n    const e2 = await _.fromOption(() => 'none')(O.some(1))({})({})()\n    assert.deepStrictEqual(e2, E.right([1, {}]))\n  })\n\n  it('fromReaderEither', async () => {\n    const e1 = await _.fromReaderEither(RE.left('a'))({})({})()\n    U.deepStrictEqual(e1, E.left('a'))\n    const e2 = await _.fromReaderEither(RE.right(1))({})({})()\n    assert.deepStrictEqual(e2, E.right([1, {}]))\n  })\n\n  it('chainEitherK', async () => {\n    const f = (s: string) => E.right(s.length)\n    const x = await pipe(_.right('a'), _.chainEitherK(f))(undefined)(undefined)()\n    assert.deepStrictEqual(x, E.right([1, undefined]))\n  })\n\n  it('chainIOEitherK', async () => {\n    const f = (s: string) => IE.right(s.length)\n    const x = await pipe(_.right('a'), _.chainIOEitherK(f))(undefined)(undefined)()\n    assert.deepStrictEqual(x, E.right([1, undefined]))\n  })\n\n  it('chainTaskEitherK', async () => {\n    const f = (s: string) => TE.right(s.length)\n    const x = await pipe(_.right('a'), _.chainTaskEitherK(f))(undefined)(undefined)()\n    assert.deepStrictEqual(x, E.right([1, undefined]))\n  })\n\n  it('flatMapTaskEither', async () => {\n    const f = (s: string) => TE.right(s.length)\n    const x = await pipe(_.right('a'), _.flatMapTaskEither(f))(undefined)(undefined)()\n    assert.deepStrictEqual(x, E.right([1, undefined]))\n  })\n\n  it('chainReaderTaskEitherK', async () => {\n    const f = (s: string) => RTE.right(s.length)\n    const x = await pipe(_.right('a'), _.chainReaderTaskEitherK(f))(undefined)(undefined)()\n    assert.deepStrictEqual(x, E.right([1, undefined]))\n  })\n\n  it('put', async () => {\n    assert.deepStrictEqual(await _.put(2)(1)({})(), E.right([undefined, 2]))\n  })\n\n  it('get', async () => {\n    assert.deepStrictEqual(await _.get()(1)({})(), E.right([1, 1]))\n  })\n\n  it('modify', async () => {\n    assert.deepStrictEqual(await _.modify(U.double)(1)({})(), E.right([undefined, 2]))\n  })\n\n  it('gets', async () => {\n    U.deepStrictEqual(await _.gets(U.double)(1)({})(), E.right([2, 1]))\n  })\n\n  it('do notation', async () => {\n    assert.deepStrictEqual(\n      await pipe(\n        _.right<void, void, string, number>(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.right('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )(undefined)(undefined)(),\n      E.right([{ a: 1, b: 'b', c: [1, 'b'] }, undefined])\n    )\n  })\n\n  it('apS', async () => {\n    assert.deepStrictEqual(\n      await pipe(_.right<void, void, string, number>(1), _.bindTo('a'), _.apS('b', _.right('b')))(undefined)(\n        undefined\n      )(),\n      E.right([{ a: 1, b: 'b' }, undefined])\n    )\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', async () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.right(a + i) : _.left('e')))\n      U.deepStrictEqual(await pipe(RA.empty, f)(undefined)(undefined)(), E.right(tuple(RA.empty, undefined)))\n      U.deepStrictEqual(await pipe(input, f)(undefined)(undefined)(), E.right(tuple(['a0', 'b1'], undefined)))\n      U.deepStrictEqual(await pipe(['a', ''], f)(undefined)(undefined)(), E.left('e'))\n      const append = (_i: number, n: number): _.StateReaderTaskEither<ReadonlyArray<number>, {}, Error, void> =>\n        _.modify((a) => [...a, n])\n      U.deepStrictEqual(\n        await pipe(\n          [1, 2, 3],\n          _.traverseReadonlyArrayWithIndex(append),\n          _.map(() => undefined)\n        )([])({})(),\n        E.right(tuple(undefined, [1, 2, 3]))\n      )\n    })\n\n    it('sequenceReadonlyArray', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.StateReaderTaskEither<undefined, undefined, string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.StateReaderTaskEither<undefined, undefined, string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(\n        await pipe([right(1), right(2)], _.traverseReadonlyArrayWithIndex(SK))(undefined)(undefined)(),\n        E.right(tuple([1, 2], undefined))\n      )\n      U.deepStrictEqual(\n        await pipe([right(3), left('a')], _.traverseReadonlyArrayWithIndex(SK))(undefined)(undefined)(),\n        E.left('a')\n      )\n      U.deepStrictEqual(\n        await pipe([left('b'), right(4)], _.traverseReadonlyArrayWithIndex(SK))(undefined)(undefined)(),\n        E.left('b')\n      )\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n\n    // old\n    it('sequenceArray', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.StateReaderTaskEither<undefined, undefined, string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.StateReaderTaskEither<undefined, undefined, string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      assert.deepStrictEqual(\n        await pipe([right(1), right(2)], _.sequenceArray)(undefined)(undefined)(),\n        E.right([[1, 2], undefined])\n      )\n      U.deepStrictEqual(await pipe([right(3), left('a')], _.sequenceArray)(undefined)(undefined)(), E.left('a'))\n      U.deepStrictEqual(await pipe([left('b'), right(4)], _.sequenceArray)(undefined)(undefined)(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n\n    it('#1486', async () => {\n      const append = (n: number): _.StateReaderTaskEither<ReadonlyArray<number>, {}, Error, void> =>\n        _.modify((a) => [...a, n])\n      U.deepStrictEqual(\n        await pipe(\n          [1, 2, 3],\n          _.traverseArray(append),\n          _.map(() => undefined)\n        )([])({})(),\n        E.right(tuple(undefined, [1, 2, 3]))\n      )\n    })\n  })\n\n  it('fromState', async () => {\n    const s: State<unknown, number> = (s) => [1, s]\n    const e = await pipe(_.fromState(s), _.evaluate(state))({})()\n    U.deepStrictEqual(e, E.right(1))\n  })\n\n  it('fromStateK', async () => {\n    const ma = _.fromStateK(\n      (n: number): State<number, number> =>\n        (s) =>\n          [n * 2, s + 1]\n    )\n    U.deepStrictEqual(await ma(3)(2)({})(), E.right([6, 3]))\n  })\n\n  it('chainStateK', async () => {\n    const f = _.chainStateK(\n      (n: number): State<number, number> =>\n        (s) =>\n          [n * 2, s + 1]\n    )\n    const right: _.StateReaderTaskEither<number, unknown, never, number> = _.right(3)\n    U.deepStrictEqual(await pipe(right, f)(2)({})(), E.right([6, 3]))\n    const left: _.StateReaderTaskEither<number, unknown, string, number> = _.left('a')\n    U.deepStrictEqual(await pipe(left, f)(2)({})(), E.left('a'))\n  })\n\n  it('local', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.asks((n: number) => n + 1),\n        _.local(S.size)\n      )({})('aaa')(),\n      E.right(tuple(4, {}))\n    )\n  })\n\n  it('asksStateReaderTaskEither', async () => {\n    interface Env {\n      readonly count: number\n    }\n    const e: Env = { count: 0 }\n    const f = (e: Env) => _.of(e.count + 1)\n    U.deepStrictEqual(await _.asksStateReaderTaskEither(f)({})(e)(), E.right(tuple(1, {})))\n  })\n\n  it('tapEither', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.tapEither(f), _.evaluate(state))({})(), E.right('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.tapEither(g), _.evaluate(state))({})(), E.left(1))\n  })\n\n  it('chainFirstEitherK', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstEitherK(f), _.evaluate(state))({})(), E.right('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstEitherK(g), _.evaluate(state))({})(), E.left(1))\n  })\n\n  it('tapIO', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => () => ref.push(value)\n\n    U.deepStrictEqual(await pipe(_.ask<unknown, number>(), _.tapIO(add), _.evaluate(state))(1)(), E.of(1))\n    U.deepStrictEqual(await pipe(_.left('error'), _.tapIO(add), _.evaluate(state))(undefined)(), E.left('error'))\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('tapTask', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => T.fromIO(() => ref.push(value))\n\n    U.deepStrictEqual(await pipe(_.ask<unknown, number>(), _.tapTask(add), _.evaluate(state))(1)(), E.of(1))\n    U.deepStrictEqual(await pipe(_.left('error'), _.tapTask(add), _.evaluate(state))(undefined)(), E.left('error'))\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('as', async () => {\n    U.deepStrictEqual(await pipe(_.right('a'), _.as('b'), _.evaluate(state))(undefined)(), E.right('b'))\n    U.deepStrictEqual(await pipe(_.as(_.left('error'), 'b'), _.evaluate(state))(undefined)(), E.left('error'))\n  })\n\n  it('asUnit', async () => {\n    U.deepStrictEqual(await pipe(_.of('a'), _.asUnit, _.evaluate(state))(undefined)(), E.of(undefined))\n  })\n\n  it('tapReader', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.tapReader(_.of(1), () => R.of(2)),\n        _.evaluate(state)\n      )({})(),\n      E.of(1)\n    )\n  })\n\n  it('flatMapIO', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.of(1),\n        _.flatMapIO(() => I.of(2)),\n        _.evaluate(state)\n      )(undefined)(),\n      E.of(2)\n    )\n  })\n\n  it('flatMapTask', async () => {\n    const f = (s: string) => T.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.flatMapTask(f), _.evaluate(state))(undefined)(), E.of(1))\n  })\n\n  it('flatMapReader', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.flatMapReader(_.of(1), () => R.of(2)),\n        _.evaluate(state)\n      )(undefined)(),\n      E.of(2)\n    )\n  })\n\n  it('flatMapIOEither', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.flatMapIOEither(_.of(1), () => IE.of(2)),\n        _.evaluate(state)\n      )(undefined)(),\n      E.of(2)\n    )\n  })\n  it('flatMapEither', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.flatMapEither(_.of(1), () => E.of(2)),\n        _.evaluate(state)\n      )(undefined)(),\n      E.of(2)\n    )\n  })\n\n  it('flatMapOption', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.flatMapOption(\n          _.of(1),\n          () => O.of(2),\n          () => 'error'\n        ),\n        _.evaluate(state)\n      )(undefined)(),\n      E.of(2)\n    )\n\n    U.deepStrictEqual(\n      await pipe(\n        _.flatMapOption(\n          _.of(1),\n          () => O.none,\n          () => 'error'\n        ),\n        _.evaluate(state)\n      )(undefined)(),\n      E.left('error')\n    )\n  })\n\n  it('flatMapReaderTaskEither', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.flatMapReaderTaskEither(_.of(1), () => RTE.of(2)),\n        _.evaluate(state)\n      )(undefined)(),\n      E.of(2)\n    )\n  })\n\n  it('flatMapState', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.flatMapState(_.of(1), () => stateOf(2)),\n        _.evaluate(state)\n      )(undefined)(),\n      E.of(2)\n    )\n  })\n})\n"
  },
  {
    "path": "test/Store.ts",
    "content": "import { pipe } from '../src/function'\nimport * as RA from '../src/ReadonlyArray'\nimport * as _ from '../src/Store'\nimport * as S from '../src/string'\nimport * as U from './util'\n\ndescribe('Store', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      const wa: _.Store<string, number> = { peek: S.size, pos: 'a' }\n      U.deepStrictEqual(\n        _.extract(\n          pipe(\n            wa,\n            _.map((n) => n + 1)\n          )\n        ),\n        2\n      )\n    })\n\n    it('extend', () => {\n      const wa: _.Store<string, number> = { peek: S.size, pos: 'a' }\n      U.deepStrictEqual(\n        _.extract(\n          pipe(\n            wa,\n            _.extend((wa) =>\n              _.extract(\n                pipe(\n                  wa,\n                  _.map((n) => n + 1)\n                )\n              )\n            )\n          )\n        ),\n        2\n      )\n    })\n\n    it('duplicate', () => {\n      const wa: _.Store<string, number> = { peek: S.size, pos: 'a' }\n      U.deepStrictEqual(_.extract(_.extract(pipe(wa, _.duplicate))), 1)\n    })\n  })\n\n  it('seek', () => {\n    const wa: _.Store<string, number> = { peek: S.size, pos: 'a' }\n    U.deepStrictEqual(_.extract(pipe(wa, _.seek('aa'))), 2)\n  })\n\n  it('seeks', () => {\n    const wa: _.Store<string, number> = { peek: S.size, pos: 'a' }\n    U.deepStrictEqual(\n      _.extract(\n        pipe(\n          wa,\n          _.seeks((s) => s + 'a')\n        )\n      ),\n      2\n    )\n  })\n\n  it('peeks', () => {\n    const wa: _.Store<string, number> = { peek: S.size, pos: 'a' }\n    U.deepStrictEqual(\n      pipe(\n        wa,\n        _.peeks((s) => s + 'a')\n      ),\n      2\n    )\n  })\n\n  it('experiment', () => {\n    const wa: _.Store<string, number> = { peek: S.size, pos: 'a' }\n    U.deepStrictEqual(\n      pipe(\n        wa,\n        _.experiment(RA.Functor)((s) => [s, s + 'a'])\n      ),\n      [1, 2]\n    )\n  })\n})\n"
  },
  {
    "path": "test/Strong.ts",
    "content": "import * as R from '../src/Reader'\nimport { fanout, splitStrong } from '../src/Strong'\nimport * as U from './util'\n\ndescribe('Strong', () => {\n  it('splitStrong', () => {\n    const ab = (s: string) => s.length\n    const cd = (n: number) => n >= 2\n    U.deepStrictEqual(splitStrong({ ...R.Strong, ...R.Category })(ab, cd)(['foo', 2]), [3, true])\n    U.deepStrictEqual(splitStrong({ ...R.Strong, ...R.Category })(ab, cd)(['a', 1]), [1, false])\n  })\n\n  it('fanout', () => {\n    const ab = (s: string) => s.length\n    const ac = (s: string) => s === s.toLowerCase()\n    U.deepStrictEqual(fanout({ ...R.Strong, ...R.Category })(ab, ac)('foo'), [3, true])\n    U.deepStrictEqual(fanout({ ...R.Strong, ...R.Category })(ab, ac)('A'), [1, false])\n  })\n})\n"
  },
  {
    "path": "test/Task.ts",
    "content": "import * as assert from 'assert'\n\nimport { pipe, SK } from '../src/function'\nimport * as I from '../src/IO'\nimport * as RA from '../src/ReadonlyArray'\nimport * as RNEA from '../src/ReadonlyNonEmptyArray'\nimport * as S from '../src/string'\nimport * as _ from '../src/Task'\nimport * as U from './util'\n\nconst delayReject =\n  <A>(n: number, a: A): _.Task<A> =>\n  () =>\n    new Promise<A>((_, reject) => {\n      setTimeout(() => reject(a), n)\n    })\n\nconst delay = <A>(millis: number, a: A): _.Task<A> => _.delay(millis)(_.of(a))\n\nconst assertOp =\n  <A, B, C>(f: (a: _.Task<A>, b: _.Task<B>) => _.Task<C>) =>\n  async (a: _.Task<A>, b: _.Task<B>, expected: C, expectedLog: ReadonlyArray<A | B>) => {\n    const log: Array<unknown> = []\n    const append: <A>(ma: _.Task<A>) => _.Task<A> = _.chainFirst((x) =>\n      _.fromIO(() => {\n        log.push(x)\n      })\n    )\n    const c = await pipe(f(pipe(a, append), pipe(b, append)))()\n    U.deepStrictEqual(c, expected)\n    assert.deepStrictEqual(log, expectedLog)\n  }\n\ndescribe('Task', () => {\n  // -------------------------------------------------------------------------------------\n  // safety\n  // -------------------------------------------------------------------------------------\n  // it('stack-safe', async () => {\n  //   const doProcessing = (number: number) => _.of(number * 2)\n  //   const pipeline = pipe(_.of(RNEA.range(1, 55000)), _.chain(RNEA.traverse(_.ApplicativeSeq)(doProcessing)))\n\n  //   const res = await pipeline()\n\n  //   expect(res.length).toBe(55000)\n  // })\n\n  // -------------------------------------------------------------------------------------\n  // pipeables\n  // -------------------------------------------------------------------------------------\n\n  it('map', async () => {\n    U.deepStrictEqual(await pipe(delay(1, 2), _.map(U.double))(), 4)\n  })\n\n  it('ap', async () => {\n    const deepStrictEqual = assertOp<string, string, string>((a, b) =>\n      pipe(\n        _.of((a: string) => (b: string) => a + b),\n        _.ap(a),\n        _.ap(b)\n      )\n    )\n    const a = pipe(_.of('a'), _.delay(100))\n    const b = _.of('b')\n    await deepStrictEqual(a, b, 'ab', ['b', 'a'])\n  })\n\n  it('apFirst', async () => {\n    const deepStrictEqual = assertOp((a, b) => pipe(a, _.apFirst(b)))\n    const a = pipe(_.of('a'), _.delay(100))\n    const b = _.of('b')\n    await deepStrictEqual(a, b, 'a', ['b', 'a'])\n  })\n\n  it('apSecond', async () => {\n    const deepStrictEqual = assertOp((a, b) => pipe(a, _.apSecond(b)))\n    const a = pipe(_.of('a'), _.delay(100))\n    const b = _.of('b')\n    await deepStrictEqual(a, b, 'b', ['b', 'a'])\n  })\n\n  it('flatMap', async () => {\n    const f =\n      (n: number): _.Task<number> =>\n      () =>\n        Promise.resolve(n * 2)\n    U.deepStrictEqual(await pipe(delay(1, 2), _.flatMap(f))(), 4)\n    U.deepStrictEqual(await _.flatMap(delay(1, 2), f)(), 4)\n  })\n\n  it('chain', async () => {\n    const f =\n      (n: number): _.Task<number> =>\n      () =>\n        Promise.resolve(n * 2)\n    U.deepStrictEqual(await pipe(delay(1, 2), _.chain(f))(), 4)\n  })\n\n  it('tap', async () => {\n    const f =\n      (n: number): _.Task<number> =>\n      () =>\n        Promise.resolve(n * 2)\n    U.deepStrictEqual(await pipe(delay(1, 2), _.tap(f))(), 2)\n    U.deepStrictEqual(await _.tap(delay(1, 2), f)(), 2)\n  })\n\n  it('chainFirst', async () => {\n    const f =\n      (n: number): _.Task<number> =>\n      () =>\n        Promise.resolve(n * 2)\n    U.deepStrictEqual(await pipe(delay(1, 2), _.chainFirst(f))(), 2)\n  })\n\n  it('flatten', async () => {\n    U.deepStrictEqual(await pipe(_.of(_.of('a')), _.flatten)(), 'a')\n  })\n\n  it('fromIO', async () => {\n    const io = () => 1\n    const t = _.fromIO(io)\n    U.deepStrictEqual(await t(), 1)\n  })\n\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('applicativeTaskSeq', async () => {\n    await U.assertSeq(_.ApplicativeSeq, _.FromTask, (fa) => fa())\n  })\n\n  it('applicativeTaskPar', async () => {\n    await U.assertPar(_.ApplicativePar, _.FromTask, (fa) => fa())\n  })\n\n  describe('getRaceMonoid', () => {\n    const M = _.getRaceMonoid<number>()\n\n    it('concat', async () => {\n      U.deepStrictEqual(await M.concat(delay(10, 1), delay(10, 2))(), 1)\n    })\n\n    it('empty (right)', async () => {\n      U.deepStrictEqual(await M.concat(delay(10, 1), M.empty)(), 1)\n    })\n\n    it('empty (left)', async () => {\n      U.deepStrictEqual(await M.concat(M.empty, delay(10, 1))(), 1)\n    })\n\n    it('concat (rejected)', async () => {\n      try {\n        await M.concat(delayReject(10, 1), delayReject(10, 2))()\n      } catch (actual) {\n        return U.deepStrictEqual(actual, 1)\n      }\n    })\n  })\n\n  it('getMonoid', async () => {\n    const M = _.getMonoid(S.Monoid)\n    const deepStrictEqual = assertOp(M.concat)\n    const a = pipe(_.of('a'), _.delay(100))\n    const b = _.of('b')\n    await deepStrictEqual(a, b, 'ab', ['a', 'b'])\n    await deepStrictEqual(a, M.empty, 'a', ['a', ''])\n    await deepStrictEqual(M.empty, b, 'b', ['', 'b'])\n  })\n\n  // -------------------------------------------------------------------------------------\n  // combinators\n  // -------------------------------------------------------------------------------------\n\n  it('chainIOK', async () => {\n    const f = (s: string) => I.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.chainIOK(f))(), 1)\n  })\n\n  it('chainFirstIOK', async () => {\n    const f = (s: string) => I.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.chainFirstIOK(f))(), 'a')\n  })\n\n  it('tapIO', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => () => ref.push(value)\n\n    U.deepStrictEqual(await pipe(_.of(1), _.tapIO(add))(), 1)\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('do notation', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )(),\n      { a: 1, b: 'b', c: [1, 'b'] }\n    )\n  })\n\n  it('apS', async () => {\n    U.deepStrictEqual(await pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b')))(), { a: 1, b: 'b' })\n  })\n\n  describe('array utils', () => {\n    const input: RNEA.ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', async () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => _.of(a + i))\n      U.deepStrictEqual(await pipe(RA.empty, f)(), RA.empty)\n      U.deepStrictEqual(await pipe(input, f)(), ['a0', 'b1'])\n    })\n\n    it('traverseReadonlyArrayWithIndexSeq', async () => {\n      const f = _.traverseReadonlyArrayWithIndexSeq((i, a: string) => _.of(a + i))\n      U.deepStrictEqual(await pipe(RA.empty, f)(), RA.empty)\n      U.deepStrictEqual(await pipe(input, f)(), ['a0', 'b1'])\n    })\n\n    it('sequenceReadonlyArray', async () => {\n      const log: Array<number> = []\n      const append = (n: number): _.Task<number> =>\n        _.delay(n % 2 === 0 ? 50 : 100)(\n          _.fromIO(() => {\n            log.push(n)\n            return n\n          })\n        )\n      const as = RA.makeBy(4, append)\n      U.deepStrictEqual(await pipe(as, _.traverseReadonlyArrayWithIndex(SK))(), [0, 1, 2, 3])\n      U.deepStrictEqual(log, [0, 2, 1, 3])\n    })\n\n    it('sequenceReadonlyArraySeq', async () => {\n      const log: Array<number> = []\n      const append = (n: number): _.Task<number> =>\n        _.delay(n % 2 === 0 ? 50 : 100)(\n          _.fromIO(() => {\n            log.push(n)\n            return n\n          })\n        )\n      const as = RA.makeBy(4, append)\n      U.deepStrictEqual(await pipe(as, _.traverseReadonlyArrayWithIndexSeq(SK))(), [0, 1, 2, 3])\n      U.deepStrictEqual(log, [0, 1, 2, 3])\n    })\n\n    // old\n    it('sequenceArray', async () => {\n      const log: Array<number> = []\n      const append = (n: number): _.Task<number> =>\n        _.delay(n % 2 === 0 ? 50 : 100)(\n          _.fromIO(() => {\n            log.push(n)\n            return n\n          })\n        )\n      const as = RA.makeBy(4, append)\n      U.deepStrictEqual(await pipe(as, _.sequenceArray)(), [0, 1, 2, 3])\n      U.deepStrictEqual(log, [0, 2, 1, 3])\n    })\n\n    it('sequenceSeqArray', async () => {\n      const log: Array<number> = []\n      const append = (n: number): _.Task<number> =>\n        _.delay(n % 2 === 0 ? 50 : 100)(\n          _.fromIO(() => {\n            log.push(n)\n            return n\n          })\n        )\n      const as = RA.makeBy(4, append)\n      U.deepStrictEqual(await pipe(as, _.sequenceSeqArray)(), [0, 1, 2, 3])\n      U.deepStrictEqual(log, [0, 1, 2, 3])\n    })\n  })\n\n  it('as', async () => {\n    U.deepStrictEqual(await pipe(_.of('a'), _.as('b'))(), 'b')\n  })\n\n  it('asUnit', async () => {\n    U.deepStrictEqual(await pipe(_.of('a'), _.asUnit)(), undefined)\n  })\n\n  it('flatMapIO', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.of(1),\n        _.flatMapIO(() => I.of(2))\n      )(),\n      2\n    )\n  })\n})\n"
  },
  {
    "path": "test/TaskEither.ts",
    "content": "import { sequenceT } from '../src/Apply'\nimport * as E from '../src/Either'\nimport { constVoid, identity, pipe, SK } from '../src/function'\nimport * as I from '../src/IO'\nimport * as IE from '../src/IOEither'\nimport { monoidString } from '../src/Monoid'\nimport * as N from '../src/number'\nimport { none, some } from '../src/Option'\nimport { pipeable } from '../src/pipeable'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport { left, right } from '../src/Separated'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as _ from '../src/TaskEither'\nimport * as TO from '../src/TaskOption'\nimport * as U from './util'\n\ndescribe('TaskEither', () => {\n  // -------------------------------------------------------------------------------------\n  // pipeables\n  // -------------------------------------------------------------------------------------\n\n  it('alt', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.left('a'),\n        _.alt(() => _.right(1))\n      )(),\n      E.right(1)\n    )\n  })\n\n  it('map', async () => {\n    U.deepStrictEqual(await pipe(_.right(1), _.map(U.double))(), E.right(2))\n  })\n\n  it('ap', async () => {\n    U.deepStrictEqual(await pipe(_.right(U.double), _.ap(_.right(1)))(), E.right(2))\n  })\n\n  it('apFirst', async () => {\n    U.deepStrictEqual(await pipe(_.right('a'), _.apFirst(_.right('b')))(), E.right('a'))\n  })\n\n  it('apFirstW', async () => {\n    U.deepStrictEqual(\n      await pipe(_.right<number, string>('foo'), _.apFirstW(_.right<string, boolean>(true)))(),\n      E.right('foo')\n    )\n  })\n\n  it('apSecond', async () => {\n    U.deepStrictEqual(await pipe(_.right('a'), _.apSecond(_.right('b')))(), E.right('b'))\n  })\n\n  it('apSecondW', async () => {\n    U.deepStrictEqual(\n      await pipe(_.right<number, string>('foo'), _.apSecondW(_.right<string, boolean>(true)))(),\n      E.right(true)\n    )\n  })\n\n  it('flatMap', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right('foo'),\n        _.flatMap((a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))\n      )(),\n      E.right(3)\n    )\n    U.deepStrictEqual(\n      await _.flatMap(_.right('foo'), (a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))(),\n      E.right(3)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.right('a'),\n        _.flatMap((a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))\n      )(),\n      E.left('foo')\n    )\n    U.deepStrictEqual(\n      await _.flatMap(_.right('a'), (a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))(),\n      E.left('foo')\n    )\n  })\n\n  it('chain', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right('foo'),\n        _.chain((a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))\n      )(),\n      E.right(3)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.right('a'),\n        _.chain((a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))\n      )(),\n      E.left('foo')\n    )\n  })\n\n  it('tap', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right('foo'),\n        _.tap((a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))\n      )(),\n      E.right('foo')\n    )\n    U.deepStrictEqual(\n      await _.tap(_.right('foo'), (a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))(),\n      E.right('foo')\n    )\n  })\n\n  it('chainFirst', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right('foo'),\n        _.chainFirst((a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))\n      )(),\n      E.right('foo')\n    )\n  })\n\n  it('chainFirstW', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right<number, string>('foo'),\n        _.chainFirstW((a) => (a.length > 2 ? _.right(a.length) : _.left('foo')))\n      )(),\n      E.right('foo')\n    )\n  })\n\n  it('flatten', async () => {\n    U.deepStrictEqual(await pipe(_.right(_.right('a')), _.flatten)(), E.right('a'))\n  })\n\n  it('flattenW', async () => {\n    U.deepStrictEqual(\n      await pipe(_.right<'left1', _.TaskEither<'left2', 'a'>>(_.right('a')), _.flattenW)(),\n      E.right('a')\n    )\n  })\n\n  it('bimap', async () => {\n    const f = (s: string): number => s.length\n    const g = (n: number): boolean => n > 2\n\n    U.deepStrictEqual(await pipe(_.right(1), _.bimap(f, g))(), E.right(false))\n    U.deepStrictEqual(await pipe(_.left('foo'), _.bimap(f, g))(), E.left(3))\n  })\n\n  it('mapLeft', async () => {\n    U.deepStrictEqual(await pipe(_.left(1), _.mapLeft(U.double))(), E.left(2))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('getApplicativeTaskValidation', async () => {\n    const A = _.getApplicativeTaskValidation(T.ApplicativePar, S.Semigroup)\n    U.deepStrictEqual(await sequenceT(A)(_.left('a'), _.left('b'))(), E.left('ab'))\n    const AV = _.getTaskValidation(S.Semigroup)\n    U.deepStrictEqual(await sequenceT(AV)(_.left('a'), _.left('b'))(), E.left('ab'))\n  })\n\n  it('getAltTaskValidation', async () => {\n    const A = _.getAltTaskValidation(S.Semigroup)\n    U.deepStrictEqual(await A.alt(_.left('a'), () => _.left('b'))(), E.left('ab'))\n    const AV = _.getTaskValidation(S.Semigroup)\n    U.deepStrictEqual(await AV.alt(_.left('a'), () => _.left('b'))(), E.left('ab'))\n  })\n\n  describe('getTaskValidation', () => {\n    const TV = _.getTaskValidation(S.Semigroup)\n\n    it('ap', async () => {\n      const fab = _.left('a')\n      const fa = _.left('b')\n      U.deepStrictEqual(await TV.ap(fab, fa)(), E.left('ab'))\n    })\n\n    it('alt', async () => {\n      U.deepStrictEqual(await TV.alt(_.right(1), () => _.right(2))(), E.right(1))\n      U.deepStrictEqual(await TV.alt(_.left('a'), () => _.right(2))(), E.right(2))\n      U.deepStrictEqual(await TV.alt(_.right(1), () => _.left('b'))(), E.right(1))\n      U.deepStrictEqual(await TV.alt(_.left('a'), () => _.left('b'))(), E.left('ab'))\n    })\n  })\n\n  describe('getCompactable', () => {\n    const C = _.getCompactable(S.Monoid)\n\n    it('compact', async () => {\n      U.deepStrictEqual(await C.compact(_.right(some(1)))(), E.right(1))\n    })\n\n    it('separate', async () => {\n      const s1 = C.separate(_.left('a'))\n      U.deepStrictEqual(await left(s1)(), E.left('a'))\n      U.deepStrictEqual(await right(s1)(), E.left('a'))\n      const s2 = C.separate(_.right(E.left('a')))\n      U.deepStrictEqual(await left(s2)(), E.right('a'))\n      U.deepStrictEqual(await right(s2)(), E.left(''))\n      const s3 = C.separate(_.right(E.right(1)))\n      U.deepStrictEqual(await left(s3)(), E.left(''))\n      U.deepStrictEqual(await right(s3)(), E.right(1))\n    })\n  })\n\n  describe('getFilterable', () => {\n    const F_ = _.getFilterable(RA.getMonoid<string>())\n    const { filter, filterMap, partition, partitionMap } = pipeable(F_)\n\n    it('filter', async () => {\n      U.deepStrictEqual(\n        await pipe(\n          _.right(1),\n          filter((n) => n > 0)\n        )(),\n        await _.right(1)()\n      )\n      U.deepStrictEqual(\n        await pipe(\n          _.right(-1),\n          filter((n) => n > 0)\n        )(),\n        await _.left([])()\n      )\n      U.deepStrictEqual(\n        await pipe(\n          _.left(['a']),\n          filter((n) => n > 0)\n        )(),\n        await _.left(['a'])()\n      )\n    })\n\n    it('filterMap', async () => {\n      U.deepStrictEqual(\n        await pipe(\n          _.right('aaa'),\n          filterMap((s) => (s.length > 1 ? some(s.length) : none))\n        )(),\n        E.right(3)\n      )\n      U.deepStrictEqual(\n        await pipe(\n          _.right('a'),\n          filterMap((s) => (s.length > 1 ? some(s.length) : none))\n        )(),\n        E.left([])\n      )\n      U.deepStrictEqual(\n        await pipe(\n          _.left<ReadonlyArray<string>, string>(['e']),\n          filterMap((s) => (s.length > 1 ? some(s.length) : none))\n        )(),\n        E.left(['e'])\n      )\n    })\n\n    it('partition', async () => {\n      const s = pipe(\n        _.right('a'),\n        partition((s) => s.length > 2)\n      )\n      U.deepStrictEqual(await left(s)(), E.right('a'))\n      U.deepStrictEqual(await right(s)(), E.left([]))\n    })\n\n    it('partitionMap', async () => {\n      const s = pipe(\n        _.right('a'),\n        partitionMap((s) => (s.length > 2 ? E.right(s.length) : E.left(false)))\n      )\n      U.deepStrictEqual(await left(s)(), E.right(false))\n      U.deepStrictEqual(await right(s)(), E.left([]))\n    })\n  })\n\n  describe('getSemigroup', () => {\n    it('concat', async () => {\n      const S = _.getSemigroup<string, number>(N.SemigroupSum)\n      U.deepStrictEqual(await S.concat(_.left('a'), _.left('b'))(), E.left('a'))\n      U.deepStrictEqual(await S.concat(_.left('a'), _.right(2))(), E.right(2))\n      U.deepStrictEqual(await S.concat(_.right(1), _.left('b'))(), E.right(1))\n      U.deepStrictEqual(await S.concat(_.right(1), _.right(2))(), E.right(3))\n    })\n  })\n\n  describe('getApplyMonoid', () => {\n    const M = _.getApplyMonoid(monoidString)\n\n    it('concat (right)', async () => {\n      return U.deepStrictEqual(await M.concat(_.right('a'), _.right('b'))(), E.right('ab'))\n    })\n\n    it('concat (left)', async () => {\n      return U.deepStrictEqual(await M.concat(_.right('a'), _.left('b'))(), E.left('b'))\n    })\n\n    it('empty (right)', async () => {\n      return U.deepStrictEqual(await M.concat(_.right('a'), M.empty)(), E.right('a'))\n    })\n\n    it('empty (left)', async () => {\n      return U.deepStrictEqual(await M.concat(M.empty, _.right('a'))(), E.right('a'))\n    })\n  })\n\n  it('applicativeTaskEitherSeq', async () => {\n    await U.assertSeq(_.ApplicativeSeq, _.FromTask, (fa) => fa())\n  })\n\n  it('applicativeTaskEitherPar', async () => {\n    await U.assertPar(_.ApplicativePar, _.FromTask, (fa) => fa())\n  })\n\n  // -------------------------------------------------------------------------------------\n  // utils\n  // -------------------------------------------------------------------------------------\n\n  it('taskify', async () => {\n    const api1 = (_path: string, callback: (err: Error | null | undefined, result?: string) => void): void => {\n      callback(null, 'ok')\n    }\n    const api2 = (_path: string, callback: (err: Error | null | undefined, result?: string) => void): void => {\n      callback(undefined, 'ok')\n    }\n    const api3 = (_path: string, callback: (err: Error | null | undefined, result?: string) => void): void => {\n      callback(new Error('ko'))\n    }\n    U.deepStrictEqual(await _.taskify(api1)('foo')(), E.right('ok'))\n    U.deepStrictEqual(await _.taskify(api2)('foo')(), E.right('ok'))\n    U.deepStrictEqual(await _.taskify(api3)('foo')(), E.left(new Error('ko')))\n  })\n\n  it('composed taskify', async () => {\n    const api = (callback: (err: Error | null | undefined, result?: string) => void): void => {\n      callback(null, 'ok')\n    }\n    const taskApi = _.taskify(api)()\n\n    U.deepStrictEqual(await taskApi(), E.right('ok'))\n    U.deepStrictEqual(await taskApi(), E.right('ok'))\n  })\n\n  describe('bracket', () => {\n    let log: Array<string> = []\n\n    const acquireFailure = _.left('acquire failure')\n    const acquireSuccess = _.right({ res: 'acquire success' })\n    const useSuccess = () => _.right('use success')\n    const useFailure = () => _.left('use failure')\n    const releaseSuccess = () =>\n      _.rightIO(() => {\n        log.push('release success')\n      })\n    const releaseFailure = () => _.left('release failure')\n\n    beforeEach(() => {\n      log = []\n    })\n\n    it('should return the acquire error if acquire fails', async () => {\n      U.deepStrictEqual(await _.bracket(acquireFailure, useSuccess, releaseSuccess)(), E.left('acquire failure'))\n    })\n\n    it('body and release must not be called if acquire fails', async () => {\n      await _.bracket(acquireFailure, useSuccess, releaseSuccess)()\n      U.deepStrictEqual(log, [])\n    })\n\n    it('should return the use error if use fails and release does not', async () => {\n      U.deepStrictEqual(await _.bracket(acquireSuccess, useFailure, releaseSuccess)(), E.left('use failure'))\n    })\n\n    it('should return the release error if both use and release fail', async () => {\n      U.deepStrictEqual(await _.bracket(acquireSuccess, useFailure, releaseFailure)(), E.left('release failure'))\n    })\n\n    it('release must be called if the body returns', async () => {\n      await _.bracket(acquireSuccess, useSuccess, releaseSuccess)()\n      U.deepStrictEqual(log, ['release success'])\n    })\n\n    it('release must be called if the body throws', async () => {\n      await _.bracket(acquireSuccess, useFailure, releaseSuccess)()\n      U.deepStrictEqual(log, ['release success'])\n    })\n\n    it('should return the release error if release fails', async () => {\n      U.deepStrictEqual(await _.bracket(acquireSuccess, useSuccess, releaseFailure)(), E.left('release failure'))\n    })\n  })\n\n  it('bracketW', async () => {\n    const res = await _.bracketW(\n      _.right<string, string>('string'),\n      (_a: string) => _.right<number, string>('test'),\n      (_a: string, _e: E.Either<number, string>) => _.right<Error, void>(constVoid())\n    )()\n    U.deepStrictEqual(res, E.right('test'))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // combinators\n  // -------------------------------------------------------------------------------------\n\n  it('filterOrElse', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right(12),\n        _.filterOrElse(\n          (n) => n > 10,\n          () => 'a'\n        )\n      )(),\n      E.right(12)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.right(7),\n        _.filterOrElse(\n          (n) => n > 10,\n          () => 'a'\n        )\n      )(),\n      E.left('a')\n    )\n  })\n\n  it('orElse', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.left('foo'),\n        _.orElse((l) => _.right(l.length))\n      )(),\n      E.right(3)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.right(1),\n        _.orElse(() => _.right(2))\n      )(),\n      E.right(1)\n    )\n  })\n\n  it('orElseW', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.left('foo'),\n        _.orElseW((l) => _.right(l.length))\n      )(),\n      E.right(3)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.right(1),\n        _.orElseW(() => _.right(2))\n      )(),\n      E.right(1)\n    )\n  })\n\n  it('tapError', async () => {\n    const f = (e: string) => (e.length <= 1 ? _.right(true) : _.left(e + '!'))\n    U.deepStrictEqual(await pipe(_.right(1), _.tapError(f))(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), _.tapError(f))(), E.left('a'))\n    U.deepStrictEqual(await pipe(_.left('aa'), _.tapError(f))(), E.left('aa!'))\n    U.deepStrictEqual(await _.tapError(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(await _.tapError(_.left('a'), f)(), E.left('a'))\n    U.deepStrictEqual(await _.tapError(_.left('aa'), f)(), E.left('aa!'))\n  })\n\n  it('orElseFirst', async () => {\n    const f = _.orElseFirst((e: string) => (e.length <= 1 ? _.right(true) : _.left(e + '!')))\n    U.deepStrictEqual(await pipe(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), f)(), E.left('a'))\n    U.deepStrictEqual(await pipe(_.left('aa'), f)(), E.left('aa!'))\n  })\n\n  it('orElseFirstW', async () => {\n    const f = _.orElseFirstW((e: string) => (e.length <= 1 ? _.right(true) : _.left(e + '!')))\n    U.deepStrictEqual(await pipe(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), f)(), E.left('a'))\n    U.deepStrictEqual(await pipe(_.left('aa'), f)(), E.left('aa!'))\n  })\n\n  it('orElseFirstIOK', async () => {\n    const f = _.orElseFirstIOK((e: string) => I.of(e.length))\n    U.deepStrictEqual(await pipe(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), f)(), E.left('a'))\n  })\n\n  it('orElseFirstTaskK', async () => {\n    const f = _.orElseFirstTaskK((e: string) => T.of(e.length))\n    U.deepStrictEqual(await pipe(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), f)(), E.left('a'))\n  })\n\n  it('orLeft', async () => {\n    const f = _.orLeft((e: string) => T.of(e + '!'))\n    U.deepStrictEqual(await pipe(_.right(1), f)(), E.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), f)(), E.left('a!'))\n  })\n\n  it('swap', async () => {\n    U.deepStrictEqual(await _.swap(_.right(1))(), E.left(1))\n    U.deepStrictEqual(await _.swap(_.left('a'))(), E.right('a'))\n  })\n\n  it('flatMapEither', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.flatMapEither(f))(), E.right(1))\n  })\n\n  it('chainEitherK', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainEitherK(f))(), E.right(1))\n  })\n\n  it('tapEither', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.tapEither(f))(), E.right('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.tapEither(g))(), E.left(1))\n  })\n\n  it('chainFirstEitherK', async () => {\n    const f = (s: string) => E.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstEitherK(f))(), E.right('a'))\n    const g = (s: string) => E.left(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainFirstEitherK(g))(), E.left(1))\n  })\n\n  it('chainIOEitherK', async () => {\n    const f = (s: string) => IE.right(s.length)\n    U.deepStrictEqual(await pipe(_.right('a'), _.chainIOEitherK(f))(), E.right(1))\n  })\n\n  describe('tryCatchK', () => {\n    test('with a resolved promise', async () => {\n      const g = _.tryCatchK((a: number) => Promise.resolve(a), identity)\n      U.deepStrictEqual(await g(1)(), E.right(1))\n    })\n\n    test('with a rejected promise', async () => {\n      const g = _.tryCatchK((a: number) => Promise.reject(a), identity)\n      U.deepStrictEqual(await g(-1)(), E.left(-1))\n    })\n\n    test('with a thrown error', async () => {\n      const g = _.tryCatchK((_: number) => {\n        throw new Error('Some error')\n      }, identity)\n      U.deepStrictEqual(await g(-1)(), E.left(new Error('Some error')))\n    })\n  })\n\n  // -------------------------------------------------------------------------------------\n  // constructors\n  // -------------------------------------------------------------------------------------\n\n  it('rightIO', async () => {\n    const io = () => 1\n    const fa = _.rightIO(io)\n    U.deepStrictEqual(await fa(), E.right(1))\n  })\n\n  it('leftIO', async () => {\n    U.deepStrictEqual(await _.leftIO(I.of(1))(), E.left(1))\n  })\n\n  describe('tryCatch', () => {\n    test('with a resolving promise', async () => {\n      U.deepStrictEqual(await _.tryCatch(() => Promise.resolve(1), identity)(), E.right(1))\n    })\n\n    test('with a rejected promise', async () => {\n      U.deepStrictEqual(await _.tryCatch(() => Promise.reject(1), identity)(), E.left(1))\n    })\n\n    test('with a thrown error', async () => {\n      U.deepStrictEqual(\n        await _.tryCatch(() => {\n          throw new Error('Some error')\n        }, identity)(),\n        E.left(new Error('Some error'))\n      )\n    })\n  })\n\n  it('fromNullable', async () => {\n    const testNullable = _.fromNullable('foo')\n    U.deepStrictEqual(await testNullable(1)(), E.right(1))\n    U.deepStrictEqual(await testNullable(null)(), E.left('foo'))\n    U.deepStrictEqual(await testNullable(undefined)(), E.left('foo'))\n  })\n\n  it('fromNullableK', async () => {\n    const f = _.fromNullableK('foo')((n: number) => (n > 0 ? n : n === 0 ? null : undefined))\n    U.deepStrictEqual(await f(1)(), E.right(1))\n    U.deepStrictEqual(await f(0)(), E.left('foo'))\n    U.deepStrictEqual(await f(-1)(), E.left('foo'))\n  })\n\n  it('chainNullableK', async () => {\n    const f = _.chainNullableK('foo')((n: number) => (n > 0 ? n : n === 0 ? null : undefined))\n    U.deepStrictEqual(await f(_.of(1))(), E.right(1))\n    U.deepStrictEqual(await f(_.of(0))(), E.left('foo'))\n    U.deepStrictEqual(await f(_.of(-1))(), E.left('foo'))\n  })\n\n  it('fromIOEither', async () => {\n    U.deepStrictEqual(await _.fromIOEither(() => E.right(1))(), E.right(1))\n    U.deepStrictEqual(await _.fromIOEither(() => E.left('foo'))(), E.left('foo'))\n  })\n\n  it('fromOption', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        none,\n        _.fromOption(() => 'none')\n      )(),\n      E.left('none')\n    )\n    U.deepStrictEqual(\n      await pipe(\n        some(1),\n        _.fromOption(() => 'none')\n      )(),\n      E.right(1)\n    )\n  })\n\n  it('fromTaskOption', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        TO.none,\n        _.fromTaskOption(() => 'none')\n      )(),\n      E.left('none')\n    )\n    U.deepStrictEqual(\n      await pipe(\n        TO.some(1),\n        _.fromTaskOption(() => 'none')\n      )(),\n      E.right(1)\n    )\n  })\n\n  it('fromPredicate', async () => {\n    const gt2 = _.fromPredicate(\n      (n: number) => n >= 2,\n      (n) => `Invalid number ${n}`\n    )\n    U.deepStrictEqual(await gt2(3)(), E.right(3))\n    U.deepStrictEqual(await gt2(1)(), E.left('Invalid number 1'))\n    // refinements\n    const isNumber = (u: string | number): u is number => typeof u === 'number'\n    U.deepStrictEqual(await _.fromPredicate(isNumber, () => 'not a number')(4)(), E.right(4))\n  })\n\n  it('do notation', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.right<string, number>(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.right('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      )(),\n      E.right({ a: 1, b: 'b', c: [1, 'b'] })\n    )\n  })\n\n  // TODO: PR #1584\n  // it('do notation ensuring proper param passthrough', async () => {\n  //   const c = (p: { readonly a: number }) => _.right<string, number>(p.a)\n  //   const d = (p: { readonly b: string }) => _.right<string, string>(p.b)\n  //   U.deepStrictEqual(\n  //     await pipe(\n  //       _.right<string, number>(1),\n  //       _.bindTo('a'),\n  //       _.bind('b', () => _.right('b')),\n  //       _.bind('c', c),\n  //       _.bind('d', d),\n  //       _.bind(\n  //         'e',\n  //         _.fromOptionK(() => 'err')((p: { readonly c: number }) => some(p.c))\n  //       ),\n  //       _.bind(\n  //         'f',\n  //         _.fromOptionK(() => 'err')((p) => some(p.b))\n  //       )\n  //     )(),\n  //     E.right({ a: 1, b: 'b', c: 1, d: 'b', e: 1, f: 'b' })\n  //   )\n  // })\n\n  // it('do notation bindW ensuring proper param passthrough', async () => {\n  //   const c = (p: { readonly a: number }) => _.right<string, number>(p.a)\n  //   const d = (p: { readonly b: string }) => _.right<string, string>(p.b)\n  //   U.deepStrictEqual(\n  //     await pipe(\n  //       _.right<string, number>(1),\n  //       _.bindTo('a'),\n  //       _.bindW('b', () => _.right('b')),\n  //       _.bindW('c', c),\n  //       _.bindW('d', d),\n  //       _.bindW(\n  //         'e',\n  //         _.fromOptionK(() => 1)((p: { readonly c: number }) => some(p.c))\n  //       ),\n  //       _.bindW(\n  //         'f',\n  //         _.fromOptionK(() => ({ err: 'err' }))((p) => some(p.b))\n  //       )\n  //     )(),\n  //     E.right({ a: 1, b: 'b', c: 1, d: 'b', e: 1, f: 'b' })\n  //   )\n  // })\n\n  it('apS', async () => {\n    U.deepStrictEqual(\n      await pipe(_.right<string, number>(1), _.bindTo('a'), _.apS('b', _.right('b')))(),\n      E.right({ a: 1, b: 'b' })\n    )\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', async () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.right(a + i) : _.left('e')))\n      U.deepStrictEqual(await pipe(RA.empty, f)(), E.right(RA.empty))\n      U.deepStrictEqual(await pipe(input, f)(), E.right(['a0', 'b1']))\n      U.deepStrictEqual(await pipe(['a', ''], f)(), E.left('e'))\n    })\n\n    it('traverseReadonlyArrayWithIndexSeq', async () => {\n      const f = _.traverseReadonlyArrayWithIndexSeq((i, a: string) => (a.length > 0 ? _.right(a + i) : _.left('e')))\n      U.deepStrictEqual(await pipe(RA.empty, f)(), E.right(RA.empty))\n      U.deepStrictEqual(await pipe(input, f)(), E.right(['a0', 'b1']))\n      U.deepStrictEqual(await pipe(['a', ''], f)(), E.left('e'))\n    })\n\n    it('sequenceReadonlyArray', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.TaskEither<string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.TaskEither<string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(await pipe([right(1), right(2)], _.traverseReadonlyArrayWithIndex(SK))(), E.right([1, 2]))\n      U.deepStrictEqual(await pipe([right(3), left('a')], _.traverseReadonlyArrayWithIndex(SK))(), E.left('a'))\n      U.deepStrictEqual(await pipe([left('b'), right(4)], _.traverseReadonlyArrayWithIndex(SK))(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n    })\n\n    it('sequenceReadonlyArraySeq', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.TaskEither<string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.TaskEither<string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(await pipe([right(1), right(2)], _.traverseReadonlyArrayWithIndexSeq(SK))(), E.right([1, 2]))\n      U.deepStrictEqual(await pipe([right(3), left('a')], _.traverseReadonlyArrayWithIndexSeq(SK))(), E.left('a'))\n      U.deepStrictEqual(await pipe([left('b'), right(4)], _.traverseReadonlyArrayWithIndexSeq(SK))(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n\n    // old\n    it('sequenceArray', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.TaskEither<string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.TaskEither<string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(await pipe([right(1), right(2)], _.sequenceArray)(), E.right([1, 2]))\n      U.deepStrictEqual(await pipe([right(3), left('a')], _.sequenceArray)(), E.left('a'))\n      U.deepStrictEqual(await pipe([left('b'), right(4)], _.sequenceArray)(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n    })\n\n    it('sequenceSeqArray', async () => {\n      const log: Array<number | string> = []\n      const right = (n: number): _.TaskEither<string, number> =>\n        _.rightIO(() => {\n          log.push(n)\n          return n\n        })\n      const left = (s: string): _.TaskEither<string, number> =>\n        _.leftIO(() => {\n          log.push(s)\n          return s\n        })\n      U.deepStrictEqual(await pipe([right(1), right(2)], _.sequenceSeqArray)(), E.right([1, 2]))\n      U.deepStrictEqual(await pipe([right(3), left('a')], _.sequenceSeqArray)(), E.left('a'))\n      U.deepStrictEqual(await pipe([left('b'), right(4)], _.sequenceSeqArray)(), E.left('b'))\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n  })\n\n  it('match', async () => {\n    const f = _.match(\n      () => 'left',\n      () => 'right'\n    )\n    U.deepStrictEqual(await f(_.right(1))(), 'right')\n    U.deepStrictEqual(await f(_.left(''))(), 'left')\n  })\n\n  it('matchE', async () => {\n    const f = _.matchE(\n      () => T.of('left'),\n      () => T.of('right')\n    )\n    U.deepStrictEqual(await f(_.right(1))(), 'right')\n    U.deepStrictEqual(await f(_.left(''))(), 'left')\n  })\n\n  it('chainTaskOptionK', async () => {\n    const f = _.chainTaskOptionK(() => 'a')((n: number) => (n > 0 ? TO.some(n * 2) : TO.none))\n    U.deepStrictEqual(await pipe(_.right(1), f)(), E.right(2))\n    U.deepStrictEqual(await pipe(_.right(-1), f)(), E.left('a'))\n    U.deepStrictEqual(await pipe(_.left('b'), f)(), E.left('b'))\n  })\n\n  it('flatMapTaskOption', async () => {\n    const f = _.flatMapTaskOption(\n      (n: number) => (n > 0 ? TO.some(n * 2) : TO.none),\n      () => 'a'\n    )\n    U.deepStrictEqual(await pipe(_.right(1), f)(), E.right(2))\n    U.deepStrictEqual(await pipe(_.right(-1), f)(), E.left('a'))\n    U.deepStrictEqual(await pipe(_.left('b'), f)(), E.left('b'))\n  })\n\n  it('tapIO', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => () => ref.push(value)\n\n    U.deepStrictEqual(await pipe(_.of(1), _.tapIO(add))(), E.of(1))\n    U.deepStrictEqual(await pipe(_.left('error'), _.tapIO(add))(), E.left('error'))\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('as', async () => {\n    U.deepStrictEqual(await pipe(_.right('a'), _.as('b'))(), E.right('b'))\n    U.deepStrictEqual(await _.as(_.of('a'), 'b')(), E.right('b'))\n    U.deepStrictEqual(await _.as(_.left('error'), 'b')(), E.left('error'))\n  })\n\n  it('asUnit', async () => {\n    U.deepStrictEqual(await pipe(_.of('a'), _.asUnit)(), E.of(undefined))\n  })\n\n  it('tapTask', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => T.fromIO(() => ref.push(value))\n\n    U.deepStrictEqual(await pipe(_.of(1), _.tapTask(add))(), E.of(1))\n    U.deepStrictEqual(await pipe(_.left('error'), _.tapTask(add))(), E.left('error'))\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('flatMapIO', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.of(1),\n        _.flatMapIO(() => I.of(2))\n      )(),\n      E.of(2)\n    )\n  })\n\n  it('flatMapTask', async () => {\n    const f = (s: string) => T.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.flatMapTask(f))(), E.of(1))\n  })\n\n  it('flatMapIOEither', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.of(1),\n        _.flatMapIOEither(() => IE.of(2))\n      )(),\n      E.of(2)\n    )\n  })\n})\n"
  },
  {
    "path": "test/TaskOption.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe, SK } from '../src/function'\nimport * as IO from '../src/IO'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport { ReadonlyNonEmptyArray } from '../src/ReadonlyNonEmptyArray'\nimport * as T from '../src/Task'\nimport * as TE from '../src/TaskEither'\nimport * as _ from '../src/TaskOption'\nimport * as U from './util'\n\ndescribe('TaskOption', () => {\n  // -------------------------------------------------------------------------------------\n  // type class members\n  // -------------------------------------------------------------------------------------\n\n  it('map', async () => {\n    U.deepStrictEqual(await pipe(_.some(1), _.map(U.double))(), O.some(2))\n  })\n\n  it('ap', async () => {\n    U.deepStrictEqual(await pipe(_.some(U.double), _.ap(_.some(2)))(), O.some(4))\n    U.deepStrictEqual(await pipe(_.some(U.double), _.ap(_.none))(), O.none)\n    U.deepStrictEqual(await pipe(_.none, _.ap(_.some(2)))(), O.none)\n    U.deepStrictEqual(await pipe(_.none, _.ap(_.none))(), O.none)\n  })\n\n  it('flatMap', async () => {\n    const f = (n: number) => _.some(n * 2)\n    const g = () => _.none\n    U.deepStrictEqual(await pipe(_.some(1), _.flatMap(f))(), O.some(2))\n    U.deepStrictEqual(await pipe(_.none, _.flatMap(f))(), O.none)\n    U.deepStrictEqual(await pipe(_.some(1), _.flatMap(g))(), O.none)\n    U.deepStrictEqual(await pipe(_.none, _.flatMap(g))(), O.none)\n\n    U.deepStrictEqual(await _.flatMap(_.some(1), f)(), O.some(2))\n    U.deepStrictEqual(await _.flatMap(_.none, f)(), O.none)\n    U.deepStrictEqual(await _.flatMap(_.some(1), g)(), O.none)\n    U.deepStrictEqual(await _.flatMap(_.none, g)(), O.none)\n  })\n\n  it('chain', async () => {\n    const f = (n: number) => _.some(n * 2)\n    const g = () => _.none\n    U.deepStrictEqual(await pipe(_.some(1), _.chain(f))(), O.some(2))\n    U.deepStrictEqual(await pipe(_.none, _.chain(f))(), O.none)\n    U.deepStrictEqual(await pipe(_.some(1), _.chain(g))(), O.none)\n    U.deepStrictEqual(await pipe(_.none, _.chain(g))(), O.none)\n  })\n\n  it('alt', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.some(1),\n        _.alt(() => _.some(2))\n      )(),\n      O.some(1)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.some(2),\n        _.alt(() => _.none as _.TaskOption<number>)\n      )(),\n      O.some(2)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.none,\n        _.alt(() => _.some(1))\n      )(),\n      O.some(1)\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.none,\n        _.alt(() => _.none)\n      )(),\n      O.none\n    )\n  })\n\n  it('zero', async () => {\n    U.deepStrictEqual(await _.zero()(), O.none)\n  })\n\n  it('fromIO', async () => {\n    U.deepStrictEqual(await _.fromIO(() => 1)(), O.some(1))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('ApplicativeSeq', async () => {\n    await U.assertSeq(_.ApplySeq, _.FromTask, (fa) => fa())\n    await U.assertSeq(_.ApplicativeSeq, _.FromTask, (fa) => fa())\n  })\n\n  it('ApplicativePar', async () => {\n    await U.assertPar(_.ApplyPar, _.FromTask, (fa) => fa())\n    await U.assertPar(_.ApplicativePar, _.FromTask, (fa) => fa())\n  })\n\n  // -------------------------------------------------------------------------------------\n  // constructors\n  // -------------------------------------------------------------------------------------\n\n  describe('tryCatch', () => {\n    test('with a resolving promise', async () => {\n      U.deepStrictEqual(await _.tryCatch(() => Promise.resolve(1))(), O.some(1))\n    })\n\n    test('with a rejected promise', async () => {\n      U.deepStrictEqual(await _.tryCatch(() => Promise.reject(1))(), O.none)\n    })\n\n    test('with a thrown error', async () => {\n      U.deepStrictEqual(\n        await _.tryCatch(() => {\n          throw new Error('Some error')\n        })(),\n        O.none\n      )\n    })\n  })\n\n  it('fromNullable', async () => {\n    U.deepStrictEqual(await _.fromNullable(1)(), O.some(1))\n    U.deepStrictEqual(await _.fromNullable(null)(), O.none)\n    U.deepStrictEqual(await _.fromNullable(undefined)(), O.none)\n  })\n\n  it('fromNullableK', async () => {\n    const f = _.fromNullableK((n: number) => (n > 0 ? n : n === 0 ? null : undefined))\n    U.deepStrictEqual(await f(1)(), O.some(1))\n    U.deepStrictEqual(await f(0)(), O.none)\n    U.deepStrictEqual(await f(-1)(), O.none)\n  })\n\n  it('chainNullableK', async () => {\n    const f = _.chainNullableK((n: number) => (n > 0 ? n : n === 0 ? null : undefined))\n    U.deepStrictEqual(await f(_.of(1))(), O.some(1))\n    U.deepStrictEqual(await f(_.of(0))(), O.none)\n    U.deepStrictEqual(await f(_.of(-1))(), O.none)\n  })\n\n  it('fromPredicate', async () => {\n    const p = (n: number): boolean => n > 2\n    const f = _.fromPredicate(p)\n    U.deepStrictEqual(await f(1)(), O.none)\n    U.deepStrictEqual(await f(3)(), O.some(3))\n  })\n\n  it('fromTaskEither', async () => {\n    const pl = TE.left('a')\n    const pr = TE.right('a')\n    const fl = _.fromTaskEither(pl)\n    const fr = _.fromTaskEither(pr)\n    U.deepStrictEqual(await fl(), O.none)\n    U.deepStrictEqual(await fr(), O.some('a'))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // destructors\n  // -------------------------------------------------------------------------------------\n\n  it('fold', async () => {\n    const f = _.fold(\n      () => T.of('none'),\n      (a) => T.of(`some(${a})`)\n    )\n    U.deepStrictEqual(await pipe(_.some(1), f)(), 'some(1)')\n    U.deepStrictEqual(await pipe(_.none, f)(), 'none')\n  })\n\n  it('getOrElse', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.some(1),\n        _.getOrElse(() => T.of(2))\n      )(),\n      1\n    )\n    U.deepStrictEqual(\n      await pipe(\n        _.none,\n        _.getOrElse(() => T.of(2))\n      )(),\n      2\n    )\n  })\n\n  // -------------------------------------------------------------------------------------\n  // combinators\n  // -------------------------------------------------------------------------------------\n\n  it('fromOptionK', async () => {\n    const f = _.fromOptionK((n: number) => (n > 0 ? O.some(n) : O.none))\n    U.deepStrictEqual(await f(1)(), O.some(1))\n    U.deepStrictEqual(await f(-1)(), O.none)\n  })\n\n  it('chainOptionK', async () => {\n    const f = _.chainOptionK((n: number) => (n > 0 ? O.some(n) : O.none))\n    U.deepStrictEqual(await f(_.some(1))(), O.some(1))\n    U.deepStrictEqual(await f(_.some(-1))(), O.none)\n    U.deepStrictEqual(await f(_.none)(), O.none)\n  })\n\n  describe('array utils', () => {\n    const input: ReadonlyNonEmptyArray<string> = ['a', 'b']\n\n    it('traverseReadonlyArrayWithIndex', async () => {\n      const f = _.traverseReadonlyArrayWithIndex((i, a: string) => (a.length > 0 ? _.some(a + i) : _.none))\n      U.deepStrictEqual(await pipe(RA.empty, f)(), O.some(RA.empty))\n      U.deepStrictEqual(await pipe(input, f)(), O.some(['a0', 'b1']))\n      U.deepStrictEqual(await pipe(['a', ''], f)(), O.none)\n    })\n\n    it('traverseReadonlyArrayWithIndexSeq', async () => {\n      const f = _.traverseReadonlyArrayWithIndexSeq((i, a: string) => (a.length > 0 ? _.some(a + i) : _.none))\n      U.deepStrictEqual(await pipe(RA.empty, f)(), O.some(RA.empty))\n      U.deepStrictEqual(await pipe(input, f)(), O.some(['a0', 'b1']))\n      U.deepStrictEqual(await pipe(['a', ''], f)(), O.none)\n    })\n\n    it('sequenceReadonlyArray', async () => {\n      const log: Array<number | string> = []\n      const some = (n: number): _.TaskOption<number> =>\n        _.fromIO(() => {\n          log.push(n)\n          return n\n        })\n      const none = (s: string): _.TaskOption<number> =>\n        pipe(\n          T.fromIO(() => {\n            log.push(s)\n            return s\n          }),\n          T.map(() => O.none)\n        )\n      U.deepStrictEqual(await pipe([some(1), some(2)], _.traverseReadonlyArrayWithIndex(SK))(), O.some([1, 2]))\n      U.deepStrictEqual(await pipe([some(3), none('a')], _.traverseReadonlyArrayWithIndex(SK))(), O.none)\n      U.deepStrictEqual(await pipe([none('b'), some(4)], _.traverseReadonlyArrayWithIndex(SK))(), O.none)\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n    })\n\n    it('sequenceReadonlyArraySeq', async () => {\n      const log: Array<number | string> = []\n      const some = (n: number): _.TaskOption<number> =>\n        _.fromIO(() => {\n          log.push(n)\n          return n\n        })\n      const none = (s: string): _.TaskOption<number> =>\n        pipe(\n          T.fromIO(() => {\n            log.push(s)\n            return s\n          }),\n          T.map(() => O.none)\n        )\n      U.deepStrictEqual(await pipe([some(1), some(2)], _.traverseReadonlyArrayWithIndexSeq(SK))(), O.some([1, 2]))\n      U.deepStrictEqual(await pipe([some(3), none('a')], _.traverseReadonlyArrayWithIndexSeq(SK))(), O.none)\n      U.deepStrictEqual(await pipe([none('b'), some(4)], _.traverseReadonlyArrayWithIndexSeq(SK))(), O.none)\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n\n    // old\n    it('sequenceArray', async () => {\n      const log: Array<number | string> = []\n      const some = (n: number): _.TaskOption<number> =>\n        _.fromIO(() => {\n          log.push(n)\n          return n\n        })\n      const none = (s: string): _.TaskOption<number> =>\n        pipe(\n          T.fromIO(() => {\n            log.push(s)\n            return s\n          }),\n          T.map(() => O.none)\n        )\n      U.deepStrictEqual(await pipe([some(1), some(2)], _.sequenceArray)(), O.some([1, 2]))\n      U.deepStrictEqual(await pipe([some(3), none('a')], _.sequenceArray)(), O.none)\n      U.deepStrictEqual(await pipe([none('b'), some(4)], _.sequenceArray)(), O.none)\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n    })\n\n    it('sequenceSeqArray', async () => {\n      const log: Array<number | string> = []\n      const some = (n: number): _.TaskOption<number> =>\n        _.fromIO(() => {\n          log.push(n)\n          return n\n        })\n      const none = (s: string): _.TaskOption<number> =>\n        pipe(\n          T.fromIO(() => {\n            log.push(s)\n            return s\n          }),\n          T.map(() => O.none)\n        )\n      U.deepStrictEqual(await pipe([some(1), some(2)], _.sequenceSeqArray)(), O.some([1, 2]))\n      U.deepStrictEqual(await pipe([some(3), none('a')], _.sequenceSeqArray)(), O.none)\n      U.deepStrictEqual(await pipe([none('b'), some(4)], _.sequenceSeqArray)(), O.none)\n      U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n    })\n  })\n\n  describe('tryCatchK', () => {\n    test('with a resolved promise', async () => {\n      const g = _.tryCatchK((a: number) => Promise.resolve(a))\n      U.deepStrictEqual(await g(1)(), O.some(1))\n    })\n\n    test('with a rejected promise', async () => {\n      const g = _.tryCatchK((a: number) => Promise.reject(a))\n      U.deepStrictEqual(await g(-1)(), O.none)\n    })\n\n    test('with a thrown error', async () => {\n      const g = _.tryCatchK((_: number) => {\n        throw new Error('Some error')\n      })\n      U.deepStrictEqual(await g(-1)(), O.none)\n    })\n  })\n\n  it('match', async () => {\n    const f = _.match(\n      () => 'none',\n      (a) => `some(${a})`\n    )\n    U.deepStrictEqual(await pipe(_.some(1), f)(), 'some(1)')\n    U.deepStrictEqual(await pipe(_.none, f)(), 'none')\n  })\n\n  it('matchE', async () => {\n    const f = _.matchE(\n      () => T.of('none'),\n      (a) => T.of(`some(${a})`)\n    )\n    U.deepStrictEqual(await pipe(_.some(1), f)(), 'some(1)')\n    U.deepStrictEqual(await pipe(_.none, f)(), 'none')\n  })\n\n  it('fromEitherK', async () => {\n    const f = (s: string) => (s.length <= 2 ? E.right(s + '!') : E.left(s.length))\n    const g = _.fromEitherK(f)\n    U.deepStrictEqual(await g('')(), O.some('!'))\n    U.deepStrictEqual(await g('a')(), O.some('a!'))\n    U.deepStrictEqual(await g('aa')(), O.some('aa!'))\n    U.deepStrictEqual(await g('aaa')(), O.none)\n  })\n\n  it('chainEitherK', async () => {\n    const f = (s: string) => (s.length <= 2 ? E.right(s + '!') : E.left(s.length))\n    const g = _.chainEitherK(f)\n    U.deepStrictEqual(await g(_.of(''))(), O.some('!'))\n    U.deepStrictEqual(await g(_.of('a'))(), O.some('a!'))\n    U.deepStrictEqual(await g(_.of('aa'))(), O.some('aa!'))\n    U.deepStrictEqual(await g(_.of('aaa'))(), O.none)\n  })\n\n  it('tapEither', async () => {\n    const f = (s: string) => (s.length <= 2 ? E.right(s + '!') : E.left(s.length))\n    const g = _.tapEither(f)\n    U.deepStrictEqual(await g(_.of(''))(), O.some(''))\n    U.deepStrictEqual(await g(_.of('a'))(), O.some('a'))\n    U.deepStrictEqual(await g(_.of('aa'))(), O.some('aa'))\n    U.deepStrictEqual(await g(_.of('aaa'))(), O.none)\n  })\n\n  it('chainFirstEitherK', async () => {\n    const f = (s: string) => (s.length <= 2 ? E.right(s + '!') : E.left(s.length))\n    const g = _.chainFirstEitherK(f)\n    U.deepStrictEqual(await g(_.of(''))(), O.some(''))\n    U.deepStrictEqual(await g(_.of('a'))(), O.some('a'))\n    U.deepStrictEqual(await g(_.of('aa'))(), O.some('aa'))\n    U.deepStrictEqual(await g(_.of('aaa'))(), O.none)\n  })\n\n  it('tapIO', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => () => ref.push(value)\n\n    U.deepStrictEqual(await pipe(_.of(1), _.tapIO(add))(), O.of(1))\n    U.deepStrictEqual(await pipe(_.none, _.tapIO(add))(), O.none)\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('as', async () => {\n    U.deepStrictEqual(await pipe(_.some('a'), _.as('b'))(), O.some('b'))\n    U.deepStrictEqual(await _.as(_.of('a'), 'b')(), O.some('b'))\n    U.deepStrictEqual(await _.as(_.none, 'b')(), O.none)\n  })\n\n  it('asUnit', async () => {\n    U.deepStrictEqual(await pipe(_.some('a'), _.asUnit)(), O.some(undefined))\n  })\n\n  it('tapIO', async () => {\n    const ref: Array<number> = []\n    const add = (value: number) => T.fromIO(() => ref.push(value))\n\n    U.deepStrictEqual(await pipe(_.of(1), _.tapTask(add))(), O.of(1))\n    U.deepStrictEqual(await pipe(_.none, _.tapTask(add))(), O.none)\n    U.deepStrictEqual(ref, [1])\n  })\n\n  it('flatMapIO', async () => {\n    U.deepStrictEqual(\n      await pipe(\n        _.of(1),\n        _.flatMapIO(() => IO.of(2))\n      )(),\n      O.of(2)\n    )\n  })\n\n  it('flatMapTask', async () => {\n    const f = (s: string) => T.of(s.length)\n    U.deepStrictEqual(await pipe(_.of('a'), _.flatMapTask(f))(), O.of(1))\n  })\n})\n"
  },
  {
    "path": "test/TaskThese.ts",
    "content": "import * as E from '../src/Either'\nimport { pipe, SK } from '../src/function'\nimport * as IO from '../src/IO'\nimport * as N from '../src/number'\nimport * as RA from '../src/ReadonlyArray'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as _ from '../src/TaskThese'\nimport * as TH from '../src/These'\nimport * as U from './util'\n\ndescribe('TaskThese', () => {\n  // -------------------------------------------------------------------------------------\n  // pipeables\n  // -------------------------------------------------------------------------------------\n\n  it('map', async () => {\n    U.deepStrictEqual(await pipe(_.right(1), _.map(U.double))(), TH.right(2))\n  })\n\n  it('bimap', async () => {\n    const f = (e: string) => e + e\n    const g = (a: number) => a + 1\n    U.deepStrictEqual(await pipe(_.right(1), _.bimap(f, g))(), TH.right(2))\n    U.deepStrictEqual(await pipe(_.left('a'), _.bimap(f, g))(), TH.left('aa'))\n    U.deepStrictEqual(await pipe(_.both('a', 1), _.bimap(f, g))(), TH.both('aa', 2))\n  })\n\n  it('mapLeft', async () => {\n    const f = (e: string) => e + e\n    U.deepStrictEqual(await pipe(_.right(1), _.mapLeft(f))(), TH.right(1))\n    U.deepStrictEqual(await pipe(_.left('a'), _.mapLeft(f))(), TH.left('aa'))\n    U.deepStrictEqual(await pipe(_.both('a', 1), _.mapLeft(f))(), TH.both('aa', 1))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  describe('getApplicative', () => {\n    it('Par', async () => {\n      await U.assertSeq(_.getApplicative(T.ApplicativeSeq, S.Semigroup), _.FromTask, (fa) => fa())\n    })\n\n    it('Seq', async () => {\n      await U.assertPar(_.getApplicative(T.ApplicativePar, S.Semigroup), _.FromTask, (fa) => fa())\n    })\n  })\n\n  it('getSemigroup', async () => {\n    const SSN = _.getSemigroup(S.Semigroup, N.SemigroupSum)\n    U.deepStrictEqual(await SSN.concat(_.right(1), _.right(2))(), TH.right(3))\n    U.deepStrictEqual(await SSN.concat(_.right(1), _.left('a'))(), TH.both('a', 1))\n    U.deepStrictEqual(await SSN.concat(_.left('a'), _.left('b'))(), TH.left('ab'))\n    U.deepStrictEqual(await SSN.concat(_.right(1), _.both('a', 2))(), TH.both('a', 3))\n    U.deepStrictEqual(await SSN.concat(_.left('a'), _.both('b', 2))(), TH.both('ab', 2))\n    U.deepStrictEqual(await SSN.concat(_.both('a', 1), _.both('b', 2))(), TH.both('ab', 3))\n  })\n\n  describe('getMonad', () => {\n    const M = _.getMonad(S.Monoid)\n    it('map', async () => {\n      const f = (n: number): number => n * 2\n      U.deepStrictEqual(await M.map(_.right(1), f)(), TH.right(2))\n      U.deepStrictEqual(await M.map(_.left('a'), f)(), TH.left('a'))\n      U.deepStrictEqual(await M.map(_.both('a', 1), f)(), TH.both('a', 2))\n    })\n\n    it('ap', async () => {\n      const f = (n: number): number => n * 2\n      U.deepStrictEqual(await M.ap(_.right(f), _.right(1))(), TH.right(2))\n    })\n\n    it('chain', async () => {\n      const f = (n: number) => (n > 2 ? _.both(`c`, n * 3) : n > 1 ? _.right(n * 2) : _.left(`b`))\n      U.deepStrictEqual(await M.chain(_.right(1), f)(), TH.left('b'))\n      U.deepStrictEqual(await M.chain(_.right(2), f)(), TH.right(4))\n\n      U.deepStrictEqual(await M.chain(_.left('a'), f)(), TH.left('a'))\n\n      U.deepStrictEqual(await M.chain(_.both('a', 1), f)(), TH.left('ab'))\n      U.deepStrictEqual(await M.chain(_.both('a', 2), f)(), TH.both('a', 4))\n      U.deepStrictEqual(await M.chain(_.both('a', 3), f)(), TH.both('ac', 9))\n    })\n  })\n\n  // -------------------------------------------------------------------------------------\n  // constructors\n  // -------------------------------------------------------------------------------------\n\n  it('right', async () => {\n    const x = await _.right(1)()\n    U.deepStrictEqual(x, TH.right(1))\n  })\n\n  it('left', async () => {\n    const x = await _.left('a')()\n    U.deepStrictEqual(x, TH.left('a'))\n  })\n\n  it('both', async () => {\n    const x = await _.both('a', 1)()\n    U.deepStrictEqual(x, TH.both('a', 1))\n  })\n\n  it('rightIO', async () => {\n    const x = await _.rightIO(IO.of(1))()\n    U.deepStrictEqual(x, TH.right(1))\n  })\n\n  it('leftIO', async () => {\n    const x = await _.leftIO(IO.of('a'))()\n    U.deepStrictEqual(x, TH.left('a'))\n  })\n\n  it('rightTask', async () => {\n    const x = await _.rightTask(T.of(1))()\n    U.deepStrictEqual(x, TH.right(1))\n  })\n\n  it('leftTask', async () => {\n    const x = await _.leftTask(T.of('a'))()\n    U.deepStrictEqual(x, TH.left('a'))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // destructors\n  // -------------------------------------------------------------------------------------\n\n  it('fold', async () => {\n    const f = _.fold(\n      (e) => T.of(`left ${e}`),\n      (a) => T.of(`right ${a}`),\n      (e, a) => T.of(`both ${e} ${a}`)\n    )\n    U.deepStrictEqual(await pipe(_.right(1), f)(), 'right 1')\n    U.deepStrictEqual(await pipe(_.left('a'), f)(), 'left a')\n    U.deepStrictEqual(await pipe(_.both('a', 1), f)(), 'both a 1')\n  })\n\n  it('swap', async () => {\n    U.deepStrictEqual(await _.swap(_.right(1))(), TH.left(1))\n    U.deepStrictEqual(await _.swap(_.left('a'))(), TH.right('a'))\n    U.deepStrictEqual(await _.swap(_.both('a', 1))(), TH.both(1, 'a'))\n  })\n\n  it('toTuple', async () => {\n    const f = _.toTuple('b', 2)\n    U.deepStrictEqual(await f(_.right(1))(), ['b', 1])\n    U.deepStrictEqual(await f(_.left('a'))(), ['a', 2])\n    U.deepStrictEqual(await f(_.both('a', 1))(), ['a', 1])\n  })\n\n  it('match', async () => {\n    const match = _.match(\n      (e) => `left ${e}`,\n      (a) => `right ${a}`,\n      (e, a) => `both ${e} ${a}`\n    )\n    U.deepStrictEqual(await pipe(_.right(1), match)(), 'right 1')\n    U.deepStrictEqual(await pipe(_.left('a'), match)(), 'left a')\n    U.deepStrictEqual(await pipe(_.both('a', 1), match)(), 'both a 1')\n  })\n\n  it('matchE', async () => {\n    const matchE = _.matchE(\n      (e) => T.of(`left ${e}`),\n      (a) => T.of(`right ${a}`),\n      (e, a) => T.of(`both ${e} ${a}`)\n    )\n    U.deepStrictEqual(await pipe(_.right(1), matchE)(), 'right 1')\n    U.deepStrictEqual(await pipe(_.left('a'), matchE)(), 'left a')\n    U.deepStrictEqual(await pipe(_.both('a', 1), matchE)(), 'both a 1')\n  })\n\n  it('fromTheseK', async () => {\n    const g = _.fromTheseK((n: number) => (n > 0 ? TH.right(n) : n === 0 ? TH.both('zero', n) : TH.left('negative')))\n    U.deepStrictEqual(await g(-1)(), TH.left('negative'))\n    U.deepStrictEqual(await g(0)(), TH.both('zero', 0))\n    U.deepStrictEqual(await g(1)(), TH.right(1))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // array utils\n  // -------------------------------------------------------------------------------------\n\n  it('traverseReadonlyArrayWithIndex', async () => {\n    const f = (i: number, n: number) => (n > 0 ? _.right(n + i) : n === 0 ? _.both('a', 0) : _.left(String(n)))\n    const standard = RA.traverseWithIndex(_.getApplicative(T.ApplicativePar, S.Semigroup))(f)\n    const optimized = _.traverseReadonlyArrayWithIndex(S.Semigroup)(f)\n    const assert = async (input: ReadonlyArray<number>) => {\n      U.deepStrictEqual(await standard(input)(), await optimized(input)())\n    }\n    await assert([1, 2, 3])\n    await assert([0, 2, 3])\n    await assert([1, 0, 3])\n    await assert([0, 0, 3])\n    await assert([-1, 2, 3])\n    await assert([1, -2, 3])\n    await assert(RA.empty)\n  })\n\n  it('traverseReadonlyArrayWithIndexSeq', async () => {\n    const f = (i: number, n: number) => (n > 0 ? _.right(n + i) : n === 0 ? _.both('a', 0) : _.left(String(n)))\n    const standard = RA.traverseWithIndex(_.getApplicative(T.ApplicativeSeq, S.Semigroup))(f)\n    const optimized = _.traverseReadonlyArrayWithIndexSeq(S.Semigroup)(f)\n    const assert = async (input: ReadonlyArray<number>) => {\n      U.deepStrictEqual(await standard(input)(), await optimized(input)())\n    }\n    await assert([1, 2, 3])\n    await assert([0, 2, 3])\n    await assert([1, 0, 3])\n    await assert([0, 0, 3])\n    await assert([-1, 2, 3])\n    await assert([1, -2, 3])\n    await assert(RA.empty)\n  })\n\n  it('sequenceReadonlyArray', async () => {\n    const log: Array<number | string> = []\n    const right = (n: number): _.TaskThese<string, number> =>\n      _.rightIO(() => {\n        log.push(n)\n        return n\n      })\n    const left = (s: string): _.TaskThese<string, number> =>\n      _.leftIO(() => {\n        log.push(s)\n        return s\n      })\n    const f = _.traverseReadonlyArrayWithIndex(S.Semigroup)\n    U.deepStrictEqual(await pipe([right(1), right(2)], f(SK))(), E.right([1, 2]))\n    U.deepStrictEqual(await pipe([right(3), left('a')], f(SK))(), E.left('a'))\n    U.deepStrictEqual(await pipe([left('b'), right(4)], f(SK))(), E.left('b'))\n    U.deepStrictEqual(log, [1, 2, 3, 'a', 'b', 4])\n  })\n\n  it('sequenceReadonlyArraySeq', async () => {\n    const log: Array<number | string> = []\n    const right = (n: number): _.TaskThese<string, number> =>\n      _.rightIO(() => {\n        log.push(n)\n        return n\n      })\n    const left = (s: string): _.TaskThese<string, number> =>\n      _.leftIO(() => {\n        log.push(s)\n        return s\n      })\n    const f = _.traverseReadonlyArrayWithIndexSeq(S.Semigroup)\n    U.deepStrictEqual(await pipe([right(1), right(2)], f(SK))(), E.right([1, 2]))\n    U.deepStrictEqual(await pipe([right(3), left('a')], f(SK))(), E.left('a'))\n    U.deepStrictEqual(await pipe([left('b'), right(4)], f(SK))(), E.left('b'))\n    U.deepStrictEqual(log, [1, 2, 3, 'a', 'b'])\n  })\n})\n"
  },
  {
    "path": "test/These.ts",
    "content": "import * as Apply from '../src/Apply'\nimport { identity, pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport * as S from '../src/string'\nimport * as _ from '../src/These'\nimport * as U from './util'\n\ndescribe('These', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      const f = _.map(U.double)\n      U.deepStrictEqual(pipe(_.left(2), f), _.left(2))\n      U.deepStrictEqual(pipe(_.right(2), f), _.right(4))\n      U.deepStrictEqual(pipe(_.both(1, 2), f), _.both(1, 4))\n    })\n\n    it('bimap', () => {\n      const f = _.bimap(S.size, U.double)\n      U.deepStrictEqual(pipe(_.left('a'), f), _.left(1))\n      U.deepStrictEqual(pipe(_.right(2), f), _.right(4))\n      U.deepStrictEqual(pipe(_.both('aaa', 1), f), _.both(3, 2))\n    })\n\n    it('mapLeft', () => {\n      const f = _.mapLeft(S.size)\n      U.deepStrictEqual(pipe(_.left('a'), f), _.left(1))\n      U.deepStrictEqual(pipe(_.right(2), f), _.right(2))\n      U.deepStrictEqual(pipe(_.both('aaa', 1), f), _.both(3, 1))\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          _.left('b'),\n          _.reduce('a', (b, a) => b + a)\n        ),\n        'a'\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.right('b'),\n          _.reduce('a', (b, a) => b + a)\n        ),\n        'ab'\n      )\n      U.deepStrictEqual(\n        pipe(\n          _.both(1, 'b'),\n          _.reduce('a', (b, a) => b + a)\n        ),\n        'ab'\n      )\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe(_.right('a'), _.foldMap(S.Monoid)(identity)), 'a')\n      U.deepStrictEqual(pipe(_.left(1), _.foldMap(S.Monoid)(identity)), '')\n      U.deepStrictEqual(pipe(_.both(1, 'a'), _.foldMap(S.Monoid)(identity)), 'a')\n    })\n\n    it('reduceRight', () => {\n      const f = (a: string, acc: string) => acc + a\n      U.deepStrictEqual(pipe(_.right('a'), _.reduceRight('', f)), 'a')\n      U.deepStrictEqual(pipe(_.left(1), _.reduceRight('', f)), '')\n      U.deepStrictEqual(pipe(_.both(1, 'a'), _.reduceRight('', f)), 'a')\n    })\n\n    it('traverse', () => {\n      const traverse = _.traverse(O.Applicative)((n: number) => (n > 1 ? O.some(n) : O.none))\n      U.deepStrictEqual(pipe(_.left('a'), traverse), O.some(_.left('a')))\n      U.deepStrictEqual(pipe(_.right(2), traverse), O.some(_.right(2)))\n      U.deepStrictEqual(pipe(_.right(1), traverse), O.none)\n      U.deepStrictEqual(pipe(_.both('a', 2), traverse), O.some(_.both('a', 2)))\n      U.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('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      U.deepStrictEqual(sequence(_.left('a')), O.some(_.left('a')))\n      U.deepStrictEqual(sequence(_.right(O.some(1))), O.some(_.right(1)))\n      U.deepStrictEqual(sequence(_.right(O.none)), O.none)\n      U.deepStrictEqual(sequence(_.both('a', O.some(1))), O.some(_.both('a', 1)))\n      U.deepStrictEqual(sequence(_.both('a', O.none)), O.none)\n    })\n  })\n\n  it('ap', () => {\n    const M = _.getApply(S.Semigroup)\n    const sequenceT = Apply.sequenceT(M)\n    U.deepStrictEqual(sequenceT(_.right(1), _.right(2)), _.right([1, 2]))\n    U.deepStrictEqual(sequenceT(_.right(1), _.left('b')), _.left('b'))\n    U.deepStrictEqual(sequenceT(_.right(1), _.both('b', 2)), _.both('b', [1, 2]))\n    U.deepStrictEqual(sequenceT(_.left('a'), _.right(2)), _.left('a'))\n    U.deepStrictEqual(sequenceT(_.left('a'), _.left('b')), _.left('ab'))\n    U.deepStrictEqual(sequenceT(_.left('a'), _.both('b', 2)), _.left('ab'))\n    U.deepStrictEqual(sequenceT(_.both('a', 1), _.right(2)), _.both('a', [1, 2]))\n    U.deepStrictEqual(sequenceT(_.both('a', 1), _.left('b')), _.left('ab'))\n    U.deepStrictEqual(sequenceT(_.both('a', 1), _.both('b', 2)), _.both('ab', [1, 2]))\n  })\n\n  it('chain', () => {\n    const M = _.getChain(S.Semigroup)\n    const f = (n: number) => (n >= 2 ? (n <= 5 ? _.right(n * 2) : _.both('bar', n)) : _.left('bar'))\n    U.deepStrictEqual(M.chain(_.left('foo'), f), _.left('foo'))\n    U.deepStrictEqual(M.chain(_.right(2), f), _.right(4))\n    U.deepStrictEqual(M.chain(_.right(1), f), _.left('bar'))\n    U.deepStrictEqual(M.chain(_.right(6), f), _.both('bar', 6))\n    U.deepStrictEqual(M.chain(_.both('foo', 2), f), _.both('foo', 4))\n    U.deepStrictEqual(M.chain(_.both('foo', 1), f), _.left('foobar'))\n    U.deepStrictEqual(M.chain(_.both('foo', 6), f), _.both('foobar', 6))\n  })\n\n  it('getApplicative', () => {\n    const A = _.getApplicative(S.Semigroup)\n    U.deepStrictEqual(A.of(1), _.right(1))\n  })\n\n  it('getMonad', () => {\n    const M = _.getMonad(S.Semigroup)\n    U.deepStrictEqual(M.of(1), _.right(1))\n  })\n\n  it('getEq', () => {\n    const { equals } = _.getEq(N.Eq, N.Eq)\n    U.deepStrictEqual(equals(_.left(2), _.left(2)), true)\n    U.deepStrictEqual(equals(_.left(2), _.left(3)), false)\n    U.deepStrictEqual(equals(_.left(3), _.left(2)), false)\n    U.deepStrictEqual(equals(_.left(2), _.right(2)), false)\n    U.deepStrictEqual(equals(_.left(2), _.both(2, 2)), false)\n    U.deepStrictEqual(equals(_.right(2), _.right(2)), true)\n    U.deepStrictEqual(equals(_.right(2), _.right(3)), false)\n    U.deepStrictEqual(equals(_.right(3), _.right(2)), false)\n    U.deepStrictEqual(equals(_.right(2), _.both(2, 2)), false)\n    U.deepStrictEqual(equals(_.both(2, 2), _.both(2, 2)), true)\n    U.deepStrictEqual(equals(_.both(2, 3), _.both(3, 2)), false)\n  })\n\n  it('getSemigroup', () => {\n    const { concat } = _.getSemigroup(S.Semigroup, N.SemigroupSum)\n    U.deepStrictEqual(concat(_.left('a'), _.left('b')), _.left('ab'))\n    U.deepStrictEqual(concat(_.left('a'), _.right(2)), _.both('a', 2))\n    U.deepStrictEqual(concat(_.right(2), _.left('a')), _.both('a', 2))\n    U.deepStrictEqual(concat(_.left('a'), _.both('b', 2)), _.both('ab', 2))\n    U.deepStrictEqual(concat(_.both('b', 2), _.left('a')), _.both('ba', 2))\n    U.deepStrictEqual(concat(_.right(3), _.right(2)), _.right(5))\n    U.deepStrictEqual(concat(_.right(3), _.both('b', 2)), _.both('b', 5))\n    U.deepStrictEqual(concat(_.both('b', 2), _.right(3)), _.both('b', 5))\n    U.deepStrictEqual(concat(_.both('a', 3), _.both('b', 2)), _.both('ab', 5))\n  })\n\n  it('fold', () => {\n    const f = (s: string, n: number) => S.size(s) + U.double(n)\n    const fold = _.fold(S.size, U.double, f)\n    U.deepStrictEqual(fold(_.left('foo')), 3)\n    U.deepStrictEqual(fold(_.right(1)), 2)\n    U.deepStrictEqual(fold(_.both('foo', 1)), 5)\n  })\n\n  it('toTuple', () => {\n    U.deepStrictEqual(pipe(_.left('b'), _.toTuple('a', 1)), ['b', 1])\n    U.deepStrictEqual(pipe(_.right(2), _.toTuple('a', 1)), ['a', 2])\n    U.deepStrictEqual(pipe(_.both('b', 2), _.toTuple('a', 1)), ['b', 2])\n  })\n\n  it('getLeft', () => {\n    U.deepStrictEqual(_.getLeft(_.left('a')), O.some('a'))\n    U.deepStrictEqual(_.getLeft(_.right(1)), O.none)\n    U.deepStrictEqual(_.getLeft(_.both('a', 1)), O.some('a'))\n  })\n\n  it('getRight', () => {\n    U.deepStrictEqual(_.getRight(_.left('a')), O.none)\n    U.deepStrictEqual(_.getRight(_.right(1)), O.some(1))\n    U.deepStrictEqual(_.getRight(_.both('a', 1)), O.some(1))\n  })\n\n  it('leftOrBoth', () => {\n    U.deepStrictEqual(_.leftOrBoth('a')(O.none), _.left('a'))\n    U.deepStrictEqual(_.leftOrBoth('a')(O.some(1)), _.both('a', 1))\n  })\n\n  it('rightOrBoth', () => {\n    U.deepStrictEqual(_.rightOrBoth(1)(O.none), _.right(1))\n    U.deepStrictEqual(_.rightOrBoth(1)(O.some('a')), _.both('a', 1))\n  })\n\n  it('getLeftOnly', () => {\n    U.deepStrictEqual(_.getLeftOnly(_.left('a')), O.some('a'))\n    U.deepStrictEqual(_.getLeftOnly(_.right(1)), O.none)\n    U.deepStrictEqual(_.getLeftOnly(_.both('a', 1)), O.none)\n  })\n\n  it('getRightOnly', () => {\n    U.deepStrictEqual(_.getRightOnly(_.left('a')), O.none)\n    U.deepStrictEqual(_.getRightOnly(_.right(1)), O.some(1))\n    U.deepStrictEqual(_.getRightOnly(_.both('a', 1)), O.none)\n  })\n\n  it('fromOptions', () => {\n    U.deepStrictEqual(_.fromOptions(O.none, O.none), O.none)\n    U.deepStrictEqual(_.fromOptions(O.some('a'), O.none), O.some(_.left('a')))\n    U.deepStrictEqual(_.fromOptions(O.none, O.some(1)), O.some(_.right(1)))\n    U.deepStrictEqual(_.fromOptions(O.some('a'), O.some(1)), O.some(_.both('a', 1)))\n  })\n\n  it('isLeft', () => {\n    U.deepStrictEqual(_.isLeft(_.left(1)), true)\n    U.deepStrictEqual(_.isLeft(_.right(1)), false)\n    U.deepStrictEqual(_.isLeft(_.both('1', 1)), false)\n  })\n\n  it('isRight', () => {\n    U.deepStrictEqual(_.isRight(_.left(1)), false)\n    U.deepStrictEqual(_.isRight(_.right(1)), true)\n    U.deepStrictEqual(_.isRight(_.both('1', 1)), false)\n  })\n\n  it('isBoth', () => {\n    U.deepStrictEqual(_.isBoth(_.left(1)), false)\n    U.deepStrictEqual(_.isBoth(_.right(1)), false)\n    U.deepStrictEqual(_.isBoth(_.both('1', 1)), true)\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show, S.Show)\n    U.deepStrictEqual(Sh.show(_.left('a')), `left(\"a\")`)\n    U.deepStrictEqual(Sh.show(_.right('a')), `right(\"a\")`)\n    U.deepStrictEqual(Sh.show(_.both('a', 'b')), `both(\"a\", \"b\")`)\n  })\n\n  it('swap', () => {\n    U.deepStrictEqual(_.swap(_.left('a')), _.right('a'))\n    U.deepStrictEqual(_.swap(_.right('a')), _.left('a'))\n    U.deepStrictEqual(_.swap(_.both('a', 1)), _.both(1, 'a'))\n  })\n\n  // -------------------------------------------------------------------------------------\n  // array utils\n  // -------------------------------------------------------------------------------------\n\n  it('traverseReadonlyArrayWithIndex', () => {\n    const f = (i: number, n: number) => (n > 0 ? _.right(n + i) : n === 0 ? _.both('a', 0) : _.left(String(n)))\n    const standard = RA.traverseWithIndex(_.getApplicative(S.Semigroup))(f)\n    const optimized = _.traverseReadonlyArrayWithIndex(S.Semigroup)(f)\n    const assert = (input: ReadonlyArray<number>) => {\n      U.deepStrictEqual(standard(input), optimized(input))\n    }\n    assert([1, 2, 3])\n    assert([0, 2, 3])\n    assert([1, 0, 3])\n    assert([0, 0, 3])\n    assert([-1, 2, 3])\n    assert([1, -2, 3])\n    assert(RA.empty)\n  })\n\n  it('exists', () => {\n    const gt2 = _.exists((n: number) => n > 2)\n    U.deepStrictEqual(gt2(_.left('a')), false)\n    U.deepStrictEqual(gt2(_.right(1)), false)\n    U.deepStrictEqual(gt2(_.right(3)), true)\n    U.deepStrictEqual(gt2(_.both('a', 1)), false)\n    U.deepStrictEqual(gt2(_.both('a', 3)), true)\n  })\n\n  it('elem', () => {\n    U.deepStrictEqual(_.elem(N.Eq)(2)(_.left('a')), false)\n    U.deepStrictEqual(_.elem(N.Eq)(2)(_.right(2)), true)\n    U.deepStrictEqual(_.elem(N.Eq)(1)(_.right(2)), false)\n    U.deepStrictEqual(_.elem(N.Eq)(2)(_.both('a', 2)), true)\n    U.deepStrictEqual(_.elem(N.Eq)(1)(_.both('a', 2)), false)\n  })\n})\n"
  },
  {
    "path": "test/Traced.ts",
    "content": "import * as B from '../src/boolean'\nimport { pipe } from '../src/function'\nimport { Monoid, struct } from '../src/Monoid'\nimport * as _ from '../src/Traced'\nimport * as U from './util'\n\n// Adapted from https://chshersh.github.io/posts/2019-03-25-comonadic-builders\n\ninterface Settings {\n  readonly settingsHasLibrary: boolean\n  readonly settingsGitHub: boolean\n  readonly settingsTravis: boolean\n}\n\nconst M: Monoid<Settings> = struct({\n  settingsHasLibrary: B.MonoidAny,\n  settingsGitHub: B.MonoidAny,\n  settingsTravis: B.MonoidAny\n})\n\nconst C = _.getComonad(M)\n\ninterface Project {\n  readonly projectName: string\n  readonly projectHasLibrary: boolean\n  readonly projectGitHub: boolean\n  readonly projectTravis: boolean\n}\n\ninterface ProjectBuilder extends _.Traced<Settings, Project> {}\n\nconst buildProject =\n  (projectName: string): ProjectBuilder =>\n  (settings) => ({\n    projectName,\n    projectHasLibrary: settings.settingsHasLibrary,\n    projectGitHub: settings.settingsGitHub,\n    projectTravis: settings.settingsTravis\n  })\n\nconst hasLibraryB = (wa: ProjectBuilder): Project => {\n  const p = { ...M.empty, settingsHasLibrary: true }\n  return wa(p)\n}\n\nconst gitHubB = (wa: ProjectBuilder): Project => {\n  const p = { ...M.empty, settingsGitHub: true }\n  return wa(p)\n}\n\nconst getProjectName = (project: Project): string => project.projectName\n\ndescribe('Traced', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      const wa = buildProject('myproject')\n      U.deepStrictEqual(pipe(wa, _.map(getProjectName))(M.empty), 'myproject')\n    })\n  })\n\n  it('getComonad', () => {\n    const wa = buildProject('myproject')\n    U.deepStrictEqual(C.extract(wa), {\n      projectName: 'myproject',\n      projectHasLibrary: false,\n      projectGitHub: false,\n      projectTravis: false\n    })\n    U.deepStrictEqual(C.extract(C.extend(wa, hasLibraryB)), {\n      projectName: 'myproject',\n      projectHasLibrary: true,\n      projectGitHub: false,\n      projectTravis: false\n    })\n  })\n\n  it('tracks', () => {\n    const travisB = _.tracks(M, (project: Project): Settings => ({ ...M.empty, settingsTravis: project.projectGitHub }))\n    U.deepStrictEqual(C.extract(C.extend(buildProject('travis'), travisB)), {\n      projectName: 'travis',\n      projectHasLibrary: false,\n      projectGitHub: false,\n      projectTravis: false\n    })\n    U.deepStrictEqual(C.extract(C.extend(C.extend(buildProject('github-travis'), gitHubB), travisB)), {\n      projectName: 'github-travis',\n      projectHasLibrary: false,\n      projectGitHub: true,\n      projectTravis: true\n    })\n  })\n\n  it('listen', () => {\n    U.deepStrictEqual(C.extract(_.listen(buildProject('myproject'))), [\n      {\n        projectName: 'myproject',\n        projectHasLibrary: false,\n        projectGitHub: false,\n        projectTravis: false\n      },\n      {\n        settingsHasLibrary: false,\n        settingsGitHub: false,\n        settingsTravis: false\n      }\n    ])\n  })\n\n  it('listens', () => {\n    U.deepStrictEqual(\n      C.extract(\n        pipe(\n          buildProject('myproject'),\n          _.listens((settings) => settings.settingsTravis)\n        )\n      ),\n      [\n        {\n          projectName: 'myproject',\n          projectHasLibrary: false,\n          projectGitHub: false,\n          projectTravis: false\n        },\n        false\n      ]\n    )\n  })\n\n  it('censor', () => {\n    U.deepStrictEqual(\n      C.extract(\n        pipe(\n          buildProject('myproject'),\n          _.censor((settings) => ({\n            ...settings,\n            settingsHasLibrary: !settings.settingsHasLibrary\n          }))\n        )\n      ),\n      {\n        projectName: 'myproject',\n        projectHasLibrary: true,\n        projectGitHub: false,\n        projectTravis: false\n      }\n    )\n  })\n})\n"
  },
  {
    "path": "test/Traversable.ts",
    "content": "import * as E from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as O from '../src/Option'\nimport * as RA from '../src/ReadonlyArray'\nimport * as _ from '../src/Traversable'\nimport * as U from './util'\n\nexport const ArrayOptionURI = 'ArrayOption'\n\nexport type ArrayOptionURI = typeof ArrayOptionURI\n\ndescribe('Traversable', () => {\n  it('getTraversableComposition', () => {\n    const T = _.getTraversableComposition(RA.Traversable, O.Traversable)\n    U.deepStrictEqual(\n      T.map([O.some(1), O.some(2), O.none], (n) => n * 2),\n      [O.some(2), O.some(4), O.none]\n    )\n    U.deepStrictEqual(\n      T.traverse(O.Applicative)([O.some(1), O.some(2)], (n: number) => (n <= 2 ? O.some(n * 2) : O.none)),\n      O.some([O.some(2), O.some(4)])\n    )\n    U.deepStrictEqual(\n      T.traverse(O.Applicative)([O.some(1), O.some(3)], (n: number) => (n <= 2 ? O.some(n * 2) : O.none)),\n      O.none\n    )\n    U.deepStrictEqual(T.sequence(O.Applicative)([O.some(O.some(1)), O.some(O.some(2))]), O.some([O.some(1), O.some(2)]))\n    U.deepStrictEqual(T.sequence(O.Applicative)([O.some(O.some(1)), O.none]), O.some([O.some(1), O.none]))\n    U.deepStrictEqual(T.sequence(O.Applicative)([O.some(O.some(1)), O.some(O.none)]), O.none)\n  })\n\n  it('traverse', () => {\n    const traverse = _.traverse(RA.Traversable, RA.Traversable)(E.Applicative)\n    U.deepStrictEqual(pipe([[E.right(1)]], traverse(identity)), E.right([[1]]))\n  })\n\n  it('sequence', () => {\n    const sequence = _.sequence(RA.Traversable, RA.Traversable)(E.Applicative)\n    U.deepStrictEqual(pipe([[E.right(1)]], sequence), E.right([[1]]))\n  })\n})\n"
  },
  {
    "path": "test/Tree.ts",
    "content": "import * as Eq from '../src/Eq'\nimport { identity, pipe } from '../src/function'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as _ from '../src/Tree'\nimport * as U from './util'\n\ndescribe('Tree', () => {\n  describe('pipeables', () => {\n    it('traverse', () => {\n      const fa = _.make('a', [_.make('b'), _.make('c')])\n      U.deepStrictEqual(pipe(fa, _.traverse(O.Applicative)(O.some)), O.some(fa))\n    })\n\n    it('sequence', () => {\n      U.deepStrictEqual(\n        _.sequence(O.Applicative)(_.make(O.some('a'), [_.make(O.some('b')), _.make(O.some('c'))])),\n        O.some(_.make('a', [_.make('b'), _.make('c')]))\n      )\n    })\n  })\n\n  it('map', () => {\n    const fa = _.make(1, [_.make(2), _.make(3)])\n    const expected = _.make(2, [_.make(4), _.make(6)])\n    U.deepStrictEqual(pipe(fa, _.map(U.double)), expected)\n  })\n\n  it('ap', () => {\n    const fab = _.of(U.double)\n    const fa = _.make(1, [_.make(2), _.make(3)])\n    const expected = _.make(2, [_.make(4), _.make(6)])\n    U.deepStrictEqual(pipe(fab, _.ap(fa)), expected)\n  })\n\n  it('apFirst', () => {\n    U.deepStrictEqual(pipe(_.make('a'), _.apFirst(_.make('b'))), _.make('a'))\n  })\n\n  it('apSecond', () => {\n    U.deepStrictEqual(pipe(_.make('a'), _.apSecond(_.make('b'))), _.make('b'))\n  })\n\n  it('flatMap', () => {\n    const f = (n: number) => _.of(n * 2)\n    const fa = _.make(1, [_.make(2), _.make(3)])\n    const expected = _.make(2, [_.make(4), _.make(6)])\n    U.deepStrictEqual(pipe(fa, _.flatMap(f)), expected)\n    U.deepStrictEqual(_.flatMap(fa, f), expected)\n  })\n\n  it('chain', () => {\n    const f = (n: number) => _.of(n * 2)\n    const fa = _.make(1, [_.make(2), _.make(3)])\n    const expected = _.make(2, [_.make(4), _.make(6)])\n    U.deepStrictEqual(pipe(fa, _.chain(f)), expected)\n  })\n\n  it('chainFirst', () => {\n    const f = (n: number) => _.of(n * 2)\n    const fa = _.make(1, [_.make(2), _.make(3)])\n    U.deepStrictEqual(pipe(fa, _.chainFirst(f)), fa)\n  })\n\n  it('flatten', () => {\n    U.deepStrictEqual(pipe(_.make(_.make('a')), _.flatten), _.make('a'))\n  })\n\n  it('duplicate', () => {\n    U.deepStrictEqual(pipe(_.make('a'), _.duplicate), _.make(_.make('a')))\n  })\n\n  it('extract', () => {\n    const fa = _.make(1, [_.make(2), _.make(3)])\n    U.deepStrictEqual(pipe(fa, _.extract), 1)\n  })\n\n  it('extend', () => {\n    const fa = _.make('a', [_.make('foo'), _.make('b')])\n    const f = (fa: _.Tree<string>) => fa.value.length + fa.forest.length\n    const expected = _.make(3, [_.make(3), _.make(1)])\n    U.deepStrictEqual(pipe(fa, _.extend(f)), expected)\n  })\n\n  it('reduce', () => {\n    const fa = _.make('a', [_.make('b'), _.make('c')])\n    U.deepStrictEqual(\n      pipe(\n        fa,\n        _.reduce('', (b, a) => b + a)\n      ),\n      'abc'\n    )\n  })\n\n  it('foldMap', () => {\n    const x = _.make('a', [_.make('b'), _.make('c')])\n    U.deepStrictEqual(pipe(x, _.foldMap(S.Monoid)(identity)), 'abc')\n  })\n\n  it('reduceRight', () => {\n    const x = _.make('a', [_.make('b'), _.make('c')])\n    const f = (a: string, acc: string) => acc + a\n    U.deepStrictEqual(pipe(x, _.reduceRight('', f)), 'cba')\n  })\n\n  it('drawTree', () => {\n    const tree = _.make('a')\n    U.deepStrictEqual(_.drawTree(tree), 'a')\n\n    const tree1 = _.make('a', [_.make('b'), _.make('c'), _.make('d', [_.make('e'), _.make('f')]), _.make('g')])\n    U.deepStrictEqual(\n      _.drawTree(tree1),\n      `a\n├─ b\n├─ c\n├─ d\n│  ├─ e\n│  └─ f\n└─ g`\n    )\n\n    const tree2 = _.make('a', [_.make('b', [_.make('c')])])\n    U.deepStrictEqual(\n      _.drawTree(tree2),\n      `a\n└─ b\n   └─ c`\n    )\n\n    const tree3 = _.make('a', [_.make('b', [_.make('c')]), _.make('d', [_.make('e')])])\n    U.deepStrictEqual(\n      _.drawTree(tree3),\n      `a\n├─ b\n│  └─ c\n└─ d\n   └─ e`\n    )\n\n    const tree4 = _.make('a', [_.make('b', [_.make('c', [_.make('d')]), _.make('e', [_.make('f')])]), _.make('e')])\n    U.deepStrictEqual(\n      _.drawTree(tree4),\n      `a\n├─ b\n│  ├─ c\n│  │  └─ d\n│  └─ e\n│     └─ f\n└─ e`\n    )\n  })\n\n  it('getEq', () => {\n    const S = _.getEq(N.Eq)\n    const x = _.make(1, [_.make(2)])\n    const y = _.make(2, [_.make(2)])\n    const z = _.make(1, [_.make(1)])\n    U.deepStrictEqual(S.equals(x, x), true)\n    U.deepStrictEqual(S.equals(x, y), false)\n    U.deepStrictEqual(S.equals(x, z), false)\n  })\n\n  it('unfoldTree', () => {\n    U.deepStrictEqual(\n      _.unfoldTree(1, (b) => [b, b < 3 ? [b + 1, b + 2] : []]),\n      _.make(1, [_.make(2, [_.make(3), _.make(4)]), _.make(3)])\n    )\n  })\n\n  it('unfoldTreeM', async () => {\n    U.deepStrictEqual(\n      _.unfoldTreeM(O.Monad)(1, (b) => O.some([b, b < 3 ? [b + 1, b + 2] : []])),\n      O.some(_.make(1, [_.make(2, [_.make(3), _.make(4)]), _.make(3)]))\n    )\n    U.deepStrictEqual(\n      _.unfoldTreeM(O.Monad)(1, (b) => (b < 3 ? O.some([b, [b + 1, b + 2]]) : O.none)),\n      O.none\n    )\n    U.deepStrictEqual(\n      await _.unfoldTreeM(T.Monad)(1, (b) => T.of([b, b < 3 ? [b + 1, b + 2] : []]))(),\n      _.make(1, [_.make(2, [_.make(3), _.make(4)]), _.make(3)])\n    )\n  })\n\n  it('getShow', () => {\n    const Sh = _.getShow(S.Show)\n    const t1 = _.make('a')\n    U.deepStrictEqual(Sh.show(t1), `make(\"a\")`)\n    const t2 = _.make('a', [_.make('b'), _.make('c')])\n    U.deepStrictEqual(Sh.show(t2), `make(\"a\", [make(\"b\"), make(\"c\")])`)\n  })\n\n  it('fold', () => {\n    const t = _.make(1, [_.make(2), _.make(3)])\n    U.deepStrictEqual(\n      _.fold((a: number, bs: ReadonlyArray<number>) => bs.reduce((b, acc) => Math.max(b, acc), a))(t),\n      3\n    )\n  })\n\n  it('do notation', () => {\n    U.deepStrictEqual(\n      pipe(\n        _.of(1),\n        _.bindTo('a'),\n        _.bind('b', () => _.of('b')),\n        _.let('c', ({ a, b }) => [a, b])\n      ),\n      _.make({ a: 1, b: 'b', c: [1, 'b'] })\n    )\n  })\n\n  it('apS', () => {\n    U.deepStrictEqual(pipe(_.of(1), _.bindTo('a'), _.apS('b', _.of('b'))), _.make({ a: 1, b: 'b' }))\n  })\n\n  it('elem', () => {\n    interface User {\n      readonly id: number\n    }\n    const S: Eq.Eq<User> = pipe(\n      N.Eq,\n      Eq.contramap((user: User) => user.id)\n    )\n    const users = _.make({ id: 1 }, [_.make({ id: 1 }, [_.make({ id: 3 }), _.make({ id: 4 })]), _.make({ id: 2 })])\n    U.deepStrictEqual(_.elem(S)({ id: 1 }, users), true)\n    U.deepStrictEqual(_.elem(S)({ id: 4 }, users), true)\n    U.deepStrictEqual(_.elem(S)({ id: 5 }, users), false)\n  })\n\n  it('exists', () => {\n    interface User {\n      readonly id: number\n    }\n    const users = _.make({ id: 1 }, [_.make({ id: 1 }, [_.make({ id: 3 }), _.make({ id: 4 })]), _.make({ id: 2 })])\n    U.deepStrictEqual(_.exists((user: User) => user.id === 1)(users), true)\n    U.deepStrictEqual(_.exists((user: User) => user.id === 4)(users), true)\n    U.deepStrictEqual(_.exists((user: User) => user.id === 5)(users), false)\n  })\n})\n"
  },
  {
    "path": "test/Tuple.ts",
    "content": "import * as assert from 'assert'\n\nimport { getMonoid } from '../src/Array'\nimport { left, right } from '../src/Either'\nimport { identity, pipe } from '../src/function'\nimport * as O from '../src/Option'\nimport * as S from '../src/string'\nimport * as _ from '../src/Tuple'\nimport * as U from './util'\n\ndescribe('Tuple', () => {\n  describe('pipeables', () => {\n    it('compose', () => {\n      U.deepStrictEqual(pipe([true, 2] as [boolean, number], _.compose([1, 'a'])), [true, 'a'])\n    })\n\n    it('mapFst', () => {\n      U.deepStrictEqual(pipe([1, 'a'] as [number, string], _.mapFst(U.double)), [2, 'a'])\n    })\n\n    it('extract', () => {\n      U.deepStrictEqual(pipe([1, 'a'] as [number, string], _.extract), 1)\n    })\n\n    it('extend', () => {\n      const f = (fa: [number, string]): number => _.snd(fa).length + _.fst(fa)\n      U.deepStrictEqual(pipe([1, 'bb'], _.extend(f)), [3, 'bb'])\n    })\n\n    it('bimap', () => {\n      U.deepStrictEqual(pipe([1, 'a'], _.bimap(S.size, U.double)), [2, 1])\n    })\n\n    it('mapSnd', () => {\n      U.deepStrictEqual(pipe([1, 'a'] as [number, string], _.mapSnd(S.size)), [1, 1])\n    })\n\n    it('duplicate', () => {\n      U.deepStrictEqual(pipe([1, 'a'] as [number, string], _.duplicate), [[1, 'a'], 'a'])\n    })\n\n    it('reduce', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['b', 1] as [string, number],\n          _.reduce('a', (acc, a) => acc + a)\n        ),\n        'ab'\n      )\n    })\n\n    it('foldMap', () => {\n      U.deepStrictEqual(pipe(['a', 1] as [string, number], _.foldMap(S.Monoid)(identity)), 'a')\n    })\n\n    it('reduceRight', () => {\n      U.deepStrictEqual(\n        pipe(\n          ['b', 1] as [string, number],\n          _.reduceRight('a', (acc, a) => acc + a)\n        ),\n        'ba'\n      )\n    })\n\n    it('traverse', () => {\n      const traverse = _.traverse(O.Applicative)((n: number) => (n > 1 ? O.some(n) : O.none))\n      assert.deepStrictEqual(traverse([2, 'a']), O.some([2, 'a']))\n      U.deepStrictEqual(traverse([1, 'a']), O.none)\n    })\n\n    it('sequence', () => {\n      const sequence = _.sequence(O.Applicative)\n      assert.deepStrictEqual(sequence([O.some(1), 'a']), O.some([1, 'a']))\n      U.deepStrictEqual(sequence([O.none, 'a']), O.none)\n    })\n  })\n\n  it('swap', () => {\n    U.deepStrictEqual(_.swap([1, 'a']), ['a', 1])\n  })\n\n  it('getApply', () => {\n    const apply = _.getApply(S.Monoid)\n    U.deepStrictEqual(apply.ap([U.double, 'a'], [1, 'b']), [2, 'ab'])\n  })\n\n  it('getApplicative', () => {\n    const applicative = _.getApplicative(S.Monoid)\n    U.deepStrictEqual(applicative.of(1), [1, ''])\n  })\n\n  it('getMonad', () => {\n    const monad = _.getMonad(S.Monoid)\n    U.deepStrictEqual(\n      monad.chain([1, 'a'], (a) => [a * 2, 'b']),\n      [2, 'ab']\n    )\n  })\n\n  it('chainRec', () => {\n    const { chainRec } = _.getChainRec(getMonoid<number>())\n    function seqReq(upper: number): [number, ReadonlyArray<number>] {\n      return chainRec(1, (init) => [init >= upper ? right(init) : left(init + 1), [init]])\n    }\n    const xs = _.snd(seqReq(10000))\n    U.deepStrictEqual(xs.length, 10000)\n    U.deepStrictEqual(xs[0], 1)\n    U.deepStrictEqual(xs[xs.length - 1], 10000)\n  })\n})\n"
  },
  {
    "path": "test/ValidationT.ts",
    "content": "import * as E from '../src/Either'\nimport * as IO from '../src/IO'\nimport { semigroupString } from '../src/Semigroup'\nimport * as _ from '../src/ValidationT'\nimport * as U from './util'\n\ndescribe('ValidationT', () => {\n  describe('getValidationM', () => {\n    const VT = _.getValidationM(semigroupString, IO.Monad)\n\n    it('chain', () => {\n      const f = (n: number) => (n > 0 ? IO.of(E.right(n * 2)) : IO.of(E.left('b')))\n      U.deepStrictEqual(VT.chain(IO.of(E.right(1)), f)(), E.right(2))\n      U.deepStrictEqual(VT.chain(IO.of(E.right(-1)), f)(), E.left('b'))\n      U.deepStrictEqual(VT.chain(IO.of(E.left('a')), f)(), E.left('a'))\n    })\n\n    it('alt', () => {\n      U.deepStrictEqual(VT.alt(IO.of(E.right(1)), () => IO.of(E.right(2)))(), E.right(1))\n      U.deepStrictEqual(VT.alt(IO.of(E.right(1)), () => IO.of(E.left('b')))(), E.right(1))\n      U.deepStrictEqual(VT.alt(IO.of(E.left('a')), () => IO.of(E.right(2)))(), E.right(2))\n      U.deepStrictEqual(VT.alt(IO.of(E.left('a')), () => IO.of(E.left('b')))(), E.left('ab'))\n    })\n  })\n})\n"
  },
  {
    "path": "test/Witherable.ts",
    "content": "import { pipe } from '../src/function'\nimport * as RT from '../src/ReaderTask'\nimport * as RA from '../src/ReadonlyArray'\nimport * as RR from '../src/ReadonlyRecord'\nimport * as S from '../src/string'\nimport * as T from '../src/Task'\nimport * as _ from '../src/Witherable'\nimport * as U from './util'\n\ndescribe('Witherable', () => {\n  describe('filterE', () => {\n    const filterERA = _.filterE(RA.Witherable)\n    const filterERR = _.filterE(RR.getWitherable(S.Ord))\n\n    it('Applicative1', async () => {\n      const f = (n: number) => T.of(n % 2 === 0)\n      U.deepStrictEqual(await pipe([1, 2], filterERA(T.ApplicativePar)(f))(), [2])\n      U.deepStrictEqual(await pipe({ a: 1, b: 2 }, filterERR(T.ApplicativePar)(f))(), { b: 2 })\n    })\n\n    it('Applicative2', async () => {\n      const f = (n: number) => RT.of(n % 2 === 0)\n      U.deepStrictEqual(await pipe([1, 2], filterERA(RT.ApplicativePar)(f))({})(), [2])\n      U.deepStrictEqual(await pipe({ a: 1, b: 2 }, filterERR(RT.ApplicativePar)(f))({})(), { b: 2 })\n    })\n  })\n})\n"
  },
  {
    "path": "test/Writer.ts",
    "content": "import { pipe, tuple } from '../src/function'\nimport * as S from '../src/string'\nimport * as _ from '../src/Writer'\nimport * as U from './util'\n\ndescribe('Writer', () => {\n  describe('pipeables', () => {\n    it('map', () => {\n      const x: _.Writer<string, number> = () => [1, 'a']\n      U.deepStrictEqual(pipe(x, _.map(U.double))(), [2, 'a'])\n    })\n  })\n\n  it('evalWriter', () => {\n    U.deepStrictEqual(\n      _.evalWriter(() => [1, 'a']),\n      1\n    )\n  })\n\n  it('execWriter', () => {\n    U.deepStrictEqual(\n      _.execWriter(() => [1, 'a']),\n      'a'\n    )\n  })\n\n  it('evaluate', () => {\n    U.deepStrictEqual(pipe((() => [1, 'a']) as _.Writer<string, number>, _.evaluate), 1)\n  })\n\n  it('execute', () => {\n    U.deepStrictEqual(pipe((() => [1, 'a']) as _.Writer<string, number>, _.execute), 'a')\n  })\n\n  it('tell', () => {\n    U.deepStrictEqual(_.tell(1)(), [undefined, 1])\n  })\n\n  it('listen', () => {\n    U.deepStrictEqual(_.listen(() => [1, 'a'])(), [[1, 'a'], 'a'])\n  })\n\n  it('pass', () => {\n    U.deepStrictEqual(_.pass(() => [tuple(1, (w: string) => w + 'b'), 'a'])(), [1, 'ab'])\n  })\n\n  it('listens', () => {\n    const fa: _.Writer<string, number> = () => [1, 'a']\n    U.deepStrictEqual(\n      pipe(\n        fa,\n        _.listens((w) => w.length)\n      )(),\n      [[1, 1], 'a']\n    )\n  })\n\n  it('censor', () => {\n    const fa: _.Writer<ReadonlyArray<string>, number> = () => [1, ['a', 'b']]\n    U.deepStrictEqual(\n      pipe(\n        fa,\n        _.censor((w) => w.filter((a) => a !== 'a'))\n      )(),\n      [1, ['b']]\n    )\n  })\n\n  describe('getMonad', () => {\n    const M = _.getMonad(S.Monoid)\n\n    it('of', () => {\n      U.deepStrictEqual(M.of(1)(), [1, ''])\n    })\n\n    it('ap', () => {\n      const fab: _.Writer<string, (n: number) => number> = () => [(n: number) => n * 2, 'a']\n      const fa: _.Writer<string, number> = () => [1, 'b']\n      U.deepStrictEqual(M.ap(fab, fa)(), [2, 'ab'])\n    })\n\n    it('chain', () => {\n      const fa: _.Writer<string, number> = () => [1, 'a']\n      const f =\n        (n: number): _.Writer<string, number> =>\n        () =>\n          [n * 2, 'b']\n      U.deepStrictEqual(M.chain(fa, f)(), [2, 'ab'])\n    })\n  })\n})\n"
  },
  {
    "path": "test/boolean.ts",
    "content": "import * as _ from '../src/boolean'\nimport * as U from './util'\n\ndescribe('boolean', () => {\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('Eq', () => {\n    U.deepStrictEqual(_.Eq.equals(true, true), true)\n    U.deepStrictEqual(_.Eq.equals(false, false), true)\n    U.deepStrictEqual(_.Eq.equals(false, true), false)\n  })\n\n  it('Ord', () => {\n    U.deepStrictEqual(_.Ord.compare(false, true), -1)\n    U.deepStrictEqual(_.Ord.compare(true, false), 1)\n    U.deepStrictEqual(_.Ord.compare(true, true), 0)\n  })\n\n  it('Show', () => {\n    U.deepStrictEqual(_.Show.show(true), 'true')\n    U.deepStrictEqual(_.Show.show(false), 'false')\n  })\n\n  it('BooleanAlgebra', () => {\n    const BA = _.BooleanAlgebra\n    U.deepStrictEqual(BA.implies(true, true), true)\n    U.deepStrictEqual(BA.implies(true, false), false)\n    U.deepStrictEqual(BA.implies(false, true), true)\n    U.deepStrictEqual(BA.implies(false, false), true)\n\n    U.deepStrictEqual(BA.join(true, true), true)\n    U.deepStrictEqual(BA.join(true, false), true)\n    U.deepStrictEqual(BA.join(false, true), true)\n    U.deepStrictEqual(BA.join(false, false), false)\n\n    U.deepStrictEqual(BA.meet(true, true), true)\n    U.deepStrictEqual(BA.meet(true, false), false)\n\n    U.deepStrictEqual(BA.not(true), false)\n    U.deepStrictEqual(BA.not(false), true)\n\n    U.deepStrictEqual(BA.one, true)\n    U.deepStrictEqual(BA.zero, false)\n  })\n\n  // -------------------------------------------------------------------------------------\n  // utils\n  // -------------------------------------------------------------------------------------\n\n  it('fold', () => {\n    U.deepStrictEqual(\n      _.fold(\n        () => 'false',\n        () => 'true'\n      )(true),\n      'true'\n    )\n    U.deepStrictEqual(\n      _.fold(\n        () => 'false',\n        () => 'true'\n      )(false),\n      'false'\n    )\n  })\n})\n"
  },
  {
    "path": "test/function.ts",
    "content": "import * as assert from 'assert'\n\nimport * as B from '../src/boolean'\nimport * as _ from '../src/function'\nimport { concatAll } from '../src/Monoid'\nimport * as N from '../src/number'\nimport * as RA from '../src/ReadonlyArray'\nimport * as U from './util'\n\nconst f = (n: number) => n + 1\nconst g = (n: number) => n * 2\n\ndescribe('function', () => {\n  test('flip', () => {\n    const f1 = (a: number) => (b: string) => a - b.length\n    const f2 = (a: number, b: string) => a - b.length\n\n    U.deepStrictEqual(_.flip(f1)('aaa')(2), -1)\n    // eslint-disable-next-line deprecation/deprecation\n    U.deepStrictEqual(_.flip(f2)('aaa', 2), -1)\n  })\n\n  it('not', () => {\n    const n = _.not(Boolean)\n    U.deepStrictEqual(n(false), true)\n    U.deepStrictEqual(n(1), false)\n    U.deepStrictEqual(n(''), true)\n  })\n\n  it('unsafeCoerce', () => {\n    U.deepStrictEqual(_.unsafeCoerce, _.identity)\n  })\n\n  it('constTrue', () => {\n    U.deepStrictEqual(_.constTrue(), true)\n  })\n\n  it('constFalse', () => {\n    U.deepStrictEqual(_.constFalse(), false)\n  })\n\n  it('constNull', () => {\n    U.deepStrictEqual(_.constNull(), null)\n  })\n\n  it('constUndefined', () => {\n    U.deepStrictEqual(_.constUndefined(), undefined)\n  })\n\n  it('constVoid', () => {\n    U.deepStrictEqual(_.constVoid(), undefined)\n  })\n\n  it('increment', () => {\n    U.deepStrictEqual(_.increment(2), 3)\n  })\n\n  it('decrement', () => {\n    U.deepStrictEqual(_.decrement(2), 1)\n  })\n\n  it('absurd', () => {\n    assert.throws(() => _.absurd<string>(null as any as never))\n  })\n\n  it('flow', () => {\n    U.deepStrictEqual(_.flow(f)(2), 3)\n    U.deepStrictEqual(_.flow(f, g)(2), 6)\n    U.deepStrictEqual(_.flow(f, g, f)(2), 7)\n    U.deepStrictEqual(_.flow(f, g, f, g)(2), 14)\n    U.deepStrictEqual(_.flow(f, g, f, g, f)(2), 15)\n    U.deepStrictEqual(_.flow(f, g, f, g, f, g)(2), 30)\n    U.deepStrictEqual(_.flow(f, g, f, g, f, g, f)(2), 31)\n    U.deepStrictEqual(_.flow(f, g, f, g, f, g, f, g)(2), 62)\n    U.deepStrictEqual(_.flow(f, g, f, g, f, g, f, g, f)(2), 63)\n    // this is just to satisfy noImplicitReturns and 100% coverage\n    U.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    U.deepStrictEqual(u1([1]), 2)\n    U.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    U.deepStrictEqual(u1(1), 2)\n    U.deepStrictEqual(u2(1, 2), 3)\n  })\n\n  it('pipe', () => {\n    const f = (n: number) => n + 1\n    const g = (n: number) => n * 2\n    U.deepStrictEqual(_.pipe(2), 2)\n    U.deepStrictEqual(_.pipe(2, f), 3)\n    U.deepStrictEqual(_.pipe(2, f, g), 6)\n    U.deepStrictEqual(_.pipe(2, f, g, f), 7)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g), 14)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f), 15)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g), 30)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f), 31)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g), 62)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f), 63)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g), 126)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f), 127)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g), 254)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f), 255)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g), 510)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f), 511)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g), 1022)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f), 1023)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g), 2046)\n    U.deepStrictEqual(_.pipe(2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f), 2047)\n    U.deepStrictEqual((_.pipe as any)(...[2, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g, f, g]), 4094)\n  })\n\n  it('getBooleanAlgebra', () => {\n    const BA = _.getBooleanAlgebra(B.BooleanAlgebra)<number>()\n    const f = (n: number) => n >= 0\n    const g = (n: number) => n < 2\n    U.deepStrictEqual(BA.implies(f, g)(1), true)\n    U.deepStrictEqual(BA.implies(f, g)(-1), true)\n\n    U.deepStrictEqual(BA.join(f, g)(1), true)\n    U.deepStrictEqual(BA.join(f, g)(-1), true)\n\n    U.deepStrictEqual(BA.meet(f, g)(1), true)\n    U.deepStrictEqual(BA.meet(f, g)(-1), false)\n\n    U.deepStrictEqual(BA.not(f)(1), false)\n    U.deepStrictEqual(BA.not(f)(-1), true)\n\n    U.deepStrictEqual(BA.one(1), true)\n    U.deepStrictEqual(BA.one(-1), true)\n    U.deepStrictEqual(BA.zero(1), false)\n    U.deepStrictEqual(BA.zero(-1), false)\n  })\n\n  it('getMonoid', () => {\n    const getPredicateMonoidAll = _.getMonoid(B.MonoidAll)\n    const getPredicateMonoidAny = _.getMonoid(B.MonoidAny)\n\n    const isLessThan10 = (n: number) => n <= 10\n    const isEven = (n: number) => n % 2 === 0\n\n    U.deepStrictEqual(\n      _.pipe([1, 2, 3, 40], RA.filter(concatAll(getPredicateMonoidAll<number>())([isLessThan10, isEven]))),\n      [2]\n    )\n    U.deepStrictEqual(\n      _.pipe([1, 2, 3, 40, 41], RA.filter(concatAll(getPredicateMonoidAny<number>())([isLessThan10, isEven]))),\n      [1, 2, 3, 40]\n    )\n  })\n\n  it('getSemiring', () => {\n    const S = _.getSemiring<string, number>(N.Field)\n    const f1 = (s: string): number => s.length\n    const f2 = (s: string): number => s.indexOf('a')\n    U.deepStrictEqual(S.add(f1, f2)('foo'), 2)\n    U.deepStrictEqual(S.add(f1, f2)('fooa'), 7)\n    U.deepStrictEqual(S.zero(''), 0)\n    U.deepStrictEqual(S.one(''), 1)\n    U.deepStrictEqual(S.mul(f1, f2)('foo'), -3)\n    U.deepStrictEqual(S.mul(f1, f2)('fooa'), 12)\n  })\n\n  it('getRing', () => {\n    const R = _.getRing<string, number>(N.Field)\n    const f1 = (s: string): number => s.length\n    const f2 = (s: string): number => s.indexOf('a')\n    U.deepStrictEqual(R.sub(f1, f2)('foo'), 4)\n    U.deepStrictEqual(R.sub(f1, f2)('fooa'), 1)\n  })\n\n  it('getEndomorphismMonoid', () => {\n    const M = _.getEndomorphismMonoid<number>()\n    const f = M.concat(_.increment, U.double)\n    U.deepStrictEqual(f(3), 8)\n  })\n\n  it('apply', () => {\n    U.deepStrictEqual(_.pipe(U.double, _.apply(1)), 2)\n  })\n})\n"
  },
  {
    "path": "test/index.ts",
    "content": "import * as assert from 'assert'\nimport * as glob from 'glob'\nimport * as path from 'path'\n\nimport * as _ from '../src'\n\nconst getExportName = (name: string): string => {\n  if (name === 'HKT' || name === 'IO') {\n    return name.toLowerCase()\n  }\n  if (name === 'IOEither') {\n    return 'ioEither'\n  }\n  if (name === 'IOOption') {\n    return 'ioOption'\n  }\n  if (name === 'IORef') {\n    return 'ioRef'\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).name)\n    .filter((name) => name !== 'internal')\n}\n\ndescribe('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/number.ts",
    "content": "import * as _ from '../src/number'\nimport * as U from './util'\n\ndescribe('string', () => {\n  it('Ord', () => {\n    U.deepStrictEqual(_.Ord.compare(1, 2), -1)\n    U.deepStrictEqual(_.Ord.compare(2, 1), 1)\n    U.deepStrictEqual(_.Ord.compare(2, 2), 0)\n  })\n\n  it('Field', () => {\n    U.deepStrictEqual(_.Field.degree(0), 1)\n    U.deepStrictEqual(_.Field.degree(1), 1)\n    U.deepStrictEqual(_.Field.degree(2), 1)\n  })\n\n  it('Show', () => {\n    U.deepStrictEqual(_.Show.show(1), '1')\n  })\n\n  it('SemigroupProduct', () => {\n    U.deepStrictEqual(_.SemigroupProduct.concat(2, 3), 6)\n  })\n\n  it('MagmaSub', () => {\n    U.deepStrictEqual(_.MagmaSub.concat(2, 3), -1)\n  })\n})\n"
  },
  {
    "path": "test/pipeable.ts",
    "content": "import * as assert from 'assert'\n\nimport * as C from '../src/Const'\nimport * as E from '../src/Either'\nimport { pipe } from '../src/function'\nimport { fold } from '../src/Monoid'\nimport * as N from '../src/number'\nimport * as O from '../src/Option'\nimport { pipeable } from '../src/pipeable'\nimport * as R from '../src/Reader'\nimport * as RA from '../src/ReadonlyArray'\nimport { separated } from '../src/Separated'\nimport * as U from './util'\n\ndescribe('pipeable', () => {\n  it('{}', () => {\n    const r = pipeable<'{}', {}>({ URI: '{}' })\n    U.deepStrictEqual(r, {})\n  })\n\n  it('Functor', () => {\n    const { map } = pipeable(RA.Functor)\n    U.deepStrictEqual(map((n: number) => n * 2)([1, 2, 3]), [2, 4, 6])\n  })\n\n  it('Contravariant', () => {\n    const { contramap } = pipeable(C.Contravariant)\n    U.deepStrictEqual(contramap((s: string) => s.length * 2)(C.make(1)), 1)\n  })\n\n  it('FunctorWithIndex', () => {\n    const { mapWithIndex } = pipeable(RA.FunctorWithIndex)\n    U.deepStrictEqual(mapWithIndex((i, n: number) => n * 2 + i)([1, 2, 3]), [2, 5, 8])\n  })\n\n  it('Apply', () => {\n    const { ap, apFirst, apSecond } = pipeable(RA.Applicative)\n    U.deepStrictEqual(ap([1, 2, 3])([(n) => n * 2]), [2, 4, 6])\n    U.deepStrictEqual(apFirst([2])([1]), [1])\n    U.deepStrictEqual(apSecond([2])([1]), [2])\n  })\n\n  it('Chain', () => {\n    const { chain, chainFirst, flatten } = pipeable(RA.Monad)\n    U.deepStrictEqual(chain((n: number) => [n * 2])([1, 2, 3]), [2, 4, 6])\n    U.deepStrictEqual(chainFirst((n: number) => [n * 2])([1, 2, 3]), [1, 2, 3])\n    U.deepStrictEqual(flatten([[1], [2], [3]]), [1, 2, 3])\n  })\n\n  it('Bifunctor', () => {\n    const { bimap, mapLeft } = pipeable(E.Bifunctor)\n    U.deepStrictEqual(\n      bimap(\n        (s: string) => s.length,\n        (n: number) => n * 2\n      )(E.right(1)),\n      E.right(2)\n    )\n    U.deepStrictEqual(\n      bimap(\n        (s: string) => s.length,\n        (n: number) => n * 2\n      )(E.left('aa')),\n      E.left(2)\n    )\n    U.deepStrictEqual(mapLeft((s: string) => s.length)(E.right(1)), E.right(1))\n    U.deepStrictEqual(mapLeft((s: string) => s.length)(E.left('aa')), E.left(2))\n  })\n\n  it('Extend', () => {\n    const { extend, duplicate } = pipeable(RA.Extend)\n    U.deepStrictEqual(extend((as: ReadonlyArray<number>) => fold(N.MonoidSum)(as))([1, 2, 3]), [6, 5, 3])\n    U.deepStrictEqual(duplicate([1, 2, 3]), [[1, 2, 3], [2, 3], [3]])\n  })\n\n  it('Foldable', () => {\n    const { reduce, foldMap, reduceRight } = pipeable(RA.Foldable)\n    U.deepStrictEqual(reduce(0, (acc, n: number) => acc + n)([1, 2, 3]), 6)\n    U.deepStrictEqual(foldMap(N.MonoidSum)((n: number) => n)([1, 2, 3]), 6)\n    U.deepStrictEqual(reduceRight(0, (n: number, acc) => -acc + n)([1, 2, 3]), 2)\n  })\n\n  it('FoldableWithIndex', () => {\n    const { reduceWithIndex, foldMapWithIndex, reduceRightWithIndex } = pipeable(RA.FoldableWithIndex)\n    U.deepStrictEqual(reduceWithIndex(0, (i, acc, n: number) => acc + n + i)([1, 2, 3]), 9)\n    U.deepStrictEqual(foldMapWithIndex(N.MonoidSum)((i, n: number) => n + i)([1, 2, 3]), 9)\n    U.deepStrictEqual(reduceRightWithIndex(0, (i, n: number, acc) => -acc + n + i)([1, 2, 3]), 3)\n  })\n\n  it('Alt', () => {\n    const { alt } = pipeable(RA.Alt)\n    U.deepStrictEqual(alt(() => [4, 5, 6])([1, 2, 3]), [1, 2, 3, 4, 5, 6])\n  })\n\n  it('Filterable', () => {\n    const { filter, filterMap, partition, partitionMap } = pipeable(RA.Filterable)\n    U.deepStrictEqual(pipe([O.some(1), O.none, O.some(2)], filter(O.isSome)), [O.some(1), O.some(2)] as ReadonlyArray<\n      O.Some<number>\n    >)\n    U.deepStrictEqual(filterMap(<A>(a: O.Option<A>) => a)([O.some(1), O.none, O.some(2)]), [1, 2])\n    assert.deepStrictEqual(\n      pipe([O.some(1), O.none, O.some(2)], partition(O.isSome)),\n      separated([O.none], [O.some(1), O.some(2)])\n    )\n    U.deepStrictEqual(\n      partitionMap((n: number) => (n > 2 ? E.right(n) : E.left(String(n))))([1, 2, 3]),\n      separated(['1', '2'], [3])\n    )\n  })\n\n  it('FilterableWithIndex', () => {\n    const { filterWithIndex, filterMapWithIndex, partitionWithIndex, partitionMapWithIndex } = pipeable(\n      RA.FilterableWithIndex\n    )\n    U.deepStrictEqual(\n      filterWithIndex((i, a: O.Option<number>) => i > 1 && O.isSome(a))([O.some(1), O.none, O.some(2)]),\n      [O.some(2)]\n    )\n    U.deepStrictEqual(\n      filterMapWithIndex((i, a: O.Option<number>) =>\n        pipe(\n          a,\n          O.map((n) => n + i)\n        )\n      )([O.some(1), O.none, O.some(2)]),\n      [1, 4]\n    )\n    U.deepStrictEqual(\n      partitionWithIndex((i, a: O.Option<number>) => i > 1 && O.isSome(a))([O.some(1), O.none, O.some(2)]),\n      separated([O.some(1), O.none], [O.some(2)])\n    )\n    U.deepStrictEqual(\n      partitionMapWithIndex((i, n: number) => (i < 2 && n > 1 ? E.right(n) : E.left(String(n))))([1, 2, 3]),\n      separated(['1', '3'], [2])\n    )\n  })\n\n  it('Profunctor', () => {\n    const { promap } = pipeable(R.Profunctor)\n    const f = promap(\n      (s: string) => s + 'a',\n      (n: number) => n > 2\n    )((s: string) => s.length)\n    U.deepStrictEqual(f('a'), false)\n    U.deepStrictEqual(f('aa'), true)\n  })\n\n  it('Semigroupoid', () => {\n    const { compose } = pipeable(R.Category)\n    U.deepStrictEqual(compose((s: string) => s.length)((n) => n * 2)('aa'), 4)\n  })\n\n  it('MonadThrow', () => {\n    const { fromEither, fromOption, fromPredicate, filterOrElse } = pipeable(E.MonadThrow)\n    U.deepStrictEqual(fromEither(E.right(1)), E.right(1))\n    U.deepStrictEqual(fromEither(E.left('a')), E.left('a'))\n    U.deepStrictEqual(fromOption(() => 'none')(O.none), E.left('none'))\n    U.deepStrictEqual(fromOption(() => 'none')(O.some(1)), E.right(1))\n    const gt2 = fromPredicate(\n      (n: number) => n >= 2,\n      (n) => `Invalid number ${n}`\n    )\n    U.deepStrictEqual(gt2(3), E.right(3))\n    U.deepStrictEqual(gt2(1), E.left('Invalid number 1'))\n    const gt10 = (n: number): boolean => n > 10\n    U.deepStrictEqual(\n      pipe(\n        E.right(12),\n        filterOrElse(gt10, () => -1)\n      ),\n      E.right(12)\n    )\n    U.deepStrictEqual(\n      pipe(\n        E.right(7),\n        filterOrElse(gt10, () => -1)\n      ),\n      E.left(-1)\n    )\n    U.deepStrictEqual(\n      pipe(\n        E.left(12),\n        filterOrElse(gt10, () => -1)\n      ),\n      E.left(12)\n    )\n    U.deepStrictEqual(\n      pipe(\n        E.right(7),\n        filterOrElse(gt10, (n) => `invalid ${n}`)\n      ),\n      E.left('invalid 7')\n    )\n  })\n})\n"
  },
  {
    "path": "test/string.ts",
    "content": "import { pipe } from '../src/function'\nimport * as _ from '../src/string'\nimport * as U from './util'\n\ndescribe('string', () => {\n  // -------------------------------------------------------------------------------------\n  // instances\n  // -------------------------------------------------------------------------------------\n\n  it('Show', () => {\n    U.deepStrictEqual(_.Show.show('a'), '\"a\"')\n  })\n\n  // -------------------------------------------------------------------------------------\n  // utils\n  // -------------------------------------------------------------------------------------\n\n  it('empty', () => {\n    U.deepStrictEqual(_.empty, '')\n  })\n\n  it('isEmpty', () => {\n    U.deepStrictEqual(_.isEmpty(_.empty), true)\n    U.deepStrictEqual(_.isEmpty(''), true)\n    U.deepStrictEqual(_.isEmpty('a'), false)\n  })\n\n  it('isString', () => {\n    U.deepStrictEqual(_.isString(_.empty), true)\n    U.deepStrictEqual(_.isString('a'), true)\n    U.deepStrictEqual(_.isString(1), false)\n  })\n\n  it('size', () => {\n    U.deepStrictEqual(_.size(_.empty), 0)\n    U.deepStrictEqual(_.size(''), 0)\n    U.deepStrictEqual(_.size('a'), 1)\n  })\n\n  it('toUpperCase', () => {\n    U.deepStrictEqual(_.toUpperCase('a'), 'A')\n  })\n\n  it('toLowerCase', () => {\n    U.deepStrictEqual(_.toLowerCase('A'), 'a')\n  })\n\n  it('replace', () => {\n    U.deepStrictEqual(pipe('abc', _.replace('b', 'd')), 'adc')\n  })\n\n  it('split', () => {\n    U.deepStrictEqual(pipe('abc', _.split('')), ['a', 'b', 'c'])\n    U.deepStrictEqual(pipe('', _.split('')), [''])\n  })\n\n  it('trim', () => {\n    U.deepStrictEqual(pipe(' a ', _.trim), 'a')\n  })\n\n  it('trimLeft', () => {\n    U.deepStrictEqual(pipe(' a ', _.trimLeft), 'a ')\n  })\n\n  it('trimRight', () => {\n    U.deepStrictEqual(pipe(' a ', _.trimRight), ' a')\n  })\n\n  it('includes', () => {\n    U.deepStrictEqual(pipe('abc', _.includes('b')), true)\n    U.deepStrictEqual(pipe('abc', _.includes('b', 2)), false)\n  })\n\n  it('startsWith', () => {\n    U.deepStrictEqual(pipe('abc', _.startsWith('a')), true)\n  })\n\n  it('endsWith', () => {\n    U.deepStrictEqual(pipe('abc', _.endsWith('c')), true)\n  })\n\n  it('slice', () => {\n    U.deepStrictEqual(pipe('abcd', _.slice(1, 3)), 'bc')\n  })\n})\n"
  },
  {
    "path": "test/struct.ts",
    "content": "import { pipe } from '../src/function'\nimport * as _ from '../src/struct'\nimport * as U from './util'\n\ndescribe('struct', () => {\n  it('getAssignSemigroup', () => {\n    type T = {\n      readonly foo?: number\n      readonly bar: string\n    }\n    const foo: T = {\n      foo: 123,\n      bar: '456'\n    }\n    const bar: T = {\n      bar: '123'\n    }\n    const S = _.getAssignSemigroup<T>()\n    U.deepStrictEqual(S.concat(foo, bar), Object.assign({}, foo, bar))\n  })\n\n  it('evolve', () => {\n    U.deepStrictEqual(\n      pipe(\n        { a: 'a', b: 1, c: true },\n        _.evolve({\n          a: (s) => s.length,\n          b: (b) => b > 0,\n          c: (c) => !c\n        })\n      ),\n      { a: 1, b: true, c: false }\n    )\n    // should ignore non own properties\n    const x: Record<'b', number> = Object.create({ a: 1 })\n    x.b = 1\n    U.deepStrictEqual(pipe(x, _.evolve({ b: (b) => b > 0 })), { b: true })\n  })\n})\n"
  },
  {
    "path": "test/util.ts",
    "content": "import * as assert from 'assert'\n\nimport { Apply, Apply1, Apply2, Apply2C, Apply3, Apply4, sequenceT } from '../src/Apply'\nimport { FromTask, FromTask1, FromTask2, FromTask3, FromTask4 } from '../src/FromTask'\nimport { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from '../src/HKT'\nimport * as T from '../src/Task'\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 interface AssertParSeq {\n  <F extends URIS4>(\n    F: Apply4<F>,\n    MT: FromTask4<F>,\n    run: (fa: Kind4<F, unknown, unknown, unknown, unknown>) => Promise<unknown>\n  ): Promise<void>\n  <F extends URIS3>(\n    F: Apply3<F>,\n    MT: FromTask3<F>,\n    run: (fa: Kind3<F, unknown, unknown, unknown>) => Promise<unknown>\n  ): Promise<void>\n  <F extends URIS2>(\n    F: Apply2<F>,\n    MT: FromTask2<F>,\n    run: (fa: Kind2<F, unknown, unknown>) => Promise<unknown>\n  ): Promise<void>\n  <F extends URIS2, E>(\n    F: Apply2C<F, E>,\n    MT: FromTask2<F>,\n    run: (fa: Kind2<F, E, unknown>) => Promise<unknown>\n  ): Promise<void>\n  <F extends URIS>(F: Apply1<F>, MT: FromTask1<F>, run: (fa: Kind<F, unknown>) => Promise<unknown>): Promise<void>\n  <F>(F: Apply<F>, MT: FromTask<F>, run: (fa: HKT<F, unknown>) => Promise<unknown>): Promise<void>\n}\n\nexport const assertParSeq =\n  (expected: ReadonlyArray<string>): AssertParSeq =>\n  async <F>(F: Apply<F>, MT: FromTask<F>, run: (fa: HKT<F, unknown>) => Promise<unknown>) => {\n    const log: Array<string> = []\n    const a = MT.fromTask(T.delay(100)(T.fromIO(() => log.push('a'))))\n    const b = MT.fromTask(T.fromIO(() => log.push('b')))\n    const ab = sequenceT(F)(a, b)\n    await run(ab)\n    deepStrictEqual(log, expected)\n  }\n\nexport const assertPar = assertParSeq(['b', 'a'])\n\nexport const assertSeq = assertParSeq(['a', 'b'])\n"
  },
  {
    "path": "tsconfig.build-es6.json",
    "content": "{\n  \"extends\": \"./tsconfig.build.json\",\n  \"compilerOptions\": {\n    \"outDir\": \"./dist/es6\",\n    \"module\": \"es6\"\n  }\n}\n"
  },
  {
    "path": "tsconfig.build.json",
    "content": "{\n  \"extends\": \"./tsconfig.json\",\n  \"compilerOptions\": {\n    \"noEmit\": false\n  },\n  \"include\": [\"./src\"]\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    \"./benchmark/**/*.ts\",\n    \"./vitest.config.ts\",\n    \"./scripts/**/*.ts\"\n  ]\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"noEmit\": true,\n    \"outDir\": \"./dist/lib\",\n    \"target\": \"es5\",\n    \"module\": \"commonjs\",\n    \"moduleResolution\": \"node\",\n    \"esModuleInterop\": true,\n    \"lib\": [],\n    \"sourceMap\": false,\n    \"declaration\": true,\n    \"strict\": true,\n    \"noImplicitReturns\": true,\n    \"noUnusedLocals\": true,\n    \"noUnusedParameters\": true,\n    \"noFallthroughCasesInSwitch\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"stripInternal\": true,\n    \"skipLibCheck\": true,\n    \"types\": [\"vitest/globals\"],\n    \"plugins\": [\n      {\n        \"name\": \"@effect/language-service\"\n      }\n    ]\n  },\n  \"include\": [\"./src\", \"./test\", \"./scripts\", \"./perf\", \"./dtslint\"],\n  \"exclude\": [\"./node_modules\"]\n}\n"
  },
  {
    "path": "vite.config.ts",
    "content": "/// <reference types=\"vitest\" />\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  test: {\n    include: ['./test/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n    exclude: ['./test/**/util.ts'],\n    globals: true,\n    coverage: {\n      provider: 'istanbul'\n    }\n  }\n})\n"
  }
]