Haskell error with cabal: no instance for - haskell

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.

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.

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.

Random Word8 duplicate instance declaration during cabal testpack installation

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.

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.

How to install generic haskell

after install hugs and then install ghc6 then install generic-haskell has the following message, How to do?
# make package
Creating generic-haskell package ...
ghc-pkg: cannot find package generic-haskell
Reading package info from "generic-haskell.cabal.pkg" ... done.
generic-haskell-1.80: missing id field
generic-haskell-1.80: dependency "base-4.2.0.0" doesn't exist (use --force to override)
generic-haskell-1.80: dependency "haskell98-1.0.1.1" doesn't exist (use --force to override)
generic-haskell-1.80: dependency "containers-0.3.0.0" doesn't exist (use --force to override)
make: *** [package] Error 1
in ubuntu i compile ghc-6.2.2 got the following error
/usr/bin/ghc -M -optdep-f -optdep.depend -osuf o -H16m -O HaskTags.hs
on the commandline:
Warning: -optdep-f is deprecated: Use -dep-makefile instead
------------------------------------------------------------------------
==fptools== make boot - --no-print-directory -r;
in /home/martin/ghc-6.2.2/ghc/utils/ghc-pkg
------------------------------------------------------------------------
/usr/bin/ghc -M -optdep-f -optdep.depend -osuf o -H16m -O -cpp -DPKG_TOOL -DWANT_PRETTY Main.hs Package.hs ParsePkgConfLite.hs Version.hs
on the commandline:
Warning: -optdep-f is deprecated: Use -dep-makefile instead
make all
/usr/bin/ghc -H16m -O -cpp -DPKG_TOOL -DWANT_PRETTY -c Main.hs -o Main.o -ohi Main.hi
Main.hs:496:11:
Ambiguous type variable `e' in the constraint:
`Exception.Exception e'
arising from a use of `Exception.throw' at Main.hs:496:11-25
Possible cause: the monomorphism restriction applied to the following:
my_catch :: forall a. IO a -> (e -> IO a) -> IO a
(bound at Main.hs:499:0)
my_throw :: forall a. e -> a (bound at Main.hs:496:0)
Probable fix: give these definition(s) an explicit type signature
or use -XNoMonomorphismRestriction
Main.hs:498:13:
Ambiguous type variable `e1' in the constraint:
`Exception.Exception e1'
arising from a use of `Exception.catch' at Main.hs:498:13-27
Possible cause: the monomorphism restriction applied to the following:
eval_catch :: forall a. a -> (e1 -> IO a) -> IO a
(bound at Main.hs:498:0)
Probable fix: give these definition(s) an explicit type signature
or use -XNoMonomorphismRestriction
make[4]: *** [Main.o] Error 1
make[3]: *** [boot] Error 2
make[2]: *** [boot] Error 1
make[1]: *** [boot] Error 1
Any one have installed old version of GHC and generic haskell in ubuntu 10?
There are many pairs of version , i tried ghc-6.2.2 got above error, will i need to uninstall ubuntu 10 to install older version ubuntu to get it work? which version of ubuntu for which version of ghc work?
http://www.cs.uu.nl/research/projects/generic-haskell/compiler.html
I tried installing generic-haskell myself from the source, I managed, and am able to describe how I fixed it. My installation platform is the Haskell Platform 2011.2.0.1-x86_64, but the following instruction are somewhat more general.
I met three problems, including the first one you describe (no. 3 below). For other users, I also describe the first two ones, which you probably solved as well.
1) Other users have first to fix an error depending on Data.Map.lookup type having changed, for containers >= 0.2.0.0: it used to return Monad m => m b (in containers-1.0.0.0), now it returns just Maybe b.
I added calls to Data.Maybe.maybeToList to fix a few call-sites needing to use a list type; I bet you fixed the same error in some way. You can find this fix at:
http://hpaste.org/47624.
2) Another error I had, with GHC 7, is that the configure script does not realize that it is newer than GHC 6.8, so it needs to also depend on containers. configure output included this line:
checking whether base package is split (GHC 6.8 or newer)... no
To fix this, you need to replace
if test $ghc_ma -ge 6 -a $ghc_mi -ge 8; then
with
if test $ghc_ma -eq 6 -a $ghc_mi -ge 8 -o $ghc_ma -ge 7; then
3) To fix your problem, you need to edit build/generic-haskell.cabal.pkg (assuming you are not doing an in-place installation with make in-place). You need to add an id: line and fix the depends line to use package-ids of packages present on your systems instead of package names. You can find out the ids using the following commands (output on my system included):
$ ghc-pkg field base id
id: base-4.3.1.0-f5c465200a37a65ca26c5c6c600f6c76
$ ghc-pkg field haskell98 id
id: haskell98-1.1.0.1-150131ea75216886448a7146c9e0526b
$ ghc-pkg field containers id
id: containers-0.4.0.0-b4885363abca642443ccd842502a3b7e
The change to build/generic-haskell.cabal.pkg would then be:
-depends: base-4.3.1.0
- haskell98-1.1.0.1
- containers-0.4.0.0
+depends: base-4.3.1.0-f5c465200a37a65ca26c5c6c600f6c76
+ haskell98-1.1.0.1-150131ea75216886448a7146c9e0526b
+ containers-0.4.0.0-b4885363abca642443ccd842502a3b7e
Furthermore, you need to add an id line to the same file - any id will do, as long as you change it if/when you reinstall the library. Here I've used:
id: generic-haskell-1.80-lib-md5sum-2a7ae9d60440627618ad0b0139ef090b
I've also aligned all fields with spaces, as in the existing files. The syntax reference for this file can be found in:
http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/packages.html#installed-pkg-info
Apparently, the generic-haskell package depends on an old version of base.
The Haskell Platform specifies base-4.3.1.0, while generic-haskell needs an older version. Please contact the maintainers, or possibly, install an older version of GHC.

Resources