Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 15 19:04
    NthPortal review_requested #9786
  • Oct 15 17:20
    Kordyjan commented #1284
  • Oct 15 17:14
    Kordyjan synchronize #1284
  • Oct 15 17:13
    Kordyjan opened #1284
  • Oct 15 16:31
    som-snytt commented #12473
  • Oct 15 15:22
    NthPortal commented #12473
  • Oct 15 15:18
    NthPortal commented #12473
  • Oct 15 15:16
    NthPortal commented #12473
  • Oct 15 15:15
    NthPortal commented #12473
  • Oct 15 15:11
    NthPortal commented #12473
  • Oct 15 14:49
    ches commented #12378
  • Oct 15 13:15
    bishabosha edited #2205
  • Oct 15 13:15
    bishabosha assigned #2205
  • Oct 15 13:14
    bishabosha review_requested #2205
  • Oct 15 13:14
    bishabosha review_requested #2205
  • Oct 15 13:14
    bishabosha opened #2205
  • Oct 15 11:15

    bishabosha on main

    simplify sbt cheatsheet eliminate we from scala 3 guide implement suggestions and 8 more (compare)

  • Oct 15 11:15
    bishabosha closed #2202
  • Oct 15 02:06
    SethTisue commented #10831
  • Oct 15 02:06
    SethTisue closed #10831
oscar-broman
@oscar-broman
stdlib-golf
martijn.hoekstra.zivver
@martijn.hoekstra.zivver:matrix.org
[m]
we Idris now boys
Hanns Holger Rutz
@Sciss

I suddenly have a new problem with native packager and jdeps:

[info] Running: jdeps --multi-release 11 -R ...
[error] Exception in thread "main" java.lang.module.FindException: Module java.activation not found, required by java.xml.bind
[error]     at java.base/java.lang.module.Resolver.findFail(Resolver.java:877)
[error]     at java.base/java.lang.module.Resolver.resolve(Resolver.java:191)
[error]     at java.base/java.lang.module.Resolver.resolve(Resolver.java:140)
[error]     at java.base/java.lang.module.Configuration.resolve(Configuration.java:422)
[error]     at java.base/java.lang.module.Configuration.resolve(Configuration.java:256)
[error]     at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:564)
[error]     at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:603)
[error]     at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:557)
[error]     at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:533)
[error]     at jdk.jdeps/com.sun.tools.jdeps.Main.run(Main.java:64)
[error]     at jdk.jdeps/com.sun.tools.jdeps.Main$JDepsToolProvider.run(Main.java:73)
[error]     at java.base/java.util.spi.ToolProvider.run(ToolProvider.java:137)
[error]     at ru.eldis.toollauncher.ToolLauncher.runTool(ToolLauncher.java:68)
[error]     at ru.eldis.toollauncher.ToolLauncher.lambda$main$1(ToolLauncher.java:33)
[error]     at ru.eldis.toollauncher.ToolLauncher.main(ToolLauncher.java:48)

Urgently need help fixing this. Any ideas what is causing this, and how to fix it? I tried different OpenJDK 11 minor versions now, no luck, I don't think this is root of the problem.

Is very weird, because this problem didn't exist in february when I last did a full native package process; at the same using native-packager 1.8.0, and I try again with the same version, and this problem persists. I'm clueless.
Hanns Holger Rutz
@Sciss
Like, I even revert everything to the state of Feburary when I successfully built: sbt 1.4.7, sbt-native-package 1.8.0, OpenJDK 11.0.9+11. how can this no longer work? is it a cache problem? I tried sbt clean but perhaps that's not enough.
Hanns Holger Rutz
@Sciss

O-kay. I think it comes from newer versions in my dependencies. Anyone got an idea:

[info]   | +-de.sciss:lucre-pi_2.13:1.7.0 [S]
[info]   | | +-com.pi4j:pi4j-core:1.4
[info]   | | | +-javax.xml.bind:jaxb-api:2.3.1
[info]   | | |   +-javax.activation:javax.activation-api:1.2.0

I suspect this is the root of the problem. Why would this cause Module java.activation not found, required by java.xml.bind in jlink?

I'm a bit dumb regarding Java modules. Why would javax.xml.bind translate to java.xml.bind and javax.activation translate to java.activation, and why is the latter missing?
Hanns Holger Rutz
@Sciss
Alright, I can suppress with "de.sciss" %% "lucre-pi" % "1.7.0" exclude ("javax.xml.bind", "jaxb-api"). But I would still like to know how I can properly include java.activation.
Vsevolod Kvachev
@Rasie1

How to reference scala enums from other jvm languages? Enum is defined like that in scala:

object MyOuter extends BlahBlah {
  object MyEnum extends Enumeration {
    val Option1, Option2 = Value
  }
}

And decompiled into this:

object MyOuter extends scala.AnyRef with BlahBlah {
  object MyEnum extends scala.Enumeration {
    val Option1 : MyEnum.Value = { /* compiled code */ }
    val Option2 : MyEnum.Value = { /* compiled code */ }
  }
}

I try, for example,

val x: MyOuter.MyEnum
val y = MyOuter.MyEnum.Option1()

And, compiler gives unresolved reference for MyEnum symbol. Also, linter in android studio recognizes it and even suggests completion for MyOuter.MyEnum. How is it possible? Is it a bug?

martijn.hoekstra.zivver
@martijn.hoekstra.zivver:matrix.org
[m]
@Rasie1: to a close approximation, nobody uses Enumeration. It's not very good.
maybe you can access MyOuter.MyEnum as MyOuter.MyEnum$
(there isn't much education in that educated guess)
Vsevolod Kvachev
@Rasie1

Thanks,

MyOuter.`MyEnum$`.`MODULE$`.Option1()

does work in Kotlin

Seth Tisue
@SethTisue

@SethTisue : Have you personally setup an Akka cluster before?

no, I know very little about distributed systems. but if you don't get help here, maybe try https://discuss.lightbend.com

I now want to know if the supported features (and limitations) described there are for all code in the scala 3 sub project or only for the public types and methods that the 2.13-project will access directly?

@PerWiklander only for the public types and methods the 2.13 project will access directly

Seth Tisue
@SethTisue
@Rasie1 seconded that Enumeration is pretty janky stuff. but Scala 3 has a very nice enum feature https://docs.scala-lang.org/scala3/reference/enums/enums.html
erglkjef
@erglkjef:matrix.org
[m]
I had a function returning a union type, and now I'm trying to add error handling by having it return an either. How do I return a union type in Right? This won't compile: https://scastie.scala-lang.org/hEIzMNDOSVaRSgxSwhGYAw
Furthermore, how do I test for the inner union type when evaluating the returned value from getTestType?
Luis Miguel Mejía Suárez
@BalmungSan
@erglkjef:matrix.org A and B are not a TestType maybe you missed an extends?
Also there are no union types there.
erglkjef
@erglkjef:matrix.org
[m]
thank you
wouldn't that TestType is A or B make it union type?
eric-bzb
@eric-bzb
is this the expected behavior?
for { a <- (0 to 20).map(_ * 2)} yield a gives 0,2,3,4... : IndexedSeq[Int] (so far so good), but when adding an additional statement such as for {a <- (0 to 20).map(_ * 2); b <- (0 to 20).map(_ => scala.util.Random.nextBoolean()} yield (a,b) I get something odd...all the as are zero but they should be 0,2,4,6.. I made a scastie here: https://scastie.scala-lang.org/hhfQSM50TpeLvKj0lJKLgg
som-snytt
@som-snytt
scala> for {a <- (0 to 20).map(_ * 2); b <- (0 to 20).map(_ => scala.util.Random.nextBoolean())} yield (a,b)
val res0: IndexedSeq[(Int, Boolean)] = Vector((0,true), (0,true), (0,true), (0,true), (0,false), (0,false), (0,false), (0,true), (0,false), (0,true), (0,false), (0,true), (0,true), (0,true), (0,true), (0,true), (0,false), (0,true), (0,true), (0,false), (0,true), (2,true), (2,true), (2,false), (2,true), (2,true), (2,false), (2,false), (2,true), (2,false), (2,true), (2,true), (2,false), (2,true), (2,true), (2,false), (2,false), (2,true), (2,false), (2,true), (2,true), (2,true), (4,true), (4,true), (4,true), (4,false), (4,true), (4,false), (4,false), (4,false), (4,false), (4,false), (4,true), (4,false), (4,true), (4,true), (4,false), (4,true), (4,false), (4,false), (4,true), (4,true), (4,false), (6,true), (6,true), (6,false), (6,false), (6,true), (6,true), (6,true), (6,false), (6,true), (6,true), (6,false), (6,false), (6,true), (6,false), (6,true), (6,true), (6,false), (6,false), (6,true), (6,true), (6,false), (8,true), (8,false), (8,true), (8,false), (8,false), (8,false), (8,true), (8,true), (8,false), (8,true), (8,false), ( ... large output truncated, print value to show all
Don't actually know what it means ... large output truncated, print value to show all
eric-bzb
@eric-bzb

whoops, i figured it out (must have not had enough coffee today or something)...this works as expected:

for {
  a <- (0 to 20).map(_ * 2)
  b = scala.util.Random.nextBoolean()
  } yield (a,b) 
res8: IndexedSeq[(Int, Boolean)] = Vector(
  (0, false),
  (2, false),
....
  (18, true),

The first one up there is creating 441 entries which is not what I intended. This one properly just creates the 21 entries

Kolja
@koljamaier

Yeah for these statements it is sometimes enlightning to see the desugared version which would be something like that in this case:

val a = (0 to 20).toList.map(_ * 2)
    .flatMap(a =>
      (0 to 20).toList.map(_ => scala.util.Random.nextBoolean())
        .map(b => Tuple2.apply(a, b))
)

So here you clearly see that the input on the second function is already nested.
Also remind that the last statement in a for comprehension is resolved to a map anyways (all compositions before will be translated to a flatMap)

eric-bzb
@eric-bzb
@koljamaier yes, thanks. I ended up just desugaring it as well and it quickly reminded me the issue :-). I'm so used to using for comprehensions in the context of other non-list-like monads (IO etc) that I forgot how to do it on a list-like datastructure lol
1 reply
zeroexcuses
@zeroexcuses
In Try/Else/Failure, does Failure incur the cost of copying the stack frame ? https://docs.scala-lang.org/overviews/scala-book/functional-error-handling.html
zeroexcuses
@zeroexcuses
import scala.swing._

class UI extends MainFrame {
  title = "GUI Program #1"
  preferredSize =  new Dimension(320, 240)
  contents = new Label("Here is the contents!")
}


object GuiProgram_1 {
  def main(args: Array[String]): Unit = {
    val ui = new UI
    ui.visible = true
    println("End of main function")
  }
}
Why does title/contents show up in red (as if an error) in IntelliJ, whilethe code runs fine.
Luis Miguel Mejía Suárez
@BalmungSan
Because IntelliJ is not a real compiler and thus may have errors?
nafg
@naftoligug:matrix.org
[m]
It's true that there are some advanced scala features that intellij doesn't understand perfectly, but it's strange that this would be one of them.
@zeroexcuses: IMO it's more likely that you don't have the project configured correctly somehow
zeroexcuses
@zeroexcuses

Because IntelliJ is not a real compiler and thus may have errors?

@BalmungSan : Is this a known issue (with issue #) or are you guessing ?

Luis Miguel Mejía Suárez
@BalmungSan
Guessing, I don't like big IDEs so I haven't used it too much.
I have just seen many people with many errors over the years.
som-snytt
@som-snytt
tfw you work on a tool and someone says yeah but it's not a real compiler.
nafg
@naftoligug:matrix.org
[m]
It's not a compiler at all and doesn't claim to be. A compiler produces runnable artifacts. IntelliJ just checks your code for problems
IntelliJ getting things wrong nowadays is really uncommon in my experience, mainly in very typelevel code. Also you can change it to use scalac instead of its own typechecker (one way is via bsp) but then you lose IntelliJ's nice inspections etc.
zeroexcuses
@zeroexcuses
yeah, the crazy thing is that putting the cursor over prefereedSize, I can jump to def, but somehow it is not finding title / contents
Hanns Holger Rutz
@Sciss
@zeroexcuses is your project sbt based? have you tried exiting IntelliJ and opening it again? Sometimes it doesn't pick up library (dependency) changes when you edit the build file while you have the project open. What does it say when you hover over the red method names?
zeroexcuses
@zeroexcuses

@Sciss : it is based on mill, I have executed

        rm -rf .bsp .idea
        mill mill.scalalib.GenIdea/idea

I have also restarted IntelliJ.

Crazy thing is that it gets 1/3 but misses the other 2.

Hanns Holger Rutz
@Sciss
Hmmm. No idea about mill. Can you paste a small screenshot? Does the problem persist when you write extends Frame instead or extends scala.swing.MainFrame?
nafg
@naftoligug:matrix.org
[m]
You can also try creating it as a BSP project which I think Mill supports but I'm not sure offhand how to do it
Florian Schmaus
@Flow_gitlab

I feel like there is potentially a more idiomatic way to write

val overallMin = data.reduce((l, r) => if (l.processed.duration.min < r.processed.duration.min) l else r)

Any suggestions? :)

2 replies
Alexander Morozov
@archimed-shaman
Hi, is there any way to configure circe codecs with scala 3? Looks like circe-generic-extras is available only for 2.13.
Per Wiklander
@PerWiklander

I have abunch of these today:

trait Identifier { def value: String }
case class ItemId(value: String) extends Identifier
case class Item(id: ItemId, …)

With Scala 3 I am tempted to do

opaque type ItemId = String

But how do I keep the ability to treat it as a an Identifier( which is needed in other places)?

zhukovgreen
@zhukovgreen

Hello! I need to mock (scalamock) isPartitionsAvailable from:

object SparkUtils {
  private val log = LoggerFactory.getLogger(this.getClass)


  def isPartitionAvailable(basePath: String,
                           infoDateColumnName: String,
                           infoDateValue: LocalDate,
                           dateFormatPattern: String = "yyyy-MM-dd")
                          (implicit spark: SparkSession): Boolean = {
    val fullPath = getPartitionPath(basePath, infoDateColumnName, infoDateValue, dateFormatPattern)

    log.info(s"Checking $fullPath...")
    val fs = FileSystem.get(spark.sparkContext.hadoopConfiguration)
    fs.exists(new HadoopPath(fullPath))
  }

I tried

    val sparkUtils = mock[SparkUtils]
    (sparkUtils
      .isPartitionAvailable(_: String, _: String, _: LocalDate, _: String)(_: SparkSession))
      .expects(*, *, *, *, *)
      .returning(true)

but simply can't solve the problem when it is the object. I tried creating accompanied trait with the same method, but it still ignores the mock

Also tried to mock the fs.exists by:

    val fileSystem = mock[LocalFileSystem]
    (fileSystem.exists(_: Path)).expects(*).throws(new IllegalArgumentException("IAM"))

but got NullPointerException at val fileSystem = mock[LocalFileSystem] line

Artie Pesh-Imam
@apeshimam
Any quill users out there? I'm trying to work through how to create some raw codecs for jsonb