|
| 1 | +# SeaHUG "Parallel and concurrent programming in Haskell" materials |
| 2 | + |
| 3 | +## About the book |
| 4 | + |
| 5 | +To get more information about the source text "Parallel and Concurrent |
| 6 | +Programming in Haskell" by Simon Marlow, please visit the [book's web |
| 7 | +site][book]. You can purchase the book or read it online there for free. |
| 8 | + |
| 9 | +## Installing stack |
| 10 | + |
| 11 | +Stack is a tool for downloading, installing, and building haskell projects. It |
| 12 | +takes care of handling multiple compiler versions, and supports sandboxing |
| 13 | +sharing build results between projects. |
| 14 | + |
| 15 | +### Windows 64bit |
| 16 | + |
| 17 | +Download and run the installer from |
| 18 | +[here](https://www.stackage.org/stack/windows-x86_64-installer). |
| 19 | + |
| 20 | +Also, take a look at the instructions |
| 21 | +[here](http://docs.haskellstack.org/en/stable/install_and_upgrade/#windows). |
| 22 | +While not strictly necessary, it is a good idea to use `set |
| 23 | +STACK_ROOT=c:\stack_root` with stack, due to windows MAX_PATH restrictions. |
| 24 | + |
| 25 | +### Mac OS |
| 26 | + |
| 27 | +``` |
| 28 | +brew install haskell-stack |
| 29 | +``` |
| 30 | + |
| 31 | +### Linux 64bit |
| 32 | + |
| 33 | +There are also distribution specific versions (see the "Other" section below), |
| 34 | +but I find this to be the most straightforward way to get a recent version: |
| 35 | + |
| 36 | +``` |
| 37 | +wget https://github.com/commercialhaskell/stack/releases/download/v1.0.4/stack-1.0.4-linux-x86_64.tar.gz |
| 38 | +mkdir -p ~/.local/bin |
| 39 | +tar -xvf stack-1.0.4-linux-x86_64.tar.gz |
| 40 | +mv stack-1.0.4-linux-x86_64/stack ~/.local/bin/stack |
| 41 | +
|
| 42 | +# Optionally, remove the archive and its unpacked dir |
| 43 | +rm -r stack-1.0.4-linux-x86_64 |
| 44 | +rm stack-1.0.4-linux-x86_64.tar.gz |
| 45 | +``` |
| 46 | + |
| 47 | +Then, try `which stack`. If the response is not the `.local/bin/stack` folder |
| 48 | +within your home directory, then you will need to add `.local/bin/stack` to your |
| 49 | +PATH. To do this, add the following to your `~/.profile`, and then start a new |
| 50 | +terminal: |
| 51 | + |
| 52 | +``` |
| 53 | +if [ -d "$HOME/.local/bin" ] ; then |
| 54 | + PATH="$HOME/.local/bin:$PATH" |
| 55 | +fi |
| 56 | +``` |
| 57 | + |
| 58 | +### Other |
| 59 | + |
| 60 | +See the installation instructions |
| 61 | +[here](http://docs.haskellstack.org/en/stable/install_and_upgrade/). |
| 62 | + |
| 63 | +## Cloning this repo and setting up your environment |
| 64 | + |
| 65 | +Clone this repo as follows: |
| 66 | + |
| 67 | +``` |
| 68 | +git clone https://github.com/seahug/parconc-examples.git |
| 69 | +``` |
| 70 | + |
| 71 | +We then ask stack to set up an appropriate version of GHC: |
| 72 | + |
| 73 | +``` |
| 74 | +cd pcph/ |
| 75 | +stack setup |
| 76 | +``` |
| 77 | + |
| 78 | +## Loading examples into ghci |
| 79 | + |
| 80 | +Usually we'll only want to load up a single example at a time. `stack ghci` is |
| 81 | +a good way to do this: |
| 82 | + |
| 83 | +``` |
| 84 | +mgsloan@computer:~/oss/seahug/pcph$ stack ghci --no-build :parmonad |
| 85 | +There were multiple candidates for the Cabal entry "Lex" (/home/mgsloan/oss/seahug/pcph/examples/parinfer/Lex.x), picking /home/mgsloan/oss/seahug/pcph/examples/parinfer/Lex.hs |
| 86 | +There were multiple candidates for the Cabal entry "Parse" (/home/mgsloan/oss/seahug/pcph/examples/parinfer/Parse.y), picking /home/mgsloan/oss/seahug/pcph/examples/parinfer/Parse.hs |
| 87 | +There were multiple candidates for the Cabal entry "Lex" (/home/mgsloan/oss/seahug/pcph/examples/parinfer/Lex.x), picking /home/mgsloan/oss/seahug/pcph/examples/parinfer/Lex.hs |
| 88 | +There were multiple candidates for the Cabal entry "Parse" (/home/mgsloan/oss/seahug/pcph/examples/parinfer/Parse.y), picking /home/mgsloan/oss/seahug/pcph/examples/parinfer/Parse.hs |
| 89 | +The following GHC options are incompatible with GHCi and have not been passed to it: -threaded |
| 90 | +Using main module: 1. Package `parconc-examples' component exe:parmonad with main-is file: /home/mgsloan/oss/seahug/pcph/examples/parmonad.hs |
| 91 | +Configuring GHCi with the following packages: parconc-examples |
| 92 | +GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help |
| 93 | +Loading package ghc-prim ... linking ... done. |
| 94 | +Loading package integer-gmp ... linking ... done. |
| 95 | +Loading package base ... linking ... done. |
| 96 | +Loading package array-0.5.0.0 ... linking ... done. |
| 97 | +Loading package deepseq-1.3.0.2 ... linking ... done. |
| 98 | +Loading package containers-0.5.5.1 ... linking ... done. |
| 99 | +Loading package old-locale-1.0.0.6 ... linking ... done. |
| 100 | +Loading package time-1.4.2 ... linking ... done. |
| 101 | +Loading package random-1.0.1.1 ... linking ... done. |
| 102 | +Loading package abstract-deque-0.3 ... linking ... done. |
| 103 | +Loading package abstract-par-0.3.3 ... linking ... done. |
| 104 | +Loading package bytestring-0.10.4.0 ... linking ... done. |
| 105 | +Loading package cereal-0.4.1.1 ... linking ... done. |
| 106 | +Loading package transformers-0.3.0.0 ... linking ... done. |
| 107 | +Loading package mtl-2.1.3.1 ... linking ... done. |
| 108 | +Loading package monad-par-extras-0.3.3 ... linking ... done. |
| 109 | +Loading package primitive-0.6.1.0 ... linking ... done. |
| 110 | +Loading package vector-0.10.12.3 ... linking ... done. |
| 111 | +Loading package mwc-random-0.13.4.0 ... linking ... done. |
| 112 | +Loading package parallel-3.2.0.6 ... linking ... done. |
| 113 | +Loading package monad-par-0.3.4.7 ... linking ... done. |
| 114 | +unknown option: 'c' |
| 115 | +[1 of 1] Compiling Main ( /home/mgsloan/oss/seahug/pcph/examples/parmonad.hs, interpreted ) |
| 116 | +Ok, modules loaded: Main. |
| 117 | +*Main> :set args 4 5 |
| 118 | +*Main> main |
| 119 | +13 |
| 120 | +*Main> :t fib |
| 121 | +fib :: Integer -> Integer |
| 122 | +*Main> :bro |
| 123 | +fib :: Integer -> Integer |
| 124 | +main :: IO () |
| 125 | +``` |
| 126 | + |
| 127 | +## Building all examples |
| 128 | + |
| 129 | +To build optimized versions of the examples, run `stack build`. Then, you can |
| 130 | +run the example by name by using `stack exec`. For example, `stack exec -- |
| 131 | +parmonad 4 5`. |
| 132 | + |
| 133 | +# License |
| 134 | + |
| 135 | +Released under MIT License |
| 136 | + |
| 137 | +[book]: http://chimera.labs.oreilly.com/books/1230000000929 |
| 138 | +[cabal-install]: https://wiki.haskell.org/Cabal-Install |
| 139 | +[docker-install]: https://docs.docker.com/engine/installation/ |
| 140 | +[docker]: https://www.docker.com/ |
| 141 | +[ghc]: https://www.haskell.org/downloads |
| 142 | +[gnu-make]: https://www.gnu.org/software/make/ |
| 143 | +[haskell-docker]: https://hub.docker.com/_/haskell/ |
| 144 | +[network-windows]: http://neilmitchell.blogspot.com/2010/12/installing-haskell-network-library-on.html |
| 145 | +[official]: http://chimera.labs.oreilly.com/books/1230000000929/ch01.html#sec_sample |
0 commit comments