[Haskell-cafe] Problems installing the haskell platform

Albert Y. C. Lai trebla at vex.net
Fri Jan 21 22:48:06 CET 2011

On 11-01-19 08:52 AM, Henry Laxen wrote:
> Greetings.  I've been using haskell for about a year now, though I
> will readily admit I still don't really know what I am doing when I
> get error messages.  Today I decided to reset my haskell environment
> from scratch, avoiding the debian packages and going straight to the
> source.
> 1. Install ghc from http://www.haskell.org/ghc/download_ghc_6_12_3
> Success!!
>      ghc --version
>      The Glorious Glasgow Haskell Compilation System, version 6.12.3
>      cabal update
>      Downloading the latest package list from hackage.haskell.org

I wonder where you got your cabal from. Certainly not by installing ghc. 
Looks like an old version you failed to reset when you said "reset". 
Here is why it matters.

With ghc 6.12.3 and "cabal-install version 0.8.0 using version 
of the Cabal library", stm- does not build. The error is:

[4 of 7] Compiling Control.Concurrent.STM.TVar ( 
Control/Concurrent/STM/TVar.hs, dist/build/Control/Concurrent/STM/TVar.o )

     Ambiguous occurrence `readTVarIO'
     It could refer to either `Control.Concurrent.STM.TVar.readTVarIO', 
defined at Control/Concurrent/STM/TVar.hs:35:0
                           or `GHC.Conc.readTVarIO', imported from 
GHC.Conc at Control/Concurrent/STM/TVar.hs:29:0-14

With the same ghc 6.12.3 but "cabal-install version 0.8.2 using version of the Cabal library", stm- builds fine.

If you use Setup.hs, it calls up whichever Cabal library your ghc comes 
with, which is, so stm- builds fine too.

Why Cabal library caused the error: by generating inferior CPP 

In dist/build/autogen/cabal_macros.h it scripts:

/* package base- */
#define MIN_VERSION_base(major1,major2,minor) \
   (major1) <  4 || \
   (major1) == 4 && (major2) <  2 || \
   (major1) == 4 && (major2) == 2 && (minor) <= 0

It wants to provide a macro for testing version numbers of base, but it 
forgets a pair of defensive parentheses, so some usages will go wrong. 
Indeed, in TVar.hs:

import GHC.Conc
-- doesn't matter to us today

#if ! MIN_VERSION_base(4,2,0)
readTVarIO = atomically . readTVar

If base version is <4.2.0, then GHC.Conc does not provide readTVarIO, 
and we want to define one ourselves. If base version is >=4.2.0 (for 
example ghc 6.12.3), then GHC.Conc provides readTVarIO, and we want to 
go with that. But the macro test goes wrong, and we do both.

Cabal library generates the macro correctly:

/* package base- */
#define MIN_VERSION_base(major1,major2,minor) (\
   (major1) <  4 || \
   (major1) == 4 && (major2) <  2 || \
   (major1) == 4 && (major2) == 2 && (minor) <= 0)

More information about the Haskell-Cafe mailing list