Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-27 Thread Adrian Hey
Chaddaï Fouché wrote: 2007/9/26, Adrian Hey [EMAIL PROTECTED]: Chaddaï Fouché wrote: There can't be alternatives, unsafeIO throw by the window most guarantee that Haskell can give you and you have to provide them yourself (with a proof of this part of your program), but it's inherent to the

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Sebastian Sylvan
On 26/09/2007, Jorge Marques Pelizzoni [EMAIL PROTECTED] wrote: Hi, all! This is a newbie question: I sort of understand what unsafePerformIO does but I don't quite get its consequences. In short: how safe can one be in face of it? I mean, conceptually, it allows any Haskell function to have

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread David Roundy
On Wed, Sep 26, 2007 at 11:43:15AM -0300, Jorge Marques Pelizzoni wrote: Hi, all! This is a newbie question: I sort of understand what unsafePerformIO does but I don't quite get its consequences. In short: how safe can one be in face of it? I mean, conceptually, it allows any Haskell

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Adrian Hey
Sebastian Sylvan wrote: Rule of thumb: If your name isn't Simon*, you shouldn't use unsafePerformIO. If this is so, maybe it's time someone (who may or may not be called Simon) gave us a realistic alternative. :-) Regards -- Adrian Hey ___

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Bulat Ziganshin
Hello Jorge, Wednesday, September 26, 2007, 6:43:15 PM, you wrote: This is a newbie question: I sort of understand what unsafePerformIO does but I don't quite get its consequences. In short: how safe can one be in face of it? i redirect you to http://haskell.org/haskellwiki/IO_inside and

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Chaddaï Fouché
2007/9/26, Adrian Hey [EMAIL PROTECTED]: Sebastian Sylvan wrote: Rule of thumb: If your name isn't Simon*, you shouldn't use unsafePerformIO. If this is so, maybe it's time someone (who may or may not be called Simon) gave us a realistic alternative. There can't be alternatives, unsafeIO

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Jorge Marques Pelizzoni
Thanks! That's very clarifying. Bulat Ziganshin escreveu: Hello Jorge, Wednesday, September 26, 2007, 6:43:15 PM, you wrote: This is a newbie question: I sort of understand what unsafePerformIO does but I don't quite get its consequences. In short: how safe can one be in face of it? i

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Lennart Augustsson
Things can go arbitrarily wrong if you misuse unsafePerformIO, you can even subvert the type system. On 9/26/07, Jorge Marques Pelizzoni [EMAIL PROTECTED] wrote: Hi, all! This is a newbie question: I sort of understand what unsafePerformIO does but I don't quite get its consequences. In

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Paul Johnson
Jorge Marques Pelizzoni wrote: Hi, all! This is a newbie question: I sort of understand what unsafePerformIO does but I don't quite get its consequences. In short: how safe can one be in face of it? I mean, conceptually, it allows any Haskell function to have side effects just as in any

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Adrian Hey
Chaddaï Fouché wrote: There can't be alternatives, unsafeIO throw by the window most guarantee that Haskell can give you and you have to provide them yourself (with a proof of this part of your program), but it's inherent to the nature of the beast, it's what it do ! What about ..

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Dan Piponi
On 9/26/07, Lennart Augustsson [EMAIL PROTECTED] wrote: Things can go arbitrarily wrong if you misuse unsafePerformIO, you can even subvert the type system. So...if I was in a subversive kind of mood (speaking hypothetically), what would I have to do? -- Dan On 9/26/07, Jorge Marques

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Jonathan Cast
On Wed, 2007-09-26 at 14:28 -0700, Dan Piponi wrote: On 9/26/07, Lennart Augustsson [EMAIL PROTECTED] wrote: Things can go arbitrarily wrong if you misuse unsafePerformIO, you can even subvert the type system. So...if I was in a subversive kind of mood (speaking hypothetically), what

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Lennart Augustsson
You could do this: r :: IORef [a] r = unsafePerformIO $ newIORef [] cast :: a - b cast a = unsafePerformIO $ do writeIORef r [a] x - readIORef r return $ head x On 9/26/07, Dan Piponi [EMAIL PROTECTED] wrote: On 9/26/07, Lennart Augustsson [EMAIL PROTECTED] wrote: Things can go

Re: [Haskell-cafe] unsafePerformIO: are we safe?

2007-09-26 Thread Chaddaï Fouché
2007/9/26, Adrian Hey [EMAIL PROTECTED]: Chaddaï Fouché wrote: There can't be alternatives, unsafeIO throw by the window most guarantee that Haskell can give you and you have to provide them yourself (with a proof of this part of your program), but it's inherent to the nature of the