Skip to content

Commit bba9029

Browse files
committed
Docs
1 parent 7017ed3 commit bba9029

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,16 @@ So, we act accordingly!
221221

222222
## Maybe container
223223

224-
Have you ever since code with a lot of `if some is not None` conditions?
225-
It really bloats your source code and makes it unreadable.
224+
`None` is called the [worst mistake in the history of Computer Science](https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/).
226225

227-
But, having `None` in your source code is even worth.
228-
Actually, `None` is called the [worth mistake in the history of Computer Science](https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/).
226+
So, what can we do?
227+
You can use `Optional` and write a lot of `if some is not None` conditions.
228+
But, having them here and there makes your code unreadable.
229229

230-
So, what to do?
231-
Use [Maybe](https://returns.readthedocs.io/en/latest/pages/maybe.html) container!
230+
Or you can use
231+
[Maybe](https://returns.readthedocs.io/en/latest/pages/maybe.html) container!
232232
It consists of `Some` and `Nothing` types,
233-
representing existing state and empty (or `None`) state respectively.
233+
representing existing state and empty (instead of `None`) state respectively.
234234

235235
```python
236236
from typing import Optional
@@ -247,6 +247,8 @@ maybe_result: Maybe[float] = bad_function().map(
247247
# Otherwise, will return Nothing
248248
```
249249

250+
It follows the same composition rules as the `Result` type.
251+
You can be sure that `.map()` method won't be called for `Nothing`.
250252
Forget about `None`-related errors forever!
251253

252254

docs/pages/maybe.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ based on just a single value:
2222
Maybe.new(None)
2323
# => Nothing
2424
25-
2625
Usage
27-
-----
26+
~~~~~
2827

2928
It might be very useful for complex operations like the following one:
3029

0 commit comments

Comments
 (0)