introspection -- towards type algebra

I am looking for how far algebra on types in the manner of "set theory as an algebra" ¹ is possible. So for example in set theory one can compute for sets S, T S∪T, S∩T, S-T etc Is something similar possible for types? Say I have data Primary = Red|Green|Blue data Othercolors = Violet|Indigo|Yellow|Orange I want something like Rainbow = Primary ∪ Othercolors Equivalently if Rainbow and Primary had been defined, how to get/compute Rainbow - Primary? ------------------------- I thought the first-class types in Idris would be a good bet to try out at least a trivial prototype. Seems not... So asking here. Clearly and obviously one can use haskell to implement any language. My question is what/which are the introspective libraries/features of modern haskell that make this easy and lightweight. Thanks Rusi ¹ Yeah the term 'type algebra' may be taken in the sense of algebraic data types Cant think of a better one
participants (1)
-
Rustom Mody