on master help sign in
Add Word Random instance for GHC < 7.1
commita57c0b5360055bc4984df53d32ff64c517f6b171 authorCorey O'Connor <coreyoconnor@gmail.com> dateSat 9 Jul 2011, 21:06 (15 years ago) parentc62e5e1
1 file changed+14
test/Verify.hs+14
test/Verify.hs+14
@@ -1,3 +1,5 @@
1+{-# LANGUAGE ScopedTypeVariables #-}
2+{-# LANGUAGE CPP #-}
13{-# LANGUAGE TypeSynonymInstances #-}
24{-# LANGUAGE FlexibleInstances #-}
35{-# LANGUAGE StandaloneDeriving #-}
@@ -26,10 +28,12 @@ import Control.Applicative
2628import Control.Monad.State.Strict
2729
2830import Data.IORef
31+import Data.Word
2932
3033import Numeric ( showHex )
3134
3235import System.IO
36+import System.Random
3337
3438type Test = StateT TestState IO
3539
@@ -82,3 +86,13 @@ instance Arbitrary DoubleColumnChar where
8286liftIOResult :: Testable prop => IO prop -> Property
8387liftIOResult = morallyDubiousIOProperty
8488
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+