on master help sign in
Add Word Random instance for GHC < 7.1
a57c0b5Corey O'Connor
test/Verify.hs+14
@@ -1,3 +1,5 @@
1+{-# LANGUAGE ScopedTypeVariables #-}
2+{-# LANGUAGE CPP #-}
1{-# LANGUAGE TypeSynonymInstances #-}
3{-# LANGUAGE TypeSynonymInstances #-}
2{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE StandaloneDeriving #-}
5{-# LANGUAGE StandaloneDeriving #-}
@@ -26,10 +28,12 @@ import Control.Applicative
26import Control.Monad.State.Strict
28import Control.Monad.State.Strict
27
29
28import Data.IORef
30import Data.IORef
31+import Data.Word
29
32
30import Numeric ( showHex )
33import Numeric ( showHex )
31
34
32import System.IO
35import System.IO
36+import System.Random
33
37
34type Test = StateT TestState IO
38type Test = StateT TestState IO
35
39
@@ -82,3 +86,13 @@ instance Arbitrary DoubleColumnChar where
82liftIOResult :: Testable prop => IO prop -> Property
86liftIOResult :: Testable prop => IO prop -> Property
83liftIOResult = morallyDubiousIOProperty
87liftIOResult = morallyDubiousIOProperty
84
88
89+#if __GLASGOW_HASKELL__ <= 701
90+instance Random Word where
91+ random g =
92+ let (i :: Int, g') = random g
93+ in (toEnum i, g')
94+ randomR (l,h) g =
95+ let (i :: Int, g') = randomR (fromEnum l,fromEnum h) g
96+ in (toEnum i, g')
97+#endif
98+