ghc command line evaluation

Pedro Miguel Duarte pedromiguel.duarte at
Wed Apr 5 14:32:00 EDT 2006

I am writing a Java program with a call to a  Haskell module  M.hs,
in order to evaluate some expression   expr.

A very simple idea, which I got somewhere in the net,  is to create a
Process object p  which executes a GHC command-line instruction:

Process p = Runtime.getRuntime();
p.exec( " ghc M.hs  -e \"expr\" " );

This would be very simple, if it worked...

My problem is that  expressions i want to evaluate involve
strings, and GHC command-line  'ghc' misinterprets some special symbols when
it  parses double quoted strings.

For instance,
     ghc -e  " reverse \"2<3\" "     gives an error!

Thus any one know a simple way around this?

The only one obvious to me is to create a temporary
Haskell module M_tmp.hs,  with the expression to be evaluated,
which is then executed through   a command-line instruction
 ghc M_tmp.hs  -e  main
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Glasgow-haskell-users mailing list