-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
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?
Metadata
Metadata
Assignees
Labels
No labels