kind-projector
kind-projector copied to clipboard
not found: value λ
Any idea why I can use * but not λ?
sbt:hedgehog> show Test/libraryDependencies
[info] test / Test / libraryDependencies
[info] List(org.scala-lang:scala-library:2.12.11, org.typelevel:kind-projector:0.11.0:plugin->default(compile))
[info] runner / Test / libraryDependencies
[info] List(org.scala-lang:scala-library:2.12.11, org.typelevel:kind-projector:0.11.0:plugin->default(compile))
[info] example / Test / libraryDependencies
[info] List(org.scala-lang:scala-library:2.12.11, org.typelevel:kind-projector:0.11.0:plugin->default(compile))
[info] sbt-test / Test / libraryDependencies
[info] List(org.scala-lang:scala-library:2.12.11, org.typelevel:kind-projector:0.11.0:plugin->default(compile), org.scala-sbt:test-interface:1.0)
[info] core / Test / libraryDependencies
[info] List(org.scala-lang:scala-library:2.12.11, org.typelevel:kind-projector:0.11.0:plugin->default(compile))
[info] Test / libraryDependencies
[info] List(org.scala-lang:scala-library:2.12.11, org.typelevel:kind-projector:0.11.0:plugin->default(compile))
sbt:hedgehog> Test/compile
[info] Compiling 18 Scala sources to /Users/jason/source/scala-hedgehog/test/target/scala-2.12/test-classes ...
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/core/TreeTest.scala:8:28: not found: value λ
[error] private val ToProperty = λ[PF1[Tree, PropertyT]](treeProperty)
[error] ^
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/core/TreeTest.scala:8:52: missing argument list for method treeProperty in object TreeTest
[error] Unapplied methods are only converted to functions when a function type is expected.
[error] You can make this conversion explicit by writing `treeProperty _` or `treeProperty(_)` instead of `treeProperty`.
[error] private val ToProperty = λ[PF1[Tree, PropertyT]](treeProperty)
[error] ^
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/core/TreeTest.scala:8:15: private val ToProperty in object TreeTest is never used
[error] private val ToProperty = λ[PF1[Tree, PropertyT]](treeProperty)
[error] ^
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/core/TreeTest.scala:15:15: private method treeProperty in object TreeTest is never used
[error] private def treeProperty[A](tree: Tree[A]): PropertyT[A] =
[error] ^
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/predef/EitherTest.scala:10:28: not found: value λ
[error] private val ToProperty = λ[PF1[Either[Nothing, *], PropertyT]](eitherProperty)
[error] ^
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/predef/EitherTest.scala:10:66: missing argument list for method eitherProperty in object EitherTest
[error] Unapplied methods are only converted to functions when a function type is expected.
[error] You can make this conversion explicit by writing `eitherProperty _` or `eitherProperty(_)` instead of `eitherProperty`.
[error] private val ToProperty = λ[PF1[Either[Nothing, *], PropertyT]](eitherProperty)
[error] ^
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/predef/EitherTest.scala:5:30: Unused import
[error] import hedgehog.predef.Monad._
[error] ^
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/predef/EitherTest.scala:10:15: private val ToProperty in object EitherTest is never used
[error] private val ToProperty = λ[PF1[Either[Nothing, *], PropertyT]](eitherProperty)
[error] ^
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/predef/EitherTest.scala:17:15: private method eitherProperty in object EitherTest is never used
[error] private def eitherProperty[A](either: Either[Nothing, A]): PropertyT[A] =
[error] ^
[error] /Users/jason/source/scala-hedgehog/test/src/test/scala/hedgehog/predef/IdTest.scala:10:28: not found: value λ
[error] private val ToProperty = λ[PF1[Id, PropertyT]](identityProperty)
[error] ^
[error] 21 errors found
[error] (test / Test / compileIncremental) Compilation failed
[error] Total time: 1 s, completed 4/04/2020, 9:54:15 am
Someone else has the same problem on StackOverflow https://stackoverflow.com/questions/48767385/kind-compiler-plugin-%CE%BB-not-found
Do you have a branch where I could try to reproduce the problem?
Yep. Here is the branch https://github.com/steinybot/scala-hedgehog/tree/future-result. Here is the failed build https://travis-ci.com/github/steinybot/scala-hedgehog/jobs/313853593.
Thanks, I'll check it out.
@steinybot OK, the problem wasn't that kind-projector was triggered, but because there are some type errors underneath that produced a misleading error message.
After applying these changes to commit steinybot/scala-hedgehog@5933a2b9d2141a5636516d7d96019d9ce25d2014:
diff --git a/test/src/test/scala/hedgehog/core/TreeTest.scala b/test/src/test/scala/hedgehog/core/TreeTest.scala
index ba95937..c0af20b 100644
--- a/test/src/test/scala/hedgehog/core/TreeTest.scala
+++ b/test/src/test/scala/hedgehog/core/TreeTest.scala
@@ -5,7 +5,7 @@ import hedgehog.runner._
object TreeTest extends Properties {
- private val ToProperty = λ[PF1[Tree, PropertyT]](treeProperty)
+ private val ToProperty = λ[PF1[Tree, PropertyT]](t => treeProperty(t))
override def tests: List[Test] =
List(
diff --git a/test/src/test/scala/hedgehog/predef/EitherTest.scala b/test/src/test/scala/hedgehog/predef/EitherTest.scala
index 455220a..46d9355 100644
--- a/test/src/test/scala/hedgehog/predef/EitherTest.scala
+++ b/test/src/test/scala/hedgehog/predef/EitherTest.scala
@@ -7,7 +7,7 @@ import hedgehog.runner._
object EitherTest extends Properties {
- private val ToProperty = λ[PF1[Either[Nothing, *], PropertyT]](eitherProperty)
+ private val ToProperty = λ[PF1[Either[Nothing, *], PropertyT]](e => eitherProperty(e))
override def tests: List[Test] =
List(
Then I get the following errors:
sbt:hedgehog> ~ Test/compile
[info] Compiling 18 Scala sources to /tmp/scala-hedgehog/test/target/scala-2.12/test-classes ...
[error] /tmp/scala-hedgehog/test/src/test/scala/hedgehog/predef/EitherTest.scala:14:42: no type parameters for method propTailRecMIsStackSafe: (f: hedgehog.StackSafeTest.PF1[F,hedgehog.core.PropertyT])(implicit evidence$1: hedgehog.predef.Monad[F])hedgehog.Property exist so that it can be applied to arguments (hedgehog.StackSafeTest.PF1[[β$0$]scala.util.Either[Nothing,β$0$],hedgehog.core.PropertyT])
[error] --- because ---
[error] argument expression's type is not compatible with formal parameter type;
[error] found : hedgehog.StackSafeTest.PF1[[β$0$]scala.util.Either[Nothing,β$0$],hedgehog.core.PropertyT]
[error] required: hedgehog.StackSafeTest.PF1[?F,hedgehog.core.PropertyT]
[error] property("tailRecM is stack safe", propTailRecMIsStackSafe(ToProperty))
[error] ^
[error] /tmp/scala-hedgehog/test/src/test/scala/hedgehog/predef/EitherTest.scala:14:66: type mismatch;
[error] found : hedgehog.StackSafeTest.PF1[[β$0$]scala.util.Either[Nothing,β$0$],hedgehog.core.PropertyT]
[error] required: hedgehog.StackSafeTest.PF1[F,hedgehog.core.PropertyT]
[error] property("tailRecM is stack safe", propTailRecMIsStackSafe(ToProperty))
[error] ^
[error] /tmp/scala-hedgehog/test/src/test/scala/hedgehog/predef/EitherTest.scala:5:30: Unused import
[error] import hedgehog.predef.Monad._
[error] ^
[error] /tmp/scala-hedgehog/test/src/test/scala/hedgehog/predef/EitherTest.scala:10:15: private val ToProperty in object EitherTest is never used
[error] private val ToProperty = λ[PF1[Either[Nothing, *], PropertyT]](e => eitherProperty(e))
[error] ^
I'm unsure how to proceed from there since I'm not familiar with hedgehog, but I hope that's sufficient for you to debug the problem further. The other occurrences of λ can be modified accordingly, which either makes the error go away completely or turn up a similar type error as above.
Ahh awesome. Thank you very much @larsrh for taking the time to look into this!
Surprising that the eta-expansion isn't working as expected and that the end result is an error about not being able to find λ.
I made the same changes as you, explicitly using a function literal, and I didn't have any compilation errors.
Great to hear! Can we close this issue, then?
Well my particular problem is solved but the error is still confusing. If there is no way to improve it then yeah sure, just close this.
Good point. I'll leave it open.
Coming late to this, I think the issue here is that Kind-Projector triggers based on the shape of the trees it works with. It's possible that this code had an unsupported shape. When I get a chance I'll try to create a test case that reliably triggers the issue on valid code.