What version of the package do I have?

You need to think that this is a FAQ, but I could not find the answer to this simple question:

What version of the specific package do I have in my GHC installation?

Background

I am trying to learn Haskell and for this I go through Real World Haskell . Now I have reached chapter 11 , which, among other things, introduces QuickCheck.

Unfortunately, QuickCheck has changed since the book was published in 2009, and it looks like it has undergone various changes. Whenever I look for a new way to do things as alternatives to instructions in a book, new ways sometimes also don't work. Perhaps the "new way" was described in 2012, but QuickCheck has changed again between now and now.

Ultimately, I will need to figure out how to use QuickCheck from the documentation or source code, but it would be useful to know which version I should research.

I have not yet reached the point that I learned about Kabbalah and the like, so my question is based on simple ignorance. Hope there is a simple answer.

I am using GHC on Windows and apparently QuickCheck is already associated with my installation. I already have QuickCheck, but I don’t know which version.

+8
haskell ghc quickcheck
source share
1 answer

Using cabal info

You can use cabal info <packagename> to get package information, including the current version:

 $ cabal info QuickCheck
 * QuickCheck (library)
     Synopsis: Automatic testing of Haskell programs
     Versions available: 1.1.0.0, 1.2.0.0, 1.2.0.1, 2.6, 2.7.4, 2.7.5, 2.7.6,
                         2.8, 2.8.1 (and 24 others)
     Versions installed: 2.8.1
     Homepage: https://github.com/nick8325/quickcheck
     Bug reports: mailto: quickcheck@projects.haskell.org
     Description: QuickCheck is a library for random testing of program
                    properties.

                    The programmer provides a specification of the program, in
                    the form of properties which functions should satisfy, and
                    ...

So, all you have to do is grep "Versions installed":

 $ cabal info QuickCheck | grep "Versions installed" Versions installed: 2.8.1 

On Windows, you can use findstr:

 $ cabal info QuickCheck | findstr /C:"Versions installed" Versions installed: 2.8.1 

Note. If you do not have <packagename> installed, but want to know some information about this, you may need cabal update .

Using ghc-pkg

If you don't have cabal installed, you can still use the GHC package manager, ghc-pkg :

 $ ghc-pkg list QuickCheck C:\Program Files\MinGHC-7.8.4\ghc-7.8.4\lib\package.conf.d: QuickCheck-2.8.1 

However, note that ghc-pkg will not recognize bonded sandboxes:

 $ cabal sandbox init $ cabal install QuickCheck $ ghc-pkg list QuickCheck C:\Program Files\MinGHC-7.8.4\ghc-7.8.4\lib\package.conf.d: (no packages) 

In this case, you need to use ghc-pkg -f .\.cabal-sandbox\<platform>-packages.conf.d or cabal exec :

 $ ghc-pkg -f .\.cabal-sandbox\x86_64-windows-ghc-7.8.4-packages.conf.d list QuickCheck .\.cabal-sandbox\x86_64-windows-ghc-7.8.4-packages.conf.d: QuickCheck-2.8.1 $ cabal exec -- ghc-pkg list QuickCheck .\.cabal-sandbox\x86_64-windows-ghc-7.8.4-packages.conf.d: QuickCheck-2.8.1 

However, since you are already using cabal , you can simply use cabal info .

+6
source share

All Articles