/maybe-ts

A lightweight Maybe type for fp-ts

Primary LanguageTypeScript

maybe-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;

🤹‍♂️ Instance of your favorite type classes

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 ;)


Installation

npm install @hasparus/maybe-ts

yarn add @hasparus/maybe-ts

Requirements

fp-ts ^2.3
TypeScript >= 3.7

Contributing

Found a bug? Have an idea for improvements? Feel free to shoot a PR!


Slides: https://maybe-ts.now.sh/