仕事をする方法がわかりませんrunhaskell
。私がしていることは"main"
、ghciにパイプするだけです:
$ echo main | ghci -v0 test/Spec.hs
コマンドライン引数を渡したい場合は、それも機能します:
$ echo ':main -m "behaves correct"' | ghci -v0 test/Spec.hs
または、スクリプトでまとめることができます。
#!/usr/bin/env runhaskell
>import System.IO
>import System.Environment
>import System.Exit
>import System.Process
>
>main :: IO ()
>main = do
> source:args <- getArgs
> (Just h, Nothing, Nothing, pid) <- createProcess (proc "ghci" ["-v0", source]) {std_in = CreatePipe}
> hPutStr h ("import System.Environment\nSystem.Environment.withArgs " ++ show args ++ " main\n")
> hClose h
> waitForProcess pid >>= exitWith
次のように使用できます。
$ ./run.lhs test/Spec.hs -m "behaves correct"