module Control.Wire.Prefab.Random
(
noise,
noiseR,
noiseF,
noiseF1,
wackelkontakt
)
where
import Control.Arrow
import Control.Wire.Classes
import Control.Wire.Types
import System.Random
noise :: (ArrowRandom (>~), Random b) => Wire e (>~) a b
noise = mkFix $ arr Right <<< arrRand
noiseF :: ArrowRandom (>~) => Wire e (>~) a Double
noiseF = noise
noiseF1 :: ArrowRandom (>~) => Wire e (>~) a Double
noiseF1 = mkFix (arr (Right . (*2) . pred) <<< arrRand)
noiseR :: (ArrowRandom (>~), Random b) => Wire e (>~) (b, b) b
noiseR = mkFix $ arr Right <<< arrRandR
wackelkontakt :: ArrowRandom (>~) => Wire e (>~) Double Bool
wackelkontakt =
mkFix $ proc p -> do
s <- arrRand -< ()
returnA -< Right (not (s >= p))