Is there a way in the foreign function interface to pass to a function
a struct by value? I explain it better.
There are two ways in c to pass structs, as in the following example:
/* begin c code */
struct couple{
int a;
int b;
};
//by value
int print_couple (struct couple cpl)
{
But they are very similar! At least superficially.
They are both based on the notion of state transformer. Moreover in
the original paper about the ST monad:
http://www.dcs.gla.ac.uk/fp/papers/lazy-functional-state-threads.ps.Z
The authors say:
In this paper we describe a way to express
I was reading an old post where Hal Daume III was analyzing Haskell
performance for arrays.
He proposed a test program which initializes an array, reverse it a number
of times, and sums the contents.
So I wrote a c++ reference program, a naive haskell version using lists and
I also tweaked a
Of course I know that the list version is very unfair, but I wanted to see
what was the trade off between elegance and speed.
Regarding whether low level programming makes sense or not, I was just
curious to see what are the limits of Haskell. Moreover there is not much
literature on high
Sorry, I was very silly!
This is the correct version of the program using the doFromto loop.
And it runs fast! I hope there are no further mistakes.
Thanks Axel.
time ./IOMutUnbUnsafe
499
real0m0.708s
user0m0.573s
sys 0m0.008s
Thanks for the hints. It's a pity that (as far as I know) no one has
written a tutorial on those techniques, because I think it would be
appreciated. Some of them are quite involved and learning them just by
reading code is very time consuming.
Federico