about summary refs log tree commit diff
path: root/pkgs/development/haskell-modules/patches
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2022-03-20 09:55:59 +0100
committerNaïm Favier <n@monade.li>2022-03-22 15:58:51 +0100
commitf8c740b781135a7564fa32658c5887e606138e08 (patch)
tree40e2604aa53f22cb1229766c2e866c9f5741b2f9 /pkgs/development/haskell-modules/patches
parent6b25081893536afdd18e9a134e8c9418130dc13f (diff)
downloadnixlib-f8c740b781135a7564fa32658c5887e606138e08.tar
nixlib-f8c740b781135a7564fa32658c5887e606138e08.tar.gz
nixlib-f8c740b781135a7564fa32658c5887e606138e08.tar.bz2
nixlib-f8c740b781135a7564fa32658c5887e606138e08.tar.lz
nixlib-f8c740b781135a7564fa32658c5887e606138e08.tar.xz
nixlib-f8c740b781135a7564fa32658c5887e606138e08.tar.zst
nixlib-f8c740b781135a7564fa32658c5887e606138e08.zip
haskellPackages.misfortune: apply patch to fix GHC 9 build
Diffstat (limited to 'pkgs/development/haskell-modules/patches')
-rw-r--r--pkgs/development/haskell-modules/patches/misfortune-ghc9.patch70
1 files changed, 70 insertions, 0 deletions
diff --git a/pkgs/development/haskell-modules/patches/misfortune-ghc9.patch b/pkgs/development/haskell-modules/patches/misfortune-ghc9.patch
new file mode 100644
index 000000000000..39f983b15d78
--- /dev/null
+++ b/pkgs/development/haskell-modules/patches/misfortune-ghc9.patch
@@ -0,0 +1,70 @@
+diff --git a/misfortune.cabal b/misfortune.cabal
+index f5d0dd3..faa5794 100644
+--- a/misfortune.cabal
++++ b/misfortune.cabal
+@@ -113,7 +113,8 @@ Library
+                         directory,
+                         filepath,
+                         knob,
+-                        random-fu >= 0.2.2,
++                        random,
++                        random-fu >= 0.3,
+                         semigroups,
+                         text,
+                         utf8-string,
+diff --git a/src/Data/Fortune.hs b/src/Data/Fortune.hs
+index 16d221e..ffbc970 100644
+--- a/src/Data/Fortune.hs
++++ b/src/Data/Fortune.hs
+@@ -64,6 +64,7 @@ import Paths_misfortune
+ import System.Directory
+ import System.Environment
+ import System.FilePath
++import System.Random.Stateful (newIOGenM, newStdGen)
+ 
+ -- |The number of fortune strings in the index
+ numFortunes :: S.FortuneStats -> Int
+@@ -233,9 +234,10 @@ randomFortune paths = withFortuneFiles '%' False paths $ \fs -> do
+ -- random fortune from that file (unformly).
+ randomFortuneFromRandomFile :: RVar FortuneFile -> IO String
+ randomFortuneFromRandomFile file = do
+-    f <- sample file
++    gen <- newStdGen >>= newIOGenM
++    f <- sampleFrom gen file
+     n <- getNumFortunes f
+-    i <- sample (uniform 0 (n-1))
++    i <- sampleFrom gen (uniform 0 (n-1))
+     T.unpack <$> getFortune f i
+ 
+ -- |Given a list of 'FortuneFile's, compute a distrubution over them weighted by the number
+diff --git a/src/Fortune.hs b/src/Fortune.hs
+index 5a27578..d6ffb74 100644
+--- a/src/Fortune.hs
++++ b/src/Fortune.hs
+@@ -21,6 +21,7 @@ import System.Environment
+ import System.Exit
+ import System.FilePath
+ import System.IO
++import System.Random.Stateful (newIOGenM, newStdGen)
+ import Text.Printf
+ import Text.Regex.Base
+ import Text.Regex.PCRE
+@@ -200,6 +201,7 @@ main = do
+     fortunes <- filterM (filterFile args) (fortuneFiles args)
+     
+     dist <- getDist args fortunes
++    gen <- newStdGen >>= newIOGenM
+     
+     when (numEvents dist == 0) $ do
+         hPutStrLn stderr "No fortunes matched the filter criteria"
+@@ -225,8 +227,8 @@ main = do
+             , let pctStr = printf "(%.2f%%)" (100 * weight / totalWeight dist) :: String
+             ]
+         else do
+-            (file, fortuneDist) <- sample dist
+-            fortune <- sample fortuneDist
++            (file, fortuneDist) <- sampleFrom gen dist
++            fortune <- sampleFrom gen fortuneDist
+             putStrLn . T.unpack =<< getFortune file fortune
+ 
+ getDist :: Args -> [FortuneFile] -> IO (Categorical Float (FortuneFile, Categorical Float Int))