3 ms·
I wanted to ask the same thing: Couldn't we just use Optional and None for this? So the point of using Koda is to communicate intent (functions that don't throw
by leethargo 5y ago
I wanted to ask the same thing: Couldn't we just use Optional and None for this?
So the point of using Koda is to communicate intent (functions that don't throw exceptions), and some utility methods?
- keithasaurus 5y agoYou can also nest `Maybe`s. Just(Just(nothing)) could convey that two levels of a computation "succeeded", but the third did not. This may not be something you see often, but it's a case that Optional can't convey. There are also cases where None is a valid value, and then Optional doesn't make sense. Maybe[None] can be a valid, if rare, use case -- Just(None) is different from Nothing. But Optional[None] doesn't make sense -- since it's None | None. You can also do other stuff with Maybe, like map, flat_map, apply. And there's more that can be added.