Practical helpers to unfunctionalize fp-ts types
Functional programming is powerful, but not always the most practical. This package encourages using functional programming in Typescript using fp-ts
by providing a very practical way to interact with the broader, imperative codebase.
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
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}`);
}