【发布时间】:2015-09-23 02:27:50
【问题描述】:
我有一个FoldSignal 案例类,如下所示。
/**
* Represents a signal that is manipulated to using the functional "fold" operation
* @param s Underlying signal
* @param start seed for the fold
* @param f fold function
*/
case class FoldSignal[T, U](s: Signal[T], start: U, f: (U, T) => U) extends Signal[U]
我用它在 Signal[T] 中创建了一个函数:
sealed trait Signal[T]{
...
/**
* Return a delta of signals in windows
*/
def delta(implicit ev: T =:= (_, DateTime) ): Signal[T] = {
def foldFun(queue: List[T], t: T) = {
println(queue(0))
queue(0)._1
}
FoldSignal(this, Nil, foldFun)
}
...
}
其中 Signal[T] 是一个密封的特征:
/**
* Signal is a AST object represents a value that is continuously emitted. It does
* not specify anything about the source of the signal.
*/
sealed trait Signal[T] {...}
然后出现错误:
Error:(71, 22) type mismatch;
found : scala.collection.immutable.Nil.type
required: T
FoldSignal(this, Nil, foldFun)
^
有人可以帮帮我吗?谢谢!
【问题讨论】:
-
函数foldFun的错误信息是
Expression of type FoldSignal[T, Any] doesn't conform to expected type Signal[T]
标签: scala scaffolding folding