Previous Up Next

4  Parametric polymorphism for more flexible data specifications

Even though the presented representation allows expressive specifications, there are further extensions that make this task even easier. Modern type systems allow parametric polymorphism, which introduces type parameters for more reusability.

For example, when many variables can have missing values, it would be cumbersome to define, for each of these, a type that wraps around the actual values to tag them as observable as in:

  t = Observed value | Missing
  value = A | B

Instead we could write down a more generic definition:

  optional value = Some value | None

Similar to functions this makes it possible to use abstractions for specification. E.g.:

  v1 = optional government
  v2 = optional religion

This results in much more compact and readable data specifications, because it is not necessary anymore to explicitly write down structures that are isomorphic anyway. Legal values in the upper example could be Some Democracy of type optional government or Some Muslim of type optional religion. None would be legal in both type contexts.
This extension is currently not yet implemented in our system, but is not particularly difficult to achieve either, because the theory behind is well-understood.


Previous Up Next