Class HList
- java.lang.Object
-
- com.jnape.palatable.lambda.adt.hlist.HList
-
- Direct Known Subclasses:
HList.HCons
,HList.HNil
public abstract class HList extends java.lang.Object
An immutable heterogeneous list supporting arbitrary depth type-safety via a linearly recursive type signature. Note that due to its rapidly expanding type signature, specializations exist up to certain depths to minimize typing overhead.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HList.HCons<Head,Tail extends HList>
The consing of a head element to a tailHList
.static class
HList.HNil
The emptyHList
.
-
Constructor Summary
Constructors Modifier Constructor Description private
HList()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <Head,Tail extends HList>
HList.HCons<Head,Tail>cons(Head head, Tail tail)
Static factory method for creating an HList from the given head and tail.abstract <NewHead> HList.HCons<NewHead,? extends HList>
cons(NewHead newHead)
Cons an element onto the front of this HList.static HList.HNil
nil()
Static factory method for creating empty HLists.static <Head> SingletonHList<Head>
singletonHList(Head head)
Static factory method for creating a singleton HList.java.lang.String
toString()
static <_1,_2>
Tuple2<_1,_2>tuple(_1 _1, _2 _2)
Static factory method for creating a 2-element HList.static <_1,_2,_3>
Tuple3<_1,_2,_3>tuple(_1 _1, _2 _2, _3 _3)
Static factory method for creating a 3-element HList.static <_1,_2,_3,_4>
Tuple4<_1,_2,_3,_4>tuple(_1 _1, _2 _2, _3 _3, _4 _4)
Static factory method for creating a 4-element HList.static <_1,_2,_3,_4,_5>
Tuple5<_1,_2,_3,_4,_5>tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5)
Static factory method for creating a 5-element HList.static <_1,_2,_3,_4,_5,_6>
Tuple6<_1,_2,_3,_4,_5,_6>tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6)
Static factory method for creating a 6-element HList.static <_1,_2,_3,_4,_5,_6,_7>
Tuple7<_1,_2,_3,_4,_5,_6,_7>tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6, _7 _7)
Static factory method for creating a 7-element HList.static <_1,_2,_3,_4,_5,_6,_7,_8>
Tuple8<_1,_2,_3,_4,_5,_6,_7,_8>tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6, _7 _7, _8 _8)
Static factory method for creating an 8-element HList.
-
-
-
Method Detail
-
cons
public abstract <NewHead> HList.HCons<NewHead,? extends HList> cons(NewHead newHead)
Cons an element onto the front of this HList.- Type Parameters:
NewHead
- the new head type- Parameters:
newHead
- the new head element- Returns:
- the updated HList
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
nil
public static HList.HNil nil()
Static factory method for creating empty HLists.- Returns:
- an empty HList
-
cons
public static <Head,Tail extends HList> HList.HCons<Head,Tail> cons(Head head, Tail tail)
Static factory method for creating an HList from the given head and tail.- Type Parameters:
Head
- the head typeTail
- the tail type- Parameters:
head
- the head elementtail
- the tail HList- Returns:
- the newly created HList
-
singletonHList
public static <Head> SingletonHList<Head> singletonHList(Head head)
Static factory method for creating a singleton HList.- Type Parameters:
Head
- the head element type- Parameters:
head
- the head element- Returns:
- the singleton HList
-
tuple
public static <_1,_2> Tuple2<_1,_2> tuple(_1 _1, _2 _2)
Static factory method for creating a 2-element HList.- Type Parameters:
_1
- the head element type_2
- the second element type- Parameters:
_1
- the head element_2
- the second element- Returns:
- the 2-element HList
- See Also:
Tuple2
-
tuple
public static <_1,_2,_3> Tuple3<_1,_2,_3> tuple(_1 _1, _2 _2, _3 _3)
Static factory method for creating a 3-element HList.- Type Parameters:
_1
- the head element type_2
- the second element type_3
- the third element type- Parameters:
_1
- the head element_2
- the second element_3
- the third element- Returns:
- the 3-element HList
- See Also:
Tuple3
-
tuple
public static <_1,_2,_3,_4> Tuple4<_1,_2,_3,_4> tuple(_1 _1, _2 _2, _3 _3, _4 _4)
Static factory method for creating a 4-element HList.- Type Parameters:
_1
- the head element type_2
- the second element type_3
- the third element type_4
- the fourth element type- Parameters:
_1
- the head element_2
- the second element_3
- the third element_4
- the fourth element- Returns:
- the 4-element HList
- See Also:
Tuple4
-
tuple
public static <_1,_2,_3,_4,_5> Tuple5<_1,_2,_3,_4,_5> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5)
Static factory method for creating a 5-element HList.- Type Parameters:
_1
- the head element type_2
- the second element type_3
- the third element type_4
- the fourth element type_5
- the fifth element type- Parameters:
_1
- the head element_2
- the second element_3
- the third element_4
- the fourth element_5
- the fifth element- Returns:
- the 5-element HList
- See Also:
Tuple5
-
tuple
public static <_1,_2,_3,_4,_5,_6> Tuple6<_1,_2,_3,_4,_5,_6> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6)
Static factory method for creating a 6-element HList.- Type Parameters:
_1
- the head element type_2
- the second element type_3
- the third element type_4
- the fourth element type_5
- the fifth element type_6
- the sixth element type- Parameters:
_1
- the head element_2
- the second element_3
- the third element_4
- the fourth element_5
- the fifth element_6
- the sixth element- Returns:
- the 6-element HList
- See Also:
Tuple6
-
tuple
public static <_1,_2,_3,_4,_5,_6,_7> Tuple7<_1,_2,_3,_4,_5,_6,_7> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6, _7 _7)
Static factory method for creating a 7-element HList.- Type Parameters:
_1
- the head element type_2
- the second element type_3
- the third element type_4
- the fourth element type_5
- the fifth element type_6
- the sixth element type_7
- the seventh element type- Parameters:
_1
- the head element_2
- the second element_3
- the third element_4
- the fourth element_5
- the fifth element_6
- the sixth element_7
- the seventh element- Returns:
- the 7-element HList
- See Also:
Tuple7
-
tuple
public static <_1,_2,_3,_4,_5,_6,_7,_8> Tuple8<_1,_2,_3,_4,_5,_6,_7,_8> tuple(_1 _1, _2 _2, _3 _3, _4 _4, _5 _5, _6 _6, _7 _7, _8 _8)
Static factory method for creating an 8-element HList.- Type Parameters:
_1
- the head element type_2
- the second element type_3
- the third element type_4
- the fourth element type_5
- the fifth element type_6
- the sixth element type_7
- the seventh element type_8
- the eighth element type- Parameters:
_1
- the head element_2
- the second element_3
- the third element_4
- the fourth element_5
- the fifth element_6
- the sixth element_7
- the seventh element_8
- the eighth element- Returns:
- the 8-element HList
- See Also:
Tuple8
-
-