Why is currying and uncurrying not implicit in scala?

I don't think anything bad will happen. The conversion is completely unambiguous. Worst case, Scala will not be able to figure out that the implicit conversion applies implicit def curryImplicitlyA,B,C(f: (A, B) => C) = (a: A) => (b: B) => f(a, b) implicit def uncurryImplicitlyA,B,C(f: A => B => C) = (a: A, b: B) => f(a)(b) Then again, these would also be helpful implicit def flipImplicitlyA,B,C(f: (A, B) => C) = (b: B, a: A) => f(a, b) implicit def flipImplicitlyCurriedA,B,C(f: A => B => C) = (b: B) => (a: A) => f(a)(b) But those aren't transitive, so you need these: implicit def flipAndCurryA,B,C(f: (A, B) => C) = (b: B) => (a: A) => f(a, b) implicit def flipAndUncurryA,B,C(f: A => B => C) = (b: B, a: A) => f(a)(b) But now the conversion is ambiguous.So it's not all roses Let's know how it works out in practise.

You might need equivalents for Function3, Function4, etc.

I don't think anything bad will happen. The conversion is completely unambiguous. Worst case, Scala will not be able to figure out that the implicit conversion applies.

Implicit def curryImplicitlyA,B,C(f: (A, B) => C) = (a: A) => (b: B) => f(a, b) implicit def uncurryImplicitlyA,B,C(f: A => B => C) = (a: A, b: B) => f(a)(b) Then again, these would also be helpful. Implicit def flipImplicitlyA,B,C(f: (A, B) => C) = (b: B, a: A) => f(a, b) implicit def flipImplicitlyCurriedA,B,C(f: A => B => C) = (b: B) => (a: A) => f(a)(b) But those aren't transitive, so you need these: implicit def flipAndCurryA,B,C(f: (A, B) => C) = (b: B) => (a: A) => f(a, b) implicit def flipAndUncurryA,B,C(f: A => B => C) = (b: B, a: A) => f(a)(b) But now the conversion is ambiguous. So it's not all roses.

Let's know how it works out in practise. You might need equivalents for Function3, Function4, etc.

I've not played with this in 2.8, but I tried this back in the dark days of 2.7. X and it tended to lead to compiler crashes, in the type inferencer iirc. Things have improved a fair bit on that front, so maybe it's all good now... – Nick Partridge Aug 11 '10 at 22:14 Yeah, it's still all too easy to crash the compiler if you try to make it infer a higher-kinded type, but it's a huge improvement over 2.7.– Apocalisp Aug 12 '10 at 4:05.

Part of the advantage of strong typing is warning you when you've done something foolish. Trying too hard to make things work reduces the benefits. Here, if the conversions were done automatically, you might not call the method you meant to call.

Having them available implicitly upon request is fine, but it's not that hard to do it yourself if you need it. This is something that I would use quite rarely; I wouldn't put it in my top ten or probably even top hundred things that I'd like in the library (in part because I might prefer the automatic conversion to a tuple instead of the automatic currying/uncurrying).

3 Note that you will not be able to overload a function with arguments A => B => C and D => C, because they have the same erasure. So the problem will not come up this way in practise. – Apocalisp Aug 12 '10 at 5:20 Ah, right you are.It can still be helpful to have type signatures as a double-check if you use different method names but get the method name wrong.

– Rex Kerr Aug 12 '10 at 13:39.

After having discovered that currying multi parameter-groups method is possible, I am trying to get a partially applied function which requires implicit parameters. It seams not possible to do so. If not could you explain me why?

I use a singleton object to create this partially applied function and I want to use it in a scope where the implicit int is defined.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions