package cats contains object and package with same name: implicits - scala

Heard about the new Cats-Effect library here
http://typelevel.org/blog/2017/05/02/io-monad-for-cats.html
Immidiately added the following line to my ammonite shell predef.sc
interp.load.ivy("org.typelevel" % "cats-core_2.12" % "0.9.0")
interp.load.ivy( "org.typelevel" % "cats-effect_2.12" % "0.1-0848c9b")
Now when I load my ammonite shell. I get error
cmd0.sc:1: package cats contains object and package with same name: implicits
one of them needs to be removed from classpath
import cats.effect.IO
^
Compilation Failed
Googled and found a solution here
Package contains object and package with same name
But I wonder how can I apply the -Yresolve-term-conflict:strategy to the ammonite shell?

I was able to solve it myself. Here are the right imports
interp.load.ivy("org.typelevel" %% "cats" % "0.9.0")
interp.load.ivy( "org.typelevel" % "cats-effect_2.12" % "0.1-0848c9b")
Now everything works fine
# import cats._
import cats._
# import cats.effect.IO
import cats.effect.IO
#

Related

import not found error for sbt.build file

I am in the learning process for Scala and sbt. I have an existing project I am starting with.
On the command line under top project folder, as soon as I enter the sbt command I get:
C:\Projects\aproject\build.sbt:1: error: not found: object scalariform
import scalariform.formatter.preferences._
C:\Projects\aProject\build.sbt:2: error: object sbt is not a member of package com.typesafe
import com.typesafe.sbt.SbtScalariform
I can't find an online reference for this specific error. I assume the second error is because of the first error.
The sbt.build file has these three imports:
import scalariform.formatter.preferences._
import com.typesafe.sbt.SbtScalariform
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
I have scala version 2.13.0
and sbt version 1.2.8
Add to project/plugins.sbt
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
and refresh the project.
https://github.com/sbt/sbt-scalariform

object contrib is not a member of package meta

I am trying to use the isEqual method in ScalaMeta.
import scala.meta.contrib._
q"true".isEqual(q"true")
The import does not work:
object contrib is not a member of package meta
I am using sbt and I have the following in my build.sbt
libraryDependencies += "org.scalameta" %% "scalameta" % "4.0.0"
Where can I find the isEqual method for ScalaMeta? It appears to have been deprecated. I am following this tutorial
To get access to Scalameta Contrib you can add the following dependency:
libraryDependencies += "org.scalameta" %% "contrib" % "4.0.0"
isEqual will be accessible, but q isn't. You can import it from scala.meta._.
The corrected example:
import scala.meta._
import scala.meta.contrib._
q"true".isEqual(q"true")

How to find the missing Akka Dependencies?

I write a Scala project managed by SBT and I want to use TestKit package (http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0/scala/stream-testkit.html#TestKit).
In order to do it, I have to do the following imports:
import system.dispatcher
import akka.pattern.pipe
The problem is that I have to update build.sbt file in order to "bring" the needed dependencies. I tried to add the following dependency:
"com.typesafe.akka" %% "akka-http-testkit" % 2.4.2
and I still got an error for the lines:
import system.dispatcher
and
val probe = TestProbe()
Can you give me a hint on how to find the needed dependency given an import line?
Try to add:
"com.typesafe.akka" %% "akka-http-testkit" % 2.4.2 % Test
akka-http-teskit is a test library, so you should be adding it to the Test scope.

Repl showing error: object async is not a member of package scala on import

I am using scala 2.11.7 Repl (ubuntu) when trying to do this import I am getting :
scala> import scala.async.Async._
<console>:18: error: object async is not a member of package scala
import scala.async.Async._
^
how can I fix that ?
scala-async is not part of Scala standard library. You need to import the module in your project.
If you use sbt, you can add the following to your build file.
libraryDependencies += "org.scala-lang.modules" %% "scala-async" %
"0.9.5"
Check out this PR about the lack of information about this.
Hope this helps!
Use the following command to load the jar into classpath,
scala -classpath jarname.jar

Can't import scala.reflect.runtime.universe

I'd like to play around with reflection in scala (2.10.2) by following the example in
this tutorial. things work fine when I start the sbt (version 0.13) and import
scala.refelct.runtime.universe._
scala> import scala.reflect.runtime.universe._ │~
import scala.reflect.runtime.universe._
but when I try to put the sample code to an object like
object ReflectExample {
import scala.reflect.runtime.universe._
/*
the rest of the Example
*/
}
and compile the code by sbt compile I see the following error message like:
[error] object runtime is not a member of package reflect
[error] import scala.reflect.runtime.universe._
As explained in sbt's documentation, you need to add this line to the libraryDependencies field of your project in build.sbt:
"org.scala-lang" % "scala-reflect" % scalaVersion.value
You may want to try adding dependency to http://mvnrepository.com/artifact/org.scala-lang/scala-reflect