When running IO
actions in GHCi prompt it automatically runs the action and shows result, this is nice, but not for students trying to understand difference between IO
and non-IO
. Is there a way to change configuration of GHCi so that it runs the action, but shows something like <<IO Int action>>
instead? Something more like result for ST actions (but action should be performed):
now it does:
> return 1 :: IO Int
1
> return 1 :: ST s Int
<<ST action>>
i would like:
> return 1 :: IO Int
<<IO Int action>>
> putStrLn "bla"
bla
<<IO () action>>
Edit:
- I just found that
IO
is probably the only thing handled specially by GHCi,ST
actually has instance forShow (ST s a)
which returns"<<ST action>>"
. So maybe if I could disable this special treatment ofIO
it would be sufficient. - As for allowed code changes: manually changing evaluated expression is not an option. Change in libraries might be, but I would prefer not to do that (I considered creating wrapped
IO
type, but then interpreter will not run the action). If GHCi could automatically wrapIO
actions somehow, that would be an option.