
The example I gave was simplified. A real problem contains several other complications which makes this simple solution not practical.
There will be some generated code with several dozen of such cases (schemas). I want to keep them all in one GADT, such that I can use common code to manipulate them. This is why EList was introduced for 'Extended' container.
Another problem comes from some other container types which I did not mention before. I already have mapping from
IList to other container types (not mentioned in my mail), like
grp1 :: Group '[0, 1, ...]
grp1 = mkGroup (Item @0 &: Item @1 ... &: nil)
In my case, the IList seems like universal data type to construct other items (as long as types are properly aligned). It's very convenient from application writer perspective.
So, if at all possible, I would like to map from IList to EList.
----- Original Message -----
From: "Henning Thielemann"
Dear haskellers, I am trying to add some type safety to the program in the following situation:
There are some distinct 'Item t' types which come in groups. That is: 'EList' container can contain either:
- items 0,1 - items 0,1,2,3 - items 0,1,2,3,4,5,6
What about a solution in Haskell 98: (T0, T1, Maybe (T2, T3, Maybe (T4, T5, T6))) or with custom data types: data ItemsA = ItemsA T0 T1 (Maybe ItemsB) data ItemsB = ItemsB T2 T3 (Maybe ItemsC) data ItemsC = ItemsC T4 T5 T6 ?