Questions tagged [simulacrum]
8 questions
4
votes
1 answer
Using typeclasses wtih multiple type parameters
I'm trying to use symulacrum's @typeclass to avoid writing Ops/Syntax boilerplate. I have a trait parameterized with effect and a type:
@typeclass trait Close[F[_], T]{
def close(t: T): F[Unit]
}
With the intention to be used as follows:
trait…

St.Antario
- 26,175
- 41
- 130
- 318
3
votes
1 answer
Implicit for Function not being found
I have this typeclass
import simulacrum._
@typeclass trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B) : F[B]
def lift[A, B](fa: F[A])(f: A => B) : F[A] => F[B] = fa => map(fa)(f)
def as[A, B](fa: F[A], b: => B) : F[B] = map(fa)(_…

Knows Not Much
- 30,395
- 60
- 197
- 373
3
votes
2 answers
typeclass annotation should have been removed by simulacrum but was not
I am trying to write a simple typeclass using Simulacrum. Here is my build.sbt
ThisBuild / scalaVersion := "2.12.8"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.example"
ThisBuild / organizationName :=…

Knows Not Much
- 30,395
- 60
- 197
- 373
1
vote
1 answer
Simulacrum in Scalafiddle: exception during macro expansion
I wanted to use Simulacrum in Scalafiddle, like:
import simulacrum._
@typeclass trait Ordering[T] {
def compare(x: T, y: T): Int
@op("<") def lt(x: T, y: T): Boolean = compare(x, y) < 0
@op(">") def gt(x: T, y: T): Boolean = compare(x,…

pme
- 14,156
- 3
- 52
- 95
1
vote
1 answer
Type mismatch in typeclass definition using simulacrum
I have a hard time defining the following typeclass:
@typeclass trait ElementIterator[It[_]] {
def record[Item[Element], Element <: ElementT, Ctx >: Context[ElementT]]
(iterator: It[Item[Element]],
name: String,
what: RefExpr[Ctx, Any])
…

Midiparse
- 4,701
- 7
- 28
- 48
0
votes
2 answers
Type class pattern: simulacrum boosted method not found
I have a requirement to be able to count number of times AtomicReference[V].get is called in a class that has as field an array of wildcarded atomic references.
To that end, first, I've extended java's AtomicReference[V]:
import…

vasigorc
- 882
- 11
- 22
0
votes
1 answer
Simulacrum: macro implementation not found
I've got a simple code in Scala to try simulacrum lib:
import simulacrum._
@typeclass trait Semigroup[A] {
@op("|+|") def append(x: A, y: A): A
}
But this doesn't work. Compiler says
Error:(3, 2) macro implementation not found: macroTransform…

Stas
- 1,040
- 7
- 7
0
votes
1 answer
Adding a Typeclass to Java enum - without simulacrum
I am trying to convert a couple of Java enumerations values into another Java enumeration (the usage of Java enum over Scala Enumeration is due to legacy reasons - the enums are actually generated using JAXB).
Instead of a plain old pattern…

Arun Manivannan
- 4,213
- 3
- 29
- 38