https://github.com/jdolle/unfun-ts
Practical helpers to unfunctionalize fp-ts types
https://github.com/jdolle/unfun-ts
fp-ts functional-programming typescript
Last synced: 7 months ago
JSON representation
Practical helpers to unfunctionalize fp-ts types
- Host: GitHub
- URL: https://github.com/jdolle/unfun-ts
- Owner: jdolle
- License: mit
- Created: 2020-02-15T09:31:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-11T17:07:32.000Z (11 months ago)
- Last Synced: 2025-04-06T11:12:40.909Z (7 months ago)
- Topics: fp-ts, functional-programming, typescript
- Language: TypeScript
- Homepage: https://jdolle.github.io/unfun-ts/
- Size: 368 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unfun-ts
[](https://codeclimate.com/github/jdolle/unfun-ts/maintainability) [](https://codeclimate.com/github/jdolle/unfun-ts/test_coverage) [](https://circleci.com/gh/jdolle/unfun-ts)
Practical helpers to unfunctionalize fp-ts types
## Description
Functional programming is powerful, but not always the most practical. This package encourages using functional programming in Typescript using [`fp-ts`](https://github.com/gcanti/fp-ts) by providing a very practical way to interact with the broader, imperative codebase.
## Install
`unfun-ts` is a utility library for `fp-ts`. Therefore `fp-ts` is a peer dependency of `unfun-ts`.
```
yarn add unfun-ts
yarn add fp-ts@^2.0.0
```
## Usage
```ts
import * as UE from "unfun-ts/lib/Either";
import * as E from "fp-ts/lib/Either";
import { pipe } from "fp-ts/lib/pipeable";
// const nullyValue: undefined | number;
try {
const value = pipe(
nullyValue,
E.fromNullable("nully"),
UE.getOrThrow(),
);
} catch (bad) {
console.error(`The value was ${bad}`);
}
```