title: Pimp my function in scala - applying implicit conversions on functions
body: <p>I have some problems when I want to use implicit methods to convert a <strong>function</strong> to something else.</p>
  
  <p>I'm implementing a small DSL in Scala 2.8 for testing purposes. It should support various checks (assertions if you like) on instances. The whole DSL is a bit complex, but the following simplified example shows my problem:</p>
  
  <pre><code>object PimpMyFunction {
  
    class A(val b: Int)
  
    def b(a: A) = a.b
  
    class ZeroCheck(f: A =&gt; Int) {
      def isZeroIn(a: A) = f(a) == 0
    }
  
    implicit def fToCheck(f: A =&gt; 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)) 
    }
  }
  </code></pre>
  
  <p>First two println lines (when I explicitly call the conversion method) compile and work fine, but the last one (when I want to rely on implicits) produces the error:<br>
  <code>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</code><br>
  If I want to implicitly convert "normal" instances (which are not functions) the same way it also works, so I guess the problem is not related to scoping/importing. </p>
  
  <p>If I follow the instructions of the error message and use <code>println((b _).isZeroIn(a0))</code> it also works, but the DSL is targeted at non technical people, so I would like to keep the syntax as clean and simple as possible.</p>
  
  <p>I think I have another workaround (b should be a class extending an Assertions trait which already contain the check methods + A => Int) that would support the cleaner syntax, but it would be more verbose and less flexible, so I would prefer the implicit way. </p>
  
  <p>Any ideas how to avoid the <code>(b _)</code> syntax and still use implicits?</p>