Added functions and types for generating config file - #14
Conversation
… Also some rudimentary tests in the tests project.
…variable warning suppression in fileEntryAsText function.
…e successful if in the proper format.
|
Thanks for your patch. I'm afraid it has a number of big difficulties that make it a non-starter in its current form. I would have expected the API to be based around the existing There's no obvious way to round-trip a config through this API, i.e. parse a file, modify something (or nothing), and encode it back out. You should probably be using a pretty printing library to generate nicely indented output, rather than your current setup of tracking indentation by hand. The strategy of pasting together a big string will have very poor performance if someone wants to write a large config file (there is a 'Builder' type for exactly this purpose). I don't see the point of all of the top-level functions you have added. They almost double the size of the API without making client code any more readable or expressive. I appreciate you submitting a patch that adds tests. That is a good thing; thank you. Long story short, I'd like to see this capability added in a way that is expressive and elegant. I have confidence that you can get there, but this patch doesn't yet have either property. |
|
You are definitely right. All of those criticism are right on the money and hardly surprising to hear. I originally wanted to leverage the existing I appreciate your words of encouragement, and I might revisit this in the future when I feel I have enough skill to tackle it. My exploration of Haskell is, however, largely guided by my needs in developing my hobby project. My self-rolled solution for writing a config is adequate for those purposes, so I plan to focus on that for the time being. If you choose to pursue this yourself, or get a patch with a solution you are happy with, I would certainly find the code to be educational. |
I added some functions and types for generating a config file. Below is the sample output from the a new writeTest:
It's pretty rudimentary but I expect it to flexible enough (if not convenient) to handle most use cases. The default tab size of two spaces is not currently configurable.