我一直在尝试开始在Scotty中编写 Web 应用程序,但是当我尝试运行服务器时遇到了依赖冲突。这是我的代码:
{-# 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'sscotty.cabal
指定text
package must be >= 0.11.2.3
,在我看来,上面的代码应该可以工作。这种错误有什么解决方法吗?