-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package no.nrk.bigquery | ||
|
||
package object internal { | ||
type Nat = shapeless.Nat | ||
val nat = shapeless.nat | ||
type Sized[+Repr, L <: shapeless.Nat] = shapeless.Sized[Repr, L] | ||
val Sized = shapeless.Sized | ||
type SizedBuilder[CC[_]] = shapeless.SizedBuilder[CC] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package no.nrk.bigquery.internal | ||
|
||
import scala.compiletime.ops.int.S | ||
|
||
trait Nat | ||
|
||
object nat { | ||
|
||
type _0 = S[0] with Nat | ||
type _1 = S[1] with Nat | ||
type _2 = S[2] with Nat | ||
type _3 = S[3] with Nat | ||
type _4 = S[4] with Nat | ||
type _5 = S[5] with Nat | ||
type _6 = S[6] with Nat | ||
type _7 = S[7] with Nat | ||
type _8 = S[8] with Nat | ||
type _9 = S[9] with Nat | ||
type _10 = S[10] with Nat | ||
type _11 = S[11] with Nat | ||
type _12 = S[12] with Nat | ||
type _13 = S[13] with Nat | ||
type _14 = S[14] with Nat | ||
type _15 = S[15] with Nat | ||
type _16 = S[16] with Nat | ||
type _17 = S[17] with Nat | ||
type _18 = S[18] with Nat | ||
type _19 = S[19] with Nat | ||
type _20 = S[20] with Nat | ||
type _21 = S[21] with Nat | ||
type _22 = S[22] with Nat | ||
} |
28 changes: 28 additions & 0 deletions
28
core/src/main/scala-3/no/nrk/bigquery/internal/Sized.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package no.nrk.bigquery.internal | ||
|
||
final class Sized[+Repr, N <: Nat] (val unsized : Repr) { | ||
override def toString = unsized.toString | ||
|
||
override def equals(other: Any): Boolean = | ||
other match { | ||
case o: Sized[_, _] => unsized == o.unsized | ||
case _ => false | ||
} | ||
|
||
override def hashCode: Int = unsized.hashCode | ||
} | ||
|
||
|
||
object Sized { | ||
|
||
def apply[CC[_]] = new SizedBuilder[CC] | ||
|
||
|
||
def wrap[Repr, L <: Nat](r: Repr): Sized[Repr, L] = | ||
new Sized[Repr, L](r) | ||
|
||
extension [A, N <: Nat](sized: Sized[IndexedSeq[A], N]) | ||
def map[B](f: A => B): Sized[IndexedSeq[B], N] = | ||
new Sized[IndexedSeq[B], N](sized.unsized.map(f(_))) | ||
def length: Int = sized.unsized.length | ||
} |
27 changes: 27 additions & 0 deletions
27
core/src/main/scala-3/no/nrk/bigquery/internal/SizedBuilder.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package no.nrk.bigquery.internal | ||
|
||
class SizedBuilder[CC[_]] { | ||
def apply[A](a1: A) = new Sized[IndexedSeq[A], nat._1](IndexedSeq(a1)) | ||
def apply[A](a1: A, a2: A) = new Sized[IndexedSeq[A], nat._2](IndexedSeq(a1, a2)) | ||
def apply[A](a1: A, a2: A, a3: A) = new Sized[IndexedSeq[A], nat._3](IndexedSeq(a1, a2, a3)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A) = new Sized[IndexedSeq[A], nat._4](IndexedSeq(a1, a2, a3, a4)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A) = new Sized[IndexedSeq[A], nat._5](IndexedSeq(a1, a2, a3, a4, a5)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A) = new Sized[IndexedSeq[A], nat._6](IndexedSeq(a1, a2, a3, a4, a5, a6)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A) = new Sized[IndexedSeq[A], nat._7](IndexedSeq(a1, a2, a3, a4, a5, a6, a7)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A) = new Sized[IndexedSeq[A], nat._8](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A) = new Sized[IndexedSeq[A], nat._9](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A) = new Sized[IndexedSeq[A], nat._10](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A) = new Sized[IndexedSeq[A], nat._11](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A) = new Sized[IndexedSeq[A], nat._12](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A) = new Sized[IndexedSeq[A], nat._13](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A, a14: A) = new Sized[IndexedSeq[A], nat._14](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A, a14: A, a15: A) = new Sized[IndexedSeq[A], nat._15](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A, a14: A, a15: A, a16: A) = new Sized[IndexedSeq[A], nat._16](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A, a14: A, a15: A, a16: A, a17: A) = new Sized[IndexedSeq[A], nat._17](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A, a14: A, a15: A, a16: A, a17: A, a18: A) = new Sized[IndexedSeq[A], nat._18](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A, a14: A, a15: A, a16: A, a17: A, a18: A, a19: A) = new Sized[IndexedSeq[A], nat._19](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A, a14: A, a15: A, a16: A, a17: A, a18: A, a19: A, a20: A) = new Sized[IndexedSeq[A], nat._20](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A, a14: A, a15: A, a16: A, a17: A, a18: A, a19: A, a20: A, a21: A) = new Sized[IndexedSeq[A], nat._21](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21)) | ||
def apply[A](a1: A, a2: A, a3: A, a4: A, a5: A, a6: A, a7: A, a8: A, a9: A, a10: A, a11: A, a12: A, a13: A, a14: A, a15: A, a16: A, a17: A, a18: A, a19: A, a20: A, a21: A, a22: A) = new Sized[IndexedSeq[A], nat._22](IndexedSeq(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters