Discord is now Scala’s main chat platform. Please join us at https://discord.com/invite/scala
Found: _$1.T
| Required: GetType[T²]
|
| where: T is a type in trait MappedTo with bounds <: Id
| T² is a type in given instance extract with bounds <: MappedTo[?]
|
|
| Note: a match type could not be fully reduced:
|
| trying to reduce GetType[T]
| failed since selector T
| does not match case MappedTo[Int] => Int
| and cannot be shown to be disjoint from it either.
| Therefore, reduction cannot advance to the remaining cases
|
| case MappedTo[Long] => Long
| case MappedTo[java.util.UUID] => java.util.UUID
So, in val map: T => GetType[T]
, T is unknown and therefore the match type fails.
I guess I'm looking for a lazy Match Type if that makes sense, or is even possible.
I just found some interesting behavior in Scala 3.
infix case class ~[T1, T2](_1: T1, _2: T2)
def main(): Unit =
val ab: Int ~ Int = ~(1, 3)
println(ab)
results in value unary_~ is not a member of (Int, Int)
. In other words, ~(1, 3)
is getting parsed as unary_~
plus Tuple2(1, 3)
instead of function name ~
+ arguments (1, 3)
. Is this a change in how Scala 3 parses, a known bug, or have I discovered something interesting?
~.apply(1, 3)
seems to work as a workaround, but is a little annoying.
~ is already defined as object ~ in /path/to/the/scala/file
Hello there! I just started poking around with Scala and sbt
, but am running into some gnarly errors right out of the box that I'm finding hard to diagnose.
First, I installed sbt
via Homebrew (I'm on OSX) and followed the instructions in this example project: https://github.com/tototoshi/sbt-hot-reload-example
At first, it worked like a charm. Then I came back to it a few minutes later, did another cd framework && sbt publishLocal && cd ../app && sbt run
, and got the following error:
INFO: No global web.xml found
Dec 06, 2021 7:08:26 PM org.apache.tomcat.util.scan.StandardJarScanner processURLs
WARNING: Failed to scan [file:/Users/ths/.sbt/boot/scala-2.12.14/org.scala-sbt/sbt/1.5.5/scala-reflect.jar] from classloader hierarchy
java.io.IOException: java.lang.reflect.InvocationTargetException
at org.apache.tomcat.util.compat.Jre9Compat.jarFileNewInstance(Jre9Compat.java:209)
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:383)
at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:318)
at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java
Like it's looking for a JAR but not finding it.
sbt
, installing it via sdk
instead, but to no avail.
import
statements in Scala 3? I checked the implicit-resolution
document but that does not seem very enlightening.
Hey there, I'm having an odd problem with taking user input in the terminal. I'm using scala.io.StdIn.readLine()
method to prompt the user for interaction but it doesn't work as expected. I can type something in and press ENTER but nothing happens afterwards. Looks like everything after the readLine()
is not being called anymore.
I'm on Ubuntu 18.04 LTS using Java 11 and Scala 2 and 3. I also tried to google the problem but I couldn't find a solution yet. I was hoping that someone here had the same strange issue and might have a solution.
bash
broken?import scala.io.StdIn.readLine
object ConsoleApp extends App {
print("Enter your first name: ")
val firstName = readLine()
// This is never run. Why?
print("Enter your last name: ")
val lastName = readLine()
println(s"Your name is $firstName $lastName")
}
I have a multi project sbt as such
lazy val root = (project in file(".")).settings().aggregate(foo, bar).dependsOn(foo, bar)
// sub-project in the Foo subdirectory
lazy val foo = (project in file("Foo")).settings()
// sub-project in the Bar subdirectory
lazy val bar = (project in file("Bar")).settings()
I created a case class inside bar
module simply
object Models {
case class Example(s:String)
}
When i try to refer to it in root
module
package com.example.root
import Models._
case class RootExample(example: Example)
I get
not found: object Models
not found: type Example
This is very puzzling. Why are classes in foo
not visible in root
even though i specified dependsOn
in sbt
#tooling
channel of the Discord server: https://discord.gg/7aUsmzyD
ConsoleApp.scala
in a folder alone.
scalac ConsoleApp.scala
scala ConsoleApp
sbt publish
will push the maven style project to one remote repository if the build agent is a Jenkins and a different remote repository if the build agent is a GitHub action. I've spent about 6 hours on this today and I don't feel like I really understand much more about SBT and how to modify the behavior of sbt publish
. Does anyone here have good example sbt projects or suggestions for learning more in regard to what I am trying to do?
#tooling
channel of the discord server.
publishTo := { if (isJenkins) Some(...) else Some(...) }
x
and a deserialized class object o
fetched from a database. The fetch is polymorphic in that the object can be one of two distinct types, I don't know which one ahead of time. o
has a method .foo(x)
that expects a specific type of a value, depending on the type of o
, and for that it has a safeguard method transparent inline cast[A](a: A) = inline erasedValue[A] match {...}
. The question: given that the object is only known at runtime, is inlining going to do any good, or am I grossly misunderstanding it?