Where communities thrive


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

    joroKr21 on main

    Update sbt to 1.5.4 Merge pull request #1187 from s… (compare)

  • 08:01
    joroKr21 closed #1187
  • 05:55
    scala-steward opened #1187
  • Jun 09 10:48

    joroKr21 on main

    Update sbt-scalajs, ... to 1.6.0 Merge pull request #1186 from s… (compare)

  • Jun 09 10:48
    joroKr21 closed #1186
  • Jun 08 16:55
    scala-steward opened #1186
  • Jun 02 07:05

    joroKr21 on main

    Update sbt-github-actions to 0.… Regenerate workflow with sbt-gi… Merge pull request #1185 from s… (compare)

  • Jun 02 07:05
    joroKr21 closed #1185
  • Jun 01 21:27
    scala-steward opened #1185
  • Jun 01 11:07

    joroKr21 on main

    Optimize sized.ToHList and ToSi… Merge pull request #1184 from j… (compare)

  • Jun 01 06:09

    joroKr21 on main

    Update sbt to 1.5.3 Merge pull request #1183 from s… (compare)

  • Jun 01 06:09
    joroKr21 closed #1183
  • Jun 01 05:51
    scala-steward opened #1183
  • May 31 19:14

    joroKr21 on 2.3

    Optimize sized.ToHList and ToSi… Merge pull request #1182 from j… (compare)

  • May 31 18:43
    joroKr21 commented #1099
  • May 31 18:41
    joroKr21 commented #1099
  • May 31 18:25
    joroKr21 commented #1099
  • May 31 17:58
    joroKr21 closed #509
  • May 31 15:59
    joroKr21 labeled #1181
  • May 31 11:38
    joroKr21 commented #1181
李霖
@liewhite
trait OptionGiven[T]:
  def give: Option[T]

object OptionGiven:
  given exist[T](using NotGiven[T]): OptionGiven[T] with
    def give = None

  given notExist[T](using t: T): OptionGiven[T] with
    def give = Some(t)
case class A(a:Int)
summon[OptionGiven[Annotations[Modifier,A]]]         //this return a None
李霖
@liewhite
import shapeless3.deriving.*

def f[T](using a: OptionGiven[Annotation[Modifier,T]]) = a

@main def test(): Unit = 
  println(f[A])        // compile error here. No Annotation of type swopen.jsonToolbox.modifier.Modifier for type A
second code piece is OptionGiven[Annotation[Modifier,A]]. my mistake
Thank you for your trouble
Hernancito
@hernansaab
I have a Q here. Are you guys planning to move to shapeless 3.X and bypass shapeless 2.5.X?
is there going to be a release for shapeless 2.4.X?
2 replies
minioadmin
@minioadmin:matrix.org
[m]
    case class User(id: String = UUID.randomUUID().toString)
    val d = Default[User]

    println(d()) // eg. '91afc35e-77e2-458b-b4b9-fc0dece0840f'
    println(d()) // the same value as the previous one '91afc35e-77e2-458b-b4b9-fc0dece0840f'
    println(d()) // the same value as the previous one '91afc35e-77e2-458b-b4b9-fc0dece0840f'
is there a way of defining the case class default value as a lazy evaluatable function?
Ethan
@esuntag:matrix.org
[m]
Just use a def instead of a val, or alternately set it up as a function val d = () => Default[User]
minioadmin
@minioadmin:matrix.org
[m]
Thank you, Ethan . It will definitely work. But the actual issue is with circe.
https://github.com/circe/circe-generic-extras/blob/74c4c0e179316e0f8af3bfb749baacdbcc1a28f1/generic-extras/src/main/scala/io/circe/generic/extras/decoding/ConfiguredDecoder.scala#L159
It is the internal behavior of the lib. In my case, I have only a case class with @ConfiguredJsonCodec and the default value defined like this id: String = UUID.randomUUID().toString. For sure it can be solved with many workarounds (removing the field from the constructor's argument list and use it as the read-only class-level field, custom decoder, etc.). But I am interested in a possibility to handle it within case class logic, not removing the field from the constructor, smth like this case class User(@Default.Lazy id: String]=UUID.randomUUID().toString). I expected that there is something in the shapeless to deal with that case.
minioadmin
@minioadmin:matrix.org
[m]
:point_up: Edit: Thank you, Ethan . It will definitely work. But the actual issue with circe.
https://github.com/circe/circe-generic-extras/blob/74c4c0e179316e0f8af3bfb749baacdbcc1a28f1/generic-extras/src/main/scala/io/circe/generic/extras/decoding/ConfiguredDecoder.scala#L159
It is the internal behavior of the lib. In my case, I have only a case class with @ConfiguredJsonCodec and the default value defined like this id: String = UUID.randomUUID().toString. For sure it can be solved with many workarounds (removing the field from the constructor's argument list and use it as the read-only class-level field, custom decoder, etc.). But I am interested in a possibility to handle it within case class logic, not removing the field from the constructor, smth like this case class User(@Default.Lazy id: String]=UUID.randomUUID().toString). I expected that there is something in the shapeless to deal with that case.
Ethan
@esuntag:matrix.org
[m]
Ah. I'm unfortunately not familiar enough with the mechanics of those to know if there's an automated solution. You should be able to solve it with a newtype and a custom Default instance, but that might not be what you want either
Heikki Vesalainen
@hvesalai

Hello. Is there something I'm doing wrong. Can't get a witness for tuple.IsComposite for the result of tuple.Prepend, i.e. prepend.Out

could not find implicit value for parameter isComp: shapeless.ops.tuple.IsComposite[prepend.Out]

Is there some other way to get back the head of the prepend.Out type. I'm not interested in the tail, so don't need to know its type
Georgi Krastev
@joroKr21
Do you have sample code which fails to compile? It's hard to tell like this
Heikki Vesalainen
@hvesalai
No longer. I ditched the whole design and went with HLists
Georgi Krastev
@joroKr21
Sounds like a good idea anyway :thumbsup:
Francesco Nero
@francesconero

Hello, I’m sorry if this is not the right place to ask but I was wondering if Shapeless had some built-in way of taking a case class and flattening it recursively to a Record (nested case classes or record-like objects as well). I saw the Adjoin typeclass but it seems to only work on hlists and coproducts.

In any case, thanks for such an amazing library!

Georgi Krastev
@joroKr21
Hi this is the right place and welcome! I'm not aware of an existing combinator within shapeless but there are different ways to do this. WDYM by a Record btw - a typed record (in shapeless this is just the result of LabelledGeneric) or more like a Map[String, Any]? I found an example how to flatten a tuple: https://github.com/milessabin/shapeless/blob/main/examples/src/main/scala/shapeless/examples/flatten.scala
Georgi Krastev
@joroKr21
Francesco Nero
@francesconero
Awesome, thanks! Yes I was thinking about a LabelledGeneric in fact, just not directly the result of applying it to a case class, but recursively flattened (so ending up with the spread out fields of the nested case classes if present). Thanks for the link, it’s a great starting point!
Georgi Krastev
@joroKr21
Note that this might lead to multiple fields with the same name
vonchav
@voonchav_gitlab
Hi Georgi, thanks for another refresh. After upgrading to v2.3.5 (from 2.3.4), my compilation now fails at the line of .tupled, with the following error:
Could not find an instance of Invariant for [+A]Product with java.io.Serializable.
I realize this is not enough info. Just wanted to post it here and see if it rings any bell.
I'll need to spend a bit more time debugging on my end and try coming up with a minimal reproducible example before opening an issue.
I did a quick scan on changes in 2.3.5 and noticed there is a backport (I'm guessing for v3) regarding tuple in this release. Not sure if it is related.
Artsiom Miklushou
@mikla
Also have issues with resolving implicits after upgrading to 2.3.5. Trying to break it down and make a minimal reproduction case.
Georgi Krastev
@joroKr21
There could be bugs, this is a rather big release because there were many changes piled up over time. Please open issues to report any problems :pray:
@voonchav_gitlab are you using kittens to derive Invariant?
If you are using kittens please upgrade to 2.3.0
vonchav
@voonchav_gitlab
Thanks Georgi. I use Shapeless mostly. But I do have kittens in the dependency list (I'm experimenting some derivation with kittens). I upgraded both Shapeless and Kittens yesterday. My Shapeless code does some transformation with a tuple of refined types, basically going from a pair of Option[Either[(A, <refined_type>]] to ValidatedNel[A, (Option[<refined_type>], Option[<refined_type>])] (where ValidatedNel is from cats)... It works with Shapeless 2.3.4 (and Kittens 2.2.2) :) ... Yeah, I'll look into a bit more later today and see if I can narrow down the issue and create a small example to reproduce the problem.
vonchav
@voonchav_gitlab
I forgot to answer your question, Georgi. In the module that fails the compilation, it doesn't use kittens (I don't have any imports from kittens). Only Shapeless and cats. So I don't think I'm using kittens to derive Invariant (even though I have kittens in the project).
Georgi Krastev
@joroKr21
I think I already found one bug
Miles Sabin
@milessabin
@/all Typelevel is having another go at moving community discussion from gitter to discord. The general sense is that gitter is sufficiently dysfunctional for enough people (and discord sufficiently functional) to make a move worthwhile.
This room isn't going to go away any time soon, but I think that over time the centre of gravity will most likely shift to discord.
If you'd like to join the TL discord this link will take you there: https://discord.gg/EdKTAwv7.
Geovanny Junio
@geovannyjs
https://discord.gg/EdKTAwv7 => Invite invalid
mpilquist
@mpilquist:matrix.org
[m]
Geovanny Junio
@geovannyjs
Same result, maybe something wrong in my side, it is my first attempt with Discord
mpilquist
@mpilquist:matrix.org
[m]
huh
Geovanny Junio
@geovannyjs
Sorry the noob mistake, my email was not verified yet, everything fine now
mpilquist
@mpilquist:matrix.org
[m]
ah cool!
Geovanny Junio
@geovannyjs
Thank you
Georgi Krastev
@joroKr21
@voonchav_gitlab @mikla I think this is most probably the bug you were experiencing: milessabin/shapeless#1152 - I am very tempted to just cut another release but if you have a way to test if it works for you or for me to reproduce I would hold off.
Found this bug in the update PR for pureconfig: pureconfig/pureconfig#1037
vonchav
@voonchav_gitlab
@joroKr21 Is there a snapshot build that I can download? Alternatively, I can provide the code. Probably need to reproduce the problem in Ammonite. I wonder if I can reproduce it in scastie :)
Georgi Krastev
@joroKr21
Hmm no, looks like we publish snapshots only from main
Let me fix that
vonchav
@voonchav_gitlab
I keep getting this error from Scastie, no matter what version of cats I specify:
sbt.librarymanagement.ResolveException: Error downloading org.typelevel:cats_2.13:2.4.2 Not found
Georgi Krastev
@joroKr21
I think you need cats-core
vonchav
@voonchav_gitlab
yea, probably. I end up importing kittens instead... That's good. I just need to import 2.2.2 and 2.3.0 to see if I can reproduce the problem with 2.3.0. Almost done.
vonchav
@voonchav_gitlab
Alright, I can reproduce the problem in Scastie: https://scastie.scala-lang.org/vELbT0QtQramsGbHMAsW0w
If you go to Build Settings and change kittens to 2.2.2, it will compile and the values will be asserted.
Georgi Krastev
@joroKr21
Awesome - in the meantime there is a snapshot 2.3.5+6-1b1fb4f0-SNAPSHOT
vonchav
@voonchav_gitlab
Cool. Going to try it. Thanks.