Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intellij/sbt error: not found:object KVStore #4

Closed
kthompson opened this issue Oct 10, 2016 · 9 comments
Closed

Intellij/sbt error: not found:object KVStore #4

kthompson opened this issue Oct 10, 2016 · 9 comments

Comments

@kthompson
Copy link
Contributor

When i use the example provided:

import cats._
import cats.free._
import freasymonad.cats.free

import scala.collection.mutable

@free trait KVStore {                     // you can use any names you like
type KVStoreF[A] = Free[GrammarADT, A]  // as long as you define a type alias for Free
sealed trait GrammarADT[A]              // and a sealed trait.

  // abstract methods are automatically lifted into part of the grammar ADT
  def put[T](key: String, value: T): KVStoreF[Unit]
  def get[T](key: String): KVStoreF[Option[T]]

  def update[T](key: String, f: T => T): KVStoreF[Unit] =
    for {
      vMaybe <- get[T](key)
      _      <- vMaybe.map(v => put[T](key, f(v))).getOrElse(Free.pure(()))
    } yield ()
}

class impureInterpreter extends KVStore.Interp[Id] {
  val kvs = mutable.Map.empty[String, Any]

  def get[T](key: String): Id[Option[T]] = {
    println(s"get($key)")
    kvs.get(key).map(_.asInstanceOf[T])
  }

  def put[T](key: String, value: T): Id[Unit] = {
    println(s"put($key, $value)")
    kvs(key) = value
  }
}

I get an error Error:(64, 33) not found: value KVStore class impureInterpreter extends KVStore.Interp[Id] {

I have tried "com.thangiee" %% "freasy-monad" % "0.3.0", and "com.thangiee" %% "freasy-monad" % "0.4.0",

@Thangiee
Copy link
Owner

Hmm, I can't seem to reproduce the error.

Which scala version are you using?

Also what are you using to run the code (intellij or sbt run, etc... )?

@kthompson
Copy link
Contributor Author

kthompson commented Oct 10, 2016

I am running scalaVersion := "2.11.5", I am primarily using intellij but i get the same errors if I run sbt compile

It is a bit strange as it was working and then I changed some things, but now I get the error above.

Here is a minimal example: https://github.com/kthompson/freasy-test

@Thangiee
Copy link
Owner

Thangiee commented Oct 10, 2016

Try adding this to your build.sbt:

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

@kthompson
Copy link
Contributor Author

That seems to have helped. Not sure why it didnt work in the plugin.sbt file. Now I am getting some other weird errors:

Error:(27, 20) wrong number of type parameters for method getAll: [F[_], T](implicit I: cats.free.Inject[FilterStore.FilterStoreGrammar,F])cats.free.Free[F,List[T]] get <- getAll[Any] Error:(7, 2) too many arguments for method removeAll: ()(implicit I: cats.free.Inject[FilterStore.FilterStoreGrammar,F])cats.free.Free[F,Unit] @free

@kthompson
Copy link
Contributor Author

It looks like at least one parameter is required for the abstract methods within the trait?

@Thangiee
Copy link
Owner

Thangiee commented Oct 10, 2016

Something may not be generated correctly. I am going to look into it.

@Thangiee
Copy link
Owner

Could you give v0.4.1 a try?

resolvers += Resolver.jcenterRepo
libraryDependencies ++= Seq(
  "com.thangiee" %% "freasy-monad" % "0.4.1",
  "org.typelevel" %% "cats" % "0.7.2" 
)
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

Please tell me if it works or not, thanks!

@kthompson
Copy link
Contributor Author

Awesome! Looks like its working. Thanks for the quick responses. 😃

@Thangiee
Copy link
Owner

No problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants