Would it make sense to refactor the interface for CSV into something like FromCSV/ToCSV?
The use case that I'm thinking of is that we have a custom type:
InputRow and another OutputRow and we're going to use transformCSV to read in the InputRow and then output the OutputRow. The signature for transformCSV kinda hints at this usage:
transformCSV :: (MonadThrow m, CSV s a, CSV s' b) => ...
it could possibly be this:
transformCSV :: (MonadThrow m, FromCSV s a, ToCSV s' b) => ...
This avoids the need to write a ToNamedRecord instance for InputRow (we're only ever going to be reading from this type) and perhaps even avoids a potential error where we accidentally serialize to an input type.
Would it make sense to refactor the interface for CSV into something like
FromCSV
/ToCSV
?The use case that I'm thinking of is that we have a custom type:
InputRow
and anotherOutputRow
and we're going to usetransformCSV
to read in theInputRow
and then output theOutputRow
. The signature fortransformCSV
kinda hints at this usage:it could possibly be this:
This avoids the need to write a
ToNamedRecord
instance forInputRow
(we're only ever going to be reading from this type) and perhaps even avoids a potential error where we accidentally serialize to an input type.Thanks!