
1 Jun
2007
1 Jun
'07
7:14 p.m.
David Roundy wrote:
On Fri, Jun 01, 2007 at 07:39:32PM +0100, Andrew Coppin wrote:
No, I mean... how could you use unsafePerformIO to perform a typecast? I don't see a way to do that.
Then I'm confused. What typecast are you talking about?
cast :: a -> b cast x = unsafePerformIO (do writeIORef r x; readIORef r) where r = unsafePerformIO (newIORef undefined) The problem is that the Hindley/Milner type inference algorithm is unsound in the presence of effects - r may not be given polymorphic type. That's exactly the reason for ML's dreaded value restriction. - Andreas