Skip to content

Commit e50512d

Browse files
fixed HKT to_str example in documentation (#1639)
* fixed HKT `to_str` example in documentation * updated poetry url
1 parent b5e9350 commit e50512d

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ jobs:
3333

3434
- name: Install poetry
3535
run: |
36-
curl -sSL \
37-
"https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py" | python
36+
curl -sSL "https://install.python-poetry.org" | python
3837
3938
# Adding `poetry` to `$PATH`:
4039
echo "$HOME/.poetry/bin" >> $GITHUB_PATH

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ incremental in minor, bugfixes only are patches.
66
See [0Ver](https://0ver.org/).
77

88

9+
## 0.20.1 WIP
10+
11+
### Bugfixes
12+
13+
- Fixed HKT `to_str` example in documentation
14+
15+
916
## 0.20.0
1017

1118
### Features

docs/pages/hkt.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ Let's see how it works:
184184
.. code:: python
185185
186186
>>> from returns.primitives.hkt import Kind1
187-
>>> from returns.interfaces.container import Container1
187+
>>> from returns.interfaces.container import ContainerN
188188
>>> from typing import TypeVar
189189
190-
>>> T = TypeVar('T', bound=Container1)
190+
>>> T = TypeVar('T', bound=ContainerN)
191191
192-
>>> def to_str(arg: Kind1[T, int]) -> Kind1[T, str]:
193-
... ...
192+
>>> def to_str(container: Kind1[T, int]) -> Kind1[T, str]:
193+
... return container.map(str)
194194
195195
Now, this will work almost correctly!
196196
Why almost? Because the revealed type will be ``Kind1``.
@@ -210,8 +210,8 @@ The final solution is to decorate ``to_str`` with ``@kinded``:
210210
>>> from returns.primitives.hkt import kinded
211211
212212
>>> @kinded
213-
... def to_str(arg: Kind1[T, int]) -> Kind1[T, str]:
214-
... ...
213+
... def to_str(container: Kind1[T, int]) -> Kind1[T, str]:
214+
... return container.map(str)
215215
216216
Now, it will be fully working:
217217

@@ -222,7 +222,7 @@ Now, it will be fully working:
222222
223223
And the thing about this approach is that it will be:
224224

225-
1. Fully type-safe. It works with correct interface ``Container1``,
225+
1. Fully type-safe. It works with correct interface ``ContainerN``,
226226
returns the correct type, has correct type transformation
227227
2. Is opened for further extension and even custom types
228228

0 commit comments

Comments
 (0)