看起来很简单
type Db[F[_], A] = Kleisli[F, Connection, A]
type Transactor[DB[_], F[_]] = DB ~> F
也可用于构建功能性 JDBC 层
总结自 @SystemFw 和 @tpolecat 从https://gitter.im/scala/scala?at=5cfe6505bf4cbd167c619960回答
Free Monad 的优点:
F[_]
如此不当(异步)的效果不能在事务边界内使用。这很重要,因为大多数 JDBC 驱动程序都将java.sql.Connection
实现设计为单线程。免费单子的缺点:
F[_]
,因此您不能在事务中嵌套特定效果。Doobie 将来会有无标签版本。