假設我有兩種類型IntResult和StringResult: import cats._
import cats.data._
import cats.implicits._
scala> case class MyError(msg: String)
defined class MyError
scala> type Result[A] = Either[NonEmptyList
我想創建的Either實例中使用REPL例如asRight: import cats._
import cats.data._
import cats.implicits._
scala> val x = "xxx".asRight
<console>:20: error: value asRight is not a member of String
val x = "xx
我試圖從我的函數中使用返回類型來取回對象或字符串。在它是一個對象的情況下,我想從這個對象開始調用方法。如果是字符串,我想在其他地方調用其他函數。我一直掛斷,因爲返回的東西不是我返回的對象,它是「左」類型的,我似乎無法將該對象從「左」類型中移回到「播放器」類型中我想要。這包含在擴展可變隊列的對象中。這裏是我的功能,查找基於關閉這是我ActionQueue對象的關鍵在一個Map Player對象: d