packages feed

parconc-examples-0.4.8: parconc-examples.cabal

cabal-version:       2.2
name:                parconc-examples
version:             0.4.8
synopsis:            Examples to accompany the book "Parallel and Concurrent Programming in Haskell"
description:         Examples to accompany the book "Parallel and Concurrent Programming in Haskell"
license:             BSD-3-Clause
license-file:        LICENSE
author:              Simon Marlow
maintainer:          Simon Marlow <marlowsd@gmail.com>
copyright:           (c) Simon Marlow 2011-2013
category:            Sample Code
build-type:          Simple
bug-reports:         https://github.com/simonmar/parconc-examples/issues
homepage:            http://github.com/simonmar/parconc-examples

extra-source-files:  sudoku17.1000.txt
                     sudoku17.16000.txt
                     sudoku17.49151.txt
                     chanbench.hs
                     findpar5.hs
                     parlist.hs
                     other/correcter.hs
                     other/arithgame.hs
                     other/game.hs
                     other/README
                     distrib-db/WorkerSample.hs
                     distrib-db/DatabaseSample.hs
                     sudoku-par1.hs
                     sudoku-par2.hs
                     sudoku-par3.hs
                     sudoku-par4.hs
                     kmeans/Makefile
                     timeout2.hs
                     parinfer/benchmark.in
                     tmvar.hs
                     windowman.hs
                     ChangeLog.md
                     README.md

source-repository head
    type:     git
    location: https://github.com/simonmar/parconc-examples.git

-- -----------------------------------------------------------------------------
-- Flags

-- -f llvm: enable -fllvm to GHC; requires LLVM to be installed, but
-- makes the Repa programs faster

flag llvm
  default: False

-- -f devil: Enable the image-maniputation programs, which are
-- disabled by default because they require the devil library which
-- needs to be installed separately.

flag devil
  default: False

-- -f cuda: Build the examples that require accelerate-cuda.  These
-- need the NVidia CUDA tools installed.

flag cuda
  default: False

-- -f-accelerate: Do not build the examples that require accelerate.

flag accelerate
  default : True

-- -f-distributed: Do not build the examples that require distributed-process.

flag distributed
  default : True

-- -f network26: Use network-2.6.  Internal flag; you shouldn't need
-- to change this.

flag network26
  default : True

common deps
  default-language: Haskell2010
  build-depends:
     array >= 0.4 && <0.6,
     async >= 2.0 && < 2.3,
     base >= 4.5 && < 4.14,
     binary >=0.6.3 && < 0.11,
     bytestring >= 0.9 && < 0.12,
     containers >= 0.4 && < 0.6,
     deepseq >= 1.3 && < 1.5,
     directory >= 1.1 && < 1.4,
     filepath >= 1.3 && < 1.5,
     monad-par >= 0.3.4 && < 0.4,
       -- monad-par 0.3 has a bug:
       -- https://github.com/simonmar/monad-par/issues/23
     parallel ==3.2.*,
     random >= 1.0 && < 1.3,
     stm >=2.4 && < 2.6,
     time >= 1.4 && < 1.12,
     template-haskell >= 2.7 && < 2.16,
     transformers >=0.3 && <0.6,
     utf8-string >= 0.3 && < 1.1,
     vector >= 0.10 && < 0.13,
     xml ==1.3.*,

common network
  if flag(network26)
      build-depends: network >= 2.6 && < 2.9
                   , network-uri >= 2.6 && < 2.7
  else
      build-depends: network >= 2.3 && < 2.6

common http
  build-depends:
    http-conduit >= 2.1 && < 2.4

common monad-par
  build-depends:
    abstract-par ==0.3.*,
    monad-par >= 0.3.4 && < 0.4

common distributed
  if flag(distributed)
     build-depends:
                   distributed-process >= 0.5 && < 0.8
                 , distributed-process-simplelocalnet ==0.2.*
                 , distributed-static >= 0.2 && < 0.4
  else
     buildable: False
  if impl(ghc <= 7.6)
      -- prior to ghc-7.4 generics lived in ghc-prim
      build-depends: ghc-prim

