Generalise to MonadIO instead of plain IO.