Re:Show HN: Koda, a typesafe functional toolkit for Python
by leethargo on Monday February 07, 2022 @03:45PM
(#30250824)
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?
[ Parent
| on HN ]
Re:Show HN: Koda, a typesafe functional toolkit for Python
by keithasaurus on Monday February 07, 2022 @04:44PM
(#30251722)
You 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.