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

not found: value λ #144

Open
steinybot opened this issue Apr 3, 2020 · 9 comments
Open

not found: value λ #144

steinybot opened this issue Apr 3, 2020 · 9 comments

Comments

@steinybot
Copy link

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

@larsrh
Copy link
Contributor

larsrh commented Apr 4, 2020

Do you have a branch where I could try to reproduce the problem?

@steinybot
Copy link
Author

@larsrh
Copy link
Contributor

larsrh commented Apr 8, 2020

Thanks, I'll check it out.

@larsrh
Copy link
Contributor

larsrh commented Apr 19, 2020

@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@5933a2b:

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.

@steinybot
Copy link
Author

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.

@larsrh
Copy link
Contributor

larsrh commented Apr 21, 2020

Great to hear! Can we close this issue, then?

@steinybot
Copy link
Author

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.

@larsrh
Copy link
Contributor

larsrh commented Apr 22, 2020

Good point. I'll leave it open.

@non
Copy link
Contributor

non commented Jul 10, 2020

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.

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

No branches or pull requests

4 participants