Yesod wai-eventsource example. Problem with package dependency?

I am trying to get this sample code to compile on my system. When I try to compile a chat module using ghc Chat.hs , ghc gives me the following:

 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 have clarified (everything?), Except for the Haskell platform, like this:

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

and installed yesod and wai-eventsource from hackage again.

As I understand it, the error is due to 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 

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

So my question is: is it possible for this example (with official releases of Yesod) to work right now? With all the changes, the Yesod project goes through atm? Should I be more accurate in the versions I'm trying to install, and if so, how?


Edit:

I destroyed ~/.ghc (or actually followed the more rigorous approach given here , just in case) and tried to install the packages with one cabal install yesod wai-eventsource leads to (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 

Prior to this (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 
+4
source share
1 answer

I think you need to undo (or hide) wai 1.0.0. The current Yesod uses wai 0.4, from which the mismatch originates. (As soon as the new Yesod is released, this problem will disappear.)

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

Edit : You also need to hide the wai-eventsource, and possibly a few others. The easiest way is to run ghc-pkg unregister wai-eventsource-1.0.0 --force .

+3
source

Source: https://habr.com/ru/post/1394657/


All Articles