A lightweight Maybe type for fp-ts
A lightweight Maybe type for fp-ts
export type Nothing = null | undefined;
export const Nothing = null as Nothing;
export type Maybe<T> = T | Nothing;
Edit: Not really. This is not a functor over nullables. I wrote about it at haspar.us/speaking/maybe-ts.
counterexample to composition law of the functor:
Credits to OliverJAsh for spoiling the fun ;)
npm install @hasparus/maybe-ts
yarn add @hasparus/maybe-ts
fp-ts ^2.3
TypeScript >= 3.7
Found a bug? Have an idea for improvements? Feel free to shoot a PR!
Slides: https://maybe-ts.now.sh/