I have a customer type QueryResult which is
type QueryResult[A] = A org.scalactic.Or One[Error]
When doing multiple queries, I get a List[QueryResult[A]], but I want a QueryResult[List[A]].
I can implement a sequence method for Lists but I would like a more generic one, so I tried creating one with Scalaz.
def sequence2[A, T[_]: Traverse](traversable: T[QueryResult[A]])
(implicit app: Applicative[QueryResult]): QueryResult[T[A]] = {
app.sequence(traversable)
}
This seems to work but does not compile because there is no implicit parameter app for an Applicative[QueryResult].
How do I create one? Or can Scalaz somehow 'magically' generate one somehow?
This should work :
I also don't think you need to define
sequence2yourself, you should be able to do :