Question: I'm trying to create a program to compare the amount of time it takes various haskell scripts to run, which will later be used to create graphs and displayed in a GUI. I've tried to create said GUI using Haskell libraries but I haven't had much luck, especially since I'm having trouble finding up to date GUI libraries for Windows. I've tried to use Java to get these results but either get errors returned or simply no result. 

I've constructed a minimal example to show roughly what I'm doing at the moment:

```
    import java.io.*;
public class TestExec {
    public static void main(String[] args) {
        try {
            Process p = Runtime.getRuntime().exec("ghc test.hs 2 2");
            BufferedReader in = new BufferedReader(
                                new InputStreamReader(p.getInputStream()));
            String line = null;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

```

And here is the Haskell script this is calling, in this case a simple addition:

```
test x y =  x + y

```

Currently there simply isn't any result stored or printed. Anyone have any ideas?

Answer: 
Since you're attempting to run this as an executable, you need to provide a main. In you're case it should look something like

```
import System.Environment

test :: Integer -> Integer -> Integer
test = (+)

main = do
  [x, y] <- map read `fmap` getArgs
  print $ x `test` y

```

This just reads the command line arguments, adds them, then prints them. Though I did something like a while ago, it's much easier to do the benchmarking/testing in Haskell, and dump the output data to a text file in a more structured format, then parse/display it in Java or whatever language you like.
At first to read from output you need to use `OutputStreamReader(p.getOutputStream())` instead of `InputStreamReader`