You cannot post messages because only members can post, and you are not currently a member.
Description:
The main forum for discussions and news about the Scala language
|
|
|
parameter inference
|
| |
I accidentally noticed that on 2.10.2.v20130425-053916-403ba8 938f the following compiles:
class A { def a(i: Int) = i }
class B extends A { override def a(i) = i } // no type parameter on i
While I heard of such a potential change some time ago, I can't find the commit where it is finally merged.... more »
|
|
compiler message not clear with FiniteDuration.times
|
| |
sbt console Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_07). val fd=scala.concurrent.duration.F initeDuration(3, "seconds") fd * 2.5 // works fine res0: scala.concurrent.duration.Dura tion = 7500 milliseconds scala> val res:scala.concurrent.duration. FiniteDuration =fd * 2.5... more »
|
|
Unary type view
|
| |
Hi,
I have problems understanding Scala's type system. Why does the
following code not compile in the line 'val z = ...'?
trait Unary[U[_], A]
case class A[T](t: T)
case class B[I[_], A](i: I[A]) extends Unary[({type O[X] = B[I, X]})#O, A]
def unary[MA <: Unary[U, A], U[_], A](ma: MA with Unary[U, A]): U[A] =... more »
|
|
Mining for granularity beyond AnyVal
|
| |
[link]
*
*
/* A better way to tag types?
*
* 1) object Time: here we are distinguishing between different uses of a Long,
* yet there is no boxing whatsoever.
*
* main calls start: ()J
* main calls timed: (Function0, J)
* Function0 gives up the result: ()J... more »
|
|
Passing context instance reference to another class
|
| |
Hi! I have code: object Parser { type ParserContext = Context { type PrefixType = Parser } def ruleImpl(c: ParserContext)(r: c.Expr[Rule]): c.Expr[Boolean] = { val opTreeContext = new OpTreeContext(c) val opTree = opTreeContext.parse(r.tree) // Compilation error (see below): Parser.scala: type mismatch;... more »
|
|
Existentials and method types
|
| |
I was surprised and delighted by a bug a coworker found today, which hinged on my assuming that surely value types can never contain non-value types. Here's a simplified version:
import scala.reflect.runtime.universe ._
class A {
object B
...class C {
val a = new A
val b = a.B
...... more »
|
|
Workaround for value class type erasure?
|
| |
So it appears to me that value classes have their types erased to the type
they take for their single value. This of course causes the standard type
erasure issues to pop up.
Right now I'm having trouble with overloading. I have function a with
signatures Int => UInt and UInt => UInt. It fails to compile because of... more »
|
|
Strange behaviour of Numeric[Int]/IntIsIntegral?
|
| |
It would be great if someone could shed some light on the following REPL sessions (2.10.0) [1]: They are two attempts to produce a situation with ambiguous implicits. The first works as expected: trait Settings { def title: String } implicit object DefaultSettings extends Settings { val title = "default" }... more »
|
|
match-expression in infix position
|
| |
Is there a special reason why it is not possible to use a match-expression in infix position (without surrounding it with parentheses)?
scala> 1 match {case x => x} + 1
<console>:1: error: ';' expected but identifier found.
1 match {case x => x} + 1
^... more »
|
|
peano class-cast-exception
|
| |
After reading the "ambiguous reference to overloaded definition" thread in scala-user I played with Rex's Peano example (in 2010) where he tries to achieve what he calls "conditionally abstract". I didn't achieve it but I found a bug - the example compiles but crashes with ClassCastException. I did a minimal search for "ClassCastException" in... more »
|
|
|