Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: What is the simplest way to build a [DataRow] ? #169

Open
MMesch opened this issue Sep 12, 2020 · 1 comment
Open

Question: What is the simplest way to build a [DataRow] ? #169

MMesch opened this issue Sep 12, 2020 · 1 comment

Comments

@MMesch
Copy link

MMesch commented Sep 12, 2020

This is a question rather than a bug. I am a happy hvega user but my code usually gets bloated up at the point where I need to convert some Haskell data type into an HVega datatype.

dataFromRows expects a [DataRow] which can be constructed with dataRow. However, this constructor doesn't have the typical form [(FieldName, DataValue)] -> [DataRow] that one would expect and that could be used with a simple dataRow <$> myrows to convert a whole list of fields with associated value into a list of DataRows.

I don't understand the point of this other constructor yet. Yes it allows us to concatenate lists of DataRows but wouldn't we be able to do this with simple list operators anyway?

What are the objections against simple dataRow :: [(FieldName, DataValue)] -> [DataRow] and dataColumn :: FieldName -> [DataValue] -> [DataRow] constructors that I would expect?

@DougBurke
Copy link
Owner

So, this is code I based on the Elm Vega Lite version and haven't really looked at since (to see if it can be made "more" haskelly, to abuse a term or two).

I'm not sure if this helps you, but you can see some examples in the tests - e.g. https://github.com/DougBurke/hvega/blob/master/hvega/tests/DataTests.hs and https://github.com/DougBurke/hvega/blob/master/hvega/tests/Gallery/Bar.hs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants