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将不会使用该版本,除非你明确告诉它。所以隐藏所有较新的版本是使某个版本成为默认版本。 –