Hi,

Yes, yes, I know, I know. I shouldn't be using `unsafePerformIO'. But it
is so useful!

That it can completely mess up things shows the following (after a long
time tracked down to its bare essentials:)

-- begin code

module Bug where

import IOExts

main :: IO ()
main = writeFile "cat" buggy

buggy :: String
buggy = unsafePerformIO $
  do writeFile "cow" "Animal Farm"
     return "horse"

-- end code

After running `main', you get an "unexpected signal", and Hugs crashes.

The combination of the following two things causes the problem:

  - the writing to a file of an unsafe string,
  - that when evaluated writes to another file.

Either one of these things is no problem; if you (in the same hugs
session) first evaluate `buggy' (and the side effect is being performed),
and then type `main', everything works fine.

HBC has no problems with this.

Thanks,
Koen.

--
Koen Claessen,
[EMAIL PROTECTED],
http://www.cs.chalmers.se/~koen,
Chalmers University of Technology.

Reply via email to