Reputation: 33
I've been trying to start writing a web app in Scotty, but I'm getting a dependency conflict when I try to run the server. Here's my code:
{-# 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
When I run it using runhaskell Site.hs
, I get the following error:
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 }
Using cabal list text
, it tells me that versions 0.11.2.3
and 0.11.3.1
are installed, but 0.11.3.1
is the default. Scotty's scotty.cabal
specifies that the text
package must be >= 0.11.2.3
, which seems to me like the above code should work. Are there any workarounds for this sort of error?
Upvotes: 3
Views: 393
Reputation: 183978
The error message
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'
means that your scotty
was compiled using version 0.11.2.3 of the text
package, but the invocation of runhaskell chose to use version 0.11.3.1 (because that's the newest you have, and you haven't told it to use a different version). The (lazy) Text
types of two different package versions are, as far as GHC is concerned, two completely different types, and therefore, you must use the exact version of text
used to compile the scotty
library to run the code.
runhaskell -package=text-0.11.2.3 Site.hs
ought to work. If you compile the module, you also need to tell GHC to use the right version of text
, either directly or via Cabal.
Another option could be to recompile scotty
against the newer text
version.
Upvotes: 5