Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module reexports most common names and combinators you will need to work with Rhine. It also exports most specific clocks and resampling buffers, so you can import everything in one line:
import FRP.Rhine main :: IO () main = flow $ constMCl (putStrLn "Hello World!") @@ (waitClock :: Millisecond 100)
Synopsis
- class Monad m => MonadIO (m :: Type -> Type) where
- newChan :: IO (Chan a)
- newtype Kleisli (m :: Type -> Type) a b = Kleisli {
- runKleisli :: a -> m b
- class Arrow a => ArrowZero (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where
- zeroArrow :: a b c
- class ArrowZero a => ArrowPlus (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where
- (<+>) :: a b c -> a b c -> a b c
- newtype ArrowMonad (a :: Type -> Type -> Type) b = ArrowMonad (a () b)
- class Arrow a => ArrowLoop (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where
- loop :: a (b, d) (c, d) -> a b c
- class Arrow a => ArrowChoice (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where
- class Arrow a => ArrowApply (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where
- app :: a (a b c, b) c
- class Category a => Arrow (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where
- returnA :: Arrow a => a b b
- leftApp :: ArrowApply a => a b c -> a (Either b d) (Either c d)
- (^>>) :: Arrow a => (b -> c) -> a c d -> a b d
- (^<<) :: Arrow a => (c -> d) -> a b c -> a b d
- (>>^) :: Arrow a => a b c -> (c -> d) -> a b d
- (<<^) :: Arrow a => a c d -> (b -> c) -> a b d
- (>>>) :: forall {k} cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c
- (<<<) :: forall {k} cat (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c
- safe :: forall (m :: Type -> Type) a b e. Monad m => MSF m a b -> MSFExcept m a b e
- safely :: forall (m :: Type -> Type) a b. Monad m => MSFExcept m a b Void -> MSF m a b
- currentInput :: forall (m :: Type -> Type) e b. Monad m => MSFExcept m e b e
- exceptS :: forall (m :: Type -> Type) e a b. (Functor m, Monad m) => MSF (ExceptT e m) a b -> MSF m a (Either e b)
- runMSFExcept :: MSFExcept m a b e -> MSF (ExceptT e m) a b
- getRandomsRS_ :: forall (m :: Type -> Type) b. (MonadRandom m, Random b) => MSF m (b, b) [b]
- getRandomsRS :: forall (m :: Type -> Type) b a. (MonadRandom m, Random b) => (b, b) -> MSF m a [b]
- getRandomsS :: forall (m :: Type -> Type) b a. (MonadRandom m, Random b) => MSF m a [b]
- pauseOn :: Show a => (a -> Bool) -> String -> MSF IO a a
- traceWhen :: (Monad m, Show a) => (a -> Bool) -> (String -> m ()) -> String -> MSF m a a
- traceWith :: (Monad m, Show a) => (String -> m ()) -> String -> MSF m a a
- trace :: Show a => String -> MSF IO a a
- repeatedly :: forall (m :: Type -> Type) a. Monad m => (a -> a) -> a -> MSF m () a
- unfold :: forall (m :: Type -> Type) a b. Monad m => (a -> (b, a)) -> a -> MSF m () b
- mealy :: forall (m :: Type -> Type) a s b. Monad m => (a -> s -> (b, s)) -> s -> MSF m a b
- accumulateWith :: forall (m :: Type -> Type) a s. Monad m => (a -> s -> s) -> s -> MSF m a s
- mappendFrom :: forall n (m :: Type -> Type). (Monoid n, Monad m) => n -> MSF m n n
- mappendS :: forall n (m :: Type -> Type). (Monoid n, Monad m) => MSF m n n
- sumFrom :: forall v s (m :: Type -> Type). (VectorSpace v s, Monad m) => v -> MSF m v v
- sumS :: forall v s (m :: Type -> Type). (VectorSpace v s, Monad m) => MSF m v v
- count :: forall n (m :: Type -> Type) a. (Num n, Monad m) => MSF m a n
- fifo :: forall (m :: Type -> Type) a. Monad m => MSF m [a] (Maybe a)
- next :: forall (m :: Type -> Type) b a. Monad m => b -> MSF m a b -> MSF m a b
- iPost :: forall (m :: Type -> Type) b a. Monad m => b -> MSF m a b -> MSF m a b
- iPre :: forall (m :: Type -> Type) a. Monad m => a -> MSF m a a
- withSideEffect_ :: Monad m => m b -> MSF m a a
- withSideEffect :: Monad m => (a -> m b) -> MSF m a a
- mapMaybeS :: forall (m :: Type -> Type) a b. Monad m => MSF m a b -> MSF m (Maybe a) (Maybe b)
- type MStream (m :: Type -> Type) a = MSF m () a
- type MSink (m :: Type -> Type) a = MSF m a ()
- morphS :: (Monad m2, Monad m1) => (forall c. m1 c -> m2 c) -> MSF m1 a b -> MSF m2 a b
- liftTransS :: forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a b. (MonadTrans t, Monad m, Monad (t m)) => MSF m a b -> MSF (t m) a b
- liftBaseS :: forall (m2 :: Type -> Type) (m1 :: Type -> Type) a b. (Monad m2, MonadBase m1 m2) => MSF m1 a b -> MSF m2 a b
- liftBaseM :: forall (m2 :: Type -> Type) m1 a b. (Monad m2, MonadBase m1 m2) => (a -> m1 b) -> MSF m2 a b
- arrM :: Monad m => (a -> m b) -> MSF m a b
- constM :: Monad m => m b -> MSF m a b
- reactimate :: Monad m => MSF m () () -> m ()
- embed :: Monad m => MSF m a b -> [a] -> m [b]
- feedback :: forall (m :: Type -> Type) c a b. Monad m => c -> MSF m (a, c) (b, c) -> MSF m a b
- morphGS :: Monad m2 => (forall c. (a1 -> m1 (b1, c)) -> a2 -> m2 (b2, c)) -> MSF m1 a1 b1 -> MSF m2 a2 b2
- data MSF (m :: Type -> Type) a b
- catchE :: forall (m :: Type -> Type) e a e'. Monad m => ExceptT e m a -> (e -> ExceptT e' m a) -> ExceptT e' m a
- except :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a
- throwE :: forall (m :: Type -> Type) e a. Monad m => e -> ExceptT e m a
- newtype ExceptT e (m :: Type -> Type) a = ExceptT (m (Either e a))
- type Except e = ExceptT e Identity
- withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a
- withExcept :: (e -> e') -> Except e a -> Except e' a
- runExceptT :: ExceptT e m a -> m (Either e a)
- runExcept :: Except e a -> Either e a
- mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b
- mapExcept :: (Either e a -> Either e' b) -> Except e a -> Except e' b
- class VectorSpace v a | v -> a where
- zeroVector :: v
- (*^) :: a -> v -> v
- (^/) :: v -> a -> v
- (^+^) :: v -> v -> v
- (^-^) :: v -> v -> v
- negateVector :: v -> v
- dot :: v -> v -> a
- norm :: v -> a
- normalize :: v -> v
- data UTCTime
- type family Diff time
- class TimeDifference (Diff time) => TimeDomain time where
- class TimeDifference d where
- difference :: d -> d -> d
- add :: d -> d -> d
- newtype NumTimeDomain a = NumTimeDomain {
- fromNumTimeDomain :: a
- liftPass :: Monad m => Pass w m (Either e a) -> Pass w (ExceptT e m) a
- liftListen :: Monad m => Listen w m (Either e a) -> Listen w (ExceptT e m) a
- liftCallCC :: CallCC m (Either e a) (Either e b) -> CallCC (ExceptT e m) a b
- type IOClock m cl = HoistClock IO m cl
- type LiftClock m t cl = HoistClock m (t m) cl
- data HoistClock m1 m2 cl = HoistClock {
- unhoistedClock :: cl
- monadMorphism :: forall a. m1 a -> m2 a
- data RescaledClockS m cl time tag = RescaledClockS {
- unscaledClockS :: cl
- rescaleS :: RescalingSInit m cl time tag
- data RescaledClockM m cl time = RescaledClockM {
- unscaledClockM :: cl
- rescaleM :: RescalingM m cl time
- data RescaledClock cl time = RescaledClock {
- unscaledClock :: cl
- rescale :: Rescaling cl time
- type RescalingSInit m cl time tag = Time cl -> m (RescalingS m cl time tag, time)
- type RescalingS m cl time tag = MSF m (Time cl, Tag cl) (time, tag)
- type RescalingM m cl time = Time cl -> m time
- type Rescaling cl time = Time cl -> time
- data TimeInfo cl = TimeInfo {}
- class TimeDomain (Time cl) => Clock m cl where
- type RunningClockInit m time tag = m (RunningClock m time tag, time)
- type RunningClock m time tag = MSF m () (time, tag)
- retag :: Time cl1 ~ Time cl2 => (Tag cl1 -> Tag cl2) -> TimeInfo cl1 -> TimeInfo cl2
- rescaleMToSInit :: Monad m => (time1 -> m time2) -> time1 -> m (MSF m (time1, tag) (time2, tag), time2)
- rescaledClockToM :: Monad m => RescaledClock cl time -> RescaledClockM m cl time
- rescaledClockMToS :: Monad m => RescaledClockM m cl time -> RescaledClockS m cl time (Tag cl)
- rescaledClockToS :: Monad m => RescaledClock cl time -> RescaledClockS m cl time (Tag cl)
- liftClock :: (Monad m, MonadTrans t) => cl -> LiftClock m t cl
- ioClock :: MonadIO m => cl -> IOClock m cl
- type BehaviorF m time a b = BehaviourF m time a b
- type BehaviourF m time a b = forall cl. time ~ Time cl => ClSF m cl a b
- type Behavior m time a = Behaviour m time a
- type Behaviour m time a = forall cl. time ~ Time cl => ClSignal m cl a
- type ClSignal m cl a = forall arbitrary. ClSF m cl arbitrary a
- type ClSF m cl a b = MSF (ReaderT (TimeInfo cl) m) a b
- hoistClSF :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 cl a b
- hoistClSFAndClock :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 (HoistClock m1 m2 cl) a b
- liftClSF :: (Monad m, MonadTrans t, Monad (t m)) => ClSF m cl a b -> ClSF (t m) cl a b
- liftClSFAndClock :: (Monad m, MonadTrans t, Monad (t m)) => ClSF m cl a b -> ClSF (t m) (LiftClock m t cl) a b
- timeless :: Monad m => MSF m a b -> ClSF m cl a b
- arrMCl :: Monad m => (a -> m b) -> ClSF m cl a b
- constMCl :: Monad m => m b -> ClSF m cl a b
- mapMaybe :: Monad m => ClSF m cl a b -> ClSF m cl (Maybe a) (Maybe b)
- commuteReaders :: ReaderT r1 (ReaderT r2 m) a -> ReaderT r2 (ReaderT r1 m) a
- readerS :: Monad m => ClSF m cl (a, r) b -> ClSF (ReaderT r m) cl a b
- runReaderS :: Monad m => ClSF (ReaderT r m) cl a b -> ClSF m cl (a, r) b
- runReaderS_ :: Monad m => ClSF (ReaderT r m) cl a b -> r -> ClSF m cl a b
- runRandS :: (RandomGen g, Monad m) => ClSF (RandT g m) cl a b -> g -> ClSF m cl a (g, b)
- evalRandS :: (RandomGen g, Monad m) => ClSF (RandT g m) cl a b -> g -> ClSF m cl a b
- execRandS :: (RandomGen g, Monad m) => ClSF (RandT g m) cl a b -> g -> ClSF m cl a g
- evalRandIOS :: Monad m => ClSF (RandT StdGen m) cl a b -> IO (ClSF m cl a b)
- evalRandIOS' :: MonadIO m => ClSF (RandT StdGen m) cl a b -> ClSF m cl a b
- getRandomS :: (MonadRandom m, Random a) => Behaviour m time a
- getRandomRS :: (MonadRandom m, Random a) => BehaviourF m time (a, a) a
- getRandomRS_ :: (MonadRandom m, Random a) => (a, a) -> Behaviour m time a
- type BehaviorFExcept m time a b e = BehaviourFExcept m time a b e
- type BehaviourFExcept m time a b e = forall cl. time ~ Time cl => ClSFExcept m cl a b e
- type ClSFExcept m cl a b e = MSFExcept (ReaderT (TimeInfo cl) m) a b e
- throwS :: Monad m => ClSF (ExceptT e m) cl e a
- throw :: Monad m => e -> MSF (ExceptT e m) a b
- pass :: Monad m => MSF (ExceptT e m) a a
- throwOn :: Monad m => e -> ClSF (ExceptT e m) cl Bool ()
- throwOn' :: Monad m => ClSF (ExceptT e m) cl (Bool, e) ()
- throwOnCond :: Monad m => (a -> Bool) -> e -> ClSF (ExceptT e m) cl a a
- throwOnCondM :: Monad m => (a -> m Bool) -> e -> ClSF (ExceptT e m) cl a a
- throwMaybe :: Monad m => ClSF (ExceptT e m) cl (Maybe e) (Maybe a)
- runClSFExcept :: Monad m => ClSFExcept m cl a b e -> ClSF (ExceptT e m) cl a b
- try :: Monad m => ClSF (ExceptT e m) cl a b -> ClSFExcept m cl a b e
- once :: Monad m => (a -> m e) -> ClSFExcept m cl a b e
- once_ :: Monad m => m e -> ClSFExcept m cl a b e
- step :: Monad m => (a -> m (b, e)) -> ClSFExcept m cl a b e
- timeInfo :: Monad m => ClSF m cl a (TimeInfo cl)
- timeInfoOf :: Monad m => (TimeInfo cl -> b) -> ClSF m cl a b
- sinceLastS :: Monad m => ClSF m cl a (Diff (Time cl))
- sinceInitS :: Monad m => ClSF m cl a (Diff (Time cl))
- absoluteS :: Monad m => ClSF m cl a (Time cl)
- tagS :: Monad m => ClSF m cl a (Tag cl)
- sinceStart :: (Monad m, TimeDomain time) => BehaviourF m time a (Diff time)
- (>->) :: Category cat => cat a b -> cat b c -> cat a c
- (<-<) :: Category cat => cat b c -> cat a b -> cat a c
- arr_ :: Arrow a => b -> a c b
- clId :: Monad m => ClSF m cl a a
- integralFrom :: (Monad m, VectorSpace v s, s ~ Diff td) => v -> BehaviorF m td v v
- integral :: (Monad m, VectorSpace v s, s ~ Diff td) => BehaviorF m td v v
- derivativeFrom :: (Monad m, VectorSpace v s, s ~ Diff td) => v -> BehaviorF m td v v
- derivative :: (Monad m, VectorSpace v s, s ~ Diff td) => BehaviorF m td v v
- threePointDerivativeFrom :: (Monad m, VectorSpace v s, s ~ Diff td, Num s) => v -> BehaviorF m td v v
- threePointDerivative :: (Monad m, VectorSpace v s, s ~ Diff td, Num s) => BehaviorF m td v v
- weightedAverageFrom :: (Monad m, VectorSpace v s, s ~ Diff td, Num s) => v -> BehaviorF m td (v, s) v
- averageFrom :: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) => v -> Diff td -> BehaviorF m td v v
- average :: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) => Diff td -> BehaviourF m td v v
- averageLinFrom :: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) => v -> Diff td -> BehaviourF m td v v
- averageLin :: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) => Diff td -> BehaviourF m td v v
- lowPass :: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) => Diff td -> BehaviourF m td v v
- highPass :: (Monad m, VectorSpace v s, Floating s, Eq s, s ~ Diff td) => Diff td -> BehaviourF m td v v
- bandPass :: (Monad m, VectorSpace v s, Floating s, Eq s, s ~ Diff td) => Diff td -> BehaviourF m td v v
- bandStop :: (Monad m, VectorSpace v s, Floating s, Eq s, s ~ Diff td) => Diff td -> BehaviourF m td v v
- keepFirst :: Monad m => ClSF m cl a a
- historySince :: (Monad m, Ord (Diff (Time cl)), TimeDomain (Time cl)) => Diff (Time cl) -> ClSF m cl a (Seq (TimeInfo cl, a))
- delayBy :: (Monad m, Ord (Diff td), TimeDomain td) => Diff td -> BehaviorF m td a a
- timer :: (Monad m, TimeDomain td, Ord (Diff td)) => Diff td -> BehaviorF (ExceptT () m) td a (Diff td)
- timer_ :: (Monad m, TimeDomain td, Ord (Diff td)) => Diff td -> BehaviorF (ExceptT () m) td a ()
- scaledTimer :: (Monad m, TimeDomain td, Fractional (Diff td), Ord (Diff td)) => Diff td -> BehaviorF (ExceptT () m) td a (Diff td)
- lastS :: Monad m => a -> MSF m (Maybe a) a
- data UnscheduleClock m cl = UnscheduleClock {
- scheduleClock :: cl
- scheduleWait :: Diff (Time cl) -> m ()
- unyieldClock :: cl -> UnscheduleClock IO cl
- type ResBuf m cla clb a b = ResamplingBuffer m cla clb a b
- data ResamplingBuffer m cla clb a b = ResamplingBuffer {
- put :: TimeInfo cla -> a -> m (ResamplingBuffer m cla clb a b)
- get :: TimeInfo clb -> m (b, ResamplingBuffer m cla clb a b)
- hoistResamplingBuffer :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ResamplingBuffer m1 cla clb a b -> ResamplingBuffer m2 cla clb a b
- msfBuffer :: Monad m => MSF m (TimeInfo cl2, [(TimeInfo cl1, a)]) b -> ResamplingBuffer m cl1 cl2 a b
- data AsyncMealy m s a b = AsyncMealy {}
- timelessResamplingBuffer :: Monad m => AsyncMealy m s a b -> s -> ResamplingBuffer m cl1 cl2 a b
- trivialResamplingBuffer :: Monad m => ResamplingBuffer m cl1 cl2 () ()
- lifoUnbounded :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a)
- lifoBounded :: Monad m => Int -> ResamplingBuffer m cl1 cl2 a (Maybe a)
- lifoWatch :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a, Int)
- keepLast :: Monad m => a -> ResamplingBuffer m cl1 cl2 a a
- fifoUnbounded :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a)
- fifoBounded :: Monad m => Int -> ResamplingBuffer m cl1 cl2 a (Maybe a)
- fifoWatch :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a, Int)
- collect :: Monad m => ResamplingBuffer m cl1 cl2 a [a]
- collectSequence :: Monad m => ResamplingBuffer m cl1 cl2 a (Seq a)
- pureBuffer :: Monad m => ([a] -> b) -> ResamplingBuffer m cl1 cl2 a b
- foldBuffer :: Monad m => (a -> b -> b) -> b -> ResamplingBuffer m cl1 cl2 a b
- (>>-^) :: Monad m => ResamplingBuffer m cl1 cl2 a b -> ClSF m cl2 b c -> ResamplingBuffer m cl1 cl2 a c
- (^->>) :: Monad m => ClSF m cl1 a b -> ResamplingBuffer m cl1 cl2 b c -> ResamplingBuffer m cl1 cl2 a c
- (*-*) :: Monad m => ResamplingBuffer m cl1 cl2 a b -> ResamplingBuffer m cl1 cl2 c d -> ResamplingBuffer m cl1 cl2 (a, c) (b, d)
- (&-&) :: Monad m => ResamplingBuffer m cl1 cl2 a b -> ResamplingBuffer m cl1 cl2 a c -> ResamplingBuffer m cl1 cl2 a (b, c)
- timestamped :: Monad m => (forall b. ResamplingBuffer m cl clf b (f b)) -> ResamplingBuffer m cl clf a (f (a, TimeInfo cl))
- linear :: (Monad m, Clock m cl1, Clock m cl2, VectorSpace v s, Num s, s ~ Diff (Time cl1), s ~ Diff (Time cl2)) => v -> v -> ResamplingBuffer m cl1 cl2 v v
- sinc :: (Monad m, Clock m cl1, Clock m cl2, VectorSpace v s, Ord s, Floating s, s ~ Diff (Time cl1), s ~ Diff (Time cl2)) => s -> ResamplingBuffer m cl1 cl2 v v
- cubic :: (Monad m, VectorSpace v s, Floating v, Eq v, Fractional s, s ~ Diff (Time cl1), s ~ Diff (Time cl2)) => ResamplingBuffer m cl1 cl2 v v
- data ParClockInclusion clS cl where
- ParClockInL :: ParClockInclusion (ParallelClock clL clR) cl -> ParClockInclusion clL cl
- ParClockInR :: ParClockInclusion (ParallelClock clL clR) cl -> ParClockInclusion clR cl
- ParClockRefl :: ParClockInclusion cl cl
- data LastTime cl where
- SequentialLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (SequentialClock cl1 cl2)
- ParallelLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (ParallelClock cl1 cl2)
- LeafLastTime :: Time cl -> LastTime cl
- type family Out cl where ...
- type family In cl where ...
- type ParClock cl1 cl2 = ParallelClock cl1 cl2
- data ParallelClock cl1 cl2 = Time cl1 ~ Time cl2 => ParallelClock {
- parallelCl1 :: cl1
- parallelCl2 :: cl2
- type SeqClock cl1 cl2 = SequentialClock cl1 cl2
- data SequentialClock cl1 cl2 = Time cl1 ~ Time cl2 => SequentialClock {
- sequentialCl1 :: cl1
- sequentialCl2 :: cl2
- scheduleList :: (Monad m, MonadSchedule m) => NonEmpty (MSF m a b) -> MSF m a (NonEmpty b)
- runningSchedule :: (Monad m, MonadSchedule m, Clock m cl1, Clock m cl2, Time cl1 ~ Time cl2) => cl1 -> cl2 -> RunningClock m (Time cl1) (Tag cl1) -> RunningClock m (Time cl2) (Tag cl2) -> RunningClock m (Time cl1) (Either (Tag cl1) (Tag cl2))
- initSchedule :: (Time cl1 ~ Time cl2, Monad m, MonadSchedule m, Clock m cl1, Clock m cl2) => cl1 -> cl2 -> RunningClockInit m (Time cl1) (Either (Tag cl1) (Tag cl2))
- parClockTagInclusion :: ParClockInclusion clS cl -> Tag clS -> Tag cl
- class ToClockProxy a where
- type Cl a :: Type
- toClockProxy :: a -> ClockProxy (Cl a)
- class GetClockProxy cl where
- getClockProxy :: ClockProxy cl
- data ClockProxy cl where
- LeafProxy :: (cl ~ In cl, cl ~ Out cl) => ClockProxy cl
- SequentialProxy :: ClockProxy cl1 -> ClockProxy cl2 -> ClockProxy (SequentialClock cl1 cl2)
- ParallelProxy :: ClockProxy clL -> ClockProxy clR -> ClockProxy (ParallelClock clL clR)
- inProxy :: ClockProxy cl -> ClockProxy (In cl)
- outProxy :: ClockProxy cl -> ClockProxy (Out cl)
- inTag :: ClockProxy cl -> Tag cl -> Maybe (Tag (In cl))
- outTag :: ClockProxy cl -> Tag cl -> Maybe (Tag (Out cl))
- data SN m cl a b where
- Synchronous :: (cl ~ In cl, cl ~ Out cl) => ClSF m cl a b -> SN m cl a b
- Sequential :: (Clock m clab, Clock m clcd, Clock m (Out clab), Clock m (Out clcd), Clock m (In clab), Clock m (In clcd), GetClockProxy clab, GetClockProxy clcd, Time clab ~ Time clcd, Time clab ~ Time (Out clab), Time clcd ~ Time (In clcd)) => SN m clab a b -> ResamplingBuffer m (Out clab) (In clcd) b c -> SN m clcd c d -> SN m (SequentialClock clab clcd) a d
- Parallel :: (Clock m cl1, Clock m cl2, Clock m (Out cl1), Clock m (Out cl2), GetClockProxy cl1, GetClockProxy cl2, Time cl1 ~ Time (Out cl1), Time cl2 ~ Time (Out cl2), Time cl1 ~ Time cl2, Time cl1 ~ Time (In cl1), Time cl2 ~ Time (In cl2)) => SN m cl1 a b -> SN m cl2 a b -> SN m (ParallelClock cl1 cl2) a b
- FirstResampling :: (Clock m (In cl), Clock m (Out cl), Time cl ~ Time (Out cl), Time cl ~ Time (In cl)) => SN m cl a b -> ResamplingBuffer m (In cl) (Out cl) c d -> SN m cl (a, c) (b, d)
- Postcompose :: (Clock m (Out cl), Time cl ~ Time (Out cl)) => SN m cl a b -> ClSF m (Out cl) b c -> SN m cl a c
- Precompose :: (Clock m (In cl), Time cl ~ Time (In cl)) => ClSF m (In cl) a b -> SN m cl b c -> SN m cl a c
- Feedback :: (Clock m (In cl), Clock m (Out cl), Time (In cl) ~ Time cl, Time (Out cl) ~ Time cl) => ResBuf m (Out cl) (In cl) d c -> SN m cl (a, c) (b, d) -> SN m cl a b
- (>>>^) :: Monad m => SN m cl a b -> (b -> c) -> SN m cl a c
- (^>>>) :: Monad m => (a -> b) -> SN m cl b c -> SN m cl a c
- (>--^) :: (Clock m (Out cl), Time cl ~ Time (Out cl)) => SN m cl a b -> ClSF m (Out cl) b c -> SN m cl a c
- (^-->) :: (Clock m (In cl), Time cl ~ Time (In cl)) => ClSF m (In cl) a b -> SN m cl b c -> SN m cl a c
- (****) :: Monad m => SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d)
- (||||) :: (Monad m, Clock m clL, Clock m clR, Clock m (Out clL), Clock m (Out clR), GetClockProxy clL, GetClockProxy clR, Time clL ~ Time clR, Time clL ~ Time (Out clL), Time clL ~ Time (In clL), Time clR ~ Time (Out clR), Time clR ~ Time (In clR)) => SN m clL a b -> SN m clR a b -> SN m (ParClock clL clR) a b
- (++++) :: (Monad m, Clock m clL, Clock m clR, Clock m (Out clL), Clock m (Out clR), GetClockProxy clL, GetClockProxy clR, Time clL ~ Time clR, Time clL ~ Time (Out clL), Time clL ~ Time (In clL), Time clR ~ Time (Out clR), Time clR ~ Time (In clR)) => SN m clL a b -> SN m clR a c -> SN m (ParClock clL clR) a (Either b c)
- genTimeInfo :: (Monad m, Clock m cl) => ClockProxy cl -> Time cl -> MSF m (Time cl, Tag cl) (TimeInfo cl)
- data SelectClock cl a = SelectClock {}
- filterS :: Monad m => MSF m () (Maybe b) -> MSF m () b
- data StdinClock = StdinClock
- data EventClock event = EventClock
- type EventChanT event m = ReaderT (Chan event) m
- withChan :: Chan event -> EventChanT event m a -> m a
- runEventChanT :: MonadIO m => EventChanT event m a -> m a
- withChanS :: Monad m => Chan event -> ClSF (EventChanT event m) cl a b -> ClSF m cl a b
- emit :: MonadIO m => event -> EventChanT event m ()
- emitS :: MonadIO m => ClSF (EventChanT event m) cl event ()
- emitSMaybe :: MonadIO m => ClSF (EventChanT event m) cl (Maybe event) ()
- emit' :: (NFData event, MonadIO m) => event -> EventChanT event m ()
- emitS' :: (NFData event, MonadIO m) => ClSF (EventChanT event m) cl event ()
- emitSMaybe' :: (NFData event, MonadIO m) => ClSF (EventChanT event m) cl (Maybe event) ()
- eventClockOn :: MonadIO m => Chan event -> HoistClock (EventChanT event m) m (EventClock event)
- data Busy = Busy
- type PureAudioClockF (rate :: AudioRate) = RescaledClock (PureAudioClock rate) Float
- data PureAudioClock (rate :: AudioRate) = PureAudioClock
- data AudioClock (rate :: AudioRate) (bufferSize :: Nat) = AudioClock
- data AudioRate
- pureAudioClockF :: PureAudioClockF rate
- data Periodic (v :: [Nat]) where
- type Count = FixedStep 1
- data FixedStep (n :: Nat) where
- stepsize :: FixedStep n -> Integer
- downsampleFixedStep :: (KnownNat n, Monad m) => ResamplingBuffer m (FixedStep k) (FixedStep (n * k)) a (Vector n a)
- newtype Millisecond (n :: Nat) = Millisecond (RescaledClockS IO (UnscheduleClock IO (FixedStep n)) UTCTime Bool)
- waitClock :: KnownNat n => Millisecond n
- downsampleMillisecond :: (KnownNat n, Monad m) => ResamplingBuffer m (Millisecond k) (Millisecond (n * k)) a (Vector n a)
- data Rhine m cl a b = Rhine {}
- eraseClock :: (Monad m, Clock m cl, GetClockProxy cl) => Rhine m cl a b -> m (MSF m a (Maybe b))
- feedbackRhine :: (Clock m (In cl), Clock m (Out cl), Time (In cl) ~ Time cl, Time (Out cl) ~ Time cl) => ResamplingBuffer m (Out cl) (In cl) d c -> Rhine m cl (a, c) (b, d) -> Rhine m cl a b
- data RhineAndResamplingBuffer m cl1 inCl2 a c = forall b. RhineAndResamplingBuffer (Rhine m cl1 a b) (ResamplingBuffer m (Out cl1) inCl2 b c)
- (@@) :: (cl ~ In cl, cl ~ Out cl) => ClSF m cl a b -> cl -> Rhine m cl a b
- (>--) :: Rhine m cl1 a b -> ResamplingBuffer m (Out cl1) inCl2 b c -> RhineAndResamplingBuffer m cl1 inCl2 a c
- (-->) :: (Clock m cl1, Clock m cl2, Time cl1 ~ Time cl2, Time (Out cl1) ~ Time cl1, Time (In cl2) ~ Time cl2, Clock m (Out cl1), Clock m (Out cl2), Clock m (In cl1), Clock m (In cl2), In cl2 ~ inCl2, GetClockProxy cl1, GetClockProxy cl2) => RhineAndResamplingBuffer m cl1 inCl2 a b -> Rhine m cl2 b c -> Rhine m (SequentialClock cl1 cl2) a c
- (+@+) :: (Monad m, Clock m clL, Clock m clR, Clock m (Out clL), Clock m (Out clR), GetClockProxy clL, GetClockProxy clR, Time clL ~ Time (Out clL), Time clR ~ Time (Out clR), Time clL ~ Time (In clL), Time clR ~ Time (In clR), Time clL ~ Time clR) => Rhine m clL a b -> Rhine m clR a c -> Rhine m (ParallelClock clL clR) a (Either b c)
- (|@|) :: (Monad m, Clock m clL, Clock m clR, Clock m (Out clL), Clock m (Out clR), GetClockProxy clL, GetClockProxy clR, Time clL ~ Time (Out clL), Time clR ~ Time (Out clR), Time clL ~ Time (In clL), Time clR ~ Time (In clR), Time clL ~ Time clR) => Rhine m clL a b -> Rhine m clR a b -> Rhine m (ParallelClock clL clR) a b
- (@>>^) :: Monad m => Rhine m cl a b -> (b -> c) -> Rhine m cl a c
- (^>>@) :: Monad m => (a -> b) -> Rhine m cl b c -> Rhine m cl a c
- (@>-^) :: (Clock m (Out cl), Time cl ~ Time (Out cl)) => Rhine m cl a b -> ClSF m (Out cl) b c -> Rhine m cl a c
- (^->@) :: (Clock m (In cl), Time cl ~ Time (In cl)) => ClSF m (In cl) a b -> Rhine m cl b c -> Rhine m cl a c
- flow :: (Monad m, Clock m cl, GetClockProxy cl, Time cl ~ Time (In cl), Time cl ~ Time (Out cl)) => Rhine m cl () () -> m ()
- reactimateCl :: (Monad m, Clock m cl, GetClockProxy cl, cl ~ In cl, cl ~ Out cl) => cl -> ClSF m cl () () -> m ()
Documentation
class Monad m => MonadIO (m :: Type -> Type) where #
Monads in which IO
computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO
monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Lift a computation from the IO
monad.
This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations
(i.e. IO
is the base monad for the stack).
Example
import Control.Monad.Trans.State -- from the "transformers" library printState :: Show s => StateT s IO () printState = do state <- get liftIO $ print state
Had we omitted
, we would have ended up with this error:liftIO
• Couldn't match type ‘IO’ with ‘StateT s IO’ Expected type: StateT s IO () Actual type: IO ()
The important part here is the mismatch between StateT s IO ()
and
.IO
()
Luckily, we know of a function that takes an
and returns an IO
a(m a)
:
,
enabling us to run the program and see the expected results:liftIO
> evalStateT printState "hello" "hello" > evalStateT printState 3 3
Instances
newtype Kleisli (m :: Type -> Type) a b #
Kleisli arrows of a monad.
Kleisli | |
|
Instances
Monad m => Category (Kleisli m :: Type -> Type -> TYPE LiftedRep) | Since: base-3.0 |
Generic1 (Kleisli m a :: Type -> TYPE LiftedRep) | |
Monad m => Arrow (Kleisli m) | Since: base-2.1 |
Monad m => ArrowApply (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
Monad m => ArrowChoice (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
MonadFix m => ArrowLoop (Kleisli m) | Beware that for many monads (those for which the Since: base-2.1 |
Defined in Control.Arrow | |
MonadPlus m => ArrowPlus (Kleisli m) | Since: base-2.1 |
MonadPlus m => ArrowZero (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
Alternative m => Alternative (Kleisli m a) | Since: base-4.14.0.0 |
Applicative m => Applicative (Kleisli m a) | Since: base-4.14.0.0 |
Defined in Control.Arrow | |
Functor m => Functor (Kleisli m a) | Since: base-4.14.0.0 |
Monad m => Monad (Kleisli m a) | Since: base-4.14.0.0 |
MonadPlus m => MonadPlus (Kleisli m a) | Since: base-4.14.0.0 |
Generic (Kleisli m a b) | |
type Rep1 (Kleisli m a :: Type -> TYPE LiftedRep) | Since: base-4.14.0.0 |
Defined in Control.Arrow | |
type Rep (Kleisli m a b) | Since: base-4.14.0.0 |
Defined in Control.Arrow |
class Arrow a => ArrowZero (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where #
Instances
MonadPlus m => ArrowZero (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
(ArrowZero p, ArrowZero q) => ArrowZero (Product p q) | |
Defined in Data.Bifunctor.Product | |
(Applicative f, ArrowZero p) => ArrowZero (Tannen f p) | |
Defined in Data.Bifunctor.Tannen |
class ArrowZero a => ArrowPlus (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where #
A monoid on arrows.
newtype ArrowMonad (a :: Type -> Type -> Type) b #
The ArrowApply
class is equivalent to Monad
: any monad gives rise
to a Kleisli
arrow, and any instance of ArrowApply
defines a monad.
ArrowMonad (a () b) |
Instances
class Arrow a => ArrowLoop (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where #
The loop
operator expresses computations in which an output value
is fed back as input, although the computation occurs only once.
It underlies the rec
value recursion construct in arrow notation.
loop
should satisfy the following laws:
- extension
loop
(arr
f) =arr
(\ b ->fst
(fix
(\ (c,d) -> f (b,d))))- left tightening
loop
(first
h >>> f) = h >>>loop
f- right tightening
loop
(f >>>first
h) =loop
f >>> h- sliding
loop
(f >>>arr
(id
*** k)) =loop
(arr
(id
*** k) >>> f)- vanishing
loop
(loop
f) =loop
(arr
unassoc >>> f >>>arr
assoc)- superposing
second
(loop
f) =loop
(arr
assoc >>>second
f >>>arr
unassoc)
where
assoc ((a,b),c) = (a,(b,c)) unassoc (a,(b,c)) = ((a,b),c)
Instances
MonadFix m => ArrowLoop (Kleisli m) | Beware that for many monads (those for which the Since: base-2.1 |
Defined in Control.Arrow | |
ArrowLoop (->) | Since: base-2.1 |
Defined in Control.Arrow | |
(ArrowLoop p, ArrowLoop q) => ArrowLoop (Product p q) | |
Defined in Data.Bifunctor.Product | |
(Applicative f, ArrowLoop p) => ArrowLoop (Tannen f p) | |
Defined in Data.Bifunctor.Tannen |
class Arrow a => ArrowChoice (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where #
Choice, for arrows that support it. This class underlies the
if
and case
constructs in arrow notation.
Instances should satisfy the following laws:
left
(arr
f) =arr
(left
f)left
(f >>> g) =left
f >>>left
gf >>>
arr
Left
=arr
Left
>>>left
fleft
f >>>arr
(id
+++ g) =arr
(id
+++ g) >>>left
fleft
(left
f) >>>arr
assocsum =arr
assocsum >>>left
f
where
assocsum (Left (Left x)) = Left x assocsum (Left (Right y)) = Right (Left y) assocsum (Right z) = Right (Right z)
The other combinators have sensible default definitions, which may be overridden for efficiency.
left :: a b c -> a (Either b d) (Either c d) #
Feed marked inputs through the argument arrow, passing the rest through unchanged to the output.
right :: a b c -> a (Either d b) (Either d c) #
A mirror image of left
.
The default definition may be overridden with a more efficient version if desired.
(+++) :: a b c -> a b' c' -> a (Either b b') (Either c c') infixr 2 #
Split the input between the two argument arrows, retagging and merging their outputs. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
(|||) :: a b d -> a c d -> a (Either b c) d infixr 2 #
Fanin: Split the input between the two argument arrows and merge their outputs.
The default definition may be overridden with a more efficient version if desired.
Instances
Monad m => ArrowChoice (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
ArrowChoice (->) | Since: base-2.1 |
(ArrowChoice p, ArrowChoice q) => ArrowChoice (Product p q) | |
Defined in Data.Bifunctor.Product | |
(Applicative f, ArrowChoice p) => ArrowChoice (Tannen f p) | |
Defined in Data.Bifunctor.Tannen |
class Arrow a => ArrowApply (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where #
Some arrows allow application of arrow inputs to other inputs. Instances should satisfy the following laws:
first
(arr
(\x ->arr
(\y -> (x,y)))) >>>app
=id
first
(arr
(g >>>)) >>>app
=second
g >>>app
first
(arr
(>>> h)) >>>app
=app
>>> h
Such arrows are equivalent to monads (see ArrowMonad
).
Instances
Monad m => ArrowApply (Kleisli m) | Since: base-2.1 |
Defined in Control.Arrow | |
ArrowApply (->) | Since: base-2.1 |
Defined in Control.Arrow |
class Category a => Arrow (a :: TYPE LiftedRep -> TYPE LiftedRep -> Type) where #
The basic arrow class.
Instances should satisfy the following laws:
arr
id =id
arr
(f >>> g) =arr
f >>>arr
gfirst
(arr
f) =arr
(first
f)first
(f >>> g) =first
f >>>first
gfirst
f >>>arr
fst
=arr
fst
>>> ffirst
f >>>arr
(id
*** g) =arr
(id
*** g) >>>first
ffirst
(first
f) >>>arr
assoc =arr
assoc >>>first
f
where
assoc ((a,b),c) = (a,(b,c))
The other combinators have sensible default definitions, which may be overridden for efficiency.
Lift a function to an arrow.
first :: a b c -> a (b, d) (c, d) #
Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.
second :: a b c -> a (d, b) (d, c) #
A mirror image of first
.
The default definition may be overridden with a more efficient version if desired.
(***) :: a b c -> a b' c' -> a (b, b') (c, c') infixr 3 #
Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
(&&&) :: a b c -> a b c' -> a b (c, c') infixr 3 #
Fanout: send the input to both argument arrows and combine their output.
The default definition may be overridden with a more efficient version if desired.
Instances
Monad m => Arrow (Kleisli m) | Since: base-2.1 |
Arrow (->) | Since: base-2.1 |
(Arrow p, Arrow q) => Arrow (Product p q) | |
Defined in Data.Bifunctor.Product | |
(Applicative f, Arrow p) => Arrow (Tannen f p) | |
Defined in Data.Bifunctor.Tannen |
leftApp :: ArrowApply a => a b c -> a (Either b d) (Either c d) #
Any instance of ArrowApply
can be made into an instance of
ArrowChoice
by defining left
= leftApp
.
(^<<) :: Arrow a => (c -> d) -> a b c -> a b d infixr 1 #
Postcomposition with a pure function (right-to-left variant).
(<<^) :: Arrow a => a c d -> (b -> c) -> a b d infixr 1 #
Precomposition with a pure function (right-to-left variant).
(>>>) :: forall {k} cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c infixr 1 #
Left-to-right composition
(<<<) :: forall {k} cat (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c infixr 1 #
Right-to-left composition
currentInput :: forall (m :: Type -> Type) e b. Monad m => MSFExcept m e b e #
Immediately throw the current input as an exception.
exceptS :: forall (m :: Type -> Type) e a b. (Functor m, Monad m) => MSF (ExceptT e m) a b -> MSF m a (Either e b) #
runMSFExcept :: MSFExcept m a b e -> MSF (ExceptT e m) a b #
getRandomsRS_ :: forall (m :: Type -> Type) b. (MonadRandom m, Random b) => MSF m (b, b) [b] #
Create a stream of lists of random values in a given range, where the range is specified on every tick.
getRandomsRS :: forall (m :: Type -> Type) b a. (MonadRandom m, Random b) => (b, b) -> MSF m a [b] #
Create a stream of lists of random values in a given fixed range.
getRandomsS :: forall (m :: Type -> Type) b a. (MonadRandom m, Random b) => MSF m a [b] #
Create a stream of lists of random values.
pauseOn :: Show a => (a -> Bool) -> String -> MSF IO a a #
Outputs every input sample, with a given message prefix, when a condition is met, and waits for some input / enter to continue.
traceWhen :: (Monad m, Show a) => (a -> Bool) -> (String -> m ()) -> String -> MSF m a a #
Outputs every input sample, with a given message prefix, using an auxiliary printing function, when a condition is met.
traceWith :: (Monad m, Show a) => (String -> m ()) -> String -> MSF m a a #
Outputs every input sample, with a given message prefix, using an auxiliary printing function.
repeatedly :: forall (m :: Type -> Type) a. Monad m => (a -> a) -> a -> MSF m () a #
Generate outputs using a step-wise generation function and an initial
value. Version of unfold
in which the output and the new accumulator are
the same. Should be equal to f a -> unfold (f >>> dup) a
.
unfold :: forall (m :: Type -> Type) a b. Monad m => (a -> (b, a)) -> a -> MSF m () b #
Generate outputs using a step-wise generation function and an initial value.
mealy :: forall (m :: Type -> Type) a s b. Monad m => (a -> s -> (b, s)) -> s -> MSF m a b #
Applies a transfer function to the input and an accumulator, returning the updated accumulator and output.
accumulateWith :: forall (m :: Type -> Type) a s. Monad m => (a -> s -> s) -> s -> MSF m a s #
Applies a function to the input and an accumulator, outputting the updated
accumulator. Equal to f s0 -> feedback s0 $ arr (uncurry f >>> dup)
.
mappendFrom :: forall n (m :: Type -> Type). (Monoid n, Monad m) => n -> MSF m n n #
Accumulate the inputs, starting from an initial monoid value.
mappendS :: forall n (m :: Type -> Type). (Monoid n, Monad m) => MSF m n n #
Accumulate the inputs, starting from mempty
.
sumFrom :: forall v s (m :: Type -> Type). (VectorSpace v s, Monad m) => v -> MSF m v v #
Sums the inputs, starting from an initial vector.
sumS :: forall v s (m :: Type -> Type). (VectorSpace v s, Monad m) => MSF m v v #
Sums the inputs, starting from zero.
count :: forall n (m :: Type -> Type) a. (Num n, Monad m) => MSF m a n #
Count the number of simulation steps. Produces 1, 2, 3,...
fifo :: forall (m :: Type -> Type) a. Monad m => MSF m [a] (Maybe a) #
Buffers and returns the elements in FIFO order, returning Nothing
whenever the buffer is empty.
next :: forall (m :: Type -> Type) b a. Monad m => b -> MSF m a b -> MSF m a b #
Preprends a fixed output to an MSF
, shifting the output.
iPost :: forall (m :: Type -> Type) b a. Monad m => b -> MSF m a b -> MSF m a b #
Preprends a fixed output to an MSF
. The first input is completely
ignored.
Delay a signal by one sample.
withSideEffect_ :: Monad m => m b -> MSF m a a #
Produces an additional side effect and passes the input unchanged.
withSideEffect :: Monad m => (a -> m b) -> MSF m a a #
Applies a function to produce an additional side effect and passes the input unchanged.
type MStream (m :: Type -> Type) a = MSF m () a #
A stream is an MSF
that produces outputs, while ignoring the input. It
can obtain the values from a monadic context.
type MSink (m :: Type -> Type) a = MSF m a () #
A sink is an MSF
that consumes inputs, while producing no output. It
can consume the values with side effects.
morphS :: (Monad m2, Monad m1) => (forall c. m1 c -> m2 c) -> MSF m1 a b -> MSF m2 a b #
Apply trans-monadic actions (in an arbitrary way).
This is just a convenience function when you have a function to move across
monads, because the signature of morphGS
is a bit complex.
liftTransS :: forall (t :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a b. (MonadTrans t, Monad m, Monad (t m)) => MSF m a b -> MSF (t m) a b #
Lift inner monadic actions in monad stacks.
liftBaseS :: forall (m2 :: Type -> Type) (m1 :: Type -> Type) a b. (Monad m2, MonadBase m1 m2) => MSF m1 a b -> MSF m2 a b #
Lift innermost monadic actions in monad stack (generalisation of
liftIO
).
liftBaseM :: forall (m2 :: Type -> Type) m1 a b. (Monad m2, MonadBase m1 m2) => (a -> m1 b) -> MSF m2 a b #
Monadic lifting from one monad into another
reactimate :: Monad m => MSF m () () -> m () #
Run an MSF
indefinitely passing a unit-carrying input stream.
embed :: Monad m => MSF m a b -> [a] -> m [b] #
Apply a monadic stream function to a list.
Because the result is in a monad, it may be necessary to traverse the whole
list to evaluate the value in the results to WHNF. For example, if the
monad is the maybe monad, this may not produce anything if the MSF
produces Nothing
at any point, so the output stream cannot consumed
progressively.
To explore the output progressively, use arrM
and (>>>)
', together with
some action that consumes/actuates on the output.
This is called runSF
in Liu, Cheng, Hudak, "Causal Commutative Arrows and
Their Optimization"
feedback :: forall (m :: Type -> Type) c a b. Monad m => c -> MSF m (a, c) (b, c) -> MSF m a b #
Well-formed looped connection of an output component as a future input.
:: Monad m2 | |
=> (forall c. (a1 -> m1 (b1, c)) -> a2 -> m2 (b2, c)) | The natural transformation. |
-> MSF m1 a1 b1 | |
-> MSF m2 a2 b2 |
Generic lifting of a morphism to the level of MSF
s.
Natural transformation to the level of MSF
s.
Mathematical background: The type a -> m (b, c)
is a functor in c
,
and MSF m a b
is its greatest fixpoint, i.e. it is isomorphic to the type
a -> m (b, MSF m a b)
, by definition. The types m
, a
and b
are
parameters of the functor. Taking a fixpoint is functorial itself, meaning
that a morphism (a natural transformation) of two such functors gives a
morphism (an ordinary function) of their fixpoints.
This is in a sense the most general "abstract" lifting function, i.e. the
most general one that only changes input, output and side effect types, and
doesn't influence control flow. Other handling functions like exception
handling or ListT
broadcasting necessarily change control flow.
data MSF (m :: Type -> Type) a b #
Stepwise, side-effectful MSF
s without implicit knowledge of time.
MSF
s should be applied to streams or executed indefinitely or until they
terminate. See reactimate
and reactimateB
for details. In general,
calling the value constructor MSF
or the function unMSF
is discouraged.
except :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a #
Constructor for computations in the exception monad.
(The inverse of runExcept
).
newtype ExceptT e (m :: Type -> Type) a #
A monad transformer that adds exceptions to other monads.
ExceptT
constructs a monad parameterized over two things:
- e - The exception type.
- m - The inner monad.
The return
function yields a computation that produces the given
value, while >>=
sequences two subcomputations, exiting on the
first exception.
Instances
withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a #
Transform any exceptions thrown by the computation using the given function.
withExcept :: (e -> e') -> Except e a -> Except e' a #
Transform any exceptions thrown by the computation using the given
function (a specialization of withExceptT
).
runExceptT :: ExceptT e m a -> m (Either e a) #
The inverse of ExceptT
.
runExcept :: Except e a -> Either e a #
Extractor for computations in the exception monad.
(The inverse of except
).
mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b #
Map the unwrapped computation using the given function.
runExceptT
(mapExceptT
f m) = f (runExceptT
m)
class VectorSpace v a | v -> a where #
Vector space type relation.
A vector space is a set (type) closed under addition and multiplication by
a scalar. The type of the scalar is the field of the vector space, and
it is said that v
is a vector space over a
.
The encoding uses a type class |VectorSpace| v a
, where v
represents
the type of the vectors and a
represents the types of the scalars.
zeroVector, (*^), (^+^), dot
zeroVector :: v #
Vector with no magnitude (unit for addition).
(*^) :: a -> v -> v infixr 9 #
Multiplication by a scalar.
(^/) :: v -> a -> v infixl 9 #
Division by a scalar.
(^+^) :: v -> v -> v infixl 6 #
Vector addition
(^-^) :: v -> v -> v infixl 6 #
Vector subtraction
negateVector :: v -> v #
Vector negation. Addition with a negated vector should be same as subtraction.
Dot product (also known as scalar or inner product).
For two vectors, mathematically represented as a = a1,a2,...,an
and b
= b1,b2,...,bn
, the dot product is a . b = a1*b1 + a2*b2 + ... +
an*bn
.
Some properties are derived from this. The dot product of a vector with
itself is the square of its magnitude (norm
), and the dot product of
two orthogonal vectors is zero.
Vector's norm (also known as magnitude).
For a vector represented mathematically as a = a1,a2,...,an
, the norm
is the square root of a1^2 + a2^2 + ... + an^2
.
Return a vector with the same origin and orientation (angle), but such that the norm is one (the unit for multiplication by a scalar).
Instances
VectorSpace Double Double | |
Defined in Data.VectorSpace | |
VectorSpace Float Float | |
Defined in Data.VectorSpace | |
(Eq a, Floating a) => VectorSpace (a, a) a | Vector space instance for pairs of |
Defined in Data.VectorSpace | |
(Eq a, Floating a) => VectorSpace (a, a, a) a | Vector space instance for triplets of |
Defined in Data.VectorSpace | |
(Eq a, Floating a) => VectorSpace (a, a, a, a) a | Vector space instance for tuples with four |
Defined in Data.VectorSpace zeroVector :: (a, a, a, a) # (*^) :: a -> (a, a, a, a) -> (a, a, a, a) # (^/) :: (a, a, a, a) -> a -> (a, a, a, a) # (^+^) :: (a, a, a, a) -> (a, a, a, a) -> (a, a, a, a) # (^-^) :: (a, a, a, a) -> (a, a, a, a) -> (a, a, a, a) # negateVector :: (a, a, a, a) -> (a, a, a, a) # | |
(Eq a, Floating a) => VectorSpace (a, a, a, a, a) a | Vector space instance for tuples with five |
Defined in Data.VectorSpace zeroVector :: (a, a, a, a, a) # (*^) :: a -> (a, a, a, a, a) -> (a, a, a, a, a) # (^/) :: (a, a, a, a, a) -> a -> (a, a, a, a, a) # (^+^) :: (a, a, a, a, a) -> (a, a, a, a, a) -> (a, a, a, a, a) # (^-^) :: (a, a, a, a, a) -> (a, a, a, a, a) -> (a, a, a, a, a) # negateVector :: (a, a, a, a, a) -> (a, a, a, a, a) # dot :: (a, a, a, a, a) -> (a, a, a, a, a) -> a # |
This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.
Instances
Data UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UTCTime -> c UTCTime # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UTCTime # toConstr :: UTCTime -> Constr # dataTypeOf :: UTCTime -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UTCTime) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UTCTime) # gmapT :: (forall b. Data b => b -> b) -> UTCTime -> UTCTime # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r # gmapQ :: (forall d. Data d => d -> u) -> UTCTime -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UTCTime -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime # | |
NFData UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
Eq UTCTime | |
Ord UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
TimeDomain UTCTime | Differences between |
type Diff UTCTime | |
Defined in Data.TimeDomain |
The type of differences or durations between two timestamps
Instances
type Diff UTCTime | |
Defined in Data.TimeDomain | |
type Diff Integer | |
Defined in Data.TimeDomain | |
type Diff () | |
Defined in Data.TimeDomain type Diff () = () | |
type Diff Double | |
Defined in Data.TimeDomain | |
type Diff Float | |
Defined in Data.TimeDomain | |
type Diff (NumTimeDomain a) | |
Defined in Data.TimeDomain |
class TimeDifference (Diff time) => TimeDomain time where #
A time domain is an affine space representing a notion of time, such as real time, simulated time, steps, or a completely different notion.
Expected laws:
diffTime :: time -> time -> Diff time #
Compute the difference between two timestamps.
Mnemonic: diffTime
behaves like the (-)
operator:
is the duration it takes from diffTime
earlier later = later `diffTime
` earlierearlier
to later
.
addTime :: time -> Diff time -> time #
Add a time difference to a timestamp.
Instances
TimeDomain UTCTime | Differences between |
TimeDomain Integer | |
TimeDomain () | |
TimeDomain Double | |
TimeDomain Float | |
Num a => TimeDomain (NumTimeDomain a) | |
Defined in Data.TimeDomain type Diff (NumTimeDomain a) # diffTime :: NumTimeDomain a -> NumTimeDomain a -> Diff (NumTimeDomain a) # addTime :: NumTimeDomain a -> Diff (NumTimeDomain a) -> NumTimeDomain a # |
class TimeDifference d where #
A type of durations, or differences betweens time stamps.
Expected laws:
add
is commutative and associative(dt1
difference
dt2)add
dt2 = dt1
difference :: d -> d -> d #
Calculate the difference between two durations,
compatibly with diffTime
.
Add two time differences.
Instances
TimeDifference Integer | |
TimeDifference () | |
Defined in Data.TimeDomain difference :: () -> () -> () # | |
TimeDifference Double | |
TimeDifference Float | |
Num a => TimeDifference (NumTimeDomain a) | |
Defined in Data.TimeDomain difference :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # add :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # |
newtype NumTimeDomain a #
Any Num
can be wrapped to form a TimeDomain
.
Instances
Num a => Num (NumTimeDomain a) | |
Defined in Data.TimeDomain (+) :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # (-) :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # (*) :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # negate :: NumTimeDomain a -> NumTimeDomain a # abs :: NumTimeDomain a -> NumTimeDomain a # signum :: NumTimeDomain a -> NumTimeDomain a # fromInteger :: Integer -> NumTimeDomain a # | |
Num a => TimeDifference (NumTimeDomain a) | |
Defined in Data.TimeDomain difference :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # add :: NumTimeDomain a -> NumTimeDomain a -> NumTimeDomain a # | |
Num a => TimeDomain (NumTimeDomain a) | |
Defined in Data.TimeDomain type Diff (NumTimeDomain a) # diffTime :: NumTimeDomain a -> NumTimeDomain a -> Diff (NumTimeDomain a) # addTime :: NumTimeDomain a -> Diff (NumTimeDomain a) -> NumTimeDomain a # | |
type Diff (NumTimeDomain a) | |
Defined in Data.TimeDomain |
liftPass :: Monad m => Pass w m (Either e a) -> Pass w (ExceptT e m) a #
Lift a pass
operation to the new monad.
liftListen :: Monad m => Listen w m (Either e a) -> Listen w (ExceptT e m) a #
Lift a listen
operation to the new monad.
liftCallCC :: CallCC m (Either e a) (Either e b) -> CallCC (ExceptT e m) a b #
Lift a callCC
operation to the new monad.
type LiftClock m t cl = HoistClock m (t m) cl Source #
Lift a clock type into a monad transformer.
data HoistClock m1 m2 cl Source #
Applying a monad morphism yields a new clock.
HoistClock | |
|
Instances
(Monad m1, Monad m2, Clock m1 cl) => Clock m2 (HoistClock m1 m2 cl) Source # | |
Defined in FRP.Rhine.Clock type Time (HoistClock m1 m2 cl) Source # type Tag (HoistClock m1 m2 cl) Source # initClock :: HoistClock m1 m2 cl -> RunningClockInit m2 (Time (HoistClock m1 m2 cl)) (Tag (HoistClock m1 m2 cl)) Source # | |
GetClockProxy cl => GetClockProxy (HoistClock m1 m2 cl) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (HoistClock m1 m2 cl) Source # | |
type Tag (HoistClock m1 m2 cl) Source # | |
Defined in FRP.Rhine.Clock | |
type Time (HoistClock m1 m2 cl) Source # | |
Defined in FRP.Rhine.Clock |
data RescaledClockS m cl time tag Source #
Instead of a mere function as morphism of time domains, we can transform one time domain into the other with a monadic stream function.
RescaledClockS | |
|
Instances
(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClockS m cl time tag) Source # | |
Defined in FRP.Rhine.Clock type Time (RescaledClockS m cl time tag) Source # type Tag (RescaledClockS m cl time tag) Source # initClock :: RescaledClockS m cl time tag -> RunningClockInit m (Time (RescaledClockS m cl time tag)) (Tag (RescaledClockS m cl time tag)) Source # | |
GetClockProxy cl => GetClockProxy (RescaledClockS m cl time tag) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (RescaledClockS m cl time tag) Source # | |
type Tag (RescaledClockS m cl time tag) Source # | |
Defined in FRP.Rhine.Clock | |
type Time (RescaledClockS m cl time tag) Source # | |
Defined in FRP.Rhine.Clock |
data RescaledClockM m cl time Source #
Instead of a mere function as morphism of time domains, we can transform one time domain into the other with an effectful morphism.
RescaledClockM | |
|
Instances
(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClockM m cl time) Source # | |
Defined in FRP.Rhine.Clock type Time (RescaledClockM m cl time) Source # type Tag (RescaledClockM m cl time) Source # initClock :: RescaledClockM m cl time -> RunningClockInit m (Time (RescaledClockM m cl time)) (Tag (RescaledClockM m cl time)) Source # | |
GetClockProxy cl => GetClockProxy (RescaledClockM m cl time) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (RescaledClockM m cl time) Source # | |
type Tag (RescaledClockM m cl time) Source # | |
Defined in FRP.Rhine.Clock | |
type Time (RescaledClockM m cl time) Source # | |
Defined in FRP.Rhine.Clock |
data RescaledClock cl time Source #
Applying a morphism of time domains yields a new clock.
RescaledClock | |
|
Instances
(Monad m, TimeDomain time, Clock m cl) => Clock m (RescaledClock cl time) Source # | |
Defined in FRP.Rhine.Clock type Time (RescaledClock cl time) Source # type Tag (RescaledClock cl time) Source # initClock :: RescaledClock cl time -> RunningClockInit m (Time (RescaledClock cl time)) (Tag (RescaledClock cl time)) Source # | |
GetClockProxy cl => GetClockProxy (RescaledClock cl time) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (RescaledClock cl time) Source # | |
type Tag (RescaledClock cl time) Source # | |
Defined in FRP.Rhine.Clock | |
type Time (RescaledClock cl time) Source # | |
Defined in FRP.Rhine.Clock |
type RescalingSInit m cl time tag = Time cl -> m (RescalingS m cl time tag, time) Source #
Like RescalingS
, but allows for an initialisation
of the rescaling morphism, together with the initial time.
type RescalingS m cl time tag = MSF m (Time cl, Tag cl) (time, tag) Source #
An effectful, stateful morphism of time domains is an MSF
that uses side effects to rescale a point in one time domain
into another one.
type RescalingM m cl time = Time cl -> m time Source #
An effectful morphism of time domains is a Kleisli arrow. It can use a side effect to rescale a point in one time domain into another one.
type Rescaling cl time = Time cl -> time Source #
A pure morphism of time domains is just a function.
An annotated, rich time stamp.
class TimeDomain (Time cl) => Clock m cl where Source #
Since we want to leverage Haskell's type system to annotate signal networks by their clocks,
each clock must be an own type, cl
.
Different values of the same clock type should tick at the same speed,
and only differ in implementation details.
Often, clocks are singletons.
The time domain, i.e. type of the time stamps the clock creates.
Additional information that the clock may output at each tick, e.g. if a realtime promise was met, if an event occurred, if one of its subclocks (if any) ticked.
:: cl | The clock value, containing e.g. settings or device parameters |
-> RunningClockInit m (Time cl) (Tag cl) | The stream of time stamps, and the initial time |
The method that produces to a clock value a running clock, i.e. an effectful stream of tagged time stamps together with an initialisation time.
Instances
type RunningClockInit m time tag = m (RunningClock m time tag, time) Source #
When initialising a clock, the initial time is measured (typically by means of a side effect), and a running clock is returned.
type RunningClock m time tag = MSF m () (time, tag) Source #
A clock creates a stream of time stamps and additional information,
possibly together with side effects in a monad m
that cause the environment to wait until the specified time is reached.
retag :: Time cl1 ~ Time cl2 => (Tag cl1 -> Tag cl2) -> TimeInfo cl1 -> TimeInfo cl2 Source #
A utility that changes the tag of a TimeInfo
.
rescaleMToSInit :: Monad m => (time1 -> m time2) -> time1 -> m (MSF m (time1, tag) (time2, tag), time2) Source #
Convert an effectful morphism of time domains into a stateful one with initialisation.
Think of its type as RescalingM m cl time -> RescalingSInit m cl time tag
,
although this type is ambiguous.
rescaledClockToM :: Monad m => RescaledClock cl time -> RescaledClockM m cl time Source #
A RescaledClock
is trivially a RescaledClockM
.
rescaledClockMToS :: Monad m => RescaledClockM m cl time -> RescaledClockS m cl time (Tag cl) Source #
A RescaledClockM
is trivially a RescaledClockS
.
rescaledClockToS :: Monad m => RescaledClock cl time -> RescaledClockS m cl time (Tag cl) Source #
A RescaledClock
is trivially a RescaledClockS
.
liftClock :: (Monad m, MonadTrans t) => cl -> LiftClock m t cl Source #
Lift a clock value into a monad transformer.
type BehaviorF m time a b = BehaviourF m time a b Source #
Compatibility to U.S. american spelling.
type BehaviourF m time a b = forall cl. time ~ Time cl => ClSF m cl a b Source #
A (side-effectful) behaviour function is a time-aware synchronous stream
function that doesn't depend on a particular clock.
time
denotes the TimeDomain
.
type Behaviour m time a = forall cl. time ~ Time cl => ClSignal m cl a Source #
A (side-effectful) behaviour is a time-aware stream
that doesn't depend on a particular clock.
time
denotes the TimeDomain
.
type ClSignal m cl a = forall arbitrary. ClSF m cl arbitrary a Source #
A clocked signal is a ClSF
with no input required.
It produces its output on its own.
type ClSF m cl a b = MSF (ReaderT (TimeInfo cl) m) a b Source #
A (synchronous, clocked) monadic stream function
with the additional side effect of being time-aware,
that is, reading the current TimeInfo
of the clock cl
.
hoistClSF :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 cl a b Source #
Hoist a ClSF
along a monad morphism.
hoistClSFAndClock :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ClSF m1 cl a b -> ClSF m2 (HoistClock m1 m2 cl) a b Source #
Hoist a ClSF
and its clock along a monad morphism.
liftClSF :: (Monad m, MonadTrans t, Monad (t m)) => ClSF m cl a b -> ClSF (t m) cl a b Source #
Lift a ClSF
into a monad transformer.
liftClSFAndClock :: (Monad m, MonadTrans t, Monad (t m)) => ClSF m cl a b -> ClSF (t m) (LiftClock m t cl) a b Source #
Lift a ClSF
and its clock into a monad transformer.
timeless :: Monad m => MSF m a b -> ClSF m cl a b Source #
A monadic stream function without dependency on time
is a ClSF
for any clock.
arrMCl :: Monad m => (a -> m b) -> ClSF m cl a b Source #
Utility to lift Kleisli arrows directly to ClSF
s.
mapMaybe :: Monad m => ClSF m cl a b -> ClSF m cl (Maybe a) (Maybe b) Source #
Call a ClSF
every time the input is 'Just a'.
Caution: This will not change the time differences since the last tick.
For example,
while integrate 1
is approximately the same as timeInfoOf sinceInit
,
mapMaybe $ integrate 1
is very different from
mapMaybe $ timeInfoOf sinceInit
.
The former only integrates when the input is Just 1
,
whereas the latter always returns the correct time since initialisation.
commuteReaders :: ReaderT r1 (ReaderT r2 m) a -> ReaderT r2 (ReaderT r1 m) a Source #
Commute two ReaderT
transformer layers past each other
runReaderS :: Monad m => ClSF (ReaderT r m) cl a b -> ClSF m cl (a, r) b Source #
Remove ("run") a ReaderT
layer from the monad stack
by making it an explicit input to the behaviour.
runReaderS_ :: Monad m => ClSF (ReaderT r m) cl a b -> r -> ClSF m cl a b Source #
Remove a ReaderT
layer by passing the readonly environment explicitly.
:: (RandomGen g, Monad m) | |
=> ClSF (RandT g m) cl a b | |
-> g | The initial random seed |
-> ClSF m cl a (g, b) |
Generates random values, updating the generator on every step.
evalRandS :: (RandomGen g, Monad m) => ClSF (RandT g m) cl a b -> g -> ClSF m cl a b Source #
Updates the generator every step but discards the generator.
execRandS :: (RandomGen g, Monad m) => ClSF (RandT g m) cl a b -> g -> ClSF m cl a g Source #
Updates the generator every step but discards the value, only outputting the generator.
evalRandIOS :: Monad m => ClSF (RandT StdGen m) cl a b -> IO (ClSF m cl a b) Source #
Evaluates the random computation by using the global random generator.
evalRandIOS' :: MonadIO m => ClSF (RandT StdGen m) cl a b -> ClSF m cl a b Source #
Evaluates the random computation by using the global random generator on the first tick.
getRandomS :: (MonadRandom m, Random a) => Behaviour m time a Source #
Produce a random value at every tick.
getRandomRS :: (MonadRandom m, Random a) => BehaviourF m time (a, a) a Source #
Produce a random value at every tick, within a range given per tick.
getRandomRS_ :: (MonadRandom m, Random a) => (a, a) -> Behaviour m time a Source #
Produce a random value at every tick, within a range given once.
type BehaviorFExcept m time a b e = BehaviourFExcept m time a b e Source #
Compatibility to U.S. american spelling.
type BehaviourFExcept m time a b e = forall cl. time ~ Time cl => ClSFExcept m cl a b e Source #
A clock polymorphic ClSFExcept
,
or equivalently an exception-throwing behaviour.
Any clock with time domain time
may occur.
type ClSFExcept m cl a b e = MSFExcept (ReaderT (TimeInfo cl) m) a b e Source #
A synchronous exception-throwing signal function.
It is based on a newtype
from Dunai, MSFExcept
,
to exhibit a monad interface in the exception type.
return
then corresponds to throwing an exception,
and (>>=)
is exception handling.
(For more information, see the documentation of MSFExcept
.)
m
: The monad that the signal function may take side effects incl
: The clock on which the signal function ticksa
: The input typeb
: The output typee
: The type of exceptions that can be thrown
throwOn :: Monad m => e -> ClSF (ExceptT e m) cl Bool () Source #
Throw the given exception when the Bool
turns true.
throwOn' :: Monad m => ClSF (ExceptT e m) cl (Bool, e) () Source #
Variant of throwOn
, where the exception can vary every tick.
throwOnCond :: Monad m => (a -> Bool) -> e -> ClSF (ExceptT e m) cl a a Source #
Throw the exception e
whenever the function evaluates to True
.
throwOnCondM :: Monad m => (a -> m Bool) -> e -> ClSF (ExceptT e m) cl a a Source #
Variant of throwOnCond
for Kleisli arrows.
Throws the exception when the input is True
.
throwMaybe :: Monad m => ClSF (ExceptT e m) cl (Maybe e) (Maybe a) Source #
When the input is Just e
, throw the exception e
.
runClSFExcept :: Monad m => ClSFExcept m cl a b e -> ClSF (ExceptT e m) cl a b Source #
Leave the monad context, to use the ClSFExcept
as an Arrow
.
once :: Monad m => (a -> m e) -> ClSFExcept m cl a b e Source #
Within the same tick, perform a monadic action, and immediately throw the value as an exception.
step :: Monad m => (a -> m (b, e)) -> ClSFExcept m cl a b e Source #
Advances a single tick with the given Kleisli arrow, and then throws an exception.
timeInfo :: Monad m => ClSF m cl a (TimeInfo cl) Source #
Read the environment variable, i.e. the TimeInfo
.
timeInfoOf :: Monad m => (TimeInfo cl -> b) -> ClSF m cl a b Source #
Utility to apply functions to the current TimeInfo
,
such as record selectors:
printAbsoluteTime :: ClSF IO cl () ()
printAbsoluteTime = timeInfoOf absolute >>> arrMCl print
sinceLastS :: Monad m => ClSF m cl a (Diff (Time cl)) Source #
Continuously return the time difference since the last tick.
sinceInitS :: Monad m => ClSF m cl a (Diff (Time cl)) Source #
Continuously return the time difference since clock initialisation.
sinceStart :: (Monad m, TimeDomain time) => BehaviourF m time a (Diff time) Source #
Calculate the time passed since this ClSF
was instantiated.
This is _not_ the same as sinceInitS
,
which measures the time since clock initialisation.
For example, the following gives a sawtooth signal:
sawtooth = safely $ do try $ sinceStart >>> proc time -> do throwOn () -time 1 returnA -< time safe sawtooth
If you replace sinceStart
by sinceInitS
,
it will usually hang after one second,
since it doesn't reset after restarting the sawtooth.
(>->) :: Category cat => cat a b -> cat b c -> cat a c infixr 6 Source #
Alias for >>>
(sequential composition)
with higher operator precedence, designed to work with the other operators, e.g.:
clsf1 >-> clsf2 @@ clA |@| clsf3 >-> clsf4 @@ clB
The type signature specialises e.g. to
(>->) :: Monad m => ClSF m cl a b -> ClSF m cl b c -> ClSF m cl a c
arr_ :: Arrow a => b -> a c b Source #
Output a constant value. Specialises e.g. to this type signature:
arr_ :: Monad m => b -> ClSF m cl a b
integralFrom :: (Monad m, VectorSpace v s, s ~ Diff td) => v -> BehaviorF m td v v Source #
The output of integralFrom v0
is the numerical Euler integral
of the input, with initial offset v0
.
integral :: (Monad m, VectorSpace v s, s ~ Diff td) => BehaviorF m td v v Source #
Euler integration, with zero initial offset.
derivativeFrom :: (Monad m, VectorSpace v s, s ~ Diff td) => v -> BehaviorF m td v v Source #
The output of derivativeFrom v0
is the numerical derivative of the input,
with a Newton difference quotient.
The input is initialised with v0
.
derivative :: (Monad m, VectorSpace v s, s ~ Diff td) => BehaviorF m td v v Source #
Numerical derivative with input initialised to zero.
threePointDerivativeFrom Source #
:: (Monad m, VectorSpace v s, s ~ Diff td, Num s) | |
=> v | The initial position |
-> BehaviorF m td v v |
Like derivativeFrom
, but uses three samples to compute the derivative.
Consequently, it is delayed by one sample.
threePointDerivative :: (Monad m, VectorSpace v s, s ~ Diff td, Num s) => BehaviorF m td v v Source #
Like threePointDerivativeFrom
,
but with the initial position initialised to zeroVector
.
:: (Monad m, VectorSpace v s, s ~ Diff td, Num s) | |
=> v | The initial position |
-> BehaviorF m td (v, s) v |
A weighted moving average signal function. The output is the average of the first input, weighted by the second input (which is assumed to be always between 0 and 1). The weight is applied to the average of the last tick, so a weight of 1 simply repeats the past value unchanged, whereas a weight of 0 outputs the current value.
:: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) | |
=> v | The initial position |
-> Diff td | The time scale on which the signal is averaged |
-> BehaviorF m td v v |
An exponential moving average, or low pass.
It will average out, or filter,
all features below a given time constant t
.
(Equivalently, it filters out frequencies above 1 / (2 * pi * t)
.)
:: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) | |
=> Diff td | The time scale on which the signal is averaged |
-> BehaviourF m td v v |
An average, or low pass, initialised to zero.
:: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) | |
=> v | The initial position |
-> Diff td | The time scale on which the signal is averaged |
-> BehaviourF m td v v |
A linearised version of averageFrom
.
It is more efficient, but only accurate
if the supplied time scale is much bigger
than the average time difference between two ticks.
:: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) | |
=> Diff td | The time scale on which the signal is averaged |
-> BehaviourF m td v v |
Linearised version of average
.
lowPass :: (Monad m, VectorSpace v s, Floating s, s ~ Diff td) => Diff td -> BehaviourF m td v v Source #
Alias for average
.
:: (Monad m, VectorSpace v s, Floating s, Eq s, s ~ Diff td) | |
=> Diff td | The time constant |
-> BehaviourF m td v v |
Filters out frequencies below 1 / (2 * pi * t)
.
:: (Monad m, VectorSpace v s, Floating s, Eq s, s ~ Diff td) | |
=> Diff td | The time constant |
-> BehaviourF m td v v |
Filters out frequencies other than 1 / (2 * pi * t)
.
:: (Monad m, VectorSpace v s, Floating s, Eq s, s ~ Diff td) | |
=> Diff td | The time constant |
-> BehaviourF m td v v |
Filters out the frequency 1 / (2 * pi * t)
.
keepFirst :: Monad m => ClSF m cl a a Source #
Remembers and indefinitely outputs ("holds") the first input value.
:: (Monad m, Ord (Diff (Time cl)), TimeDomain (Time cl)) | |
=> Diff (Time cl) | The size of the time window |
-> ClSF m cl a (Seq (TimeInfo cl, a)) |
Remembers all input values that arrived within a given time window. New values are appended left.
:: (Monad m, Ord (Diff td), TimeDomain td) | |
=> Diff td | The time span to delay the signal |
-> BehaviorF m td a a |
Delay a signal by certain time span, initialising with the first input.
timer :: (Monad m, TimeDomain td, Ord (Diff td)) => Diff td -> BehaviorF (ExceptT () m) td a (Diff td) Source #
Throws an exception after the specified time difference,
outputting the time passed since the timer
was instantiated.
timer_ :: (Monad m, TimeDomain td, Ord (Diff td)) => Diff td -> BehaviorF (ExceptT () m) td a () Source #
Like timer_
, but doesn't output the remaining time at all.
scaledTimer :: (Monad m, TimeDomain td, Fractional (Diff td), Ord (Diff td)) => Diff td -> BehaviorF (ExceptT () m) td a (Diff td) Source #
Like timer
, but divides the remaining time by the total time.
lastS :: Monad m => a -> MSF m (Maybe a) a Source #
Remembers the last Just
value,
defaulting to the given initialisation value.
data UnscheduleClock m cl Source #
If cl
is a Clock
in 'ScheduleT diff m', apply UnscheduleClock
to get a clock in m
.
UnscheduleClock | |
|
Instances
(Clock (ScheduleT (Diff (Time cl)) m) cl, Monad m) => Clock m (UnscheduleClock m cl) Source # | |
Defined in FRP.Rhine.Clock.Unschedule type Time (UnscheduleClock m cl) Source # type Tag (UnscheduleClock m cl) Source # initClock :: UnscheduleClock m cl -> RunningClockInit m (Time (UnscheduleClock m cl)) (Tag (UnscheduleClock m cl)) Source # | |
type Tag (UnscheduleClock m cl) Source # | |
Defined in FRP.Rhine.Clock.Unschedule | |
type Time (UnscheduleClock m cl) Source # | |
Defined in FRP.Rhine.Clock.Unschedule |
unyieldClock :: cl -> UnscheduleClock IO cl Source #
type ResBuf m cla clb a b = ResamplingBuffer m cla clb a b Source #
A type synonym to allow for abbreviation.
data ResamplingBuffer m cla clb a b Source #
A stateful buffer from which one may get
a value,
or to which one may put
a value,
depending on the clocks.
ResamplingBuffer
s can be clock-polymorphic,
or specific to certain clocks.
m
: Monad in which theResamplingBuffer
may have side effectscla
: The clock at which data enters the bufferclb
: The clock at which data leaves the buffera
: The input typeb
: The output type
ResamplingBuffer | |
|
hoistResamplingBuffer :: (Monad m1, Monad m2) => (forall c. m1 c -> m2 c) -> ResamplingBuffer m1 cla clb a b -> ResamplingBuffer m2 cla clb a b Source #
Hoist a ResamplingBuffer
along a monad morphism.
:: Monad m | |
=> MSF m (TimeInfo cl2, [(TimeInfo cl1, a)]) b | The monadic stream function that consumes a single time stamp for the moment when an output value is required, and a list of timestamped inputs, and outputs a single value. The list will contain the newest element in the head. |
-> ResamplingBuffer m cl1 cl2 a b |
Given a monadic stream function that accepts
a varying number of inputs (a list),
a ResamplingBuffer
can be formed
that collects all input in a timestamped list.
data AsyncMealy m s a b Source #
An asynchronous, effectful Mealy machine description.
(Input and output do not happen simultaneously.)
It can be used to create ResamplingBuffer
s.
timelessResamplingBuffer Source #
:: Monad m | |
=> AsyncMealy m s a b | |
-> s | The initial state |
-> ResamplingBuffer m cl1 cl2 a b |
A resampling buffer that is unaware of the time information of the clock,
and thus clock-polymorphic.
It is built from an asynchronous Mealy machine description.
Whenever get
is called on timelessResamplingBuffer machine s
,
the method amGet
is called on machine
with state s
,
discarding the time stamp. Analogously for put
.
trivialResamplingBuffer :: Monad m => ResamplingBuffer m cl1 cl2 () () Source #
A resampling buffer that only accepts and emits units.
lifoUnbounded :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a) Source #
An unbounded LIFO buffer.
If the buffer is empty, it will return Nothing
.
lifoBounded :: Monad m => Int -> ResamplingBuffer m cl1 cl2 a (Maybe a) Source #
A bounded LIFO buffer that forgets the oldest values when the size is above a given threshold.
If the buffer is empty, it will return Nothing
.
lifoWatch :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a, Int) Source #
An unbounded LIFO buffer that also returns its current size.
keepLast :: Monad m => a -> ResamplingBuffer m cl1 cl2 a a Source #
Always keeps the last input value,
or in case of no input an initialisation value.
If cl2
approximates continuity,
this behaves like a zero-order hold.
fifoUnbounded :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a) Source #
An unbounded FIFO buffer.
If the buffer is empty, it will return Nothing
.
fifoBounded :: Monad m => Int -> ResamplingBuffer m cl1 cl2 a (Maybe a) Source #
A bounded FIFO buffer that forgets the oldest values when the size is above a given threshold.
If the buffer is empty, it will return Nothing
.
fifoWatch :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a, Int) Source #
An unbounded FIFO buffer that also returns its current size.
collect :: Monad m => ResamplingBuffer m cl1 cl2 a [a] Source #
Collects all input in a list, with the newest element at the head,
which is returned and emptied upon get
.
collectSequence :: Monad m => ResamplingBuffer m cl1 cl2 a (Seq a) Source #
Reimplementation of collect
with sequences,
which gives a performance benefit if the sequence needs to be reversed or searched.
pureBuffer :: Monad m => ([a] -> b) -> ResamplingBuffer m cl1 cl2 a b Source #
pureBuffer
collects all input values lazily in a list
and processes it when output is required.
Semantically, pureBuffer f == collect >>-^ arr f
,
but pureBuffer
is slightly more efficient.
:: Monad m | |
=> (a -> b -> b) | The folding function |
-> b | The initial value |
-> ResamplingBuffer m cl1 cl2 a b |
A buffer collecting all incoming values with a folding function.
It is strict, i.e. the state value b
is calculated on every put
.
(>>-^) :: Monad m => ResamplingBuffer m cl1 cl2 a b -> ClSF m cl2 b c -> ResamplingBuffer m cl1 cl2 a c infix 2 Source #
Postcompose a ResamplingBuffer
with a matching ClSF
.
(^->>) :: Monad m => ClSF m cl1 a b -> ResamplingBuffer m cl1 cl2 b c -> ResamplingBuffer m cl1 cl2 a c infix 1 Source #
Precompose a ResamplingBuffer
with a matching ClSF
.
(*-*) :: Monad m => ResamplingBuffer m cl1 cl2 a b -> ResamplingBuffer m cl1 cl2 c d -> ResamplingBuffer m cl1 cl2 (a, c) (b, d) infixl 4 Source #
Parallely compose two ResamplingBuffer
s.
(&-&) :: Monad m => ResamplingBuffer m cl1 cl2 a b -> ResamplingBuffer m cl1 cl2 a c -> ResamplingBuffer m cl1 cl2 a (b, c) infixl 4 Source #
Parallely compose two ResamplingBuffer
s, duplicating the input.
timestamped :: Monad m => (forall b. ResamplingBuffer m cl clf b (f b)) -> ResamplingBuffer m cl clf a (f (a, TimeInfo cl)) Source #
Given a ResamplingBuffer
where the output type depends on the input type polymorphically,
we can produce a timestamped version that simply annotates every input value
with the TimeInfo
when it arrived.
:: (Monad m, Clock m cl1, Clock m cl2, VectorSpace v s, Num s, s ~ Diff (Time cl1), s ~ Diff (Time cl2)) | |
=> v | The initial velocity (derivative of the signal) |
-> v | The initial position |
-> ResamplingBuffer m cl1 cl2 v v |
A simple linear interpolation based on the last calculated position and velocity.
:: (Monad m, Clock m cl1, Clock m cl2, VectorSpace v s, Ord s, Floating s, s ~ Diff (Time cl1), s ~ Diff (Time cl2)) | |
=> s | The size of the interpolation window (for how long in the past to remember incoming values) |
-> ResamplingBuffer m cl1 cl2 v v |
sinc-Interpolation, or Whittaker-Shannon-Interpolation.
The incoming signal is strictly bandlimited
by the frequency at which cl1
ticks.
Each incoming value is hulled in a sinc function,
these are added and sampled at cl2
's ticks.
In order not to produce a space leak,
the buffer only remembers the past values within a given window,
which should be chosen much larger than the average time between cl1
's ticks.
cubic :: (Monad m, VectorSpace v s, Floating v, Eq v, Fractional s, s ~ Diff (Time cl1), s ~ Diff (Time cl2)) => ResamplingBuffer m cl1 cl2 v v Source #
Interpolates the signal with Hermite splines,
using threePointDerivative
.
Caution: In order to calculate the derivatives of the incoming signal,
it has to be delayed by two ticks of cl1
.
In a non-realtime situation, a higher quality is achieved
if the ticks of cl2
are delayed by two ticks of cl1
.
data ParClockInclusion clS cl where Source #
An inclusion of a clock into a tree of parallel compositions of clocks.
ParClockInL :: ParClockInclusion (ParallelClock clL clR) cl -> ParClockInclusion clL cl | |
ParClockInR :: ParClockInclusion (ParallelClock clL clR) cl -> ParClockInclusion clR cl | |
ParClockRefl :: ParClockInclusion cl cl |
data LastTime cl where Source #
A tree representing possible last times to which the constituents of a clock may have ticked.
SequentialLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (SequentialClock cl1 cl2) | |
ParallelLastTime :: LastTime cl1 -> LastTime cl2 -> LastTime (ParallelClock cl1 cl2) | |
LeafLastTime :: Time cl -> LastTime cl |
type family Out cl where ... Source #
The clock that represents the rate at which data leaves the system.
Out (SequentialClock cl1 cl2) = Out cl2 | |
Out (ParallelClock cl1 cl2) = ParallelClock (Out cl1) (Out cl2) | |
Out cl = cl |
type family In cl where ... Source #
The clock that represents the rate at which data enters the system.
In (SequentialClock cl1 cl2) = In cl1 | |
In (ParallelClock cl1 cl2) = ParallelClock (In cl1) (In cl2) | |
In cl = cl |
type ParClock cl1 cl2 = ParallelClock cl1 cl2 Source #
Abbrevation synonym.
data ParallelClock cl1 cl2 Source #
Two clocks can be combined with a schedule as a clock for an asynchronous parallel composition of signal networks.
Time cl1 ~ Time cl2 => ParallelClock | |
|
Instances
(Monad m, MonadSchedule m, Clock m cl1, Clock m cl2) => Clock m (ParallelClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule type Time (ParallelClock cl1 cl2) Source # type Tag (ParallelClock cl1 cl2) Source # initClock :: ParallelClock cl1 cl2 -> RunningClockInit m (Time (ParallelClock cl1 cl2)) (Tag (ParallelClock cl1 cl2)) Source # | |
(GetClockProxy cl1, GetClockProxy cl2) => GetClockProxy (ParallelClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (ParallelClock cl1 cl2) Source # | |
type Tag (ParallelClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule | |
type Time (ParallelClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule |
type SeqClock cl1 cl2 = SequentialClock cl1 cl2 Source #
Abbrevation synonym.
data SequentialClock cl1 cl2 Source #
Two clocks can be combined with a schedule as a clock for an asynchronous sequential composition of signal networks.
Time cl1 ~ Time cl2 => SequentialClock | |
|
Instances
(Monad m, MonadSchedule m, Clock m cl1, Clock m cl2) => Clock m (SequentialClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule type Time (SequentialClock cl1 cl2) Source # type Tag (SequentialClock cl1 cl2) Source # initClock :: SequentialClock cl1 cl2 -> RunningClockInit m (Time (SequentialClock cl1 cl2)) (Tag (SequentialClock cl1 cl2)) Source # | |
(GetClockProxy cl1, GetClockProxy cl2) => GetClockProxy (SequentialClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Clock.Proxy getClockProxy :: ClockProxy (SequentialClock cl1 cl2) Source # | |
type Tag (SequentialClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule | |
type Time (SequentialClock cl1 cl2) Source # | |
Defined in FRP.Rhine.Schedule |
scheduleList :: (Monad m, MonadSchedule m) => NonEmpty (MSF m a b) -> MSF m a (NonEmpty b) Source #
runningSchedule :: (Monad m, MonadSchedule m, Clock m cl1, Clock m cl2, Time cl1 ~ Time cl2) => cl1 -> cl2 -> RunningClock m (Time cl1) (Tag cl1) -> RunningClock m (Time cl2) (Tag cl2) -> RunningClock m (Time cl1) (Either (Tag cl1) (Tag cl2)) Source #
Two clocks in the ScheduleT
monad transformer
can always be canonically scheduled.
Indeed, this is the purpose for which ScheduleT
was defined.
initSchedule :: (Time cl1 ~ Time cl2, Monad m, MonadSchedule m, Clock m cl1, Clock m cl2) => cl1 -> cl2 -> RunningClockInit m (Time cl1) (Either (Tag cl1) (Tag cl2)) Source #
A schedule implements a combination of two clocks.
It outputs a time stamp and an Either
value,
which specifies which of the two subclocks has ticked.
parClockTagInclusion :: ParClockInclusion clS cl -> Tag clS -> Tag cl Source #
Generates a tag for the composite clock from a tag of a leaf clock, given a parallel clock inclusion.
class ToClockProxy a where Source #
Extract a clock proxy from a type.
Nothing
toClockProxy :: a -> ClockProxy (Cl a) Source #
default toClockProxy :: GetClockProxy (Cl a) => a -> ClockProxy (Cl a) Source #
Instances
GetClockProxy cl => ToClockProxy (SN m cl a b) Source # | |
Defined in FRP.Rhine.SN toClockProxy :: SN m cl a b -> ClockProxy (Cl (SN m cl a b)) Source # | |
GetClockProxy cl => ToClockProxy (Rhine m cl a b) Source # | |
Defined in FRP.Rhine.Type toClockProxy :: Rhine m cl a b -> ClockProxy (Cl (Rhine m cl a b)) Source # |
class GetClockProxy cl where Source #
Clocks should be able to automatically generate a proxy for themselves.
Nothing
getClockProxy :: ClockProxy cl Source #
default getClockProxy :: (cl ~ In cl, cl ~ Out cl) => ClockProxy cl Source #
Instances
data ClockProxy cl where Source #
Witnesses the structure of a clock type,
in particular whether SequentialClock
s or ParallelClock
s are involved.
LeafProxy :: (cl ~ In cl, cl ~ Out cl) => ClockProxy cl | |
SequentialProxy :: ClockProxy cl1 -> ClockProxy cl2 -> ClockProxy (SequentialClock cl1 cl2) | |
ParallelProxy :: ClockProxy clL -> ClockProxy clR -> ClockProxy (ParallelClock clL clR) |
inProxy :: ClockProxy cl -> ClockProxy (In cl) Source #
outProxy :: ClockProxy cl -> ClockProxy (Out cl) Source #
inTag :: ClockProxy cl -> Tag cl -> Maybe (Tag (In cl)) Source #
Return the incoming tag, assuming that the incoming clock is ticked,
and Nothing
otherwise.
outTag :: ClockProxy cl -> Tag cl -> Maybe (Tag (Out cl)) Source #
Return the incoming tag, assuming that the outgoing clock is ticked,
and Nothing
otherwise.
data SN m cl a b where Source #
An SN
is a side-effectful asynchronous signal network,
where input, data processing (including side effects) and output
need not happen at the same time.
The type parameters are:
m
: The monad in which side effects take place.cl
: The clock of the whole signal network. It may be sequentially or parallely composed from other clocks.a
: The input type. Input arrives at the rateIn cl
.b
: The output type. Output arrives at the rateOut cl
.
Synchronous :: (cl ~ In cl, cl ~ Out cl) => ClSF m cl a b -> SN m cl a b | A synchronous monadic stream function is the basic building block.
For such an |
Sequential :: (Clock m clab, Clock m clcd, Clock m (Out clab), Clock m (Out clcd), Clock m (In clab), Clock m (In clcd), GetClockProxy clab, GetClockProxy clcd, Time clab ~ Time clcd, Time clab ~ Time (Out clab), Time clcd ~ Time (In clcd)) => SN m clab a b -> ResamplingBuffer m (Out clab) (In clcd) b c -> SN m clcd c d -> SN m (SequentialClock clab clcd) a d | Two |
Parallel :: (Clock m cl1, Clock m cl2, Clock m (Out cl1), Clock m (Out cl2), GetClockProxy cl1, GetClockProxy cl2, Time cl1 ~ Time (Out cl1), Time cl2 ~ Time (Out cl2), Time cl1 ~ Time cl2, Time cl1 ~ Time (In cl1), Time cl2 ~ Time (In cl2)) => SN m cl1 a b -> SN m cl2 a b -> SN m (ParallelClock cl1 cl2) a b | Two |
FirstResampling :: (Clock m (In cl), Clock m (Out cl), Time cl ~ Time (Out cl), Time cl ~ Time (In cl)) => SN m cl a b -> ResamplingBuffer m (In cl) (Out cl) c d -> SN m cl (a, c) (b, d) | Bypass the signal network by forwarding data in parallel through a |
Postcompose :: (Clock m (Out cl), Time cl ~ Time (Out cl)) => SN m cl a b -> ClSF m (Out cl) b c -> SN m cl a c | A |
Precompose :: (Clock m (In cl), Time cl ~ Time (In cl)) => ClSF m (In cl) a b -> SN m cl b c -> SN m cl a c | A |
Feedback :: (Clock m (In cl), Clock m (Out cl), Time (In cl) ~ Time cl, Time (Out cl) ~ Time cl) => ResBuf m (Out cl) (In cl) d c -> SN m cl (a, c) (b, d) -> SN m cl a b | Data can be looped back to the beginning of an |
Instances
GetClockProxy cl => ToClockProxy (SN m cl a b) Source # | |
Defined in FRP.Rhine.SN toClockProxy :: SN m cl a b -> ClockProxy (Cl (SN m cl a b)) Source # | |
type Cl (SN m cl a b) Source # | |
Defined in FRP.Rhine.SN |
(>>>^) :: Monad m => SN m cl a b -> (b -> c) -> SN m cl a c Source #
Postcompose a signal network with a pure function.
(^>>>) :: Monad m => (a -> b) -> SN m cl b c -> SN m cl a c Source #
Precompose a signal network with a pure function.
(>--^) :: (Clock m (Out cl), Time cl ~ Time (Out cl)) => SN m cl a b -> ClSF m (Out cl) b c -> SN m cl a c Source #
Postcompose a signal network with a ClSF
.
(^-->) :: (Clock m (In cl), Time cl ~ Time (In cl)) => ClSF m (In cl) a b -> SN m cl b c -> SN m cl a c Source #
Precompose a signal network with a ClSF
.
(****) :: Monad m => SN m cl a b -> SN m cl c d -> SN m cl (a, c) (b, d) Source #
Compose two signal networks on the same clock in data-parallel.
At one tick of cl
, both networks are stepped.
(||||) :: (Monad m, Clock m clL, Clock m clR, Clock m (Out clL), Clock m (Out clR), GetClockProxy clL, GetClockProxy clR, Time clL ~ Time clR, Time clL ~ Time (Out clL), Time clL ~ Time (In clL), Time clR ~ Time (Out clR), Time clR ~ Time (In clR)) => SN m clL a b -> SN m clR a b -> SN m (ParClock clL clR) a b Source #
Compose two signal networks on different clocks in clock-parallel.
At one tick of ParClock cl1 cl2
, one of the networks is stepped,
dependent on which constituent clock has ticked.
Note: This is essentially an infix synonym of Parallel
(++++) :: (Monad m, Clock m clL, Clock m clR, Clock m (Out clL), Clock m (Out clR), GetClockProxy clL, GetClockProxy clR, Time clL ~ Time clR, Time clL ~ Time (Out clL), Time clL ~ Time (In clL), Time clR ~ Time (Out clR), Time clR ~ Time (In clR)) => SN m clL a b -> SN m clR a c -> SN m (ParClock clL clR) a (Either b c) Source #
Compose two signal networks on different clocks in clock-parallel.
At one tick of ParClock cl1 cl2
, one of the networks is stepped,
dependent on which constituent clock has ticked.
genTimeInfo :: (Monad m, Clock m cl) => ClockProxy cl -> Time cl -> MSF m (Time cl, Tag cl) (TimeInfo cl) Source #
Given a clock value and an initial time, generate a stream of time stamps.
data SelectClock cl a Source #
A clock that selects certain subevents of type a
,
from the tag of a main clock.
If two SelectClock
s would tick on the same type of subevents,
but should not have the same type,
one should newtype
the subevent.
Instances
data StdinClock Source #
A clock that ticks for every line entered on the console,
outputting the entered line as its Tag
.
Instances
Semigroup StdinClock Source # | |
Defined in FRP.Rhine.Clock.Realtime.Stdin (<>) :: StdinClock -> StdinClock -> StdinClock # sconcat :: NonEmpty StdinClock -> StdinClock # stimes :: Integral b => b -> StdinClock -> StdinClock # | |
GetClockProxy StdinClock Source # | |
Defined in FRP.Rhine.Clock.Realtime.Stdin | |
MonadIO m => Clock m StdinClock Source # | |
Defined in FRP.Rhine.Clock.Realtime.Stdin type Time StdinClock Source # type Tag StdinClock Source # initClock :: StdinClock -> RunningClockInit m (Time StdinClock) (Tag StdinClock) Source # | |
type Tag StdinClock Source # | |
Defined in FRP.Rhine.Clock.Realtime.Stdin | |
type Time StdinClock Source # | |
Defined in FRP.Rhine.Clock.Realtime.Stdin |
data EventClock event Source #
A clock that ticks whenever an event
is emitted.
It is not yet bound to a specific channel,
since ideally, the correct channel is created automatically
by runEventChanT
.
If you want to create the channel manually and bind the clock to it,
use eventClockOn
.
Instances
Semigroup (EventClock event) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Event (<>) :: EventClock event -> EventClock event -> EventClock event # sconcat :: NonEmpty (EventClock event) -> EventClock event # stimes :: Integral b => b -> EventClock event -> EventClock event # | |
GetClockProxy (EventClock event) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Event getClockProxy :: ClockProxy (EventClock event) Source # | |
MonadIO m => Clock (EventChanT event m) (EventClock event) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Event type Time (EventClock event) Source # type Tag (EventClock event) Source # initClock :: EventClock event -> RunningClockInit (EventChanT event m) (Time (EventClock event)) (Tag (EventClock event)) Source # | |
type Tag (EventClock event) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Event | |
type Time (EventClock event) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Event |
type EventChanT event m = ReaderT (Chan event) m Source #
A monad transformer in which events can be emitted onto a Chan
.
withChan :: Chan event -> EventChanT event m a -> m a Source #
Escape the EventChanT
layer by explicitly providing a channel
over which events are sent.
Often this is not needed, and runEventChanT
can be used instead.
runEventChanT :: MonadIO m => EventChanT event m a -> m a Source #
Create a channel across which events can be communicated, and subsequently execute all event effects on this channel.
Ideally, this action is run _outside_ of flow
,
e.g. runEventChanT $ flow myRhine
.
This way, exactly one channel is created.
Caution: Don't use this with morphS
,
since it would create a new channel every tick.
Instead, create one chan :: Chan c
, e.g. with newChan
,
and then use withChanS
.
withChanS :: Monad m => Chan event -> ClSF (EventChanT event m) cl a b -> ClSF m cl a b Source #
Remove ("run") an EventChanT
layer from the monad stack
by passing it explicitly the channel over which events are sent.
This is usually only needed if you can't use runEventChanT
to create the channel.
Typically, create a chan :: Chan c
in your main program
before the main loop (e.g. flow
) would be run,
then, by using this function,
pass the channel to every behaviour or ClSF
that wants to emit events,
and, by using eventClockOn
, to every clock that should tick on the event.
emit :: MonadIO m => event -> EventChanT event m () Source #
Emit a single event.
This causes every EventClock
on the same monad to tick immediately.
Be cautious when emitting events from a signal clocked by an EventClock
.
Nothing prevents you from emitting more events than are handled,
causing the event buffer to grow indefinitely.
emitSMaybe :: MonadIO m => ClSF (EventChanT event m) cl (Maybe event) () Source #
Emit an event whenever the input value is Just event
.
emit' :: (NFData event, MonadIO m) => event -> EventChanT event m () Source #
Like emit
, but completely evaluates the event before emitting it.
emitS' :: (NFData event, MonadIO m) => ClSF (EventChanT event m) cl event () Source #
Like emitS
, but completely evaluates the event before emitting it.
emitSMaybe' :: (NFData event, MonadIO m) => ClSF (EventChanT event m) cl (Maybe event) () Source #
Like emitSMaybe
, but completely evaluates the event before emitting it.
eventClockOn :: MonadIO m => Chan event -> HoistClock (EventChanT event m) m (EventClock event) Source #
Create an event clock that is bound to a specific event channel.
This is usually only useful if you can't apply runEventChanT
to the main loop (see withChanS
).
A clock that ticks without waiting. All time passed between ticks amounts to computation time, side effects, time measurement and framework overhead.
Instances
GetClockProxy Busy Source # | |
Defined in FRP.Rhine.Clock.Realtime.Busy | |
Clock IO Busy Source # | |
type Tag Busy Source # | |
Defined in FRP.Rhine.Clock.Realtime.Busy | |
type Time Busy Source # | |
Defined in FRP.Rhine.Clock.Realtime.Busy |
type PureAudioClockF (rate :: AudioRate) = RescaledClock (PureAudioClock rate) Float Source #
A rescaled version of PureAudioClock
with TimeDomain
Float
.
data PureAudioClock (rate :: AudioRate) Source #
A side-effect free clock for audio synthesis and analysis.
The sample rate is given by rate
(of type AudioRate
).
Since this clock does not wait for the completion of buffers,
the producer or the consumer of the signal has the obligation to
synchronise the signal with the system clock, if realtime is desired.
Otherwise, the clock is also suitable e.g. for batch processing of audio files.
Instances
(Monad m, PureAudioClockRate rate) => Clock m (PureAudioClock rate) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Audio type Time (PureAudioClock rate) Source # type Tag (PureAudioClock rate) Source # initClock :: PureAudioClock rate -> RunningClockInit m (Time (PureAudioClock rate)) (Tag (PureAudioClock rate)) Source # | |
GetClockProxy (PureAudioClock rate) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Audio getClockProxy :: ClockProxy (PureAudioClock rate) Source # | |
type Tag (PureAudioClock rate) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Audio | |
type Time (PureAudioClock rate) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Audio |
data AudioClock (rate :: AudioRate) (bufferSize :: Nat) Source #
A clock for audio analysis and synthesis.
It internally processes samples in buffers of size bufferSize
,
(the programmer does not have to worry about this),
at a sample rate of rate
(of type AudioRate
).
Both these parameters are in the type signature,
so it is not possible to compose signals with different buffer sizes
or sample rates.
After processing a buffer, the clock will wait the remaining time
until the next buffer must be processed,
using system UTC time.
The tag of the clock specifies whether the attempt to finish the last buffer in real time was successful.
A value of Nothing
represents success,
a value of Just double
represents a lag of double
seconds.
Instances
(MonadIO m, KnownNat bufferSize, AudioClockRate rate) => Clock m (AudioClock rate bufferSize) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Audio type Time (AudioClock rate bufferSize) Source # type Tag (AudioClock rate bufferSize) Source # initClock :: AudioClock rate bufferSize -> RunningClockInit m (Time (AudioClock rate bufferSize)) (Tag (AudioClock rate bufferSize)) Source # | |
GetClockProxy (AudioClock rate bufferSize) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Audio getClockProxy :: ClockProxy (AudioClock rate bufferSize) Source # | |
type Tag (AudioClock rate bufferSize) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Audio | |
type Time (AudioClock rate bufferSize) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Audio |
pureAudioClockF :: PureAudioClockF rate Source #
A rescaled version of PureAudioClock
with TimeDomain
Float
,
using double2Float
to rescale.
data Periodic (v :: [Nat]) where Source #
A clock whose tick lengths cycle through
a (nonempty) list of type-level natural numbers.
E.g. Periodic '[1, 2]
ticks at times 1, 3, 4, 5, 7, 8, etc.
The waiting side effect is formal, in ScheduleT
.
You can use e.g. runScheduleIO
to produce an actual delay.
Instances
GetClockProxy (Periodic v) Source # | |
Defined in FRP.Rhine.Clock.Periodic getClockProxy :: ClockProxy (Periodic v) Source # | |
(Monad m, NonemptyNatList v) => Clock (ScheduleT Integer m) (Periodic v) Source # | |
type Tag (Periodic v) Source # | |
Defined in FRP.Rhine.Clock.Periodic | |
type Time (Periodic v) Source # | |
Defined in FRP.Rhine.Clock.Periodic |
data FixedStep (n :: Nat) where Source #
A pure (side effect free) clock with fixed step size,
i.e. ticking at multiples of n
.
The tick rate is in the type signature,
which prevents composition of signals at different rates.
Instances
GetClockProxy (FixedStep n) Source # | |
Defined in FRP.Rhine.Clock.FixedStep getClockProxy :: ClockProxy (FixedStep n) Source # | |
(MonadSchedule m, Monad m) => Clock (ScheduleT Integer m) (FixedStep n) Source # | |
type Tag (FixedStep n) Source # | |
Defined in FRP.Rhine.Clock.FixedStep | |
type Time (FixedStep n) Source # | |
Defined in FRP.Rhine.Clock.FixedStep |
downsampleFixedStep :: (KnownNat n, Monad m) => ResamplingBuffer m (FixedStep k) (FixedStep (n * k)) a (Vector n a) Source #
Resample into a FixedStep
clock that ticks n
times slower,
by collecting all values into a vector.
newtype Millisecond (n :: Nat) Source #
A clock ticking every n
milliseconds,
in real time.
Since n
is in the type signature,
it is ensured that when composing two signals on a Millisecond
clock,
they will be driven at the same rate.
The tag of this clock is Bool
,
where True
represents successful realtime,
and False
a lag.
Instances
Clock IO (Millisecond n) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Millisecond type Time (Millisecond n) Source # type Tag (Millisecond n) Source # initClock :: Millisecond n -> RunningClockInit IO (Time (Millisecond n)) (Tag (Millisecond n)) Source # | |
GetClockProxy (Millisecond n) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Millisecond getClockProxy :: ClockProxy (Millisecond n) Source # | |
type Tag (Millisecond n) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Millisecond | |
type Time (Millisecond n) Source # | |
Defined in FRP.Rhine.Clock.Realtime.Millisecond |
waitClock :: KnownNat n => Millisecond n Source #
This implementation measures the time after each tick,
and waits for the remaining time until the next tick.
If the next tick should already have occurred,
the tag is set to False
, representing a failed real time attempt.
Note that this clock internally uses threadDelay
which can block
for quite a lot longer than the requested time, which can cause
the clock to miss one or more ticks when using low values of n
.
When using threadDelay
, the difference between the real wait time
and the requested wait time will be larger when using
the '-threaded' ghc option (around 800 microseconds) than when not using
this option (around 100 microseconds). For low values of n
it is recommended
that '-threaded' not be used in order to miss less ticks. The clock will adjust
the wait time, up to no wait time at all, to catch up when a tick is missed.
downsampleMillisecond :: (KnownNat n, Monad m) => ResamplingBuffer m (Millisecond k) (Millisecond (n * k)) a (Vector n a) Source #
A Rhine
consists of a SN
together with a clock of matching type cl
.
It is a reactive program, possibly with open inputs and outputs.
If the input and output types a
and b
are both ()
,
that is, the Rhine
is "closed",
then it is a standalone reactive program
that can be run with the function flow
.
Otherwise, one can start the clock and the signal network jointly as a monadic stream function,
using eraseClock
.
Instances
GetClockProxy cl => ToClockProxy (Rhine m cl a b) Source # | |
Defined in FRP.Rhine.Type toClockProxy :: Rhine m cl a b -> ClockProxy (Cl (Rhine m cl a b)) Source # | |
type Cl (Rhine m cl a b) Source # | |
Defined in FRP.Rhine.Type |
eraseClock :: (Monad m, Clock m cl, GetClockProxy cl) => Rhine m cl a b -> m (MSF m a (Maybe b)) Source #
Start the clock and the signal network, effectively hiding the clock type from the outside.
Since the caller will not know when the clock
ticks,
the input In
cla
has to be given at all times, even those when it doesn't tick.
feedbackRhine :: (Clock m (In cl), Clock m (Out cl), Time (In cl) ~ Time cl, Time (Out cl) ~ Time cl) => ResamplingBuffer m (Out cl) (In cl) d c -> Rhine m cl (a, c) (b, d) -> Rhine m cl a b Source #
Loop back data from the output to the input.
Since output and input will generally tick at different clocks, the data needs to be resampled.
data RhineAndResamplingBuffer m cl1 inCl2 a c Source #
A purely syntactical convenience construction enabling quadruple syntax for sequential composition, as described below.
forall b. RhineAndResamplingBuffer (Rhine m cl1 a b) (ResamplingBuffer m (Out cl1) inCl2 b c) |
(@@) :: (cl ~ In cl, cl ~ Out cl) => ClSF m cl a b -> cl -> Rhine m cl a b infix 5 Source #
Create a synchronous Rhine
by combining a clocked signal function with a matching clock.
Synchronicity is ensured by requiring that data enters (In cl
)
and leaves (Out cl
) the system at the same as it is processed (cl
).
(>--) :: Rhine m cl1 a b -> ResamplingBuffer m (Out cl1) inCl2 b c -> RhineAndResamplingBuffer m cl1 inCl2 a c infix 2 Source #
Syntactic sugar for RhineAndResamplingBuffer
.
(-->) :: (Clock m cl1, Clock m cl2, Time cl1 ~ Time cl2, Time (Out cl1) ~ Time cl1, Time (In cl2) ~ Time cl2, Clock m (Out cl1), Clock m (Out cl2), Clock m (In cl1), Clock m (In cl2), In cl2 ~ inCl2, GetClockProxy cl1, GetClockProxy cl2) => RhineAndResamplingBuffer m cl1 inCl2 a b -> Rhine m cl2 b c -> Rhine m (SequentialClock cl1 cl2) a c infixr 1 Source #
The combinators for sequential composition allow for the following syntax:
rh1 :: Rhine m cl1 a b rh1 = ... rh2 :: Rhine m cl2 c d rh2 = ... rb :: ResamplingBuffer m (Out cl1) (In cl2) b c rb = ... rh :: Rhine m (SequentialClock cl1 cl2) a d rh = rh1 >-- rb --> rh2
(+@+) :: (Monad m, Clock m clL, Clock m clR, Clock m (Out clL), Clock m (Out clR), GetClockProxy clL, GetClockProxy clR, Time clL ~ Time (Out clL), Time clR ~ Time (Out clR), Time clL ~ Time (In clL), Time clR ~ Time (In clR), Time clL ~ Time clR) => Rhine m clL a b -> Rhine m clR a c -> Rhine m (ParallelClock clL clR) a (Either b c) infix 3 Source #
The combinators for parallel composition allow for the following syntax:
rh1 :: Rhine m clL a b rh1 = ... rh2 :: Rhine m clR a c rh2 = ... rh :: Rhine m (ParallelClock clL clR) a (Either b c) rh = rh1 +@+ rh2
(|@|) :: (Monad m, Clock m clL, Clock m clR, Clock m (Out clL), Clock m (Out clR), GetClockProxy clL, GetClockProxy clR, Time clL ~ Time (Out clL), Time clR ~ Time (Out clR), Time clL ~ Time (In clL), Time clR ~ Time (In clR), Time clL ~ Time clR) => Rhine m clL a b -> Rhine m clR a b -> Rhine m (ParallelClock clL clR) a b infix 3 Source #
The combinators for parallel composition allow for the following syntax:
rh1 :: Rhine m clL a b rh1 = ... rh2 :: Rhine m clR a b rh2 = ... rh :: Rhine m (ParallelClock clL clR) a b rh = rh1 |@| rh2
(@>>^) :: Monad m => Rhine m cl a b -> (b -> c) -> Rhine m cl a c Source #
Postcompose a Rhine
with a pure function.
(^>>@) :: Monad m => (a -> b) -> Rhine m cl b c -> Rhine m cl a c Source #
Precompose a Rhine
with a pure function.
(@>-^) :: (Clock m (Out cl), Time cl ~ Time (Out cl)) => Rhine m cl a b -> ClSF m (Out cl) b c -> Rhine m cl a c Source #
(^->@) :: (Clock m (In cl), Time cl ~ Time (In cl)) => ClSF m (In cl) a b -> Rhine m cl b c -> Rhine m cl a c Source #
flow :: (Monad m, Clock m cl, GetClockProxy cl, Time cl ~ Time (In cl), Time cl ~ Time (Out cl)) => Rhine m cl () () -> m () Source #
Takes a closed Rhine
(with trivial input and output),
and runs it indefinitely.
This is typically the main loop.
All input has to be created, and all output has to be consumed
by means of side effects in a monad m
.
Basic usage (synchronous case):
sensor :: ClSF MyMonad MyClock () a sensor = constMCl produceData processing :: ClSF MyMonad MyClock a b processing = ... actuator :: ClSF MyMonad MyClock b () actuator = arrMCl consumeData mainSF :: ClSF MyMonad MyClock () () mainSF = sensor >-> processing >-> actuator main :: MyMonad () main = flow $ mainSF @@ clock
reactimateCl :: (Monad m, Clock m cl, GetClockProxy cl, cl ~ In cl, cl ~ Out cl) => cl -> ClSF m cl () () -> m () Source #
Run a synchronous ClSF
with its clock as a main loop,
similar to Yampa's, or Dunai's, reactimate
.