Skip to content

Commit c382e15

Browse files
committed
Add Tuple2::init and fix javadocs
1 parent af80d80 commit c382e15

File tree

8 files changed

+28
-23
lines changed

8 files changed

+28
-23
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,15 @@ AppTrav extends Applicative<TravB, App>> AppTrav traverse(
237237
return fn.apply(_2).fmap(_2Prime -> fmap(constantly(_2Prime))).<TravB>fmap(Applicative::coerce).coerce();
238238
}
239239

240+
/**
241+
* Returns a {@link SingletonHList}&lt;_1&gt; of the 1st element
242+
*
243+
* @return The {@link SingletonHList}&lt;_1&gt;
244+
*/
245+
public SingletonHList<_1> init() {
246+
return invert().tail();
247+
}
248+
240249
/**
241250
* Static factory method for creating <code>Tuple2</code>s from {@link java.util.Map.Entry}s.
242251
*

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ AppTrav extends Applicative<TravB, App>> AppTrav traverse(
220220
}
221221

222222
/**
223-
* Returns a Tuple of all the elements of this Tuple except the last
223+
* Returns a {@link Tuple2}&lt;_1, _2&gt; of all the elements of this {@link Tuple3}&lt;_1, _2, _3&gt; except the last
224224
*
225-
* @return The Tuple representing all but the last element
225+
* @return The {@link Tuple2}&lt;_1, _2&gt; representing all but the last element
226226
*/
227227
public Tuple2<_1, _2> init() {
228228
return rotateR3().tail();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ AppTrav extends Applicative<TravB, App>> AppTrav traverse(
247247
}
248248

249249
/**
250-
* Returns a Tuple of all the elements of this Tuple except the last
250+
* Returns a {@link Tuple3}&lt;_1, _2, _3&gt; of all the elements of this {@link Tuple4}&lt;_1, _2, _3, _4&gt; except the last
251251
*
252-
* @return The Tuple representing all but the last element
252+
* @return The {@link Tuple3}&lt;_1, _2, _3&gt; representing all but the last element
253253
*/
254254
public Tuple3<_1, _2, _3> init() {
255255
return rotateR4().tail();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ AppTrav extends Applicative<TravB, App>> AppTrav traverse(
274274
}
275275

276276
/**
277-
* Returns a Tuple of all the elements of this Tuple except the last
277+
* Returns a {@link Tuple4}&lt;_1, _2, _3, _4&gt; of all the elements of this {@link Tuple5}&lt;_1, _2, _3, _4, _5&gt; except the last
278278
*
279-
* @return The Tuple representing all but the last element
279+
* @return The {@link Tuple4}&lt;_1, _2, _3, _4&gt; representing all but the last element
280280
*/
281281
public Tuple4<_1, _2, _3, _4> init() {
282282
return rotateR5().tail();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ AppTrav extends Applicative<TravB, App>> AppTrav traverse(
305305
}
306306

307307
/**
308-
* Returns a Tuple of all the elements of this Tuple except the last
308+
* Returns a {@link Tuple5}&lt;_1, _2, _3, _4, _5&gt; of all the elements of this {@link Tuple6}&lt;_1, _2, _3, _4, _5, _6&gt; except the last
309309
*
310-
* @return The Tuple representing all but the last element
310+
* @return The {@link Tuple5}&lt;_1, _2, _3, _4, _5&gt; representing all but the last element
311311
*/
312312
public Tuple5<_1, _2, _3, _4, _5> init() {
313313
return rotateR6().tail();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ AppTrav extends Applicative<TravB, App>> AppTrav traverse(
335335
}
336336

337337
/**
338-
* Returns a Tuple of all the elements of this Tuple except the last
338+
* Returns a {@link Tuple6}&lt;_1, _2, _3, _4, _5, _6&gt; of all the elements of this {@link Tuple7}&lt;_1, _2, _3, _4, _5, _6, _7&gt; except the last
339339
*
340-
* @return The Tuple representing all but the last element
340+
* @return The {@link Tuple6}&lt;_1, _2, _3, _4, _5, _6&gt; representing all but the last element
341341
*/
342342
public Tuple6<_1, _2, _3, _4, _5, _6> init() {
343343
return rotateR7().tail();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,9 @@ AppTrav extends Applicative<TravB, App>> AppTrav traverse(
365365
}
366366

367367
/**
368-
* Returns a Tuple of all the elements of this Tuple except the last
368+
* Returns a {@link Tuple7}&lt;_1, _2, _3, _4, _5, _6, _7&gt; of all the elements of this {@link Tuple8}&lt;_1, _2, _3, _4, _5, _6, _7, _8&gt; except the last
369369
*
370-
* @return The Tuple representing all but the last element
370+
* @return The {@link Tuple7}&lt;_1, _2, _3, _4, _5, _6, _7&gt; representing all but the last element
371371
*/
372372
public Tuple7<_1, _2, _3, _4, _5, _6, _7> init() {
373373
return rotateR8().tail();

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@
66
import org.junit.Before;
77
import org.junit.Test;
88
import org.junit.runner.RunWith;
9-
import testsupport.traits.ApplicativeLaws;
10-
import testsupport.traits.BifunctorLaws;
11-
import testsupport.traits.FunctorLaws;
12-
import testsupport.traits.MonadLaws;
13-
import testsupport.traits.MonadRecLaws;
14-
import testsupport.traits.MonadWriterLaws;
15-
import testsupport.traits.TraversableLaws;
9+
import testsupport.traits.*;
1610

1711
import java.util.HashMap;
1812
import java.util.Map;
@@ -26,10 +20,7 @@
2620
import static java.util.Collections.emptyList;
2721
import static java.util.Collections.singletonList;
2822
import static org.junit.Assert.assertEquals;
29-
import static org.mockito.Mockito.only;
30-
import static org.mockito.Mockito.spy;
31-
import static org.mockito.Mockito.verify;
32-
import static org.mockito.Mockito.verifyNoMoreInteractions;
23+
import static org.mockito.Mockito.*;
3324

3425
@RunWith(Traits.class)
3526
public class Tuple2Test {
@@ -63,6 +54,11 @@ public void tail() {
6354
assertEquals(new SingletonHList<>(2), tuple2.tail());
6455
}
6556

57+
@Test
58+
public void init() {
59+
assertEquals(new SingletonHList<>(1), tuple2.init());
60+
}
61+
6662
@Test
6763
public void cons() {
6864
assertEquals(new Tuple3<>(0, tuple2), tuple2.cons(0));

0 commit comments

Comments
 (0)