95

What are the possibilities, if any, for getting offline docs for Haskell core libraries (and maybe more)?

Sometimes I take my laptop to the coffee-shop where there is no wifi, and it would be nice having something like Hoogle but for offline use.

Chai T. Rex
  • 2,636
  • 1
  • 12
  • 25
Andriy Drozdyuk
  • 50,346
  • 44
  • 149
  • 256

9 Answers9

54

Hoogle is available offline, installable from Cabal: http://hackage.haskell.org/package/hoogle

Usage instructions are at http://www.haskell.org/haskellwiki/Hoogle#Command_Line_Search_Flags.

Usage:

$ hoogle --help
Hoogle v4.2.8, (C) Neil Mitchell 2004-2011
http://haskell.org/hoogle

hoogle [COMMAND] ... [OPTIONS]

Commands:
  [search]  Perform a search
  data      Generate Hoogle databases
  server    Start a Hoogle server
  combine   Combine multiple databases into one
  convert   Convert an input file to a database
  test      Run tests
  dump      Dump sections of a database to stdout
  rank      Generate ranking information
  log       Analyse log files

Common flags:
  -? --help     Display help message
  -V --version  Print version information
  -v --verbose  Loud verbosity
  -q --quiet    Quiet verbosity

Create a default database with hoogle data (more info at http://neilmitchell.blogspot.com/2008/08/hoogle-database-generation.html).

EDIT: A session of usage after installing Hoogle locally:

$ hoogle
No query entered
Try --help for command line options
$ hoogle data
(downloads databases...takes a few minutes)

I ran into an error here...apparently it is related to the version of Cabal, so I updated that (http://hackage.haskell.org/trac/hackage/ticket/811). That didn't help, so I ran hoogle data all, which I canceled since it was taking so long (it seems to go through every package on Hackage). It still wouldn't allow a query like hoogle map but did allow hoogle map +base (i.e. restrict the search to the base package) Hopefully it works for you!

EDIT2: This seems to fix the problem (for me):

$cd .cabal/share/hoogle-4.2.8/databases
$hoogle combine base.hoo
$hoogle foldl\'
Data.List foldl' :: (a -> b -> a) -> a -> [b] -> a
Data.Foldable foldl' :: Foldable t => (a -> b -> a) -> a -> t b -> a
Mikhail Glushenkov
  • 14,658
  • 3
  • 48
  • 65
li.davidm
  • 9,317
  • 4
  • 26
  • 29
  • 15
    You also probably want to enable documentation for your installed packages, by adding `documentation: True` to your `~/.cabal/config` file and then reinstalling those packages with `cabal install world --reinstall`. – hammar Feb 26 '12 at 17:06
  • I also have a problem with `hoogle data` command. Too bad, it would have been a nice solution, if it worked. – Andriy Drozdyuk Feb 27 '12 at 14:29
  • 2
    ``hoogle data --local`` took me 3 minutes (most of which was downloading) I can then run ``hoogle foldl`` which finds the foldl function, or ``hoogle server --local`` and then visit ``http://localhost/`` which is both a full server _and_ includes links to the HTML documentation. – Neil Mitchell Feb 27 '12 at 19:52
  • Unfortunately `hoogle data` uses `wget` and `curl` - both of which are unavailable on Windows. So... this is only useful 1/2 time (especially if I have no internet and no way of installing said utilities, even if I didn't want to). – Andriy Drozdyuk Jul 01 '12 at 00:18
  • 1
    @NeilMitchell `hoogle data all` and `hoogle data --local` do/download a lot of stuff, but it still doesn't let me find functions in packages (e.g. `parseFileWithMode`). Is this supposed to work? – nh2 Aug 22 '12 at 02:02
  • 1
    @nh2: by default Hoogle only searches the platform, try ``hoogle +haskell-src-exts parseFile`` – Neil Mitchell Aug 22 '12 at 14:46
  • 1
    `hoogle server --local` needs more visibility. It's the analogon to e.g. `godoc -http`. – sjakobi Apr 07 '14 at 19:03
  • @hammar `unknown package: world (user goal)`. Seems like things will automatically be rebuilt on configuration change, though. – Janus Troelsen Apr 10 '20 at 19:07
21

The HTML documentation can be downloaded as .tar.bz2 from the Haskell website:

https://downloads.haskell.org/~ghc/latest/docs/

I just downloaded https://www.haskell.org/ghc/docs/7.6.3/libraries.html.tar.bz2 and it's exactly what I've been hoping for.

There are also other options, such as Dash and Zeal, and see also that reddit thread.

Chai T. Rex
  • 2,636
  • 1
  • 12
  • 25
Emmanuel Touzery
  • 8,012
  • 2
  • 55
  • 67
14

If you install the Haskell Platform it includes the GHC docs and the GHC library docs (which cover the core libraries). On Windows they are on the Start Menu under "All Programs|Haskell Platform".

arx
  • 16,106
  • 2
  • 42
  • 57
  • That's great to know. Is there something like that on linux? – Andriy Drozdyuk Feb 27 '12 at 14:32
  • I think the Haskell Platform is supposed to be much the same on different OSes, but I've never used it on Linux. If you've got it installed you could try searching for the file "Data-Binary.html" (the docs for Data.Binary) to see if the docs have been installed somewhere. – arx Feb 27 '12 at 15:40
  • 4
    @drozzy: On Debian/Ubuntu, I believe there are documentation packages such as `haskell-platform-doc` you can install. – li.davidm Feb 27 '12 at 22:28
  • haskell platform won't be maintained anymore and it was always outdated, so i'd not considered this as a good answer – dredozubov Oct 27 '15 at 23:15
  • 1
    @dredozubov Source? I can't find anything about it not being maintained in the future. – Andriy Drozdyuk Apr 01 '16 at 18:32
  • @drozzy read this: https://mail.haskell.org/pipermail/ghc-devs/2015-October/010068.html It looks like it's still maintained though. – dredozubov Apr 01 '16 at 22:31
10

Edit your ~/.cabal/config file. Look for the line (probably commented out) that says documentation: False. Change that line to documentation: True and uncomment it. Now when you build projects with cabal install documentation will also be built and saved locally.

Look around a little more in that same config file and you'll find things options like doc-index-file, docdir, datadir, prefix, etc that allow you to configure where the documentation is stored.

mightybyte
  • 7,164
  • 1
  • 19
  • 36
5

It may not be "canonical" per se, but i believe that the most useful option is a docset software like dash(OS X)/zeal + generated docsets. This way you'll get the search for free and also will have an option to build your custom docsets. It's no problem to get the 'base' package haddock documentation with either of the projects out of the box. You can build custom docsets with haddocset or dash-haskell. Also it integrates nicely with emacs/vim/other editors, allows you to have project-based docsets(you'll have the relevant versions on a per-project basis this way, forget all this hassle with local hoogle!) and don't restrict you to any build flow you can have.

If you build your project with cabal-install you can set documentation: True in your ~/.cabal/config, then reinstall dependencies to get generated haddocks locally.

If you're using stack, you can utilize stack haddock command to build your dependencies and project with generated haddocks.

dredozubov
  • 615
  • 1
  • 6
  • 11
3

I use devdocs.io, it has docs for a lot of languages and libraries (including Haskell) and has an offline mode.

stusherwin
  • 1,796
  • 17
  • 18
1

Velocity is a free and beautiful universal tool to do just that. It supports a wide range of languages, technologies and libraries, and one click updating.

You will probably be able to find more of what you are already using in its documentation list.

hardcore
  • 111
  • 11
1

For Windows, install cygwin's wget and curl packages. That will enable hoogle data.

Pete Klein
  • 680
  • 3
  • 18
0

If you happen to be using a Debian derived distribution and their packages, then you will find the combined documentation of all installed Haskell packages (if you also install the libghc-foo-doc packages) at

file:///usr/share/doc/ghc-doc/html/libraries/index.html

Furthermore, the libghc-foo-doc packages contain the necessary files for hoogle, so if you apt-get install hoogle, then you should immediately be able to use hoogle to search through all libraries installed this way.

Joachim Breitner
  • 24,316
  • 5
  • 70
  • 128