Mirrors

mill.api.Mirrors
object Mirrors

Attributes

Source
Mirrors.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Mirrors.type

Members list

Type members

Classlikes

final class AutoProduct[T, L <: String, Ns <: Tuple, Ts <: Tuple](from: Product => T) extends Product

Attributes

Source
Mirrors.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
final class AutoSum[T, L <: String, Ns <: Tuple, Ts <: Tuple](ord: T => Int) extends Sum

Attributes

Source
Mirrors.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
@Scaladoc(value = "/** A store for one or more mirrors, with Root type `R`. */")
sealed trait Root[R]

A store for one or more mirrors, with Root type R.

A store for one or more mirrors, with Root type R.

Attributes

Source
Mirrors.scala
Supertypes
class Object
trait Matchable
class Any

Types

@Scaladoc(value = "/** Proof that `T` has a synthetic Mirror in `Root[R]` */")
opaque type Path[R, T <: R]

Proof that T has a synthetic Mirror in Root[R]

Proof that T has a synthetic Mirror in Root[R]

Attributes

Source
Mirrors.scala

Value members

Concrete methods

@Scaladoc(value = "/**\n * generate mirrors for a sealed hierarchy, or a single class. Only optimized for what Mill needs.\n * Does not synthesize mirrors for case classes, or values already extending Mirror.Singleton.\n *\n * This means you pay for only what is needed.\n *\n * Limitations (could be lifted later, but not needed for Mill currently):\n * - sealed children must be static, i.e. no inner classes or local classes.\n * - \"product\" types should not have type parameters.\n *\n * Note: this is not given, so must be explicitly called, which allows to control caching.\n */")
inline def autoRoot[T]: Root[T]

generate mirrors for a sealed hierarchy, or a single class. Only optimized for what Mill needs. Does not synthesize mirrors for case classes, or values already extending Mirror.Singleton.

generate mirrors for a sealed hierarchy, or a single class. Only optimized for what Mill needs. Does not synthesize mirrors for case classes, or values already extending Mirror.Singleton.

This means you pay for only what is needed.

Limitations (could be lifted later, but not needed for Mill currently):

  • sealed children must be static, i.e. no inner classes or local classes.
  • "product" types should not have type parameters.

Note: this is not given, so must be explicitly called, which allows to control caching.

Attributes

Source
Mirrors.scala
def makeRoot[T](ms: Map[String, Mirror]): Root[T]

Attributes

Source
Mirrors.scala

Givens

Givens

@Scaladoc(value = "/**\n * given a `Root[R]`, and a `Path[R, T]`, retrieve a `Mirror.Of[T]`, and cast it with correct refinements.\n * Note that this must be transparent inline to add path-dependent types,\n * therefore to avoid large bytecode blowup it only generates a single method call.\n */")
transparent inline given autoMirror[R, T <: R](using inline h: Root[R], inline p: Path[R, T]): Of[T]

given a Root[R], and a Path[R, T], retrieve a Mirror.Of[T], and cast it with correct refinements. Note that this must be transparent inline to add path-dependent types, therefore to avoid large bytecode blowup it only generates a single method call.

given a Root[R], and a Path[R, T], retrieve a Mirror.Of[T], and cast it with correct refinements. Note that this must be transparent inline to add path-dependent types, therefore to avoid large bytecode blowup it only generates a single method call.

Attributes

Source
Mirrors.scala
@Scaladoc(value = "/** Try to synthesize a proof that `T` has a synthetic Mirror inside of `Root[R]`. */")
transparent inline given autoPath[R, T <: R](using inline h: Root[R]): Path[R, T]

Try to synthesize a proof that T has a synthetic Mirror inside of Root[R].

Try to synthesize a proof that T has a synthetic Mirror inside of Root[R].

Attributes

Source
Mirrors.scala