What exactly does this code do? Is someMap a copy of the object (of ::Data.Map.Strict.Map) referred to by myMap or it's a reference only? I mean can someMap change (by another thread) after I read it with readIORef? Something like C's volatile... Is it possible? I expect that it's copy/snapshot, so any changes will not affect my someMap, or ...?
do
....
someMap <- readIORef myMap
....
readIORef :: IORef a -> IO a, somyMapmust beIORef aandreadIORef myMap :: IO a.And so
someMap :: a, because it's to the left of<-in thedocode line of the typeIO a(it'sa <- M a, always, indonotation).In your case, that
a ~ Data.Map.Strict.Map k v, i.e. a pure immutable value.If another thread writes some new value into that
myMap :: IORef (Data.Map.Strict.Map k v), then, it does. But it won't change the pure value that was already drawn from it before the switch-up.Effectful code has time. Pure referentially transparent code with immutable data is timeless.
(What is true, is true, regardless of how long it takes to prove it.)