0

I've added "QuickCheck" to the "build depends" section of the .cabal file but when I do stack setup the "QuickCheck" section of the file gets removed and I get this error:

    It is a member of the hidden package ‘Cabal-3.2.1.0’.
    You can run ‘:set -package Cabal’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
1 | import Distribution.Simple
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

the stack build and stack ghci work fine but stack test gives this error:

Could not find module ‘Test.QuickCheck’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
3 | import           Test.QuickCheck
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Progress 1/2

--  While building package palindrome-testing-0.1.0.0 (scroll up to its section to see the error) using:
      /Users/artin/.stack/setup-exe-cache/aarch64-osx/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.7 --builddir=.stack-work/dist/aarch64-osx/Cabal-3.2.1.0 build lib:palindrome-testing exe:palindrome-testing-exe test:palindrome-testing-test --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

.cabal file:

cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.34.6.
--
-- see: https://github.com/sol/hpack

name:           palindrome-testing
version:        0.1.0.0
description:    Please see the README on GitHub at <https://github.com/githubuser/palindrome-testing#readme>
homepage:       https://github.com/githubuser/palindrome-testing#readme
bug-reports:    https://github.com/githubuser/palindrome-testing/issues
author:         Author name here
maintainer:     example@example.com
copyright:      2022 Author name here
license:        BSD3
license-file:   LICENSE
build-type:     Simple
extra-source-files:
    README.md
    ChangeLog.md

source-repository head
  type: git
  location: https://github.com/githubuser/palindrome-testing

library
  exposed-modules:
      Lib
  other-modules:
      Paths_palindrome_testing
  hs-source-dirs:
      src
  build-depends:
      base >=4.7 && <5
  default-language: Haskell2010

executable palindrome-testing-exe
  main-is: Main.hs
  other-modules:
      Paths_palindrome_testing
  hs-source-dirs:
      app
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
    , palindrome-testing
  default-language: Haskell2010

test-suite palindrome-testing-test
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  other-modules:
      Paths_palindrome_testing
  hs-source-dirs:
      test
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
    , palindrome-testing
    , QuickCheck
  default-language: Haskell2010

ghc version: 8.10.7

stack version: 2.7.4

cabal version: 3.6.2

I'm running macOS monterey on M1

1 Answers1

3

Your cabal file was generated from the package.yaml file in that directory:

-- This file has been generated from package.yaml by hpack version 0.34.6.
--
-- see: https://github.com/sol/hpack

If you want to add new dependencies, add them to package.yaml. Any changes you make to the .cabal file will get overridden.

Daniel Martin
  • 23,083
  • 6
  • 50
  • 70
  • it fixed the ```stack test``` issue but ```stack setup``` still gives the same error and won't work – artin ghasivand Jan 18 '22 at 18:58
  • So `stack test` does in fact work? When you add your dependency to the `package.yaml` file, and then run `stack setup`, is there a bit in the cabal file that mentions `QuickCheck`? – Daniel Martin Jan 18 '22 at 20:33
  • Yes Daniel, it actually works and I can run my tests again! thank you. but the stack setup command still gives the same error – artin ghasivand Jan 18 '22 at 21:02