Replace hardcoded defaults. Remove parser boilerplate. (#27)#44
Replace hardcoded defaults. Remove parser boilerplate. (#27)#44georgefst merged 1 commit intofourmolu:masterfrom
Conversation
|
This looks really good! Unfortunately I don't quite have time to look at the code in-depth right now, but I should be able to review properly by the weekend.
That's an error really. We probably want universal case-insensitivity, although in practice just accepting all-lowercase would be fine since this is what the examples use.
Yeah, I'm interested in a general solution to this, and I think it could be quite neatly encapsulated in a library. See my comment on Reddit, which was largely inspired by Fourmolu. It seems that nothing complete currently exists for Haskell. I've been meaning to research what solutions are available in other languages. |
I opt for requiring all-lowercase, to keep it compatible with Ormolu (and save a few lines of code). But I can do it either way, just let me know. When reviewing please take a look at
Sounds interesting. |
9d30323 to
4cc442e
Compare
Yep, those are good enough reasons.
I'd go for uniformity here. It's a trivial enough function that I'm not too concerned about merge conflicts. Would there be any visible change in behaviour?
Yeah, unfortunately, I'm really not looking for another library to maintain right now. Some of the code you've written here would actually be a good starting point, since it's really pretty independent of Fourmolu. |
4cc442e to
faf6d1b
Compare
Ok, I did it this way.
I replaced the parser. Yes, there is a change in the error message ("unknown value:" instead of "unknown mode:" and an extra line with allowed values). I also did a naming change (
I've thought about it for a moment (not a very long one 😉 ) and I don't know how to apply these ideas when we don't know what is the type that contains the preferences (i.e. when About the solutions in other languages: are you aware of some libraries that handle this? |
Hmm, good point. I suppose we want to be able to work with any record type that has the correct kind ((
I don't know any, but I feel like there must be something out there. I can't imagine we're the first to think about generalising this. |
|
I did a quick research and found some libraries in:
Didn't have time to read any of these, though. This looks like an useful tool, and the problem seems rather accessible. If a project was started, I'd be eager to help. However, with my current Haskell skills, I don't think I'm ready to design a solution. |
|
Nice. that list is very handy! I'll let you know if I do make a start on this. Unfortunately, the likely need for TemplateHaskell to get something nice takes it out of the realms of "something I might be able to knock together on a Sunday afternoon". |
Closes #27.
This solves the problem described in #27. At the same time I wanted to reduce the number of places where the strings encoding option values were hardcoded, which resulted in rewriting/replacing
parseHaddockStyle,parseCommaStyleandparseBooland modifying the way that the help texts are built.I also decided to make the error messages a bit more user friendly by providing the user with the list of possible values of an option (because it was nearly free with the new approach).
Some comments: