Giter VIP home page Giter VIP logo

Comments (10)

MuhammedZakir avatar MuhammedZakir commented on July 21, 2024 1

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

from learn4haskell.

aleeusgr avatar aleeusgr commented on July 21, 2024

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?

from learn4haskell.

MuhammedZakir avatar MuhammedZakir commented on July 21, 2024

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.

from learn4haskell.

aleeusgr avatar aleeusgr commented on July 21, 2024

@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.

from learn4haskell.

byllgrim avatar byllgrim commented on July 21, 2024

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?

from learn4haskell.

MuhammedZakir avatar MuhammedZakir commented on July 21, 2024

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.

from learn4haskell.

byllgrim avatar byllgrim commented on July 21, 2024

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

from learn4haskell.

MuhammedZakir avatar MuhammedZakir commented on July 21, 2024

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?

from learn4haskell.

byllgrim avatar byllgrim commented on July 21, 2024

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.

from learn4haskell.

MuhammedZakir avatar MuhammedZakir commented on July 21, 2024

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/.

from learn4haskell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.