infinite negative utility

Charter

The charter tool is a basic tool for Cabal-based project scaffolding. There are a number of tools that do this—Cabal comes with the cabal init command built-in, for example, and there's also the heavily configurable hi project—but none of them had quite what I wanted, so I built my own.

It has three main modes of operation, all of which will create a directory that contains a cabal file, initialize a git repo, and build out whatever other scaffolding is required. For basic executables, you can use

$ charter quick the-thing

and it will create the-thing/the-thing.cabal and the-thing/src/Main.hs for you, with a trivial entry point, and initialize a git repo with them. For a library, you can use a similar command, with optional -m flags to add new modules

$ charter library the-thing -m This -m That.TheOther

and in addition to the-thing/the-thing.cabal, it will also create the stubbed-out library modules the-thing/src/This.hs and the-thing/src/That/TheOther.hs. Finally, for larger executables (which I prefer to implement as a wrapper executable along with a library), you can use

$ charter executable the-thing

and in addition to the-thing/the-thing.cabal, it will also create the stubbed-out library code in the-thing/src/TheThing.hs as well as stubbed-out executable code in the-thing/the-thing/Main.hs.

All of these commands can also take other flags that fill in Cabal metadata: for example, -l GPL to specify a GPL license, -d "some description" to set the package description, -a package-name to add a dependency, and so forth. You can also add extra executable stanzas with -b executable-name and modules with -m ModuleName.