Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 08 2020 13:09

    vlovgr on ce3

    WIP (compare)

  • Dec 08 2020 12:40

    vlovgr on gh-pages

    Deploy website Deploy website … (compare)

  • Dec 08 2020 12:40

    vlovgr on ce3

    Update sbt-mdoc to 2.2.13 Merge pull request #410 from sc… Update cats-effect, cats-effect… and 10 more (compare)

  • Dec 08 2020 12:37

    vlovgr on master

    Update kind-projector to 0.11.2 Change to use kind-projector * … Merge pull request #412 from sc… (compare)

  • Dec 08 2020 12:37
    vlovgr closed #412
  • Dec 08 2020 12:36
    codecov[bot] commented #412
  • Dec 08 2020 12:35

    vlovgr on gh-pages

    Deploy website Deploy website … (compare)

  • Dec 08 2020 12:32
    vlovgr synchronize #412
  • Dec 08 2020 12:31

    vlovgr on master

    Update cats-effect, cats-effect… Merge pull request #411 from sc… (compare)

  • Dec 08 2020 12:31
    vlovgr closed #411
  • Dec 04 2020 19:34

    vlovgr on gh-pages

    Deploy website Deploy website … (compare)

  • Dec 04 2020 19:29

    mergify[bot] on master

    Update sbt-ci-release to 1.5.5 Merge pull request #414 from sc… (compare)

  • Dec 04 2020 19:29
    mergify[bot] closed #414
  • Dec 04 2020 19:29
    codecov[bot] commented #414
  • Dec 04 2020 19:24
    scala-steward opened #414
  • Dec 02 2020 14:10

    vlovgr on gh-pages

    Deploy website Deploy website … (compare)

  • Dec 02 2020 14:05

    mergify[bot] on master

    Update refined to 0.9.19 Merge pull request #413 from sc… (compare)

  • Dec 02 2020 14:05
    mergify[bot] closed #413
  • Dec 02 2020 14:05
    codecov[bot] commented #413
  • Dec 02 2020 13:57
    scala-steward opened #413
Jakub Kozłowski
@kubukoz
Hi @vlovgr, have you investigated providing an Async[ConfigValue] instance? I was wondering if I could use a method like def foo[F[_]: Async] to write a custom config source.
Stack safety of flatMap might be an issue...
hmm, there is FlatMap[ConfigValue] already
I guess final def eval[F[_], A](value: F[ConfigValue[A]])(implicit F: Effect[F]): ConfigValue[A] might be my workaround.
Jakub Kozłowski
@kubukoz
btw. is there no generic derivation in ciris at the moment?
Viktor Rudebeck
@vlovgr
@kubukoz Yes, flatMap cannot be expressed in a stack-safe manner, and also pure would not be what you expect, as discussed here: https://gitter.im/vlovgr/ciris?at=5dc6643b5eb2e813dbf0f3b0
There is no generic derivation, partly because there is no 'one way' to generically read a configuration.
There's also ConfigValue.async if you really need something like Async[ConfigValue].
Jakub Kozłowski
@kubukoz
For derivation, I had "one way" when you have ConfigValue instances for all the fields - but I get that it might be specific to my usecase... Maybe a module with optional derivations would be good to have, so that people don't need to reinvent the wheel if they want that?
Viktor Rudebeck
@vlovgr
I'm not sure it's worth having that to just eliminate some (a, b, c, ...).parMapN(apply). Or is there something I'm missing?
I guess you also run into problems if you have two or more of the same type in your product, but want to read them differently.
Jakub Kozłowski
@kubukoz
it was that parMapN, yeah
two of the same type shouldn't be a problem for me, so I guess it's just one of the patterns
at the root type there will always be distinct types, but I see why it might not be true in the nested ones
have there been any attempts to integrate with cats-effect 3 milestones yet, @vlovgr ?
Viktor Rudebeck
@vlovgr
@kubukoz yes, you can preview at https://github.com/vlovgr/ciris/compare/ce3
Biggest change with that proposal is ConfigValue[+F[_], A], similar to fs2's Stream.
Jakub Kozłowski
@kubukoz
Basically going tagless instead of free?
(didn't click yet, just judging by what the type param can get us)
Viktor Rudebeck
@vlovgr
It's basically because eval/evalMap can't be expressed nicely otherwise.
Viktor Rudebeck
@vlovgr
Pull request for cats-effect 3 and scala 3 is up: vlovgr/ciris#416
Viktor Rudebeck
@vlovgr
Gary Aghedo
@GaryAghedo
Hey Guys, How do you would a config file from ''src/main/resources/abc.conf'' with Ciris?
Does Ciris work with typesafe config?
Viktor Rudebeck
@vlovgr
@GaryAghedo you're probably looking for https://github.com/2m/ciris-hocon.

Let me know if it doesn't exist and is useful and you'd like such a PR

I prefer to use env usually but had to switch a project to files because of security considerations, this little bit came out of that

Viktor Rudebeck
@vlovgr
@dimitarg it's not supported yet, so would definitely welcome a pull request
Dimitar Georgiev
@dimitarg
Cheers. I'm sort of in-between jobs, I think I'd get to it next week
Do you see this as something in core, or a separate module ?
Viktor Rudebeck
@vlovgr
It can definitely be in core.
Roland Manfrahs
@roland.manfrahs_gitlab
Hi @vlovgr
the docs on the microsite at https://cir.is/ state ciris to be available for 3.0.0-RC3 but sbt is unable to fetch it.
Do you have the leisure to release ciris for 3.0.0-RC3?
Viktor Rudebeck
@vlovgr
@roland.manfrahs_gitlab Ciris v2.0.0-RC3 is now out with support for Scala 3.0.0-RC3. Sorry for the delay.
Roland Manfrahs
@roland.manfrahs_gitlab
@vlovgr Thank you so much.
Shah Saraei
@ShahOdin

I have a value I need to encode differently based on some config. lets keep it simple

  case class MyValue(value: String)
  case class MyValueEncodingPrefix(value: String)

is there a nice way of doing this with Ciris? ConfigValue seems to need an Async to load and Circe's Encoder isn't async.

Viktor Rudebeck
@vlovgr
@ShahOdin Is the value also loaded from configuration? ConfigValue only describes how to load a configuration. Normally you would load the configuration first as a separate step, then use that configuration to do something else, e.g. encode a value. In that sense, ConfigValue and Encoder are separate.
Shah Saraei
@ShahOdin
Thanks Victor. yeah! I wanted to avoid having to pass it around specially when MyValue was nested deep inside my type. ended up having implicit def encoder(implicit prefix: MyValueEncodingPrefix) and the liked, and injecting it as config at the top level.
Maatary
@Maatary

Hi,
trying to understand the circe example, but feeling slightly confused:

import ciris.circe._
import ciris.ConfigDecoder
import io.circe.{Decoder, Json}

ConfigDecoder[String, Json]
// res0: ConfigDecoder[String, Json] = ConfigDecoder$2047428395

case class SerialNumber(value: String)

object SerialNumber {
  implicit val serialNumberDecoder: Decoder[SerialNumber] =
    Decoder[String].map(apply)
}

circeConfigDecoder[SerialNumber]("SerialNumber")

My understanding would be that, the circe module would be to parse a string that is actually a json e.g. a json Array, passed as an env variable. However in the example above, i do not see how circe is actually used. I do not see where the json is being produced. Can someone help me understand the example or how the module is supposed to be used. Let say i would like to pass as env variable an array of value, what would be the way to go ?

Dimitar Georgiev
@dimitarg
Should configvalue have a contravariant functor on the input type ?
Dimitar Georgiev
@dimitarg
 def contramap[A, A1, B](decoder: ConfigDecoder[A, B])(f: A1 => A): ConfigDecoder[A1, B] = {
    ConfigDecoder.identity[A1].map(f).mapEither(decoder.decode)
  }
Dimitar Georgiev
@dimitarg
FWIW my specific use-case was
  implicit private def secretDecoder[A](implicit dec: ConfigDecoder[String, A], show: Show[A]): ConfigDecoder[Secret[String], Secret[A]] = {
    contramap(dec)((x: Secret[String]) => x.value).map(Secret(_))
  }
Dimitar Georgiev
@dimitarg
(in case you see a built-in / more straightforward way to achieve the same. But I think the original question still stands)
Dimitar Georgiev
@dimitarg
Viktor Rudebeck
@vlovgr

@Maatary your best bet is probably to put the config decoder as an implicit in the companion object.

case class SerialNumber(value: String)

object SerialNumber {
  implicit val serialNumberDecoder: Decoder[SerialNumber] =
    Decoder[String].map(apply)

  implicit val serialNumberConfigDecoder: ConfigDecoder[String, SerialNumber] =
    circeConfigDecoder("SerialNumber")
}

and then you can e.g. do env("SERIAL").as[SerialNumber]. If you want to decode an array instead, you only need to change the decoder.

Viktor Rudebeck
@vlovgr
Here's an example on how to decode an array.
import ciris.circe._
import ciris.{ConfigDecoder, env}
import io.circe.{Decoder, Json}

ConfigDecoder[String, Json]

case class SerialNumber(value: String)

object SerialNumber {
  implicit val serialNumberDecoder: Decoder[SerialNumber] =
    Decoder[String].map(apply)
}

case class SerialNumbers(toList: List[SerialNumber])

object SerialNumbers {
  implicit val serialNumbersDecoder: Decoder[SerialNumbers] =
    Decoder[List[SerialNumber]].map(apply)

  implicit val serialNumbersConfigDecoder: ConfigDecoder[String, SerialNumbers] =
    circeConfigDecoder("SerialNumbers")
}

env("SERIAL_NUMBERS").as[SerialNumbers]
Joseph Hajduk
@josephhajduk
Is there a way to unsecret a string, im trying to use the aws-secrets module with a json secret
Joseph Hajduk
@josephhajduk
implicit def secretJsonDecoder[A:Decoder]:ConfigDecoder[Secret[String],A] =
    ConfigDecoder.instance[Secret[String],A] {
      case (key, secret) =>
        decode[A](secret.value).left.map(e => ciris.ConfigError(e.getMessage))
    }
I did that instead
Viktor Rudebeck
@vlovgr
@josephhajduk you can also .map(_.value).as[A]