File tree 1 file changed +21
-3
lines changed 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ __Table of Contents__
15
15
* [ Purity] ( #purity )
16
16
* [ Idempotent] ( #idempotent )
17
17
* [ Arity] ( #arity )
18
- * [ IO (TODO) ] ( #io-todo )
18
+ * [ IO] ( #io )
19
19
* [ Higher-Order Functions (HOF)] ( #higher-order-functions-hof )
20
20
* [ Closure (TODO)] ( #closure-todo )
21
21
* [ Partial Application] ( #partial-application )
@@ -202,6 +202,7 @@ There is a little difference between __arguments__ and __parameters__:
202
202
* __ arguments__ : are the values that are passed to a function
203
203
* __ parameters__ : are the variables in the function definition
204
204
205
+
205
206
## Higher-Order Functions (HOF)
206
207
207
208
A function that takes a function as an argument and/or returns a function, basically we can treat functions as a value.
@@ -239,9 +240,26 @@ We can create our own __HOF__, see the example below:
239
240
```
240
241
241
242
242
- ## IO (TODO)
243
+ ## IO
244
+
245
+ IO basically means Input/Output, but it is widely used to just tell that a function is impure.
246
+
247
+ We have a special type (`` IO `` ) and a decorator (`` @impure `` ) to do that in Python:
248
+
249
+ ``` python
250
+ >> > import random
251
+ >> > from returns.io import IO , impure
252
+
253
+ >> > @ impure
254
+ ... def get_random_number () -> int :
255
+ ... return random.randint(0 , 100 )
256
+
257
+ >> > assert isinstance (get_random_number(), IO )
258
+ >> >
259
+ ```
243
260
244
- TODO
261
+ __ Further reading__ :
262
+ * [ ` IO ` and ` @impure ` docs] ( https://returns.readthedocs.io/en/latest/pages/io.html )
245
263
246
264
247
265
## Closure (TODO)
You can’t perform that action at this time.
0 commit comments