Questions tagged [scala-2.13]

Version 2.13 of the Scala programming language. Use for questions particularly addressing features of this version of Scala.

Scala 2.13 brings improvements in

  • compiler performance
  • simplifying the collections
  • modularizing the standard library
  • user-friendliness
100 questions
0
votes
0 answers

In cats-effect, what is the safer alternative of `IO.unsafeRunCancelable`?

In cats-effect 2, the safer alternative to this function would be IO.runCancelable. In cats-effect 3, this API was replaced by its unsafe variant or a Dispatcher implementation, according to the following…
tribbloid
  • 4,026
  • 14
  • 64
  • 103
0
votes
1 answer

How to define induction on natural numbers in Scala 2.13?

Consider the following definition of natural numbers. sealed trait Nat final case object Z extends Nat final case class S[N <: Nat]() extends Nat And the following definition of vectors. sealed trait Vec[N <: Nat, +A] final case object Nil…
Aadit M Shah
  • 72,912
  • 30
  • 168
  • 299
0
votes
1 answer

In Scala 2.13, why is it possible to summon unqualified TypeTag for abstract type?

Considering the following code: import scala.reflect.api.Universe object UnqualifiedTypeTag { val RuntimeUniverse = scala.reflect.runtime.universe trait HasUniverse { val universe: Universe with Singleton def uType:…
tribbloid
  • 4,026
  • 14
  • 64
  • 103
0
votes
1 answer

What is the difference between generating Range and NumericRange in Scala

I am new to Scala, and I tried to generate some Range objects. val a = 0 to 10 // val a: scala.collection.immutable.Range.Inclusive = Range 0 to 10 This statement works perfectly fine and generates a range from 0 to 10. And to keyword works without…
LSampath
  • 138
  • 1
  • 3
  • 11
0
votes
0 answers

Circe encoder for a SortedMultiDict

I'm trying to write a Circe encoder for an object which has a field of scala.collection.immutable.SortedMultiDict. Circe can't find an encoder instance for that, so I need to write one. import io.circe.{Decoder, Encoder, HCursor} import…
user3468054
  • 610
  • 4
  • 11
0
votes
1 answer

Execute splice() for varargs in macro method in Scala 2.13

I want to execute splice() for each argument of my varargs: import scala.reflect.macros.blackbox object LoggerMacro { def log(context: blackbox.Context) (message: context.Expr[String], arguments: context.Expr[Any]*) :…
Martin
  • 598
  • 1
  • 4
  • 27
0
votes
2 answers

How do you run a computation, that may fail, over a list of elements so that it terminates as soon as a failure is detected?

My computation that can fail is halve() below. It returns Left(errorMessage) to indicate failure and Right(value) to indicate the successful halving of a number. def halve(n: Int): Either[String, Int] = if (n % 2 == 0) { Right(n / 2) } else…
Tim Stewart
  • 5,350
  • 2
  • 30
  • 45
0
votes
2 answers

Implicit conversion of Int* to custom class in function call

I have a custom type MySeq extending IndexedSeq[Int] and its implicit conversion: package example import scala.language.implicitConversions class MySeq(vals: IndexedSeq[Int]) extends IndexedSeq[Int] { def apply(i: Int): Int = vals(i) def…
vigr
  • 3
  • 2
0
votes
1 answer

Spark can't connect to DB with built-in connection providers

I'm trying to connect to Postgres follow this document And the document said built-in connection providers. Can anyone help me resolve this, please? ` There is a built-in connection providers for the following databases: DB2 MariaDB MS…
MasterLuV
  • 396
  • 1
  • 17
0
votes
1 answer

Completely inlining an AnyVal implicit class constructor without -Yopt-inline-heuristics:everything

I'm experimenting with the Java 17 Vector API Incubator and I decided to see if I can create a zero-cost syntactic sugar for it. Here is a small snippet of what I wrote: import jdk.incubator.vector._ object VectorOps { implicit final class…
Karol S
  • 9,028
  • 2
  • 32
  • 45
0
votes
1 answer

What's the difference between ArrayBuffer.addOne and ArrayBuffer.append?

2.13.3 API says: def addOne(elem: A): ArrayBuffer.this.type Adds a single element to this array buffer. final def append(elem: A): ArrayBuffer.this.type Appends the given elements to this buffer. They seem to do the exact same thing?
0
votes
1 answer

Scala Macro Type Args Introspection on Case Class

I've got a library that generates mappings for case classes at compile-time and it works great, unless I pass in a generic type like: Foo[Bar] (see…
darkfrog
  • 1,053
  • 8
  • 29
0
votes
1 answer

Check if two types are equivalent through reflection in scala

I have some code: import scala.concurrent.Future import scala.concurrent.ExecutionContext.Implicits.global trait LogicUnit trait Ezib extends LogicUnit trait Zieb extends LogicUnit object LogicUnit { @inline def combine[A <: LogicUnit,…
Brad Oo
  • 28
  • 4
0
votes
0 answers

In scala 2.13, how to use actual TypeTag in macro?

This capability seems to be dropped by SI-6186, and no mechanism could be used to replace it I found the following remarks in its commit message: Now we restore the broken balance by banning TypeTag from macro impls. This forces anyone to use…
tribbloid
  • 4,026
  • 14
  • 64
  • 103
0
votes
1 answer

Scala 2 macro type class derivation for `Coder[P <: Product]` ends with error `P does not take parameters`

I am a starter with Scala 2 Macros (before I switch to Dotty) who after trying out the shapeless type class derivation wanted to go one step beyond and write a macro that can generate a type class instances for any scala.Product without it. (for the…
fpopic
  • 1,756
  • 3
  • 28
  • 40