{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreih6yp3upoku4de73fm6gckeqgpek7nvkifsp6z653vez4u3b543xe",
    "uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mgubemnymew2"
  },
  "path": "/t/synthesizing-runtimerep-indexed-type-class-instances-in-a-ghc-plugin-to-simulate-monomorphization/13774#post_4",
  "publishedAt": "2026-03-11T19:47:03.000Z",
  "site": "https://discourse.haskell.org",
  "tags": [
    "Sixten"
  ],
  "textContent": "It is possible to do partial specialisation. See for example Sixten.\n\nA representation-polymorphic function accepts a witness of the representation, such as a log2 size (alignment, &c.), and uses that to deal with any values of that representation at runtime. This is a middle ground that allows separate compilation without giving up unboxing altogether.\n\nLikewise, in an existential, you would store this witness, in much the same way as a typeclass dictionary. Perhaps it could even reuse a lot of the same machinery. For example, when you see `forall (r :: RuntimeRep)`, introduce a constraint `IsRuntimeRep# r`, whose dictionary is a `Word#` holding the size.",
  "title": "Synthesizing `RuntimeRep`-indexed type class instances in a GHC plugin to simulate monomorphization"
}