{-#Language BangPatterns, TupleSections, FlexibleContexts #-}
module Csound.Control.Evt(
Evt(..), Bam, Tick,
boolToEvt, evtToBool, evtToTrig, sigToEvt, evtToSig, stepper,
filterE, filterSE, accumSE, accumE, filterAccumE, filterAccumSE,
Snap, snapshot, readSnap, snaps, snaps2, sync, syncBpm,
metro, gaussTrig, dust, metroSig, dustSig, dustSig2, impulseE, changedE, triggerE, loadbang, impulse, metroE, delEvt,
devt, eventList,
cycleE, iterateE, repeatE, appendE, mappendE, partitionE,
takeE, dropE, takeWhileE, dropWhileE,
splitToggle, toTog, toTog1,
Rnds,
oneOf, freqOf, freqAccum,
randDs, randList, randInts, randSkip, randSkipBy,
range, listAt,
every, masked
) where
import Data.Default
import Data.Boolean
import Data.Tuple
import Temporal.Media
import Csound.Typed hiding (evtToBool)
import Csound.Typed.Opcode hiding (metro, dust, dust2)
import qualified Csound.Typed.Opcode as O(metro, dust, dust2)
import Csound.Types(atArg)
type Tick = Evt Unit
evtToSig :: D -> (Evt D) -> Sig
evtToSig :: D -> Evt D -> Sig
evtToSig D
initVal Evt D
evts = (D -> SE Sig) -> Evt [D] -> Sig
forall a b. (Arg a, Sigs b) => (a -> SE b) -> Evt [a] -> b
retrigs (Sig -> SE Sig
forall a. a -> SE a
forall (m :: * -> *) a. Monad m => a -> m a
return (Sig -> SE Sig) -> (D -> Sig) -> D -> SE Sig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. D -> Sig
sig) (Evt [D] -> Sig) -> Evt [D] -> Sig
forall a b. (a -> b) -> a -> b
$ (D -> [D]) -> Evt D -> Evt [D]
forall a b. (a -> b) -> Evt a -> Evt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap D -> [D]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Evt D -> Evt [D]) -> Evt D -> Evt [D]
forall a b. (a -> b) -> a -> b
$ D -> Evt Unit -> Evt D
forall a. D -> Evt a -> Evt D
devt D
initVal Evt Unit
loadbang Evt D -> Evt D -> Evt D
forall a. Semigroup a => a -> a -> a
<> Evt D
evts
evtToBool :: Evt a -> BoolSig
evtToBool :: forall a. Evt a -> BoolSig
evtToBool Evt a
a = ( Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* Sig
1) (Sig -> BoolSig) -> Sig -> BoolSig
forall a b. (a -> b) -> a -> b
$ [Sig] -> Sig
changed ([Sig] -> Sig) -> [Sig] -> Sig
forall a b. (a -> b) -> a -> b
$ Sig -> [Sig]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (Sig -> [Sig]) -> Sig -> [Sig]
forall a b. (a -> b) -> a -> b
$ D -> Evt D -> Sig
evtToSig D
0 (Evt D -> Sig) -> Evt D -> Sig
forall a b. (a -> b) -> a -> b
$ [D] -> Evt a -> Evt D
forall a b. (Tuple a, Arg a) => [a] -> Evt b -> Evt a
cycleE [D
1, D
0] Evt a
a
evtToTrig :: Evt a -> Sig
evtToTrig :: forall a. Evt a -> Sig
evtToTrig = (\BoolSig
b -> BoolSig -> Sig -> Sig -> Sig
forall bool. (bool ~ BooleanOf Sig) => bool -> Sig -> Sig -> Sig
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB BoolSig
b Sig
1 Sig
0) (BoolSig -> Sig) -> (Evt a -> BoolSig) -> Evt a -> Sig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Evt a -> BoolSig
forall a. Evt a -> BoolSig
evtToBool
devt :: D -> Evt a -> Evt D
devt :: forall a. D -> Evt a -> Evt D
devt D
d = (a -> D) -> Evt a -> Evt D
forall a b. (a -> b) -> Evt a -> Evt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (D -> a -> D
forall a b. a -> b -> a
const D
d)
{-# DEPRECATED metroE "Use metro instead" #-}
metroE :: Sig -> Evt Unit
metroE :: Sig -> Evt Unit
metroE = Sig -> Evt Unit
sigToEvt (Sig -> Evt Unit) -> (Sig -> Sig) -> Sig -> Evt Unit
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sig -> Sig
O.metro
metro :: Sig -> Evt Unit
metro :: Sig -> Evt Unit
metro = Sig -> Evt Unit
sigToEvt (Sig -> Evt Unit) -> (Sig -> Sig) -> Sig -> Evt Unit
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sig -> Sig
O.metro
metroSig :: Sig -> Sig
metroSig :: Sig -> Sig
metroSig = Sig -> Sig
O.metro
gaussTrig :: Sig -> Sig -> Tick
gaussTrig :: Sig -> Sig -> Evt Unit
gaussTrig Sig
afreq Sig
adev = (Bam Unit -> SE ()) -> Evt Unit
forall a. (Bam a -> SE ()) -> Evt a
Evt ((Bam Unit -> SE ()) -> Evt Unit)
-> (Bam Unit -> SE ()) -> Evt Unit
forall a b. (a -> b) -> a -> b
$ \Bam Unit
bam -> do
Sig
thresh <- Sig -> Sig -> Sig -> SE Sig
gausstrig Sig
1 (Sig
afreq Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* D -> Sig
sig D
getBlockSize) Sig
adev
BoolSig -> SE () -> SE ()
when1 (Sig
thresh Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
>* Sig
0.5) (SE () -> SE ()) -> SE () -> SE ()
forall a b. (a -> b) -> a -> b
$ Bam Unit
bam Unit
unit
dust :: Sig -> Tick
dust :: Sig -> Evt Unit
dust Sig
freq = (Bam Unit -> SE ()) -> Evt Unit
forall a. (Bam a -> SE ()) -> Evt a
Evt ((Bam Unit -> SE ()) -> Evt Unit)
-> (Bam Unit -> SE ()) -> Evt Unit
forall a b. (a -> b) -> a -> b
$ \Bam Unit
bam -> do
Sig
thresh <- Sig -> Sig -> SE Sig
O.dust Sig
1 (Sig
freq Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* D -> Sig
sig D
getBlockSize)
BoolSig -> SE () -> SE ()
when1 (Sig
thresh Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
>* Sig
0.5) (SE () -> SE ()) -> SE () -> SE ()
forall a b. (a -> b) -> a -> b
$ Bam Unit
bam Unit
unit
dustSig :: Sig -> SE Sig
dustSig :: Sig -> SE Sig
dustSig Sig
freq = Sig -> Sig -> SE Sig
O.dust Sig
1 (Sig
freq Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* D -> Sig
sig D
getBlockSize)
dustSig2 :: Sig -> SE Sig
dustSig2 :: Sig -> SE Sig
dustSig2 Sig
freq = Sig -> Sig -> SE Sig
O.dust2 Sig
1 (Sig
freq Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
* D -> Sig
sig D
getBlockSize)
loadbang :: Evt Unit
loadbang :: Evt Unit
loadbang = D -> Evt Unit
impulseE D
0
impulse :: D -> Sig
impulse :: D -> Sig
impulse D
dt = Sig -> Sig
downsamp (Sig -> Sig -> Sig
mpulse (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ D
getBlockSize) Sig
0 Sig -> D -> Sig
forall a. Tuple a => a -> D -> a
`withD` D
dt) Sig -> D -> Sig
forall a. Tuple a => a -> D -> a
`withD` D
getBlockSize
impulseE :: D -> Evt Unit
impulseE :: D -> Evt Unit
impulseE = Sig -> Evt Unit
sigToEvt (Sig -> Evt Unit) -> (D -> Sig) -> D -> Evt Unit
forall b c a. (b -> c) -> (a -> b) -> a -> c
. D -> Sig
impulse
eventList :: [(Sig, Sig, a)] -> Evt (Sco a)
eventList :: forall a. [(Sig, Sig, a)] -> Evt (Sco a)
eventList [(Sig, Sig, a)]
es = (Unit -> Sco a) -> Evt Unit -> Evt (Sco a)
forall a b. (a -> b) -> Evt a -> Evt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Sco a -> Unit -> Sco a
forall a b. a -> b -> a
const (Sco a -> Unit -> Sco a) -> Sco a -> Unit -> Sco a
forall a b. (a -> b) -> a -> b
$ [Sco a] -> Sco a
forall a. Harmony a => [a] -> a
har ([Sco a] -> Sco a) -> [Sco a] -> Sco a
forall a b. (a -> b) -> a -> b
$ ((Sig, Sig, a) -> Sco a) -> [(Sig, Sig, a)] -> [Sco a]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Sig, Sig, a) -> Sco a
forall {t} {a}. Num t => (t, t, a) -> Track t a
single [(Sig, Sig, a)]
es) Evt Unit
loadbang
where single :: (t, t, a) -> Track t a
single (t
start, t
duration, a
content) = DurOf (Track t a) -> Track t a -> Track t a
forall a. Delay a => DurOf a -> a -> a
del t
DurOf (Track t a)
start (Track t a -> Track t a) -> Track t a -> Track t a
forall a b. (a -> b) -> a -> b
$ DurOf (Track t a) -> Track t a -> Track t a
forall a. Stretch a => DurOf a -> a -> a
str t
DurOf (Track t a)
duration (Track t a -> Track t a) -> Track t a -> Track t a
forall a b. (a -> b) -> a -> b
$ a -> Track t a
forall t a. Num t => a -> Track t a
temp a
content
changedE :: [Sig] -> Evt Unit
changedE :: [Sig] -> Evt Unit
changedE = Sig -> Evt Unit
sigToEvt (Sig -> Evt Unit) -> ([Sig] -> Sig) -> [Sig] -> Evt Unit
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Sig] -> Sig
changed
triggerE :: Sig -> Sig -> Sig -> Evt Unit
triggerE :: Sig -> Sig -> Sig -> Evt Unit
triggerE Sig
a1 Sig
a2 Sig
a3 = Sig -> Evt Unit
sigToEvt (Sig -> Evt Unit) -> Sig -> Evt Unit
forall a b. (a -> b) -> a -> b
$ Sig -> Sig -> Sig -> Sig
trigger Sig
a1 Sig
a2 Sig
a3
syncBpm :: (Default a, Tuple a) => Sig -> Evt a -> Evt a
syncBpm :: forall a. (Default a, Tuple a) => Sig -> Evt a -> Evt a
syncBpm Sig
dt = Sig -> Evt a -> Evt a
forall a. (Default a, Tuple a) => Sig -> Evt a -> Evt a
sync (Sig
dt Sig -> Sig -> Sig
forall a. Fractional a => a -> a -> a
/ Sig
60)
partitionE :: (a -> BoolSig) -> Evt a -> (Evt a, Evt a)
partitionE :: forall a. (a -> BoolSig) -> Evt a -> (Evt a, Evt a)
partitionE a -> BoolSig
p Evt a
evts = (Evt a
a, Evt a
b)
where
a :: Evt a
a = (a -> BoolSig) -> Evt a -> Evt a
forall a. (a -> BoolSig) -> Evt a -> Evt a
filterE a -> BoolSig
p Evt a
evts
b :: Evt a
b = (a -> BoolSig) -> Evt a -> Evt a
forall a. (a -> BoolSig) -> Evt a -> Evt a
filterE (BoolSig -> BoolSig
forall b. Boolean b => b -> b
notB (BoolSig -> BoolSig) -> (a -> BoolSig) -> a -> BoolSig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> BoolSig
p) Evt a
evts
splitToggle :: Evt D -> (Evt D, Evt D)
splitToggle :: Evt D -> (Evt D, Evt D)
splitToggle = (Evt D, Evt D) -> (Evt D, Evt D)
forall a b. (a, b) -> (b, a)
swap ((Evt D, Evt D) -> (Evt D, Evt D))
-> (Evt D -> (Evt D, Evt D)) -> Evt D -> (Evt D, Evt D)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (D -> BoolSig) -> Evt D -> (Evt D, Evt D)
forall a. (a -> BoolSig) -> Evt a -> (Evt a, Evt a)
partitionE ((Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* Sig
0) (Sig -> BoolSig) -> (D -> Sig) -> D -> BoolSig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. D -> Sig
sig)
snaps2 :: Sig2 -> Evt (D, D)
snaps2 :: (Sig, Sig) -> Evt (D, D)
snaps2 (Sig
x, Sig
y) = (Snap (Sig, Sig) -> Unit -> (D, D))
-> (Sig, Sig) -> Evt Unit -> Evt (D, D)
forall a b c.
(Tuple a, Tuple (Snap a)) =>
(Snap a -> b -> c) -> a -> Evt b -> Evt c
snapshot (D, D) -> Unit -> (D, D)
Snap (Sig, Sig) -> Unit -> (D, D)
forall a b. a -> b -> a
const (Sig
x, Sig
y) Evt Unit
triggerSig
where
triggerSig :: Evt Unit
triggerSig = Sig -> Evt Unit
sigToEvt (Sig -> Evt Unit) -> Sig -> Evt Unit
forall a b. (a -> b) -> a -> b
$ [Sig] -> Sig
changed [Sig
x, Sig
y]
cycleE :: (Tuple a, Arg a) => [a] -> Evt b -> Evt a
cycleE :: forall a b. (Tuple a, Arg a) => [a] -> Evt b -> Evt a
cycleE [a]
vals Evt b
evts = [a] -> Evt Sig -> Evt a
forall a. (Tuple a, Arg a) => [a] -> Evt Sig -> Evt a
listAt [a]
vals (Evt Sig -> Evt a) -> Evt Sig -> Evt a
forall a b. (a -> b) -> a -> b
$ (D, D) -> Evt b -> Evt Sig
forall b. (D, D) -> Evt b -> Evt Sig
range (D
0, Int -> D
int (Int -> D) -> Int -> D
forall a b. (a -> b) -> a -> b
$ [a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
vals) Evt b
evts
listAt :: (Tuple a, Arg a) => [a] -> Evt Sig -> Evt a
listAt :: forall a. (Tuple a, Arg a) => [a] -> Evt Sig -> Evt a
listAt [a]
vals Evt Sig
evt
| [a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
vals = Evt a
forall a. Monoid a => a
mempty
| Bool
otherwise = (Sig -> a) -> Evt Sig -> Evt a
forall a b. (a -> b) -> Evt a -> Evt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([a] -> Sig -> a
forall a. Tuple a => [a] -> Sig -> a
atArg [a]
vals) (Evt Sig -> Evt a) -> Evt Sig -> Evt a
forall a b. (a -> b) -> a -> b
$ (Sig -> BoolSig) -> Evt Sig -> Evt Sig
forall a. (a -> BoolSig) -> Evt a -> Evt a
filterE Sig -> BoolSig
withinBounds Evt Sig
evt
where
withinBounds :: Sig -> BoolSig
withinBounds Sig
x = (Sig
x Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
>=* Sig
0) BoolSig -> BoolSig -> BoolSig
forall b. Boolean b => b -> b -> b
&&* (Sig
x Sig -> Sig -> BooleanOf Sig
forall a. OrdB a => a -> a -> BooleanOf a
`lessThan` D -> Sig
sig D
len)
len :: D
len = Int -> D
int (Int -> D) -> Int -> D
forall a b. (a -> b) -> a -> b
$ [a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
vals
range :: (D, D) -> Evt b -> Evt Sig
range :: forall b. (D, D) -> Evt b -> Evt Sig
range (D
xMin, D
xMax) = Sig -> (Sig -> Sig) -> Evt b -> Evt Sig
forall a b. Tuple a => a -> (a -> a) -> Evt b -> Evt a
iterateE (D -> Sig
sig D
xMin) ((Sig -> Sig) -> Evt b -> Evt Sig)
-> (Sig -> Sig) -> Evt b -> Evt Sig
forall a b. (a -> b) -> a -> b
$ \Sig
x -> BoolSig -> Sig -> Sig -> Sig
forall bool. (bool ~ BooleanOf Sig) => bool -> Sig -> Sig -> Sig
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB ((Sig
x Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
+ Sig
1) Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
>=* D -> Sig
sig D
xMax) (D -> Sig
sig D
xMin) (Sig
x Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
+ Sig
1)
randInts :: (D, D) -> Evt b -> Evt Sig
randInts :: forall b. (D, D) -> Evt b -> Evt Sig
randInts (D
xMin, D
xMax) = Sig -> (b -> Sig -> SE (Sig, Sig)) -> Evt b -> Evt Sig
forall s a b.
Tuple s =>
s -> (a -> s -> SE (b, s)) -> Evt a -> Evt b
accumSE (Sig
0 :: Sig) ((b -> Sig -> SE (Sig, Sig)) -> Evt b -> Evt Sig)
-> (b -> Sig -> SE (Sig, Sig)) -> Evt b -> Evt Sig
forall a b. (a -> b) -> a -> b
$ (Sig -> SE (Sig, Sig)) -> b -> Sig -> SE (Sig, Sig)
forall a b. a -> b -> a
const ((Sig -> SE (Sig, Sig)) -> b -> Sig -> SE (Sig, Sig))
-> (Sig -> SE (Sig, Sig)) -> b -> Sig -> SE (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ \Sig
s -> (Sig -> (Sig, Sig)) -> SE Sig -> SE (Sig, Sig)
forall a b. (a -> b) -> SE a -> SE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (, Sig
s) (SE Sig -> SE (Sig, Sig)) -> SE Sig -> SE (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ SE Sig
getRnd
where getRnd :: SE Sig
getRnd = (Sig -> Sig) -> SE Sig -> SE Sig
forall a b. (a -> b) -> SE a -> SE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Sig -> Sig
forall a. SigOrD a => a -> a
int' (SE Sig -> SE Sig) -> SE Sig -> SE Sig
forall a b. (a -> b) -> a -> b
$ Sig -> Sig -> SE Sig
forall a. SigOrD a => a -> a -> SE a
random (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ D -> D
forall a. SigOrD a => a -> a
int' D
xMin) (D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ D -> D
forall a. SigOrD a => a -> a
int' D
xMax)
randDs :: Evt b -> Evt D
randDs :: forall b. Evt b -> Evt D
randDs = Sig -> (b -> Sig -> SE (D, Sig)) -> Evt b -> Evt D
forall s a b.
Tuple s =>
s -> (a -> s -> SE (b, s)) -> Evt a -> Evt b
accumSE (Sig
0 ::Sig) ((b -> Sig -> SE (D, Sig)) -> Evt b -> Evt D)
-> (b -> Sig -> SE (D, Sig)) -> Evt b -> Evt D
forall a b. (a -> b) -> a -> b
$ (Sig -> SE (D, Sig)) -> b -> Sig -> SE (D, Sig)
forall a b. a -> b -> a
const ((Sig -> SE (D, Sig)) -> b -> Sig -> SE (D, Sig))
-> (Sig -> SE (D, Sig)) -> b -> Sig -> SE (D, Sig)
forall a b. (a -> b) -> a -> b
$ \Sig
s -> (D -> (D, Sig)) -> SE D -> SE (D, Sig)
forall a b. (a -> b) -> SE a -> SE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (, Sig
s) (SE D -> SE (D, Sig)) -> SE D -> SE (D, Sig)
forall a b. (a -> b) -> a -> b
$ (Sig -> D) -> SE Sig -> SE D
forall a b. (a -> b) -> SE a -> SE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Sig -> D
Sig -> Snap Sig
forall a. (Tuple (Snap a), Tuple a) => a -> Snap a
readSnap (SE Sig -> SE D) -> SE Sig -> SE D
forall a b. (a -> b) -> a -> b
$ Sig -> Sig -> SE Sig
forall a. SigOrD a => a -> a -> SE a
random (Sig
0::Sig) Sig
1
randList :: Int -> Evt b -> Evt [D]
randList :: forall b. Int -> Evt b -> Evt [D]
randList Int
n = D -> (b -> D -> SE ([D], D)) -> Evt b -> Evt [D]
forall s a b.
Tuple s =>
s -> (a -> s -> SE (b, s)) -> Evt a -> Evt b
accumSE (D
0 :: D) ((b -> D -> SE ([D], D)) -> Evt b -> Evt [D])
-> (b -> D -> SE ([D], D)) -> Evt b -> Evt [D]
forall a b. (a -> b) -> a -> b
$ (D -> SE ([D], D)) -> b -> D -> SE ([D], D)
forall a b. a -> b -> a
const ((D -> SE ([D], D)) -> b -> D -> SE ([D], D))
-> (D -> SE ([D], D)) -> b -> D -> SE ([D], D)
forall a b. (a -> b) -> a -> b
$ \D
s -> ([D] -> ([D], D)) -> SE [D] -> SE ([D], D)
forall a b. (a -> b) -> SE a -> SE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (, D
s) (SE [D] -> SE ([D], D)) -> SE [D] -> SE ([D], D)
forall a b. (a -> b) -> a -> b
$
[SE D] -> SE [D]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence ([SE D] -> SE [D]) -> [SE D] -> SE [D]
forall a b. (a -> b) -> a -> b
$ Int -> SE D -> [SE D]
forall a. Int -> a -> [a]
replicate Int
n (SE D -> [SE D]) -> SE D -> [SE D]
forall a b. (a -> b) -> a -> b
$ (D -> D) -> SE D -> SE D
forall a b. (a -> b) -> SE a -> SE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap D -> D
D -> Snap D
forall a. (Tuple (Snap a), Tuple a) => a -> Snap a
readSnap (SE D -> SE D) -> SE D -> SE D
forall a b. (a -> b) -> a -> b
$ D -> D -> SE D
forall a. SigOrD a => a -> a -> SE a
random (D
0::D) D
1
randSkip :: Sig -> Evt a -> Evt a
randSkip :: forall a. Sig -> Evt a -> Evt a
randSkip Sig
d = (a -> SE BoolSig) -> Evt a -> Evt a
forall a. (a -> SE BoolSig) -> Evt a -> Evt a
filterSE (SE BoolSig -> a -> SE BoolSig
forall a b. a -> b -> a
const (SE BoolSig -> a -> SE BoolSig) -> SE BoolSig -> a -> SE BoolSig
forall a b. (a -> b) -> a -> b
$ (Sig -> BoolSig) -> SE Sig -> SE BoolSig
forall a b. (a -> b) -> SE a -> SE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
<=* Sig
d) (SE Sig -> SE BoolSig) -> SE Sig -> SE BoolSig
forall a b. (a -> b) -> a -> b
$ Sig -> Sig -> SE Sig
forall a. SigOrD a => a -> a -> SE a
random (Sig
0::Sig) Sig
1)
randSkipBy :: (a -> Sig) -> Evt a -> Evt a
randSkipBy :: forall a. (a -> Sig) -> Evt a -> Evt a
randSkipBy a -> Sig
d = (a -> SE BoolSig) -> Evt a -> Evt a
forall a. (a -> SE BoolSig) -> Evt a -> Evt a
filterSE (\a
x -> (Sig -> BoolSig) -> SE Sig -> SE BoolSig
forall a b. (a -> b) -> SE a -> SE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
<=* a -> Sig
d a
x) (SE Sig -> SE BoolSig) -> SE Sig -> SE BoolSig
forall a b. (a -> b) -> a -> b
$ Sig -> Sig -> SE Sig
forall a. SigOrD a => a -> a -> SE a
random (Sig
0::Sig) Sig
1)
iterateE :: (Tuple a) => a -> (a -> a) -> Evt b -> Evt a
iterateE :: forall a b. Tuple a => a -> (a -> a) -> Evt b -> Evt a
iterateE a
s0 a -> a
f = a -> (b -> a -> (a, a)) -> Evt b -> Evt a
forall s a b. Tuple s => s -> (a -> s -> (b, s)) -> Evt a -> Evt b
accumE a
s0 ((a -> (a, a)) -> b -> a -> (a, a)
forall a b. a -> b -> a
const a -> (a, a)
phi)
where phi :: a -> (a, a)
phi a
s = (a
s, a -> a
f a
s)
repeatE :: Tuple a => a -> Evt b -> Evt a
repeatE :: forall a b. Tuple a => a -> Evt b -> Evt a
repeatE a
a = (b -> a) -> Evt b -> Evt a
forall a b. (a -> b) -> Evt a -> Evt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> b -> a
forall a b. a -> b -> a
const a
a)
appendE :: Tuple a => a -> (a -> a -> a) -> Evt a -> Evt a
appendE :: forall a. Tuple a => a -> (a -> a -> a) -> Evt a -> Evt a
appendE a
empty a -> a -> a
append = a -> (a -> a -> (a, a)) -> Evt a -> Evt a
forall s a b. Tuple s => s -> (a -> s -> (b, s)) -> Evt a -> Evt b
accumE a
empty a -> a -> (a, a)
phi
where phi :: a -> a -> (a, a)
phi a
a a
s = let s1 :: a
s1 = a
s a -> a -> a
`append` a
a in (a
s1, a
s1)
mappendE :: (Monoid a, Tuple a) => Evt a -> Evt a
mappendE :: forall a. (Monoid a, Tuple a) => Evt a -> Evt a
mappendE = a -> (a -> a -> a) -> Evt a -> Evt a
forall a. Tuple a => a -> (a -> a -> a) -> Evt a -> Evt a
appendE a
forall a. Monoid a => a
mempty a -> a -> a
forall a. Monoid a => a -> a -> a
mappend
oneOf :: (Tuple a, Arg a) => [a] -> Evt b -> Evt a
oneOf :: forall a b. (Tuple a, Arg a) => [a] -> Evt b -> Evt a
oneOf [a]
vals Evt b
evt = [a] -> Evt Sig -> Evt a
forall a. (Tuple a, Arg a) => [a] -> Evt Sig -> Evt a
listAt [a]
vals (Evt Sig -> Evt a) -> Evt Sig -> Evt a
forall a b. (a -> b) -> a -> b
$ (D, D) -> Evt b -> Evt Sig
forall b. (D, D) -> Evt b -> Evt Sig
randInts (D
0, Int -> D
int (Int -> D) -> Int -> D
forall a b. (a -> b) -> a -> b
$ [a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
vals) Evt b
evt
type Rnds a = [(Sig, a)]
freqOf :: (Tuple a, Arg a) => Rnds a -> Evt b -> Evt a
freqOf :: forall a b. (Tuple a, Arg a) => Rnds a -> Evt b -> Evt a
freqOf Rnds a
rnds Evt b
evt = (D -> a) -> Evt D -> Evt a
forall a b. (a -> b) -> Evt a -> Evt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([Sig] -> [a] -> D -> a
forall a. (Tuple a, Arg a) => [Sig] -> [a] -> D -> a
takeByWeight [Sig]
accs [a]
vals) (Evt D -> Evt a) -> Evt D -> Evt a
forall a b. (a -> b) -> a -> b
$ Evt b -> Evt D
forall b. Evt b -> Evt D
randDs Evt b
evt
where
accs :: [Sig]
accs = [Sig] -> [Sig]
forall a. Num a => [a] -> [a]
accumWeightList ([Sig] -> [Sig]) -> [Sig] -> [Sig]
forall a b. (a -> b) -> a -> b
$ ((Sig, a) -> Sig) -> Rnds a -> [Sig]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Sig, a) -> Sig
forall a b. (a, b) -> a
fst Rnds a
rnds
vals :: [a]
vals = ((Sig, a) -> a) -> Rnds a -> [a]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Sig, a) -> a
forall a b. (a, b) -> b
snd Rnds a
rnds
takeByWeight :: (Tuple a, Arg a) => [Sig] -> [a] -> D -> a
takeByWeight :: forall a. (Tuple a, Arg a) => [Sig] -> [a] -> D -> a
takeByWeight [Sig]
accumWeights [a]
vals D
atD =
[(BoolSig, a)] -> a -> a
forall b. Tuple b => [(BoolSig, b)] -> b -> b
guardedTuple ((Sig -> a -> (BoolSig, a)) -> [Sig] -> [a] -> [(BoolSig, a)]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith (\Sig
w a
val -> (D -> Sig
sig D
atD Sig -> Sig -> BooleanOf Sig
forall a. OrdB a => a -> a -> BooleanOf a
`lessThan` Sig
w, a
val)) [Sig]
accumWeights [a]
vals) ([a] -> a
forall a. HasCallStack => [a] -> a
last [a]
vals)
accumWeightList :: Num a => [a] -> [a]
accumWeightList :: forall a. Num a => [a] -> [a]
accumWeightList = a -> [a] -> [a]
forall {t}. Num t => t -> [t] -> [t]
go a
0
where go :: t -> [t] -> [t]
go !t
s [t]
xs = case [t]
xs of
[] -> []
t
a:[t]
as -> t
a t -> t -> t
forall a. Num a => a -> a -> a
+ t
s t -> [t] -> [t]
forall a. a -> [a] -> [a]
: t -> [t] -> [t]
go (t
a t -> t -> t
forall a. Num a => a -> a -> a
+ t
s) [t]
as
freqAccum :: (Arg b, Arg s)
=> s -> (a -> s -> Rnds (b, s)) -> Evt a -> Evt b
freqAccum :: forall b s a.
(Arg b, Arg s) =>
s -> (a -> s -> Rnds (b, s)) -> Evt a -> Evt b
freqAccum s
s0 a -> s -> Rnds (b, s)
f = s -> (a -> s -> SE (b, s)) -> Evt a -> Evt b
forall s a b.
Tuple s =>
s -> (a -> s -> SE (b, s)) -> Evt a -> Evt b
accumSE s
s0 ((a -> s -> SE (b, s)) -> Evt a -> Evt b)
-> (a -> s -> SE (b, s)) -> Evt a -> Evt b
forall a b. (a -> b) -> a -> b
$ \a
a s
s ->
let rnds :: Rnds (b, s)
rnds = a -> s -> Rnds (b, s)
f a
a s
s
accs :: [Sig]
accs = [Sig] -> [Sig]
forall a. Num a => [a] -> [a]
accumWeightList ([Sig] -> [Sig]) -> [Sig] -> [Sig]
forall a b. (a -> b) -> a -> b
$ ((Sig, (b, s)) -> Sig) -> Rnds (b, s) -> [Sig]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Sig, (b, s)) -> Sig
forall a b. (a, b) -> a
fst Rnds (b, s)
rnds
vals :: [(b, s)]
vals = ((Sig, (b, s)) -> (b, s)) -> Rnds (b, s) -> [(b, s)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Sig, (b, s)) -> (b, s)
forall a b. (a, b) -> b
snd Rnds (b, s)
rnds
in (D -> (b, s)) -> SE D -> SE (b, s)
forall a b. (a -> b) -> SE a -> SE b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([Sig] -> [(b, s)] -> D -> (b, s)
forall a. (Tuple a, Arg a) => [Sig] -> [a] -> D -> a
takeByWeight [Sig]
accs [(b, s)]
vals (D -> (b, s)) -> (D -> D) -> D -> (b, s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. D -> D
D -> Snap D
forall a. (Tuple (Snap a), Tuple a) => a -> Snap a
readSnap) (SE D -> SE (b, s)) -> SE D -> SE (b, s)
forall a b. (a -> b) -> a -> b
$ D -> D -> SE D
forall a. SigOrD a => a -> a -> SE a
random (D
0 :: D) D
1
every :: (Tuple a, Arg a) => Int -> [Int] -> Evt a -> Evt a
every :: forall a. (Tuple a, Arg a) => Int -> [Int] -> Evt a -> Evt a
every Int
empties [Int]
beats = [Sig] -> Evt a -> Evt a
forall a. Tuple a => [Sig] -> Evt a -> Evt a
masked [Sig]
mask
where mask :: [Sig]
mask = ((Bool -> Sig) -> [Bool] -> [Sig]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\Bool
x -> if Bool
x then Sig
1 else Sig
0) ([Bool] -> [Sig]) -> [Bool] -> [Sig]
forall a b. (a -> b) -> a -> b
$ (Int -> Bool -> [Bool]
forall a. Int -> a -> [a]
replicate Int
empties Bool
False) [Bool] -> [Bool] -> [Bool]
forall a. [a] -> [a] -> [a]
++ [Int] -> [Bool]
patternToMask [Int]
beats)
masked :: (Tuple a) => [Sig] -> Evt a -> Evt a
masked :: forall a. Tuple a => [Sig] -> Evt a -> Evt a
masked [Sig]
ms = Sig -> (a -> Sig -> (BoolSig, a, Sig)) -> Evt a -> Evt a
forall s a b.
Tuple s =>
s -> (a -> s -> (BoolSig, b, s)) -> Evt a -> Evt b
filterAccumE Sig
0 ((a -> Sig -> (BoolSig, a, Sig)) -> Evt a -> Evt a)
-> (a -> Sig -> (BoolSig, a, Sig)) -> Evt a -> Evt a
forall a b. (a -> b) -> a -> b
$ \a
a Sig
s ->
let n :: Sig
n = D -> Sig
sig (D -> Sig) -> D -> Sig
forall a b. (a -> b) -> a -> b
$ Int -> D
int (Int -> D) -> Int -> D
forall a b. (a -> b) -> a -> b
$ [Sig] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Sig]
ms
s1 :: Sig
s1 = BooleanOf Sig -> Sig -> Sig -> Sig
forall bool. (bool ~ BooleanOf Sig) => bool -> Sig -> Sig -> Sig
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB (Sig
s Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
+ Sig
1 Sig -> Sig -> BooleanOf Sig
forall a. OrdB a => a -> a -> BooleanOf a
`lessThan` Sig
n) (Sig
s Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
+ Sig
1) Sig
0
in ([Sig] -> Sig -> Sig
forall a. Tuple a => [a] -> Sig -> a
atArg [Sig]
ms Sig
s Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* Sig
1, a
a, Sig
s1)
patternToMask :: [Int] -> [Bool]
patternToMask :: [Int] -> [Bool]
patternToMask [Int]
xs = case [Int]
xs of
[] -> []
Int
a:[Int]
as -> Int -> [Bool]
single Int
a [Bool] -> [Bool] -> [Bool]
forall a. [a] -> [a] -> [a]
++ [Int] -> [Bool]
patternToMask [Int]
as
where single :: Int -> [Bool]
single Int
n
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = []
| Bool
otherwise = Bool
True Bool -> [Bool] -> [Bool]
forall a. a -> [a] -> [a]
: Int -> Bool -> [Bool]
forall a. Int -> a -> [a]
replicate (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Bool
False
togGen :: D -> Tick -> Evt D
togGen :: D -> Evt Unit -> Evt D
togGen D
n = D -> (Unit -> D -> (D, D)) -> Evt Unit -> Evt D
forall s a b. Tuple s => s -> (a -> s -> (b, s)) -> Evt a -> Evt b
accumE D
n (\Unit
_ D
s -> let v :: D
v = (D -> D -> D
forall a. SigOrD a => a -> a -> a
mod' (D
s D -> D -> D
forall a. Num a => a -> a -> a
+ D
1) D
2) in (D
v, D
v))
toTog :: Tick -> Evt D
toTog :: Evt Unit -> Evt D
toTog = D -> Evt Unit -> Evt D
togGen D
1
toTog1 :: Tick -> Evt D
toTog1 :: Evt Unit -> Evt D
toTog1 = D -> Evt Unit -> Evt D
togGen D
0
mkRow :: Evt a -> Evt (a, Sig)
mkRow :: forall a. Evt a -> Evt (a, Sig)
mkRow = Sig -> (a -> Sig -> ((a, Sig), Sig)) -> Evt a -> Evt (a, Sig)
forall s a b. Tuple s => s -> (a -> s -> (b, s)) -> Evt a -> Evt b
accumE (Sig
0 :: Sig) (\a
a Sig
s -> ((a
a, Sig
s), Sig
s Sig -> Sig -> Sig
forall a. Num a => a -> a -> a
+ Sig
1) )
filterRow :: (Sig -> BoolSig) -> Evt a -> Evt a
filterRow :: forall a. (Sig -> BoolSig) -> Evt a -> Evt a
filterRow Sig -> BoolSig
p = ((a, Sig) -> a) -> Evt (a, Sig) -> Evt a
forall a b. (a -> b) -> Evt a -> Evt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a, Sig) -> a
forall a b. (a, b) -> a
fst (Evt (a, Sig) -> Evt a)
-> (Evt a -> Evt (a, Sig)) -> Evt a -> Evt a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a, Sig) -> BoolSig) -> Evt (a, Sig) -> Evt (a, Sig)
forall a. (a -> BoolSig) -> Evt a -> Evt a
filterE (Sig -> BoolSig
p (Sig -> BoolSig) -> ((a, Sig) -> Sig) -> (a, Sig) -> BoolSig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, Sig) -> Sig
forall a b. (a, b) -> b
snd) (Evt (a, Sig) -> Evt (a, Sig))
-> (Evt a -> Evt (a, Sig)) -> Evt a -> Evt (a, Sig)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Evt a -> Evt (a, Sig)
forall a. Evt a -> Evt (a, Sig)
mkRow
takeE :: Int -> Evt a -> Evt a
takeE :: forall a. Int -> Evt a -> Evt a
takeE Int
n = (Sig -> BoolSig) -> Evt a -> Evt a
forall a. (Sig -> BoolSig) -> Evt a -> Evt a
filterRow ( Sig -> Sig -> BooleanOf Sig
forall a. OrdB a => a -> a -> BooleanOf a
`lessThan` D -> Sig
sig (Int -> D
int Int
n))
dropE :: Int -> Evt a -> Evt a
dropE :: forall a. Int -> Evt a -> Evt a
dropE Int
n = (Sig -> BoolSig) -> Evt a -> Evt a
forall a. (Sig -> BoolSig) -> Evt a -> Evt a
filterRow ( Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (OrdB a, bool ~ BooleanOf a) => a -> a -> bool
>=* D -> Sig
sig (Int -> D
int Int
n))
takeWhileE :: (a -> BoolSig) -> Evt a -> Evt a
takeWhileE :: forall a. (a -> BoolSig) -> Evt a -> Evt a
takeWhileE a -> BoolSig
p = ((a, BoolSig) -> a) -> Evt (a, BoolSig) -> Evt a
forall a b. (a -> b) -> Evt a -> Evt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a, BoolSig) -> a
forall a b. (a, b) -> a
fst (Evt (a, BoolSig) -> Evt a)
-> (Evt a -> Evt (a, BoolSig)) -> Evt a -> Evt a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a, BoolSig) -> BoolSig) -> Evt (a, BoolSig) -> Evt (a, BoolSig)
forall a. (a -> BoolSig) -> Evt a -> Evt a
filterE (a, BoolSig) -> BoolSig
forall a b. (a, b) -> b
snd (Evt (a, BoolSig) -> Evt (a, BoolSig))
-> (Evt a -> Evt (a, BoolSig)) -> Evt a -> Evt (a, BoolSig)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sig
-> (a -> Sig -> ((a, BoolSig), Sig)) -> Evt a -> Evt (a, BoolSig)
forall s a b. Tuple s => s -> (a -> s -> (b, s)) -> Evt a -> Evt b
accumE (Sig
1 :: Sig) (\a
a Sig
s -> let s1 :: BoolSig
s1 = Sig
s Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* Sig
1 BoolSig -> BoolSig -> BoolSig
forall b. Boolean b => b -> b -> b
&&* a -> BoolSig
p a
a in ((a
a, BoolSig
s1), BoolSig -> Sig -> Sig -> Sig
forall bool. (bool ~ BooleanOf Sig) => bool -> Sig -> Sig -> Sig
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB BoolSig
s1 Sig
1 Sig
0))
dropWhileE :: (a -> BoolSig) -> Evt a -> Evt a
dropWhileE :: forall a. (a -> BoolSig) -> Evt a -> Evt a
dropWhileE a -> BoolSig
p = ((a, BoolSig) -> a) -> Evt (a, BoolSig) -> Evt a
forall a b. (a -> b) -> Evt a -> Evt b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a, BoolSig) -> a
forall a b. (a, b) -> a
fst (Evt (a, BoolSig) -> Evt a)
-> (Evt a -> Evt (a, BoolSig)) -> Evt a -> Evt a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a, BoolSig) -> BoolSig) -> Evt (a, BoolSig) -> Evt (a, BoolSig)
forall a. (a -> BoolSig) -> Evt a -> Evt a
filterE (BoolSig -> BoolSig
forall b. Boolean b => b -> b
notB (BoolSig -> BoolSig)
-> ((a, BoolSig) -> BoolSig) -> (a, BoolSig) -> BoolSig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, BoolSig) -> BoolSig
forall a b. (a, b) -> b
snd) (Evt (a, BoolSig) -> Evt (a, BoolSig))
-> (Evt a -> Evt (a, BoolSig)) -> Evt a -> Evt (a, BoolSig)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sig
-> (a -> Sig -> ((a, BoolSig), Sig)) -> Evt a -> Evt (a, BoolSig)
forall s a b. Tuple s => s -> (a -> s -> (b, s)) -> Evt a -> Evt b
accumE (Sig
1 :: Sig) (\a
a Sig
s -> let s1 :: BoolSig
s1 = Sig
s Sig -> Sig -> BoolSig
forall bool. (bool ~ BooleanOf Sig) => Sig -> Sig -> bool
forall a bool. (EqB a, bool ~ BooleanOf a) => a -> a -> bool
==* Sig
1 BoolSig -> BoolSig -> BoolSig
forall b. Boolean b => b -> b -> b
&&* a -> BoolSig
p a
a in ((a
a, BoolSig
s1), BoolSig -> Sig -> Sig -> Sig
forall bool. (bool ~ BooleanOf Sig) => bool -> Sig -> Sig -> Sig
forall a bool. (IfB a, bool ~ BooleanOf a) => bool -> a -> a -> a
ifB BoolSig
s1 Sig
1 Sig
0))
delEvt :: Arg a => D -> Evt a -> Evt a
delEvt :: forall a. Arg a => D -> Evt a -> Evt a
delEvt D
dt Evt a
ev = (Bam a -> SE ()) -> Evt a
forall a. (Bam a -> SE ()) -> Evt a
Evt ((Bam a -> SE ()) -> Evt a) -> (Bam a -> SE ()) -> Evt a
forall a b. (a -> b) -> a -> b
$ \Bam a
bam -> do
InstrRef a
insId <- Bam a -> SE (InstrRef a)
forall a. Arg a => (a -> SE ()) -> SE (InstrRef a)
newInstr Bam a
bam
Evt a -> Bam a -> SE ()
forall a. Evt a -> Bam a -> SE ()
runEvt Evt a
ev (Bam a -> SE ()) -> Bam a -> SE ()
forall a b. (a -> b) -> a -> b
$ \a
a -> InstrRef a -> D -> D -> Bam a
forall a. Arg a => InstrRef a -> D -> D -> a -> SE ()
scheduleEvent InstrRef a
insId D
dt D
0 a
a