Haskell build issue (Module `Language.Haskell.TH.Syntax' does not export `returnQ')
at the moment I'm trying to write a small Haskell program but ran into a build problem.
My aim is to query a table in a sql srv DB.
Here my code :
{-# 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)
If I now run 'cabal build' I get the following error :
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.
Has anyone an idea how I can resolve this issue ?
Regards, Sinan-David
Solution 1:
EDIT: This is now fixed as of ms-tds
version 0.4.0.2. You should upgrade to that version if possible instead of using the below workarounds.
The problem is the ms-tds
package uses returnQ
instead of just return
for some reason, which was never necessary for user code and was removed in GHC 9. This is something that should be properly fixed on their end, which I opened 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 returnQ
s with return
s, and then set up Cabal to use your local copy of it, like this.