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 20:55:36 +0100
committerNaïm Favier <n@monade.li>2022-03-22 15:58:52 +0100
commit832c091143013150c41d82ecbd17a680607c68e1 (patch)
treef7c8116fde211a34db91bad8a39850704b4c6112 /pkgs/development/haskell-modules/patches
parentfe3d3d5764e3e422ea7979eb68a72080046e35d7 (diff)
lambdabot: apply patch to fix GHC 9 build
Diffstat (limited to 'pkgs/development/haskell-modules/patches')
-rw-r--r--pkgs/development/haskell-modules/patches/lambdabot-core-ghc9.patch95
-rw-r--r--pkgs/development/haskell-modules/patches/lambdabot-novelty-plugins-ghc9.patch58
2 files changed, 153 insertions, 0 deletions
diff --git a/pkgs/development/haskell-modules/patches/lambdabot-core-ghc9.patch b/pkgs/development/haskell-modules/patches/lambdabot-core-ghc9.patch
new file mode 100644
index 0000000000000..87a112b821738
--- /dev/null
+++ b/pkgs/development/haskell-modules/patches/lambdabot-core-ghc9.patch
@@ -0,0 +1,95 @@
+diff --git a/lambdabot-core.cabal b/lambdabot-core.cabal
+index 861a28b..87175a3 100644
+--- a/lambdabot-core.cabal
++++ b/lambdabot-core.cabal
+@@ -19,7 +19,7 @@ homepage:               https://wiki.haskell.org/Lambdabot
+ 
+ build-type:             Simple
+ cabal-version:          >= 1.10
+-tested-with:            GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.4
++tested-with:            GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.4, GHC == 9.0.2
+ 
+ extra-source-files:     AUTHORS.md
+                         COMMENTARY.md
+@@ -89,9 +89,8 @@ library
+                         network-bsd             >= 2.7 && < 2.9,
+                         parsec                  >= 3,
+                         prim-uniq               >= 0.2 && < 0.4,
+-                        random                  >= 1,
+-                        random-fu               >= 0.2.6.2,
+-                        random-source           >= 0.3,
++                        random                  >= 1.2,
++                        random-fu               >= 0.3.0.0,
+                         regex-tdfa              >= 1.1 && < 1.4,
+                         SafeSemaphore           >= 0.9,
+                         split                   >= 0.2,
+diff --git a/src/Lambdabot/Bot.hs b/src/Lambdabot/Bot.hs
+index 1b0de2e..833fb4c 100644
+--- a/src/Lambdabot/Bot.hs
++++ b/src/Lambdabot/Bot.hs
+@@ -1,6 +1,5 @@
+ {-# LANGUAGE GADTs #-}
+ {-# LANGUAGE ScopedTypeVariables #-}
+-{-# LANGUAGE TemplateHaskell #-}
+ -- | The guts of lambdabot.
+ --
+ -- The LB/Lambdabot monad
+@@ -37,7 +36,6 @@ import Control.Monad.Error
+ import Control.Monad.Reader
+ import Control.Monad.State
+ import qualified Data.Map as M
+-import Data.Random.Source
+ import qualified Data.Set as S
+ 
+ ------------------------------------------------------------------------
+@@ -136,17 +134,3 @@ ircPrivmsg who msg = do
+ ircPrivmsg' :: Nick -> String -> LB ()
+ ircPrivmsg' who ""  = ircPrivmsg' who " "
+ ircPrivmsg' who msg = send $ privmsg who msg
+-
+-------------------------------------------------------------------------
+-
+-monadRandom [d|
+-
+-    instance MonadRandom LB where
+-        getRandomWord8          = liftIO getRandomWord8
+-        getRandomWord16         = liftIO getRandomWord16
+-        getRandomWord32         = liftIO getRandomWord32
+-        getRandomWord64         = liftIO getRandomWord64
+-        getRandomDouble         = liftIO getRandomDouble
+-        getRandomNByteInteger n = liftIO (getRandomNByteInteger n)
+-
+- |]
+diff --git a/src/Lambdabot/Util.hs b/src/Lambdabot/Util.hs
+index effdf71..259699b 100644
+--- a/src/Lambdabot/Util.hs
++++ b/src/Lambdabot/Util.hs
+@@ -23,14 +23,15 @@ module Lambdabot.Util (
+         randomSuccessMsg
+     ) where
+ 
++import Control.Concurrent.Lifted
+ import Control.Monad.Trans
++import Control.Monad.Trans.Control
+ import Data.Char
+ import Data.List
+ import Data.Random
+-import Control.Concurrent.Lifted
+-import Control.Monad.Trans.Control
+ import Lambdabot.Config
+ import Lambdabot.Config.Core
++import System.Random.Stateful (newIOGenM, newStdGen)
+ 
+ ------------------------------------------------------------------------
+ 
+@@ -63,7 +64,9 @@ listToStr conj (item:items) =
+ 
+ -- | Pick a random element of the list.
+ random :: MonadIO m => [a] -> m a
+-random = io . sample . randomElement
++random l = do
++  g <- newIOGenM =<< newStdGen
++  sampleFrom g (randomElement l)
+ 
+ ------------------------------------------------------------------------
+ 
diff --git a/pkgs/development/haskell-modules/patches/lambdabot-novelty-plugins-ghc9.patch b/pkgs/development/haskell-modules/patches/lambdabot-novelty-plugins-ghc9.patch
new file mode 100644
index 0000000000000..009951f90e07a
--- /dev/null
+++ b/pkgs/development/haskell-modules/patches/lambdabot-novelty-plugins-ghc9.patch
@@ -0,0 +1,58 @@
+diff --git a/lambdabot-novelty-plugins.cabal b/lambdabot-novelty-plugins.cabal
+index 69c8447..50a35f6 100644
+--- a/lambdabot-novelty-plugins.cabal
++++ b/lambdabot-novelty-plugins.cabal
+@@ -36,7 +36,7 @@ homepage:               https://wiki.haskell.org/Lambdabot
+ 
+ build-type:             Simple
+ cabal-version:          >= 1.10
+-tested-with:            GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.4
++tested-with:            GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.4, GHC == 9.0.2
+ 
+ source-repository head
+   type:                 git
+@@ -71,7 +71,8 @@ library
+                         lambdabot-core          >= 5.3 && < 5.4,
+                         misfortune              >= 0.1,
+                         process                 >= 1.1,
+-                        random-fu               >= 0.2.6.2,
++                        random                  >= 1.2,
++                        random-fu               >= 0.3.0.0,
+                         regex-tdfa              >= 1.1,
+ 
+                         -- runtime dependencies
+diff --git a/src/Lambdabot/Plugin/Novelty/Numberwang.hs b/src/Lambdabot/Plugin/Novelty/Numberwang.hs
+index ae41eb4..8321a14 100644
+--- a/src/Lambdabot/Plugin/Novelty/Numberwang.hs
++++ b/src/Lambdabot/Plugin/Novelty/Numberwang.hs
+@@ -7,7 +7,9 @@ import Control.Monad
+ import Data.Random
+ import Data.Random.Distribution.Poisson
+ import Lambdabot.Plugin
++import Lambdabot.Util
+ import Numeric
++import System.Random.Stateful (newIOGenM, newStdGen)
+ 
+ 
+ data NumberwangState = State
+@@ -23,7 +25,9 @@ conDist = poisson (32  :: Double)
+ 
+ numberwangPlugin :: Module NumberwangState
+ numberwangPlugin = newModule
+-    { moduleDefState = sample (State <$> cmdDist <*> conDist)
++    { moduleDefState = do
++        g <- newIOGenM =<< newStdGen
++        sampleFrom g (State <$> cmdDist <*> conDist)
+     , moduleCmds = return
+         [ (command "numberwang")
+             { help = say "@numberwang <number>: Determines if it is Numberwang."
+@@ -61,7 +65,8 @@ checkNumberwang :: (MonadLBState m, LBState m ~ NumberwangState) =>
+ checkNumberwang cmd l = withState cmd $ \ n setN nDist -> do
+     if n <= l
+         then do
+-            setN =<< lb (sample nDist)
++            g <- newIOGenM =<< newStdGen
++            setN =<< sampleFrom g nDist
+             return True
+         else do
+             setN (n - l)