Skip to content

Commit dbbbaa3

Browse files
committed
Improves docs
1 parent 43a4e71 commit dbbbaa3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/pages/context.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ the very same thing as ``RequiresContext[e, Result]``, but has nicer API:
327327
y.map(lambda number: number + 1)
328328
329329
The second one looks better, doesn't it?
330+
The same applies for ``RequiresContextIOResult`` as well.
330331

331332
How to create unit objects?
332333
~~~~~~~~~~~~~~~~~~~~~~~~~~~

docs/pages/io.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,18 @@ The second one looks better, doesn't it?
457457
How to create unit objects for IOResult?
458458
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
459459

460-
*TLDR*: you need to use ``IOSuccess`` and ``IOFailure``:
460+
*TLDR*: you need to use ``IOSuccess`` and ``IOFailure`` functions
461+
or ``IOResult.from_success`` and ``IOResult.from_failure`` methods:
461462

462463
.. code:: python
463464
464465
>>> from returns.io import IOResult, IOSuccess, IOFailure
465466
>>> first: IOResult[int, str] = IOSuccess(1)
466467
>>> second: IOResult[float, int] = IOFailure(1)
467468
469+
>>> assert IOResult.from_success(1) == IOSuccess(1)
470+
>>> assert IOResult.from_failure(2) == IOFailure(2)
471+
468472
You can also annotate your variables properly.
469473
Otherwise, ``mypy`` will treat ``IOSuccess(1)`` as ``IOSuccess[int, Any]``.
470474
You can narrow the type in advance.

0 commit comments

Comments
 (0)