gpt4 book ai didi

HaskellDB - 'Database' 变量不在范围内

转载 作者:行者123 更新时间:2023-12-02 16:03:24 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com