forked from functionaljava/functionaljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path$.java
More file actions
34 lines (26 loc) · 732 Bytes
/
$.java
File metadata and controls
34 lines (26 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package fj.data;
import fj.P1;
/**
* The constant arrow, for attaching a new name to an existing type. For every pair of types A and B, this type
* is the identity morphism from B to B.
*/
@SuppressWarnings("UnusedDeclaration")
public final class $<A, B> extends P1<B> {
private final B b;
private $(final B b) {
this.b = b;
}
/**
* Returns a function that given an argument, returns a function that ignores its argument.
* @return A function that given an argument, returns a function that ignores its argument.
*/
public static <A, B> $<A, B> __(final B b) {
return constant(b);
}
public static <A, B> $<A, B> constant(final B b) {
return new $<>(b);
}
public B _1() {
return b;
}
}