我正在尝试运行这个 haskelldb hello world 示例,
module Caturday.Model.Connect where
import Database.HaskellDB.HDBC
import Database.HaskellDB.Sql.PostgreSQL
import Database.HDBC.PostgreSQL (connectPostgreSQL)
withDB :: [(String,String)] -> (Database -> IO a) -> IO a
withDB opts = hdbcConnect generator (connectPostgreSQL conninfo)
where conninfo = unwords [ k ++ "=" ++ v | (k,v) <- opts ]
opts = [("host","localhost")
,("user","your_username")
,("password","your_password")
,("dbname","your_db_name")]
此代码取自site
在执行 runhaskell db.hs 时,它会抛出错误,
db.hs:7:33: Not in scope: type constructor or class ‘Database’
这条线是,
withDB :: [(String,String)] -> (Database -> IO a) -> IO a
最佳答案
import Database.HaskellDB
数据库
定义在那里,它应该有帮助
( https://github.com/m4dc4p/haskelldb/blob/master/src/Database/HaskellDB.hs#L68 )
关于HaskellDB - 'Database' 变量不在范围内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31207602/