Custom monad with one DB connection per logical DB operation

On the other hand, there is an equally valid way of structuring your code, where a connection is requested from the connection-pool only when some DB related operation is required, and then quickly returned back to the pool as soon as the operation is completed. This is how Yesod and Persistent work together. Here is how this might look:


module SeparateOpaleyeMonad where

import Opaleye

main :: IO ()
main = _todo