HaskellでWebアプリを作ってみようと思ったので、その作業メモというか。

まずは、Webフレームワークの選定を行った。候補としては、

が有力。WASHは、ふつうのHaskellプログラミング ふつうのプログラマのための関数型言語入門でも一瞬触れられていたような記憶がある。が、なんとなくhttp://happstack.com/index.htmlが気に入ったので、そっちを導入してみることにする。HPの説明にしたがって、tutorialを導入してみる。

$ darcs get http://patch-tag.com/r/wchogg/happstack-tutorial/pullrepo happstack-tutorial
$ cabal install

普通にエラーになりました(エラーメッセージは残ってません)。cabalを入れないとだめらしいので、頑張って入れてみた。

$ wget http://hackage.haskell.org/packages/archive/cabal-install/0.8.2/cabal-install-0.8.2.tar.gz
$ tar -zxf cabal-install-0.8.2.tar.gz
$ cd cabal-install-0.8.2
$ sh ./bootstrap.sh

これもエラーメッセージが残っていないのですが、timeが無い的なことを言われて終了。ググってみたところ、下のような感じで入っているのかどうかは確認できるらしい。

$ ghc-pkg list time

どうも、そもそも入っていないらしい。aptで探してみたらあるっぽいので、apt-getでインストール。

$ sudo apt-get install libghc6-time-doc libghc6-time-prof libghc6-time-dev
$ ghc-pkg list time

ちゃんと入ったぽいので、再びチャレンジ。

$ sh ./bootstrap.sh

インストールできたぽい?PATHの通った場所に出来たcabalを移動。

$ sudo cp .cabal/bin/cabal /usr/bin/
$ cabal --help
This program is the command line interface to the Haskell Cabal infrastructure.
See http://www.haskell.org/cabal/ for more information.

Usage: cabal COMMAND [FLAGS]
   or: cabal [GLOBAL FLAGS]

Global flags:
 -h --help            Show this help text
 -V --version         Print version information
    --numeric-version Print just the version number

Commands:
  install      Installs a list of packages.
  update       Updates list of known packages
  list         List packages matching a search string.
  info         Display detailed information about a particular package.
  upgrade      Upgrades installed packages to the latest available version
  fetch        Downloads packages for later installation.
  unpack       Unpacks packages for user inspection.
  check        Check the package for common mistakes
  sdist        Generate a source distribution file (.tar.gz).
  upload       Uploads source packages to Hackage
  report       Upload build reports to a remote server.
  init         Interactively create a .cabal file.
  configure    Prepare to build the package.
  build        Make this package ready for installation.
  copy         Copy the files into the install locations.
  haddock      Generate Haddock HTML documentation.
  clean        Clean up after a build.
  hscolour     Generate HsColour colourised code, in HTML format.
  register     Register this package with the compiler.
  test         Run the test suite, if any (configure with UserHooks).
  help         Help about commands

For more information about a command use:
  cabal COMMAND --help

To install Cabal packages from hackage use:
  cabal install foo [--dry-run]

Occasionally you need to update the list of available packages:
  cabal update

You can edit the cabal configuration file to set defaults:
  /home/***/.cabal/config

うまくいった気がするので、再度tutorialを入れてみる。

$ cd tmp/darcs/happstack-tutorial/
$ cabal install
Resolving dependencies...
[1 of 1] Compiling Main             ( /tmp/haskell-src-exts-1.9.03187/haskell-src-exts-1.9.0/Setup.hs, /tmp/haskell-src-exts-1.9.03187/haskell-src-exts-1.9.0/dist/setup/Main.o )
Linking /tmp/haskell-src-exts-1.9.03187/haskell-src-exts-1.9.0/dist/setup/setup ...
Configuring haskell-src-exts-1.9.0...
setup: happy version >=1.17 is required but it could not be found.
Configuring strict-concurrency-0.2.3...
Preprocessing library strict-concurrency-0.2.3...
Building strict-concurrency-0.2.3...
[1 of 2] Compiling Control.Concurrent.MVar.Strict ( Control/Concurrent/MVar/Strict.hs, dist/build/Control/Concurrent/MVar/Strict.o )

