-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Push-pull functional reactive programming -- -- Reactive is a simple foundation for programming reactive -- systems functionally. Like Fran/FRP, it has a notions of (reactive) -- behaviors and events. Unlike most previous FRP implementations, -- Reactive has a hybrid demand/data-driven implementation, as described -- in the paper "Push-pull functional reactive programming", -- http://conal.net/papers/push-pull-frp/. -- -- This version of Reactive has some serious bugs that show up -- particularly with some uses of the Event monad. Some problems have -- been due to bugs in the GHC run-time support for concurrency. I do not -- know whether the remaining problems in Reactive are still more subtle -- RTS issues, or some subtle laziness bugs in Reactive. Help probing the -- remaining difficulties is most welcome. -- -- Import FRP.Reactive for FRP client apps. To make a Reactive -- adapter for an imperative library, import -- FRP.Reactive.LegacyAdapters. -- -- Please see the project wiki page: -- http://haskell.org/haskellwiki/reactive -- -- © 2007-2008 by Conal Elliott; GNU AGPLv3 license (see COPYING). I am -- not thrilled with GPL. If you would like different terms, please talk -- to me. -- -- With contributions from: Robin Green, Thomas Davie, Luke Palmer, David -- Sankel, Jules Bean, Creighton Hogg, Chuan-kai Lin, and Richard Smith. -- Please let me know if I've forgotten to list you. @package reactive @version 0.11.2 -- | Write-once variables. module FRP.Reactive.Internal.IVar data IVar a newIVar :: IO (IVar a) -- | Returns the value in the IVar. The *value* will block until the -- variable becomes filled. readIVar :: IVar a -> a -- | Returns Nothing if the IVar has no value yet, otherwise returns the -- value. tryReadIVar :: IVar a -> IO (Maybe a) -- | Puts the value of the IVar. If it already has a value, block forever. writeIVar :: IVar a -> a -> IO () -- | Min monoid module Data.Min -- | Ordered monoid under min. newtype Min a Min :: a -> Min a getMin :: Min a -> a instance (Eq a) => Eq (Min a) instance (Ord a) => Ord (Min a) instance (Read a) => Read (Min a) instance (Show a) => Show (Min a) instance (Bounded a) => Bounded (Min a) instance (EqProp a) => EqProp (Min a) instance (Arbitrary a) => Arbitrary (Min a) instance (Ord a, Bounded a) => Monoid (Min a) -- | Unbounded channels. module FRP.Reactive.Internal.Chan -- | Chan is an abstract type representing an unbounded FIFO -- channel. data Chan a -- | Build and returns a new instance of Chan. newChan :: IO (Chan a) -- | Write a value to a Chan. writeChan :: Chan a -> a -> IO () -- | Read the next value from the Chan. readChan :: Chan a -> IO a -- | Duplicate a Chan: the duplicate channel begins empty, but data -- written to either channel from then on will be available from both. -- Hence this creates a kind of broadcast channel, where data written by -- anyone is seen by everyone else. dupChan :: Chan a -> IO (Chan a) -- | Put a data item back onto a channel, where it will be the next item -- read. unGetChan :: Chan a -> a -> IO () -- | Returns True if the supplied Chan is empty. isEmptyChan :: Chan a -> IO Bool -- | Return a lazy list representing the contents of the supplied -- Chan, much like System.IO.hGetContents. getChanContents :: Chan a -> IO [a] -- | Write an entire list of items to a Chan. writeList2Chan :: Chan a -> [a] -> IO () -- | A weak channel writer. Sustained by the read head. Thus channel -- consumers keep channel producers alive. weakChanWriter :: Chan a -> IO (IO (Maybe (a -> IO ()))) instance Typeable1 Chan -- | Serialize actions. module FRP.Reactive.Internal.Serial -- | Serializer. Turns actions into equivalent but serialized actions type Serial = forall a. IO a -> IO a -- | Make a locking serializer makeSerial :: IO Serial -- | Make a locking serializer with a given lock locking :: MVar () -> Serial -- | Writer monad as a pair. Until it's in Control.Monad.Instances. -- -- Use import Data.PairMonad () module Data.PairMonad instance (Monoid o) => Monad ((,) o) -- | Misc Reactive internal defs module FRP.Reactive.Internal.Misc -- | Convenient alias for dropping parentheses. type Action = IO () -- | Value consumer type Sink a = a -> Action -- | Constant-optimized representation of functions. module FRP.Reactive.Internal.Fun -- | Constant-optimized functions data Fun t a -- | constant function K :: a -> Fun t a -- | non-constant function Fun :: (t -> a) -> Fun t a -- | Functions, with constant functions optimized, with instances for many -- standard classes. module FRP.Reactive.Fun -- | Constant-optimized functions data Fun t a fun :: (t -> a) -> Fun t a -- | Fun as a function apply :: Fun t a -> (t -> a) batch :: TestBatch instance (Monoid t) => Comonad (Fun t) instance (Monoid t) => Copointed (Fun t) instance Pointed (Fun t) instance Arrow Fun instance Category Fun instance Monad (Fun t) instance Applicative (Fun t) instance Zip (Fun t) instance Functor (Fun t) instance (Monoid a) => Monoid (Fun t a) instance Model1 (Fun a) ((->) a) instance Model (Fun a b) (a -> b) instance (Show a, Arbitrary a, EqProp a, EqProp b) => EqProp (Fun a b) instance (Show b) => Show (Fun a b) instance (Arbitrary a, CoArbitrary b) => CoArbitrary (Fun a b) instance (CoArbitrary a, Arbitrary b) => Arbitrary (Fun a b) -- | Improving values -- efficient version module FRP.Reactive.Improving -- | An improving value. data Improving a Imp :: a -> (a -> Ordering) -> Improving a exact :: Improving a -> a compareI :: Improving a -> a -> Ordering -- | A known improving value (which doesn't really improve) exactly :: (Ord a) => a -> Improving a -- | A value known to be < x. before :: (Ord a) => a -> Improving a -- | A value known to be > x. after :: (Ord a) => a -> Improving a -- | Efficient combination of min and '(<=)' minI :: (Ord a) => Improving a -> Improving a -> (Improving a, Bool) -- | Efficient combination of max and '(>=)' maxI :: (Ord a) => Improving a -> Improving a -> (Improving a, Bool) batch :: TestBatch instance (EqProp a) => EqProp (Improving a) instance Model (Improving a) a instance (CoArbitrary a) => CoArbitrary (Improving a) instance (Ord a, Arbitrary a) => Arbitrary (Improving a) instance (Ord a, Bounded a) => Bounded (Improving a) instance (Ord a) => Ord (Improving a) instance (Eq a) => Eq (Improving a) instance (Show a) => Show (Improving a) -- | Add bounds to an ordered type module Data.AddBounds -- | Wrap a type into one having new least and greatest elements, -- preserving the existing ordering. data AddBounds a MinBound :: AddBounds a NoBound :: a -> AddBounds a MaxBound :: AddBounds a instance (Eq a) => Eq (AddBounds a) instance (Read a) => Read (AddBounds a) instance (Show a) => Show (AddBounds a) instance (AffineSpace t) => AffineSpace (AddBounds t) instance (EqProp a, Eq a) => EqProp (AddBounds a) instance (CoArbitrary a) => CoArbitrary (AddBounds a) instance (Arbitrary a) => Arbitrary (AddBounds a) instance (Ord a) => Ord (AddBounds a) instance Bounded (AddBounds a) -- | Max monoid module Data.Max -- | Ordered monoid under max. newtype Max a Max :: a -> Max a getMax :: Max a -> a instance (Eq a) => Eq (Max a) instance (Ord a) => Ord (Max a) instance (Bounded a) => Bounded (Max a) instance (Read a) => Read (Max a) instance (Show a) => Show (Max a) instance (EqProp a) => EqProp (Max a) instance (Arbitrary a) => Arbitrary (Max a) instance (CoArbitrary a) => CoArbitrary (Max a) instance (Ord a, Bounded a) => Monoid (Max a) -- | Representation of future values module FRP.Reactive.Internal.Future -- | Time used in futures. The parameter t can be any Ord -- and Bounded type. Pure values have time minBound, -- while never-occurring futures have time 'maxBound.' type Time t = Max -- (AddBounds t) type Time = Max -- | A future value of type a with time type t. Simply a -- time/value pair. Particularly useful with time types that have -- non-flat structure. newtype FutureG t a Future :: (Time t, a) -> FutureG t a unFuture :: FutureG t a -> (Time t, a) isNeverF :: (Bounded t, Eq t) => FutureG t t1 -> Bool -- | Apply a unary function within the FutureG representation. inFuture :: ((Time t, a) -> (Time t', b)) -> FutureG t a -> FutureG t' b -- | Apply a binary function within the FutureG representation. inFuture2 :: ((Time t, a) -> (Time t', b) -> (Time t', c)) -> FutureG t a -> FutureG t' b -> FutureG t' c -- | Run a future in the current thread. Use the given time sink to sync -- time, i.e., to wait for an output time before performing the action. runF :: (Ord t) => Sink t -> FutureG t (IO a) -> IO a instance Functor (FutureG t) instance (Bounded t, Ord t) => Applicative (FutureG t) instance (Bounded t, Ord t) => Monad (FutureG t) instance Copointed (FutureG t) instance Comonad (FutureG t) instance (Arbitrary t, Arbitrary a) => Arbitrary (FutureG t a) instance (CoArbitrary t, CoArbitrary a) => CoArbitrary (FutureG t a) instance (Show t, Show a, Eq t, Bounded t) => Show (FutureG t a) instance (Eq t, Eq a, Bounded t) => Eq (FutureG t a) -- | Representation for Reactive and Event types. Combined here, -- because they're mutually recursive. -- -- The representation used in this module is based on a close connection -- between these two types. A reactive value is defined by an initial -- value and an event that yields future values; while an event is given -- as a future reactive value. module FRP.Reactive.Internal.Reactive -- | Events. Semantically: time-ordered list of future values. Instances: -- --
-- withTimeE :: Event a -> Event (a, TimeT) --withTimeE :: (Ord t) => EventG (ImpBounds t) d -> EventG (ImpBounds t) (d, t) -- | Access occurrence times in an event. Discard the rest. See also -- withTimeE. -- --
-- withTimeE_ :: Event a -> Event TimeT --withTimeE_ :: (Ord t) => EventG (ImpBounds t) d -> EventG (ImpBounds t) t -- | Single-occurrence event at given time. See atTimes and -- atTimeG. atTime :: TimeT -> Event () -- | Event occuring at given times. See also atTime and -- atTimeG. atTimes :: [TimeT] -> Event () -- | Convert a temporally monotonic list of timed values to an event. See -- also the generalization listEG listE :: [(TimeT, a)] -> Event a -- | Generate a pair-valued event, given a pair of initial values and a -- pair of events. See also pair on Reactive. Not quite a -- zip, because of the initial pair required. zipE :: (Ord t, Bounded t) => (c, d) -> (EventG t c, EventG t d) -> EventG t (c, d) -- | Like scanl for events. scanlE :: (Ord t, Bounded t) => (a -> b -> a) -> a -> EventG t b -> EventG t a -- | Accumulate values from a monoid-typed event. Specialization of -- scanlE, using mappend and mempty. monoidE :: (Ord t, Bounded t, Monoid o) => EventG t o -> EventG t o -- | Decompose an event into its first occurrence value and a remainder -- event. See also firstE and restE. firstRestE :: (Ord t, Bounded t) => EventG t a -> (a, EventG t a) -- | Extract the first occurrence value of an event. See also -- firstRestE and restE. firstE :: (Ord t, Bounded t) => EventG t a -> a -- | Extract the remainder an event, after its first occurrence. See also -- firstRestE and firstE. restE :: (Ord t, Bounded t) => EventG t a -> EventG t a -- | Remaining part of an event. See also withRestE. remainderR :: (Ord t, Bounded t) => EventG t a -> ReactiveG t (EventG t a) -- | Tack remainders a second event onto values of a first event. Occurs -- when the first event occurs. snapRemainderE :: (Ord t, Bounded t) => EventG t b -> EventG t a -> EventG t (a, EventG t b) -- | Convert an event into a single-occurrence event, whose occurrence -- contains the remainder. onceRestE :: (Ord t, Bounded t) => EventG t a -> EventG t (a, EventG t a) -- | Pair each event value with the previous one. The second result is the -- old one. Nothing will come out for the first occurrence of e, -- but if you have an initial value a, you can do withPrevE -- (pure a mappend e). withPrevE :: (Ord t, Bounded t) => EventG t a -> EventG t (a, a) -- | Same as withPrevE, but allow a function to combine the values. -- Provided for convenience. withPrevEWith :: (Ord t, Bounded t) => (a -> a -> b) -> EventG t a -> EventG t b -- | Pair each event value with the next one one. The second result is the -- next one. withNextE :: (Ord t, Bounded t) => EventG t a -> EventG t (a, a) -- | Same as withNextE, but allow a function to combine the values. -- Provided for convenience. withNextEWith :: (Ord t, Bounded t) => (a -> a -> b) -> EventG t a -> EventG t b -- | Mealy-style state machine, given initial value and transition -- function. Carries along event data. See also mealy_. mealy :: (Ord t, Bounded t) => s -> (s -> s) -> EventG t b -> EventG t (b, s) -- | Mealy-style state machine, given initial value and transition -- function. Forgetful version of mealy. mealy_ :: (Ord t, Bounded t) => s -> (s -> s) -> EventG t b -> EventG t s -- | Count occurrences of an event, remembering the occurrence values. See -- also countE_. countE :: (Ord t, Bounded t, Num n) => EventG t b -> EventG t (b, n) -- | Count occurrences of an event, forgetting the occurrence values. See -- also countE. countE_ :: (Ord t, Bounded t, Num n) => EventG t b -> EventG t n -- | Difference of successive event occurrences. See withPrevE for a -- trick to supply an initial previous value. diffE :: (Ord t, Bounded t, AffineSpace a) => EventG t a -> EventG t (Diff a) -- | Reactive values, specialized to improving doubles for time type Reactive = ReactiveG ITime -- | Like snapshot but discarding event data (often a is -- '()'). snapshot_ :: (Ord t, Bounded t) => ReactiveG t b -> EventG t a -> EventG t b -- | Snapshot a reactive value whenever an event occurs. snapshot :: (Ord t, Bounded t) => ReactiveG t b -> EventG t a -> EventG t (a, b) -- | Filter an event according to whether a reactive boolean is true. whenE :: (Ord t, Bounded t) => EventG t a -> ReactiveG t Bool -> EventG t a -- | Like scanl for reactive values. See also scanlE. scanlR :: (Ord t, Bounded t) => (a -> b -> a) -> a -> EventG t b -> ReactiveG t a -- | Accumulate values from a monoid-valued event. Specialization of -- scanlE, using mappend and mempty. See also -- monoidE. monoidR :: (Ord t, Bounded t, Monoid a) => EventG t a -> ReactiveG t a -- | Combine two events into one. eitherE :: (Ord t, Bounded t) => EventG t a -> EventG t b -> EventG t (Either a b) -- | Start out blank (Nothing), latching onto each new a, -- and blanking on each b. If you just want to latch and not -- blank, then use mempty for lose. maybeR :: (Ord t, Bounded t) => EventG t a -> EventG t b -> ReactiveG t (Maybe a) -- | Flip-flopping reactive value. Turns true when ea occurs and -- false when eb occurs. flipFlop :: (Ord t, Bounded t) => EventG t a -> EventG t b -> ReactiveG t Bool -- | Count occurrences of an event. See also countE. countR :: (Ord t, Bounded t, Num n) => EventG t a -> ReactiveG t n -- | Partition an event into segments. splitE :: (Ord t, Bounded t) => EventG t b -> EventG t a -> EventG t (a, EventG t b) -- | Switch from one event to another, as they occur. (Doesn't merge, as -- join does.) switchE :: (Ord t, Bounded t) => EventG t (EventG t a) -> EventG t a -- | Euler integral. integral :: (VectorSpace v, AffineSpace t, (Scalar v) ~ (Diff t)) => t -> Event t -> Reactive v -> Reactive v sumR :: (Ord t, Bounded t) => (AdditiveGroup v) => EventG t v -> ReactiveG t v exact :: Improving a -> a batch :: TestBatch -- | Representation of reactive behaviors module FRP.Reactive.Internal.Behavior -- | Reactive behaviors. They can be understood in terms of a simple model -- (denotational semantics) as functions of time, namely at :: -- BehaviorG t a -> (t -> a). -- -- The semantics of BehaviorG instances are given by corresponding -- instances for the semantic model (functions). See -- http://conal.net/blog/posts/simplifying-semantics-with-type-class-morphisms/. -- --
-- time :: Behavior TimeT --time :: (Ord t) => BehaviorI t t -- | Discretely changing behavior, based on an initial value and a -- new-value event. -- --
-- stepper :: a -> Event a -> Behavior a --stepper :: a -> EventI t a -> BehaviorI t a -- | Switch between behaviors. -- --
-- switcher :: Behavior a -> Event (Behavior a) -> Behavior a --switcher :: (Ord tr, Bounded tr) => BehaviorG tr tf a -> EventG tr (BehaviorG tr tf a) -> BehaviorG tr tf a -- | Snapshots a behavior whenever an event occurs and combines the values -- using the combining function passed. Take careful note of the order of -- arguments and results. -- --
-- snapshotWith :: (a -> b -> c) -> Behavior b -> Event a -> Event c --snapshotWith :: (Ord t) => (a -> b -> c) -> BehaviorI t b -> EventI t a -> EventI t c -- | Snapshot a behavior whenever an event occurs. See also -- snapshotWith. Take careful note of the order of arguments and -- results. -- --
-- snapshot :: Behavior b -> Event a -> Event (a,b) --snapshot :: (Ord t) => BehaviorI t b -> EventI t a -> EventI t (a, b) -- | Like snapshot but discarding event data (often a is -- '()'). -- --
-- snapshot_ :: Behavior b -> Event a -> Event b --snapshot_ :: (Ord t) => BehaviorI t b -> EventI t a -> EventI t b -- | Filter an event according to whether a reactive boolean is true. -- --
-- whenE :: Behavior Bool -> Event a -> Event a --whenE :: (Ord t) => BehaviorI t Bool -> EventI t a -> EventI t a -- | Behavior from an initial value and an updater event. See also accumE. -- --
-- accumB :: a -> Event (a -> a) -> Behavior a --accumB :: a -> EventI t (a -> a) -> BehaviorI t a -- | Like scanl for behaviors. See also scanlE. -- --
-- scanlB :: forall a. (Behavior a -> Behavior a -> Behavior a) -> Behavior a -- -> Event (Behavior a) -> Behavior a --scanlB :: (Ord tr, Bounded tr) => (b -> BehaviorG tr tf a -> BehaviorG tr tf a) -> BehaviorG tr tf a -> EventG tr b -> BehaviorG tr tf a -- | Accumulate values from a monoid-valued event. Specialization of -- scanlB, using mappend and mempty. See also -- monoidE. -- --
-- monoidB :: Monoid a => Event (Behavior a) -> Behavior a --monoidB :: (Ord tr, Bounded tr, Monoid a) => EventG tr (BehaviorG tr tf a) -> BehaviorG tr tf a -- | Start out blank (Nothing), latching onto each new a, -- and blanking on each b. If you just want to latch and not -- blank, then use mempty for the second event. -- --
-- maybeB :: Event a -> Event b -> Behavior (Maybe a) --maybeB :: (Ord t) => EventI t a -> EventI t b -> BehaviorI t (Maybe a) -- | Flip-flopping behavior. Turns true whenever first event occurs and -- false whenever the second event occurs. -- --
-- flipFlop :: Event a -> Event b -> Behavior Bool --flipFlop :: (Ord t) => EventI t a -> EventI t b -> BehaviorI t Bool -- | Count occurrences of an event. See also countE. -- --
-- countB :: Num n => Event a -> Behavior n --countB :: (Ord t, Num n) => EventI t a -> BehaviorI t n -- | Like sum for behaviors. -- --
-- sumB :: AdditiveGroup a => Event a -> Behavior a --sumB :: (Ord t, AdditiveGroup a) => EventI t a -> BehaviorI t a -- | Euler integral. -- --
-- integral :: (VectorSpace v, Scalar v ~ TimeT) => -- Event () -> Behavior v -> Behavior v --integral :: (VectorSpace v, AffineSpace t, (Scalar v) ~ (Diff t), Ord t) => EventI t a -> BehaviorI t v -> BehaviorI t v instance (Monoid tr, Monoid tf) => Copointed (BehaviorG tr tf) instance (Functor g, Functor f, Copointed g, Copointed f) => Copointed (g :. f) module FRP.Reactive.VectorSpace instance (VectorSpace v) => VectorSpace (Behavior v) instance (AdditiveGroup v) => AdditiveGroup (Behavior v) -- | Numeric class instances for behaviors module FRP.Reactive.Num instance (RealFloat a) => RealFloat (Behavior a) instance (RealFrac a) => RealFrac (Behavior a) instance (Floating b) => Floating (Behavior b) instance (Fractional b) => Fractional (Behavior b) instance (Integral a) => Integral (Behavior a) instance (Num a, Ord a) => Real (Behavior a) instance (Num b) => Num (Behavior b) instance Show (Behavior b) instance (Enum a) => Enum (Behavior a) instance (Ord b) => Ord (Behavior b) instance Eq (Behavior b) -- | Serializing clocks -- -- Thanks to Luke Palmer for help with this module. module FRP.Reactive.Internal.Clock -- | Waits a specified duration and then execute an action type Delay t = t -- -> forall a. IO a -> IO a -- -- Waits until just after a specified time and then execute an action, -- passing in the actual time. type Schedule t = t -> Sink (Sink t) -- -- A serializing clock. Can (a) produce a time and (b) serialize an -- action. data Clock t Clock :: IO t -> Serial -> Clock t cGetTime :: Clock t -> IO t cSerialize :: Clock t -> Serial -- | Make a clock makeClock :: IO (Clock TimeT) module FRP.Reactive.Internal.Timing -- | Execute an action-valued event. adaptE :: Sink (Event Action) -- | Make an action to be executed regularly, given a time-source and a -- action-behavior. The generated action is optimized to do almost no -- work during known-constant phases of the given behavior. mkUpdater :: IO TimeT -> Behavior Action -> IO Action -- | Sleep past a given time sleepPast :: IO TimeT -> Sink TimeT -- | Timed values. A primitive interface for futures. module FRP.Reactive.Internal.TVal -- | An a that's fed by a b type :--> b a = (Sink b, a) -- | Make a '(:-->)'. type :+-> b a = IO (b :--> a) -- | Make a new event and a sink that writes to it. Uses the given clock to -- serialize and time-stamp. makeEvent :: Clock TimeT -> forall a. (Show a) => (a :+-> Event a) -- | Tools for making Reactive adapters for imperative ("legacy") -- libraries. module FRP.Reactive.LegacyAdapters -- | Value consumer type Sink a = a -> Action -- | Convenient alias for dropping parentheses. type Action = IO () -- | Waits a specified duration and then execute an action type Delay t = t -- -> forall a. IO a -> IO a -- -- Waits until just after a specified time and then execute an action, -- passing in the actual time. type Schedule t = t -> Sink (Sink t) -- -- A serializing clock. Can (a) produce a time and (b) serialize an -- action. data Clock t -- | Make a clock makeClock :: IO (Clock TimeT) cGetTime :: Clock t -> IO t -- | Execute an action-valued event. adaptE :: Sink (Event Action) -- | Make an action to be executed regularly, given a time-source and a -- action-behavior. The generated action is optimized to do almost no -- work during known-constant phases of the given behavior. mkUpdater :: IO TimeT -> Behavior Action -> IO Action -- | A library for programming with functional reactive behaviors. module FRP.Reactive -- | The type of time values with additional min & max elements. type TimeT = Double -- | Improving times, as used for time values in Event, -- Reactive, and ReactiveB. type ITime = ImpBounds TimeT -- | Events. Semantically: time-ordered list of future values. Instances: -- --
-- withTimeE :: Event a -> Event (a, TimeT) --withTimeE :: (Ord t) => EventG (ImpBounds t) d -> EventG (ImpBounds t) (d, t) -- | Access occurrence times in an event. Discard the rest. See also -- withTimeE. -- --
-- withTimeE_ :: Event a -> Event TimeT --withTimeE_ :: (Ord t) => EventG (ImpBounds t) d -> EventG (ImpBounds t) t -- | Generate a pair-valued event, given a pair of initial values and a -- pair of events. See also pair on Reactive. Not quite a -- zip, because of the initial pair required. zipE :: (Ord t, Bounded t) => (c, d) -> (EventG t c, EventG t d) -> EventG t (c, d) -- | Like scanl for events. scanlE :: (Ord t, Bounded t) => (a -> b -> a) -> a -> EventG t b -> EventG t a -- | Accumulate values from a monoid-typed event. Specialization of -- scanlE, using mappend and mempty. monoidE :: (Ord t, Bounded t, Monoid o) => EventG t o -> EventG t o -- | Mealy-style state machine, given initial value and transition -- function. Carries along event data. See also mealy_. mealy :: (Ord t, Bounded t) => s -> (s -> s) -> EventG t b -> EventG t (b, s) -- | Mealy-style state machine, given initial value and transition -- function. Forgetful version of mealy. mealy_ :: (Ord t, Bounded t) => s -> (s -> s) -> EventG t b -> EventG t s -- | Count occurrences of an event, remembering the occurrence values. See -- also countE_. countE :: (Ord t, Bounded t, Num n) => EventG t b -> EventG t (b, n) -- | Count occurrences of an event, forgetting the occurrence values. See -- also countE. countE_ :: (Ord t, Bounded t, Num n) => EventG t b -> EventG t n -- | Difference of successive event occurrences. See withPrevE for a -- trick to supply an initial previous value. diffE :: (Ord t, Bounded t, AffineSpace a) => EventG t a -> EventG t (Diff a) -- | Pair each event value with the previous one. The second result is the -- old one. Nothing will come out for the first occurrence of e, -- but if you have an initial value a, you can do withPrevE -- (pure a mappend e). withPrevE :: (Ord t, Bounded t) => EventG t a -> EventG t (a, a) -- | Same as withPrevE, but allow a function to combine the values. -- Provided for convenience. withPrevEWith :: (Ord t, Bounded t) => (a -> a -> b) -> EventG t a -> EventG t b -- | Combine two events into one. eitherE :: (Ord t, Bounded t) => EventG t a -> EventG t b -> EventG t (Either a b) -- | Experimental specialization of joinMaybes. justE :: (Ord t, Bounded t) => EventG t (Maybe a) -> EventG t a -- | Experimental specialization of filterMP. filterE :: (Ord t, Bounded t) => (a -> Bool) -> EventG t a -> EventG t a -- | Convert a temporally monotonic list of timed values to an event. See -- also the generalization listEG listE :: [(TimeT, a)] -> Event a -- | Event occuring at given times. See also atTime and -- atTimeG. atTimes :: [TimeT] -> Event () -- | Single-occurrence event at given time. See atTimes and -- atTimeG. atTime :: TimeT -> Event () -- | Just the first occurrence of an event. once :: (Ord t, Bounded t) => EventG t a -> EventG t a -- | Decompose an event into its first occurrence value and a remainder -- event. See also firstE and restE. firstRestE :: (Ord t, Bounded t) => EventG t a -> (a, EventG t a) -- | Extract the first occurrence value of an event. See also -- firstRestE and restE. firstE :: (Ord t, Bounded t) => EventG t a -> a -- | Extract the remainder an event, after its first occurrence. See also -- firstRestE and firstE. restE :: (Ord t, Bounded t) => EventG t a -> EventG t a -- | Tack remainders a second event onto values of a first event. Occurs -- when the first event occurs. snapRemainderE :: (Ord t, Bounded t) => EventG t b -> EventG t a -> EventG t (a, EventG t b) -- | Access the remainder with each event occurrence. withRestE :: EventG t a -> EventG t (a, EventG t a) -- | Truncate first event at first occurrence of second event. untilE :: (Ord t, Bounded t) => EventG t a -> EventG t b -> EventG t a -- | Partition an event into segments. splitE :: (Ord t, Bounded t) => EventG t b -> EventG t a -> EventG t (a, EventG t b) -- | Switch from one event to another, as they occur. (Doesn't merge, as -- join does.) switchE :: (Ord t, Bounded t) => EventG t (EventG t a) -> EventG t a -- | Pass through Just occurrences. joinMaybes :: (MonadPlus m) => m (Maybe a) -> m a -- | Pass through values satisfying p. filterMP :: (MonadPlus m) => (a -> Bool) -> m a -> m a -- | Reactive behaviors. They can be understood in terms of a simple model -- (denotational semantics) as functions of time, namely at :: -- BehaviorG t a -> (t -> a). -- -- The semantics of BehaviorG instances are given by corresponding -- instances for the semantic model (functions). See -- http://conal.net/blog/posts/simplifying-semantics-with-type-class-morphisms/. -- --
-- time :: Behavior TimeT --time :: (Ord t) => BehaviorI t t -- | Discretely changing behavior, based on an initial value and a -- new-value event. -- --
-- stepper :: a -> Event a -> Behavior a --stepper :: a -> EventI t a -> BehaviorI t a -- | Switch between behaviors. -- --
-- switcher :: Behavior a -> Event (Behavior a) -> Behavior a --switcher :: (Ord tr, Bounded tr) => BehaviorG tr tf a -> EventG tr (BehaviorG tr tf a) -> BehaviorG tr tf a -- | Snapshots a behavior whenever an event occurs and combines the values -- using the combining function passed. Take careful note of the order of -- arguments and results. -- --
-- snapshotWith :: (a -> b -> c) -> Behavior b -> Event a -> Event c --snapshotWith :: (Ord t) => (a -> b -> c) -> BehaviorI t b -> EventI t a -> EventI t c -- | Snapshot a behavior whenever an event occurs. See also -- snapshotWith. Take careful note of the order of arguments and -- results. -- --
-- snapshot :: Behavior b -> Event a -> Event (a,b) --snapshot :: (Ord t) => BehaviorI t b -> EventI t a -> EventI t (a, b) -- | Like snapshot but discarding event data (often a is -- '()'). -- --
-- snapshot_ :: Behavior b -> Event a -> Event b --snapshot_ :: (Ord t) => BehaviorI t b -> EventI t a -> EventI t b -- | Filter an event according to whether a reactive boolean is true. -- --
-- whenE :: Behavior Bool -> Event a -> Event a --whenE :: (Ord t) => BehaviorI t Bool -> EventI t a -> EventI t a -- | Behavior from an initial value and an updater event. See also accumE. -- --
-- accumB :: a -> Event (a -> a) -> Behavior a --accumB :: a -> EventI t (a -> a) -> BehaviorI t a -- | Like scanl for behaviors. See also scanlE. -- --
-- scanlB :: forall a. (Behavior a -> Behavior a -> Behavior a) -> Behavior a -- -> Event (Behavior a) -> Behavior a --scanlB :: (Ord tr, Bounded tr) => (b -> BehaviorG tr tf a -> BehaviorG tr tf a) -> BehaviorG tr tf a -> EventG tr b -> BehaviorG tr tf a -- | Accumulate values from a monoid-valued event. Specialization of -- scanlB, using mappend and mempty. See also -- monoidE. -- --
-- monoidB :: Monoid a => Event (Behavior a) -> Behavior a --monoidB :: (Ord tr, Bounded tr, Monoid a) => EventG tr (BehaviorG tr tf a) -> BehaviorG tr tf a -- | Start out blank (Nothing), latching onto each new a, -- and blanking on each b. If you just want to latch and not -- blank, then use mempty for the second event. -- --
-- maybeB :: Event a -> Event b -> Behavior (Maybe a) --maybeB :: (Ord t) => EventI t a -> EventI t b -> BehaviorI t (Maybe a) -- | Flip-flopping behavior. Turns true whenever first event occurs and -- false whenever the second event occurs. -- --
-- flipFlop :: Event a -> Event b -> Behavior Bool --flipFlop :: (Ord t) => EventI t a -> EventI t b -> BehaviorI t Bool -- | Count occurrences of an event. See also countE. -- --
-- countB :: Num n => Event a -> Behavior n --countB :: (Ord t, Num n) => EventI t a -> BehaviorI t n -- | Like sum for behaviors. -- --
-- sumB :: AdditiveGroup a => Event a -> Behavior a --sumB :: (Ord t, AdditiveGroup a) => EventI t a -> BehaviorI t a -- | Euler integral. -- --
-- integral :: (VectorSpace v, Scalar v ~ TimeT) => -- Event () -> Behavior v -> Behavior v --integral :: (VectorSpace v, AffineSpace t, (Scalar v) ~ (Diff t), Ord t) => EventI t a -> BehaviorI t v -> BehaviorI t v