blob: 443bfdc9e8c13eb68c145d66d41d898d59ef62ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
{-# LANGUAGE BangPatterns #-}
module T13043 (foo, bar) where
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import System.IO.Unsafe (unsafePerformIO)
{-# NOINLINE scServerState #-}
scServerState :: SCServerState
scServerState = unsafePerformIO (return undefined)
data SCServerState = SCServerState
{ scServer_socket :: IORef (Maybe Int)
}
foo :: IO Int
foo = do
let !_ = scServerState
readIORef (scServer_socket scServerState) >>= \xs -> case xs of
Nothing -> do
s <- undefined
writeIORef (scServer_socket scServerState) (Just s)
return s
Just s -> return s
bar :: IO ()
bar = do
let !_ = scServerState
return ()
|