val vLInts = (1 to 10).toList.right[String]
for {
i <- ListT(vLints)
_ = println(i)
} yield i
//error: no type parameters for method apply:(underlying: M[List[A]])scalaz.ListT[M,A] in object ListT exist so that it can be applied to arguments (scalaz.\/[String,List[Int]])
The problem here is that a disjunction \/[A, B]
has 2 generics and therefore isn't a Monad. When i make a type alias
type Attempt[A] = \/[String, A]
it succeeds, because I've held the left side fixed and I now have Monad. How can I get my Monad Transformer to work if the outermost type is a Disjunction, without resorting to type aliasing?
for{
i <- ListT[({type l[+a] = String \/ a})#l,Int](vLints)
_ = println(i)
} yield i
Apparently, the answer was a type lambda. It's not pretty but it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With