Showing preview only (1,197K chars total). Download the full file or copy to clipboard to get everything.
Repository: fp-ts/core
Branch: main
Commit: 7a190bacb476
Files: 208
Total size: 1.1 MB
Directory structure:
gitextract_pgmrj7hm/
├── .babel.cjs.json
├── .babel.mjs.json
├── .changeset/
│ ├── README.md
│ ├── beige-numbers-exist.md
│ ├── config.json
│ ├── famous-spies-attend.md
│ ├── flat-news-whisper.md
│ ├── hungry-comics-kneel.md
│ ├── mighty-meals-dream.md
│ ├── odd-hornets-wave.md
│ ├── sour-suits-press.md
│ └── tough-planets-lick.md
├── .eslintrc.cjs
├── .github/
│ ├── CONTRIBUTING.md
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE/
│ │ ├── Bug_report.md
│ │ ├── Documentation.md
│ │ └── Feature_request.md
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── workflows/
│ ├── main.yml
│ └── pr.yml
├── .gitignore
├── .gitpod.yml
├── .vscode/
│ ├── settings.json
│ └── tasks.json
├── CHANGELOG.md
├── LICENSE
├── README.md
├── benchmark/
│ ├── Number/
│ │ └── lessThan.ts
│ ├── These/
│ │ └── product.ts
│ ├── dual.ts
│ ├── sumAll.ts
│ └── tsconfig.json
├── docs/
│ ├── _config.yml
│ ├── _sass/
│ │ └── custom/
│ │ └── custom.scss
│ ├── index.md
│ └── modules/
│ ├── Bigint.ts.md
│ ├── Boolean.ts.md
│ ├── Either.ts.md
│ ├── Function.ts.md
│ ├── HKT.ts.md
│ ├── Identity.ts.md
│ ├── Number.ts.md
│ ├── Option.ts.md
│ ├── Ordering.ts.md
│ ├── Predicate.ts.md
│ ├── ReadonlyArray.ts.md
│ ├── ReadonlyRecord.ts.md
│ ├── String.ts.md
│ ├── Struct.ts.md
│ ├── Symbol.ts.md
│ ├── These.ts.md
│ ├── Tuple.ts.md
│ ├── index.md
│ ├── index.ts.md
│ └── typeclass/
│ ├── Alternative.ts.md
│ ├── Applicative.ts.md
│ ├── Bicovariant.ts.md
│ ├── Bounded.ts.md
│ ├── Chainable.ts.md
│ ├── Contravariant.ts.md
│ ├── Coproduct.ts.md
│ ├── Covariant.ts.md
│ ├── Equivalence.ts.md
│ ├── Filterable.ts.md
│ ├── FlatMap.ts.md
│ ├── Foldable.ts.md
│ ├── Invariant.ts.md
│ ├── Monad.ts.md
│ ├── Monoid.ts.md
│ ├── Of.ts.md
│ ├── Order.ts.md
│ ├── Pointed.ts.md
│ ├── Product.ts.md
│ ├── SemiAlternative.ts.md
│ ├── SemiApplicative.ts.md
│ ├── SemiCoproduct.ts.md
│ ├── SemiProduct.ts.md
│ ├── Semigroup.ts.md
│ ├── Traversable.ts.md
│ └── TraversableFilterable.ts.md
├── docs-ts.json
├── dtslint/
│ ├── index.d.ts
│ └── ts4.8/
│ ├── FlatMap.ts
│ ├── Monoid.ts
│ ├── Option.ts
│ ├── Predicate.ts
│ ├── Product.ts
│ ├── ReadonlyArray.ts
│ ├── ReadonlyRecord.ts
│ ├── SemiAlternative.ts
│ ├── SemiProduct.ts
│ ├── Semigroup.ts
│ ├── Tuple.ts
│ ├── index.d.ts
│ ├── index.ts
│ ├── tsconfig.json
│ └── tslint.json
├── guides/
│ ├── Either.md
│ ├── FAQ.md
│ ├── Option.md
│ ├── These.md
│ ├── ts-types.md
│ └── typeclass.md
├── package.json
├── patches/
│ ├── @effect-ts__build-utils@0.40.3.patch
│ └── docs-ts@0.6.10.patch
├── src/
│ ├── Bigint.ts
│ ├── Boolean.ts
│ ├── Either.ts
│ ├── Function.ts
│ ├── HKT.ts
│ ├── Identity.ts
│ ├── Number.ts
│ ├── Option.ts
│ ├── Ordering.ts
│ ├── Predicate.ts
│ ├── ReadonlyArray.ts
│ ├── ReadonlyRecord.ts
│ ├── String.ts
│ ├── Struct.ts
│ ├── Symbol.ts
│ ├── These.ts
│ ├── Tuple.ts
│ ├── index.ts
│ ├── internal/
│ │ ├── Either.ts
│ │ ├── Option.ts
│ │ ├── ReadonlyArray.ts
│ │ └── effect.ts
│ └── typeclass/
│ ├── Alternative.ts
│ ├── Applicative.ts
│ ├── Bicovariant.ts
│ ├── Bounded.ts
│ ├── Chainable.ts
│ ├── Contravariant.ts
│ ├── Coproduct.ts
│ ├── Covariant.ts
│ ├── Equivalence.ts
│ ├── Filterable.ts
│ ├── FlatMap.ts
│ ├── Foldable.ts
│ ├── Invariant.ts
│ ├── Monad.ts
│ ├── Monoid.ts
│ ├── Of.ts
│ ├── Order.ts
│ ├── Pointed.ts
│ ├── Product.ts
│ ├── SemiAlternative.ts
│ ├── SemiApplicative.ts
│ ├── SemiCoproduct.ts
│ ├── SemiProduct.ts
│ ├── Semigroup.ts
│ ├── Traversable.ts
│ └── TraversableFilterable.ts
├── test/
│ ├── Bigint.ts
│ ├── Boolean.ts
│ ├── Either.ts
│ ├── Function.ts
│ ├── Identity.ts
│ ├── Number.ts
│ ├── Option.ts
│ ├── Ordering.ts
│ ├── Predicate.ts
│ ├── ReadonlyArray.ts
│ ├── ReadonlyRecord.ts
│ ├── String.ts
│ ├── Struct.ts
│ ├── Symbol.ts
│ ├── These.ts
│ ├── Tuple.ts
│ ├── index.ts
│ ├── limbo/
│ │ ├── Category.ts
│ │ ├── Comonad.ts
│ │ ├── Composable.ts
│ │ ├── Extendable.ts
│ │ └── NonEmptyTraversable.ts
│ ├── typeclass/
│ │ ├── Applicative.ts
│ │ ├── Bicovariant.ts
│ │ ├── Bounded.ts
│ │ ├── Chainable.ts
│ │ ├── Contravariant.ts
│ │ ├── Coproduct.ts
│ │ ├── Covariant.ts
│ │ ├── Equivalence.ts
│ │ ├── Filterable.ts
│ │ ├── FlatMap.ts
│ │ ├── Foldable.ts
│ │ ├── Invariant.ts
│ │ ├── Monoid.ts
│ │ ├── NonEmptyTraversable.ts
│ │ ├── Of.ts
│ │ ├── Order.ts
│ │ ├── Product.ts
│ │ ├── SemiApplicative.ts
│ │ ├── SemiCoproduct.ts
│ │ ├── SemiProduct.ts
│ │ ├── Semigroup.ts
│ │ ├── Traversable.ts
│ │ └── TraversableFilterable.ts
│ └── util.ts
├── tsconfig.base.json
├── tsconfig.build-test.json
├── tsconfig.build.json
├── tsconfig.eslint.json
├── tsconfig.json
├── tsconfig.madge.json
└── vitest.config.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .babel.cjs.json
================================================
{
"plugins": [["@babel/transform-modules-commonjs"], ["annotate-pure-calls"]]
}
================================================
FILE: .babel.mjs.json
================================================
{
"plugins": [["annotate-pure-calls"]]
}
================================================
FILE: .changeset/README.md
================================================
# Changesets
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
================================================
FILE: .changeset/beige-numbers-exist.md
================================================
---
"@fp-ts/core": patch
---
Tuple: add more APIs
================================================
FILE: .changeset/config.json
================================================
{
"$schema": "https://unpkg.com/@changesets/config@1.6.4/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "fp-ts/core" }],
"commit": false,
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
================================================
FILE: .changeset/famous-spies-attend.md
================================================
---
"@fp-ts/core": patch
---
export productAll from Option, Either, Predicate
================================================
FILE: .changeset/flat-news-whisper.md
================================================
---
"@fp-ts/core": patch
---
fix bounds flipping in reverse function
================================================
FILE: .changeset/hungry-comics-kneel.md
================================================
---
"@fp-ts/core": patch
---
Function: swap apply arguments
================================================
FILE: .changeset/mighty-meals-dream.md
================================================
---
"@fp-ts/core": patch
---
add missing boolean semigroups, monoids and combinators
================================================
FILE: .changeset/odd-hornets-wave.md
================================================
---
"@fp-ts/core": patch
---
Bigint: feature parity with Number
================================================
FILE: .changeset/sour-suits-press.md
================================================
---
"@fp-ts/core": patch
---
Number: add missing functions (derivable from Order)
================================================
FILE: .changeset/tough-planets-lick.md
================================================
---
"@fp-ts/core": patch
---
ReadonlyRecord: map: add support for structs
================================================
FILE: .eslintrc.cjs
================================================
/* eslint-disable no-undef */
module.exports = {
ignorePatterns: ["build", "dist", "dtslint", "benchmark", "*.mjs", "docs", "*.md"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
project: "./tsconfig.eslint.json"
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
typescript: {
alwaysTryTypes: true
}
}
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@repo-tooling/dprint/recommended"
],
plugins: ["deprecation", "import", "sort-destructure-keys", "simple-import-sort", "codegen"],
rules: {
"codegen/codegen": "error",
"no-fallthrough": "off",
"no-irregular-whitespace": "off",
"object-shorthand": "error",
"prefer-destructuring": "off",
"sort-imports": "off",
"no-unused-vars": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"import/first": "error",
"import/no-cycle": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"import/no-unresolved": "off",
"import/order": "off",
"simple-import-sort/imports": "off",
"sort-destructure-keys/sort-destructure-keys": "error",
"deprecation/deprecation": "off",
"@typescript-eslint/array-type": ["warn", { "default": "generic", "readonly": "generic" }],
"@typescript-eslint/prefer-readonly": "warn",
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-array-constructor": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-namespace": "off",
"@repo-tooling/dprint/dprint": [
"error",
{
config: {
"indentWidth": 2,
"lineWidth": 100,
"semiColons": "asi",
"quoteStyle": "alwaysDouble",
"trailingCommas": "never",
"operatorPosition": "maintain",
"useParentheses": "preferNone"
}
}
]
}
}
================================================
FILE: .github/CONTRIBUTING.md
================================================
# Contributing to `@fp-ts/core`
We welcome all contributions to the `@fp-ts/core` library. Your help makes the library better for everyone!
## Creating an Issue
Before you begin working on a contribution, it's important to create an issue that describes what you would like to build or improve. This helps to ensure that someone else isn't already working on something similar, and also helps the maintainers understand your goals.
## Development Workflow
1. Fork the repository on GitHub.
2. Clone your forked repository using the following command: `git clone git@github.com:{your_username}/core.git`
3. Install dependencies with `pnpm install`.
4. Make your contributions and commit your changes.
5. If you have made changes to the code, run `pnpm changeset` and select the appropriate level of change (`patch`, `minor`, `major`)
### Available Commands
- `pnpm build`: Deletes the `dist` folder and recompiles the `src` code into `dist`.
- `pnpm test`: Runs all vitest tests in watch mode.
- `pnpm coverage`: Runs all vitest tests and collects coverage information.
- `pnpm dtslint`: Runs type-level tests.
### Writing Tests
`@fp-ts/core` uses vitest for testing. After making your contributions, it's important to write tests to ensure that they work as intended. Before submitting your pull request, run `pnpm coverage` to make sure there are no unintended breaking changes and that your code has 100% coverage.
### Documentation
API documentation for `@fp-ts/core` can be found in the source code as JSDoc comments. Be sure to include documentation for any changes you make to the API.
## Licensing
By contributing your code to the `@fp-ts/core` GitHub repository, you agree to license your contribution under the MIT license.
================================================
FILE: .github/FUNDING.yml
================================================
github: [gcanti]
================================================
FILE: .github/ISSUE_TEMPLATE/Bug_report.md
================================================
# Bug Report
Thank you for reporting a bug in `@fp-ts/core`. Your contribution to this project is greatly appreciated and will help make the library better for everyone.
## Describing the Bug
Please provide a clear and concise description of the issue you are encountering, including any error messages or unexpected behavior you have observed.
## Steps to Reproduce
In order to help us understand and resolve the issue, please provide the steps to reproduce the behavior, along with a minimal, self-contained code example that demonstrates the problem.
## Expected Behavior
Please describe what you expected to happen, and how the current behavior differs from your expectations.
## Environment
Please provide the following information to help us understand your setup:
- Library version: [e.g. `0.8.1`]
- TypeScript version: [e.g. `4.2.2`]
## Additional Context
Any additional information or context that you think would be helpful in resolving the issue.
================================================
FILE: .github/ISSUE_TEMPLATE/Documentation.md
================================================
# Improving Documentation
We welcome all suggestions and improvements to the documentation of `@fp-ts/core`. Your contributions help make the library easier to understand and use for everyone.
## How to Contribute
To contribute to the documentation, follow these steps:
1. Make the desired changes to the documentation files.
2. Submit a pull request with a clear description of the changes and why they are beneficial.
## Content Guidelines
When contributing to the documentation, please keep in mind the following guidelines:
- Write clear and concise explanations of features and concepts.
- Use examples and code snippets to help illustrate your explanations.
- Follow the same formatting and style used in the existing documentation.
Thank you for your contributions to the `@fp-ts/core` documentation!
================================================
FILE: .github/ISSUE_TEMPLATE/Feature_request.md
================================================
# Feature Request
Thank you for submitting a feature request for `@fp-ts/core`. Your contributions help shape the future of this library.
## Describing the Feature
Please provide a clear and concise description of the new feature you would like to see added to `@fp-ts/core`.
## Problem to Solve
Please describe the problem that this new feature will solve, and why it's important.
## Use Case
Please provide a use case or an example of how this feature will be used.
## Alternatives Considered
Please describe any alternatives you have considered and why you believe this new feature is a better solution.
## Additional Context
Please provide any additional information or context that might be relevant to this feature request.
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
# Pull Request Template
## Description
Please describe the changes you have made and the purpose of the changes. If applicable, provide context or links to relevant issues or discussions.
## Types of Changes
What types of changes does your code introduce to the library?
- [ ] Bugfix
- [ ] New feature
- [ ] Documentation update
## Checklist
- [ ] I have read the [contributing guidelines](https://github.com/fp-ts/core/blob/main/.github/CONTRIBUTING.md) for this repository
- [ ] I have written tests for the changes I have made
- [ ] I have run `pnpm coverage` and my code is 100% covered
- [ ] I have updated the documentation (if applicable)
- [ ] I agree to license my contribution under the MIT license
## Additional Information
Is there anything else you would like to add? Are there any questions that need to be answered before merging this pull request?
================================================
FILE: .github/workflows/main.yml
================================================
name: Main Flow
on:
push:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.17.1]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/action-setup@v2.0.1
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm build
- run: pnpm test
- run: pnpm dtslint
- run: pnpm lint
- run: pnpm run docs
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
version: pnpm run version
publish: pnpm exec changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
================================================
FILE: .github/workflows/pr.yml
================================================
name: PR Flow
on:
pull_request:
branches:
- 'main'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.17.1]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: pnpm/action-setup@v2.0.1
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm build
- run: pnpm test
- run: pnpm dtslint
- run: pnpm lint
- run: pnpm run docs
================================================
FILE: .gitignore
================================================
coverage/
*.tsbuildinfo
node_modules/
yarn-error.log
.ultra.cache.json
.DS_Store
tmp/
build/
dist/
.idea/
================================================
FILE: .gitpod.yml
================================================
tasks:
- init: npm install -g pnpm && pnpm && pnpm run build
github:
prebuilds:
addCheck: true
vscode:
extensions:
- dbaeumer.vscode-eslint
================================================
FILE: .vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.formatOnSave": true,
"eslint.format.enable": true,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"eslint.validate": ["markdown", "javascript", "typescript"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": false
},
"editor.acceptSuggestionOnCommitCharacter": true,
"editor.acceptSuggestionOnEnter": "on",
"editor.quickSuggestionsDelay": 10,
"editor.suggestOnTriggerCharacters": true,
"editor.tabCompletion": "off",
"editor.suggest.localityBonus": true,
"editor.suggestSelection": "recentlyUsed",
"editor.wordBasedSuggestions": true,
"editor.parameterHints.enabled": true,
"files.watcherExclude": {
"**/target": true
},
"files.insertFinalNewline": true
}
================================================
FILE: .vscode/tasks.json
================================================
{
"version": "2.0.0",
"tasks": [
{
"label": "clean",
"type": "shell",
"command": "yarn clean",
"isBackground": false,
"problemMatcher": []
},
{
"label": "build-watch",
"type": "shell",
"command": "yarn build-watch",
"problemMatcher": ["$tsc-watch"],
"isBackground": true,
"presentation": {
"focus": false,
"panel": "shared",
"group": "dev",
"showReuseMessage": true,
"clear": false
}
},
{
"label": "build",
"type": "shell",
"command": "yarn build",
"problemMatcher": [],
"isBackground": false
},
{
"label": "test-watch",
"dependsOn": ["build-watch"],
"type": "shell",
"command": "yarn test",
"problemMatcher": []
}
]
}
================================================
FILE: CHANGELOG.md
================================================
# @fp-ts/core
## 0.2.1
### Patch Changes
- [#59](https://github.com/fp-ts/core/pull/59) [`5efa9c03`](https://github.com/fp-ts/core/commit/5efa9c03572c9f39dd0e801dfe404e9e18d5fba2) Thanks [@gcanti](https://github.com/gcanti)! - Predicate: add more guards
- [#60](https://github.com/fp-ts/core/pull/60) [`c48d2f56`](https://github.com/fp-ts/core/commit/c48d2f56063c31db5a42d426fa9a9ef270977843) Thanks [@gcanti](https://github.com/gcanti)! - add getOrThrowWith to Option, Either, These
- [#57](https://github.com/fp-ts/core/pull/57) [`549509b8`](https://github.com/fp-ts/core/commit/549509b8a02a515becd514cfbb00044b313d5ede) Thanks [@gcanti](https://github.com/gcanti)! - Number: add remainder
- [#56](https://github.com/fp-ts/core/pull/56) [`cf4918de`](https://github.com/fp-ts/core/commit/cf4918de74504ec59dd00df0ff251a549fb51284) Thanks [@gcanti](https://github.com/gcanti)! - ReadonlyArray: handle mutable arrays in isEmpty, isNonEmpty guards
## 0.2.0
### Minor Changes
- [#55](https://github.com/fp-ts/core/pull/55) [`b3e7ff34`](https://github.com/fp-ts/core/commit/b3e7ff34596b9cf90cc94c7349cf340fb0df82ef) Thanks [@gcanti](https://github.com/gcanti)! - Identity: remove exports except do notation ones
- [#55](https://github.com/fp-ts/core/pull/55) [`a99a23a1`](https://github.com/fp-ts/core/commit/a99a23a15ccd1c9d1f623f39d4727cb3ff0be3f7) Thanks [@gcanti](https://github.com/gcanti)! - Either: make orElse, orElseEither lazy and remove catchAll
- [#55](https://github.com/fp-ts/core/pull/55) [`31b5fffc`](https://github.com/fp-ts/core/commit/31b5fffc175f4740c8f31f05afba48b6b8cb9cd6) Thanks [@gcanti](https://github.com/gcanti)! - Option: remove fromThrowable
- [#55](https://github.com/fp-ts/core/pull/55) [`14de6de2`](https://github.com/fp-ts/core/commit/14de6de207c63d460ecabcb6b13f5d9abb697f05) Thanks [@gcanti](https://github.com/gcanti)! - Option: remove coproductEither
- [#55](https://github.com/fp-ts/core/pull/55) [`f3cc9d2c`](https://github.com/fp-ts/core/commit/f3cc9d2cf2440586f2681f447ae9056d94a631d7) Thanks [@gcanti](https://github.com/gcanti)! - rename `element` to `appendElement`
- [#55](https://github.com/fp-ts/core/pull/55) [`2bb91d1e`](https://github.com/fp-ts/core/commit/2bb91d1e15ec62bfa762bb17aec6c97305b94692) Thanks [@gcanti](https://github.com/gcanti)! - Function: flip apply
- [#55](https://github.com/fp-ts/core/pull/55) [`9569811e`](https://github.com/fp-ts/core/commit/9569811ea5506fb4206c1b9dbde7dbdbe7e9a8bc) Thanks [@gcanti](https://github.com/gcanti)! - Covariant: flip flap
- [#55](https://github.com/fp-ts/core/pull/55) [`ae3338c0`](https://github.com/fp-ts/core/commit/ae3338c091284e0af7b24e1be818a96d59a77f09) Thanks [@gcanti](https://github.com/gcanti)! - Either: rename `firstSuccessOf` to `firstRightOf`
- [#55](https://github.com/fp-ts/core/pull/55) [`a4a6ebbc`](https://github.com/fp-ts/core/commit/a4a6ebbcf73b453e526fbc42a76424732b8fdb23) Thanks [@gcanti](https://github.com/gcanti)! - remove `orElseSucceed`
- [#55](https://github.com/fp-ts/core/pull/55) [`99088b21`](https://github.com/fp-ts/core/commit/99088b21a5945cb744a380947ee79378f19766f3) Thanks [@gcanti](https://github.com/gcanti)! - remove `imap` from exports
- [#55](https://github.com/fp-ts/core/pull/55) [`d4fcf63e`](https://github.com/fp-ts/core/commit/d4fcf63e16f15ac86a96e89b0b47c7d2647a6fe6) Thanks [@gcanti](https://github.com/gcanti)! - Option: make orElse, orElseEither lazy and remove catchAll
- [#55](https://github.com/fp-ts/core/pull/55) [`bfb22498`](https://github.com/fp-ts/core/commit/bfb22498cb9287d40e231b4992937e3313fae1fe) Thanks [@gcanti](https://github.com/gcanti)! - Option: remove `compact`
- [#55](https://github.com/fp-ts/core/pull/55) [`4463f4f1`](https://github.com/fp-ts/core/commit/4463f4f1649ca2f984d715d0aa22055a3a8d6519) Thanks [@gcanti](https://github.com/gcanti)! - Option: change `firstSomeOf` signature
- [#55](https://github.com/fp-ts/core/pull/55) [`18f70fcb`](https://github.com/fp-ts/core/commit/18f70fcb18c5e8f26980fd88c1192808df241631) Thanks [@gcanti](https://github.com/gcanti)! - Either: remove `fromThrowable`
### Patch Changes
- [#55](https://github.com/fp-ts/core/pull/55) [`ce345a8d`](https://github.com/fp-ts/core/commit/ce345a8dd5bae7694cdbdd1bf5056b337175810d) Thanks [@gcanti](https://github.com/gcanti)! - add default handler to `getOrThrow`
- [#55](https://github.com/fp-ts/core/pull/55) [`615d492e`](https://github.com/fp-ts/core/commit/615d492ea79b47472da256b4dea6f33835f24d23) Thanks [@gcanti](https://github.com/gcanti)! - algebraic operations: add support for bigint
- [#55](https://github.com/fp-ts/core/pull/55) [`14f87fb3`](https://github.com/fp-ts/core/commit/14f87fb33061ef1e36a5695c0f28578c9f860cf1) Thanks [@gcanti](https://github.com/gcanti)! - Option: add `reduceAll`
- [#51](https://github.com/fp-ts/core/pull/51) [`175d6b9e`](https://github.com/fp-ts/core/commit/175d6b9e93dbf6bfbea80b34a06f26ceb3d725aa) Thanks [@gcanti](https://github.com/gcanti)! - Option, Either, These: switch to interfaces
- [#51](https://github.com/fp-ts/core/pull/51) [`3efb6d8a`](https://github.com/fp-ts/core/commit/3efb6d8a9a343ca177ec7bcc3e360974aec307cf) Thanks [@gcanti](https://github.com/gcanti)! - Function: add dual utility
## 0.1.1
### Patch Changes
- [#48](https://github.com/fp-ts/core/pull/48) [`da0bae84`](https://github.com/fp-ts/core/commit/da0bae8487d59d78c5ba6470d37727ccc66538bb) Thanks [@gcanti](https://github.com/gcanti)! - change structural tracking
## 0.1.0
### Minor Changes
- [#46](https://github.com/fp-ts/core/pull/46) [`0bd0d604`](https://github.com/fp-ts/core/commit/0bd0d60454642d7b1692d923c2d240b747ac797b) Thanks [@gcanti](https://github.com/gcanti)! - add modules from @fp-ts/data
### Patch Changes
- [#46](https://github.com/fp-ts/core/pull/46) [`3c256fa8`](https://github.com/fp-ts/core/commit/3c256fa8b9bbb4379ad51c5e48781deaaac2990a) Thanks [@gcanti](https://github.com/gcanti)! - Add tracking code for Option
## next
**Breaking changes**
- remove `NonEmptyTraversable` module
- `Semigroup`
- make `combine` binary
- make `combineMany` binary
- `SemiCoproduct`
- make `coproduct` binary
- make `coproductMany` binary
- `SemiProduct`
- make `product` binary
- make `productMany` binary
- rename `productFlatten` to `element`
- `Order`
- make `compare` binary
**New Features**
- `Boolean`
- add `not` combinator
- `Order`
- add `array` combinator
- add `bigint` instance
- `Monoid`
- add `array`, `readonlyArray` combinators
- `Semigroup`
- add `array`, `readonlyArray` combinators
- new modules
- `typeclass/Equivalence`
- `typeclass/Filterable`
- `typeclass/TraversableFilterable`
- `Bigint`
- `Boolean`
- `Either`
- `Function`
- `Identity`
- `Number`
- `Option`
- `Ordering`
- `Predicate`
- `ReadonlyArray`
- `ReadonyRecord`
- `String`
- `Struct`
- `Symbol`
- `These`
- `Tuple`
## 0.0.11
### Patch Changes
- [#39](https://github.com/fp-ts/core/pull/39) [`c27db5e7`](https://github.com/fp-ts/core/commit/c27db5e796071966a64af1a860b56e417f99423e) Thanks [@gcanti](https://github.com/gcanti)! - revert 0.0.10 changes
## 0.0.10
### Patch Changes
- [#36](https://github.com/fp-ts/core/pull/36) [`51bb90bd`](https://github.com/fp-ts/core/commit/51bb90bd4f32bd878575a159a2bc0c8c3b3ff57b) Thanks [@gcanti](https://github.com/gcanti)! - remove readonly
## 0.0.9
### Patch Changes
- [#33](https://github.com/fp-ts/core/pull/33) [`c8246ea5`](https://github.com/fp-ts/core/commit/c8246ea56c07d44507b90be49bc529ddee2847d6) Thanks [@gcanti](https://github.com/gcanti)! - remove Compactable, Filterable, TraversableFilterable and /data folder
## 0.0.8
### Patch Changes
- [#29](https://github.com/fp-ts/core/pull/29) [`c2e0f09d`](https://github.com/fp-ts/core/commit/c2e0f09dc0d5aca2cc3c200adbe25991ff1a8c0c) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyAlternative: rename to SemiAlternative
- [#29](https://github.com/fp-ts/core/pull/29) [`adbf4dbc`](https://github.com/fp-ts/core/commit/adbf4dbc1e6d8ea2d85e897de8048be7ac6dd88c) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyProduct: rename to SemiProduct
- [#29](https://github.com/fp-ts/core/pull/29) [`07b7061b`](https://github.com/fp-ts/core/commit/07b7061bcef03d405a47777bc89e979c1b58e335) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyProduct: rename bindKind to andThenBind
- [#29](https://github.com/fp-ts/core/pull/29) [`1f116d3d`](https://github.com/fp-ts/core/commit/1f116d3ddfbb26afd9e92b7001de7f1425774d3e) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyApplicative: rename to SemiApplicative
- [#29](https://github.com/fp-ts/core/pull/29) [`d539285e`](https://github.com/fp-ts/core/commit/d539285e270d69bd995a3ebc4e98a84b74665f46) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyCoproduct: rename to SemiCoproduct
## 0.0.7
### Patch Changes
- [#26](https://github.com/fp-ts/core/pull/26) [`2aa35975`](https://github.com/fp-ts/core/commit/2aa35975d2803377c0a629603b308e3c2c6448b9) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyTraversable: rename nonEmptyTraverse to traverseNonEmpty, nonEmptySequence to sequenceNonEmpty
- [#26](https://github.com/fp-ts/core/pull/26) [`9d4ac0bb`](https://github.com/fp-ts/core/commit/9d4ac0bb2dc82a33a9959565b6af8289af0f4403) Thanks [@gcanti](https://github.com/gcanti)! - Traversable: add sequence as member
- [#26](https://github.com/fp-ts/core/pull/26) [`eb6020ca`](https://github.com/fp-ts/core/commit/eb6020ca6b8d1cbe3cb4ead58ab9b54cc9ce82a3) Thanks [@gcanti](https://github.com/gcanti)! - Foldable: remove reduceRight from typeclass
- [#28](https://github.com/fp-ts/core/pull/28) [`9f6a193e`](https://github.com/fp-ts/core/commit/9f6a193e4580aadc18ccc172a9e3cf6ffde5c19d) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyCoproduct / Coproduct: fix getSemigroup / getMonoid type params
- [#26](https://github.com/fp-ts/core/pull/26) [`29a94c17`](https://github.com/fp-ts/core/commit/29a94c17f0f018627892f1749acbdea07471374f) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyProduct: rename struct to nonEmptyStruct
- [#26](https://github.com/fp-ts/core/pull/26) [`577f9597`](https://github.com/fp-ts/core/commit/577f9597db0a53728fca14e9a945e1e0d7164957) Thanks [@gcanti](https://github.com/gcanti)! - Foldable: add a default `reduceRight` implementation
- [#26](https://github.com/fp-ts/core/pull/26) [`fc914c93`](https://github.com/fp-ts/core/commit/fc914c9319017abd3da4b11987342fbf56806eca) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyTraversable: add sequenceNonEmpty as member
- [#26](https://github.com/fp-ts/core/pull/26) [`fc4d0aae`](https://github.com/fp-ts/core/commit/fc4d0aaef2aeca6b63f10432695c62e808c6310b) Thanks [@gcanti](https://github.com/gcanti)! - NonEmptyProduct: rename tuple to nonEmptyTuple
## 0.0.6
### Patch Changes
- [#22](https://github.com/fp-ts/core/pull/22) [`e71d3d57`](https://github.com/fp-ts/core/commit/e71d3d57b0869ab3283a7bb68e76452bc0a2ffba) Thanks [@gcanti](https://github.com/gcanti)! - rename HKT params
## 0.0.5
### Patch Changes
- [#18](https://github.com/fp-ts/core/pull/18) [`be638f44`](https://github.com/fp-ts/core/commit/be638f44764484c8d93943d916d3fc0285466cbd) Thanks [@gcanti](https://github.com/gcanti)! - Semigroup: fix reverse implementation
- [#18](https://github.com/fp-ts/core/pull/18) [`ae9715f6`](https://github.com/fp-ts/core/commit/ae9715f6670fda76e25c955cdaab17c65af098ba) Thanks [@gcanti](https://github.com/gcanti)! - Foldable / FoldableWithIndex: add compositions
- [#18](https://github.com/fp-ts/core/pull/18) [`ba899d76`](https://github.com/fp-ts/core/commit/ba899d76debfd15031d0fff9079332fd33394f9b) Thanks [@gcanti](https://github.com/gcanti)! - Foldable / FlodableWithIndex: curry toReadonlyArrayWith and add toReadonlyArray
- [#18](https://github.com/fp-ts/core/pull/18) [`2d30a185`](https://github.com/fp-ts/core/commit/2d30a1852227ac4f5279ebafef46ac527f5048ee) Thanks [@gcanti](https://github.com/gcanti)! - add FunctorWithIndex module
- [#18](https://github.com/fp-ts/core/pull/18) [`9c531794`](https://github.com/fp-ts/core/commit/9c531794ca69346f38740e002687e4bd55fcb6b9) Thanks [@gcanti](https://github.com/gcanti)! - Semigroupal: remove useless zipWith export
- [#18](https://github.com/fp-ts/core/pull/18) [`9683f82d`](https://github.com/fp-ts/core/commit/9683f82d68e35bfa471a6b39d59830b078d868c9) Thanks [@gcanti](https://github.com/gcanti)! - Bounded: swap maximum, minimum arguments in fromSortable
## 0.0.4
### Patch Changes
- [#14](https://github.com/fp-ts/core/pull/14) [`1cac5547`](https://github.com/fp-ts/core/commit/1cac5547815673308916236780b94c6263825cde) Thanks [@gcanti](https://github.com/gcanti)! - rename Succeed typeclass to Pointed / of
- [#14](https://github.com/fp-ts/core/pull/14) [`6c9be695`](https://github.com/fp-ts/core/commit/6c9be6950e8bb004802dce959f8d133f7e911aa7) Thanks [@gcanti](https://github.com/gcanti)! - make all typeclass operations pipeable
- [#14](https://github.com/fp-ts/core/pull/14) [`8ae84df9`](https://github.com/fp-ts/core/commit/8ae84df993f63d1255a9b40a614fcc79fea8ad68) Thanks [@gcanti](https://github.com/gcanti)! - SemigroupKind: fix combineKind signature
- [#14](https://github.com/fp-ts/core/pull/14) [`51d62040`](https://github.com/fp-ts/core/commit/51d62040bf25ddc8e7911171d48b60282a35fb26) Thanks [@gcanti](https://github.com/gcanti)! - Ordering: remove sign function
- [#14](https://github.com/fp-ts/core/pull/14) [`89665e87`](https://github.com/fp-ts/core/commit/89665e8768e1c9fac1894c12b74e5941341a9473) Thanks [@gcanti](https://github.com/gcanti)! - remove Show typeclass
## 0.0.3
### Patch Changes
- [#12](https://github.com/fp-ts/core/pull/12) [`7c6fa2c4`](https://github.com/fp-ts/core/commit/7c6fa2c4992dd3aeffbd1e7a9aeb564a62c5f149) Thanks [@mikearnaldi](https://github.com/mikearnaldi)! - type class refactoring
## 0.0.2
### Patch Changes
- [#8](https://github.com/fp-ts/core/pull/8) [`79b1237c`](https://github.com/fp-ts/core/commit/79b1237c22a16f8354f8c5f086922585ce26b572) Thanks [@mikearnaldi](https://github.com/mikearnaldi)! - Fix package json repository urls
## 0.0.1
### Patch Changes
- [#1](https://github.com/fp-ts/core/pull/1) [`65983dd9`](https://github.com/fp-ts/core/commit/65983dd99a04cd2d1d6f503dabaa600df5c82d17) Thanks [@mikearnaldi](https://github.com/mikearnaldi)! - Dual ESM-CJS Support
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2017-present Giulio Canti
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
**Announcement**: following the [official decision](https://dev.to/effect-ts/a-bright-future-for-effect-455m) to merge the `fp-ts` project with the Effect-TS ecosystem, active development has been transferred to the repository https://github.com/Effect-TS/data.
================================================
FILE: benchmark/Number/lessThan.ts
================================================
import { dual } from "@fp-ts/core/Function";
import { lessThan } from "@fp-ts/core/Number"
import * as Benchmark from "benchmark"
/*
*/
const suite = new Benchmark.Suite()
const lessThanBaseline: {
(that: number): (self: number) => boolean;
(self: number, that: number): boolean;
} = dual(2, (self: number, that: number): boolean => self < that)
suite
.add("lessThanBaseline", function() {
lessThanBaseline(2, 1)
})
.add("lessThan", function() {
lessThan(2, 1)
})
.on("cycle", function(event: any) {
console.log(String(event.target))
})
.on("complete", function(this: any) {
console.log("Fastest is " + this.filter("fastest").map("name"))
})
.run({ async: true })
================================================
FILE: benchmark/These/product.ts
================================================
import { Product, right, fail } from "@fp-ts/core/These"
import * as Benchmark from "benchmark"
/*
*/
const suite = new Benchmark.Suite()
suite
.add("Product.product", function() {
Product.product(right(1), fail('e'))
})
.add("Product.productAll", function() {
Product.productAll([right(1), fail('e')])
})
.on("cycle", function(event: any) {
console.log(String(event.target))
})
.on("complete", function(this: any) {
console.log("Fastest is " + this.filter("fastest").map("name"))
})
.run({ async: true })
================================================
FILE: benchmark/dual.ts
================================================
import { sum } from "@fp-ts/core/Number"
import * as Benchmark from "benchmark"
/*
sum(a, b) x 39,807,035 ops/sec ±0.79% (87 runs sampled)
binary(a, b) x 745,618,052 ops/sec ±0.53% (91 runs sampled)
sum(b)(a) x 2,423,147 ops/sec ±1.50% (82 runs sampled)
curried(b)(a) x 737,608,819 ops/sec ±0.60% (88 runs sampled)
*/
const suite = new Benchmark.Suite()
const binary = (a: number, b: number): number => a + b
const curried = (a: number) => (b: number): number => a + b
suite
.add("sum(a, b)", function() {
sum(1, 2)
})
.add("binary(a, b)", function() {
binary(1, 2)
})
.add("sum(b)(a)", function() {
sum(2)(1)
})
.add("curried(b)(a)", function() {
curried(2)(1)
})
.on("cycle", function(event: any) {
console.log(String(event.target))
})
.on("complete", function(this: any) {
console.log("Fastest is " + this.filter("fastest").map("name"))
})
.run({ async: true })
================================================
FILE: benchmark/sumAll.ts
================================================
import { fromIterable } from "@fp-ts/core/internal/ReadonlyArray"
import { sumAll } from "@fp-ts/core/Number"
import * as Benchmark from "benchmark"
/*
sumAll x 98,318,148 ops/sec ±0.46% (91 runs sampled)
sum x 104,495,149 ops/sec ±0.76% (90 runs sampled)
*/
const suite = new Benchmark.Suite()
const sum = (collection: Iterable<number>): number => fromIterable(collection).reduce((a, b) => a + b, 0)
suite
.add("sumAll", function() {
sumAll([1, 2, 3, 4, 5])
})
.add("sum", function() {
sum([1, 2, 3, 4, 5])
})
.on("cycle", function(event: any) {
console.log(String(event.target))
})
.on("complete", function(this: any) {
console.log("Fastest is " + this.filter("fastest").map("name"))
})
.run({ async: true })
================================================
FILE: benchmark/tsconfig.json
================================================
{
"compilerOptions": {
"strict": true,
"module": "commonjs",
"paths": {
"@fp-ts/core": ["../src/index.ts"],
"@fp-ts/core/test/*": ["../test/*"],
"@fp-ts/core/examples/*": ["../examples/*"],
"@fp-ts/core/*": ["../src/*"]
}
}
}
================================================
FILE: docs/_config.yml
================================================
remote_theme: mikearnaldi/just-the-docs
# Enable or disable the site search
search_enabled: true
# Aux links for the upper right navigation
aux_links:
"Docs":
- "//fp-ts.github.io/core"
"API Reference":
- "//fp-ts.github.io/core/docs/modules"
"GitHub":
- "//github.com/fp-ts/core"
================================================
FILE: docs/_sass/custom/custom.scss
================================================
$fp-ts-blue-000: #0088e6;
$fp-ts-blue-100: #0075c5;
$link-color: $fp-ts-blue-000;
$btn-primary-color: $fp-ts-blue-100;
================================================
FILE: docs/index.md
================================================
---
title: Introduction
permalink: /
nav_order: 1
has_children: false
has_toc: false
---
<img alt="fp-ts logo" src="./fp-ts-logo.png" style="display: block; width: 200px; margin-bottom: 2em;">
# Typed functional programming in TypeScript
`@fp-ts/core` provides developers with popular patterns and reliable abstractions from typed functional languages in TypeScript.
{: .fs-6 .fw-300 }
**Disclaimer**. Teaching functional programming is out of scope of this project, so the documentation assumes you already know what FP is.
================================================
FILE: docs/modules/Bigint.ts.md
================================================
---
title: Bigint.ts
nav_order: 1
parent: Modules
---
## Bigint overview
This module provides utility functions and type class instances for working with the `bigint` type in TypeScript.
It includes functions for basic arithmetic operations, as well as type class instances for
`Equivalence`, `Order`, `Semigroup`, and `Monoid`.
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [guards](#guards)
- [isBigint](#isbigint)
- [instances](#instances)
- [Equivalence](#equivalence)
- [MonoidMultiply](#monoidmultiply)
- [MonoidSum](#monoidsum)
- [Order](#order)
- [SemigroupMax](#semigroupmax)
- [SemigroupMin](#semigroupmin)
- [SemigroupMultiply](#semigroupmultiply)
- [SemigroupSum](#semigroupsum)
- [math](#math)
- [decrement](#decrement)
- [divide](#divide)
- [increment](#increment)
- [multiply](#multiply)
- [multiplyAll](#multiplyall)
- [sign](#sign)
- [subtract](#subtract)
- [sum](#sum)
- [sumAll](#sumall)
- [predicates](#predicates)
- [between](#between)
- [greaterThan](#greaterthan)
- [greaterThanOrEqualTo](#greaterthanorequalto)
- [lessThan](#lessthan)
- [lessThanOrEqualTo](#lessthanorequalto)
- [utils](#utils)
- [clamp](#clamp)
- [max](#max)
- [min](#min)
---
# guards
## isBigint
Tests if a value is a `bigint`.
**Signature**
```ts
export declare const isBigint: (u: unknown) => u is bigint
```
**Example**
```ts
import { isBigint } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(isBigint(1n), true)
assert.deepStrictEqual(isBigint(1), false)
```
Added in v1.0.0
# instances
## Equivalence
**Signature**
```ts
export declare const Equivalence: equivalence.Equivalence<bigint>
```
Added in v1.0.0
## MonoidMultiply
`bigint` monoid under multiplication.
The `empty` value is `1n`.
**Signature**
```ts
export declare const MonoidMultiply: monoid.Monoid<bigint>
```
**Example**
```ts
import { MonoidMultiply } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(MonoidMultiply.combine(2n, 3n), 6n)
assert.deepStrictEqual(MonoidMultiply.combine(2n, MonoidMultiply.empty), 2n)
```
Added in v1.0.0
## MonoidSum
`bigint` monoid under addition.
The `empty` value is `0n`.
**Signature**
```ts
export declare const MonoidSum: monoid.Monoid<bigint>
```
**Example**
```ts
import { MonoidSum } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(MonoidSum.combine(2n, 3n), 5n)
assert.deepStrictEqual(MonoidSum.combine(2n, MonoidSum.empty), 2n)
```
Added in v1.0.0
## Order
**Signature**
```ts
export declare const Order: order.Order<bigint>
```
Added in v1.0.0
## SemigroupMax
A `Semigroup` that uses the maximum between two values.
**Signature**
```ts
export declare const SemigroupMax: semigroup.Semigroup<bigint>
```
**Example**
```ts
import { SemigroupMax } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(SemigroupMax.combine(2n, 3n), 3n)
```
Added in v1.0.0
## SemigroupMin
A `Semigroup` that uses the minimum between two values.
**Signature**
```ts
export declare const SemigroupMin: semigroup.Semigroup<bigint>
```
**Example**
```ts
import { SemigroupMin } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(SemigroupMin.combine(2n, 3n), 2n)
```
Added in v1.0.0
## SemigroupMultiply
`bigint` semigroup under multiplication.
**Signature**
```ts
export declare const SemigroupMultiply: semigroup.Semigroup<bigint>
```
Added in v1.0.0
## SemigroupSum
`bigint` semigroup under addition.
**Signature**
```ts
export declare const SemigroupSum: semigroup.Semigroup<bigint>
```
**Example**
```ts
import { SemigroupSum } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(SemigroupSum.combine(2n, 3n), 5n)
```
Added in v1.0.0
# math
## decrement
Decrements a number by `1n`.
**Signature**
```ts
export declare const decrement: (n: bigint) => bigint
```
**Example**
```ts
import { decrement } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(decrement(3n), 2n)
```
Added in v1.0.0
## divide
Provides a division operation on `bigint`s.
If the dividend is not a multiple of the divisor the result will be a `bigint` value
which represents the integer division rounded down to the nearest integer.
**Signature**
```ts
export declare const divide: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }
```
**Example**
```ts
import { divide } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(divide(6n, 3n), 2n)
assert.deepStrictEqual(divide(6n, 4n), 1n)
```
Added in v1.0.0
## increment
Returns the result of adding `1n` to a given number.
**Signature**
```ts
export declare const increment: (n: bigint) => bigint
```
**Example**
```ts
import { increment } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(increment(2n), 3n)
```
Added in v1.0.0
## multiply
Provides a multiplication operation on `bigint`s.
**Signature**
```ts
export declare const multiply: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }
```
**Example**
```ts
import { multiply } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(multiply(2n, 3n), 6n)
```
Added in v1.0.0
## multiplyAll
Takes an `Iterable` of `bigint`s and returns their multiplication as a single `number`.
**Signature**
```ts
export declare const multiplyAll: (collection: Iterable<bigint>) => bigint
```
**Example**
```ts
import { multiplyAll } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(multiplyAll([2n, 3n, 4n]), 24n)
```
Added in v1.0.0
## sign
Determines the sign of a given `bigint`.
**Signature**
```ts
export declare const sign: (n: bigint) => Ordering
```
**Example**
```ts
import { sign } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(sign(-5n), -1)
assert.deepStrictEqual(sign(0n), 0)
assert.deepStrictEqual(sign(5n), 1)
```
Added in v1.0.0
## subtract
Provides a subtraction operation on `bigint`s.
**Signature**
```ts
export declare const subtract: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }
```
**Example**
```ts
import { subtract } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(subtract(2n, 3n), -1n)
```
Added in v1.0.0
## sum
Provides an addition operation on `bigint`s.
**Signature**
```ts
export declare const sum: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }
```
**Example**
```ts
import { sum } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(sum(2n, 3n), 5n)
```
Added in v1.0.0
## sumAll
Takes an `Iterable` of `bigint`s and returns their sum as a single `bigint
**Signature**
```ts
export declare const sumAll: (collection: Iterable<bigint>) => bigint
```
**Example**
```ts
import { sumAll } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(sumAll([2n, 3n, 4n]), 9n)
```
Added in v1.0.0
# predicates
## between
Checks if a `bigint` is between a `minimum` and `maximum` value (inclusive).
**Signature**
```ts
export declare const between: {
(minimum: bigint, maximum: bigint): (self: bigint) => boolean
(self: bigint, minimum: bigint, maximum: bigint): boolean
}
```
**Example**
```ts
import { between } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(between(0n, 5n)(3n), true)
assert.deepStrictEqual(between(0n, 5n)(-1n), false)
assert.deepStrictEqual(between(0n, 5n)(6n), false)
```
Added in v1.0.0
## greaterThan
Returns `true` if the first argument is greater than the second, otherwise `false`.
**Signature**
```ts
export declare const greaterThan: { (that: bigint): (self: bigint) => boolean; (self: bigint, that: bigint): boolean }
```
**Example**
```ts
import { greaterThan } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(greaterThan(2n, 3n), false)
assert.deepStrictEqual(greaterThan(3n, 3n), false)
assert.deepStrictEqual(greaterThan(4n, 3n), true)
```
Added in v1.0.0
## greaterThanOrEqualTo
Returns a function that checks if a given `bigint` is greater than or equal to the provided one.
**Signature**
```ts
export declare const greaterThanOrEqualTo: {
(that: bigint): (self: bigint) => boolean
(self: bigint, that: bigint): boolean
}
```
**Example**
```ts
import { greaterThanOrEqualTo } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(greaterThanOrEqualTo(2n, 3n), false)
assert.deepStrictEqual(greaterThanOrEqualTo(3n, 3n), true)
assert.deepStrictEqual(greaterThanOrEqualTo(4n, 3n), true)
```
Added in v1.0.0
## lessThan
Returns `true` if the first argument is less than the second, otherwise `false`.
**Signature**
```ts
export declare const lessThan: { (that: bigint): (self: bigint) => boolean; (self: bigint, that: bigint): boolean }
```
**Example**
```ts
import { lessThan } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(lessThan(2n, 3n), true)
assert.deepStrictEqual(lessThan(3n, 3n), false)
assert.deepStrictEqual(lessThan(4n, 3n), false)
```
Added in v1.0.0
## lessThanOrEqualTo
Returns a function that checks if a given `bigint` is less than or equal to the provided one.
**Signature**
```ts
export declare const lessThanOrEqualTo: {
(that: bigint): (self: bigint) => boolean
(self: bigint, that: bigint): boolean
}
```
**Example**
```ts
import { lessThanOrEqualTo } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(lessThanOrEqualTo(2n, 3n), true)
assert.deepStrictEqual(lessThanOrEqualTo(3n, 3n), true)
assert.deepStrictEqual(lessThanOrEqualTo(4n, 3n), false)
```
Added in v1.0.0
# utils
## clamp
Restricts the given `bigint` to be within the range specified by the `minimum` and `maximum` values.
- If the `bigint` is less than the `minimum` value, the function returns the `minimum` value.
- If the `bigint` is greater than the `maximum` value, the function returns the `maximum` value.
- Otherwise, it returns the original `bigint`.
**Signature**
```ts
export declare const clamp: {
(minimum: bigint, maximum: bigint): (self: bigint) => bigint
(self: bigint, minimum: bigint, maximum: bigint): bigint
}
```
**Example**
```ts
import { clamp } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(clamp(0n, 5n)(3n), 3n)
assert.deepStrictEqual(clamp(0n, 5n)(-1n), 0n)
assert.deepStrictEqual(clamp(0n, 5n)(6n), 5n)
```
Added in v1.0.0
## max
Returns the maximum between two `bigint`s.
**Signature**
```ts
export declare const max: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }
```
**Example**
```ts
import { max } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(max(2n, 3n), 3n)
```
Added in v1.0.0
## min
Returns the minimum between two `bigint`s.
**Signature**
```ts
export declare const min: { (that: bigint): (self: bigint) => bigint; (self: bigint, that: bigint): bigint }
```
**Example**
```ts
import { min } from '@fp-ts/core/Bigint'
assert.deepStrictEqual(min(2n, 3n), 2n)
```
Added in v1.0.0
================================================
FILE: docs/modules/Boolean.ts.md
================================================
---
title: Boolean.ts
nav_order: 2
parent: Modules
---
## Boolean overview
This module provides utility functions and type class instances for working with the `boolean` type in TypeScript.
It includes functions for basic boolean operations, as well as type class instances for
`Equivalence`, `Order`, `Semigroup`, and `Monoid`.
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [combinators](#combinators)
- [and](#and)
- [eqv](#eqv)
- [implies](#implies)
- [nand](#nand)
- [nor](#nor)
- [not](#not)
- [or](#or)
- [xor](#xor)
- [guards](#guards)
- [isBoolean](#isboolean)
- [instances](#instances)
- [Equivalence](#equivalence)
- [MonoidAll](#monoidall)
- [MonoidAny](#monoidany)
- [MonoidEqv](#monoideqv)
- [MonoidXor](#monoidxor)
- [Order](#order)
- [SemigroupAll](#semigroupall)
- [SemigroupAny](#semigroupany)
- [SemigroupEqv](#semigroupeqv)
- [SemigroupXor](#semigroupxor)
- [pattern matching](#pattern-matching)
- [match](#match)
- [utils](#utils)
- [all](#all)
- [any](#any)
---
# combinators
## and
Combines two boolean using AND: `self && that`.
**Signature**
```ts
export declare const and: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }
```
**Example**
```ts
import { and } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(and(true, true), true)
assert.deepStrictEqual(and(true, false), false)
assert.deepStrictEqual(and(false, true), false)
assert.deepStrictEqual(and(false, false), false)
```
Added in v1.0.0
## eqv
Combines two booleans using EQV (aka XNOR): `!xor(self, that)`.
**Signature**
```ts
export declare const eqv: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }
```
**Example**
```ts
import { eqv } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(eqv(true, true), true)
assert.deepStrictEqual(eqv(true, false), false)
assert.deepStrictEqual(eqv(false, true), false)
assert.deepStrictEqual(eqv(false, false), true)
```
Added in v1.0.0
## implies
Combines two booleans using an implication: `(!self || that)`.
**Signature**
```ts
export declare const implies: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }
```
**Example**
```ts
import { implies } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(implies(true, true), true)
assert.deepStrictEqual(implies(true, false), false)
assert.deepStrictEqual(implies(false, true), true)
assert.deepStrictEqual(implies(false, false), true)
```
Added in v1.0.0
## nand
Combines two boolean using NAND: `!(self && that)`.
**Signature**
```ts
export declare const nand: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }
```
**Example**
```ts
import { nand } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(nand(true, true), false)
assert.deepStrictEqual(nand(true, false), true)
assert.deepStrictEqual(nand(false, true), true)
assert.deepStrictEqual(nand(false, false), true)
```
Added in v1.0.0
## nor
Combines two booleans using NOR: `!(self || that)`.
**Signature**
```ts
export declare const nor: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }
```
**Example**
```ts
import { nor } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(nor(true, true), false)
assert.deepStrictEqual(nor(true, false), false)
assert.deepStrictEqual(nor(false, true), false)
assert.deepStrictEqual(nor(false, false), true)
```
Added in v1.0.0
## not
Negates the given boolean: `!self`
**Signature**
```ts
export declare const not: (self: boolean) => boolean
```
**Example**
```ts
import { not } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(not(true), false)
assert.deepStrictEqual(not(false), true)
```
Added in v1.0.0
## or
Combines two boolean using OR: `self || that`.
**Signature**
```ts
export declare const or: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }
```
**Example**
```ts
import { or } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(or(true, true), true)
assert.deepStrictEqual(or(true, false), true)
assert.deepStrictEqual(or(false, true), true)
assert.deepStrictEqual(or(false, false), false)
```
Added in v1.0.0
## xor
Combines two booleans using XOR: `(!self && that) || (self && !that)`.
**Signature**
```ts
export declare const xor: { (that: boolean): (self: boolean) => boolean; (self: boolean, that: boolean): boolean }
```
**Example**
```ts
import { xor } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(xor(true, true), false)
assert.deepStrictEqual(xor(true, false), true)
assert.deepStrictEqual(xor(false, true), true)
assert.deepStrictEqual(xor(false, false), false)
```
Added in v1.0.0
# guards
## isBoolean
Tests if a value is a `boolean`.
**Signature**
```ts
export declare const isBoolean: (input: unknown) => input is boolean
```
**Example**
```ts
import { isBoolean } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(isBoolean(true), true)
assert.deepStrictEqual(isBoolean('true'), false)
```
Added in v1.0.0
# instances
## Equivalence
**Signature**
```ts
export declare const Equivalence: equivalence.Equivalence<boolean>
```
Added in v1.0.0
## MonoidAll
`boolean` monoid under conjunction, see also {@link SemigroupAll}.
The `empty` value is `true`.
**Signature**
```ts
export declare const MonoidAll: monoid.Monoid<boolean>
```
Added in v1.0.0
## MonoidAny
`boolean` monoid under disjunction, see also {@link SemigroupAny}.
The `empty` value is `false`.
**Signature**
```ts
export declare const MonoidAny: monoid.Monoid<boolean>
```
Added in v1.0.0
## MonoidEqv
`boolean` monoid under equivalence.
The `empty` value is `true`.
**Signature**
```ts
export declare const MonoidEqv: monoid.Monoid<boolean>
```
Added in v1.0.0
## MonoidXor
`boolean` monoid under exclusive disjunction, see also {@link SemigroupXor}.
The `empty` value is `false`.
**Signature**
```ts
export declare const MonoidXor: monoid.Monoid<boolean>
```
Added in v1.0.0
## Order
**Signature**
```ts
export declare const Order: order.Order<boolean>
```
Added in v1.0.0
## SemigroupAll
`boolean` semigroup under conjunction.
**Signature**
```ts
export declare const SemigroupAll: semigroup.Semigroup<boolean>
```
**Example**
```ts
import { SemigroupAll } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(SemigroupAll.combine(true, true), true)
assert.deepStrictEqual(SemigroupAll.combine(true, false), false)
assert.deepStrictEqual(SemigroupAll.combine(false, true), false)
assert.deepStrictEqual(SemigroupAll.combine(false, false), false)
```
Added in v1.0.0
## SemigroupAny
`boolean` semigroup under disjunction.
**Signature**
```ts
export declare const SemigroupAny: semigroup.Semigroup<boolean>
```
**Example**
```ts
import { SemigroupAny } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(SemigroupAny.combine(true, true), true)
assert.deepStrictEqual(SemigroupAny.combine(true, false), true)
assert.deepStrictEqual(SemigroupAny.combine(false, true), true)
assert.deepStrictEqual(SemigroupAny.combine(false, false), false)
```
Added in v1.0.0
## SemigroupEqv
`boolean` semigroup under equivalence.
**Signature**
```ts
export declare const SemigroupEqv: semigroup.Semigroup<boolean>
```
**Example**
```ts
import { SemigroupEqv } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(SemigroupEqv.combine(true, true), true)
assert.deepStrictEqual(SemigroupEqv.combine(true, false), false)
assert.deepStrictEqual(SemigroupEqv.combine(false, true), false)
assert.deepStrictEqual(SemigroupEqv.combine(false, false), true)
```
Added in v1.0.0
## SemigroupXor
`boolean` semigroup under exclusive disjunction.
**Signature**
```ts
export declare const SemigroupXor: semigroup.Semigroup<boolean>
```
**Example**
```ts
import { SemigroupXor } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(SemigroupXor.combine(true, true), false)
assert.deepStrictEqual(SemigroupXor.combine(true, false), true)
assert.deepStrictEqual(SemigroupXor.combine(false, true), true)
assert.deepStrictEqual(SemigroupXor.combine(false, false), false)
```
Added in v1.0.0
# pattern matching
## match
This function returns the result of either of the given functions depending on the value of the boolean parameter.
It is useful when you have to run one of two functions depending on the boolean value.
**Signature**
```ts
export declare const match: {
<A, B = A>(onFalse: LazyArg<A>, onTrue: LazyArg<B>): (value: boolean) => A | B
<A, B>(value: boolean, onFalse: LazyArg<A>, onTrue: LazyArg<B>): A | B
}
```
**Example**
```ts
import * as B from '@fp-ts/core/Boolean'
assert.deepStrictEqual(
B.match(
true,
() => "It's false!",
() => "It's true!"
),
"It's true!"
)
```
Added in v1.0.0
# utils
## all
This utility function is used to check if all the elements in a collection of boolean values are `true`.
**Signature**
```ts
export declare const all: (collection: Iterable<boolean>) => boolean
```
**Example**
```ts
import { all } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(all([true, true, true]), true)
assert.deepStrictEqual(all([true, false, true]), false)
```
Added in v1.0.0
## any
This utility function is used to check if at least one of the elements in a collection of boolean values is `true`.
**Signature**
```ts
export declare const any: (collection: Iterable<boolean>) => boolean
```
**Example**
```ts
import { any } from '@fp-ts/core/Boolean'
assert.deepStrictEqual(any([true, false, true]), true)
assert.deepStrictEqual(any([false, false, false]), false)
```
Added in v1.0.0
================================================
FILE: docs/modules/Either.ts.md
================================================
---
title: Either.ts
nav_order: 3
parent: Modules
---
## Either overview
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [combinators](#combinators)
- [tap](#tap)
- [combining](#combining)
- [all](#all)
- [andThenDiscard](#andthendiscard)
- [flatMap](#flatmap)
- [flatMapNullable](#flatmapnullable)
- [flatMapOption](#flatmapoption)
- [getFirstLeftMonoid](#getfirstleftmonoid)
- [getFirstLeftSemigroup](#getfirstleftsemigroup)
- [getFirstRightSemigroup](#getfirstrightsemigroup)
- [zipWith](#zipwith)
- [constructors](#constructors)
- [left](#left)
- [of](#of)
- [right](#right)
- [conversions](#conversions)
- [fromIterable](#fromiterable)
- [fromOption](#fromoption)
- [getLeft](#getleft)
- [getRight](#getright)
- [toArray](#toarray)
- [toOption](#tooption)
- [toRefinement](#torefinement)
- [debugging](#debugging)
- [inspectLeft](#inspectleft)
- [inspectRight](#inspectright)
- [do notation](#do-notation)
- [Do](#do)
- [andThenBind](#andthenbind)
- [appendElement](#appendelement)
- [bind](#bind)
- [bindTo](#bindto)
- [let](#let)
- [tupled](#tupled)
- [equivalence](#equivalence)
- [getEquivalence](#getequivalence)
- [error handling](#error-handling)
- [firstRightOf](#firstrightof)
- [mapLeft](#mapleft)
- [orElse](#orelse)
- [orElseEither](#orelseeither)
- [orElseFail](#orelsefail)
- [tapError](#taperror)
- [filtering](#filtering)
- [compact](#compact)
- [filter](#filter)
- [filterMap](#filtermap)
- [getters](#getters)
- [getOrElse](#getorelse)
- [getOrNull](#getornull)
- [getOrUndefined](#getorundefined)
- [lefts](#lefts)
- [rights](#rights)
- [guards](#guards)
- [isEither](#iseither)
- [isLeft](#isleft)
- [isRight](#isright)
- [instances](#instances)
- [Applicative](#applicative)
- [Bicovariant](#bicovariant)
- [Chainable](#chainable)
- [Covariant](#covariant)
- [FlatMap](#flatmap)
- [Foldable](#foldable)
- [Invariant](#invariant)
- [Monad](#monad)
- [Of](#of)
- [Pointed](#pointed)
- [Product](#product)
- [SemiAlternative](#semialternative)
- [SemiApplicative](#semiapplicative)
- [SemiCoproduct](#semicoproduct)
- [SemiProduct](#semiproduct)
- [Traversable](#traversable)
- [getOptionalSemigroup](#getoptionalsemigroup)
- [interop](#interop)
- [fromNullable](#fromnullable)
- [getOrThrow](#getorthrow)
- [getOrThrowWith](#getorthrowwith)
- [liftNullable](#liftnullable)
- [liftThrowable](#liftthrowable)
- [merge](#merge)
- [lifting](#lifting)
- [lift2](#lift2)
- [liftOption](#liftoption)
- [liftPredicate](#liftpredicate)
- [mapping](#mapping)
- [as](#as)
- [asUnit](#asunit)
- [bimap](#bimap)
- [flap](#flap)
- [map](#map)
- [math](#math)
- [divide](#divide)
- [multiply](#multiply)
- [subtract](#subtract)
- [sum](#sum)
- [models](#models)
- [Either (type alias)](#either-type-alias)
- [Left (interface)](#left-interface)
- [Right (interface)](#right-interface)
- [pattern matching](#pattern-matching)
- [match](#match)
- [traversing](#traversing)
- [sequence](#sequence)
- [traverse](#traverse)
- [traverseTap](#traversetap)
- [type lambdas](#type-lambdas)
- [EitherTypeLambda (interface)](#eithertypelambda-interface)
- [utils](#utils)
- [andThen](#andthen)
- [ap](#ap)
- [composeKleisliArrow](#composekleisliarrow)
- [contains](#contains)
- [exists](#exists)
- [flatten](#flatten)
- [reverse](#reverse)
- [struct](#struct)
- [tuple](#tuple)
- [unit](#unit)
---
# combinators
## tap
Returns an effect that effectfully "peeks" at the success of this effect.
**Signature**
```ts
export declare const tap: {
<E1, A, E2, _>(self: Either<E1, A>, f: (a: A) => Either<E2, _>): Either<E1 | E2, A>
<A, E2, _>(f: (a: A) => Either<E2, _>): <E1>(self: Either<E1, A>) => Either<E2 | E1, A>
}
```
Added in v1.0.0
# combining
## all
Similar to `Promise.all` but operates on `Either`s.
```
Iterable<Either<E, A>> -> Either<E, A[]>
```
Flattens a collection of `Either`s into a single `Either` that contains a list of all the `Right` values.
If there is a `Left` value in the collection, it returns the first `Left` found as the result.
**Signature**
```ts
export declare const all: <E, A>(collection: Iterable<Either<E, A>>) => Either<E, A[]>
```
**Example**
```ts
import * as E from '@fp-ts/core/Either'
assert.deepStrictEqual(E.all([E.right(1), E.right(2), E.right(3)]), E.right([1, 2, 3]))
assert.deepStrictEqual(E.all([E.right(1), E.left('error'), E.right(3)]), E.left('error'))
```
Added in v1.0.0
## andThenDiscard
Sequences the specified effect after this effect, but ignores the value
produced by the effect.
**Signature**
```ts
export declare const andThenDiscard: {
<E1, A, E2, _>(self: Either<E1, A>, that: Either<E2, _>): Either<E1 | E2, A>
<E2, _>(that: Either<E2, _>): <E1, A>(self: Either<E1, A>) => Either<E2 | E1, A>
}
```
Added in v1.0.0
## flatMap
**Signature**
```ts
export declare const flatMap: {
<A, E2, B>(f: (a: A) => Either<E2, B>): <E1>(self: Either<E1, A>) => Either<E2 | E1, B>
<E1, A, E2, B>(self: Either<E1, A>, f: (a: A) => Either<E2, B>): Either<E1 | E2, B>
}
```
Added in v1.0.0
## flatMapNullable
**Signature**
```ts
export declare const flatMapNullable: {
<A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <E1>(
self: Either<E1, A>
) => Either<E2 | E1, NonNullable<B>>
<E1, A, B, E2>(self: Either<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): Either<
E1 | E2,
NonNullable<B>
>
}
```
Added in v1.0.0
## flatMapOption
**Signature**
```ts
export declare const flatMapOption: {
<A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <E1>(self: Either<E1, A>) => Either<E2 | E1, B>
<E1, A, B, E2>(self: Either<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): Either<E1 | E2, B>
}
```
Added in v1.0.0
## getFirstLeftMonoid
`Monoid` returning the left-most `Left` value. If both operands are `Right`s then the inner values
are combined using the provided `Monoid`.
- `combine` is provided by {@link getFirstLeftSemigroup}.
- `empty` is `right(M.empty)`
**Signature**
```ts
export declare const getFirstLeftMonoid: <A, E>(M: Monoid<A>) => Monoid<Either<E, A>>
```
Added in v1.0.0
## getFirstLeftSemigroup
`Semigroup` returning the left-most `Left` value. If both operands are `Right`s then the inner values
are combined using the provided `Semigroup`.
```
| self | that | combine(self, that) |
| ---------- | ---------- | ----------------------- |
| left(e1) | left(e2) | left(e1) |
| left(e1) | right(a2) | left(e1) |
| right(a1) | left(e2) | left(e2) |
| right(a1) | right(a2) | right(combine(a1, a2)) |
```
**Signature**
```ts
export declare const getFirstLeftSemigroup: <A, E>(S: Semigroup<A>) => Semigroup<Either<E, A>>
```
Added in v1.0.0
## getFirstRightSemigroup
Semigroup returning the left-most `Right` value.
```
| self | that | combine(self, that) |
| ---------- | ---------- | ------------------- |
| left(e1) | left(e2) | left(e2) |
| left(e1) | right(a2) | right(a2) |
| right(a1) | left(e2) | right(a1) |
| right(a1) | right(a2) | right(a1) |
```
**Signature**
```ts
export declare const getFirstRightSemigroup: <E, A>() => Semigroup<Either<E, A>>
```
Added in v1.0.0
## zipWith
**Signature**
```ts
export declare const zipWith: {
<E1, A, E2, B, C>(self: Either<E1, A>, that: Either<E2, B>, f: (a: A, b: B) => C): Either<E1 | E2, C>
<E2, B, A, C>(that: Either<E2, B>, f: (a: A, b: B) => C): <E1>(self: Either<E1, A>) => Either<E2 | E1, C>
}
```
Added in v1.0.0
# constructors
## left
Constructs a new `Either` holding a `Left` value. This usually represents a failure, due to the right-bias of this
structure.
**Signature**
```ts
export declare const left: <E>(e: E) => Either<E, never>
```
Added in v1.0.0
## of
Alias of {@link right}.
**Signature**
```ts
export declare const of: <A>(a: A) => Either<never, A>
```
Added in v1.0.0
## right
Constructs a new `Either` holding a `Right` value. This usually represents a successful value due to the right bias
of this structure.
**Signature**
```ts
export declare const right: <A>(a: A) => Either<never, A>
```
Added in v1.0.0
# conversions
## fromIterable
**Signature**
```ts
export declare const fromIterable: {
<E>(onEmpty: LazyArg<E>): <A>(collection: Iterable<A>) => Either<E, A>
<A, E>(collection: Iterable<A>, onEmpty: LazyArg<E>): Either<E, A>
}
```
Added in v1.0.0
## fromOption
**Signature**
```ts
export declare const fromOption: {
<A, E>(fa: Option<A>, onNone: () => E): Either<E, A>
<E>(onNone: () => E): <A>(fa: Option<A>) => Either<E, A>
}
```
**Example**
```ts
import * as E from '@fp-ts/core/Either'
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(
E.fromOption(O.some(1), () => 'error'),
E.right(1)
)
assert.deepStrictEqual(
E.fromOption(O.none(), () => 'error'),
E.left('error')
)
```
Added in v1.0.0
## getLeft
Converts a `Either` to an `Option` discarding the value.
**Signature**
```ts
export declare const getLeft: <E, A>(self: Either<E, A>) => Option<E>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
assert.deepStrictEqual(E.getLeft(E.right('ok')), O.none())
assert.deepStrictEqual(E.getLeft(E.left('err')), O.some('err'))
```
Added in v1.0.0
## getRight
Converts a `Either` to an `Option` discarding the error.
Alias of {@link toOption}.
**Signature**
```ts
export declare const getRight: <E, A>(self: Either<E, A>) => Option<A>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
assert.deepStrictEqual(E.getRight(E.right('ok')), O.some('ok'))
assert.deepStrictEqual(E.getRight(E.left('err')), O.none())
```
Added in v1.0.0
## toArray
Transforms an `Either` into an `Array`.
If the input is `Left`, an empty array is returned.
If the input is `Right`, the value is wrapped in an array.
**Signature**
```ts
export declare const toArray: <E, A>(self: Either<E, A>) => A[]
```
**Example**
```ts
import { right, left, toArray } from '@fp-ts/core/Either'
assert.deepStrictEqual(toArray(right(1)), [1])
assert.deepStrictEqual(toArray(left('error')), [])
```
Added in v1.0.0
## toOption
Converts a `Either` to an `Option` discarding the error.
**Signature**
```ts
export declare const toOption: <E, A>(self: Either<E, A>) => Option<A>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
assert.deepStrictEqual(E.toOption(E.right(1)), O.some(1))
assert.deepStrictEqual(E.toOption(E.left('a')), O.none())
```
Added in v1.0.0
## toRefinement
Returns a `Refinement` from a `Either` returning function.
This function ensures that a `Refinement` definition is type-safe.
**Signature**
```ts
export declare const toRefinement: <A, E, B extends A>(f: (a: A) => Either<E, B>) => Refinement<A, B>
```
Added in v1.0.0
# debugging
## inspectLeft
**Signature**
```ts
export declare const inspectLeft: {
<E>(onLeft: (e: E) => void): <A>(self: Either<E, A>) => Either<E, A>
<E, A>(self: Either<E, A>, onLeft: (e: E) => void): Either<E, A>
}
```
Added in v1.0.0
## inspectRight
**Signature**
```ts
export declare const inspectRight: {
<A>(onRight: (a: A) => void): <E>(self: Either<E, A>) => Either<E, A>
<E, A>(self: Either<E, A>, onRight: (a: A) => void): Either<E, A>
}
```
Added in v1.0.0
# do notation
## Do
**Signature**
```ts
export declare const Do: Either<never, {}>
```
Added in v1.0.0
## andThenBind
Extends the `Either` value with the value of another `Either` type.
If both `Either` instances are `Left`, then the result will be the first `Left`.
**Signature**
```ts
export declare const andThenBind: {
<N extends string, A extends object, E2, B>(name: Exclude<N, keyof A>, that: Either<E2, B>): <E1>(
self: Either<E1, A>
) => Either<E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
<E1, A extends object, N extends string, E2, B>(
self: Either<E1, A>,
name: Exclude<N, keyof A>,
that: Either<E2, B>
): Either<E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
}
```
**Example**
```ts
import * as E from '@fp-ts/core/Either'
import { pipe } from '@fp-ts/core/Function'
const result = pipe(
E.Do,
E.bind('a', () => E.left('e1')),
E.andThenBind('b', E.left('e2'))
)
assert.deepStrictEqual(result, E.left('e1'))
```
Added in v1.0.0
## appendElement
Appends an element to the end of a tuple.
**Signature**
```ts
export declare const appendElement: {
<E1, A extends readonly any[], E2, B>(self: Either<E1, A>, that: Either<E2, B>): Either<E1 | E2, [...A, B]>
<E2, B>(that: Either<E2, B>): <E1, A extends readonly any[]>(self: Either<E1, A>) => Either<E2 | E1, [...A, B]>
}
```
Added in v1.0.0
## bind
**Signature**
```ts
export declare const bind: {
<N extends string, A extends object, E2, B>(name: Exclude<N, keyof A>, f: (a: A) => Either<E2, B>): <E1>(
self: Either<E1, A>
) => Either<E2 | E1, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
<E1, A extends object, N extends string, E2, B>(
self: Either<E1, A>,
name: Exclude<N, keyof A>,
f: (a: A) => Either<E2, B>
): Either<E1 | E2, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
}
```
Added in v1.0.0
## bindTo
**Signature**
```ts
export declare const bindTo: {
<N extends string>(name: N): <E, A>(self: Either<E, A>) => Either<E, { [K in N]: A }>
<E, A, N extends string>(self: Either<E, A>, name: N): Either<E, { [K in N]: A }>
}
```
Added in v1.0.0
## let
**Signature**
```ts
export declare const let: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): <E>(
self: Either<E, A>
) => Either<E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
<E, A extends object, N extends string, B>(self: Either<E, A>, name: Exclude<N, keyof A>, f: (a: A) => B): Either<
E,
{ [K in N | keyof A]: K extends keyof A ? A[K] : B }
>
}
```
Added in v1.0.0
## tupled
**Signature**
```ts
export declare const tupled: <E, A>(self: Either<E, A>) => Either<E, [A]>
```
Added in v1.0.0
# equivalence
## getEquivalence
**Signature**
```ts
export declare const getEquivalence: <E, A>(EE: Equivalence<E>, EA: Equivalence<A>) => Equivalence<Either<E, A>>
```
Added in v1.0.0
# error handling
## firstRightOf
**Signature**
```ts
export declare const firstRightOf: {
<E, A>(collection: Iterable<Either<E, A>>): (self: Either<E, A>) => Either<E, A>
<E, A>(self: Either<E, A>, collection: Iterable<Either<E, A>>): Either<E, A>
}
```
Added in v1.0.0
## mapLeft
Maps the `Left` side of an `Either` value to a new `Either` value.
**Signature**
```ts
export declare const mapLeft: {
<E, G>(f: (e: E) => G): <A>(self: Either<E, A>) => Either<G, A>
<E, A, G>(self: Either<E, A>, f: (e: E) => G): Either<G, A>
}
```
Added in v1.0.0
## orElse
Executes this effect and returns its value, if it succeeds, but otherwise
executes the specified effect.
**Signature**
```ts
export declare const orElse: {
<E1, E2, B>(that: (e1: E1) => Either<E2, B>): <A>(self: Either<E1, A>) => Either<E2, B | A>
<E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, A | B>
}
```
Added in v1.0.0
## orElseEither
Returns an effect that will produce the value of this effect, unless it
fails, in which case, it will produce the value of the specified effect.
**Signature**
```ts
export declare const orElseEither: {
<E1, E2, B>(that: (e1: E1) => Either<E2, B>): <A>(self: Either<E1, A>) => Either<E2, Either<A, B>>
<E1, A, E2, B>(self: Either<E1, A>, that: (e1: E1) => Either<E2, B>): Either<E2, Either<A, B>>
}
```
Added in v1.0.0
## orElseFail
Executes this effect and returns its value, if it succeeds, but otherwise
fails with the specified error.
**Signature**
```ts
export declare const orElseFail: {
<E2>(onLeft: LazyArg<E2>): <E1, A>(self: Either<E1, A>) => Either<E2, A>
<E1, A, E2>(self: Either<E1, A>, onLeft: LazyArg<E2>): Either<E2, A>
}
```
Added in v1.0.0
## tapError
Returns an effect that effectfully "peeks" at the failure of this effect.
**Signature**
```ts
export declare const tapError: {
<E1, E2, _>(onLeft: (e: E1) => Either<E2, _>): <A>(self: Either<E1, A>) => Either<E1 | E2, A>
<E1, A, E2, _>(self: Either<E1, A>, onLeft: (e: E1) => Either<E2, _>): Either<E1 | E2, A>
}
```
Added in v1.0.0
# filtering
## compact
**Signature**
```ts
export declare const compact: {
<E2>(onNone: LazyArg<E2>): <E1, A>(self: Either<E1, Option<A>>) => Either<E2 | E1, A>
<E1, A, E2>(self: Either<E1, Option<A>>, onNone: LazyArg<E2>): Either<E1 | E2, A>
}
```
Added in v1.0.0
## filter
**Signature**
```ts
export declare const filter: {
<C extends A, B extends A, E2, A = C>(refinement: Refinement<A, B>, onFalse: LazyArg<E2>): <E1>(
self: Either<E1, C>
) => Either<E2 | E1, B>
<B extends A, E2, A = B>(predicate: Predicate<A>, onFalse: LazyArg<E2>): <E1>(
self: Either<E1, B>
) => Either<E2 | E1, B>
<E1, C extends A, B extends A, E2, A = C>(
self: Either<E1, C>,
refinement: Refinement<A, B>,
onFalse: LazyArg<E2>
): Either<E1 | E2, B>
<E1, B extends A, E2, A = B>(self: Either<E1, B>, predicate: Predicate<A>, onFalse: LazyArg<E2>): Either<E1 | E2, B>
}
```
Added in v1.0.0
## filterMap
**Signature**
```ts
export declare const filterMap: {
<A, B, E2>(f: (a: A) => Option<B>, onNone: LazyArg<E2>): <E1>(self: Either<E1, A>) => Either<E2 | E1, B>
<E1, A, B, E2>(self: Either<E1, A>, f: (a: A) => Option<B>, onNone: LazyArg<E2>): Either<E1 | E2, B>
}
```
Added in v1.0.0
# getters
## getOrElse
Returns the wrapped value if it's a `Right` or a default value if is a `Left`.
**Signature**
```ts
export declare const getOrElse: {
<E, B>(onLeft: (e: E) => B): <A>(self: Either<E, A>) => B | A
<E, A, B>(self: Either<E, A>, onLeft: (e: E) => B): A | B
}
```
**Example**
```ts
import * as E from '@fp-ts/core/Either'
import { pipe } from '@fp-ts/core/Function'
assert.deepStrictEqual(
E.getOrElse(E.right(1), () => 0),
1
)
assert.deepStrictEqual(
E.getOrElse(E.left('error'), () => 0),
0
)
```
Added in v1.0.0
## getOrNull
**Signature**
```ts
export declare const getOrNull: <E, A>(self: Either<E, A>) => A | null
```
Added in v1.0.0
## getOrUndefined
**Signature**
```ts
export declare const getOrUndefined: <E, A>(self: Either<E, A>) => A | undefined
```
Added in v1.0.0
## lefts
Return all the `Left` elements from an `Interable` of `Either`s.
**Signature**
```ts
export declare const lefts: <E, A>(self: Iterable<Either<E, A>>) => E[]
```
Added in v1.0.0
## rights
Return all the `Right` elements from an `Interable` of `Either`s.
**Signature**
```ts
export declare const rights: <E, A>(self: Iterable<Either<E, A>>) => A[]
```
Added in v1.0.0
# guards
## isEither
Tests if a value is a `Either`.
**Signature**
```ts
export declare const isEither: (input: unknown) => input is Either<unknown, unknown>
```
**Example**
```ts
import { isEither, left, right } from '@fp-ts/core/Either'
assert.deepStrictEqual(isEither(right(1)), true)
assert.deepStrictEqual(isEither(left('error')), true)
assert.deepStrictEqual(isEither({ right: 1 }), false)
```
Added in v1.0.0
## isLeft
Determine if a `Either` is a `Left`.
**Signature**
```ts
export declare const isLeft: <E, A>(self: Either<E, A>) => self is Left<E>
```
**Example**
```ts
import { isLeft, left, right } from '@fp-ts/core/Either'
assert.deepStrictEqual(isLeft(right(1)), false)
assert.deepStrictEqual(isLeft(left('error')), true)
```
Added in v1.0.0
## isRight
Determine if a `Either` is a `Right`.
**Signature**
```ts
export declare const isRight: <E, A>(self: Either<E, A>) => self is Right<A>
```
**Example**
```ts
import { isRight, left, right } from '@fp-ts/core/Either'
assert.deepStrictEqual(isRight(right(1)), true)
assert.deepStrictEqual(isRight(left('error')), false)
```
Added in v1.0.0
# instances
## Applicative
**Signature**
```ts
export declare const Applicative: applicative.Applicative<EitherTypeLambda>
```
Added in v1.0.0
## Bicovariant
**Signature**
```ts
export declare const Bicovariant: bicovariant.Bicovariant<EitherTypeLambda>
```
Added in v1.0.0
## Chainable
**Signature**
```ts
export declare const Chainable: chainable.Chainable<EitherTypeLambda>
```
Added in v1.0.0
## Covariant
**Signature**
```ts
export declare const Covariant: covariant.Covariant<EitherTypeLambda>
```
Added in v1.0.0
## FlatMap
**Signature**
```ts
export declare const FlatMap: flatMap_.FlatMap<EitherTypeLambda>
```
Added in v1.0.0
## Foldable
**Signature**
```ts
export declare const Foldable: foldable.Foldable<EitherTypeLambda>
```
Added in v1.0.0
## Invariant
**Signature**
```ts
export declare const Invariant: invariant.Invariant<EitherTypeLambda>
```
Added in v1.0.0
## Monad
**Signature**
```ts
export declare const Monad: monad.Monad<EitherTypeLambda>
```
Added in v1.0.0
## Of
**Signature**
```ts
export declare const Of: of_.Of<EitherTypeLambda>
```
Added in v1.0.0
## Pointed
**Signature**
```ts
export declare const Pointed: pointed.Pointed<EitherTypeLambda>
```
Added in v1.0.0
## Product
**Signature**
```ts
export declare const Product: product_.Product<EitherTypeLambda>
```
Added in v1.0.0
## SemiAlternative
**Signature**
```ts
export declare const SemiAlternative: semiAlternative.SemiAlternative<EitherTypeLambda>
```
Added in v1.0.0
## SemiApplicative
**Signature**
```ts
export declare const SemiApplicative: semiApplicative.SemiApplicative<EitherTypeLambda>
```
Added in v1.0.0
## SemiCoproduct
**Signature**
```ts
export declare const SemiCoproduct: semiCoproduct.SemiCoproduct<EitherTypeLambda>
```
Added in v1.0.0
## SemiProduct
**Signature**
```ts
export declare const SemiProduct: semiProduct.SemiProduct<EitherTypeLambda>
```
Added in v1.0.0
## Traversable
**Signature**
```ts
export declare const Traversable: traversable.Traversable<EitherTypeLambda>
```
Added in v1.0.0
## getOptionalSemigroup
Semigroup that models the combination of values that may be absent, elements that are `Left` are ignored
while elements that are `Right` are combined using the provided `Semigroup`.
**Signature**
```ts
export declare const getOptionalSemigroup: <E, A>(S: Semigroup<A>) => Semigroup<Either<E, A>>
```
Added in v1.0.0
# interop
## fromNullable
Takes a lazy default and a nullable value, if the value is not nully, turn it into a `Right`, if the value is nully use
the provided default as a `Left`.
**Signature**
```ts
export declare const fromNullable: {
<A, E>(onNullable: (a: A) => E): (a: A) => Either<E, NonNullable<A>>
<A, E>(a: A, onNullable: (a: A) => E): Either<E, NonNullable<A>>
}
```
**Example**
```ts
import * as E from '@fp-ts/core/Either'
const parse = E.fromNullable(() => 'nullable')
assert.deepStrictEqual(parse(1), E.right(1))
assert.deepStrictEqual(parse(null), E.left('nullable'))
```
Added in v1.0.0
## getOrThrow
Extracts the value of an `Either` or throws if the `Either` is `Left`.
The thrown error is a default error. To configure the error thrown, see {@link getOrThrowWith}.
**Signature**
```ts
export declare const getOrThrow: <E, A>(self: Either<E, A>) => A
```
**Example**
```ts
import * as E from '@fp-ts/core/Either'
assert.deepStrictEqual(E.getOrThrow(E.right(1)), 1)
assert.throws(() => E.getOrThrow(E.left('error')))
```
Added in v1.0.0
## getOrThrowWith
Extracts the value of an `Either` or throws if the `Either` is `Left`.
If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.
**Signature**
```ts
export declare const getOrThrowWith: {
<E>(onLeft: (e: E) => unknown): <A>(self: Either<E, A>) => A
<E, A>(self: Either<E, A>, onLeft: (e: E) => unknown): A
}
```
**Example**
```ts
import * as E from '@fp-ts/core/Either'
assert.deepStrictEqual(
E.getOrThrowWith(E.right(1), () => new Error('Unexpected Left')),
1
)
assert.throws(() => E.getOrThrowWith(E.left('error'), () => new Error('Unexpected Left')))
```
Added in v1.0.0
## liftNullable
**Signature**
```ts
export declare const liftNullable: <A extends readonly unknown[], B, E>(
f: (...a: A) => B | null | undefined,
onNullable: (...a: A) => E
) => (...a: A) => Either<E, NonNullable<B>>
```
Added in v1.0.0
## liftThrowable
Lifts a function that may throw to one returning a `Either`.
**Signature**
```ts
export declare const liftThrowable: <A extends readonly unknown[], B, E>(
f: (...a: A) => B,
onThrow: (error: unknown) => E
) => (...a: A) => Either<E, B>
```
Added in v1.0.0
## merge
**Signature**
```ts
export declare const merge: <E, A>(self: Either<E, A>) => E | A
```
Added in v1.0.0
# lifting
## lift2
Lifts a binary function into `Either`.
**Signature**
```ts
export declare const lift2: <A, B, C>(
f: (a: A, b: B) => C
) => {
<E1, E2>(self: Either<E1, A>, that: Either<E2, B>): Either<E1 | E2, C>
<E2>(that: Either<E2, B>): <E1>(self: Either<E1, A>) => Either<E2 | E1, C>
}
```
Added in v1.0.0
## liftOption
**Signature**
```ts
export declare const liftOption: <A extends readonly unknown[], B, E>(
f: (...a: A) => Option<B>,
onNone: (...a: A) => E
) => (...a: A) => Either<E, B>
```
Added in v1.0.0
## liftPredicate
**Signature**
```ts
export declare const liftPredicate: {
<C extends A, B extends A, E, A = C>(refinement: Refinement<A, B>, onFalse: (c: C) => E): (c: C) => Either<E, B>
<B extends A, E, A = B>(predicate: Predicate<A>, onFalse: (b: B) => E): (b: B) => Either<E, B>
}
```
**Example**
```ts
import { liftPredicate, left, right } from '@fp-ts/core/Either'
import { pipe } from '@fp-ts/core/Function'
assert.deepStrictEqual(
pipe(
1,
liftPredicate(
(n) => n > 0,
() => 'error'
)
),
right(1)
)
assert.deepStrictEqual(
pipe(
-1,
liftPredicate(
(n) => n > 0,
() => 'error'
)
),
left('error')
)
```
Added in v1.0.0
# mapping
## as
Maps the Right value of this effect to the specified constant value.
**Signature**
```ts
export declare const as: {
<E, _, B>(self: Either<E, _>, b: B): Either<E, B>
<B>(b: B): <E, _>(self: Either<E, _>) => Either<E, B>
}
```
Added in v1.0.0
## asUnit
Returns the effect Eithering from mapping the Right of this effect to unit.
**Signature**
```ts
export declare const asUnit: <E, _>(self: Either<E, _>) => Either<E, void>
```
Added in v1.0.0
## bimap
**Signature**
```ts
export declare const bimap: {
<E1, E2, A, B>(f: (e: E1) => E2, g: (a: A) => B): (self: Either<E1, A>) => Either<E2, B>
<E1, A, E2, B>(self: Either<E1, A>, f: (e: E1) => E2, g: (a: A) => B): Either<E2, B>
}
```
Added in v1.0.0
## flap
**Signature**
```ts
export declare const flap: {
<A, E, B>(a: A, self: Either<E, (a: A) => B>): Either<E, B>
<E, A, B>(self: Either<E, (a: A) => B>): (a: A) => Either<E, B>
}
```
Added in v1.0.0
## map
Maps the `Right` side of an `Either` value to a new `Either` value.
**Signature**
```ts
export declare const map: {
<A, B>(f: (a: A) => B): <E>(self: Either<E, A>) => Either<E, B>
<E, A, B>(self: Either<E, A>, f: (a: A) => B): Either<E, B>
}
```
Added in v1.0.0
# math
## divide
**Signature**
```ts
export declare const divide: {
<E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>
<E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>
}
```
Added in v1.0.0
## multiply
**Signature**
```ts
export declare const multiply: {
<E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>
<E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>
}
```
Added in v1.0.0
## subtract
**Signature**
```ts
export declare const subtract: {
<E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>
<E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>
}
```
Added in v1.0.0
## sum
**Signature**
```ts
export declare const sum: {
<E1, E2>(self: Either<E1, number>, that: Either<E2, number>): Either<E1 | E2, number>
<E2>(that: Either<E2, number>): <E1>(self: Either<E1, number>) => Either<E2 | E1, number>
}
```
Added in v1.0.0
# models
## Either (type alias)
**Signature**
```ts
export type Either<E, A> = Left<E> | Right<A>
```
Added in v1.0.0
## Left (interface)
**Signature**
```ts
export interface Left<E> {
readonly _tag: 'Left'
readonly left: E
}
```
Added in v1.0.0
## Right (interface)
**Signature**
```ts
export interface Right<A> {
readonly _tag: 'Right'
readonly right: A
}
```
Added in v1.0.0
# pattern matching
## match
Takes two functions and an `Either` value, if the value is a `Left` the inner value is applied to the first function,
if the value is a `Right` the inner value is applied to the second function.
**Signature**
```ts
export declare const match: {
<E, B, A, C = B>(onLeft: (e: E) => B, onRight: (a: A) => C): (self: Either<E, A>) => B | C
<E, A, B, C = B>(self: Either<E, A>, onLeft: (e: E) => B, onRight: (a: A) => C): B | C
}
```
**Example**
```ts
import * as E from '@fp-ts/core/Either'
import { pipe } from '@fp-ts/core/Function'
const onLeft = (errors: ReadonlyArray<string>): string => `Errors: ${errors.join(', ')}`
const onRight = (value: number): string => `Ok: ${value}`
assert.deepStrictEqual(pipe(E.right(1), E.match(onLeft, onRight)), 'Ok: 1')
assert.deepStrictEqual(pipe(E.left(['error 1', 'error 2']), E.match(onLeft, onRight)), 'Errors: error 1, error 2')
```
Added in v1.0.0
# traversing
## sequence
**Signature**
```ts
export declare const sequence: <F extends TypeLambda>(
F: applicative.Applicative<F>
) => <TE, R, O, E, A>(self: Either<TE, Kind<F, R, O, E, A>>) => Kind<F, R, O, E, Either<TE, A>>
```
Added in v1.0.0
## traverse
**Signature**
```ts
export declare const traverse: <F extends TypeLambda>(
F: applicative.Applicative<F>
) => {
<A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): <TE>(self: Either<TE, A>) => Kind<F, R, O, E, Either<TE, B>>
<TE, A, R, O, E, B>(self: Either<TE, A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Either<TE, B>>
}
```
Added in v1.0.0
## traverseTap
**Signature**
```ts
export declare const traverseTap: <F extends TypeLambda>(
F: applicative.Applicative<F>
) => {
<TE, A, R, O, E, B>(self: Either<TE, A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Either<TE, A>>
<A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): <TE>(self: Either<TE, A>) => Kind<F, R, O, E, Either<TE, A>>
}
```
Added in v1.0.0
# type lambdas
## EitherTypeLambda (interface)
**Signature**
```ts
export interface EitherTypeLambda extends TypeLambda {
readonly type: Either<this['Out1'], this['Target']>
}
```
Added in v1.0.0
# utils
## andThen
**Signature**
```ts
export declare const andThen: {
<E1, _, E2, B>(self: Either<E1, _>, that: Either<E2, B>): Either<E1 | E2, B>
<E2, B>(that: Either<E2, B>): <E1, _>(self: Either<E1, _>) => Either<E2 | E1, B>
}
```
Added in v1.0.0
## ap
**Signature**
```ts
export declare const ap: {
<E1, A, B, E2>(self: Either<E1, (a: A) => B>, that: Either<E2, A>): Either<E1 | E2, B>
<E2, A>(that: Either<E2, A>): <E1, B>(self: Either<E1, (a: A) => B>) => Either<E2 | E1, B>
}
```
Added in v1.0.0
## composeKleisliArrow
**Signature**
```ts
export declare const composeKleisliArrow: {
<A, E1, B, E2, C>(afb: (a: A) => Either<E1, B>, bfc: (b: B) => Either<E2, C>): (a: A) => Either<E1 | E2, C>
<B, E2, C>(bfc: (b: B) => Either<E2, C>): <A, E1>(afb: (a: A) => Either<E1, B>) => (a: A) => Either<E2 | E1, C>
}
```
Added in v1.0.0
## contains
Returns a function that checks if an `Either` contains a given value using a provided `equivalence` function.
**Signature**
```ts
export declare const contains: <A>(isEquivalent: (self: A, that: A) => boolean) => {
(a: A): <E>(self: Either<E, A>) => boolean
<E>(self: Either<E, A>, a: A): boolean
}
```
Added in v1.0.0
## exists
Returns `false` if `Left` or returns the Either of the application of the given predicate to the `Right` value.
**Signature**
```ts
export declare const exists: {
<A>(predicate: Predicate<A>): <E>(self: Either<E, A>) => boolean
<E, A>(self: Either<E, A>, predicate: Predicate<A>): boolean
}
```
**Example**
```ts
import * as E from '@fp-ts/core/Either'
const f = E.exists((n: number) => n > 2)
assert.deepStrictEqual(f(E.left('a')), false)
assert.deepStrictEqual(f(E.right(1)), false)
assert.deepStrictEqual(f(E.right(3)), true)
```
Added in v1.0.0
## flatten
**Signature**
```ts
export declare const flatten: <E1, E2, A>(self: Either<E1, Either<E2, A>>) => Either<E1 | E2, A>
```
Added in v1.0.0
## reverse
**Signature**
```ts
export declare const reverse: <E, A>(self: Either<E, A>) => Either<A, E>
```
Added in v1.0.0
## struct
**Signature**
```ts
export declare const struct: <R extends Record<string, Either<any, any>>>(
fields: R
) => Either<
[R[keyof R]] extends [Either<infer E, any>] ? E : never,
{ [K in keyof R]: [R[K]] extends [Either<any, infer A>] ? A : never }
>
```
Added in v1.0.0
## tuple
Similar to `Promise.all` but operates on `Either`s.
```
[Either<E1, A>, Either<E1, B>, ...] -> Either<E1 \| E2 \| ..., [A, B, ...]>
```
**Signature**
```ts
export declare const tuple: <T extends readonly Either<any, any>[]>(
...elements: T
) => Either<
[T[number]] extends [Either<infer E, any>] ? E : never,
{ [I in keyof T]: [T[I]] extends [Either<any, infer A>] ? A : never }
>
```
Added in v1.0.0
## unit
**Signature**
```ts
export declare const unit: Either<never, void>
```
Added in v1.0.0
================================================
FILE: docs/modules/Function.ts.md
================================================
---
title: Function.ts
nav_order: 4
parent: Modules
---
## Function overview
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [guards](#guards)
- [isFunction](#isfunction)
- [type lambdas](#type-lambdas)
- [FunctionTypeLambda (interface)](#functiontypelambda-interface)
- [utils](#utils)
- [FunctionN (interface)](#functionn-interface)
- [LazyArg (interface)](#lazyarg-interface)
- [SK](#sk)
- [absurd](#absurd)
- [apply](#apply)
- [compose](#compose)
- [constFalse](#constfalse)
- [constNull](#constnull)
- [constTrue](#consttrue)
- [constUndefined](#constundefined)
- [constVoid](#constvoid)
- [constant](#constant)
- [dual](#dual)
- [flip](#flip)
- [flow](#flow)
- [hole](#hole)
- [identity](#identity)
- [pipe](#pipe)
- [tupled](#tupled)
- [unsafeCoerce](#unsafecoerce)
- [untupled](#untupled)
---
# guards
## isFunction
Tests if a value is a `function`.
**Signature**
```ts
export declare const isFunction: (input: unknown) => input is Function
```
**Example**
```ts
import { isFunction } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isFunction(isFunction), true)
assert.deepStrictEqual(isFunction('function'), false)
```
Added in v1.0.0
# type lambdas
## FunctionTypeLambda (interface)
**Signature**
```ts
export interface FunctionTypeLambda extends TypeLambda {
readonly type: (a: this['In']) => this['Target']
}
```
Added in v1.0.0
# utils
## FunctionN (interface)
**Signature**
```ts
export interface FunctionN<A extends ReadonlyArray<unknown>, B> {
(...args: A): B
}
```
**Example**
```ts
import { FunctionN } from '@fp-ts/core/Function'
export const sum: FunctionN<[number, number], number> = (a, b) => a + b
```
Added in v1.0.0
## LazyArg (interface)
A lazy argument.
**Signature**
```ts
export interface LazyArg<A> {
(): A
}
```
**Example**
```ts
import { LazyArg, constant } from '@fp-ts/core/Function'
export const constNull: LazyArg<null> = constant(null)
```
Added in v1.0.0
## SK
The SK combinator, also known as the "S-K combinator" or "S-combinator", is a fundamental combinator in the
lambda calculus and the SKI combinator calculus.
This function is useful for discarding the first argument passed to it and returning the second argument.
**Signature**
```ts
export declare const SK: <A, B>(_: A, b: B) => B
```
**Example**
```ts
import { SK } from '@fp-ts/core/Function'
assert.deepStrictEqual(SK(0, 'hello'), 'hello')
```
Added in v1.0.0
## absurd
The `absurd` function is a stub for cases where a value of type `never` is encountered in your code,
meaning that it should be impossible for this code to be executed.
This function is particularly when it's necessary to specify that certain cases are impossible.
**Signature**
```ts
export declare const absurd: <A>(_: never) => A
```
Added in v1.0.0
## apply
Apply a function to a given value.
**Signature**
```ts
export declare const apply: <A>(a: A) => <B>(self: (a: A) => B) => B
```
**Example**
```ts
import { pipe, apply } from '@fp-ts/core/Function'
import { length } from '@fp-ts/core/String'
assert.deepStrictEqual(pipe(length, apply('hello')), 5)
```
Added in v1.0.0
## compose
Composes two functions, `ab` and `bc` into a single function that takes in an argument `a` of type `A` and returns a result of type `C`.
The result is obtained by first applying the `ab` function to `a` and then applying the `bc` function to the result of `ab`.
**Signature**
```ts
export declare const compose: {
<B, C>(bc: (b: B) => C): <A>(self: (a: A) => B) => (a: A) => C
<A, B, C>(self: (a: A) => B, bc: (b: B) => C): (a: A) => C
}
```
**Example**
```ts
import { compose } from '@fp-ts/core/Function'
const increment = (n: number) => n + 1
const square = (n: number) => n * n
assert.strictEqual(compose(increment, square)(2), 9)
```
Added in v1.0.0
## constFalse
A thunk that returns always `false`.
**Signature**
```ts
export declare const constFalse: LazyArg<boolean>
```
**Example**
```ts
import { constFalse } from '@fp-ts/core/Function'
assert.deepStrictEqual(constFalse(), false)
```
Added in v1.0.0
## constNull
A thunk that returns always `null`.
**Signature**
```ts
export declare const constNull: LazyArg<null>
```
**Example**
```ts
import { constNull } from '@fp-ts/core/Function'
assert.deepStrictEqual(constNull(), null)
```
Added in v1.0.0
## constTrue
A thunk that returns always `true`.
**Signature**
```ts
export declare const constTrue: LazyArg<boolean>
```
**Example**
```ts
import { constTrue } from '@fp-ts/core/Function'
assert.deepStrictEqual(constTrue(), true)
```
Added in v1.0.0
## constUndefined
A thunk that returns always `undefined`.
**Signature**
```ts
export declare const constUndefined: LazyArg<undefined>
```
**Example**
```ts
import { constUndefined } from '@fp-ts/core/Function'
assert.deepStrictEqual(constUndefined(), undefined)
```
Added in v1.0.0
## constVoid
A thunk that returns always `void`.
**Signature**
```ts
export declare const constVoid: LazyArg<void>
```
**Example**
```ts
import { constVoid } from '@fp-ts/core/Function'
assert.deepStrictEqual(constVoid(), undefined)
```
Added in v1.0.0
## constant
Creates a constant value that never changes.
This is useful when you want to pass a value to a higher-order function (a function that takes another function as its argument)
and want that inner function to always use the same value, no matter how many times it is called.
**Signature**
```ts
export declare const constant: <A>(value: A) => LazyArg<A>
```
**Example**
```ts
import { constant } from '@fp-ts/core/Function'
const constNull = constant(null)
assert.deepStrictEqual(constNull(), null)
assert.deepStrictEqual(constNull(), null)
```
Added in v1.0.0
## dual
Creates a function that can be used in a data-last (aka `pipe`able) or data-first style.
**Signature**
```ts
export declare const dual: <
DataLast extends (...args: Array<any>) => any,
DataFirst extends (...args: Array<any>) => any
>(
arity: Parameters<DataFirst>['length'],
body: DataFirst
) => DataLast & DataFirst
```
**Example**
```ts
import { dual, pipe } from '@fp-ts/core/Function'
export const sum: {
(that: number): (self: number) => number
(self: number, that: number): number
} = dual(2, (self: number, that: number): number => self + that)
assert.deepStrictEqual(sum(2, 3), 5)
assert.deepStrictEqual(pipe(2, sum(3)), 5)
```
Added in v1.0.0
## flip
Reverses the order of arguments for a curried function.
**Signature**
```ts
export declare const flip: <A extends unknown[], B extends unknown[], C>(
f: (...a: A) => (...b: B) => C
) => (...b: B) => (...a: A) => C
```
**Example**
```ts
import { flip } from '@fp-ts/core/Function'
const f = (a: number) => (b: string) => a - b.length
assert.deepStrictEqual(flip(f)('aaa')(2), -1)
```
Added in v1.0.0
## flow
Performs left-to-right function composition. The first argument may have any arity, the remaining arguments must be unary.
See also {@link pipe}.
**Signature**
```ts
export declare function flow<A extends ReadonlyArray<unknown>, B>(ab: (...a: A) => B): (...a: A) => B
export declare function flow<A extends ReadonlyArray<unknown>, B, C>(
ab: (...a: A) => B,
bc: (b: B) => C
): (...a: A) => C
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D>(
ab: (...a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D
): (...a: A) => D
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E>(
ab: (...a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E
): (...a: A) => E
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F>(
ab: (...a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F
): (...a: A) => F
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G>(
ab: (...a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G
): (...a: A) => G
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H>(
ab: (...a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H
): (...a: A) => H
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I>(
ab: (...a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I
): (...a: A) => I
export declare function flow<A extends ReadonlyArray<unknown>, B, C, D, E, F, G, H, I, J>(
ab: (...a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J
): (...a: A) => J
```
**Example**
```ts
import { flow } from '@fp-ts/core/Function'
const len = (s: string): number => s.length
const double = (n: number): number => n * 2
const f = flow(len, double)
assert.deepStrictEqual(f('aaa'), 6)
```
Added in v1.0.0
## hole
Type hole simulation.
**Signature**
```ts
export declare const hole: <T>() => T
```
Added in v1.0.0
## identity
The identity function, i.e. A function that returns its input argument.
**Signature**
```ts
export declare const identity: <A>(a: A) => A
```
**Example**
```ts
import { identity } from '@fp-ts/core/Function'
assert.deepStrictEqual(identity(5), 5)
```
Added in v1.0.0
## pipe
Pipes the value of an expression into a pipeline of functions.
This is useful in combination with data-last functions as a simulation of methods:
```
as.map(f).filter(g) -> pipe(as, map(f), filter(g))
```
See also {@link flow}.
**Signature**
```ts
export declare function pipe<A>(a: A): A
export declare function pipe<A, B>(a: A, ab: (a: A) => B): B
export declare function pipe<A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C
export declare function pipe<A, B, C, D>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D): D
export 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
export declare function pipe<A, B, C, D, E, F>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F
): F
export declare function pipe<A, B, C, D, E, F, G>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G
): G
export declare function pipe<A, B, C, D, E, F, G, H>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H
): H
export declare function pipe<A, B, C, D, E, F, G, H, I>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I
): I
export declare function pipe<A, B, C, D, E, F, G, H, I, J>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J
): J
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K
): K
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K,
kl: (k: K) => L
): L
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K,
kl: (k: K) => L,
lm: (l: L) => M
): M
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K,
kl: (k: K) => L,
lm: (l: L) => M,
mn: (m: M) => N
): N
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K,
kl: (k: K) => L,
lm: (l: L) => M,
mn: (m: M) => N,
no: (n: N) => O
): O
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K,
kl: (k: K) => L,
lm: (l: L) => M,
mn: (m: M) => N,
no: (n: N) => O,
op: (o: O) => P
): P
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K,
kl: (k: K) => L,
lm: (l: L) => M,
mn: (m: M) => N,
no: (n: N) => O,
op: (o: O) => P,
pq: (p: P) => Q
): Q
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K,
kl: (k: K) => L,
lm: (l: L) => M,
mn: (m: M) => N,
no: (n: N) => O,
op: (o: O) => P,
pq: (p: P) => Q,
qr: (q: Q) => R
): R
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K,
kl: (k: K) => L,
lm: (l: L) => M,
mn: (m: M) => N,
no: (n: N) => O,
op: (o: O) => P,
pq: (p: P) => Q,
qr: (q: Q) => R,
rs: (r: R) => S
): S
export declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(
a: A,
ab: (a: A) => B,
bc: (b: B) => C,
cd: (c: C) => D,
de: (d: D) => E,
ef: (e: E) => F,
fg: (f: F) => G,
gh: (g: G) => H,
hi: (h: H) => I,
ij: (i: I) => J,
jk: (j: J) => K,
kl: (k: K) => L,
lm: (l: L) => M,
mn: (m: M) => N,
no: (n: N) => O,
op: (o: O) => P,
pq: (p: P) => Q,
qr: (q: Q) => R,
rs: (r: R) => S,
st: (s: S) => T
): T
```
**Example**
```ts
import { pipe } from '@fp-ts/core/Function'
const length = (s: string): number => s.length
const double = (n: number): number => n * 2
const decrement = (n: number): number => n - 1
assert.deepStrictEqual(pipe(length('hello'), double, decrement), 9)
```
Added in v1.0.0
## tupled
Creates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument.
**Signature**
```ts
export declare const tupled: <A extends readonly unknown[], B>(f: (...a: A) => B) => (a: A) => B
```
**Example**
```ts
import { tupled } from '@fp-ts/core/Function'
const sumTupled = tupled((x: number, y: number): number => x + y)
assert.deepStrictEqual(sumTupled([1, 2]), 3)
```
Added in v1.0.0
## unsafeCoerce
Casts the result to the specified type.
**Signature**
```ts
export declare const unsafeCoerce: <A, B>(a: A) => B
```
**Example**
```ts
import { unsafeCoerce, identity } from '@fp-ts/core/Function'
assert.deepStrictEqual(unsafeCoerce, identity)
```
Added in v1.0.0
## untupled
Inverse function of `tupled`
**Signature**
```ts
export declare const untupled: <A extends readonly unknown[], B>(f: (a: A) => B) => (...a: A) => B
```
**Example**
```ts
import { untupled } from '@fp-ts/core/Function'
const getFirst = untupled(<A, B>(tuple: [A, B]): A => tuple[0])
assert.deepStrictEqual(getFirst(1, 2), 1)
```
Added in v1.0.0
================================================
FILE: docs/modules/HKT.ts.md
================================================
---
title: HKT.ts
nav_order: 5
parent: Modules
---
## HKT overview
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [utils](#utils)
- [Kind (type alias)](#kind-type-alias)
- [TypeClass (interface)](#typeclass-interface)
- [TypeLambda (interface)](#typelambda-interface)
---
# utils
## Kind (type alias)
**Signature**
```ts
export type Kind<F extends TypeLambda, In, Out2, Out1, Target> = F extends {
readonly type: unknown
}
? (F & {
readonly In: In
readonly Out2: Out2
readonly Out1: Out1
readonly Target: Target
})['type']
: {
readonly F: F
readonly In: (_: In) => void
readonly Out2: () => Out2
readonly Out1: () => Out1
readonly Target: (_: Target) => Target
}
```
Added in v1.0.0
## TypeClass (interface)
**Signature**
```ts
export interface TypeClass<F extends TypeLambda> {
readonly [URI]?: F
}
```
Added in v1.0.0
## TypeLambda (interface)
**Signature**
```ts
export interface TypeLambda {
readonly In: unknown
readonly Out2: unknown
readonly Out1: unknown
readonly Target: unknown
}
```
Added in v1.0.0
================================================
FILE: docs/modules/Identity.ts.md
================================================
---
title: Identity.ts
nav_order: 6
parent: Modules
---
## Identity overview
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [do notation](#do-notation)
- [Do](#do)
- [andThenBind](#andthenbind)
- [bind](#bind)
- [bindTo](#bindto)
- [let](#let)
- [instances](#instances)
- [Applicative](#applicative)
- [Chainable](#chainable)
- [Covariant](#covariant)
- [FlatMap](#flatmap)
- [Foldable](#foldable)
- [Invariant](#invariant)
- [Monad](#monad)
- [Of](#of)
- [Pointed](#pointed)
- [Product](#product)
- [SemiApplicative](#semiapplicative)
- [SemiProduct](#semiproduct)
- [Traversable](#traversable)
- [getSemiAlternative](#getsemialternative)
- [getSemiCoproduct](#getsemicoproduct)
- [models](#models)
- [Identity (type alias)](#identity-type-alias)
- [type lambdas](#type-lambdas)
- [IdentityTypeLambda (interface)](#identitytypelambda-interface)
- [IdentityTypeLambdaFix (interface)](#identitytypelambdafix-interface)
---
# do notation
## Do
**Signature**
```ts
export declare const Do: {}
```
Added in v1.0.0
## andThenBind
A variant of `bind` that sequentially ignores the scope.
**Signature**
```ts
export declare const andThenBind: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, that: B): (self: A) => {
[K in N | keyof A]: K extends keyof A ? A[K] : B
}
<A extends object, N extends string, B>(self: A, name: Exclude<N, keyof A>, that: B): {
[K in N | keyof A]: K extends keyof A ? A[K] : B
}
}
```
Added in v1.0.0
## bind
**Signature**
```ts
export declare const bind: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): (self: A) => {
[K in N | keyof A]: K extends keyof A ? A[K] : B
}
<A extends object, N extends string, B>(self: A, name: Exclude<N, keyof A>, f: (a: A) => B): {
[K in N | keyof A]: K extends keyof A ? A[K] : B
}
}
```
Added in v1.0.0
## bindTo
**Signature**
```ts
export declare const bindTo: {
<N extends string>(name: N): <A>(self: A) => { [K in N]: A }
<A, N extends string>(self: A, name: N): { [K in N]: A }
}
```
Added in v1.0.0
## let
**Signature**
```ts
export declare const let: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): (self: A) => {
[K in N | keyof A]: K extends keyof A ? A[K] : B
}
<A extends object, N extends string, B>(self: A, name: Exclude<N, keyof A>, f: (a: A) => B): {
[K in N | keyof A]: K extends keyof A ? A[K] : B
}
}
```
Added in v1.0.0
# instances
## Applicative
**Signature**
```ts
export declare const Applicative: applicative.Applicative<IdentityTypeLambda>
```
Added in v1.0.0
## Chainable
**Signature**
```ts
export declare const Chainable: chainable.Chainable<IdentityTypeLambda>
```
Added in v1.0.0
## Covariant
**Signature**
```ts
export declare const Covariant: covariant.Covariant<IdentityTypeLambda>
```
Added in v1.0.0
## FlatMap
**Signature**
```ts
export declare const FlatMap: flatMap_.FlatMap<IdentityTypeLambda>
```
Added in v1.0.0
## Foldable
**Signature**
```ts
export declare const Foldable: foldable.Foldable<IdentityTypeLambda>
```
Added in v1.0.0
## Invariant
**Signature**
```ts
export declare const Invariant: invariant.Invariant<IdentityTypeLambda>
```
Added in v1.0.0
## Monad
**Signature**
```ts
export declare const Monad: monad.Monad<IdentityTypeLambda>
```
Added in v1.0.0
## Of
**Signature**
```ts
export declare const Of: of_.Of<IdentityTypeLambda>
```
Added in v1.0.0
## Pointed
**Signature**
```ts
export declare const Pointed: pointed.Pointed<IdentityTypeLambda>
```
Added in v1.0.0
## Product
**Signature**
```ts
export declare const Product: product_.Product<IdentityTypeLambda>
```
Added in v1.0.0
## SemiApplicative
**Signature**
```ts
export declare const SemiApplicative: semiApplicative.SemiApplicative<IdentityTypeLambda>
```
Added in v1.0.0
## SemiProduct
**Signature**
```ts
export declare const SemiProduct: semiProduct.SemiProduct<IdentityTypeLambda>
```
Added in v1.0.0
## Traversable
**Signature**
```ts
export declare const Traversable: traversable.Traversable<IdentityTypeLambda>
```
Added in v1.0.0
## getSemiAlternative
**Signature**
```ts
export declare const getSemiAlternative: <A>(
S: Semigroup<A>
) => semiAlternative.SemiAlternative<IdentityTypeLambdaFix<A>>
```
Added in v1.0.0
## getSemiCoproduct
**Signature**
```ts
export declare const getSemiCoproduct: <A>(S: Semigroup<A>) => semiCoproduct.SemiCoproduct<IdentityTypeLambdaFix<A>>
```
Added in v1.0.0
# models
## Identity (type alias)
**Signature**
```ts
export type Identity<A> = A
```
Added in v1.0.0
# type lambdas
## IdentityTypeLambda (interface)
**Signature**
```ts
export interface IdentityTypeLambda extends TypeLambda {
readonly type: Identity<this['Target']>
}
```
Added in v1.0.0
## IdentityTypeLambdaFix (interface)
**Signature**
```ts
export interface IdentityTypeLambdaFix<A> extends TypeLambda {
readonly type: Identity<A>
}
```
Added in v1.0.0
================================================
FILE: docs/modules/Number.ts.md
================================================
---
title: Number.ts
nav_order: 8
parent: Modules
---
## Number overview
This module provides utility functions and type class instances for working with the `number` type in TypeScript.
It includes functions for basic arithmetic operations, as well as type class instances for
`Equivalence`, `Order`, `Semigroup`, and `Monoid`.
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [guards](#guards)
- [isNumber](#isnumber)
- [instances](#instances)
- [Bounded](#bounded)
- [Equivalence](#equivalence)
- [MonoidMax](#monoidmax)
- [MonoidMin](#monoidmin)
- [MonoidMultiply](#monoidmultiply)
- [MonoidSum](#monoidsum)
- [Order](#order)
- [SemigroupMax](#semigroupmax)
- [SemigroupMin](#semigroupmin)
- [SemigroupMultiply](#semigroupmultiply)
- [SemigroupSum](#semigroupsum)
- [math](#math)
- [decrement](#decrement)
- [divide](#divide)
- [increment](#increment)
- [multiply](#multiply)
- [multiplyAll](#multiplyall)
- [remainder](#remainder)
- [sign](#sign)
- [subtract](#subtract)
- [sum](#sum)
- [sumAll](#sumall)
- [predicates](#predicates)
- [between](#between)
- [greaterThan](#greaterthan)
- [greaterThanOrEqualTo](#greaterthanorequalto)
- [lessThan](#lessthan)
- [lessThanOrEqualTo](#lessthanorequalto)
- [utils](#utils)
- [clamp](#clamp)
- [max](#max)
- [min](#min)
---
# guards
## isNumber
Tests if a value is a `number`.
**Signature**
```ts
export declare const isNumber: (input: unknown) => input is number
```
**Example**
```ts
import { isNumber } from '@fp-ts/core/Number'
assert.deepStrictEqual(isNumber(2), true)
assert.deepStrictEqual(isNumber('2'), false)
```
Added in v1.0.0
# instances
## Bounded
**Signature**
```ts
export declare const Bounded: bounded.Bounded<number>
```
Added in v1.0.0
## Equivalence
**Signature**
```ts
export declare const Equivalence: equivalence.Equivalence<number>
```
Added in v1.0.0
## MonoidMax
A `Monoid` that uses the maximum between two values.
The `empty` value is `Infinity`.
**Signature**
```ts
export declare const MonoidMax: monoid.Monoid<number>
```
**Example**
```ts
import { MonoidMax } from '@fp-ts/core/Number'
assert.deepStrictEqual(MonoidMax.combine(2, 3), 3)
assert.deepStrictEqual(MonoidMax.combine(2, MonoidMax.empty), 2)
```
Added in v1.0.0
## MonoidMin
A `Monoid` that uses the minimum between two values.
The `empty` value is `-Infinity`.
**Signature**
```ts
export declare const MonoidMin: monoid.Monoid<number>
```
**Example**
```ts
import { MonoidMin } from '@fp-ts/core/Number'
assert.deepStrictEqual(MonoidMin.combine(2, 3), 2)
assert.deepStrictEqual(MonoidMin.combine(2, MonoidMin.empty), 2)
```
Added in v1.0.0
## MonoidMultiply
`number` monoid under multiplication.
The `empty` value is `1`.
**Signature**
```ts
export declare const MonoidMultiply: monoid.Monoid<number>
```
**Example**
```ts
import { MonoidMultiply } from '@fp-ts/core/Number'
assert.deepStrictEqual(MonoidMultiply.combine(2, 3), 6)
assert.deepStrictEqual(MonoidMultiply.combine(2, MonoidMultiply.empty), 2)
```
Added in v1.0.0
## MonoidSum
`number` monoid under addition.
The `empty` value is `0`.
**Signature**
```ts
export declare const MonoidSum: monoid.Monoid<number>
```
**Example**
```ts
import { MonoidSum } from '@fp-ts/core/Number'
assert.deepStrictEqual(MonoidSum.combine(2, 3), 5)
assert.deepStrictEqual(MonoidSum.combine(2, MonoidSum.empty), 2)
```
Added in v1.0.0
## Order
**Signature**
```ts
export declare const Order: order.Order<number>
```
Added in v1.0.0
## SemigroupMax
A `Semigroup` that uses the maximum between two values.
**Signature**
```ts
export declare const SemigroupMax: semigroup.Semigroup<number>
```
**Example**
```ts
import { SemigroupMax } from '@fp-ts/core/Number'
assert.deepStrictEqual(SemigroupMax.combine(2, 3), 3)
```
Added in v1.0.0
## SemigroupMin
A `Semigroup` that uses the minimum between two values.
**Signature**
```ts
export declare const SemigroupMin: semigroup.Semigroup<number>
```
**Example**
```ts
import { SemigroupMin } from '@fp-ts/core/Number'
assert.deepStrictEqual(SemigroupMin.combine(2, 3), 2)
```
Added in v1.0.0
## SemigroupMultiply
`number` semigroup under multiplication.
**Signature**
```ts
export declare const SemigroupMultiply: semigroup.Semigroup<number>
```
**Example**
```ts
import { SemigroupMultiply } from '@fp-ts/core/Number'
assert.deepStrictEqual(SemigroupMultiply.combine(2, 3), 6)
```
Added in v1.0.0
## SemigroupSum
`number` semigroup under addition.
**Signature**
```ts
export declare const SemigroupSum: semigroup.Semigroup<number>
```
**Example**
```ts
import { SemigroupSum } from '@fp-ts/core/Number'
assert.deepStrictEqual(SemigroupSum.combine(2, 3), 5)
```
Added in v1.0.0
# math
## decrement
Decrements a number by `1`.
**Signature**
```ts
export declare const decrement: (n: number) => number
```
**Example**
```ts
import { decrement } from '@fp-ts/core/Number'
assert.deepStrictEqual(decrement(3), 2)
```
Added in v1.0.0
## divide
Provides a division operation on `number`s.
**Signature**
```ts
export declare const divide: { (that: number): (self: number) => number; (self: number, that: number): number }
```
**Example**
```ts
import { divide } from '@fp-ts/core/Number'
assert.deepStrictEqual(divide(6, 3), 2)
```
Added in v1.0.0
## increment
Returns the result of adding `1` to a given number.
**Signature**
```ts
export declare const increment: (n: number) => number
```
**Example**
```ts
import { increment } from '@fp-ts/core/Number'
assert.deepStrictEqual(increment(2), 3)
```
Added in v1.0.0
## multiply
Provides a multiplication operation on `number`s.
**Signature**
```ts
export declare const multiply: { (that: number): (self: number) => number; (self: number, that: number): number }
```
**Example**
```ts
import { multiply } from '@fp-ts/core/Number'
assert.deepStrictEqual(multiply(2, 3), 6)
```
Added in v1.0.0
## multiplyAll
Takes an `Iterable` of `number`s and returns their multiplication as a single `number`.
**Signature**
```ts
export declare const multiplyAll: (collection: Iterable<number>) => number
```
**Example**
```ts
import { multiplyAll } from '@fp-ts/core/Number'
assert.deepStrictEqual(multiplyAll([2, 3, 4]), 24)
```
Added in v1.0.0
## remainder
Returns the remainder left over when one operand is divided by a second operand.
It always takes the sign of the dividend.
**Signature**
```ts
export declare const remainder: { (divisor: number): (self: number) => number; (self: number, divisor: number): number }
```
**Example**
```ts
import { remainder } from '@fp-ts/core/Number'
assert.deepStrictEqual(remainder(2, 2), 0)
assert.deepStrictEqual(remainder(3, 2), 1)
assert.deepStrictEqual(remainder(-4, 2), -0)
```
Added in v1.0.0
## sign
Determines the sign of a given `number`.
**Signature**
```ts
export declare const sign: (n: number) => Ordering
```
**Example**
```ts
import { sign } from '@fp-ts/core/Number'
assert.deepStrictEqual(sign(-5), -1)
assert.deepStrictEqual(sign(0), 0)
assert.deepStrictEqual(sign(5), 1)
```
Added in v1.0.0
## subtract
Provides a subtraction operation on `number`s.
**Signature**
```ts
export declare const subtract: { (that: number): (self: number) => number; (self: number, that: number): number }
```
**Example**
```ts
import { subtract } from '@fp-ts/core/Number'
assert.deepStrictEqual(subtract(2, 3), -1)
```
Added in v1.0.0
## sum
Provides an addition operation on `number`s.
**Signature**
```ts
export declare const sum: { (that: number): (self: number) => number; (self: number, that: number): number }
```
**Example**
```ts
import { sum } from '@fp-ts/core/Number'
assert.deepStrictEqual(sum(2, 3), 5)
```
Added in v1.0.0
## sumAll
Takes an `Iterable` of `number`s and returns their sum as a single `number`.
**Signature**
```ts
export declare const sumAll: (collection: Iterable<number>) => number
```
**Example**
```ts
import { sumAll } from '@fp-ts/core/Number'
assert.deepStrictEqual(sumAll([2, 3, 4]), 9)
```
Added in v1.0.0
# predicates
## between
Checks if a `number` is between a `minimum` and `maximum` value (inclusive).
**Signature**
```ts
export declare const between: {
(minimum: number, maximum: number): (self: number) => boolean
(self: number, minimum: number, maximum: number): boolean
}
```
**Example**
```ts
import { between } from '@fp-ts/core/Number'
assert.deepStrictEqual(between(0, 5)(3), true)
assert.deepStrictEqual(between(0, 5)(-1), false)
assert.deepStrictEqual(between(0, 5)(6), false)
```
Added in v1.0.0
## greaterThan
Returns `true` if the first argument is greater than the second, otherwise `false`.
**Signature**
```ts
export declare const greaterThan: { (that: number): (self: number) => boolean; (self: number, that: number): boolean }
```
**Example**
```ts
import { greaterThan } from '@fp-ts/core/Number'
assert.deepStrictEqual(greaterThan(2, 3), false)
assert.deepStrictEqual(greaterThan(3, 3), false)
assert.deepStrictEqual(greaterThan(4, 3), true)
```
Added in v1.0.0
## greaterThanOrEqualTo
Returns a function that checks if a given `number` is greater than or equal to the provided one.
**Signature**
```ts
export declare const greaterThanOrEqualTo: {
(that: number): (self: number) => boolean
(self: number, that: number): boolean
}
```
**Example**
```ts
import { greaterThanOrEqualTo } from '@fp-ts/core/Number'
assert.deepStrictEqual(greaterThanOrEqualTo(2, 3), false)
assert.deepStrictEqual(greaterThanOrEqualTo(3, 3), true)
assert.deepStrictEqual(greaterThanOrEqualTo(4, 3), true)
```
Added in v1.0.0
## lessThan
Returns `true` if the first argument is less than the second, otherwise `false`.
**Signature**
```ts
export declare const lessThan: { (that: number): (self: number) => boolean; (self: number, that: number): boolean }
```
**Example**
```ts
import { lessThan } from '@fp-ts/core/Number'
assert.deepStrictEqual(lessThan(2, 3), true)
assert.deepStrictEqual(lessThan(3, 3), false)
assert.deepStrictEqual(lessThan(4, 3), false)
```
Added in v1.0.0
## lessThanOrEqualTo
Returns a function that checks if a given `number` is less than or equal to the provided one.
**Signature**
```ts
export declare const lessThanOrEqualTo: {
(that: number): (self: number) => boolean
(self: number, that: number): boolean
}
```
**Example**
```ts
import { lessThanOrEqualTo } from '@fp-ts/core/Number'
assert.deepStrictEqual(lessThanOrEqualTo(2, 3), true)
assert.deepStrictEqual(lessThanOrEqualTo(3, 3), true)
assert.deepStrictEqual(lessThanOrEqualTo(4, 3), false)
```
Added in v1.0.0
# utils
## clamp
Restricts the given `number` to be within the range specified by the `minimum` and `maximum` values.
- If the `number` is less than the `minimum` value, the function returns the `minimum` value.
- If the `number` is greater than the `maximum` value, the function returns the `maximum` value.
- Otherwise, it returns the original `number`.
**Signature**
```ts
export declare const clamp: {
(minimum: number, maximum: number): (self: number) => number
(self: number, minimum: number, maximum: number): number
}
```
**Example**
```ts
import { clamp } from '@fp-ts/core/Number'
assert.deepStrictEqual(clamp(0, 5)(3), 3)
assert.deepStrictEqual(clamp(0, 5)(-1), 0)
assert.deepStrictEqual(clamp(0, 5)(6), 5)
```
Added in v1.0.0
## max
Returns the maximum between two `number`s.
**Signature**
```ts
export declare const max: { (that: number): (self: number) => number; (self: number, that: number): number }
```
**Example**
```ts
import { max } from '@fp-ts/core/Number'
assert.deepStrictEqual(max(2, 3), 3)
```
Added in v1.0.0
## min
Returns the minimum between two `number`s.
**Signature**
```ts
export declare const min: { (that: number): (self: number) => number; (self: number, that: number): number }
```
**Example**
```ts
import { min } from '@fp-ts/core/Number'
assert.deepStrictEqual(min(2, 3), 2)
```
Added in v1.0.0
================================================
FILE: docs/modules/Option.ts.md
================================================
---
title: Option.ts
nav_order: 9
parent: Modules
---
## Option overview
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [combining](#combining)
- [all](#all)
- [ap](#ap)
- [getFailureMonoid](#getfailuremonoid)
- [getFailureSemigroup](#getfailuresemigroup)
- [getFirstSomeSemigroup](#getfirstsomesemigroup)
- [sequence](#sequence)
- [struct](#struct)
- [traverse](#traverse)
- [traverseTap](#traversetap)
- [tuple](#tuple)
- [zipWith](#zipwith)
- [constructors](#constructors)
- [none](#none)
- [of](#of)
- [some](#some)
- [conversions](#conversions)
- [fromEither](#fromeither)
- [fromIterable](#fromiterable)
- [fromNullable](#fromnullable)
- [getLeft](#getleft)
- [getOrThrow](#getorthrow)
- [getOrThrowWith](#getorthrowwith)
- [getRight](#getright)
- [liftNullable](#liftnullable)
- [liftThrowable](#liftthrowable)
- [toArray](#toarray)
- [toEither](#toeither)
- [toRefinement](#torefinement)
- [debugging](#debugging)
- [inspectNone](#inspectnone)
- [inspectSome](#inspectsome)
- [do notation](#do-notation)
- [Do](#do)
- [andThenBind](#andthenbind)
- [appendElement](#appendelement)
- [bind](#bind)
- [bindTo](#bindto)
- [let](#let)
- [tupled](#tupled)
- [equivalence](#equivalence)
- [getEquivalence](#getequivalence)
- [error handling](#error-handling)
- [firstSomeOf](#firstsomeof)
- [orElse](#orelse)
- [orElseEither](#orelseeither)
- [filtering](#filtering)
- [filter](#filter)
- [filterMap](#filtermap)
- [partitionMap](#partitionmap)
- [folding](#folding)
- [reduceCompact](#reducecompact)
- [getters](#getters)
- [getOrElse](#getorelse)
- [getOrNull](#getornull)
- [getOrUndefined](#getorundefined)
- [guards](#guards)
- [isNone](#isnone)
- [isOption](#isoption)
- [isSome](#issome)
- [lifting](#lifting)
- [lift2](#lift2)
- [liftEither](#lifteither)
- [liftPredicate](#liftpredicate)
- [math](#math)
- [divide](#divide)
- [multiply](#multiply)
- [multiplyCompact](#multiplycompact)
- [subtract](#subtract)
- [sum](#sum)
- [sumCompact](#sumcompact)
- [models](#models)
- [None (interface)](#none-interface)
- [Option (type alias)](#option-type-alias)
- [Some (interface)](#some-interface)
- [pattern matching](#pattern-matching)
- [match](#match)
- [sorting](#sorting)
- [getOrder](#getorder)
- [transforming](#transforming)
- [andThen](#andthen)
- [andThenDiscard](#andthendiscard)
- [as](#as)
- [asUnit](#asunit)
- [composeKleisliArrow](#composekleisliarrow)
- [flap](#flap)
- [flatMap](#flatmap)
- [flatMapEither](#flatmapeither)
- [flatMapNullable](#flatmapnullable)
- [flatten](#flatten)
- [map](#map)
- [tap](#tap)
- [type lambdas](#type-lambdas)
- [OptionTypeLambda (interface)](#optiontypelambda-interface)
- [utils](#utils)
- [Alternative](#alternative)
- [Applicative](#applicative)
- [Chainable](#chainable)
- [Coproduct](#coproduct)
- [Covariant](#covariant)
- [Filterable](#filterable)
- [FlatMap](#flatmap)
- [Foldable](#foldable)
- [Invariant](#invariant)
- [Monad](#monad)
- [Of](#of)
- [Pointed](#pointed)
- [Product](#product)
- [SemiAlternative](#semialternative)
- [SemiApplicative](#semiapplicative)
- [SemiCoproduct](#semicoproduct)
- [SemiProduct](#semiproduct)
- [Traversable](#traversable)
- [contains](#contains)
- [exists](#exists)
- [getOptionalMonoid](#getoptionalmonoid)
- [unit](#unit)
---
# combining
## all
Similar to `Promise.all` but operates on `Option`s.
```
Iterable<Option<A>> -> Option<A[]>
```
Flattens a collection of `Option`s into a single `Option` that contains a list of all the `Some` values.
If there is a `None` value in the collection, it returns `None` as the result.
**Signature**
```ts
export declare const all: <A>(collection: Iterable<Option<A>>) => Option<A[]>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.all([O.some(1), O.some(2), O.some(3)]), O.some([1, 2, 3]))
assert.deepStrictEqual(O.all([O.some(1), O.none(), O.some(3)]), O.none())
```
Added in v1.0.0
## ap
**Signature**
```ts
export declare const ap: {
<A, B>(self: Option<(a: A) => B>, that: Option<A>): Option<B>
<A>(that: Option<A>): <B>(self: Option<(a: A) => B>) => Option<B>
}
```
Added in v1.0.0
## getFailureMonoid
Monoid that models the combination of computations that can fail, if at least one element is `None`
then the resulting combination is `None`, otherwise if all elements are `Some` then the resulting combination
is the combination of the wrapped elements using the provided `Monoid`.
The `empty` value is `some(M.empty)`.
See also `getFailureSemigroup` if you need a `Semigroup` instead of a `Monoid`.
**Signature**
```ts
export declare const getFailureMonoid: <A>(M: Monoid<A>) => Monoid<Option<A>>
```
Added in v1.0.0
## getFailureSemigroup
Semigroup that models the combination of computations that can fail, if at least one element is `None`
then the resulting combination is `None`, otherwise if all elements are `Some` then the resulting combination
is the combination of the wrapped elements using the provided `Semigroup`.
See also `getFailureMonoid` if you need a `Monoid` instead of a `Semigroup`.
**Signature**
```ts
export declare const getFailureSemigroup: <A>(S: Semigroup<A>) => Semigroup<Option<A>>
```
Added in v1.0.0
## getFirstSomeSemigroup
Semigroup returning the first `Some` value encountered.
**Signature**
```ts
export declare const getFirstSomeSemigroup: <A>() => Semigroup<Option<A>>
```
Added in v1.0.0
## sequence
Combines an `Option` of an `F`-structure to an `F`-structure of an `Option` with the same inner type.
**Signature**
```ts
export declare const sequence: <F extends TypeLambda>(
F: applicative.Applicative<F>
) => <R, O, E, A>(self: Option<Kind<F, R, O, E, A>>) => Kind<F, R, O, E, Option<A>>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
const sequence = O.sequence(E.Applicative)
assert.deepStrictEqual(sequence(O.some(E.right(1))), E.right(O.some(1)))
assert.deepStrictEqual(sequence(O.some(E.left('error'))), E.left('error'))
assert.deepStrictEqual(sequence(O.none()), E.right(O.none()))
```
Added in v1.0.0
## struct
Takes a struct of `Option`s and returns an `Option` of a struct of values.
**Signature**
```ts
export declare const struct: <R extends Record<string, Option<any>>>(
fields: R
) => Option<{ [K in keyof R]: [R[K]] extends [Option<infer A>] ? A : never }>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.struct({ a: O.some(1), b: O.some('hello') }), O.some({ a: 1, b: 'hello' }))
assert.deepStrictEqual(O.struct({ a: O.some(1), b: O.none() }), O.none())
```
Added in v1.0.0
## traverse
Applies an `Option` value to an effectful function that returns an `F` value.
**Signature**
```ts
export declare const traverse: <F extends TypeLambda>(
F: applicative.Applicative<F>
) => {
<A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): (self: Option<A>) => Kind<F, R, O, E, Option<B>>
<A, R, O, E, B>(self: Option<A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Option<B>>
}
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
const traverse = O.traverse(E.Applicative)
const f = (n: number) => (n >= 0 ? E.right(1) : E.left('negative'))
assert.deepStrictEqual(traverse(O.some(1), f), E.right(O.some(1)))
assert.deepStrictEqual(traverse(O.some(-1), f), E.left('negative'))
assert.deepStrictEqual(traverse(O.none(), f), E.right(O.none()))
```
Added in v1.0.0
## traverseTap
**Signature**
```ts
export declare const traverseTap: <F extends TypeLambda>(
F: applicative.Applicative<F>
) => {
<A, R, O, E, B>(self: Option<A>, f: (a: A) => Kind<F, R, O, E, B>): Kind<F, R, O, E, Option<A>>
<A, R, O, E, B>(f: (a: A) => Kind<F, R, O, E, B>): (self: Option<A>) => Kind<F, R, O, E, Option<A>>
}
```
Added in v1.0.0
## tuple
Similar to `Promise.all` but operates on `Option`s.
```
[Option<A>, Option<B>, ...] -> Option<[A, B, ...]>
```
Takes a tuple of `Option`s and returns an `Option` of a tuple of values.
**Signature**
```ts
export declare const tuple: <T extends readonly Option<any>[]>(
...elements: T
) => Option<{ [I in keyof T]: [T[I]] extends [Option<infer A>] ? A : never }>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.tuple(O.some(1), O.some('hello')), O.some([1, 'hello']))
assert.deepStrictEqual(O.tuple(O.some(1), O.none()), O.none())
```
Added in v1.0.0
## zipWith
Zips two `Option` values together using a provided function, returning a new `Option` of the result.
**Signature**
```ts
export declare const zipWith: {
<A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>
<B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>
}
```
Added in v1.0.0
# constructors
## none
Creates a new `Option` that represents the absence of a value.
**Signature**
```ts
export declare const none: <A = never>() => Option<A>
```
Added in v1.0.0
## of
Alias of {@link some}.
**Signature**
```ts
export declare const of: <A>(value: A) => Option<A>
```
Added in v1.0.0
## some
Creates a new `Option` that wraps the given value.
**Signature**
```ts
export declare const some: <A>(value: A) => Option<A>
```
Added in v1.0.0
# conversions
## fromEither
Converts a `Either` to an `Option` discarding the error.
**Signature**
```ts
export declare const fromEither: <E, A>(self: Either<E, A>) => Option<A>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
assert.deepStrictEqual(O.fromEither(E.right(1)), O.some(1))
assert.deepStrictEqual(O.fromEither(E.left('error message')), O.none())
```
Added in v1.0.0
## fromIterable
Converts an `Iterable` of values into an `Option`. Returns the first value of the `Iterable` wrapped in a `Some`
if the `Iterable` is not empty, otherwise returns `None`.
**Signature**
```ts
export declare const fromIterable: <A>(collection: Iterable<A>) => Option<A>
```
**Example**
```ts
import { fromIterable, some, none } from '@fp-ts/core/Option'
assert.deepStrictEqual(fromIterable([1, 2, 3]), some(1))
assert.deepStrictEqual(fromIterable([]), none())
```
Added in v1.0.0
## fromNullable
Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise
returns the value wrapped in a `Some`.
**Signature**
```ts
export declare const fromNullable: <A>(nullableValue: A) => Option<NonNullable<A>>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.fromNullable(undefined), O.none())
assert.deepStrictEqual(O.fromNullable(null), O.none())
assert.deepStrictEqual(O.fromNullable(1), O.some(1))
```
Added in v1.0.0
## getLeft
Converts a `Either` to an `Option` discarding the value.
**Signature**
```ts
export declare const getLeft: <E, A>(self: Either<E, A>) => Option<E>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
assert.deepStrictEqual(O.getLeft(E.right('ok')), O.none())
assert.deepStrictEqual(O.getLeft(E.left('error')), O.some('error'))
```
Added in v1.0.0
## getOrThrow
Extracts the value of an `Option` or throws if the `Option` is `None`.
The thrown error is a default error. To configure the error thrown, see {@link getOrThrowWith}.
**Signature**
```ts
export declare const getOrThrow: <A>(self: Option<A>) => A
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.getOrThrow(O.some(1)), 1)
assert.throws(() => O.getOrThrow(O.none()))
```
Added in v1.0.0
## getOrThrowWith
Extracts the value of an `Option` or throws if the `Option` is `None`.
If a default error is sufficient for your use case and you don't need to configure the thrown error, see {@link getOrThrow}.
**Signature**
```ts
export declare const getOrThrowWith: {
(onNone: () => unknown): <A>(self: Option<A>) => A
<A>(self: Option<A>, onNone: () => unknown): A
}
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(
O.getOrThrowWith(O.some(1), () => new Error('Unexpected None')),
1
)
assert.throws(() => O.getOrThrowWith(O.none(), () => new Error('Unexpected None')))
```
Added in v1.0.0
## getRight
Converts a `Either` to an `Option` discarding the error.
Alias of {@link fromEither}.
**Signature**
```ts
export declare const getRight: <E, A>(self: Either<E, A>) => Option<A>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
assert.deepStrictEqual(O.getRight(E.right('ok')), O.some('ok'))
assert.deepStrictEqual(O.getRight(E.left('err')), O.none())
```
Added in v1.0.0
## liftNullable
This API is useful for lifting a function that returns `null` or `undefined` into the `Option` context.
**Signature**
```ts
export declare const liftNullable: <A extends readonly unknown[], B>(
f: (...a: A) => B | null | undefined
) => (...a: A) => Option<NonNullable<B>>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
const parse = (s: string): number | undefined => {
const n = parseFloat(s)
return isNaN(n) ? undefined : n
}
const parseOption = O.liftNullable(parse)
assert.deepStrictEqual(parseOption('1'), O.some(1))
assert.deepStrictEqual(parseOption('not a number'), O.none())
```
Added in v1.0.0
## liftThrowable
A utility function that lifts a function that throws exceptions into a function that returns an `Option`.
This function is useful for any function that might throw an exception, allowing the developer to handle
the exception in a more functional way.
**Signature**
```ts
export declare const liftThrowable: <A extends readonly unknown[], B>(f: (...a: A) => B) => (...a: A) => Option<B>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
const parse = O.liftThrowable(JSON.parse)
assert.deepStrictEqual(parse('1'), O.some(1))
assert.deepStrictEqual(parse(''), O.none())
```
Added in v1.0.0
## toArray
Transforms an `Option` into an `Array`.
If the input is `None`, an empty array is returned.
If the input is `Some`, the value is wrapped in an array.
**Signature**
```ts
export declare const toArray: <A>(self: Option<A>) => A[]
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.toArray(O.some(1)), [1])
assert.deepStrictEqual(O.toArray(O.none()), [])
```
Added in v1.0.0
## toEither
Converts an `Option` to an `Either`, allowing you to provide a value to be used in the case of a `None`.
**Signature**
```ts
export declare const toEither: {
<A, E>(self: Option<A>, onNone: () => E): Either<E, A>
<E>(onNone: () => E): <A>(self: Option<A>) => Either<E, A>
}
```
**Example**
```ts
import { pipe } from '@fp-ts/core/Function'
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
const onNone = () => 'error'
assert.deepStrictEqual(pipe(O.some(1), O.toEither(onNone)), E.right(1))
assert.deepStrictEqual(pipe(O.none(), O.toEither(onNone)), E.left('error'))
```
Added in v1.0.0
## toRefinement
Returns a type guard from a `Option` returning function.
This function ensures that a type guard definition is type-safe.
**Signature**
```ts
export declare const toRefinement: <A, B extends A>(f: (a: A) => Option<B>) => (a: A) => a is B
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
const parsePositive = (n: number): O.Option<number> => (n > 0 ? O.some(n) : O.none())
const isPositive = O.toRefinement(parsePositive)
assert.deepStrictEqual(isPositive(1), true)
assert.deepStrictEqual(isPositive(-1), false)
```
Added in v1.0.0
# debugging
## inspectNone
Useful for debugging purposes, the `onNone` callback is is called if `self` is a `None`.
**Signature**
```ts
export declare const inspectNone: {
(onNone: () => void): <A>(self: Option<A>) => Option<A>
<A>(self: Option<A>, onNone: () => void): Option<A>
}
```
Added in v1.0.0
## inspectSome
Useful for debugging purposes, the `onSome` callback is called with the value of `self` if it is a `Some`.
**Signature**
```ts
export declare const inspectSome: {
<A>(onSome: (a: A) => void): (self: Option<A>) => Option<A>
<A>(self: Option<A>, onSome: (a: A) => void): Option<A>
}
```
Added in v1.0.0
# do notation
## Do
**Signature**
```ts
export declare const Do: Option<{}>
```
Added in v1.0.0
## andThenBind
A variant of `bind` that sequentially ignores the scope.
**Signature**
```ts
export declare const andThenBind: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, that: Option<B>): (
self: Option<A>
) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>
<A extends object, N extends string, B>(self: Option<A>, name: Exclude<N, keyof A>, that: Option<B>): Option<{
[K in N | keyof A]: K extends keyof A ? A[K] : B
}>
}
```
Added in v1.0.0
## appendElement
Appends an element to the end of a tuple wrapped in an `Option` type.
**Signature**
```ts
export declare const appendElement: {
<A extends readonly any[], B>(self: Option<A>, that: Option<B>): Option<[...A, B]>
<B>(that: Option<B>): <A extends readonly any[]>(self: Option<A>) => Option<[...A, B]>
}
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.appendElement(O.some([1, 2]), O.some(3)), O.some([1, 2, 3]))
assert.deepStrictEqual(O.appendElement(O.some([1, 2]), O.none()), O.none())
```
Added in v1.0.0
## bind
**Signature**
```ts
export declare const bind: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => Option<B>): (
self: Option<A>
) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>
<A extends object, N extends string, B>(self: Option<A>, name: Exclude<N, keyof A>, f: (a: A) => Option<B>): Option<{
[K in N | keyof A]: K extends keyof A ? A[K] : B
}>
}
```
Added in v1.0.0
## bindTo
**Signature**
```ts
export declare const bindTo: {
<N extends string>(name: N): <A>(self: Option<A>) => Option<{ [K in N]: A }>
<A, N extends string>(self: Option<A>, name: N): Option<{ [K in N]: A }>
}
```
Added in v1.0.0
## let
**Signature**
```ts
export declare const let: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): (
self: Option<A>
) => Option<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>
<A extends object, N extends string, B>(self: Option<A>, name: Exclude<N, keyof A>, f: (a: A) => B): Option<{
[K in N | keyof A]: K extends keyof A ? A[K] : B
}>
}
```
Added in v1.0.0
## tupled
**Signature**
```ts
export declare const tupled: <A>(self: Option<A>) => Option<[A]>
```
Added in v1.0.0
# equivalence
## getEquivalence
**Signature**
```ts
export declare const getEquivalence: <A>(E: Equivalence<A>) => Equivalence<Option<A>>
```
**Example**
```ts
import { none, some, getEquivalence } from '@fp-ts/core/Option'
import * as N from '@fp-ts/core/Number'
const isEquivalent = getEquivalence(N.Equivalence)
assert.deepStrictEqual(isEquivalent(none(), none()), true)
assert.deepStrictEqual(isEquivalent(none(), some(1)), false)
assert.deepStrictEqual(isEquivalent(some(1), none()), false)
assert.deepStrictEqual(isEquivalent(some(1), some(2)), false)
assert.deepStrictEqual(isEquivalent(some(1), some(1)), true)
```
Added in v1.0.0
# error handling
## firstSomeOf
Given an `Iterable` collection of `Option`s, returns the first `Some` found in the collection.
**Signature**
```ts
export declare const firstSomeOf: <A>(collection: Iterable<Option<A>>) => Option<A>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.firstSomeOf([O.none(), O.some(1), O.some(2)]), O.some(1))
```
Added in v1.0.0
## orElse
Returns the provided `Option` `that` if `self` is `None`, otherwise returns `self`.
**Signature**
```ts
export declare const orElse: {
<B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<B | A>
<A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<A | B>
}
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import { pipe } from '@fp-ts/core/Function'
assert.deepStrictEqual(
pipe(
O.none(),
O.orElse(() => O.none())
),
O.none()
)
assert.deepStrictEqual(
pipe(
O.some('a'),
O.orElse(() => O.none())
),
O.some('a')
)
assert.deepStrictEqual(
pipe(
O.none(),
O.orElse(() => O.some('b'))
),
O.some('b')
)
assert.deepStrictEqual(
pipe(
O.some('a'),
O.orElse(() => O.some('b'))
),
O.some('a')
)
```
Added in v1.0.0
## orElseEither
Similar to `orElse`, but instead of returning a simple union, it returns an `Either` object,
which contains information about which of the two `Option`s has been chosen.
This is useful when it's important to know whether the value was retrieved from the first `Option` or the second option.
**Signature**
```ts
export declare const orElseEither: {
<B>(that: LazyArg<Option<B>>): <A>(self: Option<A>) => Option<Either<A, B>>
<A, B>(self: Option<A>, that: LazyArg<Option<B>>): Option<Either<A, B>>
}
```
Added in v1.0.0
# filtering
## filter
Filters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`.
If you need to change the type of the `Option` in addition to filtering, see `filterMap`.
**Signature**
```ts
export declare const filter: {
<C extends A, B extends A, A = C>(self: Option<C>, refinement: (a: A) => a is B): Option<B>
<B extends A, A = B>(self: Option<B>, predicate: (a: A) => boolean): Option<B>
<C extends A, B extends A, A = C>(refinement: (a: A) => a is B): (self: Option<C>) => Option<B>
<B extends A, A = B>(predicate: (a: A) => boolean): (self: Option<B>) => Option<B>
}
```
Added in v1.0.0
## filterMap
Maps over the value of an `Option` and filters out `None`s.
Useful when in addition to filtering you also want to change the type of the `Option`.
**Signature**
```ts
export declare const filterMap: {
<A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>
<A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>
}
```
Added in v1.0.0
## partitionMap
**Signature**
```ts
export declare const partitionMap: {
<A, B, C>(f: (a: A) => Either<B, C>): (self: Option<A>) => [Option<B>, Option<C>]
<A, B, C>(self: Option<A>, f: (a: A) => Either<B, C>): [Option<B>, Option<C>]
}
```
Added in v1.0.0
# folding
## reduceCompact
Reduces an `Iterable` of `Option<A>` to a single value of type `B`, elements that are `None` are ignored.
**Signature**
```ts
export declare const reduceCompact: {
<B, A>(b: B, f: (b: B, a: A) => B): (self: Iterable<Option<A>>) => B
<A, B>(self: Iterable<Option<A>>, b: B, f: (b: B, a: A) => B): B
}
```
**Example**
```ts
import { some, none, reduceCompact } from '@fp-ts/core/Option'
import { pipe } from '@fp-ts/core/Function'
const iterable = [some(1), none(), some(2), none()]
assert.deepStrictEqual(
pipe(
iterable,
reduceCompact(0, (b, a) => b + a)
),
3
)
```
Added in v1.0.0
# getters
## getOrElse
Returns the value of the `Option` if it is `Some`, otherwise returns `onNone`
**Signature**
```ts
export declare const getOrElse: {
<B>(onNone: LazyArg<B>): <A>(self: Option<A>) => B | A
<A, B>(self: Option<A>, onNone: LazyArg<B>): A | B
}
```
**Example**
```ts
import { some, none, getOrElse } from '@fp-ts/core/Option'
import { pipe } from '@fp-ts/core/Function'
assert.deepStrictEqual(
pipe(
some(1),
getOrElse(() => 0)
),
1
)
assert.deepStrictEqual(
pipe(
none(),
getOrElse(() => 0)
),
0
)
```
Added in v1.0.0
## getOrNull
Returns the value of the `Option` if it is a `Some`, otherwise returns `null`.
**Signature**
```ts
export declare const getOrNull: <A>(self: Option<A>) => A | null
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.getOrNull(O.some(1)), 1)
assert.deepStrictEqual(O.getOrNull(O.none()), null)
```
Added in v1.0.0
## getOrUndefined
Returns the value of the `Option` if it is a `Some`, otherwise returns `undefined`.
**Signature**
```ts
export declare const getOrUndefined: <A>(self: Option<A>) => A | undefined
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
assert.deepStrictEqual(O.getOrUndefined(O.some(1)), 1)
assert.deepStrictEqual(O.getOrUndefined(O.none()), undefined)
```
Added in v1.0.0
# guards
## isNone
Determine if a `Option` is a `None`.
**Signature**
```ts
export declare const isNone: <A>(self: Option<A>) => self is None
```
**Example**
```ts
import { some, none, isNone } from '@fp-ts/core/Option'
assert.deepStrictEqual(isNone(some(1)), false)
assert.deepStrictEqual(isNone(none()), true)
```
Added in v1.0.0
## isOption
Tests if a value is a `Option`.
**Signature**
```ts
export declare const isOption: (input: unknown) => input is Option<unknown>
```
**Example**
```ts
import { some, none, isOption } from '@fp-ts/core/Option'
assert.deepStrictEqual(isOption(some(1)), true)
assert.deepStrictEqual(isOption(none()), true)
assert.deepStrictEqual(isOption({}), false)
```
Added in v1.0.0
## isSome
Determine if a `Option` is a `Some`.
**Signature**
```ts
export declare const isSome: <A>(self: Option<A>) => self is Some<A>
```
**Example**
```ts
import { some, none, isSome } from '@fp-ts/core/Option'
assert.deepStrictEqual(isSome(some(1)), true)
assert.deepStrictEqual(isSome(none()), false)
```
Added in v1.0.0
# lifting
## lift2
Lifts a binary function into `Option`.
**Signature**
```ts
export declare const lift2: <A, B, C>(
f: (a: A, b: B) => C
) => { (self: Option<A>, that: Option<B>): Option<C>; (that: Option<B>): (self: Option<A>) => Option<C> }
```
Added in v1.0.0
## liftEither
Lifts an `Either` function to an `Option` function.
**Signature**
```ts
export declare const liftEither: <A extends readonly unknown[], E, B>(
f: (...a: A) => Either<E, B>
) => (...a: A) => Option<B>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
const parse = (s: string) => (isNaN(+s) ? E.left(`Error: ${s} is not a number`) : E.right(+s))
const parseNumber = O.liftEither(parse)
assert.deepEqual(parseNumber('12'), O.some(12))
assert.deepEqual(parseNumber('not a number'), O.none())
```
Added in v1.0.0
## liftPredicate
Transforms a `Predicate` function into a `Some` of the input value if the predicate returns `true` or `None`
if the predicate returns `false`.
**Signature**
```ts
export declare const liftPredicate: {
<C extends A, B extends A, A = C>(refinement: Refinement<A, B>): (c: C) => Option<B>
<B extends A, A = B>(predicate: Predicate<A>): (b: B) => Option<B>
}
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
const getOption = O.liftPredicate((n: number) => n >= 0)
assert.deepStrictEqual(getOption(-1), O.none())
assert.deepStrictEqual(getOption(1), O.some(1))
```
Added in v1.0.0
# math
## divide
**Signature**
```ts
export declare const divide: {
(self: Option<number>, that: Option<number>): Option<number>
(that: Option<number>): (self: Option<number>) => Option<number>
}
```
Added in v1.0.0
## multiply
**Signature**
```ts
export declare const multiply: {
(self: Option<number>, that: Option<number>): Option<number>
(that: Option<number>): (self: Option<number>) => Option<number>
}
```
Added in v1.0.0
## multiplyCompact
Multiply all numbers in an iterable of `Option<number>` ignoring the `None` values.
**Signature**
```ts
export declare const multiplyCompact: (self: Iterable<Option<number>>) => number
```
**Example**
```ts
import { multiplyCompact, some, none } from '@fp-ts/core/Option'
const iterable = [some(2), none(), some(3), none()]
assert.deepStrictEqual(multiplyCompact(iterable), 6)
```
Added in v1.0.0
## subtract
**Signature**
```ts
export declare const subtract: {
(self: Option<number>, that: Option<number>): Option<number>
(that: Option<number>): (self: Option<number>) => Option<number>
}
```
Added in v1.0.0
## sum
**Signature**
```ts
export declare const sum: {
(self: Option<number>, that: Option<number>): Option<number>
(that: Option<number>): (self: Option<number>) => Option<number>
}
```
Added in v1.0.0
## sumCompact
Sum all numbers in an iterable of `Option<number>` ignoring the `None` values.
**Signature**
```ts
export declare const sumCompact: (self: Iterable<Option<number>>) => number
```
**Example**
```ts
import { sumCompact, some, none } from '@fp-ts/core/Option'
const iterable = [some(2), none(), some(3), none()]
assert.deepStrictEqual(sumCompact(iterable), 5)
```
Added in v1.0.0
# models
## None (interface)
**Signature**
```ts
export interface None {
readonly _tag: 'None'
}
```
Added in v1.0.0
## Option (type alias)
**Signature**
```ts
export type Option<A> = None | Some<A>
```
Added in v1.0.0
## Some (interface)
**Signature**
```ts
export interface Some<A> {
readonly _tag: 'Some'
readonly value: A
}
```
Added in v1.0.0
# pattern matching
## match
Matches the given `Option` and returns either the provided `onNone` value or the result of the provided `onSome`
function when passed the `Option`'s value.
**Signature**
```ts
export declare const match: {
<B, A, C = B>(onNone: LazyArg<B>, onSome: (a: A) => C): (self: Option<A>) => B | C
<A, B, C = B>(self: Option<A>, onNone: LazyArg<B>, onSome: (a: A) => C): B | C
}
```
**Example**
```ts
import { some, none, match } from '@fp-ts/core/Option'
import { pipe } from '@fp-ts/core/Function'
assert.deepStrictEqual(
pipe(
some(1),
match(
() => 'a none',
(a) => `a some containing ${a}`
)
),
'a some containing 1'
)
assert.deepStrictEqual(
pipe(
none(),
match(
() => 'a none',
(a) => `a some containing ${a}`
)
),
'a none'
)
```
Added in v1.0.0
# sorting
## getOrder
The `Order` instance allows `Option` values to be compared with
`compare`, whenever there is an `Order` instance for
the type the `Option` contains.
`None` is considered to be less than any `Some` value.
**Signature**
```ts
export declare const getOrder: <A>(O: Order<A>) => Order<Option<A>>
```
**Example**
```ts
import { none, some, getOrder } from '@fp-ts/core/Option'
import * as N from '@fp-ts/core/Number'
import { pipe } from '@fp-ts/core/Function'
const O = getOrder(N.Order)
assert.deepStrictEqual(O.compare(none(), none()), 0)
assert.deepStrictEqual(O.compare(none(), some(1)), -1)
assert.deepStrictEqual(O.compare(some(1), none()), 1)
assert.deepStrictEqual(O.compare(some(1), some(2)), -1)
assert.deepStrictEqual(O.compare(some(1), some(1)), 0)
```
Added in v1.0.0
# transforming
## andThen
**Signature**
```ts
export declare const andThen: {
<_, B>(self: Option<_>, that: Option<B>): Option<B>
<B>(that: Option<B>): <_>(self: Option<_>) => Option<B>
}
```
Added in v1.0.0
## andThenDiscard
Sequences the specified `that` `Option` but ignores its value.
It is useful when we want to chain multiple operations, but only care about the result of `self`.
**Signature**
```ts
export declare const andThenDiscard: {
<A, _>(self: Option<A>, that: Option<_>): Option<A>
<_>(that: Option<_>): <A>(self: Option<A>) => Option<A>
}
```
Added in v1.0.0
## as
Maps the `Some` value of this `Option` to the specified constant value.
**Signature**
```ts
export declare const as: { <_, B>(self: Option<_>, b: B): Option<B>; <B>(b: B): <_>(self: Option<_>) => Option<B> }
```
Added in v1.0.0
## asUnit
Returns the `Option` resulting from mapping the `Some` value to `void`.
This is useful when the value of the `Option` is not needed, but the presence or absence of the value is important.
**Signature**
```ts
export declare const asUnit: <_>(self: Option<_>) => Option<void>
```
Added in v1.0.0
## composeKleisliArrow
**Signature**
```ts
export declare const composeKleisliArrow: {
<A, B, C>(afb: (a: A) => Option<B>, bfc: (b: B) => Option<C>): (a: A) => Option<C>
<B, C>(bfc: (b: B) => Option<C>): <A>(afb: (a: A) => Option<B>) => (a: A) => Option<C>
}
```
Added in v1.0.0
## flap
**Signature**
```ts
export declare const flap: {
<A, B>(a: A, self: Option<(a: A) => B>): Option<B>
<A, B>(self: Option<(a: A) => B>): (a: A) => Option<B>
}
```
Added in v1.0.0
## flatMap
Applies a function to the value of an `Option` and flattens the result, if the input is `Some`.
**Signature**
```ts
export declare const flatMap: {
<A, B>(f: (a: A) => Option<B>): (self: Option<A>) => Option<B>
<A, B>(self: Option<A>, f: (a: A) => Option<B>): Option<B>
}
```
Added in v1.0.0
## flatMapEither
Applies a provided function that returns an `Either` to the contents of an `Option`, flattening the result into another `Option`.
**Signature**
```ts
export declare const flatMapEither: {
<A, E, B>(f: (a: A) => Either<E, B>): (self: Option<A>) => Option<B>
<A, E, B>(self: Option<A>, f: (a: A) => Either<E, B>): Option<B>
}
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as E from '@fp-ts/core/Either'
import { pipe } from '@fp-ts/core/Function'
const f = (n: number) => (n > 2 ? E.left('Too big') : E.right(n + 1))
assert.deepStrictEqual(pipe(O.some(1), O.flatMapEither(f)), O.some(2))
assert.deepStrictEqual(pipe(O.some(3), O.flatMapEither(f)), O.none())
```
Added in v1.0.0
## flatMapNullable
This is `flatMap` + `fromNullable`, useful when working with optional values.
**Signature**
```ts
export declare const flatMapNullable: {
<A, B>(f: (a: A) => B | null | undefined): (self: Option<A>) => Option<NonNullable<B>>
<A, B>(self: Option<A>, f: (a: A) => B | null | undefined): Option<NonNullable<B>>
}
```
**Example**
```ts
import { some, none, flatMapNullable } from '@fp-ts/core/Option'
import { pipe } from '@fp-ts/core/Function'
interface Employee {
company?: {
address?: {
street?: {
name?: string
}
}
}
}
const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }
assert.deepStrictEqual(
pipe(
some(employee1),
flatMapNullable((employee) => employee.company?.address?.street?.name)
),
some('high street')
)
const employee2: Employee = { company: { address: { street: {} } } }
assert.deepStrictEqual(
pipe(
some(employee2),
flatMapNullable((employee) => employee.company?.address?.street?.name)
),
none()
)
```
Added in v1.0.0
## flatten
**Signature**
```ts
export declare const flatten: <A>(self: Option<Option<A>>) => Option<A>
```
Added in v1.0.0
## map
Maps the `Some` side of an `Option` value to a new `Option` value.
**Signature**
```ts
export declare const map: {
<A, B>(f: (a: A) => B): (self: Option<A>) => Option<B>
<A, B>(self: Option<A>, f: (a: A) => B): Option<B>
}
```
Added in v1.0.0
## tap
Applies the provided function `f` to the value of the `Option` if it is `Some` and returns the original `Option`
unless `f` returns `None`, in which case it returns `None`.
This function is useful for performing additional computations on the value of the input `Option` without affecting its value.
**Signature**
```ts
export declare const tap: {
<A, _>(self: Option<A>, f: (a: A) => Option<_>): Option<A>
<A, _>(f: (a: A) => Option<_>): (self: Option<A>) => Option<A>
}
```
Added in v1.0.0
# type lambdas
## OptionTypeLambda (interface)
**Signature**
```ts
export interface OptionTypeLambda extends TypeLambda {
readonly type: Option<this['Target']>
}
```
Added in v1.0.0
# utils
## Alternative
**Signature**
```ts
export declare const Alternative: alternative.Alternative<OptionTypeLambda>
```
Added in v1.0.0
## Applicative
**Signature**
```ts
export declare const Applicative: applicative.Applicative<OptionTypeLambda>
```
Added in v1.0.0
## Chainable
**Signature**
```ts
export declare const Chainable: chainable.Chainable<OptionTypeLambda>
```
Added in v1.0.0
## Coproduct
**Signature**
```ts
export declare const Coproduct: coproduct_.Coproduct<OptionTypeLambda>
```
Added in v1.0.0
## Covariant
**Signature**
```ts
export declare const Covariant: covariant.Covariant<OptionTypeLambda>
```
Added in v1.0.0
## Filterable
**Signature**
```ts
export declare const Filterable: filterable.Filterable<OptionTypeLambda>
```
Added in v1.0.0
## FlatMap
**Signature**
```ts
export declare const FlatMap: flatMap_.FlatMap<OptionTypeLambda>
```
Added in v1.0.0
## Foldable
**Signature**
```ts
export declare const Foldable: foldable.Foldable<OptionTypeLambda>
```
Added in v1.0.0
## Invariant
**Signature**
```ts
export declare const Invariant: invariant.Invariant<OptionTypeLambda>
```
Added in v1.0.0
## Monad
**Signature**
```ts
export declare const Monad: monad.Monad<OptionTypeLambda>
```
Added in v1.0.0
## Of
**Signature**
```ts
export declare const Of: of_.Of<OptionTypeLambda>
```
Added in v1.0.0
## Pointed
**Signature**
```ts
export declare const Pointed: pointed.Pointed<OptionTypeLambda>
```
Added in v1.0.0
## Product
**Signature**
```ts
export declare const Product: product_.Product<OptionTypeLambda>
```
Added in v1.0.0
## SemiAlternative
**Signature**
```ts
export declare const SemiAlternative: semiAlternative.SemiAlternative<OptionTypeLambda>
```
Added in v1.0.0
## SemiApplicative
**Signature**
```ts
export declare const SemiApplicative: semiApplicative.SemiApplicative<OptionTypeLambda>
```
Added in v1.0.0
## SemiCoproduct
**Signature**
```ts
export declare const SemiCoproduct: semiCoproduct.SemiCoproduct<OptionTypeLambda>
```
Added in v1.0.0
## SemiProduct
**Signature**
```ts
export declare const SemiProduct: semiProduct.SemiProduct<OptionTypeLambda>
```
Added in v1.0.0
## Traversable
**Signature**
```ts
export declare const Traversable: traversable.Traversable<OptionTypeLambda>
```
Added in v1.0.0
## contains
Returns a function that checks if an `Option` contains a given value using a provided `Equivalence` instance.
**Signature**
```ts
export declare const contains: <A>(isEquivalent: (self: A, that: A) => boolean) => {
(a: A): (self: Option<A>) => boolean
(self: Option<A>, a: A): boolean
}
```
**Example**
```ts
import { some, none, contains } from '@fp-ts/core/Option'
import { Equivalence } from '@fp-ts/core/Number'
import { pipe } from '@fp-ts/core/Function'
assert.deepStrictEqual(pipe(some(2), contains(Equivalence)(2)), true)
assert.deepStrictEqual(pipe(some(1), contains(Equivalence)(2)), false)
assert.deepStrictEqual(pipe(none(), contains(Equivalence)(2)), false)
```
Added in v1.0.0
## exists
Check if a value in an `Option` type meets a certain predicate.
**Signature**
```ts
export declare const exists: {
<A>(predicate: Predicate<A>): (self: Option<A>) => boolean
<A>(self: Option<A>, predicate: Predicate<A>): boolean
}
```
**Example**
```ts
import { some, none, exists } from '@fp-ts/core/Option'
import { pipe } from '@fp-ts/core/Function'
const isEven = (n: number) => n % 2 === 0
assert.deepStrictEqual(pipe(some(2), exists(isEven)), true)
assert.deepStrictEqual(pipe(some(1), exists(isEven)), false)
assert.deepStrictEqual(pipe(none(), exists(isEven)), false)
```
Added in v1.0.0
## getOptionalMonoid
Monoid that models the combination of values that may be absent, elements that are `None` are ignored
while elements that are `Some` are combined using the provided `Semigroup`.
The `empty` value is `none()`.
**Signature**
```ts
export declare const getOptionalMonoid: <A>(Semigroup: Semigroup<A>) => Monoid<Option<A>>
```
**Example**
```ts
import * as O from '@fp-ts/core/Option'
import * as N from '@fp-ts/core/Number'
import { pipe } from '@fp-ts/core/Function'
const M = O.getOptionalMonoid(N.SemigroupSum)
assert.deepStrictEqual(M.combine(O.none(), O.none()), O.none())
assert.deepStrictEqual(M.combine(O.some(1), O.none()), O.some(1))
assert.deepStrictEqual(M.combine(O.none(), O.some(1)), O.some(1))
assert.deepStrictEqual(M.combine(O.some(1), O.some(2)), O.some(3))
```
Added in v1.0.0
## unit
**Signature**
```ts
export declare const unit: Option<void>
```
Added in v1.0.0
================================================
FILE: docs/modules/Ordering.ts.md
================================================
---
title: Ordering.ts
nav_order: 10
parent: Modules
---
## Ordering overview
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [instances](#instances)
- [Monoid](#monoid)
- [Semigroup](#semigroup)
- [model](#model)
- [Ordering (type alias)](#ordering-type-alias)
- [pattern matching](#pattern-matching)
- [match](#match)
- [utils](#utils)
- [reverse](#reverse)
---
# instances
## Monoid
`Monoid` instance for `Ordering`, returns the left-most non-zero `Ordering`.
The `empty` value is `0`.
**Signature**
```ts
export declare const Monoid: monoid.Monoid<0 | 1 | -1>
```
**Example**
```ts
import { Monoid } from '@fp-ts/core/Ordering'
assert.deepStrictEqual(Monoid.combine(Monoid.empty, -1), -1)
assert.deepStrictEqual(Monoid.combine(Monoid.empty, 1), 1)
assert.deepStrictEqual(Monoid.combine(1, -1), 1)
```
Added in v1.0.0
## Semigroup
`Semigroup` instance for `Ordering`, returns the left-most non-zero `Ordering`.
**Signature**
```ts
export declare const Semigroup: semigroup.Semigroup<0 | 1 | -1>
```
**Example**
```ts
import { Semigroup } from '@fp-ts/core/Ordering'
assert.deepStrictEqual(Semigroup.combine(0, -1), -1)
assert.deepStrictEqual(Semigroup.combine(0, 1), 1)
assert.deepStrictEqual(Semigroup.combine(1, -1), 1)
```
Added in v1.0.0
# model
## Ordering (type alias)
**Signature**
```ts
export type Ordering = -1 | 0 | 1
```
Added in v1.0.0
# pattern matching
## match
Depending on the `Ordering` parameter given to it, returns a value produced by one of the 3 functions provided as parameters.
**Signature**
```ts
export declare const match: {
<A, B, C = B>(onLessThan: LazyArg<A>, onEqual: LazyArg<B>, onGreaterThan: LazyArg<C>): (self: Ordering) => A | B | C
<A, B, C = B>(o: Ordering, onLessThan: LazyArg<A>, onEqual: LazyArg<B>, onGreaterThan: LazyArg<C>): A | B | C
}
```
**Example**
```ts
import { match } from '@fp-ts/core/Ordering'
import { constant } from '@fp-ts/core/Function'
const toMessage = match(constant('less than'), constant('equal'), constant('greater than'))
assert.deepStrictEqual(toMessage(-1), 'less than')
assert.deepStrictEqual(toMessage(0), 'equal')
assert.deepStrictEqual(toMessage(1), 'greater than')
```
Added in v1.0.0
# utils
## reverse
Inverts the ordering of the input `Ordering`.
**Signature**
```ts
export declare const reverse: (o: Ordering) => Ordering
```
**Example**
```ts
import { reverse } from '@fp-ts/core/Ordering'
assert.deepStrictEqual(reverse(1), -1)
assert.deepStrictEqual(reverse(-1), 1)
assert.deepStrictEqual(reverse(0), 0)
```
Added in v1.0.0
================================================
FILE: docs/modules/Predicate.ts.md
================================================
---
title: Predicate.ts
nav_order: 11
parent: Modules
---
## Predicate overview
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [combinators](#combinators)
- [and](#and)
- [not](#not)
- [or](#or)
- [constructors](#constructors)
- [contramap](#contramap)
- [do notation](#do-notation)
- [Do](#do)
- [andThenBind](#andthenbind)
- [bindTo](#bindto)
- [guards](#guards)
- [isBigint](#isbigint)
- [isBoolean](#isboolean)
- [isDate](#isdate)
- [isError](#iserror)
- [isFunction](#isfunction)
- [isNever](#isnever)
- [isNotNull](#isnotnull)
- [isNotNullable](#isnotnullable)
- [isNotUndefined](#isnotundefined)
- [isNull](#isnull)
- [isNullable](#isnullable)
- [isNumber](#isnumber)
- [isObject](#isobject)
- [isReadonlyRecord](#isreadonlyrecord)
- [isRecord](#isrecord)
- [isString](#isstring)
- [isSymbol](#issymbol)
- [isUndefined](#isundefined)
- [isUnknown](#isunknown)
- [instances](#instances)
- [Contravariant](#contravariant)
- [Invariant](#invariant)
- [Of](#of)
- [Product](#product)
- [SemiProduct](#semiproduct)
- [getMonoidAll](#getmonoidall)
- [getMonoidAny](#getmonoidany)
- [getSemigroupAll](#getsemigroupall)
- [getSemigroupAny](#getsemigroupany)
- [models](#models)
- [Predicate (interface)](#predicate-interface)
- [Refinement (interface)](#refinement-interface)
- [type lambdas](#type-lambdas)
- [PredicateTypeLambda (interface)](#predicatetypelambda-interface)
- [utils](#utils)
- [all](#all)
- [any](#any)
- [appendElement](#appendelement)
- [compose](#compose)
- [of](#of)
- [struct](#struct)
- [tuple](#tuple)
- [tupled](#tupled)
- [unit](#unit)
---
# combinators
## and
Combines two predicates into a new predicate that returns `true` if both of the predicates returns `true`.
**Signature**
```ts
export declare const and: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>
}
```
**Example**
```ts
import * as P from '@fp-ts/core/Predicate'
const minLength = (n: number) => (s: string) => s.length >= n
const maxLength = (n: number) => (s: string) => s.length <= n
const length = (n: number) => P.and(minLength(n), maxLength(n))
assert.deepStrictEqual(length(2)('aa'), true)
assert.deepStrictEqual(length(2)('a'), false)
assert.deepStrictEqual(length(2)('aaa'), false)
```
Added in v1.0.0
## not
Negates the result of a given predicate.
**Signature**
```ts
export declare const not: <A>(self: Predicate<A>) => Predicate<A>
```
**Example**
```ts
import * as P from '@fp-ts/core/Predicate'
import * as N from '@fp-ts/core/Number'
const isPositive = P.not(N.lessThan(0))
assert.deepStrictEqual(isPositive(-1), false)
assert.deepStrictEqual(isPositive(0), true)
assert.deepStrictEqual(isPositive(1), true)
```
Added in v1.0.0
## or
Combines two predicates into a new predicate that returns `true` if at least one of the predicates returns `true`.
**Signature**
```ts
export declare const or: {
<A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
<A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>
}
```
**Example**
```ts
import * as P from '@fp-ts/core/Predicate'
import * as N from '@fp-ts/core/Number'
const nonZero = P.or(N.lessThan(0), N.greaterThan(0))
assert.deepStrictEqual(nonZero(-1), true)
assert.deepStrictEqual(nonZero(0), false)
assert.deepStrictEqual(nonZero(1), true)
```
Added in v1.0.0
# constructors
## contramap
Given a `Predicate<A>` returns a `Predicate<B>`
**Signature**
```ts
export declare const contramap: {
<B, A>(f: (b: B) => A): (self: Predicate<A>) => Predicate<B>
<A, B>(self: Predicate<A>, f: (b: B) => A): Predicate<B>
}
```
**Example**
```ts
import * as P from '@fp-ts/core/Predicate'
import * as N from '@fp-ts/core/Number'
const minLength3 = P.contramap(N.greaterThan(2), (s: string) => s.length)
assert.deepStrictEqual(minLength3('a'), false)
assert.deepStrictEqual(minLength3('aa'), false)
assert.deepStrictEqual(minLength3('aaa'), true)
assert.deepStrictEqual(minLength3('aaaa'), true)
```
Added in v1.0.0
# do notation
## Do
**Signature**
```ts
export declare const Do: Predicate<{}>
```
Added in v1.0.0
## andThenBind
A variant of `bind` that sequentially ignores the scope.
**Signature**
```ts
export declare const andThenBind: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, that: Predicate<B>): (
self: Predicate<A>
) => Predicate<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
<A extends object, N extends string, B>(
self: Predicate<A>,
name: Exclude<N, keyof A>,
that: Predicate<B>
): Predicate<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }>
}
```
Added in v1.0.0
## bindTo
**Signature**
```ts
export declare const bindTo: {
<N extends string>(name: N): <A>(self: Predicate<A>) => Predicate<{ readonly [K in N]: A }>
<A, N extends string>(self: Predicate<A>, name: N): Predicate<{ readonly [K in N]: A }>
}
```
Added in v1.0.0
# guards
## isBigint
Tests if a value is a `bigint`.
**Signature**
```ts
export declare const isBigint: (input: unknown) => input is bigint
```
**Example**
```ts
import { isBigint } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isBigint(1n), true)
assert.deepStrictEqual(isBigint(1), false)
```
Added in v1.0.0
## isBoolean
Tests if a value is a `boolean`.
**Signature**
```ts
export declare const isBoolean: (input: unknown) => input is boolean
```
**Example**
```ts
import { isBoolean } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isBoolean(true), true)
assert.deepStrictEqual(isBoolean('true'), false)
```
Added in v1.0.0
## isDate
A guard that succeeds when the input is a `Date`.
**Signature**
```ts
export declare const isDate: (input: unknown) => input is Date
```
**Example**
```ts
import { isDate } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isDate(new Date()), true)
assert.deepStrictEqual(isDate(null), false)
assert.deepStrictEqual(isDate({}), false)
```
Added in v1.0.0
## isError
A guard that succeeds when the input is an `Error`.
**Signature**
```ts
export declare const isError: (input: unknown) => input is Error
```
**Example**
```ts
import { isError } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isError(new Error()), true)
assert.deepStrictEqual(isError(null), false)
assert.deepStrictEqual(isError({}), false)
```
Added in v1.0.0
## isFunction
Tests if a value is a `function`.
**Signature**
```ts
export declare const isFunction: (input: unknown) => input is Function
```
**Example**
```ts
import { isFunction } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isFunction(isFunction), true)
assert.deepStrictEqual(isFunction('function'), false)
```
Added in v1.0.0
## isNever
A guard that always fails.
**Signature**
```ts
export declare const isNever: (input: unknown) => input is never
```
**Example**
```ts
import { isNever } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isNever(null), false)
assert.deepStrictEqual(isNever(undefined), false)
assert.deepStrictEqual(isNever({}), false)
assert.deepStrictEqual(isNever([]), false)
```
Added in v1.0.0
## isNotNull
Tests if a value is not `undefined`.
**Signature**
```ts
export declare const isNotNull: <A>(input: A) => input is Exclude<A, null>
```
**Example**
```ts
import { isNotNull } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isNotNull(undefined), true)
assert.deepStrictEqual(isNotNull('null'), true)
assert.deepStrictEqual(isNotNull(null), false)
```
Added in v1.0.0
## isNotNullable
A guard that succeeds when the input is not `null` or `undefined`.
**Signature**
```ts
export declare const isNotNullable: <A>(input: A) => input is NonNullable<A>
```
**Example**
```ts
import { isNotNullable } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isNotNullable({}), true)
assert.deepStrictEqual(isNotNullable([]), true)
assert.deepStrictEqual(isNotNullable(null), false)
assert.deepStrictEqual(isNotNullable(undefined), false)
```
Added in v1.0.0
## isNotUndefined
Tests if a value is not `undefined`.
**Signature**
```ts
export declare const isNotUndefined: <A>(input: A) => input is Exclude<A, undefined>
```
**Example**
```ts
import { isNotUndefined } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isNotUndefined(null), true)
assert.deepStrictEqual(isNotUndefined('undefined'), true)
assert.deepStrictEqual(isNotUndefined(undefined), false)
```
Added in v1.0.0
## isNull
Tests if a value is `undefined`.
**Signature**
```ts
export declare const isNull: (input: unknown) => input is null
```
**Example**
```ts
import { isNull } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isNull(null), true)
assert.deepStrictEqual(isNull(undefined), false)
assert.deepStrictEqual(isNull('null'), false)
```
Added in v1.0.0
## isNullable
A guard that succeeds when the input is `null` or `undefined`.
**Signature**
```ts
export declare const isNullable: <A>(input: A) => input is Extract<A, null | undefined>
```
**Example**
```ts
import { isNullable } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isNullable(null), true)
assert.deepStrictEqual(isNullable(undefined), true)
assert.deepStrictEqual(isNullable({}), false)
assert.deepStrictEqual(isNullable([]), false)
```
Added in v1.0.0
## isNumber
Tests if a value is a `number`.
**Signature**
```ts
export declare const isNumber: (input: unknown) => input is number
```
**Example**
```ts
import { isNumber } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isNumber(2), true)
assert.deepStrictEqual(isNumber('2'), false)
```
Added in v1.0.0
## isObject
Tests if a value is an `object`.
**Signature**
```ts
export declare const isObject: (input: unknown) => input is object
```
**Example**
```ts
import { isObject } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isObject({}), true)
assert.deepStrictEqual(isObject([]), true)
assert.deepStrictEqual(isObject(null), false)
assert.deepStrictEqual(isObject(undefined), false)
```
Added in v1.0.0
## isReadonlyRecord
A guard that succeeds when the input is a readonly record.
**Signature**
```ts
export declare const isReadonlyRecord: (input: unknown) => input is {}
```
**Example**
```ts
import { isReadonlyRecord } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isReadonlyRecord({}), true)
assert.deepStrictEqual(isReadonlyRecord({ a: 1 }), true)
assert.deepStrictEqual(isReadonlyRecord([]), false)
assert.deepStrictEqual(isReadonlyRecord([1, 2, 3]), false)
assert.deepStrictEqual(isReadonlyRecord(null), false)
assert.deepStrictEqual(isReadonlyRecord(undefined), false)
```
Added in v1.0.0
## isRecord
A guard that succeeds when the input is a record.
**Signature**
```ts
export declare const isRecord: (input: unknown) => input is {}
```
**Example**
```ts
import { isRecord } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isRecord({}), true)
assert.deepStrictEqual(isRecord({ a: 1 }), true)
assert.deepStrictEqual(isRecord([]), false)
assert.deepStrictEqual(isRecord([1, 2, 3]), false)
assert.deepStrictEqual(isRecord(null), false)
assert.deepStrictEqual(isRecord(undefined), false)
```
Added in v1.0.0
## isString
Tests if a value is a `string`.
**Signature**
```ts
export declare const isString: (input: unknown) => input is string
```
**Example**
```ts
import { isString } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isString('a'), true)
assert.deepStrictEqual(isString(1), false)
```
Added in v1.0.0
## isSymbol
Tests if a value is a `symbol`.
**Signature**
```ts
export declare const isSymbol: (input: unknown) => input is symbol
```
**Example**
```ts
import { isSymbol } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isSymbol(Symbol.for('a')), true)
assert.deepStrictEqual(isSymbol('a'), false)
```
Added in v1.0.0
## isUndefined
Tests if a value is `undefined`.
**Signature**
```ts
export declare const isUndefined: (input: unknown) => input is undefined
```
**Example**
```ts
import { isUndefined } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isUndefined(undefined), true)
assert.deepStrictEqual(isUndefined(null), false)
assert.deepStrictEqual(isUndefined('undefined'), false)
```
Added in v1.0.0
## isUnknown
A guard that always succeeds.
**Signature**
```ts
export declare const isUnknown: (input: unknown) => input is unknown
```
**Example**
```ts
import { isUnknown } from '@fp-ts/core/Predicate'
assert.deepStrictEqual(isUnknown(null), true)
assert.deepStrictEqual(isUnknown(undefined), true)
assert.deepStrictEqual(isUnknown({}), true)
assert.deepStrictEqual(isUnknown([]), true)
```
Added in v1.0.0
# instances
## Contravariant
**Signature**
```ts
export declare const Contravariant: contravariant.Contravariant<PredicateTypeLambda>
```
Added in v1.0.0
## Invariant
**Signature**
```ts
export declare const Invariant: invariant.Invariant<PredicateTypeLambda>
```
Added in v1.0.0
## Of
**Signature**
```ts
export declare const Of: of_.Of<PredicateTypeLambda>
```
Added in v1.0.0
## Product
**Signature**
```ts
export declare const Product: product_.Product<PredicateTypeLambda>
```
Added in v1.0.0
## SemiProduct
**Signature**
```ts
export declare const SemiProduct: semiProduct.SemiProduct<PredicateTypeLambda>
```
Added in v1.0.0
## getMonoidAll
**Signature**
```ts
export declare const getMonoidAll: <A>() => monoid.Monoid<Predicate<A>>
```
Added in v1.0.0
## getMonoidAny
**Signature**
```ts
export declare const getMonoidAny: <A>() => monoid.Monoid<Predicate<A>>
```
Added in v1.0.0
## getSemigroupAll
**Signature**
```ts
export declare const getSemigroupAll: <A>() => semigroup.Semigroup<Predicate<A>>
```
Added in v1.0.0
## getSemigroupAny
**Signature**
```ts
export declare const getSemigroupAny: <A>() => semigroup.Semigroup<Predicate<A>>
```
Added in v1.0.0
# models
## Predicate (interface)
**Signature**
```ts
export interface Predicate<A> {
(a: A): boolean
}
```
Added in v1.0.0
## Refinement (interface)
**Signature**
```ts
export interface Refinement<A, B extends A> {
(a: A): a is B
}
```
Added in v1.0.0
# type lambdas
## PredicateTypeLambda (interface)
**Signature**
```ts
export interface PredicateTypeLambda extends TypeLambda {
readonly type: Predicate<this['Target']>
}
```
Added in v1.0.0
# utils
## all
**Signature**
```ts
export declare const all: <A>(collection: Iterable<Predicate<A>>) => Predicate<A>
```
Added in v1.0.0
## any
**Signature**
```ts
export declare const any: <A>(collection: Iterable<Predicate<A>>) => Predicate<A>
```
Added in v1.0.0
## appendElement
This function appends a predicate to a tuple-like predicate, allowing you to create a new predicate that includes
the original elements and the new one.
**Signature**
```ts
export declare const appendElement: {
<A extends readonly any[], B>(self: Predicate<A>, that: Predicate<B>): Predicate<readonly [...A, B]>
<B>(that: Predicate<B>): <A extends readonly any[]>(self: Predicate<A>) => Predicate<readonly [...A, B]>
}
```
Added in v1.0.0
## compose
**Signature**
```ts
export declare const compose: {
<A, B extends A, C extends B>(bc: Refinement<B, C>): (ab: Refinement<A, B>) => Refinement<A, C>
<A, B extends A, C extends B>(ab: Refinement<A, B>, bc: Refinement<B, C>): Refinement<A, C>
}
```
Added in v1.0.0
## of
**Signature**
```ts
export declare const of: <A>(_: A) => Predicate<A>
```
Added in v1.0.0
## struct
**Signature**
```ts
export declare const struct: <R extends Record<string, Predicate<any>>>(
predicates: R
) => Predicate<{ readonly [K in keyof R]: [R[K]] extends [Predicate<infer A>] ? A : never }>
```
Added in v1.0.0
## tuple
Similar to `Promise.all` but operates on `Predicate`s.
```
[Predicate<A>, Predicate<B>, ...] -> Predicate<[A, B, ...]>
```
**Signature**
```ts
export declare const tuple: <T extends readonly Predicate<any>[]>(
...predicates: T
) => Predicate<Readonly<{ [I in keyof T]: [T[I]] extends [Predicate<infer A>] ? A : never }>>
```
Added in v1.0.0
## tupled
**Signature**
```ts
export declare const tupled: <A>(self: Predicate<A>) => Predicate<readonly [A]>
```
Added in v1.0.0
## unit
**Signature**
```ts
export declare const unit: Predicate<void>
```
Added in v1.0.0
================================================
FILE: docs/modules/ReadonlyArray.ts.md
================================================
---
title: ReadonlyArray.ts
nav_order: 12
parent: Modules
---
## ReadonlyArray overview
This module provides utility functions for working with arrays in TypeScript.
Added in v1.0.0
---
<h2 class="text-delta">Table of contents</h2>
- [combining](#combining)
- [flatMap](#flatmap)
- [flatMapNonEmpty](#flatmapnonempty)
- [flatMapNullable](#flatmapnullable)
- [flatten](#flatten)
- [flattenNonEmpty](#flattennonempty)
- [constructors](#constructors)
- [empty](#empty)
- [make](#make)
- [makeBy](#makeby)
- [of](#of)
- [range](#range)
- [replicate](#replicate)
- [unfold](#unfold)
- [conversions](#conversions)
- [fromEither](#fromeither)
- [fromIterable](#fromiterable)
- [fromNullable](#fromnullable)
- [fromOption](#fromoption)
- [do notation](#do-notation)
- [Do](#do)
- [andThenBind](#andthenbind)
- [bind](#bind)
- [bindTo](#bindto)
- [let](#let)
- [filtering](#filtering)
- [compact](#compact)
- [filter](#filter)
- [filterMap](#filtermap)
- [partition](#partition)
- [partitionMap](#partitionmap)
- [separate](#separate)
- [span](#span)
- [traverseFilterMap](#traversefiltermap)
- [traversePartitionMap](#traversepartitionmap)
- [folding](#folding)
- [combineMap](#combinemap)
- [combineMapNonEmpty](#combinemapnonempty)
- [coproductMapKind](#coproductmapkind)
- [reduce](#reduce)
- [reduceKind](#reducekind)
- [reduceRight](#reduceright)
- [scan](#scan)
- [scanRight](#scanright)
- [getters](#getters)
- [chunksOf](#chunksof)
- [chunksOfNonEmpty](#chunksofnonempty)
- [drop](#drop)
- [dropRight](#dropright)
- [dropWhile](#dropwhile)
- [findFirst](#findfirst)
- [findFirstIndex](#findfirstindex)
- [findLast](#findlast)
- [findLastIndex](#findlastindex)
- [get](#get)
- [head](#head)
- [headNonEmpty](#headnonempty)
- [init](#init)
- [initNonEmpty](#initnonempty)
- [last](#last)
- [lastNonEmpty](#lastnonempty)
- [lefts](#lefts)
- [length](#length)
- [rights](#rights)
- [splitAt](#splitat)
- [splitNonEmptyAt](#splitnonemptyat)
- [tail](#tail)
- [tailNonEmpty](#tailnonempty)
- [take](#take)
- [takeRight](#takeright)
- [takeWhile](#takewhile)
- [unappend](#unappend)
- [unprepend](#unprepend)
- [grouping](#grouping)
- [group](#group)
- [groupBy](#groupby)
- [guards](#guards)
- [isEmpty](#isempty)
- [isEmptyArray](#isemptyarray)
- [isNonEmpty](#isnonempty)
- [isNonEmptyArray](#isnonemptyarray)
- [instances](#instances)
- [Applicative](#applicative)
- [Chainable](#chainable)
- [Covariant](#covariant)
- [Filterable](#filterable)
- [FlatMap](#flatmap)
- [Foldable](#foldable)
- [Invariant](#invariant)
- [Monad](#monad)
- [Of](#of)
- [Pointed](#pointed)
- [Product](#product)
- [SemiApplicative](#semiapplicative)
- [SemiProduct](#semiproduct)
- [Traversable](#traversable)
- [TraversableFilterable](#traversablefilterable)
- [getIntersectionSemigroup](#getintersectionsemigroup)
- [getMonoid](#getmonoid)
- [getSemigroup](#getsemigroup)
- [getUnionMonoid](#getunionmonoid)
- [getUnionSemigroup](#getunionsemigroup)
- [lifting](#lifting)
- [getOrder](#getorder)
- [lift2](#lift2)
- [liftEither](#lifteither)
- [liftMonoid](#liftmonoid)
- [liftNullable](#liftnullable)
- [liftOption](#liftoption)
- [liftPredicate](#liftpredicate)
- [mapping](#mapping)
- [as](#as)
- [flap](#flap)
- [map](#map)
- [mapNonEmpty](#mapnonempty)
- [tupled](#tupled)
- [models](#models)
- [NonEmptyArray (type alias)](#nonemptyarray-type-alias)
- [NonEmptyReadonlyArray (type alias)](#nonemptyreadonlyarray-type-alias)
- [pattern matching](#pattern-matching)
- [match](#match)
- [matchLeft](#matchleft)
- [matchRight](#matchright)
- [predicates](#predicates)
- [contains](#contains)
- [every](#every)
- [some](#some)
- [sorting](#sorting)
- [sort](#sort)
- [sortBy](#sortby)
- [sortByNonEmpty](#sortbynonempty)
- [sortNonEmpty](#sortnonempty)
- [traversing](#traversing)
- [sequence](#sequence)
- [sequenceNonEmpty](#sequencenonempty)
- [traverse](#traverse)
- [traverseNonEmpty](#traversenonempty)
- [traverseTap](#traversetap)
- [type lambdas](#type-lambdas)
- [ReadonlyArrayTypeLambda (interface)](#readonlyarraytypelambda-interface)
- [unsafe](#unsafe)
- [unsafeGet](#unsafeget)
- [utils](#utils)
- [ap](#ap)
- [append](#append)
- [appendAll](#appendall)
- [appendAllNonEmpty](#appendallnonempty)
- [chop](#chop)
- [chopNonEmpty](#chopnonempty)
- [composeKleisliArrow](#composekleisliarrow)
- [copy](#copy)
- [difference](#difference)
- [extend](#extend)
- [insertAt](#insertat)
- [intercalate](#intercalate)
- [intercalateNonEmpty](#intercalatenonempty)
- [intersection](#intersection)
- [intersperse](#intersperse)
- [intersperseNonEmpty](#interspersenonempty)
- [join](#join)
- [max](#max)
- [min](#min)
- [modify](#modify)
- [modifyNonEmptyHead](#modifynonemptyhead)
- [modifyNonEmptyLast](#modifynonemptylast)
- [modifyOption](#modifyoption)
- [prepend](#prepend)
- [prependAll](#prependall)
- [prependAllNonEmpty](#prependallnonempty)
- [remove](#remove)
- [replace](#replace)
- [replaceOption](#replaceoption)
- [reverse](#reverse)
- [reverseNonEmpty](#reversenonempty)
- [rotate](#rotate)
- [rotateNonEmpty](#rotatenonempty)
- [setNonEmptyHead](#setnonemptyhead)
- [setNonEmptyLast](#setnonemptylast)
- [traverseFilter](#traversefilter)
- [traversePartition](#traversepartition)
- [union](#union)
- [unionNonEmpty](#unionnonempty)
- [uniq](#uniq)
- [uniqNonEmpty](#uniqnonempty)
- [unzip](#unzip)
- [unzipNonEmpty](#unzipnonempty)
- [zip](#zip)
- [zipNonEmpty](#zipnonempty)
- [zipNonEmptyWith](#zipnonemptywith)
- [zipWith](#zipwith)
---
# combining
## flatMap
**Signature**
```ts
export declare const flatMap: {
<A, B>(f: (a: A, i: number) => readonly B[]): (self: readonly A[]) => B[]
<A, B>(self: readonly A[], f: (a: A, i: number) => readonly B[]): B[]
}
```
Added in v1.0.0
## flatMapNonEmpty
**Signature**
```ts
export declare const flatMapNonEmpty: {
<A, B>(f: (a: A, i: number) => readonly [B, ...B[]]): (self: readonly [A, ...A[]]) => [B, ...B[]]
<A, B>(self: readonly [A, ...A[]], f: (a: A, i: number) => readonly [B, ...B[]]): [B, ...B[]]
}
```
Added in v1.0.0
## flatMapNullable
**Signature**
```ts
export declare const flatMapNullable: {
<A, B>(f: (a: A) => B | null | undefined): (self: readonly A[]) => NonNullable<B>[]
<A, B>(self: readonly A[], f: (a: A) => B | null | undefined): NonNullable<B>[]
}
```
Added in v1.0.0
## flatten
**Signature**
```ts
export declare const flatten: <A>(self: readonly (readonly A[])[]) => A[]
```
Added in v1.0.0
## flattenNonEmpty
**Signature**
```ts
export declare const flattenNonEmpty: <A>(
self: readonly [readonly [A, ...A[]], ...(readonly [A, ...A[]])[]]
) => [A, ...A[]]
```
Added in v1.0.0
# constructors
## empty
**Signature**
```ts
export declare const empty: <A = never>() => A[]
```
Added in v1.0.0
## make
Builds a `NonEmptyArray` from an non-empty collection of elements.
**Signature**
```ts
export declare const make: <Elements extends [any, ...any[]]>(
...elements: Elements
) => [Elements[number], ...Elements[number][]]
```
Added in v1.0.0
## makeBy
Return a `NonEmptyArray` of length `n` with element `i` initialized with `f(i)`.
**Note**. `n` is normalized to an integer >= 1.
**Signature**
```ts
export declare const makeBy: <A>(n: number, f: (i: number) => A) => [A, ...A[]]
```
**Example**
```ts
import { makeBy } from '@fp-ts/core/ReadonlyArray'
assert.deepStrictEqual(
makeBy(5, (n) => n * 2),
[0, 2, 4, 6, 8]
)
```
Added in v1.0.0
## of
**Signature**
```ts
export declare const of: <A>(a: A) => [A, ...A[]]
```
Added in v1.0.0
## range
Return a `NonEmptyArray` containing a range of integers, including both endpoints.
**Signature**
```ts
export declare const range: (start: number, end: number) => [number, ...number[]]
```
**Example**
```ts
import { range } from '@fp-ts/core/ReadonlyArray'
assert.deepStrictEqual(range(1, 3), [1, 2, 3])
```
Added in v1.0.0
## replicate
Return a `NonEmptyArray` containing a value repeated the specified number of times.
**Note**. `n` is normalized to an integer >= 1.
**Signature**
```ts
export declare const replicate: { (n: number): <A>(a: A) => [A, ...A[]]; <A>(a: A, n: number): [A, ...A[]] }
```
**Example**
```ts
import { replicate } from '@fp-ts/core/ReadonlyArray'
assert.deepStrictEqual(replicate('a', 3), ['a', 'a', 'a'])
```
Added in v1.0.0
## unfold
**Signature**
```ts
export declare const unfold: <B, A>(b: B, f: (b: B) => Option<readonly [A, B]>) => A[]
```
Added in v1.0.0
# conversions
## fromEither
**Signature**
```ts
export declare const fromEither: <E, A>(self: Either<E, A>) => A[]
```
Added in v1.0.0
## fromIterable
**Signature**
```ts
export declare const fromIterable: <A>(collection: Iterable<A>) => A[]
```
Added in v1.0.0
## fromNullable
**Signature**
```ts
export declare const fromNullable: <A>(a: A) => NonNullable<A>[]
```
Added in v1.0.0
## fromOption
**Signature**
```ts
export declare const fromOption: <A>(self: Option<A>) => A[]
```
Added in v1.0.0
# do notation
## Do
**Signature**
```ts
export declare const Do: readonly {}[]
```
Added in v1.0.0
## andThenBind
A variant of `bind` that sequentially ignores the scope.
**Signature**
```ts
export declare const andThenBind: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, that: readonly B[]): (
self: readonly A[]
) => { [K in N | keyof A]: K extends keyof A ? A[K] : B }[]
<A extends object, N extends string, B>(self: readonly A[], name: Exclude<N, keyof A>, that: readonly B[]): {
[K in N | keyof A]: K extends keyof A ? A[K] : B
}[]
}
```
Added in v1.0.0
## bind
**Signature**
```ts
export declare const bind: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => readonly B[]): (
self: readonly A[]
) => { [K in N | keyof A]: K extends keyof A ? A[K] : B }[]
<A extends object, N extends string, B>(self: readonly A[], name: Exclude<N, keyof A>, f: (a: A) => readonly B[]): {
[K in N | keyof A]: K extends keyof A ? A[K] : B
}[]
}
```
Added in v1.0.0
## bindTo
**Signature**
```ts
export declare const bindTo: {
<N extends string>(name: N): <A>(self: readonly A[]) => { [K in N]: A }[]
<A, N extends string>(self: readonly A[], name: N): { [K in N]: A }[]
}
```
Added in v1.0.0
## let
**Signature**
```ts
export declare const let: {
<N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): (
self: readonly A[]
) => { [K in N | keyof A]: K extends keyof A ? A[K] : B }[]
<A extends object, N extends string, B>(self: readonly A[], name: Exclude<N, keyof A>, f: (a: A) => B): {
[K in N | keyof A]: K extends keyof A ? A[K] : B
}[]
}
```
Added in v1.0.0
# filtering
## compact
**Signature**
```ts
export declare const compact: <A>(self: Iterable<Option<A>>) => A[]
```
Added in v1.0.0
## filter
**Signature**
```ts
export declare const filter: {
<C extends A, B extends A, A = C>(refinement: (a: A, i: number) => a is B): (self: Iterable<C>) => B[]
<B extends A, A = B>(predicate: (a: A, i: number) => boolean): (self: Iterable<B>) => B[]
<C extends A, B extends A, A = C>(self: Iterable<C>, refinement: (a: A, i: number) => a is B): B[]
<B extends A, A = B>(self: Iterable<B>, predicate: (a: A, i: number) => boolean): B[]
}
```
Added in v1.0.0
## filterMap
**Signature**
```ts
export declare const filterMap: {
<A, B>(f: (a: A, i: number) => Option<B>): (self: Iterable<A>) => B[]
<A, B>(self: Iterabl
gitextract_pgmrj7hm/ ├── .babel.cjs.json ├── .babel.mjs.json ├── .changeset/ │ ├── README.md │ ├── beige-numbers-exist.md │ ├── config.json │ ├── famous-spies-attend.md │ ├── flat-news-whisper.md │ ├── hungry-comics-kneel.md │ ├── mighty-meals-dream.md │ ├── odd-hornets-wave.md │ ├── sour-suits-press.md │ └── tough-planets-lick.md ├── .eslintrc.cjs ├── .github/ │ ├── CONTRIBUTING.md │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── Bug_report.md │ │ ├── Documentation.md │ │ └── Feature_request.md │ ├── PULL_REQUEST_TEMPLATE.md │ └── workflows/ │ ├── main.yml │ └── pr.yml ├── .gitignore ├── .gitpod.yml ├── .vscode/ │ ├── settings.json │ └── tasks.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── benchmark/ │ ├── Number/ │ │ └── lessThan.ts │ ├── These/ │ │ └── product.ts │ ├── dual.ts │ ├── sumAll.ts │ └── tsconfig.json ├── docs/ │ ├── _config.yml │ ├── _sass/ │ │ └── custom/ │ │ └── custom.scss │ ├── index.md │ └── modules/ │ ├── Bigint.ts.md │ ├── Boolean.ts.md │ ├── Either.ts.md │ ├── Function.ts.md │ ├── HKT.ts.md │ ├── Identity.ts.md │ ├── Number.ts.md │ ├── Option.ts.md │ ├── Ordering.ts.md │ ├── Predicate.ts.md │ ├── ReadonlyArray.ts.md │ ├── ReadonlyRecord.ts.md │ ├── String.ts.md │ ├── Struct.ts.md │ ├── Symbol.ts.md │ ├── These.ts.md │ ├── Tuple.ts.md │ ├── index.md │ ├── index.ts.md │ └── typeclass/ │ ├── Alternative.ts.md │ ├── Applicative.ts.md │ ├── Bicovariant.ts.md │ ├── Bounded.ts.md │ ├── Chainable.ts.md │ ├── Contravariant.ts.md │ ├── Coproduct.ts.md │ ├── Covariant.ts.md │ ├── Equivalence.ts.md │ ├── Filterable.ts.md │ ├── FlatMap.ts.md │ ├── Foldable.ts.md │ ├── Invariant.ts.md │ ├── Monad.ts.md │ ├── Monoid.ts.md │ ├── Of.ts.md │ ├── Order.ts.md │ ├── Pointed.ts.md │ ├── Product.ts.md │ ├── SemiAlternative.ts.md │ ├── SemiApplicative.ts.md │ ├── SemiCoproduct.ts.md │ ├── SemiProduct.ts.md │ ├── Semigroup.ts.md │ ├── Traversable.ts.md │ └── TraversableFilterable.ts.md ├── docs-ts.json ├── dtslint/ │ ├── index.d.ts │ └── ts4.8/ │ ├── FlatMap.ts │ ├── Monoid.ts │ ├── Option.ts │ ├── Predicate.ts │ ├── Product.ts │ ├── ReadonlyArray.ts │ ├── ReadonlyRecord.ts │ ├── SemiAlternative.ts │ ├── SemiProduct.ts │ ├── Semigroup.ts │ ├── Tuple.ts │ ├── index.d.ts │ ├── index.ts │ ├── tsconfig.json │ └── tslint.json ├── guides/ │ ├── Either.md │ ├── FAQ.md │ ├── Option.md │ ├── These.md │ ├── ts-types.md │ └── typeclass.md ├── package.json ├── patches/ │ ├── @effect-ts__build-utils@0.40.3.patch │ └── docs-ts@0.6.10.patch ├── src/ │ ├── Bigint.ts │ ├── Boolean.ts │ ├── Either.ts │ ├── Function.ts │ ├── HKT.ts │ ├── Identity.ts │ ├── Number.ts │ ├── Option.ts │ ├── Ordering.ts │ ├── Predicate.ts │ ├── ReadonlyArray.ts │ ├── ReadonlyRecord.ts │ ├── String.ts │ ├── Struct.ts │ ├── Symbol.ts │ ├── These.ts │ ├── Tuple.ts │ ├── index.ts │ ├── internal/ │ │ ├── Either.ts │ │ ├── Option.ts │ │ ├── ReadonlyArray.ts │ │ └── effect.ts │ └── typeclass/ │ ├── Alternative.ts │ ├── Applicative.ts │ ├── Bicovariant.ts │ ├── Bounded.ts │ ├── Chainable.ts │ ├── Contravariant.ts │ ├── Coproduct.ts │ ├── Covariant.ts │ ├── Equivalence.ts │ ├── Filterable.ts │ ├── FlatMap.ts │ ├── Foldable.ts │ ├── Invariant.ts │ ├── Monad.ts │ ├── Monoid.ts │ ├── Of.ts │ ├── Order.ts │ ├── Pointed.ts │ ├── Product.ts │ ├── SemiAlternative.ts │ ├── SemiApplicative.ts │ ├── SemiCoproduct.ts │ ├── SemiProduct.ts │ ├── Semigroup.ts │ ├── Traversable.ts │ └── TraversableFilterable.ts ├── test/ │ ├── Bigint.ts │ ├── Boolean.ts │ ├── Either.ts │ ├── Function.ts │ ├── Identity.ts │ ├── Number.ts │ ├── Option.ts │ ├── Ordering.ts │ ├── Predicate.ts │ ├── ReadonlyArray.ts │ ├── ReadonlyRecord.ts │ ├── String.ts │ ├── Struct.ts │ ├── Symbol.ts │ ├── These.ts │ ├── Tuple.ts │ ├── index.ts │ ├── limbo/ │ │ ├── Category.ts │ │ ├── Comonad.ts │ │ ├── Composable.ts │ │ ├── Extendable.ts │ │ └── NonEmptyTraversable.ts │ ├── typeclass/ │ │ ├── Applicative.ts │ │ ├── Bicovariant.ts │ │ ├── Bounded.ts │ │ ├── Chainable.ts │ │ ├── Contravariant.ts │ │ ├── Coproduct.ts │ │ ├── Covariant.ts │ │ ├── Equivalence.ts │ │ ├── Filterable.ts │ │ ├── FlatMap.ts │ │ ├── Foldable.ts │ │ ├── Invariant.ts │ │ ├── Monoid.ts │ │ ├── NonEmptyTraversable.ts │ │ ├── Of.ts │ │ ├── Order.ts │ │ ├── Product.ts │ │ ├── SemiApplicative.ts │ │ ├── SemiCoproduct.ts │ │ ├── SemiProduct.ts │ │ ├── Semigroup.ts │ │ ├── Traversable.ts │ │ └── TraversableFilterable.ts │ └── util.ts ├── tsconfig.base.json ├── tsconfig.build-test.json ├── tsconfig.build.json ├── tsconfig.eslint.json ├── tsconfig.json ├── tsconfig.madge.json └── vitest.config.ts
SYMBOL INDEX (102 symbols across 56 files)
FILE: dtslint/ts4.8/FlatMap.ts
type RAW (line 5) | interface RAW<R, E, A> {
type RAWTypeLambda (line 9) | interface RAWTypeLambda extends TypeLambda {
FILE: dtslint/ts4.8/Product.ts
type RAW (line 4) | interface RAW<R, E, A> {
type RAWTypeLambda (line 8) | interface RAWTypeLambda extends TypeLambda {
FILE: dtslint/ts4.8/ReadonlyRecord.ts
function mapToBoolean (line 37) | function mapToBoolean(): { [K in keyof typeof constStruct]: boolean } {
FILE: dtslint/ts4.8/SemiAlternative.ts
type RAW (line 5) | interface RAW<R, E, A> {
type RAWTypeLambda (line 9) | interface RAWTypeLambda extends TypeLambda {
FILE: dtslint/ts4.8/index.ts
function testIssue536 (line 4) | function testIssue536<F extends _.TypeLambda, G extends _.TypeLambda, R,...
FILE: src/Either.ts
type Either (line 40) | type Either<E, A> = Left<E> | Right<A>
type Left (line 46) | interface Left<E> {
type Right (line 55) | interface Right<A> {
type EitherTypeLambda (line 64) | interface EitherTypeLambda extends TypeLambda {
FILE: src/Function.ts
type FunctionTypeLambda (line 10) | interface FunctionTypeLambda extends TypeLambda {
type LazyArg (line 92) | interface LazyArg<A> {
type FunctionN (line 104) | interface FunctionN<A extends ReadonlyArray<unknown>, B> {
function flow (line 312) | function flow(
function pipe (line 689) | function pipe(
FILE: src/HKT.ts
type TypeClass (line 13) | interface TypeClass<F extends TypeLambda> {
type TypeLambda (line 20) | interface TypeLambda {
type Kind (line 30) | type Kind<F extends TypeLambda, In, Out2, Out1, Target> = F extends {
FILE: src/Identity.ts
type Identity (line 28) | type Identity<A> = A
type IdentityTypeLambda (line 34) | interface IdentityTypeLambda extends TypeLambda {
type IdentityTypeLambdaFix (line 42) | interface IdentityTypeLambdaFix<A> extends TypeLambda {
FILE: src/Option.ts
type Option (line 44) | type Option<A> = None | Some<A>
type None (line 50) | interface None {
type Some (line 58) | interface Some<A> {
type OptionTypeLambda (line 67) | interface OptionTypeLambda extends TypeLambda {
FILE: src/Ordering.ts
type Ordering (line 13) | type Ordering = -1 | 0 | 1
FILE: src/Predicate.ts
type Predicate (line 20) | interface Predicate<A> {
type PredicateTypeLambda (line 28) | interface PredicateTypeLambda extends TypeLambda {
type Refinement (line 36) | interface Refinement<A, B extends A> {
FILE: src/ReadonlyArray.ts
type ReadonlyArrayTypeLambda (line 44) | interface ReadonlyArrayTypeLambda extends TypeLambda {
type NonEmptyReadonlyArray (line 52) | type NonEmptyReadonlyArray<A> = readonly [A, ...Array<A>]
type NonEmptyArray (line 58) | type NonEmptyArray<A> = [A, ...Array<A>]
function every (line 2169) | function every<A>(predicate: Predicate<A>): Predicate<ReadonlyArray<A>> {
FILE: src/ReadonlyRecord.ts
type ReadonlyRecord (line 28) | interface ReadonlyRecord<A> {
type ReadonlyRecordTypeLambda (line 36) | interface ReadonlyRecordTypeLambda extends TypeLambda {
FILE: src/These.ts
type Both (line 42) | interface Both<E, A> {
type These (line 52) | type These<E, A> = Either<E, A> | Both<E, A>
type Validated (line 58) | type Validated<E, A> = These<NonEmptyReadonlyArray<E>, A>
type TheseTypeLambda (line 64) | interface TheseTypeLambda extends TypeLambda {
type ValidatedTypeLambda (line 72) | interface ValidatedTypeLambda extends TypeLambda {
FILE: src/Tuple.ts
type TupleTypeLambda (line 18) | interface TupleTypeLambda extends TypeLambda {
FILE: src/typeclass/Alternative.ts
type Alternative (line 12) | interface Alternative<F extends TypeLambda> extends SemiAlternative<F>, ...
FILE: src/typeclass/Applicative.ts
type Applicative (line 15) | interface Applicative<F extends TypeLambda> extends SemiApplicative<F>, ...
FILE: src/typeclass/Bicovariant.ts
type Bicovariant (line 12) | interface Bicovariant<F extends TypeLambda> extends TypeClass<F> {
FILE: src/typeclass/Bounded.ts
type Bounded (line 15) | interface Bounded<A> extends Order<A> {
type BoundedTypeLambda (line 24) | interface BoundedTypeLambda extends TypeLambda {
FILE: src/typeclass/Chainable.ts
type Chainable (line 13) | interface Chainable<F extends TypeLambda> extends FlatMap<F>, Covariant<...
FILE: src/typeclass/Contravariant.ts
type Contravariant (line 12) | interface Contravariant<F extends TypeLambda> extends Invariant<F> {
FILE: src/typeclass/Coproduct.ts
type Coproduct (line 13) | interface Coproduct<F extends TypeLambda> extends SemiCoproduct<F> {
FILE: src/typeclass/Covariant.ts
type Covariant (line 12) | interface Covariant<F extends TypeLambda> extends Invariant<F> {
FILE: src/typeclass/Equivalence.ts
type Equivalence (line 24) | interface Equivalence<A> {
type EquivalenceTypeLambda (line 32) | interface EquivalenceTypeLambda extends TypeLambda {
FILE: src/typeclass/Filterable.ts
type Filterable (line 18) | interface Filterable<F extends TypeLambda> extends TypeClass<F> {
FILE: src/typeclass/FlatMap.ts
type FlatMap (line 11) | interface FlatMap<F extends TypeLambda> extends TypeClass<F> {
FILE: src/typeclass/Foldable.ts
type Foldable (line 15) | interface Foldable<F extends TypeLambda> extends TypeClass<F> {
FILE: src/typeclass/Invariant.ts
type Invariant (line 16) | interface Invariant<F extends TypeLambda> extends TypeClass<F> {
FILE: src/typeclass/Monad.ts
type Monad (line 12) | interface Monad<F extends TypeLambda> extends FlatMap<F>, Pointed<F> {}
FILE: src/typeclass/Monoid.ts
type Monoid (line 12) | interface Monoid<A> extends Semigroup<A> {
FILE: src/typeclass/Of.ts
type Of (line 10) | interface Of<F extends TypeLambda> extends TypeClass<F> {
FILE: src/typeclass/Order.ts
type Order (line 20) | interface Order<A> {
type OrderTypeLambda (line 28) | interface OrderTypeLambda extends TypeLambda {
FILE: src/typeclass/Pointed.ts
type Pointed (line 12) | interface Pointed<F extends TypeLambda> extends Covariant<F>, Of<F> {}
FILE: src/typeclass/Product.ts
type Product (line 13) | interface Product<F extends TypeLambda> extends SemiProduct<F>, Of<F> {
FILE: src/typeclass/SemiAlternative.ts
type SemiAlternative (line 12) | interface SemiAlternative<F extends TypeLambda> extends SemiCoproduct<F>...
FILE: src/typeclass/SemiApplicative.ts
type SemiApplicative (line 15) | interface SemiApplicative<F extends TypeLambda> extends SemiProduct<F>, ...
FILE: src/typeclass/SemiCoproduct.ts
type SemiCoproduct (line 13) | interface SemiCoproduct<F extends TypeLambda> extends Invariant<F> {
FILE: src/typeclass/SemiProduct.ts
type SemiProduct (line 14) | interface SemiProduct<F extends TypeLambda> extends Invariant<F> {
type EnforceNonEmptyRecord (line 150) | type EnforceNonEmptyRecord<R> = keyof R extends never ? never : R
FILE: src/typeclass/Semigroup.ts
type Semigroup (line 17) | interface Semigroup<A> {
type SemigroupTypeLambda (line 26) | interface SemigroupTypeLambda extends TypeLambda {
FILE: src/typeclass/Traversable.ts
type Traversable (line 12) | interface Traversable<T extends TypeLambda> extends TypeClass<T> {
FILE: src/typeclass/TraversableFilterable.ts
type TraversableFilterable (line 23) | interface TraversableFilterable<T extends TypeLambda> extends TypeClass<...
FILE: test/Either.ts
type A (line 97) | type A = { readonly type: "A" }
type B (line 98) | type B = { readonly type: "B" }
type C (line 99) | type C = A | B
FILE: test/Option.ts
type A (line 107) | type A = { readonly type: "A" }
type B (line 108) | type B = { readonly type: "B" }
type C (line 109) | type C = A | B
type X (line 378) | interface X {
type Direction (line 448) | type Direction = "asc" | "desc"
FILE: test/Predicate.ts
type NonEmptyStringBrand (line 10) | interface NonEmptyStringBrand {
type NonEmptyString (line 14) | type NonEmptyString = string & NonEmptyStringBrand
type A (line 50) | type A = {
FILE: test/ReadonlyArray.ts
type X (line 1233) | interface X {
FILE: test/index.ts
function getModuleNames (line 13) | function getModuleNames(): ReadonlyArray<string> {
FILE: test/limbo/Category.ts
type Category (line 11) | interface Category<F extends TypeLambda> extends Composable<F> {
FILE: test/limbo/Comonad.ts
type Comonad (line 11) | interface Comonad<F extends TypeLambda> extends Extendable<F> {
FILE: test/limbo/Composable.ts
type Composable (line 10) | interface Composable<F extends TypeLambda> extends TypeClass<F> {
FILE: test/limbo/Extendable.ts
type Extendable (line 11) | interface Extendable<F extends TypeLambda> extends Covariant<F> {
FILE: test/limbo/NonEmptyTraversable.ts
type NonEmptyTraversable (line 15) | interface NonEmptyTraversable<T extends TypeLambda> extends TypeClass<T> {
FILE: test/typeclass/Equivalence.ts
type Person (line 22) | interface Person {
type T (line 34) | type T = readonly [string, number, boolean]
type T (line 52) | type T = readonly [string, number, boolean]
FILE: test/typeclass/NonEmptyTraversable.ts
type NonEmptyReadonlyArrayTypeLambda (line 20) | interface NonEmptyReadonlyArrayTypeLambda extends TypeLambda {
FILE: test/typeclass/Order.ts
type T (line 34) | type T = [number, string]
type T (line 77) | type T = [number, string]
type A (line 161) | type A = { a: number }
type A (line 176) | type A = { a: number }
FILE: test/typeclass/Semigroup.ts
type Item (line 44) | type Item = { a: number }
type Item (line 60) | type Item = { a: number }
Condensed preview — 208 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,227K chars).
[
{
"path": ".babel.cjs.json",
"chars": 82,
"preview": "{\n \"plugins\": [[\"@babel/transform-modules-commonjs\"], [\"annotate-pure-calls\"]]\n}\n"
},
{
"path": ".babel.mjs.json",
"chars": 43,
"preview": "{\n \"plugins\": [[\"annotate-pure-calls\"]]\n}\n"
},
{
"path": ".changeset/README.md",
"chars": 510,
"preview": "# Changesets\n\nHello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that wo"
},
{
"path": ".changeset/beige-numbers-exist.md",
"chars": 51,
"preview": "---\n\"@fp-ts/core\": patch\n---\n\nTuple: add more APIs\n"
},
{
"path": ".changeset/config.json",
"chars": 291,
"preview": "{\n \"$schema\": \"https://unpkg.com/@changesets/config@1.6.4/schema.json\",\n \"changelog\": [\"@changesets/changelog-github\","
},
{
"path": ".changeset/famous-spies-attend.md",
"chars": 79,
"preview": "---\n\"@fp-ts/core\": patch\n---\n\nexport productAll from Option, Either, Predicate\n"
},
{
"path": ".changeset/flat-news-whisper.md",
"chars": 70,
"preview": "---\n\"@fp-ts/core\": patch\n---\n\nfix bounds flipping in reverse function\n"
},
{
"path": ".changeset/hungry-comics-kneel.md",
"chars": 61,
"preview": "---\n\"@fp-ts/core\": patch\n---\n\nFunction: swap apply arguments\n"
},
{
"path": ".changeset/mighty-meals-dream.md",
"chars": 86,
"preview": "---\n\"@fp-ts/core\": patch\n---\n\nadd missing boolean semigroups, monoids and combinators\n"
},
{
"path": ".changeset/odd-hornets-wave.md",
"chars": 65,
"preview": "---\n\"@fp-ts/core\": patch\n---\n\nBigint: feature parity with Number\n"
},
{
"path": ".changeset/sour-suits-press.md",
"chars": 83,
"preview": "---\n\"@fp-ts/core\": patch\n---\n\nNumber: add missing functions (derivable from Order)\n"
},
{
"path": ".changeset/tough-planets-lick.md",
"chars": 75,
"preview": "---\n\"@fp-ts/core\": patch\n---\n\nReadonlyRecord: map: add support for structs\n"
},
{
"path": ".eslintrc.cjs",
"chars": 2758,
"preview": "/* eslint-disable no-undef */\nmodule.exports = {\n ignorePatterns: [\"build\", \"dist\", \"dtslint\", \"benchmark\", \"*.mjs\", \"d"
},
{
"path": ".github/CONTRIBUTING.md",
"chars": 1746,
"preview": "# Contributing to `@fp-ts/core`\n\nWe welcome all contributions to the `@fp-ts/core` library. Your help makes the library "
},
{
"path": ".github/FUNDING.yml",
"chars": 17,
"preview": "github: [gcanti]\n"
},
{
"path": ".github/ISSUE_TEMPLATE/Bug_report.md",
"chars": 970,
"preview": "# Bug Report\n\nThank you for reporting a bug in `@fp-ts/core`. Your contribution to this project is greatly appreciated a"
},
{
"path": ".github/ISSUE_TEMPLATE/Documentation.md",
"chars": 816,
"preview": "# Improving Documentation\n\nWe welcome all suggestions and improvements to the documentation of `@fp-ts/core`. Your contr"
},
{
"path": ".github/ISSUE_TEMPLATE/Feature_request.md",
"chars": 741,
"preview": "# Feature Request\n\nThank you for submitting a feature request for `@fp-ts/core`. Your contributions help shape the futur"
},
{
"path": ".github/PULL_REQUEST_TEMPLATE.md",
"chars": 873,
"preview": "# Pull Request Template\n\n## Description\n\nPlease describe the changes you have made and the purpose of the changes. If ap"
},
{
"path": ".github/workflows/main.yml",
"chars": 1538,
"preview": "name: Main Flow\n\non:\n push:\n branches: [main]\n\n # Allows you to run this workflow manually from the Actions tab\n w"
},
{
"path": ".github/workflows/pr.yml",
"chars": 1233,
"preview": "name: PR Flow\n\non:\n pull_request:\n branches:\n - 'main'\n\n # Allows you to run this workflow manually from the A"
},
{
"path": ".gitignore",
"chars": 105,
"preview": "coverage/\n*.tsbuildinfo\nnode_modules/\nyarn-error.log\n.ultra.cache.json\n.DS_Store\ntmp/\nbuild/\ndist/\n.idea/"
},
{
"path": ".gitpod.yml",
"chars": 154,
"preview": "tasks:\n - init: npm install -g pnpm && pnpm && pnpm run build\ngithub:\n prebuilds:\n addCheck: true\nvscode:\n extensi"
},
{
"path": ".vscode/settings.json",
"chars": 1342,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\",\n \"typescript.preferences.importModuleSpecifier\": \"non-relative\",\n"
},
{
"path": ".vscode/tasks.json",
"chars": 829,
"preview": "{\n \"version\": \"2.0.0\",\n \"tasks\": [\n {\n \"label\": \"clean\",\n \"type\": \"shell\",\n \"command\": \"yarn clean\","
},
{
"path": "CHANGELOG.md",
"chars": 14384,
"preview": "# @fp-ts/core\n\n## 0.2.1\n\n### Patch Changes\n\n- [#59](https://github.com/fp-ts/core/pull/59) [`5efa9c03`](https://github.c"
},
{
"path": "LICENSE",
"chars": 1077,
"preview": "MIT License\n\nCopyright (c) 2017-present Giulio Canti\n\nPermission is hereby granted, free of charge, to any person obtain"
},
{
"path": "README.md",
"chars": 262,
"preview": "**Announcement**: following the [official decision](https://dev.to/effect-ts/a-bright-future-for-effect-455m) to merge t"
},
{
"path": "benchmark/Number/lessThan.ts",
"chars": 706,
"preview": "import { dual } from \"@fp-ts/core/Function\";\nimport { lessThan } from \"@fp-ts/core/Number\"\nimport * as Benchmark from \"b"
},
{
"path": "benchmark/These/product.ts",
"chars": 543,
"preview": "import { Product, right, fail } from \"@fp-ts/core/These\"\nimport * as Benchmark from \"benchmark\"\n\n/*\n*/\n\nconst suite = ne"
},
{
"path": "benchmark/dual.ts",
"chars": 922,
"preview": "import { sum } from \"@fp-ts/core/Number\"\nimport * as Benchmark from \"benchmark\"\n\n/*\nsum(a, b) x 39,807,035 ops/sec ±0.79"
},
{
"path": "benchmark/sumAll.ts",
"chars": 749,
"preview": "import { fromIterable } from \"@fp-ts/core/internal/ReadonlyArray\"\nimport { sumAll } from \"@fp-ts/core/Number\"\nimport * a"
},
{
"path": "benchmark/tsconfig.json",
"chars": 270,
"preview": "{\n \"compilerOptions\": {\n \"strict\": true,\n \"module\": \"commonjs\",\n \"paths\": {\n \"@fp-ts/core\": [\"../src/inde"
},
{
"path": "docs/_config.yml",
"chars": 301,
"preview": "remote_theme: mikearnaldi/just-the-docs\n\n# Enable or disable the site search\nsearch_enabled: true\n\n# Aux links for the u"
},
{
"path": "docs/_sass/custom/custom.scss",
"chars": 120,
"preview": "$fp-ts-blue-000: #0088e6;\n$fp-ts-blue-100: #0075c5;\n\n$link-color: $fp-ts-blue-000;\n$btn-primary-color: $fp-ts-blue-100;\n"
},
{
"path": "docs/index.md",
"chars": 529,
"preview": "---\ntitle: Introduction\npermalink: /\nnav_order: 1\nhas_children: false\nhas_toc: false\n---\n\n<img alt=\"fp-ts logo\" src=\"./f"
},
{
"path": "docs/modules/Bigint.ts.md",
"chars": 10669,
"preview": "---\ntitle: Bigint.ts\nnav_order: 1\nparent: Modules\n---\n\n## Bigint overview\n\nThis module provides utility functions and ty"
},
{
"path": "docs/modules/Boolean.ts.md",
"chars": 9626,
"preview": "---\ntitle: Boolean.ts\nnav_order: 2\nparent: Modules\n---\n\n## Boolean overview\n\nThis module provides utility functions and "
},
{
"path": "docs/modules/Either.ts.md",
"chars": 33912,
"preview": "---\ntitle: Either.ts\nnav_order: 3\nparent: Modules\n---\n\n## Either overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">"
},
{
"path": "docs/modules/Function.ts.md",
"chars": 16135,
"preview": "---\ntitle: Function.ts\nnav_order: 4\nparent: Modules\n---\n\n## Function overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-del"
},
{
"path": "docs/modules/HKT.ts.md",
"chars": 1134,
"preview": "---\ntitle: HKT.ts\nnav_order: 5\nparent: Modules\n---\n\n## HKT overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Table "
},
{
"path": "docs/modules/Identity.ts.md",
"chars": 5058,
"preview": "---\ntitle: Identity.ts\nnav_order: 6\nparent: Modules\n---\n\n## Identity overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-del"
},
{
"path": "docs/modules/Number.ts.md",
"chars": 12012,
"preview": "---\ntitle: Number.ts\nnav_order: 8\nparent: Modules\n---\n\n## Number overview\n\nThis module provides utility functions and ty"
},
{
"path": "docs/modules/Option.ts.md",
"chars": 40176,
"preview": "---\ntitle: Option.ts\nnav_order: 9\nparent: Modules\n---\n\n## Option overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">"
},
{
"path": "docs/modules/Ordering.ts.md",
"chars": 2590,
"preview": "---\ntitle: Ordering.ts\nnav_order: 10\nparent: Modules\n---\n\n## Ordering overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-de"
},
{
"path": "docs/modules/Predicate.ts.md",
"chars": 16321,
"preview": "---\ntitle: Predicate.ts\nnav_order: 11\nparent: Modules\n---\n\n## Predicate overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-"
},
{
"path": "docs/modules/ReadonlyArray.ts.md",
"chars": 52794,
"preview": "---\ntitle: ReadonlyArray.ts\nnav_order: 12\nparent: Modules\n---\n\n## ReadonlyArray overview\n\nThis module provides utility f"
},
{
"path": "docs/modules/ReadonlyRecord.ts.md",
"chars": 18368,
"preview": "---\ntitle: ReadonlyRecord.ts\nnav_order: 13\nparent: Modules\n---\n\n## ReadonlyRecord overview\n\nThis module provides utility"
},
{
"path": "docs/modules/String.ts.md",
"chars": 9634,
"preview": "---\ntitle: String.ts\nnav_order: 14\nparent: Modules\n---\n\n## String overview\n\nThis module provides utility functions and t"
},
{
"path": "docs/modules/Struct.ts.md",
"chars": 4989,
"preview": "---\ntitle: Struct.ts\nnav_order: 15\nparent: Modules\n---\n\n## Struct overview\n\nThis module provides utility functions for w"
},
{
"path": "docs/modules/Symbol.ts.md",
"chars": 725,
"preview": "---\ntitle: Symbol.ts\nnav_order: 16\nparent: Modules\n---\n\n## Symbol overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\""
},
{
"path": "docs/modules/These.ts.md",
"chars": 38489,
"preview": "---\ntitle: These.ts\nnav_order: 17\nparent: Modules\n---\n\n## These overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">T"
},
{
"path": "docs/modules/Tuple.ts.md",
"chars": 6690,
"preview": "---\ntitle: Tuple.ts\nnav_order: 18\nparent: Modules\n---\n\n## Tuple overview\n\nThis module provides utility functions for wor"
},
{
"path": "docs/modules/index.md",
"chars": 79,
"preview": "---\ntitle: Modules\nhas_children: true\npermalink: /docs/modules\nnav_order: 2\n---"
},
{
"path": "docs/modules/index.ts.md",
"chars": 5911,
"preview": "---\ntitle: index.ts\nnav_order: 7\nparent: Modules\n---\n\n## index overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delta\">Ta"
},
{
"path": "docs/modules/typeclass/Alternative.ts.md",
"chars": 432,
"preview": "---\ntitle: typeclass/Alternative.ts\nnav_order: 19\nparent: Modules\n---\n\n## Alternative overview\n\nAdded in v1.0.0\n\n---\n\n<h"
},
{
"path": "docs/modules/typeclass/Applicative.ts.md",
"chars": 859,
"preview": "---\ntitle: typeclass/Applicative.ts\nnav_order: 20\nparent: Modules\n---\n\n## Applicative overview\n\nAdded in v1.0.0\n\n---\n\n<h"
},
{
"path": "docs/modules/typeclass/Bicovariant.ts.md",
"chars": 1894,
"preview": "---\ntitle: typeclass/Bicovariant.ts\nnav_order: 21\nparent: Modules\n---\n\n## Bicovariant overview\n\nAdded in v1.0.0\n\n---\n\n<h"
},
{
"path": "docs/modules/typeclass/Bounded.ts.md",
"chars": 1700,
"preview": "---\ntitle: typeclass/Bounded.ts\nnav_order: 22\nparent: Modules\n---\n\n## Bounded overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class="
},
{
"path": "docs/modules/typeclass/Chainable.ts.md",
"chars": 2333,
"preview": "---\ntitle: typeclass/Chainable.ts\nnav_order: 23\nparent: Modules\n---\n\n## Chainable overview\n\nAdded in v1.0.0\n\n---\n\n<h2 cl"
},
{
"path": "docs/modules/typeclass/Contravariant.ts.md",
"chars": 1646,
"preview": "---\ntitle: typeclass/Contravariant.ts\nnav_order: 24\nparent: Modules\n---\n\n## Contravariant overview\n\nAdded in v1.0.0\n\n---"
},
{
"path": "docs/modules/typeclass/Coproduct.ts.md",
"chars": 803,
"preview": "---\ntitle: typeclass/Coproduct.ts\nnav_order: 25\nparent: Modules\n---\n\n## Coproduct overview\n\nAdded in v1.0.0\n\n---\n\n<h2 cl"
},
{
"path": "docs/modules/typeclass/Covariant.ts.md",
"chars": 2963,
"preview": "---\ntitle: typeclass/Covariant.ts\nnav_order: 26\nparent: Modules\n---\n\n## Covariant overview\n\nAdded in v1.0.0\n\n---\n\n<h2 cl"
},
{
"path": "docs/modules/typeclass/Equivalence.ts.md",
"chars": 4380,
"preview": "---\ntitle: typeclass/Equivalence.ts\nnav_order: 27\nparent: Modules\n---\n\n## Equivalence overview\n\nThis module provides an "
},
{
"path": "docs/modules/typeclass/Filterable.ts.md",
"chars": 3923,
"preview": "---\ntitle: typeclass/Filterable.ts\nnav_order: 28\nparent: Modules\n---\n\n## Filterable overview\n\n`Filterable` represents da"
},
{
"path": "docs/modules/typeclass/FlatMap.ts.md",
"chars": 2136,
"preview": "---\ntitle: typeclass/FlatMap.ts\nnav_order: 29\nparent: Modules\n---\n\n## FlatMap overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class="
},
{
"path": "docs/modules/typeclass/Foldable.ts.md",
"chars": 2809,
"preview": "---\ntitle: typeclass/Foldable.ts\nnav_order: 30\nparent: Modules\n---\n\n## Foldable overview\n\nAdded in v1.0.0\n\n---\n\n<h2 clas"
},
{
"path": "docs/modules/typeclass/Invariant.ts.md",
"chars": 2306,
"preview": "---\ntitle: typeclass/Invariant.ts\nnav_order: 31\nparent: Modules\n---\n\n## Invariant overview\n\nThe `Invariant` typeclass is"
},
{
"path": "docs/modules/typeclass/Monad.ts.md",
"chars": 386,
"preview": "---\ntitle: typeclass/Monad.ts\nnav_order: 32\nparent: Modules\n---\n\n## Monad overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"tex"
},
{
"path": "docs/modules/typeclass/Monoid.ts.md",
"chars": 5219,
"preview": "---\ntitle: typeclass/Monoid.ts\nnav_order: 33\nparent: Modules\n---\n\n## Monoid overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"t"
},
{
"path": "docs/modules/typeclass/Of.ts.md",
"chars": 1146,
"preview": "---\ntitle: typeclass/Of.ts\nnav_order: 34\nparent: Modules\n---\n\n## Of overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"text-delt"
},
{
"path": "docs/modules/typeclass/Order.ts.md",
"chars": 6667,
"preview": "---\ntitle: typeclass/Order.ts\nnav_order: 35\nparent: Modules\n---\n\n## Order overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class=\"tex"
},
{
"path": "docs/modules/typeclass/Pointed.ts.md",
"chars": 395,
"preview": "---\ntitle: typeclass/Pointed.ts\nnav_order: 36\nparent: Modules\n---\n\n## Pointed overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class="
},
{
"path": "docs/modules/typeclass/Product.ts.md",
"chars": 1597,
"preview": "---\ntitle: typeclass/Product.ts\nnav_order: 37\nparent: Modules\n---\n\n## Product overview\n\nAdded in v1.0.0\n\n---\n\n<h2 class="
},
{
"path": "docs/modules/typeclass/SemiAlternative.ts.md",
"chars": 454,
"preview": "---\ntitle: typeclass/SemiAlternative.ts\nnav_order: 38\nparent: Modules\n---\n\n## SemiAlternative overview\n\nAdded in v1.0.0\n"
},
{
"path": "docs/modules/typeclass/SemiApplicative.ts.md",
"chars": 3396,
"preview": "---\ntitle: typeclass/SemiApplicative.ts\nnav_order: 39\nparent: Modules\n---\n\n## SemiApplicative overview\n\nAdded in v1.0.0\n"
},
{
"path": "docs/modules/typeclass/SemiCoproduct.ts.md",
"chars": 996,
"preview": "---\ntitle: typeclass/SemiCoproduct.ts\nnav_order: 40\nparent: Modules\n---\n\n## SemiCoproduct overview\n\nAdded in v1.0.0\n\n---"
},
{
"path": "docs/modules/typeclass/SemiProduct.ts.md",
"chars": 5152,
"preview": "---\ntitle: typeclass/SemiProduct.ts\nnav_order: 42\nparent: Modules\n---\n\n## SemiProduct overview\n\nAdded in v1.0.0\n\n---\n\n<h"
},
{
"path": "docs/modules/typeclass/Semigroup.ts.md",
"chars": 6542,
"preview": "---\ntitle: typeclass/Semigroup.ts\nnav_order: 41\nparent: Modules\n---\n\n## Semigroup overview\n\nAdded in v1.0.0\n\n---\n\n<h2 cl"
},
{
"path": "docs/modules/typeclass/Traversable.ts.md",
"chars": 2526,
"preview": "---\ntitle: typeclass/Traversable.ts\nnav_order: 43\nparent: Modules\n---\n\n## Traversable overview\n\nAdded in v1.0.0\n\n---\n\n<h"
},
{
"path": "docs/modules/typeclass/TraversableFilterable.ts.md",
"chars": 3845,
"preview": "---\ntitle: typeclass/TraversableFilterable.ts\nnav_order: 44\nparent: Modules\n---\n\n## TraversableFilterable overview\n\n`Tra"
},
{
"path": "docs-ts.json",
"chars": 82,
"preview": "{\n \"exclude\": [\"src/internal/**/*.ts\"],\n \"theme\": \"mikearnaldi/just-the-docs\"\n}\n"
},
{
"path": "dtslint/index.d.ts",
"chars": 27,
"preview": "// TypeScript Version: 4.8\n"
},
{
"path": "dtslint/ts4.8/FlatMap.ts",
"chars": 559,
"preview": "import * as _ from \"@fp-ts/core/typeclass/FlatMap\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport { pipe } fro"
},
{
"path": "dtslint/ts4.8/Monoid.ts",
"chars": 394,
"preview": "import * as _ from \"@fp-ts/core/typeclass/Monoid\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as String from \""
},
{
"path": "dtslint/ts4.8/Option.ts",
"chars": 2233,
"preview": "import { pipe } from '@fp-ts/core/Function'\nimport * as _ from '@fp-ts/core/Option'\n\ndeclare const n: number\ndeclare con"
},
{
"path": "dtslint/ts4.8/Predicate.ts",
"chars": 5434,
"preview": "import * as _ from '@fp-ts/core/Predicate'\n\ndeclare const u: unknown\ndeclare const anys: Array<any>\ndeclare const unknow"
},
{
"path": "dtslint/ts4.8/Product.ts",
"chars": 898,
"preview": "import * as _ from \"@fp-ts/core/typeclass/Product\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\n\ninterface RAW<R, E"
},
{
"path": "dtslint/ts4.8/ReadonlyArray.ts",
"chars": 2591,
"preview": "import { pipe } from '@fp-ts/core/Function'\nimport * as RA from '@fp-ts/core/ReadonlyArray'\nimport * as O from '@fp-ts/c"
},
{
"path": "dtslint/ts4.8/ReadonlyRecord.ts",
"chars": 1459,
"preview": "import { pipe } from '@fp-ts/core/Function'\nimport * as RR from '@fp-ts/core/ReadonlyRecord'\n\ndeclare const r: Record<st"
},
{
"path": "dtslint/ts4.8/SemiAlternative.ts",
"chars": 618,
"preview": "import * as _ from \"@fp-ts/core/typeclass/SemiAlternative\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport { pi"
},
{
"path": "dtslint/ts4.8/SemiProduct.ts",
"chars": 342,
"preview": "import { OptionTypeLambda } from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/typeclass/SemiProduct\"\n\nexport dec"
},
{
"path": "dtslint/ts4.8/Semigroup.ts",
"chars": 415,
"preview": "import * as _ from \"@fp-ts/core/typeclass/Semigroup\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as String fro"
},
{
"path": "dtslint/ts4.8/Tuple.ts",
"chars": 274,
"preview": "import * as T from '@fp-ts/core/Tuple'\nimport { pipe } from '@fp-ts/core/Function'\n\n//\n// tuple\n//\n\n// $ExpectType [stri"
},
{
"path": "dtslint/ts4.8/index.d.ts",
"chars": 0,
"preview": ""
},
{
"path": "dtslint/ts4.8/index.ts",
"chars": 218,
"preview": "import * as _ from '../../src/HKT'\n\n// issue #536\nfunction testIssue536<F extends _.TypeLambda, G extends _.TypeLambda, "
},
{
"path": "dtslint/ts4.8/tsconfig.json",
"chars": 608,
"preview": "{\n \"compilerOptions\": {\n \"noEmit\": true,\n \"strict\": true,\n \"noImplicitAny\": false,\n \"noImplicitThis\": true,"
},
{
"path": "dtslint/ts4.8/tslint.json",
"chars": 716,
"preview": "{\n \"extends\": \"dtslint/dtslint.json\",\n \"rules\": {\n \"no-duplicate-imports\": false,\n \"semicolon\": false,\n \"arra"
},
{
"path": "guides/Either.md",
"chars": 30893,
"preview": "# The `Either` data type\n\nThe `Either` data type is a powerful and flexible tool for handling potentially failed computa"
},
{
"path": "guides/FAQ.md",
"chars": 2349,
"preview": "# FAQ\n\n## HKT implementation\n\n**What’s that second branch of conditional type in `Kind` type?**\n\nThat's to enforce varia"
},
{
"path": "guides/Option.md",
"chars": 32930,
"preview": "# The `Option` data type\n\nThe `Option` data type represents an optional value: every `Option` is either `Some` and conta"
},
{
"path": "guides/These.md",
"chars": 785,
"preview": "# The `These` data type\n\n## A data structure providing \"inclusive-or\" as opposed to `Either`'s \"exclusive-or\".\n\nIf you i"
},
{
"path": "guides/ts-types.md",
"chars": 11571,
"preview": "# Standard TypeScript types\n\n## strings\n\n| Module | Name | Given | To |\n| -------"
},
{
"path": "guides/typeclass.md",
"chars": 19173,
"preview": "# Introduction\n\nThe functional abstractions in `@fp-ts/core` can be broadly divided into two categories.\n\n- Abstractions"
},
{
"path": "package.json",
"chars": 3807,
"preview": "{\n \"name\": \"@fp-ts/core\",\n \"version\": \"0.2.1\",\n \"publishConfig\": {\n \"access\": \"public\",\n \"directory\": \"dist\"\n "
},
{
"path": "patches/@effect-ts__build-utils@0.40.3.patch",
"chars": 6026,
"preview": "diff --git a/pack-v3.js b/pack-v3.js\nindex c12e36a7f85c59e8d219df0eec1001c495be4f64..129b8d678ff6796f9a3d78056da47b5f2d9"
},
{
"path": "patches/docs-ts@0.6.10.patch",
"chars": 2496,
"preview": "diff --git a/lib/Core.js b/lib/Core.js\nindex c0f282ca9e3ddd93e44a62e1d05c1cc45b9f5c6a..616f7f6223459e0621522279ea7fc1cf1"
},
{
"path": "src/Bigint.ts",
"chars": 11846,
"preview": "/**\n * This module provides utility functions and type class instances for working with the `bigint` type in TypeScript."
},
{
"path": "src/Boolean.ts",
"chars": 10221,
"preview": "/**\n * This module provides utility functions and type class instances for working with the `boolean` type in TypeScript"
},
{
"path": "src/Either.ts",
"chars": 40067,
"preview": "/**\n * @since 1.0.0\n */\n\nimport type { LazyArg } from \"@fp-ts/core/Function\"\nimport { constNull, constUndefined, dual, i"
},
{
"path": "src/Function.ts",
"chars": 17895,
"preview": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\n\n/**\n * @category type lambdas\n * @since 1.0.0"
},
{
"path": "src/HKT.ts",
"chars": 746,
"preview": "/**\n * @since 1.0.0\n */\n\n/**\n * @since 1.0.0\n */\nexport declare const URI: unique symbol\n\n/**\n * @since 1.0.0\n */\nexport"
},
{
"path": "src/Identity.ts",
"chars": 7281,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp"
},
{
"path": "src/Number.ts",
"chars": 13821,
"preview": "/**\n * This module provides utility functions and type class instances for working with the `number` type in TypeScript."
},
{
"path": "src/Option.ts",
"chars": 49253,
"preview": "/**\n * @since 1.0.0\n */\nimport type { Either } from \"@fp-ts/core/Either\"\nimport type { LazyArg } from \"@fp-ts/core/Funct"
},
{
"path": "src/Ordering.ts",
"chars": 3326,
"preview": "/**\n * @since 1.0.0\n */\nimport type { LazyArg } from \"@fp-ts/core/Function\"\nimport { dual } from \"@fp-ts/core/Function\"\n"
},
{
"path": "src/Predicate.ts",
"chars": 18944,
"preview": "/**\n * @since 1.0.0\n */\nimport { constFalse, constTrue, dual, isFunction as isFunction_ } from \"@fp-ts/core/Function\"\nim"
},
{
"path": "src/ReadonlyArray.ts",
"chars": 68167,
"preview": "/**\n * This module provides utility functions for working with arrays in TypeScript.\n *\n * @since 1.0.0\n */\n\nimport type"
},
{
"path": "src/ReadonlyRecord.ts",
"chars": 24991,
"preview": "/**\n * This module provides utility functions for working with records in TypeScript.\n *\n * @since 1.0.0\n */\n\nimport typ"
},
{
"path": "src/String.ts",
"chars": 13669,
"preview": "/**\n * This module provides utility functions and type class instances for working with the `string` type in TypeScript."
},
{
"path": "src/Struct.ts",
"chars": 5206,
"preview": "/**\n * This module provides utility functions for working with structs in TypeScript.\n *\n * @since 1.0.0\n */\n\nimport * a"
},
{
"path": "src/Symbol.ts",
"chars": 640,
"preview": "/**\n * @since 1.0.0\n */\n\nimport * as predicate from \"@fp-ts/core/Predicate\"\nimport * as equivalence from \"@fp-ts/core/ty"
},
{
"path": "src/These.ts",
"chars": 44505,
"preview": "/**\n * @since 1.0.0\n */\n\nimport type { Either, Left, Right } from \"@fp-ts/core/Either\"\nimport * as E from \"@fp-ts/core/E"
},
{
"path": "src/Tuple.ts",
"chars": 6862,
"preview": "/**\n * This module provides utility functions for working with tuples in TypeScript.\n *\n * @since 1.0.0\n */\nimport { dua"
},
{
"path": "src/index.ts",
"chars": 5538,
"preview": "/**\n * @since 1.0.0\n */\n\n// -------------------------------------------------------------------------------------\n// HKT"
},
{
"path": "src/internal/Either.ts",
"chars": 1211,
"preview": "/**\n * @since 1.0.0\n */\n\nimport type { Either, Left, Right } from \"@fp-ts/core/Either\"\nimport { dual } from \"@fp-ts/core"
},
{
"path": "src/internal/Option.ts",
"chars": 546,
"preview": "/**\n * @since 1.0.0\n */\n\nimport { proto } from \"@fp-ts/core/internal/effect\"\nimport type { None, Option, Some } from \"@f"
},
{
"path": "src/internal/ReadonlyArray.ts",
"chars": 366,
"preview": "/**\n * @since 1.0.0\n */\n\nimport type { NonEmptyArray } from \"@fp-ts/core/ReadonlyArray\"\n\n/** @internal */\nexport const i"
},
{
"path": "src/internal/effect.ts",
"chars": 215,
"preview": "/**\n * @since 1.0.0\n */\n\n/** @internal */\nexport const structural = Symbol.for(\"@effect/data/Equal/structural\")\n\n/** @in"
},
{
"path": "src/typeclass/Alternative.ts",
"chars": 360,
"preview": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Coproduct } from \"@fp-ts/core/ty"
},
{
"path": "src/typeclass/Applicative.ts",
"chars": 1098,
"preview": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Monoid } from \"@fp-ts/core"
},
{
"path": "src/typeclass/Bicovariant.ts",
"chars": 1834,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda "
},
{
"path": "src/typeclass/Bounded.ts",
"chars": 1667,
"preview": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Monoid } from \"@fp-ts/core/typec"
},
{
"path": "src/typeclass/Chainable.ts",
"chars": 2790,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/H"
},
{
"path": "src/typeclass/Contravariant.ts",
"chars": 1288,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/H"
},
{
"path": "src/typeclass/Coproduct.ts",
"chars": 831,
"preview": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Monoid } from \"@fp-ts/core"
},
{
"path": "src/typeclass/Covariant.ts",
"chars": 3018,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/H"
},
{
"path": "src/typeclass/Equivalence.ts",
"chars": 5853,
"preview": "/**\n * This module provides an implementation of the `Equivalence` type class, which defines a binary relation\n * that i"
},
{
"path": "src/typeclass/Filterable.ts",
"chars": 4393,
"preview": "/**\n * `Filterable` represents data structures which can be _partitioned_/_filtered_.\n *\n * @since 1.0.0\n */\nimport type"
},
{
"path": "src/typeclass/FlatMap.ts",
"chars": 2200,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda "
},
{
"path": "src/typeclass/Foldable.ts",
"chars": 3373,
"preview": "/**\n * @since 1.0.0\n */\n\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda"
},
{
"path": "src/typeclass/Invariant.ts",
"chars": 2288,
"preview": "/**\n * The `Invariant` typeclass is a higher-order abstraction over types that allow mapping the contents of a type in b"
},
{
"path": "src/typeclass/Monad.ts",
"chars": 324,
"preview": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { FlatMap } from \"@fp-ts/core/type"
},
{
"path": "src/typeclass/Monoid.ts",
"chars": 5589,
"preview": "/**\n * @since 1.0.0\n */\nimport type { Bounded } from \"@fp-ts/core/typeclass/Bounded\"\nimport type { Semigroup } from \"@fp"
},
{
"path": "src/typeclass/Of.ts",
"chars": 831,
"preview": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\n\n/**\n * @category type class\n"
},
{
"path": "src/typeclass/Order.ts",
"chars": 8858,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nim"
},
{
"path": "src/typeclass/Pointed.ts",
"chars": 317,
"preview": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/ty"
},
{
"path": "src/typeclass/Product.ts",
"chars": 1738,
"preview": "/**\n * @since 1.0.0\n */\n\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Of } from \"@fp-ts/core/ty"
},
{
"path": "src/typeclass/SemiAlternative.ts",
"chars": 358,
"preview": "/**\n * @since 1.0.0\n */\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/core/ty"
},
{
"path": "src/typeclass/SemiApplicative.ts",
"chars": 4546,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual, identity, SK } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from "
},
{
"path": "src/typeclass/SemiCoproduct.ts",
"chars": 872,
"preview": "/**\n * @since 1.0.0\n */\n\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Invariant } from \"@fp-ts/"
},
{
"path": "src/typeclass/SemiProduct.ts",
"chars": 6021,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambda } from \"@fp-ts/core/H"
},
{
"path": "src/typeclass/Semigroup.ts",
"chars": 8968,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual } from \"@fp-ts/core/Function\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nim"
},
{
"path": "src/typeclass/Traversable.ts",
"chars": 2507,
"preview": "/**\n * @since 1.0.0\n */\nimport { dual, identity } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeClass, TypeLambda "
},
{
"path": "src/typeclass/TraversableFilterable.ts",
"chars": 4492,
"preview": "/**\n * `TraversableFilterable` represents data structures which can be _partitioned_ with effects in some `Applicative` "
},
{
"path": "test/Bigint.ts",
"chars": 2425,
"preview": "import * as Bigint from \"@fp-ts/core/Bigint\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport { deepStrictEqual } from"
},
{
"path": "test/Boolean.ts",
"chars": 7469,
"preview": "import * as Boolean from \"@fp-ts/core/Boolean\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport { deepStrictEqual } fr"
},
{
"path": "test/Either.ts",
"chars": 18903,
"preview": "import * as E from \"@fp-ts/core/Either\"\nimport { flow, identity, pipe } from \"@fp-ts/core/Function\"\nimport { structural "
},
{
"path": "test/Function.ts",
"chars": 4398,
"preview": "import * as _ from \"@fp-ts/core/Function\"\nimport * as String from \"@fp-ts/core/String\"\nimport { deepStrictEqual, double "
},
{
"path": "test/Identity.ts",
"chars": 2208,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as _ from \"@fp-ts/core/Identity\"\nimport * as O from \"@fp-ts/core/Op"
},
{
"path": "test/Number.ts",
"chars": 3472,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport { deepStrictEqual } from"
},
{
"path": "test/Option.ts",
"chars": 19810,
"preview": "import { equivalence } from \"@fp-ts/core\"\nimport * as E from \"@fp-ts/core/Either\"\nimport { pipe } from \"@fp-ts/core/Func"
},
{
"path": "test/Ordering.ts",
"chars": 1512,
"preview": "import * as _ from \"@fp-ts/core/Ordering\"\nimport { deepStrictEqual } from \"./util\"\n\ndescribe(\"Ordering\", () => {\n it(\"m"
},
{
"path": "test/Predicate.ts",
"chars": 8095,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as _ from \"@fp-ts/core/Predicate\"\nimport { deepStrictEqual } from \""
},
{
"path": "test/ReadonlyArray.ts",
"chars": 53341,
"preview": "import * as E from \"@fp-ts/core/Either\"\nimport { identity, pipe } from \"@fp-ts/core/Function\"\nimport * as Number from \"@"
},
{
"path": "test/ReadonlyRecord.ts",
"chars": 6952,
"preview": "import * as E from \"@fp-ts/core/Either\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Opti"
},
{
"path": "test/String.ts",
"chars": 5900,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as S from \"@fp-ts/core/String\"\nimport { deepStrictEqual } from \"@fp"
},
{
"path": "test/Struct.ts",
"chars": 511,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as S from \"@fp-ts/core/Struct\"\n\ndescribe.concurrent(\"Struct\", () =>"
},
{
"path": "test/Symbol.ts",
"chars": 605,
"preview": "import * as S from \"@fp-ts/core/Symbol\"\n\ndescribe.concurrent(\"Symbol\", () => {\n it(\"isSymbol\", () => {\n expect(S.isS"
},
{
"path": "test/These.ts",
"chars": 30979,
"preview": "import * as E from \"@fp-ts/core/Either\"\nimport { identity, pipe } from \"@fp-ts/core/Function\"\nimport { structural } from"
},
{
"path": "test/Tuple.ts",
"chars": 975,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as T from \"@fp-ts/core/Tuple\"\n\ndescribe.concurrent(\"Tuple\", () => {"
},
{
"path": "test/index.ts",
"chars": 1047,
"preview": "import * as _ from \"@fp-ts/core\"\nimport * as assert from \"assert\"\nimport * as glob from \"glob\"\nimport * as path from \"pa"
},
{
"path": "test/limbo/Category.ts",
"chars": 308,
"preview": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Composable } from \"./Compo"
},
{
"path": "test/limbo/Comonad.ts",
"chars": 335,
"preview": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Extendable } from \"@fp-ts/"
},
{
"path": "test/limbo/Composable.ts",
"chars": 362,
"preview": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeClass, TypeLambda } from \"@fp-ts/core/HKT\"\n\n/**\n * @category type class\n"
},
{
"path": "test/limbo/Extendable.ts",
"chars": 403,
"preview": "/**\n * @since 1.0.0\n */\nimport type { Kind, TypeLambda } from \"@fp-ts/core/HKT\"\nimport type { Covariant } from \"@fp-ts/c"
},
{
"path": "test/limbo/NonEmptyTraversable.ts",
"chars": 2572,
"preview": "/**\n * NonEmptyTraversable<T> describes a parameterized type T<A> that contains one or more values of type `A`.\n *\n * @s"
},
{
"path": "test/typeclass/Applicative.ts",
"chars": 577,
"preview": "import * as N from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/typeclas"
},
{
"path": "test/typeclass/Bicovariant.ts",
"chars": 1033,
"preview": "import * as E from \"@fp-ts/core/Either\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport * as RA from \"@fp-ts/core/Rea"
},
{
"path": "test/typeclass/Bounded.ts",
"chars": 616,
"preview": "import * as Number from \"@fp-ts/core/Number\"\nimport * as _ from \"@fp-ts/core/typeclass/Bounded\"\nimport * as U from \"../u"
},
{
"path": "test/typeclass/Chainable.ts",
"chars": 1151,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/type"
},
{
"path": "test/typeclass/Contravariant.ts",
"chars": 892,
"preview": "import * as P from \"@fp-ts/core/Predicate\"\nimport * as S from \"@fp-ts/core/String\"\nimport * as _ from \"@fp-ts/core/typec"
},
{
"path": "test/typeclass/Coproduct.ts",
"chars": 711,
"preview": "import * as O from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/typeclass/Coproduct\"\nimport * as U from \"../util"
},
{
"path": "test/typeclass/Covariant.ts",
"chars": 1666,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/Rea"
},
{
"path": "test/typeclass/Equivalence.ts",
"chars": 3699,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as _ from \"@fp-ts/core/typeclass/Equivalence\"\n\ndescribe(\"Equivalenc"
},
{
"path": "test/typeclass/Filterable.ts",
"chars": 2375,
"preview": "import * as E from \"@fp-ts/core/Either\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Opti"
},
{
"path": "test/typeclass/FlatMap.ts",
"chars": 1239,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as _ from \"@fp-ts/core/type"
},
{
"path": "test/typeclass/Foldable.ts",
"chars": 2103,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as N from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/core/Opti"
},
{
"path": "test/typeclass/Invariant.ts",
"chars": 1795,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as P from \"@fp-ts/core/Pred"
},
{
"path": "test/typeclass/Monoid.ts",
"chars": 1774,
"preview": "import * as N from \"@fp-ts/core/Number\"\nimport * as String from \"@fp-ts/core/String\"\nimport * as _ from \"@fp-ts/core/typ"
},
{
"path": "test/typeclass/NonEmptyTraversable.ts",
"chars": 2773,
"preview": "import { identity, pipe } from \"@fp-ts/core/Function\"\nimport type { TypeLambda } from \"@fp-ts/core/HKT\"\nimport * as O fr"
},
{
"path": "test/typeclass/Of.ts",
"chars": 398,
"preview": "import * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/core/"
},
{
"path": "test/typeclass/Order.ts",
"chars": 6503,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport { sort } from \"@fp-ts/core/ReadonlyArray\"\nimport * as _ from \"@fp-ts/"
},
{
"path": "test/typeclass/Product.ts",
"chars": 2545,
"preview": "import * as Boolean from \"@fp-ts/core/Boolean\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as O from \"@fp-ts/c"
},
{
"path": "test/typeclass/SemiApplicative.ts",
"chars": 1880,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as String from \"@fp-ts/core"
},
{
"path": "test/typeclass/SemiCoproduct.ts",
"chars": 637,
"preview": "import * as E from \"@fp-ts/core/Either\"\nimport * as _ from \"@fp-ts/core/typeclass/SemiCoproduct\"\nimport * as U from \"../"
},
{
"path": "test/typeclass/SemiProduct.ts",
"chars": 8391,
"preview": "import * as Boolean from \"@fp-ts/core/Boolean\"\nimport { pipe } from \"@fp-ts/core/Function\"\nimport type { Kind, TypeLambd"
},
{
"path": "test/typeclass/Semigroup.ts",
"chars": 4152,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as Number from \"@fp-ts/core/Number\"\nimport * as String from \"@fp-ts"
},
{
"path": "test/typeclass/Traversable.ts",
"chars": 1115,
"preview": "import { pipe } from \"@fp-ts/core/Function\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/Rea"
},
{
"path": "test/typeclass/TraversableFilterable.ts",
"chars": 3183,
"preview": "import * as E from \"@fp-ts/core/Either\"\nimport * as O from \"@fp-ts/core/Option\"\nimport * as RA from \"@fp-ts/core/Readonl"
}
]
// ... and 8 more files (download for full content)
About this extraction
This page contains the full source code of the fp-ts/core GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 208 files (1.1 MB), approximately 372.1k tokens, and a symbol index with 102 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.