2

I am trying to create a Request value and am getting the following error:

ghci> :m +Network.HTTP Network.URI Data.Maybe
ghci> Request { rqURI = fromJust $ parseURI "http://www.google.com", rqMethod = GET, rqHeaders = [], rqBody = ""}

<interactive>:18:19:
    Couldn't match expected type `network-2.3.1.0:Network.URI.URI'
                with actual type `URI'
    In the `rqURI' field of a record
    In the expression:
      Request
        {rqURI = fromJust $ parseURI "http://www.google.com",
         rqMethod = GET, rqHeaders = [], rqBody = ""}
    In an equation for `it':
        it
          = Request
              {rqURI = fromJust $ parseURI "http://www.google.com",
               rqMethod = GET, rqHeaders = [], rqBody = ""}

cabal list network shows the following:

* network
    Synopsis: Low-level networking interface
    Default available version: 2.4.0.1
    Installed versions: 2.3.1.0, 2.4.0.1
    Homepage: https://github.com/haskell/network
    License:  BSD3

From the docs on Hackage, I believe that the URI I am creating with parseURI is a Network.URI.URI.

I am running the Haskell Platform 2012.4.0.0 (64 bit) on OS X Mountain Lion.

Is this an example of "cabal hell" that I hear about?

1 Answer 1

3

Your HTTP package was built using network-2.3.1.0, but ghci loads the newest version of network unless it is explicitly told which version to use.

So parseURI returns a Maybe network-2.4.0.1:Network.URI.URI but the Request requires the type from network-2.3.1.0.

You can

  • invoke ghci with a -package flag specifying the version of network to use, $ ghci -package network-2.3.1.0 other arguments,
  • rebuild HTTP and everything depending on it against network-2.4.0.1 - in that case, it's probably better to rebuild everything that transitively depends on network-2.3.1.0.

Is this an example of "cabal hell" that I hear about?

I wouldn't go so far as to call that "hell" yet, but it's a small example of that indeed.

Sign up to request clarification or add additional context in comments.

4 Comments

The problem appears to be that hxt-9.3.1.1 depends specifically on network-2.3.1.0. Forcing a reinstall of network will break HXT.
In that case, the -package flag is the way to go. Inconvenient it is, but it works.
I actually got the original error compiling an application (actually running with runhaskell). I copied the relevant parts to GHCi to test it further and wrote my SOF question from that. Guess I'm out-of-luck.
The -package flag is for GHC in general, not only ghci. If you want to compile a cabalised project, cabal figures out which version of network (in this example) gives a consistent plan and automatically chooses 2.3.1.0 (unless you use other things that depend on 2.4.0.1, in which case it'll tell you that it can't find a consistent plan). runhaskell -package ntework-2.3.1.0 whatever may work or not, I expect it would, but I'm not sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.