Wrote 'safer' version of unsafeMapToIO'