I have created a simple trait using cats-tagless lib:
@finalAlg
@autoFunctorK(true)
trait MyService[F[_]] {
def put(element: Element): F[Element]
def get(elementId: Id): F[Element]
def all(): F[List[Element]]
def delete(elementId: Id): F[Unit]
}
but when I tried to compile it, I got an error:
Error:(8, 7) macro annotation could not be expanded (the most common reason for that is that you need to enable the macro paradise plugin; another possibility is that you try to use macro annotation in the same compilation run that defines it)
I also added addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full) into plugins.sbt file and build.sbt but it did not help. Can you help me to solve it?
My build.sbt file looks like:
addCompilerPlugin(("org.scalameta" % "paradise" % "3.0.0-M11").cross(CrossVersion.full))
lazy val commonSettings = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % CatsVersion,
"org.typelevel" %% "cats-effect" % "1.2.0",
"org.typelevel" %% "cats-tagless-macros" % "0.5",
"org.typelevel" %% "cats-tagless-legacy-macros" % "0.5",
"org.typelevel" %% "cats-mtl-core" % "0.5.0",
)
)
In an empty new project with this
build.sbt:this code:
compiles just fine, as advertised here.
If I remove
addCompilerPlugin("org.scalameta" % "paradise" % "3.0.0-M11" cross CrossVersion.full), I get the same error message:Again, this is as documented, the linked page says:
So it seems that you need it because of
@finalAlgand@autoFunctorK.Note that I didn't modify anything in
project/.EDIT
If you have multiple subprojects, you have to add the compiler plugin to the subproject that actually needs it. Notice that
is essentially just
so in your case, you probably should try something like
and then add this to your
algebrasubproject.