Intermediate factory that creates an Instances trait based on provided Implicits.
Normally, this factory is used as implicit constructor parameter of base classes for companion objects
of RPC traits (e.g. DefaultRestApiCompanion).
This all serves to reduce boilerplate associated with RPC trait companion declarations and makes RPC trait
definitions as concise as possible. It also lets the programmer easily inject additional implicits into
macro-materialization of RPC-related typeclasses (AsReal, AsRaw, metadata, etc.).
Instances is a trait that aggregates multiple macro materialized typeclass instances.
There is no fixed interface for Instances, its members are inspected by materialize macro and implemented
automatically. Instances must contain only parameterless abstract methods. Return type of each method
must have a companion object which contains materialize macro. That macro will be used to implement
that method.
The Implicits type is typically a trait with a collection of implicit definitions whose companion object
implements that trait, e.g. DefaultRestImplicits.
When the macro implements apply method of MacroInstances contents of Implicits are imported into the
body of apply and visible further by macros that materialize InstancesTrait.
If MacroInstances is accepted as implicit super constructor parameter of a companion object
(which is the typical situation) then this reference should be passed as companion.
This is in order to work around https://github.com/scala/bug/issues/7666
Intermediate factory that creates an
Instances
trait based on providedImplicits
. Normally, this factory is used as implicit constructor parameter of base classes for companion objects of RPC traits (e.g. DefaultRestApiCompanion). This all serves to reduce boilerplate associated with RPC trait companion declarations and makes RPC trait definitions as concise as possible. It also lets the programmer easily inject additional implicits into macro-materialization of RPC-related typeclasses (AsReal
,AsRaw
, metadata, etc.).Instances
is a trait that aggregates multiple macro materialized typeclass instances. There is no fixed interface forInstances
, its members are inspected bymaterialize
macro and implemented automatically.Instances
must contain only parameterless abstract methods. Return type of each method must have a companion object which containsmaterialize
macro. That macro will be used to implement that method.Example of
Instances
: ClientInstancesThe
Implicits
type is typically a trait with a collection of implicit definitions whose companion object implements that trait, e.g. DefaultRestImplicits. When the macro implementsapply
method ofMacroInstances
contents ofImplicits
are imported into the body ofapply
and visible further by macros that materializeInstancesTrait
.If
MacroInstances
is accepted as implicit super constructor parameter of a companion object (which is the typical situation) thenthis
reference should be passed ascompanion
. This is in order to work around https://github.com/scala/bug/issues/7666