macro classDeriveId extends Annotation with StaticAnnotation
This annotation can be used on any kind of object to automatically
create an inner Id tagged FUUID type with convenient methods for
its creation.
This annotation can be used on any kind of object to automatically
create an inner Id tagged FUUID type with convenient methods for
its creation. It also provides implicit instances for cats' Hash,
Order and Show type-classes. All these instances are available
in the enclosing object.
The deriveMeta parameter can be used to control whether to
automatically derive (by setting it to true) a
doobie's Meta
instance for the generated Id type (a dependency with fuuid-doobie
and doobie-postgres will be necessary).
Annotations
@compileTimeOnly(...)@silent("never used")
Example:
For an object named User
object User {
trait IdTag
type Id = shapeless.tag.@@[FUUID, IdTag]
object Id {
//Creates a new `Id` from a `FUUID`def apply(fuuid: FUUID): User.Id = ???
//Creates a new `Id` from an `UUID` literal. This method//uses a macro to compile check the literal valuedef apply(s: String): User.Id = ???
//Creates a random `Id` wrapped in an `F`def random[F[_]: cats.effect.Sync]: F[User.Id] = ???
object Unsafe {
//Creates an unwrapped random `Id`def random: User.Id = ???
}
}
implicitval IdHashOrderShowInstances: Hash[User.Id]
with Order[User.Id] with Show[User.Id] = ???
//If `deriveMeta` is `true`implicitval IdMetaInstance: Meta[User.Id] = ???
}
This annotation can be used on any kind of object to automatically create an inner
Id
taggedFUUID
type with convenient methods for its creation. It also provides implicit instances for cats'Hash
,Order
andShow
type-classes. All these instances are available in the enclosing object.The
deriveMeta
parameter can be used to control whether to automatically derive (by setting it totrue
) a doobie's Meta instance for the generatedId
type (a dependency withfuuid-doobie
anddoobie-postgres
will be necessary).For an object named
User