dependent-method-type

    3熱度

    1回答

    我使用從屬方法類型和編譯器(2.10.0.r26005-b20111114020239)的每晚構建試圖抽象case類的模塊中進行匹配。我從Miles Sabin' example發現了一些靈感。 我真的不明白什麼是錯在下面的(自足)代碼。輸出取決於foo中的模式順序。 // afaik, the compiler doesn't not expose the unapply method //

    5熱度

    1回答

    我試圖讓Scala找到來自單例類型的路徑依賴類型的正確類型。 首先,這裏是該示例的類型的容器,和一個實例: trait Container { type X def get(): X } val container = new Container { type X = String def get(): X = "" } 我可以看到在第一次嘗試的

    3熱度

    1回答

    我正在探索在Scala中抽象案例分類的方法。例如,這裏是Either[Int, String]嘗試(使用Scala的2.10.0-M1和-Yvirtpatmat):根據這個定義 trait ApplyAndUnApply[T, R] extends Function1[T, R] { def unapply(r: R): Option[T] } trait Module {

    12熱度

    1回答

    當與Scala的相關方法類型的打,我遇到了默認的方法的參數衝突: abstract class X { type Y case class YY(y: Y) } object XX extends X { type Y = String } trait SomeTrait { def method(x: X)(y: x.YY, default:

    2熱度

    3回答

    我試圖使用Scala 2.10.0-M1如下: def bar[C <: Container](c: C)(x: C#X): c.X = x :使用這種形式時 trait Container { type X } class Test[C <: Container](val c: C) { def foo(x: c.X): C#X = x // this compile

    7熱度

    1回答

    我有一堆看起來都一樣的數據存儲類型類。 trait FooStore[C] { def create(f: FooId => Foo)(c: C): Foo // update and find methods } 我想簡化事情,並希望利用相關的方法類型,以獲得更接近於 sealed trait AR { type Id type Type }