Skip to content

Instantly share code, notes, and snippets.

View 987Nabil's full-sized avatar

Nabil Abdel-Hafeez 987Nabil

  • Rewe Digtial
  • Dortmund
  • 00:28 (UTC +02:00)
View GitHub Profile
@adamgfraser
adamgfraser / hset.scala
Created August 13, 2021 20:18
Type level sets
import scala.annotation.implicitNotFound
import scala.language.implicitConversions
object hset extends App {
type ??? = Nothing
// Set(1, 2, 3) Set of ints
// Set("Adam", "Kit") Set of strings
// "Adam" :*: 1 :*: true :*: HNil
@adamw
adamw / gen.scala
Created September 6, 2022 07:15
How to generate an exhaustive match for a sealed trait in a Scala 3 macro?
// TestMacro.scala
import scala.quoted.*
object TestMacro {
inline def name[E](e: E): String = ${ nameImpl[E]('e) }
def nameImpl[E: Type](e: Expr[E])(using Quotes): Expr[String] = {
import quotes.reflect.*