macro classtypeclass extends Annotation with StaticAnnotation
Annotation that may be applied to a trait or class of one type parameter to generate
boilerplate that makes the type class easier to use.
The only type parameter must either by a proper type or a unary type constructor.
Types of other shapes, like binary type constructors, are not currently supported.
As a result of adding this annotation, the following code is generated in the companion:
an implicit summoning method, providing syntax like MyTypeClass[Type] as a
shortcut for implicitly[MyTypeClass[Type]].
a trait, named Ops, which provides object oriented style forwarding
methods -- aka, syntax -- for the methods defined directly on the type class.
a trait, named AllOps, which extends Ops and the Ops traits for any
super types.
a trait, named ToMyTypeClassOps, which provides an implicit conversion
that enables use of the Ops trait.
an object, named ops, which provides an implicit conversion to the
AllOps trait.
As a result, the ops can be used by either importing MyTypeClass.ops._ or
by mixing MyTypeClass.ToMyTypeClassOps in to a type.
Annotation that may be applied to a trait or class of one type parameter to generate boilerplate that makes the type class easier to use.
The only type parameter must either by a proper type or a unary type constructor. Types of other shapes, like binary type constructors, are not currently supported.
As a result of adding this annotation, the following code is generated in the companion:
MyTypeClass[Type]as a shortcut forimplicitly[MyTypeClass[Type]].Ops, which provides object oriented style forwarding methods -- aka, syntax -- for the methods defined directly on the type class.AllOps, which extendsOpsand theOpstraits for any super types.ToMyTypeClassOps, which provides an implicit conversion that enables use of theOpstrait.ops, which provides an implicit conversion to theAllOpstrait.As a result, the ops can be used by either importing
MyTypeClass.ops._or by mixingMyTypeClass.ToMyTypeClassOpsin to a type.