
4 Mar
2008
4 Mar
'08
11:17 a.m.
Hi
showsType io = showString "(IO " . showsType a . showChar ')' where a = unsafePerformIO io
You don't even need unsafePerformIO! All you need is a proxy a which has the right type, this can be done by doing: showsType io = showString "(IO " . showsType a . showChar ')' where a = undefined b = asTypeOf (return a) io i.e. instead of unwrapping the io, you wrap up the a, and demand it has the same type as io. Same result, but now entirely "safe". [Note: entirely untested, but the idea should be sound] Thanks Neil