href を入れてみた

昔入れたけど今のシステムには入っていなかったので入れてみた

$ make
$ make prefix=$HOME/modules/href-0.3.3
$ env HREF_DATADIR=$HOME/modules/href-0.3.3/data ./mkhref ref/*
$ vi ~/modules/href-0.3.3/bin/wrapper.sh
$ cat -n !$
     1  #!/bin/sh
     2  
     3  root=$HOME/modules/href-0.3.3
     4  HREF_DATADIR=$root/data 
     5  export HREF_DATADIR
     6  
     7  basename=/usr/bin/basename
     8  lv=/opt/local/bin/lv
     9  
    10  exec $root/bin/`$basename $0` ${1+"$@"} | lv | cat
$ vi ~/modules/href-0.3.3/bin/href_datadir
$ cat -n !$
     1  #!/bin/sh
     2  
     3  echo $HREF_DATADIR
$ cd ~/local
$ vi .setup/href-0.3.3.sh
$ cat -n !$
     1  #!/bin/sh
     2  
     3  root=$HOME/modules/href-0.3.3
     4  ( cd bin && ( for f in `ls $root/bin/* | egrep -v wrapper.sh`; do rm `basename $f`; ln -s $root/bin/wrapper.sh `basename $f`; done ) )
s $root/bin/wrapper.sh `basename $f`; done ) )
$ sh .setup/href-0.3.3.sh
$ rehash
$ cat <<EOL >> .zshrc
# href の補完
compctl -K _href href
functions _href () {
  local href_datadir=`href_datadir`
  reply=(`cat $href_datadir/comptable|awk -F, '{print $2}'|sort|uniq`)
}
EOL

datadir を href から取れるようにしないとなー.まいーや.

参考

Cabal で作ってみよう

基本(Cabal パッケージのインストール)

$ runhaskell Setup.hs configure --user
$ runhaskell Setup.hs build
$ runhaskell Setup.hs install
$ ghc-pkg list

準備

ドキュメント(haddock)

(略)

テスト

  • 本物のプログラマHaskellを使う の 第16回 Haskellでのテストの自動化を考える を読めばいいんじゃないか?
  • ということで,下のSetup.hs は,そのまま連載のものをコピーした

(略)

ということで作ってみる

$ cat <<EOL > aaa.cabal
name:    Hoge
version: 0.0

executable hoge
  main-is:  Hoge.hs
  build-depentds: base

executable Test
  main-is:  Test.hs
  build-depends: base, directory, QuickCheck, HUnit
EOL
$ cat <<EOL > Hoge.hs
main = print hello

hello = "Hello"
EOL
$ cat <<EOL > Setup.hs
module Main (main) where

import Distribution.Simple
import Distribution.PackageDescription
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..))

import Data.List (isInfixOf)
import System.Directory (getCurrentDirectory)
import System.Cmd (system)
import System.FilePath ((</>), dropExtension)

main :: IO ()
main = do
  defaultMainWithHooks $ simpleUserHooks {runTests = doTest}
  where doTest _ _ pkgDisc bInfo = do
          curr <- getCurrentDirectory
          let dir = buildDir bInfo
              -- data: を取り出す
              testData = dataFiles pkgDisc
              -- 名前に "Test" がつくもののみ
              filterName = filter (("Test" `isInfixOf`) . exeName)
              -- buildable: が False でないもののみ
              filterBuildable = filter (buildable . buildInfo)
              filterTest = filterName . filterBuildable
              -- executable: の実行可能ファイルの完全パス名を作成
              path exec = curr </> dir
                          </> (dropExtension . exeName) exec
                          </> (dropExtension . exeName) exec
          mapM_ (system . path) $ filterTest $ executables pkgDisc
EOL
$ cat <<EOL > Test.hs
import Test.QuickCheck
import Text.Printf

main = mapM_ (\(s,a) -> printf "%-25s: " s >> a) tests

prop_id s = id (s::Int) == s

tests  = [("id",        test prop_id)]
EOL
$ runhaskell Setup.hs configure --user
$ runhaskell Setup.hs build
$ runhaskell Setup.hs test

これだと,test とbuild の依存関係が表現できないなぁ.
とあいえ,configure -> setup-config みたいな依存関係ってないのかも.
clean が動いてないような気もするなぁ.

mkcabal を使えよ.みたいな話しはあるけど,以下のようにもあるから許してね.と


The new tool mkcabal automates all this for you,
but you should understand all the parts even so.

cabal-install 使えよ的な話もあるけど,それはそれで.

参考