Created
September 26, 2014 18:42
-
-
Save carymrobbins/d4f7a473c62a226312c3 to your computer and use it in GitHub Desktop.
Analogous to runDB for cabal repl.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Prelude | |
| import Control.Monad.Logger (LoggingT, runStdoutLoggingT) | |
| import Control.Monad.Trans.Resource (ResourceT, runResourceT) | |
| import qualified Database.Persist | |
| import Database.Persist.Sql (SqlPersistT, runSqlPool) | |
| import qualified Settings | |
| import Yesod.Default.Config (DefaultEnv(Development), withYamlEnvironment) | |
| runDBDev :: SqlPersistT (LoggingT (ResourceT IO)) a -> IO a | |
| runDBDev m = do | |
| dbconf <- withYamlEnvironment "config/postgresql.yml" Development | |
| Database.Persist.loadConfig >>= Database.Persist.applyEnv | |
| pool <- Database.Persist.createPoolConfig (dbconf :: Settings.PersistConf) | |
| runResourceT $ runStdoutLoggingT $ runSqlPool m pool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment