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

Bulat Ziganshin bulat.ziganshin at gmail.com
Fri Sep 11 12:39:34 EDT 2009


Hello Neil,

Friday, September 11, 2009, 7:26:47 PM, you wrote:

i suggest you to import extensible-exceptions package instead - it's
available even for ghc 6.8. alternatively, you may import
old-exceptions package (or something like this). trying to develop code
compatible with both versions of exceptions should be a nightmare :D


> 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.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list