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 can also perform "let"-bindings:

...> let incr v = readTVar v >>= writeTVar v . (+1)
...> :t incr
incr :: (Num a) => TVar a -> STM ()
...> atomically (incr moo)
...> atomically (readTVar moo)
2
...>

For the details, see the GHC reference.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to