I do not know how to make runhaskell work. What I am doing is just pipe "main" to ghci:
$ echo main | ghci -v0 test/Spec.hs
If you want to pass command line arguments, this also works:
$ echo ':main -m "behaves correct"' | ghci -v0 test/Spec.hs
Or you can wrap it in a script:
#!/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
What can be used like this:
$ ./run.lhs test/Spec.hs -m "behaves correct"
source share