dbrattli / OSlash

Functors, Applicatives, And Monads in Python
MIT License
714 stars 50 forks source link

Add boolean combine for Maybe #2

Closed duythinht closed 7 years ago

duythinht commented 7 years ago

In my opinion we need combine Maybe instance by boolean operator. For example when I want to check a value is None and return Nothing instead of Just(None)

return value and Just(value) or Nothing()

Should be

return Just(value) or Nothing()
dbrattli commented 7 years ago

Thanks, this is great idea! A bit unsure if I want to use .value, (as it is sort of a hack) and perhaps impl. __bool__() for both Nothing and Maybe. But I can change that later if I decide to do it that way.