Skip to content

Commit fdcadcc

Browse files
committed
Present is a singleton
1 parent 1db219c commit fdcadcc

File tree

1 file changed

+4
-1
lines changed
  • src/main/java/com/jnape/palatable/lambda/monoid/builtin

1 file changed

+4
-1
lines changed

src/main/java/com/jnape/palatable/lambda/monoid/builtin/Present.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
*/
2828
public final class Present<A> implements MonoidFactory<Semigroup<A>, Maybe<A>> {
2929

30+
private static final Present INSTANCE = new Present<>();
31+
3032
private Present() {
3133
}
3234

@@ -36,8 +38,9 @@ public Monoid<Maybe<A>> apply(Semigroup<A> aSemigroup) {
3638
nothing());
3739
}
3840

41+
@SuppressWarnings("unchecked")
3942
public static <A> Present<A> present() {
40-
return new Present<>();
43+
return INSTANCE;
4144
}
4245

4346
public static <A> Monoid<Maybe<A>> present(Semigroup<A> semigroup) {

0 commit comments

Comments
 (0)