External Publication
Visit Post

Using RGB types to gain intuition about Type Level Programming and Generics

Haskell Community [Unofficial] February 4, 2026
Source

Type data are cool and I’m always glad to see someone interesting in graphical programming.

I 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.

I 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


Don’t give up on type-level programming, it is a powerful worth learning to wield.

Discussion in the ATmosphere

Loading comments...