simulacrum
package simulacrum
Type Members
- class TypeClassMacros extends AnyRef
-
class
noop extends Annotation with StaticAnnotation
Annotation that may be applied to methods on a type that is annotated with
@typeclass
.Annotation that may be applied to methods on a type that is annotated with
@typeclass
.Doing so results in the method being excluded from the generated syntax ops type.
- Annotations
- @compileTimeOnly( ... )
-
class
op extends Annotation with StaticAnnotation
Annotation that may be applied to methods on a type that is annotated with
@typeclass
.Annotation that may be applied to methods on a type that is annotated with
@typeclass
.Doing so changes the code generation strategy used when generating the syntax ops type. Instead of the type class method name being used, the name specified on this annotation is used. If
alias
is true, two methods are generated, one with the original name and one with the specified name.- Annotations
- @compileTimeOnly( ... )
-
macro
class
typeclass 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.
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 forimplicitly[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 extendsOps
and theOps
traits for any super types. - a trait, named
ToMyTypeClassOps
, which provides an implicit conversion that enables use of theOps
trait. - an object, named
ops
, which provides an implicit conversion to theAllOps
trait.
As a result, the ops can be used by either importing
MyTypeClass.ops._
or by mixingMyTypeClass.ToMyTypeClassOps
in to a type.- Annotations
- @compileTimeOnly( ... )
- an implicit summoning method, providing syntax like