-- -----------------------------------------------------------------------------
-- par-eval

executable rpar
  import: deps
  main-is: rpar.hs
  ghc-options: -threaded

executable sudoku1
  import: deps
  main-is: sudoku1.hs
  other-modules: Sudoku

executable sudoku2
  import: deps
  main-is: sudoku2.hs
  other-modules: Sudoku
  ghc-options: -threaded

executable sudoku3
  import: deps
  main-is: sudoku3.hs
  other-modules: Sudoku
  ghc-options: -threaded

executable sudoku4
  import: deps
  main-is: sudoku4.hs
  other-modules: Sudoku
  ghc-options: -threaded

executable sudoku5
  import: deps
  main-is: sudoku5.hs
  other-modules: Sudoku
  ghc-options: -threaded

-- -----------------------------------------------------------------------------
-- par-strat

executable strat
  import: deps
  main-is: strat.hs
  ghc-options: -threaded

executable strat2
  import: deps
  main-is: strat2.hs
  ghc-options: -threaded

executable strat3
  import: deps
  main-is: strat3.hs
  ghc-options: -threaded

executable rsa
  import: deps
  main-is: rsa.hs
  other-modules: ByteStringCompat

executable rsa1
  import: deps
  main-is: rsa1.hs
  other-modules: ByteStringCompat
  ghc-options: -threaded

executable rsa2
  import: deps
  main-is: rsa2.hs
  other-modules: ByteStringCompat
  ghc-options: -threaded

executable kmeans
  import: deps
  hs-source-dirs: kmeans
  main-is: kmeans.hs
  other-modules: KMeansCore
  ghc-options: -threaded

executable GenSamples
  import: deps
  hs-source-dirs: kmeans
  main-is: GenSamples.hs
  other-modules: KMeansCore
  build-depends: normaldistribution >= 1.1 && < 1.2

-- -----------------------------------------------------------------------------
-- par-monad

executable parmonad
  import: deps
  main-is: parmonad.hs
  ghc-options: -threaded

executable rsa-pipeline
  import: deps
  main-is: rsa-pipeline.hs
  other-modules: ByteStringCompat Stream
  ghc-options: -threaded

executable fwsparse
  import: deps
  main-is: fwsparse.hs
  other-modules: SparseGraph MapCompat
  hs-source-dirs: fwsparse

executable fwsparse1
  import: deps
  main-is: fwsparse1.hs
  other-modules: SparseGraph MapCompat
  hs-source-dirs: fwsparse
  ghc-options: -threaded

executable  timetable
  import: deps
  main-is: timetable.hs

executable  timetable1
  import: deps
  main-is: timetable1.hs

executable  timetable2
  import: deps
  main-is: timetable2.hs

executable  timetable3
  import: deps
  main-is: timetable3.hs

executable  parinfer
  import: deps
  main-is: parinfer.hs
  hs-source-dirs: parinfer
  other-modules:  InferMonad
                  Term
                  FiniteMap
                  Shows
                  Environment
                  Lex
                  MaybeM
                  Parse
                  MyList
                  Type
                  Infer
                  Substitution
                  StateX
  build-tool-depends: alex:alex, happy:happy

-- -----------------------------------------------------------------------------
-- par-repa

executable  fwdense
  import: deps
  main-is: fwdense.hs
  build-depends:
    repa >= 3.2 && < 3.5
  ghc-options: -O2
  if flag(llvm)
     ghc-options: -fllvm

executable  fwdense1
  import: deps
  main-is: fwdense1.hs
  build-depends:
    repa >= 3.2 && < 3.5
  ghc-options: -O2 -threaded
  if flag(llvm)
     ghc-options: -fllvm

executable rotateimage
  import: deps
  main-is: rotateimage.hs
  build-depends:
    repa >= 3.2 && < 3.5
  ghc-options: -O2 -threaded
  if flag(devil)
     build-depends: repa-devil == 0.3.*
  else
     buildable: False
  if flag(llvm)
     ghc-options: -fllvm

