Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

various fixes; organise by chapter in the .cabal file

  • Loading branch information...
commit 24c8d9ab854e191f462cbe71b23cd15cf05ac650 1 parent 2d0a842
@simonmar authored
View
2  TBQueue.hs
@@ -1,6 +1,6 @@
module TBQueue (TBQueue, newTBQueue, writeTBQueue, readTBQueue) where
-import Control.Concurrent.STM
+import Control.Concurrent.STM hiding (TBQueue, newTBQueue, writeTBQueue, readTBQueue)
-- <<TBQueue
data TBQueue a = TBQueue (TVar Int) (TVar [a]) (TVar [a]) -- <1>
View
2  chan.hs
@@ -25,8 +25,8 @@ writeChan :: Chan a -> a -> IO ()
writeChan (Chan _ writeVar) val = do
newHole <- newEmptyMVar
oldHole <- takeMVar writeVar
- putMVar writeVar newHole
putMVar oldHole (Item val newHole)
+ putMVar writeVar newHole
-- >>
-- <<readChan
View
2  chan2.hs
@@ -25,8 +25,8 @@ writeChan :: Chan a -> a -> IO ()
writeChan (Chan _ writeVar) val = do
newHole <- newEmptyMVar
oldHole <- takeMVar writeVar
- putMVar writeVar newHole
putMVar oldHole (Item val newHole)
+ putMVar writeVar newHole
-- >>
-- <<readChan
View
15 chan3.hs
@@ -21,6 +21,15 @@ newChan = do
return (Chan readVar writeVar)
-- >>
+-- <<wrongWriteChan
+wrongWriteChan :: Chan a -> a -> IO ()
+wrongWriteChan (Chan _ writeVar) val = do
+ newHole <- newEmptyMVar
+ modifyMVar_ writeVar $ \oldHole -> do
+ putMVar oldHole (Item val newHole) -- <1>
+ return newHole -- <2>
+-- >>
+
-- <<writeChan
writeChan :: Chan a -> a -> IO ()
writeChan (Chan _ writeVar) val = do
@@ -34,9 +43,9 @@ writeChan (Chan _ writeVar) val = do
-- <<readChan
readChan :: Chan a -> IO a
readChan (Chan readVar _) = do
- modifyMVar readVar $ \readEnd -> do
- (Item val newReadEnd) <- readMVar readEnd
- return (newReadEnd, val)
+ modifyMVar readVar $ \stream -> do
+ Item val tail <- readMVar stream
+ return (tail, val)
-- >>
main = do
View
2  findpar4.hs
@@ -7,8 +7,8 @@ import Data.List hiding (find)
import GHC.Conc (getNumCapabilities)
import Text.Printf
-import Control.Monad.Par hiding (runParIO)
import Control.Monad.Par.IO
+import Control.Monad.Par.Class
import Control.Monad.IO.Class
import Control.Exception
View
2  modifytwo.hs
@@ -1,9 +1,11 @@
import Control.Concurrent
+-- <<modifyTwo
modifyTwo :: MVar a -> MVar b -> (a -> b -> IO (a,b)) -> IO ()
modifyTwo ma mb f =
modifyMVar_ mb $ \b ->
modifyMVar ma $ \a -> f a b
+-- >>
main = do
ma <- newMVar 'a'
View
511 parconc-examples.cabal
@@ -11,6 +11,177 @@ category: Sample Code
build-type: Simple
cabal-version: >=1.10
+-- -----------------------------------------------------------------------------
+-- par-eval
+
+executable sudoku1
+ main-is: sudoku1.hs
+ build-depends: base >= 4.5 && < 4.7
+ , parallel ==3.2.*
+ , array ==0.4.*
+ default-language: Haskell2010
+
+executable sudoku2
+ main-is: sudoku2.hs
+ build-depends: base >= 4.5 && < 4.7
+ , parallel ==3.2.*
+ , array ==0.4.*
+ , deepseq ==1.3.*
+ ghc-options: -threaded
+ default-language: Haskell2010
+
+executable sudoku3
+ main-is: sudoku3.hs
+ build-depends: base >= 4.5 && < 4.7
+ , parallel ==3.2.*
+ , array ==0.4.*
+ ghc-options: -threaded
+ default-language: Haskell2010
+
+executable sudoku4
+ main-is: sudoku4.hs
+ build-depends: base >= 4.5 && < 4.7
+ , parallel ==3.2.*
+ , array ==0.4.*
+ ghc-options: -threaded
+ default-language: Haskell2010
+
+-- -----------------------------------------------------------------------------
+-- par-strat
+
+executable rsa
+ main-is: rsa.hs
+ build-depends: base >= 4.5 && < 4.7
+ , bytestring >= 0.10 && < 0.11
+ default-language: Haskell2010
+
+executable rsa1
+ main-is: rsa1.hs
+ build-depends: base >= 4.5 && < 4.7
+ , bytestring >= 0.10 && < 0.11
+ -- bytestring-0.10 needed to get instance NFData ByteString
+ , parallel ==3.2.*
+ ghc-options: -threaded
+ default-language: Haskell2010
+
+executable rsa2
+ main-is: rsa2.hs
+ build-depends: base >= 4.5 && < 4.7
+ , bytestring >= 0.10 && < 0.11
+ -- bytestring-0.10 needed to get instance NFData ByteString
+ , parallel ==3.2.*
+ ghc-options: -threaded
+ default-language: Haskell2010
+
+executable kmeans
+ hs-source-dirs: kmeans
+ main-is: kmeans.hs
+ build-depends: base >= 4.5 && < 4.7
+ , parallel ==3.2.*
+ , time ==1.4.*
+ , deepseq ==1.3.*
+ , monad-par >= 0.3.4 && < 0.4
+ -- monad-par 0.3 has a bug:
+ -- https://github.com/simonmar/monad-par/issues/23
+ , binary >= 0.6.3 && < 0.7
+ , array ==0.4.*
+ , bytestring >= 0.9 && < 0.11
+ , vector >= 0.10 && < 0.11
+ ghc-options: -threaded
+ default-language: Haskell2010
+
+executable GenSamples
+ hs-source-dirs: kmeans
+ main-is: GenSamples.hs
+ build-depends: base >= 4.5 && < 4.7
+ , binary >= 0.6.3 && < 0.7
+ , array ==0.4.*
+ , vector >= 0.10 && < 0.11
+ , random >= 1.0 && < 1.1
+ , normaldistribution >= 1.1 && < 1.2
+ , deepseq ==1.3.*
+ , bytestring >= 0.9 && < 0.11
+ default-language: Haskell2010
+
+-- -----------------------------------------------------------------------------
+-- par-monad
+
+executable parmonad
+ main-is: parmonad.hs
+ build-depends: base >= 4.5 && < 4.7
+ , monad-par >= 0.3.4 && < 0.4
+ ghc-options: -threaded
+ default-language: Haskell2010
+
+executable rsa-pipeline
+ main-is: rsa-pipeline.hs
+ build-depends: base >= 4.5 && < 4.7
+ , bytestring >= 0.10 && < 0.11
+ -- bytestring-0.10 needed to get instance NFData ByteString
+ , monad-par >= 0.3.4 && < 0.4
+ , deepseq ==1.3.*
+ ghc-options: -threaded
+ default-language: Haskell2010
+
+executable fwsparse
+ main-is: fwsparse.hs
+ hs-source-dirs: fwsparse
+ build-depends: base >= 4.5 && < 4.7
+ , random >= 1.0 && < 1.1
+ , array ==0.4.*
+ , containers >= 0.4 && < 0.6
+ default-language: Haskell2010
+
+executable fwsparse1
+ main-is: fwsparse1.hs
+ hs-source-dirs: fwsparse
+ build-depends: base >= 4.5 && < 4.7
+ , random >= 1.0 && < 1.1
+ , array ==0.4.*
+ , containers >= 0.4 && < 0.6
+ , monad-par >= 0.3.4 && < 0.4
+ , deepseq ==1.3.*
+ ghc-options: -threaded
+ default-language: Haskell2010
+
+executable timetable
+ main-is: timetable.hs
+ build-depends: base >= 4.5 && < 4.7
+ , containers >= 0.4 && < 0.6
+ , deepseq ==1.3.*
+ , random >= 1.0 && < 1.1
+ default-language: Haskell2010
+
+executable timetable1
+ main-is: timetable1.hs
+ build-depends: base >= 4.5 && < 4.7
+ , containers >= 0.4 && < 0.6
+ , deepseq ==1.3.*
+ , monad-par >= 0.3.4 && < 0.4
+ , random >= 1.0 && < 1.1
+ default-language: Haskell2010
+
+executable timetable2
+ main-is: timetable2.hs
+ build-depends: base >= 4.5 && < 4.7
+ , containers >= 0.4 && < 0.6
+ , deepseq ==1.3.*
+ , monad-par >= 0.3.4 && < 0.4
+ , random >= 1.0 && < 1.1
+ default-language: Haskell2010
+
+executable timetable3
+ main-is: timetable3.hs
+ build-depends: base >= 4.5 && < 4.7
+ , containers >= 0.4 && < 0.6
+ , deepseq ==1.3.*
+ , monad-par >= 0.3.4 && < 0.4
+ , random >= 1.0 && < 1.1
+ default-language: Haskell2010
+
+-- -----------------------------------------------------------------------------
+-- conc-fork
+
executable fork
main-is: fork.hs
build-depends: base >= 4.5 && < 4.7
@@ -26,6 +197,9 @@ executable reminders2
build-depends: base >= 4.5 && < 4.7
default-language: Haskell2010
+-- -----------------------------------------------------------------------------
+-- conc-mvar
+
executable mvar1
main-is: mvar1.hs
build-depends: base >= 4.5 && < 4.7
@@ -46,6 +220,25 @@ executable logger
build-depends: base >= 4.5 && < 4.7
default-language: Haskell2010
+executable phonebook
+ main-is: phonebook.hs
+ build-depends: base >= 4.5 && < 4.7
+ , containers >= 0.4 && < 0.6
+ default-language: Haskell2010
+
+executable chan
+ main-is: chan.hs
+ build-depends: base >= 4.5 && < 4.7
+ default-language: Haskell2010
+
+executable chan2
+ main-is: chan2.hs
+ build-depends: base >= 4.5 && < 4.7
+ default-language: Haskell2010
+
+-- -----------------------------------------------------------------------------
+-- conc-overlap
+
executable geturls1
main-is: geturls1.hs
build-depends: base >= 4.5 && < 4.7
@@ -105,18 +298,11 @@ executable geturls6
, HTTP ==4000.2.*
default-language: Haskell2010
-executable geturls7
- main-is: geturls7.hs
- build-depends: base >= 4.5 && < 4.7
- , stm ==2.4.*
- , bytestring >= 0.9 && < 0.11
- , time ==1.4.*
- , network ==2.3.*
- , HTTP ==4000.2.*
- default-language: Haskell2010
+-- -----------------------------------------------------------------------------
+-- conc-asyncex
-executable geturls8
- main-is: geturls8.hs
+executable geturlscancel
+ main-is: geturlscancel.hs
build-depends: base >= 4.5 && < 4.7
, stm ==2.4.*
, bytestring >= 0.9 && < 0.11
@@ -125,8 +311,8 @@ executable geturls8
, HTTP ==4000.2.*
default-language: Haskell2010
-executable geturls9
- main-is: geturls9.hs
+executable geturlscancel2
+ main-is: geturlscancel2.hs
build-depends: base >= 4.5 && < 4.7
, stm ==2.4.*
, bytestring >= 0.9 && < 0.11
@@ -140,73 +326,16 @@ executable modifytwo
build-depends: base >= 4.5 && < 4.7
default-language: Haskell2010
-executable chan
- main-is: chan.hs
- build-depends: base >= 4.5 && < 4.7
- default-language: Haskell2010
-
-executable chan2
- main-is: chan2.hs
- build-depends: base >= 4.5 && < 4.7
- default-language: Haskell2010
-
executable chan3
main-is: chan3.hs
build-depends: base >= 4.5 && < 4.7
default-language: Haskell2010
-executable deadlock1
- main-is: deadlock1.hs
- build-depends: base >= 4.5 && < 4.7
- default-language: Haskell2010
-
-executable deadlock2
- main-is: deadlock2.hs
- build-depends: base >= 4.5 && < 4.7
- default-language: Haskell2010
-
-executable threadperf1
- main-is: threadperf1.hs
- build-depends: base >= 4.5 && < 4.7
- default-language: Haskell2010
-
-executable threadperf2
- main-is: threadperf2.hs
- build-depends: base >= 4.5 && < 4.7
- ghc-options: -rtsopts
- default-language: Haskell2010
-
-executable geturlscancel
- main-is: geturlscancel.hs
- build-depends: base >= 4.5 && < 4.7
- , stm ==2.4.*
- , bytestring >= 0.9 && < 0.11
- , time ==1.4.*
- , network ==2.3.*
- , HTTP ==4000.2.*
- default-language: Haskell2010
-
-executable geturlscancel2
- main-is: geturlscancel2.hs
- build-depends: base >= 4.5 && < 4.7
- , stm ==2.4.*
- , bytestring >= 0.9 && < 0.11
- , time ==1.4.*
- , network ==2.3.*
- , HTTP ==4000.2.*
- default-language: Haskell2010
-
executable timeout
main-is: timeout.hs
build-depends: base >= 4.5 && < 4.7
default-language: Haskell2010
-executable timeout2
- main-is: timeout.hs
- build-depends: base >= 4.5 && < 4.7
- , async ==2.0.*
- default-language: Haskell2010
-
executable catch-mask
main-is: catch-mask.hs
build-depends: base >= 4.5 && < 4.7
@@ -217,6 +346,10 @@ executable catch-mask2
build-depends: base >= 4.5 && < 4.7
default-language: Haskell2010
+-- -----------------------------------------------------------------------------
+-- conc-stm
+
+-- not mentioned in the text?
executable windowman
main-is: windowman.hs
build-depends: base >= 4.5 && < 4.7
@@ -240,28 +373,6 @@ executable geturlsfirst
, network ==2.3.*
default-language: Haskell2010
-executable bingtranslator
- main-is: bingtranslator.hs
- build-depends: base >= 4.5 && < 4.7
- , bytestring >= 0.9 && < 0.11
- , time ==1.4.*
- , HTTP ==4000.2.*
- , network ==2.3.*
- , utf8-string ==0.3.*
- , xml ==1.3.*
- default-language: Haskell2010
-
-executable bingtranslatorconc
- main-is: bingtranslatorconc.hs
- build-depends: base >= 4.5 && < 4.7
- , bytestring >= 0.9 && < 0.11
- , time ==1.4.*
- , HTTP ==4000.2.*
- , network ==2.3.*
- , utf8-string ==0.3.*
- , xml ==1.3.*
- default-language: Haskell2010
-
executable TList
main-is: TList.hs
build-depends: base >= 4.5 && < 4.7
@@ -274,46 +385,54 @@ executable TQueue
, stm ==2.4.*
default-language: Haskell2010
-executable geturlsstm
- main-is: geturlsstm.hs
+executable TBQueue
+ main-is: TBQueue.hs
build-depends: base >= 4.5 && < 4.7
, stm ==2.4.*
- , bytestring >= 0.9 && < 0.11
- , time ==1.4.*
- , network ==2.3.*
- , HTTP ==4000.2.*
default-language: Haskell2010
-executable Async
- main-is: Async.hs
+-- -----------------------------------------------------------------------------
+-- conc-higher
+
+executable geturls7
+ main-is: geturls7.hs
build-depends: base >= 4.5 && < 4.7
, stm ==2.4.*
+ , bytestring >= 0.9 && < 0.11
+ , time ==1.4.*
+ , network ==2.3.*
+ , HTTP ==4000.2.*
default-language: Haskell2010
-executable server
- main-is: server.hs
+executable geturls8
+ main-is: geturls8.hs
build-depends: base >= 4.5 && < 4.7
, stm ==2.4.*
+ , bytestring >= 0.9 && < 0.11
+ , time ==1.4.*
, network ==2.3.*
+ , HTTP ==4000.2.*
default-language: Haskell2010
-executable server2
- main-is: server2.hs
+executable geturls9
+ main-is: geturls9.hs
build-depends: base >= 4.5 && < 4.7
, stm ==2.4.*
- , async ==2.0.*
+ , bytestring >= 0.9 && < 0.11
+ , time ==1.4.*
, network ==2.3.*
+ , HTTP ==4000.2.*
default-language: Haskell2010
-executable chat
- main-is: chat.hs
+executable timeout2
+ main-is: timeout.hs
build-depends: base >= 4.5 && < 4.7
- , containers >= 0.4 && < 0.6
, async ==2.0.*
- , stm ==2.4.*
- , network ==2.3.*
default-language: Haskell2010
+-- -----------------------------------------------------------------------------
+-- conc-par
+
executable findseq
main-is: findseq.hs
build-depends: base >= 4.5 && < 4.7
@@ -346,6 +465,48 @@ executable findpar3
, stm ==2.4.*
default-language: Haskell2010
+executable findpar4
+ main-is: findpar4.hs
+ build-depends: base >= 4.5 && < 4.7
+ , filepath ==1.3.*
+ , directory >= 1.1 && < 1.3
+ , async ==2.0.*
+ , stm ==2.4.*
+ , transformers ==0.3.*
+ , abstract-par ==0.3.*
+ , monad-par >= 0.3.4 && < 0.4
+ default-language: Haskell2010
+
+-- -----------------------------------------------------------------------------
+-- conc-server
+
+executable server
+ main-is: server.hs
+ build-depends: base >= 4.5 && < 4.7
+ , stm ==2.4.*
+ , network ==2.3.*
+ default-language: Haskell2010
+
+executable server2
+ main-is: server2.hs
+ build-depends: base >= 4.5 && < 4.7
+ , stm ==2.4.*
+ , async ==2.0.*
+ , network ==2.3.*
+ default-language: Haskell2010
+
+executable chat
+ main-is: chat.hs
+ build-depends: base >= 4.5 && < 4.7
+ , containers >= 0.4 && < 0.6
+ , async ==2.0.*
+ , stm ==2.4.*
+ , network ==2.3.*
+ default-language: Haskell2010
+
+-- -----------------------------------------------------------------------------
+-- conc-distrib
+
executable ping
main-is: distrib-ping/ping.hs
build-depends: base >= 4.5 && < 4.7
@@ -402,6 +563,7 @@ executable ping-tc-merge
build-depends: ghc-prim
default-language: Haskell2010
+-- extra, not in the text?
executable ping-tc-notify
main-is: distrib-ping/ping-tc-notify.hs
build-depends: base >= 4.5 && < 4.7
@@ -485,121 +647,74 @@ executable distrib-db
build-depends: ghc-prim
default-language: Haskell2010
-executable sudoku1
- main-is: sudoku1.hs
- build-depends: base >= 4.5 && < 4.7
- , parallel ==3.2.*
- , array ==0.4.*
- default-language: Haskell2010
+-- -----------------------------------------------------------------------------
+-- conc-debugging-tuning
-executable sudoku2
- main-is: sudoku2.hs
+executable mvar4
+ main-is: mvar4.hs
build-depends: base >= 4.5 && < 4.7
- , parallel ==3.2.*
- , array ==0.4.*
- , deepseq ==1.3.*
- ghc-options: -threaded
default-language: Haskell2010
-executable sudoku3
- main-is: sudoku3.hs
+executable deadlock1
+ main-is: deadlock1.hs
build-depends: base >= 4.5 && < 4.7
- , parallel ==3.2.*
- , array ==0.4.*
- ghc-options: -threaded
default-language: Haskell2010
-executable sudoku4
- main-is: sudoku4.hs
+executable deadlock2
+ main-is: deadlock2.hs
build-depends: base >= 4.5 && < 4.7
- , parallel ==3.2.*
- , array ==0.4.*
- ghc-options: -threaded
default-language: Haskell2010
-executable kmeans
- hs-source-dirs: kmeans
- main-is: kmeans.hs
+executable threadperf1
+ main-is: threadperf1.hs
build-depends: base >= 4.5 && < 4.7
- , parallel ==3.2.*
- , time ==1.4.*
- , deepseq ==1.3.*
- , monad-par >= 0.3.4 && < 0.4
- -- monad-par 0.3 has a bug:
- -- https://github.com/simonmar/monad-par/issues/23
- , binary >= 0.6.3 && < 0.7
- , array ==0.4.*
- , bytestring >= 0.9 && < 0.11
- , vector >= 0.10 && < 0.11
- ghc-options: -threaded
default-language: Haskell2010
-executable GenSamples
- hs-source-dirs: kmeans
- main-is: GenSamples.hs
+executable threadperf2
+ main-is: threadperf2.hs
build-depends: base >= 4.5 && < 4.7
- , binary >= 0.6.3 && < 0.7
- , array ==0.4.*
- , vector >= 0.10 && < 0.11
- , random >= 1.0 && < 1.1
- , normaldistribution >= 1.1 && < 1.2
- , deepseq ==1.3.*
- , bytestring >= 0.9 && < 0.11
+ ghc-options: -rtsopts
default-language: Haskell2010
-executable rsa
- main-is: rsa.hs
- build-depends: base >= 4.5 && < 4.7
- , bytestring >= 0.10 && < 0.11
- default-language: Haskell2010
+-- -----------------------------------------------------------------------------
+-- Extras (exercises etc.)
-executable rsa1
- main-is: rsa1.hs
- build-depends: base >= 4.5 && < 4.7
- , bytestring >= 0.10 && < 0.11
- -- bytestring-0.10 needed to get instance NFData ByteString
- , parallel ==3.2.*
- ghc-options: -threaded
- default-language: Haskell2010
-
-executable rsa2
- main-is: rsa2.hs
+executable bingtranslator
+ main-is: bingtranslator.hs
build-depends: base >= 4.5 && < 4.7
- , bytestring >= 0.10 && < 0.11
- -- bytestring-0.10 needed to get instance NFData ByteString
- , parallel ==3.2.*
- ghc-options: -threaded
+ , bytestring >= 0.9 && < 0.11
+ , time ==1.4.*
+ , HTTP ==4000.2.*
+ , network ==2.3.*
+ , utf8-string ==0.3.*
+ , xml ==1.3.*
default-language: Haskell2010
-executable rsa-pipeline
- main-is: rsa-pipeline.hs
+executable bingtranslatorconc
+ main-is: bingtranslatorconc.hs
build-depends: base >= 4.5 && < 4.7
- , bytestring >= 0.10 && < 0.11
- -- bytestring-0.10 needed to get instance NFData ByteString
- , monad-par >= 0.3.4 && < 0.4
- , deepseq ==1.3.*
- ghc-options: -threaded
+ , bytestring >= 0.9 && < 0.11
+ , time ==1.4.*
+ , HTTP ==4000.2.*
+ , network ==2.3.*
+ , utf8-string ==0.3.*
+ , xml ==1.3.*
default-language: Haskell2010
-executable fwsparse
- main-is: fwsparse.hs
- hs-source-dirs: fwsparse
+executable geturlsstm
+ main-is: geturlsstm.hs
build-depends: base >= 4.5 && < 4.7
- , random >= 1.0 && < 1.1
- , array ==0.4.*
- , containers >= 0.4 && < 0.6
+ , stm ==2.4.*
+ , bytestring >= 0.9 && < 0.11
+ , time ==1.4.*
+ , network ==2.3.*
+ , HTTP ==4000.2.*
default-language: Haskell2010
-executable fwsparse1
- main-is: fwsparse1.hs
- hs-source-dirs: fwsparse
+executable Async
+ main-is: Async.hs
build-depends: base >= 4.5 && < 4.7
- , random >= 1.0 && < 1.1
- , array ==0.4.*
- , containers >= 0.4 && < 0.6
- , monad-par >= 0.3.4 && < 0.4
- , deepseq ==1.3.*
- ghc-options: -threaded
+ , stm ==2.4.*
default-language: Haskell2010
-- ToDo:
View
2  parmonad.hs
@@ -1,6 +1,4 @@
import Control.Exception
-import Data.Time.Clock
-import Text.Printf
import System.Environment
import Control.Monad.Par.Scheds.Trace
-- NB. using Trace here, Direct is too strict and forces the fibs in
View
10 timeout.hs
@@ -12,9 +12,9 @@ instance Show Timeout where
instance Exception Timeout
-- <<timeout
-timeout n m
- | n < 0 = fmap Just m -- <1>
- | n == 0 = return Nothing -- <1>
+timeout t m
+ | t < 0 = fmap Just m -- <1>
+ | t == 0 = return Nothing -- <1>
| otherwise = do
pid <- myThreadId -- <2>
u <- newUnique -- <3>
@@ -22,9 +22,9 @@ timeout n m
handleJust -- <4>
(\e -> if e == ex then Just () else Nothing) -- <5>
(\_ -> return Nothing) -- <6>
- (bracket (forkIO $ do threadDelay n -- <7>
+ (bracket (forkIO $ do threadDelay t -- <7>
throwTo pid ex)
- (\t -> throwTo t ThreadKilled) -- <8>
+ (\tid -> throwTo tid ThreadKilled) -- <8>
(\_ -> fmap Just m)) -- <9>
-- >>
View
7 timetable.hs
@@ -1,12 +1,9 @@
{-# LANGUAGE OverloadedStrings #-}
-import qualified Data.Text as Text
-import Data.Text (Text)
import System.Random
import System.Environment
import Debug.Trace
import Data.List
-import Control.Monad.Par
import Control.DeepSeq
import Data.Map (Map)
@@ -26,7 +23,7 @@ instance Show Talk where
-- <<Person
data Person = Person
- { name :: Text
+ { name :: String
, talks :: [Talk]
}
deriving (Show)
@@ -105,7 +102,7 @@ bench nslots ntracks ntalks npersons c_per_s gen =
mkpersons :: Int -> StdGen -> [Person]
mkpersons 0 g = []
- mkpersons n g = Person (Text.pack ('P':show n)) (take c_per_s cs) : rest
+ mkpersons n g = Person ('P':show n) (take c_per_s cs) : rest
where
(g1,g2) = split g
rest = mkpersons (n-1) g2
View
7 timetable1.hs
@@ -1,12 +1,9 @@
{-# LANGUAGE OverloadedStrings #-}
-import qualified Data.Text as Text
-import Data.Text (Text)
import System.Random
import System.Environment
import Debug.Trace
import Data.List
-import Control.Monad.Par
import Control.DeepSeq
import Data.Map (Map)
@@ -26,7 +23,7 @@ instance Show Talk where
-- <<Person
data Person = Person
- { name :: Text
+ { name :: String
, talks :: [Talk]
}
deriving (Show)
@@ -115,7 +112,7 @@ bench nslots ntracks ntalks npersons c_per_s gen =
mkpersons :: Int -> StdGen -> [Person]
mkpersons 0 g = []
- mkpersons n g = Person (Text.pack ('P':show n)) (take c_per_s cs) : rest
+ mkpersons n g = Person ('P':show n) (take c_per_s cs) : rest
where
(g1,g2) = split g
rest = mkpersons (n-1) g2
View
6 timetable2.hs
@@ -1,7 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
-import qualified Data.Text as Text
-import Data.Text (Text)
import System.Random
import System.Environment
import Debug.Trace
@@ -26,7 +24,7 @@ instance Show Talk where
-- <<Person
data Person = Person
- { name :: Text
+ { name :: String
, talks :: [Talk]
}
deriving (Show)
@@ -132,7 +130,7 @@ bench nslots ntracks ntalks npersons c_per_s gen =
mkpersons :: Int -> StdGen -> [Person]
mkpersons 0 g = []
- mkpersons n g = Person (Text.pack ('P':show n)) (take c_per_s cs) : rest
+ mkpersons n g = Person ('P':show n) (take c_per_s cs) : rest
where
(g1,g2) = split g
rest = mkpersons (n-1) g2
View
6 timetable3.hs
@@ -1,7 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
-import qualified Data.Text as Text
-import Data.Text (Text)
import System.Random
import System.Environment
import Debug.Trace
@@ -26,7 +24,7 @@ instance Show Talk where
-- <<Person
data Person = Person
- { name :: Text
+ { name :: String
, talks :: [Talk]
}
deriving (Show)
@@ -135,7 +133,7 @@ bench nslots ntracks ntalks npersons c_per_s gen =
mkpersons :: Int -> StdGen -> [Person]
mkpersons 0 g = []
- mkpersons n g = Person (Text.pack ('P':show n)) (take c_per_s cs) : rest
+ mkpersons n g = Person ('P':show n) (take c_per_s cs) : rest
where
(g1,g2) = split g
rest = mkpersons (n-1) g2
Please sign in to comment.
Something went wrong with that request. Please try again.