It would be nice to have a "map-like" Sum/Variant type to go along with Data.Type.Map. It could look something like:
data Sum (n :: [Mapping Symbol *]) where
This :: Var k -> v -> Sum ((k ':-> v) ': m)
That :: Sum m -> Sum ((k ':-> v) ': m)
I'm using Map right now to build up records by field name (irrespective of field order), and I want to extend it to records with more than one constructor. Sum would be perfect for this, because one could represent:
data A = B { one :: Int, two :: Bool } | C { three :: Char }
as the generic
Sum '[ "B" ':-> Map '[ "one" ':-> Int, "two" ':-> Bool ]
, "C" ':-> Map '[ "three" ':-> Char ]
]
As far as I'm aware, there are packages on hackage that provide generic variant types, but none that provide a generic tagged and sorted variant that's dual to Map. Would it make sense to add this to type-level-sets?
It would be nice to have a "map-like" Sum/Variant type to go along with
Data.Type.Map. It could look something like:I'm using
Mapright now to build up records by field name (irrespective of field order), and I want to extend it to records with more than one constructor.Sumwould be perfect for this, because one could represent:as the generic
As far as I'm aware, there are packages on hackage that provide generic variant types, but none that provide a generic tagged and sorted variant that's dual to
Map. Would it make sense to add this totype-level-sets?