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
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe