I'm looking at this repo on github that is using both play and doobie.
I want to understand how it is eventually converting from a connectionIO/IO from cats to a Future that the playframework is built around from.
I'm looking at a controller and I can see the userRepo but I don't see where or how it is going to/from futures to IO.
def doEdit(): Action[AnyContent] = UserAction { implicit req =>
GsForms.user.bindFromRequest.fold(
formWithErrors => editView(formWithErrors),
data => userRepo.edit(data)
.map(_ => Redirect(PublishedSpeakerRoutes.detail(req.user.slug)).flashing("success" -> "Profile updated"))
)
}
Eventually there is a call to unsafeToFuture
which
Evaluates the effect and produces the result in a Future.
at line UICtrl.scala#L59. These questions are best answered by Goto definition feature of IDE. For example, Metals provides it for all major editors. Often the shortcut is command+click
or control+click
on the symbol name.