I think one of the most common stuffs to build when learning a programming language is web app, so when learning Haskell, I decided to give Snap a try.
I'm on macOS Monterey (x64), didn't install GHC via Homebrew. Used ghcup, instead
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
This is what I got when running ghcup tui
GHCup 0.1.22.0 (latest, recommended)
Stack 2.15.5 (recommended)
HLS 2.7.0.0 (recommended)
cabal 3.10.3.0 (latest,recommended)
GHC 9.8.2
Let's install snap:
$ cabal update
$ cabal install snap snap-templates
Then create a Snap project:
$ mkdir snapdtest
$ cd snaptest
$ snap init barebones
$ cabal install
Got these errors:
Error: cabal: Could not resolve dependencies:
[__0] trying: snaptest-0.1 (user goal)
[__1] next goal: bytestring (dependency of snaptest)
[__1] rejecting: bytestring-0.12.1.0/installed-ab96 (conflict: snaptest =>
bytestring>=0.9.1 && <0.11)
[__1] skipping: bytestring-0.12.1.0, bytestring-0.12.0.2, bytestring-0.12.0.1,
bytestring-0.12.0.0, bytestring-0.11.5.3, bytestring-0.11.5.2,
bytestring-0.11.5.1, bytestring-0.11.5.0, bytestring-0.11.4.0,
bytestring-0.11.3.1, bytestring-0.11.3.0, bytestring-0.11.2.0,
bytestring-0.11.1.0, bytestring-0.11.0.0 (has the same characteristics that
caused the previous version to fail: excluded by constraint '>=0.9.1 && <0.11'
from 'snaptest')
[__1] trying: bytestring-0.10.12.1
[__2] next goal: base (dependency of snaptest)
[__2] rejecting: base-4.19.1.0/installed-654f (conflict: bytestring =>
base>=4.2 && <4.16)
[__2] skipping: base-4.20.0.1, base-4.20.0.0, base-4.19.1.0, base-4.19.0.0,
base-4.18.2.1, base-4.18.2.0, base-4.18.1.0, base-4.18.0.0, base-4.17.2.1,
base-4.17.2.0, base-4.17.1.0, base-4.17.0.0, base-4.16.4.0, base-4.16.3.0,
base-4.16.2.0, base-4.16.1.0, base-4.16.0.0 (has the same characteristics that
caused the previous version to fail: excluded by constraint '>=4.2 && <4.16'
from 'bytestring')
[__2] rejecting: base-4.15.1.0, base-4.15.0.0, base-4.14.3.0, base-4.14.2.0,
base-4.14.1.0, base-4.14.0.0, base-4.13.0.0, base-4.12.0.0, base-4.11.1.0,
base-4.11.0.0, base-4.10.1.0, base-4.10.0.0, base-4.9.1.0, base-4.9.0.0,
base-4.8.2.0, base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1,
base-4.7.0.0, base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0,
base-4.4.1.0, base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2,
base-4.2.0.1, base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2,
base-3.0.3.1 (constraint from non-upgradeable package requires installed
instance)
[__2] fail (backjumping, conflict set: base, bytestring, snaptest)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: bytestring, base, snaptest
How to solve this?
Info added: my .cabal
file:
Name: snaptest
Version: 0.1
Synopsis: Project Synopsis Here
Description: Project Description Here
License: AllRightsReserved
Author: Author
Maintainer: maintainer@example.com
Stability: Experimental
Category: Web
Build-type: Simple
Cabal-version: >=1.2
Executable snaptest
hs-source-dirs: src
main-is: Main.hs
Build-depends:
base >= 4 && < 5,
bytestring >= 0.9.1 && < 0.11,
mtl >= 2 && < 3,
snap-core >= 1.0 && < 1.1,
snap-server >= 1.0 && < 1.2
if impl(ghc >= 6.12.0)
ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2
-fno-warn-unused-do-bind
else
ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2
As a first experiment, try cabal build --allow-newer
. If that succeeds, then you can know that the following advice will eventually get you something that works.
My read of this is that snap init
wrote a .cabal
file with a bytestring
dependency that's too strict/is out of date. From hackage, we can see that the latest snap
s can work with bytestring-0.12.*, so try relaxing the dependency on bytestring
(and possibly on snap
) in the auto-generated file.
I reproduced your issue using this .cabal
file. If you're using the same one, I also needed to update the cabal-version
directive to 1.8; after that, it built with ghc-9.8.1 (the one I have installed, too lazy to try with ghc-9.8.2 but I'd be shocked if it worked on one but not the other). Here's the exact diff:
11c11
< Cabal-version: >=1.2
---
> Cabal-version: >=1.8
19c19
< bytestring >= 0.9.1 && < 0.11,
---
> bytestring >= 0.9.1 && < 0.12,