[Haskell] Using unsafePerformIO safely