4 Mar 2008 17:17
Re: coreFunc has extra argument
Neil Mitchell <ndmitchell <at> gmail.com>
2008-03-04 16:17:41 GMT
2008-03-04 16:17:41 GMT
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
Thanks
Neil
RSS Feed