https://github.com/hasparus/maybe-ts
A lightweight Maybe type for fp-ts
https://github.com/hasparus/maybe-ts
Last synced: about 1 year ago
JSON representation
A lightweight Maybe type for fp-ts
- Host: GitHub
- URL: https://github.com/hasparus/maybe-ts
- Owner: hasparus
- Created: 2019-12-11T23:27:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-04T13:02:14.000Z (about 6 years ago)
- Last Synced: 2024-10-19T05:17:00.830Z (over 1 year ago)
- Language: TypeScript
- Homepage: https://maybe-ts.now.sh/
- Size: 1010 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# maybe-ts
A lightweight Maybe type for fp-ts
```ts
export type Nothing = null | undefined;
export const Nothing = null as Nothing;
export type Maybe = 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](https://haspar.us/speaking/maybe-ts).
counterexample to composition law of the functor:

Credits to [OliverJAsh](https://github.com/OliverJAsh) for spoiling the fun ;)
---
- [x] ~~[Monad1](https://dev.to/gcanti/getting-started-with-fp-ts-monad-6k)~~
- [x] [Foldable1](https://github.com/gcanti/fp-ts/blob/master/src/Foldable.ts)
- [x] [Traversable1](https://github.com/gcanti/fp-ts/blob/master/src/Traversable.ts)
- [x] [Alternative1](https://github.com/gcanti/fp-ts/blob/master/src/Alternative.ts)
- [x] [Extend1](https://github.com/gcanti/fp-ts/blob/master/src/Extend.ts)
- [x] [Compactable1](https://github.com/gcanti/fp-ts/blob/master/src/Compactable.ts)
- [x] [Filterable1](https://github.com/gcanti/fp-ts/blob/master/src/Filterable.ts)
## 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/