haskell-code-explorer
Memo
cabal でビルドしたら動かなかった
パッケージによっては動かないこともある (Mac 限定で GHC のバグっぽい)
サブパッケージは自動的にインデックスされないので、自分で処理するしかない
インストール
stack
λ git clone https://github.com/alexwl/haskell-code-explorer
λ cd haskell-code-explorer/
λ stack install
使い方
haskell-code-indexer
ヘルプメッセージ
λ haskell-code-indexer -h
Usage: haskell-code-indexer [-p|--package PATH] [--dist RELATIVE_PATH]
[--output DIRECTORY_NAME] [--logfile PATH]
[-v|--verbose] [--before-preprocessing]
[--no-compression] [--ghc OPTIONS]
[--ignore DIRECTORY_NAME]
haskell-code-indexer collects and saves information about the source code of a
Cabal package. haskell-code-indexer version 0.1.0.0, GHC version 8.6.5.0
Available options:
-h,--help Show this help text
-p,--package PATH Path to a Cabal package (default: ".")
--dist RELATIVE_PATH Relative path to a dist directory
--output DIRECTORY_NAME Output directory (default is
'.haskell-code-explorer')
--logfile PATH Path to a log file (by default log is written to
stdout)
-v,--verbose Write debug information to a log
--before-preprocessing Index source code before preprocessor pass (by
default source code after preprocessing is indexed)
--no-compression Do not compress json files (by default json files are
compressed using gzip)
--ghc OPTIONS Command-line options for GHC
--ignore DIRECTORY_NAME Directories to ignore (e.g. node_modules)
パッケージのインデックス方法
インデックスを作成したいパッケージのディレクトリに移動し、以下のコマンドを実行する
λ cabal new-build
λ haskell-code-indexer
パッケージを指定してインデックスを作成
λ cabal new-build
λ haskell-code-indexer -p <path>
詳細なメッセージを出す
普通に -v
オプションで良い。
λ haskell-code-indexer -v
haskell-code-server
ヘルプメッセージ
λ haskell-code-server -h
Usage: haskell-code-server [--packages PATH] [-p|--package PATH] [--port PORT]
[--no-static] [--no-expressions]
[--index-directory DIRECTORY_NAME] [--logfile PATH]
[--static-url-prefix STRING] [--js-path PATH]
[--max-per-page INTEGER]
([--create-store PATH_TO_DATA_DIRECTORY] |
[--use-store PATH_TO_DATA_DIRECTORY] |
[--use-store-mmap PATH_TO_DATA_DIRECTORY])
[--use-hoogle-api]
haskell-code-server provides an HTTP API for Haskell Code Explorer
Available options:
--packages PATH Path to a directory with Cabal packages
-p,--package PATH Path to a Cabal package (defaults to '.' if
'packages' not provided either)
--port PORT Port to use (default is 8080)
--no-static Do not serve static files
--no-expressions Disable queries that return expressions inside
selected span (reduces memory usage)
--index-directory DIRECTORY_NAME
Name of a directory with index (default is
'.haskell-code-explorer')
--logfile PATH Path to a log file (by default log is written to
stdout)
--static-url-prefix STRING
URL prefix for static files (default is 'files')
--js-path PATH Path to a directory with javascript files (by
default, the server uses javascript files that are
embedded in the executable)
--max-per-page INTEGER Maximum number of items per page (default is 50)
--create-store PATH_TO_DATA_DIRECTORY
Create a key-value store from PackageInfo of each
indexed package. The key-value store allows to
significantly reduce memory usage of the server (3x
times for a real-world set of Haskell packages).
--use-store PATH_TO_DATA_DIRECTORY
Use existing key-value store. Read 'values' file into
memory.
--use-store-mmap PATH_TO_DATA_DIRECTORY
Use existing key-value store. Memory map 'values'
file (the server uses less memory but may be slower
to respond to requests).
--use-hoogle-api Use public Hoogle JSON API
(https://github.com/ndmitchell/hoogle/blob/3dbf68bfd701f942d3af2e6debb74a0a78cd392e/docs/API.md#json-api)
to get documentation for not indexed packages
(disabled by default)
-h,--help Show this help text
サーバーの起動
インデックスを作成したディレクトリで以下のコマンドを叩く
λ haskell-code-server
ポートを指定して起動
λ haskell-code-server --port 3000
Hoogle API を利用
Hoogle API を有効にすると、他のパッケージの関数や型についての情報を Hoogle API から引っ張ってくる。
λ haskell-code-server --use-hoogle-api
参考リソース
Last updated