3

我正在尝试运行这个 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")]

此代码取自网站

在执行 runhaskell db.hs 时,它会抛出错误,

db.hs:7:33: Not in scope: type constructor or class ‘Database’

这条线是,

withDB :: [(String,String)] -> (Database -> IO a) -> IO a
4

1 回答 1

4

导入数据库.HaskellDB

Database在那里定义,它应该有帮助

https://github.com/m4dc4p/haskelldb/blob/master/src/Database/HaskellDB.hs#L68

于 2015-07-03T13:31:36.590 回答