Skip to content

Instantly share code, notes, and snippets.

@bitc
Last active January 22, 2018 14:42
Show Gist options
  • Save bitc/79c15d6e11ba6f213e55dc759d2ca806 to your computer and use it in GitHub Desktop.
Save bitc/79c15d6e11ba6f213e55dc759d2ca806 to your computer and use it in GitHub Desktop.
Using hdevtools "classic" with stack

Hardcore way of using "classic" version of hdevtools with stack.

First build and install the "classic" version of hdevtools, using stack:

$ cd /tmp
$ git clone --depth 1 https://github.com/bitc/hdevtools.git
$ cd hdevtools
# Modify the flags in the following line to use the same settings you use in your project:
$ stack --install-ghc --no-system-ghc --resolver lts-7.1 init
$ stack install

Now you should have an hdevtools executable in ~/.local/bin/hdevtools. Copy it to somewhere in you $PATH or verify that the directory is already in your $PATH.

Lookup up stack's snapshot-pkg-db path:

$ stack path --install-ghc --no-system-ghc --resolver lts-7.1 --snapshot-pkg-db
/home/bitc/.stack/snapshots/x86_64-linux/lts-7.1/8.0.1/pkgdb

The above path is what you use for GHC's -package-db option.

You also will need to specifiy GHC's -package-id option for each package(haskell library) that you will be using.

To check which packages you have installed:

$ ls -1 /home/bitc/.stack/snapshots/x86_64-linux/lts-7.1/8.0.1/pkgdb
cmdargs-0.10.14-8WOlFWoK1XlCebTZE2edgd.conf
extra-1.4.10-2LEZ2hBhlUuEhqffYmrH30.conf
ghc-paths-0.1.0.9-GIOnKzk0HmEBZ77Q1HsThK.conf
hashable-1.2.4.0-EMu4H7FB10MAl6hwKw992G.conf
js-flot-0.8.3-DwW7tRfA2DS2odTaEQO7re.conf
js-jquery-3.1.0-FhGyG2QmJFC9cqB7DILb9n.conf
network-2.6.3.1-G4Up1CPKbp7DeFsnywOnGG.conf
package.cache
primitive-0.6.1.0-Ip44DqhfCp21tTUYbecwa.conf
random-1.1-54KmMHXjttlERYcr1mvsAe.conf
shake-0.15.10-GcLMYwHJl6F2fOZ4KrIiXZ.conf
syb-0.6-C65vWCsht6A8uLstpQIXyj.conf
text-1.2.2.1-5QpmrLQApEZ4Ly9nMHWY0s.conf
unordered-containers-0.2.7.1-Eo9jd5DMz45DhBLCG8skzW.conf
utf8-string-1.0.1.1-2T8mBCuEDlXDo8zed8Onw4.conf

The -package-id that you use is one of the above filenames, but without the ".conf" extension.

Example of invoking hdevtools on the file "Build.hs", which uses packages "text" and "shake":

$ hdevtools check -g-package-db -g/home/bitc/.stack/snapshots/x86_64-linux/lts-7.1/8.0.1/pkgdb -g-package-id -gtext-1.2.2.1-5QpmrLQApEZ4Ly9nMHWY0s -g-package-id -gshake-0.15.10-GcLMYwHJl6F2fOZ4KrIiXZ Build.hs

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment