Pergunta

I am not quite sure how to use the postgresqlConnect function in module Database.HaskellDB.HDBC.PostgreSQL to connect to a PostgreSQL database. The Haddock documentation page only states the type signature:

postgresqlConnect :: MonadIO m => [(String, String)] -> (Database -> m a) -> m a

What is a supposed to be?

How do I connect to a PostgreSQL server with postgresqlConnect?

Foi útil?

Solução

This is what I guess: The first parameter is a list of options, if you have no specific options, just pass []. The next parameter is the code you actually want to run with the database. You get a Database argument and can do any monadic stuff with it. The postgresqlConnect function evaluates this monadic action, disconnects the databse and returns the result of it - m a. Most time you probably want to use IO a though.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top