I want to run a haskell code that involves networking stuff.
ghc firewall.hs
Error Message
firewall.hs:1:8:
Could not find module `Network.HTTP.Enumerator'
Use -v to see a list of the files searched for.
can anyone tell me how to install module in haskell if this problem is related to that.
The syntax for importing modules in a Haskell script is import <module name>. This must be done before defining any functions, so imports are usually done at the top of the file. One script can, of course, import several modules. Just put each import statement into a separate line.
If you don't need a fully partitioned GHC environment and are happy with the installed versions on DICE, cabal might be the simplest way to install the Haskell packages you require. By default stack installs packages to ~/. cabal and ~/. ghc in your home directory.
To set up Haskell environment on your Windows computer, go to their official website https://www.haskell.org/platform/windows.html and download the Installer according to your customizable architecture. Check out your system's architecture and download the corresponding setup file and run it.
Basic Haskell Commands :quit (or :q) :load [filename] (or :l [filename]) :reload -- reload the current file set after you'ved edited it (or :r) :cd -- change to another directory.
The cabal
tool handles this. In this case you need:
cabal update # to download the latest package list if not done recently
cabal install http-enumerator
If you didn't install GHC via the Haskell Platform you may not have this tool. If so, get the Haskell Platform here: http://www.haskell.org/platform/
To find out what package you need for a particular module, use the search box here: http://hackage.haskell.org/packages/archive/pkg-list.html
In some cases the answer may be ambiguous as two packages are allowed to define the same module.
7-years later edit. Use ghcup from https://haskell.org/ghcup This can install cabal-install and GHC.
Old answer: To augment Ganesh's answer, most people I know don't bother with using the Haskell Platform but instead install GHC then using cabal-install's bootstrap script:
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
export PATH=$PATH:$HOME/.ghcup/bin
Using wget (or curl, if you prefer):
wget http://hackage.haskell.org/packages/archive/cabal-install/1.18.0.1/cabal-install-1.18.0.1.tar.gz
tar xzf cabal-install-1.18.0.1.tar.gz
cd cabal-install-1.18.0.1
sh ./bootstrap.sh
export PATH=$PATH:$HOME/.cabal/bin
After that it's just a matter of using 'cabal' to install Haskell packages.
cabal update
cabal install http-enumerator
You can see this package and many others on http://hackage.haskell.org.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With