3
我一直在嘗試開始編寫Scotty中的Web應用程序,但是當我嘗試運行服務器時,出現依賴關係衝突。這裏是我的代碼:Haskell依賴衝突
{-# LANGUAGE OverloadedStrings #-}
module Site where
import Web.Scotty
import Control.Monad.IO.Class
import qualified Data.Text.Lazy.IO as T
-- Controllers
indexController :: ActionM()
indexController = do
index <- liftIO $ T.readFile "public/index.html"
html index
routes :: ScottyM()
routes = do
get "/" indexController
main :: IO()
main = do
scotty 9901 routes
當我運行它使用runhaskell Site.hs
,我得到以下錯誤:
Site.hs:12:10:
Couldn't match expected type `text-0.11.2.3:Data.Text.Lazy.Internal.Text'
with actual type `Data.Text.Lazy.Internal.Text'
In the first argument of `html', namely `index'
In a stmt of a 'do' block: html index
In the expression:
do { index <- liftIO $ T.readFile "public/index.html";
html index }
使用cabal list text
,它告訴我,版本0.11.2.3
和0.11.3.1
安裝,但0.11.3.1
是默認。 Scotty的scotty.cabal
指定text
包必須是>= 0.11.2.3
,在我看來,上面的代碼應該可以工作。這種錯誤是否有任何解決方法?
太棒了!有沒有辦法在全球範圍內設置默認包? – nahiluhmot
不,不是。默認情況下使用最新版本(如最高版本號所示)。你可以隱藏你不想使用的版本,'ghc-pkg hide foo-0.1.2.3',然後GHC將不會使用該版本,除非你明確告訴它。所以隱藏所有較新的版本是使某個版本成爲默認版本。 –