commit 6fddba48223c2d3c08af887ffc798e47221676da Author: Yann Esposito (Yogsototh) Date: Fri Nov 15 00:25:55 2013 +0100 initial commit (does not work yet) diff --git a/init-haskell-project.sh b/init-haskell-project.sh new file mode 100755 index 0000000..a524c83 --- /dev/null +++ b/init-haskell-project.sh @@ -0,0 +1,250 @@ +#!/usr/bin/env zsh + +answer="" +ask(){ + local elem=$1 + local gitconfigelem + print -n -- "What is your $elem?" + [[ -e ~/.gitconfig ]] && { + gitconfigelem="$(< ~/.gitconfig| awk '$1 == "'$elem'" {$1="";$2="";gsub("^ *","");print}')" + [[ $gitconfigelem = "" ]] || { + print -n -- " ($gitconfigelem)" + } + } + print -n ": " + read answer + [[ $answer = "" ]] && answer=$gitconfigelem +} + +print -n -- "What is the name of your project? (start with a capital)" +read project + +err(){print -- $*>&2;exit 1} +[[ $project = "" ]] && err "Can't use empty project name" +[[ -e $project ]] && err "$project already exists" + +ask name +name="$answer" +ask email +email="$answer" +print -n -- "A short description of the project: " +read description +print -n -- "What is your github user name? " +read github +mkdir $project +cd $project + +git init . + +print -- ".gitignore" +>.gitignore cat < $project.cabal cat <=1.10 + +executable yml + main-is: Main.hs + -- other-modules: + -- other-extensions: + build-depends: base >=4.6 && <4.7 + hs-source-dirs: src + ghc-options: -Wall + default-language: Haskell2010 + +library + exposed-modules: $project + , $project.Foo + , $project.Bar + -- other-modules: + -- other-extensions: + build-depends: base >=4.6 && <4.7 + ghc-options: -Wall + hs-source-dirs: src + default-language: Haskell2010 + +executable test-yml + hs-source-dirs: test + ghc-options: -Wall + main-is: Test.hs + default-language: Haskell2010 + build-depends: base ==4.6.*, Cabal >= 1.16.0 + , $project + , HUnit + , QuickCheck + , smallcheck + , tasty + , tasty-hunit + , tasty-quickcheck + , tasty-smallcheck +test-suite Tests + hs-source-dirs: test + ghc-options: -Wall + main-is: Test.hs + Type: exitcode-stdio-1.0 + default-language: Haskell2010 + build-depends: base ==4.6.*, Cabal >= 1.16.0 + , vector + , $project + , HUnit + , QuickCheck + , smallcheck + , tasty + , tasty-hunit + , tasty-quickcheck + , tasty-smallcheck +END + +print -- "Setup.hs" +> Setup.hs cat < LICENSE cat< test/Test.hs cat < test/$project/Foo/Test.hs cat < src/$project/Foo.hs cat < String -> String +foo prefix suffix = prefix ++ suffix +END + +print -- "test/$project/Bar/Test.hs" +> test/$project/Bar/Test.hs cat < Serial m BarDataStruct where series = cons1 BarDataStruct +-- Now we could test properties with smallcheck on BarDataStruct type. + +barSuite :: TestTree +barSuite = testGroup "bar" + [ testCase "bar" testBar + , SC.testProperty "bar property" prop_bar + ] + +testCost :: Assertion +testCost = bar @=? 10 + +prop_cost_positive :: Property IO +prop_cost_positive = forAll $ \barStruct -> barfunc barStruct >= 0 +END + +print -- "src/$project/Bar.hs" +> src/$project/Bar.hs cat < Int +barfunc (BarConstr l) = length l +END + +cabal sandbox init +cabal install +cabal test