Created
May 19, 2021 12:59
-
-
Save kubukoz/5fe00d447ef0f80dbbad68324b390a1e to your computer and use it in GitHub Desktop.
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
trait Labels[S] { | |
def label(v: S): String | |
} | |
object Labels { | |
import scala.deriving.* | |
import scala.compiletime.* | |
inline def derived[T](using s: Mirror.SumOf[T]): Labels[T] = | |
a => summonAll[scala.Tuple.Map[s.MirroredElemLabels, ValueOf]].toList(s.ordinal(a)).asInstanceOf[ValueOf[String]].value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment