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.
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.