A way to avoid a common use of unsafePerformIO
I often find this pattern in Haskell code: options :: MVar OptionRecord options = unsafePerformIO $ newEmptyMVar ... doSomething :: Foo -> Bar doSomething = unsafePerformIO $ do opt <- readMVar options doSomething' where ... Basically, one has a record of options or something similar, that is initially set at the program's beginning. As the programmer is lazy, he doesn't want to carry the options record all over the program. He defines an MVar to keep it - defined by an ugly use of unsafePerformIO . The programmer ensures, that the state is set only once and before any operation has taken