3 ms·
Could you unpack this a bit for the relative layperson? I once heard a guy at a Haskell meetup say that “codata is the categorical dual of data” but I didn’t kn
by zachrose 9y ago
Could you unpack this a bit for the relative layperson? I once heard a guy at a Haskell meetup say that “codata is the categorical dual of data” but I didn’t know what that means then and I still don’t know.
- Retra 9y agoData is finite data structures, while Codata is infinite data structures (like streams.) They are duals because you can generate and process data using induction, while you can use coinduction to generate and process codata. One is "built up" naturally, and the other is "torn down" naturally.
- naasking 9y agoTo elaborate a little on the other poster, the data types you're used to are finite values built incrementally, ie. build this, then build this, then build that. Codata is the inverse, in that you can see it as a finite set of observations of some already built infinite data structure, ie. unpack this value at the head, then unpack that, etc. For instance, the stream of values observed from a process that runs forever. We usually encode codata using inductive data types, but this is awkward for all of the reasons that come up in FRP and other reactive systems.