typelevel / catapult

https://typelevel.org/catapult/
Apache License 2.0
14 stars 4 forks source link

Circe module for json variation #135

Open zarthross opened 3 months ago

zarthross commented 3 months ago

Would y'all be open to a circe module for json variation to make it easier to work with Json?

zarthross commented 2 months ago

@bplommer Thoughts?

bplommer commented 2 months ago

This is definitely something I think would be good to have. What sort of API do you envisage? I guess the core functionality would be a pair of methods for converting between Circe's Json and LD's LDValue (and that would be a good start for sure) but it feels a bit clumsy still - maybe a pair of extension methods like toCirce and toLDValue would make it nicer to work with, what do you think?

zarthross commented 2 months ago

I thinking along the lines of extension methods for LaunchDarklyClient[F]

implicit class LaunchDarklyClientExt[F[_]: Monad](private val client: LaunchDarklyClient[F]) {
    def circeValueVariation[Ctx: ContextEncoder, A: Encoder: Decoder](
      featureKey: String,
      context: Ctx,
      defaultValue: A,
  ): F[Decoder.Result[A]] = ???

or Just

implicit class LaunchDarklyClientExt[F[_]: MonadThrow](private val client: LaunchDarklyClient[F]) {
    def circeValueVariation[Ctx: ContextEncoder, A: Encoder: Decoder](
      featureKey: String,
      context: Ctx,
      defaultValue: A,
  ): F[A] = ??? // Lift the decoder failure into F