https://github.com/lagunoff/typescript-concrete-optics
Very basic concrete optics in typescript
https://github.com/lagunoff/typescript-concrete-optics
functional-programming lens lenses optics prism typescript
Last synced: 2 months ago
JSON representation
Very basic concrete optics in typescript
- Host: GitHub
- URL: https://github.com/lagunoff/typescript-concrete-optics
- Owner: lagunoff
- Created: 2019-08-27T12:16:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T00:10:32.000Z (over 2 years ago)
- Last Synced: 2023-03-08T14:40:37.965Z (about 2 years ago)
- Topics: functional-programming, lens, lenses, optics, prism, typescript
- Language: TypeScript
- Homepage:
- Size: 101 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://shields.io/)
## Installation
```sh
$ yarn add typescript-concrete-optics```
## API reference
#### compose`function compose(left: Lens, right: Lens): Lens;
function compose(left: Prism, right: Prism): Prism;
function compose(left: Iso, right: Iso): Iso;
function compose(left: Iso, right: Lens): Lens;
function compose(left: Lens, right: Iso): Lens;
function compose(left: Iso, right: Prism): Prism;
function compose(left: Prism, right: Iso): Prism;
function compose(left: Optic, right: Optic): Optic;
function compose>(...args: Array>): R;`Compose several different optics. Function can receive one or more
arguments with type-aligned `Optic`s, but type signatures exist
only for two parameters.```ts
const lens = optics.identityLens();
const prism = optics.identityPrism();
const iso = optics.identityIso();assert.isTrue(optics.isLens(optics.compose(lens, lens)));
assert.isTrue(optics.isPrism(optics.compose(prism, prism)));
assert.isTrue(optics.isIso(optics.compose(iso, iso)));
assert.isTrue(optics.isLens(optics.compose(iso, lens)));
assert.isTrue(optics.isPrism(optics.compose(iso, prism)));
assert.isTrue(optics.isCompose(optics.compose(lens, prism)));
```