Packages

o

magnolia

Magnolia

object Magnolia

the object which defines the Magnolia macro

Linear Supertypes
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. final def checkParamLengths(fieldValues: Seq[Any], paramsLength: Int, typeName: String): Unit
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. 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 combine, dispatch 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 combine method with an instance of CaseClass, like so,

       <derivation>.combine(<caseClass>): Typeclass[T]
    
    That is to say, the macro expects there to exist a method called combine 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 combine will therefore typically look like this,
       def combine[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 dispatch method with an instance of SealedTrait, like so,

       <derivation>.dispatch(<sealedTrait>): Typeclass[T]
    
    so a definition such as,
       def dispatch[T](sealedTrait: SealedTrait[Typeclass, T]): Typeclass[T] = ...
    
    will suffice, however the qualifications regarding additional type parameters and implicit parameters apply equally to dispatch as to combine.

  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def keepLeft[A, B](values: Either[A, B]*): List[A]
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. def param[Tc[_], T, P](name: String, idx: Int, isRepeated: Boolean, typeclassParam: CallByNeed[Tc[P]], defaultVal: CallByNeed[Option[P]], annotationsArrayParam: Array[Any]): Param[Tc, T]

    constructs a new Param instance

    constructs a new Param instance

    This method is intended to be called only from code generated by the Magnolia macro, and should not be called directly from users' code.

  19. def subtype[Tc[_], T, S <: T](name: TypeName, idx: Int, anns: Array[Any], tc: CallByNeed[Tc[S]], isType: (T) ⇒ Boolean, asType: (T) ⇒ S): Subtype[Tc, T]

    constructs a new Subtype instance

    constructs a new Subtype instance

    This method is intended to be called only from code generated by the Magnolia macro, and should not be called directly from users' code.

  20. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  21. def toString(): String
    Definition Classes
    AnyRef → Any
  22. def valueParam[Tc[_], T, P](name: String, deref: (T) ⇒ P, isRepeated: Boolean, typeclassParam: CallByNeed[Tc[P]], defaultVal: CallByNeed[Option[P]], annotationsArrayParam: Array[Any]): Param[Tc, T]
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped