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.
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
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.
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".
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.
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.
I use devdocs.io, it has docs for a lot of languages and libraries (including Haskell) and has an offline mode.
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.
For Windows, install cygwin's wget and curl packages. That will enable hoogle data.
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.
Related
I work with the Yocto Project quite a bit and a common challenge is determining why (or from what recipe) a file has been included on the rootfs. This is something that can hopefully be derived from the build system's environment, log & meta data. Ideally, a set of commands would allow linking a file back to a source (ie. recipe).
My usual strategy is to perform searches on the meta data (e.g. grep -R filename ../layers/*) and searches on the internet of said filenames to find clues of possible responsible recipes. However, this is not always very effective. In many cases, filenames are not explicitly stated within a recipe. Additionally, there are many cases where a filename is provided by multiple recipes which leads to additional work to find which recipe ultimately supplied it. There are of course many other clues available to find the answer. Regardless, this investigation is often quite laborious when it seems the build system should have enough information to make resolving the answer simple.
This is exact use case for oe-pkgdata-util script and its subcommand find-path. That script is part of openembedded-core.
See this example (executed in OE build environment, i.e. bitbake works):
tom#pc:~/oe/build> oe-pkgdata-util find-path /lib/ld-2.24.so
glibc: /lib/ld-2.24.so
You can clearly see that this library belongs to glibc recipe.
oe-pkgdata-util has more useful subcommands to see information about packages and recipes, it worth to check the --help.
If you prefer a graphical presentation, the Toaster web UI will also show you this, plus dependency information.
The candidate files deployed for each recipe are placed in each $WORKDIR/image
So you can cd to
$ cd ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}
and perform a
$ find . -path '*/image/*/fileYouAreLookingFor'
from the result you should be able to infer the ${PN} of the recipe which deploys such file.
For example:
$ find . -path '*/image/*/mc'
./bash-completion/2.4-r0/image/usr/share/bash-completion/completions/mc
./mc/4.8.18-r0/image/usr/share/mc
./mc/4.8.18-r0/image/usr/bin/mc
./mc/4.8.18-r0/image/usr/libexec/mc
./mc/4.8.18-r0/image/etc/mc
I want to run hoogle on a project of mine. I successfully generated the hoogle database (a file with .hoo extension) from my project.
But when I run the server locally, hoogle cannot find any of the functions or types that are defined in my project.
It can find some of the prelude functions such as map, but none of the functions that are defined in my project.
hoogle dump my-project.hoo dumps the content with no error.
I also moved my-project.hoo to ~/.cabal/share/x86_64-osx-ghc-7.8.4/hoogle-4.2.38/databases where all the .hoo files reside. No success again.
-verbose switch also does not output any useful information.
Any suggestion is appreciated.
Edit:
Thanks to mhuesch's suggestion, I was able to get the search results. Although, the returned results are not linked to the local hackage documents. Something that I couldn't find anywhere on the web is that the hoogle server looks for a file called default.hoo in the current directory.
Edit 2:
If you, like me, have 5000+ databases (i.e., .hoo files) you may get a "too many open files" error when combining them. The trick is simple: run hoogle combine x*.hoo -o=parts/x.hoo for all x='a' ... 'z' and then run hoogle combine *.hoo -o=default.hoo in the parts folder.
Edit 3:
If you want to link your hoogle search results with local hackage documentation,
use hoogle convert --doc='absolute-path-to-your-doc' your-package-hoogle-doc.txt default.hoo.
I couldn't get relative path working.
Hoogle searches the current directory (where the command hoogle is run) for a database called 'default.hoo', so if you rename your database to that it should find it.
To add it to the database in your cabal directory, I believe this should work (taken from http://newartisans.com/2012/09/running-a-fully-local-hoogle/):
cd {...path to hoogle databases dir...}
mv default.hoo default.hoo-prev
hoogle combine *.hoo
Edit: (in response on Oxy's edits)
My knowledge of default.hoo comes from here. It seems to doesn't seem to be very well know.
hoobuddy (the above linked project), while cool, doesn't seem to address what you want. I think the key to that is in the help of hoogle data
$ hoogle data --help
...
-l --local[=FILEPATH] Use local documentation if available
...
I haven't done it myself so I am not sure. The author of this writeup achieved local documentation linking by compiling hoogle from source and adding his local docs directory. I think that you can avoid that by using hoogle data.
How do I find the source of the code I am importing. Like if I do
λ <Prelude>: import Graphics.EasyPlot
λ <Prelude Graphics.EasyPlot>:
How do I find that code. I do not mean an online copy of the code (Google is very good at indexing Hackage by that) but where it is on my system that I can edit. The reason is that it is a bit buggy, and I want to try and fix it. (I might submit a patch, but I just want to fix it for my own use first.)
As #ThomasDuBuisson mentioned, you many not necessarily find that on your system. One thing which I generally do is fetch it using cabal:
cabal fetch package-name
It downloads the tarballs of the package. Once you have fetched it, the entire source will be under the path where cabal puts it. In my case, it is (/home/sibi/.cabal/packages/hackage.haskell.org/package-name ). You can then untar and then build it from the cabal file which is already present there.
That being said you should probably using the version control system which the project is using as #bheklilr pointed out.
I have developed a module (M.hs) which depends upon 3 other modules (A.hs, B.hs and C.hs). Now I want to use the module M across multiple other projects. So I have to install this module. But for learning purpose I don't want to use cabal, I want to do it manually. I want to install it in my home dir.
What is a proper course of action? Which files to be created, copied? where? How to use this module in other project?
Additional info:
I am using Debian 6
I am using GHC 6.12
You say you don’t want to use cabal, but would you use Cabal?
cabal is the name of the command line tool provided by cabal-install which can download packages from Hackage and resolve dependencies.
Cabal is the library that Haskell code uses to drive the compilation (e.g. pre-process files, build in the right order, build variants, generate documentation) and install into the right location.
I would not recommend not using Cabal, even for learning purposes, until you want to write a replacement for it. But if you really want to do it, here is the rough outline, with enough details to figure out for a good learning experience:
Build your files with -package-name yourpkgname-version.
Link the generated files to form a libyourpkgname-version.a file.
Create a package configuration file like /var/lib/ghc/package.conf.d/mtl-2.1.2.conf, and pay attention to name, `exposed-modules, import-dirs, library-dirs and hs-libraries
Register package by passing it to ghc-pkg register
The ~/.cabal/config stores configuration which cabal-install uses. I wanted to do some hackery on it. (Specifically, having multiple GHC versions installed, I wish to have separate documentation indexes).
I couldn't, however, find any documentation about its' syntax or variables except for what is included in default file. Is there any documentation available?
Edit: I've stated the goal above, but let me add some details: If the same package (eg. GTK) is installed in two versions of GHC they end up in the same documentation index file. I wan't that local documentation index to be separate for each GHC installation. I believe it is possible in some way using documentation directory setting, but there has to be a variable for currently used GHC version. If there isn't one there might be some workarounds available, but I won't be able to say that unless I see the documentation.
This seems to work, although I've only tested it with one version of GHC:
documentation: True
doc-index-file: $datadir/doc/$compiler/index.html
install-dirs user
docdir: $datadir/doc/$compiler/$pkgid
With the other options left at the default, this generates documentation in .cabal/share/doc/<ghc-version>/<package-name>, and the index in .cabal/share/doc/<ghc-version>/index.html.
There appears to be very little online - not even the haddocks for the cabal-install code. So your best bet may be to puzzle it out from the source. cabal unpack cabal-install, or view the cabal-install repo online. Look at SavedConfig in Distribution/Client/Config.hs. As an example, it imports GlobalFlags from Setup.hs; the individual flags, eg globalCacheDir, are associated with their config-file syntax (which is also the command-line syntax) in the globalCommand function below, remote-repo-cache in this case.
You should also ask dcoutts in the #haskell channel on irc.freenode.net, in case he has new docs available.