Errors about needing to add parsec to my build-depends in the .cabal file even though I already added it

Help
d1d2d3
2012-12-26
2012-12-28
  • d1d2d3
    d1d2d3
    2012-12-26

    In one of my source files, I import Text.ParserCombinators.Parsec. After I save the file (and ghci tries to compile it in the pane at the bottom of the screen,) it says:

    Could not find module `Text.ParserCombinators.Parsec'
        It is a member of the hidden package `parsec-3.1.3'.
        Perhaps you need to add `parsec' to the build-depends in your .cabal file.
        It is a member of the hidden package `parsec-2.1.0.1'.
        Perhaps you need to add `parsec' to the build-depends in your .cabal file.
        It is a member of the hidden package `parsec-3.1.2'.
        Perhaps you need to add `parsec' to the build-depends in your .cabal file.
        Use -v to see a list of the files searched for.
    Failed, modules loaded: none.
    

    After the first time I saw this message, I added "parsec" to my .cabal file. Later, every time I try to compile, in the ghci window, it looks as if my module was successfully loaded before showing the above message again.

    This is what my cabal file looks like:

    name:           Test2
    version:        0.1
    cabal-version:  >=1.2
    build-type:     Simple
    author:         xxxxxxxx
    
    library
      hs-source-dirs:  src
      build-depends:   
                       base >= 4,
                       parsec,
                       parsec3,
                       parsec2
      ghc-options:     -Wall
      exposed-modules: FindMiddle
    
    test-suite FindMiddle
      type:            exitcode-stdio-1.0
      x-uses-tf:       true
      ghc-options:     -Wall -rtsopts
      build-depends:   
                       base >= 4, HUnit >= 1.2 && < 2, QuickCheck >= 2.4, test-framework >= 0.4.1, test-framework-quickcheck2, test-framework-hunit,
                       parsec, parsec3, parsec2
      hs-source-dirs:  
                       src, 
                       tests
      main-is:         FindMiddle.hs
    
     
  • JP Moresmau
    JP Moresmau
    2012-12-27

    Have you restarted the GHCi session after having changed the cabal file? the list of packages is passed to GHCi on invocation.

     
  • d1d2d3
    d1d2d3
    2012-12-28

    Yes that seems to work, thanks!

    However, every time I open up Eclipse (in the same workspace,) I get the following message twice in the console:

    configuring because setup_config not present
    cabal: At least the following dependencies are missing:
    parsec2 -any, parsec3 -any
    

    I'm pretty sure I have those dependencies (especially since the code that depends on parsec runs.) I am unsure of what the -any flags mean though, and I think that may have something to do with it.

     
    Last edit: d1d2d3 2012-12-28
  • JP Moresmau
    JP Moresmau
    2012-12-28

    -any just means you didn't specify specific version bounds in your cabal file, that's normal. There are three parsec dependencies in your cabal, so you could have code depending on parsec working, but not code depending on parsec2 or parsec3