@@ -85,19 +85,17 @@ inline def findT[C <: Tuple, Label <: Singleton]: Find[C, Label] =
85
85
/** Pick only `TypedColumns` with certain labels */
86
86
type Pick [Columns <: Tuple , Labels <: Tuple ] <: Tuple =
87
87
Labels match
88
- case EmptyTuple => EmptyTuple
89
- case IsSingleton [h] *: t => Find [Columns , h] *: Pick [Columns , t]
90
-
91
- inline def pickT [C <: Tuple , Labels <: Tuple ]: Pick [C , Labels ] =
92
- inline erasedValue[Labels ] match
93
- case _ : EmptyTuple => EmptyTuple
94
- case _ : (IsSingleton [h] *: t) => findT[C , h] *: pickT[C , t]
88
+ case EmptyTuple =>
89
+ EmptyTuple
90
+ case h *: t =>
91
+ h match
92
+ case Singleton => Find [Columns , h & Singleton ] *: Pick [Columns , t]
95
93
96
94
type Reify [C <: Tuple ] <: Tuple =
97
95
C match
98
96
case EmptyTuple =>
99
97
EmptyTuple
100
- case TypedColumn [IsSingleton [n] , a, t, c] *: tail =>
98
+ case TypedColumn [n , a, t, c] *: tail =>
101
99
TypedColumn [n, a, t, c] *: Reify [tail]
102
100
103
101
// WARNING: it doesn't work if there's a type with given instance not
@@ -107,22 +105,22 @@ inline def reifyT[C <: Tuple]: Reify[C] =
107
105
inline erasedValue[C ] match
108
106
case _ : EmptyTuple =>
109
107
EmptyTuple
110
- case _ : (TypedColumn [IsSingleton [n] , a, t, c] *: tail) =>
108
+ case _ : (TypedColumn [n , a, t, c] *: tail) =>
111
109
TypedColumn [n, a, t, c](constValue[n], summonInline[IsColumn [a]]) *: reifyT[tail]
112
110
113
111
type ReifyN [C <: NonEmptyTuple ] <: NonEmptyTuple =
114
112
C match
115
- case TypedColumn [IsSingleton [n] , a, t, c] *: EmptyTuple =>
113
+ case TypedColumn [n , a, t, c] *: EmptyTuple =>
116
114
TypedColumn [n, a, t, c] *: EmptyTuple
117
- case TypedColumn [IsSingleton [n] , a, t, c] *: h2 *: tail =>
115
+ case TypedColumn [n , a, t, c] *: h2 *: tail =>
118
116
TypedColumn [n, a, t, c] *: ReifyN [h2 *: tail]
119
117
120
118
/** Reify a homogenous tuple of `TypedColumn` */
121
119
inline def reifyNT [C <: NonEmptyTuple ]: ReifyN [C ] =
122
120
inline erasedValue[C ] match
123
- case _ : (TypedColumn [IsSingleton [n] , a, t, c] *: EmptyTuple ) =>
121
+ case _ : (TypedColumn [n , a, t, c] *: EmptyTuple ) =>
124
122
TypedColumn [n, a, t, c](constValue[n], summonInline[IsColumn [a]]) *: EmptyTuple
125
- case _ : (TypedColumn [IsSingleton [n] , a, t, c] *: h2 *: tail) =>
123
+ case _ : (TypedColumn [n , a, t, c] *: h2 *: tail) =>
126
124
TypedColumn [n, a, t, c](constValue[n], summonInline[IsColumn [a]]) *: reifyNT[h2 *: tail]
127
125
128
126
type GetNames [C <: Tuple ] <: Tuple =
@@ -141,8 +139,12 @@ inline def getNamesT[C <: Tuple]: GetNames[C] =
141
139
142
140
type GetInNames [I <: NonEmptyTuple ] <: NonEmptyTuple =
143
141
I match
144
- case TypedColumn .In [IsSingleton [n], ? , ? ] *: EmptyTuple => n *: EmptyTuple
145
- case TypedColumn .In [IsSingleton [n], ? , ? ] *: t => n *: GetInNames [t]
142
+ case TypedColumn .In [n, ? , ? ] *: EmptyTuple =>
143
+ n match
144
+ case Singleton => n *: EmptyTuple
145
+ case TypedColumn .In [n, ? , ? ] *: t =>
146
+ n match
147
+ case Singleton => n *: GetInNames [t]
146
148
147
149
/** Match type to transform `(a, b, c, d)` of `TypedColumn.In` into `(((a, b), c), d)` (or `a ~ b ~
148
150
* c ~ d`)
@@ -159,9 +161,6 @@ type TwiddleInGo[I <: Tuple, A <: Tuple] =
159
161
160
162
// Generic operations
161
163
162
- /** Type-level unapply, checking if `T` is a singleton */
163
- type IsSingleton [T <: Singleton ] = T
164
-
165
164
/** If `A` in tuple `T` - return `True` branch, otherwise `False` branch */
166
165
type IfIn [T <: Tuple , A , True , False ] <: True | False = T match
167
166
case EmptyTuple => False
0 commit comments