I have some problems when I want to use implicit methods to convert a function to another.
I use a small DSL in Scala 2.8 for testing. It should support various checks (statements, if you want) on instances. The entire DSL is a bit complicated, but the following simplified example shows my problem:
object PimpMyFunction {
class A(val b: Int)
def b(a: A) = a.b
class ZeroCheck(f: A => Int) {
def isZeroIn(a: A) = f(a) == 0
}
implicit def fToCheck(f: A => Int): ZeroCheck = new ZeroCheck(f)
def main(args: Array[String]) {
val a0 = new A(0)
val a1 = new A(1)
println(fToCheck(b).isZeroIn(a0))
println(fToCheck(b).isZeroIn(a1))
println(b.isZeroIn(a0))
}
}
println ( ) , ( implicits) :
Compile error: missing arguments for method b in object PimpMyFunction; follow this method with '_' if you want to treat it as a partially applied function
"" ( ) , , , /.
println((b _).isZeroIn(a0)), , DSL , , .
, (b , Assertions, + A = > Int), , , .
, (b _) - implicits?