Say there is a sum type that has a layer of nesting, like so:
data LandVehicle = Car | Truck
deriving (Eq, Enum, Bounded)
data MarineVehicle = Submarine | Tugboat
deriving (Eq, Enum, Bounded)
data Vehicle = Land LandVehicle | Marine MarineVehicle
Is there some generic version of enumerate
that will produce a list containing all four possible values of Vehicle
?
Land Car
Land Truck
Marine Submarine
Marine Tugboat
There’s a similar question on StackOverflow that makes reference to rolling one’s own implementation with Typeable
/Data
. But does there exist a package that provides this functionality out of the box?