Interpret haskell within haskell.

Alastair Reid alastair@reid-consulting-uk.ltd.uk
20 Dec 2002 12:24:24 +0000


John Hughes <rjmh@cs.chalmers.se> writes:
> When I want to do this kind of thing, I use hugs as a back-end. I
> write the expressions I want to evaluate, or whatever, to a file of
> hugs commands, and then run

> 	system "hugs <hugsinput >hugsoutput"

> then read and process the output (choose your favourite filenames,
> /tmp/... or whatever).

A variant on this idea would be to use the 'Hugs Server API'.  We used
to publicise this API on the Hugs pages but it seems to have gone
missing so you can grab a copy from:

  http://www.reid-consulting-uk.ltd.uk/alastair/publications/server.ps.gz

You'll find a more up to date version in the Hugs distribution in
hugs98/docs/server.{tex,html}

The server API provides an interface for use from C programs but
Haskell's foreign function interface makes it a snap to access that
from Haskell.  

There's only one caveat: you will have to use GHC or NHC to use the
Hugs server; you can't use Hugs to use the Hugs server.  Bummer!

--
Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/