Exploring Haskell Packages

So, I installed packages in Haskell using Cabal. I don't see any documentation for most of them (in general), and I was told that one of the best ways to find out that haskell is to just read the code in the package, find out what it does, and play with it in GHCi or whatever something like that. But how do you do that? After installing these packages in the sandbox or something else, I don’t even see what the names of the modules are, not to mention their source code - how can I find this information?

+8
package haskell cabal
source share
2 answers

I usually look at the documentation for Hackage packages online, https://hackage.haskell.org/package/nameOfPackage . It has (if not broken, which, alas,), is associated with the documentation for each module, as well as links to the source code inside it.

EDIT broken documents:

Unfortunately, the Hackage doc build system sometimes does not work for any reason, which usually leads to the fact that the list of modules is plain text without links. In this case, a good idea is to check the list of links to older versions of packages: often one of them works.

There is also the problem that some libraries are not well documented at all, in which case all you get is type declarations, captions and source links. (But check if there are links to other documents on the first page of the package.)

+6
source share

see documentation

The cabal haddock will create documentation for you and put it in dist/doc . If you use --enable-documentation (or set documentation: True to ~/.cabal/config ), cabal install also compile documentation for all your packages in ~/.cabal/share/doc . You can also use --hyperlink-source or set hyperlink-source: True in the haddock ~/.cabal/config section.

read the code in the package

You can cabal unpack package to get the source. For the foo version xy package, by default the source will be placed in a directory named foo-xy .

play with him in ghci

Once you have the source of the package, you can go to the directory and run cabal repl to get a ghci instance with all the packages loaded.

see what module names

The Modules: cabal info section will be interesting cabal info . After installing the package, you can also use ghc-pkg describe to get similar functionality. (The main difference here is which packages are known, cabal info will know that in Hackage / any package repository that you have configured cabal to use, even if the package is not already installed, and ghc-pkg will know about any package that you installed even if this package did not come from Hackage.)

+3
source share

All Articles