HaskellDB - '数据库'变量不在范围内

时间:2015-07-03 13:06:03

标签: haskell haskelldb

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

1 个答案:

答案 0 :(得分:4)

  

导入Database.HaskellDB

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

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