Skip to content

Commit 52a49fd

Browse files
committed
Merge branch 'master' of https://github.com/functionaljava/functionaljava into optimizable-typeclasses
# Conflicts: # core/src/main/java/fj/Ord.java
2 parents 18690a2 + e6abe86 commit 52a49fd

File tree

19 files changed

+340
-140
lines changed

19 files changed

+340
-140
lines changed

README.adoc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The library is intended for use in production applications and is thoroughly tes
1313
Functional Java provides abstractions for the following types:
1414

1515
* Basic Data Structures - total and partial functions, products, unit, option, unbiased and right biased unions (either and validation), void.
16-
* Immutable Collections - array, list, vector, stream, set, map, finger tree, heterogenous list, difference list.
16+
* Immutable Collections - array, list, vector, stream, set, map, priority queue, finger tree, heterogenous list, difference list.
1717
* Other Abstractions - monoid, semigroup, natural, random number generator, reader, writer, state, input/output, parser, zipper, specification based testing (quickcheck), actors, optics (lens, prism, fold, traversal and others), concurrency and type conversion.
1818
1919
== URLs
@@ -35,43 +35,43 @@ The Functional Java artifact is published to Maven Central using the group `org.
3535
* Java 8 specific support (`functionaljava-java8`)
3636
* property based testing (`functionaljava-quickcheck`)
3737

38-
The latest stable version is `4.5`. This can be added to your Gradle project by adding the dependencies:
38+
The latest stable version is `4.6`. This can be added to your Gradle project by adding the dependencies:
3939
----
40-
compile "org.functionaljava:functionaljava:4.5"
41-
compile "org.functionaljava:functionaljava-java8:4.5"
42-
compile "org.functionaljava:functionaljava-quickcheck:4.5"
43-
compile "org.functionaljava:functionaljava-java-core:4.5"
40+
compile "org.functionaljava:functionaljava:4.6"
41+
compile "org.functionaljava:functionaljava-java8:4.6"
42+
compile "org.functionaljava:functionaljava-quickcheck:4.6"
43+
compile "org.functionaljava:functionaljava-java-core:4.6"
4444
----
4545

4646
and in Maven:
4747
----
4848
<dependency>
4949
<groupId>org.functionaljava</groupId>
5050
<artifactId>functionaljava</artifactId>
51-
<version>4.5</version>
51+
<version>4.6</version>
5252
</dependency>
5353
<dependency>
5454
<groupId>org.functionaljava</groupId>
5555
<artifactId>functionaljava-java8</artifactId>
56-
<version>4.5</version>
56+
<version>4.6</version>
5757
</dependency>
5858
<dependency>
5959
<groupId>org.functionaljava</groupId>
6060
<artifactId>functionaljava-quickcheck</artifactId>
61-
<version>4.5</version>
61+
<version>4.6</version>
6262
</dependency>
6363
<dependency>
6464
<groupId>org.functionaljava</groupId>
6565
<artifactId>functionaljava-java-core</artifactId>
66-
<version>4.5</version>
66+
<version>4.6</version>
6767
</dependency>
6868
----
6969

7070
== Building
7171

7272
FunctionalJava uses the Retro Lambda project to backport Java 8 lambdas to Java 6 bytecode. This requires access to both JDK 6 and 8. The build system requires the environment variables `JAVA6_HOME` and `JAVA8_HOME` to refer to the appropriate directories.
7373

74-
Building is done using Gradle 2.10. In the root directory run:
74+
Building is done using Gradle 2.13. In the root directory run:
7575
----
7676
./gradlew
7777
----
@@ -100,6 +100,7 @@ A more complete description of the features mentioned above are:
100100
** Immutable set implementation using a red/black tree (`fj.data.Set`).
101101
** Immutable multi-way tree - aka rose tree (`fj.data.Tree`).
102102
** Immutable tree-map using a red/black tree implementation (`fj.data.TreeMap`).
103+
** Immutable priority queue using finger trees (`fj.data.PriorityQueue`).
103104
** Difference lists, a highly performant list.
104105
* Other Abstractions
105106
** Monoid (`fj.Monoid`).

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ allprojects {
4949

5050
ext {
5151
isSnapshot = true
52-
fjBaseVersion = "4.6"
52+
fjBaseVersion = "4.7"
5353

5454
snapshotAppendix = "-SNAPSHOT"
5555
fjVersion = fjBaseVersion + (isSnapshot ? snapshotAppendix : "")
56-
fjConsumeVersion = "4.5"
56+
fjConsumeVersion = "4.6"
5757

5858
signModule = false
5959
useRetroLambda = false

core/src/main/java/fj/Ord.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public boolean isGreaterThan(final A a1, final A a2) {
178178
* @return A function that returns true if its argument is less than the argument to this method.
179179
*/
180180
public F<A, Boolean> isLessThan(final A a) {
181-
return compose(o -> o != Ordering.LT, def.compare(a));
181+
return compose(o -> o == Ordering.GT, def.compare(a));
182182
}
183183

184184
/**
@@ -188,7 +188,7 @@ public F<A, Boolean> isLessThan(final A a) {
188188
* @return A function that returns true if its argument is greater than the argument to this method.
189189
*/
190190
public F<A, Boolean> isGreaterThan(final A a) {
191-
return compose(o -> o != Ordering.GT, def.compare(a));
191+
return compose(o -> o == Ordering.LT, def.compare(a));
192192
}
193193

194194
/**
@@ -564,26 +564,32 @@ public static <A extends Comparable<A>> Ord<A> comparableOrd() {
564564

565565
/**
566566
* An order instance that uses {@link Object#hashCode()} for computing the order and equality,
567-
* thus objects returning the same hashCode are considered to be equals (check {@link #hashEqualsOrd()}
568-
* for an additional check on {@link Object#equals(Object)}).
567+
* thus objects returning the same hashCode are considered to be equals.
568+
* This is not safe and therefore this method is deprecated.
569569
*
570570
* @return An order instance that is based on {@link Object#hashCode()}.
571-
* @see #hashEqualsOrd()
571+
*
572+
* @deprecated As of release 4.7.
572573
*/
574+
@Deprecated
573575
public static <A> Ord<A> hashOrd() {
574576
return ordDef(a -> {
575577
int aHash = a.hashCode();
576-
return a2 -> Ordering.fromInt(Integer.compare(aHash, a2.hashCode()));
578+
return a2 -> Ordering.fromInt(Integer.valueOf(aHash).compareTo(a2.hashCode()));
577579
});
578580
}
579581

580582
/**
581583
* An order instance that uses {@link Object#hashCode()} and {@link Object#equals} for computing
582584
* the order and equality. First the hashCode is compared, if this is equal, objects are compared
583585
* using {@link Object#equals}.
586+
* WARNING: This ordering violate antisymmetry on hash collisions.
584587
*
585588
* @return An order instance that is based on {@link Object#hashCode()} and {@link Object#equals}.
589+
*
590+
* @deprecated As of release 4.7.
586591
*/
592+
@Deprecated
587593
public static <A> Ord<A> hashEqualsOrd() {
588594
return ordDef(a -> {
589595
int aHash = a.hashCode();

core/src/main/java/fj/control/Trampoline.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ public <B> Trampoline<B> bind(final F<A, Trampoline<B>> f) {
5252
// The resumption of a Codense is the resumption of its subcomputation. If that computation is done, its result
5353
// gets shifted into the continuation.
5454
public Either<P1<Trampoline<A>>, A> resume() {
55-
return left(sub.resume().either(p -> p.map(ot -> {
56-
// WARNING: In JDK 8, update 25 (current version) the following code is a
57-
// workaround for an internal JDK compiler error, likely due to
58-
// https:bugs.openjdk.java.net/browse/JDK-8062253.
59-
F<Normal<Object>, Trampoline<A>> f = o -> o.foldNormal(cont, t -> t._1().bind(cont));
60-
F<Codense<Object>, Trampoline<A>> g = c -> codense(c.sub, o -> c.cont.f(o).bind(cont));
61-
return ot.fold(f, g);
62-
}), o -> P.lazy(() -> cont.f(o))));
55+
return left(sub.resume().either(p -> p.map(ot ->
56+
ot.fold(
57+
o -> o.foldNormal(cont, t -> t._1().bind(cont)),
58+
c -> codense(c.sub, o -> c.cont.f(o).bind(cont))
59+
)
60+
), o -> P.lazy(() -> cont.f(o))));
6361
}
6462
}
6563

0 commit comments

Comments
 (0)