No runhugs for Macintosh?

Hans Aberg haberg@matematik.su.se
Mon, 8 Jan 2001 19:14:06 +0100


At 18:00 +0200 1-01-08, Jussi Piitulainen wrote:
>I would like to run a completed program
>without the need to talk to it: just click a script that launches Hugs
>with one program after another, and I'd go away for a while or at
>least take my fingers off the keyboard and mouse.
>
>There doesn't seem to be an option to run a main function
>automatically. When I open Hugs with Control or Command, I can tell it
>to read its standard input from a file, which would be fine, if I
>didn't need to be in the loop myself.
>
>A separate application like the runhugs in unixen might be best. An
>option to run a main function or to read commands from a file might be
>second best. Well, the best would be to learn that I just overlooked
>something and it can already be done. Help?

The MacOS replacement of UNIX command line arguments is AppleEvent's: High
level events that programs can use to communicate with each other (as
opposed to low level events that the OS uses to communicate with programs).

There is an experimental MacHugs implementation that can accept and send
arbitrary AppleEvent's.

I think you might achieve what you want by writing an AppleScript that
first opens this experimental MacHugs with suitable source files, and then
sends to it a suitable AppleEvent. When MacHugs receives this event, a
special function
  receive :: Event -> IO ()
is executed that has the AppleEvent translated into a string as an
argument. You then define this function "receive" to call whatever other
function you want to be executed.

This MacHugs version is experimental, because the Hugs kernel isn't thread
safe, so if it receives several ApppleEvent's to be executed in parallel or
while it is already computing something, something might break. In your
case, I think it would work OK, but know you know of it.

If you want, I can send you the sources or a binary (but you will have to
do the AppleScript programming yourself).

  Hans Aberg