8000 Update README.md · jgarte/functional-jargon-python@00721ac · GitHub
[go: up one dir, main page]

Skip to content

Commit 00721ac

Browse files
authored
Update README.md
1 parent b6c8357 commit 00721ac

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ __Table of Contents__
1515
* [Purity](#purity)
1616
* [Idempotent](#idempotent)
1717
* [Arity](#arity)
18-
* [IO (TODO)](#io-todo)
18+
* [IO](#io)
1919
* [Higher-Order Functions (HOF)](#higher-order-functions-hof)
2020
* [Closure (TODO)](#closure-todo)
2121
* [Partial Application](#partial-application)
@@ -202,6 +202,7 @@ There is a little difference between __arguments__ and __parameters__:
202202
* __arguments__: are the values that are passed to a function
203203
* __parameters__: are the variables in the function definition
204204

205+
205206
## Higher-Order Functions (HOF)
206207

207208
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:
239240
```
240241

241242

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+
```
243260

244-
TODO
261+
__Further reading__:
262+
* [`IO` and `@impure` docs](https://returns.readthedocs.io/en/latest/pages/io.html)
245263

246264

247265
## Closure (TODO)

0 commit comments

Comments
 (0)
0