Skip to content

Commit 3a05085

Browse files
committed
Fixes docs for pointfree
1 parent 327b53c commit 3a05085

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

docs/pages/pointfree.rst

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ but the same result.
1212
bind
1313
----
1414

15-
Without ``bind()`` it would be very hard to declaratively compose two entities:
15+
Without ``bind()`` function
16+
it would be very hard to declaratively compose two entities:
1617

1718
1. Existings container
1819
2. Existing functions that accepts a regular value and returns a container
@@ -31,15 +32,35 @@ but how can we do it inversevely?
3132
>>> container: Maybe[str] = Some('a')
3233
>>> # We now have two way of composining these entities.
3334
>>> # 1. Via ``.bind``:
34-
>>> str(container.bind(bindable)) # works!
35-
'<Some: 1>'
36-
>>> # 2. Or via ``box``, the same but in the inverse way:
37-
>>> str(bind(bindable)(container))
38-
'<Some: 1>'
35+
>>> assert container.bind(bindable) == Some(1)
36+
>>> # 2. Or via ``bind`` function, the same but in the inverse way:
37+
>>> assert bind(bindable)(container) == Some(1)
3938
4039
That's it.
4140

4241

42+
rescue
43+
------
44+
45+
The same applies for ``rescue()`` function.
46+
It is also required for better declarative programming.
47+
48+
.. code:: python
49+
50+
>>> from returns.pointfree import rescue
51+
>>> from returns.result import Success, Failure, Result
52+
53+
>>> def function(arg: str) -> Result[int, str]:
54+
... return Success(1)
55+
56+
>>> container: Result[int, str] = Failure('a')
57+
>>> # We now have two way of composining these entities.
58+
>>> # 1. Via ``.rescue``:
59+
>>> assert container.rescue(function) == Success(1)
60+
>>> # 2. Or via ``rescue`` function, the same but in the inverse way:
61+
>>> assert rescue(function)(container) == Success(1)
62+
63+
4364
Further reading
4465
---------------
4566

@@ -51,3 +72,5 @@ API Reference
5172
-------------
5273

5374
.. autofunction:: returns.pointfree.bind
75+
76+
.. autofunction:: returns.pointfree.rescue

0 commit comments

Comments
 (0)