You could do this:<br><br>r :: IORef [a]<br>r = unsafePerformIO $ newIORef []<br><br>cast :: a -> b<br>cast a = unsafePerformIO $ do<br> writeIORef r [a]<br> x <- readIORef r<br> return $ head x<br><br><br><div>
<span class="gmail_quote">On 9/26/07, <b class="gmail_sendername">Dan Piponi</b> <<a href="mailto:dpiponi@gmail.com">dpiponi@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 9/26/07, Lennart Augustsson <<a href="mailto:lennart@augustsson.net">lennart@augustsson.net</a>> wrote:<br>> Things can go arbitrarily wrong if you misuse unsafePerformIO, you can even<br>> subvert the type system.
<br><br>So...if I was in a subversive kind of mood (speaking hypothetically),<br>what would I have to do?<br>--<br>Dan<br><br>><br>><br>> On 9/26/07, Jorge Marques Pelizzoni < <a href="mailto:jpeliz@icmc.usp.br">
jpeliz@icmc.usp.br</a>> wrote:<br>> ><br>> > Hi, all!<br>> ><br>> > This is a newbie question: I sort of understand what unsafePerformIO does<br>> > but I don't quite get its consequences. In short: how safe can one be in
<br>> > face of it? I mean, conceptually, it allows any Haskell function to have<br>> > side effects just as in any imperative language, doesn't it? Doesn't it<br>> > blow up referential transparency for good? Is there anything intrinsic to
<br>> > it that still keeps Haskell "sound" no matter what unsafePerformIO users<br>> > do (unlikely) or else what are the guidelines we should follow when using<br>> > it?<br>> ><br>> > Thanks in advance. Cheers,
<br>> ><br>> > Jorge.<br>> ><br>> > _______________________________________________<br>> > Haskell-Cafe mailing list<br>> > <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org
</a><br>> > <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>> ><br>><br>><br>> _______________________________________________
<br>> Haskell-Cafe mailing list<br>> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe
</a><br>><br>><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">
http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>