littleball-games / lb-f

A collection of functional programming functions
MIT License
0 stars 1 forks source link

Implement maybe as plain JS objects #18

Closed skylize closed 2 years ago

skylize commented 6 years ago

Here is another attempt at Maybe, this time with just some objects and helper functions.

"Maybe" itself becomes only an abstract idea that mentally captures either Nothing or Just. I rather like this result, but the possibility of real type checking is out the window.

This example is a bit more complete than the class example because I wasn't distracted by class boilerplate and I needed to implement the join method before I could test the internal values.