Skip to content

Commit

Permalink
format and fix imports
Browse files Browse the repository at this point in the history
simplify nat for scala 3
  • Loading branch information
hamnis authored and ingarabr committed Sep 11, 2023
1 parent c775ae6 commit 04b9895
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 50 deletions.
6 changes: 6 additions & 0 deletions core/src/main/scala-2/no/nrk/bigquery/internal/package.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright 2020 NRK
*
* SPDX-License-Identifier: Apache-2.0
*/

package no.nrk.bigquery

package object internal {
Expand Down
58 changes: 31 additions & 27 deletions core/src/main/scala-3/no/nrk/bigquery/internal/Nat.scala
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
package no.nrk.bigquery.internal
/*
* Copyright 2020 NRK
*
* SPDX-License-Identifier: Apache-2.0
*/

import scala.compiletime.ops.int.S
package no.nrk.bigquery.internal

trait Nat
sealed 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
}
type _0 = 0 with Nat
type _1 = 1 with Nat
type _2 = 2 with Nat
type _3 = 3 with Nat
type _4 = 4 with Nat
type _5 = 5 with Nat
type _6 = 6 with Nat
type _7 = 7 with Nat
type _8 = 8 with Nat
type _9 = 9 with Nat
type _10 = 10 with Nat
type _11 = 11 with Nat
type _12 = 12 with Nat
type _13 = 13 with Nat
type _14 = 14 with Nat
type _15 = 15 with Nat
type _16 = 16 with Nat
type _17 = 17 with Nat
type _18 = 18 with Nat
type _19 = 19 with Nat
type _20 = 20 with Nat
type _21 = 21 with Nat
type _22 = 22 with Nat
}
10 changes: 7 additions & 3 deletions core/src/main/scala-3/no/nrk/bigquery/internal/Sized.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/*
* Copyright 2020 NRK
*
* SPDX-License-Identifier: Apache-2.0
*/

package no.nrk.bigquery.internal

final class Sized[+Repr, N <: Nat] (val unsized : Repr) {
final class Sized[+Repr, N <: Nat](val unsized: Repr) {
override def toString = unsized.toString

override def equals(other: Any): Boolean =
Expand All @@ -12,12 +18,10 @@ final class Sized[+Repr, N <: Nat] (val unsized : Repr) {
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)

Expand Down
205 changes: 188 additions & 17 deletions core/src/main/scala-3/no/nrk/bigquery/internal/SizedBuilder.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright 2020 NRK
*
* SPDX-License-Identifier: Apache-2.0
*/

package no.nrk.bigquery.internal

class SizedBuilder[CC[_]] {
Expand All @@ -6,22 +12,187 @@ class SizedBuilder[CC[_]] {
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))
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))

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ trait BQShowSyntax extends UdfSyntax {
implicit def bqShowInterpolator(sc: StringContext): BQShow.BQShowInterpolator = new BQShow.BQShowInterpolator(sc)
implicit def bqShowOps[A](a: A): BQShowOps[A] = new BQShowOps[A](a)
implicit def bqFragmentsOps[S[_]: Foldable, A](values: S[A]): FragmentsOps[S, A] = new FragmentsOps(values)
implicit def bqFragmentsOpsIndexedSeq[A](values: IndexedSeq[A]): FragmentsOps[IndexedSeq, A] = new FragmentsOps(
values.toVector)
implicit def bqFilledTableLocalDateOps(fill: BQFilledTable[LocalDate]): BQFilledTableLocalDateOps =
new BQFilledTableLocalDateOps(fill)

Expand All @@ -30,7 +32,7 @@ class BQShowOps[A](a: A) {

/** A way to flatten a list of fragments. The `S` just means it works for any collection data structure
*/
class FragmentsOps[S[_]: Foldable, A](private val values: S[A]) {
class FragmentsOps[+S[_]: Foldable, A](private val values: S[A]) {
def mkFragment(sep: String)(implicit T: BQShow[A]): BQSqlFrag =
mkFragment(BQSqlFrag(sep))

Expand Down
6 changes: 6 additions & 0 deletions core/src/main/scala/no/nrk/bigquery/internal/UdfSyntax.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright 2020 NRK
*
* SPDX-License-Identifier: Apache-2.0
*/

package no.nrk.bigquery.internal

import no.nrk.bigquery.{BQSqlFrag, UDF}
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/no/nrk/bigquery/UDFTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package no.nrk.bigquery

import munit.FunSuite
import no.nrk.bigquery.syntax._
import shapeless._0
import no.nrk.bigquery.internal.nat._0

class UDFTest extends FunSuite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import munit.FunSuite
import no.nrk.bigquery.UpdateOperation.{CreatePersistentUdf, Illegal, UpdatePersistentUdf}
import no.nrk.bigquery._
import no.nrk.bigquery.syntax._
import shapeless._0
import no.nrk.bigquery.internal.nat._0

class UdfUpdateOperationTest extends FunSuite {

Expand Down

0 comments on commit 04b9895

Please sign in to comment.