From: Neil Smith Date: Sun, 3 Dec 2017 11:47:03 +0000 (+0000) Subject: More tweaks to cabal and readme file X-Git-Url: https://git.njae.me.uk/?p=advent-of-code-17.git;a=commitdiff_plain;h=01d3c73db8c1622ea9d1786c5cbac95289da5ba9 More tweaks to cabal and readme file --- diff --git a/README.html b/README.html index 50c66bb..58b7faf 100644 --- a/README.html +++ b/README.html @@ -16,37 +16,39 @@

Learn you a Haskell, Introduction to Haskell 98, and Hackage are good resources.

The Stack documentation and How I Start: Haskell are good sources of using the tools.

Toolchain

-

I'm using the basic Haskell Platform installation, togeher with Stack to manage the packages and dependencies (install with

+

I'm using the basic Haskell Platform installation, togeher with stack to manage the packages and dependencies (install with

$ sudo aptitude install haskell-platform haskell-stack

).

Creating the repository and project

Create the repository as normal: create the project in Gitolite, clone it, and insert the .gitignore and README.md files.

-

Within the project directory, there will be one package for each day. This will save time waiting for stack to check every executable before compiling what's changed. Each package needs a separate directory tree and a separate .cabal file.

-

Creating the first package

-

Then create the basic stack project with it. This will create a new directory. Note that this new directory name can't have a hyphen-delimited word that's just digits, so the initial project will have to be adventofcode1701

-
stack new adventofcode1701 simple
-

This project will be demoted to being a package, but one that will hold the overall project.

-

Then create the top-level stack.yaml file to hold the overall project information.

-
stack init
-

Modify this top-level stack.yaml file as needed, such as adding the ghc-options stanza. You can then delete adventofcode1701/stack.yaml.

-

Creating subsequent packages

-

Each package needs a separate directory tree and a separate .cabal file.

-

To work on a project, cd into that project's directory.

+

There's just one package, with the code in sub-directories of the src directory. Each day will generate one (or more) entries in the adventofcode17.cabal file.

+

Create the basic stack project. This will create a new directory. Note that this new directory name can't have a hyphen-delimited word that's just digits, so the project will have to be advent-of-code

+
stack new advent-of-code --bare simple
+

Modify the stack.yaml file as needed, such as adding the ghc-options stanza.

+

Creating subsequent days

+

Each day lives in a separate directory within the src directory. It will also need it's own stanza in advent-of-code.cabal.

Compile with

stack build

or

-
stack build adventofcode1701
+
stack build advent01

Run with

stack exec advent01

Run interactively with

-
stack ghci adventofcode1701:exe:advent01
+
stack ghci advent-of-code:exe:advent01

To profile, use

stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto -rtsopts" adventofcode1601

then run with

stack exec -- advent01 +RTS -p -hy
+

Packages

+

Stack is using the 9.14-lts resolver for packages, so make sure you read the correct documentation for the packages included in it.

+

When you use a new package, use

+
stack solver
+

to see how the stack.yaml file needs to change, and

+
stack solver --update-yaml
+

to implement the changes.

IHaskell

Install following the IHaskell instructions.

-

To run, change into the package's directory (after modifying the .cabal file) and run it with

+

Run it with

stack exec jupyter -- notebook

Readme

Build this readme file wth

