Question

I recently bought a laptop and install Xubuntu 13.10 on it. Today, I freshly reinstalled it because I couldn't get GHC to work on it. I did apt-get update and upgrade, as well as install linux-headers-generic and install bcmwl-kernel-source.

This is how I proceeded:

Downloaded GHC from: https://www.haskell.org/ghc/download_ghc_7_6_3#x86_64linux

tar xjf ghc-7.6.3......
cd ghc-7.6.3
./configure

Here he doesn't configure, so I have to download libgmp.so.3 and install it

sudo make install

GHC installs properly.

Now I try running it with ghci and get an error of missing libgmp.so. I download it as well and install. Both using ubuntu software center and from pkgs.com

Now I run ghci. It works fine. I try:

import Control.Monad.Error

Here my real problem starts:

<no location info>:
    Could not find module `Control.Monad.Error'
    Perhaps you meant
      Control.Monad.Fix (from base)
      Control.Monad.ST (from base)
      Control.Monad.Zip (from base)

I have NO idea why this happens. I can easily do: obviously

:m +Control.Monad

Which gives: Prelude Control.Monad> But can't do it with error. as I understand it, this library comes with GHC itself, but I downloaded it and installed just in case using: sudo apt-get install libghc-mtl-dev

But it still didn't work. I need help in making this work, or generally setting haskell up.

Was it helpful?

Solution

As Hoogle will tell you, this module is not in the base package but in mtl. Ah, I see you've already found out yourself. The thing is, a package needs to be registered with GHC. If you apt-get install a package, this will have nothing to do with a manually-installed GHC.

In general the way to get a new Haskell library package is

cabal install mtl

...for which you need cabal of course.

Really, you should just have installed the Haskell platform instead of GHC alone; current release has ghc-7.6.3 in it.

In ?ubuntu 13.10, you'll actually get that version as simple as

sudo apt-get install haskell-platform

no need to install anything by hand at all.

OTHER TIPS

It's much easier to use your distro's package manager to install GHC (or the whole Haskell platform, if you want it). I suspect that GHC 7.6.3 is on aptitude by now. And instead of using cabal(-install), you should use your package manager to install the various Haskell packages that you want.

However, if you really really really want to install manually (perhaps because you want the latest version of GHC 7.8.1), here's what I do on a new machine. WARNING: Don't do this unless you're able and willing to clean up a possible mess!

  1. Use the distro's package manager to install the Haskell platform. You don't care if it's an older version. You're just doing this to get any GHC dependencies plus cabal-install.

  2. Now install the version of GHC that you want.

    sudo mkdir /usr/local/ghc-X.X.X

    ./configure --prefix=/usr/local/ghc-X.X.X

    sudo make install

    Add this GHC to your PATH!

  3. Optional: Uninstall GHC using your package manager (so that it won't be upgraded in future updates).

After you've done this once, when you upgrade to a new version of GHC, you only need to do step 2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top