⟨/⟩ AT Protocol Record Source
at://did:plc:pi6woz4d47bkuws673w2il2r/site.standard.document/3mnubth24kna2
← Back to post
{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreiftsmobt2eevx6wucjg3oodra7hv7hnll4lwk65gehuzetqsq7fuq",
    "uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mnubth24jda2"
  },
  "path": "/t/haskells-missing-mutable-reference-type/14248#post_4",
  "publishedAt": "2026-06-09T12:06:25.000Z",
  "site": "https://discourse.haskell.org",
  "textContent": "Unless I’m totally misreading something, the logging example _doesn’t_ capture the logger. Everything that accesses it also takes it as a parameter. So it’s really equivalent to\n\n\n    loggerExample :: IO ()\n    loggerExample = do\n      let logger = newLogger 0\n      logMsg logger 1 \"Getting user\"\n      user <- getUser\n      logMsg logger 1 (\"Is VIP: \" <> show (isVip user))\n      let modification = if isVip user then (+ 10) else id\n      d <- do\n        -- Instead of overriding it with a continuation, we can just shadow the variable\n        -- (the (<-) and pure are necessary since regular lets are recursive and don't allow shadowing)\n        logger <- pure (modifySeverity logger modification)\n        logMsg logger 0 \"Getting data\"\n        getData user\n      writeData d\n      logMsg logger 0 \"Done\"\n\n\nand then I don’t see the advantage of passing this additional reference around if all you’re doing with it is modifying it in a lexically scoped way like you already can with regular variables",
  "title": "Haskell's missing mutable reference type"
}