-- -----------------------------------------------------------------------------
-- par-accel

executable  fwaccel
  import: deps
  main-is: fwaccel.hs
  other-modules: AccelerateCompat
  ghc-options: -O2
  if flag(accelerate)
     build-depends: accelerate >= 0.12 && < 1.3
  else
     buildable: False

executable  fwaccel-gpu
  import: deps
  main-is: fwaccel-gpu.hs
  if flag(accelerate)
     build-depends: accelerate >= 0.12 && < 1.3
  else
     buildable: False
  if flag(cuda)
     build-depends: accelerate-cuda >= 0.12 && < 0.15
  else
     buildable: False
  ghc-options: -O2

executable  mandel
  import: deps
  main-is: mandel.hs
  other-modules: Config
  hs-source-dirs: mandel
  build-depends:   fclabels
  if flag(accelerate)
     build-depends: accelerate >= 0.12 && < 1.3
                  , accelerate-io
  else
     buildable: False
  if flag(cuda)
     build-depends: accelerate-cuda >= 0.12 && < 0.15
  else
     buildable: False
  ghc-options: -O2

-- -----------------------------------------------------------------------------
-- conc-fork

executable  fork
  import: deps
  main-is: fork.hs

executable  reminders
  import: deps
  main-is: reminders.hs

executable  reminders2
  import: deps
  main-is: reminders2.hs

-- -----------------------------------------------------------------------------
-- conc-mvar

executable  mvar1
  import: deps
  main-is: mvar1.hs

executable  mvar2
  import: deps
  main-is: mvar2.hs

executable  mvar3
  import: deps
  main-is: mvar3.hs

executable  logger
  import: deps
  main-is: logger.hs

executable  phonebook
  import: deps
  main-is: phonebook.hs

executable  chan
  import: deps
  main-is: chan.hs

executable  chan2
  import: deps
  main-is: chan2.hs

-- -----------------------------------------------------------------------------
-- conc-overlap

executable geturls1
  import: deps, network, http
  main-is: geturls1.hs
  other-modules: GetURL

executable  geturls2
  import: deps, network, http
  main-is: geturls2.hs
  other-modules: GetURL

executable  geturls3
  import: deps, network, http
  main-is: geturls3.hs
  other-modules: TimeIt GetURL

executable  geturls4
  import: deps, network, http
  main-is: geturls4.hs
  other-modules: GetURL

executable  geturls5
  import: deps, network, http
  main-is: geturls5.hs
  other-modules: GetURL

executable  geturls6
  import: deps, network, http
  main-is: geturls6.hs
  other-modules: TimeIt GetURL

-- -----------------------------------------------------------------------------
-- conc-asyncex

executable  geturlscancel
  import: deps, network, http
  main-is: geturlscancel.hs
  other-modules: TimeIt GetURL

executable  geturlscancel2
  import: deps, network, http
  main-is: geturlscancel2.hs
  other-modules: TimeIt GetURL

executable  modifytwo
  import: deps
  main-is: modifytwo.hs

executable  chan3
  import: deps
  main-is: chan3.hs

executable  timeout
  import: deps
  main-is: timeout.hs

executable  catch-mask
  import: deps
  main-is: catch-mask.hs

executable  catch-mask2
  import: deps
  main-is: catch-mask2.hs

-- -----------------------------------------------------------------------------
-- conc-stm

