{
  "$type": "site.standard.document",
  "path": "/t/using-rgb-types-to-gain-intuition-about-type-level-programming-and-generics/13651#post_3",
  "publishedAt": "2026-02-04T22:47:10.000Z",
  "site": "https://discourse.haskell.org",
  "tags": [
    "improving memory abstractions"
  ],
  "textContent": "Type data are cool  and I’m always glad to see someone interesting in graphical programming.\n\nI am actually working on improving memory abstractions and one of my applied test cases is in porting an old C game engine of mine, so color spaces, pixel formats, and c struct / bitfield layouts are naturally interesting to me on several fronts.\n\nI don’t have a finalized solution quite yet, but my current approach mirrors that of `Data.Vector.Unboxed` by having a `type MemRep` that declared a backing storage type which is effective enough for now, and I am leaning towards eg using something like `MemTensor [w,h,channels,depth] Bit` or `MemTensor [w,h,channels] Byte` for homogenous RGB sizes, but inhomogenous formats like R5G6B5 are awkward and are technically ragged tensors so I am still pondering them. On the other hand, such formats are usually for storage only, are usually converted to some homogenous format upon loading, and could be represented via `MemMatrix w h pxfmt`\n\n* * *\n\nDon’t give up on type-level programming, it is a powerful worth learning to wield.",
  "title": "Using RGB types to gain intuition about Type Level Programming and Generics"
}