o

magnolia1

Magnolia

object Magnolia

the object which defines the Magnolia macro

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Magnolia
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. 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 calling Derivation.gen[T] or with implicitly[Typeclass[T]], if the implicit method is imported into the current scope.

    If the gen is not implicit, 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 like Show[T] which take only a single type parameter, Magnolia can also derive typeclass instances for types such as Decoder[Format, Type] which would typically fix the Format parameter while varying the Type 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 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 type Typeclass[T]. The implementation of join 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 to split as to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    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 to split as to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 type Typeclass[T]. The implementation of join 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 to split as to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    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 to split as to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    Derivation { // other definitions implicit def gen[T]: Typeclass[T] = Magnolia.gen[T] } derivation of typeclass instances by calling Derivation.gen[T] or with implicitly[Typeclass[T]], if the implicit method is imported into the current scope.

    If the gen is not implicit, 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 like Show[T] which take only a single type parameter, Magnolia can also derive typeclass instances for types such as Decoder[Format, Type] which would typically fix the Format parameter while varying the Type 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 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 type Typeclass[T]. The implementation of join 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 to split as to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    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 to split as to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 type Typeclass[T]. The implementation of join 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 to split as to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    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 to split as to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

    <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 to join.

    split[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ... additional type parameters and implicit parameters apply equally to split as to join.

  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  16. def toString(): String
    Definition Classes
    AnyRef → Any
  17. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  19. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped