Simon Marlow wrote:
Perhaps there are some trivial examples of
unshared thunks that we could spot, though.
The sharing analysis in the interpreter is also very simple and
inexpensive. But the gain is frequent. Maybe giving it a try would be
worthwhile.
Thanks again for all your answers!
Bernd
Bernd Brassel wrote:
There is another point that makes me wonder now. If the update frame for
the recursive call is the problem then my solution with foreign C
functions would produce a bad stack also. But this is not the case.
The code looks now like this:
sim [] = True
sim (_:xs) = yags
I have got around the problem by defining my unsafe actions by the
foreign function interface. But I still think there is a bug concerning
stack use in unsafePerformIO in ghc. And I also think that this bug
potentially concerns every use of unsafe. Or did I just not get the
point of your argument
Bernd Brassel wrote:
Thanks for your answer Simon.
Simon Marlow wrote:
Bernd Brassel wrote:
Consider the following program:
module Stack where
import System.IO.Unsafe
main = print (sim (replicate 1299959 ()))
sim [] = True
sim (_:xs) = goodStack (sim xs)
goodStack x = fromJust (Just
Simon Marlow wrote:
So the upshot is: you can use unsafeDupablePerformIO right now, or you
can wait until I've tested and committed this patch to get
tail-recursion with unsafePerformIO.
Wow, thank you for the detailed answer! That was really interesting.
I've no idea how it works in Hugs,
There is another point that makes me wonder now. If the update frame for
the recursive call is the problem then my solution with foreign C
functions would produce a bad stack also. But this is not the case.
The code looks now like this:
sim [] = True
sim (_:xs) = yags (sim xs)
ref =
Bernd Brassel wrote:
Consider the following program:
module Stack where
import System.IO.Unsafe
main = print (sim (replicate 1299959 ()))
sim [] = True
sim (_:xs) = goodStack (sim xs)
goodStack x = fromJust (Just x) --no stack overflow
badStack x = unsafePerformIO (return x)
Thanks for your answer Simon.
Simon Marlow wrote:
Bernd Brassel wrote:
Consider the following program:
module Stack where
import System.IO.Unsafe
main = print (sim (replicate 1299959 ()))
sim [] = True
sim (_:xs) = goodStack (sim xs)
goodStack x = fromJust (Just x) --no
Consider the following program:
module Stack where
import System.IO.Unsafe
main = print (sim (replicate 1299959 ()))
sim [] = True
sim (_:xs) = goodStack (sim xs)
goodStack x = fromJust (Just x) --no stack overflow
badStack x = unsafePerformIO (return x) --stack overflow