Re: What does unsafePerformIO do to the stack

2008-02-08 Thread Bernd Brassel
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

Re: What does unsafePerformIO do to the stack

2008-02-08 Thread Simon Marlow
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

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Bernd Brassel
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

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Simon Marlow
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

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Bernd Brassel
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,

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Bernd Brassel
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 =

Re: What does unsafePerformIO do to the stack

2008-02-01 Thread Simon Marlow
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)

Re: What does unsafePerformIO do to the stack

2008-02-01 Thread Bernd Brassel
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

What does unsafePerformIO do to the stack

2008-01-31 Thread Bernd Brassel
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