Kirill G.
Kirill G.

Reputation: 960

Loading Network.HTTP module in Haskell on GHC7.4.1

I am trying to load a file in GHCi (Windows 7 / Haskell Platform 2012.2.0.0 ) which starts with:

import Network.HTTP
import System.IO
...

But I get an error:

Could not find module `Network.HTTP'

This module is in HTTP package, right? So when I run >cabal list HTTP it finds the following:

* HTTP
    Synopsis: A library for client-side HTTP
    Default available version: 4000.2.3
    Installed version: 4000.2.3
    Homepage: https://github.com/haskell/HTTP
    License: BSD3

Which means the package is installed right? What do I do wrong?

Thank you!

Upvotes: 3

Views: 2642

Answers (1)

Petr
Petr

Reputation: 63359

Having the package installed by cabal doesn't make it automatically available to your code. (For example, you could have installed 2 versions of some package, so it's not possible to determine automatically what to make available and what to hide).

Probably the simplest solution is to manage, build and run your project using cabal as well. See How to write a Haskell program, Section 2 describes (among other things) how to set up the files required by Cabal. In particular, your cabal file will contain a line similar to this:

build-depends: base, HTTP

See also Cabal User Guide.


Edit: You can try the following:

Create file test.cabal containing:

Name:                test
Version:             0.0
Description:         My network program
Build-Type:          Simple
Cabal-Version:       >=1.2

Executable test
  Main-is:           Test.hs
  Build-Depends:     base >= 4 && < 5, HTTP

(Replace Test.hs with your source file.) Then Run

cabal install --only-dependencies

this installs all required dependencies. If it all goes well, you can configure and build the project:

cabal configure
cabal build

Maybe to work interactively with your project, you could use cabal-ghci. I haven't tried it, but looks like it could be just what you need.

Upvotes: 3

Related Questions