replacing guile with haskell?

David Roundy droundy at
Fri Oct 17 13:18:57 EDT 2003

On Fri, Oct 17, 2003 at 02:08:06PM +0100, Alastair Reid wrote:
> > I'm wondering what the possibilities are for replacing the use of guile
> > with a haskell interpereter? I'd like to be able to embed a haskell
> > interpereter (presumably hugs) withing my program, so that the input file
> > could be a haskell program.
> Do you want to embed Haskell code or to embed a Haskell interpreter?

I actually would like to embed a Haskell interpreter.

> > There are a couple of issues with this.  The first is that I've heard that
> > hugs isn't intended for numerical work (which is what I'm doing).  I'm not
> > sure if this will be a problem, since hugs won't be doing any of the real
> > work anyways.
> It's hard to comment on this.  Hugs numeric routines are a lot better than 
> when the original "don't use" advice was written - but people do complain 
> every now and then.

That's good news.  I'll hope that since the heavy lifting is in C++ I
should be fine...

> > The other is that according to the man page, it seems that hugs only
> > supports ffi on x86, powerpc and sparc, which seems likely to be a show
> > stopper.  Since I'll need to run the code on supercomputers, I won't always
> > have a choice of architectures, and at least support for POWER (maybe comes
> > free with powerpc?) would be necesary--IBM SP machines are quite nice.  In
> > this regard, ghc seems worse than hugs (the thought of bootstrapping ghc on
> > a supercomputer gives me the shivers), and nhc98 last time I looked didn't
> > support 64 bit platforms.
> It's only calling Haskell functions from C which is non-portable.  
> Unfortunately, I'd guess that's the bit you need!

Hmmmm.  I may be able to get by without calling haskell functions from C.
Most of the work would be done in C, and haskell would just be the "glue"
language to let the user flexibly specify what he/she wants done.  It
*would* be nice, however, to let the user specify the dielectric function
as a function of position as a haskell function!  But in most cases, the
user will build up the structure out of primitives (cylinders, spheres,
etc), and that can be done without calling haskell from C.

> Porting Hugs' ffi to a new platform is pretty easy for someone with
> assembly code experience since you only have to write one function -
> albeit a tricky one.  Less if ghc has already been ported to that
> platform since we can steal code from them :-) The code involved is the
> function 'mkThunk' in hugs98/ src/builtin.c

That's encouraging, but alas I have no real assembly code experience.

> I would guess that nhc is easy to port to 64 bit machines since (at least
> some) C compilers provide flags to compile for 32-bits.  But I could
> easily be wrong...

Hmmmm.  The catch is that you'd then be using 32 pointers, and I doubt that
the MPI libraries will run in 32 bit mode...

Thanks for the advice! I'm a bit more optimistic now that the runhugs
solution will work.  I've still got a week or two of C++ work to go, plus
putting a C wrapper around everything, before I can seriously consider
starting work on a haskell interface.
David Roundy

More information about the Haskell-Cafe mailing list