module FRP.NetWire.Random
(
noise,
noise1,
noiseGen,
noiseR,
wackelkontakt
)
where
import FRP.NetWire.Wire
import System.Random.Mersenne
noise :: Wire a Double
noise = noiseGen
noise1 :: Wire a Double
noise1 =
mkGen $ \(wsRndGen -> mt) _ -> do
x <- fmap (pred . (2*)) $ random mt
x `seq` return (Just x, noise1)
noiseGen :: MTRandom b => Wire a b
noiseGen =
mkGen $ \(wsRndGen -> mt) _ -> do
x <- random mt
x `seq` return (Just x, noiseGen)
noiseR :: (Real a, Integral b) => Wire a b
noiseR =
mkGen $ \(wsRndGen -> mt) n -> do
x' <- random mt
let x = floor ((x' :: Double) * realToFrac n)
x `seq` return (Just x, noiseR)
wackelkontakt :: Wire a Bool
wackelkontakt = noiseGen