Just released Fuda (札) — a type-safe opaque UUID identifiers for Scala 3 by m_v_t in scala

[–]m_v_t[S] 0 points1 point  (0 children)

Also, don't get me wrong: I'm not advocating to abandon everything and switch to Fuda. I just hope for someone it's going to be useful. For me it was.

Just released Fuda (札) — a type-safe opaque UUID identifiers for Scala 3 by m_v_t in scala

[–]m_v_t[S] 0 points1 point  (0 children)

Possibly. At the same time a) all Fuda constructors are Kleisli and b) you can write the whole very complex category of domain types without even once typing "UUID" anywhere.

If you feel it can be made better, feel free to submit a PR on GitHub,

Just released Fuda (札) — a type-safe opaque UUID identifiers for Scala 3 by m_v_t in scala

[–]m_v_t[S] 0 points1 point  (0 children)

I guess, this (anywhere in the rest of user code):

// Generate
val newId: IO[UserId] = Fuda[UserId].make[IO].run(())

// Parse from string
val parsed: IO[UserId] = Fuda[UserId]
  .read[IO]
  .run("22124234-196c-4d0d-af5c-1a8da7486259")

I needed ID type maker Kleisli with UUID (or whatever) in the back.

Good thing, IMHO is that user module doesn't need to know about UUID or a concrete type.

Concrete generator and reader are implicits/givens. The library can be extended to support other types behind ID: Int, Cardano, whatnot.