문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top