Can ToField have Vectors/Functors instances?
Cmdv opened this issue · 0 comments
Cmdv commented
I've been trying to make a csv that has run time generated columns.
I'm doing this with my type:
data MyType = MyType
{ callId :: UUID.UUID
, agentDisplayName :: Text
, callLabels :: Vector (Maybe Text)
}
deriving (Generic, Show, Eq)
But I just can't make an instance of Csv.ToField (Vector (Maybe Text))
I then tried to have a custom Csv.ToNamedRecord
instance and do
instance Csv.ToNamedRecord MyType where
toNamedRecord CallReportCSV {..} = do
Csv.namedRecord ["callId" .= callId
, "Agent Display Name"
]
<> Csv.namedRecord (V.toList (convertToListFunc <$> callLabels) :: [(ByteString, ByteString)])
but then the instance for Csv.DefaultOrdered
fails as I can't get at the vector as headerOrder
needs to be headerOrder _
:
instance Csv.DefaultOrdered MyType where
headerOrder MyType{..} = ...
Is this the expected behaviour?
I've also tried with Map a a
& [a]
😄