4

I'm trying to get this example code to compile on my system. When I try to compile the Chat module with ghc Chat.hs, ghc gives me this:

Chat.hs:76:39:
    Couldn't match expected type `Network.Wai.Request'
                with actual type `wai-0.4.3:Network.Wai.Request'
    In the second argument of `eventSourceApp', namely `req'
    In the second argument of `($)', namely `eventSourceApp chan req'
    In a stmt of a 'do' expression:
        res <- lift $ eventSourceApp chan req

I am on OS X Snow Leopard and cleared up (everything?) except the Haskell Platform like this:

rm -r ~/.cabal
rm -r ~/.ghc
rm -r ~/Library/Haskell

and installed yesod and wai-eventsource anew from hackage.

As far as I understand the error comes from a dependency problem.

    wai
    Synopsis: Web Application Interface.
    Default available version: 1.0.0
    Installed versions: 0.4.3, 1.0.0
    Homepage: https://github.com/yesodweb/wai
    License:  BSD3

Where yesod-0.9.4.1 requires wai == 0.4.* and wai-eventsource-1.0.0 requires wai >= 1.0.

So, my question would be: Is it possible to get this example (with the official releases of yesod) to work right now? With all the change the yesod project is going through atm? Do I have to be more precise on the versions I try to install and, if so, how?


Edit:

I wiped out ~/.ghc (or actually followed a more rigorous approach given here, just in case) and tried to install the packages with a single cabal install yesod wai-eventsource resulting in (incomplete):

Resolving dependencies...
cabal: cannot configure yesod-0.9.4.1. It requires wai ==0.4.* and warp ==0.4.*
For the dependency on wai ==0.4.* there are these packages: wai-0.4.0,
wai-0.4.1, wai-0.4.2 and wai-0.4.3. However none of them are available.
wai-0.4.0 was excluded because wai-eventsource-1.0.0 requires wai >=1.0
...
wai-0.4.3 was excluded because wai-eventsource-1.0.0 requires wai >=1.0
For the dependency on warp ==0.4.* there are these packages: warp-0.4.0,
warp-0.4.0.1, warp-0.4.1, warp-0.4.1.1, warp-0.4.1.2, warp-0.4.2, warp-0.4.3,
warp-0.4.3.1, warp-0.4.4, warp-0.4.5, warp-0.4.6, warp-0.4.6.1, warp-0.4.6.2
and warp-0.4.6.3. However none of them are available.
warp-0.4.0 was excluded because wai-eventsource-1.0.0 requires warp >=1.0
...
warp-0.4.6.3 was excluded because wai-eventsource-1.0.0 requires warp >=1.0

Before that (with yesod and wai-eventsource installed separately) I tried ghc -hide-package wai-1.0.0 Chat.hs resulting in,

Chat.hs:77:39:
Couldn't match expected type `wai-1.0.0:Network.Wai.Request'
            with actual type `Network.Wai.Request'
In the second argument of `eventSourceApp', namely `req'
In the second argument of `($)', namely `eventSourceApp chan req'
In a stmt of a 'do' expression:
    res <- lift $ eventSourceApp chan req
Community
  • 1
  • 1
dmb
  • 247
  • 5
  • 15
  • As a general rule, it's often a good idea to install packages that need to work together with a single `cabal install` command, e.g `cabal install yesod wai-eventsource`. This makes Cabal try to pick a single version of each package such that they all work together. Installing separately, you sometimes end up installing multiple versions of a package, causing problems like this. – hammar Feb 04 '12 at 19:18

1 Answers1

3

I think you need to unregister (or hide) wai 1.0.0. The current Yesod is using wai 0.4, which is where the mismatch is coming from. (Once a newer Yesod is released, this problem will disappear.)

Alternatively, you could wipe out your ~/.ghc folder again and run cabal install yesod wai-eventsource, which should automatically install only the compatible versions.

Edit: You need to hide wai-eventsource as well, and possibly a few others. And simplest approach is to run ghc-pkg unregister wai-eventsource-1.0.0 --force.

Michael Snoyman
  • 31,100
  • 3
  • 48
  • 77
  • If I run the `ghc-pkg unregister wai-eventsource-1.0.0 --force` command, a subsequent `ghc Chat.hs` results in a `Could not find module `Network.Wai.EventSource'` Error. How is hiding needed packages help compile this module? – dmb Feb 06 '12 at 07:12
  • You don't have the *correct* version of wai-eventsource installed. That's why I recommened `cabal install yesod wai-eventsource`. – Michael Snoyman Feb 06 '12 at 10:11
  • Yeah, but as mentioned in my edited question above, a single call, as suggested, results in unresolved dependencies since **both** (wai/warp)==0.4.* and (wai/warp)>=1.0.0 are required. There is no version prior to wai-eventsource-1.0.0 on hackage, if that is what you mean. – dmb Feb 06 '12 at 14:48
  • Doh, I'd forgotten about that. You'd have to either install wai-eventsource from github, or just wait till Yesod is out this week. – Michael Snoyman Feb 07 '12 at 06:02