Currently I have these datatypes:
data NumberColumn = NumberColumn String [Double]
data StringColumn = StringColumn String [String]
data UnknownColumn = UnknownColumn String [String]
All of these datatypes (there are others too, these are just domain examples) model csv file columns. They can represent plain numbers, names, money, simple text and so on.
What I would like to achieve is something like this:
data Column = NumberColumn String [Double] | StringColumn String [String] | UnknownColumn String [String]
That is, I would like to put them in a single datatype so that it would be possible to map, filter and create new items, like so:
sumColumn :: NumberColumn -> NumberColumn -> NumberColumn
sumColumn...
The problem is that NumberColumn is not a datatype but a constructor, so the best that I can think of is to accept and return Column types:
sumColumn :: Column -> Column -> Column
sumColumn (NumberColumn...) (NumberColumn...)...
This works but the explicitness that the function should only take NumberColumns is lost and I would very much like to keep it.
Can this be achieved?