-- NB. The book refers to "tmvar.hs" and "windowmanager.hs", so we
-- can't change rename these files.  However, we need to use proper
-- upper-case module names, so we use symbolic links from a
-- subdirectory (mismodules) so that the repo remains safe to use on
-- case-insensitive filesystems (#15).
executable  miscmodules
  import: deps
  main-is: miscmodules.hs
  hs-source-dirs: miscmodules .
  other-modules: TMVar, TList, TQueue, TBQueue, WindowManager

executable  geturlsfirst
  import: deps, network, http
  main-is: geturlsfirst.hs
  other-modules: ConcurrentUtils, GetURL

executable  TChan
  import: deps
  main-is: TChan.hs

-- -----------------------------------------------------------------------------
-- conc-higher

executable  geturls7
  import: deps, network, http
  main-is: geturls7.hs
  other-modules: ConcurrentUtils, GetURL

executable  geturls8
  import: deps, network, http
  main-is: geturls8.hs
  other-modules: Async, GetURL

executable  geturls9
  import: deps, network, http
  main-is: geturls9.hs
  other-modules: Async, GetURL

executable  timeout2
  import: deps
  main-is: timeout.hs

-- -----------------------------------------------------------------------------
-- conc-par

executable findseq
  import: deps
  main-is: findseq.hs

executable findpar
  import: deps
  main-is: findpar.hs
  ghc-options: -threaded

executable findpar2
  import: deps
  main-is: findpar2.hs
  ghc-options: -threaded

executable findpar3
  import: deps
  main-is: findpar3.hs
  other-modules: CasIORef
  ghc-options: -threaded

executable findpar4
  import: deps, monad-par
  main-is: findpar4.hs
  ghc-options: -threaded

executable findpar5
  import: deps, monad-par
  main-is: findpar5.hs
  ghc-options: -threaded

-- -----------------------------------------------------------------------------
-- conc-server

executable  server
  import: deps, network
  main-is: server.hs
  other-modules: ConcurrentUtils

executable  server2
  import: deps, network
  main-is: server2.hs
  other-modules: ConcurrentUtils

executable chat
  import: deps, network
  main-is: chat.hs
  other-modules: ConcurrentUtils

-- -----------------------------------------------------------------------------
-- conc-distrib

executable ping
  import: deps, network, distributed
  main-is: distrib-ping/ping.hs
  other-modules: DistribUtils

executable ping-multi
  import: deps, network, distributed
  main-is: distrib-ping/ping-multi.hs
  other-modules: DistribUtils

executable ping-tc
  import: deps, network, distributed
  main-is: distrib-ping/ping-tc.hs
  other-modules: DistribUtils

executable ping-tc-merge
  import: deps, network, distributed
  main-is: distrib-ping/ping-tc-merge.hs
  other-modules: DistribUtils

-- extra, not in the text?
executable ping-tc-notify
  import: deps, network, distributed
  main-is: distrib-ping/ping-tc-notify.hs
  other-modules: DistribUtils

executable ping-fail
  import: deps, network, distributed
  main-is: distrib-ping/ping-fail.hs
  other-modules: DistribUtils

executable distrib-chat
  import: deps, network, distributed
  main-is: distrib-chat/chat.hs
  other-modules: ConcurrentUtils DistribUtils

executable distrib-chat-noslave
  import: deps, network, distributed
  main-is: distrib-chat/chat-noslave.hs
  other-modules: ConcurrentUtils

executable distrib-db
  import: deps, network, distributed
  main-is: db.hs
  hs-source-dirs: . distrib-db
  other-modules: DistribUtils Database

-- -----------------------------------------------------------------------------
-- conc-debugging-tuning

executable  mvar4
  import: deps
  main-is: mvar4.hs

executable  deadlock1
  import: deps
  main-is: deadlock1.hs

executable  deadlock2
  import: deps
  main-is: deadlock2.hs

executable  threadperf1
  import: deps
  main-is: threadperf1.hs

executable  threadperf2
  import: deps
  main-is: threadperf2.hs
  ghc-options: -rtsopts

-- -----------------------------------------------------------------------------
-- Extras (exercises etc.)

executable  bingtranslator
  import: deps, network, http
  main-is: bingtranslator.hs
  other-modules: BingTranslate GetURL
  hs-source-dirs: other .

executable  bingtranslatorconc
  import: deps, network, http
  main-is: bingtranslatorconc.hs
  other-modules: BingTranslate GetURL
  hs-source-dirs: other .

executable  geturlsstm
  import: deps, network, http
  main-is: geturlsstm.hs
  other-modules: TimeIt GetURL

-- ToDo:
--   euler35
--   index
--   sudoku-par{1,2,3,4,5}