object Magnolia
the object which defines the Magnolia macro
- Alphabetic
- By Inheritance
- Magnolia
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
gen[T](c: Context)(implicit arg0: scala.reflect.macros.whitebox.Context.WeakTypeTag[T]): scala.reflect.macros.whitebox.Context.Tree
derives a generic typeclass instance for the type
T
derives a generic typeclass instance for the type
T
This is a macro definition method which should be bound to a method defined inside a Magnolia generic derivation object, that is, one which defines the methods
join
,split
and the type constructor,Typeclass[_]
. This will typically look like,object Derivation { // other definitions implicit def gen[T]: Typeclass[T] = Magnolia.gen[T] }
which would support automatic derivation of typeclass instances by callingDerivation.gen[T]
or withimplicitly[Typeclass[T]]
, if the implicit method is imported into the current scope.If the
gen
is notimplicit
, semi-auto derivation is used instead, whereby implicits will not be generated outside of this ADT.The definition expects a type constructor called
Typeclass
, taking one *-kinded type parameter to be defined on the same object as a means of determining how the typeclass should be genericized. While this may be obvious for typeclasses likeShow[T]
which take only a single type parameter, Magnolia can also derive typeclass instances for types such asDecoder[Format, Type]
which would typically fix theFormat
parameter while varying theType
parameter.While there is no "interface" for a derivation, in the object-oriented sense, the Magnolia macro expects to be able to call certain methods on the object within which it is bound to a method.
Specifically, for deriving case classes (product types), the macro will attempt to call the
join
method with an instance of CaseClass, like so,<derivation>.join(<caseClass>): Typeclass[T]
That is to say, the macro expects there to exist a method calledjoin
on the derivation object, which may be called with the code above, and for it to return a type which conforms to the typeTypeclass[T]
. The implementation ofjoin
will therefore typically look like this,def join[T](caseClass: CaseClass[Typeclass, T]): Typeclass[T] = ...
however, there is the flexibility to provide additional type parameters or additional implicit parameters to the definition, provided these do not affect its ability to be invoked as described above.Likewise, for deriving sealed traits (coproduct or sum types), the macro will attempt to call the
split
method with an instance of SealedTrait, like so,<derivation>.split(<sealedTrait>): Typeclass[T]
so a definition such as,def split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ...
will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally tosplit
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.split(<sealedTrait>): Typeclass[T] split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally to
split
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.join[T](caseClass: CaseClass[Typeclass, T]): Typeclass[T] = ... parameters or additional implicit parameters to the definition, provided these do not affect its ability to be invoked as described above.
Likewise, for deriving sealed traits (coproduct or sum types), the macro will attempt to call the
split
method with an instance of SealedTrait, like so,<derivation>.split(<sealedTrait>): Typeclass[T]
so a definition such as,def split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ...
will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally tosplit
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.split(<sealedTrait>): Typeclass[T] split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally to
split
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.join(<caseClass>): Typeclass[T] to exist a method called
join
on the derivation object, which may be called with the code above, and for it to return a type which conforms to the typeTypeclass[T]
. The implementation ofjoin
will therefore typically look like this,def join[T](caseClass: CaseClass[Typeclass, T]): Typeclass[T] = ...
however, there is the flexibility to provide additional type parameters or additional implicit parameters to the definition, provided these do not affect its ability to be invoked as described above.Likewise, for deriving sealed traits (coproduct or sum types), the macro will attempt to call the
split
method with an instance of SealedTrait, like so,<derivation>.split(<sealedTrait>): Typeclass[T]
so a definition such as,def split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ...
will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally tosplit
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.split(<sealedTrait>): Typeclass[T] split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally to
split
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.join[T](caseClass: CaseClass[Typeclass, T]): Typeclass[T] = ... parameters or additional implicit parameters to the definition, provided these do not affect its ability to be invoked as described above.
Likewise, for deriving sealed traits (coproduct or sum types), the macro will attempt to call the
split
method with an instance of SealedTrait, like so,<derivation>.split(<sealedTrait>): Typeclass[T]
so a definition such as,def split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ...
will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally tosplit
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.split(<sealedTrait>): Typeclass[T] split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally to
split
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.Derivation { // other definitions implicit def gen[T]: Typeclass[T] = Magnolia.gen[T] } derivation of typeclass instances by calling
Derivation.gen[T]
or withimplicitly[Typeclass[T]]
, if the implicit method is imported into the current scope.If the
gen
is notimplicit
, semi-auto derivation is used instead, whereby implicits will not be generated outside of this ADT.The definition expects a type constructor called
Typeclass
, taking one *-kinded type parameter to be defined on the same object as a means of determining how the typeclass should be genericized. While this may be obvious for typeclasses likeShow[T]
which take only a single type parameter, Magnolia can also derive typeclass instances for types such asDecoder[Format, Type]
which would typically fix theFormat
parameter while varying theType
parameter.While there is no "interface" for a derivation, in the object-oriented sense, the Magnolia macro expects to be able to call certain methods on the object within which it is bound to a method.
Specifically, for deriving case classes (product types), the macro will attempt to call the
join
method with an instance of CaseClass, like so,<derivation>.join(<caseClass>): Typeclass[T]
That is to say, the macro expects there to exist a method calledjoin
on the derivation object, which may be called with the code above, and for it to return a type which conforms to the typeTypeclass[T]
. The implementation ofjoin
will therefore typically look like this,def join[T](caseClass: CaseClass[Typeclass, T]): Typeclass[T] = ...
however, there is the flexibility to provide additional type parameters or additional implicit parameters to the definition, provided these do not affect its ability to be invoked as described above.Likewise, for deriving sealed traits (coproduct or sum types), the macro will attempt to call the
split
method with an instance of SealedTrait, like so,<derivation>.split(<sealedTrait>): Typeclass[T]
so a definition such as,def split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ...
will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally tosplit
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.split(<sealedTrait>): Typeclass[T] split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally to
split
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.join[T](caseClass: CaseClass[Typeclass, T]): Typeclass[T] = ... parameters or additional implicit parameters to the definition, provided these do not affect its ability to be invoked as described above.
Likewise, for deriving sealed traits (coproduct or sum types), the macro will attempt to call the
split
method with an instance of SealedTrait, like so,<derivation>.split(<sealedTrait>): Typeclass[T]
so a definition such as,def split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ...
will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally tosplit
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.split(<sealedTrait>): Typeclass[T] split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally to
split
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.join(<caseClass>): Typeclass[T] to exist a method called
join
on the derivation object, which may be called with the code above, and for it to return a type which conforms to the typeTypeclass[T]
. The implementation ofjoin
will therefore typically look like this,def join[T](caseClass: CaseClass[Typeclass, T]): Typeclass[T] = ...
however, there is the flexibility to provide additional type parameters or additional implicit parameters to the definition, provided these do not affect its ability to be invoked as described above.Likewise, for deriving sealed traits (coproduct or sum types), the macro will attempt to call the
split
method with an instance of SealedTrait, like so,<derivation>.split(<sealedTrait>): Typeclass[T]
so a definition such as,def split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ...
will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally tosplit
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.split(<sealedTrait>): Typeclass[T] split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally to
split
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.join[T](caseClass: CaseClass[Typeclass, T]): Typeclass[T] = ... parameters or additional implicit parameters to the definition, provided these do not affect its ability to be invoked as described above.
Likewise, for deriving sealed traits (coproduct or sum types), the macro will attempt to call the
split
method with an instance of SealedTrait, like so,<derivation>.split(<sealedTrait>): Typeclass[T]
so a definition such as,def split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ...
will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally tosplit
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
.<derivation>.split(<sealedTrait>): Typeclass[T] split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally to
split
as tojoin
.split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to
split
as tojoin
. -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Deprecated Value Members
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated