Trouble including tasty-quickcheck in the build - haskell

I am new to stack.
I have a stack project that I want to use tasty-quickcheck. When I add tasty-quickcheck to package.yaml, stack asks me to add it to stack.yaml as well under extra-deps section. After adding tasty-quickcheck-0.10.1.1 to extra-deps stack asked me to add around a dozen more packages to extra-deps which I added.
Now I am at a stage where I get the following error when I try to do stack build.
stack build
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for transformers-compat-0.6.5:
transformers-0.5.6.2 from stack configuration does not match >=0.3 && ==0.2.*
needed due to tic-tac-toe-0.1.0.0 -> transformers-compat-0.6.5
Some different approaches to resolving this:
* Set 'allow-newer: true'
in /Users/home/.stack/config.yaml to ignore all version constraints and build anyway.
Plan construction failed.
My package.yaml looks like below.
...
dependencies:
- base >= 4.7 && < 5
- vector
- mtl
- tasty-quickcheck
...
My stack.yaml looks like below.
...
resolver: ghc-8.8.3
extra-deps:
- vector-0.12.1.2
- primitive-0.7.0.1
- tasty-quickcheck-0.10.1.1
- random-1.1
- tagged-0.8.6
- tasty-1.3.1
- QuickCheck-2.14
- ansi-terminal-0.10.3
- async-2.2.2
- clock-0.8
- optparse-applicative-0.15.1.0
- unbounded-delays-0.1.1.0
- wcwidth-0.0.2
- ansi-wl-pprint-0.6.9
- colour-2.3.5
- hashable-1.3.0.0
- splitmix-0.0.5
- transformers-compat-0.6.5
...
I have two questions.
How do I fix the error above?
Is it usual that stack tells you to add a dozen more dependencies just to get a single package like tasty-quickcheck included? That doesn't sound great to me. Is that the norm with most packages?

Quoting a comment:
Which resolver (or snapshot) is specified in your stack.yaml?
#duplode It is resolver: ghc-8.8.3
You presumably don't want to use the ghc-* resolvers in this case. They only specify the GHC version (and the version of small handful of packages which are bundled with GHC), which is why you had to add everything else to extra-deps. Change the resolver to lts-16.0 (the most recent Stackage LTS, which does include tasty-quickcheck-0.10.1.1), remove the extra-deps from the stack.yaml file; that should be enough for things to work.

Related

transformers-0.5.6.2 from stack configuration does not match >=0.3 && ==0.2.*

I'm trying to include quickcheck-instances package for testing. Here is how my dependencies field in package.yaml looks like:
dependencies:
- blackjack
- quickcheck-instances >= 0.3.25 && < 0.4
- QuickCheck >= 2.14.2 && < 2.15
Here is how my extra-deps field in stack.yaml looks like:
extra-deps:
- quickcheck-instances-0.3.25.2#sha256:083b84b91fccb3bbf22cd906f5bc731c8e6ee96c7554e892985452f2d61d4ad3,4484
- hashable-1.3.3.0#sha256:7f3b67151162a1dfe8472dc30430af98ed5470801d3f4b6c9b8d7a7443c920d4,4068
- unordered-containers-0.2.14.0#sha256:2fe789f78246b7c7ec10d7b85c72d898a9f72fdda5b60d581e839d21016bc628,4992
- QuickCheck-2.14.2#sha256:4ce29211223d5e6620ebceba34a3ca9ccf1c10c0cf387d48aea45599222ee5aa,7736
- case-insensitive-1.2.1.0#sha256:9dfd3171fc7698cf8d931727d3af3a7b389135b583e46b5adac1f9d2026fff61,2244
- data-fix-0.3.2#sha256:ca5ee8d5e15d08e65e9af74004cd663391706c0a62b7d1c6d0023e4c34cd0038,1659
- integer-logarithms-1.0.3.1#sha256:888fb6c4fbd79ed2e8f8b94b61bccac25f7fab2b13b32b496e86828bc60b17cf,3184
- old-time-1.1.0.3#sha256:c91fbb3ee73d20ccd015842b30f1f29a304893ebe0ae3128b7bbc13d5bb0d4c8,1328
- scientific-0.3.7.0#sha256:0f188a7b92780d81a2e3cf1195a3a24cfe3e7c43d0e9e0f2101a465803d68076,4773
- splitmix-0.1.0.3#sha256:fc3aae74c467f4b608050bef53aec17904a618731df9407e655d8f3bf8c32d5c,6049
- strict-0.4.0.1#sha256:50187e750751a258efea12ef2979e16a014a953c15bf4c2fca2f1168a44a5a12,4156
- tagged-0.8.6.1#sha256:29c67d98a4404607f024750ab9c7210dadcbbef4e1944c48c52902f2071b2662,2874
- these-1.1.1.1#sha256:bdc0a3015b2e5cdf016e402937d71856ae5fe4e9e9a0d4823cc94a214c55a39b,2732
- time-compat-1.9.6.1#sha256:cddf1a7654ccc3564d2197e6bf0064254abf792c591a9fa0eaa16e6039036152,4997
- uuid-types-1.0.5#sha256:5031383749d57cb95877d7e56f0300be66652b6e57f5ba6681dcc6e4f78d046d,2541
- vector-0.12.3.0#sha256:0ae2c1ba86f0077910be242ec6802cc3d7725fe7b2bea6987201aa3737b239b5,7953
- assoc-1.0.2#sha256:a824e4f615469a27ad949dbf4907ba258bd6b459deebec00524c7bcb3f65cc9f,1205
- base-orphans-0.8.5#sha256:b01baac1b88cc80e70214c064ec8c174718c19400232588bff591f5a9c49a750,3177
- old-locale-1.0.0.7#sha256:fa998be2c7e00cd26a6e9075bea790caaf3932caa3e9497ad69bc20380dd6911,1071
- primitive-0.7.2.0#sha256:d7c3635e83ae160129cdfe2be4092ab6389199d73a2c29adf904124dbcfe6100,2660
- random-1.2.0#sha256:195506fedaa7c31c1fa2a747e9b49b4a5d1f0b09dd8f1291f23a771656faeec3,6097
- bifunctors-5.5.11#sha256:cc425ee85aae56dba1123baf6fb3fa7abcd90782f26bb904eef14c7332ee85f6,3919
- comonad-5.0.8#sha256:1f1aabd73ec7f80f20cf078a748a60cd48d8e57277802fdf6a9ab3601a9b8f7e,3631
- th-abstraction-0.4.3.0#sha256:db4b3b69398acd8a7c5c8cc8a962da55d65d05d44d5039b51bd3cb5fb3d8400f,2148
- distributive-0.6.2.1#sha256:0f99f5541cca04acf89b64432b03422b6408e830a8dff30e6c4334ef1a48680c,2996
- indexed-traversable-0.1.1#sha256:e4602357513aa3b146546227732e6e5698392f4324ab690e109cc05676ba3b4f,2491
- transformers-compat-0.6.6#sha256:510709db2b12d1510d70de824ee544ca0a9e6f27aa7e299218cbacc0750b4a5e,5560
- transformers-0.5.6.2#sha256:6c959d14430f4deffb99579ba019de07c3d852a2122b6f449344386c7d75ff1d,3172
This is the error I got:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for transformers-compat-0.6.6:
transformers-0.5.6.2 from stack configuration does not match >=0.3 && ==0.2.*
needed due to blackjack-0.1.0.0 -> transformers-compat-0.6.6
Some different approaches to resolving this:
* Set 'allow-newer: true' in /home/xwtek/.stack/config.yaml to ignore all version constraints and build anyway.
Plan construction failed.
Of course after setting the allow-newer into true, it works, but I don't want to mess with that setting, because I fear that something like that would make things break later. Any better solution?
Clearly, you are missing how stack works. You should read the stack user guide, but let me explain briefly. stack uses two files to work:
stack.yaml: It defines from where stack should download packages. By default Stackage. Optionally, git repos, hackage or local libraries.
package.yaml: It defines which libraries you'll be using along with how to build your executable. Dependencies, compiler flags, test, etc...
In general the only thing you need to touch from stack.yaml is the resolver, and then use package.yaml to list your dependencies. So, How does stack.yaml is used?
You should have a line like this
resolver:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/6.yaml
This specifies the set of packages you gonna use, called: resolver or snapshot. All libraries version within an snapshot are guaranteed to build togheter with no dependency hell. In the example above the resolver is set to lts-18.6. So, If you visit stackage page for that snapshot you'll see all suported libraries and the compiler version: ghc-8.10.4
So let say I want to add QuickCheck to my dependencies. In my package.yaml I would list it down the library dependencies label
library:
dependencies:
- QuickCheck
The version of QuickCheck is determine by the selected resolver (18.6) which in this case is QuickCheck-2.14.2 as you can check in the stackage web. Of course, it is a good practise to specify the actual version in package.yaml
library:
dependencies:
- QuickCheck-2.14.2
But it is not necessary, since the resolver already sets the version from you. If you need another version of the package, then you have to add it to extra-deps, indicating stack that you want packages from lts-18.6 and a different package listed in extra-deps
The stack documentation is fairly good, so you should read it more carefully.

Stack doesn't seem to apply package revision

I had the following (excerpt of) stack.yaml:
extra-deps:
- bytestring-0.10.12.0
Then I wanted to install cassava, which I did by adding:
extra-deps:
- bytestring-0.10.12.0
- cassava-0.5.2.0
But then I had this error on stack build:
In the dependencies for cassava-0.5.2.0:
bytestring-0.10.12.0 from stack configuration does not match >=0.9.2 && <0.10.4 (latest matching version is 0.10.2.0)
needed due to my-project-0.1.0.0 -> cassava-0.5.2.0
To which I discovered that there's a revision (all of them from rev2 onwards) that deals with this explicit problem, by bumping the dependency on ByteString to <0.12.
Therefore stack.yaml now looks like this:
extra-deps:
- bytestring-0.10.12.0
- cassava-0.5.2.0#rev:4
But nothing changes on stack build, I still got the same error. Is there any way around this?

How to resolve dependency tree with different version ranges of same packages?

I'm trying to set up a happstack-lite application using stack.
I initialized project with these commands:
stack new my-happstack
cd my-happstack
stack setup
I changed package.yaml so it contains:
dependencies:
- base >= 4.7 && < 5
- happstack-lite >= 7.3
Then I ran stack build several times and changed extra-deps in stack.yaml in project directory according to recommendations (added dependencies, such as happstack-server).
Apparently, I was asked to add to extra-deps the packages already listed there, with different version bounds and one with the same (template-haskell-2.11.1.0):
stack.yaml content:
extra-deps:
- happstack-lite-7.3.6
- happstack-server-7.4.6.4
- Win32-2.2.2.0#sha256:10ed55dd31315f386910c121c1d1d442df83bd2ee92090a753cd65300735a8ca
- network-2.6.3.6#sha256:1ca79d81af02d7acd6032d5e6c9bde4618a8fdcfbe19bd42b49d420183975df0
- template-haskell-2.11.1.0#sha256:f90d6ab73ad35c749e8547ca132e7ab5d32d2f8e7bb2e2ff6d597be26b58e061
- transformers-compat-0.5.1.4#sha256:1b4bfa8589afb1ca0e719129ab261bd90ef0cc3e6c0b9963f94970c082b61250
output from stack build:
F:\Projects\Haskell\my-happstack>stack build
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for Cabal-2.4.1.0:
Win32-2.2.2.0 from stack configuration does not match >=2.3.0.0 && <2.9 (latest matching
version is 2.8.3.0)
needed due to my-happstack-0.1.0.0 -> Cabal-2.4.1.0
In the dependencies for happstack-server-7.4.6.4:
template-haskell-2.14.0.0 from stack configuration does not match <2.12 (latest matching
version is 2.11.1.0)
needed due to my-happstack-0.1.0.0 -> happstack-server-7.4.6.4
In the dependencies for transformers-base-0.4.5.2:
transformers-compat-0.5.1.4 from stack configuration does not match >=0.6.1 (latest matching
version is 0.6.4)
needed due to my-happstack-0.1.0.0 -> transformers-base-0.4.5.2
Some different approaches to resolving this:
* Set 'allow-newer: true' in C:\sr\config.yaml to ignore all version constraints and build anyway.
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some
working build configuration. This can be convenient when dealing with many complicated
constraint errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps
in F:\Projects\Haskell\my-happstack\stack.yaml:
Win32-2.8.3.0#sha256:58fa6f52e8a0d455a74bb19445c177f2cc79a0975cae5fd96e2334bd38a516d4
template-haskell-2.11.1.0#sha256:f90d6ab73ad35c749e8547ca132e7ab5d32d2f8e7bb2e2ff6d597be26b58e061
transformers-compat-0.6.4#sha256:d298cd9d1bb7b05160229e244436bae825b53660865e3d5fd695ea0fafec1e6f
Plan construction failed.
I've tried these steps:
1) Set 'allow-newer: true' in C:\sr\config.yaml. In this case, I'm getting error about wrong types usage from inside one of the dependent packages (can paste error output upon request, if needed).
2) Run stack solver. I've got the error from cabal planner (error output upon request).
So, I expect stack to resolve dependencies the way npm does - each package dependencies are resolved independently from other's packages needs. Any advice of how I can solve this particular problem will be helpful, though (including manual dependencies resolving).

Stack is unable to resolve the correct package version

