You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-42Lines changed: 47 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,9 +42,41 @@ Make sure you know how to get started, [check out our docs](https://returns.read
42
42
43
43
## Contents
44
44
45
+
-[Maybe container](#maybe-container) that allows you to write `None`-free code
45
46
-[Result container](#result-container) that let's you to get rid of exceptions
46
47
-[IO marker](#io-marker) that marks all impure operations and structures them
47
-
-[Maybe container](#maybe-container) that allows you to write `None`-free code
48
+
49
+
50
+
## Maybe container
51
+
52
+
`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/).
53
+
54
+
So, what can we do to check for `None` in our programs?
55
+
You can use `Optional` and write a lot of `if some is not None:` conditions.
56
+
But, having them here and there makes your code unreadable.
It will return [Success[Response] or Failure[Exception]](https://returns.readthedocs.io/en/latest/pages/result.html).
@@ -188,7 +226,7 @@ import requests
188
226
from returns.io importIO, impure
189
227
from returns.result import Result, safe
190
228
from returns.pipeline import pipe
191
-
from returns.functions importlift, lift_io
229
+
from returns.functions importbox
192
230
193
231
classFetchUserProfile(object):
194
232
"""Single responsibility callable object that fetches user profile."""
@@ -198,9 +236,9 @@ class FetchUserProfile(object):
198
236
return pipe(
199
237
user_id,
200
238
self._make_request,
201
-
#lift: def (Result) -> Result
202
-
#lift_io: def (IO[Result]) -> IO[Result]
203
-
lift(box(self._parse_json), IO),
239
+
#after box: def (Result) -> Result
240
+
#after IO.lift: def (IO[Result]) -> IO[Result]
241
+
IO.lift(box(self._parse_json)),
204
242
)
205
243
206
244
@impure
@@ -223,39 +261,6 @@ that it does `IO` and might fail.
223
261
So, we act accordingly!
224
262
225
263
226
-
## Maybe container
227
-
228
-
`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/).
229
-
230
-
So, what can we do?
231
-
You can use `Optional` and write a lot of `if some is not None` conditions.
232
-
But, having them here and there makes your code unreadable.
0 commit comments