Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top