Skip to content

llfrometa89/uuid4s

 
 

Repository files navigation

uuid4s

Build Status Maven Central codecov.io Join the chat at https://gitter.im/pure4s-uuid4s/community GitHub Issues GitHub PR License: MIT HitCount

uuid4s is yet another functional uuid for Scala. It tries to be typeful and purely functional. Java UUID’s aren’t safe and are not referentially transparent. The objetive of this library is provide a set of tools for interacting with FUUID’s.

Installation

Add the following to your build.sbt.

// For Scala 2.11, or 2.12
libraryDependencies += "org.pure4s" %% "uuid4s" % "0.1.3"

Rationale

  1. It's easy to use.
  2. It does not force a specific target context. You can run your computations in any type F[_] that has an instance of cats-effect's Sync[F].
  3. It has documentation.
  4. It's modular.

Modules

Module name Description Version
uuid4s The core functionality of uuid4s 0.1.3
uuid4s-fast Use fast uuid fast-uuid 0.1.3
uuid4s-circe Encode and decode HTTP entities with Circe 0.1.3
uuid4s-http4s Run your HTTP requests with http4s http4s 0.1.3

Usage

Example 1:

import java.util.UUID
import cats.effect.IO
import cats.implicits._
import org.pure4s.uuid4s.FUUID
import org.pure4s.uuid4s.implicits._

object BasicExampleMain extends App {

  //Parsing
  val uuid1: UUID =
    FUUID[IO].fromString("7cfb70a9-0764-4851-a28c-309393aea2eb").unsafeRunSync()

  //Generating
  val uuid2: UUID = FUUID[IO].random.unsafeRunSync()

  //Comparing
  val result1: Boolean = uuid2 < uuid1
  val result2: Boolean = uuid2 <= uuid1
  val result3: Boolean = uuid1 > uuid2
  val result4: Boolean = uuid1 >= uuid2
  val result5: Boolean = uuid1 === uuid1
}

Code of conduct

People are expected to follow the conduct-code when discussing the project on the available communication channels.

About

Functional UUID's for Scala

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 99.0%
  • Shell 1.0%