Skip to content

Commit 87ed771

Browse files
committed
Renaming Singleton to SingletonHList
1 parent e037f58 commit 87ed771

12 files changed

Lines changed: 42 additions & 42 deletions

File tree

src/main/java/com/jnape/palatable/lambda/adt/hlist/HList.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @param <Head> The head element type
1010
* @param <Tail> The encoded recursive tail HList type
11-
* @see Singleton
11+
* @see SingletonHList
1212
* @see Tuple2
1313
* @see Tuple3
1414
* @see Tuple4
@@ -29,12 +29,12 @@ public static HNil nil() {
2929
return new HCons<>(head, tail);
3030
}
3131

32-
public static <Head> Singleton<Head> singleton(Head head) {
33-
return new Singleton<>(head);
32+
public static <Head> SingletonHList<Head> singletonHList(Head head) {
33+
return new SingletonHList<>(head);
3434
}
3535

3636
public static <_1, _2> Tuple2<_1, _2> tuple(_1 _1, _2 _2) {
37-
return singleton(_2).cons(_1);
37+
return singletonHList(_2).cons(_1);
3838
}
3939

4040
public static <_1, _2, _3> Tuple3<_1, _2, _3> tuple(_1 _1, _2 _2, _3 _3) {
@@ -100,8 +100,8 @@ public static final class HNil extends HList<Void, HNil> {
100100
private static final HNil INSTANCE = new HNil();
101101

102102
@Override
103-
public <Head> Singleton<Head> cons(Head head) {
104-
return new Singleton<>(head);
103+
public <Head> SingletonHList<Head> cons(Head head) {
104+
return new SingletonHList<>(head);
105105
}
106106

107107
@Override

src/main/java/com/jnape/palatable/lambda/adt/hlist/Singleton.java renamed to src/main/java/com/jnape/palatable/lambda/adt/hlist/SingletonHList.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* @see Tuple4
1616
* @see Tuple5
1717
*/
18-
public final class Singleton<_1> extends HCons<_1, HNil> implements Functor<_1> {
18+
public final class SingletonHList<_1> extends HCons<_1, HNil> implements Functor<_1> {
1919

20-
Singleton(_1 _1) {
20+
SingletonHList(_1 _1) {
2121
super(_1, nil());
2222
}
2323

@@ -27,7 +27,7 @@ public <_0> Tuple2<_0, _1> cons(_0 _0) {
2727
}
2828

2929
@Override
30-
public <_1Prime> Singleton<_1Prime> fmap(Fn1<? super _1, ? extends _1Prime> fn) {
31-
return new Singleton<>(fn.apply(head()));
30+
public <_1Prime> SingletonHList<_1Prime> fmap(Fn1<? super _1, ? extends _1Prime> fn) {
31+
return new SingletonHList<>(fn.apply(head()));
3232
}
3333
}

src/main/java/com/jnape/palatable/lambda/adt/hlist/Tuple2.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
* @param <_1> The first slot element type
1414
* @param <_2> The second slot element type
1515
* @see HList
16-
* @see Singleton
16+
* @see SingletonHList
1717
* @see Tuple3
1818
* @see Tuple4
1919
* @see Tuple5
2020
*/
21-
public final class Tuple2<_1, _2> extends HCons<_1, Singleton<_2>> implements Map.Entry<_1, _2>, Functor<_2>, Bifunctor<_1, _2> {
21+
public final class Tuple2<_1, _2> extends HCons<_1, SingletonHList<_2>> implements Map.Entry<_1, _2>, Functor<_2>, Bifunctor<_1, _2> {
2222

23-
Tuple2(_1 _1, Singleton<_2> tail) {
23+
Tuple2(_1 _1, SingletonHList<_2> tail) {
2424
super(_1, tail);
2525
}
2626

@@ -76,6 +76,6 @@ public <_1Prime, _2Prime> Tuple2<_1Prime, _2Prime> biMap(Fn1<? super _1, ? exten
7676
}
7777

7878
public static <K, V> Tuple2<K, V> fromEntry(Map.Entry<K, V> entry) {
79-
return new Tuple2<>(entry.getKey(), singleton(entry.getValue()));
79+
return new Tuple2<>(entry.getKey(), singletonHList(entry.getValue()));
8080
}
8181
}

src/main/java/com/jnape/palatable/lambda/adt/hlist/Tuple3.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @param <_2> The second slot element type
1313
* @param <_3> The third slot element type
1414
* @see HList
15-
* @see Singleton
15+
* @see SingletonHList
1616
* @see Tuple2
1717
* @see Tuple4
1818
* @see Tuple5

src/main/java/com/jnape/palatable/lambda/adt/hlist/Tuple4.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @param <_3> The third slot element type
1414
* @param <_4> The fourth slot element type
1515
* @see HList
16-
* @see Singleton
16+
* @see SingletonHList
1717
* @see Tuple2
1818
* @see Tuple3
1919
* @see Tuple5

src/main/java/com/jnape/palatable/lambda/adt/hlist/Tuple5.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @param <_4> The fourth slot element type
1515
* @param <_5> The fifth slot element type
1616
* @see HList
17-
* @see Singleton
17+
* @see SingletonHList
1818
* @see Tuple2
1919
* @see Tuple3
2020
* @see Tuple4

src/test/java/com/jnape/palatable/lambda/adt/hlist/HListTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import static com.jnape.palatable.lambda.adt.hlist.HList.cons;
66
import static com.jnape.palatable.lambda.adt.hlist.HList.nil;
7-
import static com.jnape.palatable.lambda.adt.hlist.HList.singleton;
7+
import static com.jnape.palatable.lambda.adt.hlist.HList.singletonHList;
88
import static com.jnape.palatable.lambda.adt.hlist.HList.tuple;
99
import static org.junit.Assert.assertEquals;
1010
import static org.junit.Assert.assertFalse;
@@ -29,7 +29,7 @@ public void tail() {
2929
@Test
3030
public void convenienceStaticFactoryMethods() {
3131
assertEquals(nil().cons(1), cons(1, nil()));
32-
assertEquals(nil().cons(1), singleton(1));
32+
assertEquals(nil().cons(1), singletonHList(1));
3333
assertEquals(nil().cons('2').cons(1), tuple(1, '2'));
3434
assertEquals(nil().cons("3").cons('2').cons(1), tuple(1, '2', "3"));
3535
assertEquals(nil().cons(4.0).cons("3").cons('2').cons(1), tuple(1, '2', "3", 4.0));

src/test/java/com/jnape/palatable/lambda/adt/hlist/SingletonTest.java renamed to src/test/java/com/jnape/palatable/lambda/adt/hlist/SingletonHListTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@
66
import static com.jnape.palatable.lambda.adt.hlist.HList.nil;
77
import static org.junit.Assert.assertEquals;
88

9-
public class SingletonTest {
9+
public class SingletonHListTest {
1010

11-
private Singleton<Integer> singleton;
11+
private SingletonHList<Integer> singletonHList;
1212

1313
@Before
1414
public void setUp() {
15-
singleton = new Singleton<>(1);
15+
singletonHList = new SingletonHList<>(1);
1616
}
1717

1818
@Test
1919
public void head() {
20-
assertEquals((Integer) 1, singleton.head());
20+
assertEquals((Integer) 1, singletonHList.head());
2121
}
2222

2323
@Test
2424
public void tail() {
25-
assertEquals(nil(), singleton.tail());
25+
assertEquals(nil(), singletonHList.tail());
2626
}
2727

2828
@Test
2929
public void cons() {
30-
assertEquals(new Tuple2<>("0", singleton), singleton.cons("0"));
30+
assertEquals(new Tuple2<>("0", singletonHList), singletonHList.cons("0"));
3131
}
3232

3333
@Test
3434
public void functorProperties() {
35-
assertEquals(new Singleton<>("1"), singleton.fmap(Object::toString));
35+
assertEquals(new SingletonHList<>("1"), singletonHList.fmap(Object::toString));
3636
}
3737
}

src/test/java/com/jnape/palatable/lambda/adt/hlist/Tuple2Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Tuple2Test {
1515

1616
@Before
1717
public void setUp() throws Exception {
18-
tuple2 = new Tuple2<>(1, new Singleton<>(2));
18+
tuple2 = new Tuple2<>(1, new SingletonHList<>(2));
1919
}
2020

2121
@Test
@@ -25,7 +25,7 @@ public void head() {
2525

2626
@Test
2727
public void tail() {
28-
assertEquals(new Singleton<>(2), tuple2.tail());
28+
assertEquals(new SingletonHList<>(2), tuple2.tail());
2929
}
3030

3131
@Test
@@ -41,12 +41,12 @@ public void accessors() {
4141

4242
@Test
4343
public void functorProperties() {
44-
assertEquals(new Tuple2<>(1, new Singleton<>("2")), tuple2.fmap(Object::toString));
44+
assertEquals(new Tuple2<>(1, new SingletonHList<>("2")), tuple2.fmap(Object::toString));
4545
}
4646

4747
@Test
4848
public void bifunctorProperties() {
49-
assertEquals(new Tuple2<>("1", new Singleton<>("2")), tuple2.biMap(Object::toString, Object::toString));
49+
assertEquals(new Tuple2<>("1", new SingletonHList<>("2")), tuple2.biMap(Object::toString, Object::toString));
5050
}
5151

5252
@Test

src/test/java/com/jnape/palatable/lambda/adt/hlist/Tuple3Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class Tuple3Test {
1111

1212
@Before
1313
public void setUp() {
14-
tuple3 = new Tuple3<>(1, new Tuple2<>("2", new Singleton<>('3')));
14+
tuple3 = new Tuple3<>(1, new Tuple2<>("2", new SingletonHList<>('3')));
1515
}
1616

1717
@Test
@@ -21,7 +21,7 @@ public void head() {
2121

2222
@Test
2323
public void tail() {
24-
assertEquals(new Tuple2<>("2", new Singleton<>('3')), tuple3.tail());
24+
assertEquals(new Tuple2<>("2", new SingletonHList<>('3')), tuple3.tail());
2525
}
2626

2727
@Test
@@ -38,11 +38,11 @@ public void accessors() {
3838

3939
@Test
4040
public void functorProperties() {
41-
assertEquals(new Tuple3<>(1, new Tuple2<>("2", new Singleton<>("3"))), tuple3.fmap(Object::toString));
41+
assertEquals(new Tuple3<>(1, new Tuple2<>("2", new SingletonHList<>("3"))), tuple3.fmap(Object::toString));
4242
}
4343

4444
@Test
4545
public void bifunctorProperties() {
46-
assertEquals(new Tuple3<>(1, new Tuple2<>(2, new Singleton<>("3"))), tuple3.biMap(Integer::parseInt, Object::toString));
46+
assertEquals(new Tuple3<>(1, new Tuple2<>(2, new SingletonHList<>("3"))), tuple3.biMap(Integer::parseInt, Object::toString));
4747
}
4848
}

0 commit comments

Comments
 (0)