{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreicj5t67bdaggahll24dizkrxr724lbjadirkzf2oi5g5ehelwjxli",
    "uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3moarz5tr5lx2"
  },
  "path": "/t/haskells-missing-mutable-reference-type/14248?page=3#post_56",
  "publishedAt": "2026-06-14T12:17:32.000Z",
  "site": "https://discourse.haskell.org",
  "tags": [
    "loggerExampleConcurrently",
    "Concurrency",
    "fork-fragile-reader-like-operations"
  ],
  "textContent": "> OK, this is supposed to be clear from loggerExampleConcurrently. I’ll see if I can clarify that.\n\nIn that example you do the modification _inside_ the fork, so it wasn’t obvious to me whether the modification would be visible if you did it the other way around.\n\n> How would the behaviour differ? Do you mean that `InheritedThreadLocalIORef` could be modified within a thread like an `IORef`?\n\nYes. You modify it just like an `IORef`, it’s just that such a modification is visible to a) your current thread, and b) child threads (if it happens before you fork the thread). That is, exactly how masking state works today.\n\n> I just don’t like the semantics of the latter. It would allow you to observe whether you’re running in a forked thread. See “the interaction between the semantics of thread creation and of `IOScopedRef` are good” in the Concurrency section.\n\nI don’t understand how it would do that, can you give an example?\n\n> What’s the use of having thread local state that allows non-scoped modifications?\n\nWhat’s a “non-scoped modification”? Do you mean `writeIORef` versus `withModifiedIORef :: IORef a -> (a -> a) -> IO a -> IO a`? People seem to be perfectly happy with the non-scoped modification functions on `IORef`, and you can implement the scoped ones with it if you want?\n\nThe point of having thread-local state is: modifications in child threads don’t affect the parent or sibling threads.\n\nThe point of having inherited thread-local state is: forked code “continues” from the parent context in a natural way.\n\nThe problems you observe in fork-fragile-reader-like-operations seem to me to be related to these two things. I’m arguing that the “scoped” part of it is perhaps not the crux!",
  "title": "Haskell's missing mutable reference type"
}