How can I browse Haskell source code preferably without internet connection? Right now I click through hackage search results, click source link and search the source page. There are two problems:
Usually IDEs let you download sources for any library and open new editor tab with definition. I prefer reading code than documentation, less surprises along the way and I can learn something from them.
So, how can I setup for recursive source searches using Haskell tools or standard GNU tools if necessary? All I know right now is that I can generate ctags for vim but where does cabal store sources?
This is the opinionated workflow I follow to render the documentation with the source link enabled.
$ cd <package-name>
$ cabal sandbox init
$ cabal install --only-dependencies --enable-documentation --haddock-hyperlink-source
$ cabal configure --enable-documentation --haddock-hyperlink-source
$ cabal haddock --hyperlink-source
$ firefox dist/doc/html/<package-name>/index.html
The Source
link should be enabled for all packages, including the dependencies, as long as they are installed in the sandbox.
In the particular case of Arch Linux, the distro I use, I try to avoid installing Haskell system packages through pacman
because, by default, the documentation is not built with the source link enabled. In Arch Linux you can use ABS and modify the PKGBUILD with the parameters described above. I'm pretty sure something similar could be done in other distros, but have no idea about Windows or Mac OS X.
It's also worth mentioning that you don't need to type those parameters every time you run cabal
. You can enable them by default in your .cabal/config
This should work without the sandbox but if you are dealing with more than one Haskell project I strongly recommend to use sandboxes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With