diff --git a/README.md b/README.md index 1561e11..1556de0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The [Stack documentation](https://docs.haskellstack.org/en/stable/README/) and [ # Toolchain -I'm using the basic Haskell Platform installation, togeher with `Stack` to manage the packages and dependencies (install with +I'm using the basic Haskell Platform installation, togeher with `stack` to manage the packages and dependencies (install with ``` $ sudo aptitude install haskell-platform haskell-stack ``` @@ -20,30 +20,19 @@ $ sudo aptitude install haskell-platform haskell-stack ## Creating the repository and project Create the repository as normal: create the project in Gitolite, clone it, and insert the `.gitignore` and `README.md` files. -Within the project directory, there will be one package for each day. This will save time waiting for `stack` to check every executable before compiling what's changed. Each package needs a separate directory tree and a separate `.cabal` file. +There's just one package, with the code in sub-directories of the `src` directory. Each day will generate one (or more) entries in the `adventofcode17.cabal` file. -## Creating the first package -Then create the basic `stack` project with it. This will create a new directory. Note that this new directory name can't have a hyphen-delimited word that's just digits, so the initial project will have to be `adventofcode1701` +Create the basic `stack` project. This will create a new directory. Note that this new directory name can't have a hyphen-delimited word that's just digits, so the project will have to be `advent-of-code` ``` -stack new adventofcode1701 simple +stack new advent-of-code --bare simple ``` -This project will be demoted to being a package, but one that will hold the overall project. +Modify the `stack.yaml` file as needed, such as adding the `ghc-options` stanza. -Then create the top-level `stack.yaml` file to hold the overall project information. +## Creating subsequent days -``` -stack init -``` - -Modify this top-level `stack.yaml` file as needed, such as adding the `ghc-options` stanza. You can then delete `adventofcode1701/stack.yaml`. - -## Creating subsequent packages - -Each package needs a separate directory tree and a separate `.cabal` file. - -To work on a project, `cd` into that project's directory. +Each day lives in a separate directory within the `src` directory. It will also need it's own stanza in `advent-of-code.cabal`. Compile with ``` @@ -51,7 +40,7 @@ stack build ``` or ``` -stack build adventofcode1701 +stack build advent01 ``` Run with @@ -61,7 +50,7 @@ stack exec advent01 Run interactively with ``` -stack ghci adventofcode1701:exe:advent01 +stack ghci advent-of-code:exe:advent01 ``` To profile, use @@ -73,11 +62,26 @@ then run with stack exec -- advent01 +RTS -p -hy ``` +# Packages + +Stack is using the [9.14-lts resolver](https://www.stackage.org/lts-9.14) for packages, so make sure you read the [correct documentation for the packages included in it](https://www.stackage.org/lts-9.14/docs). + +When you use a new package, use + +``` +stack solver +``` +to see how the `stack.yaml` file needs to change, and +``` +stack solver --update-yaml +``` +to implement the changes. + # IHaskell Install following the [IHaskell instructions](https://github.com/gibiansky/IHaskell). -To run, change into the package's directory (after modifying the `.cabal` file) and run it with +Run it with ``` stack exec jupyter -- notebook diff --git a/advent-of-code.cabal b/advent-of-code.cabal new file mode 100644 index 0000000..53e492c --- /dev/null +++ b/advent-of-code.cabal @@ -0,0 +1,41 @@ +name: advent-of-code +version: 17.1.0.0 +-- synopsis: +-- description: +homepage: https://github.com/neilnjae/advent-of-code-17#readme +license: BSD3 +license-file: LICENSE +author: Neil Smith +maintainer: noone@njae.me.uk +copyright: 2017 Neil Smith +category: None +build-type: Simple +cabal-version: >=1.10 +extra-source-files: README.md + +library + hs-source-dirs: src + build-depends: base >= 4.7 && < 5 + default-language: Haskell2010 + +executable advent01 + hs-source-dirs: src/advent01 + main-is: advent01.hs + default-language: Haskell2010 + build-depends: base >= 4.7 && < 5 + , parsec + +executable advent01verbose + hs-source-dirs: src/advent01 + main-is: advent01verbose.hs + default-language: Haskell2010 + build-depends: base >= 4.7 && < 5 + , parsec + +executable advent02 + hs-source-dirs: src/advent02 + main-is: advent02.hs + default-language: Haskell2010 + build-depends: base >= 4.7 && < 5 + , parsec + , parsec-numbers diff --git a/adventofcode17.cabal b/adventofcode17.cabal deleted file mode 100644 index 0bb0202..0000000 --- a/adventofcode17.cabal +++ /dev/null @@ -1,34 +0,0 @@ -name: adventofcode17 -version: 0.1.0.0 --- synopsis: --- description: -homepage: https://github.com/neilnjae/advent-of-code-17#readme -license: BSD3 -license-file: LICENSE -author: Neil Smith -maintainer: noone@njae.me.uk -copyright: 2017 Neil Smith -category: None -build-type: Simple -cabal-version: >=1.10 -extra-source-files: README.md - -library - hs-source-dirs: src - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -executable advent01 - hs-source-dirs: src/advent01 - main-is: advent01.hs - default-language: Haskell2010 - build-depends: base >= 4.7 && < 5 - , parsec - -executable advent02 - hs-source-dirs: src/advent02 - main-is: advent02.hs - default-language: Haskell2010 - build-depends: base >= 4.7 && < 5 - , parsec - , parsec-numbers