Skip to content

Commit a8c403d

Browse files
committed
Deprecating Force
1 parent d652830 commit a8c403d

File tree

6 files changed

+13
-39
lines changed

6 files changed

+13
-39
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1515
### Fixed
1616
- `SafeT#zip` is now stack-safe regardless of the underlying monad's `zip` implementation
1717

18+
### Deprecated
19+
- `Force`, in favor if traversing into an `IO` and explicitly running it
20+
1821
## [5.0.0] - 2019-09-23
1922
### Changed
2023
- ***Breaking Change***: `MonadT` is now witnessed by a parameter for better subtyping, and no longer requires a common
@@ -52,7 +55,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
5255

5356
### Deprecated
5457
- `Peek`, `Peek2`, `Maybe#peek`, and `Either#peek` in favor of explicitly matching into `IO` and running it
55-
- `Force`, in favor if traversing into an `IO` and explicitly running it
5658
- `IO#exceptionally` in favor of `IO#catchError` (from `MonadError`)
5759

5860
## [4.0.0] - 2019-05-20

src/main/java/com/jnape/palatable/lambda/functions/builtin/fn1/Force.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package com.jnape.palatable.lambda.functions.builtin.fn1;
22

33
import com.jnape.palatable.lambda.functions.Fn1;
4+
import com.jnape.palatable.lambda.io.IO;
5+
import com.jnape.palatable.lambda.traversable.LambdaIterable;
46

57
/**
68
* Force a full iteration of an {@link Iterable}, presumably to perform any side-effects contained therein. Returns the
79
* {@link Iterable} back.
810
*
911
* @param <A> the Iterable element type
12+
* @deprecated in favor of {@link LambdaIterable#traverse(Fn1, Fn1) traversing} into an {@link IO} and running it
1013
*/
14+
@Deprecated
1115
public final class Force<A> implements Fn1<Iterable<A>, Iterable<A>> {
1216

1317
private static final Force<?> INSTANCE = new Force<>();

src/test/java/com/jnape/palatable/lambda/functions/builtin/fn1/ForceTest.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/test/java/com/jnape/palatable/lambda/functions/builtin/fn2/DropWhileTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.List;
1616

1717
import static com.jnape.palatable.lambda.functions.builtin.fn1.Constantly.constantly;
18-
import static com.jnape.palatable.lambda.functions.builtin.fn1.Force.force;
1918
import static com.jnape.palatable.lambda.functions.builtin.fn2.DropWhile.dropWhile;
2019
import static java.util.Arrays.asList;
2120
import static org.junit.Assert.assertThat;
@@ -50,13 +49,13 @@ public void dropsNoElementsIfPredicateImmediatelyFails() {
5049
public void deforestingExecutesPredicatesInOrder() {
5150
List<Integer> innerInvocations = new ArrayList<>();
5251
List<Integer> outerInvocations = new ArrayList<>();
53-
force(dropWhile(y -> {
52+
dropWhile(y -> {
5453
outerInvocations.add(y);
5554
return true;
5655
}, dropWhile(x -> {
5756
innerInvocations.add(x);
5857
return x > 2;
59-
}, asList(1, 2, 3))));
58+
}, asList(1, 2, 3))).forEach(__ -> {});
6059
assertThat(innerInvocations, iterates(1, 2, 3));
6160
assertThat(outerInvocations, iterates(1, 2));
6261
}

src/test/java/com/jnape/palatable/lambda/functions/builtin/fn2/FilterTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.List;
1616

1717
import static com.jnape.palatable.lambda.functions.builtin.fn1.Constantly.constantly;
18-
import static com.jnape.palatable.lambda.functions.builtin.fn1.Force.force;
1918
import static com.jnape.palatable.lambda.functions.builtin.fn2.Filter.filter;
2019
import static java.util.Arrays.asList;
2120
import static org.junit.Assert.assertThat;
@@ -42,13 +41,13 @@ public void filtersOutMatchingElements() {
4241
public void deforestingExecutesPredicatesInOrder() {
4342
List<Integer> innerInvocations = new ArrayList<>();
4443
List<Integer> outerInvocations = new ArrayList<>();
45-
force(filter(y -> {
44+
filter(y -> {
4645
outerInvocations.add(y);
4746
return true;
4847
}, filter(x -> {
4948
innerInvocations.add(x);
5049
return x % 2 == 0;
51-
}, asList(1, 2, 3))));
50+
}, asList(1, 2, 3))).forEach(__ -> {});
5251
assertThat(innerInvocations, iterates(1, 2, 3));
5352
assertThat(outerInvocations, iterates(2));
5453
}

src/test/java/com/jnape/palatable/lambda/functions/builtin/fn2/TakeWhileTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.List;
1616

1717
import static com.jnape.palatable.lambda.functions.builtin.fn1.Constantly.constantly;
18-
import static com.jnape.palatable.lambda.functions.builtin.fn1.Force.force;
1918
import static com.jnape.palatable.lambda.functions.builtin.fn2.TakeWhile.takeWhile;
2019
import static java.util.Arrays.asList;
2120
import static org.junit.Assert.assertThat;
@@ -55,13 +54,13 @@ public void takesNoElementsIfPredicateImmediatelyFails() {
5554
public void deforestingExecutesPredicatesInOrder() {
5655
List<Integer> innerInvocations = new ArrayList<>();
5756
List<Integer> outerInvocations = new ArrayList<>();
58-
force(takeWhile(y -> {
57+
takeWhile(y -> {
5958
outerInvocations.add(y);
6059
return true;
6160
}, takeWhile(x -> {
6261
innerInvocations.add(x);
6362
return x < 3;
64-
}, asList(1, 2, 3))));
63+
}, asList(1, 2, 3))).forEach(__ -> {});
6564
assertThat(innerInvocations, iterates(1, 2, 3));
6665
assertThat(outerInvocations, iterates(1, 2));
6766
}

0 commit comments

Comments
 (0)