[scalding] Automatic tupling of functions?

8 prikaza
Preskoči na prvu nepročitanu poruku

Vesa Muhonen

nepročitano,
31. srp 2015. 07:00:5731. 07. 2015.
u cascading-user
Hi

I was wondering whether it would be possible to have (some) operations in the type-safe API to apply Scala 'tupled' by default or some easy way. Writing a code like this
pipe.filter { i => i._2 == "bar" }
definitely works but can be somewhat obscure. As an alternative this would work
pipe.filter { case (_, foo, _) => foo == "bar" }
One can use Function.tupled to make it look like this
pipe.filter { tupled ((_, foo, _) => foo == "bar") }
but still looks a bit cluttered to me. If it would be possible to have filter automatically accept functions with several arguments you could just write
pipe.filter { (_, foo, _) => foo == "bar" }
which to me looks cleanest. Or if automatically is tricky one could think of
pipe.tfilter { (_, foo, _) => foo == "bar"

However, at this point I have mostly exhausted my detailed knowledge of Scala and Scalding internals and don't know if this actually makes sense or is possible to implement is any reasonable way... Would this make any sense?

Cheers,
Vesa
Odgovori svima
Odgovori autoru
Proslijedi
0 novih poruka