开发者

How do I use postgresqlConnect in the Database.HaskellDB.HDBC.PostgreSQL module?

开发者 https://www.devze.com 2023-04-11 20:41 出处:网络
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 sign

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, Str开发者_如何学编程ing)] -> (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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号