[Haskell-cafe] ANN: json-0.4.1

Bas van Dijk v.dijk.bas at gmail.com
Tue Jan 13 14:58:22 EST 2009


On Tue, Jan 13, 2009 at 8:47 PM, Alex Ott <alexott at gmail.com> wrote:
> Hello
>
>>>>>> "SF" == Sigbjorn Finne writes:
>  SF> Hi, a new release of the 'json' package is now available via hackage,
>  SF> version 0.4.1
>
>  SF>   http://hackage.haskell.org/cgi-bin/hackage-scripts/package/json
>
> I tried to upgrade it via cabal on mac os x & linux (both use ghc 6.10.1)
> and it fails with
>
> Building json-0.4.1...
>
> Text/JSON/Generic.hs:33:7:
>    Could not find module `Data.Generics':
>      it was found in multiple packages: base-3.0.3.0 syb
> cabal: Error: some packages failed to install:
> json-0.4.1 failed during the building phase. The exception was:
> exit: ExitFailure 1

The standard solution for this is to add a cabal flag that controls
wether to depend on base-4 or base-3:

------------------------------------------------------
flag small_base
  description:          Choose the new smaller, split-up base package.

Library
  if flag(small_base)
    Build-Depends:      base == 4.*, syb
    CPP-Options:        -DBASE_4
  else
    Build-Depends:      base == 3.*
------------------------------------------------------

And use some CPP in your modules like this:

------------------------------------------------------
{-# LANGUAGE CPP #-}

#ifdef BASE_4
import Data.Data (Data)
#else
import Data.Generics (Data)
#endif
------------------------------------------------------

See for example how I do it in http://code.haskell.org/Stream

regards,

Bas


More information about the Haskell-Cafe mailing list