I am trying to use grenade in Haskell. Using stack as a configuration tool, I have
# stack.yaml
extra-deps:
- diagrams-solve-0.1.1
- dual-tree-0.2.2
- SVGFonts-1.6.0.3
- diagrams-core-1.4.1
- diagrams-lib-1.4.2.2
- diagrams-postscript-1.4.1
- diagrams-svg-1.4.2
- Chart-diagrams-1.8.3
- hip-1.5.3.0
- singletons-2.2
- template-haskell-2.11.1.0
- th-desugar-1.6
- grenade-0.1.0
But when I execute stack build, it gives me the following error
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for th-desugar-1.6:
template-haskell-2.12.0.0 from stack configuration does not match <2.12 (latest
matching version is 2.11.1.0)
needed due to Brain-0.1.0.0 -> th-desugar-1.6
Some different approaches to resolving this:
* Set 'allow-newer: true' to ignore all version constraints and build anyway.
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to
find some working build configuration. This can be convenient when dealing with
many complicated constraint errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps
in [Project directory]/stack.yaml:
- template-haskell-2.11.1.0
Plan construction failed.
Even if I put - template-haskell-2.11.1.0 before diagrams-solve, stack still gives me the same error. Allowing newer versions is not viable since it breaks th-desugar.
That looks like a lot of extra-deps. I'd recommend figuring out a good resolver first. The best way to do that is use the original repo:
git clone git#github.com:HuwCampbell/grenade.git
cd grenade
stack init
Which gives you the following output:
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- ./
- examples/
Selecting the best among 13 snapshots...
* Partially matches lts-11.13
criterion version 1.3.0.0 found
- grenade requires ==1.1.*
Downloaded nightly-2018-06-16 build plan.
* Partially matches nightly-2018-06-16
criterion version 1.4.1.0 found
- grenade requires ==1.1.*
hmatrix version 0.19.0.0 found
- grenade requires ==0.18.*
- grenade-examples requires ==0.18.*
singletons version 2.4.1 found
- grenade requires >=2.1 && <2.4
* Partially matches lts-10.10
criterion version 1.2.6.0 found
- grenade requires ==1.1.*
Downloaded lts-9.21 build plan.
* Matches lts-9.21
Selected resolver: lts-9.21
Initialising configuration using resolver: lts-9.21
Total number of user packages considered: 2
Writing configuration to file: stack.yaml
All done.
So use the base resolver lts-9.21. And I'd open an issue on the repo of grenade to add it to stack.

Why am I getting build plan errors running "stack haddock" when "stack test" works?

I'm creating a new Haskell project using Stack 0.1.3.1 on Windows 8. My stack.yaml file looks like this:
flags: {}
packages:
- 'lazy-engine'
extra-deps: []
resolver: lts-3.4
When I run stack build or stack test, everything works beautifully. I can run haddock manually from the command line and that works, too. But when I run stack haddock I get output like this:
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the haddock command is functionally equivalent to 'build --haddock'
While constructing the BuildPlan the following exceptions were encountered:
-- Failure when adding dependencies:
base: needed (>=4.5 && <4.9), latest is 4.8.1.0, but not present in build plan
needed for package: array-0.5.1.0
-- While attempting to add dependency,
Could not find package base in known packages
-- Failure when adding dependencies:
array: needed (-any), latest is 0.5.1.0, but couldn't resolve its dependencies
base: needed (>=4.2 && <5), latest is 4.8.1.0, but not present in build plan
deepseq: needed (>=1.2 && <1.5), latest is 1.4.1.2, but couldn't resolve its dependencies
ghc-prim: needed (-any), latest is 0.4.0.0, but not present in build plan
needed for package: containers-0.5.6.2
-- Failure when adding dependencies:
array: needed (>=0.3 && <0.6), latest is 0.5.1.0, but couldn't resolve its dependencies
base: needed (==4.3.* || >=4.5 && <4.9), latest is 4.8.1.0, but not present in build plan
needed for package: deepseq-1.4.1.1
-- While attempting to add dependency,
Could not find package ghc-prim in known packages
-- Failure when adding dependencies:
base: needed (>=4.7 && <5), latest is 4.8.1.0, but not present in build plan
containers: needed (==0.5.*), latest is 0.5.6.3, but couldn't resolve its dependencies
needed for package: lazy-engine-0.1.0.0
Recommended action: try adding the following to your extra-deps in
C:\Users\Aaron\Documents\GitHub\lazy-engine\stack.yaml
- base-4.8.1.0
- ghc-prim-0.4.0.0
You may also want to try the 'stack solver' command
Obviously this is nonsense—I shouldn't have to add base to my extra-deps, especially since I'm working off an LTS package set! What is going on here?
Update: As discussed in the answer below, this seems to have been a bug in stack and should be fixed in newer versions. See https://github.com/fpco/minghc/issues/85.
A guess: you're using a GHC install that does not include documentation, or at least not as stack expects it to be discovered. Can you try with "--install-ghc --no-system-ghc"? I may have the specific flag names wrong.
Also, how is GHC installed on your system?
I solved this by installing the ghc-doc package (available in most package managers).

Resources