File tree 1 file changed +1
-29
lines changed
1 file changed +1
-29
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ return Optional.ofNullable(getNullableString())
97
97
.orElse(" Oh my god. It is empty" );
98
98
```
99
99
100
- This library has two monads: [ ` Try ` ] ( #try ) and [ ` Lazy ` ] ( #lazy ) .
100
+ This library has one monads: [ ` Try ` ] ( #try ) .
101
101
102
102
###### Try
103
103
@@ -214,34 +214,6 @@ assert 2 == t.orElseThrow();
214
214
215
215
All terminal operations are listed in the [ javadoc] ( ./src/main/java/com/kirekov/juu/monad/Try.java ) .
216
216
217
- ###### Lazy
218
-
219
- The name of the monad defines its purpose.
220
-
221
- ``` java
222
- Lazy<String > lazy = Lazy . of(this :: executeRpc)
223
- .map(String :: valueOf);
224
- .map(this :: reverseString);
225
-
226
- String result = lazy. calculate();
227
- ```
228
-
229
- The thing is that all declared steps won't be executed
230
- until ` calculate ` method call. This behaviour is similar
231
- to laziness of Haskell language. ` Lazy ` can be used to measure
232
- execution time of different chains.
233
-
234
- ``` java
235
- ImmutableList<Lazy<Integer > > list = getList();
236
- ExecutionResult<Integer > minTimeResult =
237
- list. map(lazy - > Measure . executionTime(lazy:: calculate)
238
- .inMillis())
239
- .min(Comparator . comparingLong(ExecutionResult :: getTime))
240
- .orElseThrow(IllegalStateException :: new );
241
- ```
242
-
243
- You can also combine `Lazy ` and `Try ` monads to prevent unexpected errors.
244
-
245
217
##### Collections
246
218
247
219
The "Collections" part consists of two subparts:
You can’t perform that action at this time.
0 commit comments