<div dir="ltr"><br><br><div class="gmail_quote">On Sun, Aug 17, 2008 at 8:45 PM, Paul Jarc <span dir="ltr">&lt;<a href="mailto:prj@po.cwru.edu">prj@po.cwru.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have a Haskell script called &quot;notify&quot;, without a .hs extension,<br>
which causes some problems. &nbsp;(I&#39;m using ghc <a href="http://6.8.3." target="_blank">6.8.3.</a>)<br>
<br>
First attempt: runhaskell notify<br>
Without the .hs extension, ghc doesn&#39;t know it&#39;s a Haskell script, and<br>
so I get &quot;Could not find module `notify&#39;&quot;. &nbsp;Maybe runhaskell should<br>
automatically add &quot;-x hs&quot; to the ghc command?<br>
<br>
Second attempt: runhaskell -x hs notify<br>
This get me &quot;Not in scope: `main&#39;&quot;. &nbsp;runhaskell is invoking ghc with<br>
these arguments:<br>
 &nbsp;-ignore-dot-ghci -x -e &#39;:set prog &quot;hs&quot;&#39; -e &#39;:main [&quot;notify&quot;]&#39; hs<br>
So it looks like runhaskell it treating &quot;-x&quot; as an argument to be<br>
relayed to ghc, &quot;hs&quot; as the name of the script, and &quot;notify&quot; as an<br>
argument to the script. &nbsp;I guess I need to use &quot;--&quot; to make it clear<br>
where the ghc arguments end and where the script and its arguments<br>
begin.<br>
<br>
Third attempt: runhaskell -- -x hs -- notify<br>
This gets me &quot;Not in scope: `main&#39;&quot; again. &nbsp;runhaskell is invoking ghc<br>
with these arguments:<br>
 &nbsp;-ignore-dot-ghci -x -e &#39;:set prog &quot;hs&quot;&#39; -e &#39;:main [&quot;--&quot;,&quot;notify&quot;]&#39; hs<br>
This looks like a bug in the &quot;--&quot; handling, unless I&#39;m misinterpreting<br>
the usage message I get from running plain &quot;runhaskell&quot;.<br>
<br>
Fourth attempt: ghc -ignore-dot-ghci -e &#39;:set prog &quot;notify&quot;&#39; \<br>
 &nbsp;-e &#39;:main []&#39; -x hs notify<br>
This works, but passing arguments becomes rather cumbersome. &nbsp;If<br>
there&#39;s a way to get runhaskell to pass &quot;-x hs&quot; in the right place,<br>
that would be much better.<br>
<br>
A somewhat related issue: I&#39;d like to avoid hard-coding the path to<br>
runhaskell or ghc in the #! line. &nbsp;Instead, I&#39;d like to use #!/bin/sh,<br>
and have the shell find runhaskell or ghc in $PATH. &nbsp;</blockquote><div><br>I&#39;ll let someone more knowledgeable address the other issues, but as for the argument to #!, I believe you could/should use &quot;#!/usr/bin/env runhaskell&quot;.<br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">This means the<br>
first few lines of the script would have to be executed by sh, but<br>
ignored by ghc. &nbsp;Most scripting langauges have some way of doing this,<br>
although it&#39;s often by accident. &nbsp;The best way I&#39;ve seen is in Guile,<br>
where &quot;#!&quot; starts a multi-line comment, and &quot;!#&quot; ends it. &nbsp;For<br>
Haskell, this is the best I could come up with:<br>
<br>
#!/bin/sh<br>
{- &gt; /dev/null 2&gt;&amp;1<br>
exec ghc -ignore-dot-ghci \<br>
 &nbsp;-e &quot;:set prog \&quot;$0\&quot;&quot; \<br>
 &nbsp;-e &#39;:main []&#39; -x hs &quot;$0&quot;<br>
-}<br>
<br>
But this depends on &quot;{-&quot; not existing as an executable command, or at<br>
least not doing anything harmful when invoked like this. &nbsp;I&#39;d like to<br>
avoid depending on anything like that. &nbsp;Does anyone have any better<br>
ideas?<br>
</blockquote><div><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
paul<br>
_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
</blockquote></div><br></div>