[Haskell] unsafePerformIO and optimizations