Let's say I have some sql that is going to return a result set that looks like this:
ID | Value |
---|---|
A1 | Val1 |
A1 | Val2 |
A1 | Val3 |
B1 | Val4 |
B1 | Val5 |
B1 | Val6 |
val query = sql"""select blah""".query[(ID, VALUE)]
val result: ConnectionIO[(ID, List[VALUE])] = for {
tuples <- query.to[List]
} yield tuples.traverse(t => t._1 -> t._2)
This is the closest I can get, but I get a compiler error:
Could not find an instance of Applicative for [+T2](ID, T2)
What I want is to turn this into a Map[ID, List[VALUE]]