我正在尝试运行这个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
答案 0 :(得分:4)
导入Database.HaskellDB
Database
在那里定义,它应该有帮助
(https://github.com/m4dc4p/haskelldb/blob/master/src/Database/HaskellDB.hs#L68)