[Yhc] coreFunc has extra argument
Neil Mitchell
ndmitchell at gmail.com
Tue Mar 4 11:17:41 EST 2008
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
More information about the Yhc
mailing list