[Haskell-cafe] Starting your own Haskell project: part 2

Donald Bruce Stewart dons at cse.unsw.edu.au
Sun Nov 19 07:54:03 EST 2006


dagit:
> On 11/19/06, Dougal Stanton <ithika at gmail.com> wrote:
> >Quoth Donald Bruce Stewart, nevermore,
> >> P.S. It might even be useful to have a tool, haskell-project, which
> >> sets up all these files automatically.
> >
> >I was wondering about that just the other day. Is there such an
> >application to interrogate the user about particulars and then create a
> >fully compliant *.cabal file?
> 
> I'm unaware of such a tool, but as far as UIs go, it should be fairly

Ok, done!

    darcs get http://www.cse.unsw.edu.au/~dons/code/mkcabal

mkcabal creates a new project directory for an executable, populates
with cabal files, setup.hs and a stub .hs file, based on the project
name.

A transcript:
    
    $ mkcabal 
    Project name: haq
    Created new project directory: haq

    $ cd haq
    $ ls
    Haq.hs    Setup.hs  haq.cabal

    $ cat Haq.hs
    main :: IO ()
    main = putStrLn "Hello, world!"

    $ cat Setup.hs 
    #!/usr/bin/env runhaskell
    import Distribution.Simple
    $ cat haq.cabal 
    Name:                haq
    Version:             0.0
    Description:         Project description
    License:             BSD3
    License-file:        LICENSE
    Author:              Author Name
    Maintainer:          user at email.address
    Build-Depends:       base
     
    Executable:          haq
    Main-is:             Haq.hs

    $ c
    Configuring haq-0.0...
    ...

    $ b
    Preprocessing executables for haq-0.0...
    Building haq-0.0...
    [1 of 1] Compiling Main             ( Haq.hs, /usr/obj/cabal/haq/haq-tmp/Main.o )
    Linking /usr/obj/cabal/haq/haq ...

And we're in business.

We could be smarter and figure out more defaults, and generate some stub
quickcheck and haddock details. We could also init and create the
project in a darcs directory.

Comments, suggestions *and patches* welcome!

-- Don


More information about the Haskell-Cafe mailing list