Skip to content

Commit 1e7ab1f

Browse files
committed
Fn0 is now Callable
1 parent 6fed0ab commit 1e7ab1f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1616
- `Concat` monoid can now fold infinite iterables
1717
- all `Function<? super XXX, Boolean>` are now `Function<? super XXX, ? extends Boolean>` for better compatibility
1818
- `Either#diverge` returns a `Choice3`
19-
- `Maybe` is now a `CoProduct2` of `Unit` and `A`
19+
- `Maybe` is now a `CoProduct2` of `Unit` and `A`
20+
- `Fn0` now additionally implements `Callable`
2021

2122
### Added
2223
- `Predicate#predicate` static factory method

src/main/java/com/jnape/palatable/lambda/functions/Fn0.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.jnape.palatable.lambda.functor.Applicative;
55
import com.jnape.palatable.lambda.monad.Monad;
66

7+
import java.util.concurrent.Callable;
78
import java.util.function.Function;
89
import java.util.function.Supplier;
910

@@ -16,9 +17,10 @@
1617
* @param <A> the result type
1718
* @see Fn1
1819
* @see Supplier
20+
* @see Callable
1921
*/
2022
@FunctionalInterface
21-
public interface Fn0<A> extends Fn1<Unit, A>, Supplier<A> {
23+
public interface Fn0<A> extends Fn1<Unit, A>, Supplier<A>, Callable<A> {
2224

2325
A apply();
2426

@@ -85,7 +87,12 @@ default <B> Fn0<B> andThen(Function<? super A, ? extends B> after) {
8587

8688
@Override
8789
default A get() {
88-
return apply(UNIT);
90+
return apply();
91+
}
92+
93+
@Override
94+
default A call() {
95+
return apply();
8996
}
9097

9198
/**

0 commit comments

Comments
 (0)