[Haskell-cafe] Control.Exception base-3/base-4 woes

Neil Brown nccb2 at kent.ac.uk
Fri Sep 11 11:26:47 EDT 2009


Hi,

In my CHP library I need to do some exception catching.  I want the 
library to work on GHC 6.8 (with base-3 -- this is the current version 
in Ubuntu Hardy and Jaunty, for example) and GHC 6.10 (which comes with 
base-4).  But base-3 and base-4 need different code for exception 
catching (whether it's importing Control.OldException or giving a type 
to the catch method). 

Here's what I currently do -- my Haskell file contains this:

#if __GLASGOW_HASKELL__ >= 609
import qualified Control.OldException as C
#else
import qualified Control.Exception as C
#endif

My cabal file contains this (it used to say just "base,..." but Hackage 
complained at me the other day when I tried to upload that):

Build-Depends:   base >= 3 && < 5, ...

This works on two machines: one is 6.8+base-3, the other is 
6.10+base-3&base-4, where cabal seems to use base-4.  However, I have 
had a bug report (now replicated) which stems from a different 
6.10+base-3&base-4 machine where cabal picks base-3 instead.  The real 
problem is that the #if is based on GHC version, but really it should be 
based on which base-* library is being used.  I know the code works with 
base-3 (use Control.Exception) and base-4 (use Control.OldException) but 
I can't get the build process right to alter the code based on which 
base-* library is being used.

Can anyone tell me how to fix this?  I don't think that changing to 
always use Control.Exception would fix this, because I need to give a 
different type for catch in base-3 to base-4, so there's still the 
incompatibility to be dealt with.

Thanks,

Neil.


More information about the Haskell-Cafe mailing list