Control/Concurrent/MVar/Strict.hs:63:12:
    Not in scope: type constructor or class `NFData'

Control/Concurrent/MVar/Strict.hs:65:26: Not in scope: `rnf'

Control/Concurrent/MVar/Strict.hs:74:15:
    Not in scope: type constructor or class `NFData'

Control/Concurrent/MVar/Strict.hs:83:11:
    Not in scope: type constructor or class `NFData'

Control/Concurrent/MVar/Strict.hs:93:12:
    Not in scope: type constructor or class `NFData'

Control/Concurrent/MVar/Strict.hs:105:12:
    Not in scope: type constructor or class `NFData'

Control/Concurrent/MVar/Strict.hs:120:12:
    Not in scope: type constructor or class `NFData'

Control/Concurrent/MVar/Strict.hs:134:15:
    Not in scope: type constructor or class `NFData'

Control/Concurrent/MVar/Strict.hs:146:14:
    Not in scope: type constructor or class `NFData'
cabal: Error: some packages failed to install:
HJScript-0.5.0 depends on haskell-src-exts-1.9.0 which failed to install.
happs-tutorial-0.9.4 depends on strict-concurrency-0.2.3 which failed to
install.
happstack-0.5.0.2 depends on strict-concurrency-0.2.3 which failed to install.
happstack-data-0.5.0.2 depends on strict-concurrency-0.2.3 which failed to
install.
happstack-helpers-0.51 depends on strict-concurrency-0.2.3 which failed to
install.
happstack-ixset-0.5.0.2 depends on strict-concurrency-0.2.3 which failed to
install.
happstack-server-0.5.0.2 depends on strict-concurrency-0.2.3 which failed to
install.
happstack-state-0.5.0.2 depends on strict-concurrency-0.2.3 which failed to
install.
happstack-util-0.5.0.2 depends on strict-concurrency-0.2.3 which failed to
install.
haskell-src-exts-1.9.0 failed during the configure step. The exception was:
ExitFailure 1
hsp-0.5.2 depends on haskell-src-exts-1.9.0 which failed to install.
hsx-0.7.0 depends on haskell-src-exts-1.9.0 which failed to install.
strict-concurrency-0.2.3 failed during the building phase. The exception was:
ExitFailure 1

んー。どうも、strict-concurrency-0.2.3とやらがうまく入らないみたいだが、原因は分からず。直接落としてきても同じエラーが出たので、ここで詰み。ググってみたら、debianにはaptで取ってこれるhappstackがあるっぽいので、debianを入れてみようかな(今まで作業してたのはubuntu)。
で、どうせならWASHも試してみることに。

$ sh ./bootstrap.sh
$ wget http://www.informatik.uni-freiburg.de/~thiemann/WASH/WashNGo-2.12.tgz
$ tar xzvf WashNGo-2.12.tgz
$ cd WashNGo-2.12/
$ cabal install
Resolving dependencies...
Configuring WashNGo-2.12...
Warning: No 'build-type' specified. If you do not need a custom Setup.hs or
./configure script then use 'build-type: Simple'.
Preprocessing library WashNGo-2.12...
Preprocessing executables for WashNGo-2.12...
Building WashNGo-2.12...

WASH/CGI/CGIMonad.hs:1:15:
    Warning: -fno-monomorphism-restriction is deprecated: use -XNoMonomorphismRestriction or pragma {-# LANGUAGE NoMonomorphismRestriction#-} instead

WASH/CGI/SubmitXX.hs:1:15:
    Warning: -fallow-undecidable-instances is deprecated: use -XUndecidableInstances or pragma {-# LANGUAGE UndecidableInstances#-} instead

WASH/CGI/CGIHistory.hs:10:17:
    Could not find module `Data.Map':
      it is a member of the hidden package `containers-0.2.0.1'
      Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:
WashNGo-2.12 failed during the building phase. The exception was:
ExitFailure 1

うんまあ、こっちもなんかダメみたいだ…。取りあえず、今日はここまで。debianVM作ってみよう。