Search code examples
haskellinstallationpackagingcabalhaskell-platform

Can't install Lattices for Haskell


I'm trying to follow the instructions for installing the Haskell components required by Quipper; but, working from a fresh installation of Haskell using the binary installer.

I get as far on the list as attempting to install the Lattices package:

cabal update
cabal install random
cabal install mtl
cabal install primes
cabal install Lattices

However I encounter the follwoing error:

Lattices-0.0.1 failed during the building phase. The exception was: ExitFailure 1

If I attempt to continue the Quipper install instructions:

cabal install zlib
cabal install easyrender

I encounter further errors:

cabal: Could not resolve dependencies:

I'm not sure how to proceed. What can I do to complete the package installation instructions for Quipper?


Resolving dependencies...
Configuring Lattices-0.0.1...
Building Lattices-0.0.1...
Failed to install Lattices-0.0.1
Build log ( /Users/Roy/.cabal/logs/Lattices-0.0.1.log ):
Configuring Lattices-0.0.1...
Building Lattices-0.0.1...
Preprocessing library Lattices-0.0.1...
[1 of 2] Compiling Math.LinearAlgebra.GramSchmidt ( src/Math/LinearAlgebra/GramSchmidt.hs, dist/build/Math/LinearAlgebra/GramSchmidt.o )

src/Math/LinearAlgebra/GramSchmidt.hs:25:26:
    Ambiguous occurrence ‘*>’
    It could refer to either ‘Prelude.*>’,
                             imported from ‘Prelude’ at src/Math/LinearAlgebra/GramSchmidt.hs:2:8-37
                             (and originally defined in ‘GHC.Base’)
                          or ‘Math.Algebra.LinearAlgebra.*>’,
                             imported from ‘Math.Algebra.LinearAlgebra’ at src/Math/LinearAlgebra/GramSchmidt.hs:7:1-43
cabal: Error: some packages failed to install:
Lattices-0.0.1 failed during the building phase. The exception was:
ExitFailure 1

Resolving dependencies...
cabal: Could not resolve dependencies:
trying: easyrender-0.1.0.1 (user goal)
next goal: base (dependency of easyrender-0.1.0.1)
rejecting: base-4.8.1.0/installed-075... (conflict: easyrender => base>=4.6 &&
<4.8)
rejecting: base-4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1, 4.6.0.0,
4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2, 4.2.0.1,
4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global constraint requires
installed instance)
Dependency tree exhaustively searched.

OS X 10.10.4; Xcode 6.4; CLT: 6.4.0.0.1.1435007323; Clang: 6.1 build 602; Haskell GHC: 7.10.2. Using Homebrew in general, but, following what appears to be Homebrew's recommendation, not for Haskell.


Solution

  • The source of Lattices-0.0.1 is not compatible with the newer versions of base included in GHC 7.10.1 or greater which now includes the Applicative Functor operators (<$>), (<*>), (*>) & (<*) by default.

    In previous versions of base, the Applicative Functor operators would need to be explicitly imported:

    import Control.Applicative ((<$>), (<*>), (*>), (<*))
    
    main = show <$> getArgs -- use the applicative operator(s)
    

    In the latest version of base included with GHC 7.10.1 or greater these operators are included implicitly in the Prelude module.

    -- This is not necessary
    -- import Control.Applicative ((<$>), (<*>), (*>), (<*))
    
    main = show <$> getArgs -- use the applicative operator(s)
    

    Since the Lattices-0.0.1 package was created a long time ago, it's source is not compatible with the newest version of GHC & base which you installed via the haskell-platform. If you look at the source you can see that the *> operator is used from a mathematics package import. But given the implicit prelude import of *> from the Applicative Functor module there is now a naming ambiguity that did not exist in earlier versions of base. This causes the compilation error.

    To correctly compile the Lattice-0.0.1 package you will need to use a version of GHC which is older than GHC 7.10.1.

    The haskell-platform is well maintained, unfortunately the Lattices-0.0.1 package is not...