@@ -57,11 +57,12 @@ is used to literally bind two different containers together.
5757
5858 from returns.result import Result, Success
5959
60- def may_fail (user_id : int ) -> Result[int , str ]:
60+ def may_fail (user_id : int ) -> Result[float , str ]:
6161 ...
6262
63- # Can be assumed as either Success[int] or Failure[str]:
64- result: Result[int , str ] = Success(1 ).bind(may_fail)
63+ value: Result[int , str ] = Success(1 )
64+ # Can be assumed as either Success[float] or Failure[str]:
65+ result: Result[float , str ] = value.bind(may_fail)
6566
6667 And we have :func: `~returns.primitives.container.Mappable.map `
6768to use containers with regular functions.
@@ -105,7 +106,7 @@ It mean that our code can go on two tracks:
1051062. Failed one: where something went wrong
106107
107108We can switch from track to track: we can fail something
108- or we can rescue the situation.
109+ or we can fix the situation.
109110
110111.. mermaid ::
111112 :caption: Railway oriented programming.
@@ -123,7 +124,7 @@ or we can rescue the situation.
123124 F2 -- Fix --> S3
124125 S3 -- Fail --> F4
125126 S5 -- Fail --> F6
126- F6 -- Rescue --> S7
127+ F6 -- Fix --> S7
127128
128129 style S1 fill:green
129130 style S3 fill:green
@@ -147,7 +148,7 @@ types like ``Failure``:
147148 transforms error to value (failure became success)
148149 that works only when container is in failed state,
149150 is the opposite of ``map `` method
150- - :func: `~returns.primitives.container.UnwrapableFailure.map_failure `
151+ - :func: `~returns.primitives.container.UnwrapableFailure.alt `
151152 transforms error to another error
152153 that works only when container is in failed state,
153154 is the opposite of ``map `` method
@@ -162,7 +163,7 @@ during the pipeline execution:
162163 def double (state : int ) -> float :
163164 return state * 2.0
164165
165- result: Result[Any, float ] = Failure(1 ).map_failure (double)
166+ result: Result[Any, float ] = Failure(1 ).alt (double)
166167 # => Failure(2.0)
167168
168169 result: Result[float , int ] = Failure(1 ).fix(double)
@@ -180,14 +181,12 @@ It can also rescue your flow and get on the successful track again:
180181 return Success(0 )
181182 return Failure(state)
182183
183- result: Result[int , Exception ] = Failure(
184- ZeroDivisionError (),
185- ).rescue(tolerate_exception)
184+ value: Result[int , Exception ] = Failure(ZeroDivisionError ())
185+ result: Result[int , Exception ] = value.rescue(tolerate_exception)
186186 # => Success(0)
187187
188- result2: Result[int , Exception ] = Failure(
189- ValueError (),
190- ).rescue(tolerate_exception)
188+ value2: Result[int , Exception ] = Failure(ValueError ())
189+ result2: Result[int , Exception ] = value2.rescue(tolerate_exception)
191190 # => Failure(ValueError())
192191
193192
0 commit comments