Random Word8 duplicate instance declaration during cabal testpack installation - haskell

What does the following error message mean when cabal install testpack-2.1.1 has failed:
... Everything above this succeeded with no problems.
[22 of 22] Compiling Control.Monad.Cont ( Control/Monad/Cont.hs, dist/build/Control/Monad/Cont.o )
Registering mtl-2.2.1...
Installing library in /home/ely/.cabal/lib/mtl-2.2.1/ghc-7.4.2
Registering mtl-2.2.1...
Downloading testpack-2.1.1...
Configuring testpack-2.1.1...
Building testpack-2.1.1...
Preprocessing library testpack-2.1.1...
[1 of 3] Compiling Test.QuickCheck.Instances ( src/Test/QuickCheck/Instances.hs, dist/build/Test/QuickCheck/Instances.o )
src/Test/QuickCheck/Instances.hs:50:10:
Duplicate instance declarations:
instance Random Word8
-- Defined at src/Test/QuickCheck/Instances.hs:50:10
instance Random Word8 -- Defined in `System.Random'
cabal: Error: some packages failed to install:
testpack-2.1.1 failed during the building phase. The exception was:
ExitFailure 1
I've tried Googling, but cannot make sense of this install error.

testpack-2.1.1 provides a so called orphan instance for Random Word8, that is, an instance where it doesn't define either the class or the type itself.
One of the several problems with orphan instances is that one of the packages which do define the class or type might choose to add that instance themselves in a later version, which is precisely what the random package has done in this case, and so the instances conflict.
From testpack version 2.1.2 there is a check that makes sure to only define the instance if the random package is too old to have done so itself. So you should be able to fix this by installing a later version of testpack instead.

Related

haskell stack won't install dates

In a standalone module I'm using the dates package http://hackage.haskell.org/package/dates installed via cabal and it works fine. But a problem emerges when I try to make a small package out of this module using stack. The dates package is appropriately listed in dependencies and all but it doesn't work. When I try to manually install the package using stack in the project sandbox, I get the below error. Meanwhile I can install this package with cabal outside the stack sandbox without issues.
VERSIONS IN THE SANDBOX:
ghc-8.4.3
stack-1.7.1
SYSTEM VERSIONS:
ghc-8.0.2
cabal-1.24.0.2 (compiled 1.24.2.0)
error message:
Configuring dates-0.2.2.1...
Preprocessing library for dates-0.2.2.1..
Building library for dates-0.2.2.1..
[1 of 4] Compiling Data.Dates.Internal ( Data/Dates/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Data/Dates/Internal.o )
[2 of 4] Compiling Data.Dates.Types ( Data/Dates/Types.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Data/Dates/Types.o )
/tmp/stack16211/dates-0.2.2.1/Data/Dates/Types.hs:62:10: error:
• No instance for (Semigroup DateTime)
arising from the superclasses of an instance declaration
• In the instance declaration for ‘Monoid DateTime’
|
62 | instance Monoid DateTime where
| ^^^^^^^^^^^^^^^
In the end I needed to change the resolver in the stack.yaml file to an older version (lts-8.24) which would enforce the use of ghc-8.0.2. Using
stack --resolver ghc-8.0.2 setup/build
did not prevent stack from using the latest ghc version when I did
stack exec blah-exe
which raised the conflict.

Haskell error with cabal: no instance for

I'm trying to follow the steps for installation for derivation of software product lines called hephaestus-pl. However, at the time of performing the installation steps, according to the tutorial, there is an error when executing the cabal install command on all cloned repositories. The erros is:
$ sudo cabal install
Resolving dependencies...
Notice: installing into a sandbox located at
/home/notebook/workspace/hephaestus/hephaestus-sb
Configuring funsat-0.6.2...
Building funsat-0.6.2...
Failed to install funsat-0.6.2
Build log ( /home/notebook/workspace/hephaestus/hephaestus-sb/logs/funsat-0.6.2.log ):
cabal: Entering directory '.'
Configuring funsat-0.6.2...
Building funsat-0.6.2...
Preprocessing library funsat-0.6.2...
[ 4 of 10] Compiling Funsat.Monad ( src/Funsat/Monad.hs, dist/dist-sandbox-cf02e0bc/build/Funsat/Monad.o )
src/Funsat/Monad.hs:64:10: error:
• No instance for (Applicative (SSTErrMonad e st s))
arising from the superclasses of an instance declaration
• In the instance declaration for ‘Monad (SSTErrMonad e st s)’
src/Funsat/Monad.hs:88:10: error:
• Could not deduce (GHC.Base.Alternative (SSTErrMonad e st s))
arising from the superclasses of an instance declaration
from the context: Error e
bound by the instance declaration at src/Funsat/Monad.hs:88:10-52
• In the instance declaration for ‘MonadPlus (SSTErrMonad e st s)’
cabal: Leaving directory '.'
cabal: Error: some packages failed to install:
funsat-0.6.2 failed during the building phase. The exception was:
ExitFailure 1
I'm using the following version of ghci, which came installed along with the haskell-platform:
$ ghci
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
The cabal version is:
$ cabal --version
cabal-install version 1.24.0.1
compiled using version 1.24.1.0 of the Cabal library
My operating system is debian 9.2.
This is failing to compile due to the Functor/Applicative/Monad proposal implemented in more recent versions of GHC. The code would originally have compiled just fine, but in recent versions of GHC, you cannot declare something as Monad without first declaring it as Functor and Applicative. You used to be able to, but now you cannot.
The library authors need to update the library's code to fix this new restriction.

Cabal fails to install dependencies, but can install them if asked directly

I've seen a very strange recurring problem with Cabal that's interfering with my ability to get repeatable Haskell builds. I have a cabal project with a sandbox. If I do cabal install, I get errors of the form
Y failed during the building phase. The exception was:
ExitFailure 1
X depends on Y which failed to install.
where X is a direct dependency of my project and Y is some transitive dependency. However, if I just type cabal install X, then it works!
Here's a specific example: my project depends on the interpolate package. When I do cabal install --allow-newer, I get errors like this:
Resolving dependencies...
Configuring haskell-src-meta-0.6.0.9...
Building haskell-src-meta-0.6.0.9...
Preprocessing library haskell-src-meta-0.6.0.9...
[1 of 6] Compiling Language.Haskell.TH.Instances.Lift ( src/Language/Haskell/TH/Instances/Lift.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/TH/Instances/Lift.o )
[2 of 6] Compiling Language.Haskell.Meta.Syntax.Translate ( src/Language/Haskell/Meta/Syntax/Translate.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta/Syntax/Translate.o )
[3 of 6] Compiling Language.Haskell.Meta.Parse ( src/Language/Haskell/Meta/Parse.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta/Parse.o )
[4 of 6] Compiling Language.Haskell.Meta.Parse.Careful ( src/Language/Haskell/Meta/Parse/Careful.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta/Parse/Careful.o )
[5 of 6] Compiling Language.Haskell.Meta ( src/Language/Haskell/Meta.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta.o )
[6 of 6] Compiling Language.Haskell.Meta.Utils ( src/Language/Haskell/Meta/Utils.hs, dist/dist-sandbox-d2861272/build/Language/Haskell/Meta/Utils.o )
src/Language/Haskell/Meta/Utils.hs:67:1:
Duplicate instance declarations:
instance Typeable Q
-- Defined at src/Language/Haskell/Meta/Utils.hs:67:1
instance Typeable Q -- Defined in ‘Language.Haskell.TH.Instances’
src/Language/Haskell/Meta/Utils.hs:71:1:
Duplicate instance declarations:
instance Typeable QuasiQuoter
-- Defined at src/Language/Haskell/Meta/Utils.hs:71:1
instance Typeable QuasiQuoter
-- Defined in ‘Language.Haskell.TH.Instances’
Failed to install haskell-src-meta-0.6.0.9
...
haskell-src-meta-0.6.0.9 failed during the building phase. The exception was:
ExitFailure 1
interpolate-0.1.0 depends on haskell-src-meta-0.6.0.9 which failed to install.
However, if I proceed to type cabal install interpolate-0.1.0, the installation succeeds and I'm able to keep installing my project.
This is frustrating because I have to "manually" install several packages before I can get all my dependencies installed. The fact that the original installations fail with compiler errors seems to suggest that the compiler is configured differently somehow?
I'm using GHC 7.8.3 and cabal-install 1.22.4.0 (version 1.22.3.0 of the Cabal library). Many thanks for any help!
Actually it's not a problem with the version of haskell-src-meta but rather with the version of its dependency th-orphans.
haskell-src-meta (versions 0.6.0.8 and 0.6.0.9) has an upper bound th-orphans <0.12.
With --allow-newer you told Cabal to ignore version upper bounds, so Cabal decided to use th-orphans version 0.12.0, since it's newer and presumably better. But, in fact, haskell-src-meta really does not build with th-orphans version 0.12.0, as you found out.
Unrestricted use of --allow-newer is likely to run into this kind of problem in general. It's better to specify the packages whose upper bounds you want to ignore with --allow-newer=base,containers,..., though in some cases doing so can be rather tedious.
In the first sentence of your question you mentioned repeatable builds. If that is what you want, there is no substitute for simply recording the exact versions that you want of all of your direct and indirect dependencies.

Cannot install yesod with "duplicate instance declaration"

When I try to install yesod using the command "cabal install yesod", I got the following errors:
cabal install rsa
Resolving dependencies...
Configuring RSA-1.0.6.1...
Preprocessing library RSA-1.0.6.1...
Preprocessing executables for RSA-1.0.6.1...
Building RSA-1.0.6.1...
[1 of 1] Compiling Codec.Crypto.RSA ( Codec/Crypto/RSA.hs, dist/build/Codec/Crypto/RSA.o )
Codec/Crypto/RSA.hs:577:10:
Duplicate instance declarations:
instance Random Word8 -- Defined at Codec/Crypto/RSA.hs:577:10-21
instance Random Word8 -- Defined in System.Random
cabal: Error: some packages failed to install:
It seems RSA lib conflicts with another library.
Any idea?
My environment:
Mac OS X 10.7
GHC 7.0.3
Thanks in advance.
The random package started exporting new instances in version 1.0.1.0. One solution would be to conditionally compile the RSA library's instance only when the random package is that version or later; some variation like this should work:
{-# LANGUAGE CPP #-}
#if MIN_VERSION_random(1,0,1)
#else
instance Random Word8 where
...
#endif
Bonus points if you send a patch to the maintainer of the RSA library.
Alternately, you could ask cabal to use an older version of random.

windows install for Haskell Frp package?

I was trying to install the reactive banana package on Windows, with little success.
It seems to know about the packages, but fail on installation.
Any hints?
>cabal install Reactive
Resolving dependencies...
...
cabal: Error: some packages failed to install:
category-extras-0.53.5 failed during the building phase. The exception was:
ExitFailure 1
reactive-0.11.5 depends on category-extras-0.53.5 which failed to install.
>cabal install category-extras
Resolving dependencies...
Configuring category-extras-0.53.5...
...
cabal: Error: some packages failed to install:
category-extras-0.53.5 failed during the building phase. The exception was:
ExitFailure 1
>cabal install reactive-banana-wx
Resolving dependencies...
Downloading monads-tf-0.1.0.0...
Warning: monads-tf.cabal: A package using 'cabal-version: >=1.2.3' must use
section syntax. See the Cabal user guide for details.
...
setup.exe: wx-config: does not exist
cabal: Error: some packages failed to install:
reactive-banana-wx-0.3.0.1 depends on wxcore-0.12.1.7 which failed to install.
wx-0.12.1.6 depends on wxcore-0.12.1.7 which failed to install.
wxcore-0.12.1.7 failed during the configure step. The exception was:
ExitFailure 1
etc...
OK, I got all the wx-stuff installed - took several steps. wx-config, then wxWidgets, then install the Haskell parts (wx, wxcore, reactive-banana.wx). But the basic Reactive and category-extras still fail as above. - step 39 of 99 of category-extras fails:
[39 of 99] Compiling Control.Monad.Either ( src\Control\Monad\Either.hs, dist\bu
ild\Control\Monad\Either.o )
src\Control\Monad\Either.hs:44:10:
Duplicate instance declarations:
instance Monad (Either e)
-- Defined at src\Control\Monad\Either.hs:44:10-25
instance Monad (Either e) -- Defined in Control.Monad.Instances
src\Control\Monad\Either.hs:49:10:
Duplicate instance declarations:
instance Applicative (Either e)
-- Defined at src\Control\Monad\Either.hs:49:10-31
instance Applicative (Either e) -- Defined in Control.Applicative
src\Control\Monad\Either.hs:53:10:
Duplicate instance declarations:
instance MonadFix (Either e)
-- Defined at src\Control\Monad\Either.hs:53:10-28
instance MonadFix (Either e) -- Defined in Control.Monad.Fix
cabal: Error: some packages failed to install:
category-extras-0.53.5 failed during the building phase. The exception was:
ExitFailure 1
Update:
I find the Wx universe for Haskell a bit of a mess. There are lots of notes on this and descriptions of issues with wx & wxHaskell on windows, requiring old versions of GHC in some suggestions, etc. The code is not compatible with current MSoft compilers, so require other compiler installs, etc. All in all fairly disappointing to me after a few hours of poking at it. I did install wx-config, wxPack, wxWidgets, then wxHaskell, and then from cabal wx & wxcore; all reported success - still it failed (wxmsw28_gcc.dll not found; although it is in the library). Their initial tests (samples/controls...) fail. All of the samples links and many more are broken on the wxWidgets and wxHaskell pages. After a reboot (?!) it does seem to run some tests - so I am hoping for success now.
I was hoping for a magic "apt-get install" like experience.
For FRP -- The FRP examples (in leksah) give lots of: "Link destinations not found for..." error messages, but so far now do run.
All in all it from my experience it seems like wxHaskell and FRP don't seem very easy to use on Windows. Certainly not something I'd assign to a class to try as a good example of Haskell's ease and utility! :-)
I appreciate all the complexity and work involved in these packages, and don't mean to complain - just an experience report. Perhaps the wxHaskell packages are not commonly used, or ..??
Note that you have to include the "banana" in "reactive-banana". :-)
cabal install reactive-banana
cabal install reactive-banana-wx
In other words, Reactive is not the package you are looking for, reactive-banana is. (The Reactive package is an older experiment by Conal Elliott with similar goals, but it has a few systemic bugs and has now bitrotted a bit.)
It looks like there's a windows port of wx-config here. I'd be surprised if it isn't in wx-core already. Do you have the WX c library installed? It is needed - the Haskell package is just bindings to the C library.

Resources