logo       

two things about defs: msg#00409

lang.scala

Subject: two things about defs

I've posted one of these features into buglist, another one is probably
waiting it's turn.

First one:

scala> def sum(a: Int)(b: Int): Int = a+b
sum: (scala.Int)(scala.Int)scala.Int

scala> val sum2 = (x: int) => (y: int) => x + y
sum2: (scala.Int) => (scala.Int) => scala.Int = <function>

Could interpreter print out only one version of type output? Personally
I think the best one is: scala.Int => scala.Int => scala.Int = <function>

Second one:

scala> def yyy = &(List(1,2) foldLeft)
yyy: => (scala.Nothing) => ((scala.Nothing, scala.Int) => scala.Nothing) =>
scala.Nothing

scala> def xxx[a] : (a => ((a, int) => a) => a) = &(List(1,2) foldLeft)
xxx: [a](a) => ((a, scala.Int) => a) => a

Is it possible for type inference mechanism to abstract over scala.Nothing
when deciding type for yyy? It would be great to have xxx automatically.
Though, this problem may be undecidable.

-- WBR, Alexander Sergeev.




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise