attoparsec Illegal equational constraint - haskell

as of the time of this writing, I'm running the newest GHC (7.9.20140608) and cabal (1.20.0.0), and it seems that attoparsec is failing.
Data/Attoparsec/ByteString/Internal.hs:519:7:
Illegal equational constraint a_audv ~ (ByteString, t)
(Use GADTs or TypeFamilies to permit this)
In the context: (a_audv ~ (ByteString, t))
While checking the inferred type for ‘succ'’
In the expression:
let
succ' t' pos' more' a
= succ t' pos' more' (substring pos (pos' - pos) t', a)
in runParser p t pos more lose succ'
In the second argument of ‘($)’, namely
‘\ t pos more lose succ
-> let succ' t' pos' more' a = ...
in runParser p t pos more lose succ'’
Am I missing any language extensions? Or would this issue be a little more tricky? Here is my cabal file: http://lpaste.net/105329
Any help with this would be incredible :) Happy Hacking!

For now, the best way to use ghc-7.8 (if your distro package manager doesn't include it) is to go to the ghc download page and follow the directions for the current stable release. There are binary packages, or you can install from source (with a source tarball, this can be as simple as ./configure && make && make install, but you'll need to have a working ghc already).
If you do install from source, you might consider changing the version, e.g. to 7.8.2.1. You can do this by editing the AC_INIT line in configure.ac then executing autoreconf before configure. If you do this, and also install to a version-specific location (e.g. /usr/local/ghc/ghc-7.8.2.1.src, this can be set via ./configure --PREFIX=/path/to/install), you'll be able to have your locally-compiled version installed concurrently with the packaged installation (or platform, or any other versions).
Be advised that ghc-7.8.3 is due out shortly (probably within two weeks at most); it's a bugfix release. Also there is currently no Haskell Platform release that includes ghc-7.8, so that's not an option at this time.

Related

Can older Cabal or Haskell projects be run on newer versions of Cabal and Haskell?

I'm trying to build my project and I'm running into a really strange problem. I got my friend to install Haskell with Chocolatey and when he goes to compile my project with cabal build and cabal run project he runs into the following error that I just don't have:
Expr.hs:103:1: error:
Type applications in patterns are not yet supported
|
103 | evalVal env val #(HInteger _) = return $ val
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I assumed that the cabal file would take care of dependencies but obviously not. A cursory search as well proves fruitless because I can't even find another instance of someone having the same error.
I'm not sure if the problem is due to him being on ghc 9.0.1 and cabal 3.4 and I'm on ghc 8.8.3 and cabal 3.2 or if it's due to different operating systems, his being Windows and I OSX.
My worry is that if I upgrade my ghc and cabal versions then I will run into this error and I'll have to reinstall everything which was messy and difficult the first time
It turns out that was a change in GHC 9.0: Whitespace-sensitive !, ~, #, and $
it's the second point there:
f # x = y
Before: value binding that binds both f and x to y using an as-pattern
After: infix function named (#)
To restore the old behavior, remove the leading and trailing whitespace around #, like so:
f#x = x
So if you change it to
evalVal env val#(HInteger _) = return $ val
it should work for both compilers

Type mismatch after cabal update?

Program has the following import:
import Pipes.Network.TCP
import Pipes
import Pipes.Core
import qualified Data.ByteString.Char8 as C
Compilation fails like so:
Couldn't match expected type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString'
with actual type `C.ByteString'
Expected type: Proxy
Int
bytestring-0.9.2.1:Data.ByteString.Internal.ByteString
()
b0
m0
()
Actual type: Proxy Int C.ByteString () C.ByteString IO ()
I can be more specific about the code, but it looks like this is not related to code - rather some cabal whim. Perhaps, Pipes that I import are considered to use a different ByteString than the one imported with qualified name.
The program used to compile some time ago (I have its working executable), but now it stopped, and I suspect there could have been some cabal update or package installation. How to debug and fix this?
Assuming your program is built with cabal, you should re-configure it. This may highlight other problems, such as dependencies which would require re-installing or breaking other parts of the dependency tree. The "old way" to solve this is to progressively cabal install more and more things until the dependency solver agrees it's possible, e.g.
$ cabal install .
# complains that reinstalls might break lens
$ cabal install . lens
# complains that reinstalls might break bytestring
$ cabal install . lens bytestring
# complains that reinstalls might break X
$ cabal install . lens bytestring X
...etc. The "new way" is to use no-reinstall cabal. You will still need to reconfigure before you build, and may need to install some dependencies again to transition properly.

Problems with SourceGraph (Haskell)

I try to visualize an existing Haskell code base with SourceGraph.
SourceGraph mycabal.cabal
But all I get are error messages like this:
Could not parse source file ./src/mysource.hs
SourceGraph: Could not find data file templates/default.html
Any hints what to do or where to look for documentation?
The only documentation I have found so far is this one: http://code.haskell.org/~ivanm/Sample_SourceGraph/SourceGraph/SourceGraph.html which unfortunately only consists of catchy images but with no hints how to produce them.
Regarding your immediate question, it seems like the best documentation here is the source: http://code.haskell.org/SourceGraph/
I tried it on a repository of my own, and ran into the parsing issue, too. This is haskell-src-exts failing to parse a module. The following patch shows the actual error:
--- Parsing.hs 2013-02-14 12:59:34.000000000 +0100
+++ ../SourceGraph-0.7.0.5-fixed/Parsing.hs 2014-04-08 20:49:54.000000000 +0200
## -64,7 +64,7 ##
parseFile :: FileContents -> Either FilePath Module
parseFile (p,f) = case (parseFileContentsWithMode mode f) of
(ParseOk hs) -> Right hs
- _ -> Left p
+ x -> Left $ p ++ ": " ++ show x
where
mode = defaultParseMode { parseFilename = p
, fixities = Nothing
It turns out that most of my failing modules failed because "MultiParamTypeClasses is not enabled". This is apparently haskell-src-exts being rightfully strict, while ghc is happy without the MultiParamTypeClasses extension: https://github.com/haskell-suite/haskell-src-exts/issues/29
So as a quick fix, try adding
{-# LANGUAGE MultiParamTypeClasses #-}
at the top of your failing modules.
Just ran into a similar issue, so I thought I'd document here what I did. I put my changes in a patch file.
https://gist.github.com/ivanperez-keera/b398ce71a22e8a4849f3
cabal sandbox init
cabal unpack SourceGraph
wget https://gist.githubusercontent.com/ivanperez-keera/b398ce71a22e8a4849f3/raw/bf26ffc45564934c0f175e7619ded8a299a9b7d5/verbose-sourcegraph.patch
cd SourceGraph-0.7.0.6/
patch -i ../verbose-sourcegraph.patch
cd ..
cabal install SourceGraph-0.7.0.6/
Most of the "errors" in my files where due to bang patterns and multi param type classes. There must be a better solution to make SourceGraph's parse mode default to the same as GHC.

Snap: Params type error

I get this type error:
Couldn't match type `containers-0.5.0.0:Data.Map.Base.Map
ByteString [ByteString]'
with `M.Map ByteString [ByteString]'
Expected type: M.Map ByteString [ByteString]
Actual type: Params
But Params type is Map ByteString [ByteString]
type Params = Map ByteString [ByteString]
If it is of any help, this is the full function:
import qualified Data.Map as M
categoryDoc :: Params -> Document
categoryDoc params = map (\(k,[v]) -> T.decodeUtf8 k =: T.decodeUtf8 v) $ M.toList params
Thank you.
You have encountered cabal hell.
The problem is that there are multiple versions of the containers package installed. This means that there are two versions of the Map data type, one from containers-0.5.0.0 and one from the other version. Those two won't match, and that's why you get the error.
The easiest solution to that problem is to delete the ~/.ghc (on unix) directory and rebuilt everything. But that won't protect you from such problems in future, and there is also a chance that it won't work at all. So this is not a good solution.
If you have cabal-install of at least version 1.18, you can use the cabal sandboxes feature. This allows you to create an isolated package environment for each project, and thus avoid such conflicts. Just switch to your project and run:
cabal sandbox init # Create a new sandbox
cabal install --only-dependencies # Install dependencies
cabal build # Build your project
You can also use cabal install to install your project into the sandbox or cabal repl to start GHCi with the right settings for your project.
If you do not have a new-enough version of cabal-install and can't upgrade, you can use cabal-dev to create and manage sandboxes.

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