I have a module that uses Control.Exception
in Base < 4
which is Control.OldException
in Base >= 4
. How can I, using cabal or any other tool, get rid of the version dependency (just depend on Base
and not Base < 4
) and import Control.OldException
when using Base >= 4
and Control.Exception
when using Base < 4
?
cabal
automatically sets certain CPP definitions based on the version of packages used.
So for your case I would:
{-# LANGUAGE CPP #-}
module Blah where
#if MIN_VERSION_base(0,4,0)
import Control.OldException
#else
import Control.Exception
#endif
This method builds fine with cabal.
(actually, I would use new exceptions and wouldn't bother supporting base < 4, but that's just me)
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