Skip to content

Commit

Permalink
Get rid of Sized and IndexedSeq from APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrohdezma committed Jul 27, 2023
1 parent db00d49 commit 1cd73c4
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,4 @@ private[prometheus4cats] trait ShapelessPolyfill {

val Succ = shapeless.Succ

type Sized[+Repr, L <: Nat] = shapeless.Sized[Repr, L]

val Sized = shapeless.Sized

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ import scala.quoted.*

private[prometheus4cats] trait ShapelessPolyfill {

type Represented[R] = R match {
case IndexedSeq[a] => a
}

type Nat = Int

object Nat {
Expand Down Expand Up @@ -52,22 +48,4 @@ private[prometheus4cats] trait ShapelessPolyfill {
given gt2[A <: Nat, B <: Nat](using GT[A, B]): GT[S[A], S[B]] = new GT[S[A], S[B]] {}
}

type TupleSized[R, A, N <: Int] <: Tuple = N match {
case 0 => EmptyTuple
case S[n] => A *: TupleSized[R, A, n]
}

extension [R, A, N <: Int](s: TupleSized[R, A, N]) {
def unsized: IndexedSeq[A] =
s.productIterator.toIndexedSeq.asInstanceOf[IndexedSeq[A]]
def :+(a: A): TupleSized[R, A, N + 1] =
(s :* a).asInstanceOf[TupleSized[R, A, N + 1]]
}

type Sized[Repr, L <: Nat] = TupleSized[Repr, Represented[Repr], L]

object Sized {
def apply[A](a1: A): Sized[IndexedSeq[A], 1] = Tuple1(a1)
}

}
Loading

0 comments on commit 1cd73c4

Please sign in to comment.