<div>Thanks a lot for the sugestions!</div>
<div>I am going to try them...</div>
<div>&nbsp;</div>
<div>pedro<br><br>&nbsp;</div>
<div><span class="gmail_quote">On 4/5/06, <b class="gmail_sendername">Björn Bringert</b> &lt;<a href="mailto:bringert@cs.chalmers.se">bringert@cs.chalmers.se</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Benjamin Franksen wrote:<br>&gt; On Wednesday 05 April 2006 20:32, Pedro Miguel Duarte wrote:<br>&gt;<br>&gt;&gt;I am writing a Java program with a call to a&nbsp;&nbsp;Haskell module&nbsp;&nbsp;
M.hs,<br>&gt;&gt;in order to evaluate some expression&nbsp;&nbsp; expr.<br>&gt;&gt;<br>&gt;&gt;A very simple idea, which I got somewhere in the net,&nbsp;&nbsp;is to create a<br>&gt;&gt;Process object p&nbsp;&nbsp;which executes a GHC command-line instruction:
<br>&gt;&gt;<br>&gt;&gt;Process p = Runtime.getRuntime();<br>&gt;&gt;p.exec( &quot; ghc M.hs&nbsp;&nbsp;-e \&quot;expr\&quot; &quot; );<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;This would be very simple, if it worked...<br>&gt;&gt;<br>&gt;&gt;
<br>&gt;&gt;My problem is that&nbsp;&nbsp;expressions i want to evaluate involve<br>&gt;&gt;strings, and GHC command-line&nbsp;&nbsp;'ghc' misinterprets some special<br>&gt;&gt;symbols when it&nbsp;&nbsp;parses double quoted strings.<br>&gt;&gt;<br>&gt;&gt;For instance,
<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; ghc -e&nbsp;&nbsp;&quot; reverse \&quot;2&lt;3\&quot; &quot;&nbsp;&nbsp;&nbsp;&nbsp; gives an error!<br>&gt;<br>&gt;<br>&gt; Hmm. On my Linux machine (running zsh):<br>&gt;<br>&gt; ben@sarun: .../play/ghc-e &gt; ghc -e&nbsp;&nbsp;&quot; reverse \&quot;2&lt;3\&quot; &quot;
<br>&gt; &quot;3&lt;2&quot;<br>&gt;<br>&gt; But now I see that you run 'p.exec' in Java which probably translates<br>&gt; (more or less) to a 'exec' system call. 'exec' is not a shell, it<br>&gt; cannot translate complex quotings and unquotings. I would try
<br>&gt;<br>&gt; p.exec( &quot;/bin/sh ghc M.hs&nbsp;&nbsp;-e \&quot;expr\&quot; &quot; );<br>&gt;<br>&gt; or something similar.<br><br>Another way could be to use one of the other exec() methods (which BTW<br>are available from the Runtime class, not the Process class). For
<br>example, using the &quot;exec(String[] cmdarray)&quot; version, you could write<br>something like (not tested):<br><br>Runtime r = Runtime.getRuntime();<br>Process p = r.exec(new String[]{&quot;ghc&quot;, &quot;-e&quot;, expr});
<br><br>/Björn<br></blockquote></div><br>