You can generate all of the Haskell haddock docs you need offline and search them with a shell function. Since Dash just added Haskell support I decided to share the lightweight approach that I use. The idea should work for both cabal and stack based workflows so long as you've generated haddocks for the package in question. I've written it for stack users.
stackdoc is available as a gist for
Usage is simple.
~ $ stackdoc Usage: stackdoc PACKAGE [COMMAND]
In a project directory
stackdoc will search local packages before checking user-level snapshot packages. For example, in a project that depends on GPipe you can call:
~/my/project/dir $ stackdoc GPipe Search GPipe in ~/my/project/dir/.stack-work/install/x86_64-osx/nightly-2015-11-17/7.10.2/doc Found ~/my/project/dir/.stack-work/install/x86_64-osx/nightly-2015-11-17/7.10.2/doc/GPipe-GLFW-1.2.1/index.html
To look up the
MVar docs which are in the package
base you can invoke:
~ $ stackdoc base Search base in ~/.stack/global/.stack-work/install/x86_64-osx/lts-3.9/7.10.2/doc Search base in ~/.stack/snapshots/x86_64-osx/lts-3.9/7.10.2/doc Found ~/.stack/snapshots/x86_64-osx/lts-3.9/7.10.2/doc/base-18.104.22.168/index.html
The utility of this command comes from being able to launch your browser. The default command just prints
Found ..., but you can specify your own.
~ $ stackdoc $PACKAGE chromium
Finally, if you can't find docs for a package it is possible the haddocks have yet to be generated. Try running:
~ $ stack haddock $PACKAGE ~ $ stackdoc $PACKAGE chromium
Incidentally, this was a nice exercise in translating code from
fish is way nicer to code in!
This post originally appeared on my old blog.