windows install for Haskell Frp package? - haskell

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.

Related

Craft3e: cabal install not in scope: Applicative

I am attempting to install the code for "Haskell: The Craft of Functional Programming", 3rd edition.
I'm using GHCi, version 7.6.3 on Centos version 7.
Then:
cabal unpack Craft3e
cd Craft3e-0.1.1.0/
cabal install
...
[29 of 67] Compiling CalcParseLib ( Calculator/CalcParseLib.hs, dist/build/CalcParseLib.o )
Calculator/CalcParseLib.hs:132:10:
Not in scope: type constructor or class `Applicative'
Failed to install Craft3e-0.1.1.0
cabal: Error: some packages failed to install:
Craft3e-0.1.1.0 failed during the building phase. The exception was:
ExitFailure 1
I have attempted this installation multiple times, but cannot
overcome this error.
Could I use something other than "cabal install"?
I have plenty to learn about Haskell before I get to this example,
but it would be great to know the installation is fine! :)
You have three options:
Install an older version of the Craft3e package, with e.g. cabal unpack Craft3e-0.1.0.10.
Find Calculator/CalcParseLib.hs in the source files you have downloaded with cabal unpack and add a...
import Control.Applicative
... line next to the other import lines at the beginning. I suspect you will have to do the same with other modules, if the same error shows up elsewhere after you do this change, and there might be other issues of a similar nature.
Install a newer version of GHC (7.6.3 is from 2013). Though the default CentOS repositories won't offer that, there are other options, such as an unofficial Fedora repository and a manual installation. See this page for instructions.
#3 is the definitive solution. If you just want to get started with the book right now, though, you can go for #1 and leave the reinstall for later.
For the sake of reference, here is a brief explanation of the problem (I will use some unfamiliar terms, but you will soon enough learn about them as you study Haskell). There is an important type class called Applicative which, for historical reasons, wasn't as well integrated with the rest of the core libraries as it should be. This situation was corrected in GHC 7.10, which both included Applicative in the Prelude (the module which is imported by default in Haskell programs) and made it necessary to add Applicative instances in a number of places where they were missing. The code in the Craft3e package was updated so that these Applicative instances were in place (cf. this entry in the book's blog), but the import Control.Applicative line, which would be necessary to make the updated code work in older GHCs that do not have Applicative in the Prelude, wasn't added, leading to the error that you are seeing.

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.

Ambiguous occurence `unsafePerformIO' when installing binary-strict

I'm trying to cabal install binary-strict and I get this error:
src/Data/Binary/BitBuilder.hs:205:37:
Ambiguous occurrence `unsafePerformIO'
It could refer to either `Foreign.unsafePerformIO',
imported from `Foreign' at src/Data/Binary/BitBuilder.hs:38:1-14
or `System.IO.Unsafe.unsafePerformIO',
imported from `System.IO.Unsafe' at src/Data/Binary/BitBuilder.hs:42:26-40
(and originally defined in `GHC.IO')
Failed to install binary-strict-0.4.8.1
cabal: Error: some packages failed to install:
binary-strict-0.4.8.1 failed during the building phase. The exception was:
ExitFailure 1
I'm running ghc 7.6.3. If it's relevant, I have binary-0.7.2.3 installed too.
As written, binary-strict only works for base >= 4.7. GHC 7.6.3 uses base = 4.6.* so it will not work. You should file a bug with the maintainer and work around the issue by adding hiding (unsafePerformIO) to the import Foreign line of the file in question.
I only just found out about this. It is now fixed. Also I have listed the git repo in the package details so you can now raise issues and I will know about them. Thanks to Thomas for suggesting the fix.

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.

Another installing Yesod on Ubuntu difficulty

Looking around StackOverflow I see a bunch of similar problems, but each about a specific library.
Here's mine :
When trying to run :
cabal install yesod
I get
Resolving dependencies...
Configuring yaml-0.8.7...
Building yaml-0.8.7...
Preprocessing library yaml-0.8.7...
Data/Yaml/Parser.hs:15:8:
Could not find module `Data.Conduit.Lift'
Perhaps you meant
Data.Conduit.List (from conduit-1.0.8)
Data.Conduit.List (needs flag -package conduit-1.0.5.1)
Data.Conduit.Text (needs flag -package conduit-1.0.5.1)
Use -v to see a list of the files searched for.
Failed to install yaml-0.8.7
Configuring yesod-core-1.2.10...
Building yesod-core-1.2.10...
Preprocessing library yesod-core-1.2.10...
Yesod/Core/Json.hs:47:8:
Could not find module `Data.Conduit.Lift'
Perhaps you meant
Data.Conduit.List (from conduit-1.0.8)
Data.Conduit.List (needs flag -package conduit-1.0.5.1)
Data.Conduit.Text (needs flag -package conduit-1.0.5.1)
Use -v to see a list of the files searched for.
Failed to install yesod-core-1.2.10
cabal: Error: some packages failed to install:
yaml-0.8.7 failed during the building phase. The exception was:
ExitFailure 1
yesod-1.2.5.2 depends on yesod-core-1.2.10 which failed to install.
yesod-auth-1.3.0.2 depends on yesod-core-1.2.10 which failed to install.
yesod-core-1.2.10 failed during the building phase. The exception was:
ExitFailure 1
yesod-form-1.3.8.1 depends on yesod-core-1.2.10 which failed to install.
yesod-persistent-1.2.2.2 depends on yesod-core-1.2.10 which failed to install.
Is something broken in Hackage or is this just on my machine?
You're trying to install a version of yaml that doesn't have a strict enough lower bound on conduit. There is a newer version already on Hackage. It looks like you haven't run cabal update.

Resources