module Data.Random.Source.MWC where
import Data.Random.Internal.Primitives
import Data.Random.Internal.Words
import Data.Random.Source
import System.Random.MWC
import Control.Monad.ST
instance RandomSource (ST s) (Gen s) where
supportedPrimsFrom _ PrimWord8 = True
supportedPrimsFrom _ PrimWord16 = True
supportedPrimsFrom _ PrimWord32 = True
supportedPrimsFrom _ PrimWord64 = True
supportedPrimsFrom _ PrimDouble = True
supportedPrimsFrom _ _ = False
getSupportedRandomPrimFrom gen PrimWord8 = uniform gen
getSupportedRandomPrimFrom gen PrimWord16 = uniform gen
getSupportedRandomPrimFrom gen PrimWord32 = uniform gen
getSupportedRandomPrimFrom gen PrimWord64 = uniform gen
getSupportedRandomPrimFrom gen PrimDouble = fmap wordToDouble (uniform gen)
getSupportedRandomPrimFrom _ p = error ("getSupportedRandomPrimFrom/Gen s: unsupported prim requested: " ++ show p)
instance RandomSource IO (Gen RealWorld) where
supportedPrimsFrom _ PrimWord8 = True
supportedPrimsFrom _ PrimWord16 = True
supportedPrimsFrom _ PrimWord32 = True
supportedPrimsFrom _ PrimWord64 = True
supportedPrimsFrom _ PrimDouble = True
supportedPrimsFrom _ _ = False
getSupportedRandomPrimFrom gen prim = stToIO (getSupportedRandomPrimFrom gen prim)