I have a datatype with a list of translations, like so:
type Lang = Text
data Trans = Trans {
key :: Text,
translations :: [(Lang, Text)]
}
And I want to generate a csv like
| key |
de |
en |
es |
fr |
| title |
Ein Titel |
A Title |
|
Un Titre |
| something |
|
Something |
|
Quelqechose |
from a [Trans] like
[
Trans {
key = "title",
translations = [("de", "Ein Titel"), ("en", "A Title"), …]
},
…
]
But it is not clear to me whether it’s possible to generate a NamedEncoder a that sets their column names based on the a.
i.e. I think I need something like
namedRow :: (a -> Builder) -> Encoder a -> NamedEncoder [a]
But there only is
row :: Builder -> Encoder a -> Encoder [a]
and I’m not sure the internal encoding (heh) of Encoder would even allow for such a thing.
A complication here is that it’s not entirely clear that every translations would even list the same languages, so the rows might be different for every Trans; maybe my Trans should be represented differently?
I have a datatype with a list of translations, like so:
And I want to generate a csv like
from a
[Trans]likeBut it is not clear to me whether it’s possible to generate a
NamedEncoder athat sets their column names based on thea.i.e. I think I need something like
But there only is
and I’m not sure the internal encoding (heh) of
Encoderwould even allow for such a thing.A complication here is that it’s not entirely clear that every
translationswould even list the same languages, so the rows might be different for everyTrans; maybe myTransshould be represented differently?