harness.deriving.OptionalAnnotation.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of harness-deriving_3 Show documentation
Show all versions of harness-deriving_3 Show documentation
Miscellaneous libraries/utilities for Scala.
The newest version!
package harness.deriving
import cats.syntax.option.*
import harness.deriving.internal.AnnotationMacros
import scala.quoted.*
trait OptionalAnnotation[Annotated, Annotation] {
def annotation: Option[Annotation]
}
object OptionalAnnotation {
def apply[Annotated, Annotation](implicit annotation: OptionalAnnotation[Annotated, Annotation]): OptionalAnnotation[Annotated, Annotation] = annotation
def some[Annotated, Annotation](_annotation: Annotation): OptionalAnnotation[Annotated, Annotation] =
new OptionalAnnotation[Annotated, Annotation] {
override def annotation: Option[Annotation] = _annotation.some
}
def none[Annotated, Annotation]: OptionalAnnotation[Annotated, Annotation] =
new OptionalAnnotation[Annotated, Annotation] {
override def annotation: Option[Annotation] = None
}
inline def mkAnnotation[Annotated, Annotation] = ${ AnnotationMacros.mkOptionalAnnotation[Annotated, Annotation] }
inline given [Annotated, Annotation]: OptionalAnnotation[Annotated, Annotation] = mkAnnotation[Annotated, Annotation]
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy