Producing fortran/C code with haskell?

I seem to recall a discussion, don't know if it was here or on comp.lang.functional, where somebody said he uses haskell to generate fortran code. That fascinated me a lot, because that would mean being able to generate a program already specialized for a specific input, by first reading input in haskell and then producing code (fortran, but could be C either) - and because I guess it can add static safety exploiting haskell types. Since we already have that nice syntax for monads those programs should be readable, too. Where could I find information on such topics, or existing libraries to generate programs with haskell? Is somebody willing to share what (s)he already did? V.

On Jan 30, 2004, at 1:32 PM, Vincenzo aka Nick Name wrote:
I seem to recall a discussion, don't know if it was here or on comp.lang.functional, where somebody said he uses haskell to generate fortran code.
That fascinated me a lot, because that would mean being able to generate a program already specialized for a specific input, by first reading input in haskell and then producing code (fortran, but could be C either) - and because I guess it can add static safety exploiting haskell types. Since we already have that nice syntax for monads those programs should be readable, too.
Where could I find information on such topics, or existing libraries to generate programs with haskell? Is somebody willing to share what (s)he already did?
V.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
You might try looking at http://www.fftw.org. They use an Objective Caml program to generate optimized C fourier transforms for various machine architectures. Best Wishes, Greg

On Fri, 30 Jan 2004 19:32:53 +0100
Vincenzo aka Nick Name
I seem to recall a discussion, don't know if it was here or on comp.lang.functional, where somebody said he uses haskell to generate fortran code.
That fascinated me a lot, because that would mean being able to generate a program already specialized for a specific input, by first reading input in haskell and then producing code (fortran, but could be C either) - and because I guess it can add static safety exploiting haskell types. Since we already have that nice syntax for monads those programs should be readable, too.
Where could I find information on such topics, or existing libraries to generate programs with haskell? Is somebody willing to share what (s)he already did?
Googling for "embedded domain specific compilers" should turn up links on one interesting technique to achieve this.

Strafunski might help?
--- Derek Elkins
On Fri, 30 Jan 2004 19:32:53 +0100 Vincenzo aka Nick Name
wrote: I seem to recall a discussion, don't know if it was here or on comp.lang.functional, where somebody said he uses haskell to generate fortran code.
That fascinated me a lot, because that would mean being able to generate a program already specialized for a specific input, by first reading input in haskell and then producing code (fortran, but could be C either) - and because I guess it can add static safety exploiting haskell types. Since we already have that nice syntax for monads those programs should be readable, too.
Where could I find information on such topics, or existing libraries to generate programs with haskell? Is somebody willing to share what (s)he already did?
Googling for "embedded domain specific compilers" should turn up links on one interesting technique to achieve this.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
===== Christopher Milton cmiltonperl@yahoo.com

On Fri, Jan 30, 2004 at 07:32:53PM +0100, Vincenzo aka Nick Name wrote:
I seem to recall a discussion, don't know if it was here or on comp.lang.functional, where somebody said he uses haskell to generate fortran code.
That fascinated me a lot, because that would mean being able to generate a program already specialized for a specific input, by first reading input in haskell and then producing code (fortran, but could be C either) - and because I guess it can add static safety exploiting haskell types. Since we already have that nice syntax for monads those programs should be readable, too.
Where could I find information on such topics, or existing libraries to generate programs with haskell? Is somebody willing to share what (s)he already did?
I've used haskell to generate C code for a few inner loops. You can browse
my code at the following link:
http://jdj5.mit.edu/cgi-bin/darcs?meep*
The haskell code is all in the hsrc directory, and StepGen.lhs is the
module that does the work, assisted a bit by Complex.lhs and
YeeLattice.lhs, which define stuff releting to complex numbers and the Yee
lattice respectively. The files step_d_gen.hs, etc., each create a program
whose output is a chunk of C++ code that is then #included into the
relevant function.
My code is ugly and not very general at all, but it has allowed me to
cobble together something that generates the inner loop in something
resembling a reasonable manner. The main problem the code tries to solve
is situations where you'd like to code
for (int i=0;i

Where could I find information on such topics, or existing libraries to generate programs with haskell? Is somebody willing to share what (s)he already did?
A possibly useful resource is: My cross-module inliner for C contains a bunch of type definitions to represent C code, a pretty-printer, a C parser (which supports al the gcc extensions) and various useful libraries (e.g., generate dependency graph, estimate size of generated code, etc.) It is GPLed, the code for manipulating C is clearly separated from the application that uses it. You can get it from: http://www.cs.utah.edu/flux/knit/cmi.html -- Alastair Reid haskell-consulting.com
participants (6)
-
Alastair Reid
-
Christopher Milton
-
David Roundy
-
Derek Elkins
-
Gregory Wright
-
Vincenzo aka Nick Name