Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
taig committed Nov 20, 2024
1 parent 229a2d7 commit a2dcf5f
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,36 @@ abstract class EnumerationValues[A]:
object EnumerationValues:
type Aux[A, B] = EnumerationValues[A] { type Out = B }

inline def apply[A](using values: EnumerationValues[A]): EnumerationValues.Aux[A, values.Out] = values

inline def apply[A, B](using values: EnumerationValues.Aux[A, B]): EnumerationValues.Aux[A, B] = values

def apply[A, B](values: NonEmptyList[B]): EnumerationValues.Aux[A, B] = new EnumerationValues[A]:
override type Out = B

override def toNonEmptyList: NonEmptyList[Out] = values

inline given [A](using
mirror: Mirror.SumOf[A],
values: EnumerationValues.Aux[mirror.MirroredElemTypes, A]
): EnumerationValues.Aux[A, A] = new EnumerationValues[A]:
override type Out = A
override val toNonEmptyList: NonEmptyList[A] = values.toNonEmptyList
): EnumerationValues.Aux[A, A] = EnumerationValues(values = values.toNonEmptyList)

inline given singleton[A <: Singleton, B <: Tuple, C >: A](using
values: EnumerationValues.Aux[B, C]
): EnumerationValues.Aux[A *: B, C] = new EnumerationValues[A *: B]:
override type Out = C
override def toNonEmptyList: NonEmptyList[C] = valueOf[A] :: values.toNonEmptyList
): EnumerationValues.Aux[A *: B, C] = EnumerationValues(values = valueOf[A] :: values.toNonEmptyList)

inline given nested[A, B <: Tuple, C >: A](using
mirror: Mirror.SumOf[A],
head: EnumerationValues.Aux[mirror.MirroredElemTypes, C],
tail: EnumerationValues.Aux[B, C]
): EnumerationValues.Aux[A *: B, C] = new EnumerationValues[A *: B]:
override type Out = C
override def toNonEmptyList: NonEmptyList[C] = head.toNonEmptyList.concatNel(tail.toNonEmptyList)
): EnumerationValues.Aux[A *: B, C] = EnumerationValues(values = head.toNonEmptyList.concatNel(tail.toNonEmptyList))

inline given nestedOne[A, B >: A](using
mirror: Mirror.SumOf[A],
head: EnumerationValues.Aux[mirror.MirroredElemTypes, B]
): EnumerationValues.Aux[A *: EmptyTuple, B] = new EnumerationValues[A *: EmptyTuple]:
override type Out = B
override def toNonEmptyList: NonEmptyList[B] = head.toNonEmptyList
): EnumerationValues.Aux[A *: EmptyTuple, B] = EnumerationValues(values = head.toNonEmptyList)

inline given last[A <: Singleton, B >: A]: EnumerationValues.Aux[A *: EmptyTuple, B] =
new EnumerationValues[A *: EmptyTuple]:
override type Out = B
override def toNonEmptyList: NonEmptyList[B] = NonEmptyList.one(valueOf[A])
EnumerationValues(values = NonEmptyList.one(valueOf[A]))

def valuesOf[A](using values: EnumerationValues.Aux[A, A]): NonEmptyList[A] = values.toNonEmptyList

0 comments on commit a2dcf5f

Please sign in to comment.