{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreihhvqqjwkbbsffj5qtpkulkbrlubu66llzveui3lqtsqyrafnnyye",
"uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mnupknblxkf2"
},
"path": "/t/haskells-missing-mutable-reference-type/14248#post_8",
"publishedAt": "2026-06-09T16:51:34.000Z",
"site": "https://discourse.haskell.org",
"textContent": "Okay, I had to spend 40 minutes figuring out what this is, and I’m still not sure.\n\nAm I correct to understand that the problem you’re looking to solve is that of a user-definable implicit global context, which can be adjusted locally, e.g.\n\n\n overriding :: Contextual a -> (a -> a) -> (forall b. IO b -> IO b) -- deeply magical\n\n contextual x :: Contextual Int -- still magical\n contextual x = 5\n\n foo = do\n a <- getContextual x\n print a\n\n --- Library user doesn't get to implement anything above this line\n\n -- Prints number 7\n main = overriding x (+2) foo\n\n\nI assumed if a feature like this were to exist it’d be on the compiler to collect all the “contextual” references upfront. This wouldn’t be mutable from user perspective, so I wouldn’t bring up `IORef` at all when talking about it.",
"title": "Haskell's missing mutable reference type"
}