Curry method with type parameter (generics)

I noticed the type is inferred when I curry a method with a generic type parameter. Is it possible to avoid that?

def parseString[A](input:String)(parse:String => A) = parse(input)

val curried = parseString(input)

val toInt = curried(_.toInt)

val toDouble = curried(_.toDouble)

If I try to create a few functions from the method I get a “missing parameter type for expanded function” error on the toInt and toDouble functions.

My plan was to use an implicit class (Ops class/extension methods), wrap the input and then declare the different parsing alternatives with the curried function.

Unfortunately that’s not possible (yet?). curried would have to be a polymorphic function value, which does not exist yet in scala.

You could write some custom class, but it would not really be a “function”.

scala> class CurriedPolyFunction(input: String) { def apply[A](parse:String => A) = parse(input) }
class CurriedPolyFunction

scala> def parseString(input:String) = new CurriedPolyFunction(input)
def parseString(input: String): CurriedPolyFunction

scala> val curried = parseString("43")
val curried: CurriedPolyFunction = CurriedPolyFunction@543248ff

scala> curried(_.toInt)
val res4: Int = 43

Thanks, have to rethink my plan.