[Haskell-beginners] Compiling C into Haskell

Hein Hundal hundalhh at yahoo.com
Wed Apr 14 07:34:32 EDT 2010


Thank you to everyone who responded.

My main question was "Say you had a C program.  Can you always
convert it to Haskell in such a way that the compiled Haskell 
is not too slow and does not need too much memory?"  supposing 
that too slow means slower than 1/4 the speed of C and too much 
memory means twice the memory of C.


Let me summarize some of your responses:

1) The general consensus seems to be the answer is probably yes.  
The exceptions, if there are any, are C programs with complex 
data structures.

2) One of the simpler ways to get the speed and memory 
efficiency of C is using the ST monad.

3) The "Foreign Function Interface" (FFI) is sometimes used by 
Haskell programmers to improve the speed or memory efficiency
of a slow or memory intensive subroutine.

4) For my particular project, I should look into "hmatrix" 
which binds to LAPACK, a linear algebra package that I have 
used before.

5) The conversion process from the C program to the speedy 
Haskell program is probably not simple.  


These responses were great!  

Cheers,
Hein 










      


More information about the Beginners mailing list