Closed aleeusgr closed 2 years ago
Use GHC-8.10.7
. If you really want to use 9.0.2
, then apply this patch (you might encounter compilation errors):
diff --git a/learn4haskell.cabal b/learn4haskell.cabal
index 9435632..eae3f7f 100644
--- a/learn4haskell.cabal
+++ b/learn4haskell.cabal
@@ -22,7 +22,7 @@ source-repository head
location: https://github.com/kowainik/learn4haskell.git
common common-options
- build-depends: base ^>= 4.14.0.0
+ build-depends: base >= 4.14.0.0 && <= 4.15.1.0
ghc-options: -Wall
-Wcompat
@@ -42,7 +42,7 @@ common common-options
common common-doctest
import: common-options
hs-source-dirs: test
- build-depends: doctest ^>= 0.17
+ build-depends: doctest >= 0.17 && <= 0.18.2
ghc-options: -threaded
library
@@ -63,7 +63,7 @@ test-suite learn4haskell-test
Test.Chapter3
Test.Chapter4
build-depends: learn4haskell
- , hspec ^>= 2.7.4
+ , hspec >= 2.7.4 && <= 2.8.5
, hspec-hedgehog
, hedgehog >= 1.0.2 && < 2
ghc-options: -threaded
Thank you. I get the behavior as you predicted with the patch: dependencies resolved, but there are errors that suggest that versions are incompatible. I will search how to install 8.10 on my system Should I close the issue?
Can you post the errors here? With above patch, I don't get any errors and I was able to compile successfully with both Cabal and Stack. So I guess the issue is probably with your setup. Maybe try a clean build (delete cabal data/caches, clone repo to new dir and try again)
FYI, versons of my haskell tools:
$ ghcup list -c set
Tool Version Tags Notes
ββ ghc 9.0.2 base-4.15.1.0 hls-powered
ββ cabal 3.6.2.0 latest,recommended
ββ hls 1.6.1.0 latest,recommended
ββ stack 2.7.5 latest,recommended
ββ ghcup 0.1.17.6 latest,recommended
Also, for installing haskell tools, I highly recommend GHCup.
@MuhammedZakir Totally agree. I went with ghcup today and it installed ghc 8.10 out of the box, with which Chapter1 compiled as expected.
I think my mistake was to use distro-specific installation method. Once I removed ghc and installed ghcup, an then ghc using it, it went smoothly.
I hope, at least.
Does that mean that the whole tutorial is only for ghc 8? I am having the exact same problems as aleeusgr reported. The readme says "Install the latest version of the Haskell compiler" but that doesn't seem to be true. I don't even know if my distro allows me to install some old version of a package, so maybe it is easier for me to download ghc 8 sources and build it myself, but that seems a bit much just for running a tutorial?
I have compiled this with GHC 9.0.2 and 9.2.2 and it worked. Note that to get this built with newer versions, you will have to adjust version constraints of packages. For simplicity, you can just remove version constraints in .cabal
file. Version constraints are added because newer GHC versions may break some packages.
Regarding installing GHC: you can use GHCup or Stack. Both will work just fine.
With the patch above I get this:
$ make test-chapter1
cabal test doctest-chapter1 --enable-tests --test-show-details=direct
Resolving dependencies...
Build profile: -w ghc-9.0.2 -O1
In order, the following will be built (use -v for more details):
- doctest-0.18.2 (lib) (requires download & build)
- learn4haskell-0.0.0.0 (test:doctest-chapter1) (first run)
Downloading doctest-0.18.2
Downloaded doctest-0.18.2
Starting doctest-0.18.2 (lib)
Building doctest-0.18.2 (lib)
Failed to build doctest-0.18.2.
Build log (
/home/<username>/.cabal/logs/ghc-9.0.2/doctest-0.18.2-76bdcbe9c085fa8da19502fbbf539a5a280bb30ad97d8ceaf5953f2f6c351d08.log
):
Configuring library for doctest-0.18.2..
Preprocessing library for doctest-0.18.2..
Building library for doctest-0.18.2..
[ 1 of 15] Compiling GhcUtil ( src/GhcUtil.hs, dist/build/GhcUtil.o, dist/build/GhcUtil.dyn_o )
src/GhcUtil.hs:4:1: error:
Could not find module βGHC.Pathsβ
There are files missing in the βghc-paths-0.1.0.12β package,
try running 'ghc-pkg check'.
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
4 | import GHC.Paths (libdir)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Failed to build doctest-0.18.2 (which is required by
test:doctest-chapter1 from learn4haskell-0.0.0.0). See the build log above for
details.
make: *** [Makefile:11: test-chapter1] Error 1
I don't know how what is meant by "you can just remove version constraints", and assuming that one doesn't need to know how cabal works in order to patch a tutorial before following the tutorial, I tried this:
index 9435632..5f00e28 100644
--- a/learn4haskell.cabal
+++ b/learn4haskell.cabal
@@ -22,7 +22,7 @@ source-repository head
location: https://github.com/kowainik/learn4haskell.git
common common-options
- build-depends: base ^>= 4.14.0.0
+ build-depends: base
ghc-options: -Wall
-Wcompat
@@ -42,7 +42,7 @@ common common-options
common common-doctest
import: common-options
hs-source-dirs: test
- build-depends: doctest ^>= 0.17
+ build-depends: doctest
ghc-options: -threaded
library
@@ -63,9 +63,9 @@ test-suite learn4haskell-test
Test.Chapter3
Test.Chapter4
build-depends: learn4haskell
- , hspec ^>= 2.7.4
+ , hspec
, hspec-hedgehog
- , hedgehog >= 1.0.2 && < 2
+ , hedgehog
ghc-options: -threaded
-rtsopts
-with-rtsopts=-N
But that results in (seemingly the same thing):
$ make test-chapter1
cabal test doctest-chapter1 --enable-tests --test-show-details=direct
Resolving dependencies...
Build profile: -w ghc-9.0.2 -O1
In order, the following will be built (use -v for more details):
- doctest-0.20.0 (lib) (requires build)
- learn4haskell-0.0.0.0 (test:doctest-chapter1) (first run)
Starting doctest-0.20.0 (lib)
Building doctest-0.20.0 (lib)
Failed to build doctest-0.20.0.
Build log (
/home/<username>/.cabal/logs/ghc-9.0.2/doctest-0.20.0-bae3fb9a26dcba15d4ded7de0673c0e935f8497b11dcb2df9325a3844b22dc08.log
):
Configuring library for doctest-0.20.0..
Preprocessing library for doctest-0.20.0..
Building library for doctest-0.20.0..
[ 1 of 16] Compiling GhcUtil ( src/GhcUtil.hs, dist/build/GhcUtil.o, dist/build/GhcUtil.dyn_o )
src/GhcUtil.hs:4:1: error:
Could not find module βGHC.Pathsβ
There are files missing in the βghc-paths-0.1.0.12β package,
try running 'ghc-pkg check'.
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
4 | import GHC.Paths (libdir)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Failed to build doctest-0.20.0 (which is required by
test:doctest-chapter1 from learn4haskell-0.0.0.0). See the build log above for
details.
make: *** [Makefile:11: test-chapter1] Error 1
I don't know how what is meant by "you can just remove version constraints", and assuming that one doesn't need to know how cabal works in order to patch a tutorial before following the tutorial, I tried this:
What you did is what I meant.
But that results in (seemingly the same thing):
I used stack
for building. When I posted above, I also tried cabal
and it worked. I think it is probably related to your GHC installation. Can you install GHC using GHCup
or stack
and try again?
Hi @MuhammedZakir. Thanks for replying to my messages and trying to help. I appreciate it. Sorry but I will not pursue this further. I was interested in following this tutorial to learn Haskell, but I am not too interested in debugging what quite frankly looks like bit rot.
You're welcome! Whenever I install a language's toolchain, I always try to use tools similiar to GHCup
. I have encountered problems when using them via system package manager. That's why, I suggested you to give GHCup
a try. It's very easy and straightforward.
However, I can understand what you mean. Good luck! :-)
P.S. When/if you want to learn Haskell again, you should also look at http://learnyouahaskell.com/, or/and if you're willing to spend some money, then https://haskellbook.com/.
Hi! I am trying the course, after cloning the repo first thing I do is to run a test.
$make test-chapter1-basic
I am using:
which I have installed and configured following this guide I have tried modifying learn4haskell.cabal and removing version constraint, which resulted in a failure in a different dependency.
Please comment on possible solutions or workarounds. Thank you