我有以下代码,无法编译:
object PcpProtocol {
private type PcpHead = String
private type PcpBody = String
private type PcpValidity[A] = Either[String, A]
private val PcpIndicator = "pcp-channel:apc"
implicit val pcpProtocol: Protocol[PcpProtocol] = new Protocol[PcpProtocol] {
override def encode(text: String): PcpProtocol = ???
override def decode(msg: PcpProtocol): String = ???
}
private val validatePcp: PcpValidity[PcpHead] = (head: String) => {
if (head.contains(PcpIndicator)) {
Right(head)
} else {
Left("The message does not correspond to SAP PCP protocol")
}
}
}
错误消息显示:
type mismatch;
[error] found : String => scala.util.Either[String,String]
[error] required: com.sweetsoft.PcpProtocol.PcpValidity[com.sweetsoft.PcpProtocol.PcpHead]
[error] (which expands to) scala.util.Either[String,String]
[error] private val validatePcp: PcpValidity[PcpHead] = (head: String) => {
我无法弄清错误。怎么了?