Haskell 构建问题(模块“Language.Haskell.TH.Syntax”不导出“returnQ”)

Haskell build issue (Module `Language.Haskell.TH.Syntax' does not export `returnQ')

目前我正在尝试编写一个小 Haskell 程序,但是 运行 遇到了构建问题。

我的目标是在 sql srv 数据库中查询 table。

这是我的代码:

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Network.Socket (withSocketsDo)
import Control.Exception (bracket)

import Database.MSSQLServer.Connection
import Database.MSSQLServer.Query

main :: IO ()
main = do       
    let info = defaultConnectInfo { connectHost = "www"
                                  , connectDatabase = "xxx"
                                  , connectUser = "yyy"
                                  , connectPassword = "zzz"
                                  }
    withSocketsDo $
        bracket (connect info) close $ \conn -> do
        result <- sql conn "SELECT * FROM ProdData_" :: IO [ProdData]
        print result

data ProdData 
    = ProdData
        { mst_ID             :: Int
        , anl_ID             :: Int
        , nameMSt            :: String
        , anlageMst          :: String
        , maschinenID        :: String
        , maschine           :: String
        , maschinentyp       :: String
        , zeitstempel        :: UTCTime
        , auftrag            :: String
        , artikelnummer      :: String
        , werkzeug           :: String
        , sollmenge          :: Int
        , gutmenge           :: Int
        , ausschuss          :: Int
        , nester             :: Int
        , zykluszeit         :: Float
        , fortschrittProzent :: Float
        , verbleibendeZeit   :: Int
        } 
    deriving (Show)

如果我现在 运行 'cabal build' 我得到以下错误:

src\Database\Tds\Primitives\Fixed.hs:87:36: error:
    Module `Language.Haskell.TH.Syntax' does not export `returnQ'
   |
87 | import Language.Haskell.TH.Syntax (returnQ)
   |                                    ^^^^^^^
cabal.exe: Failed to build ms-tds-0.4.0.1 (which is required by
exe:UpdateProdData from UpdateProdData-0.1.0.0). See the build log above for
details.

有人知道我该如何解决这个问题吗?

此致, 思南-大卫

编辑:从 ms-tds 版本 0.4.0.2 开始,此问题现已修复。如果可能,您应该升级到该版本,而不是使用以下解决方法。


问题是 ms-tds 包出于某种原因使用 returnQ 而不是仅仅 return,这对于用户代码来说从来都不是必需的,并且在 GHC 9 中被删除了。这是一个问题那应该在我打开的那一端得到妥善修复 https://github.com/mitsuji/ms-tds/issues/1 about. In the meantime, there's two ways you can use this package anyway. The easier approach is to downgrade to GHC 8.10.7. Your other option is to download the source of that package, comment out that import, replace all returnQs with returns, and then set up Cabal to use your local copy of it, .