Type output right to left

I created the following code snippet:

class PimpToRight[A](f: A => Boolean) { def <| (a: A) = f(a) } implicit def f2pimp[A](f: A => Boolean) = new PimpToRight(f) class PimpToLeft[A](a: A) { def <|: (f: A => Boolean) = f(a) def |> (f: A => Boolean) = f(a) } implicit def a2pimp[A](a: A) = new PimpToLeft(a) 

Right and left associative methods are available.

The following code works:

 ((_: Int) > 3) <| 7 ((_: Int) > 3) <|: 7 7 |> (_ > 3) 

But this is not so:

 (_ > 3) <| 7 (_ > 3) <|: 7 

Is it possible to derive type parameters from right to left?

+7
source share
1 answer

The two problems are related: SI-4773 and SI-1980 . Based on these questions, the answer to your question seems no. Despite the fact that Paul Chiusano is not directly related to your question, there is a very nice article on doing most of type inference in Scala , which addresses the current state of type inference in Scala and gives some useful tips.

+5
source

All Articles