Skip to content

Instantly share code, notes, and snippets.

@mkscrg
Created December 26, 2013 22:56
Show Gist options
  • Save mkscrg/8139812 to your computer and use it in GitHub Desktop.
Save mkscrg/8139812 to your computer and use it in GitHub Desktop.
Start a new Cabal project with minimal sane defaults.
#!/usr/bin/env bash
set -e
template='name: $$NAME$$
version: 0.0.0
build-type: Simple
cabal-version: >= 1.9.2
executable $$NAME$$
main-is: Main.hs
hs-source-dirs: src
ghc-options: -Wall -O2
-- extensions:
build-depends:
base >= 4.6 && < 4.7
'
main='module Main where
main :: IO ()
main = putStrLn "hello world"
'
gitignore='dist/
.cabal-sandbox
cabal.sandbox.config
'
if [[ -z "$1" ]]; then
name="$(basename "$(pwd)")"
else
name="$1"
fi
name="$(echo "$name" | sed -e 's/ /-/g')"
echo -n "$template" | sed -e 's/\$\$NAME\$\$/'"$name"'/g' > ${name}.cabal
echo "Wrote ${name}.cabal"
mkdir src && echo -n "$main" > src/Main.hs
echo "Wrote src/Main.hs"
echo -n "$gitignore" > .gitignore
echo "Wrote .gitignore"
cabal sandbox init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment