Open Cmdv opened 3 years ago
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))
Csv.ToField (Vector (Maybe Text))
I then tried to have a custom Csv.ToNamedRecord instance and do
Csv.ToNamedRecord
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 _:
Csv.DefaultOrdered
headerOrder
headerOrder _
instance Csv.DefaultOrdered MyType where headerOrder MyType{..} = ...
Is this the expected behaviour?
I've also tried with Map a a & [a] 😄
Map a a
[a]
I've been trying to make a csv that has run time generated columns.
I'm doing this with my type:
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 dobut then the instance for
Csv.DefaultOrdered
fails as I can't get at the vector asheaderOrder
needs to beheaderOrder _
:Is this the expected behaviour?
I've also tried with
Map a a
&[a]
😄