Skip to content

Instantly share code, notes, and snippets.

@Tritlo
Created November 12, 2013 22:50
Show Gist options
  • Save Tritlo/7440273 to your computer and use it in GitHub Desktop.
Save Tritlo/7440273 to your computer and use it in GitHub Desktop.
Heroku helper for haskell
module Helpers.Heroku (herokuConf) where
import Prelude
import Data.ByteString (ByteString)
import Data.Text (Text)
import Data.Text.Encoding (encodeUtf8)
import Database.Persist.Postgresql (PostgresConf(..))
import Web.Heroku (dbConnParams)
import qualified Data.Text as T
herokuConf :: IO PostgresConf
herokuConf = do
params <- dbConnParams
return PostgresConf
{ pgConnStr = formatParams params
, pgPoolSize = 10 -- Adjust this as you see fit!
}
where
formatParams :: [(Text, Text)] -> ByteString
formatParams = encodeUtf8 . T.unwords . map toKeyValue
toKeyValue :: (Text, Text) -> Text
toKeyValue (k, v) = k `T.append` "=" `T.append` v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment