What is polytypic programming?

Generic programming — Or: write everything once

Ralf Hinze summarizes polytypic programming, with a focus on Generic Haskell. He discusses:

  • Generic functions on types
  • Generic functions on type constructors
  • Generic types
In addition to the usual generic equality and serialization, he mentions fold and map (though not by name), along with a dozen other ideas that use polytypism. He also notes that the Generic Haskell experiment will be continued and integrated into a "standard Haskell compiler".

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

No mention of other projects

I will add that he doesn't mention other Haskell generic programming projects, like PolyP (the only one with type-safe fold and unfold) and the ubiquitous SYB.

under-developed topic

I was scouting around this area the other month and I have to say I was surprised with what I found. All the technologies I found were certainly impressive achievements, but I am not sure any successfully provided "generic programming" as I was looking for it. Generic Haskell seems to be just a little more than template meta-programming. SYB is the standout in the field I think.

I am glad to hear the experiment will be continuting.

I guess I am posting this to try and start some discussion on the merits and problems of each (SYB, PolyP, GH) as my own investigation wasn't able to tease out all the issues.

Introspection

A connection that I don't think is explicitly mentioned often (or at all) in relation to generic programming is that, at least to me, the basic approaches revolve around an "FP" version of introspection (structural reflection). Getting the shape of an algebraic data type is very much like getting the collection of fields/methods of an object.