Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [implicit]

An implicit in Scala is a function applied or a parameter provided without explicitly appearing in the source code.

1 vote
0 answers
54 views

Can I disable default Marker Context (NoMarker) passed implicitly when using play.api.Logger and require a different MarkerContext is always provided?

I am trying to add a unique request id to logs for each request that is made to a rest api. For that I want to pass implicitly a MarkerContext to each logger method called. Currently the NoMarker ...
Stefan Stojkovski's user avatar
0 votes
1 answer
47 views

scala how to declare a type define which must have implicit conversion?

I need call a function def fromJsonString[Result <: B : C](jsonString: String): Result = ???. And I define a trait MyContext in order to matching a various instance of type Result. MyContext define ...
LoranceChen's user avatar
  • 2,541
2 votes
1 answer
162 views

givens / implicits for Scala 3 Union Types

I have some typeclass, e.g.: trait ExampleTypeClass[A] // imagine one or more methods here object ExampleTypeClass: given ExampleTypeClass[Int] = new ExampleTypeClass{/* ... */} given ...
MartinHH's user avatar
  • 1,188
1 vote
2 answers
165 views

Can't execute an extension method of a context function in Scala 3

I defined an extension method on a context function in Scala 3: object Scope { extension [E, A](a: List[E] ?=> A) def extFoo: A = foo(a) private def foo[E, A](a: List[E] ?=> A) = { ...
riccardo.cardin's user avatar
3 votes
1 answer
80 views

Can't create an anonymous implementation of ContextFunction1 in Scala 3

I'm trying to create an anonymous implementation of a context function in Scala 3. In detail, the code is the following: def mem[E, A](block: Raise[E] ?=> A): Raise[E] ?=> A = new ...
riccardo.cardin's user avatar
0 votes
1 answer
46 views

how to call a class inside another Scala Object?

I have a class DFHelper which helps getting the dataframe keys. I want to maintain it as generic code and call it from another main scala object. E.g the first code section i am defining for generic ...
Shankar Panda's user avatar
0 votes
2 answers
59 views

Converting generic types implicitly

I have a generic Result class I want to write an implicit operator function so I can cast Result-T to Result-V but I could not figure out how to do it. public class Result<T> { public bool ...
Bora Aydın's user avatar
0 votes
1 answer
121 views

ZIO Quill: Can't find implicit SchemaMeta for type models.Pet

I'm currently working on a pet store application using ZIO and Quill. As part of my learning process, I've set up a local H2 database and configured it to store pet information. However, I'm ...
Penchala Yegu's user avatar
2 votes
2 answers
80 views

How to define a "fallback" implicit?

Consider a tapir.Codec object (this is how I encountered this problem, but I don't think it has much to do with tapir specifically, it is just about implicit resolution priority in general), it has a ...
Dima's user avatar
  • 40.3k
0 votes
1 answer
88 views

In Scala 2/3, why can't unboxing or view bounds be chained (as in OCaml), and how to fix/circumvent it?

Considering the following example, derived from the official manual of Scala 3 on Context Abstractions: https://docs.scala-lang.org/scala3/guides/migration/incompat-contextual-abstractions.html#view-...
tribbloid's user avatar
  • 4,028
2 votes
1 answer
116 views

How to test fastparse parsers in a separate class?

I'm writing a parser, something like, object MyParser: def int[$: P]: P[Int] = digit.rep(1).!.map(s => s.toInt) def digit[$: P]: P[Unit] = CharIn("0-9") Now I'd like to test this in ...
Todd O'Bryan's user avatar
  • 2,230
0 votes
0 answers
78 views

Scanamo Paginated Query Issues

Need example of a method to create paginated query on dynamoDb using scala's, Scanamo library I am trying to create to create a method which performs paginated queries on dynamodb table using a query ...
zeus's user avatar
  • 1
0 votes
0 answers
62 views

All partial unification algorithms failed on implicit conversion from functions - How to improve in Scala?

Here is a simple example: object UnificationOnConversionFromFn { trait :=>[I, R] implicit def fromVanilla[I, R]( vanilla: I => R ): I :=> R = ??? // fail implicit def ...
tribbloid's user avatar
  • 4,028
1 vote
1 answer
98 views

Implicit resolution failure when multiple instances present, despite having different types

My goal is to implement a Schema[T] (from scala-jsonschema) and Writes[T] (from play-json) for a handful of T classes whose companions I can't modify. My sub-goal is to define them close together to ...
Dylan's user avatar
  • 13.8k
2 votes
0 answers
40 views

Extensions methods using implicits do not compile with Scala 3

Following code compiles fine with Scala 2.13.12, but not with Scala 3.3.1: import scala.language.implicitConversions object Types { trait Vector3f implicit class Vector3fOps(v: Vector3f) { ...
Suma's user avatar
  • 34.1k

15 30 50 per page
1
2 3 4 5
121