-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
Description
This is a cool tool, but I think it would be even nicer if it the templates were allowed to be regular cabal packages.
When there is no package-name.cabal.template hi could look for a ".cabal" file my-template.cabal (where my-template is the name of the template). It should be easy to locate as it will be the only ".cabal" file.
Instead of requiring...
Name: $packageName
Author: $author <$email>
...
Library
Exposed-Modules: $moduleName
Other-Modules: $moduleName.Internal
allow...
Name: my-template
Author: Hamish Mackenzie <Hamish.K.Mackenzie@gmail.com>
...
Library
Exposed-Modules: Module.Name
Other-Modules: Module.Name.Internal
We can still easily replace name and author (just find the line starting with "Author:"). I think other top level cabal properties should be handled in a similar way. The module names might be harder to handle and maybe we would need a hi.info file or something could tell you which modules to rename.
I think there are a lot of advantages to this approach
- Users can see the info about the template (who is the author, what version is it)
- Template packages could be uploaded to hackage to make them visible and haddock docs available
- Hi could just run "cabal unpack" to download the template package
- Users could "cabal install" the template package and try it out
- Many existing packages would be valid hi templates (like hello)
- To make a new template from an existing one just run "hi" on it and make the changes you want in your new template
- Because the template is a valid package you can use cabal build (and cabal test) to check it
- cabal-src-install can be used to install templates locally