Package

io.chrisdavenport.fuuid

annotation

Permalink

package annotation

Visibility
  1. Public
  2. All

Type Members

  1. macro class DeriveId extends Annotation with StaticAnnotation

    Permalink

    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:
    1. 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 value
             def 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 = ???
             }
         }
         implicit val IdHashOrderShowInstances: Hash[User.Id]
           with Order[User.Id] with Show[User.Id] = ???
         //If `deriveMeta` is `true`
         implicit val IdMetaInstance: Meta[User.Id] = ???
      }

Value Members

  1. object DeriveIdMacros

    Permalink

Ungrouped