[BLOG] Typesafe complicated combinations

Heya everyone –

I’ve written a blogpost based on a recent experience adding typesafety to the pmmd codebase – handling a lot of different data and functions that needs to be combined in the right ways.

In it I make use of phantom types and OCamls module system to express the invariants - which I find is a nice set of typesystem features to express complicated relations in a relatively simple but efficient and scaleable way. Also, I think interesting design patterns can emerge from this way of working.

Let me know here if you have any questions or comments

Thanks (:

4 Likes

To those of you interested, I updated the text with further discussion of the design-pattern - specifically about the fact that it reverses the dependency-relation between combined data, vs what one would have done by aggregating data within data.

This is also loosely related to OO in an interesting way - in that objects in OO have identities, and contain data and procedures - where here it’s individual data-sources (Socket.Endpoints) that have identities, which are carried across different data, and finally used to combine in a typesafe way.

I would be interested to hear if anyone also has experience with related patterns, and for what? Tyxml is one example.