utdemir / hs-nix-template

A Haskell project template that uses Nix and comes with cabal-install, ghcid, ormolu, haskell-language-server and more.
MIT License
103 stars 12 forks source link

Allow user to select library or executable #22

Closed chiroptical closed 3 years ago

chiroptical commented 3 years ago

Closes #18

The only real question is do we expect more libraries than executables? I think the answer is yes but maybe you have an opinion

utdemir commented 3 years ago

Thank you!

The only real question is do we expect more libraries than executables? I think the answer is yes but maybe you have an opinion

I personally use this more often for libraries, however even when I am writing an executable I also have an internal library doing most of the stuff, and a very thin executable section mostly for invoking the library. The main reason is to be able to import the library from the test-suite's.

For the same reason, I have a slight preference for formulating the question more like "do you need an executable section?" rather than "is this a library or an executable?"; because I think it is closer to what we are doing. But if you prefer it this way, I am happy with it too.

I think it would also be good to have another test for this functionality too. Ideally, we'd test every combination of options ((,) <$> [useHpack, useCabal] <*> [Library, Executable]. I think it still is doable when we only have a few toggles, but it might get unwieldy. So, feel free to add either a few manual test cases, or a slightly more complex logic testing all combinations of the project_configuration_tool and project_type parameters.

chiroptical commented 3 years ago

For the same reason, I have a slight preference for formulating the question more like "do you need an executable section?" rather than "is this a library or an executable?"; because I think it is closer to what we are doing. But if you prefer it this way, I am happy with it too.

Yeah, I like the former as well. Another option, maybe, would be to add a commented executable section to *.cabal, package.yaml just so it is easy to include one if you want. I agree that most of the time I am opening up the library section first.

utdemir commented 3 years ago

Another option, maybe, would be to add a commented executable section to *.cabal, package.yaml just so it is easy to include one if you want.

But then, would we still include the main module (and possibly a separate directory)? That doesn't sound ideal to me, I think your approach on this PR is better.

If you change the prompt to something along the lines of "include executable section/stanza/module" (feel free to pick a better wording) instead of "library or executable", and add some test cases, I'm happy with this PR merged :).

If you don't have time, I'd be happy to work on this too, just let me know :).

chiroptical commented 3 years ago

The multiline string thing doesn't appear to work. I have no clue how to get it to pass CI. I think I'll revert that for now and submit an issue

chiroptical commented 3 years ago

Updated! I think this will be a nice ergo boost for users!

utdemir commented 3 years ago

This is great, thanks!