WindowsでHoogleをインストールする

Windows環境でhoogleをインストールした時のメモ。

Failed to install unix-2.6.0.1

追記:cabal-4.2.20で修正されたようです。仕事はやい!
http://code.google.com/p/ndmitchell/issues/detail?id=619

<=4.2.19
> cabal install hoogle
(略)
Configuring unix-2.6.0.1...
cabal: The package has a './configure' script. This requires a Unix
compatibility toolchain such as MinGW+MSYS or Cygwin.
Failed to install unix-2.6.0.1
cabal: Error: some packages failed to install:
hoogle-4.2.19 depends on unix-2.6.0.1 which failed to install.
unix-2.6.0.1 failed during the configure step. The exception was:
ExitFailure 1

ググってもこんなとこでつまづいたという情報がない。MinGW+MSYS入れてみてもconfigure後にエラー。というか

The package is not supported under Windows (except under Cygwin).

http://hackage.haskell.org/package/unix

無理じゃないのこれ。

# 理由を知りたくてHackageに載ってたSource repositoryを見たら全然更新されてなかった
hoogle.cabalの113行目あたりを見ると

executable hoogle
    main-is:            Main.hs
    hs-source-dirs:     src
    default-language: Haskell98

    build-depends:
        base > 4 && < 5,
        hoogle, bytestring, filepath, unix, directory, process, random,

とあり、このunixWindows環境では(必要ないのに)詰みポイントになってるので削除してしまいます*1

> cabal unpack hoogle
> cd hoogle-4.2.19
> (前述の通りhoogle.cabalを修正)
> cabal install
(略)
Installed hoogle-4.2.19

wget(curl)/tar/gzip

Hoogleはwget(もしくはcurl)、tar、gzipを使うようなので、GnuWin版をダウンロードしてパスを通す。ちなみにhoogle dataを実行したときにこれらのツールがなければ、ダウンロードできるサイトを表示してくれる。
MSYSのtar/gzipだと"..\hoge"というパス指定を受け付けなくて使えない*2らしい。
wgetはGnuWin版だとデバッグ出力がうるさい*3ので、他のを使うのがいいかも。

*1:この問題が修正された4.2.20では!os(mingw32)指定になっています。libraryセクションでは以前から同じようにしてunixに依存しているようですが、executableセクションに新しく追加した際に条件指定を忘れたんでしょうね。

*2:http://code.google.com/p/ndmitchell/issues/detail?id=609

*3:http://daregada.blogspot.jp/2012/01/windowsemacsauto-installwgetsystemwgetr.html