
To give you more context, I have a soft using ACID state to store and
retrieve values.
For example I have a function like that:
newPlayer :: PlayerName -> IO ()
newPlayer name = update $ AddPlayer name
It seems that ACID uses a global state or a file to store the events... I'd
like to suppress the ACID state for the moment, how should I do?
Change all the* IO () *types to *StateT Game IO ()*?
Indead the ACID state is started with:
c <- localStartSystemState (Proxy :: Proxy Game)
Best,
C
On Wed, Aug 29, 2012 at 12:00 PM, Corentin Dupont wrote: Thanks Eugene and Ozgur.
I also looked on the side of IORef, but it doesn't looked to be a good
solution since we have to use unsafePerformIO. I have a big program to modify, and I want to pass some new data to
existing functions of type IO(). I'd like to avoid changing all the
function's types down the chain... What is the best way to do that? On Wed, Aug 29, 2012 at 11:43 AM, Ozgur Akgun On 29 August 2012 10:21, Corentin Dupont *f,g :: IO ()
f = withFile "toto" WriteMode (flip hPutStr "42")
g = withFile "toto" ReadMode hGetLine >>= (\s -> putStrLn $ "Answer:" ++
s)
main = f >> g* Is it possible to do the same without files (the types must remain IO())? One can use an IORef to get a similar effect. import Data.IORef
import System.IO.Unsafe {-# NOINLINE toto #-}
toto :: IORef String
toto = unsafePerformIO (newIORef "") f,g :: IO ()
f = writeIORef toto "42"
g = readIORef toto >>= (\s -> putStrLn $ "Answer:" ++ s) main = f >> g HTH,
Ozgur
participants (1)
-
Corentin Dupont