Friday, March 5, 2010

ProjectTemplate - a template-based tool for creating Haskell projects

Yesterday I created 5 projects, and found many boilerplate code on preparing cabal files, Setup.hs and directory structure. So I decided to simplify project creation for haskellers and created ProjectTemplate.

I was inspired by the Don’s mkcabal tool, and created the similar dialog-based application.

mkcabal, created by Don, is very simple tool, and it helps, when you start using Haskell, but this tool hasn’t any configuration and personalization of Haskell project, so I every time after creating project with mkcabal make some changes in the directory structure and file names.

ProjectTemplate is the template-based project creation tool. It was developed for ease creation of Haskell projects, but now I see, it could ease creation different directory structures, based on templates (for example web sites).

Templates are directories with files it them, which will be copied to the newly created project. Each template could contain complex directory hierarchy. Each file/directory name could be the plain name, or template name. Template name is created from the double underscore and parameter name, and in the project directory is substituted to the parameter value.

For example __ProjectName.cabal file with ProjectName parameter set to test, will be substituted to test.cabal. The same is true for directories.

ProjectTemplate also fills template files, where substitutes parameters to their values. The template file should have .template extension, which will be cut of in the destination file. In the template file parameters are enclosed in $ character. The example cabal file, with template parameters could look like:

name:                $ProjectName$
version: 0.1
synopsis:
description:
category: $Category$
license: BSD3
license-file: LICENSE
author: $Author$
maintainer: $Maintainer$
build-depends: base
build-type: Simple

executable: $ProjectName$
main-is: src/Main.hs
ghc-options:

ProjectTemplate defines following parameters: ProjectName, Day, Month, Year. All other parameters will be asked to user during the project creation.

You could look at sample templates in the ProjectTemplate repository, to better understanding how this tool works.

No comments:

Post a Comment