diff --git a/core/src/main/scala-2/no/nrk/bigquery/internal/package.scala b/core/src/main/scala-2/no/nrk/bigquery/internal/package.scala new file mode 100644 index 00000000..5c8a649c --- /dev/null +++ b/core/src/main/scala-2/no/nrk/bigquery/internal/package.scala @@ -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] +} diff --git a/core/src/main/scala-3/no/nrk/bigquery/internal/Nat.scala b/core/src/main/scala-3/no/nrk/bigquery/internal/Nat.scala new file mode 100644 index 00000000..19b6e343 --- /dev/null +++ b/core/src/main/scala-3/no/nrk/bigquery/internal/Nat.scala @@ -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 +} \ No newline at end of file diff --git a/core/src/main/scala-3/no/nrk/bigquery/internal/Sized.scala b/core/src/main/scala-3/no/nrk/bigquery/internal/Sized.scala new file mode 100644 index 00000000..a264f187 --- /dev/null +++ b/core/src/main/scala-3/no/nrk/bigquery/internal/Sized.scala @@ -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 +} diff --git a/core/src/main/scala-3/no/nrk/bigquery/internal/SizedBuilder.scala b/core/src/main/scala-3/no/nrk/bigquery/internal/SizedBuilder.scala new file mode 100644 index 00000000..3edc2d8f --- /dev/null +++ b/core/src/main/scala-3/no/nrk/bigquery/internal/SizedBuilder.scala @@ -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)) + +} diff --git a/core/src/main/scala/no/nrk/bigquery/UDF.scala b/core/src/main/scala/no/nrk/bigquery/UDF.scala index 29b39ff3..033b160b 100644 --- a/core/src/main/scala/no/nrk/bigquery/UDF.scala +++ b/core/src/main/scala/no/nrk/bigquery/UDF.scala @@ -6,8 +6,8 @@ import cats.Show import no.nrk.bigquery.UDF._ import no.nrk.bigquery.UDF.UDFId._ import no.nrk.bigquery.syntax._ -import shapeless.{Nat, Sized, SizedBuilder} -import shapeless.nat. _0 +import no.nrk.bigquery.internal.{Nat, Sized, SizedBuilder} +import no.nrk.bigquery.internal.nat._0 /** The UDF has an apply method rendering a BQSqlFrag that matches the size of `params`. * diff --git a/core/src/main/scala/no/nrk/bigquery/internal/UdfSyntax.scala b/core/src/main/scala/no/nrk/bigquery/internal/UdfSyntax.scala index ae8dde55..eb4dae21 100644 --- a/core/src/main/scala/no/nrk/bigquery/internal/UdfSyntax.scala +++ b/core/src/main/scala/no/nrk/bigquery/internal/UdfSyntax.scala @@ -1,7 +1,7 @@ package no.nrk.bigquery.internal import no.nrk.bigquery.{BQSqlFrag, UDF} -import shapeless.nat._ +import no.nrk.bigquery.internal.nat._ trait UdfSyntax { implicit def bqUdfOps0(udf: UDF[UDF.UDFId, _0]): UdfOps0 = new UdfOps0(udf)