Hi,
Is the following safe?
moo :: TVar Int
moo = unsafePerformIO $ newTVarIO 1
I'm interested in writing a stateful application, and I wanted to start with
writing some IO functions that did stuff on some state and then test them
over long periods of time in GHCi.
I was worried I might be
On 8 Dec 2008, at 01:28, John Ky wrote:
Hi,
Is the following safe?
moo :: TVar Int
moo = unsafePerformIO $ newTVarIO 1
I'm interested in writing a stateful application, and I wanted to
start with writing some IO functions that did stuff on some state
and then test them over long periods
Does that mean there is no place to store state while running the
interpreter and that I have to put the state elsewhere such as a file? I
was hoping to avoid that as I'm only prototyping at this stage and don't
want to write a persistent layer just yet.
Thanks
-John
On Mon, Dec 8, 2008 at
2008/12/7 John Ky [EMAIL PROTECTED]
Does that mean there is no place to store state while running the
interpreter and that I have to put the state elsewhere such as a file? I
was hoping to avoid that as I'm only prototyping at this stage and don't
want to write a persistent layer just yet.
Inline.
On Mon, Dec 8, 2008 at 1:28 PM, Luke Palmer [EMAIL PROTECTED] wrote:
2008/12/7 John Ky [EMAIL PROTECTED]
Does that mean there is no place to store state while running the
interpreter and that I have to put the state elsewhere such as a file? I
was hoping to avoid that as I'm only
John Ky said:
Does that mean there is no place to store state while running the
interpreter [...]?
If all you are doing is experimenting at the GHCi prompt, then maybe
this is what you are missing:
... moo - newTVarIO 1
... :t moo
moo :: TVar Integer
... atomically (readTVar moo)
1
...
You